Esempio n. 1
0
 public function get($tag, $attr = 'content')
 {
     $tag = trim($tag);
     $attrName = 'widget_' . $attr;
     if (empty($tag)) {
         return;
     }
     $unlimCache = K_Cache_Manager::get('unlim');
     $blockCacheID = 'widget_' . $tag;
     if ($unlimCache->test($blockCacheID)) {
         $cacheData = $unlimCache->load($blockCacheID);
         if (isset($cacheData[$attrName])) {
             echo $cacheData[$attrName];
         }
     } else {
         K_Loader::load('widgets', APP_PATH . '/default/model/');
         $widgetsTable = new widgetsModel();
         $widgetInfo = $widgetsTable->fetchRow(K_Db_Select::create()->where(array('widget_tag' => $tag))->limit(1));
         if (count($widgetInfo)) {
             $unlimCache->save($blockCacheID, $widgetInfo);
             if (isset($widgetInfo[$attrName])) {
                 echo $widgetInfo[$attrName];
             }
         }
     }
 }
Esempio n. 2
0
 public static function logout()
 {
     self::init();
     // Кеш для релогин триггера, удаляем кеш, так как он уже не нужен
     K_Cache_Manager::get('24h')->remove('RL' . self::$_userInfo['id']);
     self::$_userInfo = null;
     K_Session::remove('UserInfo', 'K_Auth');
     self::$_options = array();
     self::$_options['isLogin'] = false;
     self::$_options['isUserlogout'] = false;
     self::$_options['isAdmin'] = false;
     self::$_options['accessLevel'] = 0;
     self::$_options['clientType'] = DMA_CT_GUEST;
     self::$_options['roles'] = array('guests');
     K_Session::write('Options', self::$_options, 'K_Auth');
 }
Esempio n. 3
0
 private static function saveAclArrays($pref, &$aclObj)
 {
     $grabResources = $aclObj->grabResources();
     $grabRoles = $aclObj->grabRoles();
     $grabRules = $aclObj->grabRules();
     K_Cache_Manager::get('unlim')->save($pref . "RE", $grabResources);
     K_Cache_Manager::get('unlim')->save($pref . "RO", $grabRoles);
     K_Cache_Manager::get('unlim')->save($pref . "RU", $grabRules);
 }
Esempio n. 4
0
 public static function parseCurrency()
 {
     $cacheManager = K_Registry::get('cacheManager');
     $cacheEver = K_Cache_Manager::get('unlim');
     $cache24h = K_Cache_Manager::get('24h');
     $currencyList = array();
     if (!$cache24h->test('CURS')) {
         $content = file_get_contents('http://finance.ua/ru/');
         $matches = array();
         preg_match('#<div\\s*id="portlet-currency-cash-cashless".*?>.*?<div\\s*class="portlet-content">(?P<table>.*?)</div>#is', $content, $matches);
         if (!empty($matches['table'])) {
             $table = $matches['table'];
             $matches = array();
             preg_match_all('#<tr\\s*class="(odd|even)">(?P<list>.*?)</tr>#is', $table, $matches);
             if (count($matches['list'])) {
                 foreach ($matches['list'] as $line) {
                     $matches = array();
                     $pattern = '<td\\s*class="iname">';
                     $pattern .= '.*?<a.*?>(?P<currency_digit>\\d+|)(?P<currency_name>.*?)</a>';
                     // чуток поправил паттерн
                     $pattern .= '.*?<td.*?>.*?(?P<cur1>[0-9.]+)';
                     $pattern .= '.*?<td.*?>.*?(?P<cur2>[0-9.]+)';
                     $pattern .= '.*?<td.*?>.*?(?P<cur3>[0-9.]+)';
                     $pattern .= '.*?<td.*?>.*?(?P<cur4>[0-9.]+)';
                     preg_match('#' . $pattern . '#is', $line, $matches);
                     if (count($matches)) {
                         $currencyList[$matches['currency_name']] = array('digit' => $matches['currency_digit'], 'cash_bid' => number_format($matches['cur1'], 2, '.', ' '), 'cash_ask' => number_format($matches['cur2'], 2, '.', ' '), 'noncash_bid' => number_format($matches['cur3'], 2, '.', ' '), 'noncash_ask' => number_format($matches['cur4'], 2, '.', ' '));
                     }
                 }
             }
         }
         preg_match('#<div\\s*id="portlet-currency-official".*?>.*?<div\\s*class="portlet-content">(?P<table>.*?)</div>#is', $content, $matches);
         if (!empty($matches['table'])) {
             $table = $matches['table'];
             $matches = array();
             preg_match_all('#<tr\\s*class="(odd|even)">(?P<list>.*?)</tr>#is', $table, $matches);
             if (count($matches['list'])) {
                 foreach ($matches['list'] as $line) {
                     $matches = array();
                     $pattern = '<td\\s*class="iname">';
                     $pattern .= '.*?<a.*?>(?P<currency_digit>\\d+|)(?P<currency_name>.*?)</a>';
                     // чуток поправил паттерн
                     $pattern .= '.*?<td.*?>.*?(?P<cur1>[0-9.]+)';
                     preg_match('#' . $pattern . '#is', $line, $matches);
                     if (count($matches)) {
                         $currencyListNbu[$matches['currency_name']] = array('cash' => number_format($matches['cur1'], 2, '.', ' '));
                     }
                 }
             }
         }
         if (count($currencyListNbu)) {
             $currencyList['NBU'] = $currencyListNbu;
         }
         if (count($currencyList)) {
             $cacheEver->save('CURS', $currencyList);
         } else {
             $currencyList = $cacheEver->load('CURS');
             // K_Log_Syslog::write();  @to-do сделать оповищение о ошибке парсинга
         }
         $cache24h->save('CURS', $currencyList);
     } else {
         $currencyList = $cache24h->load('CURS');
     }
     return $currencyList;
 }
Esempio n. 5
0
 /**
  * Remove page info
  * @param Array $data   where array
  */
 public function remove($data)
 {
     $cacheID = null;
     if (isset($data['url_url']) && !empty($data['url_url'])) {
         $cacheID = 'url_' . md5(trim(mb_strtolower($data['url_url'], 'utf-8')));
     }
     if (isset($data['url_params_json']) && is_array($data['url_params_json'])) {
         $data['url_params_json'] = json_encode($data['url_params_json']);
     }
     $unlimCache = K_Cache_Manager::get('unlim');
     if (!empty($cacheID)) {
         if ($unlimCache->test($cacheID)) {
             $unlimCache->remove($cacheID);
         }
     }
     $this->rewriteUrlsTable->remove(K_Db_Select::create()->where($data));
 }