Exemple #1
0
 function draw()
 {
     global $display;
     $this->beginForm(false, "POST", false, Url::build_current());
     //search theo ngay thang nam
     $display->add('created_time_from', Url::get('created_time_from'));
     $display->add('created_time_to', Url::get('created_time_to'));
     $created_time_from = 0;
     $created_time_to = 0;
     if (Url::get('created_time_from')) {
         $date_arr = explode('/', Url::get('created_time_from'));
         if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
             $created_time_from = EClassApi::render_time($date_arr[1] . '/' . $date_arr[0] . '/' . (int) $date_arr[2], 0);
         }
     }
     if (Url::get('created_time_to')) {
         $date_arr = explode('/', Url::get('created_time_to'));
         if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
             $created_time_to = EClassApi::render_time($date_arr[1] . '/' . $date_arr[0] . '/' . (int) $date_arr[2], 1);
         }
     }
     $search_value = 1;
     $last_log = (int) Url::get('last_log');
     if ($last_log) {
         if ($created_time_from) {
             $search_value .= ' AND last_login >= ' . $created_time_from;
         }
         if ($created_time_to) {
             $search_value .= ' AND last_login <= ' . $created_time_to;
         }
     } else {
         if ($created_time_from) {
             $search_value .= ' AND create_time >= ' . $created_time_from;
         }
         if ($created_time_to) {
             $search_value .= ' AND create_time <= ' . $created_time_to;
         }
     }
     $display->add('last_log', $last_log);
     if (Url::get('active') == 1) {
         $search_value .= ' AND (is_active=1)';
         $display->add('active_checked', 'checked');
     } else {
         $display->add('active_checked', '');
     }
     if (Url::get('tracking') == 1) {
         $search_value .= ' AND (tracking=1)';
         $display->add('tracking_checked', 'checked');
     } else {
         $display->add('tracking_checked', '');
     }
     if (Url::get('invalid') == 1) {
         $search_value .= ' AND (invalid_time > 0 OR invalid_time = -1)';
         $order_by = ' ORDER BY invalid_time DESC ';
         $display->add('invalid_checked', 'checked');
     } else {
         //$search_value .= ' AND invalid_time = 0';
         $order_by = ' ORDER BY id DESC ';
         $display->add('invalid_checked', '');
     }
     if (Url::get('block') == 1) {
         $search_value .= ' AND (block_time >= ' . TIME_NOW . ' OR block_time = -1)';
         $order_by = ' ORDER BY block_time DESC ';
         $display->add('block_checked', 'checked');
     } else {
         //$search_value .= ' AND block_time!=-1 AND block_time <= '.TIME_NOW;
         $display->add('block_checked', '');
     }
     $od_by = Url::get('order_by');
     $od_dir = Url::get('order_dir', 'DESC');
     if ($od_by == 'name') {
         $order_by = ' ORDER BY user_name ' . $od_dir;
     } elseif ($od_by == 'id') {
         $order_by = ' ORDER BY id ' . $od_dir;
     } elseif ($od_by == 'time') {
         $order_by = ' ORDER BY create_time ' . $od_dir;
     } elseif ($last_log) {
         $order_by = ' ORDER BY last_login ' . $od_dir;
     }
     if (Url::get('ava')) {
         $search_value .= ' AND avatar_url != ""';
         $display->add('ava_checked', 'checked');
     } else {
         $display->add('ava_checked', '');
     }
     // search ô textbox	 ID
     $id_search = (int) Url::get('id_search', 0);
     if ($id_search) {
         $search_value .= ' AND id=' . $id_search;
     }
     if ($id_search == 0) {
         $id_search = '';
     }
     $display->add('id_search', $id_search);
     // search ô textbox	tài khoản
     if (Url::get('text_value') != '') {
         $text_value = trim(Url::get('text_value'));
         $display->add('text_value', $text_value);
         $str_search = str_replace("'", '"', $text_value);
         $str_search = str_replace("&#39;", '"', $str_search);
         $str_search = str_replace("&quot;", '"', $str_search);
         $s_user = User::getByUserName($str_search, true);
         if ($s_user) {
             $search_value .= " AND id='{$s_user['id']}' ";
         } else {
             $search_value .= " AND  0 ";
         }
     }
     $cid = 0;
     if (Url::get('cid') != 0) {
         $cid = trim(Url::get('cid'));
         $search_value .= ' AND (CONCAT(",", class_id, ",") LIKE "%,' . $cid . ',%") ';
     }
     $display->add('id_phone', Url::get('id_phone'));
     $item_per_page = Url::get('item_per_page', 50);
     $sql_count = 'SELECT COUNT(id) AS total_item FROM account WHERE ' . $search_value;
     $total = DB::fetch($sql_count, 'total_item', 0);
     $items = array();
     $str_id = '';
     $uids = '';
     if ($total) {
         $limit = '';
         require_once ROOT_PATH . 'core/ECPagging.php';
         $paging = ECPagging::pagingSE($limit, $total, $item_per_page, 10, 'page_no', true, 'Thành viên', 'Trang');
         $sql = 'SELECT * FROM account WHERE ' . $search_value . ' ' . $order_by . $limit;
         $result = DB::query($sql);
         if ($result) {
             while ($row = mysql_fetch_assoc($result)) {
                 $row['create_time'] = date('d/m/y H:i', $row['create_time']);
                 if ($row['last_login']) {
                     $row['last_login'] = date('d/m/y H:i', $row['last_login']);
                 } else {
                     $row['last_login'] = false;
                 }
                 if ($row['block_time'] > TIME_NOW || $row['block_time'] == -1) {
                     if ($row['block_time'] != -1) {
                         $row['status'] = "<font color=red><b>" . date('H:i d/m/y', $row['block_time']) . '</b></font>';
                     } else {
                         $row['status'] = '<font color=red><b>Khóa vĩnh viễn</b></font>';
                     }
                     $row['bgcolor'] = 'bgcolor="#CCCCCC"';
                     $row['is_block'] = true;
                     $display->add('type_reason', 'Khóa');
                 } else {
                     $row['status'] = "";
                     $row['bgcolor'] = '';
                     $row['is_block'] = false;
                 }
                 $row['gender'] = '';
                 $row['unban_nick'] = Url::build_all(array('chk_id', 'del_all', 'cmd', 'id', 'lock_die_all', 'hd_ac'), 'cmd=unban_nick&id=' . $row['id']);
                 if (User::is_root()) {
                     $row['del_link'] = Url::build_all(array('chk_id', 'del_all', 'cmd', 'id', 'lock_die_all', 'hd_ac'), 'cmd=del_user&id=' . $row['id']);
                 }
                 $row['detail'] = Url::build_current(array('cmd' => 'edit', 'id' => $row['id']));
                 $row['openids'] = array();
                 $row['del_cache'] = Url::build_all(array('cmd', 'id'), 'cmd=del_cache&id=' . $row['id']);
                 $uids .= ($uids ? ',' : '') . $row['id'];
                 $items[$row['id']] = $row;
             }
         }
     } else {
         $paging = '';
     }
     //
     //		if($uids){
     //			$re = DB::query("SELECT openid_url,user_id FROM openid WHERE user_id IN($uids)");
     //
     //			if($re){
     //				while ($oid = mysql_fetch_assoc($re)) {
     //					$items[$oid['user_id']]['openids'][] = $oid['openid_url'];
     //				}
     //			}
     //		}
     //lay ly do khoa nicks hoac kiem duyet nick
     $arr_reason = array();
     if ($str_id) {
         $where = '';
         if (Url::get('block') == 1) {
             $where = ' AND type IN (0,1) ';
         } else {
             if (Url::get('invalid') == 1) {
                 $where = ' AND type = 2 ';
             }
         }
         $sql = 'SELECT user_id, time, note, type,admin_id, admin_name FROM acc_lock WHERE user_id IN(' . $str_id . ') ' . $where . ' ORDER BY id ASC';
         $result = DB::query($sql);
         while ($row = mysql_fetch_assoc($result)) {
             $arr_reason[$row['user_id']] = $row;
         }
     }
     foreach ($items as $value) {
         if (isset($arr_reason[$value['id']]['user_id']) && $value['id'] == $arr_reason[$value['id']]['user_id']) {
             $items[$value['id']]['lock_reason'] = EClassApi::filter_title($arr_reason[$value['id']]['note']);
             $items[$value['id']]['lock_type'] = $arr_reason[$value['id']]['type'];
             $items[$value['id']]['time_lock'] = date("d/m/y H:i", $arr_reason[$value['id']]['time']);
             $items[$value['id']]['create_time_lock'] = $arr_reason[$value['id']]['time'];
             $items[$value['id']]['admin_name'] = $arr_reason[$value['id']]['admin_name'];
         } else {
             $items[$value['id']]['lock_reason'] = '';
             $items[$value['id']]['lock_type'] = '';
             $items[$value['id']]['time_lock'] = '';
             $items[$value['id']]['create_time_lock'] = 0;
             $items[$value['id']]['admin_name'] = '';
         }
     }
     //end lay ly do khoa nick
     if ($od_dir == 'ASC') {
         $od_dir = 'DESC';
     } else {
         $od_dir = 'ASC';
     }
     $href_id = Url::build_all(array('chk_id', 'del_all', 'cmd', 'id', 'lock_die_all', 'hd_ac'), 'order_by=id&order_dir=' . $od_dir);
     $href_name = Url::build_all(array('chk_id', 'del_all', 'cmd', 'id', 'lock_die_all', 'hd_ac'), 'order_by=name&order_dir=' . $od_dir);
     $href_up = Url::build_all(array('chk_id', 'del_all', 'cmd', 'id', 'lock_die_all', 'hd_ac'), 'order_by=up&order_dir=' . $od_dir);
     $href_time = Url::build_all(array('chk_id', 'del_all', 'cmd', 'id', 'lock_die_all', 'hd_ac'), 'order_by=time&order_dir=' . $od_dir);
     $img_id = '<img src="style/images/admin/downarrow.png" alt="">';
     //default
     $img_name = '';
     $img_up = '';
     $img_time = '';
     if ($od_by == 'id') {
         $img_id = '<img src="style/images/admin/' . ($od_dir != 'DESC' ? 'down' : 'up') . 'arrow.png" alt="">';
     }
     if ($od_by == 'name') {
         $img_name = '<img src="style/images/admin/' . ($od_dir != 'DESC' ? 'down' : 'up') . 'arrow.png" alt="">';
         $img_id = '';
     }
     if ($od_by == 'up') {
         $img_up = '<img src="style/images/admin/' . ($od_dir != 'DESC' ? 'down' : 'up') . 'arrow.png" alt="">';
         $img_id = '';
     }
     if ($od_by == 'time') {
         $img_time = '<img src="style/images/admin/' . ($od_dir != 'DESC' ? 'down' : 'up') . 'arrow.png" alt="">';
         $img_id = '';
     }
     // neu show cac thanh vien bi khoa, se sap xep theo thoi diem khoa hien tai giam dan
     if (Url::get('block') == 1) {
         usort($items, array("ListUserAdminForm", "cmp"));
     }
     $display->add('img_id', $img_id);
     $display->add('img_name', $img_name);
     $display->add('img_up', $img_up);
     $display->add('img_time', $img_time);
     $display->add('href_id', $href_id);
     $display->add('href_name', $href_name);
     $display->add('href_up', $href_up);
     $display->add('href_time', $href_time);
     $display->add('total_account', $total);
     $display->add('limit_date', BAN_NICK_DATE);
     $display->add('items', $items);
     $display->add('cid', $cid);
     //System::debug($items);
     $display->add('paging', $paging);
     $display->add('is_root', User::is_root());
     $display->output('list');
     $this->endForm();
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 function getNoteItem()
 {
     if (!User::is_login()) {
         $json['msg'] = 'no_login';
         die(json_encode($json));
     }
     $userId = User::id();
     $select = 'SELECT id,img_id,item_name,img_server,item_url,img_url,user_id,item_price FROM img_save';
     $where = ' WHERE user_id = ' . $userId;
     $order_by = ' ORDER BY id DESC';
     $limit = ' LIMIT 6 ';
     $sql = $select . $where . $order_by . $limit;
     $items = array();
     $re = DB::query($sql);
     if ($re) {
         $noteItem = array();
         while ($item = mysql_fetch_assoc($re)) {
             $item['price'] = $item['item_price'];
             $item['title'] = EClassApi::subString(EClassApi::filter_title($item['item_name']), 0, 40, true);
             $item['des'] = EClassApi::subString(EClassApi::filter_title($item['item_name']), 0, 42, true);
             /*$item['name'] 				= EClassApi::word_limit($item['name'],12,'');*/
             $item['img56'] = $item['img_url'] ? EClassApi::getImageThumb($item['img_url'], 56, 56, 0, $item['img_server']) : 'style/images/no-images-69x53.jpg';
             $item['href'] = $item['item_url'];
             $noteItem[] = $item;
         }
         $json['msg'] = 'success';
         $json['data'] = $noteItem;
         die(json_encode($json));
     }
 }