Plugin Directory

Changeset 2118892


Ignore:
Timestamp:
07/07/2019 01:16:43 PM (7 years ago)
Author:
kunalnagar
Message:

Publishing version: 3.2.11

Location:
custom-404-pro/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • custom-404-pro/trunk/README.md

    r2113409 r2118892  
    44
    55Override the default 404 page with **any page** from the Admin Panel or a **Custom URL**.
    6 
    7 **UPDATE [June 26, 2019]**: This plugin is currently taken off the [WordPress plugin repository](https://wordpress.org/plugins/custom-404-pro/) due to a few security loopholes. I am currently working on the highest priority to fix them and work with the WordPress Plugin team to get it back up. I apologize for any inconvenience caused to all of you and I appreciate your understanding in this matter. Thanks!
    86
    97As always, if you do like the plugin, please take a minute and give it a rating. Thanks!
  • custom-404-pro/trunk/admin/AdminClass.php

    r2113409 r2118892  
    149149    public function custom_404_pro_redirect() {
    150150        global $wpdb;
    151         if(current_user_can('administrator')) {
    152             if ( is_404() ) {
    153                 $sql                     = 'SELECT * FROM ' . $this->helpers->table_options;
    154                 $sql_result              = $wpdb->get_results( $sql );
    155                 $row_mode                = $sql_result[0];
    156                 $row_mode_page           = $sql_result[1];
    157                 $row_mode_url            = $sql_result[2];
    158                 $row_send_email          = $sql_result[3];
    159                 $row_logging_enabled     = $sql_result[4];
    160                 $row_redirect_error_code = $sql_result[5];
    161                 if ( $row_logging_enabled->value ) {
    162                     self::custom_404_pro_log( $row_send_email->value );
    163                 }
    164                 if ( $row_mode->value === 'page' ) {
    165                     $page = get_post( $row_mode_page->value );
    166                     wp_redirect( $page->guid, $row_redirect_error_code->value );
    167                 } elseif ( $row_mode->value === 'url' ) {
    168                     wp_redirect( $row_mode_url->value, $row_redirect_error_code->value );
    169                 }
     151        if ( is_404() ) {
     152            $sql                     = 'SELECT * FROM ' . $this->helpers->table_options;
     153            $sql_result              = $wpdb->get_results( $sql );
     154            $row_mode                = $sql_result[0];
     155            $row_mode_page           = $sql_result[1];
     156            $row_mode_url            = $sql_result[2];
     157            $row_send_email          = $sql_result[3];
     158            $row_logging_enabled     = $sql_result[4];
     159            $row_redirect_error_code = $sql_result[5];
     160            if ( $row_logging_enabled->value ) {
     161                self::custom_404_pro_log( $row_send_email->value );
     162            }
     163            if ( $row_mode->value === 'page' ) {
     164                $page = get_post( $row_mode_page->value );
     165                wp_redirect( $page->guid, $row_redirect_error_code->value );
     166            } elseif ( $row_mode->value === 'url' ) {
     167                wp_redirect( $row_mode_url->value, $row_redirect_error_code->value );
    170168            }
    171169        }
     
    174172    private function custom_404_pro_log( $is_email ) {
    175173        global $wpdb;
    176         if(current_user_can('administrator')) {
    177             if ( ! $this->helpers->is_option( 'log_ip' ) ) {
    178                 $this->helpers->insert_option( 'log_ip', true );
    179             }
    180             if ( empty( $this->helpers->get_option( 'log_ip' ) ) ) {
    181                 $ip = 'N/A';
     174        if ( ! $this->helpers->is_option( 'log_ip' ) ) {
     175            $this->helpers->insert_option( 'log_ip', true );
     176        }
     177        if ( empty( $this->helpers->get_option( 'log_ip' ) ) ) {
     178            $ip = 'N/A';
     179        } else {
     180            if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
     181                $ip = $_SERVER['HTTP_CLIENT_IP'];
     182            } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
     183                $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    182184            } else {
    183                 if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
    184                     $ip = $_SERVER['HTTP_CLIENT_IP'];
    185                 } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
    186                     $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    187                 } else {
    188                     $ip = $_SERVER['REMOTE_ADDR'];
    189                 }
    190             }
    191             $path    = $_SERVER['REQUEST_URI'];
    192             $referer = '';
    193             if ( array_key_exists( 'HTTP_REFERER', $_SERVER ) ) {
    194                 $referer = $_SERVER['HTTP_REFERER'];
    195             }
    196             $user_agent = $_SERVER['HTTP_USER_AGENT'];
    197             $sql_save   = 'INSERT INTO ' . $this->helpers->table_logs . " (ip, path, referer, user_agent) VALUES ('$ip', '$path', '$referer', '$user_agent')";
    198             $wpdb->query( $sql_save );
    199             if ( ! empty( $is_email ) ) {
    200                 self::custom_404_pro_send_mail( $ip, $path, $referer, $user_agent );
    201             }
     185                $ip = $_SERVER['REMOTE_ADDR'];
     186            }
     187        }
     188        $path    = $_SERVER['REQUEST_URI'];
     189        $referer = '';
     190        if ( array_key_exists( 'HTTP_REFERER', $_SERVER ) ) {
     191            $referer = $_SERVER['HTTP_REFERER'];
     192        }
     193        $user_agent = $_SERVER['HTTP_USER_AGENT'];
     194        $sql_save   = 'INSERT INTO ' . $this->helpers->table_logs . " (ip, path, referer, user_agent) VALUES ('$ip', '$path', '$referer', '$user_agent')";
     195        $wpdb->query( $sql_save );
     196        if ( ! empty( $is_email ) ) {
     197            self::custom_404_pro_send_mail( $ip, $path, $referer, $user_agent );
    202198        }
    203199    }
    204200
    205201    private function custom_404_pro_send_mail( $ip, $path, $referer, $user_agent ) {
    206         if(current_user_can('administrator')) {
    207             $admin_email = get_option( 'admin_email' );
    208             if ( is_multisite() ) {
    209                 global $blog_id;
    210                 $current_blog_details = get_blog_details( array( 'blog_id' => $blog_id ) );
    211                 $current_site_name    = $current_blog_details->blogname;
    212             } else {
    213                 $current_site_name = get_bloginfo( 'name' );
    214             }
    215             $headers[] = 'From: Site Admin <' . $admin_email . '>' . "\r\n";
    216             $headers[] = 'Content-Type: text/html; charset=UTF-8';
    217             $message   = '<p>Here are the 404 Log Details:</p>';
    218             $message  .= '<table>';
    219             $message  .= '<tr>';
    220             $message  .= '<th>Site</th>';
    221             $message  .= '<td>' . $current_site_name . '</td>';
    222             $message  .= '</tr>';
    223             $message  .= '<tr>';
    224             $message  .= '<th>User IP</th>';
    225             $message  .= '<td>' . $ip . '</td>';
    226             $message  .= '</tr>';
    227             $message  .= '<tr>';
    228             $message  .= '<th>404 Path</th>';
    229             $message  .= '<td>' . $path . '</td>';
    230             $message  .= '</tr>';
    231             $message  .= '<tr>';
    232             $message  .= '<th>Referer</th>';
    233             $message  .= '<td>' . $referer . '</td>';
    234             $message  .= '</tr>';
    235             $message  .= '<tr>';
    236             $message  .= '<th>User Agent</th>';
    237             $message  .= '<td>' . $user_agent . '</td>';
    238             $message  .= '</tr>';
    239             $message  .= '</table>';
    240             $is_sent   = wp_mail(
    241                 $admin_email,
    242                 '404 Error on Site',
    243                 $message,
    244                 $headers
    245             );
    246         }
     202        $admin_email = get_option( 'admin_email' );
     203        if ( is_multisite() ) {
     204            global $blog_id;
     205            $current_blog_details = get_blog_details( array( 'blog_id' => $blog_id ) );
     206            $current_site_name    = $current_blog_details->blogname;
     207        } else {
     208            $current_site_name = get_bloginfo( 'name' );
     209        }
     210        $headers[] = 'From: Site Admin <' . $admin_email . '>' . "\r\n";
     211        $headers[] = 'Content-Type: text/html; charset=UTF-8';
     212        $message   = '<p>Here are the 404 Log Details:</p>';
     213        $message  .= '<table>';
     214        $message  .= '<tr>';
     215        $message  .= '<th>Site</th>';
     216        $message  .= '<td>' . $current_site_name . '</td>';
     217        $message  .= '</tr>';
     218        $message  .= '<tr>';
     219        $message  .= '<th>User IP</th>';
     220        $message  .= '<td>' . $ip . '</td>';
     221        $message  .= '</tr>';
     222        $message  .= '<tr>';
     223        $message  .= '<th>404 Path</th>';
     224        $message  .= '<td>' . $path . '</td>';
     225        $message  .= '</tr>';
     226        $message  .= '<tr>';
     227        $message  .= '<th>Referer</th>';
     228        $message  .= '<td>' . $referer . '</td>';
     229        $message  .= '</tr>';
     230        $message  .= '<tr>';
     231        $message  .= '<th>User Agent</th>';
     232        $message  .= '<td>' . $user_agent . '</td>';
     233        $message  .= '</tr>';
     234        $message  .= '</table>';
     235        $is_sent   = wp_mail(
     236            $admin_email,
     237            '404 Error on Site',
     238            $message,
     239            $headers
     240        );
    247241    }
    248242
  • custom-404-pro/trunk/custom-404-pro.php

    r2113409 r2118892  
    55Plugin URI: https://wordpress.org/plugins/custom-404-pro/
    66Description: Override the default 404 page with any page or a custom URL from the Admin Panel.
    7 Version: 3.2.10
     7Version: 3.2.11
    88Author: Kunal Nagar
    99Author URI: https://kunalnagar.in
  • custom-404-pro/trunk/readme.txt

    r2113409 r2118892  
    55Requires at least: 3.0.1
    66Tested up to: 5.2
    7 Stable tag: 3.2.10
     7Stable tag: 3.2.11
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4343
    4444== Changelog ==
     45
     46= 3.2.11 =
     47* Fix Redirect Bug
    4548
    4649= 3.2.10 =
Note: See TracChangeset for help on using the changeset viewer.