Пример #1
0
 static function set($array)
 {
     if (CACHE_ON && self::$cache_file) {
         if (MEMCACHE_ON) {
             AZMemcache::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;
 }
Пример #2
0
 static function getProvinces($update_cache = 0, $delcache = false)
 {
     if (!CGlobal::$provinces || $delcache || $update_cache) {
         if (AZArrCache::is_not_cached('provinces_arr', 0, '', $delcache)) {
             if (!$delcache) {
                 $re = DB::query('SELECT id, name, brief_name, status, area FROM province ORDER BY position', __LINE__ . __FILE__);
                 $topProvinces = array();
                 $ortherProvinces = array();
                 if ($re) {
                     while ($province = mysql_fetch_assoc($re)) {
                         $province['ebname'] = AZLib::safe_title($province['name']);
                         if ($province['status'] == "HOME") {
                             $topProvinces[$province['id']] = $province;
                         } else {
                             $ortherProvinces[$province['id']] = $province;
                         }
                     }
                 }
                 $topProvinces[0] = array('id' => 0, 'name' => 'Toàn quốc', 'brief_name' => 'Toàn quốc', 'status' => 'SHOW', 'area' => '1', 'ebname' => 'Toan-Quoc');
                 CGlobal::$provinces = $topProvinces + $ortherProvinces;
                 AZArrCache::set(CGlobal::$provinces);
             } else {
                 foreach (CGlobal::$my_server as $server) {
                     //Tạo lại file js cho city
                     @fopen("http://{$server}/citygen.php", "r");
                 }
                 $js_ver = rand(1, 1000);
                 AZMemcache::do_put("city_ver:", $js_ver);
             }
         } else {
             CGlobal::$provinces = AZArrCache::$arr_cache;
             AZArrCache::$arr_cache = array();
         }
     }
 }