private function _pmSend($res, $data) { global $_G; $touid = (int) $data['toUid']; $pmid = (int) $data['pmid']; $_GET['topmuid'] = $touid; $_POST['message'] = $this->_transMessage($data['msg']); $_POST['subject'] = ''; $users = array(); $type = 0; $waittime = interval_check('post'); if ($waittime > 0) { // showmessage('message_can_not_send_2', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'message_can_not_send_2')); } if (($checkMessage = mobcent_cknewuser()) != '') { return $this->makeErrorInfo($res, WebUtils::emptyHtml($checkMessage)); } if (!checkperm('allowsendpm')) { // showmessage('no_privilege_sendpm', '', array(), array('return' => true)); return $this->makeErrorInfo($res, 'no_privilege_sendpm'); } if ($touid) { if (isblacklist($touid)) { // showmessage('is_blacklist', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'is_blacklist')); } } // !($_G['group']['exempt'] & 1) && checklowerlimit('sendpm', 0, $coef); $message = (!empty($_POST['messageappend']) ? $_POST['messageappend'] . "\n" : '') . trim($_POST['message']); if (empty($message)) { // showmessage('unable_to_send_air_news', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'unable_to_send_air_news')); } // $message = censor($message); loadcache(array('smilies', 'smileytypes')); foreach ($_G['cache']['smilies']['replacearray'] as $key => $smiley) { $_G['cache']['smilies']['replacearray'][$key] = '[img]' . $_G['siteurl'] . 'static/image/smiley/' . $_G['cache']['smileytypes'][$_G['cache']['smilies']['typearray'][$key]]['directory'] . '/' . $smiley . '[/img]'; } $message = preg_replace($_G['cache']['smilies']['searcharray'], $_G['cache']['smilies']['replacearray'], $message); $subject = ''; if ($type == 1) { $subject = dhtmlspecialchars(trim($_POST['subject'])); } include_once libfile('function/friend'); $return = 0; if ($touid || $pmid) { if ($touid) { if ($value = getuserbyuid($touid)) { $value['onlyacceptfriendpm'] = $value['onlyacceptfriendpm'] ? $value['onlyacceptfriendpm'] : ($_G['setting']['onlyacceptfriendpm'] ? 1 : 2); if ($_G['group']['allowsendallpm'] || $value['onlyacceptfriendpm'] == 2 || $value['onlyacceptfriendpm'] == 1 && friend_check($touid)) { $return = sendpm($touid, $subject, $message, '', 0, 0, $type); } else { // showmessage('message_can_not_send_onlyfriend', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'message_can_not_send_onlyfriend')); } } else { // showmessage('message_bad_touid', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'message_bad_touid')); } } else { $topmuid = intval($_GET['topmuid']); $return = sendpm($topmuid, $subject, $message, '', $pmid, 0); } } elseif ($users) { $newusers = $uidsarr = $membersarr = array(); if ($users) { $membersarr = C::t('common_member')->fetch_all_by_username($users); foreach ($membersarr as $aUsername => $aUser) { $uidsarr[] = $aUser['uid']; } } if (empty($membersarr)) { showmessage('message_bad_touser', '', array(), array('return' => true)); } if (isset($membersarr[$_G['uid']])) { showmessage('message_can_not_send_to_self', '', array(), array('return' => true)); } friend_check($uidsarr); foreach ($membersarr as $key => $value) { $value['onlyacceptfriendpm'] = $value['onlyacceptfriendpm'] ? $value['onlyacceptfriendpm'] : ($_G['setting']['onlyacceptfriendpm'] ? 1 : 2); if ($_G['group']['allowsendallpm'] || $value['onlyacceptfriendpm'] == 2 || $value['onlyacceptfriendpm'] == 1 && $_G['home_friend_' . $value['uid'] . '_' . $_G['uid']]) { $newusers[$value['uid']] = $value['username']; unset($users[array_search($value['username'], $users)]); } } if (empty($newusers)) { showmessage('message_can_not_send_onlyfriend', '', array(), array('return' => true)); } foreach ($newusers as $key => $value) { if (isblacklist($key)) { showmessage('is_blacklist', '', array(), array('return' => true)); } } $coef = count($newusers); $return = sendpm(implode(',', $newusers), $subject, $message, '', 0, 1, $type); } else { // showmessage('message_can_not_send_9', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'message_can_not_send_9')); } if ($return > 0) { include_once libfile('function/stat'); updatestat('sendpm', 0, $coef); C::t('common_member_status')->update($_G['uid'], array('lastpost' => TIMESTAMP)); !($_G['group']['exempt'] & 1) && updatecreditbyaction('sendpm', 0, array(), '', $coef); if (!empty($newusers)) { if ($type == 1) { $returnurl = 'home.php?mod=space&do=pm&filter=privatepm'; } else { $returnurl = 'home.php?mod=space&do=pm'; } showmessage(count($users) ? 'message_send_result' : 'do_success', $returnurl, array('users' => implode(',', $users), 'succeed' => count($newusers))); } else { if (!defined('IN_MOBILE')) { // showmessage('do_success', 'home.php?mod=space&do=pm&subop=view&touid='.$touid, array('pmid' => $return), $_G['inajax'] ? array('msgtype' => 3, 'showmsg' => false) : array()); } else { // showmessage('do_success', 'home.php?mod=space&do=pm&subop=view'.(intval($_POST['touid']) ? '&touid='.intval($_POST['touid']) : ( intval($_POST['plid']) ? '&plid='.intval($_POST['plid']).'&daterange=1&type=1' : '' ))); } $res = $this->makeErrorInfo($res, 'do_success', array('noError' => 1, 'alert' => 0)); $msgInfo = uc_pm_viewnode($_G['uid'], $type, $return); $res['body']['plid'] = (int) $msgInfo['plid']; $res['body']['pmid'] = (int) $msgInfo['pmid']; $res['body']['sendTime'] = $msgInfo['dateline'] . '000'; // ios push UserUtils::pushIOSMessage($touid, 'pm', $_G['username'] . WebUtils::t(' 对 您 说: ') . $message); } } else { if (in_array($return, range(-16, -1))) { // showmessage('message_can_not_send_'.abs($return)); return $this->makeErrorInfo($res, lang('message', 'message_can_not_send_' . abs($return))); } else { // showmessage('message_can_not_send', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'message_can_not_send')); } } return $res; }
private function replyPost($extract) { global $_G; extract($extract); // 获取主题和帖子要插入的状态信息 $topicStatus = ForumUtils::getPostSendStatus('topic', $_GET['platType']); $postStatus = ForumUtils::getPostSendStatus('post', $_GET['platType']); //$navtitle .= ' - '.$thread['subject'].' - '.$_G['forum']['name']; //copy from dz source/include/post/post_newreply.php require_once libfile('function/forumlist'); $isfirstpost = 0; $showthreadsorts = 0; $quotemessage = ''; if (!$_G['uid'] && !(!$_G['forum']['replyperm'] && $_G['group']['allowreply'] || $_G['forum']['replyperm'] && forumperm($_G['forum']['replyperm']))) { return WebUtils::makeErrorInfo_oldVersion($res, 'replyperm_login_nopermission', array('{login}' => 1)); } elseif (empty($_G['forum']['allowreply'])) { if (!$_G['forum']['replyperm'] && !$_G['group']['allowreply']) { return WebUtils::makeErrorInfo_oldVersion($res, 'replyperm_none_nopermission', array('{login}' => 1)); } elseif ($_G['forum']['replyperm'] && !forumperm($_G['forum']['replyperm'])) { $msg = mobcent_showmessagenoperm('replyperm', $_G['forum']['fid']); return WebUtils::makeErrorInfo_oldVersion($res, $msg['message'], $msg['params']); } } elseif ($_G['forum']['allowreply'] == -1) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_forum_newreply_nopermission'); } if (!$_G['uid'] && ($_G['setting']['need_avatar'] || $_G['setting']['need_email'] || $_G['setting']['need_friendnum'])) { return WebUtils::makeErrorInfo_oldVersion($res, 'replyperm_login_nopermission', array('{login}' => 1)); } if (empty($thread)) { return WebUtils::makeErrorInfo_oldVersion($res, 'thread_nonexistence'); } elseif ($thread['price'] > 0 && $thread['special'] == 0 && !$_G['uid']) { return WebUtils::makeErrorInfo_oldVersion($res, 'group_nopermission', array('{grouptitle}' => $_G['group']['grouptitle'])); } checklowerlimit('reply', 0, 1, $_G['forum']['fid']); if ($_G['setting']['commentnumber'] && !empty($_GET['comment'])) { if (!submitcheck('commentsubmit', 0, $seccodecheck, $secqaacheck)) { return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd'); showmessage('submitcheck_error', NULL); } $post = C::t('forum_post')->fetch('tid:' . $_G['tid'], $_GET['pid']); if (!$post) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_nonexistence'); } if ($thread['closed'] && !$_G['forum']['ismoderator'] && !$thread['isgroup']) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_thread_closed'); } elseif (!$thread['isgroup'] && ($post_autoclose = checkautoclose($thread))) { return WebUtils::makeErrorInfo_oldVersion($res, $post_autoclose, array('{autoclose}' => $_G['forum']['autoclose'])); } elseif (checkflood()) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_flood_ctrl', array('{floodctrl}' => $_G['setting']['floodctrl'])); } elseif (checkmaxperhour('pid')) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_flood_ctrl_posts_per_hour', array('posts_per_hour' => $_G['group']['maxpostsperhour'])); } $commentscore = ''; if (!empty($_GET['commentitem']) && !empty($_G['uid']) && $post['authorid'] != $_G['uid']) { foreach ($_GET['commentitem'] as $itemk => $itemv) { if ($itemv !== '') { $commentscore .= strip_tags(trim($itemk)) . ': <i>' . intval($itemv) . '</i> '; } } } $comment = cutstr(($commentscore ? $commentscore . '<br />' : '') . censor(trim(dhtmlspecialchars($_GET['message'])), '***'), 200, ' '); if (!$comment) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_sm_isnull'); } C::t('forum_postcomment')->insert(array('tid' => $post['tid'], 'pid' => $post['pid'], 'author' => $_G['username'], 'authorid' => $_G['uid'], 'dateline' => TIMESTAMP, 'comment' => $comment, 'score' => $commentscore ? 1 : 0, 'useip' => $_G['clientip'])); C::t('forum_post')->update('tid:' . $_G['tid'], $_GET['pid'], array('comment' => 1)); if (!empty($_G['uid'])) { Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_post.php'); mobcent_updatepostcredits('+', $_G['uid'], 'reply', $_G['fid']); } if (!empty($_G['uid']) && $_G['uid'] != $post['authorid']) { notification_add($post['authorid'], 'pcomment', 'comment_add', array('tid' => $_G['tid'], 'pid' => $_GET['pid'], 'subject' => $thread['subject'], 'from_id' => $_G['tid'], 'from_idtype' => 'pcomment', 'commentmsg' => cutstr(str_replace(array('[b]', '[/b]', '[/color]'), '', preg_replace("/\\[color=([#\\w]+?)\\]/i", "", $comment)), 200))); } update_threadpartake($post['tid']); $pcid = C::t('forum_postcomment')->fetch_standpoint_by_pid($_GET['pid']); $pcid = $pcid['id']; if (!empty($_G['uid']) && $_GET['commentitem']) { $totalcomment = array(); foreach (C::t('forum_postcomment')->fetch_all_by_pid_score($_GET['pid'], 1) as $comment) { $comment['comment'] = addslashes($comment['comment']); if (strexists($comment['comment'], '<br />')) { if (preg_match_all("/([^:]+?):\\s<i>(\\d+)<\\/i>/", $comment['comment'], $a)) { foreach ($a[1] as $k => $itemk) { $totalcomment[trim($itemk)][] = $a[2][$k]; } } } } $totalv = ''; foreach ($totalcomment as $itemk => $itemv) { $totalv .= strip_tags(trim($itemk)) . ': <i>' . floatval(sprintf('%1.1f', array_sum($itemv) / count($itemv))) . '</i> '; } if ($pcid) { C::t('forum_postcomment')->update($pcid, array('comment' => $totalv, 'dateline' => TIMESTAMP + 1)); } else { C::t('forum_postcomment')->insert(array('tid' => $post['tid'], 'pid' => $post['pid'], 'author' => '', 'authorid' => '-1', 'dateline' => TIMESTAMP + 1, 'comment' => $totalv)); } } C::t('forum_postcache')->delete($post['pid']); return WebUtils::makeErrorInfo_oldVersion($res, 'comment_add_succeed'); //showmessage('comment_add_succeed', "forum.php?mod=viewthread&tid=$post[tid]&pid=$post[pid]&page=$_GET[page]&extra=$extra#pid$post[pid]", array('tid' => $post['tid'], 'pid' => $post['pid'])); } if ($special == 127) { $postinfo = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['tid']); $sppos = strrpos($postinfo['message'], chr(0) . chr(0) . chr(0)); $specialextra = substr($postinfo['message'], $sppos + 3); } if (getstatus($thread['status'], 3)) { $rushinfo = C::t('forum_threadrush')->fetch($_G['tid']); if ($rushinfo['creditlimit'] != -996) { $checkcreditsvalue = $_G['setting']['creditstransextra'][11] ? getuserprofile('extcredits' . $_G['setting']['creditstransextra'][11]) : $_G['member']['credits']; if ($checkcreditsvalue < $rushinfo['creditlimit']) { $creditlimit_title = $_G['setting']['creditstransextra'][11] ? $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][11]]['title'] : lang('forum/misc', 'credit_total'); return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd'); showmessage('post_rushreply_creditlimit', '', array('creditlimit_title' => $creditlimit_title, 'creditlimit' => $rushinfo['creditlimit'])); } } // author:HanPengyu Date:2014/11/20 针对x3版本的抢楼帖回帖限制控制 if (isset($rushinfo['replylimit']) && $rushinfo['replylimit'] > 0) { $replycount = C::t('forum_post')->count_by_tid_invisible_authorid($thread['tid'], $_G['uid']); if ($replycount >= $rushinfo['replylimit']) { return WebUtils::makeErrorInfo_oldVersion($res, lang('message', 'noreply_replynum_error')); } } } if ($thread['closed'] && !$_G['forum']['ismoderator'] && !$thread['isgroup']) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_thread_closed'); } elseif (!$thread['isgroup'] && ($post_autoclose = checkautoclose($thread))) { return WebUtils::makeErrorInfo_oldVersion($res, $post_autoclose, array('{autoclose}' => $_G['forum']['autoclose'])); } if (trim($subject) == '' && trim($message) == '' && $thread['special'] != 2) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_sm_isnull'); } elseif ($post_invalid = checkpost($subject, $message, $special == 2 && $_G['group']['allowposttrade'])) { return WebUtils::makeErrorInfo_oldVersion($res, $post_invalid, array('{minpostsize}' => $_G['setting']['minpostsize']), array('{maxpostsize}' => $_G['setting']['maxpostsize'])); //showmessage($post_invalid, '', array('minpostsize' => $_G['setting']['minpostsize'], 'maxpostsize' => $_G['setting']['maxpostsize'])); } elseif (checkflood()) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_flood_ctrl', array('{floodctrl}' => $_G['setting']['floodctrl'])); //showmessage('post_flood_ctrl', '', array('floodctrl' => $_G['setting']['floodctrl'])); } elseif (checkmaxperhour('pid')) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_flood_ctrl_posts_per_hour', array('{posts_per_hour}' => $_G['group']['maxpostsperhour'])); //showmessage('post_flood_ctrl_posts_per_hour', '', array('posts_per_hour' => $_G['group']['maxpostsperhour'])); } $attentionon = empty($_GET['attention_add']) ? 0 : 1; $attentionoff = empty($attention_remove) ? 0 : 1; $heatthreadset = update_threadpartake($_G['tid'], true); if ($_G['group']['allowat']) { $atlist = $atlist_tmp = $ateduids = array(); preg_match_all("/@([^\r\n]*?)\\s/i", $message . ' ', $atlist_tmp); $atlist_tmp = array_slice(array_unique($atlist_tmp[1]), 0, $_G['group']['allowat']); $atnum = $maxselect = 0; foreach (C::t('home_notification')->fetch_all_by_authorid_fromid($_G['uid'], $_G['tid'], 'at') as $row) { $atnum++; $ateduids[$row[uid]] = $row['uid']; } $maxselect = $_G['group']['allowat'] - $atnum; if ($maxselect > 0 && !empty($atlist_tmp)) { if (empty($_G['setting']['at_anyone'])) { foreach (C::t('home_follow')->fetch_all_by_uid_fusername($_G['uid'], $atlist_tmp) as $row) { if (!in_array($row['followuid'], $ateduids)) { $atlist[$row[followuid]] = $row['fusername']; } if (count($atlist) == $maxselect) { break; } } if (count($atlist) < $maxselect) { $query = C::t('home_friend')->fetch_all_by_uid_username($_G['uid'], $atlist_tmp); foreach ($query as $row) { if (!in_array($row['followuid'], $ateduids)) { $atlist[$row[fuid]] = $row['fusername']; } } } } else { foreach (C::t('common_member')->fetch_all_by_username($atlist_tmp) as $row) { if (!in_array($row['uid'], $ateduids)) { $atlist[$row[uid]] = $row['username']; } if (count($atlist) == $maxselect) { break; } } } } if ($atlist) { foreach ($atlist as $atuid => $atusername) { $atsearch[] = "/@" . str_replace('/', '\\/', preg_quote($atusername)) . " /i"; $atreplace[] = "[url=home.php?mod=space&uid={$atuid}]@{$atusername}[/url] "; } $message = preg_replace($atsearch, $atreplace, $message . ' ', 1); } } $bbcodeoff = checkbbcodes($message, !empty($_GET['bbcodeoff'])); $smileyoff = checksmilies($message, !empty($_GET['smileyoff'])); $parseurloff = !empty($_GET['parseurloff']); $htmlon = $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0; $usesig = !empty($_GET['usesig']) && $_G['group']['maxsigsize'] ? 1 : 0; $isanonymous = $_G['group']['allowanonymous'] && !empty($_GET['isanonymous']) ? 1 : 0; $author = empty($isanonymous) ? $_G['username'] : ''; if ($thread['displayorder'] == -4) { $modnewreplies = 0; } $pinvisible = $modnewreplies ? -2 : ($thread['displayorder'] == -4 ? -3 : 0); $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message); $postcomment = in_array(2, $_G['setting']['allowpostcomment']) && $_G['group']['allowcommentreply'] && !$pinvisible && !empty($_GET['reppid']) && ($nauthorid != $_G['uid'] || $_G['setting']['commentpostself']) ? messagecutstr($message, 200, ' ') : ''; if (!empty($_GET['noticetrimstr'])) { $message = $_GET['noticetrimstr'] . "\n\n" . $message; $bbcodeoff = false; } $pid = insertpost(array('fid' => $_G['fid'], 'tid' => $_G['tid'], 'first' => '0', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $_G['timestamp'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => $pinvisible, 'anonymous' => $isanonymous, 'usesig' => $usesig, 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0', 'status' => (defined('IN_MOBILE') ? 8 : 0) | $postStatus)); if ($_G['group']['allowat'] && $atlist) { foreach ($atlist as $atuid => $atusername) { notification_add($atuid, 'at', 'at_message', array('from_id' => $_G['tid'], 'from_idtype' => 'at', 'buyerid' => $_G['uid'], 'buyer' => $_G['username'], 'tid' => $_G['tid'], 'subject' => $thread['subject'], 'pid' => $pid, 'message' => messagecutstr($message, 150))); } set_atlist_cookie(array_keys($atlist)); } $updatethreaddata = $heatthreadset ? $heatthreadset : array(); $postionid = C::t('forum_post')->fetch_maxposition_by_tid($thread['posttableid'], $_G['tid']); $updatethreaddata[] = DB::field('maxposition', $postionid); if (getstatus($thread['status'], 3) && $postionid) { $rushstopfloor = $rushinfo['stopfloor']; if ($rushstopfloor > 0 && $thread['closed'] == 0 && $postionid >= $rushstopfloor) { $updatethreaddata[] = 'closed=1'; } } useractionlog($_G['uid'], 'pid'); $nauthorid = 0; if (!empty($_GET['noticeauthor']) && !$isanonymous && !$modnewreplies) { list($ac, $nauthorid) = explode('|', authcode($_GET['noticeauthor'], 'DECODE')); if ($nauthorid != $_G['uid']) { if ($ac == 'q') { notification_add($nauthorid, 'post', 'reppost_noticeauthor', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'fid' => $_G['fid'], 'pid' => $pid, 'from_id' => $pid, 'from_idtype' => 'quote')); } elseif ($ac == 'r') { notification_add($nauthorid, 'post', 'reppost_noticeauthor', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'fid' => $_G['fid'], 'pid' => $pid, 'from_id' => $thread['tid'], 'from_idtype' => 'post')); } } if ($postcomment) { $rpid = intval($_GET['reppid']); if ($rpost = C::t('forum_post')->fetch('tid:' . $thread['tid'], $rpid)) { if (!$rpost['first']) { C::t('forum_postcomment')->insert(array('tid' => $thread['tid'], 'pid' => $rpid, 'rpid' => $pid, 'author' => $_G['username'], 'authorid' => $_G['uid'], 'dateline' => TIMESTAMP, 'comment' => $postcomment, 'score' => 0, 'useip' => $_G['clientip'])); C::t('forum_post')->update('tid:' . $thread['tid'], $rpid, array('comment' => 1)); C::t('forum_postcache')->delete($rpid); } } unset($postcomment); } } if ($thread['authorid'] != $_G['uid'] && getstatus($thread['status'], 6) && empty($_GET['noticeauthor']) && !$isanonymous && !$modnewreplies) { $thapost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['tid'], 0); notification_add($thapost['authorid'], 'post', 'reppost_noticeauthor', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'fid' => $_G['fid'], 'pid' => $pid, 'from_id' => $thread['tid'], 'from_idtype' => 'post')); // ios push UserUtils::pushIOSMessage($thread['authorid'], 'reply', $_G['username'] . WebUtils::t(' 回复了您的帖子 ') . $thread['subject']); } $feedid = 0; if (helper_access::check_module('follow') && !empty($_GET['adddynamic']) && !$isanonymous) { require_once libfile('function/discuzcode'); require_once libfile('function/followcode'); $feedcontent = C::t('forum_threadpreview')->count_by_tid($thread['tid']); $firstpost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']); if (empty($feedcontent)) { $feedcontent = array('tid' => $thread['tid'], 'content' => followcode($firstpost['message'], $thread['tid'], $pid, 1000)); C::t('forum_threadpreview')->insert($feedcontent); C::t('forum_thread')->update_status_by_tid($thread['tid'], '512'); } else { C::t('forum_threadpreview')->update_relay_by_tid($thread['tid'], 1); } $notemsg = cutstr(followcode($message, $thread['tid'], $pid, 0, false), 140); $followfeed = array('uid' => $_G['uid'], 'username' => $_G['username'], 'tid' => $thread['tid'], 'note' => $notemsg, 'dateline' => TIMESTAMP); $feedid = C::t('home_follow_feed')->insert($followfeed, true); C::t('common_member_count')->increase($_G['uid'], array('feeds' => 1)); } if ($thread['replycredit'] > 0 && !$modnewreplies && $thread['authorid'] != $_G['uid'] && $_G['uid']) { $replycredit_rule = C::t('forum_replycredit')->fetch($_G['tid']); if (!empty($replycredit_rule['times'])) { $have_replycredit = C::t('common_credit_log')->count_by_uid_operation_relatedid($_G['uid'], 'RCA', $_G['tid']); if ($replycredit_rule['membertimes'] - $have_replycredit > 0 && $thread['replycredit'] - $replycredit_rule['extcredits'] >= 0) { $replycredit_rule['extcreditstype'] = $replycredit_rule['extcreditstype'] ? $replycredit_rule['extcreditstype'] : $_G['setting']['creditstransextra'][10]; if ($replycredit_rule['random'] > 0) { $rand = rand(1, 100); $rand_replycredit = $rand <= $replycredit_rule['random'] ? true : false; } else { $rand_replycredit = true; } if ($rand_replycredit) { updatemembercount($_G['uid'], array($replycredit_rule['extcreditstype'] => $replycredit_rule['extcredits']), 1, 'RCA', $_G[tid]); C::t('forum_post')->update('tid:' . $_G['tid'], $pid, array('replycredit' => $replycredit_rule['extcredits'])); $updatethreaddata[] = DB::field('replycredit', $thread['replycredit'] - $replycredit_rule['extcredits']); } } } } ($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) && ($_GET['attachnew'] || $special == 2 && $_GET['tradeaid']) && updateattach($thread['displayorder'] == -4 || $modnewreplies, $_G['tid'], $pid, $_GET['attachnew']); $replymessage = 'post_reply_succeed'; if ($special == 2 && $_G['group']['allowposttrade'] && $thread['authorid'] == $_G['uid'] && !empty($_GET['trade']) && !empty($_GET['item_name'])) { require_once libfile('function/trade'); trade_create(array('tid' => $_G['tid'], 'pid' => $pid, 'aid' => $_GET['tradeaid'], 'item_expiration' => $_GET['item_expiration'], 'thread' => $thread, 'discuz_uid' => $_G['uid'], 'author' => $author, 'seller' => empty($_GET['paymethod']) && $_GET['seller'] ? dhtmlspecialchars(trim($_GET['seller'])) : '', 'item_name' => $_GET['item_name'], 'item_price' => $_GET['item_price'], 'item_number' => $_GET['item_number'], 'item_quality' => $_GET['item_quality'], 'item_locus' => $_GET['item_locus'], 'transport' => $_GET['transport'], 'postage_mail' => $_GET['postage_mail'], 'postage_express' => $_GET['postage_express'], 'postage_ems' => $_GET['postage_ems'], 'item_type' => $_GET['item_type'], 'item_costprice' => $_GET['item_costprice'], 'item_credit' => $_GET['item_credit'], 'item_costcredit' => $_GET['item_costcredit'])); $replymessage = 'trade_add_succeed'; if (!empty($_GET['tradeaid'])) { convertunusedattach($_GET['tradeaid'], $_G['tid'], $pid); } } $_G['forum']['threadcaches'] && deletethreadcaches($_G['tid']); include_once libfile('function/stat'); updatestat($thread['isgroup'] ? 'grouppost' : 'post'); $param = array('fid' => $_G['fid'], 'tid' => $_G['tid'], 'pid' => $pid, 'from' => $_GET['from'], 'sechash' => !empty($_GET['sechash']) ? $_GET['sechash'] : ''); if ($feedid) { $param['feedid'] = $feedid; } dsetcookie('clearUserdata', 'forum'); if ($modnewreplies) { updatemoderate('pid', $pid); unset($param['pid']); if ($updatethreaddata) { C::t('forum_thread')->update($_G['tid'], $updatethreaddata, false, false, 0, true); } C::t('forum_forum')->update_forum_counter($_G['fid'], 0, 0, 1, 1); $url = empty($_POST['portal_referer']) ? "forum.php?mod=viewthread&tid={$thread[tid]}" : $_POST['portal_referer']; manage_addnotify('verifypost'); // if(!isset($inspacecpshare)) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_reply_mod_succeed', array('noError' => 1)); //showmessage('post_reply_mod_succeed', $url, $param); // } } else { $fieldarr = array('lastposter' => array($author), 'replies' => 1); if ($thread['lastpost'] < $_G['timestamp']) { $fieldarr['lastpost'] = array($_G['timestamp']); } $row = C::t('forum_threadaddviews')->fetch($_G['tid']); if (!empty($row)) { C::t('forum_threadaddviews')->update($_G['tid'], array('addviews' => 0)); $fieldarr['views'] = $row['addviews']; } $updatethreaddata = array_merge($updatethreaddata, C::t('forum_thread')->increase($_G['tid'], $fieldarr, false, 0, true)); if ($thread['displayorder'] != -4) { Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_post.php'); mobcent_updatepostcredits('+', $_G['uid'], 'reply', $_G['fid']); if ($_G['forum']['status'] == 3) { if ($_G['forum']['closed'] > 1) { C::t('forum_thread')->increase($_G['forum']['closed'], $fieldarr, true); } C::t('forum_groupuser')->update_counter_for_user($_G['uid'], $_G['fid'], 0, 1); C::t('forum_forumfield')->update($_G['fid'], array('lastupdate' => TIMESTAMP)); require_once libfile('function/grouplog'); updategroupcreditlog($_G['fid'], $_G['uid']); } $lastpost = "{$thread['tid']}\t{$thread['subject']}\t{$_G['timestamp']}\t{$author}"; C::t('forum_forum')->update($_G['fid'], array('lastpost' => $lastpost)); C::t('forum_forum')->update_forum_counter($_G['fid'], 0, 1, 1); if ($_G['forum']['type'] == 'sub') { C::t('forum_forum')->update($_G['forum']['fup'], array('lastpost' => $lastpost)); } } $page = getstatus($thread['status'], 4) ? 1 : @ceil(($thread['special'] ? $thread['replies'] + 1 : $thread['replies'] + 2) / $_G['ppp']); if ($updatethreaddata) { C::t('forum_thread')->update($_G['tid'], $updatethreaddata, false, false, 0, true); } /* if(!isset($inspacecpshare)) { // showmessage($replymessage, $url, $param); } */ } if ($jsonInfo['isShowPostion']) { $data = DB::query('INSERT INTO %t VALUES(poi_id,%f,%f,%d,%d,%s)', array('home_surrounding_user', $jsonInfo['longitude'], $jsonInfo['latitude'], $pid, 2, (string) $jsonInfo['location'])); } /* //客户端回复帖子积分入库 $temp = DB::fetch_first('SELECT extcredits3 FROM '.DB::table('common_credit_rule').' WHERE rid =%d',array(2)); $extcredits3 = DB::fetch_first('SELECT extcredits3 FROM '.DB::table('common_member_count').' WHERE uid = %d',array($_G['uid'])); $temp = $extcredits3['extcredits3'] + $temp['extcredits3']; DB::query('UPDATE '.DB::table('common_member_count').' set extcredits3 = %d WHERE uid = %d',array($temp,$_G['uid'])); */ // return array('rs'=>1,'errcode'=>WebUtils::t('发贴成功')); return $this->makeErrorInfo($res, 'mobcent_post_reply_succeed', array('noError' => 1)); }
private function _adminUser($act, $uid) { global $_G; $errorMsg = ''; require_once libfile('function/spacecp'); require_once libfile('function/home'); require_once libfile('function/friend'); if (friend_request_check($uid) && $act == 'add') { $act = 'add2'; } if ($act == 'add' || $act == 'add2') { if ($uid == $_G['uid']) { $list = $this->makeErrorInfo($res, 'friend_self_error'); $this->_exitWithHtmlAlert($list['errcode']); } if (friend_check($uid)) { $list = $this->makeErrorInfo($res, 'you_have_friends'); $this->_exitWithHtmlAlert($list['errcode']); } $tospace = getuserbyuid($uid); if (empty($tospace)) { $list = $this->makeErrorInfo($res, 'space_does_not_exist'); $this->_exitWithHtmlAlert($list['errcode']); } if (isblacklist($tospace['uid'])) { $list = $this->makeErrorInfo($res, 'is_blacklist'); $this->_exitWithHtmlAlert($list['errcode']); } space_merge($space, 'count'); space_merge($space, 'field_home'); $maxfriendnum = checkperm('maxfriendnum'); if ($maxfriendnum && $space['friends'] >= $maxfriendnum + $space['addfriend']) { if ($_G['magic']['friendnum']) { $list = $this->makeErrorInfo($res, 'enough_of_the_number_of_friends_with_magic'); $this->_exitWithHtmlAlert($list['errcode']); } else { $list = $this->makeErrorInfo($res, 'enough_of_the_number_of_friends'); $this->_exitWithHtmlAlert($list['errcode']); } } if ($act == 'add') { if (!checkperm('allowfriend')) { $list = $this->makeErrorInfo($res, 'no_privilege_addfriend'); $this->_exitWithHtmlAlert($list['errcode']); } if (C::t('home_friend_request')->count_by_uid_fuid($uid, $_G['uid'])) { $list = $this->makeErrorInfo($res, 'waiting_for_the_other_test'); $this->_exitWithHtmlAlert($list['errcode']); } } } require_once libfile('function/friend'); require_once libfile('function/spacecp'); if (!empty($_POST)) { switch ($act) { case 'add': $note = $_GET['note']; if (!friend_request_check($uid)) { $_POST['gid'] = $gid; $_POST['note'] = censor(htmlspecialchars(cutstr($note, strtolower(CHARSET) == 'utf-8' ? 30 : 20, ''))); friend_add($uid, $_POST['gid'], $_POST['note']); $note = array('uid' => $_G['uid'], 'url' => 'home.php?mod=spacecp&ac=friend&op=add&uid=' . $_G['uid'] . '&from=notice', 'from_id' => $_G['uid'], 'from_idtype' => 'friendrequest', 'note' => !empty($_POST['note']) ? lang('spacecp', 'friend_request_note', array('note' => $_POST['note'])) : ''); notification_add($uid, 'friend', 'friend_request', $note); // ios push UserUtils::pushIOSMessage($uid, 'friend', $_G['username'] . WebUtils::t(' 请求加您为好友') . $note['note']); require_once libfile('function/mail'); $values = array('username' => $tospace['username'], 'url' => getsiteurl() . 'home.php?mod=spacecp&ac=friend&op=request'); sendmail_touser($uid, lang('spacecp', 'friend_subject', $values), '', 'friend_add'); $list = $this->makeErrorInfo($res, 'request_has_been_sent'); $this->_exitWithHtmlAlert($list['errcode']); } $this->_exitWithHtmlAlert($res['errcode']); case 'add2': global $_G; require_once libfile('function/home'); $_POST['gid'] = intval($gid); friend_add($uid, $uid); if (ckprivacy('friend', 'feed')) { require_once libfile('function/feed'); feed_add('friend', 'feed_friend_title', array('touser' => "<a href=\"home.php?mod=space&uid={$tospace['uid']}\">{$tospace['username']}</a>")); } notification_add($uid, 'friend', 'friend_add'); // showmessage('friends_add', dreferer(), array('username' => $tospace['username'], 'uid'=>$uid, 'from' => $_GET['from']), array('showdialog'=>1, 'showmsg' => true, 'closetime' => true)); $list = $this->makeErrorInfo($res, 'friends_add', array('{username}' => $tospace['username'])); $this->_exitWithHtmlAlert($list['errcode']); break; case 'ignore': global $_G; require_once libfile('function/friend'); friend_delete($uid); $params['noError'] = 1; $list = $this->makeErrorInfo($res, 'do_success', $params); $this->_exitWithHtmlAlert($list['errcode']); break; case 'shield': global $_G, $space; // $type = empty($_GET['type'])?'':preg_replace("/[^0-9a-zA-Z\_\-\.]/", '', $_GET['type']); // if(submitcheck('ignoresubmit')) { $authorid = empty($_POST['authorid']) ? 0 : intval($_POST['authorid']); $type = 'friend'; if ($type) { $type_uid = $type . '|' . $authorid; if (empty($space['privacy']['filter_note']) || !is_array($space['privacy']['filter_note'])) { $space['privacy']['filter_note'] = array(); } $space['privacy']['filter_note'][$type_uid] = $type_uid; privacy_update(); } $this->_exitWithHtmlAlert('do_success'); // showmessage('do_success', dreferer(), array(), array('showdialog'=>1, 'showmsg' => true, 'closetime' => true)); // } $formid = random(8); break; default: $errorMsg = '错误的动作参数'; break; } } else { if ($act == 'add') { require_once libfile('function/friend'); $groups = $this->_getFriendGroupList(); $tospace = getuserbyuid($uid); } elseif ($act == 'add2') { require_once libfile('function/friend'); $groups = $this->_getFriendGroupList(); $tospace = $this->_getFriendUserByUid($uid); } } $this->getController()->renderPartial('userAdmin', array('formUrl' => WebUtils::createUrl_oldVersion('user/useradminview', array('uid' => $uid, 'act' => $act, 'type' => $type)), 'errorMsg' => $errorMsg, 'action' => $act, '_G' => $_G, 'groups' => $groups, 'tospace' => $tospace)); }