Changeset 2915
- Timestamp:
- 09/24/2005 06:07:46 PM (20 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
wp-admin/import/mt.php (modified) (10 diffs)
-
wp-includes/registration-functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/mt.php
r2875 r2915 60 60 global $wpdb; 61 61 //mtnames is an array with the names in the mt import file 62 $ md5pass = md5(changeme);62 $pass = 'changeme'; 63 63 if (!(in_array($author, $this->mtnames))) { //a new mt author name is found 64 64 ++ $this->j; 65 65 $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 user66 $user_id = username_exists($this->newauthornames[$j]); //check if the new author name defined by the user is a pre-existing wp user 67 67 if (!$user_id) { //banging my head against the desk now. 68 68 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); 71 70 $this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank. 72 71 } else { 73 72 $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); 75 74 } 76 75 } else { … … 79 78 } else { 80 79 $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 $newauthornames80 $user_id = username_exists($this->newauthornames[$key]); //use that key to get the value of the author's name from $newauthornames 82 81 } 83 82 … … 278 277 279 278 // 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)) { 281 280 echo "Post already imported."; 282 281 } else { … … 285 284 $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'); 286 285 $post_id = wp_insert_post($postdata); 287 288 286 // Add categories. 289 287 if (0 != count($post_categories)) { … … 292 290 echo " Post imported successfully..."; 293 291 } 292 293 $comment_post_ID = $post_id; 294 294 295 295 // Now for comments … … 301 301 $comment_author = $wpdb->escape(trim($comment_author[1])); 302 302 $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])); 305 305 $comment = preg_replace('|(\n?EMAIL:.*)|', '', $comment); 306 306 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]); 309 309 $comment = preg_replace('|(\n?IP:.*)|', '', $comment); 310 310 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])); 313 313 $comment = preg_replace('|(\n?URL:.*)|', '', $comment); 314 314 … … 321 321 $comment_content = str_replace('-----', '', $comment_content); 322 322 // 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 VALUES326 ($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); 327 327 echo "Comment added."; 328 328 } … … 341 341 $ping = preg_replace('|(\n?BLOG NAME:.*)|', '', $ping); 342 342 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]); 347 345 $ping = preg_replace('|(\n?IP:.*)|', '', $ping); 348 346 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])); 351 349 $ping = preg_replace('|(\n?URL:.*)|', '', $ping); 352 350 … … 365 363 $comment_content = "<strong>$ping_title</strong>\n\n$comment_content"; 366 364 365 $comment_type = 'trackback'; 366 367 367 // 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 VALUES371 ($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."; 373 373 } 374 375 374 } 376 375 } … … 380 379 } 381 380 382 upgrade_all();383 381 echo '</ol>'; 384 382 echo '<h3>'.sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')).'</h3>'; -
trunk/wp-includes/registration-functions.php
r2895 r2915 106 106 } 107 107 108 function wp_create_user( $username, $password, $email ) {108 function wp_create_user( $username, $password, $email = '') { 109 109 global $wpdb; 110 110
Note: See TracChangeset
for help on using the changeset viewer.