function __construct($row){ Module::Module($row); require_once 'forms/header.php'; $str_keywords = ''; $str_catSub = ''; $meta_desc = ''; //limit character description and keyword CGlobal::$keywords = EClassApi::word_limit(CGlobal::$keywords,20,''); CGlobal::$meta_desc = EClassApi::word_limit(CGlobal::$meta_desc,250,''); //Gán title cho các trang trong! if(isset($page_title_arr[EClass::$page['name']])){ CGlobal::$website_title = $page_title_arr[EClass::$page['name']].' | '.CGlobal::$website_title; } $this->add_form(new HeaderForm); }
function update() { if (User::is_admin()) { $item_id = EClassApi::getParam('item_id'); $info = EClassApi::getParam('id'); if ($info == 'description') { $value = Url::get('value'); if (get_magic_quotes_gpc()) { $value = stripslashes($value); } require_once ROOT_PATH . 'includes/htmLawed.php'; $config = array('safe' => 1, 'elements' => '*', 'deny_attribute' => 'class, id'); $spec = 'a = title, href;'; // The 'a' element can have only these attributes $value = htmLawed($value, $config, $spec); $value = EClassApi::clean_value($value); } else { /* $value = EClassApi::cleanHtml(EClassApi::filter_title(Url::get('value'))); $value = EClassApi::trimSpace(str_replace("\n"," ",$value)); */ $value = EClassApi::getParam('value'); mb_internal_encoding("UTF-8"); $value = mb_strtoupper(mb_substr($value, 0, 1)) . mb_substr($value, 1); } $info_array = array('name', 'description'); if (!in_array($info, $info_array)) { die("no_info"); } $row = Item::get_item($item_id); $item_memcache = $row; if ($info == 'description' && strlen(EClassApi::plainText(EClassApi::post_db_parse_html($value))) < 15) { echo "unsuccess"; exit; } /* if(!User::is_foodnet_team()){ $arr_badwords = EClassApi::checkBadWord($value,true); $value_badwords = $arr_badwords["bad"]."@enbac@".$arr_badwords["bad_key"]; if((strlen(trim($row['bad_words']))!=strlen(trim($value_badwords))) && strlen($arr_badwords["bad"])>0){ die('bad_content'); } } */ //if( $item_id && User::is_login()){ if ($item_id) { //if(($row["user_id"] == User::id() && !User::is_block()) || User::have_permit(ADMIN_ITEM) || User::have_cat_permit($row["category_id"])){ if ($info == 'name' && strlen($value) >= 5 && strlen($value) <= 150) { $input = array('name' => $value); $item_memcache['name'] = $value; $output = $value; if ($value != $row['name'] && $row['is_up_auto'] == 1) { //Nếu thay đổi tên thì cập nhật cho cả lịch up tin DB::query("UPDATE up_item_schedule SET des='{$value}' WHERE item_id=" . $row['id']); } } else { if ($info == 'description') { $sapo = EClassApi::word_limit(String::html2txt(EClassApi::post_db_parse_html($value)), 30, ''); $input = array('description' => $value, 'sapo' => $sapo); $item_memcache['description'] = $value; $output = preg_replace("/\\[([\\s]*[0-9]{1,2}[\\s]*)\\]/eis", "\$this->embeded('\$1','{$item_id}')", EClassApi::parseBBCode(Url::get('value'))); } else { $input = array(); } } $item_memcache['modify_user_name'] = User::user_name(); $item_memcache['filter_des'] = ""; $input['modify_user_name'] = User::user_name(); if ($row["status"] == 2) { $item_memcache['modify_time_user'] = TIME_NOW; $input['modify_time_user'] = TIME_NOW; } if ($input) { DB::Update('item', $input, "id='" . $item_id . "'"); ///update realtime if (SORL_FILTER_ON) { $solr = new Solr_Search(); $solr->doUpdateItem($item_id); } //----- if (MEMCACHE_ON) { eb_memcache::do_put("item:{$item_id}", $item_memcache); } } echo $output; exit; /* } else{ die("no_permission"); } */ } } die("no_perm"); }
function show_mes_outbox() { $search_text = EClassApi::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; require_once ROOT_PATH . 'core/ECPagging.php'; $paging = ECPagging::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, account.avatar_url, account.img_server FROM ' . $table_text . ', ' . $table_topics . ', account WHERE ' . $table_text . '.msg_id = ' . $table_topics . '.mt_msg_id AND ' . $table_topics . '.mt_from_id = account.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'] = EClassApi::getImageThumb($row['avatar_url'], 50, 50, 0, $row['img_server']); } else { $row['avatar_url'] = "style/images/50x50.gif"; } //$row['msg_date'] = EClassApi::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(EClassApi::parseBBCode(EClassApi::convert_one_br($row['msg_post'])), '<br />'); if (strlen($row['msg_post']) > 40) { $row['msg_post_short'] = EClassApi::word_limit($row['msg_post'], 40, ' ...'); //$row['msg_post_short'] = EClassApi::cleanHtml(EClassApi::word_limit($row['msg_post'],40,' ...')); } else { $row['msg_post_short'] = $row['msg_post']; //$row['msg_post_short'] = EClassApi::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?tab=gt' . $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?tab=gt' . $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 build_rss_cat($cat_id = '0', $cat_name = 'home', $limit = 100, $user_id = false) { $rss2 = ''; // content of rss2 file // start:begin rss2 $rss2 = '<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel>'; $rss2 .= '<title>' . $cat_name . ' - Enbac.com</title>'; $rss2 .= '<description>' . $cat_name . ' - Enbac.com</description>'; //$rss2.= '<link>'.trim(XMLLib::_xml_encode_attribute(WEB_ROOT.'?page=list_detail&category_id='.$cat_id)).'</link>'; //$cat_id ? $rss2.= '<link>'.WEB_ROOT.'?page=list_detail&category_id='.$cat_id.'</link>' : $rss2.='<link>'.WEB_ROOT.'?page=list_detail</link>'; $rss2 .= '<link>' . WEB_ROOT . '</link>'; //$rss2.= '<link>'.WEB_ROOT.'?page=list_detail&category_id='.$cat_id.'</link>'; $rss2 .= '<copyright>Enbac.com: http://chonmon.vn , Powered by Enbac Team: enbac@vccorp.vn</copyright>'; $rss2 .= '<docs>http://backend.userland.com/rss</docs>'; $rss2 .= '<generator>Enbac.com:http://chonmon.vn/rss.html</generator>'; $rss2 .= '<image><title>ChọnMón.vn</title><url>' . WEB_ROOT . 'style/images/logo.gif</url><link>http://chonmon.vn</link><width>290</width><height>65</height></image>'; //Tối ưu if ($user_id) { $sql = "SELECT item.id, category_id, item.name, up_time, item.description, item.transaction_type, item.created_time\n\t\t\t\t\t\tFROM item WHERE user_id=" . $user_id . " AND status=1 ORDER BY created_time DESC LIMIT 0,25"; } else { $sqlCate = "SELECT id FROM category WHERE parent_id = {$cat_id}"; $re = DB::query($sqlCate); $strId = "{$cat_id}"; if ($re) { while ($aryId = mysql_fetch_assoc($re)) { $strId .= "," . $aryId['id']; } } $sql = "SELECT id, category_id, name, up_time, description, transaction_type, created_time FROM item WHERE category_id IN({$strId}) AND status=1 ORDER BY created_time DESC LIMIT 0,{$limit}"; } /*$user_id ? $sql = "SELECT item.id, category_id, item.name, up_time, item.description, item.transaction_type, item.created_time FROM item WHERE user_id=".$user_id." AND status=1 ORDER BY created_time DESC LIMIT 0,25" : $sql = "SELECT item.id, category_id, item.name, up_time, item.description, item.transaction_type, item.created_time FROM item, category WHERE category.id = item.category_id AND item.status=1 AND (category_id='".$cat_id."' OR category.parent_id='".$cat_id."') ORDER BY created_time DESC LIMIT 0,".$limit;*/ $re = DB::query($sql); if ($re) { while ($item = mysql_fetch_assoc($re)) { $page = 'item_detail'; $item['name'] = trim(XMLLib::_xml_encode_attribute(strip_tags(html_entity_decode($item['name'])))); $item['description'] = trim(XMLLib::_xml_encode_attribute(strip_tags(html_entity_decode(EClassApi::word_limit($item['description'], 150), ENT_QUOTES, "UTF-8")))); //$item['url'] = trim(XMLLib::_xml_encode_attribute(WEB_ROOT."?page=".$page."&id=".$item['id']."&category_id=".$item['category_id']."&ebname=".EClassApi::safe_title($item['name']))); $item['url'] = WEB_ROOT . "p" . $item['id'] . "/" . EClassApi::safe_title($item['name']) . ".html"; //$item['url'] = EClassApi::remove_4_js($item['url']); //rss2 $rss2 .= "<item>"; $rss2 .= "<title>" . $item['name'] . " - Enbac.com</title>"; $rss2 .= "<description>(Enbac) - " . $item['description'] . "</description>"; $rss2 .= "<link>" . $item['url'] . "</link>"; $rss2 .= '<guid isPermaLink="True">' . $item['url'] . '</guid>'; $rss2 .= "<pubDate>" . date("D, d M Y H:i:s", $item['created_time']) . " GMT</pubDate>"; $rss2 .= "</item>"; } } //content:end // end:begin $rss2 .= '</channel></rss>'; // end:end return $rss2; }
function get_feed_notify_bar() { EClassApi::getCats(); $json = ""; if (!User::is_login()) { $json = '({"msg":"no_login"})'; echo $json; exit; } $item_comment_ids = ""; //Id các phản hồi giao dịch $user_comment_ids = ""; //Id các lưu bút $entry_comment_ids = ""; //Id các bài viết /*$follow_ids = "";//Id các theo đuôi*/ $blast_user_ids = ""; // Id các balst $arr_data = array(); $user = User::getUser(User::id()); if ($user["total_pm"]) { // neu co PM moi $arr_data = array("new_pm" => $user["total_pm"]); } $where = "WHERE user_id = " . User::id(); $limit = " LIMIT 20"; $sql = "SELECT * FROM feed {$where} ORDER BY time DESC {$limit}"; $re = DB::query($sql); if ($re) { while ($feed = mysql_fetch_assoc($re)) { if ($feed['type'] == 1 || $feed['type'] == 2) { // phan hoi $item_comment_ids .= ($item_comment_ids != '' ? ',' : '') . $feed['ref_id']; } elseif ($feed['type'] == 3) { // luu but $user_comment_ids .= ($user_comment_ids != '' ? ',' : '') . $feed['ref_id']; } elseif ($feed['type'] == 5 || $feed['type'] == 6) { // bai viet $entry_comment_ids .= ($entry_comment_ids != '' ? ',' : '') . $feed['ref_id']; } /*elseif($feed['type']==7){// theo duoi $follow_ids.=($follow_ids!=''?',':'').$feed['ref_id']; }*/ } } //Phản hồi giao dịch $item_comment_arr = array(); if ($item_comment_ids != '') { $item_ids = ""; $re = DB::query("SELECT time, item_id, parent_id, COUNT(item_id) AS total_comment FROM comment WHERE id IN({$item_comment_ids}) GROUP BY item_id"); if ($re) { while ($comment = mysql_fetch_assoc($re)) { $item_ids .= ($item_ids != '' ? ',' : '') . $comment['item_id']; $comment['time'] = EClassApi::duration_time($comment['time']); $item_comment_arr[$comment['item_id']] = $comment; } if ($item_comment_arr && $item_ids) { // Query de lay ID va Tieu de tin $re = DB::query("SELECT id, name, level_1_category_id FROM item WHERE id IN({$item_ids})"); while ($item = mysql_fetch_assoc($re)) { if ($item["id"] == $item_comment_arr[$item["id"]]["item_id"]) { $item_comment_arr[$item["id"]]["item_name"] = EClassApi::word_limit($item["name"], 7, '...'); $ebname = EClassApi::safe_title($item['name']); if (isset(CGlobal::$allCategories[$item['level_1_category_id']])) { $cat_name = CGlobal::$allCategories[$item['level_1_category_id']]['name']; $item_comment_arr[$item["id"]]["url_link"] = WEB_DIR . EClassApi::safe_title($cat_name) . "/p{$item['id']}/{$ebname}.html"; } else { $item_comment_arr[$item["id"]]["url_link"] = WEB_DIR . "/p{$item['id']}/{$ebname}.html"; } } } } } if ($item_comment_arr) { $item_comment_arrs["comment"] = $item_comment_arr; $arr_data += $item_comment_arrs; } } // End Phan hoi giao dich //Luu but $total_comment_arr = array(); if ($user_comment_ids != '') { $re = DB::query("SELECT time, COUNT(id) AS total_comment_user FROM comment_user WHERE id IN({$user_comment_ids}) GROUP BY receiver_user_id ORDER BY time DESC"); if ($re) { $comment_user = mysql_fetch_assoc($re); $total_comment_arr["total"] = $comment_user["total_comment_user"]; $total_comment_arr['time'] = EClassApi::duration_time($comment_user['time']); $total_comment_arr["url_link"] = WEB_DIR . 'Shop/' . User::user_name() . '/Luu-but'; } if ($total_comment_arr) { $total_comment_arrs["comment_user"] = $total_comment_arr; $arr_data += $total_comment_arrs; } } //End Luu but // Theo duoi /*$follow_arr = array(); if($follow_ids!=''){ $re = DB::query("SELECT id, follower_name, time FROM follow WHERE id IN($follow_ids) ORDER BY time DESC"); if($re){ while ($follow = mysql_fetch_assoc($re)){ $follow['time'] = EClassApi::duration_time($follow['time']); $follow["url_link"] = WEB_DIR.$follow['follower_name']; $follow_arr[$follow['id']] = $follow; } } if($follow_arr){ $follow_arrs["follow"] = $follow_arr; $arr_data += $follow_arrs; } }*/ // end Theo duoi // Phản hồi bài viết $entry_comment_arr = array(); if ($entry_comment_ids != '') { $entry_ids = ""; $re = DB::query("SELECT time, entry_id, parent_id FROM user_entry_comment WHERE id IN({$entry_comment_ids})"); if ($re) { while ($comment_entry = mysql_fetch_assoc($re)) { $entry_ids .= ($entry_ids != '' ? ',' : '') . $comment_entry['entry_id']; $comment_entry['time'] = EClassApi::duration_time($comment_entry['time']); $comment_entry['total_comment_entry'] = count(explode(',', $entry_comment_ids)); $entry_comment_arr[$comment_entry['entry_id']] = $comment_entry; } if ($entry_comment_arr && $entry_ids) { // Query de lay ID va Tieu de bai viet $re = DB::query("SELECT id, title FROM user_entry WHERE id IN({$entry_ids})"); while ($entry = mysql_fetch_assoc($re)) { if ($entry["id"] == $entry_comment_arr[$entry["id"]]["entry_id"]) { $entry_comment_arr[$entry["id"]]["title"] = EClassApi::word_limit($entry["title"], 7, '...'); $ebname = EClassApi::safe_title($entry['title']); $entry_comment_arr[$entry["id"]]["url_link"] = WEB_DIR . "Bai-viet/" . User::user_name() . "/e{$entry['id']}/{$ebname}"; } } } } if ($entry_comment_arr) { $item_comment_arrs["entry"] = $entry_comment_arr; $arr_data += $item_comment_arrs; } } // End Phan hoi bài viết $json = json_encode($arr_data); echo $json; exit; }