Plugin Directory

Changeset 2705068


Ignore:
Timestamp:
04/05/2022 12:27:06 PM (3 years ago)
Author:
isaumya
Message:

Adding nonce support for deletion of banned users

Location:
ad-invalid-click-protector/trunk/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ad-invalid-click-protector/trunk/inc/admin_setup.php

    r2656496 r2705068  
    523523            $bannedUserTableOBJ = new AICP_BANNED_USER_TABLE();
    524524            $aicpOBJ = new AICP();
    525             if( 'delete'=== $bannedUserTableOBJ->current_action() ) {
    526                 global $wpdb;
    527                 $fetchedID = $_REQUEST['id'];
    528                 if( is_array( $fetchedID ) ) { // for bulk operation arry will return
    529                     $selectedID = implode( ',', array_fill( 0, count( $fetchedID ), '%d' ) );
    530                 } else { //for singel delete just the id will return
    531                             $selectedID = '%d';
    532                 }
    533                 if( empty( $selectedID ) ) {
    534                     $this->delete_notice( false );
    535                 } else {
    536                     $query = $wpdb->prepare(
    537                                 "DELETE FROM {$aicpOBJ->table_name} WHERE {$aicpOBJ->table_name}.id IN ($selectedID)",
    538                                 $fetchedID
    539                             );
    540                     $wpdb->query( $query );
    541                     $this->delete_notice( true );
    542                 }
    543             }
    544             /* End of handelling the deletion process */
    545             /* Now it's time to show our data */
     525            if( ( 'delete'=== $bannedUserTableOBJ->current_action() ) && isset( $_REQUEST['nonce'] ) && wp_verify_nonce( $_REQUEST['nonce'], 'delete_banned_user' ) ) {
     526                global $wpdb;
     527                $fetchedID = $_REQUEST['id'];
     528                if( is_array( $fetchedID ) ) { // for bulk operation arry will return
     529                    $selectedID = implode( ',', array_fill( 0, count( $fetchedID ), '%d' ) );
     530                } else { //for singel delete just the id will return
     531                    $selectedID = '%d';
     532                }
     533                if( empty( $selectedID ) ) {
     534                    $this->delete_notice( false );
     535                } else {
     536                    $query = $wpdb->prepare(
     537                        "DELETE FROM {$aicpOBJ->table_name} WHERE {$aicpOBJ->table_name}.id IN ($selectedID)",
     538                        $fetchedID
     539                    );
     540                    $wpdb->query( $query );
     541            $this->delete_notice( true );
     542                }
     543            }
     544            /* End of handelling the deletion process */
     545            /* Now it's time to show our data */
    546546            ?>
    547547            <div class="wrap">
  • ad-invalid-click-protector/trunk/inc/banned_user_table.php

    r1565011 r2705068  
    3434        public function column_ip( $item ) {
    3535            $actions = array(
    36                 'delete'    => sprintf( '<a class="aicp_delete" href="?page=%s&action=%s&id=%s">Delete</a>', $_REQUEST['page'], 'delete', $item->id ),
     36                'delete'    => sprintf( '<a class="aicp_delete" href="?page=%s&action=%s&id=%s&nonce=%s">Delete</a>', $_REQUEST['page'], 'delete', $item->id, wp_create_nonce( 'delete_banned_user' ) ),
    3737            );
    3838
Note: See TracChangeset for help on using the changeset viewer.