Plugin Directory

Changeset 1605904


Ignore:
Timestamp:
03/01/2017 11:59:09 AM (9 years ago)
Author:
shahalom
Message:

Fix security issues and update the version of Delete Comments By Status plugin

Location:
delete-comments-by-status/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • delete-comments-by-status/trunk/admin/form-handler.php

    r1603497 r1605904  
    1212
    1313    public function update_options() {
    14         if ( ! isset($_POST['msbd_btn_confirm_comments_delete']) || $_POST['action']!='action-confirm-comments-delete' ) {
     14        if ( !isset($_POST['msbd_btn_confirm_comments_delete']) || $_POST['action']!='action-confirm-comments-delete' ) {
    1515            return;
    1616        }
     
    2929        $page_url = admin_url( 'admin.php?page=msbd-delete-comments' );
    3030
    31         $comment_statuses = explode(",", $_POST['msbd_comment_statuses']);
     31        $comment_statuses = explode(",", msbd_sanitization($_POST['msbd_comment_statuses']));
    3232        $filter="";
    3333        foreach($comment_statuses as $val) {
  • delete-comments-by-status/trunk/admin/main.php

    r1603497 r1605904  
    3636     */
    3737    public function plugin_pages() {
    38         $page       = isset($_GET['page']) ? $_GET['page'] : '';
    39         $id            = isset($_GET['id']) ? intval( $_GET['id'] ) : 0;
     38        $page = isset($_GET['page']) ? msbd_sanitization($_GET['page']) : '';
     39        $id = isset($_GET['id']) ? intval( msbd_sanitization($_GET['id']) ) : 0;
    4040       
    4141        $action     = 'dashboard';
    4242        if (isset($_POST['action'])) {
    43             $action = $_POST['action'];
     43            $action = msbd_sanitization($_POST['action']);
    4444        } elseif (isset($_GET['action'])) {
    45             $action = $_GET['action'];
     45            $action = msbd_sanitization($_GET['action']);
    4646        }
    4747
  • delete-comments-by-status/trunk/admin/views/confirm-delete.php

    r1603497 r1605904  
    1717        $total_comments_delete = 0;
    1818       
    19         $submitValues = isset($_POST['msbd_comnts_statuses']) ? $_POST['msbd_comnts_statuses'] : array();
     19        $submitValues = isset($_POST['msbd_comnts_statuses']) ? msbd_sanitization($_POST['msbd_comnts_statuses']) : array();
    2020        $comment_statuses = msbddelcom_comment_statuses();
    2121       
  • delete-comments-by-status/trunk/functions.php

    r1549808 r1605904  
    11<?php
     2if (!function_exists('msbd_sanitization')) {
     3    /*
     4     * @ $field_type = title, text, email, number, html, no_html, custom_html, html_js default text
     5     */
     6    function msbd_sanitization($data, $field_type='text', $oArray=array()) {       
     7       
     8        if( is_array($data) ) {
     9           
     10            if( empty($data) )
     11                return $data;
     12            else {
     13                foreach($data as $i=>$v) {
     14                    $data[$i] = msbd_sanitization($v, $field_type, $oArray);
     15                }
     16               
     17                return $data;
     18            }           
     19        }
     20
     21        $output = '';
     22
     23        switch($field_type) {
     24            case 'number':
     25                $output = sanitize_text_field($data);
     26                $output = intval($output);
     27                break;
     28           
     29            case 'boolean':
     30                $var_permitted_values = array('y', 'n', 'true', 'false', '1', '0', 'yes', 'no');
     31                $output = in_array($data, $var_permitted_values) ? $data : 0;//returned false if not valid
     32                break;
     33           
     34            case 'email':
     35                $output = sanitize_email($data);
     36                $output = is_email($output);//returned false if not valid
     37                break;
     38               
     39            case 'textarea':
     40                $output = esc_textarea($data);
     41                break;
     42           
     43            case 'html':                                         
     44                $output = wp_kses_post($data);
     45                break;
     46           
     47            case 'custom_html':                   
     48                $allowedTags = isset($oArray['allowedTags']) ? $oArray['allowedTags'] : "";                                       
     49                $output = wp_kses($data, $allowedTags);
     50                break;
     51           
     52            case 'no_html':                                       
     53                $output = strip_tags( $data );
     54                break;
     55           
     56           
     57            case 'html_js':
     58                $output = $data;
     59                break;
     60           
     61            case 'title':
     62                $output = sanitize_title($data);
     63                break;
     64           
     65            case 'text':
     66            default:
     67                $output = sanitize_text_field($data);
     68                break;
     69        }
     70
     71        return $output;
     72    }
     73}
     74
     75
    276function msbddelcom_comment_statuses() {
    377    return array(
    4                     '0' => 'pending',
    5                     'spam' => 'spam',
    6                     'trash' => 'trash',
    7                     '1' => 'approved',
    8                 );
     78        '0' => 'pending',
     79        'spam' => 'spam',
     80        'trash' => 'trash',
     81        '1' => 'approved',
     82    );
    983}
    1084
  • delete-comments-by-status/trunk/main.php

    r1603497 r1605904  
    44 * Plugin URI: http://microsolutionsbd.com/
    55 * Description: Plugin to delete all comments by selecting the status (pending, spam, trash, approved)
    6  * Version: 1.5.2
     6 * Version: 1.5.3
    77 * Author: Micro Solutions Bangladesh
    8  * Author URI: http://mcqacademy.com/author/shahalom/
     8 * Author URI: http://microsolutionsbd.com/
    99 * License: GPL2
    1010 * Text Domain: msbddelcom
  • delete-comments-by-status/trunk/readme.txt

    r1603497 r1605904  
    2828
    2929== Changelog ==
     30
     31= 1.5.3 =
     32
     33* Fix more security issues
    3034
    3135= 1.5.2 =
Note: See TracChangeset for help on using the changeset viewer.