function item_history() { $itemids = Url::get('itemids'); $item_history = array(); if ($itemids) { $itemids = explode(',', $itemids); if (is_array($itemids)) { foreach ($itemids as $key) { $item = Item::get_item($key); if ($item) { unset($item['description'], $item['post_ip'], $item['created_time']); $item_['item_id'] = $item['id']; $item_['item_url'] = "p" . $item['id'] . "/" . EClassApi::safe_title($item['name']) . ".html"; $item_['item_title'] = ucfirst(EnbacLib::remove_4_js($item['name'])); $item_['price'] = $item['price'] ? number_format(EClassApi::convertCurrency($item['price'], $item['currency_id']), 0, ',', '.') : 'Liên hệ'; $item_['item_image'] = $item['original_image_url'] ? EClassApi::getImageThumb($item['original_image_url'], 120, 105, 0, $item['img_server']) : ''; $item_history[] = $item_; unset($item); } } } /* $re = DB::query("SELECT id, name, price, currency_id, original_image_url, img_server, status, state FROM item WHERE id IN($itemids) ORDER BY find_in_set(id, '$itemids')"); if ($re) { while ($fitem = mysql_fetch_assoc($re)) { if ($fitem['status'] == 1 && $fitem['state'] == 0) { $item['item_id'] = $fitem['id']; $item['item_url'] = "p" . $fitem['id'] . "/" . EClassApi::safe_title($fitem['name']) . ".html"; $item['item_title'] = ucfirst(EnbacLib::remove_4_js($fitem['name'])); // $item['price'] = $fitem['price']?number_format($fitem['price'],0,',','.'):'Liên hệ'; $item['price'] = $fitem['price'] ? number_format(EClassApi::convertCurrency($fitem['price'], $fitem['currency_id']), 0, ',', '.') : 'Liên hệ'; //$item['item_image'] = ($fitem['original_image_url']) ? EClassApi::getImageThumbIn($fitem['original_image_url'],150,120,$fitem['img_server']) : ''; $item['item_image'] = ($fitem['original_image_url']) ? EClassApi::getImageThumb($fitem['original_image_url'], 120, 105, 0, $fitem['img_server']) : ''; $item_history[] = $item; } } }*/ } echo json_encode($item_history); }
/** * List product base condition filter * * @author MinhNV * Date 2010/07/09 */ private function getListProductByFilter() { $isRelatedProduct = Url::get('isRelatedProduct', 0); $urlRelatedProduct = $isRelatedProduct ? '&isRelatedProduct=' . $isRelatedProduct : ''; $url_filter = Url::get('url_filter'); $category_id = EnbacLib::getParamInt('cat_id'); //Url::get ( 'cat_id', 0 ); $check_price = Url::get('check_price', 0); $txt_search_product = Url::get('txt_search_product'); $is_new = Url::get('is_new', 0); $is_discount_new = Url::get('is_discount_new', 0); $is_discount = Url::get('is_discount', 0); $cur_page = Url::get('page_no', 0); $query = ''; $fq = array(); $fq[] = "published:1 AND status:1 AND is_solo_buy: 1 AND price_solo: [1 TO *]"; //lay ra tat ca san pham hay la san pham dang ban if (isset($_REQUEST['type_list_pro'])) { $type_list_pro = EnbacLib::getParamInt('type_list_pro'); if ($type_list_pro) { $fq[] = "published:1 AND status:1 AND is_solo_buy:1 AND price_solo: [1 TO *]"; } else { $fq[] = "published:1 AND status:1"; } } //$query .= "published:1 AND "; if ($category_id > 0) { $query .= "category_id:" . $category_id . " AND "; } if ($check_price == 1) { $query .= "(min_price:[1 TO *] OR min_price_fake:[1 TO *]) AND "; } if ($txt_search_product != '') { $objLib = new SoLib(); $query .= "name:" . $objLib->escapeSolrKeyword($txt_search_product) . " AND "; } $q_special = ''; //Hang moi if ($is_new == 1) { $q_special .= " ( is_new:1 "; } //Hang moi giam gia if ($is_discount_new == 1) { if ($q_special == '') { $q_special .= " ( is_discount_new:[1 TO *] "; } else { $q_special .= " OR is_discount_new:[1 TO *] "; } } //Hang pha gia if ($is_discount == 1) { if ($q_special == '') { $q_special .= " ( is_discount:1 "; } else { $q_special .= " OR is_discount:1 "; } } if ($q_special != '') { $q_special .= " ) AND "; $query .= $q_special; } if ($url_filter) { $query .= $this->buildConditionSearchSolr($url_filter); } if (strlen($query) > 0) { $query = substr($query, 0, strlen($query) - 4); } $aryProduct = array(); $aryData = array(); if ($query != "") { $solr = Solr::getInstanceProduct(); $start = 0; $offset = self::NUMBER_PER_PAGE; //$query = "*:*"; $responseCheck = $solr->search($query, 0, 0); $total_row = 0; $paging = ''; $params = array(); $params['fl'] = 'id, name, min_price, max_price, num_classified, images, date, description'; $params['fq'] = $fq; if ($responseCheck) { if ($responseCheck->getHttpStatus() == 200) { $total_row = $responseCheck->response->numFound; if ($total_row > 0) { $url_path = 'ajax.php?act=so_advanced&code=get_list_product_filter' . $urlRelatedProduct; //lay ra tat ca san pham hay la san pham dang ban if (isset($_REQUEST['type_list_pro'])) { $url_path .= '&type_list_pro=' . $type_list_pro; } if ($category_id > 0) { $url_path .= "&cat_id=" . $category_id; } if ($check_price == 1) { $url_path .= "&check_price=" . $check_price; } if ($txt_search_product != '') { $url_path .= "&txt_search_product=" . $txt_search_product; } if ($url_filter) { $url_path .= "&url_filter=" . $url_filter; } if ($is_new == 1) { $url_path .= "&is_new=" . $is_new; } if ($is_discount_new == 1) { $url_path .= "&is_discount_new=" . $is_discount_new; } if ($is_discount == 1) { $url_path .= "&is_discount=" . $is_discount; } //$url_path = 'ajax.php?act=so_advanced&code=get_list_product_filter&url_filter=' . $url_filter.$urlRelatedProduct. '&cat_id='.$category_id; //BMPaging::AjaxPagingSolr ( $paging, $start, $total_row, $offset, self::NUMBER_PAGE_SHOW/*CGlobal::$number_per_page, CGlobal::$number_pages_show*/, 'page_no', true, $url_path, 'paging_ajax_filter_template' ); //echo $start; $response = $solr->search($query, $start, $offset, $params); if ($response->getHttpStatus() == 200) { $total_row = $response->response->numFound; if ($total_row > 0) { $i = 0; foreach ($response->response->docs as $doc) { $aryProduct[$i]['id'] = $doc->id; $aryProduct[$i]['name'] = $doc->name; $aryProduct[$i]['min_price'] = number_format($doc->min_price, 0, '.', '.'); $aryProduct[$i]['max_price'] = number_format($doc->max_price, 0, '.', '.'); $aryProduct[$i]['num_classified'] = $doc->num_classified; $aryProduct[$i]['description'] = $doc->description; $aryProduct[$i]['images'] = SoImg::getImage($doc->images, $doc->id, SoImg::FOLDER_PRODUCT, $doc->date, '70x0'); $i++; } BMPaging::AjaxPagingSolr($paging, $start, $total_row, $offset, self::NUMBER_PAGE_SHOW, 'page_no', true, $url_path, 'paging_ajax_filter_template'); } } else { //$aryData ['msg'] = 'Query solr thất bại.'; $aryData['intIsOK'] = -1; } if (is_array($aryProduct) && count($aryProduct) > 0) { global $display; $display->add('aryProduct', $aryProduct); $display->add('paging', $paging); $display->add('total_row', $total_row); if ($isRelatedProduct) { $aryHtml = $display->output('ListRelatedProduct', true, 'SoManageProducts'); } else { $aryHtml = $display->output('list_product', true, 'SoBoxAdvanced'); } $aryData['htmlProduct'] = $aryHtml; $aryData['intIsOK'] = 1; } } } else { //$aryData ['msg'] = 'Query solr thất bại.'; $aryData['intIsOK'] = -1; } } else { //$aryData ['msg'] = 'Query solr thất bại.'; $aryData['intIsOK'] = -1; } } echo json_encode($aryData); exit; //} }
function fn_invalid_user() { if (!User::is_login() || !User::have_permit(array(ADMIN_USER, MOD_VALID_USER))) { echo "no_perm"; exit; } $user_id = (int) Url::get('user_id', 0); $invalid_time = (int) Url::get('invalid_time', 0); $date_invalid = (int) Url::get('date_invalid', 0); $type_invalid = (int) Url::get('type_invalid', 0); $reason_invalid = EnbacLib::getParam('reason_invalid', ''); $reason_invalid = $reason_invalid ? $reason_invalid : 'Không nhập lý do kiểm duyệt'; $user = User::getUser($user_id); if ($user['invalid_time'] > 0 || $user['invalid_time'] == -1) { if (DB::update('account', array('invalid_time' => "0"), 'id =' . $user_id)) { $sql_select_reason = 'SELECT id,admin_name,time FROM acc_lock WHERE user_id = ' . $user_id . ' AND type = 2 ORDER BY id DESC LIMIT 1'; $user_invalid = DB::fetch($sql_select_reason); if (MEMCACHE_ON) { $sql = "SELECT * FROM item\t\n\t\t\t\t\t\t\t WHERE user_id = {$user_id} AND status = 2 AND valid_time = {$user_invalid['time']} AND modify_time_user = 0 AND valid_user ='******'admin_name']}'"; $re = DB::query($sql); while ($item_memcache = mysql_fetch_assoc($re)) { $item_memcache['status'] = 1; $item_memcache['valid_time'] = TIME_NOW; $item_memcache['valid_user'] = User::user_name(); eb_memcache::do_put("item:" . $item_memcache['id'], $item_memcache); //update realtime if (SORL_FILTER_ON) { $solr = new Solr_Search(); $solr->doUpdateItem($item_memcache['id']); } //----- } } if (User::have_permit(array(ADMIN_USER))) { // chi admin quyen User moi duoc mo kiem duyet thanh vien DB::update('item', array('status' => 1, 'valid_time' => TIME_NOW, 'valid_user' => User::user_name()), 'user_id = ' . $user_id . ' AND status = 2 AND valid_time = ' . $user_invalid['time'] . ' AND modify_time_user = 0 AND valid_user ="******"'); DB::update('acc_lock', array('unlock_time' => TIME_NOW, 'unlock_user' => User::user_name()), 'id = ' . $user_invalid['id']); } User::getUser($user_id, 1, 0); // update lai cache user echo $user['id']; exit; } } elseif ($user['invalid_time'] == 0) { if ($type_invalid == 1 && $date_invalid) { //$timeInvalid = TIME_NOW+($date_invalid*3600*24); $time_start = mktime(24, 0, 0, date('m'), date('d'), date('Y')); $timeInvalid = $time_start + $date_invalid * 24 * 3600; } elseif ($type_invalid == 2) { $timeInvalid = -1; } else { echo 'fail_valid'; exit; } if (DB::update('account', array('invalid_time' => $timeInvalid), 'id =' . $user_id)) { $user = DB::fetch('SELECT id,user_name FROM account WHERE id = ' . $user_id); if ($user) { DB::insert('acc_lock', array('time' => TIME_NOW, 'time_expire' => $timeInvalid, 'user_id' => $user['id'], 'user_name' => $user['user_name'], 'type' => 2, 'note' => $reason_invalid, 'admin_id' => User::id(), 'admin_name' => User::user_name())); } $sql_item = 'SELECT id FROM item where user_id = ' . $user_id . ' AND status = 1'; $re_item = DB::query($sql_item); while ($item = mysql_fetch_assoc($re_item)) { $reason = "KDTV : {$reason_invalid}"; $sql_insert = "INSERT INTO bad_content (`type`,`id_item`,`user_id`,`user_name`,`reason`,`time_post`) VALUES (2,{$item['id']}," . User::id() . ",'" . User::user_name() . "','" . $reason . "'," . TIME_NOW . ")"; DB::query($sql_insert); } if (MEMCACHE_ON) { $sql = "SELECT * FROM item\t\n\t\t\t\t\t\t\t WHERE user_id = {$user_id} AND status = 1"; $re = DB::query($sql); while ($item_memcache = mysql_fetch_assoc($re)) { $item_memcache['status'] = 2; $item_memcache['valid_time'] = TIME_NOW; $item_memcache['valid_user'] = User::user_name(); eb_memcache::do_put("item:" . $item_memcache['id'], $item_memcache); //update realtime if (SORL_FILTER_ON) { $solr = new Solr_Search(); $solr->doUpdateItem($item_memcache['id']); } //----- } } $receiver_user = User::getUser($user_id); $title_pm = 'Thông báo kiểm duyệt thành viên từ EClass'; $content_pm = 'Bạn đã bị kiểm duyệt với lý do: ' . $reason . ' Tất cả các tin đăng của bạn cũng sẽ bị kiểm duyệt. Đề nghị bạn hãy thực hiện đúng các quy định của Én Bạc. Xin cảm ơn bạn. Vui lòng không trả lời tin nhắn này!'; EClassApi::Send_pm(User::id(), User::user_name(), $receiver_user, $title_pm, $content_pm, true); DB::update('item', array('status' => "2", 'valid_time' => TIME_NOW, 'valid_user' => User::user_name()), 'user_id = ' . $user_id . ' AND status = 1'); User::getUser($user_id, 1, 0); // update lai cache user echo $user['id']; exit; } } else { echo 'fail_valid'; exit; } }