Exemplo n.º 1
0
 function on_submit()
 {
     if (!User::is_block()) {
         $file_name = strtolower($_FILES['avatar_url']['name']);
         $upload_path = AZLib::folderUpload(User::id(), 'avatar');
         $max_upload_file_size = 2 * 1024 * 1024;
         $file_ext = AZLib::getExtension(strtolower($file_name));
         $new_path = '';
         if ($file_name && in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png')) && filesize($_FILES['avatar_url']['tmp_name']) < $max_upload_file_size) {
             if (AZLib::ftp_check_dir($upload_path, true, IMAGE_SERVER_NO)) {
                 if (User::$current->data['avatar_url'] != '') {
                     @AZLib::ftp_image_delete_file(User::$current->data['avatar_url'], User::$current->data['img_server']);
                 }
                 $new_path = $upload_path . date("YmdHis", TIME_NOW) . '_' . substr(AZLib::make_safe_name(basename($file_name, $file_ext)), 0, 36) . $file_ext;
                 @AZLib::ftp_image_put_file($new_path, $_FILES['avatar_url']['tmp_name'], IMAGE_SERVER_NO);
             }
         }
         $phone_verify = User::$current->data['phone_verify'];
         $this->update_user($new_path, $phone_verify, IMAGE_SERVER_NO);
         //đang làm dở
         User::getUser(User::id(), true);
         echo '<script>document.location.href="' . WEB_ROOT . AZRewrite::formatUrl('?page=personal&cmd=edit_user&action=success_edit_user') . '"</script>';
     } else {
         $this->setFormError('', "Tài khoản của bạn hiện đang bị khóa, bạn không thể thực hiện chức năng này!");
     }
 }
Exemplo n.º 2
0
 private function rulePage($page = "")
 {
     if ($page) {
         if (!self::$page_patten) {
             self::$page_patten = array('list_detail' => array('url_in' => array("/\\?page=list_detail&category_id=([0-9]+)&ebname=([a-zA-Z0-9_\\-]*)&page_no=([0-9]+)/", "/\\?page=list_detail&category_id=([0-9]+)&ebname=([a-zA-Z0-9_\\-]*)/"), 'url_out' => array("c\$1/\$2/page-\$3", "c\$1/\$2")), 'item_detail' => array('url_in' => array("/\\?page=item_detail&id=([0-9]+)&ebname=([a-zA-Z0-9_\\-]*)&nice_name=([a-zA-Z0-9_\\-]+)/", "/\\?page=item_detail&id=([0-9]+)&ebname=([a-zA-Z0-9_\\-]*)/", "/\\?page=item_detail&id=([0-9]+)/"), 'url_out' => array("\$3/p\$1/\$2.html", "p\$1/\$2.html", "p\$1.html")), 'AllFeedback' => array('url_in' => array("/\\?page=AllFeedback&id=([0-9]+)&category_id=([0-9]+)&ebname=([a-zA-Z0-9_\\-]*)/", "/\\?page=AllFeedback&id=([0-9]+)&ebname=([a-zA-Z0-9_\\-]*)/"), 'url_out' => array("c\$2/fb\$1/\$3.html", "fb\$1/\$2.html")), 'user_entry' => array('url_in' => array("/\\?page=user_entry&user_name=([a-zA-Z0-9_\\-]*)&cmd_entry=view&entry_id=([0-9]+)&ebname=([a-zA-Z0-9_\\-]*)/", "/\\?page=user_entry&user_name=([a-zA-Z0-9_\\-]*)/", "/\\?page=user_entry&user_id=([0-9]+)&user_name=([a-zA-Z0-9_\\-]*)/"), 'url_out' => array("Bai-viet/\$1/e\$2/\$3", "Bai-viet/\$1", "Bai-viet/\$2")), 'shop' => array('url_in' => array("/\\?page=shop&user_id=([0-9]+)&user_name=([a-zA-Z0-9_\\-]+)&label_id=([0-9]+)&ebname=([a-zA-Z0-9_\\-]*)/", "/\\?page=shop&user_name=([a-zA-Z0-9_\\-]+)&label_id=([0-9]+)&mode=shop&ebname=([a-zA-Z0-9_\\-]*)/", "/\\?page=shop&user_name=([a-zA-Z0-9_\\-]+)&label_id=([0-9]+)&ebname=([a-zA-Z0-9_\\-]*)/", "/\\?page=shop&user_id=([0-9]+)&user_name=([a-zA-Z0-9_\\-]+)/", "/\\?page=shop&user_name=([a-zA-Z0-9_\\-]+)&mode=shop/", "/\\?page=shop&user_name=([a-zA-Z0-9_\\-]+)&mode=comment/", "/\\?page=shop&user_name=([a-zA-Z0-9_\\-]+)&mode=setting/", "/\\?page=shop&user_name=([a-zA-Z0-9_\\-]+)/"), 'url_out' => array("Shop/\$1/L\$3/\$4", "Shop/\$1/L\$2/\$3", "Shop/\$1/L\$2/\$3", "Shop\$1/\$2", "Shop/\$1/San-pham", "Shop/\$1/Luu-but", "Shop/\$1/Cai-dat", "\$1")), 'sph_search' => array('url_in' => array("/\\?page=sph_search/"), 'url_out' => array("search")));
         }
         return isset(self::$page_patten[$page]) ? self::$page_patten[$page] : '';
     }
     return;
 }
Exemplo n.º 3
0
 function draw()
 {
     $this->beginForm();
     global $display;
     $str_badword = stripslashes(Url::get("bad_word"));
     $show_bw = array();
     if (Url::get("submit") == "Kiểm tra" && $str_badword) {
         $show_bw = array();
         $show_bw = AZLib::checkBadWord($str_badword, true, false, true);
         $display->add('show_bw', $show_bw);
     }
     $display->add('bad_word', $str_badword);
     $search_value = ' contents <>"" ';
     if (Url::get('contents')) {
         $search_value .= ' AND contents like "%' . Url::get('contents') . '%"  OR reason like "%' . Url::get('contents') . '%" ';
     }
     $item_per_page = 100;
     $sql_count = 'SELECT COUNT(*) AS total_item FROM bad_words WHERE ' . $search_value;
     $total = DB::fetch($sql_count, 'total_item', 0);
     $items = array();
     if ($total) {
         $limit = '';
         $paging = AZPagging::pagingSE($limit, $total, $item_per_page, 10, 'page_no', true, 'Tin', 'Trang');
         $sql = 'SELECT * FROM bad_words WHERE ' . $search_value . ' ORDER BY exact DESC, id DESC ' . $limit;
         $result = DB::query($sql);
         if ($result) {
             while ($row = mysql_fetch_assoc($result)) {
                 $row['del_link'] = Url::build_all(array('chk_id', 'del_all', 'cmd', 'id', 'contents'), 'cmd=delete&id=' . $row['id']);
                 if ($row['is_phone'] == 1) {
                     $row['contents'] = BadWord::filter_badword_show($row['contents']);
                 }
                 $items[$row['id']] = $row;
             }
         }
     } else {
         $paging = '';
     }
     $display->add('items', $items);
     $display->add('url_add', WEB_DIR . AZRewrite::formatUrl('?page=manage_badword&cmd=add'));
     $display->add('contents', Url::get('contents'));
     $display->add('paging', $paging);
     $display->output('list');
     $this->endForm();
 }
Exemplo n.º 4
0
 function on_submit()
 {
     $captcha_register = Url::get('captcha_register');
     $email = Url::get('email');
     if ($email && isset($_SESSION["enbac_validate"]) && $captcha_register != '' && $captcha_register == $_SESSION["enbac_validate"]) {
         if ($row = DB::fetch("SELECT id,user_name,email FROM user WHERE email ='{$email}'")) {
             $id = $row['id'];
             $user = $row['user_name'];
             $email = $row['email'];
             $link1 = '<a href="' . WEB_ROOT . AZRewrite::formatUrl('?page=forgot_password&u=' . md5($user . $email) . '&id=' . $id) . '"><b>Khôi phục Mật khẩu</b></a>';
             $link2 = '<a href="' . WEB_ROOT . AZRewrite::formatUrl('?page=forgot_password&u=' . md5($user . $email) . '&id=' . $id) . '"><b>Khoi phuc Mat khau</b></a>';
             $message = file_get_contents('templates/ForgotPassword/messenger.html');
             $message = str_replace('[[|link1|]]', $link1, $message);
             $message = str_replace('[[|link2|]]', $link2, $message);
             $message = str_replace('[[|user|]]', $user, $message);
             if (System::sendEBEmail($email, 'Khôi phục mật khẩu!', $message)) {
                 Url::redirect_current(array('action' => 'success'));
             } else {
                 Url::redirect_current(array('action' => 'error'));
             }
         }
     }
 }
Exemplo n.º 5
0
    static function paging_unlimit(&$limit = false, $itemperpage, $page_name = 'page_no', $url_path = '')
    {
        $currentpage = (int) Url::get($page_name);
        if ($currentpage <= 0) {
            $currentpage = 1;
        } elseif ($currentpage > 200) {
            $currentpage = 200;
        }
        if ($currentpage <= 6) {
            $totalpage = 11;
        } else {
            $totalpage = $currentpage + 4 < 200 ? $currentpage + 4 : 200;
        }
        $limit = ' LIMIT ' . ($currentpage - 1) * $itemperpage . ',' . $itemperpage;
        if ($currentpage > 3) {
            $startpage = $currentpage - 3;
            if ($totalpage - $startpage < 7) {
                $startpage = $totalpage - 7 + 1;
            }
        } else {
            $startpage = 1;
        }
        if ($startpage < 1) {
            $startpage = 1;
        }
        if ($url_path == '') {
            $url_path = Url::build_all(array($page_name));
        }
        //Link den trang truoc
        if ($currentpage > 1) {
            $paging_str = '<div class="paging_bg floatLeft" onmouseout="this.className=\'paging_bg floatLeft\'" onmouseover="this.className=\'paging_bg_hover floatLeft\'">
						<div class="paging_pre">
							<a href=\'' . $url_path . ($currentpage > 2 ? '&' . $page_name . '=' . ($currentpage - 1) : '') . '\'>&laquo; Trước</a>
						</div>
					</div>';
        } else {
            $paging_str = '<div class="paging_bg_dis floatLeft ">
							<div class="paging_pre_dis">
									&laquo; Trước
							</div>
			 				</div>';
        }
        //Danh sach cac trang
        $i = 1;
        while ($i <= 4) {
            if ($startpage > $i) {
                if ($i < 4) {
                    $paging_str .= '<div class="floatLeft  paging_bg" onmouseover="javascript:this.className=\'floatLeft  paging_bg_hover\'" onmouseout="javascript:this.className=\'floatLeft  paging_bg\'">
                                    <div class="paging_node">
                                        <a  href="' . $url_path . ($i > 1 ? '&' . $page_name . '=' . $i : '') . '">' . $i . '</a>
                                    </div>
                            </div>';
                } else {
                    $paging_str .= '<div class="floatLeft  paging_bg">
                                <div class="paging_node_dot">
                                    ...
                                </div>
                        </div>';
                }
            }
            $i++;
        }
        for ($i = $startpage; $i <= $startpage + 6 && $i <= $totalpage; $i++) {
            if ($i == $currentpage) {
                $paging_str .= '<div class="floatLeft paging_bg_hover paging_bg_current">
                                <div class="paging_node">
                                    <a href="' . $url_path . ($i > 1 ? '&' . $page_name . '=' . $i : '') . '">' . $i . '</a>
                                </div>
                        	</div>';
            } else {
                $paging_str .= '<div class="floatLeft  paging_bg" onmouseover="javascript:this.className=\'floatLeft  paging_bg_hover\'" onmouseout="javascript:this.className=\'floatLeft  paging_bg\'">
                                <div class="paging_node">
                                    <a  href="' . $url_path . ($i > 1 ? '&' . $page_name . '=' . $i : '') . '">' . $i . '</a>
                                </div>
                        </div>';
            }
        }
        $j = 8;
        while ($j <= 10) {
            if ($i <= $j && $i <= 10) {
                $paging_str .= '<div class="floatLeft  paging_bg" onmouseover="javascript:this.className=\'floatLeft  paging_bg_hover\'" onmouseout="javascript:this.className=\'floatLeft  paging_bg\'">
									<div class="paging_node">
										<a  href="' . $url_path . '&' . $page_name . '=' . $j . '">' . $j . '</a>
									</div>
							</div>';
                if ($i < 10) {
                    $i++;
                }
            }
            $j++;
        }
        if ($i > 201) {
            $paging_str .= '<div class="floatLeft  paging_bg" onmouseover="javascript:this.className=\'floatLeft  paging_bg_hover\'" onmouseout="javascript:this.className=\'floatLeft  paging_bg\'">
								<div class="paging_node">
									<a  href="' . $url_path . '&' . $page_name . '=200">200</a>
								</div>
						</div>';
        } elseif ($i < 201) {
            $paging_str .= '<div class="floatLeft  paging_bg">
								<div class="paging_node_dot">
									...
								</div>
						</div>';
        }
        //Trang sau
        if ($currentpage < 200) {
            $paging_str .= '<div class="paging_bg floatLeft " onmouseout="this.className=\'paging_bg floatLeft \'" onmouseover="this.className=\'paging_bg_hover floatLeft \'">
				<div class="paging_next">
					<a href=\'' . $url_path . '&' . $page_name . '=' . ($currentpage + 1) . '\'>Sau &raquo;</a>
				</div>
			</div>';
        } else {
            $paging_str .= '<div class="paging_bg_dis floatLeft ">
							<div class="paging_next_dis">
								Sau &raquo;
							</div>
				 		</div>';
        }
        $paging_str = AZRewrite::formatUrl($paging_str);
        return $paging_str;
    }
Exemplo n.º 6
0
 function draw()
 {
     global $display;
     AZLib::getCats();
     $this->beginForm(false, 'post', false, Url::build_current());
     $created_time_from = 0;
     $created_time_to = 0;
     $time_from = "";
     $time_to = "";
     $phrase_checked = "";
     $free_cat_checked = "";
     $up_checked = "";
     $pagging = "";
     $limit = "";
     $lock_checked = '';
     $select_subcat_checked = '';
     $items = array();
     $id_search = (int) Url::get("id_search");
     $censor = Url::get("censor", 1);
     $user_name = AZLib::getParam("user_name");
     $zone_id = Url::get("zone_id");
     $searchByCat = Url::get("searchByCat");
     $searchByCatType = Url::get("searchByCatType", 0);
     $searchBySubCat = Url::get("searchBySubCat");
     $searchBySubCatType = Url::get("searchBySubCatType", 0);
     $sort_type = Url::get("sort_type", 1);
     $keywords = Url::get("keywords");
     $have_img = Url::get("have_img", 0);
     $lock_item = Url::get("lock");
     $phrase_selected = Url::get("phrase");
     $free_cat_selected = Url::get("free_cat");
     $up = Url::get("up");
     $select_subcat = Url::get("select_subcat", "");
     $opt_have_img = AZLib::getOption(array(0 => "-Tìm theo ảnh-", 1 => "-Có ảnh-", 2 => "-Không ảnh-"), $have_img);
     if (isset($_REQUEST["created_time"]) && $_REQUEST["created_time"]) {
         $time_from = Url::get("created_time");
     }
     if (isset($_REQUEST["created_time_to"]) && $_REQUEST["created_time_to"]) {
         $time_to = Url::get("created_time_to");
     }
     if ($time_from) {
         $date_arr = explode("-", $time_from);
         if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
             $created_time_from = mktime(0, 0, 0, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
         }
     }
     if ($time_to) {
         $date_arr = explode("-", $time_to);
         if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
             $created_time_to = mktime(23, 59, 59, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
         }
     }
     $search_value = "";
     $where = "";
     //$order_by   	= "ORDER BY del_time DESC";
     $order_by = "";
     $total_item = 0;
     if ($keywords) {
         $search_value = ($search_value == "" ? " WHERE " : " AND ") . "id IN (0)";
     }
     if ($sort_type == 1) {
         $order_by = "ORDER BY id DESC";
     } elseif ($sort_type == 2) {
         $order_by = "ORDER BY modify_time DESC";
     } elseif ($sort_type == 3) {
         $order_by = "ORDER BY item_order ASC";
     }
     if ($free_cat_selected) {
         $free_cat_checked = "checked";
         $catids = implode(",", array_keys(CGlobal::$allCategories));
         $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "category_id NOT IN({$catids})";
         $order_by = $order_by != "" ? $order_by : "ORDER BY id DESC";
     } else {
         if ($searchBySubCat) {
             if ($searchBySubCatType) {
                 // Nếu chỉ tìm trong danh mục con của danh mục cấp 2
                 $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "level_2_catid = " . $searchBySubCat;
                 // Lọc những item có trường level_2_catid là danh mục cấp 2
             } else {
                 $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "category_id = " . $searchBySubCat;
                 // Ngược lại, lấy các bản ghi thuộc chính danh mục cấp 2
             }
         } elseif ($searchByCat) {
             // Nếu chỉ tìm trong danh mục con của danh mục cấp 1
             if ($searchByCatType) {
                 // Lọc những item có trường level_1_catid là danh mục cấp 1
                 $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "level_1_catid = " . $searchByCat;
             } else {
                 // Ngược lại, lấy các bản ghi thuộc chính danh mục cấp 1
                 $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "category_id = " . $searchByCat;
             }
         }
     }
     if ($censor != 9) {
         $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "status=" . $censor;
     }
     if ($user_name != "") {
         $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "user_name ='{$user_name}'";
     }
     if ($select_subcat) {
         $select_subcat_checked = "checked";
     }
     if ($up) {
         if ($created_time_from) {
             $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "created_time >= " . $created_time_from;
         }
         if ($created_time_to) {
             $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "created_time <= " . $created_time_to;
         }
         $up_checked = "checked";
     } else {
         if ($created_time_from) {
             $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "modify_time >= " . $created_time_from;
         }
         if ($created_time_to) {
             $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "modify_time <= " . $created_time_to;
         }
     }
     if ($have_img == 1) {
         //có ảnh
         $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "have_image=1";
     } elseif ($have_img == 2) {
         //ko có ảnh
         $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "have_image=0";
     }
     if ($id_search) {
         //ID sản phẩm
         $search_value .= ($search_value == "" ? " WHERE " : " AND ") . "id={$id_search}";
     }
     if (Url::get("up")) {
         $order_by = $order_by != "" ? $order_by : "ORDER BY created_time DESC";
     } else {
         $order_by = $order_by != "" ? $order_by : "ORDER BY modify_time DESC";
     }
     $sql = "SELECT * FROM item {$search_value} {$order_by}";
     $sql_count = "SELECT count(*) AS total_row FROM item {$search_value}";
     $total_item = (int) DB::fetch($sql_count, "total_row");
     if ($total_item) {
         $pagging = AZPagging::pagingSE($limit, $total_item, 50, 10, 'page_no', true, 'Sản phẩm', 'Trang');
         $sql .= $limit;
     }
     $re = DB::query($sql);
     if ($re) {
         $index_temp = 0;
         while ($item = mysql_fetch_assoc($re)) {
             //trạng thái sản phẩm:
             if ($item['status'] == -1) {
                 $item['bgcolor'] = "bgcolor=\"#FF6633\"";
             } elseif ($index_temp) {
                 $item['bgcolor'] = "bgcolor=\"#EFEFEF\"";
             } else {
                 $item['bgcolor'] = "";
             }
             $index_temp = 1 - $index_temp;
             $item['created_time'] = 'Đăng: <b>' . date("d/m/Y H:i", $item['created_time']) . '</b>';
             if ($item['del_time'] && $item['del_user'] && $item['status'] == -1) {
                 $item['del_time'] = '<br /><font color=red>Xoá: <b>' . date("d/m/Y H:i", $item['del_time']) . '</font></b> ( <a target="_blank" href="' . WEB_DIR . $item['del_user'] . '"><strong>' . $item['del_user'] . '</strong></a>)';
             } else {
                 $item['del_time'] = '';
             }
             if ($item['modify_user_name'] && $item['status'] != -1) {
                 $item['is_modify'] = '<br><font color=gray>Sửa: <b>' . date("d/m/Y H:i", $item['modify_time']) . '</font></b>';
                 $item['is_modify'] .= ' ( <a target="_blank" href="' . WEB_DIR . $item['modify_user_name'] . '"><strong>' . $item['modify_user_name'] . '</strong></a>)';
             } else {
                 $item['is_modify'] = '';
             }
             $item['name'] = AZLib::filter_title($item['name']);
             $item['description'] = AZLib::remove_4_js(AZLib::plainText($item['description']));
             $item['price'] = number_format($item['price'], 0, ',', '.');
             $item['price_out'] = number_format($item['price_out'], 0, ',', '.');
             $item['currency_option'] = AZLib::getOption(array(1 => "VNĐ", 2 => "\$"), $item['currency_id']);
             //$item['price']	=  "Giá bán: ".AZLib::priceFomart($item['price'],$item['currency_id']);
             //$item['price_out']	=  "<br /><font color='#999999'>Giá TT: ".AZLib::priceFomart($item['price_out'],$item['currency_id']).'</font>';
             if ($item['level_1_catid'] > 0) {
                 if (isset(CGlobal::$allCategories[$item['level_1_catid']])) {
                     $item['cat_name'] = '<b>' . CGlobal::$allCategories[$item['level_1_catid']]['name'] . ' (' . $item['level_1_catid'] . ')</b>';
                 } else {
                     $item['cat_name'] = '<b><font color=red>(' . $item['level_1_catid'] . ')</font></b>';
                 }
                 if ($item['category_id'] > 0 && $item['category_id'] != $item['level_1_catid'] || $item['cat_name'] == '') {
                     if (isset(CGlobal::$allCategories[$item['category_id']])) {
                         $item['cat_name'] .= ' - <i>' . CGlobal::$allCategories[$item['category_id']]['name'] . ' (' . $item['category_id'] . ')</i>';
                     } else {
                         $item['cat_name'] .= ' - <i><b><font color=red>(' . $item['category_id'] . ')</font></b></i>';
                     }
                 }
             }
             if ($item['img_url']) {
                 $item['image_src'] = 'http://' . CGlobal::$img_server[$item['img_server']] . $item['img_url'];
                 $item['image'] = AZLib::getImageThumb($item['img_url'], 110, 0, 1, $item["img_server"]);
             } else {
                 $item['image_src'] = '';
                 $item['image'] = '';
             }
             $item['href'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . AZLib::safe_title($item['name']));
             $item['edit'] = Url::build('post_item', array('cmd' => 'edit', 'id' => $item['id']));
             if ($item['status'] == -1) {
                 $item['del_link'] = Url::build_all(array('cmd', 'id'), 'cmd=del_forever&id=' . $item['id']);
                 $item['re_post'] = Url::build_all(array('cmd', 'id'), 'cmd=re_post&id=' . $item['id']);
             } elseif ($item['status'] == 2) {
                 $item['del_link'] = Url::build_all(array('cmd', 'id'), 'cmd=delete&id=' . $item['id']);
                 $item['show_link'] = Url::build_all(array('cmd', 'id'), 'cmd=show&id=' . $item['id']);
             } else {
                 $item['del_link'] = Url::build_all(array('cmd', 'id'), 'cmd=delete&id=' . $item['id']);
                 $item['hide_link'] = Url::build_all(array('cmd', 'id'), 'cmd=hide&id=' . $item['id']);
             }
             $item['del_cache'] = Url::build_all(array('cmd', 'id'), 'cmd=del_cache&id=' . $item['id']);
             $items[$item['id']] = $item;
         }
     }
     $display->add('items', $items);
     $type_arr = array(1 => "-Sản phẩm không ẩn-", 2 => "-Sản phẩm ẩn-");
     if (User::have_permit(ADMIN_DEL_ITEM)) {
         $type_arr[-1] = "-Sản phẩm đã xoá-";
         $type_arr[9] = "-Tất cả các sản phẩm (Cả sản phẩm xóa)-";
     }
     $option_censor = AZLib::getOption($type_arr, Url::get('censor', 1));
     $display->add('censor', $censor);
     $display->add('option_censor', $option_censor);
     $display->add('have_img_option', $opt_have_img);
     $display->add('lock_checked', $lock_checked);
     $display->add('user_name', $user_name);
     $display->add('created_time', $time_from);
     $display->add('created_time_to', $time_to);
     $display->add('phrase_checked', $phrase_checked);
     $display->add('free_cat_checked', $free_cat_checked);
     $display->add('up_checked', $up_checked);
     $display->add('select_subcat_checked', $select_subcat_checked);
     $display->add('id_search', $id_search);
     $item_cat_search = $this->GetCatTree();
     $display->add('list_top_cat_js', AZLib::getOption(AZLib::getTopCats(), 999999999));
     $display->add('IS_ADMIN', User::is_admin());
     $display->add('page_no', Url::get('page_no'));
     $display->add('paging', $pagging);
     $display->add('total_item', $total_item);
     $display->add('item_cat', AZLib::getOption($this->getOtionCats(), Url::get('id_cats')));
     $display->add('category_tree', json_encode($item_cat_search));
     $display->add('catSelected', Url::get('searchByCat', 0));
     $display->add('catSelectedType', Url::get('searchByCatType', 0));
     $display->add('subCatSelected', Url::get('searchBySubCat', 0));
     $display->add('subCatSelectedType', Url::get('searchBySubCatType', 0));
     $display->add('keywords', $keywords);
     $display->add('sort_type', $sort_type);
     $display->output('ManageItem');
     $this->endForm();
 }
Exemplo n.º 7
0
 function draw()
 {
     global $display;
     $header_menu = array();
     $menu = array();
     $sub_menu = array();
     if (isset($_COOKIE['page_img_id'])) {
         // luu trang cuoi cung admin xem trong quan ly anh
         $page_img = "&page_no=" . $_COOKIE['page_img_id'];
     } else {
         $page_img = "";
     }
     //First menu
     $menu = array('title' => 'Trang chủ', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=home'));
     $sub_menu[] = array('title' => 'Trang quản trị', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=admin'));
     if (User::is_root()) {
         $sub_menu[] = array('title' => 'Quản trị Pages', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=page'));
         $sub_menu[] = array('title' => 'Quản trị Modules', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=module'));
     }
     if (User::is_admin()) {
         $sub_menu[] = array('title' => 'Quản trị Payment', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=payment_ebp'));
         $sub_menu[] = array('title' => 'Phân quyền', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=list_admin'));
     }
     if (User::have_permit(ADMIN_USER)) {
         $sub_menu[] = array('title' => 'Quản lý Thành viên', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=user'));
     }
     $sub_menu[] = array('title' => 'Người dùng online', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=online'));
     $menu['sub_menu'] = $sub_menu;
     $header_menu[] = $menu;
     //End First menu
     //Second menu
     $sub_menu = array();
     if (User::have_permit(ADMIN_ITEM) || User::is_mod()) {
         $menu = array('title' => 'Quản trị Sản phẩm', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=manage_item'));
         if (User::have_permit(ADMIN_ITEM) || User::is_mod()) {
             $sub_menu[] = array('title' => 'Quản trị Sản phẩm', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=manage_item'));
             /*$sub_menu[]=array(
             			'title'	=>'Chuyển Sản phẩm',
             			'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=content_category'),
             		);*/
         }
     }
     if (User::have_permit(ADMIN_CURRENCY)) {
         $sub_menu[] = array('title' => 'Quản trị tỷ giá', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=exchange'));
     }
     if (User::have_permit(ADMIN_IMAGE)) {
         $sub_menu[] = array('title' => 'Quản trị Ảnh', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=manage_image' . $page_img));
     }
     /*if(User::have_permit(ADMIN_ITEM)){
     			$sub_menu[]=array(
     								'title'	=>'Quản trị Comment',
     								'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=manage_comment'),
     							 );
     							 					
     			$sub_menu[]=array(
     								'title'	=>'Quản trị Lưu bút',
     								'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=manage_comment_user'),
     							 );
     							 
     		}*/
     if (User::have_permit(ADMIN_CATEGORY)) {
         $sub_menu[] = array('title' => 'Quản trị Danh mục', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=category'));
         /*$sub_menu[]=array(
         		'title'	=>'Quản trị giao dịch hot',
         		'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=manage_product_hot'),
         	 );				 
         	 */
     }
     if (User::have_permit(ADMIN_NEWS)) {
         $sub_menu[] = array('title' => 'Quản trị Danh mục tin', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=news_cats'));
         $sub_menu[] = array('title' => 'Quản trị Tin tức', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=news_admin'));
     }
     if (User::have_permit(ADMIN_ITEM)) {
         $sub_menu[] = array('title' => 'Quản trị Giỏ hàng', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=cart_admin'));
     }
     /*if(User::have_permit(ADMIN_ADV)){						
     			$sub_menu[]=array(
     								'title'	=>'Quản trị Đối tác',
     								'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=partner'),
     							 );
     		}*/
     if (User::have_permit(ADMIN_PROVINCE)) {
         $sub_menu[] = array('title' => 'Quản trị tỉnh thành', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=province'));
     }
     if (User::have_permit(ADMIN_TAG_SEARCH)) {
         $sub_menu[] = array('title' => 'Quản trị tag search', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=manage_tag_search'));
     }
     if (User::have_permit(ADMIN_ITEM)) {
         $sub_menu[] = array('title' => 'Quản trị khoá ip', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=manage_ban_ip'));
     }
     $menu['sub_menu'] = $sub_menu;
     $header_menu[] = $menu;
     //END Second menu
     //Third menu
     if (User::is_admin()) {
         $menu = array('title' => 'Quản trị Badword', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=manage_badword'));
         $sub_menu = array();
         $sub_menu[] = array('title' => 'Quản trị Badword', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=manage_badword'));
         $menu['sub_menu'] = $sub_menu;
         $header_menu[] = $menu;
     }
     //END Third menu
     //Forth menu
     if (User::have_permit(array(ADMIN_USER, ADMIN_MESSAGE))) {
         $sub_menu = array();
         if (User::have_permit(ADMIN_USER)) {
             $menu = array('title' => 'Quản lý Thành viên', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=user'));
         } else {
             $menu = array('title' => 'Quản lý Thành viên', 'url' => 'javascript:void(0);');
         }
         $sub_menu[] = $menu;
         /*if(User::have_permit(ADMIN_NOTICE)){
         			$sub_menu[]=array(
         								'title'	=>'Thông báo của BQT',
         								'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=admin_notice'),
         								);
         		}
         		
         		if(User::have_permit(ADMIN_NOTICE)){
         			$sub_menu[]=array(
         								'title'	=>'Cảnh báo Thành viên',
         								'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=admin_notice&act=user'),
         								);
         		}*/
         if (User::have_permit(ADMIN_NOTICE)) {
             $sub_menu[] = array('title' => 'Log thành viên bị khóa', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=user_lock'));
         }
         if (User::have_permit(ADMIN_MESSAGE)) {
             $sub_menu[] = array('title' => 'NT cho Thành viên', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=send_multi'));
         }
         if (User::is_admin()) {
             $sub_menu[] = array('title' => 'Spam Mail', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=spam_mail'));
         }
         $menu['sub_menu'] = $sub_menu;
         $header_menu[] = $menu;
     }
     //END Forth menu
     $display->add('header_menu', $header_menu);
     $display->add('admin_user', User::$current->data['user_name']);
     $display->output('Navigation');
 }
Exemplo n.º 8
0
 function search()
 {
     global $display;
     $catid = (int) Url::get('catid', 0);
     $total = (int) Url::get('total', 0);
     $page = (int) Url::get('page', 0);
     $tt = (int) Url::get('tt', 0);
     $keywords = Url::get('keywords');
     require "./includes/sphinxapi.class.php";
     AZLib::getCats();
     foreach (CGlobal::$allCategories as $value) {
         if ($value['parent_id'] == 0) {
             $cat_list[$value['id']] = $value['brief_name'];
         }
     }
     $category = $this->getCategory($keywords);
     foreach ($category as $row) {
         $row['brief_name'] = isset($cat_list[$row['level_1_catid']]) && $cat_list[$row['level_1_catid']] ? $cat_list[$row['level_1_catid']] : "Khác";
         $listCat[$row['level_1_catid']] = array("level_1_catid" => $row["level_1_catid"], "brief_name" => $row['brief_name'], "count_ad" => $row['@count']);
     }
     $catActive = '';
     $total_cat = 0;
     if ($listCat) {
         $catActive = $listCat[$catid]['brief_name'];
         $total_cat = count($listCat);
     }
     $i = 0;
     $allrecord = 0;
     $otherCat = '';
     $cat_content = "";
     foreach ($listCat as $cat) {
         $allrecord = $allrecord + $cat['count_ad'];
     }
     $display->add("cat_content", $cat_content);
     $display->add("CatActiveId", $catid);
     $display->add("catActive", $catActive);
     $display->add("listCat", $listCat);
     $display->add("allrecord", $allrecord);
     $display->add("total_cat", $total_cat);
     $pager = new Pager();
     $limit = SEARCH_LIMIT;
     $pager->type = "search";
     $pager->catid = $catid;
     $pager->total = $total;
     $pager->limit = $limit;
     $pager->page_param = 'page';
     $pager->page = $page;
     $offset = $pager->get_offset();
     $limit_from = $pager->limit_from();
     $limit_to = $pager->limit_to();
     //Sphinx search by Nova
     $q = $keywords;
     //$mode = SPH_MATCH_ALL;
     $mode = SPH_MATCH_EXTENDED2;
     //Init config
     $host = SPHINX_SERVER;
     $port = SPHINX_PORT;
     $index = 'enbac';
     $filtervals = array();
     //$ranker = SPH_RANK_PROXIMITY_BM25;
     $ranker = SPH_RANK_WORDCOUNT;
     $cl = new SphinxClient();
     $cl->SetServer($host, $port);
     $cl->SetConnectTimeout(1);
     $cl->SetWeights(array(100, 1));
     $cl->SetMatchMode($mode);
     $cl->SetFilter('level_1_catid', array($catid));
     $cl->SetFilter('status', array('1'));
     $cl->SetFieldWeights(array('user_name' => 10000, 'name' => 1000, 'description' => 1));
     //$cl->SetSortMode( SPH_SORT_EXTENDED, 'up_time DESC' );
     //$cl->SetSortMode( SPH_SORT_RELEVANCE);//Sort theo kq chính xác nhất
     //$cl->SetSortMode ( SPH_SORT_EXPR, "@weight + ( user_karma + ln(pageviews) )*0.1");
     $cl->SetSortMode(SPH_SORT_EXPR, "@weight");
     //Sort theo trọng số
     $cl->SetLimits($offset, $limit, 10000);
     $cl->SetRankingMode($ranker);
     $cl->SetArrayResult(true);
     $res = $cl->Query($q, $index);
     if ($res && isset($res["matches"])) {
         if (is_array($res["matches"])) {
             foreach ($res["matches"] as $results) {
                 $list_item_id[] = $results['id'];
             }
         }
         $comma_separated = join(",", $list_item_id);
     }
     if ($total) {
         if ($limit_to > $total) {
             $limit_to = $total;
         }
         $comma_separated = join(",", $list_item_id);
         if ($comma_separated) {
             //$sql = "SELECT id,name,up_time,price,user_id,user_name, level_1_catid,category_id,description,img_url, img_server FROM item WHERE id IN ($comma_separated) AND status=1 ORDER BY up_time DESC";
             $sql = "SELECT id,name,up_time,price,user_id,user_name, level_1_catid,category_id,description,img_url, img_server FROM item WHERE id IN ({$comma_separated}) AND status=1 ORDER BY find_in_set(id,'{$comma_separated}')";
             $search_result = DB::query($sql);
             $pager->total = $total;
             $paging = $pager->page_link();
         }
     }
     $item_array = array();
     if ($search_result) {
         AZLib::getCats();
         $highlight = '';
         if ($keywords) {
             $highlight = $str_search = str_replace(array('+', '/', '|', '-', '*'), "", $keywords);
             $highlight = AZLib::trimSpace($highlight);
             $highlight = str_replace("'", '', $highlight);
             $highlight = str_replace("&#39;", '', $highlight);
             $highlight = str_replace("&quot;", '', $highlight);
         }
         $highlight1 = '';
         if ($highlight) {
             $arr = explode(' ', $highlight);
             if ($arr) {
                 $highlight = "";
                 foreach ($arr as $word) {
                     $highlight = ($highlight ? $highlight . ', ' : '') . "'{$word}'";
                     $highlight1 = ($highlight1 ? $highlight1 . ',' : '') . $word;
                 }
             }
         }
         while ($item = mysql_fetch_assoc($search_result)) {
             $item['profile_url'] = WEB_DIR . $item['user_name'];
             //$item['name'] = AZLib::subString(strip_tags(AZLib::filter_title($item['name'])), 0, 115, true);
             $item['name_hl'] = AZLib::HighLightKeyword(strip_tags(AZLib::filter_title($item['name'])), $highlight1);
             $item_time = TIME_NOW - $item['up_time'];
             //neu nho hon 1h thi tinh ra phut
             if ($item_time < 3600) {
                 $item['item_time'] = floor($item_time / 60) . " phút trước đây";
             } elseif ($item_time < 86400) {
                 $item['item_time'] = floor($item_time / 3600) . " giờ trước đây";
             } else {
                 $item['item_time'] = date('\\n\\gà\\y j \\t\\há\\n\\g n', $item['up_time']);
             }
             //$item['description'] = String::display_sort_title(AZLib::delDoubleSpace(AZLib::trimSpace(strip_tags(AZLib::post_db_parse_html($item['description'])))), 35);
             $item['description'] = AZLib::HighLightKeyword(AZLib::delDoubleSpace(AZLib::trimSpace(strip_tags(AZLib::post_db_parse_html(preg_replace('/\\[[0-9]{1,3}\\]/', '', $item['description']))))), $highlight1, 35, "background:yellow;font-size:14px;font-weight:bold;color:blue;");
             $ebname = AZLib::safe_title($item['name']);
             $ebname_tmp = substr(AZLib::safe_title($item['name']), 0, 20);
             if (isset(CGlobal::$allCategories[$item['category_id']])) {
                 $item['item_url'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . $ebname . '&nice_name=' . CGlobal::$allCategories[$item['category_id']]['nice_name']);
                 $item['item_url_tmp'] = WEB_ROOT . CGlobal::$allCategories[$item['category_id']]['nice_name'] . '/p' . $item['id'] . '/' . $ebname_tmp . '...';
             } else {
                 $item['item_url'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . $ebname);
                 $item['item_url_tmp'] = WEB_ROOT . 'p' . $item['id'] . '/' . $ebname_tmp . '...';
             }
             if ($item['img_url']) {
                 $item['img_url'] = AZLib::getImageThumb($item['img_url'], 110, 0, 1, $item['img_server']);
             }
             $item['price'] = number_format($item['price'], 0, ',', '.');
             $item_array[] = $item;
         }
     }
     $display->add('total_item_cat', $total);
     $display->add('name_item_cat', $catActive);
     $display->add('paging', $paging);
     $display->add('keywords', $keywords);
     $display->add('items', $item_array);
     $display->output('sphinx_search_ajax', false, 'sphinx_search');
 }
Exemplo n.º 9
0
 function draw()
 {
     global $display;
     if (isset($_COOKIE['page_img_id'])) {
         // luu trang cuoi cung admin xem trong quan ly anh
         $page_img = "&page_no=" . $_COOKIE['page_img_id'];
     } else {
         $page_img = "";
     }
     $admin_link_list = array();
     if (User::have_permit(ADMIN_ITEM)) {
         $admin_link_list[] = array('title' => 'Quản trị Sản phẩm', 'des' => 'Quản trị Sản phẩm', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=manage_item'), 'image' => 'style/images/admin/icon_item.gif');
         $admin_link_list[] = array('title' => 'Import Excel', 'des' => 'Cập nhật sản phẩm hàng loạt từ Excel', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=import_excel'), 'image' => 'style/images/admin/icon_item.gif');
         /*$admin_link_list[]=array(
         		'title'	=>'Chuyển Sản phẩm',
         		'des'	=>'Chuyển Sản phẩm từ danh mục này sang danh mục khác',
         		'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=content_category'),
         		'image'	=>'style/images/admin/icon_item.gif'
         		);*/
         /*$admin_link_list[]=array(
         		'title'	=>'Comment',
         		'des'	=>'Quản trị comment',
         		'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=manage_comment'),
         		'image'	=>'style/images/admin/icon_comment.gif'
         		);*/
     }
     if (User::have_permit(ADMIN_CATEGORY)) {
         $admin_link_list[] = array('title' => 'Danh mục', 'des' => 'Quản trị Danh mục', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=category'), 'image' => 'style/images/admin/icon_category.gif');
         /*$admin_link_list[]=array(
         		'title'	=>'Giao dịch hot',
         		'des'	=>'Quản trị giao dịch hot',
         		'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=manage_product_hot'),
         		'image'	=>'style/images/admin/icon_category.gif'
         		);	*/
     }
     if (User::have_permit(ADMIN_NEWS)) {
         $admin_link_list[] = array('title' => 'Danh mục tin', 'des' => 'Quản trị Danh mục tin', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=news_cats'), 'image' => 'style/images/admin/icon_category.gif');
         $admin_link_list[] = array('title' => 'Tin tức', 'des' => 'Quản trị Tin tức', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=news_admin'), 'image' => 'style/images/admin/icon_city.gif');
     }
     if (User::have_permit(ADMIN_ITEM)) {
         $admin_link_list[] = array('title' => 'Giỏ hàng', 'des' => 'Quản trị Giỏ hàng', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=cart_admin'), 'image' => 'style/images/admin/icon_cart.gif');
     }
     if (User::have_permit(ADMIN_IMAGE)) {
         $admin_link_list[] = array('title' => 'Ảnh', 'des' => 'Quản trị Ảnh', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=manage_image' . $page_img), 'image' => 'style/images/admin/icon_image.gif');
     }
     /*if(User::have_permit(ADMIN_ITEM))
     		{
     			$admin_link_list[]=array(
     									'title'	=>'Lưu bút',
     									'des'	=>'Quản trị Lưu bút',
     									'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=manage_comment_user'),
     									'image'	=>'style/images/admin/icon_comment.gif'
     									);
     		}*/
     if (User::is_admin()) {
         $admin_link_list[] = array('title' => 'Badword', 'des' => 'Quản trị Badword', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=manage_badword'), 'image' => 'style/images/admin/icon_bad.gif');
     }
     if (User::have_permit(ADMIN_MESSAGE)) {
         $admin_link_list[] = array('title' => 'Nhắn tin Spam', 'des' => 'Nhắn tin spam cho nhiều thành viên', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=send_multi'), 'image' => 'style/images/admin/icon_pm.gif');
     }
     if (User::is_admin()) {
         $admin_link_list[] = array('title' => 'Spam mail', 'des' => 'Gửi spam mail', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=spam_mail'), 'image' => 'style/images/admin/icon_comment.gif');
     }
     /*if(User::have_permit(ADMIN_ADV)){
     			$admin_link_list[]=array(
     									'title'	=>'Đối tác, ADV',
     									'des'	=>'Quản trị Đối tác, Quảng cáo',
     									'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=partner'),
     									'image'	=>'style/images/admin/icon_adv.gif'
     									);
     		}*/
     if (User::have_permit(ADMIN_TAG_SEARCH)) {
         $admin_link_list[] = array('title' => 'Tag search', 'des' => 'Quản trị Tag search', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=manage_tag_search'), 'image' => 'style/images/admin/icon_adv.gif');
     }
     if (User::have_permit(ADMIN_PROVINCE)) {
         $admin_link_list[] = array('title' => 'Tỉnh thành', 'des' => 'Quản trị Tỉnh thành', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=province'), 'image' => 'style/images/admin/icon_city.gif');
     }
     if (User::have_permit(ADMIN_USER)) {
         $admin_link_list[] = array('title' => 'Thành viên', 'des' => 'Quản trị Thành viên', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=user'), 'image' => 'style/images/admin/icon_user.gif');
     }
     if (User::have_permit(ADMIN_USER)) {
         $admin_link_list[] = array('title' => 'User lock', 'des' => 'Quản trị Thành viên bị khóa', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=user_lock'), 'image' => 'style/images/admin/icon_user.gif');
     }
     /*if(User::have_permit(ADMIN_NOTICE)){
     			$admin_link_list[]=array(
     									'title'	=>'Thông báo của BQT',
     									'des'	=>'Thông báo của BQT',
     									'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=admin_notice'),
     									'image'	=>'style/images/admin/icon_user.gif'
     									);
     		}
     		
     		if(User::have_permit(ADMIN_NOTICE)){
     			$admin_link_list[]=array(
     									'title'	=>'Cảnh báo User',
     									'des'	=>'Cảnh báo Thành viên',
     									'url'	=>WEB_DIR.AZRewrite::formatUrl('?page=admin_notice&act=user'),
     									'image'	=>'style/images/admin/icon_user.gif'
     									);
     		}*/
     if (User::have_permit(ADMIN_CURRENCY)) {
         $admin_link_list[] = array('title' => 'Quản lý tỷ giá', 'des' => 'Quản lý tỷ giá', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=exchange'), 'image' => 'style/images/admin/icon_sms.gif');
     }
     $admin_link_list[] = array('title' => 'Online Users', 'des' => 'Thành viên online', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=online'), 'image' => 'style/images/admin/icon_statistic.gif');
     if (User::is_root()) {
         $admin_link_list[] = array('title' => 'Pages Admin', 'des' => 'Quản trị, cấu hình các Pages', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=page'), 'image' => 'style/images/admin/icon_config.gif');
         $admin_link_list[] = array('title' => 'Modules Admin', 'des' => 'Quản trị Modules', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=module'), 'image' => 'style/images/admin/icon_config.gif');
     }
     if (User::is_admin()) {
         $admin_link_list[] = array('title' => 'Phân quyền', 'des' => 'Phân quyền, phân nhóm, chỉ định danh mục thao tác quản trị cho các thành viên', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=list_admin'), 'image' => 'style/images/admin/icon_key.gif');
     }
     if (User::is_admin()) {
         $admin_link_list[] = array('title' => 'Poll', 'des' => 'Quản lý thăm dò dư luận', 'url' => WEB_DIR . AZRewrite::formatUrl('?page=admin_survey'), 'image' => 'style/images/admin/icon_statistic.gif');
     }
     $display->add('admin_link_list', $admin_link_list);
     $display->output('AdminHome');
 }
Exemplo n.º 10
0
 function draw()
 {
     global $display;
     AZLib::get_config();
     /*if (CGlobal::$curZone) {
           $zone_id = CGlobal::$curZone['id'];
       } else {
           $zone_id = 0;
       }*/
     $zid = (int) Url::get("zone_id", 0);
     $display->add('cur_page', AZNet::$page['name']);
     $display->add('ADMIN_LOGO', User::have_permit(ADMIN_LOGO));
     $in_detail_page = AZNet::$page['name'] == 'item_detail';
     $topcats = array();
     $pcats = array();
     $stt = 0;
     $stt2 = 0;
     foreach (CGlobal::$subCategories as $top_id => $sub_cats) {
         if (isset(CGlobal::$allCategories[$top_id]) && CGlobal::$allCategories[$top_id]['parent_id'] == 0) {
             $topcat = CGlobal::$allCategories[$top_id];
             if ($topcat['status'] == "HOME") {
                 $topcat['name'] = $topcat['brief_name'];
                 if (count($sub_cats) > 7) {
                     $stt2++;
                 }
                 $topcat['left'] = "-" . (($stt2 - 1) * 30 + 10) . "px";
                 $topcat['url'] = WEB_DIR . "c{$topcat['id']}/{$topcat['ebname']}";
                 $topcat['selected'] = (int) (CGlobal::$curMainCat && CGlobal::$curMainCat['id'] == $topcat['id']);
                 $topcat['selected2'] = 0;
                 if ($topcat['selected']) {
                     if ($sub_cats) {
                         $topcat['class'] = "hm_item_list_sub";
                     } else {
                         $topcat['class'] = "hm_item_seleted";
                     }
                 } else {
                     $topcat['class'] = "hm_item";
                 }
                 if ($sub_cats) {
                     $topcat['subs'] = array();
                     $num_sub = 0;
                     foreach ($sub_cats as $sid => $subcat) {
                         if ($subcat['status'] != "HIDE") {
                             $subcat['url'] = WEB_DIR . "c{$subcat['id']}/{$topcat['ebname']}-{$subcat['ebname']}";
                             //$subcat['name'] 		= $subcat['brief_name'];
                             if (CGlobal::$curLevel2Cat && CGlobal::$curLevel2Cat['id'] == $subcat['id']) {
                                 $topcat['selected2'] = 1;
                                 $topcat['class'] = "hm_item_seleted";
                                 $subcat['class'] = "class='sub_seleted'";
                             }
                             $topcat['subs'][$sid] = $subcat;
                             $num_sub++;
                         }
                     }
                     if ($topcat['selected'] && !$topcat['selected2']) {
                         $max_per_col = ceil($num_sub / 5);
                         if ($max_per_col <= 0) {
                             $max_per_col = 1;
                         }
                         $display->add('max_per_col', $max_per_col);
                         $display->add('subcat_items', $topcat['subs']);
                     }
                 }
                 $topcats[$top_id] = $topcat;
                 // if($stt++ >= 6)
                 //break;
             }
         }
     }
     $display->add('topcats', $topcats);
     $display->add('web_dir', WEB_DIR);
     $display->add('DATA_PATH', DATA_PATH);
     //Load Logo
     //$test_time = mktime(0,0,0,11,26,2010);
     AZLib::getWebsiteLogo();
     if (CGlobal::$websiteLogo !== FALSE && isset(CGlobal::$websiteLogo['current']['expired']) && CGlobal::$websiteLogo['current']['expired'] && CGlobal::$websiteLogo['current']['expired'] < TIME_NOW) {
         //  Nếu Logo đang sử dụng đã hết hạn, lấy Logo còn hạn hoặc lấy Logo mặc định
         AZLib::getWebsiteLogo(1);
     }
     $display->add('logo', CGlobal::$websiteLogo['current']);
     $display->add('logos', CGlobal::$websiteLogo['logos']);
     //Top menu
     if (!isset($_SESSION['is_load_page_first'])) {
         $_SESSION['is_load_page_first'] = 0;
     }
     $display->add('url_root', WEB_ROOT);
     if (!User::is_login()) {
         $num_mess = 0;
     } else {
         $num_mess = User::$current->data['total_pm'] > 0 ? User::$current->data['total_pm'] : 0;
     }
     if (User::id()) {
         $display->add('user_id', User::id());
         $user_name = User::$current->data['user_name'];
         $display->add('user_name', $user_name);
     }
     $referer_login_url = '';
     $yahoo_open_id_href = '';
     $google_open_id_href = '';
     if (isset($_SESSION['openid_url']) && $_SESSION['user_id'] != 0) {
         $display->add('show_openid', FALSE);
     } elseif (!User::is_az_team()) {
         AZLib::check_uri();
         $referer_login_url = base64_encode(CGlobal::$query_string);
         $yahoo_open_id_href = OID_URL . 'index.html?openid_identifier=http://me.yahoo.com/&long_redirect=' . base64_encode(CGlobal::$query_string);
         $google_open_id_href = OID_URL . 'index.html?openid_identifier=https://www.google.com/users/o8/id&long_redirect=' . base64_encode(CGlobal::$query_string);
         $display->add('show_openid', TRUE);
     }
     $display->add('OID_URL', $yahoo_open_id_href);
     $display->add('OID_URL_GOG', $google_open_id_href);
     $display->add('referer_login_url', $referer_login_url);
     $display->add('google_open_id_href', $google_open_id_href);
     $display->add('yahoo_open_id_href', $yahoo_open_id_href);
     $display->add('openid_on', OPENID_ON);
     $display->add('num_mess', $num_mess);
     $display->add('is_login', (int) User::is_login());
     $display->add('is_admin', (int) User::is_az_team());
     $display->add('is_admin_item', (int) User::have_permit(ADMIN_ITEM));
     $display->add('is_root', User::is_root());
     //End Top menu
     $display->add('category_id', CGlobal::$curCategory);
     $display->add('keywords', AZLib::cleanHtml(Url::get('keywords', '')));
     $display->add('not_error_page', (int) (AZNet::$page['name'] != 'error'));
     $display->add('is_load_page_first', $_SESSION['is_load_page_first']);
     // Tỷ giá
     AZLib::get_config();
     //$exchange = CGlobal::$configs['exchange']['conf_val'];
     //$display->add('exchange', number_format($exchange, 0, ',', '.'));
     // End Tỷ giá
     if ($_SESSION['is_load_page_first'] == 1) {
         $_SESSION['is_load_page_first'] = 0;
     }
     //End of top menu
     $curMainCat = CGlobal::$curMainCat;
     $curLevel2Cat = CGlobal::$curLevel2Cat;
     //Cat menu
     $sub_menu = FALSE;
     $sub_menu = $curMainCat && isset(CGlobal::$allCategories[$curMainCat['id']]) && isset(CGlobal::$subCategories[$curMainCat['id']]);
     $display->add('CURENT_TOP_CATID', (int) @$curMainCat['id']);
     $display->add('CURENT_LEVEL2_CATID', (int) @$curLevel2Cat['id']);
     $display->add('CURENT_CITY_ID', CGlobal::$curCity);
     $display->add('cur_page', Url::get('page'));
     $display->add('sub_menu', $sub_menu);
     $display->add('block_id', Module::$block_id);
     // System::debug($display->get_template_vars());
     //End Cat menu
     if (User::is_root()) {
         $display->add("DEBUG", DEBUG);
         $display->add("show_bug_url", AZRewrite::formatUrl(Url::build_all(array(), "ebug=" . (int) (!DEBUG))));
     }
     ################################################################################################################
     #Event config
     $event_on = @CGlobal::$configs['event_on']['conf_val'];
     $submit = Url::get('submit', '');
     if (User::is_admin()) {
         if ($submit == 'Cập nhật') {
             $display->add('msg', $this->showFormErrorMessages(1));
         }
         $status_arr = array(0 => 'Tắt', 1 => 'Bật');
         $display->add('status_option', AZLib::getOption($status_arr, $event_on));
     }
     $display->add('event', $event_on);
     $display->add("data_path", DATA_PATH);
     #Event config
     ################################################################################################################
     ################################################################################################################
     #Search
     $search_catid = (int) Url::get('search_catid');
     $search_cat_arr = array(-1 => '--Tất cả danh mục--');
     foreach (CGlobal::$subCategories as $top_id => $sub_cats) {
         if (isset(CGlobal::$allCategories[$top_id]) && CGlobal::$allCategories[$top_id]['parent_id'] == 0) {
             $topcat = CGlobal::$allCategories[$top_id];
             if ($topcat['status'] != "HIDE") {
                 $search_cat_arr[$top_id] = $topcat['name'];
                 if ($sub_cats) {
                     foreach ($sub_cats as $sid => $subcat) {
                         if ($subcat['status'] != "HIDE") {
                             $search_cat_arr[$sid] = "-----" . $subcat['name'];
                         }
                     }
                 }
             }
         }
     }
     $display->add('search_cat_option', AZLib::getOption($search_cat_arr, $search_catid));
     #Search
     ################################################################################################################
     /*   System::debug($topcats);*/
     $cat_newss = array();
     $news_cat_id = Url::get('news_catid', 'id', 0);
     AZLib::getNewsCats();
     $display->add('news_cat_id', $news_cat_id);
     if (CGlobal::$allNewsCategories) {
         foreach (CGlobal::$allNewsCategories as $news_cat) {
             if ($news_cat['public']) {
                 $news_cat['url'] = URL::build('news_list', array('news_catid' => $news_cat['id'], 'azname' => AZLib::safe_title($news_cat['name'])));
                 $cat_newss[$news_cat['id']] = $news_cat;
             }
         }
     }
     $display->add('cat_newss', $cat_newss);
     $display->output("Header");
     // $display->output("header_old");
 }
Exemplo n.º 11
0
 function forgot_password()
 {
     $email = Url::get("email", "");
     $captcha_register = AZLib::getParam('captcha_register');
     $str_error = "";
     if ($email && $captcha_register) {
         $sql = "SELECT id FROM user WHERE email = '{$email}'";
         DB::query($sql);
         if (!DB::num_rows()) {
             $str_error .= "<div>Email này không tồn tại</div>";
         }
         if (!isset($_SESSION["enbac_validate"]) || $captcha_register == '' || $captcha_register != $_SESSION["enbac_validate"]) {
             $str_error .= "<div>Mã bảo mật không đúng</div>";
         }
         if (!$str_error) {
             if ($row = DB::fetch("SELECT id,user_name,email FROM user WHERE email ='{$email}'")) {
                 $id = $row['id'];
                 $user = $row['user_name'];
                 $email = $row['email'];
                 $link1 = '<a href="' . WEB_ROOT . AZRewrite::formatUrl('?page=forgot_password&u=' . md5($user . $email) . '&id=' . $id) . '"><b>Khôi phục Mật khẩu</b></a>';
                 $link2 = '<a href="' . WEB_ROOT . AZRewrite::formatUrl('?page=forgot_password&u=' . md5($user . $email) . '&id=' . $id) . '"><b>Khoi phuc Mat khau</b></a>';
                 $message = file_get_contents('templates/ForgotPassword/messenger.html');
                 $message = str_replace('[[|link1|]]', $link1, $message);
                 $message = str_replace('[[|link2|]]', $link2, $message);
                 $message = str_replace('[[|user|]]', $user, $message);
                 if (System::sendEBEmail($email, 'Khôi phục mật khẩu!', $message)) {
                     $str_error = "";
                 } else {
                     $str_error .= "<div>Email chưa được gửi đi. Hãy thử lại lần nữa</div>";
                 }
             }
         }
     } else {
         $str_error = "<div>Có lỗi xẩy ra. Không thực hiện được</div>";
     }
     echo $str_error;
     exit;
 }
Exemplo n.º 12
0
    function get_more_comment()
    {
        $parent_id = AZLib::getParam('comment_id');
        $item_user_name = AZLib::getParam('item_user_name');
        $item_id = AZLib::getParam('item_id');
        $cat_id = AZLib::getParam('cat_id');
        $guest_email = AZLib::getParam('guest_email');
        $guest_name = AZLib::getParam('guest_name');
        //$cur_id  		= AZLib::getParam('cur_id',0);
        $cur_id = User::id();
        $item_user_id = AZLib::getParam('user_id');
        $show_guest_email = User::have_cat_permit($cat_id) || User::id() == $item_user_id;
        $sql = 'SELECT `comment`.`id`, `time`, `content`, `item_id`, `sender_email`, `sender_user_name`, user.img_server, `receiver_user_name`,`sender_user_id`, `receiver_user_id`, `parent_id`, `have_child`, user.avatar_url, user.id as user_id, user.gids, user.block_time FROM `comment` LEFT JOIN `user` ON user.id=comment.sender_user_id
					WHERE `comment`.`parent_id` =' . $parent_id . ' AND `comment`.`display`=0 ORDER BY time DESC LIMIT 0,100';
        $re = DB::query($sql);
        $i = 0;
        $result = '';
        $str_user_id = '';
        while ($item = mysql_fetch_assoc($re)) {
            $item['index'] = $i;
            $i++;
            if ($item['block_time'] > TIME_NOW) {
                $item['is_block'] = 1;
            } else {
                $item['is_block'] = 0;
            }
            $str_user_id .= ($str_user_id != '' ? ',' : '') . $item['sender_user_id'];
            //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 (TIME_NOW - $item['time'] < 24 * 3600) {
                $time_left = TIME_NOW - $item['time'];
                $hour = floor($time_left / 3600);
                $day = '';
                $minute = floor($time_left % 3600 / 60) . ' phút';
                $time_left = ($hour ? $hour . ' giờ ' : '') . $minute;
                if ($time_left == 0) {
                    $time_left = 'Vài giây';
                }
                $item['created_time'] = $time_left . ' trước';
            } elseif (date('Y') != date('Y', $item['time'])) {
                $item['created_time'] = date('H:i | d.m.Y', $item['time']);
            } else {
                $item['created_time'] = date('H:i | d.m', $item['time']);
            }
            $item['content'] = AZLib::parseBBCode($item['content']);
            if ($item['sender_user_id']) {
                $item['sender_link'] = Url::build('shop', array('user_name' => $item['sender_user_name']));
            } else {
                $item['sender_link'] = '';
            }
            $item['URL_badcontent'] = Url::build('item_detail', array('id' => Url::get('id'), 'ctype' => 'comment', 'id_comment' => $item['id']));
            $result .= '<tr id="' . $item['id'] . '"';
            $result .= ' onmouseover="show_hide_menu(' . $item['id'] . ')" onmouseout="show_hide_menu(' . $item['id'] . ')" ';
            $result .= '><td width="28" align="right" valign="top"><div style="height:5px"><span></span></div>';
            if ($item['sender_user_id'] == 0) {
                if ($item['id'] % 3 == 0) {
                    $item['sender_avatar_url'] = 'style/images/avatar_01.gif';
                } elseif ($item['id'] % 3 == 1) {
                    $item['sender_avatar_url'] = 'style/images/avatar_02.gif';
                } else {
                    $item['sender_avatar_url'] = 'style/images/avatar_03.gif';
                }
                $html_content = '';
                $result .= '<div class="feedbackAvatarSub" id="avatar_content_' . $item['user_id'] . '"><img src="' . $item['sender_avatar_url'] . '" width="25" height="25" /></div>';
            } else {
                if ($item['avatar_url']) {
                    $item['sender_avatar_url'] = AZLib::getImageThumb($item['avatar_url'], 60, 0, 1, $item['img_server']);
                    if ($item['parent_id'] > 0) {
                        $html_content = '<a href="' . $item['sender_link'] . '"><img src="' . $item['sender_avatar_url'] . '" width="25"/></a>';
                    } else {
                        $html_content = '<a href="' . $item['sender_link'] . '"><img src="' . $item['sender_avatar_url'] . '" width="50"/></a>';
                    }
                } else {
                    $item['sender_avatar_url'] = '';
                    if ($item['parent_id'] > 0) {
                        $html_content = '<a href="' . $item['sender_link'] . '"><img src="style/images/50x50.gif" width="25" height="25" /></a>';
                    } else {
                        $html_content = '<a href="' . $item['sender_link'] . '"><img src="style/images/50x50.gif" width="50" height="50" /></a>';
                    }
                }
                $result .= '<div class="profile_load"  id="c' . $item['id'] . '" lang="' . $item['user_id'] . '"><div class="feedbackAvatarSub" ';
                $result .= ' id="avatar_content_' . $item['user_id'] . '"><div class="bubbleInfo" id="info_' . $item['id'] . '" lang="' . $item['user_id'] . '"><div class="commentAva trigger">' . $html_content . '</div><!-- BEGIN POPUP MENU --><div class="popup" style="text-align: left;"><div id="show_mini_profile_c' . $item['id'] . '" style="display:none;"></div><div id="hide_mini_profile_c' . $item['id'] . '"><div class="contentPop" style="background-color:#fff"><div style="margin:4px;"><div class="blastTopLeft"><div class="blastTopRight"><div class="blastTopbg"><span></span></div></div></div><div class="blast"><img src="style/images/ajax-loader4.gif" width="62" height="13" /></div><div class="blastBottomLeft"><div class="blastBottomRight"><div class="blastBottombg"><span></span></div></div></div></div></div></div></div><!--END POPUP MENU --></div></div></div>';
            }
            $result .= '</td><td valign="top"><div class="contentFeedback" align="left"><div ';
            if (isset($item['is_admin_mod']['id']) && ($item['is_admin_mod']['id'] == 9 || $item['is_admin_mod']['id'] == 1)) {
                $result .= ' class="topFeedback_admin" ';
            } elseif (isset($item['is_admin_mod']['id']) && ($item['is_admin_mod']['id'] == 2 || $item['is_admin_mod']['id'] == 3)) {
                $result .= ' class="topFeedback_mod" ';
            } elseif ($item['sender_user_name'] == $item_user_name) {
                $result .= ' class="topFeedbackSelf" ';
            } else {
                $result .= ' class="topFeedback"';
            }
            $result .= ' >';
            if ($item['sender_user_id'] == 0) {
                $result .= ' <span class="guest_name">' . $item['sender_user_name'];
                $result .= $show_guest_email ? '<a href="mailto:' . $item['sender_email'] . '" title="Gửi e-mail cho người dùng này!"><img src="style/images/comment_email/email.gif" border="0" width="15" height="11"/></a>' : '';
                $result .= '</span>';
            } else {
                $result .= ' <a ';
                $result .= $item['is_block'] == 1 ? ' title="Đang bị khóa nick" ' : ' ';
                $result .= $item['is_admin_mod'] ? ' title="' . $item['is_admin_mod']['des'] . '" ' : ' ';
                $result .= '  href="' . WEB_DIR . $item['sender_user_name'] . '">';
                $result .= $item['is_block'] == 1 ? ' <s><i> ' : ' ';
                $result .= $item['sender_user_name'];
                $result .= $item['is_block'] == 1 ? ' </i></s> ' : ' ';
                $result .= '</a>';
            }
            $result .= ' <span class="fb_time">' . $item['created_time'] . '</span> ';
            $result .= '<div class="floatRight" style="margin-top:-12px; height:16px"><div id="show_menu_' . $item['id'] . '" style="display:none">';
            if ($item['user_id'] != $cur_id && $item['sender_user_id'] != 0) {
                $result .= ' <span class="send_pm_fb" onclick="fn_send_pm_fb(' . $item['user_id'] . ',\'' . $item['sender_user_name'] . '\');" id="' . $item['user_id'] . '-' . $item['sender_user_name'] . '" style="margin-left:5px"><a href="javascript: void(0)">gửi tin nhắn </a></span>|<span class="send_fb"><a href="' . WEB_DIR . AZRewrite::formatUrl('?page=shop&user_name=' . $item['sender_user_name'] . '&mode=comment') . '">viết lưu bút</a></span> ';
                if ($item && $item['sender_user_id'] == 0 && $cur_id == $item['receiver_user_id'] || User::have_permit(ADMIN_ITEM)) {
                    $result .= ' | ';
                }
            }
            if ($item && $item['sender_user_id'] == 0 && $cur_id == $item['receiver_user_id'] || User::have_permit(ADMIN_ITEM)) {
                $result .= '<span onclick="fn_click_del_comment_aj(' . $item['id'] . ',' . $item_id . ')" id="' . $item['id'] . '|' . $item_id . '"><a href="javascript:void()"><img src="style/images/icon_delete.gif" width="9" height="9" /></a></span>';
            }
            $result .= '</div></div><div style="clear:both"><span></span></div>';
            $result .= ' </div> <div align="center" id="mess_success_' . $item['id'] . '" style="display:none" class="mess_success"></div> <div class="detailFeedback" align="left"  style="width:485px; overflow:hidden">' . $item['content'] . '</div> ';
            if ($item['user_id'] != $cur_id) {
                $result .= '<div id="reply_' . $item['id'] . '" ><div  class="btn_fast_reply" onmouseout="if(this.className==\'btn_fast_reply_hover\')this.className=\'btn_fast_reply\'" onmouseover="if(this.className==\'btn_fast_reply\')this.className=\'btn_fast_reply_hover\'" style="float:right" onclick="show_box_reply(' . $item['id'] . ',' . $item['parent_id'] . ',\'' . $guest_name . '\',\'' . $guest_email . '\',\'' . $item['sender_user_name'] . '\',' . $item['sender_user_id'] . '); return true;">trả lời</div></div>';
                $result .= ' <div style="clear:right" id="box_reply_' . $item['id'] . '"></div>';
            }
            $result .= '</div></td></tr><tr id="space_' . $item['id'] . '"><td height="1" colspan="2"><div style="height:1px; margin:5px 0; background-color:#fff"><span></span></div></td></tr>';
            $result .= '</tr>';
        }
        echo $result;
        System::halt();
    }
Exemplo n.º 13
0
    function fn_lock_topic()
    {
        if (!User::is_login()) {
            echo "no_perm";
            exit;
        }
        if (!User::have_permit(ADMIN_ITEM) && !User::is_mod()) {
            echo "no_perm";
            exit;
        }
        $id = (int) Url::get('id', 0);
        $type = AZLib::getParam('type');
        $reason_lock = AZLib::getParam('reason_lock');
        $value = $type == 'lock' ? 1 : 0;
        if ($id > 0) {
            $item = Item::get_item($id);
            $item_memcache = $item;
            if ($item) {
                if (!User::have_permit(ADMIN_ITEM) && !User::have_cat_permit($item['category_id'])) {
                    echo "no_perm";
                    exit;
                }
                DB::query("UPDATE item SET state={$value}, valid_time = " . TIME_NOW . ", valid_user = '******', up_time = " . ($item["up_time"] - TIME_DOWN) . " WHERE id=" . $id);
                if (MEMCACHE_ON) {
                    $item_memcache['state'] = $value;
                    $item_memcache['valid_time'] = TIME_NOW;
                    $item_memcache['valid_user'] = User::user_name();
                    AZMemcache::do_put("item:{$id}", $item_memcache);
                }
                if ($type == 'lock') {
                    AZLib::getCats();
                    $link_help = 'http://help.enbac.com/index.php/Quy_%C4%91%E1%BB%8Bnh_%C4%91%C4%83ng_tin';
                    if (CGlobal::$allCategories[$item['category_id']]['link_help']) {
                        $link_help = CGlobal::$allCategories[$item['category_id']]['link_help'];
                    } elseif (isset(CGlobal::$allCategories[$item['category_id']]['parent_id']) && CGlobal::$allCategories[CGlobal::$allCategories[$item['category_id']]['parent_id']]['link_help']) {
                        $link_help = CGlobal::$allCategories[CGlobal::$allCategories[$item['category_id']]['parent_id']]['link_help'];
                    }
                    $receiver_user = DB::select('user', 'id = ' . $item["user_id"]);
                    $title_pm = 'Thông báo từ EnBac';
                    $content_pm = 'Tin [url=' . WEB_ROOT . AZRewrite::formatUrl('?page=item_detail&id=' . $id . '&ebname=' . AZLib::safe_title($item['name'])) . ']' . $item['name'] . '[/url] của bạn đã bị khóa với lý do: ' . $reason_lock . '
					
					Bạn click [url=' . $link_help . '][b]vào đây[/b][/url] để xem quy định đăng tin! Hoặc [url=http://blog.enbac.com/?p=28] [b]vào đây[/b][/url] để xem hướng dẫn đăng tin. 
					
					Ban quản trị Én bạc.
					
					Vui lòng không trả lời tin nhắn này!';
                    AZLib::Send_pm(User::id(), User::user_name(), $receiver_user, $title_pm, $content_pm, true);
                    $item_array = array('item_id' => $id, 'user_id' => User::id(), 'user_name' => User::user_name(), 'lock_time' => TIME_NOW, 'reason_lock' => $reason_lock);
                    DB::insert('item_lock', $item_array);
                } elseif ($type == 'unlock') {
                    DB::delete('item_lock', 'item_id=' . $id);
                }
                echo $type;
                exit;
            } else {
                echo "unsuccess";
                exit;
            }
        } else {
            echo "unsuccess";
            exit;
        }
    }
Exemplo n.º 14
0
 function draw()
 {
     global $display;
     $this->item['price'] = AZLib::convertCurrency($this->item['price'], $this->item['currency_id']);
     $this->item['price_out'] = AZLib::convertCurrency($this->item['price_out'], $this->item['currency_id']);
     $this->item['currency_id'] = 1;
     //For ajax_upload form
     $display->add('url_gallery', WEB_ROOT . AZRewrite::formatUrl('?page=gallery&is_popup=1&user_id=' . $this->item['user_id']));
     ////$display->add('no_img_upload',AZLib::getImageSrc('',100,100));
     $display->add('browser_is_ie', $this->browser_is_ie);
     $display->add('no_img_upload', $this->no_image);
     $display->add('user_id', User::id());
     $display->add('item_user_id', $this->item['user_id']);
     $display->add('is_can_edit', (int) User::have_permit(ADMIN_ITEM));
     $display->add('user_name', $this->item['user_name']);
     if (isset($_POST["avatar_img_server"])) {
         $avatar['img_server'] = $_POST["avatar_img_server"];
         $avatar['img_url'] = $_POST["avatar_img_url"];
         $avatar['thumb280_280'] = AZLib::getImageThumb($_POST["avatar_img_url"], 280, 280, 0, $_POST["avatar_img_server"]);
         $avatar['max_path'] = AZLib::getImageThumbMax($_POST["avatar_img_url"], 'thumb_max', 1, $_POST["avatar_img_server"]);
         $display->add('avatarInfo', $avatar);
         $display->add('avatar', json_encode($avatar));
     } elseif ($this->item['img_url']) {
         $avatar['img_server'] = $this->item['img_server'];
         $avatar['img_url'] = $this->item['img_url'];
         $avatar['thumb280_280'] = AZLib::getImageThumb($this->item['img_url'], 280, 280, 0, $this->item['img_server']);
         $avatar['max_path'] = AZLib::getImageThumbMax($this->item['img_url'], $this->item['name'], 1, $this->item['img_server']);
         $display->add('avatarInfo', $avatar);
         $display->add('avatar', json_encode($avatar));
     }
     $display->output('ajax_upload');
     //For ajax_upload form
     $this->beginForm(true);
     //$display->add('img_fnkjgk',json_encode($bakjgkj));
     $display->add('max_image_page', $this->max_image_page);
     $display->add('images_per_page', $this->images_per_page);
     $display->add('post_item_images', $this->item_images);
     $display->add('jsImages', json_encode($this->jsImages));
     if ($this->item['level_1_catid'] != $this->item['category_id']) {
         $first = $this->item['level_1_catid'];
         $second = $this->item['category_id'];
     } else {
         $first = $this->item['category_id'];
         $second = 0;
     }
     $display->add('first_combo', (int) Url::get('first_combo', $first));
     $display->add('second_combo', (int) Url::get('second_combo', $second));
     ///$display->add('category_tree',json_encode(AZLib::getCategoriesTree(0,true)));
     $display->add('category_tree', json_encode(AZLib::getCategoriesTree(true)));
     $display->add('currency_tree', json_encode(CGlobal::$currency));
     $display->add('az_filters', json_encode(CGlobal::$filters));
     $display->add('item_filters', $this->item['filter_ids']);
     $display->add('image_path', 'http://' . IMAGE_PATH);
     $display->add('img_cur_server', IMAGE_SERVER_NO);
     $display->add('img_server', json_encode(CGlobal::$img_server));
     $display->add('multi_upload', User::have_permit(ADMIN_ITEM));
     $display->add('no_img', $this->no_image);
     $display->add('post_img', $display->output('post_img', true));
     $display->add('currency_id_option', AZLib::getOption(CGlobal::$currency, Url::get('currency_id', $this->item['currency_id'])));
     $display->add('msg', $this->showFormErrorMessages(1));
     $display->add('name', stripslashes(Url::get('name', $this->item['name'])));
     $display->add('sku', Url::get('sku', $this->item['sku']));
     $display->add('offer', stripslashes(Url::get('offer', $this->item['offer'])));
     if (isset(CGlobal::$allCategories[$this->item['category_id']])) {
         $item_href = WEB_DIR . CGlobal::$allCategories[$this->item['category_id']]['nice_name'] . "/p{$this->item['id']}/" . AZLib::safe_title($this->item['name']) . ".html";
     } else {
         $item_href = WEB_DIR . "p{$this->item['id']}/" . AZLib::safe_title($this->item['name']) . ".html";
     }
     $display->add('item_href', $item_href);
     $display->add('name_length', 120 - mb_strlen(AZLib::stripUnicode(Url::get('name', $this->item['name'])), "UTF-8"));
     $display->add('brief', stripslashes(Url::get('brief', $this->item['brief'])));
     $display->add('item_description', stripslashes(Url::get('item_description', $this->item['description'])));
     $display->add('mode', "CẬP NHẬT");
     $display->add('price', number_format(Url::get('price', $this->item['price']), 0, ',', '.'));
     $display->add('price_out', number_format(Url::get('price_out', $this->item['price_out']), 0, ',', '.'));
     $display->add('quantity', number_format(Url::cdouble(Url::get('quantity', $this->item['quantity'])), 0, ',', '.'));
     $display->add('item_order', (int) Url::get('item_order', $this->item['item_order']));
     $display->add('made_in', Url::get('made_in', $this->item['made_in']));
     $display->add('warranty', Url::get('warranty', $this->item['warranty']));
     $display->output('post_sale');
     $this->endForm();
 }
Exemplo n.º 15
0
 function show_all_notify()
 {
     global $display;
     AZLib::getCats();
     $feed_follows = array();
     //hoạt động của các thành viên mà mình theo đuôi
     $follow_ids = '';
     //hoạt động của các thành viên mà mình theo đuôi
     $action = Url::get('action');
     $num_per_page = 20;
     $ajax_mod = (int) (Url::get('act') == 'shop_giaodich');
     $page_no = 1;
     $cur_group = 0;
     $all_feeds = array();
     //Lưu mảng tất cả các cập nhật
     $all_feed_ars = array();
     //mảng các cập nhật đã đc sắp xếp, xử lý
     $user_arr = array();
     //Mảng các user
     $item_arr = array();
     //Mảng các Giao dịch
     $entry_arr = array();
     //Mảng các Bài viết
     $item_ids_ar = array();
     //Mảng id các Giao dịch
     $user_ids_ar = array();
     //Mảng id các user
     $entry_ids_ar = array();
     //Mảng id các Bài viết
     $item_comment_ids = "";
     //Id các phản hồi giao dịch
     $item_comment_arr = array();
     //các phản hồi giao dịch
     $user_comment_ids = "";
     //Id các lưu bút
     $user_comment_arr = array();
     //các lưu bút
     $pm_ids = "";
     //Id các tin nhắn
     $pm_arr = array();
     //các tin nhắn
     $entry_comment_ids = "";
     //Id các bài viết
     $entry_comment_arr = array();
     //các bài viết
     $this->show_more = false;
     //các bài viết
     $where = "WHERE user_id = " . User::id();
     $limit = " LIMIT " . $num_per_page * ($page_no - 1) . "," . ($num_per_page + 1);
     $where .= " AND type IN(1,2,3,4,5,6)";
     $total_unread = 0;
     $sql = "SELECT * FROM feed {$where} ORDER BY time DESC {$limit}";
     $re = DB::query($sql);
     $stt = 0;
     if ($re) {
         while ($feed = mysql_fetch_assoc($re)) {
             if ($stt < $num_per_page) {
                 if ($feed['type'] == 1 || $feed['type'] == 2) {
                     $item_comment_ids .= ($item_comment_ids != '' ? ',' : '') . $feed['ref_id'];
                     if (!in_array($feed['item_id'], $item_ids_ar)) {
                         $item_ids_ar[$feed['item_id']] = $feed['item_id'];
                     }
                 } elseif ($feed['type'] == 3) {
                     $user_comment_ids .= ($user_comment_ids != '' ? ',' : '') . $feed['ref_id'];
                 } elseif ($feed['type'] == 4) {
                     $pm_ids .= ($pm_ids != '' ? ',' : '') . $feed['ref_id'];
                 } elseif ($feed['type'] == 5 || $feed['type'] == 6) {
                     $entry_comment_ids .= ($entry_comment_ids != '' ? ',' : '') . $feed['ref_id'];
                     if ($feed['item_id']) {
                         $entry_ids_ar[$feed['item_id']] = $feed['item_id'];
                     }
                 }
                 if ($feed['act_user_id'] && !in_array($feed['act_user_id'], $user_ids_ar)) {
                     $user_ids_ar[$feed['act_user_id']] = $feed['act_user_id'];
                 }
                 $all_feeds[$feed['id']] = $feed;
                 $stt++;
             } else {
                 $this->show_more = true;
             }
         }
     }
     if ($item_ids_ar) {
         $item_ids = implode(',', $item_ids_ar);
         if ($item_ids != '') {
             $re = DB::query("SELECT  id, name ,up_time, status, state, currency_id, category_id, img_server, img_url AS image_url FROM item WHERE id IN({$item_ids})");
             if ($re) {
                 while ($item = mysql_fetch_assoc($re)) {
                     if (isset(CGlobal::$allCategories[$item['category_id']])) {
                         $item['link_view'] = Url::build('item_detail', array('id' => $item['id'], 'ebname' => AZLib::safe_title($item['name']), 'nice_name' => CGlobal::$allCategories[$item['category_id']]['nice_name']));
                     } else {
                         $item['link_view'] = Url::build('item_detail', array('id' => $item['id'], 'ebname' => AZLib::safe_title($item['name'])));
                     }
                     if (!$item['status']) {
                         $total_unread++;
                     }
                     $item_arr[$item['id']] = $item;
                 }
             }
         }
     }
     if (!empty($entry_ids_ar)) {
         $entry_ids = implode(',', $entry_ids_ar);
         if ($entry_ids != '') {
             $re = DB::query("SELECT id, title, status, user_name, time_modify, image_url FROM user_entry WHERE id IN({$entry_ids})");
             if ($re) {
                 while ($entry = mysql_fetch_assoc($re)) {
                     $entry['link_view'] = WEB_DIR . AZRewrite::formatUrl('?page=user_entry&user_name=' . $entry['user_name'] . '&cmd_entry=view&entry_id=' . $entry['id'] . '&ebname=' . AZLib::safe_title($entry['title']));
                     if (!$entry['status']) {
                         $total_unread++;
                     }
                     $entry_arr[$entry['id']] = $entry;
                 }
             }
         }
     }
     if ($user_ids_ar) {
         $user_ids = implode(',', $user_ids_ar);
         if ($user_ids != '') {
             $re = DB::query("SELECT id, user_name, blast, avatar_url,img_server FROM user WHERE id IN({$user_ids})");
             if ($re) {
                 while ($user = mysql_fetch_assoc($re)) {
                     if ($user['avatar_url']) {
                         $user['avatar_url'] = 'http://' . CGlobal::$img_server[$user['img_server']] . 'thumb/50_50/' . $user['avatar_url'];
                     } else {
                         $user['avatar_url'] = 'style/images/54x54.gif';
                     }
                     $user_arr[$user['id']] = $user;
                 }
             }
         }
     }
     //Phản hồi giao dịch
     if ($item_comment_ids != '') {
         $re = DB::query("SELECT * FROM comment WHERE id IN({$item_comment_ids})");
         if ($re) {
             while ($comment = mysql_fetch_assoc($re)) {
                 $comment['content'] = AZLib::parseBBCode(stripslashes($comment['content']));
                 $comment['s_content'] = AZLib::plainText($comment['content']);
                 if (strlen($comment['s_content']) > 20) {
                     $comment['s_content'] = AZLib::word_limit($comment['s_content'], 10, '..');
                 }
                 $comment['time'] = AZLib::duration_time($comment['time']);
                 if (!$comment['status']) {
                     $total_unread++;
                 }
                 $item_comment_arr[$comment['id']] = $comment;
             }
         }
     }
     //Lưu bút
     if ($user_comment_ids != '') {
         $re = DB::query("SELECT * FROM comment_user WHERE id IN({$user_comment_ids})");
         if ($re) {
             while ($comment = mysql_fetch_assoc($re)) {
                 $comment['content'] = AZLib::parseBBCode(stripslashes($comment['content']));
                 $comment['s_content'] = AZLib::plainText($comment['content']);
                 if (strlen($comment['s_content']) > 20) {
                     $comment['s_content'] = AZLib::word_limit($comment['s_content'], 10, '..');
                 }
                 $comment['time'] = AZLib::duration_time($comment['time']);
                 if (!$comment['status']) {
                     $total_unread++;
                 }
                 $user_comment_arr[$comment['id']] = $comment;
             }
         }
     }
     if ($pm_ids != '' && $pm_ids != 0) {
         //Tin nhắn
         $re = DB::query("SELECT mt.*, msg.msg_post as content FROM (SELECT mt_id AS id, mt_msg_id, mt_title, mt_ref_id , mt_from_id AS sender_user_id, mt_date AS time, mt_read AS status FROM message_topics WHERE mt_id IN({$pm_ids})) AS mt LEFT JOIN message_text AS msg ON mt.mt_msg_id = msg.msg_id");
         if ($re) {
             while ($comment = mysql_fetch_assoc($re)) {
                 $comment['content'] = AZLib::parseBBCode(stripslashes($comment['content']));
                 $comment['s_content'] = AZLib::plainText($comment['content']);
                 if (strlen($comment['s_content']) > 20) {
                     $comment['s_content'] = AZLib::word_limit($comment['s_content'], 10, '..');
                 }
                 $comment['time'] = AZLib::duration_time($comment['time']);
                 if (!$comment['status']) {
                     $total_unread++;
                 }
                 $pm_arr[$comment['id']] = $comment;
             }
         }
     }
     if ($entry_comment_ids != '') {
         //Phản hồi bài viết
         $re = DB::query("SELECT id, entry_id, content, time, sender_user_id, sender_user_name, sender_email, status FROM user_entry_comment WHERE id IN({$entry_comment_ids})");
         if ($re) {
             while ($comment = mysql_fetch_assoc($re)) {
                 $comment['content'] = AZLib::parseBBCode(stripslashes($comment['content']));
                 $comment['s_content'] = AZLib::plainText($comment['content']);
                 if (strlen($comment['s_content']) > 20) {
                     $comment['s_content'] = AZLib::word_limit($comment['s_content'], 10, '..');
                 }
                 $comment['time'] = AZLib::duration_time($comment['time']);
                 if (!$comment['status']) {
                     $total_unread++;
                 }
                 $entry_comment_arr[$comment['id']] = $comment;
             }
         }
     }
     $item_ids_ar = array();
     //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_ar2 = array();
     //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á!
     $entry_ids_ar = array();
     $entry_ids_ar2 = array();
     $c_user_ids_ar = array();
     $pm_ids_ar = array();
     $unread_feed_ids = '';
     $del_feed_ids = '';
     if ($all_feeds) {
         foreach ($all_feeds as $feed) {
             if ($feed['type'] == 4) {
                 //Tin nhắn
                 if (isset($user_arr[$feed['act_user_id']])) {
                     $feed['sender_user_name'] = $user_arr[$feed['act_user_id']]['user_name'];
                 } else {
                     $feed['sender_user_name'] = '';
                 }
             }
             if ($feed['type'] == 1 || $feed['type'] == 2) {
                 //Phản hồi giao dịch hoặc Trả lời phản hồi giao dịch
                 if (isset($item_comment_arr[$feed['ref_id']])) {
                     $feed['item_id'] = $item_comment_arr[$feed['ref_id']]['item_id'];
                     $feed['content'] = $item_comment_arr[$feed['ref_id']]['content'];
                     $feed['s_content'] = $item_comment_arr[$feed['ref_id']]['s_content'];
                     $feed['time'] = $item_comment_arr[$feed['ref_id']]['time'];
                     $feed['sender_user_id'] = $item_comment_arr[$feed['ref_id']]['sender_user_id'];
                     $feed['sender_user_name'] = $item_comment_arr[$feed['ref_id']]['sender_user_name'];
                     $feed['sender_email'] = $item_comment_arr[$feed['ref_id']]['sender_email'];
                     $status = $feed['status'];
                     if ($feed['type'] == 1) {
                         $feed['status'] = $item_comment_arr[$feed['ref_id']]['status'];
                     } else {
                         $feed['status'] = $item_comment_arr[$feed['ref_id']]['replied_status'];
                     }
                     if ($feed['status'] == 0 || $status == 0) {
                         $unread_feed_ids .= ($unread_feed_ids != '' ? ',' : '') . $feed['id'];
                         if ($feed['type'] == 1 && $feed['status'] == 0) {
                             //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_ar[$feed['item_id']] = $feed['item_id'];
                         } elseif ($feed['type'] == 2 && $feed['status'] == 0) {
                             //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_ar2[$feed['item_id']] = $feed['item_id'];
                         }
                     }
                     if (isset($item_arr[$feed['item_id']]) && $item_arr[$feed['item_id']]['state'] == 0 && $item_arr[$feed['item_id']]['status'] != -1) {
                         $feed['item'] = $item_arr[$feed['item_id']];
                         $all_feed_ars[$feed['id']] = $feed;
                     } else {
                         $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                     }
                 } else {
                     $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                 }
             } elseif ($feed['type'] == 3) {
                 //Lưu bút
                 if (isset($user_comment_arr[$feed['ref_id']])) {
                     $feed['content'] = $user_comment_arr[$feed['ref_id']]['content'];
                     $feed['s_content'] = $user_comment_arr[$feed['ref_id']]['s_content'];
                     $feed['time'] = $user_comment_arr[$feed['ref_id']]['time'];
                     $feed['sender_user_id'] = $user_comment_arr[$feed['ref_id']]['sender_user_id'];
                     $feed['sender_user_name'] = $user_comment_arr[$feed['ref_id']]['sender_user_name'];
                     $status = $feed['status'];
                     $feed['status'] = $user_comment_arr[$feed['ref_id']]['status'];
                     if ($feed['status'] == 0 || $status == 0) {
                         $unread_feed_ids .= ($unread_feed_ids != '' ? ',' : '') . $feed['id'];
                         if ($feed['status'] == 0) {
                             //
                             $c_user_ids_ar[$feed['ref_id']] = $feed['ref_id'];
                         }
                     }
                     $all_feed_ars[$feed['id']] = $feed;
                 } else {
                     $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                 }
             } elseif ($feed['type'] == 4) {
                 //Tin nhắn
                 if (isset($pm_arr[$feed['ref_id']])) {
                     $feed['content'] = $pm_arr[$feed['ref_id']]['content'];
                     $feed['s_content'] = $pm_arr[$feed['ref_id']]['s_content'];
                     $feed['time'] = $pm_arr[$feed['ref_id']]['time'];
                     $feed['sender_user_id'] = $pm_arr[$feed['ref_id']]['sender_user_id'];
                     $feed['mt_title'] = $pm_arr[$feed['ref_id']]['mt_title'];
                     $id = $pm_arr[$feed['ref_id']]['mt_ref_id'] ? $pm_arr[$feed['ref_id']]['mt_ref_id'] : $pm_arr[$feed['ref_id']]['id'];
                     $feed['mt_title_link'] = "message.html#inbox/{$id}";
                     $status = $feed['status'];
                     $feed['status'] = $pm_arr[$feed['ref_id']]['status'];
                     if ($feed['status'] == 0 || $status == 0) {
                         $unread_feed_ids .= ($unread_feed_ids != '' ? ',' : '') . $feed['id'];
                         if ($feed['status'] == 0) {
                             //
                             $pm_ids_ar[$feed['ref_id']] = $feed['ref_id'];
                         }
                     }
                     $all_feed_ars[$feed['id']] = $feed;
                 } else {
                     $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                 }
             } elseif ($feed['type'] == 5 || $feed['type'] == 6) {
                 //Phản hồi Bài viết
                 if (isset($entry_comment_arr[$feed['ref_id']])) {
                     $feed['entry_id'] = $entry_comment_arr[$feed['ref_id']]['entry_id'];
                     $feed['content'] = $entry_comment_arr[$feed['ref_id']]['content'];
                     $feed['s_content'] = $entry_comment_arr[$feed['ref_id']]['s_content'];
                     $feed['time'] = $entry_comment_arr[$feed['ref_id']]['time'];
                     $feed['sender_user_id'] = $entry_comment_arr[$feed['ref_id']]['sender_user_id'];
                     $feed['sender_user_name'] = $entry_comment_arr[$feed['ref_id']]['sender_user_name'];
                     $feed['sender_email'] = $entry_comment_arr[$feed['ref_id']]['sender_email'];
                     $status = $feed['status'];
                     if ($feed['type'] == 5) {
                         $feed['status'] = $entry_comment_arr[$feed['ref_id']]['status'];
                     } else {
                         $feed['status'] = $entry_comment_arr[$feed['ref_id']]['replied_status'];
                     }
                     if ($feed['status'] == 0 || $status == 0) {
                         $unread_feed_ids .= ($unread_feed_ids != '' ? ',' : '') . $feed['id'];
                         if ($feed['type'] == 5 && $feed['status'] == 0) {
                             //Mảng entrry_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á!
                             $entry_ids_ar[$feed['entry_id']] = $feed['entry_id'];
                         }
                         if ($feed['type'] == 6 && $feed['status'] == 0) {
                             //Mảng entrry_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á!
                             $entry_ids_ar2[$feed['entry_id']] = $feed['entry_id'];
                         }
                     }
                     if (isset($entry_arr[$feed['entry_id']])) {
                         $feed['entry'] = $entry_arr[$feed['entry_id']];
                         $all_feed_ars[$feed['id']] = $feed;
                     } else {
                         $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                     }
                 } else {
                     $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                 }
             }
         }
     }
     $display->add('all_feed_ars', $all_feed_ars);
     $display->add('image_path', 'http://' . IMAGE_PATH);
     $display->add('get_page', AZNet::$page['name']);
     $display->add('get_cmd', Url::get('cmd', 'office'));
     $display->add('get_act', $action);
     $display->add('user_name', User::user_name());
     $this->total_group = count($all_feed_ars);
     $display->add('total_group', $this->total_group);
     $display->add('cur_group', $cur_group);
     $display->add('show_more', $this->show_more);
     $display->add('cur_user_name', User::user_name());
     $display->add('more_notify', WEB_DIR . AZRewrite::formatUrl('?page=personal'));
     $transact_office = $display->output('tbl_notify_ajax', true, 'Personal');
     $display->add('transact_office', $transact_office);
     $display->add('total_comment_user', User::$current->data['total_comment_user']);
     $display->add('total_new_comment', User::$current->data['total_new_comment']);
     $display->add('total_pm', User::$current->data['total_pm']);
     $display->add('can_edit_blast', User::is_admin() || !User::is_block());
     $blast = User::$current->data['blast'];
     $avatar_link = '';
     $avatar_url = 'style/images/no_avatar_item.gif';
     if (User::$current->data['avatar_url'] != '') {
         $avatar_link = "http://" . CGlobal::$img_server[User::$current->data['img_server']] . User::$current->data['avatar_url'];
         $avatar_url = AZLib::getImageThumb(User::$current->data['avatar_url'], 80, 80, 0, User::$current->data['img_server']);
     }
     if ($blast == '') {
         $blast = '...';
     } else {
         $blast = ' ' . $blast;
         if (strpos($blast, 'http://')) {
             $user_blast = $blast;
             while (strpos($user_blast, 'http://')) {
                 $tmp = substr($user_blast, strpos($user_blast, 'http://'));
                 if (strpos($tmp, ' ') || strpos($tmp, '<')) {
                     if (strpos($tmp, ' ') && strpos($tmp, '<') && strpos($tmp, ' ') > strpos($tmp, '<')) {
                         $blast_url = substr($tmp, 0, strpos($tmp, '<'));
                     } else {
                         $blast_url = substr($tmp, 0, strpos($tmp, ' '));
                     }
                 } else {
                     $blast_url = $tmp;
                 }
                 $user_blast = str_replace($blast_url, '', $user_blast);
             }
             $new_blast_url = ' <a rel="nofollow" href="' . $blast_url . '" target="_blank">Click here</a>';
             $blast = substr($user_blast . $new_blast_url, 1);
         }
     }
     $display->add('avatar_link', $avatar_link);
     $display->add('avatar_url', $avatar_url);
     $display->add('blast', $blast);
     $display->add('user_id', User::id());
     //Cập nhật sách theo đuôi
     if (isset($user_arr[$feed['act_user_id']]) && $user_arr[$feed['act_user_id']]['avatar_url']) {
         $feed['avatar_url'] = $user_arr[$feed['act_user_id']]['avatar_url'];
     } else {
         $feed['avatar_url'] = 'style/images/54x54.gif';
     }
     if ($feed_follows) {
         $tmp_feed_follows = $feed_follows;
         $feed_follows = array();
         foreach ($tmp_feed_follows as $feed) {
             if (isset($user_arr[$feed['user_id']])) {
                 if ($user_arr[$feed['user_id']]['avatar_url']) {
                     $avatar_url = $user_arr[$feed['user_id']]['avatar_url'];
                 } else {
                     $avatar_url = 'style/images/54x54.gif';
                 }
                 $user_name = $user_arr[$feed['user_id']]['user_name'];
                 if ($feed['type'] == 7) {
                     //entry
                     if (isset($entry_arr[$feed['item_id']])) {
                         $feed_follows[$feed['user_id']]['user_name'] = $user_name;
                         $feed_follows[$feed['user_id']]['avatar_url'] = $avatar_url;
                         $feed['entry_name'] = $entry_arr[$feed['item_id']]['title'];
                         $feed['entry_link'] = WEB_DIR . AZRewrite::formatUrl('?page=user_entry&user_name=' . $user_name . '&cmd_entry=view&entry_id=' . $feed['item_id'] . '&ebname=' . AZLib::safe_title($feed['entry_name']));
                         $feed['time'] = date('H:i d/m/Y', $feed['time']);
                         $feed_follows[$feed['user_id']]['feeds'][$feed['id']] = $feed;
                     }
                 } else {
                     $feed_follows[$feed['user_id']]['user_name'] = $user_name;
                     $feed_follows[$feed['user_id']]['avatar_url'] = $avatar_url;
                     $feed['blast'] = $user_arr[$feed['user_id']]['blast'];
                     $feed['time'] = date('H:i d/m/Y', $feed['time']);
                     $feed_follows[$feed['user_id']]['feeds'][$feed['id']] = $feed;
                 }
             }
         }
     }
     $json = array();
     $active_notify = array();
     $active_notify['item_ids_ar'] = $item_ids_ar;
     $active_notify['item_ids_ar2'] = $item_ids_ar2;
     $active_notify['c_user_ids_ar'] = $c_user_ids_ar;
     $active_notify['pm_ids_ar'] = $pm_ids_ar;
     $json['active_notify'] = $active_notify;
     $json['total_unread'] = $total_unread;
     $json['total_notify'] = User::$current->data['total_comment_user'] + User::$current->data['total_new_comment'] + User::$current->data['total_pm'];
     $json['content'] = $display->output('tb_notify', true, 'Personal');
     echo json_encode($json);
     exit;
 }
Exemplo n.º 16
0
 static function redirect_url($url = false, $type = false)
 {
     /*if(!$url || $url==''){
     			$url='?'.$_SERVER['QUERY_STRING'];
     		}*/
     if ($url != '') {
         if (strpos($url, WEB_ROOT) === 0) {
             $url = substr($url, strlen(WEB_ROOT));
         }
         if (strpos($url, WEB_DIR) === 0) {
             $url = substr($url, strlen(WEB_DIR));
         }
         /*if (REWRITE_ON){
         			$url= AZRewrite::doReplace($url);
         			unset($rewrite);
         		}*/
         $url = AZRewrite::formatUrl($url);
     } else {
         $url = '';
     }
     if ($type == 301) {
         Header("HTTP/1.1 301 Moved Permanently");
     }
     header('Location:' . WEB_DIR . $url);
     System::halt();
 }
Exemplo n.º 17
0
 function action_reply_entry_comment()
 {
     $act_ = Url::get('act_');
     $comment_id = (int) Url::get('re_c_entry_id', 0);
     $content = '';
     $json = "";
     if (!User::is_login()) {
         $json = '({"msg":"no_login"})';
         echo $json;
         exit;
     }
     if (User::is_block() || !$comment_id || $act_ != 'skip' && $act_ != 'reply') {
         $json = '({"msg":"no_perm"})';
         echo $json;
         exit;
     }
     $comment_row = DB::select('user_entry_comment', "id={$comment_id}");
     if (!$comment_row || $comment_row && $comment_row['replied_user_id'] != User::id()) {
         $json = '({"msg":"no_perm"})';
         echo $json;
         exit;
     }
     if ($comment_row['parent_id'] == 0 || $comment_row['receiver_user_id'] == User::id() || $comment_row['sender_user_id'] == User::id() || $act_ == 'reply' && $comment_row['replied_status'] == 1) {
         //Không được trả lời cho chính mình! hoặc trả lời phản hồi đã đc trả lời rồi!
         $json = '({"msg":"success"})';
         echo $json;
         exit;
     }
     $entry_id = $comment_row['entry_id'];
     $entry = DB::select('user_entry', "id={$entry_id}");
     if (!$entry || $entry && $entry['status'] == 0) {
         $json = '({"msg":"no_perm"})';
         echo $json;
         exit;
     }
     $json = '({"msg":"success"';
     if ($act_ == 'reply') {
         $content = trim(AZLib::getParam('content'));
         if (!$content) {
             $json = '({"msg":"short_content"})';
             echo $json;
             exit;
         }
         if (AZLib::checkBadWord($content)) {
             $json = '({"msg":"bad_word"})';
             echo $json;
             exit;
         }
         $content = preg_replace("/\n/", "<br />", $content);
         $content = str_replace('<br /><br />', '&nbsp;', $content);
         $parent_id = $comment_row['parent_id'];
         if ($comment_row['sender_user_id']) {
             $content = '@<a href="' . WEB_DIR . $comment_row['sender_user_name'] . '" class="fast_reply_link" title="' . $comment_row['sender_user_name'] . '">' . $comment_row['sender_user_name'] . '</a>: ' . $content;
         } else {
             $content = '<font color="#999">@<span style="text-decoration:underline">' . $comment_row['sender_user_name'] . '</span> </font>: ' . $content;
         }
         $comment = array('time' => time(), 'post_ip' => AZLib::ip(), 'content' => $content, 'entry_id' => $entry['id'], 'order_time' => time(), 'parent_id' => $parent_id, 'receiver_user_id' => $entry['user_id'], 'receiver_user_name' => $entry['user_name'], 'display' => 1, 'status' => 1);
         $comment['sender_user_id'] = User::id();
         $comment['sender_user_name'] = User::user_name();
         if ($comment_row['sender_user_id']) {
             $comment['replied_user_id'] = $comment_row['sender_user_id'];
             $comment['replied_user_name'] = $comment_row['sender_user_name'];
         }
         $id = DB::insert('user_entry_comment', $comment);
         if ($id) {
             $re = DB::query("SELECT id FROM user_entry_comment WHERE parent_id = {$parent_id} AND display = 1 ORDER BY id DESC LIMIT 3,1");
             if ($re) {
                 if ($row = mysql_fetch_assoc($re)) {
                     if ($row) {
                         DB::query("UPDATE user_entry_comment SET display = 0 WHERE parent_id = {$parent_id} AND display = 1 AND id<={$row['id']}");
                     }
                 }
             }
             if ($comment_id == $parent_id) {
                 DB::query("UPDATE user_entry_comment SET replied_status = 1,have_child = have_child + 1, order_time = " . time() . " WHERE id = {$comment_id}");
             } else {
                 DB::query("UPDATE user_entry_comment SET have_child = have_child + 1, order_time = " . time() . " WHERE id = {$parent_id}");
                 DB::query("UPDATE user_entry_comment SET replied_status = 1 WHERE id = {$comment_id}");
             }
             //Cập nhật đã đọc - trả lời cho feed
             DB::query("UPDATE feed SET status=1 WHERE ref_id = {$comment_id} AND type=6");
         }
         //Cập nhật cron job
         $user_item = User::getUser($entry['user_id']);
         if ($user_item['email'] && $user_item['email_alert'] && $user_item['id'] != User::id()) {
             $link = WEB_ROOT . '?page=user_entry&user_name=' . $entry['user_name'] . '&cmd_entry=view&entry_id=' . $entry['id'] . '&ebname=' . AZLib::safe_title($entry['title']);
             $link = AZRewrite::formatUrl($link);
             $title = "<a href='{$link}' target='_blank' style='text-decoration:none;color:#003399;'><font color='#003399'>{$entry['title']}</font></a>";
             AZLib::addCronJob('entry_comment', AZLib::parseBBCode($content, true), $user_item['id'], User::user_name(), '', $entry['id'], $title, $link);
         }
     } else {
         if ($comment_row['replied_status'] == 0) {
             DB::query("UPDATE user_entry_comment SET replied_status = 1 WHERE id = {$comment_id}");
         }
         //Cập nhật đã đọc - trả lời cho feed
         DB::query("UPDATE feed SET status=1 WHERE ref_id = {$comment_id} AND type=6");
     }
     $json .= "})";
     echo $json;
     exit;
 }
Exemplo n.º 18
0
 function draw()
 {
     global $display;
     $items = array();
     $bcats = array();
     $filter_groups = array();
     if (Build::$bcatid) {
         $filter_ids = trim(DB::fetch("SELECT GROUP_CONCAT(filter_ids SEPARATOR ',') AS filter_ids FROM (SELECT filter_ids FROM item WHERE " . CGlobal::$item_condition . " AND filter_ids != '') AS filter", 'filter_ids', ''));
         $pf_array = array();
         if ($filter_ids != '') {
             $f_array = array_count_values(explode(',', $filter_ids));
             foreach ($f_array as $fid => $count) {
                 if (isset(CGlobal::$allFilters[$fid])) {
                     $fgid = CGlobal::$allFilters[$fid]['fgid'];
                     if (isset(CGlobal::$all_gfilters[$fgid])) {
                         $pf_array[$fgid][$fid] = $count;
                     }
                 }
             }
         }
         //Tạo Menu Filter
         if ($this->filter_groups) {
             foreach ($this->filter_groups as $fgid => $gfilter) {
                 if (isset($pf_array[$fgid])) {
                     if ($gfilter['filters']) {
                         $group_filter = array();
                         foreach ($gfilter['filters'] as $fid => $filter) {
                             if (isset($pf_array[$fgid][$fid])) {
                                 if (!$group_filter) {
                                     $group_filter = array('name' => CGlobal::$all_gfilters[$fgid]['name'], 'filters' => array());
                                 }
                                 $link = AZRewrite::formatUrl(Url::build_all(array('min', 'max', 'filter', 'page_no')));
                                 if ($this->filter_get) {
                                     foreach ($this->filter_get as $get_gid => $get_fid) {
                                         if ($get_gid != $fgid) {
                                             $link .= "&filter[{$get_gid}]={$get_fid}";
                                         }
                                     }
                                 }
                                 if (isset($this->filter_get[$fgid]) && $this->filter_get[$fgid] == $filter['id']) {
                                     if ($this->min) {
                                         $link .= "&min=" . $this->min;
                                     }
                                     if ($this->max) {
                                         $link .= "&max=" . $this->max;
                                     }
                                     $group_filter['filters'] = array($fid => array('link' => $link, 'name' => $filter['name'], 'count' => $pf_array[$fgid][$fid], 'remove' => 1));
                                     break;
                                 } else {
                                     $link .= "&filter[{$fgid}]={$filter['id']}";
                                     //$link = str_replace(array('?filter=&','?filter=','&filter='),array('?','',''),$link);
                                     if ($this->min) {
                                         $link .= "&min=" . $this->min;
                                     }
                                     if ($this->max) {
                                         $link .= "&max=" . $this->max;
                                     }
                                 }
                                 $group_filter['filters'][$fid] = array('link' => $link, 'name' => $filter['name'], 'count' => $pf_array[$fgid][$fid]);
                             }
                         }
                         if ($group_filter) {
                             $filter_groups[$fgid] = $group_filter;
                         }
                     }
                 }
             }
         }
         $display->add('url_filter', Url::build_current(array('mode', 'bcatid' => Build::$bcatid)));
         $display->add('cat_name', CGlobal::$allCategories[Build::$bcatid]['name']);
         if (isset(Build::$cats[Build::$bcatid]['next_id']) && Build::$cats[Build::$bcatid]['next_id']) {
             $display->add('next_url', Url::build_current(array('mode', 'bcatid' => Build::$cats[Build::$bcatid]['next_id'])));
         } else {
             $display->add('next_url', Url::build_current());
         }
         $display->add('recomend', str_replace(chr(13) . chr(10), "<br />", CGlobal::$allCategories[Build::$bcatid]['recomend']));
         $display->add('filter_groups', $filter_groups);
         $display->add('filter_price', $this->filter_price);
         $sql = 'SELECT * FROM item WHERE ';
         $where = '';
         $sql .= CGlobal::$item_condition . " ORDER BY price ASC";
         $total_row = DB::count("item", CGlobal::$item_condition);
         #######################################################################################
         #Paging
         $filter_get = Url::get('filter');
         $min = Url::get('min');
         $max = Url::get('max');
         $order = Url::get('order');
         $paging = AZPagging::paging_list($limit, $total_row, 10, 10, 'page_no', '', true, 'Linh kiện', 'Trang');
         $sql .= $limit;
         #Paging
         #######################################################################################
         $re = DB::query($sql);
         if ($re) {
             while ($item = mysql_fetch_assoc($re)) {
                 if (isset(CGlobal::$allCategories[$item['category_id']])) {
                     $item['href'] = WEB_DIR . CGlobal::$allCategories[$item['category_id']]['nice_name'] . "/p{$item['id']}/" . AZLib::safe_title($item['name']) . ".html";
                 } else {
                     $item['href'] = WEB_DIR . "p{$item['id']}/" . AZLib::safe_title($item['name']) . ".html";
                 }
                 $item['price'] = AZLib::convertCurrency($item['price'], $item['currency_id']);
                 if ($item['price']) {
                     $item['price'] = number_format($item['price'], 0, ',', '.') . " VNĐ";
                 } else {
                     $item['price'] = 'Liên hệ';
                 }
                 if ($item['list_brief'] == '') {
                     $item['list_brief'] = $item['brief'];
                 }
                 $item['list_brief'] = AZLib::remove_4_js(AZLib::plainText(AZLib::parseBBCode(html_entity_decode($item['list_brief'], ENT_QUOTES, "UTF-8"))));
                 $item['list_brief'] = preg_replace("/\\[([\\s]*[0-9]{1,2}[\\s]*)\\]/eis", " ", $item['list_brief']);
                 $item['list_brief'] = str_replace(array("'", "\""), array("", " "), $item['list_brief']);
                 $item['list_brief'] = AZLib::word_limit($item['list_brief'], 50, '');
                 $item['select'] = Url::build_current(array('bcatid' => $item['category_id'], 'mode', 'item_id' => $item['id']));
                 $items[$item['id']] = $item;
             }
         }
         $display->add('items', $items);
         $display->add('paging', $paging);
     }
     $display->add('bcats', Build::$cats);
     if (Build::$price) {
         $display->add('total_price', number_format(Build::$price, 0, ',', '.') . " VNĐ");
     }
     $display->add('bitems', Build::$items);
     $display->add('bcatid', Build::$bcatid);
     $display->add('cur_url', $_SERVER['REQUEST_URI']);
     $display->add("print_link", Url::open_popup(Url::build('build_print'), 1000, 800, false, false, false, false, false, 1, 1));
     $build_catids = @CGlobal::$configs['BuildCatIDs']['conf_val'];
     $display->add('build_catids', $build_catids);
     $display->add('is_admin', User::is_admin());
     $display->add('begin_form', $this->beginForm(false, 'post', false, false, 1));
     $display->add('end_form', $this->endForm(1));
     $display->output('Build');
 }
Exemplo n.º 19
0
 function formatUrl($url = '', $options = array())
 {
     return AZRewrite::formatUrl($url, $options);
 }
Exemplo n.º 20
0
 function draw()
 {
     global $display;
     //For ajax_upload form
     $display->add('url_gallery', WEB_ROOT . AZRewrite::formatUrl('?page=gallery&is_popup=1&user_id=' . User::id()));
     //$display->add('no_img_upload',AZLib::getImageSrc('',100,100));
     $display->add('no_img_upload', $this->no_image);
     // Keep item avatar when update false
     if (isset($_POST["avatar_img_server"]) && $_POST["avatar_img_server"]) {
         $avatar['img_server'] = $_POST["avatar_img_server"];
         $avatar['img_url'] = $_POST["avatar_img_url"];
         $avatar['thumb280_280'] = AZLib::getImageThumb($_POST["avatar_img_url"], 280, 280, 0, $_POST["avatar_img_server"]);
         $avatar['max_path'] = AZLib::getImageThumbMax($_POST["avatar_img_url"], 'thumb_max', 1, $_POST["avatar_img_server"]);
         $display->add('avatarInfo', $avatar);
         $display->add('avatar', json_encode($avatar));
     }
     $display->add('item_user_id', User::id());
     $display->add('user_name', User::user_name());
     $display->add('user_id', User::id());
     $display->add('is_can_edit', (int) User::have_permit(ADMIN_ITEM));
     $display->add('browser_is_ie', $this->browser_is_ie);
     $display->output('ajax_upload');
     //For ajax_upload form
     $this->beginForm(true);
     $display->add('max_image_page', $this->max_image_page);
     $display->add('images_per_page', $this->images_per_page);
     $display->add('post_item_images', $this->item_images);
     $display->add('jsImages', json_encode($this->jsImages));
     $display->add('first_combo', (int) Url::get('first_combo'));
     $display->add('second_combo', (int) Url::get('second_combo'));
     //$display->add('category_tree',json_encode(AZLib::getCategoriesTree(0,true)));
     $display->add('category_tree', json_encode(AZLib::getCategoriesTree(true)));
     $display->add('currency_tree', json_encode(CGlobal::$currency));
     $display->add('az_filters', json_encode(CGlobal::$filters));
     $display->add('image_path', 'http://' . IMAGE_PATH);
     $display->add('img_cur_server', IMAGE_SERVER_NO);
     $display->add('img_server', json_encode(CGlobal::$img_server));
     $display->add('no_img', $this->no_image);
     $display->add('multi_upload', User::have_permit(ADMIN_ITEM));
     $display->add('post_img', $display->output('post_img', true));
     $display->add('currency_id_option', AZLib::getOption(CGlobal::$currency, Url::get('currency_id', 1)));
     $display->add('msg', $this->showFormErrorMessages(1));
     $display->add('mode', "ĐĂNG");
     $display->add('sku', Url::get('sku'));
     $display->add('name', stripslashes(Url::get('name')));
     $display->add('offer', stripslashes(Url::get('offer')));
     $display->add('brief', stripslashes(Url::get('brief')));
     $display->add('item_description', stripslashes(Url::get('item_description')));
     $display->add('price', number_format(Url::cdouble(Url::get('price')), 0, ',', '.'));
     $display->add('price', number_format(Url::cdouble(Url::get('price')), 0, ',', '.'));
     $display->add('price_out', number_format(Url::cdouble(Url::get('price_out')), 0, ',', '.'));
     $display->add('quantity', number_format(Url::cdouble(Url::get('quantity')), 0, ',', '.'));
     $display->add('item_order', (int) Url::get('item_order'));
     $display->add('made_in', Url::get('made_in'));
     $display->add('warranty', Url::get('warranty'));
     $display->add('add_for_user', User::have_permit(ADMIN_ITEM));
     $display->output('post_sale');
     $this->endForm();
 }
Exemplo n.º 21
0
 function draw()
 {
     $this->beginForm();
     global $display;
     $search_value = '';
     $display->add('up_checked', 'checked="checked"');
     if (Url::get('root_img')) {
         $search_value .= ($search_value != '' ? ' AND ' : ' WHERE') . ' root_id=0 ';
         $display->add('root_img_checked', 'checked="checked"');
     } else {
         //$search_value.=($search_value!=''?' AND ':' WHERE').' img.root_id>0 ';
         $display->add('root_img_checked', '');
     }
     if (Url::get('no_item_img')) {
         $search_value .= ($search_value != '' ? ' AND ' : ' WHERE') . ' item_id=0 ';
         $display->add('no_item_img_checked', 'checked="checked"');
     } else {
         //$search_value.=($search_value!=''?' AND ':' WHERE').' root_id>0 ';
         $display->add('no_item_img_checked', '');
     }
     // search ô textbox
     if (Url::get('user_name') != '') {
         $search_value .= ($search_value != '' ? ' AND ' : ' WHERE') . ' user_name LIKE "%' . Url::get('user_name') . '%" ';
     }
     //search theo ngay thang nam
     $created_time_from = 0;
     $created_time_to = 0;
     $current_time_from = null;
     $current_time_to = null;
     if (Url::get('created_time_from')) {
         $current_time_from = Url::get('created_time_from');
         $date_arr = explode('-', $current_time_from);
         if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
             $created_time_from = mktime(0, 0, 0, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
         }
     }
     if (Url::get('created_time_to')) {
         $current_time_to = Url::get('created_time_to');
         $date_arr = explode('-', $current_time_to);
         if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
             $created_time_to = mktime(23, 59, 59, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
         }
     }
     if ($created_time_from) {
         $search_value .= ($search_value != '' ? ' AND ' : ' WHERE') . ' time >= ' . $created_time_from;
     }
     if ($created_time_to) {
         $search_value .= ($search_value != '' ? ' AND ' : ' WHERE') . ' time <= ' . $created_time_to;
     }
     if ($search_value == '') {
         //create current date
         $date = Date('d-m-Y');
         $current_time_from = $date;
         $date_arr = explode('-', $current_time_from);
         if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
             $created_time_from = mktime(0, 0, 0, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
         }
         $current_time_to = $date;
         $date_arr = explode('-', $current_time_to);
         if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
             $created_time_to = mktime(23, 59, 59, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
         }
         if ($created_time_from) {
             $search_value .= ($search_value != '' ? ' AND ' : ' WHERE') . ' time >= ' . $created_time_from;
         }
         if ($created_time_to) {
             $search_value .= ($search_value != '' ? ' AND ' : ' WHERE') . ' time <= ' . $created_time_to;
         }
     }
     $display->add('created_time_from', $current_time_from);
     $display->add('created_time_to', $current_time_to);
     $item_per_page = 120;
     $sql_count = 'SELECT count(*) AS total_img FROM item_image ' . $search_value;
     $total = DB::fetch($sql_count, 'total_img', 0);
     $items = array();
     if ($total) {
         $limit = '';
         $paging = AZPagging::pagingSE($limit, $total, $item_per_page, 10, 'page_no', true);
         $sql = 'SELECT id,img_server, img_url,item_id, title, des, time, user_name, user_id, img_server FROM `item_image`';
         $sql .= $search_value . ' ORDER BY id ASC ' . $limit;
         $item_ids = '';
         $re = DB::query($sql);
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $row['link_gallery'] = WEB_DIR . AZRewrite::formatUrl('?page=gallery&user_id=' . $row['user_id'] . '&year=' . date('Y', $row['time']) . '&month=' . (int) date('m', $row['time']) . '&day=' . (int) date('d', $row['time']));
                 if (date('d.m.y', $row['time']) == date('d.m.y', TIME_NOW)) {
                     $row['time'] = date('H:i', $row['time']);
                 } elseif (date('y', $row['time']) == date('y', TIME_NOW)) {
                     $row['time'] = date('d/m H:i', $row['time']);
                 } else {
                     $row['time'] = date('d/m/y H:i', $row['time']);
                 }
                 //if(!eregi('/',$row['img_url'])){
                 //	$row['link_img']='http://'.CGlobal::$img_server[$row['img_server']].'uploaded/items/'.$row['img_url'];
                 //}
                 //else{
                 $row['link_img'] = 'http://' . CGlobal::$img_server[$row['img_server']] . $row['img_url'];
                 //}
                 if ($row['item_id']) {
                     $item_ids .= ($item_ids ? ',' : '') . $row['item_id'];
                     if (isset($row['name'])) {
                         $row['item_link'] = WEB_DIR . AZRewrite::formatUrl("?page=item_detail&id={$row['item_id']}&ebname=" . AZLib::safe_title($row['name']));
                         if (date('d.m.y', $row['created_time']) == date('d.m.y', TIME_NOW)) {
                             $row['created_time'] = date('H:i', $row['created_time']);
                         } elseif (date('y', $row['created_time']) == date('y', TIME_NOW)) {
                             $row['created_time'] = date('d/m H:i', $row['created_time']);
                         } else {
                             $row['created_time'] = date('d/m/y H:i', $row['created_time']);
                         }
                     } else {
                         $row['item_link'] = WEB_DIR . AZRewrite::formatUrl("?page=item_detail&id={$row['item_id']}");
                         $row['created_time'] = '';
                     }
                     $row['title'] = stripslashes($row['title']);
                 } else {
                     $row['title'] = stripslashes($row['des']);
                     $row['created_time'] = '';
                     $row['item_link'] = '';
                 }
                 $row['image_thumb'] = AZLib::getImageThumb($row['img_url'], 110, 0, 1, $row["img_server"]);
                 $row['image_max'] = AZLib::getImageThumbMax($row['img_url'], $row['title'], 1, $row["img_server"]);
                 $row['images_url_root'] = 'http://' . CGlobal::$img_server[$row['img_server']];
                 $row['del_link'] = Url::build_all(array('chk_id', 'del_all', 'cmd', 'id'), 'cmd=delete&id=' . $row['id']);
                 $items[$row['id']] = $row;
             }
             if ($item_ids) {
                 $all_items = array();
                 $sql = "SELECT id, name, created_time FROM item WHERE id IN({$item_ids})";
                 $re = DB::query($sql);
                 if ($re) {
                     while ($item = mysql_fetch_assoc($re)) {
                         $all_items[$item['id']] = $item;
                     }
                 }
                 foreach ($items as &$item_img) {
                     if ($item_img['item_id'] && isset($all_items[$item_img['item_id']])) {
                         $item_img['item_link'] = WEB_DIR . AZRewrite::formatUrl("?page=item_detail&id={$item_img['item_id']}&ebname=" . AZLib::safe_title($all_items[$item_img['item_id']]['name']));
                         if (date('d.m.y', $all_items[$item_img['item_id']]['created_time']) == date('d.m.y', TIME_NOW)) {
                             $item_img['created_time'] = date('H:i', $all_items[$item_img['item_id']]['created_time']);
                         } elseif (date('y', $all_items[$item_img['item_id']]['created_time']) == date('y', TIME_NOW)) {
                             $item_img['created_time'] = date('d/m H:i', $all_items[$item_img['item_id']]['created_time']);
                         } else {
                             $item_img['created_time'] = date('d/m/y H:i', $all_items[$item_img['item_id']]['created_time']);
                         }
                     } else {
                         $item_img['item_link'] = '';
                         $item_img['created_time'] = '';
                     }
                 }
             }
         }
     } else {
         $paging = '';
     }
     AZLib::my_setcookie("page_img_id", Url::get("page_no") != "" ? intval(Url::get("page_no")) : 1, 60 * 60 * 24 * 365 + TIME_NOW);
     $display->add("uri", CGlobal::$request_uri);
     $display->add("images_url_root", 'http://' . CGlobal::$img_server[IMAGE_SERVER_NO]);
     $display->add('user_name', Url::get('user_name'));
     $display->add('item_title', Url::get('item_title'));
     $display->add('items', $items);
     $display->add('paging', $paging);
     $display->output('ManageImage');
     $this->endForm();
 }
Exemplo n.º 22
0
 function admin_links(&$item_detail)
 {
     //Menu admin
     global $display;
     $edit_link = '';
     $del_link = '';
     $del_link_item = '';
     if (!User::is_block() && User::have_permit(ADMIN_ITEM)) {
         $edit_link = WEB_DIR . AZRewrite::formatUrl('?page=post_item&cmd=edit&id=' . $item_detail['id']);
         if (Item::$item['status'] != -1) {
             $del_link = 1;
         }
         $display->add("have_permit", 1);
         $del_link_item = ' [ <a class="delete" href="javascript:void(0)" title="Xóa sản phẩm này!" onclick="del_item(' . $item_detail['id'] . ');return false;">Xóa</a> ] ';
         if ($item_detail['status'] == -1) {
             $this->setFormError('', '<center><font color=red>Sản phẩm đã bị xoá (bởi <b>' . $item_detail['del_user'] . '</b> lúc <b>' . date('d/m/Y H:i', $item_detail['del_time']) . '</b>)</font></center>');
         } elseif ($item_detail['status'] == 2) {
             //Sản phẩm bị ẩn
             $this->setFormError('', '<center><font color=red>Sản phẩm đang bị ẩn (bởi <b>' . $item_detail['modify_user_name'] . '</b> lúc <b>' . date('d/m/Y H:i', $item_detail['modify__time']) . '</b>)</font></center>');
         }
     }
     $display->add("edit_link", $edit_link);
     $display->add("del_link", $del_link);
     $display->add("del_link_item", $del_link_item);
 }
Exemplo n.º 23
0
 function draw2()
 {
     $keywords = AZLib::getParam('keywords');
     $total_item = 0;
     $search_result = false;
     $items = array();
     $paging = '';
     $cmd = '';
     $cat_search_id = 0;
     $item_array = array();
     $listCat = array();
     if ($keywords) {
         //AZLib::getCats();
         require "./includes/sphinxapi.class.php";
         foreach (CGlobal::$allCategories as $value) {
             if ($value['parent_id'] == 0) {
                 $cat_list[$value['id']] = $value['brief_name'];
             }
         }
         $category = $this->getTotalPerCategory($keywords);
         foreach ($category as $row) {
             $row['brief_name'] = isset($cat_list[$row['level_1_catid']]) && $cat_list[$row['level_1_catid']] ? $cat_list[$row['level_1_catid']] : "Khác";
             $listCat[$row['level_1_catid']] = array("level_1_catid" => $row["level_1_catid"], "brief_name" => $row['brief_name'], "count_ad" => $row['@count']);
         }
         $total = 0;
         $catid = 0;
         $catActive = '';
         $total_cat = 0;
         if ($listCat) {
             $first_val = array_slice($listCat, 0, 1);
             $total = $first_val[0]['count_ad'];
             $catid = $first_val[0]['level_1_catid'];
             $catActive = $first_val[0]['brief_name'];
             $total_cat = count($listCat);
         }
         $i = 0;
         $allrecord = 0;
         $otherCat = '';
         $cat_content = "";
         foreach ($listCat as $cat) {
             if ($i < 3) {
                 $active = $i == 0 ? "class=\"active\"" : "";
                 $cat_content .= "<li id=\"tab_{$i}\" {$active} onclick=\"javascript:acive_tab_cat(this);\"><a href=\"javascript:void(0);\" onclick=\"javascript:search_cat({$cat['level_1_catid']},{$cat['count_ad']},1,0);\"><span id=\"kby_{$cat['level_1_catid']}\">" . $cat['brief_name'] . " <font style=\"color: #5a7e92;font-weight: normal;\">(" . $cat['count_ad'] . ")</font></span></a></li>";
             } else {
                 $otherCat .= "<div class=\"other\"><a href=\"javascript:void(0);\" onclick=\"javascript:search_cat({$cat['level_1_catid']},{$cat['count_ad']},1,0);acive_tab_cat(this);\" id=\"tab_{$i}\"><span id=\"kby_{$cat['level_1_catid']}\">" . $cat['brief_name'] . " <font style=\"color: #5a7e92;font-weight: normal;\">(" . $cat['count_ad'] . ")</font></span></a></div>";
             }
             $i++;
             $allrecord = $allrecord + $cat['count_ad'];
         }
         $display->add("cat_content", $cat_content);
         $display->add("CatActiveId", $catid);
         $display->add("catActive", $catActive);
         $display->add("listCat", $listCat);
         $display->add("allrecord", $allrecord);
         $display->add("otherCat", str_replace(array(chr(13), chr(10)), "", $otherCat));
         $display->add("total_cat", $total_cat);
         //Init for sphinx search paging
         $pager = new Pager();
         //config
         $limit = SEARCH_LIMIT;
         $pager->type = "search";
         $pager->catid = $catid;
         $pager->total = $total;
         $pager->limit = $limit;
         $pager->page_param = 'page';
         $pager->page = 1;
         $offset = $pager->get_offset();
         $limit_from = $pager->limit_from();
         $limit_to = $pager->limit_to();
         //Sphinx search by Nova
         $q = $keywords;
         $mode = SPH_MATCH_EXTENDED2;
         //Init config
         $host = SPHINX_SERVER;
         $port = SPHINX_PORT;
         //$index 		= SPHINX_INDEX;
         $index = "enbac delta";
         $filtervals = array();
         $ranker = SPH_RANK_WORDCOUNT;
         $cl = new SphinxClient();
         $cl->SetServer($host, $port);
         $cl->SetConnectTimeout(1);
         $cl->SetWeights(array(100, 1));
         $cl->SetMatchMode($mode);
         //filter
         if ($catid) {
             $cl->SetFilter('level_1_catid', array($catid));
         }
         $cl->SetFilter('status', array('1'));
         $cl->SetFieldWeights(array('user_name' => 10000, 'name' => 1000, 'description' => 1));
         //$cl->SetSortMode( SPH_SORT_EXTENDED, 'up_time DESC' );
         //$cl->SetSortMode( SPH_SORT_RELEVANCE);//Sort theo kq chính xác nhất
         //$cl->SetSortMode ( SPH_SORT_EXPR, "@weight + ( user_karma + ln(pageviews) )*0.1");
         $cl->SetSortMode(SPH_SORT_EXPR, "@weight");
         //Sort theo trọng số
         //SPH_RANK_WORDCOUNT
         //SPH_MATCH_EXTENDED2
         //end filter
         $cl->SetLimits($offset, $limit, 10000);
         $cl->SetRankingMode($ranker);
         $cl->SetArrayResult(true);
         $res = $cl->Query($q, $index);
         /*echo '<pre>';
         		print_r($res["matches"]);*/
         if ($res && isset($res["matches"])) {
             if (is_array($res["matches"])) {
                 foreach ($res["matches"] as $results) {
                     $list_item_id[] = $results['id'];
                 }
             }
             $comma_separated = join(",", $list_item_id);
         }
         if ($total) {
             if ($limit_to > $total) {
                 $limit_to = $total;
             }
             $comma_separated = join(",", $list_item_id);
             if ($comma_separated) {
                 //$sql = "SELECT id,name,up_time,price,user_id,user_name, level_1_catid,category_id,description,img_url, img_server FROM item WHERE id IN($comma_separated) AND status=1 ORDER BY up_time DESC";
                 //$sql = "SELECT id,name,up_time,price,user_id,user_name, level_1_catid,category_id,description,img_url, img_server FROM item WHERE id IN($comma_separated) AND status=1  AND state=0 ORDER BY find_in_set(id,'$comma_separated')";
                 $sql = "SELECT id,name,up_time,price,user_id,user_name, level_1_catid,category_id,description,img_url, img_server FROM item WHERE id IN({$comma_separated}) AND status=1 ORDER BY find_in_set(id,'{$comma_separated}')";
                 $search_result = DB::query($sql);
                 $pager->total = $total;
                 $paging = $pager->page_link();
             }
         }
     }
     $highlight = '';
     if ($keywords) {
         $highlight = $str_search = str_replace(array('+', '/', '|', '-', '*'), "", $keywords);
         $highlight = AZLib::trimSpace($highlight);
         $highlight = str_replace("'", '', $highlight);
         $highlight = str_replace("&#39;", '', $highlight);
         $highlight = str_replace("&quot;", '', $highlight);
     }
     $highlight1 = '';
     if ($highlight) {
         $arr = explode(' ', $highlight);
         if ($arr) {
             $highlight = "";
             foreach ($arr as $word) {
                 $highlight = ($highlight ? $highlight . ', ' : '') . "'{$word}'";
                 $highlight1 = ($highlight1 ? $highlight1 . ',' : '') . $word;
             }
         }
     }
     if ($keywords && $search_result) {
         while ($item = mysql_fetch_assoc($search_result)) {
             $item['profile_url'] = WEB_DIR . $item['user_name'];
             $item['name_hl'] = AZLib::HighLightKeyword(strip_tags(AZLib::filter_title($item['name'])), $highlight1);
             $item_time = TIME_NOW - $item['up_time'];
             //neu nho hon 1h thi tinh ra phut
             if ($item_time < 3600) {
                 $item['item_time'] = floor($item_time / 60) . " phút trước đây";
             } elseif ($item_time < 86400) {
                 $item['item_time'] = floor($item_time / 3600) . " giờ trước đây";
             } else {
                 $item['item_time'] = date('\\n\\gà\\y j \\t\\há\\n\\g n', $item['up_time']);
             }
             $item['description'] = AZLib::HighLightKeyword(AZLib::delDoubleSpace(AZLib::trimSpace(strip_tags(AZLib::post_db_parse_html(preg_replace('/\\[[0-9]{1,3}\\]/', '', $item['description']))))), $highlight1, 35, "background:yellow;font-size:14px;font-weight:bold;color:blue;");
             $ebname = AZLib::safe_title($item['name']);
             $ebname_tmp = substr(AZLib::safe_title($item['name']), 0, 20);
             if (isset(CGlobal::$allCategories[$item['category_id']])) {
                 $item['item_url'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . $ebname . '&nice_name=' . CGlobal::$allCategories[$item['category_id']]['nice_name']);
                 $item['item_url_tmp'] = WEB_ROOT . CGlobal::$allCategories[$item['category_id']]['nice_name'] . '/p' . $item['id'] . '/' . $ebname_tmp . '...';
             } else {
                 $item['item_url'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . $ebname);
                 $item['item_url_tmp'] = WEB_ROOT . 'p' . $item['id'] . '/' . $ebname_tmp . '...';
             }
             if ($item['img_url']) {
                 $item['img_url'] = AZLib::getImageThumb($item['img_url'], 110, 0, 1, $item['img_server']);
             }
             $item['price'] = number_format($item['price'], 0, ',', '.');
             $item_array[] = $item;
         }
     }
     global $start_rb;
     $mtime = microtime();
     $mtime = explode(" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $end_rb = $mtime;
     $search_time = round($end_rb - $start_rb, 3);
     $display->add('limit_from', $limit_from);
     $display->add('limit_to', $limit_to);
     $display->add('search_time', $search_time);
     $display->add('keywords', $keywords);
     $display->add('base_url', WEB_ROOT);
     $display->add('highlight', $highlight);
     $display->add('total_item_cat', $total);
     $display->add('name_item_cat', $catActive);
     $display->add('block_id', Module::$block_id);
     $display->add('paging', $paging);
     $display->add('items', $item_array);
     $display->output('sphinx_search');
 }
Exemplo n.º 24
0
<?php

if (REWRITE_ON) {
    ob_start();
    //start buffering//@ob_start('ob_gzhandler');
}
require_once ROOT_PATH . 'core/AutoLoader.php';
CGlobal::$my_server = $server_list;
CGlobal::$img_server = $img_server;
CGlobal::$img_ftp_server = $img_ftp_server;
define('CPC_URL', WEB_DIR . AZRewrite::formatUrl("?page=cpc_ad"));
if (MEMCACHE_ON) {
    CGlobal::$memcache_server = $memcache_server;
}
unset($memcache_server, $server_list, $img_server, $img_ftp_server);
if (isset($_REQUEST['trigger']) && (int) $_REQUEST['trigger'] == 1) {
    //Xoá cache tự động
    AZArrCache::del_cache();
    AZCache::auto_delete();
    AZNet::del_page_cache();
    StaticCache::delCache();
    exit;
}
$is_search_engine_array = array("Google", "Fast", "Slurp", "Ink", "Atomz", "Scooter", "Crawler", "MSNbot", "Poodle", "Genius");
$is_search_engine = 0;
foreach ($is_search_engine_array as $key => $val) {
    if (strstr($_SERVER['HTTP_USER_AGENT'], $val)) {
        $is_search_engine++;
    }
}
if (isset($_GET['page']) && $_GET['page'] == 'error') {
Exemplo n.º 25
0
 function draw()
 {
     $this->beginForm();
     global $display;
     $display->add('created_time_from', Url::get('created_time_from'));
     $display->add('created_time_to', Url::get('created_time_to'));
     $display->add('sender_user_name', Url::get('sender_user_name'));
     $display->add('processed', Url::get('processed'));
     //search theo ngay thang nam
     $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 = mktime(0, 0, 0, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
         }
     }
     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 = mktime(23, 59, 59, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
         }
     }
     $search_value = ' 1 ';
     if ($created_time_from) {
         $search_value .= ' AND time_post >= ' . $created_time_from;
     }
     if ($created_time_to) {
         $search_value .= ' AND time_post <= ' . $created_time_to;
     }
     // search ô textbox
     if (Url::get('sender_user_name') != '') {
         $search_value .= ' AND b.user_name like "%' . Url::get('sender_user_name') . '%" ';
     }
     if (Url::get('processed') == 1) {
         $search_value .= ' AND b.status = 0';
     }
     $item_per_page = 50;
     $sql_count = 'SELECT COUNT(*) AS total_item FROM `bad_content` AS b WHERE b.type = 1 AND ' . $search_value;
     $total = DB::fetch($sql_count, 'total_item', 0);
     $items = array();
     if ($total) {
         $limit = '';
         $paging = AZPagging::pagingSE($limit, $total, $item_per_page, 10, 'page_no', true, 'Phản hồi', 'Trang');
         $sql = 'SELECT i.name,i.transaction_type,i.category_id, b.id, b.admin_name, b.status, b.type,b.id_item, b.reason,b.user_id,b.user_name, b.note, b.time_post FROM `bad_content` b LEFT JOIN item i ON i.id = b.id_item WHERE b.type = 1 AND ' . $search_value . ' ORDER BY b.status, b.time_post DESC, b.type ASC ' . $limit;
         $result = DB::query($sql);
         if ($result) {
             while ($row = mysql_fetch_assoc($result)) {
                 $row['content'] = $row['name'];
                 $row['time_post'] = date('d/m/y H:i', $row['time_post']);
                 $row['content_tooltip'] = AZLib::remove_4_js(AZLib::filter_title($row['content']));
                 $row['content'] = AZLib::word_limit($row['content'], 12, '...');
                 $row['reason_tooltip'] = AZLib::remove_4_js(AZLib::filter_title($row['reason']));
                 $row['reason'] = AZLib::word_limit($row['reason'], 12, '...');
                 $row['note_tooltip'] = AZLib::remove_4_js(AZLib::filter_title($row['note']));
                 $row['note'] = AZLib::word_limit($row['note'], 12, '...');
                 $row['href'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $row['id_item'] . '&ebname=' . AZLib::safe_title($row['name']));
                 $row['del_link'] = Url::build_all(array('chk_id', 'del_all', 'cmd', 'id'), 'cmd=delete&id=' . $row['id']);
                 $items[$row['id']] = $row;
             }
         }
     } else {
         $paging = '';
     }
     $display->add('items', $items);
     $display->add('paging', $paging);
     $display->output('list');
     $this->endForm();
 }
Exemplo n.º 26
0
    function load_shop_label()
    {
        if (!CGlobal::$user_profile) {
            User::check_get_user();
        }
        if (CGlobal::$user_profile) {
            $mode_default = 'comment';
            if (!CGlobal::$shop_setting) {
                if (CGlobal::$user_profile['shop_setting']) {
                    CGlobal::$shop_setting = unserialize(stripslashes(CGlobal::$user_profile['shop_setting']));
                }
                if (!CGlobal::$shop_setting) {
                    CGlobal::$shop_setting = array('shop_name' => CGlobal::$user_profile['full_name'] ? CGlobal::$user_profile['full_name'] : CGlobal::$user_profile['user_name'], 'default_mode' => 1, 'default_layout' => 1, 'item_list_mode' => 0, 'adv_banner' => '');
                }
            }
            if (CGlobal::$shop_setting && !isset(CGlobal::$shop_setting['default_layout'])) {
                CGlobal::$shop_setting['default_layout'] = 1;
            }
            if (Url::get("mode") == "comment" || CGlobal::$shop_setting['default_mode'] == 2) {
                CGlobal::$website_title = 'Lưu bút - Shop ' . CGlobal::$user_profile['user_name'];
            }
            if (!CGlobal::$shop_setting['default_mode']) {
                if (Url::get('mode') == 'shop' || DB::select('item', 'user_id=' . CGlobal::$user_profile['id'] . ' AND status=1')) {
                    //Nếu có sp, mặc định là vào shop
                    CGlobal::$shop_setting['default_mode'] = 1;
                    $mode_default = 'shop';
                } else {
                    //Nếu ko có sản phẩm, mặc định vào lưu bút
                    CGlobal::$shop_setting['default_mode'] = 2;
                    $mode_default = 'comment';
                }
            } else {
                if (CGlobal::$shop_setting['default_mode'] == 1) {
                    $mode_default = 'shop';
                } else {
                    $mode_default = 'comment';
                }
            }
        }
        if (CGlobal::$shop_label) {
            CGlobal::$website_title .= ' | ' . CGlobal::$shop_label['name'];
            $this->label_id = CGlobal::$shop_label['id'];
        } else {
            $this->label_id = (int) Url::get('label_id', 0);
            if ($this->label_id) {
                CGlobal::$shop_label = DB::select("label", "id=" . $this->label_id);
            }
            if (!CGlobal::$shop_label) {
                $this->label_id = 0;
            }
        }
        $page_shop_item = (int) Url::get('page_shop_item', 1);
        $label_id = (int) Url::get("label_id", 0);
        $list_type = (int) Url::get("list_type", 0);
        global $display;
        $display->add('top_level_id', $label_id);
        $display->add('list_type', $list_type);
        $display->add('can_edit', User::have_permit(ADMIN_ITEM) || User::id() == CGlobal::$user_profile['id']);
        $status_check = User::id() == CGlobal::$user_profile['id'] || User::have_permit(ADMIN_ITEM) ? ' status IN(0,1,2,3,4,5)' : ' status =1';
        if ($label_id) {
            $total_item = DB::fetch('SELECT count(*) AS total_row FROM label_item AS L JOIN item AS I ON L.item_id=I.id AND I.' . $status_check . ' AND I.user_id=' . CGlobal::$user_profile['id'] . ' WHERE L.user_id=' . CGlobal::$user_profile['id'] . ' AND L.label_id=' . $label_id, 'total_row', 0);
        } else {
            $total_item = DB::fetch('SELECT count(*) AS total_row FROM item WHERE ' . $status_check . ' AND user_id=' . CGlobal::$user_profile['id'], 'total_row', 0);
        }
        $pagging = '';
        $items = array();
        $divID = 'shop_item';
        $item_per_page = 0;
        if ($total_item) {
            $item_per_page = 9;
            $limit = '';
            $url_path = WEB_DIR . 'ajax.php?act=shop&code=load_shop_label&user_id=' . CGlobal::$user_profile['id'] . '&label_id=' . $label_id . (!$list_type ? '' : '&list_type=' . $list_type);
            $pagging = AZPagging::AjaxPaging($limit, $total_item, $item_per_page, 5, 'page_shop_item', '', false, false, $url_path, $divID, true);
            if ($label_id) {
                $display->add('label_name', CGlobal::$shop_label['name']);
                $select = 'SELECT I.id, I.name,I.sapo, I.user_name, I.user_id,I.description,I.category_id, I.read_count, I.reply_count, I.currency_id, I.price, I.province_id, I.up_time,I.price_out, I.brief, I.img_url, I.status, I.state, I.img_server
				FROM label_item AS L JOIN item AS I ON L.item_id=I.id AND I.' . $status_check . ' AND I.user_id=' . CGlobal::$user_profile['id'] . ' WHERE L.user_id=' . CGlobal::$user_profile['id'] . ' AND L.label_id=' . $label_id . ' ORDER BY shop_order, up_time DESC' . $limit;
            } else {
                $select = 'SELECT id, name, sapo, user_name, user_id, description, category_id, read_count, reply_count, currency_id, price, brief, img_url, province_id, up_time, price_out, status, state, img_server,sticky FROM item WHERE ' . $status_check . ' AND user_id=' . CGlobal::$user_profile['id'] . ' ORDER BY shop_order, up_time DESC' . $limit;
            }
            $re = DB::query($select);
            if (User::is_login()) {
                $wids = User::get_wishlist('wish_list_items');
                $w_items = array();
                if ($wids) {
                    $w_items = explode(',', $wids);
                }
            }
            if ($re) {
                AZLib::getProvinces();
                AZLib::getCats();
                $item_ids = '';
                while ($item = mysql_fetch_assoc($re)) {
                    $item['price'] = AZLib::convertCurrency($item['price'], $item['currency_id']);
                    $item['price_out'] = AZLib::convertCurrency($item['price_out'], $item['currency_id']);
                    $item['currency_id'] = 1;
                    if ($item['img_url']) {
                        $item['image_url'] = AZLib::getImageThumb($item['img_url'], 200, 200, 0, $item['img_server']);
                    }
                    if (isset(CGlobal::$allCategories[$item['category_id']])) {
                        $item['href'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . AZLib::safe_title(AZLib::word_limit($item['name'], 12, '')) . '&nice_name=' . CGlobal::$allCategories[$item['category_id']]['nice_name']);
                    } else {
                        $item['href'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . AZLib::safe_title(AZLib::word_limit($item['name'], 12, '')));
                    }
                    $tooltip = '';
                    $tooltip .= 'Xem: ' . $item['read_count'] . ' - Phản hồi: ' . $item['reply_count'];
                    $item['time_label'] = '';
                    $up_time = date('H:i | ', $item['up_time']);
                    if (date('d.m.y', $item['up_time']) == date('d.m.y', TIME_NOW)) {
                        $up_time .= '<font color="green">H&#244;m nay</font>';
                    } else {
                        $up_time .= date('d.m.y', $item['up_time']);
                    }
                    //$item['created_time'] = 'đăng '.AZLib::duration_time($item['up_time']);
                    $item['created_time'] = $up_time;
                    if ($item['price']) {
                        $item['price'] = number_format($item['price'], 0, ',', '.');
                        $item['currency_id'] = CGlobal::$currency[$item['currency_id']];
                    } else {
                        $item['price'] = '';
                        $item['currency_id'] = '';
                    }
                    $item['price_title'] = 'Giá bán';
                    if ($item['price_out'] > 0) {
                        $item['price_out'] = number_format($item['price_out'], 0, ',', '.') . ($item['currency_id'] == ' ' ? ' ' . CGlobal::$currency[$item['currency_id']] : '');
                    } else {
                        $item['price_out'] = '0';
                    }
                    $item['no_base_source'] = AZLib::remove_4_js(str_replace(array("<br>", "<br />"), '', $item['brief']));
                    $item['description'] = AZLib::plainText(AZLib::parseBBCode(html_entity_decode($item['description'], ENT_QUOTES, "UTF-8")));
                    $item['description'] = preg_replace("/\\[([\\s]*[0-9]{1,2}[\\s]*)\\]/eis", " ", $item['description']);
                    $item['description'] = str_replace(array("'", "\""), array("", " "), $item['description']);
                    $item['description'] = AZLib::word_limit($item['description'], 250, '');
                    /* if($item['sapo']!=''){
                       $item['brief'] = $item['sapo'];
                       $item['brief'] = AZLib::subString(AZLib::filter_title($item['brief']),0,255,true);
                       $item['brief'] = AZLib::word_limit($item['brief'],30,'');
                       }
                       else{
                       $item['brief'] = String::display_sort_title($item['description'],30);
                       } */
                    $item['brief'] = '';
                    $item['parent_name'] = '';
                    if (isset(CGlobal::$allCategories[$item['category_id']]) && CGlobal::$allCategories[$item['category_id']]['parent_id']) {
                        $parent_id = CGlobal::$allCategories[$item['category_id']]['parent_id'];
                        if (isset(CGlobal::$allCategories[$parent_id])) {
                            $item['parent_name'] = CGlobal::$allCategories[$parent_id]['name'] . ' - ';
                        }
                    }
                    if (isset(CGlobal::$allCategories[$item['category_id']]['name'])) {
                        $item['category_name'] = $item['parent_name'] . CGlobal::$allCategories[$item['category_id']]['name'];
                    } else {
                        $item['category'] = '';
                        $item['category_name'] = '';
                    }
                    $item['safe_title'] = AZLib::safe_title($item['parent_name'] . $item['category_name']);
                    $item['category_href'] = WEB_DIR . AZRewrite::formatUrl('?page=list_detail&category_id=' . $item['category_id'] . '&ebname=' . $item['safe_title']);
                    $item['name'] = AZLib::subString(AZLib::filter_title($item['name']), 0, 115, true);
                    $item['name'] = AZLib::word_limit($item['name'], 12, '');
                    $item['user_name'] = $item['user_name'];
                    $item['profile_url'] = WEB_DIR . $item['user_name'];
                    $item['city'] = CGlobal::$provinces[$item['province_id']]['name'];
                    if ($item['img_url']) {
                        $item['img_url'] = AZLib::getImageThumb($item['img_url'], 110, 0, 1, $item['img_server']);
                    } else {
                        $item['img_url'] = 'style/images/no-images-69x53.jpg';
                    }
                    if (isset($_GET['ebname'])) {
                        $item['up_url'] = Url::build_current(array('action' => 'up', 'id' => $item['id'], 'category_id' => CGlobal::$curCategory, 'type' => Url::get('type'), 'ebname' => $_GET['ebname']));
                        $item['down_url'] = Url::build_current(array('action' => 'down', 'id' => $item['id'], 'category_id' => CGlobal::$curCategory, 'type' => Url::get('type'), 'ebname' => $_GET['ebname']));
                    } else {
                        $item['up_url'] = Url::build_current(array('action' => 'up', 'id' => $item['id'], 'category_id' => CGlobal::$curCategory, 'type' => Url::get('type')));
                        $item['down_url'] = Url::build_current(array('action' => 'down', 'id' => $item['id'], 'category_id' => CGlobal::$curCategory, 'type' => Url::get('type')));
                    }
                    $item['in_wish_list'] = false;
                    if (User::is_login()) {
                        if (in_array($item['id'], $w_items)) {
                            $item['in_wish_list'] = true;
                        } else {
                            $item['in_wish_list'] = false;
                        }
                    } else {
                        if (isset($_COOKIE['wish_list_item_ids'])) {
                            $arr = explode(',', $_COOKIE['wish_list_item_ids']);
                            foreach ($arr as $k => $v) {
                                if ($v == $item['id']) {
                                    $item['in_wish_list'] = true;
                                }
                            }
                        }
                    }
                    if (CGlobal::$user_profile['id'] == User::id()) {
                        $tooltip .= ' - <strong>ID tin: ' . $item['id'] . '</strong>';
                    }
                    $item['invalid'] = '';
                    if ($item['status'] == 2) {
                        $tooltip .= '<div style=\\\'color:red\\\'>(Đang kiểm duyệt)</div>';
                        $item['invalid'] = '<font color="red">(Đang kiểm duyệt)</font>';
                    } elseif ($item['status'] == 3) {
                        $tooltip .= '<div style=\\\'color:red\\\'>(Tin theo dõi lừa đảo)</div>';
                        $item['invalid'] = '<font color="red">(Theo dõi lừa đảo)</font>';
                    } elseif ($item['status'] == 0) {
                        $tooltip .= '<div style=\\\'color:red\\\'>(Đang ẩn)</div>';
                        $item['invalid'] = '<font color="red">(Đang ẩn)</font>';
                    } elseif ($item['status'] == 5) {
                        $tooltip .= '<div style=\\\'color:red\\\'>(Đang kiểm duyệt chờ chứng thực)</div>';
                        $item['invalid'] = '<font color="red">(KD chờ chứng thực)</font>';
                    } elseif ($item['status'] == 4) {
                        $tooltip .= '<div style=\\\'color:red\\\'>(Tin trùng)</div>';
                        $item['invalid'] = '<font color="red">(Tin trùng)</font>';
                    } elseif ($item['state'] == 1) {
                        $tooltip .= '<div style=\\\'color:red\\\'>(Đang khóa)</div>';
                        $item['invalid'] = '<font color="red">(Đang khóa)</font>';
                    }
                    $item['tooltip'] = $tooltip;
                    $item['lids'] = '';
                    $item_ids .= ($item_ids != '' ? ',' : '') . $item['id'];
                    $items[$item['id']] = $item;
                }
            }
            if ($item_ids) {
                $item_labels = array();
                //Label của tất cả sp đang đc hiển thị
                $re = DB::query("SELECT id, label_id, item_id FROM label_item WHERE item_id IN({$item_ids})");
                if ($re) {
                    while ($l_item = mysql_fetch_assoc($re)) {
                        if (isset($items[$l_item['item_id']])) {
                            $items[$l_item['item_id']]['lids'] .= ($items[$l_item['item_id']]['lids'] != '' ? ',' : '') . $l_item['label_id'];
                        }
                    }
                }
            }
        }
        $display->add('loading_ajax', true);
        $display->add('is_admin', (int) User::have_permit(ADMIN_ITEM));
        $display->add('cur_id', (int) User::id());
        $display->add('total_sp', (int) $total_item);
        $display->add('items', $items);
        $display->add('paging', $pagging);
        $display->add('item_per_page', $item_per_page);
        $display->add('page_num', $page_shop_item);
        $display->add('shop_user_id', CGlobal::$user_profile['id']);
        $display->add('shop_user_name', CGlobal::$user_profile['user_name']);
        $display->output($list_type != 1 ? 'ShopItem' : 'ShopItemListDetail', false, 'Shop');
    }