Make WordPress Core


Ignore:
Timestamp:
05/07/2007 04:10:20 PM (19 years ago)
Author:
ryan
Message:

Add nonces to importers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/wp-admin/import/greymatter.php

    r4239 r5406  
    77        function header() {
    88                echo '<div class="wrap">';
    9                 echo '<h2>'.__('Import Greymatter').'</h2>';
     9                echo '<h2>'.__('Import GreyMatter').'</h2>';
    1010        }
    1111
    … …  
    3535<input type="hidden" name="import" value="greymatter" />
    3636<input type="hidden" name="step" value="1" />
     37<?php wp_nonce_field('import-greymatter'); ?>
    3738<h3><?php _e('Second step: GreyMatter details:') ?></h3>
    3839<p><table cellpadding="0">
    … …  
    6768                return($string);
    6869        }
    69        
     70
    7071        function import() {
    7172                global $wpdb;
    72        
     73
    7374                $wpvarstoreset = array('gmpath', 'archivespath', 'lastentry');
    7475                for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    … …  
    8889
    8990                if (!chdir($archivespath))
    90                         die(sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $archivespath));
     91                        wp_die(__("Wrong path, the path to the GM entries does not exist on the server"));
    9192
    9293                if (!chdir($gmpath))
    93                         die(sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $gmpath));
    94                        
     94                        wp_die(__("Wrong path, the path to the GM files does not exist on the server"));
     95
     96                $lastentry = (int) $lastentry;
     97
    9598                $this->header();
    9699?>
    … …  
    129132                $user_id = wp_insert_user($user_info);
    130133                $this->gmnames[$userdata[0]] = $user_id;
    131                
     134
    132135                printf('<li>'.__('user %s...').' <strong>'.__('Done').'</strong></li>', "<em>$user_login</em>");
    133136        }
    … …  
    137140
    138141        chdir($archivespath);
    139        
     142
    140143        for($i = 0; $i <= $lastentry; $i = $i + 1) {
    141                
     144
    142145                $entryfile = "";
    143                
     146
    144147                if ($i<10000000) {
    145148                        $entryfile .= "0";
    … …  
    195198                        $comment_status = 'open';
    196199                        $ping_status = 'closed';
    197                        
     200
    198201                        if ($post_ID = post_exists($post_title, '', $post_date)) {
    199202                                echo ' ';
    … …  
    214217                                        $user_url=$wpdb->escape("");
    215218                                        $user_joindate=$wpdb->escape($user_joindate);
    216                                        
     219
    217220                                        $user_info = array("user_login"=>$user_login, "user_pass"=>$pass1, "user_nickname"=>$user_nickname, "user_email"=>$user_email, "user_url"=>$user_url, "user_ip"=>$user_ip, "user_domain"=>$user_domain, "user_browser"=>$user_browser, "dateYMDhour"=>$user_joindate, "user_level"=>0, "user_idmode"=>"nickname");
    218221                                        $user_id = wp_insert_user($user_info);
    219222                                        $this->gmnames[$postinfo[1]] = $user_id;
    220                                        
     223
    221224                                        echo ': ';
    222225                                        printf(__('registered deleted user %s at level 0 '), "<em>$user_login</em>");
    223226                                }
    224                        
     227
    225228                                if (array_key_exists($postinfo[1], $this->gmnames)) {
    226229                                        $post_author = $this->gmnames[$postinfo[1]];
    … …  
    228231                                        $post_author = $user_id;
    229232                                }
    230                        
     233
    231234                                $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');
    232235                                $post_ID = wp_insert_post($postdata);
    … …  
    282285</ul><strong><?php _e('Done') ?></strong></li></ul>
    283286<p>&nbsp;</p>
    284 <p><?php _e('Completed Greymatter import!') ?></p>
     287<p><?php _e('Completed GreyMatter import!') ?></p>
    285288<?php
    286289        $this->footer();
    … …  
    298301                                break;
    299302                        case 1:
     303                                check_admin_referer('import-greymatter');
    300304                                $this->import();
    301305                                break;
    … …  
    304308
    305309        function GM_Import() {
    306                 // Nothing.     
     310                // Nothing.
    307311        }
    308312}
    … …  
    310314$gm_import = new GM_Import();
    311315
    312 register_importer('greymatter', __('Greymatter'), __('Import posts and comments from your Greymatter blog'), array ($gm_import, 'dispatch'));
     316register_importer('greymatter', __('GreyMatter'), __('Import users, posts, and comments from a Greymatter blog'), array ($gm_import, 'dispatch'));
    313317?>
Note: See TracChangeset for help on using the changeset viewer.