function draw() { global $display; $item_ids = ''; $item_news = array(); $configs = @CGlobal::$configs['ItemNew']['conf_val']; if ($configs) { $configs = unserialize(stripslashes($configs)); $title_new = $configs['title']; $item_ids = $configs['item_ids']; } else { $title_new = "SẢN PHẨM MỚI"; $item_ids = ''; } if ($item_ids) { $re = DB::query("SELECT * FROM item WHERE id IN({$item_ids}) AND status = 1 ORDER BY find_in_set(id,'{$item_ids}')"); if ($re) { while ($product = mysql_fetch_assoc($re)) { if ($product['img_url']) { $product['image'] = AZLib::getImageThumb($product['img_url'], 160, 150, 0, $product['img_server']); } else { $product['image'] = ""; //"style/images/no-images-35x35.gif"; } if (isset(CGlobal::$allCategories[$product['category_id']])) { $product['url'] = WEB_DIR . CGlobal::$allCategories[$product['category_id']]['nice_name'] . "/p{$product['id']}/" . AZLib::safe_title($product['name']) . ".html"; } else { $product['url'] = WEB_DIR . "p{$product['id']}/" . AZLib::safe_title($product['name']) . ".html"; } $product['name'] = stripslashes($product['name']); if ($product['list_brief'] == '') { $product['list_brief'] = $product['brief']; } $product['list_brief'] = AZLib::remove_4_js(AZLib::plainText(AZLib::parseBBCode(html_entity_decode($product['list_brief'], ENT_QUOTES, "UTF-8")))); $product['list_brief'] = preg_replace("/\\[([\\s]*[0-9]{1,2}[\\s]*)\\]/eis", " ", $product['list_brief']); $product['list_brief'] = str_replace(array("'", "\""), array("", " "), $product['list_brief']); $product['list_brief'] = AZLib::word_limit($product['list_brief'], 50, ''); $product['list_brief'] = '<b>' . str_replace(array("'", "\""), array("", " "), $product['name']) . '</b><br />' . $product['list_brief']; $product['price_num'] = $product['price']; $product['price'] = AZLib::getPrice($product['price'], $product['currency_id']); $item_news[$product['id']] = $product; } } } if (User::is_admin()) { $display->add("is_admin", 1); $display->add("msg", $this->showFormErrorMessages(1)); $display->add('begin_form', $this->beginForm(true, 'post', false, false, 1)); $display->add('end_form', $this->endForm(true)); } $display->add('title_new', $title_new); $display->add('item_ids', $item_ids); $display->add('item_news', $item_news); $display->output("ItemNew"); }
static function Send_pm($sender_id, $sender_name, $receiver_user, $title, $content, $once_way = false, $ref_id = 0) { $num_send = 0; $new_row_msg = array('msg_date' => TIME_NOW, 'msg_post' => htmlspecialchars_decode($content), 'msg_author_id' => $sender_id, 'msg_author_name' => $sender_name, 'msg_ip_address' => AZLib::ip()); // ***** CHÚ Ý ***** // Newest = 0 - Mới nhất, = 1 - Cũ hơn (Do lỗi tạo giá trị mặc định trường này là 0, nên quy ước hơi bị ngược, để đỡ mất công chạy lệnh update database // ***** CHÚ Ý ***** $msg_id = DB::insert('message_text', $new_row_msg); $inbox_ref_id = 0; if ($ref_id) { $msgText = DB::select('message_topics', 'mt_id = ' . $ref_id . ' AND mt_owner_id = ' . $sender_id); if ($msgText['mt_msg_id']) { // Kiểm tra xem người nhận còn tin nhắn gốc hay không $mtTopic = DB::select('message_topics', 'mt_msg_id = ' . $msgText['mt_msg_id'] . ' AND mt_id <> ' . $ref_id . ' AND mt_owner_id = ' . $receiver_user['id'] . ' AND mt_from_id <> ' . $receiver_user['id']); // Nế còn tin nhắn gốc if ($mtTopic['mt_id']) { // Gán tin nhắn sắp gửi là tin nhắn mới nhất // Lấy id tin nhắn gốc của người gửi làm ref_id cho tin nhắn sắp gửi $inbox_ref_id = $mtTopic['mt_id']; } } } // Đặt cờ tin nhắn mới nhất (inbox) của các tin trong luồng của người nhận = 0 if ($inbox_ref_id) { DB::query('UPDATE message_topics SET mt_newest = 1 WHERE mt_newest = 0 AND mt_vid_folder = \'inbox\' AND (mt_ref_id = ' . $inbox_ref_id . ' OR mt_id = ' . $inbox_ref_id . ') AND mt_owner_id = ' . $receiver_user["id"]); } // Đặt cờ tin nhắn mới nhất (sent) của các tin trong luồng của người gửi = 0 if ($ref_id) { DB::query('UPDATE message_topics SET mt_newest = 1 WHERE mt_newest = 0 AND mt_vid_folder = \'sent\' AND (mt_ref_id = ' . $ref_id . ' OR mt_id = ' . $ref_id . ') AND mt_owner_id = ' . $sender_id); } $new_row_msg = array('mt_msg_id' => $msg_id, 'mt_date' => TIME_NOW, 'mt_title' => $title, 'mt_ref_id' => $inbox_ref_id, 'mt_newest' => 0, 'mt_to_name' => $receiver_user["user_name"], 'mt_read' => 0); $arrID = array($sender_id, $sender_name, $receiver_user["id"], $receiver_user["user_name"]); // Tạo tiêu đề tin nhắn mới $msg_id_inbox = AZLib::InserMessage($new_row_msg, $arrID, $status = 'inbox'); if ($msg_id_inbox) { $num_send++; //insert vao bang feed $feed_sql = "(4,{$receiver_user['id']},{$msg_id_inbox},{$new_row_msg['mt_date']},{$sender_id},0)"; $feed_sql = "INSERT INTO feed (`type`,`user_id`,`ref_id`,`time`,`act_user_id`,`item_id`) VALUES " . $feed_sql; DB::query($feed_sql); } if ($once_way == false) { $new_row_msg['mt_read'] = 1; $new_row_msg['mt_ref_id'] = $ref_id; $msg_id_sent = AZLib::InserMessage($new_row_msg, $arrID, $status = 'sent'); $num_send++; } else { $msg_id_sent = true; } // Nếu tin được tạo mới là tin nhắn trả lời //if($inbox_ref_id) //{ // Đặt cờ đã có tin nhắn trả lời cho tin nhắn gốc trong cả "inbox" và "sent" //DB::query(' UPDATE message_topics SET mt_has_reply = 1 WHERE mt_id = ' . $ref_id . ' AND mt_vid_folder = \'inbox\''); // DB::query(' UPDATE message_topics SET mt_has_reply = 1 WHERE mt_id = ' . $inbox_ref_id); //} if ($msg_id_inbox && $msg_id_sent) { $count_pm = true; // Đối với tin trả lời, chỉ đếm những tin trả lời mới cho tin thuộc các luồng tin khác nhau if ($ref_id) { // Kiểm tra xem trong luồng tin hiện tại có tin trả lời nào chưa đọc hay không $re = DB::query('SELECT COUNT(*) AS unreadCount FROM message_topics WHERE mt_ref_id = ' . $ref_id . ' AND mt_vid_folder = \'inbox\' AND mt_owner_id = ' . $receiver_user["id"] . ' AND mt_read = 0'); if ($re) { $row = mysql_fetch_assoc($re); // Nếu có thì không tính thêm tin này vào tổng pm if ($row['unreadCount'] > 1) { $count_pm = false; } } } if ($count_pm) { DB::query('UPDATE user SET total_pm = total_pm + 1 WHERE id=' . $receiver_user["id"]); } User::getUser($receiver_user["id"], 0, 1); DB::query("UPDATE message_text SET msg_sent_to_count = {$num_send} WHERE msg_id = {$msg_id}"); if ($receiver_user['email'] && $receiver_user['email_alert']) { $link = WEB_ROOT . Url::build('message'); $content = trim(addslashes(AZLib::parseBBCode($title . ' - ' . $content, true))); AZLib::addCronJob('pm', $content, $receiver_user['id'], User::user_name(), '', 0, '', $link); } return true; } else { return false; } }
function transaction() { // viet luu but header("Content-type: application/xml"); if (!User::is_login()) { echo "<comments><content>no_login</content></comments>"; exit; } else { if (User::is_block()) { echo "<comments><content>no_perm</content></comments>"; exit; } if (AZLib::isBlackList(User::$current->data['id'], AZLib::getParam('user_id'))) { echo "<comments><content>blacklist</content></comments>"; exit; } if (AZLib::checkBadWord(AZLib::getParam('content'))) { echo "<comments><content>bad_word</content></comments>"; exit; } $user_id = AZLib::getParam('user_id'); if (!($user = User::getUser($user_id))) { echo "<comments><content>no_perm</content></comments>"; exit; } $content = preg_replace("/\n/", "<br />", Url::get('content')); $content = str_replace('<br /><br />', ' ', $content); $comment_content = $content; $id = DB::insert('comment_user', array('content' => $comment_content, 'time' => TIME_NOW, 'post_ip' => AZLib::ip(), 'sender_user_id' => User::id(), 'sender_user_name' => User::user_name(), 'receiver_user_id' => $user['id'], 'receiver_user_name' => $user['user_name'], 'is_read' => 0)); if ($id) { DB::query('UPDATE user set total_comment_user=total_comment_user+1 WHERE id=' . $user['id']); // so luu but User::getUser($user['id'], 0, 1); if ($user['email'] && $user['email_alert'] && $user['id'] != User::id()) { //Add to cron job: $link = WEB_ROOT . AZRewrite::formatUrl('?page=shop&user_name=' . $user['user_name'] . '&mode=comment'); AZLib::addCronJob('user_comment', AZLib::parseBBCode($comment_content, true), $user['id'], User::user_name(), '', 0, '', $link); } } $time = $up_time = date('H:i | '); $xml = "<comments><content><![CDATA[" . AZLib::parseBBCode($comment_content) . "]]></content><post_time>{$time}</post_time></comments>"; echo $xml; System::halt(); } }
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 />', ' ', $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; }
function show_mes_outbox() { $search_text = AZLib::getParam('search_text'); $is_archive = Url::get('is_archive', 0); $table_topics = 'message_topics'; $table_text = 'message_text'; $url_archive = ''; $url_cmd = ''; if ($is_archive) { $table_topics = $table_topics . '_archive'; $table_text = $table_text . '_archive'; $url_cmd = '?cmd=archive'; $url_archive = '&is_archive=1'; } $condition = $table_topics . '.mt_owner_id =' . User::id() . ' AND ' . $table_topics . '.mt_vid_folder = "sent" AND ' . $table_topics . '.mt_newest = 0'; if ($search_text && $search_text != "Account thành viên") { $condition .= " AND mt_to_name LIKE '%{$search_text}%' "; } $str_content = '<form name="message"> <div id="boxFunctions"> Chọn: <a style="cursor:pointer" id="select_all">Tất cả</a>, <a style="cursor:pointer" id="select_read">Đã đọc</a>, <a style="cursor:pointer" id="select_unchecked">Không chọn</a> <div id="boxFunctionRight"> <div id="btn_del_mess" align="center" class="btnAllNewFeedback" onmouseout="this.className=\'btnAllNewFeedback\'" onmouseover="this.className=\'btnAllNewFeedbackHover\'" style="width:40px;"> <div class="btnRightAllFeedback" align="center" style="width:40px"><a title="Xóa tất cả tin nhặn đã chọn" href="javascript:void(0)" onClick="return delMessage(0,\'true\',\'outbox\')">Xoá</a></div> </div> </div> </div> '; $str_content .= '<table cellpadding="3" cellspacing="0" border="0" width="100%">'; $sql_count = 'SELECT COUNT(mt_id) AS total_row FROM ' . $table_topics . ' WHERE ' . $condition; $total_item = DB::fetch($sql_count, 'total_row', 0); $item_per_page = 15; $limit = ''; $divID = 'mess_content'; $url_path = WEB_DIR . 'ajax.php?act=personal&code=show_mes_outbox' . $url_archive . '&search_text=' . $search_text; $paging = AZPagging::AjaxPaging($limit, $total_item, $item_per_page, 5, 'page_mes', '', false, false, $url_path, $divID, true); $sql = 'SELECT ' . $table_text . '.msg_id, ' . $table_text . '.msg_author_name, ' . $table_text . '.msg_date, ' . $table_text . '.msg_post, ' . $table_topics . '.mt_id, ' . $table_topics . '.mt_ref_id, ' . $table_topics . '.mt_title, ' . $table_topics . '.mt_from_id, ' . $table_topics . '.mt_owner_id, ' . $table_topics . '.mt_read, ' . $table_topics . '.mt_owner_name, ' . $table_topics . '.mt_to_name, user.avatar_url, user.img_server FROM ' . $table_text . ', ' . $table_topics . ', user WHERE ' . $table_text . '.msg_id = ' . $table_topics . '.mt_msg_id AND ' . $table_topics . '.mt_from_id = user.id AND ' . $condition . ' ORDER BY ' . $table_text . '.msg_date DESC ' . $limit; //echo $sql; //exit; $result = DB::query($sql); $stt = 0; if ($result) { while ($row = mysql_fetch_assoc($result)) { if ($stt < $item_per_page) { if ($row['mt_ref_id']) { $sourceTitle = DB::select($table_topics, 'mt_id = ' . $row['mt_ref_id']); if ($sourceTitle['mt_title']) { $row['mt_title'] = $sourceTitle['mt_title']; } //else //{ // $sentTitle = DB::select($table_topics,'mt_mgsid = ' . $row['mt_ref_id']); //} $row["mt_id"] = $row['mt_ref_id']; $row['mt_ref_id'] = 0; } if ($row['avatar_url']) { $row['avatar_url'] = AZLib::getImageThumb($row['avatar_url'], 50, 50, 0, $row['img_server']); } else { $row['avatar_url'] = "style/images/50x50.gif"; } //$row['msg_date'] = AZLib::duration_time($row['msg_date']); $msg_date = date('H:i | ', $row['msg_date']); if (date('d.m.y', $row['msg_date']) == date('d.m.y', TIME_NOW)) { $msg_date .= '<font color="green">Hôm nay</font>'; } else { $msg_date .= date('d.m.y', $row['msg_date']); } $row['msg_date'] = $msg_date; $row['msg_post'] = preg_replace("/\n/", "<br />", $row['msg_post']); $row['msg_post'] = strip_tags(AZLib::parseBBCode(AZLib::convert_one_br($row['msg_post'])), '<br />'); if (strlen($row['msg_post']) > 40) { $row['msg_post_short'] = AZLib::word_limit($row['msg_post'], 40, ' ...'); //$row['msg_post_short'] = AZLib::cleanHtml(AZLib::word_limit($row['msg_post'],40,' ...')); } else { $row['msg_post_short'] = $row['msg_post']; //$row['msg_post_short'] = AZLib::cleanHtml($row['msg_post']); } //$str_title = '<a onclick="fn_show_mes_detail('.$row["mt_id"].')" rel="history" href="message.html'.$url_cmd.'#outbox/'.$row["mt_id"].'" id="a_'.$row["mt_id"].'" title="Hiển thị chi tiết" >'.$row["mt_title"].'</a> - <span class="textMestime">'.$row['msg_date'].'</span>'; if ($row['mt_owner_id'] != User::id()) { $strUser = '******' . $row["mt_owner_name"] . '">' . $row["mt_owner_name"] . '</a>'; } else { $strUser = '******' . $row["mt_to_name"] . '">' . $row["mt_to_name"] . '</a>'; } if ($row["mt_read"] == 0 && !$is_archive) { $str_title = '<a onclick="detail_reload_jcache = true;fn_show_mes_detail(' . $row["mt_id"] . ',1,\'outbox\')" rel="history" id="a_' . $row["mt_id"] . '" href="message.html' . $url_cmd . '#outbox/' . $row["mt_id"] . '" title="Hiển thị chi tiết" ><b>' . $row["mt_title"] . '</b></a>'; $read_class = ' unreadMessage'; } else { $str_title = '<a onclick="detail_reload_jcache = true;fn_show_mes_detail(' . $row["mt_id"] . ',1,\'outbox\')" rel="history" id="a_' . $row["mt_id"] . '" href="message.html' . $url_cmd . '#outbox/' . $row["mt_id"] . '" title="Hiển thị chi tiết">' . $row["mt_title"] . '</a>'; $read_class = ''; } $str_content .= '<tr id="' . $row["mt_id"] . '"> <td align="center" class="listMessage' . $read_class . '"><input type="checkbox" class="rowbox' . $read_class . '" id="inbox_' . $row["mt_id"] . '" name="inbox[]" value="' . $row["mt_id"] . '"></td> <td align="center" class="listMessage' . $read_class . '"> <a href="' . $row["msg_author_name"] . '"><img src="' . $row["avatar_url"] . '"/></a> </td> <td valign="top" class="listMessage' . $read_class . '" style="white-space:nowrap; padding-right:15px; vertical-align:middle;"> <div>' . $strUser . '</div> <div class="textMestime">' . $row['msg_date'] . '</div> </td> <td valign="top" class="listMessage clickable' . $read_class . '" style="padding-right:15px;width:65%;" lang="' . $row["mt_id"] . '"> <div style="margin-top:6px;">' . $str_title . '</div> <div style="margin:6px 0;color:#808080">' . $row['msg_post_short'] . '</div> </td> <td align="center" class="listMessage' . $read_class . '" style="padding-right:10px;"> <span><a title="Xóa tin nhắn" onClick="return delMessage(' . $row["mt_id"] . ',\'false\',\'inbox\')" href="javascript:void(0)" style="padding:20px;" class="deleteButton"> </a></span></td> </tr> '; /*$str_content .= '<tr id="'.$row["mt_id"].'"> <td align="center" class="listMessage' . $read_class . '"><input type="checkbox" id="inbox_'.$row["mt_id"].'" name="inbox[]" value="'.$row["mt_id"].'"></td> <td align="center" class="listMessage' . $read_class . '"> <a href="'.$row["mt_to_name"].'"><img src="'.$row["avatar_url"].'" vspace="4" hspace="4"/></a> <div><a href="'.$row["mt_to_name"].'">'.$row["mt_to_name"].'</a></div> </td> <td valign="top" style="width:65%;" class="listMessage' . $read_class . '"> <div>'.$str_title.'</div> <div style="margin-top:6px">'.$row['msg_post_short'].'</div> </td> <td align="center" class="listMessage' . $read_class . '"> <span><a title="Xóa tin nhắn" onClick="delMessage('.$row["mt_id"].',\'false\',\'sent\')" href="javascript:void(0)"> <img src="style/images/icon_delete.gif" width="9" height="9" /></a></span></td> </tr>';*/ } $stt++; } } if ($stt > 0) { $str_content .= '<tr><td></td><td> </td><td colspan="2"><div style="float:right">' . $paging . '</div><div style="clear:right"></div></td></tr>'; } else { $str_content .= '<tr><td></td><td colspan="3"> <center><div class="noMess">Không có Tin nhắn nào trong tin đã gửi</div></center> </td></tr>'; } $str_content .= '</table></form>'; echo $str_content; exit; }
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'); }
function processItem($item, $admin_item) { 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['modify_time'] = date('H:i | d.m.y', $item['modify_time']); $item['price'] = AZLib::convertCurrency($item['price'], $item['currency_id']); $item['price_out'] = AZLib::convertCurrency($item['price_out'], $item['currency_id']); $item['currency_id'] = 1; $item['price_num'] = (int) $item['price']; if ($item['price']) { $item['price'] = number_format($item['price'], 0, ',', '.'); } else { $item['price'] = ''; } $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['price'] = AZLib::convertCurrency($item['price'], $item['currency_id']); //$item['price_out'] = AZLib::convertCurrency($item['price_out'], $item['currency_id']); if ($admin_item) { $item['description'] = AZLib::remove_4_js(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'], 200, ''); } $item['name'] = AZLib::filter_title($item['name']); if ($item['img_url']) { $item['img_thumb_wl'] = AZLib::getImageThumb($item['img_url'], 180, 0, 1, $item['img_server']); } else { $item['img_url'] = ''; } if (!CGlobal::$curLevel2Cat) { if (isset(CGlobal::$allCategories[$item['category_id']])) { $item['cat_name'] = CGlobal::$allCategories[$item['category_id']]['name']; } else { $item['cat_name'] = "ID: {$item['category_id']}"; } } return $item; }
function get_comment($sql, $sub = 0) { global $user_id_arr, $stt, $item_per_page; $re = DB::query($sql); $items = array(); $id_parent = ''; while ($item = mysql_fetch_assoc($re)) { if ($sub == 0) { $stt++; } if ($sub || $sub == 0 && $stt <= $item_per_page) { //$item['created_time'] = AZLib::duration_time($item['time']); $item['created_time'] = date('H:i | d.m.Y', $item['time']); if ($item['sender_user_id']) { $item['sender_link'] = Url::build('shop', array('user_name' => $item['sender_user_name'])); } else { $item['sender_link'] = ''; } if ($item['sender_user_id']) { $item['user_id'] = $item['sender_user_id']; if (!in_array($item['sender_user_id'], $user_id_arr)) { $user_id_arr[$item['sender_user_id']] = $item['sender_user_id']; } } else { $item['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 = ''; $item['is_block'] = 0; $item['is_admin_mod'] = array(); } $item['content'] = AZLib::parseBBCode($item['content']); $item['URL_badcontent'] = Url::build('item_detail', array('id' => Url::get('id'), 'ctype' => 'comment', 'id_comment' => $item['id'])); if ($sub) { $items['item'][$item['parent_id']][$item['id']] = $item; } else { if ($item['have_child'] > 0) { $id_parent .= ($id_parent ? ',' : '') . $item['id']; } $items['item'][$item['id']] = $item; } $items['id_parent'] = $id_parent; } } return $items; }
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ô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'); }