Changeset 2928 for trunk/wp-admin/import/blogger.php
- Timestamp:
- 10/01/2005 11:29:03 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/blogger.php
r2894 r2928 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 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>24 <p>Before you get started, you may want to back up your Blogger template 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 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"; 40 return "<html><head><script type='text/javascript'>window.onload=setInterval('window.location.reload()', $msec);</script>\n</head>\n<body>"; 44 41 } 45 42 … … 82 79 curl_setopt($ch, CURLOPT_POSTFIELDS,$params); 83 80 curl_setopt($ch, CURLOPT_URL,$_url); 84 curl_setopt($ch, CURLOPT_USERAGENT, ' Blogger Exporter');81 curl_setopt($ch, CURLOPT_USERAGENT, 'Developing Blogger Exporter'); 85 82 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 86 83 curl_setopt($ch, CURLOPT_HEADER,1); … … 102 99 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 103 100 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 104 curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter');105 101 curl_setopt($ch, CURLOPT_HEADER,1); 106 102 if (is_array($header)) curl_setopt($ch, CURLOPT_HTTPHEADER, $header); … … 135 131 if ($user && $pass) curl_setopt($ch, CURLOPT_USERPWD,"{$user}:{$pass}"); 136 132 curl_setopt($ch, CURLOPT_URL,$url); 137 curl_setopt($ch, CURLOPT_USERAGENT, ' Blogger Exporter');133 curl_setopt($ch, CURLOPT_USERAGENT, 'Developing Blogger Exporter'); 138 134 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 139 135 curl_setopt($ch, CURLOPT_HEADER,$parse); … … 170 166 171 167 // Publishes. 172 function publish_blogger($i, $text) { 173 $head = $this->refresher(1000) . "<h1>$text</h1>\n"; 168 function publish_blogger($i) { 174 169 if ( ! $this->import['blogs'][$_GET['blog']]['publish'][$i] ) { 175 170 // First call. Start the publish process. … … 183 178 if ( preg_match('#<p class="progressIndicator">.*</p>#U', $response['body'], $matches) ) { 184 179 $progress = $matches[0]; 185 die($ head . $progress);180 die($progress); 186 181 } else { 187 182 echo "matches:<pre>" . print_r($matches,1) . "</pre>\n"; 188 183 } 189 184 } else { 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 } 185 echo "<h1>Publish error: No 302</h1><p>Please tell the devs.</p><pre>" . addslashes(print_r($response,1)) . "</pre>\n"; 197 186 } 198 187 die(); … … 205 194 if ( strstr($progress, '100%') ) 206 195 $this->set_next_step($i); 207 die($ head . $progress);196 die($progress); 208 197 } else { 209 198 echo "<h1>Publish error: No matches</h1><p>Please tell the devs.</p><pre>" . print_r($matches,1) . "</pre>\n"; … … 282 271 'published' => false, 283 272 'archives' => false, 273 'newusers' => array(), 284 274 'lump_authors' => false, 285 275 'newusers' => 0, … … 378 368 // Step 3: Publish with the new template and settings. 379 369 function publish_blog() { 380 $this->publish_blogger(5, 'Publishing with new template and options'); 370 echo $this->refresher(2400) . "<h1>Publishing with new template and options</h1>\n"; 371 $this->publish_blogger(5); 381 372 } 382 373 … … 412 403 $commentcount = 0; 413 404 $skippedcommentcount = 0; 414 $status = 'in progress...'; 415 $this->import['blogs'][$_GET['blog']]['archives']["$url"] = $status; 416 update_option('import-blogger', $import); 405 $status = ''; 417 406 $archive = implode('',file($url)); 418 407 … … 428 417 //$post_number = $postinfo[3]; 429 418 $post_title = ( $postinfo[4] != '' ) ? $postinfo[4] : $postinfo[3]; 430 $post_author_name = $wpdb->escape(trim($postinfo[1])); 419 $post_author = trim($wpdb->escape($postinfo[1])); 420 $post_author_name = trim(addslashes($postinfo[1])); 431 421 $post_author_email = $postinfo[5] ? $postinfo[5] : 'no@email.com'; 432 422 … … 475 465 $post_status = 'publish'; 476 466 477 if ( $comment_post_ID =post_exists($post_title, '', $post_date) ) {467 if ( post_exists($post_title, '', $post_date) ) { 478 468 $skippedpostcount++; 469 $comment_post_ID = $dupcheck[0]['ID']; 479 470 } else { 480 471 $post_array = compact('post_author', 'post_content', 'post_title', 'post_category', 'post_author', 'post_date', 'post_status'); … … 500 491 $commenthour = '00'; 501 492 $comment_date = "$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond"; 502 $comment_author = addslashes(strip_tags(html_entity_decode($commentinfo[1]))); 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. 503 494 if ( strpos($commentinfo[1], 'a href') ) { 504 495 $comment_author_parts = explode('"', htmlentities($commentinfo[1])); 505 496 $comment_author_url = $comment_author_parts[1]; 506 497 } else $comment_author_url = ''; 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) ) { 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) ) { 511 501 $skippedcommentcount++; 512 502 } else { 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++; 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 "); 516 509 } 517 510 $commentcount++; … … 530 523 if ( ! $did_one ) 531 524 $this->set_next_step(7); 532 die( $this->refresher( 1000) . $output );525 die( $this->refresher(5000) . $output ); 533 526 } 534 527 … … 576 569 // Step 8: Republish, all back to normal 577 570 function republish_blog() { 578 $this->publish_blogger(9, 'Publishing with original template and options'); 571 echo $this->refresher(2400) . "<h1>Publishing with original template and options</h1>\n"; 572 $this->publish_blogger(9); 579 573 } 580 574 … … 588 582 if ( count($this->import['blogs']) > 1 ) 589 583 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"; 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";584 if ( $n = count($this->import['blogs'][$_GET['blog']]['newusers']) ) 585 echo "<li>Since we had to create $n new users, 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"; 592 586 593 587 echo "\n<ul>"; … … 602 596 if ( isset($_GET['noheader']) ) { 603 597 $this->import = get_settings('import-blogger'); 604 605 ob_start();606 598 607 599 if ( isset($_GET['step']) ) { … … 614 606 $step = 0; 615 607 } 616 617 608 switch ($step) { 618 609 case 0 :
Note: See TracChangeset
for help on using the changeset viewer.