Changeset 1355 for trunk/wp-admin/import-mt.php
- Timestamp:
- 05/24/2004 08:22:18 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import-mt.php
r1292 r1355 72 72 73 73 function users_form($n) { 74 global $wpdb, $t ableusers, $testing;75 $users = $wpdb->get_results("SELECT * FROM $ tableusers ORDER BY ID");74 global $wpdb, $testing; 75 $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID"); 76 76 ?><select name="userselect[<?php echo $n; ?>]"> 77 77 <option value="#NONE#">- Select -</option> … … 148 148 //function to check the authorname and do the mapping 149 149 function checkauthor($author) { 150 global $wpdb, $ tableusers, $mtnames, $newauthornames, $j;//mtnames is an array with the names in the mt import file150 global $wpdb, $mtnames, $newauthornames, $j;//mtnames is an array with the names in the mt import file 151 151 $md5pass = md5(changeme); 152 152 if (!(in_array($author, $mtnames))) { //a new mt author name is found 153 153 ++$j; 154 154 $mtnames[$j] = $author; //add that new mt author name to an array 155 $user_id = $wpdb->get_var("SELECT ID FROM $ tableusers WHERE user_login = '$newauthornames[$j]'"); //check if the new author name defined by the user is a pre-existing wp user155 $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$j]'"); //check if the new author name defined by the user is a pre-existing wp user 156 156 if (!$user_id) { //banging my head against the desk now. 157 157 if ($newauthornames[$j] == 'left_blank') { //check if the user does not want to change the authorname 158 $wpdb->query("INSERT INTO $ tableusers (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$author', '$md5pass', '$author')"); // if user does not want to change, insert the authorname $author159 $user_id = $wpdb->get_var("SELECT ID FROM $ tableusers WHERE user_login = '$author'");158 $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 159 $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$author'"); 160 160 $newauthornames[$j] = $author; //now we have a name, in the place of left_blank. 161 161 } else { 162 $wpdb->query("INSERT INTO $ tableusers (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$newauthornames[$j]', '$md5pass', '$newauthornames[$j]')"); //if not left_blank, insert the user specified name163 $user_id = $wpdb->get_var("SELECT ID FROM $ tableusers WHERE user_login = '$newauthornames[$j]'");162 $wpdb->query("INSERT INTO $wpdb->users (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$newauthornames[$j]', '$md5pass', '$newauthornames[$j]')"); //if not left_blank, insert the user specified name 163 $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$j]'"); 164 164 } 165 165 } else return $user_id; // return pre-existing wp username if it exists 166 166 } else { 167 167 $key = array_search($author, $mtnames); //find the array key for $author in the $mtnames array 168 $user_id = $wpdb->get_var("SELECT ID FROM $ tableusers WHERE user_login = '$newauthornames[$key]'");//use that key to get the value of the author's name from $newauthornames168 $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$key]'");//use that key to get the value of the author's name from $newauthornames 169 169 } 170 170 return $user_id; … … 273 273 274 274 // Let's check to see if it's in already 275 if ($wpdb->get_var("SELECT ID FROM $ tableposts WHERE post_title = '$post_title' AND post_date = '$post_date'")) {275 if ($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$post_title' AND post_date = '$post_date'")) { 276 276 echo "Post already imported."; 277 277 } else { 278 278 $post_author = checkauthor($post_author);//just so that if a post already exists, new users are not created by checkauthor 279 $wpdb->query("INSERT INTO $ tableposts (279 $wpdb->query("INSERT INTO $wpdb->posts ( 280 280 post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_name, post_modified, post_modified_gmt) 281 281 VALUES 282 282 ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_name','$post_date', '$post_date_gmt')"); 283 $post_id = $wpdb->get_var("SELECT ID FROM $ tableposts WHERE post_title = '$post_title' AND post_date = '$post_date'");283 $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$post_title' AND post_date = '$post_date'"); 284 284 if (0 != count($post_categories)) { 285 285 foreach ($post_categories as $post_category) { 286 286 // See if the category exists yet 287 $cat_id = $wpdb->get_var("SELECT cat_ID from $ tablecategories WHERE cat_name = '$post_category'");287 $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'"); 288 288 if (!$cat_id && '' != trim($post_category)) { 289 289 $cat_nicename = sanitize_title($post_category); 290 $wpdb->query("INSERT INTO $ tablecategories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')");291 $cat_id = $wpdb->get_var("SELECT cat_ID from $ tablecategories WHERE cat_name = '$post_category'");290 $wpdb->query("INSERT INTO $wpdb->categories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')"); 291 $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'"); 292 292 } 293 293 if ('' == trim($post_category)) $cat_id = 1; 294 294 // Double check it's not there already 295 $exists = $wpdb->get_row("SELECT * FROM $ tablepost2cat WHERE post_id = $post_id AND category_id = $cat_id");295 $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = $cat_id"); 296 296 297 297 if (!$exists) { 298 298 $wpdb->query(" 299 INSERT INTO $ tablepost2cat299 INSERT INTO $wpdb->post2cat 300 300 (post_id, category_id) 301 301 VALUES … … 305 305 } // end category loop 306 306 } else { 307 $exists = $wpdb->get_row("SELECT * FROM $ tablepost2cat WHERE post_id = $post_id AND category_id = 1");308 if (!$exists) $wpdb->query("INSERT INTO $ tablepost2cat (post_id, category_id) VALUES ($post_id, 1) ");307 $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = 1"); 308 if (!$exists) $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_id, 1) "); 309 309 } 310 310 echo " Post imported successfully..."; … … 339 339 340 340 // Check if it's already there 341 if (!$wpdb->get_row("SELECT * FROM $ tablecomments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) {342 $wpdb->query("INSERT INTO $ tablecomments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved)341 if (!$wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) { 342 $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) 343 343 VALUES 344 344 ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1')"); … … 384 384 385 385 // Check if it's already there 386 if (!$wpdb->get_row("SELECT * FROM $ tablecomments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) {387 $wpdb->query("INSERT INTO $ tablecomments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved)386 if (!$wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) { 387 $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) 388 388 VALUES 389 389 ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1')");
Note: See TracChangeset
for help on using the changeset viewer.