Make WordPress Core

Changeset 5405


Ignore:
Timestamp:
05/07/2007 03:57:15 PM (19 years ago)
Author:
ryan
Message:

Add nonces to importers

Location:
branches/2.2/wp-admin
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/wp-admin/admin-functions.php

    r5289 r5405  
    20032003<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>">
    20042004<p>
     2005<?php wp_nonce_field('import-upload'); ?>
    20052006<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?> )
    20062007<input type="file" id="upload" name="import" size="25" />
  • branches/2.2/wp-admin/import/blogger.php

    r5087 r5405  
    744744        // Step 9: Congratulate the user
    745745        function congrats() {
     746                $blog = (int) $_GET['blog'];
    746747                echo '<h1>'.__('Congratulations!').'</h1><p>'.__('Now that you have imported your Blogger blog into WordPress, what are you going to do? Here are some suggestions:').'</p><ul><li>'.__('That was hard work! Take a break.').'</li>';
    747748                if ( count($this->import['blogs']) > 1 )
    748749                        echo '<li>'.__('In case you haven\'t done it already, you can import the posts from your other blogs:'). $this->show_blogs() . '</li>';
    749                 if ( $n = count($this->import['blogs'][$_GET['blog']]['newusers']) )
     750                if ( $n = count($this->import['blogs'][$blog]['newusers']) )
    750751                        echo '<li>'.sprintf(__('Go to <a href="%s" target="%s">Authors &amp; Users</a>, where you can modify the new user(s) 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.'), 'users.php', '_parent').'</li>';
    751752                echo '<li>'.__('For security, click the link below to reset this importer.').'</li>';
     
    766767                if ( isset( $_REQUEST['blog'] ) ) {
    767768                        $blog = is_array($_REQUEST['blog']) ? array_shift( array_keys( $_REQUEST['blog'] ) ) : $_REQUEST['blog'];
     769                        $blog = (int) $blog;
    768770                        $this->import_blog( $blog );
    769771                } elseif ( isset($_GET['token']) )
  • branches/2.2/wp-admin/import/dotclear.php

    r5087 r5405  
    148148                echo '<p>'.__('Your DotClear Configuration settings are as follows:').'</p>';
    149149                echo '<form action="admin.php?import=dotclear&amp;step=1" method="post">';
     150                wp_nonce_field('import-dotclear');
    150151                $this->db_form();
    151                 echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' &raquo;" /></p>';
     152                echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories &raquo;')).'" /></p>';
    152153                echo '</form></div>';
    153154        }
     
    559560
    560561                echo '<form action="admin.php?import=dotclear&amp;step=2" method="post">';
    561                 printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
     562                wp_nonce_field('import-dotclear');
     563                printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users')));
    562564                echo '</form>';
    563565
     
    571573
    572574                echo '<form action="admin.php?import=dotclear&amp;step=3" method="post">';
    573                 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
     575                wp_nonce_field('import-dotclear');
     576                printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts')));
    574577                echo '</form>';
    575578        }
     
    582585
    583586                echo '<form action="admin.php?import=dotclear&amp;step=4" method="post">';
    584                 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
     587                wp_nonce_field('import-dotclear');
     588                printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments')));
    585589                echo '</form>';
    586590        }
     
    593597
    594598                echo '<form action="admin.php?import=dotclear&amp;step=5" method="post">';
    595                 printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
     599                wp_nonce_field('import-dotclear');
     600                printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links')));
    596601                echo '</form>';
    597602        }
     
    605610
    606611                echo '<form action="admin.php?import=dotclear&amp;step=6" method="post">';
    607                 printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
     612                wp_nonce_field('import-dotclear');
     613                printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish')));
    608614                echo '</form>';
    609615        }
     
    668674                if ( $step > 0 )
    669675                {
     676                        check_admin_referer('import-dotclear');
     677
    670678                        if($_POST['dbuser'])
    671679                        {
    672680                                if(get_option('dcuser'))
    673681                                        delete_option('dcuser');
    674                                 add_option('dcuser',$_POST['dbuser']);
     682                                add_option('dcuser', sanitize_user($_POST['dbuser'], true));
    675683                        }
    676684                        if($_POST['dbpass'])
     
    678686                                if(get_option('dcpass'))
    679687                                        delete_option('dcpass');
    680                                 add_option('dcpass',$_POST['dbpass']);
     688                                add_option('dcpass', sanitize_user($_POST['dbpass'], true));
    681689                        }
    682690
     
    685693                                if(get_option('dcname'))
    686694                                        delete_option('dcname');
    687                                 add_option('dcname',$_POST['dbname']);
     695                                add_option('dcname', sanitize_user($_POST['dbname'], true));
    688696                        }
    689697                        if($_POST['dbhost'])
     
    691699                                if(get_option('dchost'))
    692700                                        delete_option('dchost');
    693                                 add_option('dchost',$_POST['dbhost']);
     701                                add_option('dchost', sanitize_user($_POST['dbhost'], true));
    694702                        }
    695703                        if($_POST['dccharset'])
     
    697705                                if(get_option('dccharset'))
    698706                                        delete_option('dccharset');
    699                                 add_option('dccharset',$_POST['dccharset']);
     707                                add_option('dccharset', sanitize_user($_POST['dccharset'], true));
    700708                        }
    701709                        if($_POST['dbprefix'])
     
    703711                                if(get_option('dcdbprefix'))
    704712                                        delete_option('dcdbprefix');
    705                                 add_option('dcdbprefix',$_POST['dbprefix']);
     713                                add_option('dcdbprefix', sanitize_user($_POST['dbprefix'], true));
    706714                        }
    707715
  • branches/2.2/wp-admin/import/greymatter.php

    r4953 r5405  
    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">
     
    8889
    8990                if (!chdir($archivespath))
    90                         wp_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                         wp_die(sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $gmpath));
     94                        wp_die(__("Wrong path, the path to the GM files does not exist on the server"));
     95
     96                $lastentry = (int) $lastentry;
    9497
    9598                $this->header();
     
    298301                                break;
    299302                        case 1:
     303                                check_admin_referer('import-greymatter');
    300304                                $this->import();
    301305                                break;
  • branches/2.2/wp-admin/import/livejournal.php

    r5087 r5405  
    154154                                break;
    155155                        case 1 :
     156                                check_admin_referer('import-upload');
    156157                                $this->import();
    157158                                break;
  • branches/2.2/wp-admin/import/mt.php

    r5087 r5405  
    148148                echo '<ol id="authors">';
    149149                echo '<form action="?import=mt&amp;step=2&amp;id=' . $this->id . '" method="post">';
     150                wp_nonce_field('import-mt');
    150151                $j = -1;
    151152                foreach ($authors as $author) {
     
    418419                                break;
    419420                        case 1 :
     421                                check_admin_referer('import-upload');
    420422                                $this->select_authors();
    421423                                break;
    422424                        case 2:
     425                                check_admin_referer('import-mt');
    423426                                $this->import();
    424427                                break;
  • branches/2.2/wp-admin/import/rss.php

    r4608 r5405  
    157157                                break;
    158158                        case 1 :
     159                                check_admin_referer('import-upload');
    159160                                $this->import();
    160161                                break;
  • branches/2.2/wp-admin/import/textpattern.php

    r4608 r5405  
    5757                echo '<p>'.__('Your Textpattern Configuration settings are as follows:').'</p>';
    5858                echo '<form action="admin.php?import=textpattern&amp;step=1" method="post">';
     59                wp_nonce_field('import-textpattern');
    5960                $this->db_form();
    60                 echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' &raquo;" /></p>';
     61                echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories &raquo;')).'" /></p>';
    6162                echo '</form>';
    6263                echo '</div>';
     
    484485
    485486                echo '<form action="admin.php?import=textpattern&amp;step=2" method="post">';
    486                 printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
     487                wp_nonce_field('import-textpattern');
     488                printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users')));
    487489                echo '</form>';
    488490
     
    496498
    497499                echo '<form action="admin.php?import=textpattern&amp;step=3" method="post">';
    498                 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
     500                wp_nonce_field('import-textpattern');
     501                printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts')));
    499502                echo '</form>';
    500503        }
     
    507510
    508511                echo '<form action="admin.php?import=textpattern&amp;step=4" method="post">';
    509                 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
     512                wp_nonce_field('import-textpattern');
     513                printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments')));
    510514                echo '</form>';
    511515        }
     
    518522
    519523                echo '<form action="admin.php?import=textpattern&amp;step=5" method="post">';
    520                 printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
     524                wp_nonce_field('import-textpattern');
     525                printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links')));
    521526                echo '</form>';
    522527        }
     
    530535
    531536                echo '<form action="admin.php?import=textpattern&amp;step=6" method="post">';
    532                 printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
     537                wp_nonce_field('import-textpattern');
     538                printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish')));
    533539                echo '</form>';
    534540        }
     
    591597                if ( $step > 0 )
    592598                {
     599                        check_admin_referer('import-textpattern');
     600
    593601                        if($_POST['dbuser'])
    594602                        {
    595603                                if(get_option('txpuser'))
    596604                                        delete_option('txpuser');
    597                                 add_option('txpuser',$_POST['dbuser']);
     605                                add_option('txpuser', sanitize_user($_POST['dbuser'], true));
    598606                        }
    599607                        if($_POST['dbpass'])
     
    601609                                if(get_option('txppass'))
    602610                                        delete_option('txppass');
    603                                 add_option('txppass',$_POST['dbpass']);
     611                                add_option('txppass',  sanitize_user($_POST['dbpass'], true));
    604612                        }
    605613
     
    608616                                if(get_option('txpname'))
    609617                                        delete_option('txpname');
    610                                 add_option('txpname',$_POST['dbname']);
     618                                add_option('txpname',  sanitize_user($_POST['dbname'], true));
    611619                        }
    612620                        if($_POST['dbhost'])
     
    614622                                if(get_option('txphost'))
    615623                                        delete_option('txphost');
    616                                 add_option('txphost',$_POST['dbhost']);
     624                                add_option('txphost',  sanitize_user($_POST['dbhost'], true));
    617625                        }
    618626                        if($_POST['dbprefix'])
     
    620628                                if(get_option('tpre'))
    621629                                        delete_option('tpre');
    622                                 add_option('tpre',$_POST['dbprefix']);
     630                                add_option('tpre',  sanitize_user($_POST['dbprefix']));
    623631                        }
    624632
  • branches/2.2/wp-admin/import/wordpress.php

    r5252 r5405  
    160160                echo '<ol id="authors">';
    161161                echo '<form action="?import=wordpress&amp;step=2&amp;id=' . $this->id . '" method="post">';
     162                wp_nonce_field('import-wordpress');
    162163                $j = -1;
    163164                foreach ($authors as $author) {
     
    364365                                break;
    365366                        case 1 :
     367                                check_admin_referer('import-upload');
    366368                                $this->select_authors();
    367369                                break;
    368370                        case 2:
     371                                check_admin_referer('import-wordpress');
    369372                                $this->import();
    370373                                break;
Note: See TracChangeset for help on using the changeset viewer.