Changeset 111
- Timestamp:
- Apr 27, 2006 1:49:54 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/file_importer.php
r42 r111 43 43 // added_datetime 44 44 // ) VALUES ( 45 // '" . addslashes(0) . "',46 // '" . addslashes('hosting') . "',47 // '" . addslashes($file_date) . "',48 // '" . addslashes($amt[1]) . "',49 // '" . addslashes('Paid') . "',50 // '" . addslashes('') . "',51 // '" . addslashes($file_text) . "',52 // '" . addslashes($file_date) . "',45 // '" . DB::escapeString(0) . "', 46 // '" . DB::escapeString('hosting') . "', 47 // '" . DB::escapeString($file_date) . "', 48 // '" . DB::escapeString($amt[1]) . "', 49 // '" . DB::escapeString('Paid') . "', 50 // '" . DB::escapeString('') . "', 51 // '" . DB::escapeString($file_text) . "', 52 // '" . DB::escapeString($file_date) . "', 53 53 // NOW() 54 54 // ) -
trunk/bin/module_maker/form_template.cli.php
r106 r111 28 28 29 29 // Get DB table column info. 30 $qid = DB::query("DESCRIBE " . addslashes($db_tbl));30 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl)); 31 31 while ($row = mysql_fetch_row($qid)) { 32 32 $cols[] = $row; -
trunk/bin/module_maker/list_template.cli.php
r51 r111 41 41 42 42 // Get DB table column info. 43 $qid = DB::query("DESCRIBE " . addslashes($db_tbl));43 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl)); 44 44 while ($row = mysql_fetch_row($qid)) { 45 45 $cols[] = $row; -
trunk/bin/module_maker/module.cli.php
r87 r111 141 141 // Ensure requested table contains columns. 142 142 // Get DB table column info. 143 $qid = DB::query("DESCRIBE " . addslashes($db_tbl));143 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl)); 144 144 while ($row = mysql_fetch_row($qid)) { 145 145 $cols[] = $row; -
trunk/bin/module_maker/skel/admin.php
r42 r111 146 146 if (getFormdata('repeat', false)) { 147 147 // Display edit function with next available ID. 148 $qid = DB::query("SELECT %PRIMARY_KEY% FROM %DB_TBL% WHERE %PRIMARY_KEY% > '" . addslashes(getFormData('%PRIMARY_KEY%')) . "' ORDER BY %PRIMARY_KEY% ASC LIMIT 1");148 $qid = DB::query("SELECT %PRIMARY_KEY% FROM %DB_TBL% WHERE %PRIMARY_KEY% > '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "' ORDER BY %PRIMARY_KEY% ASC LIMIT 1"); 149 149 if (list($next_id) = mysql_fetch_row($qid)) { 150 150 App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $next_id); … … 217 217 SELECT * 218 218 FROM %DB_TBL% 219 WHERE %PRIMARY_KEY% = '" . addslashes($id) . "'219 WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "' 220 220 "); 221 221 if (!$frm = mysql_fetch_assoc($qid)) { … … 259 259 SELECT <##> 260 260 FROM %DB_TBL% 261 WHERE %PRIMARY_KEY% = '" . addslashes($id) . "'261 WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "' 262 262 "); 263 263 if (! list($name) = mysql_fetch_row($qid)) { … … 268 268 269 269 // Delete the record. 270 DB::query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . addslashes($id) . "'");270 DB::query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'"); 271 271 272 272 App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__); … … 336 336 if (getFormData('filter_<##>', false)) { 337 337 // Limit by filter. 338 $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " <##> = '" . addslashes(getFormData('filter_<##>')) . "'";338 $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " <##> = '" . DB::escapeString(getFormData('filter_<##>')) . "'"; 339 339 } 340 340 … … 418 418 DB::query(" 419 419 UPDATE %DB_TBL% SET 420 rank = '" . addslashes($new_rank) . "'421 WHERE %PRIMARY_KEY% = '" . addslashes($id) . "'420 rank = '" . DB::escapeString($new_rank) . "' 421 WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "' 422 422 "); 423 423 } -
trunk/bin/module_maker/skel/public.php
r42 r111 36 36 $qid = DB::query(" 37 37 SELECT * FROM %DB_TBL% 38 WHERE %PRIMARY_KEY% = '" . addslashes(getFormData('%PRIMARY_KEY%')) . "'38 WHERE %PRIMARY_KEY% = '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "' 39 39 AND publish = 'true' 40 40 <##>AND (publish_date <= CURDATE() OR publish_date = '0000-00-00') … … 50 50 UPDATE %DB_TBL% 51 51 SET hit_count = hit_count + 1 52 WHERE %PRIMARY_KEY% = '" . addslashes(getFormData('%PRIMARY_KEY%')) . "'52 WHERE %PRIMARY_KEY% = '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "' 53 53 "); 54 54 -
trunk/bin/module_maker/sql.cli.php
r44 r111 46 46 47 47 // Get DB table column info. 48 $qid = DB::query("DESCRIBE " . addslashes($db_tbl));48 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl)); 49 49 while ($row = mysql_fetch_row($qid)) { 50 50 $cols[] = $row; … … 70 70 } else if ('set' == $type) { 71 71 // Set types usually need to be converted to comma-delimited lists. 72 $c[$field] = "'\" . dbArrayToList(\$frm['$field']) . \"'";72 $c[$field] = "'\" . escapedList(array_keys(\$frm['$field'])) . \"'"; 73 73 } else if ('featured' == $field || 'publish' == $field || preg_match("/enum\('true'\)/", $col[1])) { 74 74 // Toggle types. … … 76 76 } else if ('added_by_user_id' == $field || 'modified_by_user_id' == $field) { 77 77 // Toggle types. 78 $c[$field] = "'\" . addslashes(\$auth->getVal('user_id')) . \"'";78 $c[$field] = "'\" . DB::escapeString(\$auth->getVal('user_id')) . \"'"; 79 79 } else if ('added_datetime' == $field || 'modified_datetime' == $field) { 80 80 // DB record insertion datetime. … … 82 82 } else { 83 83 // Default. Just insert data. 84 $c[$field] = "'\" . addslashes(\$frm['$field']) . \"'";84 $c[$field] = "'\" . DB::escapeString(\$frm['$field']) . \"'"; 85 85 } 86 86 } … … 135 135 DB::query(" 136 136 UPDATE $db_tbl SET$key_eq_val 137 WHERE $primary_key = '" . addslashes(\$frm['$primary_key']) . "'137 WHERE $primary_key = '" . DB::escapeString(\$frm['$primary_key']) . "' 138 138 "); 139 139 E_O_F; … … 148 148 $delim = 'WHERE'; 149 149 if (!empty($primary_key)) { 150 $where_clause = " $delim $primary_key = '\" . addslashes(\$frm['$primary_key']) . \"'\n";150 $where_clause = " $delim $primary_key = '\" . DB::escapeString(\$frm['$primary_key']) . \"'\n"; 151 151 $delim = 'AND'; 152 152 } … … 155 155 continue; 156 156 } 157 $where_clause .= " $delim $k = '\" . addslashes(\$frm['$k']) . \"'\n";157 $where_clause .= " $delim $k = '\" . DB::escapeString(\$frm['$k']) . \"'\n"; 158 158 $delim = 'AND'; 159 159 } … … 183 183 if (!isset($op) || 'search' == $op) { 184 184 $search_skip_columns = array('added_datetime', 'added_by_user_id', 'modified_datetime', 'modified_by_user_id', 'publish', 'featured'); 185 $search_columns = $db_tbl . '.' . join(" LIKE '%\" . addslashes(\$qry_words[\$i]) . \"%'\n OR $db_tbl.", array_diff(array_keys($c), $search_skip_columns));185 $search_columns = $db_tbl . '.' . join(" LIKE '%\" . DB::escapeString(\$qry_words[\$i]) . \"%'\n OR $db_tbl.", array_diff(array_keys($c), $search_skip_columns)); 186 186 echo <<<E_O_F 187 187 \$where_clause .= (empty(\$where_clause) ? 'WHERE' : 'AND') . " 188 188 ( 189 $search_columns LIKE '%" . addslashes(\$qry_words[\$i]) . "%'189 $search_columns LIKE '%" . DB::escapeString(\$qry_words[\$i]) . "%' 190 190 ) 191 191 "; -
trunk/bin/module_maker/validation.cli.php
r42 r111 28 28 29 29 // Get DB table column info. 30 $qid = DB::query("DESCRIBE " . addslashes($db_tbl));30 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl)); 31 31 while ($row = mysql_fetch_row($qid)) { 32 32 $cols[] = $row; -
trunk/lib/Auth_SQL.inc.php
r103 r111 305 305 SELECT *, " . $this->_params['db_primary_key'] . " AS user_id 306 306 FROM " . $this->_params['db_table'] . " 307 WHERE " . $this->_params['db_username_column'] . " = '" . addslashes($username) . "'308 AND BINARY userpass = '" . addslashes($this->encryptPassword($password)) . "'307 WHERE " . $this->_params['db_username_column'] . " = '" . DB::escapeString($username) . "' 308 AND BINARY userpass = '" . DB::escapeString($this->encryptPassword($password)) . "' 309 309 "); 310 310 … … 453 453 $qid = DB::query(" 454 454 SELECT 1 FROM " . $this->_params['db_table'] . " 455 WHERE " . $this->_params['db_primary_key'] . " = '" . addslashes($user_id) . "'455 WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "' 456 456 AND DATE_ADD(last_login_datetime, INTERVAL '" . $this->_params['login_timeout'] . "' SECOND) > NOW() 457 457 AND DATE_ADD(last_access_datetime, INTERVAL '" . $this->_params['idle_timeout'] . "' SECOND) > NOW() … … 572 572 573 573 if ($this->getParam('blocking')) { 574 if (strlen( addslashes($reason)) > 255) {574 if (strlen(DB::escapeString($reason)) > 255) { 575 575 // blocked_reason field is varchar(255). 576 576 App::logMsg(sprintf('Blocked reason provided is greater than 255 characters: %s', $reason), LOG_WARNING, __FILE__, __LINE__); … … 582 582 UPDATE " . $this->_params['db_table'] . " SET 583 583 blocked = 'true', 584 blocked_reason = '" . addslashes($reason) . "'585 WHERE " . $this->_params['db_primary_key'] . " = '" . addslashes($user_id) . "'584 blocked_reason = '" . DB::escapeString($reason) . "' 585 WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "' 586 586 "); 587 587 } … … 602 602 blocked = '', 603 603 blocked_reason = '' 604 WHERE " . $this->_params['db_primary_key'] . " = '" . addslashes($user_id) . "'604 WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "' 605 605 "); 606 606 } … … 620 620 SELECT 1 621 621 FROM " . $this->_params['db_table'] . " 622 WHERE " . $this->_params['db_username_column'] . " = '" . addslashes($username) . "'622 WHERE " . $this->_params['db_username_column'] . " = '" . DB::escapeString($username) . "' 623 623 "); 624 624 return (mysql_num_rows($qid) > 0); … … 638 638 SELECT " . $this->_params['db_username_column'] . " 639 639 FROM " . $this->_params['db_table'] . " 640 WHERE " . $this->_params['db_primary_key'] . " = '" . addslashes($user_id) . "'640 WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "' 641 641 "); 642 642 if (list($username) = mysql_fetch_row($qid)) { … … 717 717 DB::query(" 718 718 UPDATE " . $this->_params['db_table'] . " 719 SET userpass = '" . addslashes($this->encryptPassword($password)) . "'720 WHERE " . $this->_params['db_primary_key'] . " = '" . addslashes($user_id) . "'719 SET userpass = '" . DB::escapeString($this->encryptPassword($password)) . "' 720 WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "' 721 721 "); 722 722 } … … 739 739 $qid = DB::query(" 740 740 SELECT * FROM " . $this->_params['db_table'] . " 741 WHERE " . $this->_params['db_primary_key'] . " = '" . addslashes($user_id) . "'741 WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "' 742 742 "); 743 743 if (!$user_data = mysql_fetch_assoc($qid)) { -
trunk/lib/Hierarchy.inc.php
r92 r111 197 197 title 198 198 ) VALUES ( 199 '" . addslashes($parent['node_type']) . "',200 '" . addslashes($parent['node_id']) . "',201 '" . addslashes($child_type) . "',202 '" . addslashes($child_id) . "',203 " . (is_null($relationship_type) ? "NULL" : "'" . addslashes($relationship_type) . "'") . ",204 '" . addslashes($title) . "'199 '" . DB::escapeString($parent['node_type']) . "', 200 '" . DB::escapeString($parent['node_id']) . "', 201 '" . DB::escapeString($child_type) . "', 202 '" . DB::escapeString($child_id) . "', 203 " . (is_null($relationship_type) ? "NULL" : "'" . DB::escapeString($relationship_type) . "'") . ", 204 '" . DB::escapeString($title) . "' 205 205 ) 206 206 "); … … 245 245 DB::query(" 246 246 DELETE FROM node_tbl 247 WHERE child_type = '" . addslashes($child_type) . "'248 AND child_id = '" . addslashes($child_id) . "'247 WHERE child_type = '" . DB::escapeString($child_type) . "' 248 AND child_id = '" . DB::escapeString($child_id) . "' 249 249 "); 250 250 App::logMsg(sprintf('deleteNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__); … … 311 311 $qid = DB::query(" 312 312 SELECT title FROM node_tbl 313 WHERE child_type = '" . addslashes($child_type) . "'314 AND child_id = '" . addslashes($child_id) . "'315 AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . addslashes($relationship_type) . "'") . "313 WHERE child_type = '" . DB::escapeString($child_type) . "' 314 AND child_id = '" . DB::escapeString($child_id) . "' 315 AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . DB::escapeString($relationship_type) . "'") . " 316 316 "); 317 317 list($title) = mysql_fetch_row($qid); … … 321 321 DB::query(" 322 322 DELETE FROM node_tbl 323 WHERE child_type = '" . addslashes($child_type) . "'324 AND child_id = '" . addslashes($child_id) . "'325 AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . addslashes($relationship_type) . "'") . "323 WHERE child_type = '" . DB::escapeString($child_type) . "' 324 AND child_id = '" . DB::escapeString($child_id) . "' 325 AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . DB::escapeString($relationship_type) . "'") . " 326 326 "); 327 327 App::logMsg(sprintf('moveNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__); … … 359 359 $type_constraint = array($type_constraint); 360 360 } 361 $in_clause = "AND parent_type IN ('" . join("','", array_map( 'addslashes', $type_constraint)) . "')";361 $in_clause = "AND parent_type IN ('" . join("','", array_map(array('DB', 'escapeString'), $type_constraint)) . "')"; 362 362 } 363 363 … … 365 365 SELECT parent_type, parent_id 366 366 FROM node_tbl 367 WHERE child_type = '" . addslashes($child_type) . "'368 AND child_id = '" . addslashes($child_id) . "'367 WHERE child_type = '" . DB::escapeString($child_type) . "' 368 AND child_id = '" . DB::escapeString($child_id) . "' 369 369 $in_clause 370 " . addslashes($order) . "370 " . DB::escapeString($order) . " 371 371 "); 372 372 … … 405 405 SELECT child_type, child_id, title, subnode_quantity 406 406 FROM node_tbl 407 WHERE child_type = '" . addslashes($child_type) . "'408 AND child_id = '" . addslashes($child_id) . "'407 WHERE child_type = '" . DB::escapeString($child_type) . "' 408 AND child_id = '" . DB::escapeString($child_id) . "' 409 409 "); 410 410 … … 448 448 $type_constraint = array($type_constraint); 449 449 } 450 $in_clause = "AND child_type IN ('" . join("','", array_map( 'addslashes', $type_constraint)) . "')";450 $in_clause = "AND child_type IN ('" . join("','", array_map(array('DB', 'escapeString'), $type_constraint)) . "')"; 451 451 } 452 452 … … 454 454 SELECT * 455 455 FROM node_tbl 456 WHERE parent_type = '" . addslashes($child_type) . "'457 AND parent_id = '" . addslashes($child_id) . "'456 WHERE parent_type = '" . DB::escapeString($child_type) . "' 457 AND parent_id = '" . DB::escapeString($child_id) . "' 458 458 $in_clause 459 " . addslashes($order) . "459 " . DB::escapeString($order) . " 460 460 "); 461 461 … … 497 497 $type_constraint = array($type_constraint); 498 498 } 499 $in_clause = "AND child_type IN ('" . join("','", array_map( 'addslashes', $type_constraint)) . "')";499 $in_clause = "AND child_type IN ('" . join("','", array_map(array('DB', 'escapeString'), $type_constraint)) . "')"; 500 500 } 501 501 … … 503 503 SELECT COUNT(*) 504 504 FROM node_tbl 505 WHERE parent_type = '" . addslashes($child_type) . "'506 AND parent_id = '" . addslashes($child_id) . "'505 WHERE parent_type = '" . DB::escapeString($child_type) . "' 506 AND parent_id = '" . DB::escapeString($child_id) . "' 507 507 $in_clause 508 508 "); … … 585 585 SELECT parent_type, parent_id, child_type, child_id, title, subnode_quantity 586 586 FROM node_tbl 587 WHERE child_type = '" . addslashes($child_type) . "'588 AND child_id = '" . addslashes($child_id) . "'587 WHERE child_type = '" . DB::escapeString($child_type) . "' 588 AND child_id = '" . DB::escapeString($child_id) . "' 589 589 "); 590 590 while ($row = mysql_fetch_assoc($qid)) { … … 644 644 $qid = DB::query(" 645 645 SELECT 1 FROM node_tbl 646 WHERE parent_type = '" . addslashes($parent_type) . "'647 AND parent_id = '" . addslashes($parent_id) . "'648 AND child_type = '" . addslashes($child_type) . "'649 AND child_id = '" . addslashes($child_id) . "'650 AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . addslashes($relationship_type) . "'") . "646 WHERE parent_type = '" . DB::escapeString($parent_type) . "' 647 AND parent_id = '" . DB::escapeString($parent_id) . "' 648 AND child_type = '" . DB::escapeString($child_type) . "' 649 AND child_id = '" . DB::escapeString($child_id) . "' 650 AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . DB::escapeString($relationship_type) . "'") . " 651 651 "); 652 652 } else { 653 653 $qid = DB::query(" 654 654 SELECT 1 FROM node_tbl 655 WHERE child_type = '" . addslashes($child_type) . "'656 AND child_id = '" . addslashes($child_id) . "'655 WHERE child_type = '" . DB::escapeString($child_type) . "' 656 AND child_id = '" . DB::escapeString($child_id) . "' 657 657 "); 658 658 } … … 775 775 DB::query(" 776 776 UPDATE node_tbl 777 SET subnode_quantity = subnode_quantity + '" . addslashes($num_children) . "'778 WHERE child_type = '" . addslashes($child_type) . "'779 AND child_id = '" . addslashes($child_id) . "'777 SET subnode_quantity = subnode_quantity + '" . DB::escapeString($num_children) . "' 778 WHERE child_type = '" . DB::escapeString($child_type) . "' 779 AND child_id = '" . DB::escapeString($child_id) . "' 780 780 ",false); 781 781 $qid = DB::query(" 782 782 SELECT parent_type, parent_id 783 783 FROM node_tbl 784 WHERE child_type = '" . addslashes($child_type) . "'785 AND child_id = '" . addslashes($child_id) . "'784 WHERE child_type = '" . DB::escapeString($child_type) . "' 785 AND child_id = '" . DB::escapeString($child_id) . "' 786 786 ",false); 787 787 while ((list($parent_type, $parent_id) = mysql_fetch_row($qid)) && $parent_id > 0) { -
trunk/lib/PageNumbers.inc.php
r53 r111 190 190 { 191 191 if (is_numeric($this->first_item) && is_numeric($this->_per_page)) { 192 return ' LIMIT ' . addslashes($this->first_item) . ', ' . addslashes($this->_per_page) . ' ';192 return ' LIMIT ' . DB::escapeString($this->first_item) . ', ' . DB::escapeString($this->_per_page) . ' '; 193 193 } else { 194 194 App::logMsg(sprintf('Could not find SQL to LIMIT by %s %s.', $this->first_item, $this->_per_page), LOG_WARNING, __FILE__, __LINE__); -
trunk/lib/RecordLock.inc.php
r71 r111 156 156 $qid = DB::query(" 157 157 SELECT * FROM " . $this->getParam('db_table') . " 158 WHERE lock_id = '" . addslashes($record_table_or_lock_id) . "'158 WHERE lock_id = '" . DB::escapeString($record_table_or_lock_id) . "' 159 159 "); 160 160 } else { … … 162 162 $qid = DB::query(" 163 163 SELECT * FROM " . $this->getParam('db_table') . " 164 WHERE record_table = '" . addslashes($record_table_or_lock_id) . "'165 AND record_key = '" . addslashes($record_key) . "'166 AND record_val = '" . addslashes($record_val) . "'164 WHERE record_table = '" . DB::escapeString($record_table_or_lock_id) . "' 165 AND record_key = '" . DB::escapeString($record_key) . "' 166 AND record_val = '" . DB::escapeString($record_val) . "' 167 167 "); 168 168 } … … 199 199 200 200 if (isset($this->data['lock_id'])) { 201 $qid = DB::query("SELECT * FROM " . $this->getParam('db_table') . " WHERE lock_id = '" . addslashes($this->data['lock_id']) . "'");201 $qid = DB::query("SELECT * FROM " . $this->getParam('db_table') . " WHERE lock_id = '" . DB::escapeString($this->data['lock_id']) . "'"); 202 202 if ($lock = mysql_fetch_assoc($qid)) { 203 203 return ($lock['set_by_admin_id'] == $this->_auth->getVal('user_id')); … … 230 230 DB::query(" 231 231 DELETE FROM " . $this->getParam('db_table') . " 232 WHERE record_table = '" . addslashes($record_table) . "'233 AND record_key = '" . addslashes($record_key) . "'234 AND record_val = '" . addslashes($record_val) . "'232 WHERE record_table = '" . DB::escapeString($record_table) . "' 233 AND record_key = '" . DB::escapeString($record_key) . "' 234 AND record_val = '" . DB::escapeString($record_val) . "' 235 235 "); 236 236 … … 245 245 lock_datetime 246 246 ) VALUES ( 247 '" . addslashes($record_table) . "',248 '" . addslashes($record_key) . "',249 '" . addslashes($record_val) . "',250 '" . addslashes($title) . "',251 '" . addslashes($this->_auth->getVal('user_id')) . "',247 '" . DB::escapeString($record_table) . "', 248 '" . DB::escapeString($record_key) . "', 249 '" . DB::escapeString($record_val) . "', 250 '" . DB::escapeString($title) . "', 251 '" . DB::escapeString($this->_auth->getVal('user_id')) . "', 252 252 NOW() 253 253 ) … … 274 274 DB::query(" 275 275 DELETE FROM " . $this->getParam('db_table') . " 276 WHERE lock_id = '" . addslashes($this->data['lock_id']) . "'276 WHERE lock_id = '" . DB::escapeString($this->data['lock_id']) . "' 277 277 "); 278 278 … … 292 292 if (isset($user_id)) { 293 293 // Delete specific user's locks. 294 DB::query("DELETE FROM " . $this->getParam('db_table') . " WHERE set_by_admin_id = '" . addslashes($user_id) . "'");294 DB::query("DELETE FROM " . $this->getParam('db_table') . " WHERE set_by_admin_id = '" . DB::escapeString($user_id) . "'"); 295 295 App::logMsg(sprintf('Record locks owned by %s %s have been deleted', $this->_auth->getVal('auth_name'), $this->_auth->getUsername($user_id)), LOG_DEBUG, __FILE__, __LINE__); 296 296 } else { -
trunk/lib/RecordVersion.inc.php
r49 r111 182 182 version_datetime 183 183 ) VALUES ( 184 '" . addslashes($record_table) . "',185 '" . addslashes($record_key) . "',186 '" . addslashes($record_val) . "',187 '" . addslashes(gzcompress(serialize($record), 9)) . "',188 '" . addslashes($title) . "',189 '" . addslashes($notes) . "',190 '" . addslashes($this->_auth->getVal('user_id')) . "',184 '" . DB::escapeString($record_table) . "', 185 '" . DB::escapeString($record_key) . "', 186 '" . DB::escapeString($record_val) . "', 187 '" . DB::escapeString(gzcompress(serialize($record), 9)) . "', 188 '" . DB::escapeString($title) . "', 189 '" . DB::escapeString($notes) . "', 190 '" . DB::escapeString($this->_auth->getVal('user_id')) . "', 191 191 NOW() 192 192 ) … … 210 210 $qid = DB::query(" 211 211 SELECT * FROM " . $this->getParam('db_table') . " 212 WHERE version_id = '" . addslashes($version_id) . "'212 WHERE version_id = '" . DB::escapeString($version_id) . "' 213 213 "); 214 214 if (!$record = mysql_fetch_assoc($qid)) { … … 227 227 228 228 // SQLize the keys of the specified versioned record. 229 $replace_keys = join(",\n", array_map( 'addslashes', array_keys($data)));229 $replace_keys = join(",\n", array_map(array('DB', 'escapeString'), array_keys($data))); 230 230 231 231 // SQLize the keys of the values of the specified versioned record. (These are more complex because we need to account for SQL null values.) … … 233 233 $comma = ''; 234 234 foreach ($data as $v) { 235 $replace_values .= is_null($v) ? "$comma\nNULL" : "$comma\n'" . addslashes($v) . "'";235 $replace_values .= is_null($v) ? "$comma\nNULL" : "$comma\n'" . DB::escapeString($v) . "'"; 236 236 $comma = ','; 237 237 } … … 268 268 $qid = DB::query(" 269 269 SELECT COUNT(*) FROM " . $this->getParam('db_table') . " 270 WHERE record_table = '" . addslashes($record_table) . "'271 AND record_key = '" . addslashes($record_key) . "'272 AND record_val = '" . addslashes($record_val) . "'270 WHERE record_table = '" . DB::escapeString($record_table) . "' 271 AND record_key = '" . DB::escapeString($record_key) . "' 272 AND record_val = '" . DB::escapeString($record_val) . "' 273 273 "); 274 274 list($v_count) = mysql_fetch_row($qid); … … 280 280 $qid = DB::query(" 281 281 SELECT version_id FROM " . $this->getParam('db_table') . " 282 WHERE record_table = '" . addslashes($record_table) . "'283 AND record_key = '" . addslashes($record_key) . "'284 AND record_val = '" . addslashes($record_val) . "'282 WHERE record_table = '" . DB::escapeString($record_table) . "' 283 AND record_key = '" . DB::escapeString($record_key) . "' 284 AND record_val = '" . DB::escapeString($record_val) . "' 285 285 ORDER BY version_datetime ASC 286 286 LIMIT " . ($v_count - $this->getParam('min_qty')) . " … … 297 297 $qid = DB::query(" 298 298 SELECT version_id FROM " . $this->getParam('db_table') . " 299 WHERE record_table = '" . addslashes($record_table) . "'300 AND record_key = '" . addslashes($record_key) . "'301 AND record_val = '" . addslashes($record_val) . "'299 WHERE record_table = '" . DB::escapeString($record_table) . "' 300 AND record_key = '" . DB::escapeString($record_key) . "' 301 AND record_val = '" . DB::escapeString($record_val) . "' 302 302 AND DATE_ADD(version_datetime, INTERVAL '" . $this->getParam('min_days') . "' DAY) < NOW() 303 303 ORDER BY version_datetime ASC … … 334 334 SELECT version_id, saved_by_admin_id, version_datetime, version_title 335 335 FROM " . $this->getParam('db_table') . " 336 WHERE record_table = '" . addslashes($record_table) . "'337 AND record_key = '" . addslashes($record_key) . "'338 AND record_val = '" . addslashes($record_val) . "'336 WHERE record_table = '" . DB::escapeString($record_table) . "' 337 AND record_key = '" . DB::escapeString($record_key) . "' 338 AND record_val = '" . DB::escapeString($record_val) . "' 339 339 ORDER BY version_datetime DESC 340 340 "); … … 362 362 $qid = DB::query(" 363 363 SELECT * FROM " . $this->getParam('db_table') . " 364 WHERE version_id = '" . addslashes($version_id) . "'364 WHERE version_id = '" . DB::escapeString($version_id) . "' 365 365 "); 366 366 return mysql_fetch_assoc($qid); … … 381 381 $qid = DB::query(" 382 382 SELECT * FROM " . $this->getParam('db_table') . " 383 WHERE version_id = '" . addslashes($version_id) . "'383 WHERE version_id = '" . DB::escapeString($version_id) . "' 384 384 "); 385 385 $record = mysql_fetch_assoc($qid); … … 403 403 404 404 $qid = DB::query(" 405 SELECT * FROM " . addslashes($record_table) . "406 WHERE " . addslashes($record_key) . " = '" . addslashes($record_val) . "'405 SELECT * FROM " . DB::escapeString($record_table) . " 406 WHERE " . DB::escapeString($record_key) . " = '" . DB::escapeString($record_val) . "' 407 407 "); 408 408 if ($record = mysql_fetch_assoc($qid)) { -
trunk/lib/SortOrder.inc.php
r46 r111 143 143 144 144 if (!empty($this->_columns[strtolower($this->sort_by)][strtolower($this->order)])) { 145 return sprintf(' ORDER BY %s ', addslashes($this->_columns[strtolower($this->sort_by)][strtolower($this->order)]));145 return sprintf(' ORDER BY %s ', DB::escapeString($this->_columns[strtolower($this->sort_by)][strtolower($this->order)])); 146 146 } else { 147 147 App::logMsg(sprintf('Could not find SQL to sort by %s %s.', $this->sort_by, $this->order), LOG_WARNING, __FILE__, __LINE__); -
trunk/lib/TemplateGlue.inc.php
r64 r111 66 66 function getSetEnumFieldValues($db_table, $db_col) 67 67 { 68 $qid = DB::query("SHOW COLUMNS FROM " . addslashes($db_table) . " LIKE '" . addslashes($db_col) . "'",false);68 $qid = DB::query("SHOW COLUMNS FROM " . DB::escapeString($db_table) . " LIKE '" . DB::escapeString($db_col) . "'",false); 69 69 70 70 $row = mysql_fetch_row($qid); -
trunk/lib/Utilities.inc.php
r103 r111 105 105 /** 106 106 * Returns text with stylistic modifications. Warning: this will break some HTML attibutes! 107 * FIXME: Allow a string such as this to be passted: <a href="javascript:openPopup('/foo/bar.php')">Click here</a>107 * TODO: Allow a string such as this to be passted: <a href="javascript:openPopup('/foo/bar.php')">Click here</a> 108 108 * 109 109 * @param string $txt Text to clean. … … 463 463 464 464 /** 465 * Adds slashes to values of an array and converts the array to a 466 * comma delimited list. If value provided is not an array or is empty 467 * return nothing. This is useful for putting values coming in from 468 * posted checkboxes into a SET column of a database. 469 * 470 * @param array $array Array to convert. 465 * Adds slashes to values of an array and converts the array to a comma 466 * delimited list. If value provided is a string return the string 467 * escaped. This is useful for putting values coming in from posted 468 * checkboxes into a SET column of a database. 469 * 470 * 471 * @param array $in Array to convert. 471 472 * @return string Comma list of array values. 472 473 */ 473 function dbArrayToList($array) 474 { 475 if (is_array($array) && !empty($array)) { 476 return join(',', array_map('addslashes', array_keys($array))); 477 } 478 } 479 480 /** 481 * Converts a human string date into a SQL-safe date. 482 * Dates nearing infinity use the date 2038-01-01 so conversion to unix time 483 * format remain within valid range. 474 function escapedList($in) 475 { 476 if (is_array($in) && !empty($in)) { 477 return "'" . join("', '", array_map(array('DB', 'escapeString'), $in)) . "'"; 478 } else { 479 return DB::escapeString($in); 480 } 481 } 482 483 /** 484 * Converts a human string date into a SQL-safe date. Dates nearing 485 * infinity use the date 2038-01-01 so conversion to unix time format 486 * remain within valid range. 484 487 * 485 488 * @param array $date String date to convert. -
trunk/services/admins.php
r72 r111 154 154 if (getFormdata('repeat', false)) { 155 155 // Display edit function with next available ID. 156 $qid = DB::query("SELECT admin_id FROM admin_tbl WHERE admin_id > '" . addslashes(getFormData('admin_id')) . "' ORDER BY admin_id ASC LIMIT 1");156 $qid = DB::query("SELECT admin_id FROM admin_tbl WHERE admin_id > '" . DB::escapeString(getFormData('admin_id')) . "' ORDER BY admin_id ASC LIMIT 1"); 157 157 if (list($next_id) = mysql_fetch_row($qid)) { 158 158 App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $next_id); … … 268 268 SELECT * 269 269 FROM admin_tbl 270 WHERE admin_id = '" . addslashes($id) . "'270 WHERE admin_id = '" . DB::escapeString($id) . "' 271 271 "); 272 272 if (!$frm = mysql_fetch_assoc($qid)) { … … 325 325 $qid = DB::query(" 326 326 SELECT username, user_type from admin_tbl 327 WHERE admin_id = '" . addslashes($id) . "'327 WHERE admin_id = '" . DB::escapeString($id) . "' 328 328 "); 329 329 if (! list($name, $user_type) = mysql_fetch_row($qid)) { … … 347 347 } else { 348 348 // Delete the record. 349 DB::query("DELETE FROM admin_tbl WHERE admin_id = '" . addslashes($id) . "'");349 DB::query("DELETE FROM admin_tbl WHERE admin_id = '" . DB::escapeString($id) . "'"); 350 350 App::raiseMsg(sprintf(_("The admin <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__); 351 351 } … … 373 373 added_datetime 374 374 ) VALUES ( 375 '" . addslashes($frm['username']) . "',376 '" . addslashes($frm['first_name']) . "',377 '" . addslashes($frm['last_name']) . "',378 '" . addslashes($frm['email']) . "',379 '" . addslashes($frm['user_type']) . "',380 '" . addslashes($auth->getVal('user_id')) . "',375 '" . DB::escapeString($frm['username']) . "', 376 '" . DB::escapeString($frm['first_name']) . "', 377 '" . DB::escapeString($frm['last_name']) . "', 378 '" . DB::escapeString($frm['email']) . "', 379 '" . DB::escapeString($frm['user_type']) . "', 380 '" . DB::escapeString($auth->getVal('user_id')) . "', 381 381 NOW() 382 382 ) … … 417 417 DB::query(" 418 418 UPDATE admin_tbl SET 419 username = '" . addslashes($frm['username']) . "',420 first_name = '" . addslashes($frm['first_name']) . "',421 last_name = '" . addslashes($frm['last_name']) . "',422 email = '" . addslashes($frm['email']) . "',423 user_type = '" . addslashes($frm['user_type']) . "',424 modified_by_user_id = '" . addslashes($auth->getVal('user_id')) . "',419 username = '" . DB::escapeString($frm['username']) . "', 420 first_name = '" . DB::escapeString($frm['first_name']) . "', 421 last_name = '" . DB::escapeString($frm['last_name']) . "', 422 email = '" . DB::escapeString($frm['email']) . "', 423 user_type = '" . DB::escapeString($frm['user_type']) . "', 424 modified_by_user_id = '" . DB::escapeString($auth->getVal('user_id')) . "', 425 425 modified_datetime = NOW() 426 WHERE admin_id = '" . addslashes($frm['admin_id']) . "'426 WHERE admin_id = '" . DB::escapeString($frm['admin_id']) . "' 427 427 "); 428 428 … … 450 450 $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " 451 451 ( 452 admin_tbl.username LIKE '%" . addslashes($qry_words[$i]) . "%'453 OR admin_tbl.first_name LIKE '%" . addslashes($qry_words[$i]) . "%'454 OR admin_tbl.last_name LIKE '%" . addslashes($qry_words[$i]) . "%'455 OR admin_tbl.email LIKE '%" . addslashes($qry_words[$i]) . "%'452 admin_tbl.username LIKE '%" . DB::escapeString($qry_words[$i]) . "%' 453 OR admin_tbl.first_name LIKE '%" . DB::escapeString($qry_words[$i]) . "%' 454 OR admin_tbl.last_name LIKE '%" . DB::escapeString($qry_words[$i]) . "%' 455 OR admin_tbl.email LIKE '%" . DB::escapeString($qry_words[$i]) . "%' 456 456 ) 457 457 ";
Note: See TracChangeset
for help on using the changeset viewer.