/** * @see Sppc_Protection_Abstract::isValid() * * @param $value string */ public function isValid($value = null) { if (is_null($value)) { // Если не передан ip, тогда берем ip из параметров $parameters = Sppc_Protection_Parameters::getInstance(); $value = $parameters->getParameter('ip_address'); } $this->_setValue($value); $CI =& get_instance(); $CI->load->helper('location'); $ip = iptolong($this->_value); $number = (int) $this->_getSetting('MaximumSearchNumber', 100); $period = (int) $this->_getSetting('TimePeriod', 5); if (0 < $number) { // Use database $CI->db->insert('fraud_quick_search', array('ip' => $ip, 'search_date' => time())); // Чекаем $CI->db->where('ip', $ip)->where('search_date >=', time() - $period)->from('fraud_quick_search'); $count = $CI->db->count_all_results(); if ($count > $number) { $this->_error(); return false; } } return true; }
/** * Получение экземпляра класса * * @param array $parameters * @return Sppc_Protection_Parameters */ public static function getInstance() { if (null === self::$instance) { self::$instance = new Sppc_Protection_Parameters(); } return self::$instance; }
/** * @see Sppc_Protection_Abstract::isValid() * * @param $value string */ public function isValid($value = null) { if (null === $value) { // Если не передан referer, тогда берем referer из параметров $parameters = Sppc_Protection_Parameters::getInstance(); $value = $parameters->getParameter('referer'); } $this->_setValue($value); if ('true' == $this->_getSetting('ReferrerNonEmpty', 'true') && empty($this->_value)) { $this->_error(); return false; } return true; }
/** * @see Sppc_Protection_Abstract::isValid() */ public function isValid($value = null) { if (is_null($value)) { // Если не передана страна, тогда получаем страну из параметров $parameters = Sppc_Protection_Parameters::getInstance(); $value = $parameters->getParameter('country'); } $this->_setValue($value); // Проверяем страну на принадлежность к списку разрешенных стран if (!in_array($this->_value, $this->_allowedCountriesList)) { $this->_error(); return false; } return true; }
/** * @see Sppc_Protection_Abstract::isValid() */ public function isValid($value = null) { if (is_null($value)) { // Если не передан ip, тогда получаем ip из параметров $parameters = Sppc_Protection_Parameters::getInstance(); $value = $parameters->getParameter('ip_address'); } $CI =& get_instance(); $CI->load->helper('location'); $this->_setValue($value); $ip = iptolong($this->_value); $CI->db->from('fraud_firewall')->where('ip_start <=', $ip)->where('ip_finish >=', $ip); if (0 < $CI->db->count_all_results()) { $this->_error(); return false; } return true; }
/** * Установка значения для проверки * * @param mixed $value */ protected function _setValue($value) { // Параметры $parameters = Sppc_Protection_Parameters::getInstance(); // Получаем время клика if (isset($value['click_ip'])) { $this->_ip_click = $value['click_ip']; } else { $this->_ip_click = $parameters->getParameter('ip_address'); } // Получаем время поиска if (isset($value['search_ip'])) { $this->_ip_search = $value['search_ip']; } else { $this->_ip_search = $parameters->getParameter('search_ip_address'); } // Обнуляем массив сообщений об ошибках $this->_messages = array(); }
/** * Установка значения для проверки * * @param mixed $value */ protected function _setValue($value) { // Параметры $parameters = Sppc_Protection_Parameters::getInstance(); // Получаем айпи визитора if (isset($value['ip'])) { $this->_ip = $value['ip']; } else { $this->_ip = $parameters->getParameter('ip_address'); } // Получаем айпи прокси визитора if (isset($value['ip_proxy'])) { $this->_ip_proxy = $value['ip_proxy']; } else { $this->_ip_proxy = $parameters->getParameter('ip_address_proxy'); } // Обнуляем массив сообщений об ошибках $this->_messages = array(); }
/** * Подготовка параметров для протекшенов * */ protected function prepareProtectionParameters() { // Формируем данные для протекта $params = array('datetime' => time(), 'country' => $this->country, 'language' => $this->language, 'browser' => $this->browser, 'user_agent' => $this->user_agent, 'referer' => $this->referer, 'ip_address' => $this->ip_address, 'ip' => $this->ip, 'ip_address_proxy' => $this->ip_address_proxy, 'ip_proxy' => $this->ip_proxy); // Инициализируем класс поисковых параметров $parameters = Sppc_Protection_Parameters::getInstance(); $parameters->setParameters($params); }
/** * Блокировка IP адреса * * @var $ip_address string */ public static function blockIp() { $CI =& get_instance(); $parameters = Sppc_Protection_Parameters::getInstance(); $ip = $parameters->getParameter('ip'); $CI->db->from('fraud_firewall')->where('ip_start <=', $ip)->where('ip_finish >=', $ip); if (0 == $CI->db->count_all_results()) { // Заносим в базу $CI->db->insert('fraud_firewall', array('ip_start' => $ip, 'ip_finish' => $ip)); } }
/** * Подготовка параметров для протекшенов * */ protected function prepareProtectionParameters() { parent::prepareProtectionParameters(); // Инициализируем класс поисковых параметров $parameters = Sppc_Protection_Parameters::getInstance(); $parameters->setParameter('referer', $this->real_referer); $parameters->setParameter('engine', 'search'); $parameters->setParameter('ad_type', $this->ad_type); }