static function getCats($update_cache = 0, $delcache = false) { if (!CGlobal::$allCategories || $delcache || $update_cache) { if (AZArrCache::is_not_cached('cat_arr', 0, '', $delcache)) { if (!$delcache) { $re = DB::query("SELECT zoneid, catid,category_zone_cat.position FROM category_zone_cat LEFT JOIN category_zone ON category_zone_cat.zoneid = category_zone.id ORDER BY category_zone.position,category_zone_cat.position"); $cat_zones = array(); $allZoneCats = array(); if ($re) { while ($zcat = mysql_fetch_assoc($re)) { $allZoneCats[$zcat['zoneid']][$zcat['catid']] = $zcat['catid']; $cat_zones[$zcat['catid']][$zcat['zoneid']] = $zcat['zoneid']; } } $re = DB::query('SELECT id, name, brief_name, total_item, position, class FROM category_zone WHERE status=1 ORDER BY position', __LINE__ . __FILE__); if ($re) { while ($zone = mysql_fetch_assoc($re)) { $zone['ebname'] = AZLib::safe_title($zone['name']); if (isset($allZoneCats[$zone['id']])) { $zone['cats'] = $allZoneCats[$zone['id']]; } else { $zone['cats'] = array(); } CGlobal::$allZones[$zone['id']] = $zone; } } $re = DB::query('SELECT id,ref_id, name, brief_name, status, parent_id, keywords, description, position, tag_search, img_server, price_str, recomend FROM category WHERE status!="HIDE" ORDER BY parent_id, position', __LINE__ . __FILE__); if ($re) { while ($cat = mysql_fetch_assoc($re)) { $cat['ebname'] = AZLib::safe_title($cat['name']); $cat['nice_name'] = $cat['ebname']; if ($cat['parent_id']) { //Nếu là danh mục cấp 2 if (isset(CGlobal::$allCategories[$cat['parent_id']])) { //Nếu tồn tại danh mục cha if ($cat['parent_id'] == 104) { //Hàng hiệu $cat['nice_name'] = CGlobal::$allCategories[$cat['parent_id']]['nice_name'] . "-{$cat['ebname']}"; } else { $cat['nice_name'] = CGlobal::$allCategories[$cat['parent_id']]['nice_name']; } if (CGlobal::$allCategories[$cat['parent_id']]['parent_id']) { //Nếu là danh mục cấp 3 $level2_id = $cat['parent_id']; $top_id = CGlobal::$allCategories[$cat['parent_id']]['parent_id']; if (isset(CGlobal::$allCategories[$top_id])) { //Nếu tồn tại danh mục cha $cat['nice_name'] = CGlobal::$allCategories[$top_id]['nice_name']; } } else { CGlobal::$subCategories[$cat['parent_id']][$cat['id']] = $cat; } } else { CGlobal::$subCategories[$cat['parent_id']][$cat['id']] = $cat; } } elseif (!isset(CGlobal::$subCategories[$cat['id']])) { CGlobal::$subCategories[$cat['id']] = array(); if (isset($cat_zones[$cat['id']])) { $cat['zones'] = $cat_zones[$cat['id']]; } else { $cat['zones'] = array(); } } CGlobal::$allCategories[$cat['id']] = $cat; } } AZArrCache::set(array('allZones' => CGlobal::$allZones, 'allCategories' => CGlobal::$allCategories, 'subCategories' => CGlobal::$subCategories)); } else { /* foreach (CGlobal::$my_server as $server){//Tạo lại file js cho chuyên mục @fopen("http://$server/catgen.php","r"); } */ // @fopen(WEB_ROOT . "seo.php", "r"); /*$js_ver = rand(1, 1000); AZMemcache::do_put("cat_ver:", $js_ver);*/ } } else { CGlobal::$allZones = AZArrCache::$arr_cache['allZones']; CGlobal::$allCategories = AZArrCache::$arr_cache['allCategories']; CGlobal::$subCategories = AZArrCache::$arr_cache['subCategories']; AZArrCache::$arr_cache = array(); } } }