PageRenderTime 57ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/post.php

https://bitbucket.org/johnroyer/phpwind8.7
PHP | 305 lines | 262 code | 22 blank | 21 comment | 147 complexity | 43be7993838b7ddfce4fc2cbf5af0c97 MD5 | raw file
  1. <?php
  2. define('SCR','post');
  3. if (isset($_POST['ajax']) && $_POST['ajax'] == 1) {
  4. define("AJAX",1);
  5. }
  6. require_once('global.php');
  7. L::loadClass('forum', 'forum', false);
  8. L::loadClass('post', 'forum', false);
  9. //* include_once pwCache::getPath(D_P.'data/bbscache/cache_post.php');
  10. pwCache::getData(D_P.'data/bbscache/cache_post.php');
  11. /**
  12. * 版塊緩衝文件
  13. */
  14. empty($fid) && Showmsg('undefined_action');
  15. $pwforum = new PwForum($fid);
  16. $pwpost = new PwPost($pwforum);
  17. if (!S::inArray($windid, $manager)) {
  18. $pwpost->forumcheck();
  19. $pwpost->postcheck();
  20. }
  21. $foruminfo =& $pwforum->foruminfo;
  22. $forumset =& $pwforum->forumset;
  23. if ($forumset['link']) {
  24. Showmsg('本版塊為外鏈版塊,禁止發帖');
  25. }
  26. S::gp(array('action','article','pid','page'));
  27. S::gp(array('special','modelid','pcid', 'cyid','actmid'),GP,2);
  28. $replacedb = array();
  29. $secondurl = "thread.php?fid=$fid";
  30. !$action && $action = "new";
  31. $replayorder_default = 'checked';
  32. if ($action == 'new') {
  33. $theSpecialFlag = false;//是否是特殊帖子(分類、團購、活動)
  34. if ($modelid > 0) {/*主題分類*/
  35. L::loadClass('posttopic', 'forum', false);
  36. $postTopic = new postTopic($pwpost);
  37. if (!$_G['allowmodelid']) {
  38. Showmsg('post_allowpost');
  39. }
  40. if (strpos(",".$pwforum->foruminfo['modelid'].",",",".$modelid.",") === false) {
  41. Showmsg('forum_model_undefined');
  42. }
  43. if (!$postTopic->topiccatedb[$postTopic->topicmodeldb[$modelid]['cateid']]['ifable']) {
  44. Showmsg('topic_cate_unable');
  45. }
  46. !$postTopic->topicmodeldb[$modelid]['ifable'] && Showmsg('topic_model_unable');
  47. $special = $pcid = $actmid = 0;
  48. $theSpecialFlag = true;
  49. } elseif ($pcid > 0) {/*團購*/
  50. L::loadClass('postcate', 'forum', false);
  51. $postCate = new postCate($pwpost);
  52. if (strpos(",".$pwforum->foruminfo['pcid'].",",",".$pcid.",") === false) {
  53. Showmsg('post_allowtype');
  54. }
  55. if (!$postCate->postcatedb[$pcid]['ifable']) {
  56. Showmsg('forum_pc_undefined');
  57. }
  58. if (strpos(",".$_G['allowpcid'].",",",".$pcid.",") === false) {
  59. Showmsg('post_allowpost');
  60. }
  61. $special = $modelid = $actmid = 0;
  62. $theSpecialFlag = true;
  63. } elseif ($actmid > 0) {/*活動分類*/
  64. L::loadClass('ActivityForBbs', 'activity', false);
  65. $postActForBbs = new PW_ActivityForBbs($pwpost);
  66. if (!$_G['allowactivity']) {
  67. Showmsg('post_allowpost');
  68. }
  69. if (strpos(",".$pwforum->foruminfo['actmids'].",",",".$actmid.",") === false) {
  70. Showmsg('forum_model_undefined');
  71. }
  72. if (!$postActForBbs->activitycatedb[$postActForBbs->activitymodeldb[$actmid]['actid']]['ifable']) {
  73. Showmsg('topic_cate_unable');
  74. }
  75. !$postActForBbs->activitymodeldb[$actmid]['ifable'] && Showmsg('topic_model_unable');
  76. $special = $pcid = $modelid = 0;
  77. $theSpecialFlag = true;
  78. } elseif (!($pwforum->foruminfo['allowtype'] & pow(2,$special))) {
  79. $modelid = $pcid = $actmid = 0;
  80. if (empty($special) && $pwforum->foruminfo['allowtype'] > 0) {
  81. $special = (int)log($pwforum->foruminfo['allowtype'],2);
  82. } elseif ($pwforum->foruminfo['modelid'] || $pwforum->foruminfo['pcid'] || $pwforum->foruminfo['actmids']) {
  83. L::loadClass('posttopic', 'forum', false);
  84. $postTopic = new postTopic($pwpost);
  85. $modeliddb = explode(",",$pwforum->foruminfo['modelid']);
  86. /*判斷分類信息是否存在*/
  87. foreach ($modeliddb as $value) {
  88. if ($postTopic->topiccatedb[$postTopic->topicmodeldb[$value]['cateid']]['ifable'] && $_G['allowmodelid'] && $postTopic->topicmodeldb[$value]['ifable']) {
  89. $modelid = $value;
  90. $theSpecialFlag = true;
  91. break;
  92. }
  93. }
  94. /*判斷團購是否存在*/
  95. if (!$modelid) {
  96. L::loadClass('postcate', 'forum', false);
  97. $postCate = new postCate($pwpost);
  98. $pciddb = explode(",",$pwforum->foruminfo['pcid']);
  99. foreach ($pciddb as $value) {
  100. if ($postCate->postcatedb[$value]['ifable'] && strpos(",".$_G['allowpcid'].",",",".$value.",") !== false) {
  101. $theSpecialFlag = true;
  102. $pcid = $value;
  103. break;
  104. }
  105. }
  106. }
  107. /*判斷活動是否存在*/
  108. if (!$pcid && !$modelid) {
  109. L::loadClass('ActivityForBbs', 'activity', false);
  110. $postActForBbs = new PW_ActivityForBbs($pwpost);
  111. $actmiddb = explode(",",$pwforum->foruminfo['actmids']);
  112. foreach ($actmiddb as $value) {
  113. if ($postActForBbs->activitycatedb[$postActForBbs->activitymodeldb[$value]['actid']]['ifable'] && $_G['allowactivity'] && $postActForBbs->activitymodeldb[$value]['ifable']) {
  114. $actmid = $value;
  115. $theSpecialFlag = true;
  116. break;
  117. }
  118. }
  119. if (!$actmid) {
  120. Showmsg('post_allowtype');
  121. }
  122. }
  123. } else {
  124. Showmsg('post_allowtype');
  125. }
  126. }
  127. }
  128. /**
  129. * 禁止受限制用戶發言
  130. */
  131. if ($groupid == 6 || getstatus($winddb['userstatus'], PW_USERSTATUS_BANUSER)) {
  132. $flag = 0;
  133. $bandb = $delban = array();
  134. $query = $db->query("SELECT * FROM pw_banuser WHERE uid=".S::sqlEscape($winduid));
  135. while ($rt = $db->fetch_array($query)) {
  136. if ($rt['type'] == 1 && $timestamp - $rt['startdate'] > $rt['days']*86400) {
  137. $delban[] = $rt['id'];
  138. } elseif ($rt['fid'] == 0 || $rt['fid'] == $fid) {
  139. $bandb[$rt['fid']] = $rt;
  140. } else {
  141. $flag = 1;
  142. }
  143. }
  144. $delban && $db->update('DELETE FROM pw_banuser WHERE id IN('.S::sqlImplode($delban).')');
  145. $updateUser = array();
  146. if ($groupid == 6 && !isset($bandb[0])) {
  147. $updateUser['groupid'] = -1;
  148. }
  149. if (getstatus($winddb['userstatus'], PW_USERSTATUS_BANUSER) && !isset($bandb[$fid]) && !$flag) {
  150. $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */
  151. $userService->setUserStatus($winduid, PW_USERSTATUS_BANUSER, false);
  152. }
  153. if (count($updateUser)) {
  154. $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */
  155. $userService->update($winduid, $updateUser);
  156. }
  157. if ($bandb) {
  158. $bandb = current($bandb);
  159. if ($bandb['type'] == 1) {
  160. $s_date = get_date($bandb['startdate']);
  161. $e_date = $bandb['startdate'] + $bandb['days']*86400;
  162. $e_date = get_date($e_date);
  163. Showmsg('ban_info1');
  164. } else {
  165. if ($bandb['type'] == 3) {
  166. Cookie('force',$winduid);
  167. Showmsg('ban_info3');
  168. } else {
  169. Showmsg('ban_info2');
  170. }
  171. }
  172. }
  173. }
  174. if (GetCookie('force') && $winduid != GetCookie('force')) {
  175. $force = GetCookie('force');
  176. $bandb = $db->get_one("SELECT type FROM pw_banuser WHERE uid=".S::sqlEscape($force)." AND fid='0'");
  177. if ($bandb['type'] == 3) {
  178. Showmsg('ban_info3');
  179. } else {
  180. Cookie('force','',0);
  181. }
  182. }
  183. $userlastptime = $groupid != 'guest' ? $winddb['lastpost'] : GetCookie('userlastptime');
  184. /**
  185. * 灌水預防
  186. */
  187. $tdtime >= $winddb['lastpost'] && $winddb['todaypost'] = 0;
  188. $montime >= $winddb['lastpost'] && $winddb['monthpost'] = 0;
  189. if ($_G['postlimit'] && $winddb['todaypost'] >= $_G['postlimit']) {
  190. Showmsg('post_gp_limit');
  191. }
  192. if (!empty($_POST['step']) && !$pwpost->isGM && $_G['postpertime'] && $timestamp>=$userlastptime && $timestamp-$userlastptime<=$_G['postpertime'] && !pwRights($pwpost->isBM,'postpers')) {
  193. Showmsg('post_limit');
  194. }
  195. list($postq,$showq) = explode("\t", $db_qcheck);
  196. $_G['uploadtype'] && $db_uploadfiletype = $_G['uploadtype'];
  197. $db_uploadfiletype = !empty($db_uploadfiletype) ? (is_array($db_uploadfiletype) ? $db_uploadfiletype : unserialize($db_uploadfiletype)) : array();
  198. empty($db_sellset['type']) && $db_sellset['type'] = array('money');
  199. empty($db_enhideset['type']) && $db_enhideset['type'] = array('rvrc');
  200. if (empty($_POST['step'])) {
  201. require_once(R_P.'require/credit.php');
  202. $editor = getstatus($winddb['userstatus'], PW_USERSTATUS_EDITOR) ? 'wysiwyg' : 'textmode';
  203. !is_numeric($db_attachnum) && $db_attachnum = 1;
  204. $htmlsell = ($pwforum->foruminfo['allowsell'] && $_G['allowsell']) ? '' : 'disabled';
  205. $htmlhide = ($pwforum->forumset['allowencode'] && $_G['allowencode']) ? '' : 'disabled';
  206. $htmlpost = $attachHide = ($pwforum->foruminfo['allowhide'] && $_G['allowhidden']) ? '' : 'disabled';
  207. $ifanonymous= ($pwpost->isGM || $pwforum->forumset['anonymous'] && $_G['anonymous']) ? '' : 'disabled';
  208. $groupid == 'guest' && $userrvrc = 0;
  209. $atc_title = $atc_content = $ifmailck = $selltype = $enhidetype = $alltype = $replyrewardcredit = '';
  210. $sellCredit = $enhideCredit = $customCreditValue = $userAllCredits = array();
  211. $attachAllow = pwJsonEncode($db_uploadfiletype);
  212. $imageAllow = pwJsonEncode(getAllowKeysFromArray($db_uploadfiletype, array('jpg','jpeg','gif','png','bmp')));
  213. if (S::inArray($action, array('new', 'modify')) && $_G['allowreplyreward'] && S::isArray($_CREDITDB)) {
  214. $customCreditValue = $credit->get($winduid, 'CUSTOM');
  215. }
  216. foreach ($credit->cType as $key => $value) {
  217. if (S::inArray($action, array('new', 'modify')) && $_G['allowreplyreward'] && ($winddb[$key] || $customCreditValue[$key])) {
  218. $replyrewardcredit .= "<option value=\"$key\">" . $value . "</option>";
  219. $userAllCredits['c' . $key] = array(
  220. $winddb[$key] ? ($key == 'rvrc' ? $winddb[$key] / 10 : $winddb[$key]) : $customCreditValue[$key],
  221. $value,
  222. $credit->cUnit[$key]
  223. );
  224. }
  225. $alltype .= "<option value=\"$key\">".$value."</option>";
  226. }
  227. $userAllCredits && $userAllCredits = pwJsonEncode($userAllCredits);
  228. foreach ($db_sellset['type'] as $key => $value) {
  229. $selltype .= "<option value=\"$value\">".$credit->cType[$value]."</option>";
  230. $sellCredit[$value] = $credit->cType[$value];
  231. }
  232. if (is_array($db_enhideset['type'])) {
  233. foreach ($db_enhideset['type'] as $key => $value) {
  234. $enhidetype .= "<option value=\"$value\">".$credit->cType[$value]."</option>";
  235. $enhideCredit[$value] = $credit->cType[$value];
  236. }
  237. }
  238. list($sellCredit, $enhideCredit) = array(pwJsonEncode($sellCredit), pwJsonEncode($enhideCredit));
  239. require_once(R_P.'require/showimg.php');
  240. list($postFaceUrl) = showfacedesign($winddb['icon'],1,'m');
  241. $icondb = array();
  242. if ($db_threademotion) {
  243. $emotion = @opendir(S::escapeDir("$imgdir/post/emotion"));
  244. while (($emotionimg = @readdir($emotion)) !== false) {
  245. if ($emotionimg != "." && $emotionimg != ".." && $emotionimg != "" && preg_match("/^(\d+)\.(gif|jpg|png|bmp)$/i", $emotionimg, $emotionMatch)) {
  246. $icondb[$emotionMatch[1]] = $emotionimg;
  247. }
  248. }
  249. ksort($icondb);
  250. @closedir($emotion);
  251. }
  252. //multiple post types
  253. if ($foruminfo['allowtype'] && (($foruminfo['allowtype'] & 1) || ($foruminfo['allowtype'] & 2 && $_G['allownewvote']) || ($foruminfo['allowtype'] & 4 && $_G['allowactive']) || ($foruminfo['allowtype'] & 8 && $_G['allowreward'])|| ($foruminfo['allowtype'] & 16) || $foruminfo['allowtype'] & 32 && $_G['allowdebate'])) {
  254. $N_allowtypeopen = true;
  255. } else {
  256. $N_allowtypeopen = false;
  257. }
  258. } else {
  259. if ($db_cloudgdcode && defined('AJAX') && S::inArray($action, array('reply', 'quote'))) $keepCloudCaptchaCode = true;
  260. PostCheck(1, ($db_gdcheck & 4) && (!$db_postgd || $winddb['postnum'] < $db_postgd), ($db_ckquestion & 4 && (!$postq || $winddb['postnum'] < $postq) && $db_question));
  261. !$windid && $windid = '遊客';
  262. /*
  263. if ($db_xforwardip && $_POST['_hexie'] != GetVerify($onlineip.$winddb['regdate'].$fid.$tid)) {
  264. Showmsg('undefined_action');
  265. }
  266. */
  267. }
  268. //默認動漫表情處理
  269. if ($db_windmagic && ($action == 'new' || ($action == 'modify' && $pid == 'tpc'))) {
  270. $mDef = '';
  271. //* @include_once pwCache::getPath(D_P."data/bbscache/myshow_default.php");
  272. pwCache::getData(D_P."data/bbscache/myshow_default.php");
  273. }
  274. if ($action == "new") {
  275. require_once(R_P.'require/postnew.php');
  276. } elseif ($action == "reply" || $action == "quote") {
  277. require_once(R_P.'require/postreply.php');
  278. } elseif ($action == "modify") {
  279. require_once(R_P.'require/postmodify.php');
  280. } else {
  281. Showmsg('undefined_action');
  282. }
  283. ?>