PageRenderTime 55ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/source/module/forum/forum_ajax.php

https://github.com/kuaileshike/upload
PHP | 665 lines | 628 code | 31 blank | 6 comment | 124 complexity | 32bd52aaa69f3b3feed26c337d45da45 MD5 | raw file
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: forum_ajax.php 30465 2012-05-30 04:10:03Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. define('NOROBOT', TRUE);
  12. if($_GET['action'] == 'checkusername') {
  13. $username = trim($_GET['username']);
  14. $usernamelen = dstrlen($username);
  15. if($usernamelen < 3) {
  16. showmessage('profile_username_tooshort', '', array(), array('handle' => false));
  17. } elseif($usernamelen > 15) {
  18. showmessage('profile_username_toolong', '', array(), array('handle' => false));
  19. }
  20. loaducenter();
  21. $ucresult = uc_user_checkname($username);
  22. if($ucresult == -1) {
  23. showmessage('profile_username_illegal', '', array(), array('handle' => false));
  24. } elseif($ucresult == -2) {
  25. showmessage('profile_username_protect', '', array(), array('handle' => false));
  26. } elseif($ucresult == -3) {
  27. if(C::t('common_member')->fetch_by_username($username) || C::t('common_member_archive')->fetch_by_username($username)) {
  28. showmessage('register_check_found', '', array(), array('handle' => false));
  29. } else {
  30. showmessage('register_activation', '', array(), array('handle' => false));
  31. }
  32. }
  33. $censorexp = '/^('.str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote(($_G['setting']['censoruser'] = trim($_G['setting']['censoruser'])), '/')).')$/i';
  34. if($_G['setting']['censoruser'] && @preg_match($censorexp, $username)) {
  35. showmessage('profile_username_protect', '', array(), array('handle' => false));
  36. }
  37. } elseif($_GET['action'] == 'checkemail') {
  38. require_once libfile('function/member');
  39. checkemail($_GET['email']);
  40. } elseif($_GET['action'] == 'checkinvitecode') {
  41. $invitecode = trim($_GET['invitecode']);
  42. if(!$invitecode) {
  43. showmessage('no_invitation_code', '', array(), array('handle' => false));
  44. }
  45. $result = array();
  46. if($invite = C::t('common_invite')->fetch_by_code($invitecode)) {
  47. if(empty($invite['fuid']) && (empty($invite['endtime']) || $_G['timestamp'] < $invite['endtime'])) {
  48. $result['uid'] = $invite['uid'];
  49. $result['id'] = $invite['id'];
  50. $result['appid'] = $invite['appid'];
  51. }
  52. }
  53. if(empty($result)) {
  54. showmessage('wrong_invitation_code', '', array(), array('handle' => false));
  55. }
  56. } elseif($_GET['action'] == 'checkuserexists') {
  57. if(C::t('common_member')->fetch_by_username(trim($_GET['username'])) || C::t('common_member_archive')->fetch_by_username(trim($_GET['username']))) {
  58. showmessage('<img src="'.$_G['style']['imgdir'].'/check_right.gif" width="13" height="13">', '', array(), array('msgtype' => 3));
  59. } else {
  60. showmessage('username_nonexistence', '', array(), array('msgtype' => 3));
  61. }
  62. } elseif($_GET['action'] == 'attachlist') {
  63. require_once libfile('function/post');
  64. loadcache('groupreadaccess');
  65. $attachlist = getattach($_GET['pid'], intval($_GET['posttime']), $_GET['aids']);
  66. $attachlist = $attachlist['attachs']['unused'];
  67. $_G['group']['maxprice'] = isset($_G['setting']['extcredits'][$_G['setting']['creditstrans']]) ? $_G['group']['maxprice'] : 0;
  68. include template('common/header_ajax');
  69. include template('forum/ajax_attachlist');
  70. include template('common/footer_ajax');
  71. dexit();
  72. } elseif($_GET['action'] == 'imagelist') {
  73. require_once libfile('function/post');
  74. $attachlist = getattach($_GET['pid'], intval($_GET['posttime']), $_GET['aids']);
  75. $imagelist = $attachlist['imgattachs']['unused'];
  76. include template('common/header_ajax');
  77. include template('forum/ajax_imagelist');
  78. include template('common/footer_ajax');
  79. dexit();
  80. } elseif($_GET['action'] == 'get_rushreply_membernum') {
  81. $tid = intval($_GET['tid']);
  82. if($tid) {
  83. $membernum = C::t('forum_post')->count_author_by_tid($tid);
  84. showmessage('thread_reshreply_membernum', '', array('membernum' => intval($membernum - 1)), array('alert' => 'info'));
  85. }
  86. dexit();
  87. } elseif($_GET['action'] == 'deleteattach') {
  88. $count = 0;
  89. if($_GET['aids']) {
  90. foreach($_GET['aids'] as $aid) {
  91. $attach = C::t('forum_attachment_n')->fetch('aid:'.$aid, $aid);
  92. if($attach && ($attach['pid'] && $attach['pid'] == $_GET['pid'] && $_G['uid'] == $attach['uid'])) {
  93. updatecreditbyaction('postattach', $attach['uid'], array(), '', -1, 1, $_G['fid']);
  94. }
  95. if($attach && ($attach['pid'] && $attach['pid'] == $_GET['pid'] && $_G['uid'] == $attach['uid'] || $_G['forum']['ismoderator'] || !$attach['pid'] && $_G['uid'] == $attach['uid'])) {
  96. C::t('forum_attachment_n')->delete('aid:'.$aid, $aid);
  97. C::t('forum_attachment')->delete($aid);
  98. dunlink($attach);
  99. $count++;
  100. }
  101. }
  102. }
  103. include template('common/header_ajax');
  104. echo $count;
  105. include template('common/footer_ajax');
  106. dexit();
  107. } elseif($_GET['action'] == 'secondgroup') {
  108. require_once libfile('function/group');
  109. $groupselect = get_groupselect($_GET['fupid'], $_GET['groupid']);
  110. include template('common/header_ajax');
  111. include template('forum/ajax_secondgroup');
  112. include template('common/footer_ajax');
  113. dexit();
  114. } elseif($_GET['action'] == 'displaysearch_adv') {
  115. $display = $_GET['display'] == 1 ? 1 : '';
  116. dsetcookie('displaysearch_adv', $display);
  117. } elseif($_GET['action'] == 'checkgroupname') {
  118. $groupname = trim($_GET['groupname']);
  119. if(empty($groupname)) {
  120. showmessage('group_name_empty', '', array(), array('msgtype' => 3));
  121. }
  122. $tmpname = cutstr($groupname, 20, '');
  123. if($tmpname != $groupname) {
  124. showmessage('group_name_oversize', '', array(), array('msgtype' => 3));
  125. }
  126. if(C::t('forum_forum')->fetch_fid_by_name($groupname)) {
  127. showmessage('group_name_exist', '', array(), array('msgtype' => 3));
  128. }
  129. showmessage('', '', array(), array('msgtype' => 3));
  130. include template('common/header_ajax');
  131. include template('common/footer_ajax');
  132. dexit();
  133. } elseif($_GET['action'] == 'getthreadtypes') {
  134. include template('common/header_ajax');
  135. if(empty($_GET['selectname'])) $_GET['selectname'] = 'threadtypeid';
  136. echo '<select name="'.$_GET['selectname'].'">';
  137. if(!empty($_G['forum']['threadtypes']['types'])) {
  138. if(!$_G['forum']['threadtypes']['required']) {
  139. echo '<option value="0"></option>';
  140. }
  141. foreach($_G['forum']['threadtypes']['types'] as $typeid => $typename) {
  142. if($_G['forum']['threadtypes']['moderators'][$typeid] && $_G['forum'] && !$_G['forum']['ismoderator']) {
  143. continue;
  144. }
  145. echo '<option value="'.$typeid.'">'.$typename.'</option>';
  146. }
  147. } else {
  148. echo '<option value="0" /></option>';
  149. }
  150. echo '</select>';
  151. include template('common/footer_ajax');
  152. } elseif($_GET['action'] == 'getimage') {
  153. $_GET['aid'] = intval($_GET['aid']);
  154. $image = C::t('forum_attachment_n')->fetch('aid:'.$_GET['aid'], $_GET['aid'], 1);
  155. include template('common/header_ajax');
  156. if($image['aid']) {
  157. echo '<img src="'.getforumimg($image['aid'], 1, 300, 300, 'fixnone').'" id="image_'.$image['aid'].'" onclick="insertAttachimgTag(\''.$image['aid'].'\')" width="'.($image['width'] < 110 ? $image['width'] : 110).'" cwidth="'.($image['width'] < 300 ? $image['width'] : 300).'" />';
  158. }
  159. include template('common/footer_ajax');
  160. dexit();
  161. } elseif($_GET['action'] == 'setthreadcover') {
  162. $aid = intval($_GET['aid']);
  163. $imgurl = $_GET['imgurl'];
  164. require_once libfile('function/post');
  165. if($_G['forum'] && ($aid || $imgurl)) {
  166. if($imgurl) {
  167. $tid = intval($_GET['tid']);
  168. $pid = intval($_GET['pid']);
  169. } else {
  170. $threadimage = C::t('forum_attachment_n')->fetch('aid:'.$aid, $aid);
  171. $tid = $threadimage['tid'];
  172. $pid = $threadimage['pid'];
  173. }
  174. if($tid && $pid) {
  175. $thread =get_thread_by_tid($tid);
  176. } else {
  177. $thread = array();
  178. }
  179. if(empty($thread) || (!$_G['forum']['ismoderator'] && $_G['uid'] != $thread['authorid'])) {
  180. if($_GET['newthread']) {
  181. showmessage('set_cover_faild', '', array(), array('msgtype' => 3));
  182. } else {
  183. showmessage('set_cover_faild', '', array(), array('closetime' => 3));
  184. }
  185. }
  186. if(setthreadcover($pid, $tid, $aid, 0, $imgurl)) {
  187. if(empty($imgurl)) {
  188. C::t('forum_threadimage')->delete_by_tid($threadimage['tid']);
  189. C::t('forum_threadimage')->insert(array(
  190. 'tid' => $threadimage['tid'],
  191. 'attachment' => $threadimage['attachment'],
  192. 'remote' => $threadimage['remote'],
  193. ));
  194. }
  195. if($_GET['newthread']) {
  196. showmessage('set_cover_succeed', '', array(), array('msgtype' => 3));
  197. } else {
  198. showmessage('set_cover_succeed', '', array(), array('alert' => 'right', 'closetime' => 1));
  199. }
  200. }
  201. }
  202. if($_GET['newthread']) {
  203. showmessage('set_cover_faild', '', array(), array('msgtype' => 3));
  204. } else {
  205. showmessage('set_cover_faild', '', array(), array('closetime' => 3));
  206. }
  207. } elseif($_GET['action'] == 'updateattachlimit') {
  208. $_G['forum']['allowpostattach'] = isset($_G['forum']['allowpostattach']) ? $_G['forum']['allowpostattach'] : '';
  209. $_G['group']['allowpostattach'] = $_G['forum']['allowpostattach'] != -1 && ($_G['forum']['allowpostattach'] == 1 || (!$_G['forum']['postattachperm'] && $_G['group']['allowpostattach']) || ($_G['forum']['postattachperm'] && forumperm($_G['forum']['postattachperm'])));
  210. $_G['forum']['allowpostimage'] = isset($_G['forum']['allowpostimage']) ? $_G['forum']['allowpostimage'] : '';
  211. $_G['group']['allowpostimage'] = $_G['forum']['allowpostimage'] != -1 && ($_G['forum']['allowpostimage'] == 1 || (!$_G['forum']['postimageperm'] && $_G['group']['allowpostimage']) || ($_G['forum']['postimageperm'] && forumperm($_G['forum']['postimageperm'])));
  212. $allowuploadnum = $allowuploadtoday = TRUE;
  213. if($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) {
  214. if($_G['group']['maxattachnum']) {
  215. $allowuploadnum = $_G['group']['maxattachnum'] - getuserprofile('todayattachs');
  216. $allowuploadnum = $allowuploadnum < 0 ? 0 : $allowuploadnum;
  217. if(!$allowuploadnum) {
  218. $allowuploadtoday = false;
  219. }
  220. }
  221. if($_G['group']['maxsizeperday']) {
  222. $allowuploadsize = $_G['group']['maxsizeperday'] - getuserprofile('todayattachsize');
  223. $allowuploadsize = $allowuploadsize < 0 ? 0 : $allowuploadsize;
  224. if(!$allowuploadsize) {
  225. $allowuploadtoday = false;
  226. }
  227. $allowuploadsize = $allowuploadsize / 1048576 >= 1 ? round(($allowuploadsize / 1048576), 1).'MB' : round(($allowuploadsize / 1024)).'KB';
  228. }
  229. }
  230. include template('common/header_ajax');
  231. include template('forum/post_attachlimit');
  232. include template('common/footer_ajax');
  233. exit;
  234. } elseif($_GET['action'] == 'forumchecknew' && !empty($_GET['fid']) && !empty($_GET['time'])) {
  235. $fid = intval($_GET['fid']);
  236. $time = intval($_GET['time']);
  237. if(!$_GET['uncheck']) {
  238. $foruminfo = C::t('forum_forum')->fetch($fid);
  239. $lastpost_str = $foruminfo['lastpost'];
  240. if($lastpost_str) {
  241. $lastpost = explode("\t", $lastpost_str);
  242. unset($lastpost_str);
  243. }
  244. include template('common/header_ajax');
  245. echo $lastpost['2'] > $time ? 1 : 0 ;
  246. include template('common/footer_ajax');
  247. exit;
  248. } else {
  249. $query = C::t('forum_forumfield')->fetch($fid);
  250. $forum_field['threadtypes'] = dunserialize($query['threadtypes']);
  251. $forum_field['threadsorts'] = dunserialize($query['threadsorts']);
  252. unset($query);
  253. $forum_field = daddslashes($forum_field);
  254. $todaytime = strtotime(dgmdate(TIMESTAMP, 'Ymd'));
  255. foreach(C::t('forum_thread')->fetch_all_by_fid_lastpost($fid, $time, TIMESTAMP) as $thread) {
  256. list($thread['subject'], $thread['author'], $thread['lastposter']) = daddslashes(array($thread['subject'], $thread['author'], $thread['lastposter']));
  257. $thread['dateline'] = $thread['dateline'] > $todaytime ? "<span class=\"xi1\">".dgmdate($thread['dateline'], 'd')."</span>" : "<span>".dgmdate($thread['dateline'], 'd')."</span>";
  258. $thread['lastpost'] = dgmdate($thread['lastpost']);
  259. if($forum_field['threadtypes']['prefix']) {
  260. if($forum_field['threadtypes']['prefix'] == 1) {
  261. $thread['threadtype'] = $forum_field['threadtypes']['types'][$thread['typeid']] ? '<em>[<a href="forum.php?mod=forumdisplay&fid='.$fid.'&filter=typeid&typeid='.$thread['typeid'].'">'.$forum_field['threadtypes']['types'][$thread['typeid']].'</a>]</em> ' : '' ;
  262. } elseif($forum_field['threadtypes']['prefix'] == 2) {
  263. $thread['threadtype'] = $forum_field['threadtypes']['icons'][$thread['typeid']] ? '<em><a href="forum.php?mod=forumdisplay&fid='.$fid.'&filter=typeid&typeid='.$thread['typeid'].'"><img src="'.$forum_field['threadtypes']['icons'][$thread['typeid']].'"/></a></em> ' : '' ;
  264. }
  265. }
  266. if($forum_field['threadsorts']['prefix']) {
  267. $thread['threadsort'] = $forum_field['threadsorts']['types'][$thread['sortid']] ? '<em>[<a href="forum.php?mod=forumdisplay&fid='.$fid.'&filter=sortid&typeid='.$thread['sortid'].'">'.$forum_field['threadsorts']['types'][$thread['sortid']].'</a>]</em>' : '' ;
  268. }
  269. if(in_array('forum_viewthread', $_G['setting']['rewritestatus'])) {
  270. $thread['threadurl'] = '<a href="'.rewriteoutput('forum_viewthread', 1, '', $thread['tid'], 1, '', '').'" class="xst" onclick="atarget(this)">'.$thread['subject'].'</a>';
  271. } else {
  272. $thread['threadurl'] = '<a href="forum.php?mod=viewthread&amp;tid='.$thread['tid'].'" class="xst" onclick="atarget(this)">'.$thread['subject'].'</a>';
  273. }
  274. $thread['threadurl'] = $thread['threadtype'].$thread['threadsort'].$thread['threadurl'];
  275. if(in_array('home_space', $_G['setting']['rewritestatus'])) {
  276. $thread['authorurl'] = '<a href="'.rewriteoutput('home_space', 1, '', $thread['authorid'], '', '').'">'.$thread['author'].'</a>';
  277. $thread['lastposterurl'] = '<a href="'.rewriteoutput('home_space', 1, '', '', rawurlencode($thread['lastposter']), '').'">'.$thread['lastposter'].'</a>';
  278. } else {
  279. $thread['authorurl'] = '<a href="home.php?mod=space&uid='.$thread['authorid'].'">'.$thread['author'].'</a>';
  280. $thread['lastposterurl'] = '<a href="home.php?mod=space&username='.rawurlencode($thread['lastposter']).'">'.$thread['lastposter'].'</a>';
  281. }
  282. $threadlist[] = $thread;
  283. }
  284. if($threadlist) {
  285. krsort($threadlist);
  286. }
  287. include template('forum/ajax_threadlist');
  288. }
  289. } elseif($_GET['action'] == 'downremoteimg') {
  290. $_GET['message'] = str_replace(array("\r", "\n"), array($_GET['wysiwyg'] ? '<br />' : '', "\\n"), $_GET['message']);
  291. preg_match_all("/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]|\[img=\d{1,4}[x|\,]\d{1,4}\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is", $_GET['message'], $image1, PREG_SET_ORDER);
  292. preg_match_all("/\<img.+src=('|\"|)?(.*)(\\1)([\s].*)?\>/ismUe", $_GET['message'], $image2, PREG_SET_ORDER);
  293. $temp = $aids = $existentimg = array();
  294. if(is_array($image1) && !empty($image1)) {
  295. foreach($image1 as $value) {
  296. $temp[] = array(
  297. '0' => $value[0],
  298. '1' => trim(!empty($value[1]) ? $value[1] : $value[2])
  299. );
  300. }
  301. }
  302. if(is_array($image2) && !empty($image2)) {
  303. foreach($image2 as $value) {
  304. $temp[] = array(
  305. '0' => $value[0],
  306. '1' => trim($value[2])
  307. );
  308. }
  309. }
  310. require_once libfile('class/image');
  311. if(is_array($temp) && !empty($temp)) {
  312. $upload = new discuz_upload();
  313. $attachaids = array();
  314. foreach($temp as $value) {
  315. $imageurl = $value[1];
  316. $hash = md5($imageurl);
  317. if(strlen($imageurl)) {
  318. $imagereplace['oldimageurl'][] = $value[0];
  319. if(!isset($existentimg[$hash])) {
  320. $existentimg[$hash] = $imageurl;
  321. $attach['ext'] = $upload->fileext($imageurl);
  322. if(!$upload->is_image_ext($attach['ext'])) {
  323. continue;
  324. }
  325. $content = '';
  326. if(preg_match('/^(http:\/\/|\.)/i', $imageurl)) {
  327. $content = dfsockopen($imageurl);
  328. } elseif(preg_match('/^('.preg_quote(getglobal('setting/attachurl'), '/').')/i', $imageurl)) {
  329. $imagereplace['newimageurl'][] = $value[0];
  330. }
  331. if(empty($content)) continue;
  332. $patharr = explode('/', $imageurl);
  333. $attach['name'] = trim($patharr[count($patharr)-1]);
  334. $attach['thumb'] = '';
  335. $attach['isimage'] = $upload -> is_image_ext($attach['ext']);
  336. $attach['extension'] = $upload -> get_target_extension($attach['ext']);
  337. $attach['attachdir'] = $upload -> get_target_dir('forum');
  338. $attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('forum').'.'.$attach['extension'];
  339. $attach['target'] = getglobal('setting/attachdir').'./forum/'.$attach['attachment'];
  340. if(!@$fp = fopen($attach['target'], 'wb')) {
  341. continue;
  342. } else {
  343. flock($fp, 2);
  344. fwrite($fp, $content);
  345. fclose($fp);
  346. }
  347. if(!$upload->get_image_info($attach['target'])) {
  348. @unlink($attach['target']);
  349. continue;
  350. }
  351. $attach['size'] = filesize($attach['target']);
  352. $upload->attach = $attach;
  353. $thumb = $width = 0;
  354. if($upload->attach['isimage']) {
  355. if($_G['setting']['thumbsource'] && $_G['setting']['sourcewidth'] && $_G['setting']['sourceheight']) {
  356. $image = new image();
  357. $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['sourcewidth'], $_G['setting']['sourceheight'], 1, 1) ? 1 : 0;
  358. $width = $image->imginfo['width'];
  359. $upload->attach['size'] = $image->imginfo['size'];
  360. }
  361. if($_G['setting']['thumbstatus']) {
  362. $image = new image();
  363. $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], 0) ? 1 : 0;
  364. $width = $image->imginfo['width'];
  365. }
  366. if($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) {
  367. list($width) = @getimagesize($upload->attach['target']);
  368. }
  369. if($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
  370. $image = new image();
  371. $image->Watermark($attach['target'], '', 'forum');
  372. $upload->attach['size'] = $image->imginfo['size'];
  373. }
  374. }
  375. $aids[] = $aid = getattachnewaid();
  376. $setarr = array(
  377. 'aid' => $aid,
  378. 'dateline' => $_G['timestamp'],
  379. 'filename' => $upload->attach['name'],
  380. 'filesize' => $upload->attach['size'],
  381. 'attachment' => $upload->attach['attachment'],
  382. 'isimage' => $upload->attach['isimage'],
  383. 'uid' => $_G['uid'],
  384. 'thumb' => $thumb,
  385. 'remote' => '0',
  386. 'width' => $width
  387. );
  388. C::t("forum_attachment_unused")->insert($setarr);
  389. $attachaids[$hash] = $imagereplace['newimageurl'][] = '[attachimg]'.$aid.'[/attachimg]';
  390. } else {
  391. $imagereplace['newimageurl'][] = $attachaids[$hash];
  392. }
  393. }
  394. }
  395. if(!empty($aids)) {
  396. require_once libfile('function/post');
  397. }
  398. $_GET['message'] = str_replace($imagereplace['oldimageurl'], $imagereplace['newimageurl'], $_GET['message']);
  399. $_GET['message'] = addcslashes($_GET['message'], '/"');
  400. }
  401. print <<<EOF
  402. <script type="text/javascript">
  403. parent.ATTACHORIMAGE = 1;
  404. parent.updateDownImageList('$_GET[message]');
  405. </script>
  406. EOF;
  407. dexit();
  408. } elseif($_GET['action'] == 'exif') {
  409. $exif = C::t('forum_attachment_exif')->fetch($_GET['aid']);
  410. $s = $exif['exif'];
  411. if(!$s) {
  412. require_once libfile('function/attachment');
  413. $s = getattachexif($_GET['aid']);
  414. C::t('forum_attachment_exif')->insert($_GET['aid'], $s);
  415. }
  416. include template('common/header_ajax');
  417. echo $s;
  418. include template('common/footer_ajax');
  419. exit;
  420. } elseif($_GET['action'] == 'getthreadclass') {
  421. $fid = intval($_GET['fid']);
  422. $threadclass = '';
  423. if($fid) {
  424. $option = array();
  425. $forumfield = C::t('forum_forumfield')->fetch($fid);
  426. if(!empty($forumfield['threadtypes'])) {
  427. foreach(C::t('forum_threadclass')->fetch_all_by_fid($fid) as $tc) {
  428. $option[] = '<option value="'.$tc['typeid'].'">'.$tc['name'].'</option>';
  429. }
  430. if(!empty($option)) {
  431. $threadclass .= '<option value="">'.lang('forum/template', 'modcp_select_threadclass').'</option>';
  432. $threadclass .= implode('', $option);
  433. }
  434. }
  435. }
  436. if(!empty($threadclass)) {
  437. $threadclass = '<select name="typeid" id="typeid" width="168" class="ps">'.$threadclass.'</select>';
  438. }
  439. include template('common/header_ajax');
  440. echo $threadclass;
  441. include template('common/footer_ajax');
  442. exit;
  443. } elseif($_GET['action'] == 'forumjump') {
  444. require_once libfile('function/forumlist');
  445. $favforums = C::t('home_favorite')->fetch_all_by_uid_idtype($_G['uid'], 'fid');
  446. $visitedforums = array();
  447. if($_G['cookie']['visitedfid']) {
  448. loadcache('forums');
  449. foreach(explode('D', $_G['cookie']['visitedfid']) as $fid) {
  450. $visitedforums[$fid] = $_G['cache']['forums'][$fid]['name'];
  451. }
  452. }
  453. $forumlist = forumselect(FALSE, 1);
  454. include template('forum/ajax_forumlist');
  455. } elseif($_GET['action'] == 'quickreply') {
  456. $tid = intval($_GET['tid']);
  457. $fid = intval($_GET['fid']);
  458. $list = C::t('forum_post')->fetch_all_by_tid('tid:'.$tid, $tid, true, 'DESC', 0, 10, null, 0);
  459. loadcache('smilies');
  460. foreach($list as $pid => $post) {
  461. if($post['first']) {
  462. unset($list[$pid]);
  463. } else {
  464. $post['message'] = preg_replace($_G['cache']['smilies']['searcharray'], '', $post['message']);
  465. $post['message'] = preg_replace("/\{\:soso_((e\d+)|(_\d+_\d))\:\}/e", '', $post['message']);
  466. $list[$pid]['message'] = cutstr(preg_replace("/\[.+?\]/ies", '', dhtmlspecialchars($post['message'])), 300) ;
  467. }
  468. }
  469. krsort($list);
  470. $seccodecheck = ($_G['setting']['seccodestatus'] & 4) && (!$_G['setting']['seccodedata']['minposts'] || getuserprofile('posts') < $_G['setting']['seccodedata']['minposts']);
  471. $secqaacheck = $_G['setting']['secqaa']['status'] & 2 && (!$_G['setting']['secqaa']['minposts'] || getuserprofile('posts') < $_G['setting']['secqaa']['minposts']);
  472. include template('forum/ajax_quickreply');
  473. } elseif($_GET['action'] == 'getpost') {
  474. $tid = intval($_GET['tid']);
  475. $fid = intval($_GET['fid']);
  476. $pid = intval($_GET['pid']);
  477. $thread = C::t('forum_thread')->fetch($tid);
  478. $post = C::t('forum_post')->fetch($thread['posttableid'], $pid);
  479. include template('forum/ajax_followpost');
  480. } elseif($_GET['action'] == 'quickclear') {
  481. $uid = intval($_GET['uid']);
  482. if($_G['adminid'] != 1) {
  483. showmessage('quickclear_noperm');
  484. }
  485. include_once libfile('function/misc');
  486. include_once libfile('function/member');
  487. if(!submitcheck('qclearsubmit')) {
  488. $crimenum_avatar = crime('getcount', $uid, 'crime_avatar');
  489. $crimenum_sightml = crime('getcount', $uid, 'crime_sightml');
  490. $crimenum_customstatus = crime('getcount', $uid, 'crime_customstatus');
  491. $crimeauthor = getuserbyuid($uid);
  492. $crimeauthor = $crimeauthor['username'];
  493. include template('forum/ajax');
  494. } else {
  495. if(empty($_GET['operations'])) {
  496. showmessage('quickclear_need_operation');
  497. }
  498. $reason = checkreasonpm();
  499. $allowop = array('avatar', 'sightml', 'customstatus');
  500. $cleartype = array();
  501. if(in_array('avatar', $_GET['operations'])) {
  502. C::t('common_member')->update($uid, array('avatarstatus'=>0));
  503. loaducenter();
  504. uc_user_deleteavatar($uid);
  505. $cleartype[] = lang('forum/misc', 'avatar');
  506. crime('recordaction', $uid, 'crime_avatar', lang('forum/misc', 'crime_reason', array('reason' => $reason)));
  507. }
  508. if(in_array('sightml', $_GET['operations'])) {
  509. C::t('common_member_field_forum')->update($uid, array('sightml' => ''), 'UNBUFFERED');
  510. $cleartype[] = lang('forum/misc', 'signature');
  511. crime('recordaction', $uid, 'crime_sightml', lang('forum/misc', 'crime_reason', array('reason' => $reason)));
  512. }
  513. if(in_array('customstatus', $_GET['operations'])) {
  514. C::t('common_member_field_forum')->update($uid, array('customstatus' => ''), 'UNBUFFERED');
  515. $cleartype[] = lang('forum/misc', 'custom_title');
  516. crime('recordaction', $uid, 'crime_customstatus', lang('forum/misc', 'crime_reason', array('reason' => $reason)));
  517. }
  518. if(($_G['group']['reasonpm'] == 2 || $_G['group']['reasonpm'] == 3) || !empty($_GET['sendreasonpm'])) {
  519. sendreasonpm(array('authorid' => $uid), 'reason_quickclear', array(
  520. 'cleartype' => implode(',', $cleartype),
  521. 'reason' => $reason,
  522. 'from_id' => 0,
  523. 'from_idtype' => 'quickclear'
  524. ));
  525. }
  526. showmessage('quickclear_success', $_POST['redirect'], array(), array('showdialog'=>1, 'closetime' => true, 'msgtype' => 2, 'locationtime' => 1));
  527. }
  528. } elseif($_GET['action'] == 'getpostfeed') {
  529. $tid = intval($_GET['tid']);
  530. $pid = intval($_GET['pid']);
  531. $flag = intval($_GET['flag']);
  532. $feed = $thread = array();
  533. if($tid) {
  534. $thread = C::t('forum_thread')->fetch($tid);
  535. if($flag) {
  536. $post = C::t('forum_post')->fetch($thread['posttableid'], $pid);
  537. require_once libfile('function/discuzcode');
  538. require_once libfile('function/followcode');
  539. $post['message'] = followcode($post['message'], $tid, $pid);
  540. } else {
  541. if(!isset($_G['cache']['forums'])) {
  542. loadcache('forums');
  543. }
  544. $feedid = intval($_GET['feedid']);
  545. $feed = C::t('forum_threadpreview')->fetch($tid);
  546. if($feedid) {
  547. $feed = array_merge($feed, C::t('home_follow_feed')->fetch_by_feedid($feedid));
  548. }
  549. $post['message'] = $feed['content'];
  550. }
  551. }
  552. include template('forum/ajax_followpost');
  553. } elseif($_GET['action'] == 'setnav') {
  554. if($_G['adminid'] != 1) {
  555. showmessage('quickclear_noperm');
  556. }
  557. $allowfuntype = array('portal', 'group', 'follow', 'collection', 'guide', 'feed', 'blog', 'doing', 'album', 'share', 'wall', 'homepage', 'ranklist');
  558. $type = in_array($_GET['type'], $allowfuntype) ? trim($_GET['type']) : '';
  559. $do = in_array($_GET['do'], array('open', 'close')) ? $_GET['do'] : 'close';
  560. if(!submitcheck('funcsubmit')) {
  561. $navtitle = lang('spacecp', $do == 'open' ? 'select_the_navigation_position' : 'close_module', array('type' => lang('spacecp', $type)));
  562. $closeprompt = lang('spacecp', 'close_module', array('type' => lang('spacecp', $type)));
  563. include template('forum/ajax');
  564. } else {
  565. if(!empty($type)) {
  566. $funkey = $type.'status';
  567. $funstatus = $do == 'open' ? 1 : 0;
  568. if($type != 'homepage') {
  569. $identifier = array('portal' => 1, 'group' => 3, 'feed' => 4, 'ranklist' => 8, 'follow' => 9, 'guide' => 10, 'collection' => 11, 'blog' => 12, 'album' => 13, 'share' => 14, 'doing' => 15);
  570. $navdata = array('available' => -1);
  571. $navtype = $do == 'open' ? array() : array(0, 3);
  572. if(in_array($type, array('blog', 'album', 'share', 'doing', 'follow'))) {
  573. $navtype[] = 2;
  574. }
  575. if($do == 'open') {
  576. if($_GET['location']['header']) {
  577. $navtype[] = 0;
  578. $navdata['available'] = 1;
  579. }
  580. if($_GET['location']['quick']) {
  581. $navtype[] = 3;
  582. $navdata['available'] = 1;
  583. }
  584. $navdata['available'] = $navdata['available'] == 1 ? 1 : 0;
  585. if(empty($_GET['location']['header']) || empty($_GET['location']['quick'])) {
  586. C::t('common_nav')->update_by_navtype_type_identifier(array(0, 2, 3), 0, array("$type", "$identifier[$type]"), array('available' => 0));
  587. }
  588. }
  589. if($navtype) {
  590. C::t('common_nav')->update_by_navtype_type_identifier($navtype, 0, array("$type", "$identifier[$type]"), $navdata);
  591. if(in_array($type, array('blog', 'album', 'share', 'doing', 'follow')) && !$navdata['available']) {
  592. C::t('common_nav')->update_by_navtype_type_identifier(array(2), 0, array("$type"), array('available' => 1));
  593. }
  594. }
  595. }
  596. C::t('common_setting')->update($funkey, $funstatus);
  597. $setting[$funkey] = $funstatus;
  598. include libfile('function/cache');
  599. updatecache('setting');
  600. }
  601. showmessage('do_success', dreferer(), array(), array('header'=>true));
  602. }
  603. exit;
  604. }
  605. function tmpiconv($s, $d, $str) {
  606. if(is_array($str)) {
  607. foreach($str as $k => $v) {
  608. $str[$k] = tmpiconv($s, $d, $v);
  609. }
  610. } else {
  611. $str = iconv($s, $d, $str);
  612. }
  613. return $str;
  614. }
  615. function modifynav($type, $flag) {
  616. }
  617. showmessage('succeed', '', array(), array('handle' => false));
  618. ?>