/** * Обработка Ajax вызова * */ public function doAjax() { // Смотрим какой блок вызывать $className = $this->CI->input->post('block'); // Пытаемся загрузить try { Sppc_Loader::tryLoadClass($className); /* @var $block Sppc_Dashboard_Ajax_Interface */ $block = new $className(); if ($block instanceof Sppc_Dashboard_Ajax_Interface) { $block->doAjax(); } } catch (Exception $e) { // Class $className not found } }
/** * Загрузка протекшенов для построения цепочки * */ protected function _loadFraudProtections() { $CI =& get_instance(); $protections = array(); $feEngine = $CI->config->item('protections_frontend_engine'); $feOptions = $CI->config->item('protections_frontend'); $beEngine = $CI->config->item('protections_backend_engine'); $beOptions = $CI->config->item('protections_backend'); if (isset($beOptions['cache_dir']) && !file_exists($beOptions['cache_dir'])) { mkdir($beOptions['cache_dir']); chmod($beOptions['cache_dir'], 0777); } $cache = Zend_Cache::factory($feEngine, $beEngine, $feOptions, $beOptions); if (false === ($protections = $cache->load('protections_' . $this->_engine))) { $protections = array(); $CI->db->select('slug, id_action, use_actions')->from('fraud_protections')->where('status', 'enabled')->where("FIND_IN_SET('" . $this->_engine . "', target) > 0", null, false)->where('id_action <>', self::ACTION_PAY); $query = $CI->db->get(); if (0 < $query->num_rows()) { foreach ($query->result_array() as $row) { $row['use_actions'] = 'true' == $row['use_actions']; array_push($protections, $row); } } $cache->save($protections, 'protections_' . $this->_engine); } $this->_fraudProtections = array(); foreach ($protections as $row) { // Добавляем протекшн в цепочку $class = str_replace(' ', '', ucwords(str_replace('_', ' ', $row['slug']))); $protectionClass = 'Sppc_Protection_' . $class; try { Sppc_Loader::tryLoadClass($protectionClass); $this->addProtection(new $protectionClass()); // Сохраняем параметры для этого protection $this->_fraudProtections[$protectionClass] = array('id_action' => $row['id_action'], 'slug' => $row['slug'], 'use_actions' => $row['use_actions']); } catch (Exception $e) { // Class $protectionClass not found } } }