Ignore:
Timestamp:
Apr 27, 2006 1:49:54 AM (18 years ago)
Author:
scdev
Message:

Q - Finished depreciating addslashes. array_map instances need to use array('DB', 'escapeString') as first argument.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Hierarchy.inc.php

    r92 r111  
    197197                    title
    198198                ) 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) . "'
    205205                )
    206206            ");
     
    245245        DB::query("
    246246            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) . "'
    249249        ");
    250250        App::logMsg(sprintf('deleteNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);
     
    311311            $qid = DB::query("
    312312                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) . "'") . "
    316316            ");
    317317            list($title) = mysql_fetch_row($qid);
     
    321321        DB::query("
    322322            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) . "'") . "
    326326        ");
    327327        App::logMsg(sprintf('moveNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);
     
    359359                $type_constraint = array($type_constraint);
    360360            }
    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)) . "')";
    362362        }
    363363
     
    365365            SELECT parent_type, parent_id
    366366            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) . "'
    369369            $in_clause
    370             " . addslashes($order) . "
     370            " . DB::escapeString($order) . "
    371371        ");
    372372
     
    405405            SELECT child_type, child_id, title, subnode_quantity
    406406            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) . "'
    409409        ");
    410410
     
    448448                $type_constraint = array($type_constraint);
    449449            }
    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)) . "')";
    451451        }
    452452
     
    454454            SELECT *
    455455            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) . "'
    458458            $in_clause
    459             " . addslashes($order) . "
     459            " . DB::escapeString($order) . "
    460460        ");
    461461
     
    497497                $type_constraint = array($type_constraint);
    498498            }
    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)) . "')";
    500500        }
    501501
     
    503503            SELECT COUNT(*)
    504504            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) . "'
    507507            $in_clause
    508508        ");
     
    585585            SELECT parent_type, parent_id, child_type, child_id, title, subnode_quantity
    586586            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) . "'
    589589        ");
    590590        while ($row = mysql_fetch_assoc($qid)) {
     
    644644            $qid = DB::query("
    645645                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) . "'") . "
    651651            ");
    652652        } else {
    653653            $qid = DB::query("
    654654                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) . "'
    657657            ");
    658658        }
     
    775775        DB::query("
    776776            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) . "'
    780780        ",false);
    781781        $qid = DB::query("
    782782            SELECT parent_type, parent_id
    783783            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) . "'
    786786        ",false);
    787787        while ((list($parent_type, $parent_id) = mysql_fetch_row($qid)) && $parent_id > 0) {
Note: See TracChangeset for help on using the changeset viewer.