Changeset 877 for trunk/wifidog-auth/wifidog/classes/Node.php
- Timestamp:
- 12/29/05 16:29:35 (7 years ago)
- Files:
-
- 1 modified
-
trunk/wifidog-auth/wifidog/classes/Node.php (modified) (46 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/wifidog/classes/Node.php
r874 r877 107 107 $sql = "SELECT node_id, last_heartbeat_ip from nodes WHERE last_heartbeat_ip='$_SERVER[REMOTE_ADDR]' ORDER BY last_heartbeat_timestamp DESC"; 108 108 $node_rows = null; 109 $db-> ExecSql($sql, $node_rows, false);109 $db->execSql($sql, $node_rows, false); 110 110 $num_match = count($node_rows); 111 111 if ($num_match == 0) … … 134 134 $_SERVER['REMOTE_ADDR']; 135 135 $sql = "SELECT node_id, last_heartbeat_ip from connections NATURAL JOIN nodes WHERE user_id='$current_user_id' ORDER BY last_updated DESC "; 136 $db-> ExecSql($sql, $node_rows, false);136 $db->execSql($sql, $node_rows, false); 137 137 $node_row = $node_rows[0]; 138 138 if ($node_row != null && $node_row['last_heartbeat_ip'] == $_SERVER['REMOTE_ADDR']) … … 152 152 { 153 153 global $db; 154 $id = $db-> EscapeString($this->getId());155 if (!$db-> ExecSqlUpdate("DELETE FROM nodes WHERE node_id='{$id}'", false))154 $id = $db->escapeString($this->getId()); 155 if (!$db->execSqlUpdate("DELETE FROM nodes WHERE node_id='{$id}'", false)) 156 156 { 157 157 $errmsg = _('Could not delete node!'); … … 185 185 $node_id = get_guid(); 186 186 } 187 $node_id = $db-> EscapeString($node_id);187 $node_id = $db->escapeString($node_id); 188 188 189 189 if (empty ($network)) … … 191 191 $network = Network :: getCurrentNetwork(); 192 192 } 193 $network_id = $db-> EscapeString($network->getId());194 195 $node_deployment_status = $db-> EscapeString("IN_PLANNING");193 $network_id = $db->escapeString($network->getId()); 194 195 $node_deployment_status = $db->escapeString("IN_PLANNING"); 196 196 $node_name = _("New node"); 197 197 if (Node :: nodeExists($node_id)) … … 200 200 $sql = "INSERT INTO nodes (node_id, network_id, creation_date, node_deployment_status, name) VALUES ('$node_id', '$network_id', NOW(),'$node_deployment_status', '$node_name')"; 201 201 202 if (!$db-> ExecSqlUpdate($sql, false))202 if (!$db->execSqlUpdate($sql, false)) 203 203 { 204 204 throw new Exception(_('Unable to insert new node into database!')); … … 221 221 $sql = "SELECT node_id, name from nodes WHERE 1=1 $sql_additional_where ORDER BY node_id"; 222 222 $node_rows = null; 223 $db-> ExecSql($sql, $node_rows, false);223 $db->execSql($sql, $node_rows, false); 224 224 if ($node_rows != null) 225 225 { … … 316 316 $name = "{$user_prefix}"; 317 317 $status_list = null; 318 $db-> ExecSql("SELECT node_deployment_status FROM node_deployment_status", $status_list, false);318 $db->execSql("SELECT node_deployment_status FROM node_deployment_status", $status_list, false); 319 319 if ($status_list == null) 320 320 throw new Exception(_("No deployment statues could be found in the database")); … … 344 344 $this->mDb = & $db; 345 345 346 $node_id_str = $db-> EscapeString($node_id);346 $node_id_str = $db->escapeString($node_id); 347 347 $sql = "SELECT * FROM nodes WHERE node_id='$node_id_str'"; 348 348 $row = null; 349 $db-> ExecSqlUniqueRes($sql, $row, false);349 $db->execSqlUniqueRes($sql, $row, false); 350 350 if ($row == null) 351 351 { … … 371 371 function setId($id) 372 372 { 373 $id = $this->mDb-> EscapeString($id);374 $retval = $this->mDb-> ExecSqlUpdate("UPDATE nodes SET node_id = '{$id}' WHERE node_id = '{$this->getId()}'");373 $id = $this->mDb->escapeString($id); 374 $retval = $this->mDb->execSqlUpdate("UPDATE nodes SET node_id = '{$id}' WHERE node_id = '{$this->getId()}'"); 375 375 if ($retval) 376 376 { … … 401 401 if (!empty ($pt)) 402 402 { 403 $lat = $this->mDb-> EscapeString($pt->getLatitude());404 $long = $this->mDb-> EscapeString($pt->getLongitude());403 $lat = $this->mDb->escapeString($pt->getLatitude()); 404 $long = $this->mDb->escapeString($pt->getLongitude()); 405 405 406 406 if (!empty ($lat) && !empty ($long)) 407 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET latitude = $lat, longitude = $long WHERE node_id = '{$this->getId()}'");407 $this->mDb->execSqlUpdate("UPDATE nodes SET latitude = $lat, longitude = $long WHERE node_id = '{$this->getId()}'"); 408 408 else 409 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET latitude = NULL, longitude = NULL WHERE node_id = '{$this->getId()}'");409 $this->mDb->execSqlUpdate("UPDATE nodes SET latitude = NULL, longitude = NULL WHERE node_id = '{$this->getId()}'"); 410 410 $this->refresh(); 411 411 } … … 421 421 function setName($name) 422 422 { 423 $name = $this->mDb-> EscapeString($name);424 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET name = '{$name}' WHERE node_id = '{$this->getId()}'");423 $name = $this->mDb->escapeString($name); 424 $this->mDb->execSqlUpdate("UPDATE nodes SET name = '{$name}' WHERE node_id = '{$this->getId()}'"); 425 425 $this->refresh(); 426 426 } … … 433 433 function setCreationDate($creation_date) 434 434 { 435 $creation_date = $this->mDb-> EscapeString($creation_date);436 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET creation_date = '{$creation_date}' WHERE node_id = '{$this->getId()}'");435 $creation_date = $this->mDb->escapeString($creation_date); 436 $this->mDb->execSqlUpdate("UPDATE nodes SET creation_date = '{$creation_date}' WHERE node_id = '{$this->getId()}'"); 437 437 $this->refresh(); 438 438 } … … 445 445 function setHomePageUrl($url) 446 446 { 447 $url = $this->mDb-> EscapeString($url);448 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET home_page_url = '{$url}' WHERE node_id = '{$this->getId()}'");447 $url = $this->mDb->escapeString($url); 448 $this->mDb->execSqlUpdate("UPDATE nodes SET home_page_url = '{$url}' WHERE node_id = '{$this->getId()}'"); 449 449 $this->refresh(); 450 450 } … … 457 457 function setDescription($description) 458 458 { 459 $description = $this->mDb-> EscapeString($description);460 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET description = '{$description}' WHERE node_id = '{$this->getId()}'");459 $description = $this->mDb->escapeString($description); 460 $this->mDb->execSqlUpdate("UPDATE nodes SET description = '{$description}' WHERE node_id = '{$this->getId()}'"); 461 461 $this->refresh(); 462 462 } … … 469 469 function setMapURL($url) 470 470 { 471 $url = $this->mDb-> EscapeString($url);472 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET map_url = '{$url}' WHERE node_id = '{$this->getId()}'");471 $url = $this->mDb->escapeString($url); 472 $this->mDb->execSqlUpdate("UPDATE nodes SET map_url = '{$url}' WHERE node_id = '{$this->getId()}'"); 473 473 $this->refresh(); 474 474 } … … 481 481 public function setCivicNumber($civic_number) 482 482 { 483 $civic_number = $this->mDb-> EscapeString($civic_number);484 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET civic_number = '{$civic_number}' WHERE node_id = '{$this->getId()}'");483 $civic_number = $this->mDb->escapeString($civic_number); 484 $this->mDb->execSqlUpdate("UPDATE nodes SET civic_number = '{$civic_number}' WHERE node_id = '{$this->getId()}'"); 485 485 $this->refresh(); 486 486 } … … 493 493 public function setStreetName($street_name) 494 494 { 495 $street_name = $this->mDb-> EscapeString($street_name);496 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET street_name = '{$street_name}' WHERE node_id = '{$this->getId()}'");495 $street_name = $this->mDb->escapeString($street_name); 496 $this->mDb->execSqlUpdate("UPDATE nodes SET street_name = '{$street_name}' WHERE node_id = '{$this->getId()}'"); 497 497 $this->refresh(); 498 498 } … … 505 505 public function setCity($city) 506 506 { 507 $city = $this->mDb-> EscapeString($city);508 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET city = '{$city}' WHERE node_id = '{$this->getId()}'");507 $city = $this->mDb->escapeString($city); 508 $this->mDb->execSqlUpdate("UPDATE nodes SET city = '{$city}' WHERE node_id = '{$this->getId()}'"); 509 509 $this->refresh(); 510 510 } … … 517 517 public function setProvince($province) 518 518 { 519 $province = $this->mDb-> EscapeString($province);520 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET province = '{$province}' WHERE node_id = '{$this->getId()}'");519 $province = $this->mDb->escapeString($province); 520 $this->mDb->execSqlUpdate("UPDATE nodes SET province = '{$province}' WHERE node_id = '{$this->getId()}'"); 521 521 $this->refresh(); 522 522 } … … 529 529 protected function setCountry($country) 530 530 { 531 $country = $this->mDb-> EscapeString($country);532 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET country = '{$country}' WHERE node_id = '{$this->getId()}'");531 $country = $this->mDb->escapeString($country); 532 $this->mDb->execSqlUpdate("UPDATE nodes SET country = '{$country}' WHERE node_id = '{$this->getId()}'"); 533 533 $this->refresh(); 534 534 } … … 541 541 public function setPostalCode($postal_code) 542 542 { 543 $postal_code = $this->mDb-> EscapeString($postal_code);544 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET postal_code = '{$postal_code}' WHERE node_id = '{$this->getId()}'");543 $postal_code = $this->mDb->escapeString($postal_code); 544 $this->mDb->execSqlUpdate("UPDATE nodes SET postal_code = '{$postal_code}' WHERE node_id = '{$this->getId()}'"); 545 545 $this->refresh(); 546 546 } … … 553 553 function setTelephone($phone) 554 554 { 555 $phone = $this->mDb-> EscapeString($phone);556 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET public_phone_number = '{$phone}' WHERE node_id = '{$this->getId()}'");555 $phone = $this->mDb->escapeString($phone); 556 $this->mDb->execSqlUpdate("UPDATE nodes SET public_phone_number = '{$phone}' WHERE node_id = '{$this->getId()}'"); 557 557 $this->refresh(); 558 558 } … … 565 565 function setTransitInfo($transit_info) 566 566 { 567 $transit_info = $this->mDb-> EscapeString($transit_info);568 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET mass_transit_info = '{$transit_info}' WHERE node_id = '{$this->getId()}'");567 $transit_info = $this->mDb->escapeString($transit_info); 568 $this->mDb->execSqlUpdate("UPDATE nodes SET mass_transit_info = '{$transit_info}' WHERE node_id = '{$this->getId()}'"); 569 569 $this->refresh(); 570 570 } … … 577 577 function setEmail($email) 578 578 { 579 $email = $this->mDb-> EscapeString($email);580 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET public_email = '{$email}' WHERE node_id = '{$this->getId()}'");579 $email = $this->mDb->escapeString($email); 580 $this->mDb->execSqlUpdate("UPDATE nodes SET public_email = '{$email}' WHERE node_id = '{$this->getId()}'"); 581 581 $this->refresh(); 582 582 } … … 589 589 function setDeploymentStatus($status) 590 590 { 591 $status = $this->mDb-> EscapeString($status);592 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET node_deployment_status = '{$status}' WHERE node_id = '{$this->getId()}'");591 $status = $this->mDb->escapeString($status); 592 $this->mDb->execSqlUpdate("UPDATE nodes SET node_deployment_status = '{$status}' WHERE node_id = '{$this->getId()}'"); 593 593 $this->refresh(); 594 594 } … … 601 601 function setLastPaged($last_paged) 602 602 { 603 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET last_paged = {$last_paged}::abstime WHERE node_id = '{$this->getId()}'");603 $this->mDb->execSqlUpdate("UPDATE nodes SET last_paged = {$last_paged}::abstime WHERE node_id = '{$this->getId()}'"); 604 604 $this->refresh(); 605 605 } … … 622 622 function setLastHeartbeatTimestamp($timestamp) 623 623 { 624 $this->mDb-> ExecSqlUpdate("UPDATE nodes SET last_heartbeat_timestamp = '{$timestamp}' WHERE node_id = '{$this->getId()}'");624 $this->mDb->execSqlUpdate("UPDATE nodes SET last_heartbeat_timestamp = '{$timestamp}' WHERE node_id = '{$this->getId()}'"); 625 625 $this->refresh(); 626 626 } … … 653 653 global $db; 654 654 $value ? $value = 'TRUE' : $value = 'FALSE'; 655 $retval = $db-> ExecSqlUpdate("UPDATE nodes SET is_splash_only_node = {$value} WHERE node_id = '{$this->getId()}'", false);655 $retval = $db->execSqlUpdate("UPDATE nodes SET is_splash_only_node = {$value} WHERE node_id = '{$this->getId()}'", false); 656 656 $this->refresh(); 657 657 } … … 676 676 { 677 677 global $db; 678 $value = $db-> EscapeString($value);679 $retval = $db-> ExecSqlUpdate("UPDATE nodes SET custom_portal_redirect_url = '{$value}' WHERE node_id = '{$this->getId()}'", false);678 $value = $db->escapeString($value); 679 $retval = $db->execSqlUpdate("UPDATE nodes SET custom_portal_redirect_url = '{$value}' WHERE node_id = '{$this->getId()}'", false); 680 680 $this->refresh(); 681 681 } … … 1240 1240 { 1241 1241 global $db; 1242 $content_id = $db-> EscapeString($content->getId());1242 $content_id = $db->escapeString($content->getId()); 1243 1243 $sql = "INSERT INTO node_has_content (node_id, content_id) VALUES ('$this->id','$content_id')"; 1244 $db-> ExecSqlUpdate($sql, false);1244 $db->execSqlUpdate($sql, false); 1245 1245 exit; 1246 1246 } … … 1250 1250 { 1251 1251 global $db; 1252 $content_id = $db-> EscapeString($content->getId());1252 $content_id = $db->escapeString($content->getId()); 1253 1253 $sql = "DELETE FROM node_has_content WHERE node_id='$this->id' AND content_id='$content_id'"; 1254 $db-> ExecSqlUpdate($sql, false);1254 $db->execSqlUpdate($sql, false); 1255 1255 } 1256 1256 … … 1271 1271 else 1272 1272 $sql = "SELECT content_id FROM node_has_content WHERE node_id='{$this->id}' AND display_location='$display_location' ORDER BY subscribe_timestamp DESC"; 1273 $db-> ExecSql($sql, $content_rows, false);1273 $db->execSql($sql, $content_rows, false); 1274 1274 1275 1275 if ($content_rows != null) … … 1291 1291 $sql = "SELECT * FROM content_group JOIN content ON (content.content_id = content_group.content_group_id) JOIN node_has_content ON (node_has_content.content_id = content_group.content_group_id AND node_has_content.node_id = '{$this->getId()}') WHERE is_persistent = true AND is_artistic_content = true AND is_locative_content = true ORDER BY subscribe_timestamp DESC"; 1292 1292 $content_rows = null; 1293 $db-> ExecSql($sql, $content_rows, false);1293 $db->execSql($sql, $content_rows, false); 1294 1294 if ($content_rows != null) 1295 1295 { … … 1320 1320 $retval = array (); 1321 1321 $users = null; 1322 $db-> ExecSql("SELECT users.user_id FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}'", $users, false);1322 $db->execSql("SELECT users.user_id FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}'", $users, false); 1323 1323 if ($users != null) 1324 1324 { … … 1339 1339 $retval = array (); 1340 1340 $row = null; 1341 $db-> ExecSqlUniqueRes("SELECT COUNT(DISTINCT users.user_id) as count FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}'", $row, false);1341 $db->execSqlUniqueRes("SELECT COUNT(DISTINCT users.user_id) as count FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}'", $row, false); 1342 1342 return $row['count']; 1343 1343 } … … 1350 1350 $retval = array (); 1351 1351 $owners = null; 1352 $db-> ExecSql("SELECT user_id FROM node_stakeholders WHERE is_owner = true AND node_id='{$this->id}'", $owners, false);1352 $db->execSql("SELECT user_id FROM node_stakeholders WHERE is_owner = true AND node_id='{$this->id}'", $owners, false); 1353 1353 if ($owners != null) 1354 1354 { … … 1370 1370 $retval = array (); 1371 1371 $officers = null; 1372 $db-> ExecSql("SELECT user_id FROM node_stakeholders WHERE is_tech_officer = true AND node_id='{$this->id}'", $officers, false);1372 $db->execSql("SELECT user_id FROM node_stakeholders WHERE is_tech_officer = true AND node_id='{$this->id}'", $officers, false); 1373 1373 if ($officers != null) 1374 1374 { … … 1388 1388 global $db; 1389 1389 $rows = null; 1390 $db-> ExecSql("SELECT * FROM node_stakeholders WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}'", $rows, false);1390 $db->execSql("SELECT * FROM node_stakeholders WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}'", $rows, false); 1391 1391 if (!$rows) 1392 1392 { 1393 if (!$db-> ExecSqlUpdate("INSERT INTO node_stakeholders (node_id, user_id, is_owner) VALUES ('{$this->getId()}','{$user->getId()}', true)", false))1393 if (!$db->execSqlUpdate("INSERT INTO node_stakeholders (node_id, user_id, is_owner) VALUES ('{$this->getId()}','{$user->getId()}', true)", false)) 1394 1394 throw new Exception(_('Could not add owner')); 1395 1395 } 1396 1396 else 1397 if (!$db-> ExecSqlUpdate("UPDATE node_stakeholders SET is_owner = true WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false))1397 if (!$db->execSqlUpdate("UPDATE node_stakeholders SET is_owner = true WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 1398 1398 throw new Exception(_('Could not add owner')); 1399 1399 } … … 1406 1406 global $db; 1407 1407 $rows = null; 1408 $db-> ExecSql("SELECT * FROM node_stakeholders WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}'", $rows, false);1408 $db->execSql("SELECT * FROM node_stakeholders WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}'", $rows, false); 1409 1409 if (!$rows) 1410 1410 { 1411 if (!$db-> ExecSqlUpdate("INSERT INTO node_stakeholders (node_id, user_id, is_tech_officer) VALUES ('{$this->getId()}','{$user->getId()}', true)", false))1411 if (!$db->execSqlUpdate("INSERT INTO node_stakeholders (node_id, user_id, is_tech_officer) VALUES ('{$this->getId()}','{$user->getId()}', true)", false)) 1412 1412 throw new Exception(_('Could not add tech officer')); 1413 1413 } 1414 1414 else 1415 if (!$db-> ExecSqlUpdate("UPDATE node_stakeholders SET is_tech_officer = true WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false))1415 if (!$db->execSqlUpdate("UPDATE node_stakeholders SET is_tech_officer = true WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 1416 1416 throw new Exception(_('Could not set existing user as tech officer')); 1417 1417 } … … 1423 1423 { 1424 1424 global $db; 1425 if (!$db-> ExecSqlUpdate("UPDATE node_stakeholders SET is_owner = false WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false))1425 if (!$db->execSqlUpdate("UPDATE node_stakeholders SET is_owner = false WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 1426 1426 throw new Exception(_('Could not remove owner')); 1427 1427 } … … 1433 1433 { 1434 1434 global $db; 1435 if (!$db-> ExecSqlUpdate("UPDATE node_stakeholders SET is_tech_officer = false WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false))1435 if (!$db->execSqlUpdate("UPDATE node_stakeholders SET is_tech_officer = false WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 1436 1436 throw new Exception(_('Could not remove tech officer')); 1437 1437 } … … 1447 1447 $retval = false; 1448 1448 $row = null; 1449 $db-> ExecSqlUniqueRes("SELECT * FROM node_stakeholders WHERE is_owner = true AND node_id='{$this->id}' AND user_id='{$user_id}'", $row, false);1449 $db->execSqlUniqueRes("SELECT * FROM node_stakeholders WHERE is_owner = true AND node_id='{$this->id}' AND user_id='{$user_id}'", $row, false); 1450 1450 if ($row != null) 1451 1451 { … … 1466 1466 $retval = false; 1467 1467 $row = null; 1468 $db-> ExecSqlUniqueRes("SELECT * FROM node_stakeholders WHERE is_tech_officer = true AND node_id='{$this->id}' AND user_id='{$user_id}'", $row, false);1468 $db->execSqlUniqueRes("SELECT * FROM node_stakeholders WHERE is_tech_officer = true AND node_id='{$this->id}' AND user_id='{$user_id}'", $row, false); 1469 1469 if ($row != null) 1470 1470 { … … 1480 1480 global $db; 1481 1481 $retval = false; 1482 $id_str = $db-> EscapeString($id);1482 $id_str = $db->escapeString($id); 1483 1483 $sql = "SELECT * FROM nodes WHERE node_id='{$id_str}'"; 1484 1484 $row = null; 1485 $db-> ExecSqlUniqueRes($sql, $row, false);1485 $db->execSqlUniqueRes($sql, $row, false); 1486 1486 if ($row != null) 1487 1487 { … … 1507 1507 */ 1508 1508 ?> 1509
