function change_status() { $id = intval(Url::get('id'), 0); $amount = intval(Url::get('amount'), 0); if ($amount == '' || $amount <= 0) { echo 'amount_null'; } else { $log = Logs::get_log($id); $str_change = array(); if (!empty($log)) { $str_change = unserialize($log['data']); } $value = array('status' => '00', 'amount' => $amount, 'description' => 'Giao dịch thành công.', 'pin' => $str_change['pin'], 'serial' => $str_change['serial'], 'type' => $str_change['type']); $value = serialize($value); $id = Logs::update_log($id, array('data' => $value)); if ($id) { $str_topup = array('uid' => $log['uid'], 'serial' => $str_change['serial'], 'pin' => $str_change['pin'], 'type' => $str_change['type'], 'created' => $log['origin_time'], 'price' => $amount); DB::insert('topup', $str_topup); $user = PersonalDB::get_account_byId($log['uid']); $new_coin = $user['coin'] + $amount; DB::update_id('account', array('coin' => $new_coin), $user['id']); } } exit; }
function on_submit() { $user_name = AZLib::getParam('user_name'); $content = AZLib::getParam('content'); $active = (int) Url::get('active'); $expire = (int) Url::get('expire', 7); $id = (int) Url::get('id'); $cmd = Url::get('cmd'); $sql = "SELECT id FROM user WHERE user_name='{$user_name}'"; $row = DB::fetch($sql); $user_id = (int) $row["id"]; if (!$user_id) { $this->setFormError('user_name', 'Không tồn tại thành viên này!'); } elseif (!$user_name || !$content) { $this->setFormError('content', 'Dữ liệu không hợp lệ!'); } else { if ($cmd == "add") { $item_array = array('content' => $content, 'user_name' => $user_name, 'user_id' => $user_id, 'admin_add' => User::user_name(), 'active' => $active, 'time_add' => TIME_NOW, 'expire_date' => TIME_NOW + 86400 * $expire); DB::insert('admin_notice_user', $item_array); } elseif ($cmd == "edit" && $id) { $item_array = array('content' => $content, 'user_name' => $user_name, 'user_id' => $user_id, 'admin_edit' => User::user_name(), 'active' => $active, 'time_edit' => TIME_NOW, 'expire_date' => TIME_NOW + 86400 * $expire); DB::update_id('admin_notice_user', $item_array, $id); } User::getAdminNoticeUser($user_id, 0, 1); Url::redirect_current(array('act')); } }
static function update_log($id, $data) { $data = self::render_before_save($data); DB::update_id(self::TBL_NAME, $data, $id); self::remove_cache($id); return $id; }
public static function paymentCallback1PaySMS() { $paymentConfig = CGlobal::$payment1pay; $access_key = $paymentConfig['access_key']; $secret = $paymentConfig['secret']; $arParams = array(); $arParams['access_key'] = $_REQUEST['access_key'] ? $_REQUEST['access_key'] : 'no_access_key'; $arParams['command'] = $_REQUEST['command'] ? $_REQUEST['command'] : 'no_command'; //ma tin: CuPhap $arParams['mo_message'] = $_REQUEST['mo_message'] ? $_REQUEST['mo_message'] : 'no_mo_message'; //noi dung tin nhan $arrSMS = split(" ", $arParams['mo_message']); $arParams['msisdn'] = $_REQUEST['msisdn'] ? $_REQUEST['msisdn'] : 'no_msisdn'; //so dien thoai $arParams['request_id'] = $_REQUEST['request_id'] ? $_REQUEST['request_id'] : 'no_request_id'; //id tin nhan $arParams['request_time'] = $_REQUEST['request_time'] ? $_REQUEST['request_time'] : 'no_request_time'; //thoi gian smsc nhan dc tin nhan $arParams['short_code'] = $_REQUEST['short_code'] ? $_REQUEST['short_code'] : 'no_short_code'; //8538 với 8738 $arParams['signature'] = $_REQUEST['signature'] ? $_REQUEST['signature'] : 'no_signature'; $data = "access_key=" . $arParams['access_key'] . "&command=" . $arParams['command'] . "&mo_message=" . $arParams['mo_message'] . "&msisdn=" . $arParams['msisdn'] . "&request_id=" . $arParams['request_id'] . "&request_time=" . $arParams['request_time'] . "&short_code=" . $arParams['short_code']; $signature = hash_hmac("sha256", $data, $secret); // sinh ra signature de so sanh $arrResult['status'] = 0; //cong tien, 0= chua cong tien $arrResult['type'] = 'text'; //echo $arrResult; // kiem tra signature neu can if ($arParams['signature'] == $signature && sizeof($arrSMS) == 2) { //add tien o day $arParams['amount'] = 15000; $userId = $arrSMS[1]; //NTP userId $user = User::getUserById($userId); if (!$user) { $arrResult['sms'] = 'Khong tim thay nguoi dung'; return json_encode($arrResult); } $package = $arParams['amount']; $totalCoin = $package[0]; $log = array('type_id' => -1, 'object_id' => 0, 'time' => time(), 'data' => serailize($arParams), 'uid' => $userId); DB::insert('logs', $log); DB::update_id('account', array('coin' => $user['coin'] + $arParams['amount']), $userId); //PaymentLog::sendLog1Pay($arParams); $arrResult['status'] = 1; $arrResult['sms'] = 'Nạp tiền thành công ' . $arParams['amount'] . 'coin cho tài khoản ' . $user['user_name']; } else { //loi gi do $arrResult['sms'] = 'Sai chu ky'; } //end of write payment log return json_encode($arrResult); }
function on_submit() { $class_ids = Url::get('class_ids'); $class_ids = implode(',', $class_ids); $list_class = Classes::get_collection(null, ' id IN (' . $class_ids . ') '); $total = 0; foreach ($list_class as $c) { $total = $total + $c['price']; } $user = PersonalDB::get_account_information(); if ($user['coin'] >= $total) { foreach ($list_class as $class) { if ($class['price'] > 0) { $paid = DB::select('student_paid', ' uid =' . User::id() . ' AND cid=' . $class['id']); if (!$paid) { if (intval(date('d')) < 5) { $month = date('n'); } else { $month = date('n', strtotime('+1 month')); } $data = array('uid' => User::id(), 'price' => $class['price'], 'cid' => $class['id'], 'time' => time(), 'month' => $month); DB::insert('student_paid', $data); } else { if (intval(date('d')) < 5) { $month = date('n'); } else { $month = date('n', strtotime('+1 month')); } $data = array('price' => $class['price'], 'time' => time(), 'month' => $month); DB::update_id('student_paid', $data, $paid['id']); } } } $coin = $user['coin'] - $total; $new_coin = array('coin' => $coin); PersonalDB::update_account_information($new_coin); $this->setSuccessMessage('personal/extra_time', 'Gia hạn thành công, chúc bạn học tập tốt!'); //Url::redirect_url('personal.html?cmd=extra_time'); } else { $this->setErrorMessage('personal/extra_time', "Số tiền trong tài khoản của bạn không đủ để gia hạn, xin vui lòng nạp thêm!"); Url::redirect_url('personal.html?cmd=extra_time'); exit; } Url::redirect_url('personal.html?cmd=extra_time'); }
function on_submit() { $title = AZLib::getParam('title'); $sapo = AZLib::getParam('sapo'); $link = AZLib::getParam('link', ''); $active = (int) Url::get('active'); $id = (int) Url::get('id'); $cmd = Url::get('cmd'); if (!$title || !$sapo) { $this->setFormError('title', 'Dữ liệu không hợp lệ!'); } else { if ($cmd == "add") { $item_array = array('title' => $title, 'sapo' => $sapo, 'link' => $link, 'admin_add' => User::user_name(), 'active' => $active, 'time_add' => TIME_NOW); DB::insert('admin_notice', $item_array); } elseif ($cmd == "edit" && $id) { $item_array = array('title' => $title, 'sapo' => $sapo, 'link' => $link, 'admin_edit' => User::user_name(), 'active' => $active, 'time_edit' => TIME_NOW); DB::update_id('admin_notice', $item_array, $id); } User::getAdminNotice(0, 1); Url::redirect_current(); } }
function on_submit() { $name = Url::get('name'); $brief_name = Url::get('brief_name'); $status = Url::get('status', "HIDE"); $area = (int) Url::get('area'); $position = (int) Url::get('position', 0); $this->checkFormInput('Tên đối tác', 'name', $name, 'str', true, '', 2, 75); $this->checkFormInput('Vị trí', 'position', $position, 'int', true, '', 1); if ($brief_name == '') { $brief_name = $name; } if (!$this->errNum) { $new_row = array('name' => $name, 'brief_name' => $brief_name, 'position' => $position, 'status' => $status, 'area' => $area); if (Url::get('cmd') == 'edit') { DB::update_id('province', $new_row, $this->province['id']); } else { DB::insert('province', $new_row); } AZLib::getProvinces(1, true); Url::redirect_current(); } }
function feedback() { header("Content-type: application/xml"); $pattern = '/^xe360/i'; $content = trim(EClassApi::getParam('content')); $comment_id = (int) Url::get('comment_id', 0); $sender_user_name = trim(EClassApi::getParam('user_name')); $sender_email = trim(EClassApi::getParam('sender_email')); $subItemId = (int) Url::get('sub_item_id', 0); $comment_row = array(); // if(isset($_COOKIE['setTimeOutComment'])){ // if(time()-$_COOKIE['setTimeOutComment']<=30){// 30 giay // echo "<comments><content>time_out</content></comments>"; // exit(); // } // } // else{ // EClassApi::my_setcookie("setTimeOutComment", time(), 30 + TIME_NOW); // 30 giay // } if (preg_match($pattern, $sender_user_name) || preg_match($pattern, $sender_email) || preg_match($pattern, $content)) { echo "<comments><content>bad_word</content></comments>"; exit; } if (User::is_login() && User::is_block()) { echo "<comments><content>no_perm</content></comments>"; exit; } if ($comment_id) { $comment_row = DB::select('comment', "id={$comment_id}"); if (!$comment_row) { echo "<comments><content>no_perm</content></comments>"; exit; } if (User::is_login() && $comment_row['sender_user_id'] == User::id()) { //Không được trả lời cho chính mình! echo "<comments><content>no_perm</content></comments>"; exit; } if (!($item = Item::get_item($comment_row['item_id']))) { echo "<comments><content>no_perm</content></comments>"; exit; } } else { $item_id = (int) Url::get('item_id', 0); if (!$item_id || !($item = Item::get_item($item_id))) { echo "<comments><content>no_perm</content></comments>"; exit; } } $item_memcache = $item; if (EClassApi::isBlackList(User::id(), $item['user_id'])) { echo "<comments><content>blacklist</content></comments>"; exit; } if (!User::is_login() && EClassApi::checkBadWord($sender_user_name)) { echo "<comments><content>bad_word</content></comments>"; exit; } if ($item["state"] == 1 && !User::have_permit(ADMIN_ITEM)) { echo "<comments><content>no_perm</content></comments>"; exit; } $username = strtolower($sender_user_name); if (!User::is_login() && (strlen($username) < 3 || strlen($sender_email) < 3 || $username == 'admin' || $username == 'administrator' || $username == 'moderator' || $username == 'enbac')) { echo "<comments><content>bad_word</content></comments>"; exit; } if (EClassApi::checkBadWord($content)) { echo "<comments><content>bad_word</content></comments>"; exit; } /*if(!User::is_login()){ $captcha = EClassApi::getParam('captcha'); if(!isset($_SESSION["enbac_validate"]) || $captcha=='' || $captcha != $_SESSION["enbac_validate"]){ echo "<comments><content>false_captcha</content></comments>"; exit(); } }*/ $content = preg_replace("/\n/", "<br />", $content); $content = str_replace('<br /><br />', ' ', $content); $receiver_user_id = 0; $receiver_username = ''; if ($comment_id) { if ($comment_row['parent_id']) { $receiver_user_id = $comment_row['sender_user_id']; $receiver_username = $comment_row['sender_user_name']; if ($receiver_user_id) { $content = '@<a href="' . WEB_DIR . $receiver_username . '" class="fast_reply_link" title="' . $receiver_username . '">' . $receiver_username . '</a>: ' . $content; } else { $content = '<font color="#999">@<span style="text-decoration:underline">' . $receiver_username . '</span> </font>: ' . $content; } $parent_id = $comment_row['parent_id']; } else { $parent_id = $comment_row['id']; } } else { $parent_id = 0; } $user_item = User::getUser($item['user_id']); if ($user_item) { $user_type = 0; if (User::is_login()) { $sender_user_name = User::user_name(); $user_id = User::id(); $user_send = User::getUser($user_id); if (!$user_send['avatar_url']) { /*gen 1 cai avatar cho nguoiwf dungf nayf*/ // EClassApi::genAvatar('40',md5($sender_user_name)); } /* #note-comment 11.02 by ngannv Nên bỏ cái query này đi rà xoát lại cơ chế liên quan đến trường user_type trong bảng comment */ $sql = "SELECT sms_total FROM sms_user_active WHERE user_id = {$user_id}"; $user_active = DB::fetch($sql); if ($user_active) { $sms_total = $user_active['sms_total']; if ($sms_total >= 3) { $user_type = 2; } else { $user_type = 1; } } else { $user_type = 1; } } else { // set guest cookie $week = 60 * 60 * 24 * 365 + TIME_NOW; EClassApi::my_setcookie("guest_name", $sender_user_name, $week); EClassApi::my_setcookie("guest_email", $sender_email, $week); /*Tạo một avatar cho khách*/ //EClassApi::genAvatar('40',md5($sender_user_name)); } $up_up_count = ''; if ($content != '') { $comment = array('content' => $content, 'item_id' => $item['id'], 'time' => TIME_NOW, 'order_time' => TIME_NOW, 'post_ip' => EClassApi::ip(), 'parent_id' => $parent_id, 'receiver_user_id' => $item['user_id'], 'receiver_user_name' => $item['user_name'], 'display' => 1, 'sub_item_id' => $subItemId, 'user_type' => $user_type); if (User::id()) { if ($item['user_id'] == User::id()) { //Chuyển trạng thái đã trả lời khi comment chính topic của mình! $comment['status'] = 1; } $comment['sender_user_id'] = User::id(); $comment['sender_user_name'] = User::user_name(); } else { $comment['sender_user_id'] = 0; $comment['sender_user_name'] = $sender_user_name; $comment['sender_email'] = $sender_email; } if ($comment_row && $comment_row['sender_user_id'] && $comment_row['sender_user_id'] != $item['user_id']) { $comment['replied_user_id'] = $comment_row['sender_user_id']; $comment['replied_user_name'] = $comment_row['sender_user_name']; } elseif ($comment_row && $comment_row['sender_user_id'] == $item['user_id']) { $comment['replied_status'] = 1; } $id = DB::insert('comment', $comment); if ($id) { /* if(!User::id()){ EClassApi::reload_captcha(); }*/ /*Cập nhật tăng thêm số lượt comment trong bảng item_sub*/ if ($subItemId > 0) { $updItemSubTbl = "UPDATE item_sub SET comment_count=comment_count+1 WHERE id={$subItemId} LIMIT 1"; DB::query($updItemSubTbl); } if ($parent_id) { $re = DB::query("SELECT id FROM comment WHERE item_id = {$item['id']} AND 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) { if (User::is_login() && $item['user_id'] == User::id()) { DB::query("UPDATE comment SET have_child = have_child + 1, order_time = " . time() . ", status=1 WHERE id = {$parent_id}"); } else { DB::query("UPDATE comment SET have_child = have_child + 1, order_time = " . time() . " WHERE id = {$parent_id}"); } } else { DB::query("UPDATE comment SET have_child = have_child + 1, order_time = " . time() . " WHERE id = {$parent_id}"); if (User::is_login() && $item['user_id'] == User::id()) { 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"); } } if (User::is_login()) { //Nếu là thành viên //Cập nhật lại replied_status nếu chưa được check! if ($item['user_id'] != User::id() && $comment_row['replied_user_id'] == User::id() && $comment_row['replied_status'] == 0) { DB::query("UPDATE 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=2"); //Cập nhật comment mới cho chính mình DB::query('UPDATE account SET total_new_comment = total_new_comment - 1 WHERE id=' . User::id() . ' AND total_new_comment>0'); User::getUser(User::id(), 0, 1); } if ($item['user_id'] != User::id()) { //Nếu ko fải giao dịch của mình //Cập nhật comment mới cho chủ topic DB::query('UPDATE account SET total_new_comment = total_new_comment + 1 WHERE id=' . $item['user_id']); User::getUser($item['user_id'], 0, 1); } elseif ($comment_row && $comment_row['status'] == 0) { //Cập nhật comment mới cho chính mình DB::query('UPDATE account SET total_new_comment = total_new_comment - 1 WHERE id=' . User::id() . ' AND total_new_comment>0'); User::getUser(User::id(), 0, 1); } //Cập nhật comment mới cho người có comment được trả lời if ($comment_row['sender_user_id'] && $comment_row['sender_user_id'] != $item['user_id'] && $comment_row['sender_user_id'] != User::id() && $comment_row['sender_user_id'] != $item['user_id']) { //Nếu trả lời comment cho 1 người nào đó ko fải chủ topic DB::query('UPDATE account SET total_new_comment = total_new_comment + 1 WHERE id=' . $comment_row['sender_user_id']); User::getUser($comment_row['sender_user_id'], 0, 1); } } else { //Nếu là khách vãng lai //Cập nhật comment mới cho chủ topic DB::query('UPDATE account SET total_new_comment = total_new_comment + 1 WHERE id=' . $item['user_id']); User::getUser($item['user_id'], 0, 1); //Cập nhật comment mới cho người có comment được trả lời if ($comment_row['sender_user_id'] && $comment_row['sender_user_id'] != $item['user_id'] && $comment_row['sender_user_id'] != $item['user_id']) { //Nếu trả lời comment cho 1 người nào đó ko fải chủ topic DB::query('UPDATE account SET total_new_comment = total_new_comment + 1 WHERE id=' . $comment_row['sender_user_id']); User::getUser($comment_row['sender_user_id'], 0, 1); } } } EClassApi::update_cache_comment($item['id']); } $total_feedback = DB::count('comment', "item_id={$item['id']} AND sub_item_id=0"); /*vãi #note-comment 01 by ngannv*/ $up_up_count = '<up_count>'; $up_up_count .= $user_item['up_item']; if (!$subItemId) { DB::update_id('item', array('reply_count' => $total_feedback), $item['id']); } if (MEMCACHE_ON) { $item_memcache['reply_count'] = $total_feedback; eb_memcache::do_put("item:{$item['id']}", $item_memcache); } $up_up_count .= '</up_count>'; //Cập nhật cron job if ($user_item && $user_item['email'] && $user_item['email_alert'] && $user_item['id'] != User::id()) { if (User::id()) { $sender_email = ''; } $link = WEB_ROOT . ECRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . EClassApi::safe_title($item['name'])); $title = "<a href='{$link}' target='_blank' style='text-decoration:none;color:#003399;'><font color='#003399'>{$item['name']}</font></a>"; EClassApi::addCronJob('item_comment', EClassApi::parseBBCode($content, true), $user_item['id'], User::id() ? User::user_name() : $sender_user_name, $sender_email, $item['id'], $title, $link); } } else { $id = 0; } $time = date('H:i - d/m'); $xml = "<comments><content><![CDATA[" . EClassApi::parseBBCode($content) . "]]></content><post_time>" . date('H:i') . "</post_time>"; /* * longnt * thêm trả lại id comment mới insert */ $xml .= "<insert_id>{$id}</insert_id>"; $action = 'item_comment'; if (User::id() != $item['user_id']) { require_once ROOT_PATH . 'includes/enbac/comment.php'; Comment::addNewComment($item['user_id']); } $xml .= $up_up_count . "<id>" . $id % 3 . "</id></comments>"; //del cache html if ($subItemId) { $caheFile = 'fb_' . $subItemId; if (MEMCACHE_ON) { eb_memcache::do_put('update_comment_sub_' . $item['id'] . '_' . $subItemId, 1); /*ngannv #update_comment_sub tìm thêm trong ajax_item_detai.ajax*/ } } else { $caheFile = 'fb_' . $item['id']; } StaticCache::delCache($caheFile); echo $xml; System::halt(); } }
function action_reply_item_comment() { $act_ = Url::get('act_'); $comment_id = (int) Url::get('re_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 || $comment_row && $comment_row['replied_user_id'] != User::id()) { $json = '({"msg":"no_perm"})'; echo $json; exit; } //if($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! if ($comment_row['receiver_user_id'] == User::id() || $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 && $item == -1) { $json = '({"msg":"no_perm"})'; echo $json; exit; } if ($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' => 0); $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']; } if ($comment_row['sender_user_id'] == $item['user_id']) { $comment['replied_status'] = 1; } $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 replied_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 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=2"); DB::query('UPDATE user SET total_new_comment = total_new_comment + 1 WHERE id=' . $item['user_id']); User::getUser($item['user_id'], 0, 1); if ($comment_row['sender_user_id'] && $comment_row['sender_user_id'] != $item['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); } } $total_feedback = DB::count('comment', 'item_id="' . $item['id'] . '"'); DB::update_id('item', array('reply_count' => $total_feedback), $item['id']); if (MEMCACHE_ON) { $item_memcache['reply_count'] = $total_feedback; AZMemcache::do_put("item:{$item['id']}", $item_memcache); } $receiver_user = User::getUser($item['user_id'], 1); //Cập nhật cron job if ($receiver_user && $receiver_user['email'] && $receiver_user['email_alert']) { $link = WEB_ROOT . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . AZLib::safe_title($item['name'])); $link = AZRewrite::formatUrl($link); $title = "<a href='{$link}' target='_blank' style='text-decoration:none;color:#003399;'><font color='#003399'>{$item['name']}</font></a>"; AZLib::addCronJob('item_comment', AZLib::parseBBCode($content, true), $receiver_user['id'], User::user_name(), '', $item['id'], $title, $link); } } else { if ($comment_row['replied_status'] == 0) { DB::query("UPDATE 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=2"); } 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; }
function update_note() { if (!User::have_permit('user_note')) { echo 'Bạn không có quyền cập nhật ghi chú của khách hàng'; exit; } $id = trim($_POST['id']); $note = trim($_POST['note']); $update_row = array('note' => $note); DB::update_id('account', $update_row, $id); echo 'Cập nhật ghi chú của khách hàng thành công'; exit; }
function on_submit() { $phone = EClassApi::getParam('register_user_tel'); $user = array(); //Check password if ($phone != '') { function check_mobile_number($mobile) { return preg_match('/[0-9]/', $mobile) && (strpos($mobile, "09") === 0 && strlen($mobile) == 10 || strpos($mobile, "01") === 0 && strlen($mobile) == 11); } if (preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\\.[A-Z]{2,6}\$/i", $phone)) { $res = DB::query("SELECT * FROM account WHERE email = '{$phone}' LIMIT 1"); $user = mysql_fetch_assoc($res); mysql_free_result($res); if (!$user) { $this->setFormError('register_user_tel', 'Email chưa được đăng ký. Mời bạn <a href="register.html"><b>đăng ký tại đây</b></a>!!!'); return false; } } elseif (preg_match('/[^A-Za-z0-9_]/', $phone)) { $this->setFormError('register_user_tel', '<b>Số di động</b> sai định dạng!!!'); return false; } if (!$user) { $res = DB::query("SELECT * FROM account WHERE user_name = '{$phone}' LIMIT 1"); $user = mysql_fetch_assoc($res); mysql_free_result($res); if (!$user) { if (check_mobile_number($phone)) { $this->setFormError('register_user_tel', 'Số di động chưa được đăng ký. Mời bạn <a href="register.html"><b>đăng ký tại đây</b></a>!!!'); return false; } else { $this->setFormError('register_user_tel', '<b>Số di động</b> sai định dạng!!!'); return false; } } } // $captcha_register = Url::get('recaptcha_response_field'); // // if ($captcha_register=='') // { // $this->setFormError('captcha_register',"Bạn chưa nhập <b>Mã số bảo mật</b>!"); // } // else // { // $resp = recaptcha_check_answer (CGlobal::$captcha_privatekey, // $_SERVER["REMOTE_ADDR"], // Url::get('recaptcha_challenge_field'), // Url::get('recaptcha_response_field') // ); // // if (!$resp->is_valid) // { // $this->setFormError('captcha_register',"<b>Mã bảo mật</b> không chính xác!"); // } // } } else { $this->setFormError('register_user_tel', 'Bạn chưa nhập <b>Số di động</b> hoặc <b>Email</b>!'); } if (!$this->errNum) { $password = EClassApi::generateCode(6); $new_password = User::eat_encode_password($password, SALTAUTH); $success = 1; /*Tracking reset password - Tuvv 26.03.2013*/ if (!empty($user)) { if ($val = DB::select('account_reset_pass', 'user_id=' . $user['id'])) { DB::update_id('account_reset_pass', array('user_id' => $user['id'], 'new_pass' => $new_password, 'ip' => EClassApi::ip(), 'time' => TIME_NOW), $val['id']); } else { DB::insert('account_reset_pass', array('user_id' => $user['id'], 'new_pass' => $new_password, 'ip' => EClassApi::ip(), 'time' => TIME_NOW)); } } if (check_mobile_number($user['user_name'])) { //Send sms password $sms = "<mClass.vn> Mat khau moi cua ban la: {$password}, vui long dang nhap trong vong 24h."; //$sms = str_replace('#PASSWORD#', $password, 'This is your new password: #PASSWORD#'); $smsId = uniqid(); //$sms = functionHelper::addPrefixSms($fMobile, $sms); $code = EClassApi::sendSMS($sms, $user['user_name'], $smsId); if (trim($user['full_name']) == '') { $user['full_name'] = $user['email']; } else { $user['full_name'] = "{$user['full_name']} ({$user['user_name']})"; } $content_email = "Chào {$user['full_name']},<br/><br/>Một yêu cầu khôi phục mật khẩu đã được gởi đến http://suma.vn, mật khẩu mới đã được gửi tới số di động của bạn: <b>{$user['user_name']}</b>\n <br /><br />Hãy sử dụng mật khẩu đó để Đăng nhập SuMa.vn tại: <a href='http://suma.vn/signin.html'>http://suma.vn/signin.html</a> trong vòng 24h.\n <br /><br />Xin hãy thay đổi mật khẩu đó khi bạn đăng nhập!<br /><br /><b>Vui lòng không trả lời Email này!</b>\n <br /><br /><br />Cảm ơn bạn,<br /><br /><b>Đối với bất kỳ câu hỏi, xin vui lòng liên hệ với chúng tôi tại support@suma.vn hoặc 08 73.013.939.</b>"; //Send email here; //if(System::send_mail($user['email'],'<SUMA.VN> Khôi phục mật khẩu!',$content_email, 'SuMa.vn')) //{ $this->setFormSucces('', '<b>Khôi phục mật khẩu thành công!</b><br /><br />Mật khẩu mới đã được gửi tới số di động: ' . $user['user_name'] . '<br />Vui lòng đăng nhập trong vòng 24h.'); //} } else { if (trim($user['full_name']) == '') { $user['full_name'] = $user['user_name']; } else { $user['full_name'] = "{$user['full_name']} ({$user['user_name']})"; } // $content_email = "Chào {$user['full_name']},<br/><br/>Một yêu cầu khôi phục mật khẩu đã được gởi đến http://suma.vn, mật khẩu mới đã được gửi tới số di động của bạn: <b>{$user['user_name']}</b> // <br /><br />Hãy sử dụng mật khẩu đó để Đăng nhập SuMa.vn tại: <a href='http://suma.vn/signin.html'>http://suma.vn/signin.html</a> trong vòng 24h. // <br /><br />Xin hãy thay đổi mật khẩu đó khi bạn đăng nhập!<br /><br /><b>Vui lòng không trả lời Email này!</b> // <br /><br /><br />Cảm ơn bạn,<br /><br /><b>Đối với bất kỳ câu hỏi, xin vui lòng liên hệ với chúng tôi tại support@suma.vn hoặc 08 73.013.939.</b>"; // // //Send email here; // if(System::send_mail($user['email'],'<SUMA.VN> Khôi phục mật khẩu!',$content_email, 'SuMa.vn')) // { // $this->setFormSucces('','<b>Khôi phục mật khẩu thành công!</b><br /><br />Mật khẩu mới đã được gửi tới email: '. $user['email'].'<br />Vui lòng đăng nhập trong vòng 24h.'); // } // else // { // $success = 0; // } $this->setFormSucces('', '<b>Khôi phục mật khẩu thành công!</b><br /><br />Mật khẩu mới đã được gửi tới email: ' . $user['email'] . '<br />Vui lòng đăng nhập trong vòng 24h.'); } if ($success) { DB::update('account', array('changed_pass' => 0, 'reset_pass' => 1), 'id=' . $user['id']); // DB::update('account', array('password' => $new_password), 'id=' . $user['id']); $_SESSION['reseted_pass'] = true; } } }
function del_user_same() { if (!User::have_permit(ADMIN_ITEM)) { echo "no_perm"; exit; } $user_id = (int) Url::get('user_id', 0); if ($user_id) { $str_value = ""; $arr_user = DB::fetch("SELECT group_same_id FROM user_same WHERE user_id = {$user_id}"); DB::query("DELETE FROM user_same WHERE user_id = {$user_id}"); $arr_group = DB::fetch("SELECT user_ids FROM user_same_group WHERE id = " . $arr_user["group_same_id"]); $arr_user_ids = explode(",", $arr_group["user_ids"]); foreach ($arr_user_ids as $user_ids) { if ($user_ids != $user_id) { $str_value .= ($str_value ? "," : "") . $user_ids; } if ($str_value) { $data_info = array('date_modify' => TIME_NOW, 'admin_modify' => User::user_name(), 'user_ids' => $str_value); DB::update_id('user_same_group', $data_info, $arr_user["group_same_id"]); } } echo $user_id; exit; } else { echo "unsuccess"; exit; } }
function remove_favourite() { $json = array(); if (!User::is_login()) { $json['msg'] = 'no_login'; die(json_encode($json)); } $uid = User::id(); $fid = EClassApi::getParam('fid'); DB::delete('account_food_favourites', 'uid=' . $uid . ' AND fid=' . $fid); // get count like of food $sql = 'SELECT count_like, rid FROM food_res WHERE id = ' . $fid . ' ORDER BY id DESC LIMIT 0, 1'; $result = DB::query($sql); $row = mysql_fetch_assoc($result); mysql_free_result($result); $count_like = intval($row['count_like']) - 1; $update_row = array('count_like' => $count_like); DB::update_id('food_res', $update_row, $fid); if (MEMCACHE_ON) { eb_memcache::do_remove('list_favourites_' . $uid); eb_memcache::do_remove('supplier_food_' . $row['rid']); eb_memcache::do_remove('supplier_spec_food_' . $row['rid']); } $json['fid'] = $fid; $json['msg'] = 'success'; die(json_encode($json)); }
function fn_comment() { header("Content-type: application/xml"); $content = trim(AZLib::getParam('content')); $comment_id = (int) Url::get('comment_id', 0); $comment_row = array(); if ($content == '') { echo "<comments><content>no_perm</content></comments>"; exit; } if (User::is_login()) { if (User::is_block()) { echo "<comments><content>no_perm</content></comments>"; exit; } $sender_user_name = User::user_name(); $sender_email = ''; } else { $sender_user_name = AZLib::getParam('user_name'); $sender_email = AZLib::getParam('sender_email', ''); $username_lower = strtolower($sender_user_name); if (strlen($username_lower) < 3 || $username_lower == 'admin' || $username_lower == 'administrator' || $username_lower == 'moderator' || $username_lower == 'enbac') { echo "<comments><content>bad_word</content></comments>"; exit; } } if ($comment_id) { $comment_row = DB::select("user_entry_comment", "id={$comment_id}"); if (!$comment_row || $comment_row && User::is_login() && $comment_row['sender_user_id'] == User::id()) { //Không được trả lời cho chính mình! echo "<comments><content>no_perm</content></comments>"; exit; } $entry_id = $comment_row['entry_id']; } else { $entry_id = (int) Url::get('entry_id', 0); } if (!$entry_id || !($user_entry = DB::select('user_entry', "id={$entry_id}"))) { echo "<comments><content>no_perm</content></comments>"; exit; } if (User::is_login() && AZLib::isBlackList(User::id(), $user_entry['user_id'])) { echo "<comments><content>blacklist</content></comments>"; exit; } if (!User::is_login() && AZLib::checkBadWord($sender_user_name) || AZLib::checkBadWord($content)) { echo "<comments><content>bad_word</content></comments>"; exit; } if (AZLib::checkBadWord($content)) { echo "<comments><content>bad_word</content></comments>"; exit; } if (!User::is_login()) { $captcha = AZLib::getParam('captcha'); if (!isset($_SESSION["enbac_validate"]) || $captcha == '' || $captcha != $_SESSION["enbac_validate"]) { echo "<comments><content>false_captcha</content></comments>"; exit; } } $content = preg_replace("/\n/", "<br />", $content); $content = str_replace('<br /><br />', ' ', $content); if ($comment_row) { if ($comment_row['parent_id']) { $parent_id = $comment_row['parent_id']; //$sender_user_name = $comment_row['sender_user_name']; $sender_user_name = User::user_name(); if ($comment_row['sender_user_id']) { $content = '@<a href="' . WEB_DIR . $comment_row['sender_user_name'] . '" class="fast_reply_link" title="' . $sender_user_name . '">' . $comment_row['sender_user_name'] . '</a>: ' . $content; } else { $content = '<font color="#999">@<span style="text-decoration:underline">' . $sender_user_name . '</span> </font>: ' . $content; } } else { $parent_id = $comment_row['id']; } } else { $parent_id = 0; } // set guest cookie if (!User::id()) { $week = 60 * 60 * 24 * 365 + TIME_NOW; AZLib::my_setcookie("guest_name", $sender_user_name, $week); AZLib::my_setcookie("guest_email", $sender_email, $week); } $user_entry_comment = array('content' => $content, 'entry_id' => $user_entry['id'], 'time' => TIME_NOW, 'order_time' => TIME_NOW, 'post_ip' => AZLib::ip(), 'parent_id' => $parent_id, 'receiver_user_id' => $user_entry['user_id'], 'display' => 1, 'receiver_user_name' => $user_entry['user_name']); if (User::id()) { $user_entry_comment['sender_user_id'] = User::id(); } else { $user_entry_comment['sender_user_id'] = 0; $user_entry_comment['sender_email'] = $sender_email; } $user_entry_comment['sender_user_name'] = $sender_user_name; if ($comment_row && $comment_row['sender_user_id'] && $comment_row['sender_user_id'] != $user_entry['user_id']) { //Lưu lại người được trả lời $user_entry_comment['replied_user_id'] = $comment_row['sender_user_id']; $user_entry_comment['replied_user_name'] = $comment_row['sender_user_name']; } elseif ($comment_row && $comment_row['sender_user_id'] == $user_entry['user_id']) { $user_entry_comment['replied_status'] = 1; } $id = DB::insert('user_entry_comment', $user_entry_comment); if ($id) { if (!User::id()) { AZLib::reload_captcha(); } if ($parent_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 = {$comment_id} AND display = 1 AND id<={$row['id']}"); } } } if ($comment_id == $parent_id) { if (User::is_login() && $user_entry['user_id'] == User::id()) { DB::query("UPDATE user_entry_comment SET have_child = have_child + 1, order_time = " . time() . ", status=1 WHERE id = {$parent_id}"); } else { DB::query("UPDATE user_entry_comment SET have_child = have_child + 1, order_time = " . time() . " WHERE id = {$parent_id}"); } } else { DB::query("UPDATE user_entry_comment SET have_child = have_child + 1, order_time = " . time() . " WHERE id = {$parent_id}"); if (User::is_login() && $user_entry['user_id'] == User::id()) { DB::query("UPDATE user_entry_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=5"); //Cập nhật lại replied_status nếu chưa được check! if (User::is_login() && $comment_row['replied_user_id'] == User::id() && $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"); } } } $total_feedback = DB::count('user_entry_comment', 'entry_id="' . $user_entry['id'] . '"'); DB::update_id('user_entry', array('reply_count' => $total_feedback), $user_entry['id']); $xml = "<comments><content><![CDATA[" . AZLib::parseBBCode($content) . "]]></content><post_time>vài giây trước</post_time>"; $xml .= "<id>" . $id % 3 . "</id><parent_id>{$parent_id}</parent_id></comments>"; echo $xml; $user_item = User::getUser($user_entry['user_id']); if ($user_item && $user_item['email'] && $user_item['email_alert'] && $user_item['id'] != User::id()) { if (User::id()) { $sender_email = ''; } $link = WEB_ROOT . '?page=user_entry&user_name=' . $user_entry['user_name'] . '&cmd_entry=view&entry_id=' . $user_entry['id'] . '&ebname=' . AZLib::safe_title($user_entry['title']); $link = AZRewrite::formatUrl($link); $title = "<a href='{$link}' target='_blank' style='text-decoration:none;color:#003399;'><font color='#003399'>{$user_entry['title']}</font></a>"; AZLib::addCronJob('entry_comment', AZLib::parseBBCode($content, true), $user_item['id'], User::id() ? User::user_name() : $sender_user_name, $sender_email, $user_entry['id'], $title, $link); } System::halt(); }
function edit_address() { if (!User::is_admin() && !User::have_permit('change_address')) { echo 'no_perm'; exit; } $uid = EClassApi::trimSpace($_POST['id']); if (isset($_POST['delete'])) { if (!empty($uid) && DB::delete_id('delivery_address', $uid)) { echo 'success'; } else { echo 'error'; } exit; } $did = EClassApi::trimSpace($_POST['district']); $tel = EClassApi::trimSpace($_POST['tel']); $full_name = $_POST['full_name']; $address = $_POST['address']; $note = $_POST['note']; $edit = $_POST['edit']; $edit_id = $_POST['edit_id']; $new_row = array('did' => $did, 'tel' => $tel, 'full_name' => $full_name, 'address' => $address, 'note' => $note, 'uid' => $uid); if ((int) $edit == 1) { if (!empty($uid) && !empty($did) && DB::update_id('delivery_address', $new_row, $edit_id)) { echo 'success'; } else { echo 'error'; } } else { if (!empty($uid) && !empty($did) && DB::insert('delivery_address', $new_row)) { echo 'success'; } else { echo 'error'; } } }