Пример #1
0
 public static function set_hit_count($fix_count = false)
 {
     global $iwp_mmb_core;
     if ($fix_count || !is_admin() && !IWP_MMB_Stats::is_bot()) {
         $date = date('Y-m-d');
         $iwp_client_user_hit_count = (array) get_option('iwp_client_user_hit_count');
         if (!$iwp_client_user_hit_count) {
             $iwp_client_user_hit_count[$date] = 1;
             update_option('iwp_client_user_hit_count', $iwp_client_user_hit_count);
         } else {
             $dated_keys = array_keys($iwp_client_user_hit_count);
             $last_visit_date = $dated_keys[count($dated_keys) - 1];
             $days = intval((strtotime($date) - strtotime($last_visit_date)) / 60 / 60 / 24);
             if ($days > 1) {
                 $date_to_add = date('Y-m-d', strtotime($last_visit_date));
                 for ($i = 1; $i < $days; $i++) {
                     if (count($iwp_client_user_hit_count) > 14) {
                         $shifted = @array_shift($iwp_client_user_hit_count);
                     }
                     $next_key = strtotime('+1 day', strtotime($date_to_add));
                     if ($next_key == $date) {
                         break;
                     } else {
                         $iwp_client_user_hit_count[$next_key] = 0;
                     }
                 }
             }
             if (!isset($iwp_client_user_hit_count[$date])) {
                 $iwp_client_user_hit_count[$date] = 0;
             }
             if (!$fix_count) {
                 $iwp_client_user_hit_count[$date] = (int) $iwp_client_user_hit_count[$date] + 1;
             }
             if (count($iwp_client_user_hit_count) > 14) {
                 $shifted = @array_shift($iwp_client_user_hit_count);
             }
             update_option('iwp_client_user_hit_count', $iwp_client_user_hit_count);
         }
     }
 }
Пример #2
0
 function iwp_mmb_parse_request()
 {
     if (!isset($HTTP_RAW_POST_DATA)) {
         $HTTP_RAW_POST_DATA = file_get_contents('php://input');
     }
     ob_start();
     global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
     $data = base64_decode($HTTP_RAW_POST_DATA);
     if ($data) {
         //$num = @extract(unserialize($data));
         $unserialized_data = unserialize($data);
         if (isset($unserialized_data['params'])) {
             $unserialized_data['params'] = iwp_mmb_filter_params($unserialized_data['params']);
         }
         $iwp_action = $unserialized_data['iwp_action'];
         $params = $unserialized_data['params'];
         $id = $unserialized_data['id'];
         $signature = $unserialized_data['signature'];
     }
     if (isset($iwp_action)) {
         if (!defined('IWP_AUTHORISED_CALL')) {
             define('IWP_AUTHORISED_CALL', 1);
         }
         if (function_exists('register_shutdown_function')) {
             register_shutdown_function("iwp_mmb_shutdown");
         }
         $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'] = microtime(1);
         error_reporting(E_ALL ^ E_NOTICE);
         @ini_set("display_errors", 1);
         $action = $iwp_action;
         $_wp_using_ext_object_cache = false;
         @set_time_limit(600);
         if (!$iwp_mmb_core->check_if_user_exists($params['username'])) {
             iwp_mmb_response('Username <b>' . $params['username'] . '</b> does not have administrative access. Enter the correct username in the site options.', false);
         }
         if ($action == 'add_site') {
             iwp_mmb_add_site($params);
             iwp_mmb_response('You should never see this.', false);
         }
         $auth = $iwp_mmb_core->authenticate_message($action . $id, $signature, $id);
         if ($auth === true) {
             if (isset($params['username']) && !is_user_logged_in()) {
                 $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin($params['username']);
                 wp_set_current_user($user->ID);
                 //For WPE
                 if (@getenv('IS_WPE')) {
                     wp_set_auth_cookie($user->ID);
                 }
             }
             /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
             if (strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR')) {
                 if (get_option('db_version') != $wp_db_version) {
                     /* in multisite network, please update database manualy */
                     if (empty($wpmu_version) || function_exists('is_multisite') && !is_multisite()) {
                         if (!function_exists('wp_upgrade')) {
                             include_once ABSPATH . 'wp-admin/includes/upgrade.php';
                         }
                         ob_clean();
                         @wp_upgrade();
                         @do_action('after_db_upgrade');
                         ob_end_clean();
                     }
                 }
             }
             if (isset($params['secure'])) {
                 if ($decrypted = $iwp_mmb_core->_secure_data($params['secure'])) {
                     $decrypted = maybe_unserialize($decrypted);
                     if (is_array($decrypted)) {
                         foreach ($decrypted as $key => $val) {
                             if (!is_numeric($key)) {
                                 $params[$key] = $val;
                             }
                         }
                         unset($params['secure']);
                     } else {
                         $params['secure'] = $decrypted;
                     }
                 } elseif (isset($params['secure']['account_info'])) {
                     $params['account_info'] = $params['secure']['account_info'];
                 }
             }
             if (!$iwp_mmb_core->register_action_params($action, $params)) {
                 global $_iwp_mmb_plugin_actions;
                 $_iwp_mmb_plugin_actions[$action] = $params;
             }
         } else {
             iwp_mmb_response($auth['error'], false);
         }
     } else {
         IWP_MMB_Stats::set_hit_count();
     }
     ob_end_clean();
 }