Changeset 2894 for trunk/wp-admin/import/blogger.php
- Timestamp:
- 09/20/2005 03:17:43 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/blogger.php
r2880 r2894 22 22 echo '<h2>'.__('Import Blogger').'</h2>'; 23 23 _e("<p>Howdy! This importer allows you to import posts and comments from your Blogger account into your WordPress blog.</p> 24 <p>Before you get started, you may want to back up your Blogger templateby copying and pasting it into a text file on your computer. This script has to modify your template and other Blogger settings so it can get your posts and comments. It should restore everything afterwards but if you have put a lot of work into your template, it would be a good idea to make your own backup first.</p>24 <p>Before you get started, you should <u>back up your Blogger template</u> by copying and pasting it into a text file on your computer. This script has to modify your template and other Blogger settings so it can get your posts and comments. It should restore everything afterwards but if you have put a lot of work into your template, it would be a good idea to make your own backup first.</p> 25 25 <p>When you are ready to begin, enter your Blogger username and password below and click Start. Do not close this window until the process is complete.</p>"); 26 26 echo "<iframe src='admin.php?import=blogger&noheader=true' height='350px' width = '99%'></iframe>"; … … 38 38 // Generates a string that will make the page reload in a specified interval. 39 39 function refresher($msec) { 40 return "<html><head><script type='text/javascript'>window.onload=setInterval('window.location.reload()', $msec);</script>\n</head>\n<body>"; 40 if ( $msec ) 41 return "<html><head><script type='text/javascript'>window.onload=setTimeout('window.location.reload()', $msec);</script>\n</head>\n<body>\n"; 42 else 43 return "<html><head><script type='text/javascript'>window.onload=window.location.reload();</script>\n</head>\n<body>\n"; 41 44 } 42 45 … … 79 82 curl_setopt($ch, CURLOPT_POSTFIELDS,$params); 80 83 curl_setopt($ch, CURLOPT_URL,$_url); 81 curl_setopt($ch, CURLOPT_USERAGENT, ' DevelopingBlogger Exporter');84 curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter'); 82 85 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 83 86 curl_setopt($ch, CURLOPT_HEADER,1); … … 99 102 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 100 103 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 104 curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter'); 101 105 curl_setopt($ch, CURLOPT_HEADER,1); 102 106 if (is_array($header)) curl_setopt($ch, CURLOPT_HTTPHEADER, $header); … … 131 135 if ($user && $pass) curl_setopt($ch, CURLOPT_USERPWD,"{$user}:{$pass}"); 132 136 curl_setopt($ch, CURLOPT_URL,$url); 133 curl_setopt($ch, CURLOPT_USERAGENT, ' DevelopingBlogger Exporter');137 curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter'); 134 138 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 135 139 curl_setopt($ch, CURLOPT_HEADER,$parse); … … 166 170 167 171 // Publishes. 168 function publish_blogger($i) { 172 function publish_blogger($i, $text) { 173 $head = $this->refresher(1000) . "<h1>$text</h1>\n"; 169 174 if ( ! $this->import['blogs'][$_GET['blog']]['publish'][$i] ) { 170 175 // First call. Start the publish process. … … 178 183 if ( preg_match('#<p class="progressIndicator">.*</p>#U', $response['body'], $matches) ) { 179 184 $progress = $matches[0]; 180 die($ progress);185 die($head . $progress); 181 186 } else { 182 187 echo "matches:<pre>" . print_r($matches,1) . "</pre>\n"; 183 188 } 184 189 } else { 185 echo "<h1>Publish error: No 302</h1><p>Please tell the devs.</p><pre>" . addslashes(print_r($response,1)) . "</pre>\n"; 190 if ( strstr($response['body'], 'Please sign in before proceeding') ) { 191 $this->import['cookies'] = $this->login_blogger($this->import['user'], $this->import['pass']); 192 update_option('import-blogger', $this->import); 193 die($this->refresher(500) . "<h1>Logging into Blogger again...</h1>"); 194 } else { 195 echo "<h1>Publish error: No 302</h1><p>Please tell the devs.</p><pre>" . addslashes(print_r($response,1)) . "</pre>\n"; 196 } 186 197 } 187 198 die(); … … 194 205 if ( strstr($progress, '100%') ) 195 206 $this->set_next_step($i); 196 die($ progress);207 die($head . $progress); 197 208 } else { 198 209 echo "<h1>Publish error: No matches</h1><p>Please tell the devs.</p><pre>" . print_r($matches,1) . "</pre>\n"; … … 271 282 'published' => false, 272 283 'archives' => false, 273 'newusers' => array(),274 284 'lump_authors' => false, 275 285 'newusers' => 0, … … 368 378 // Step 3: Publish with the new template and settings. 369 379 function publish_blog() { 370 echo $this->refresher(2400) . "<h1>Publishing with new template and options</h1>\n"; 371 $this->publish_blogger(5); 380 $this->publish_blogger(5, 'Publishing with new template and options'); 372 381 } 373 382 … … 403 412 $commentcount = 0; 404 413 $skippedcommentcount = 0; 405 $status = ''; 414 $status = 'in progress...'; 415 $this->import['blogs'][$_GET['blog']]['archives']["$url"] = $status; 416 update_option('import-blogger', $import); 406 417 $archive = implode('',file($url)); 407 418 … … 417 428 //$post_number = $postinfo[3]; 418 429 $post_title = ( $postinfo[4] != '' ) ? $postinfo[4] : $postinfo[3]; 419 $post_author = trim($wpdb->escape($postinfo[1])); 420 $post_author_name = trim(addslashes($postinfo[1])); 430 $post_author_name = $wpdb->escape(trim($postinfo[1])); 421 431 $post_author_email = $postinfo[5] ? $postinfo[5] : 'no@email.com'; 422 432 … … 465 475 $post_status = 'publish'; 466 476 467 if ( post_exists($post_title, '', $post_date) ) {477 if ( $comment_post_ID = post_exists($post_title, '', $post_date) ) { 468 478 $skippedpostcount++; 469 $comment_post_ID = $dupcheck[0]['ID'];470 479 } else { 471 480 $post_array = compact('post_author', 'post_content', 'post_title', 'post_category', 'post_author', 'post_date', 'post_status'); … … 491 500 $commenthour = '00'; 492 501 $comment_date = "$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond"; 493 $comment_author = addslashes(strip_tags(html_entity_decode($commentinfo[1]))); // Believe it or not, Blogger allows a user to call himself "Mr. Hell's Kitchen" which, as a string, really confuses SQL.502 $comment_author = addslashes(strip_tags(html_entity_decode($commentinfo[1]))); 494 503 if ( strpos($commentinfo[1], 'a href') ) { 495 504 $comment_author_parts = explode('"', htmlentities($commentinfo[1])); 496 505 $comment_author_url = $comment_author_parts[1]; 497 506 } else $comment_author_url = ''; 498 $comment_content = addslashes($commentinfo[2]); 499 $comment_content = str_replace('<br>', '<br />', $comment_content); 500 if ( $comment_post_ID == comment_exists($comment_author, $comment_date) ) { 507 $comment_content = $commentinfo[2]; 508 $comment_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $comment_content); 509 $comment_approved = 1; 510 if ( comment_exists($comment_author, $comment_date) ) { 501 511 $skippedcommentcount++; 502 512 } else { 503 $result = $wpdb->query(" 504 INSERT INTO $wpdb->comments 505 (comment_post_ID,comment_author,comment_author_url,comment_date,comment_content) 506 VALUES 507 ('$comment_post_ID','$comment_author','$comment_author_url','$comment_date','$comment_content') 508 "); 513 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_date', 'comment_content', 'comment_approved'); 514 $commentdata = wp_filter_comment($commentdata); 515 if ( false == wp_insert_comment($commentdata) ) $skippedcommentcount++; 509 516 } 510 517 $commentcount++; … … 523 530 if ( ! $did_one ) 524 531 $this->set_next_step(7); 525 die( $this->refresher( 5000) . $output );532 die( $this->refresher(1000) . $output ); 526 533 } 527 534 … … 569 576 // Step 8: Republish, all back to normal 570 577 function republish_blog() { 571 echo $this->refresher(2400) . "<h1>Publishing with original template and options</h1>\n"; 572 $this->publish_blogger(9); 578 $this->publish_blogger(9, 'Publishing with original template and options'); 573 579 } 574 580 … … 582 588 if ( count($this->import['blogs']) > 1 ) 583 589 echo "<li>In case you haven't done it already, you can import the posts from any other blogs you may have:" . $this->show_blogs() . "</li>\n"; 584 if ( $n = count($this->import['blogs'][$_GET['blog']]['newusers']))585 echo "<li>Since we had to create $n new user s, you probably want to go to <a href='users.php' target='_parent'>Authors & Users</a>, where you can give them new passwords or delete them. If you want to make all of the imported posts yours, you will be given that option when you delete the new authors.</li>\n";590 if ( $n = $this->import['blogs'][$_GET['blog']]['newusers'] ) 591 echo "<li>Since we had to create $n new user" . ( $n > 1 ? 's' : '' ) . ", you probably want to go to <a href='users.php' target='_parent'>Authors & Users</a>, where you can give them new passwords or delete them. If you want to make all of the imported posts yours, you will be given that option when you delete the new authors.</li>\n"; 586 592 587 593 echo "\n<ul>"; … … 596 602 if ( isset($_GET['noheader']) ) { 597 603 $this->import = get_settings('import-blogger'); 604 605 ob_start(); 598 606 599 607 if ( isset($_GET['step']) ) { … … 606 614 $step = 0; 607 615 } 616 608 617 switch ($step) { 609 618 case 0 :
Note: See TracChangeset
for help on using the changeset viewer.