当前位置: 首页>>代码示例>>PHP>>正文


PHP AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline方法代码示例

本文整理汇总了PHP中AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline方法的典型用法代码示例。如果您正苦于以下问题:PHP AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline方法的具体用法?PHP AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline怎么用?PHP AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AIOWPSecurity_Utility_IP的用法示例。


在下文中一共展示了AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render_tab1

    function render_tab1()
    {
        global $aio_wp_security;
        global $aiowps_feature_mgr;
        $result = 1;
        if (isset($_POST['aiowps_save_blacklist_settings'])) {
            $nonce = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce, 'aiowpsec-blacklist-settings-nonce')) {
                $aio_wp_security->debug_logger->log_debug("Nonce check failed for save blacklist settings!", 4);
                die(__('Nonce check failed for save blacklist settings!', 'all-in-one-wp-security-and-firewall'));
            }
            if (isset($_POST["aiowps_enable_blacklisting"]) && empty($_POST['aiowps_banned_ip_addresses']) && empty($_POST['aiowps_banned_user_agents'])) {
                $this->show_msg_error('You must submit at least one IP address or one User Agent value or both!', 'all-in-one-wp-security-and-firewall');
            } else {
                if (!empty($_POST['aiowps_banned_ip_addresses'])) {
                    $ip_addresses = $_POST['aiowps_banned_ip_addresses'];
                    $ip_list_array = AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline($ip_addresses);
                    $payload = AIOWPSecurity_Utility_IP::validate_ip_list($ip_list_array, 'blacklist');
                    if ($payload[0] == 1) {
                        //success case
                        $result = 1;
                        $list = $payload[1];
                        $banned_ip_data = implode(PHP_EOL, $list);
                        $aio_wp_security->configs->set_value('aiowps_banned_ip_addresses', $banned_ip_data);
                        $_POST['aiowps_banned_ip_addresses'] = '';
                        //Clear the post variable for the banned address list
                    } else {
                        $result = -1;
                        $error_msg = $payload[1][0];
                        $this->show_msg_error($error_msg);
                    }
                } else {
                    $aio_wp_security->configs->set_value('aiowps_banned_ip_addresses', '');
                    //Clear the IP address config value
                }
                if (!empty($_POST['aiowps_banned_user_agents'])) {
                    $result = $result * $this->validate_user_agent_list();
                } else {
                    //clear the user agent list
                    $aio_wp_security->configs->set_value('aiowps_banned_user_agents', '');
                }
                if ($result == 1) {
                    $aio_wp_security->configs->set_value('aiowps_enable_blacklisting', isset($_POST["aiowps_enable_blacklisting"]) ? '1' : '');
                    $aio_wp_security->configs->save_config();
                    //Save the configuration
                    //Recalculate points after the feature status/options have been altered
                    $aiowps_feature_mgr->check_feature_status_and_recalculate_points();
                    $this->show_msg_settings_updated();
                    $write_result = AIOWPSecurity_Utility_Htaccess::write_to_htaccess();
                    //now let's write to the .htaccess file
                    if (!$write_result) {
                        $this->show_msg_error(__('The plugin was unable to write to the .htaccess file. Please edit file manually.', 'all-in-one-wp-security-and-firewall'));
                        $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_Blacklist_Menu - The plugin was unable to write to the .htaccess file.");
                    }
                }
            }
        }
        ?>
        <h2><?php 
        _e('Ban IPs or User Agents', 'all-in-one-wp-security-and-firewall');
        ?>
</h2>
        <div class="aio_blue_box">
            <?php 
        echo '<p>' . __('The All In One WP Security Blacklist feature gives you the option of banning certain host IP addresses or ranges and also user agents.', 'all-in-one-wp-security-and-firewall') . '
            <br />' . __('This feature will deny total site access for users which have IP addresses or user agents matching those which you have configured in the settings below.', 'all-in-one-wp-security-and-firewall') . '
            <br />' . __('The plugin achieves this by making appropriate modifications to your .htaccess file.', 'all-in-one-wp-security-and-firewall') . '
            <br />' . __('By blocking people via the .htaccess file your are using the most secure first line of defence which denies all access to blacklisted visitors as soon as they hit your hosting server.', 'all-in-one-wp-security-and-firewall') . '
            </p>';
        ?>
        </div>
        <div class="aio_grey_box">
            <?php 
        $addon_link = '<strong><a href="http://www.site-scanners.com/country-blocking-addon/" target="_blank">Country Blocking Addon</a></strong>';
        $info_msg = sprintf(__('You may also be interested in our %s.', 'all-in-one-wp-security-and-firewall'), $addon_link);
        $info_msg2 = __('This addon allows you to automatically block IP addresses based on their country of origin.', 'all-in-one-wp-security-and-firewall');
        echo '<p>' . $info_msg . '<br />' . $info_msg2 . '</p>';
        ?>
        </div>

        <div class="postbox">
        <h3 class="hndle"><label for="title"><?php 
        _e('IP Hosts and User Agent Blacklist Settings', 'all-in-one-wp-security-and-firewall');
        ?>
</label></h3>
        <div class="inside">
        <?php 
        //Display security info badge
        global $aiowps_feature_mgr;
        $aiowps_feature_mgr->output_feature_details_badge("blacklist-manager-ip-user-agent-blacklisting");
        ?>
    
        <form action="" method="POST">
        <?php 
        wp_nonce_field('aiowpsec-blacklist-settings-nonce');
        ?>
        <div class="aio_orange_box">
            <p>
            <?php 
        $read_link = '<a href="https://www.tipsandtricks-hq.com/wordpress-security-and-firewall-plugin#advanced_features_note" target="_blank">must read this message</a>';
//.........这里部分代码省略.........
开发者ID:crazyyy,项目名称:bessarabia,代码行数:101,代码来源:wp-security-blacklist-menu.php

示例2: blacklist_ip_address

 function blacklist_ip_address($entries)
 {
     global $wpdb, $aio_wp_security;
     $bl_ip_addresses = $aio_wp_security->configs->get_value('aiowps_banned_ip_addresses');
     //get the currently saved blacklisted IPs
     $ip_list_array = AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline($bl_ip_addresses);
     if (is_array($entries)) {
         //Get the selected IP addresses
         $id_list = "(" . implode(",", $entries) . ")";
         //Create comma separate list for DB operation
         $events_table = AIOWPSEC_TBL_EVENTS;
         $query = "SELECT ip_or_host FROM {$events_table} WHERE ID IN " . $id_list;
         $results = $wpdb->get_col($query);
         if (empty($results)) {
             AIOWPSecurity_Admin_Menu::show_msg_error_st(__('Could not process the request because the IP addresses for the selected entries could not be found!', 'WPS'));
             return false;
         } else {
             foreach ($results as $entry) {
                 $ip_list_array[] = $entry;
             }
         }
     } elseif ($entries != NULL) {
         //Blacklist single record
         $ip_list_array[] = $entries;
     }
     $payload = AIOWPSecurity_Utility_IP::validate_ip_list($ip_list_array, 'blacklist');
     if ($payload[0] == 1) {
         //success case
         $result = 1;
         $list = $payload[1];
         $banned_ip_data = implode(PHP_EOL, $list);
         $aio_wp_security->configs->set_value('aiowps_enable_blacklisting', '1');
         //Force blacklist feature to be enabled
         $aio_wp_security->configs->set_value('aiowps_banned_ip_addresses', $banned_ip_data);
         $aio_wp_security->configs->save_config();
         //Save the configuration
         $write_result = AIOWPSecurity_Utility_Htaccess::write_to_htaccess();
         //now let's write to the .htaccess file
         if ($write_result == -1) {
             AIOWPSecurity_Admin_Menu::show_msg_error_st(__('The plugin was unable to write to the .htaccess file. Please edit file manually.', 'aiowpsecurity'));
             $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_Blacklist_Menu - The plugin was unable to write to the .htaccess file.");
         } else {
             AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected IP addresses have been added to the blacklist and will be permanently blocked!', 'WPS'));
         }
     } else {
         $result = -1;
         $error_msg = $payload[1][0];
         AIOWPSecurity_Admin_Menu::show_msg_error_st($error_msg);
     }
 }
开发者ID:Rudchyk,项目名称:wp-framework,代码行数:50,代码来源:wp-security-list-404.php

示例3: render_tab4

    function render_tab4()
    {
        global $aio_wp_security;
        global $aiowps_feature_mgr;
        $result = 1;
        $your_ip_address = AIOWPSecurity_Utility_IP::get_user_ip_address();
        if (isset($_POST['aiowps_save_whitelist_settings'])) {
            $nonce = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce, 'aiowpsec-whitelist-settings-nonce')) {
                $aio_wp_security->debug_logger->log_debug("Nonce check failed for save whitelist settings!", 4);
                die(__('Nonce check failed for save whitelist settings!', 'all-in-one-wp-security-and-firewall'));
            }
            if (isset($_POST["aiowps_enable_whitelisting"]) && empty($_POST['aiowps_allowed_ip_addresses'])) {
                $this->show_msg_error('You must submit at least one IP address!', 'all-in-one-wp-security-and-firewall');
            } else {
                if (!empty($_POST['aiowps_allowed_ip_addresses'])) {
                    $ip_addresses = $_POST['aiowps_allowed_ip_addresses'];
                    $ip_list_array = AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline($ip_addresses);
                    $payload = AIOWPSecurity_Utility_IP::validate_ip_list($ip_list_array, 'whitelist');
                    if ($payload[0] == 1) {
                        //success case
                        $result = 1;
                        $list = $payload[1];
                        $whitelist_ip_data = implode(PHP_EOL, $list);
                        $aio_wp_security->configs->set_value('aiowps_allowed_ip_addresses', $whitelist_ip_data);
                        $_POST['aiowps_allowed_ip_addresses'] = '';
                        //Clear the post variable for the banned address list
                    } else {
                        $result = -1;
                        $error_msg = htmlspecialchars($payload[1][0]);
                        $this->show_msg_error($error_msg);
                    }
                } else {
                    $aio_wp_security->configs->set_value('aiowps_allowed_ip_addresses', '');
                    //Clear the IP address config value
                }
                if ($result == 1) {
                    $aio_wp_security->configs->set_value('aiowps_enable_whitelisting', isset($_POST["aiowps_enable_whitelisting"]) ? '1' : '');
                    $aio_wp_security->configs->save_config();
                    //Save the configuration
                    //Recalculate points after the feature status/options have been altered
                    $aiowps_feature_mgr->check_feature_status_and_recalculate_points();
                    $this->show_msg_settings_updated();
                    $write_result = AIOWPSecurity_Utility_Htaccess::write_to_htaccess();
                    //now let's write to the .htaccess file
                    if (!$write_result) {
                        $this->show_msg_error(__('The plugin was unable to write to the .htaccess file. Please edit file manually.', 'all-in-one-wp-security-and-firewall'));
                        $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_whitelist_Menu - The plugin was unable to write to the .htaccess file.");
                    }
                }
            }
        }
        ?>
        <h2><?php 
        _e('Login Whitelist', 'all-in-one-wp-security-and-firewall');
        ?>
</h2>
        <div class="aio_blue_box">
            <?php 
        echo '<p>' . __('The All In One WP Security Whitelist feature gives you the option of only allowing certain IP addresses or ranges to have access to your WordPress login page.', 'all-in-one-wp-security-and-firewall') . '
            <br />' . __('This feature will deny login access for all IP addresses which are not in your whitelist as configured in the settings below.', 'all-in-one-wp-security-and-firewall') . '
            <br />' . __('The plugin achieves this by writing the appropriate directives to your .htaccess file.', 'all-in-one-wp-security-and-firewall') . '
            <br />' . __('By allowing/blocking IP addresses via the .htaccess file your are using the most secure first line of defence because login access will only be granted to whitelisted IP addresses and other addresses will be blocked as soon as they try to access your login page.', 'all-in-one-wp-security-and-firewall') . '
            </p>';
        ?>
        </div>
        <div class="aio_yellow_box">
            <?php 
        $brute_force_login_feature_link = '<a href="admin.php?page=' . AIOWPSEC_BRUTE_FORCE_MENU_SLUG . '&tab=tab2" target="_blank">Cookie-Based Brute Force Login Prevention</a>';
        $rename_login_feature_link = '<a href="admin.php?page=' . AIOWPSEC_BRUTE_FORCE_MENU_SLUG . '&tab=tab1" target="_blank">Rename Login Page</a>';
        echo '<p>' . sprintf(__('Attention: If in addition to enabling the white list feature, you also have one of the %s or %s features enabled, <strong>you will still need to use your secret word or special slug in the URL when trying to access your WordPress login page</strong>.', 'all-in-one-wp-security-and-firewall'), $brute_force_login_feature_link, $rename_login_feature_link) . '</p>
            <p>' . __('These features are NOT functionally related. Having both of them enabled on your site means you are creating 2 layers of security.', 'all-in-one-wp-security-and-firewall') . '</p>';
        ?>
        </div>

        <div class="postbox">
        <h3 class="hndle"><label for="title"><?php 
        _e('Login IP Whitelist Settings', 'all-in-one-wp-security-and-firewall');
        ?>
</label></h3>
        <div class="inside">
        <?php 
        //Display security info badge
        global $aiowps_feature_mgr;
        $aiowps_feature_mgr->output_feature_details_badge("whitelist-manager-ip-login-whitelisting");
        ?>
    
        <form action="" method="POST">
        <?php 
        wp_nonce_field('aiowpsec-whitelist-settings-nonce');
        ?>
            
        <table class="form-table">
            <tr valign="top">
                <th scope="row"><?php 
        _e('Enable IP Whitelisting', 'all-in-one-wp-security-and-firewall');
        ?>
:</th>
                <td>
                <input name="aiowps_enable_whitelisting" type="checkbox"<?php 
//.........这里部分代码省略.........
开发者ID:crazyyy,项目名称:bessarabia,代码行数:101,代码来源:wp-security-brute-force-menu.php


注:本文中的AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。