Make WordPress Core


Ignore:
Timestamp:
07/05/2005 08:47:22 PM (21 years ago)
Author:
ryan
Message:

Use wpdb->escape instead of addslashes to prepare DB bound data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import-greymatter.php

    r2687 r2699  
    9191                $user_joindate=substr($s,6,4)."-".substr($s,0,2)."-".substr($s,3,2)." 00:00:00";
    9292
    93                 $user_login=addslashes($userdata[0]);
    94                 $pass1=addslashes($userdata[1]);
    95                 $user_nickname=addslashes($userdata[0]);
    96                 $user_email=addslashes($userdata[2]);
    97                 $user_url=addslashes($userdata[3]);
    98                 $user_joindate=addslashes($user_joindate);
     93                $user_login=$wpdb->escape($userdata[0]);
     94                $pass1=$wpdb->escape($userdata[1]);
     95                $user_nickname=$wpdb->escape($userdata[0]);
     96                $user_email=$wpdb->escape($userdata[2]);
     97                $user_url=$wpdb->escape($userdata[3]);
     98                $user_joindate=$wpdb->escape($user_joindate);
    9999
    100100                $loginthere = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '$user_login'");
     
    148148                        $postmorecontent=gm2autobr($entry[3]);
    149149
    150                         $post_author=trim(addslashes($postinfo[1]));
     150                        $post_author=trim($wpdb->escape($postinfo[1]));
    151151                        // we'll check the author is registered, or if it's a deleted author
    152152                        $sql = "SELECT * FROM $wpdb->users WHERE user_login = '$post_author'";
     
    154154                        if (! $result) { // if deleted from GM, we register the author as a level 0 user in wp
    155155                                $user_joindate="1979-06-06 00:41:00";
    156                                 $user_login=addslashes($post_author);
    157                                 $pass1=addslashes("password");
    158                                 $user_nickname=addslashes($post_author);
    159                                 $user_email=addslashes("user@deleted.com");
    160                                 $user_url=addslashes("");
    161                                 $user_joindate=addslashes($user_joindate);
     156                                $user_login=$wpdb->escape($post_author);
     157                                $pass1=$wpdb->escape("password");
     158                                $user_nickname=$wpdb->escape($post_author);
     159                                $user_email=$wpdb->escape("user@deleted.com");
     160                                $user_url=$wpdb->escape("");
     161                                $user_joindate=$wpdb->escape($user_joindate);
    162162                                $query = "INSERT INTO $wpdb->users (user_login,user_pass,user_email,user_url,user_registered,user_level) VALUES ('$user_login','$pass1','$user_email','$user_url','$user_joindate','0')";
    163163                                $result = $wpdb->query($query);
     
    172172
    173173                        $post_title=gm2autobr($postinfo[2]);
    174                         $post_title=addslashes($post_title);
     174                        $post_title=$wpdb->escape($post_title);
    175175
    176176                        $postyear=$postinfo[6];
     
    189189                        if (strlen($postmorecontent)>3)
    190190                                $post_content .= "<!--more--><br /><br />".$postmorecontent;
    191                         $post_content=addslashes($post_content);
     191                        $post_content=$wpdb->escape($post_content);
    192192
    193193                        $post_karma=$postinfo[12];
     
    223223                                        $commentinfo=explode("|",$entry[$j]);
    224224                                        $comment_post_ID=$post_ID;
    225                                         $comment_author=addslashes($commentinfo[0]);
    226                                         $comment_author_email=addslashes($commentinfo[2]);
    227                                         $comment_author_url=addslashes($commentinfo[3]);
    228                                         $comment_author_IP=addslashes($commentinfo[1]);
     225                                        $comment_author=$wpdb->escape($commentinfo[0]);
     226                                        $comment_author_email=$wpdb->escape($commentinfo[2]);
     227                                        $comment_author_url=$wpdb->escape($commentinfo[3]);
     228                                        $comment_author_IP=$wpdb->escape($commentinfo[1]);
    229229
    230230                                        $commentyear=$commentinfo[7];
     
    238238                                        $comment_date="$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond";
    239239
    240                                         $comment_content=addslashes($commentinfo[12]);
     240                                        $comment_content=$wpdb->escape($commentinfo[12]);
    241241
    242242                                        $sql3 = "INSERT INTO $wpdb->comments (comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_author_IP,comment_date,comment_content) VALUES ('$comment_post_ID','$comment_author','$comment_author_email','$comment_author_url','$comment_author_IP','$comment_date','$comment_content')";
Note: See TracChangeset for help on using the changeset viewer.