Ejemplo n.º 1
0
 static function set($array)
 {
     if (CACHE_ON && self::$cache_file) {
         if (MEMCACHE_ON) {
             eb_memcache::do_put("acache:" . self::$cache_file, $array, self::$expire);
         } else {
             @file_put_contents(self::$cache_file, addslashes(serialize($array)));
         }
         self::$arr_cache = $array;
     }
     return true;
 }
Ejemplo n.º 2
0
Archivo: Init.php Proyecto: hqd276/bigs
<?php

if (REWRITE_ON) {
    ob_start();
    //start buffering//@ob_start('ob_gzhandler');
}
require_once ROOT_PATH . 'core/AutoLoader.php';
if (MEMCACHE_ON) {
    CGlobal::$memcache_server = $memcache_server;
}
unset($memcache_server, $server_list, $img_server, $img_ftp_server);
if (isset($_REQUEST['trigger']) && (int) $_REQUEST['trigger'] == 1) {
    EBArrCache::del_cache();
    ECCache::auto_delete();
    StaticCache::delCache();
    EClass::del_page_cache();
    exit;
}
if (isset($_GET['page']) && $_GET['page'] == 'error') {
    define('ERROR_PAGE', 1);
} else {
    define('ERROR_PAGE', 0);
}
if (!EClassApi::is_search_engine() && !defined('NO_SESSION') && !ERROR_PAGE) {
    if (SESSION_TYPE == 'db') {
        require_once ROOT_PATH . 'includes/session.class.php';
        //Session db store
    } elseif (SESSION_TYPE == 'memcache') {
        require_once ROOT_PATH . "includes/memcache.session.php";
        //Session memcache store
    } else {
Ejemplo n.º 3
0
 function produc_hot()
 {
     if (!User::is_login()) {
         echo 'no_login';
         exit;
     }
     if (!User::have_permit(ADMIN_CATEGORY)) {
         echo 'no_perm';
         exit;
     }
     $cat_id = EClassApi::getParam('cat_id', '0');
     $item_ids = EClassApi::getParam('item_ids');
     $vip_item_ids = EClassApi::getParam('vip_item_ids');
     if ($item_ids == '' && $vip_item_ids == '') {
         //$file = DIR_CACHE."html/product_hot/data_".$cat_id.".js";
         //if(@file_exists($file)){
         //	StaticCache::delCache("product_hot/data_".$cat_id,"js");
         //}
         $sql = "update configs set conf_val = '' where conf_key = 'product_hot_" . $cat_id . "'";
         $sql_vip = "delete from item_vip where product_hot_cat_id =" . $cat_id;
         DB::query($sql);
         DB::query($sql_vip);
         EClassApi::get_item_vip(0, true);
         EClassApi::get_config(0, true);
         exit;
     }
     // item thuong
     $item_array = explode(',', $item_ids);
     $items = array();
     foreach ($item_array as $item) {
         if ($item) {
             $items[] = intval($item);
         }
     }
     $id_items_after = '';
     $item_ids = join(',', $items);
     $sql = "delete from configs where conf_key = 'product_hot_" . $cat_id . "'";
     DB::query($sql);
     EClassApi::get_config(0, true);
     if ($item_ids != '') {
         $sql = "SELECT id, name, brief, price, currency_id, original_image_url\n\t\t\t\t\t   FROM item \n\t\t\t\t\t   WHERE status = 1 AND id IN({$item_ids})";
         $result = DB::query($sql);
         $i = 0;
         while ($item = mysql_fetch_array($result)) {
             if (isset($item['id'])) {
                 $id_items[$i] = $item['id'];
                 $i++;
             }
         }
         $id_items_after = '';
         for ($i = 0; $i < count($item_array); $i++) {
             for ($j = 0; $j < count($id_items); $j++) {
                 if ($item_array[$i] == $id_items[$j]) {
                     $id_items_after .= $id_items[$j] . ",";
                 }
             }
         }
         if ($id_items_after != '') {
             $id_items_after = substr($id_items_after, 0, -1);
         }
         $sql_check = "SELECT id FROM configs WHERE conf_key = 'product_hot_" . $cat_id . "'";
         DB::query($sql_check);
         $row = DB::fetch_row();
         if ($row['id'] != '') {
             $sql = "UPDATE configs SET conf_val = '" . $id_items_after . "' WHERE conf_key = 'product_hot_" . $cat_id . "'";
             DB::query($sql);
             EClassApi::get_config(0, true);
             // xoa cache config
         } else {
             $sql = "INSERT INTO configs (`conf_key`,`conf_val`) values ('product_hot_" . $cat_id . "','" . $id_items_after . "')";
             DB::query($sql);
             EClassApi::get_config(0, true);
             // xoa cache config
         }
     }
     //item vip
     $vip_item_array = explode(',', $vip_item_ids);
     $vip_items = array();
     foreach ($vip_item_array as $vip_item) {
         if ($vip_item) {
             $vip_items[] = intval($vip_item);
         }
     }
     $vip_id_items_after = '';
     $vip_item_ids = join(',', $vip_items);
     $sql_vip = "delete from item_vip where product_hot_cat_id =" . $cat_id;
     DB::query($sql_vip);
     EClassApi::get_item_vip(0, true);
     if ($vip_item_ids != '') {
         $sql = "SELECT id, name, brief, price, currency_id, original_image_url\n\t\t\t\t\t   FROM item \n\t\t\t\t\t   WHERE status > 0 AND id IN({$vip_item_ids})";
         $result = DB::query($sql);
         while ($item = mysql_fetch_array($result)) {
             if (isset($item['id'])) {
                 $vip_id_items_after .= $item['id'] . ",";
                 $sql_check = "select count(*) AS total from item_vip where item_id = " . $item['id'] . " And product_hot_cat_id=" . $cat_id;
                 DB::query($sql_check);
                 $row = DB::fetch_row();
                 if ($row['total'] == 0) {
                     $sql = "insert into item_vip (`item_id`,`product_hot_cat_id`) values (" . $item['id'] . "," . $cat_id . ")";
                     DB::query($sql);
                     EClassApi::get_item_vip(0, true);
                 }
             }
         }
         if ($vip_id_items_after != '') {
             $vip_id_items_after = substr($vip_id_items_after, 0, -1);
         }
     }
     $id_items_after .= '|' . $vip_id_items_after;
     // check file
     //if(@file_exists(DIR_CACHE."html/product_hot/data_".$cat_id.".js")){
     //StaticCache::delCache("product_hot/data_".$cat_id,"js");
     //}
     EBArrCache::del_cache('arrProductHotCache');
     echo $id_items_after;
     exit;
 }
Ejemplo n.º 4
0
    static function getWebsiteLogo($delcache = false)
    {
        if (CGlobal::$websiteLogo === false || (is_array(CGlobal::$websiteLogo) && !count(CGlobal::$websiteLogo)) || $delcache) {
            if (EBArrCache::is_not_cached('websiteLogo', 0, '', $delcache)) {
                if (!$delcache) {
                    CGlobal::$websiteLogo['current'] = array('id' => 0,
                        'img_src' => 'style/images201005/eb_logo.gif',
                        'title' => 'Trang chủ',
                        'expired' => ''
                    );

                    // For logo management
                    $re = DB::query("SELECT * FROM website_logo ORDER BY start_date DESC, end_date DESC");

                    if ($re) {
                        $logos = array();
                        $active = false;
                        while ($row = mysql_fetch_assoc($re)) {
                            if (isset(CGlobal::$img_server[$row['img_server']])) {
                                $row['img_src'] = "http://" . CGlobal::$img_server[$row['img_server']] . $row['image'];

                                if ($row['status'])
                                    $row['active'] = "Active";
                                if ($row['start_date'])
                                    $row['startDate'] = date('d-m-Y', $row['start_date']);
                                if ($row['end_date'])
                                    $row['endDate'] = date('d-m-Y', $row['end_date']);
                                $logos[$row['id']] = $row;

                                // Chọn logo theo sự kiện, hoạt động nào đó của énbạc
                                if ($row['status'] && !$active) { // Nếu trạng thái của logo là đang active và chưa có logo nào được chọn
                                    if (!$row['start_date'] || ($row['start_date'] < TIME_NOW)) {
                                        if (!$row['end_date'] || ($row['end_date'] >= TIME_NOW)) {
                                            $active = true;
                                        }
                                    }

                                    if ($active) {
                                        CGlobal::$websiteLogo['current'] = array(
                                            'id' => $row['id'],
                                            'img_src' => 'http://' . CGlobal::$img_server[$row['img_server']] . $row['image'],
                                            'title' => EClassApi::remove_4_js(EClassApi::trimSpace(EClassApi::plainText(addslashes($row['title'])))),
                                            'expired' => $row['end_date']
                                        );
                                        DB::query("UPDATE website_logo SET status = 0 WHERE id <> " . $row['id']);
                                    }
                                }
                            }
                        }

                        CGlobal::$websiteLogo['logos'] = $logos;

                        EBArrCache::set(array('websiteLogo' => CGlobal::$websiteLogo));
                    }
                }
            } else {
                CGlobal::$websiteLogo = EBArrCache::$arr_cache['websiteLogo'];
                EBArrCache::$arr_cache = array();
            }
        }
    }