function del_comment() { $json['msg'] = ''; if (!User::is_login() || User::is_block()) { $json['msg'] = "not_perm"; die(json_encode($json)); } $id = (int) Url::get("id"); if ($id) { $comment = DB::fetch("SELECT * FROM comment WHERE id={$id} LIMIT 1"); if (count($comment) == 0) { exit; } if (User::have_permit(ADMIN_ITEM) || User::id() == $comment['receiver_user_id'] && $comment['sender_user_id'] == 0) { EClassApi::update_cache_comment($comment['item_id']); if (DB::delete('comment', 'id=' . $id)) { $subItemId = $comment['sub_item_id']; $itemId = $comment['item_id']; if (MEMCACHE_ON) { //eb_memcache::do_put('update_comment_sub_' . $itemId . '_' . $subItemId, 1); /*ngannv #update_comment_sub tìm thêm trong ajax_item_detai.ajax*/ eb_memcache::do_remove('comment_sub_' . $itemId . '_' . $subItemId); } $countChild = $comment['have_child']; if ($countChild > 0) { DB::delete('comment', 'parent_id=' . $id); } $countChildDel = $countChild + 1; if ($subItemId > 0) { DB::query("UPDATE item_sub SET comment_count=comment_count-{$countChildDel} WHERE id={$subItemId} LIMIT 1"); /*SubItem chưa có cache nên tạm thời truy vấn lại để lấy số comment*/ $subCommentRes = DB::fetch("SELECT comment_count FROM item_sub WHERE id={$subItemId} LIMIT 1"); if (!empty($subCommentRes)) { $json['countCommentSubItem'] = $subCommentRes['comment_count']; } } else { DB::query("UPDATE item SET reply_count=reply_count-{$countChildDel} WHERE id={$itemId} LIMIT 1"); $itemReset = Item::get_item($itemId); $item_memcache = $itemReset; if ($itemReset) { $item_memcache['reply_count'] = $itemReset['reply_count'] - $countChildDel; if (SORL_FILTER_ON) { $solr = new Solr_Search(); $solr->doUpdateItem($itemId); } if (MEMCACHE_ON) { eb_memcache::do_put("item:{$itemId}", $item_memcache); } $caheFile = 'fb_' . $itemReset['id']; StaticCache::delCache($caheFile); $json['countCommentItem'] = $item_memcache['reply_count']; } } if ($comment['parent_id'] > 0) { $item_id = $comment['item_id']; if ($comment['parent_id'] > 0) { DB::query('UPDATE comment SET have_child = have_child-1 WHERE id=' . $comment['parent_id'] . ' '); if ($comment['display'] == 1) { DB::query('UPDATE comment SET display = 1 where item_id = ' . $comment['item_id'] . ' AND parent_id = ' . $comment['parent_id'] . ' AND display = 0 order by id DESC limit 1'); } } } /*Đếm lại commemnt*/ $json['msg'] = EClassApi::getParam('id'); exit(json_encode($json)); } else { $json['msg'] = "unsuccess"; exit(json_encode($json)); } } else { $json['msg'] = "not_perm"; exit(json_encode($json)); } } else { $json['msg'] = "not_perm"; exit(json_encode($json)); } }
function action_item_comment() { $act_ = Url::get('act_'); $comment_id = (int) Url::get('c_item_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('comment', "id={$comment_id}"); if (!$comment_row) { $json = '({"msg":"no_perm"})'; echo $json; exit; } //if($comment_row['sender_user_id'] == User::id() || ($act_=='reply' && $comment_row['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! if ($comment_row['sender_user_id'] == User::id()) { //Không được trả lời cho chính mình! $json = '({"msg":"success"})'; echo $json; exit; } $item_id = $comment_row['item_id']; $item = Item::get_item($item_id); $item_memcache = $item; if (!($item && $item['user_id'] == User::id())) { $json = '({"msg":"no_perm"})'; echo $json; exit; } if ($act_ == 'reply' && $item["state"] == 1 && !User::have_permit(ADMIN_ITEM)) { $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); if ($comment_row['parent_id']) { $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; } } else { $parent_id = $comment_row['id']; } $comment = array('content' => $content, 'item_id' => $item['id'], 'time' => time(), 'order_time' => time(), 'post_ip' => AZLib::ip(), 'parent_id' => $parent_id, 'receiver_user_id' => $item['user_id'], 'receiver_user_name' => $item['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('comment', $comment); if ($id) { $re = DB::query("SELECT id FROM 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 comment SET display = 0 WHERE parent_id = {$parent_id} AND display = 1 AND id<={$row['id']}"); } } } if ($comment_id == $parent_id) { DB::query("UPDATE comment SET status = 1, have_child = have_child + 1, order_time = " . time() . " WHERE id = {$comment_id}"); } else { DB::query("UPDATE comment SET have_child = have_child + 1, order_time = " . time() . " WHERE id = {$parent_id}"); DB::query("UPDATE comment SET status = 1 WHERE id = {$comment_id}"); } if ($comment_row['sender_user_id']) { DB::query('UPDATE user SET total_new_comment = total_new_comment + 1 WHERE id=' . $comment_row['sender_user_id']); User::getUser($comment_row['sender_user_id'], 0, 1); } //Cập nhật đã đọc - trả lời cho feed DB::query("UPDATE feed SET status = 1 WHERE ref_id = {$comment_id} AND type=1"); } $total_feedback = DB::count('comment', 'item_id="' . $item['id'] . '"'); DB::update_id('item', array('reply_count' => $total_feedback), $item['id']); if (MEMCACHE_ON) { $caheFile = 'fb_' . $item['id']; StaticCache::delCache($caheFile); $item_memcache['reply_count'] = $total_feedback; AZMemcache::do_put("item:{$item['id']}", $item_memcache); } //Cập nhật cron job //... } else { if ($comment_row['status'] == 0) { DB::query("UPDATE comment SET 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=1"); } DB::query('UPDATE user SET total_new_comment = total_new_comment - 1 WHERE id=' . User::id() . ' AND total_new_comment>0'); User::getUser(User::id(), 0, 1); $json .= "})"; echo $json; //exit; System::halt(); }
function fn_del_static_cache() { if (!User::is_login()) { echo "not_login"; exit; } if (!User::have_permit(ADMIN_ITEM)) { echo "no_perm"; exit; } $cache_file = Url::get('cache_file'); StaticCache::delCache($cache_file); echo 'success'; exit; }
<?php if (REWRITE_ON) { ob_start(); //start buffering//@ob_start('ob_gzhandler'); } require_once ROOT_PATH . 'core/AutoLoader.php'; 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) { EBArrCache::del_cache(); ECCache::auto_delete(); StaticCache::delCache(); EClass::del_page_cache(); exit; } if (isset($_GET['page']) && $_GET['page'] == 'error') { define('ERROR_PAGE', 1); } else { define('ERROR_PAGE', 0); } if (!EClassApi::is_search_engine() && !defined('NO_SESSION') && !ERROR_PAGE) { if (SESSION_TYPE == 'db') { require_once ROOT_PATH . 'includes/session.class.php'; //Session db store } elseif (SESSION_TYPE == 'memcache') { require_once ROOT_PATH . "includes/memcache.session.php"; //Session memcache store } else {
function del_comment() { if (!User::is_login() || User::is_block()) { echo "not_perm"; exit; } $id = (int) Url::get("id"); if ($id) { $comment = DB::fetch("SELECT item_id,sender_user_id,display,receiver_user_id,have_child,parent_id FROM comment WHERE id={$id}"); /*$current_user = User::$current->data; if($current_user['up_item'] == 0){ echo "not_up_item"; exit(); }*/ if (User::have_permit(ADMIN_ITEM) || User::id() == $comment['receiver_user_id'] && $comment['sender_user_id'] == 0) { if (DB::delete('comment', 'id=' . $id)) { if ($comment['have_child'] > 0) { DB::delete('comment', 'parent_id=' . $id); } if ($comment['item_id'] > 0) { $item_id = $comment['item_id']; if ($comment['parent_id'] > 0) { DB::query('UPDATE comment SET have_child = have_child-1 WHERE id=' . $comment['parent_id'] . ' '); if ($comment['display'] == 1) { DB::query('UPDATE comment SET display = 1 where item_id = ' . $comment['item_id'] . ' AND parent_id = ' . $comment['parent_id'] . ' AND display = 0 order by id DESC limit 1'); } } if ($item_id) { $item = Item::get_item($item_id); $item_memcache = $item; if ($item) { $item_memcache['reply_count'] = $item['reply_count'] - (1 + $comment['have_child']); if (MEMCACHE_ON) { AZMemcache::do_put("item:{$item_id}", $item_memcache); } DB::query('UPDATE item SET reply_count = ' . $item_memcache['reply_count'] . ' WHERE id="' . $comment['item_id'] . '" '); } } } //del cache html $caheFile = 'fb_' . $item['id']; StaticCache::delCache($caheFile); /*if(!User::have_permit(ADMIN_ITEM)){ DB::query('UPDATE user set up_item = up_item-1 WHERE id='.$comment['receiver_user_id'].' AND up_item>0');// tru luot up User::getUser($comment['receiver_user_id'],0,1); }*/ echo AZLib::getParam('id'); exit; } else { echo "unsuccess"; exit; } } else { echo "not_perm"; exit; } } else { echo "not_perm"; exit; } }