function sendPost($tid, $uid, $title, $content) { global $winddb, $winduid, $windid, $groupid, $fid, $timestamp, $pwforum, $pwpost, $_G, $db_uploadfiletype, $uploadcredit, $uploadmoney, $manager, $isBM, $_time; $timestamp = time(); $_time = array('hours' => get_date($timestamp, 'G'), 'day' => get_date($timestamp, 'j'), 'week' => get_date($timestamp, 'w')); list($uid, $tid, $title, $content) = array(intval($uid), intval($tid), trim($title), trim($content)); if ($uid < 1 || $tid < 1 || !$content) { return $this->buildResponse(THREAD_INVALID_PARAMS); } ACloud_Sys_Core_Common::setGlobal('customized_current_uid', $uid); $user = $this->getCurrentUser(); if (!$user->isLogin()) { return $this->buildResponse(USER_NOT_LOGIN); } if ($user->groupid == 6 || getstatus($user->info['userstatus'], PW_USERSTATUS_BANUSER)) { return $this->buildResponse(THREAD_USER_NOT_RIGHT); } $user->initRight(); $winduid = $user->uid; $groupid = $user->groupid; $windid = $user->username; $winddb = $user->info; $_G = $user->_G; if ($_G['postlimit'] && $winddb['todaypost'] >= $_G['postlimit']) { return $this->buildResponse(POST_GP_LIMIT); } $tpcarray = $GLOBALS['db']->get_one("SELECT t.tid,t.fid,t.locked,t.ifcheck,t.author,t.authorid,t.postdate,t.lastpost,t.ifmail,t.special,t.subject,t.type,t.ifshield,t.anonymous,t.ptable,t.replies,t.tpcstatus FROM pw_threads t WHERE t.tid=" . pwEscape($tid)); L::loadClass('forum', 'forum', false); $pwforum = new PwForum($tpcarray['fid']); if (!$pwforum->isForum()) { return $this->buildResponse(THREAD_FORUM_NOT_EXIST); } $fid = $tpcarray['fid']; $isBM = $pwforum->isBM($windid); $isGM = S::inArray($windid, $manager); if (!$isGM && $tpcarray['locked'] % 3 != 0 && !pwRights($isBM, 'replylock')) { return $this->buildResponse(THREAD_LOCKED); } L::loadClass('post', 'forum', false); require_once ACLOUD_VERSION_PATH . '/customized/ver.customized.bbscode.php'; $pwpost = new PwPost($pwforum); $pwpost->errMode = true; $pwpost->forumcheck(); $pwpost->postcheck(); L::loadClass('replypost', 'forum', false); $replypost = new replyPost($pwpost); $replypost->setTpc($tpcarray); $replypost->check(); $pw_posts = GetPtable($replypost->tpcArr['ptable']); $postdata = new replyPostData($pwpost); $postdata->setTitle($title); $postdata->setContent($content); $postdata->conentCheck(); if ($pwpost->errMsg && ($msg = reset($pwpost->errMsg))) { return $this->buildResponse(THREAD_SYSTEM_ERROR, $msg); } require_once ACLOUD_VERSION_PATH . '/customized/ver.customized.attupload.php'; if (PwUpload::getUploadNum()) { $_G['uploadtype'] && ($db_uploadfiletype = $_G['uploadtype']); $db_uploadfiletype = !empty($db_uploadfiletype) ? is_array($db_uploadfiletype) ? $db_uploadfiletype : unserialize($db_uploadfiletype) : array(); $postdata->att = new AttUpload($user->uid); $return = $postdata->att->check(); if ($return) { $msginfo = getLangInfo('msg', $return); return $this->errMessage(THREAD_USER_NOT_RIGHT, $msginfo); } list($windVersion) = explode(',', WIND_VERSION); if ($windVersion && $windVersion < '8.5') { $postdata->att->transfer(); PwUpload::upload($postdata->att); } } $replypost->execute($postdata); $pid = $replypost->getNewId(); return $this->buildResponse(0, array('pid' => $pid)); }
checkWapPost(0); require_once R_P . 'lib/forum/replypost.class.php'; $replypost = new replyPost($pwpost); $replypost->setTpc($tpcarray); $replypost->check(); !empty($pwpost->errMsg) && wap_msg($pwpost->errMsg); require_once R_P . 'require/bbscode.php'; $replypost->setTpc($tpcarray); $content = $content . "\r\n\r\n[size=2][color=#a5a5a5]内容来自[/color][color=#4f81bd][url=" . $db_bbsurl . "/m/index.php][手机版][/url][/color] [/size]"; $postdata = new replyPostData($pwpost); $postdata->setTitle(wap_cv($subject, false)); $postdata->setContent(wap_cv($content, false)); $postdata->conentCheck(); $postdata->checkdata(); !empty($pwpost->errMsg) && wap_msg($pwpost->errMsg); $replypost->execute($postdata); $pid = $replypost->getNewId(); pwHook::runHook('after_reply'); $rurl = "index.php?a=read&tid={$tid}&fid={$fid}&page=e"; if ($postdata->getIfcheck() == '0') { wap_msg("发帖成功,请等待管理员审核", $rurl); } if ($_POST['upload']) { $rurl = "index.php?a=upload&tid={$tid}&fid={$fid}&page=e"; header("Location:{$rurl}"); } /*删除缓存*/ $_filename = D_P . "data/wapcache/wap_all_cache.php"; if (file_exists($_filename)) { P_unlink($_filename); }
/** * 新增一个回复 * @param int $tid * @param string $content */ function addPost($tid, $content) { global $timestamp; $tpcarray = $this->db->get_one("SELECT tid,fid,locked,subject,ifcheck,postdate,lastpost,ptable,author,replies,type,ifshield,anonymous,tpcstatus FROM pw_threads WHERE tid=" . S::sqlEscape($tid)); L::loadClass('forum', 'forum', false); L::loadClass('post', 'forum', false); if ($tpcarray['tid'] != $tid) { return false; } $tpcarray['openIndex'] = getstatus($tpcarray['tpcstatus'], 2); $pwforum = new PwForum($tpcarray['fid']); $pwpost = new PwPost($pwforum); if (!$pwforum->foruminfo['allowrp'] && !$pwpost->admincheck && $GLOBALS['_G']['allowrp'] == 0) { return 'reply_group_right'; } elseif ($pwforum->forumset['lock'] && !$pwpost->isGM && $timestamp - $tpcarray['postdate'] > $pwforum->forumset['lock'] * 86400 && !pwRights($pwpost->isBM, 'replylock')) { //$forumset['lock'] = $pwforum->forumset['lock']; return 'forum_locked'; } elseif (!$pwpost->isGM && !$tpcarray['ifcheck'] && !pwRights($pwpost->isBM, 'viewcheck')) { return 'reply_ifcheck'; } elseif (!$pwpost->isGM && $tpcarray['locked'] % 3 != 0 && !pwRights($pwpost->isBM, 'replylock')) { return 'reply_lockatc'; } else { L::loadClass('replypost', 'forum', false); $replypost = new replyPost($pwpost); $replypost->setTpc($tpcarray); $pwpost->errMode = true; $replypost->check(); if ($pwpost->errMsg && ($msg = reset($pwpost->errMsg))) { return $msg; } require_once R_P . 'require/bbscode.php'; $postdata = new replyPostData($pwpost); //set title //$title = '回 楼主(' . $tpcarray['author'].')的帖子'; //strlen($title) <= intval($postdata->titlemax) && $postdata->setTitle($title); $replypost->setTpc($tpcarray); $postdata->setContent($content); $postdata->conentCheck(); $replypost->execute($postdata); return true; } }
function reply($tid, $author, $title, $content) { global $winddb, $winduid, $windid, $groupid, $timestamp, $pwforum, $pwpost; $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */ $winddb = $userService->getByUserName($author, true, true); if (empty($winddb)) { return new ApiResponse('API_THREAD_AUTHOR_NOT_EXISTS'); //return new ErrorMsg(API_THREAD_AUTHOR_NOT_EXISTS, 'User not exists'); } $winduid = $winddb['uid']; $groupid = $winddb['groupid']; $windid = $winddb['username']; $groupid == '-1' && ($groupid = $winddb['memberid']); if ($groupid == 6 || getstatus($winddb['userstatus'], PW_USERSTATUS_BANUSER)) { //会员禁言 return new ApiResponse('API_THREAD_THE_USER_BAN'); } $tpcarray = $this->db->get_one("SELECT t.tid,t.fid,t.locked,t.ifcheck,t.author,t.authorid,t.postdate,t.lastpost,t.ifmail,t.special,t.subject,t.type,t.ifshield,t.anonymous,t.ptable,t.replies,t.tpcstatus FROM pw_threads t WHERE t.tid=" . pwEscape($tid)); L::loadClass('forum', 'forum', false); $pwforum = new PwForum($tpcarray['fid']); if (!$pwforum->isForum()) { return new ApiResponse('THREAD_FORUM_NOT_EXIST'); } L::loadClass('post', 'forum', false); require_once R_P . 'require/bbscode.php'; $pwpost = new PwPost($pwforum); $pwpost->errMode = true; $pwpost->forumcheck(); $pwpost->postcheck(); L::loadClass('replypost', 'forum', false); $replypost = new replyPost($pwpost); $replypost->setTpc($tpcarray); $replypost->check(); $postdata = new replyPostData($pwpost); $postdata->setTitle($title); $postdata->setContent($content); $postdata->conentCheck(); if ($pwpost->errMsg && ($msg = reset($pwpost->errMsg))) { return new ApiResponse('THREAD_SYSTEM_ERROR'); } $replypost->execute($postdata); $pid = $replypost->getNewId(); return new ApiResponse($pid); }