WordPress.org

Make WordPress Core

Changeset 2915


Ignore:
Timestamp:
09/24/05 18:07:46 (9 years ago)
Author:
ryan
Message:

Moving more stuff to new API.

Location:
trunk
Files:
2 edited

Legend:

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

    r2875 r2915  
    6060        global $wpdb; 
    6161        //mtnames is an array with the names in the mt import file 
    62         $md5pass = md5(changeme); 
     62        $pass = 'changeme'; 
    6363        if (!(in_array($author, $this->mtnames))) { //a new mt author name is found 
    6464            ++ $this->j; 
    6565            $this->mtnames[$this->j] = $author; //add that new mt author name to an array  
    66             $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$this->newauthornames[$j]'"); //check if the new author name defined by the user is a pre-existing wp user 
     66            $user_id = username_exists($this->newauthornames[$j]); //check if the new author name defined by the user is a pre-existing wp user 
    6767            if (!$user_id) { //banging my head against the desk now.  
    6868                if ($newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname 
    69                     $wpdb->query("INSERT INTO $wpdb->users (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$author', '$md5pass', '$author')"); // if user does not want to change, insert the authorname $author 
    70                     $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$author'"); 
     69                    $user_id = wp_create_user($author, $pass); 
    7170                    $this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank. 
    7271                } else { 
    7372                    $wpdb->query("INSERT INTO $wpdb->users (user_level, user_login, user_pass, user_nickname) VALUES ('1', '{$this->newauthornames[$this->j]}', '$md5pass', '{$this->newauthornames[$this->j]}')"); //if not left_blank, insert the user specified name 
    74                     $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '{$this->newauthornames[$this->j]}'"); 
     73                    $user_id = wp_create_user($this->newauthornames[$this->j], $pass); 
    7574                } 
    7675            } else { 
     
    7978        } else { 
    8079            $key = array_search($author, $this->mtnames); //find the array key for $author in the $mtnames array 
    81             $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '{$this->newauthornames[$key]}'"); //use that key to get the value of the author's name from $newauthornames 
     80            $user_id = username_exists($this->newauthornames[$key]); //use that key to get the value of the author's name from $newauthornames 
    8281        } 
    8382 
     
    278277 
    279278                // Let's check to see if it's in already 
    280                 if (posts_exists($post_title, '', $post_date)) { 
     279                if ($post_id = posts_exists($post_title, '', $post_date)) { 
    281280                    echo "Post already imported."; 
    282281                } else { 
     
    285284                    $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt'); 
    286285                    $post_id = wp_insert_post($postdata); 
    287  
    288286                    // Add categories. 
    289287                    if (0 != count($post_categories)) { 
     
    292290                    echo " Post imported successfully..."; 
    293291                } 
     292 
     293                $comment_post_ID = $post_id; 
    294294 
    295295                // Now for comments 
     
    301301                        $comment_author = $wpdb->escape(trim($comment_author[1])); 
    302302                        $comment = preg_replace('|(\n?AUTHOR:.*)|', '', $comment); 
    303                         preg_match("|EMAIL:(.*)|", $comment, $comment_email); 
    304                         $comment_email = $wpdb->escape(trim($comment_email[1])); 
     303                        preg_match("|EMAIL:(.*)|", $comment, $comment_author_email); 
     304                        $comment_author_email = $wpdb->escape(trim($comment_author_email[1])); 
    305305                        $comment = preg_replace('|(\n?EMAIL:.*)|', '', $comment); 
    306306 
    307                         preg_match("|IP:(.*)|", $comment, $comment_ip); 
    308                         $comment_ip = trim($comment_ip[1]); 
     307                        preg_match("|IP:(.*)|", $comment, $comment_author_IP); 
     308                        $comment_author_IP = trim($comment_author_IP[1]); 
    309309                        $comment = preg_replace('|(\n?IP:.*)|', '', $comment); 
    310310 
    311                         preg_match("|URL:(.*)|", $comment, $comment_url); 
    312                         $comment_url = $wpdb->escape(trim($comment_url[1])); 
     311                        preg_match("|URL:(.*)|", $comment, $comment_author_url); 
     312                        $comment_author_url = $wpdb->escape(trim($comment_author_url[1])); 
    313313                        $comment = preg_replace('|(\n?URL:.*)|', '', $comment); 
    314314 
     
    321321                        $comment_content = str_replace('-----', '', $comment_content); 
    322322                        // Check if it's already there 
    323                         if (!$wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) { 
    324                             $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved) 
    325                                                                                                 VALUES 
    326                                                                                                 ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1')"); 
     323                        if (!comment_exists($comment_author, $comment_date)) { 
     324                            $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content'); 
     325                            $commentdata = wp_filter_comment($commentdata); 
     326                            wp_insert_comment($commentdata); 
    327327                            echo "Comment added."; 
    328328                        } 
     
    341341                        $ping = preg_replace('|(\n?BLOG NAME:.*)|', '', $ping); 
    342342 
    343                         $comment_email = ''; 
    344  
    345                         preg_match("|IP:(.*)|", $ping, $comment_ip); 
    346                         $comment_ip = trim($comment_ip[1]); 
     343                        preg_match("|IP:(.*)|", $ping, $comment_author_IP); 
     344                        $comment_author_IP = trim($comment_author_IP[1]); 
    347345                        $ping = preg_replace('|(\n?IP:.*)|', '', $ping); 
    348346 
    349                         preg_match("|URL:(.*)|", $ping, $comment_url); 
    350                         $comment_url = $wpdb->escape(trim($comment_url[1])); 
     347                        preg_match("|URL:(.*)|", $ping, $comment_author_url); 
     348                        $comment_author_url = $wpdb->escape(trim($comment_author_url[1])); 
    351349                        $ping = preg_replace('|(\n?URL:.*)|', '', $ping); 
    352350 
     
    365363                        $comment_content = "<strong>$ping_title</strong>\n\n$comment_content"; 
    366364 
     365                        $comment_type = 'trackback'; 
     366 
    367367                        // Check if it's already there 
    368                         if (!$wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) { 
    369                             $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved, comment_type) 
    370                                                                                                                 VALUES 
    371                                                                                                                 ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1', 'trackback')"); 
    372                             echo " Comment added."; 
     368                        if (!comment_exists($comment_author, $comment_date)) { 
     369                            $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_type'); 
     370                            $commentdata = wp_filter_comment($commentdata); 
     371                            wp_insert_comment($commentdata); 
     372                            echo "Comment added."; 
    373373                        } 
    374  
    375374                    } 
    376375                } 
     
    380379        } 
    381380 
    382         upgrade_all(); 
    383381        echo '</ol>'; 
    384382        echo '<h3>'.sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')).'</h3>'; 
  • trunk/wp-includes/registration-functions.php

    r2895 r2915  
    106106} 
    107107 
    108 function wp_create_user( $username, $password, $email ) { 
     108function wp_create_user( $username, $password, $email = '') { 
    109109    global $wpdb; 
    110110     
Note: See TracChangeset for help on using the changeset viewer.