static function getAssets($type) { $assets = eb_memcache::do_get('cpvm_' . $type); if (!$assets) { $assets = Assets::get_collection(null, null, null, $type); eb_memcache::do_put('cpvm_' . $type, $assets, 24 * 60 * 60); } return $assets; }
function draw() { global $display; $arrVar = array(); $this->beginForm(1); $options = ""; EClassApi::getCats(); $where = ''; $group_id = Url::get('group_id', ''); $group_name = Url::get('group_name', ''); if ($group_id) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " id = '{$group_id}' "; $arrVar['group_id'] = $group_id; } if ($group_name) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " name = '{$group_name}' "; $arrVar['group_name'] = $group_name; } $item_per_page = 50; $limit = ''; $sql_count = "SELECT COUNT(*) AS total FROM products_extra_fields_group {$where}"; $total = DB::fetch($sql_count, 'total', 0); if ($total) { require_once ROOT_PATH . 'core/ECPagging.php'; $paging = ECPagging::pagingSE($limit, $total, $item_per_page, 10, 'page_no', true, 'Nhóm trường', 'Trang'); $re = DB::query("SELECT * FROM products_extra_fields_group {$where} order by id desc {$limit}"); if ($re) { while ($row = mysql_fetch_assoc($re)) { $products_extra_fields_group[$row['id']] = $row; } } } $categories = eb_memcache::do_get('categories_new'); if (!is_array($categories)) { //if($total){ require_once ROOT_PATH . 'core/ECPagging.php'; $re = DB::query("SELECT * FROM products_category order by orders"); if ($re) { while ($row = mysql_fetch_assoc($re)) { $categories[$row['parent_id']][$row['id']] = $row; } } eb_memcache::do_put('categories_new', $categories); } print_category($categories, 0, $options); //} $arrVar['options'] = $options; $arrVar['zones'] = CGlobal::$allZones; $arrVar['paging'] = $paging; $arrVar['products_extra_fields_group'] = $products_extra_fields_group; $display->templateAdvance = TRUE; $display->setTemplate('ManageFilterAdd', $arrVar); $this->endForm(); }
static function is_not_cached($a_name = '', $expire = 3600, $subDirCache = '', $del_cache = false) { self::$arr_cache = array(); if (CACHE_ON) { $c_name = ($subDirCache ? $subDirCache . '/' : '') . $a_name; self::$cache_file = $c_name; if ($del_cache || isset($_GET['delscache']) && (int) $_GET['delscache'] == '1') { self::del_cache($c_name); return true; } self::$expire = $expire < 0 ? 0 : $expire; if (MEMCACHE_ON) { self::$arr_cache = eb_memcache::do_get("acache:{$c_name}"); if (!empty(self::$arr_cache)) { if (DEBUG) { $info = "<br /><font color=red><b>" . self::$cache_file . "</b></font><br /><b>Cache Time:</b> " . self::$expire . "s "; if (!self::$expire) { $info .= "<b> Expire:</b> forever"; } self::$cache_list .= "<li>" . $info . "</li>"; } return false; } } elseif (EClassApi::CheckDir(DIR_CACHE . 'arr/' . ($subDirCache ? $subDirCache . '/' : ''), MEMCACHE_ON)) { self::$cache_file = DIR_CACHE . 'arr/' . $c_name . '.eb'; if (file_exists(self::$cache_file)) { self::$createdTime = filemtime(self::$cache_file); if (self::$expire == 0 || self::$expire > 0 && TIME_NOW < self::$createdTime + self::$expire) { self::$arr_cache = unserialize(stripslashes(@file_get_contents(self::$cache_file))); if (DEBUG) { $info = "<br /><font color=red><b>" . self::$cache_file . "</b></font><br /><b>Cache Time:</b> " . self::$expire . "s "; $info .= "<b>Created:</b> " . date('d/m/Y H:i:s', self::$createdTime); if (self::$expire > 0) { $info .= "<b> Expire:</b> " . date('d/m/Y H:i:s', self::$expire + self::$createdTime); } else { $info .= "<b> Expire:</b> forever"; } self::$cache_list .= "<li>" . $info . "</li>"; } return false; } } } } return true; }
function draw() { global $display; $arrVar = array(); $this->beginForm(0); EClassApi::getCats(); $categories = eb_memcache::do_get('categories_new'); if (!is_array($categories)) { //if($total){ require_once ROOT_PATH . 'core/ECPagging.php'; $re = DB::query("SELECT * FROM products_category order by orders"); if ($re) { while ($row = mysql_fetch_assoc($re)) { $categories[$row['parent_id']][$row['id']] = $row; } } eb_memcache::do_put('categories_new', $categories); } $arrVar['zones'] = CGlobal::$allZones; $display->templateAdvance = TRUE; $display->setTemplate('ManageFilterSync', $arrVar); $this->endForm(); }
static function get_category($cat_id, $refresh = true) { if (is_numeric($cat_id) && $cat_id > 0) { $sql = 'SELECT * FROM news_category WHERE id=' . $cat_id . ' LIMIT 0, 1'; if ($refresh) { $query = DB::query($sql); $category = mysql_fetch_assoc($query); if (empty($category['shortcut'])) { if (empty($category['name_en'])) { $category['name_en'] = $category['name']; } $category['shortcut'] = strtolower(EClassApi::safe_title($category['name'])); } eb_memcache::do_put('news_category/' . $cat_id, $category, 5000); mysql_free_result($query); } else { $category = eb_memcache::do_get('news_category:' . $cat_id); if (empty($category)) { NewsCategory::get_category($cat_id, true); } } return $category; } }
function get_all_comment() { global $display; $winner = array(); global $user_id_arr, $stt, $item_per_page; $stt = 0; $is_admin_mod = array(); $user_arr = array(); $user_id_arr = array(); $items = array(); $limit = ''; $divID = 'comment_list_all'; $cmd = 'pagging_comment'; $url_path = WEB_DIR . "ajax.php?act=comment&code=display_feedback&show_all=1&id=" . Item::$id . "&cmd=" . $cmd; $item_per_page = 50; if (Url::get('show_all') || Url::get('cmd') == $cmd) { $display->add('show_all', true); } else { $display->add('show_all', false); } $pagging = ECPagging::fb_pagging($limit, $item_per_page, true, 'fb_page', $url_path, $divID); $sql = "SELECT id, time, content, item_id, sender_email, sender_user_name, sender_user_id, have_child,receiver_user_id,sub_item_id FROM comment WHERE item_id=" . Item::$item['id'] . " AND sub_item_id=0 AND parent_id = 0 ORDER BY order_time DESC {$limit}"; $comment_cache_version = eb_memcache::do_get("comment_cache:" . Item::$id . ":{$limit}:comment_cache_version"); $item_comment_cache_version = eb_memcache::do_get("comment_cache:" . Item::$id . ":comment_cache_version"); //echo "comment_cache:".Item::$id.":$limit:comment_cache_version".$item_comment_cache_version; if ($item_comment_cache_version != $comment_cache_version || $item_comment_cache_version == 0) { if ($item_comment_cache_version == 0) { $item_comment_cache_version = 1; eb_memcache::do_put("comment_cache:" . Item::$id . ":comment_cache_version", $item_comment_cache_version); } $items_all = $this->get_comment($sql); if ($items_all) { $items = $items_all['item']; if ($items_all['id_parent']) { $sql_sub = "SELECT id, time, content, item_id, sender_email, sender_user_name, sender_user_id,parent_id,receiver_user_id,sub_item_id FROM comment WHERE parent_id IN({$items_all['id_parent']}) ORDER BY order_time DESC"; $subComment_all = $this->get_comment($sql_sub, 1); if ($subComment_all) { $sub_comments = $subComment_all['item']; foreach ($sub_comments as $id => $subs) { if (isset($items[$id])) { $items[$id]['sub_comment'] = $subs; } } } } unset($items_all); unset($subComment_all); } $display->add('show_fb_page', true); $display->add('pagging', $pagging); if ($user_id_arr) { $uid = implode(',', $user_id_arr); if ($uid != '') { $re = DB::query("SELECT id, avatar_url, gids, block_time, img_server FROM account WHERE id IN({$uid})"); if ($re) { while ($user = mysql_fetch_assoc($re)) { $user_arr[$user['id']] = $user; } } } } if ($items && $user_arr) { foreach ($items as &$item) { //add by nhatvt $item['content'] = $this->process_description($item['content']); // echo $item['content'];exit; //end if (isset($item['sub_comment']) && $item['sub_comment']) { foreach ($item['sub_comment'] as &$sub_item) { if ($sub_item['sender_user_id']) { if (isset($user_arr[$sub_item['sender_user_id']])) { $sub_item['avatar_url'] = $user_arr[$sub_item['sender_user_id']]['avatar_url']; $sub_item['block_time'] = $user_arr[$sub_item['sender_user_id']]['block_time']; $sub_item['gids'] = $user_arr[$sub_item['sender_user_id']]['gids']; $sub_item['img_server'] = $user_arr[$sub_item['sender_user_id']]['img_server']; } if ($sub_item['avatar_url']) { $sub_item['sender_avatar_url'] = EClassApi::getImageThumb($sub_item['avatar_url'], 60, 0, 1, $sub_item['img_server']); if ($sub_item['parent_id'] > 0) { $html_content = '<a href="' . $sub_item['sender_link'] . '"><img src="' . $sub_item['sender_avatar_url'] . '" width="40" class="lazyload"/></a>'; } else { $html_content = '<a href="' . $sub_item['sender_link'] . '"><img src="' . $sub_item['sender_avatar_url'] . '" width="40" class="lazyload"/></a>'; } } else { $sub_item['sender_avatar_url'] = WEB_DIR . '_cache/eb_avatar/' . md5($item['sender_user_name']) . '.gif'; //'style/avatar/1.png'; $html_content = '<a href="' . $sub_item['sender_link'] . '"><img src="' . $sub_item['sender_avatar_url'] . '" width="40" height="40" class="lazyload"/></a>'; } if ($sub_item['block_time'] > TIME_NOW) { $sub_item['is_block'] = 1; } else { $sub_item['is_block'] = 0; } $sub_item['htmlContent'] = $html_content; //set quyen quan tri if ($sub_item['gids']) { $is_admin_mod = CGlobal::$group[User::check_admin($sub_item['gids'])]; } else { $is_admin_mod = array(); } $sub_item['is_admin_mod'] = $is_admin_mod; } } } if ($item['sender_user_id']) { if (isset($user_arr[$item['sender_user_id']])) { $item['avatar_url'] = $user_arr[$item['sender_user_id']]['avatar_url']; $item['block_time'] = $user_arr[$item['sender_user_id']]['block_time']; $item['gids'] = $user_arr[$item['sender_user_id']]['gids']; $item['img_server'] = $user_arr[$item['sender_user_id']]['img_server']; } if ($item['avatar_url']) { $item['sender_avatar_url'] = EClassApi::getImageThumb($item['avatar_url'], 60, 0, 1, $item['img_server']); $html_content = '<a href="' . $item['sender_link'] . '"><img src="' . $item['sender_avatar_url'] . '" width="40"/></a>'; } else { $item['sender_avatar_url'] = 'style/avatar/1.png'; $html_content = '<a href="' . $item['sender_link'] . '"><img src="style/avatar/3.png" width="40" height="40" /></a>'; } $item['htmlContent'] = $html_content; if ($item['block_time'] > TIME_NOW) { $item['is_block'] = 1; } else { $item['is_block'] = 0; } //set quyen quan tri if ($item['gids']) { $is_admin_mod = CGlobal::$group[User::check_admin($item['gids'])]; } else { $is_admin_mod = array(); } $item['is_admin_mod'] = $is_admin_mod; } } } if (User::is_login() && Item::$item['user_id'] == User::id()) { $account = User::$current->data; } else { if (isset(Item::$item['user_id'])) { $account = User::getUser(Item::$item['user_id']); } if (!$account) { $account = array('id' => 0, 'user_name' => '', 'create_time' => '', 'blast' => '', 'email' => '', 'show_email' => '', 'skype_id' => '', 'yahoo_id' => ''); } } if (User::is_login()) { if (User::$current->data['mobile_phone'] != '') { $display->add('user_phone', true); $user_phone = User::$current->data['mobile_phone']; } elseif (User::$current->data['home_phone'] != '') { $display->add('user_phone', true); $user_phone = User::$current->data['home_phone']; } else { $display->add('user_phone', false); $user_phone = ''; } $display->add('cur_user_name', User::$current->data['user_name']); $display->add('cur_created_time', User::$current->data['create_time']); $cur_user_name = User::$current->data['user_name']; $cur_created_time = User::$current->data['create_time']; if (User::$current->data['avatar_url'] == '') { $cur_avatar_url = 'style/avatar/1.png'; } else { $cur_avatar_url = EClassApi::getImageThumb(User::$current->data['avatar_url'], 60, 0, 1, User::$current->data['img_server']); } } else { $cur_user_name = ''; $cur_created_time = ''; $user_phone = ''; $cur_avatar_url = 'style/avatar/2.png'; $display->add('cur_user_name', ''); $display->add('cur_created_time', ''); $display->add('check_user_name', ''); $display->add('user_phone', false); } $guest_name = 'Số điện thoại'; $guest_email = 'Email'; if (isset($_COOKIE['guest_name'])) { if ($_COOKIE['guest_name'] == 'undefined' || $_COOKIE['guest_email'] == 'undefined') { $guest_name = 'Số điện thoại'; $guest_email = 'Email'; } else { $guest_name = $_COOKIE['guest_name']; $guest_email = $_COOKIE['guest_email']; } } $display->add('cur_user_name', $cur_user_name); $display->add('guest_name', $guest_name); $display->add('guest_email', $guest_email); $display->add('check_user_name', $account['user_name']); $display->add('cur_id', (int) User::id()); //$display->add('msg',$this->showFormErrorMessages(1)); //$display->add('pagging',$pagging); // System::debug($items); $display->add('item_comments', $items); $display->add('item_id', Item::$item['id']); $display->add('category_id', Item::$item['category_id']); $display->add('item_name', Item::$item['name']); //rewrite URL $display->add('name_url', EClassApi::safe_title(Item::$item['name'])); //End rewrite URL Item::$item['currency_id'] = 1; $display->add('currency_id', CGlobal::$currency[Item::$item['currency_id']]); $display->add('total_feedback', Item::$item['reply_count']); if (strtolower(Url::get('page')) == 'allfeedback' || Url::get('cmd') == $cmd) { echo '<div id="totalReplyCount" style="display:none;">' . Item::$item['reply_count'] . '</div>'; } //echo EClassApi::parseBBCode($display->output('AllFeedback',true)); $template = $display->output('AllFeedbackListold', true, 'AllFeedback'); //$display->output('FeedBackItemList',false,'AllFeedback'); eb_memcache::do_put("comment_cache:" . Item::$id . ":{$limit}", $template); eb_memcache::do_put("comment_cache:" . Item::$id . ":{$limit}:comment_cache_version", $item_comment_cache_version); //echo "updated:comment_cache:".Item::$id.":$limit:comment_cache_version".$item_comment_cache_version; echo $template; } else { //echo "cached:".Item::$id.":$limit:comment_cache_version".$item_comment_cache_version; $template = eb_memcache::do_get("comment_cache:" . Item::$id . ":{$limit}"); echo $template; } EClassApi::update_cache_comment(Item::$id); }
public function getItemAdvertiseById($id) { $item = ''; if (MEMCACHE_ON) { $item = eb_memcache::do_get('item_advertise_widget_' . $id); } if (!$item) { $result = DB::query("SELECT * FROM advertise WHERE status = 1 AND id = {$id}"); $item = array(); if ($result) { while ($row = mysql_fetch_assoc($result)) { $row['image'] = EClassApi::getImageThumb($row['images'], 130, 110, 0, IMAGE_SERVER_NO); $row['price'] = EClassApi::numberFormat($row['price']); $item = $row; } eb_memcache::do_put('item_advertise_widget_' . $id, $item); } } return $item; }
<?php require_once '../../../core/config.php'; //System Config... require_once '../../../core/Init.php'; //System Init... require_once '../../../core/DB.php'; //System Api... $token = Url::get('t', ''); $user = eb_memcache::do_get($token); if (!$user) { Util::requestToMobile(false, 19); } $user = eb_memcache::do_remove($token); // $_SESSION['token']=''; User::LogOut(); Util::requestToMobile(true, 35);
static function notExistCache($filePath, $exp_time = 0, $handleContent = false, $subDir = '') { self::$curentContent = ''; self::$handleContent = $handleContent; if (!CACHE_ON) { //Nếu tắt chế độ cache return true; } if (MEMCACHE_ON) { //Nếu bật chế độ mem_cache if ($subDir != '') { $filePath = $subDir . '/' . $filePath; } self::$curentCacheFilePath = $filePath; self::$curentExpTime = $exp_time; if (isset($_GET['delscache']) && (int) $_GET['delscache'] == '1') { self::delCache($filePath); return true; } $s_content = eb_memcache::do_get("scache:{$filePath}"); if ($s_content !== false) { if (DEBUG) { self::$cNum++; self::$pNum++; if (class_exists('Module') && Module::$name != '') { $module_name = Module::$name; } else { $module_name = "-- Enbac system"; } $info = "<b>" . $module_name . "</b><br /><font color=red><b>" . self::$curentCacheFilePath . "</b></font><br /><b>Cache Time:</b> " . $exp_time . "s "; if ($exp_time > 0) { $info .= "<b> Expire:</b> {$exp_time} sec"; } else { $info .= "<b> Expire:</b> forever"; } self::$cacheFilesList .= "<li>" . $info . "</li>"; } if (self::$handleContent) { self::$curentContent = $s_content; } else { echo $s_content; } return false; } } else { if ($subDir != '') { EClassApi::CheckDir(DIR_CACHE . 'html/' . $subDir . '/', MEMCACHE_ON); $filePath = $subDir . '/' . $filePath; } else { EClassApi::CheckDir(DIR_CACHE . 'html/', MEMCACHE_ON); } self::$curentCacheFilePath = DIR_CACHE . 'html/' . $filePath . '.html'; self::$curentExpTime = $exp_time; if (isset($_GET['delscache']) && (int) $_GET['delscache'] == '1') { self::delCache($filePath); return true; } if (file_exists(self::$curentCacheFilePath)) { if ($exp_time > 0) { $filemtime = filemtime(self::$curentCacheFilePath); if (TIME_NOW > $filemtime + $exp_time) { return true; } } else { $filemtime = 0; } if (DEBUG) { self::$cNum++; self::$pNum++; if (class_exists('Module') && Module::$name != '') { $module_name = Module::$name; } else { $module_name = "-- Enbac system"; } $info = "<b>" . $module_name . "</b><br /><font color=red><b>" . self::$curentCacheFilePath . "</b></font><br /><b>Cache Time:</b> " . $exp_time . "s "; $info .= "<b>Created:</b> " . date('d/m/Y H:i:s', $filemtime); if ($exp_time > 0) { $info .= "<b> Expire:</b> " . date('d/m/Y H:i:s', TIME_NOW + $exp_time); } else { $info .= "<b> Expire:</b> forever"; } self::$cacheFilesList .= "<li>" . $info . "</li>"; } if (self::$handleContent) { self::$curentContent = file_get_contents(self::$curentCacheFilePath); } else { echo file_get_contents(self::$curentCacheFilePath); } return false; } } return true; }
function draw() { global $display; $arrVar = array(); $this->beginForm(); EClassApi::getCats(); $where = ''; $filter_id = Url::get('filter_id', ''); $filter_name = Url::get('filter_name', ''); $cat_product_id = Url::get('cat_product_id', ''); $zone_id = Url::get('zone_id', ''); $arrVar['zone_id'] = $zone_id; $arrVar['cat_product_id'] = $cat_product_id; if ($filter_id) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " id = '{$filter_id}' "; $arrVar['filter_id'] = $filter_id; } if ($filter_name) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " filter_name = '{$filter_name}' "; $arrVar['filter_name'] = $filter_name; } if ($cat_product_id) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " cat_product_id = '{$cat_product_id}' "; } else { if ($zone_id) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " zone_id = '{$zone_id}' "; } } $item_per_page = 50; $limit = ''; $item_vips = array(); $sql_count = "SELECT COUNT(*) AS total FROM products_filter {$where} "; $total = DB::fetch($sql_count, 'total', 0); $paging = ''; $filters = array(); if ($total) { require_once ROOT_PATH . 'core/ECPagging.php'; $paging = ECPagging::pagingSE($limit, $total, $item_per_page, 20, 'page_no', true); $re = DB::query("SELECT * FROM products_filter {$where} order by orders {$limit}"); if ($re) { while ($row = mysql_fetch_assoc($re)) { $filters[$row['id']] = $row; } } } $categories = eb_memcache::do_get('categories_new'); if (!is_array($categories)) { //if($total){ require_once ROOT_PATH . 'core/ECPagging.php'; $re = DB::query("SELECT * FROM products_category order by orders"); if ($re) { while ($row = mysql_fetch_assoc($re)) { $categories[$row['parent_id']][$row['id']] = $row; } } eb_memcache::do_put('categories_new', $categories); } print_category($categories, 0, $options, $zone_id, $cat_product_id); $arrVar['options'] = $options; $arrVar['zones'] = CGlobal::$allZones; $arrVar['filters'] = $filters; $arrVar['paging'] = $paging; $display->templateAdvance = TRUE; $display->setTemplate('ManageFilter', $arrVar); $this->endForm(); }
function getItemVipCat() { EClassApi::getCities(); EClassApi::getCats(); //get ID VIP CAT if (MEMCACHE_ON) { $category_id = CGlobal::$curCategory; $id_vip_cat = eb_memcache::do_get("id_vip_cat:{$category_id}"); if (!$id_vip_cat || $id_vip_cat['ex_time'] < TIME_NOW) { $id_vip_cat = $this->getIdVipCat(); eb_memcache::do_put("id_vip_cat:{$category_id}", $id_vip_cat); } } else { $id_vip_cat = $this->getIdVipCat(); } $str_item_id = ''; if (isset($id_vip_cat['id'])) { foreach ($id_vip_cat['id'] as $val) { $str_item_id .= $str_item_id != '' ? ",{$val}" : "{$val}"; } } $items = array(); if ($str_item_id != '') { $sql = 'SELECT id, name, up_time, created_time, user_id, user_name, description, city_id, category_id, currency_id, price, original_image_url, img_server FROM item WHERE'; $where = ''; $where .= ($where != '' ? " AND " : "") . " id IN({$str_item_id})"; $where .= ($where != '' ? " AND " : "") . " (status=1 OR status = 2)"; $sql .= "{$where} ORDER BY up_time DESC"; $items = array(); $re = DB::query($sql); if ($re) { while ($value = mysql_fetch_assoc($re)) { $value['price'] = EClassApi::convertCurrency($value['price'], $value['currency_id']); $value['currency_id'] = 1; if (isset(CGlobal::$allCategories[$value['category_id']])) { $value['href'] = WEB_DIR . ECRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . EClassApi::safe_title($value['name']) . '&nice_name=' . CGlobal::$allCategories[$value['category_id']]['nice_name']); } else { $value['href'] = WEB_DIR . ECRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . EClassApi::safe_title($value['name'])); } $value['item_time'] = date('h:i | d.m', $value['created_time']); $value['price_name'] = 'Giá bán'; $value['item_type'] = 'Giao dịch bán'; $value['name'] = strip_tags(EClassApi::filter_title($value['name'])); if ($value['price'] && $value['price'] > 0) { $value['price'] = number_format($value['price'], 0, ',', '.'); $value['currency_id'] = CGlobal::$currency[$value['currency_id']]; } else { $value['price'] = 'Liên hệ'; $value['currency_id'] = ''; } if ($value['original_image_url']) { $value['original_image_url'] = EClassApi::getImageThumb($value['original_image_url'], 80, 80, 0, $value['img_server']); } else { $value['original_image_url'] = 'style/images/no-images-69x53.jpg'; } $value['profile_url'] = WEB_DIR . $value['user_name']; $value['user_name_title'] = $value['user_name']; $value['user_name'] = strlen($value['user_name']) > 10 ? substr($value['user_name'], 0, 10) . '...' : $value['user_name']; if (isset(CGlobal::$cities[$value['city_id']])) { $value['city'] = CGlobal::$cities[$value['city_id']]['name']; } else { $value['city'] = "Toàn quốc"; } $value['vip_cat_img'] = "style/images/item-list/item_vip.gif"; $value['can_buy'] = 0; $items[$value['id']] = $value; } } } // $items['str_item_id'] = $str_item_id; return $items; }
function update_user_online(){ $user_id = isset($_SESSION['user_id'])?(int)$_SESSION['user_id']:0; if($user_id) { $session_id = session_id(); $page =''; $page_id =0; $user_name = isset($_SESSION['user_name'])?$_SESSION['user_name']:0; $login_type = (isset($_SESSION['openid_url']) && $_SESSION['openid_url']!='')?1:0; $open_id = (isset($_SESSION['openid_url']) && $_SESSION['openid_url']!='')?$_SESSION['openid_url']:''; if(class_exists('EClass')){ $page =EClass::$page['name']; $page_id =(int)EClass::$page['id']; } if(($page=='ItemDetail' || $page=='item_detail') && isset($_GET['id']) && $_GET['id']){ $item_id=(int)$_GET['id']; } else{ $item_id=0; } if(in_array(basename($_SERVER['PHP_SELF']),array('ebxml.php','ajax.php','captcha.php'))){ $ref_url=''; } else{ EClassApi::check_uri(); $ref_url=CGlobal::$query_string; } $sql = "SELECT session_referer, page, page_id, item_id FROM "._SESS_TABLE." WHERE session_id = '$session_id'"; $result = DB::query($sql,__LINE__.__FILE__); if (mysql_num_rows($result)) { $s_row = mysql_fetch_assoc($result); } else{ $s_row = array(); } if($s_row){ if($ref_url=='' || in_array(basename($_SERVER['PHP_SELF']),array('ebxml.php','ajax.php','captcha.php'))){ $ref_url=stripslashes($s_row['session_referer']); } if(!$page) $page = $s_row['page'] ; if(!$page_id) $page_id = (int)$s_row['page_id'] ; if(!$item_id) $item_id = (int)$s_row['item_id'] ; $sql = "UPDATE "._SESS_TABLE." SET session_expires = ".time().", session_referer = '".addslashes($ref_url)."', session_ip = '".$_SERVER['SERVER_ADDR'].'::'.$_SERVER['REMOTE_ADDR']."', page = '$page', page_id = $page_id, category_id = ".CGlobal::$curCategory.", item_id = $item_id, user_id = '$user_id', user_name = '$user_name', login_type = '$login_type', open_id = '$open_id' WHERE session_id = '$session_id'"; } else{ $sql = "INSERT INTO "._SESS_TABLE." ( session_id, session_expires, session_referer, session_ip, page, page_id, category_id, item_id, user_id, user_name, login_type, open_id ) VALUES ( '$session_id', ".time().", '".addslashes($ref_url)."', '".$_SERVER['SERVER_ADDR'].'::'.$_SERVER['REMOTE_ADDR']."', '$page', $page_id, ".CGlobal::$curCategory.", $item_id, $user_id , '$user_name' , $login_type , '$open_id')"; } DB::query($sql,__LINE__.__FILE__); if(User::is_login() && MEMCACHE_ON){//Nếu đã đăng nhập $user = User::$current->data; if($user && !isset($user['last_login']) || (isset($user['last_login']) && $user['last_login']<(TIME_NOW-300))){ DB::query("UPDATE account SET last_login="******" WHERE id={$user['id']}"); $user_memcache = eb_memcache::do_get("user:{$user['id']}"); if($user_memcache){ $user_memcache['last_login'] = TIME_NOW; eb_memcache::do_put("user:{$user['id']}", $user_memcache); } } } } }
static function get() { if (isset($_GET['delcache']) && (int) $_GET['delcache'] == 1) { self::auto_delete(self::_my_file()); return false; } if (MEMCACHE_ON) { $arr = eb_memcache::do_get("qcache:" . self::_my_file()); if ($arr !== false) { return $arr; } } else { $cfile = DIR_CACHE . 'db/' . self::_my_file(); if (file_exists($cfile)) { self::$createdTime = filemtime($cfile); if (self::$expire > 0 && TIME_NOW < self::$createdTime + self::$expire || self::$expire == 0) { return unserialize(stripslashes(@file_get_contents($cfile))); } } } return false; }
function submit_payandship() { /*$site_code = Url::get('site_code',""); $secure_hash = Url::get('secure_hash',"");*/ $user_id = Url::get('user_id'); $status = Url::get('status'); $msg = ""; /*if(!$site_code || !$secure_hash){ if(DB::update('account',array('payship' => $payType, 'soha_site_code' => '', 'soha_secure_hash' => ''),'id='.$user_id)){ DB::update('account_payship',array('status' => 1),'account_id='.$user_id); $msg = "success_des"; } } else*/ if ($status != 0) { $payType = 0; $userStatus = 1; } else { $payType = 2; $userStatus = 3; } if (DB::update('account', array('payship' => $payType), 'id=' . $user_id)) { DB::update('account_payship', array('status' => $userStatus), 'account_id=' . $user_id); if ($payType == 0) { $msg = "success_des"; } else { $msg = "success"; } } if (MEMCACHE_ON) { $user = eb_memcache::do_get("user:{$user_id}"); if ($user) { $user['payship'] = $payType; //$user['soha_site_code'] = $site_code; //$user['soha_secure_hash'] = $secure_hash; eb_memcache::do_put("user:{$user_id}", $user); } } echo $msg; exit; }
function draw() { global $display; $arrVar = array(); $this->beginForm(1); $arrVar['id'] = Url::get('id', 0); $options = ""; if ($arrVar['id'] == 0) { Url::redirect_current(); } EClassApi::getCats(); $where = ''; $filter = DB::fetch_all_array("select * from products_filter where id={$arrVar['id']}"); $filte_value = json_decode($filter[0]['filter_value']); $arrVar['filter'] = $filter[0]; $arrVar['filter_value'] = $filte_value; $item_per_page = 50; $limit = ''; $sql_count = "SELECT COUNT(*) AS total FROM products_extra_fields_group {$where}"; $total = DB::fetch($sql_count, 'total', 0); if ($total) { require_once ROOT_PATH . 'core/ECPagging.php'; $paging = ECPagging::pagingSE($limit, $total, $item_per_page, 10, 'page_no', true, 'Nhóm trường', 'Trang'); $re = DB::query("SELECT * FROM products_extra_fields_group {$where} order by id desc {$limit}"); if ($re) { while ($row = mysql_fetch_assoc($re)) { $products_extra_fields_group[$row['id']] = $row; } } } $filter_count = 0; foreach ($filte_value as $key => $val) { if ($filter_count < $val->order) { $filter_count = $val->order; } } if (count($filte_value) > $filter_count) { $filter_count = count($filte_value); } $categories = eb_memcache::do_get('categories_new'); if (!is_array($categories)) { //if($total){ require_once ROOT_PATH . 'core/ECPagging.php'; $re = DB::query("SELECT * FROM products_category order by orders"); if ($re) { while ($row = mysql_fetch_assoc($re)) { $categories[$row['parent_id']][$row['id']] = $row; } } eb_memcache::do_put('categories_new', $categories); } print_category($categories, 0, $options, $filter[0]['zone_id'], $filter[0]['cat_product_id']); $arrVar['options'] = $options; $arrVar['filter_count'] = $filter_count; $arrVar['zones'] = CGlobal::$allZones; $arrVar['paging'] = $paging; $arrVar['products_extra_fields_group'] = $products_extra_fields_group; $display->templateAdvance = TRUE; $display->setTemplate('ManageFilterEdit', $arrVar); $this->endForm(); }
function update_notify_read() { $total_new_comment = 0; $total_comment_user = 0; $total_pm = 0; $item_ids_ar = Url::get('item_ids_ar', ''); $item_ids_ar2 = Url::get('item_ids_ar2', ''); $c_user_ids_ar = Url::get('c_user_ids_ar', ''); $pm_ids_ar = Url::get('pm_ids_ar', ''); if ($item_ids_ar) { //Mảng item_id cập nhật bỏ qua cho các feed chủ thể tương ứng khi giao dịch bị xoá hoặc khoá! $item_ids = explode(',', $item_ids_ar); DB::query("UPDATE comment SET status=1 WHERE item_id IN({$item_ids_ar})"); $total_new_comment -= count($item_ids); } if ($item_ids_ar2) { //Mảng item_id cập nhật bỏ qua cho các feed khách thể tương ứng khi giao dịch bị xoá hoặc khoá! $item_ids = explode(',', $item_ids_ar2); DB::query("UPDATE comment SET replied_status=1 WHERE item_id IN({$item_ids_ar2})"); $total_new_comment += count($item_ids); } if ($c_user_ids_ar) { $u_user_ids = explode(',', $c_user_ids_ar); DB::query("UPDATE comment_user SET status=1 WHERE id IN({$c_user_ids_ar})"); $total_comment_user += count($u_user_ids); } if ($pm_ids_ar) { $pm_ids = explode(',', $pm_ids_ar); DB::query("UPDATE message_topics SET mt_read=1 WHERE mt_id IN({$pm_ids_ar})"); $total_pm += count($pm_ids); } if ($unread_feed_ids != '' && $unread_feed_ids != 0) { DB::query("UPDATE feed SET status=1 WHERE id IN({$unread_feed_ids})"); } if ($total_new_comment || $total_comment_user || $total_pm) { $update_sql = ""; if ($item_comment_ids) { //$total_new_comment = User::$current->data['total_new_comment'] - $total_new_comment; //$total_new_comment = DB::fetch("SELECT count(*) AS total_feed FROM feed WHERE user_id = ".User::id()." AND type IN(1,2) AND status=0 AND time>".(TIME_NOW-15*24*3600),'total_feed',0); //$total_new_comment = DB::fetch("SELECT count(*) AS total_feed FROM comment WHERE receiver_user_id = ".User::id()." AND mt_read=0 AND mt_vid_folder='inbox' AND mt_date>".(TIME_NOW-15*24*3600),'total_feed',0); //$update_sql.="total_new_comment=$total_new_comment"; $total_new_comment = 0; $update_sql .= "total_new_comment={$total_new_comment}"; } if ($total_comment_user) { //$total_comment_user = User::$current->data['total_comment_user'] - $total_comment_user; //$total_comment_user = DB::fetch("SELECT count(*) AS total_feed FROM feed WHERE user_id = ".User::id()." AND type = 3 AND status=0 AND time>".(TIME_NOW-15*24*3600),'total_feed',0); $total_comment_user = DB::fetch("SELECT count(*) AS total_feed FROM comment_user WHERE receiver_user_id = " . User::id() . " AND status=0 AND sender_user_id != " . User::id() . " AND time>" . (TIME_NOW - 15 * 24 * 3600), 'total_feed', 0); $update_sql .= ($update_sql != '' ? ', ' : '') . "total_comment_user={$total_comment_user}"; } if ($total_pm) { //$total_pm = User::$current->data['total_pm'] - $total_pm; //$total_pm = DB::fetch("SELECT count(*) AS total_feed FROM feed WHERE user_id = ".User::id()." AND type = 4 AND status=0 AND time>".(TIME_NOW-15*24*3600),'total_feed',0); $total_pm = DB::fetch("SELECT count(*) AS total_feed FROM message_topics WHERE mt_owner_id = " . User::id() . " AND mt_read=0 AND mt_vid_folder='inbox' AND mt_date>" . (TIME_NOW - 15 * 24 * 3600), 'total_feed', 0); $update_sql .= ($update_sql != '' ? ', ' : '') . "total_pm={$total_pm}"; } if ($update_sql != '') { DB::query("UPDATE account SET {$update_sql} WHERE id=" . User::id()); if (MEMCACHE_ON) { $user_memcache = eb_memcache::do_get("user:"******"user:" . User::id(), $user_memcache); } } else { User::getUser(User::id(), 0, 1); } } } echo 'success'; exit; }
static function update_cache_comment($item_id) { if (MEMCACHE_ON) { $item_comment_cache_version = eb_memcache::do_get("comment_cache:" . $item_id . ":comment_cache_version"); eb_memcache::do_put("comment_cache:" . $item_id . ":comment_cache_version", $item_comment_cache_version + 1); } }
static function getUser($user_id, $update_cache = false, $delcache = false) { $user = array(); /*if($user_id){ $subDir='user/'.floor($user_id/1000); $user = ECCache::cache('SELECT * FROM account WHERE id='.(int)$user_id.' LIMIT 0,1',__LINE__.__FILE__,2592000,$update_cache,'',$subDir,$delcache); } if($user&&!$delcache){ $user[0]['is_block'] = ($user[0]['block_time']>TIME_NOW || $user[0]['block_time']==-1)?true:false; return $user[0]; }*/ if ($user_id) { if (MEMCACHE_ON) { if ($delcache || $update_cache) { //Xoá cache if (MEMCACHE_ON) { eb_memcache::do_remove("user:$user_id"); } return true; } else { if (MEMCACHE_ON) { $user = eb_memcache::do_get("user:$user_id"); } if (!$user) { $sql = "SELECT * FROM account WHERE id=" . (int)$user_id . " LIMIT 1"; $user = mysql_fetch_assoc(DB::query($sql)); //$user['is_block'] = ($user['block_time']>TIME_NOW || $user['block_time']==-1)?true:false; if (MEMCACHE_ON && $user) { eb_memcache::do_put("user:$user_id", $user); } } } } else { //cache file //echo "ddđ"; exit(); $subDir = 'user/' . floor($user_id / 1000); $user = ECCache::cache('SELECT * FROM account WHERE id=' . (int)$user_id . ' LIMIT 0,1', __LINE__ . __FILE__, 2592000, intval($update_cache), '', $subDir, $delcache); if ($user && !$delcache) { $user[0]['is_block'] = ($user[0]['block_time'] > TIME_NOW || $user[0]['block_time'] == -1) ? true : false; return $user[0]; } } } return $user; }
static function getFields($table_name, $call_pos = '') { $fields = false; if (MEMCACHE_ON && isset($_GET['delcache']) && $_GET['delcache'] == 1) { eb_memcache::do_remove('fields_' . $table_name); } if (MEMCACHE_ON && !isset($_GET['delcache'])) { $fields = eb_memcache::do_get('fields_' . $table_name); } if (!$fields) { $q_select = "SHOW COLUMNS FROM {$table_name}"; self::query($q_select, $call_pos); if (self::$db_result) { while ($r = mysql_fetch_assoc(self::$db_result)) { $fields[$r['Field']]['key'] = $r['Key']; $fields[$r['Field']]['extra'] = $r['Extra']; $fields[$r['Field']]['name'] = $r['Field']; $fields[$r['Field']]['data'] = ''; $strLength = strlen($r['Type']); $len = stripos($r['Type'], '(') - $strLength; $fields[$r['Field']]['type'] = substr($r['Type'], 0, $len); $fields[$r['Field']]['type_length'] = substr($r['Type'], stripos($r['Type'], '(') + 1, -1); } if (MEMCACHE_ON) { eb_memcache::do_put('fields_' . $table_name, $fields, 0); } } } $curTable['fields'] = $fields; return $curTable; }