Plugin Directory

Changeset 1917088


Ignore:
Timestamp:
07/30/2018 09:17:23 PM (7 years ago)
Author:
mindnl
Message:

added nonces and current_user_can() for security purpose

Location:
ad-buttons/tags/3.0
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ad-buttons/tags/3.0/adbuttons.php

    r1915633 r1917088  
    360360        echo $after_widget;
    361361    }
    362    
     362       
    363363    function ad_buttons_widget_control() {
    364364        $options = $newoptions = get_option('widget_adbuttons_cfg');
    365         if($_SERVER['REQUEST_METHOD'] == 'POST'){
    366             if ( !empty($_POST['ad_buttons_widget_submit']) ) {
     365        if($_SERVER['REQUEST_METHOD'] == 'POST' && current_user_can( 'manage_options' )) {
     366            // add a nonce check here
     367            //adbuttonsupdtitle
     368           
     369            if ( !empty($_POST['ad_buttons_widget_submit']) && wp_verify_nonce( $_POST['adbuttonsupdtitle'], 'adbuttons_updatewidgettitle' )) {
    367370                $newoptions['ab_title'] = sanitize_text_field( $_POST['ad_buttons_widget_title'] );
    368371            }
     
    373376        }
    374377        $title = esc_attr($options['ab_title']);
     378        // add a nonce creation here
    375379        ?>
    376380            <p><label for="ad_buttons_widget_title"><?php _e('Title:'); ?> <input class="widefat" id="ad_buttons_widget_title"
    377381            name="ad_buttons_widget_title" type="text" value="<?php echo esc_html( $title ); ?>" /></label></p>
     382            <?php wp_nonce_field( 'adbuttons_updatewidgettitle', 'adbuttonsupdtitle' ); ?>
    378383            <input type="hidden" id="ad_buttons_widget_submit" name="ad_buttons_widget_submit" value="1" /><br/>
    379384            That's all you can set here. All other options and ad controls can be found in the <strong>Ad Buttons</strong>
  • ad-buttons/tags/3.0/adbuttonsact.php

    r1915633 r1917088  
    6868
    6969// check if the form has been submitted and validate input
    70 if( $_SERVER['REQUEST_METHOD'] == 'POST' ){
     70if( $_SERVER['REQUEST_METHOD'] == 'POST' && current_user_can( 'manage_options' )){
    7171    if ( ! isset( $_POST['_abupd'] ) || ! wp_verify_nonce( $_POST['_abupd'], 'update-ad' )) {
    7272        print 'Sorry, your nonce did not verify.';
  • ad-buttons/tags/3.0/adbuttonsadmin.php

    r1915633 r1917088  
    3636
    3737// check if the form has been submitted and validate input
    38 if( $_SERVER['REQUEST_METHOD'] == 'POST' ){
     38if( $_SERVER['REQUEST_METHOD'] == 'POST' && current_user_can( 'manage_options' )){
    3939    if ( ! isset( $_POST['_abupd'] ) || ! wp_verify_nonce( $_POST['_abupd'], 'update-settings' )) {
    4040        print 'Sorry, your nonce did not verify.';
  • ad-buttons/tags/3.0/adbuttonsstats.php

    r1915633 r1917088  
    5555<p>
    5656<?php
    57 if ($cleanup === 1) {
    58    
     57if ($cleanup === 1 && wp_verify_nonce( $_REQUEST['adbuttonscleanup'], 'cleanupstats' ) && current_user_can( 'manage_options' )) {
     58
    5959    echo "cleaning up stats database...</br>";
    6060    // CLEANUP PROCEDURE
     
    8484
    8585if ($old_records > 0) {
    86     echo "Total old records: <b>";
    87     echo $old_records; 
    88     echo "</b> cleaning up old records will free up space in the database. The daily totals will still be available for viewing here.</br>";
    89     echo "<a class=\"button button-primary \" href=\"$nplink&cln=1\">clean up now</a>";
     86    echo 'Total old records: <b>'.$old_records.'</b> cleaning up old records will free up space in the database. The daily totals will still be available for viewing here.</br>';
     87    echo '<a class="button button-primary" href="'.esc_url( add_query_arg( array( 'cln' => '1', 'adbuttonscleanup' => wp_create_nonce('cleanupstats') ) ) ).'">clean up now</a>';
    9088}   
     89
    9190
    9291?> 
Note: See TracChangeset for help on using the changeset viewer.