Changes in trunk/wp-admin/import/blogger.php [4369:3397]
- File:
-
- 1 edited
-
trunk/wp-admin/import/blogger.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/blogger.php
r4369 r3397 26 26 function restart() { 27 27 delete_option('import-blogger'); 28 wp_redirect("admin.php?import=blogger");28 header("Location: admin.php?import=blogger"); 29 29 die(); 30 30 } … … 136 136 if ($header) curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 137 137 $response = curl_exec ($ch); 138 138 139 139 if ($parse) { 140 140 $response = $this->parse_response($response); … … 142 142 return $response; 143 143 } 144 144 145 145 return $response; 146 146 } … … 211 211 update_option('import-blogger', $this->import); 212 212 } 213 213 214 214 // Redirects to next step 215 215 function do_next_step() { 216 wp_redirect("admin.php?import=blogger&noheader=true&blog={$_GET['blog']}");216 header("Location: admin.php?import=blogger&noheader=true&blog={$_GET['blog']}"); 217 217 die(); 218 218 } … … 225 225 $this->login_form(__('The script will log into your Blogger account, change some settings so it can read your blog, and restore the original settings when it\'s done. Here\'s what you do:').'</p><ol><li>'.__('Back up your Blogger template.').'</li><li>'.__('Back up any other Blogger settings you might need later.').'</li><li>'.__('Log out of Blogger').'</li><li>'.__('Log in <em>here</em> with your Blogger username and password.').'</li><li>'.__('On the next screen, click one of your Blogger blogs.').'</li><li>'.__('Do not close this window or navigate away until the process is complete.').'</li></ol>'); 226 226 } 227 228 // Try logging in. If we get an array of cookies back, we at least connected. 227 228 // Try logging in. If we get an array of cookies back, we at least connected. 229 229 $this->import['cookies'] = $this->login_blogger($_POST['user'], $_POST['pass']); 230 230 if ( !is_array( $this->import['cookies'] ) ) { 231 231 $this->login_form(__('Login failed. Please enter your credentials again.')); 232 232 } 233 233 234 234 // Save the password so we can log the browser in when it's time to publish. 235 235 $this->import['pass'] = $_POST['pass']; … … 242 242 preg_match_all('#posts\.g\?blogID=(\d+)">([^<]+)</a>#U', $response['body'], $blogsary); 243 243 if ( ! count( $blogsary[1] < 1 ) ) 244 wp_die(__('No blogs found for this user.'));244 die(__('No blogs found for this user.')); 245 245 $this->import['blogs'] = array(); 246 246 $template = '<MainPage><br /><br /><br /><p>'.__('Are you looking for %title%? It is temporarily out of service. Please try again in a few minutes. Meanwhile, discover <a href="http://wordpress.org/">a better blogging tool</a>.').'</p><BloggerArchives><a class="archive" href="<$BlogArchiveURL$>"><$BlogArchiveName$></a><br /></BloggerArchives></MainPage><ArchivePage><Blogger><wordpresspost><$BlogItemDateTime$>|W|P|<$BlogItemAuthorNickname$>|W|P|<$BlogItemBody$>|W|P|<$BlogItemNumber$>|W|P|<$BlogItemTitle$>|W|P|<$BlogItemAuthorEmail$><BlogItemCommentsEnabled><BlogItemComments><wordpresscomment><$BlogCommentDateTime$>|W|P|<$BlogCommentAuthor$>|W|P|<$BlogCommentBody$></BlogItemComments></BlogItemCommentsEnabled></Blogger></ArchivePage>'; … … 274 274 } 275 275 update_option('import-blogger', $this->import); 276 wp_redirect("admin.php?import=blogger&noheader=true&step=1");276 header("Location: admin.php?import=blogger&noheader=true&step=1"); 277 277 } 278 278 die(); … … 307 307 $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode=0", $headers); 308 308 if ( $response['code'] >= 400 ) 309 wp_die('<h2>'.__('Failed attempt to change publish mode from FTP to BlogSpot.').'</h2><pre>' . addslashes(print_r($headers, 1)) . addslashes(print_r($response, 1)) . '</pre>');309 die('<h2>'.__('Failed attempt to change publish mode from FTP to BlogSpot.').'</h2><pre>' . addslashes(print_r($headers, 1)) . addslashes(print_r($response, 1)) . '</pre>'); 310 310 $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $optary['modify']['subdomain'] . '.blogspot.com/'; 311 311 sleep(2); … … 322 322 $response = $this->post_blogger($posturl, $headers, $paramary); 323 323 if ( $response['code'] >= 400 || strstr($response['body'], 'There are errors on this form') ) 324 wp_die('<p>'.__('Error on form submission. Retry or reset the importer.').'</p>' . addslashes(print_r($response, 1)));324 die('<p>'.__('Error on form submission. Retry or reset the importer.').'</p>' . addslashes(print_r($response, 1))); 325 325 } 326 326 $output .= "<del><p>$blog_opt</p></del>\n"; … … 342 342 $form.= $body; 343 343 $form.= "</div><script type='text/javascript'>forms=document.getElementsByTagName('form');for(i=0;i<forms.length;i++){if(forms[i].action.search('{$blog_opt}')){forms[i].submit();break;}}</script>"; 344 $output.= '<p>'.sprintf( __('<strong>%s</strong> in progress, please wait...'), $blog_opt)."</p>\n";344 $output.= '<p>'.sprintf('<strong>%s</strong> in progress, please wait...', $blog_opt)."</p>\n"; 345 345 } else { 346 346 $output.= "<p>$blog_opt</p>\n"; … … 365 365 $bloghtml = $this->get_blogger($this->import['blogs'][$_GET['blog']]['url']); 366 366 if (! strstr($bloghtml['body'], '<a class="archive"') ) 367 wp_die(__('Your Blogger blog did not take the new template or did not respond.'));367 die(__('Your Blogger blog did not take the new template or did not respond.')); 368 368 preg_match_all('#<a class="archive" href="([^"]*)"#', $bloghtml['body'], $archives); 369 369 foreach ($archives[1] as $archive) { … … 396 396 $archive = $this->get_blogger($url); 397 397 if ( $archive['code'] > 200 ) 398 continue; 398 continue; 399 399 $posts = explode('<wordpresspost>', $archive['body']); 400 400 for ($i = 1; $i < count($posts); $i = $i + 1) { … … 410 410 $post_author_name = $wpdb->escape(trim($postinfo[1])); 411 411 $post_author_email = $postinfo[5] ? $postinfo[5] : 'user@wordpress.org'; 412 412 413 413 if ( $this->lump_authors ) { 414 414 // Ignore Blogger authors. Use the current user_ID for all posts imported. … … 421 421 $user_password = substr(md5(uniqid(microtime())), 0, 6); 422 422 $result = wp_create_user( $user_login, $user_password, $user_email ); 423 $status.= sprintf( __('Registered user <strong>%s</strong>.'), $user_login);423 $status.= sprintf('Registered user <strong>%s</strong>.', $user_login); 424 424 $this->import['blogs'][$_GET['blog']]['newusers'][] = $user_login; 425 425 } … … 436 436 $postminute = zeroise($post_date_His[1], 2); 437 437 $postsecond = zeroise($post_date_His[2], 2); 438 438 439 439 if (($post_date[2] == 'PM') && ($posthour != '12')) 440 440 $posthour = $posthour + 12; 441 441 else if (($post_date[2] == 'AM') && ($posthour == '12')) 442 442 $posthour = '00'; 443 443 444 444 $post_date = "$postyear-$postmonth-$postday $posthour:$postminute:$postsecond"; 445 445 446 446 $post_content = addslashes($post_content); 447 447 $post_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $post_content); // the XHTML touch... ;) 448 448 449 449 $post_title = addslashes($post_title); 450 450 451 451 $post_status = 'publish'; 452 452 453 453 if ( $ID = post_exists($post_title, '', $post_date) ) { 454 454 $post_array[$i]['ID'] = $ID; … … 510 510 } 511 511 $status = sprintf(__('%s post(s) parsed, %s skipped...'), $postcount, $skippedpostcount).' '. 512 sprintf(__('%s comment(s) parsed, %s skipped...'), $commentcoun t, $skippedcommentcount).' '.512 sprintf(__('%s comment(s) parsed, %s skipped...'), $commentcoun, $skippedcommentcount).' '. 513 513 ' <strong>'.__('Done').'</strong>'; 514 514 $import = $this->import; … … 547 547 sleep(2); 548 548 if ( $response['code'] >= 400 ) 549 wp_die('<h1>'.__('Error restoring publishMode').'</h1><p>'.__('Please tell the devs.').'</p>' . addslashes(print_r($response, 1)) );549 die('<h1>Error restoring publishMode.</h1><p>Please tell the devs.</p>' . addslashes(print_r($response, 1)) ); 550 550 } 551 551 } … … 598 598 $this->restart(); 599 599 } 600 600 601 601 if ( isset($_GET['noheader']) ) { 602 header('Content-Type: text/html; charset=utf-8'); 603 604 $this->import = get_option('import-blogger'); 602 $this->import = get_settings('import-blogger'); 605 603 606 604 if ( false === $this->import ) { … … 616 614 } 617 615 //echo "Step $step."; 618 // wp_die('<pre>'.print_r($this->import,1).'</pre');616 //die('<pre>'.print_r($this->import,1).'</pre'); 619 617 switch ($step) { 620 618 case 0 : … … 650 648 } 651 649 die; 652 650 653 651 } else { 654 652 $this->greet(); … … 663 661 $blogger_import = new Blogger_Import(); 664 662 665 register_importer('blogger', __('Blogger and Blog*Spot'), __('Import <strong>posts and comments</strong> from yourBlogger account'), array ($blogger_import, 'start'));663 register_importer('blogger', 'Blogger', __('Import posts and comments from a Blogger account'), array ($blogger_import, 'start')); 666 664 667 665 ?>
Note: See TracChangeset
for help on using the changeset viewer.