コード例 #1
0
ファイル: cache.php プロジェクト: SwayWebStudio/night.com
 public function clear_all()
 {
     if (!$this->user->hasPermission('modify', 'module/journal2')) {
         throw new Exception('You do not have permissions to modify Journal2 module');
     }
     Journal2Cache::deleteCache();
 }
コード例 #2
0
 private function addJournalVersion($url, $is_minified)
 {
     if (!$this->cache->getDeveloperMode() && $is_minified) {
         return $url;
     }
     if (strpos($url, '?') === false) {
         return $url . '?j2v=' . JOURNAL_VERSION;
     }
     return $url . '&j2v=' . JOURNAL_VERSION;
 }
コード例 #3
0
ファイル: nitro.php プロジェクト: artlabsdesign/missbloom
 public function clearPageCache()
 {
     if ($this->user->hasPermission('modify', 'module/journal2')) {
         if (class_exists('Journal2Cache')) {
             Journal2Cache::deleteCache();
         }
     }
     initNitroProductCacheDb();
     $this->db->query("TRUNCATE TABLE " . DB_PREFIX . "nitro_product_cache");
     $this->trunc_folder(NITRO_PAGECACHE_FOLDER, 'index.html');
     return true;
 }
コード例 #4
0
ファイル: journal2.php プロジェクト: SwayWebStudio/night.com
 public function clear_cache()
 {
     if ($this->user->hasPermission('modify', 'module/journal2')) {
         Journal2Cache::deleteCache();
         $this->session->data['success'] = 'Journal Cache has been successfully cleared.';
     } else {
         $this->session->data['warning'] = 'You do not have permissions to modify Journal2 module.';
     }
     if (isset($this->session->data['j2_redirect'])) {
         $redirect = $this->url->link($this->session->data['j2_redirect'], 'token=' . $this->session->data['token'], 'SSL');
         unset($this->session->data['j2_redirect']);
     } else {
         $redirect = $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL');
     }
     if (Front::$IS_OC2) {
         $this->response->redirect($redirect);
     } else {
         $this->redirect($redirect);
     }
 }
コード例 #5
0
 public function set()
 {
     if (!$this->user->hasPermission('modify', 'module/journal2')) {
         throw new Exception('You do not have permissions to modify Journal2 module');
     }
     if (!isset($this->post_data['value'])) {
         throw new Exception('Parameter value was not found');
     }
     $value = $this->post_data['value'];
     if (!isset($this->get_data['key'])) {
         throw new Exception('Parameter key was not found');
     }
     $key = $this->get_data['key'];
     if (!isset($this->get_data['store_id'])) {
         $store_id = 0;
     } else {
         $store_id = $this->get_data['store_id'];
     }
     if (is_scalar($value)) {
         $json_encoded = 0;
     } else {
         $value = json_encode($value);
         $json_encoded = 1;
     }
     $this->db->query('INSERT INTO ' . DB_PREFIX . 'journal2_config (`key`, `store_id`, `value`, `serialized`) VALUES ("' . $this->db->escape($key) . '", "' . (int) $store_id . '", "' . $this->db->escape($value) . '", "' . $json_encoded . '") ON DUPLICATE KEY UPDATE `value` = "' . $this->db->escape($value) . '", `serialized` = "' . $json_encoded . '"');
     Journal2Cache::deleteModuleCache("config_{$key}");
     return null;
 }
コード例 #6
0
 public function save()
 {
     if (!$this->user->hasPermission('modify', 'module/journal2')) {
         throw new Exception('You do not have permissions to modify Journal2 module');
     }
     if (!isset($this->get_data['module_type'])) {
         throw new Exception('Parameter module_type was not found');
     }
     if (!isset($this->post_data['module_data'])) {
         throw new Exception('Parameter module_data was not found');
     }
     $module_type = 'journal2_' . $this->get_data['module_type'];
     $module_data = $this->post_data['module_data'];
     if (Front::$IS_OC2) {
         $this->db->query('DELETE FROM ' . DB_PREFIX . 'layout_module WHERE `code` LIKE "' . $this->db->escape($module_type) . '%"');
         $this->db->query('DELETE FROM ' . DB_PREFIX . 'setting WHERE `code` LIKE "' . $this->db->escape($module_type) . '"');
         foreach ($module_data as $module) {
             $this->db->query('INSERT INTO ' . DB_PREFIX . 'layout_module (`layout_id`, `code`, `position`, `sort_order`) VALUES (' . (int) $module['layout_id'] . ', "' . $this->db->escape($module_type . '.' . (int) $module['module_id']) . '", "' . $this->db->escape($module['position']) . '", ' . (int) $module['sort_order'] . ')');
             $this->db->query('INSERT INTO ' . DB_PREFIX . 'setting (`code`, `key`, `value`, `serialized`) VALUES ("' . $this->db->escape($module_type) . '", "' . $this->db->escape($module_type . '_' . (int) $this->db->getLastId() . '_status') . '", "' . (int) $module['status'] . '", 0)');
         }
     } else {
         $this->load->model('setting/extension');
         $this->load->model('setting/setting');
         $this->model_setting_extension->uninstallJ2Extension('module', $module_type);
         $this->model_setting_extension->install('module', $module_type);
         $this->model_setting_setting->editSetting($module_type, array($module_type . '_module' => $module_data));
     }
     Journal2Cache::deleteModuleCache("module_journal_{$this->get_data['module_type']}");
     return null;
 }
コード例 #7
0
ファイル: currency.php プロジェクト: kctan0620/onlinestore
 public function refresh($force = false)
 {
     if (extension_loaded('curl')) {
         $data = array();
         if ($force) {
             $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "'");
         } else {
             $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified < '" . $this->db->escape(date('Y-m-d H:i:s', strtotime('-1 day'))) . "'");
         }
         foreach ($query->rows as $result) {
             $data[] = $this->config->get('config_currency') . $result['code'] . '=X';
         }
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv');
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($curl, CURLOPT_HEADER, false);
         curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
         curl_setopt($curl, CURLOPT_TIMEOUT, 30);
         $content = curl_exec($curl);
         curl_close($curl);
         $lines = explode("\n", trim($content));
         foreach ($lines as $line) {
             $currency = utf8_substr($line, 4, 3);
             $value = utf8_substr($line, 11, 6);
             if ((double) $value) {
                 $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (double) $value . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($currency) . "'");
             }
         }
         $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'");
         if (defined('JOURNAL_FLUSH_CURRENCY_CACHE')) {
             require_once DIR_SYSTEM . 'journal2/classes/journal2_cache.php';
             Journal2Cache::deleteCache();
         }
         $this->cache->delete('currency');
     }
 }
コード例 #8
0
ファイル: core.php プロジェクト: artlabsdesign/missbloom
function cleanNitroCacheFolders($touch = false, $time = false)
{
    cleanFolder(NITRO_PAGECACHE_FOLDER, $touch, $time);
    cleanFolder(NITRO_DBCACHE_FOLDER, $touch, $time);
    cleanFolder(NITRO_FOLDER . 'temp' . DS, $touch, $time);
    cleanFolder(dirname(DIR_APPLICATION) . DS . 'assets' . DS . 'css' . DS, $touch, $time);
    cleanFolder(dirname(DIR_APPLICATION) . DS . 'assets' . DS . 'js' . DS, $touch, $time);
    if (class_exists('Journal2Cache')) {
        Journal2Cache::deleteCache();
    }
    $db = NitroDb::getInstance();
    $db->query("TRUNCATE TABLE " . DB_PREFIX . "nitro_product_cache");
}
コード例 #9
0
 public function index()
 {
     $this->load->model('tool/image');
     /* blog manager compatibility */
     $route = isset($this->request->get['route']) ? $this->request->get['route'] : null;
     if ($route !== null && in_array($route, array('blog/article', 'blog/category'))) {
         return;
     }
     /* end of blog manager compatibility */
     $this->s_url = Journal2Cache::getCurrentUrl();
     switch ($this->journal2->page->getType()) {
         case 'product':
             $this->load->model('catalog/product');
             $product_info = $this->model_catalog_product->getProduct($this->journal2->page->getId());
             if ($product_info) {
                 $this->s_title = $product_info['name'];
                 $this->s_description = trim(utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, 300));
                 $this->s_image = Journal2Utils::staticAsset('image/' . $product_info['image']);
                 $this->s_rating = (int) $product_info['rating'];
                 $this->journal2->settings->set('product_google_snippet', 'itemscope itemtype="http://schema.org/Product"');
                 $this->journal2->settings->set('product_price_currency', $this->currency->getCode());
                 $this->journal2->settings->set('product_num_reviews', $product_info['reviews']);
                 $this->journal2->settings->set('product_in_stock', $product_info['quantity'] > 0 ? 'yes' : 'no');
                 /* review ratings */
                 $this->language->load('product/product');
                 $this->load->model('catalog/review');
                 $this->data['text_on'] = $this->language->get('text_on');
                 $this->data['text_no_reviews'] = $this->language->get('text_no_reviews');
                 if (isset($this->request->get['page'])) {
                     $page = $this->request->get['page'];
                 } else {
                     $page = 1;
                 }
                 $this->data['reviews'] = array();
                 $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
                 $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5);
                 foreach ($results as $result) {
                     $this->data['reviews'][] = array('author' => $result['author'], 'text' => $result['text'], 'rating' => (int) $result['rating'], 'reviews' => sprintf($this->language->get('text_reviews'), (int) $review_total), 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])));
                 }
                 $pagination = new Pagination();
                 $pagination->total = $review_total;
                 $pagination->page = $page;
                 $pagination->limit = 5;
                 $pagination->text = $this->language->get('text_pagination');
                 $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}');
                 $this->data['pagination'] = $pagination->render();
                 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/review.tpl')) {
                     $this->template = $this->config->get('config_template') . '/template/product/review.tpl';
                 } else {
                     $this->template = 'default/template/product/review.tpl';
                 }
                 $this->journal2->settings->set('product_reviews', $this->render());
             }
             break;
         case 'category':
             $this->load->model('catalog/category');
             $parts = explode('_', $this->journal2->page->getId());
             $category_id = (int) array_pop($parts);
             $category_info = $this->model_catalog_category->getCategory($category_id);
             if ($category_info) {
                 $this->s_title = $category_info['name'];
                 $this->s_description = trim(utf8_substr(strip_tags(html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8')), 0, 300));
                 $this->s_image = Journal2Utils::staticAsset('image/' . $category_info['image']);
             }
             break;
         default:
             $this->s_title = $this->config->get('config_name');
             $meta_description = $this->config->get('config_meta_description');
             if (is_array($meta_description)) {
                 $lang_id = $this->config->get('config_language_id');
                 if (isset($meta_description[$lang_id])) {
                     $this->s_description = $meta_description[$lang_id] . '...';
                 }
             } else {
                 $this->s_description = $meta_description . '...';
             }
             $this->s_image = Journal2Utils::resizeImage($this->model_tool_image, $this->config->get('config_logo'), self::IMG_WIDTH, self::IMG_HEIGHT, 'fit');
             break;
     }
     $this->journal2->settings->set('fb_meta_title', $this->s_title);
     $this->journal2->settings->set('fb_meta_description', $this->s_description);
     $this->journal2->settings->set('fb_meta_url', $this->s_url);
     $this->journal2->settings->set('fb_meta_image', $this->s_image);
 }
コード例 #10
0
 public static function enablePageCache($language = 'en', $currency = 'usd')
 {
     if (!session_id()) {
         session_start();
     }
     if (self::canPageCache()) {
         self::$page_cache_file = Journal2Cache::$path . '/' . Journal2Cache::$dir . implode('_', array(md5(self::getCurrentUrl()), $language, $currency, self::$device));
         if (file_exists(self::$page_cache_file)) {
             echo file_get_contents(self::$page_cache_file);
             exit;
         }
     }
 }