PageRenderTime 49ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/source/module/forum/forum_ajax.php

https://github.com/jinbo51/DiscuzX
PHP | 695 lines | 657 code | 32 blank | 6 comment | 139 complexity | 5a33277ee034e211275e4421636a43dc MD5 | raw file
Possible License(s): BSD-3-Clause
  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 33457 2013-06-19 04:15:44Z jeffjzhang $
  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. $_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
  250. $query = C::t('forum_forumfield')->fetch($fid);
  251. $forum_field['threadtypes'] = dunserialize($query['threadtypes']);
  252. $forum_field['threadsorts'] = dunserialize($query['threadsorts']);
  253. unset($query);
  254. $forum_field = daddslashes($forum_field);
  255. $todaytime = strtotime(dgmdate(TIMESTAMP, 'Ymd'));
  256. foreach(C::t('forum_thread')->fetch_all_by_fid_lastpost($fid, $time, TIMESTAMP) as $thread) {
  257. $thread['icontid'] = $thread['forumstick'] || !$thread['moved'] && $thread['isgroup'] != 1 ? $thread['tid'] : $thread['closed'];
  258. if(!$thread['forumstick'] && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])) {
  259. $thread['icontid'] = $thread['closed'] > 1 ? $thread['closed'] : $thread['tid'];
  260. }
  261. list($thread['subject'], $thread['author'], $thread['lastposter']) = daddslashes(array($thread['subject'], $thread['author'], $thread['lastposter']));
  262. $thread['dateline'] = $thread['dateline'] > $todaytime ? "<span class=\"xi1\">".dgmdate($thread['dateline'], 'd')."</span>" : "<span>".dgmdate($thread['dateline'], 'd')."</span>";
  263. $thread['lastpost'] = dgmdate($thread['lastpost']);
  264. if($forum_field['threadtypes']['prefix']) {
  265. if($forum_field['threadtypes']['prefix'] == 1) {
  266. $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> ' : '' ;
  267. } elseif($forum_field['threadtypes']['prefix'] == 2) {
  268. $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> ' : '' ;
  269. }
  270. }
  271. if($forum_field['threadsorts']['prefix']) {
  272. $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>' : '' ;
  273. }
  274. if($thread['highlight']) {
  275. $string = sprintf('%02d', $thread['highlight']);
  276. $stylestr = sprintf('%03b', $string[0]);
  277. $thread['highlight'] = ' style="';
  278. $thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  279. $thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  280. $thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  281. $thread['highlight'] .= $string[1] ? 'color: '.$_G['forum_colorarray'][$string[1]].';' : '';
  282. if($thread['bgcolor']) {
  283. $thread['highlight'] .= "background-color: $thread[bgcolor];";
  284. }
  285. $thread['highlight'] .= '"';
  286. } else {
  287. $thread['highlight'] = '';
  288. }
  289. $target = $thread['isgroup'] == 1 || $thread['forumstick'] ? ' target="_blank"' : ' onclick="atarget(this)"';
  290. if(in_array('forum_viewthread', $_G['setting']['rewritestatus'])) {
  291. $thread['threadurl'] = '<a href="'.rewriteoutput('forum_viewthread', 1, '', $thread['tid'], 1, '', '').'"'.$thread['highlight'].$target.'class="s xst">'.$thread['subject'].'</a>';
  292. } else {
  293. $thread['threadurl'] = '<a href="forum.php?mod=viewthread&amp;tid='.$thread['tid'].'"'.$thread['highlight'].$target.'class="s xst">'.$thread['subject'].'</a>';
  294. }
  295. if(in_array($thread['displayorder'], array(1, 2, 3, 4))) {
  296. $thread['id'] = 'stickthread_'.$thread['tid'];
  297. } else {
  298. $thread['id'] = 'normalthread_'.$thread['tid'];
  299. }
  300. $thread['threadurl'] = $thread['threadtype'].$thread['threadsort'].$thread['threadurl'];
  301. if(in_array('home_space', $_G['setting']['rewritestatus'])) {
  302. $thread['authorurl'] = '<a href="'.rewriteoutput('home_space', 1, '', $thread['authorid'], '', '').'">'.$thread['author'].'</a>';
  303. $thread['lastposterurl'] = '<a href="'.rewriteoutput('home_space', 1, '', '', rawurlencode($thread['lastposter']), '').'">'.$thread['lastposter'].'</a>';
  304. } else {
  305. $thread['authorurl'] = '<a href="home.php?mod=space&uid='.$thread['authorid'].'">'.$thread['author'].'</a>';
  306. $thread['lastposterurl'] = '<a href="home.php?mod=space&username='.rawurlencode($thread['lastposter']).'">'.$thread['lastposter'].'</a>';
  307. }
  308. $threadlist[] = $thread;
  309. }
  310. if($threadlist) {
  311. krsort($threadlist);
  312. }
  313. include template('forum/ajax_threadlist');
  314. }
  315. } elseif($_GET['action'] == 'downremoteimg') {
  316. $_GET['message'] = str_replace(array("\r", "\n"), array($_GET['wysiwyg'] ? '<br />' : '', "\\n"), $_GET['message']);
  317. 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);
  318. preg_match_all("/\<img.+src=('|\"|)?(.*)(\\1)([\s].*)?\>/ismUe", $_GET['message'], $image2, PREG_SET_ORDER);
  319. $temp = $aids = $existentimg = array();
  320. if(is_array($image1) && !empty($image1)) {
  321. foreach($image1 as $value) {
  322. $temp[] = array(
  323. '0' => $value[0],
  324. '1' => trim(!empty($value[1]) ? $value[1] : $value[2])
  325. );
  326. }
  327. }
  328. if(is_array($image2) && !empty($image2)) {
  329. foreach($image2 as $value) {
  330. $temp[] = array(
  331. '0' => $value[0],
  332. '1' => trim($value[2])
  333. );
  334. }
  335. }
  336. require_once libfile('class/image');
  337. if(is_array($temp) && !empty($temp)) {
  338. $upload = new discuz_upload();
  339. $attachaids = array();
  340. foreach($temp as $value) {
  341. $imageurl = $value[1];
  342. $hash = md5($imageurl);
  343. if(strlen($imageurl)) {
  344. $imagereplace['oldimageurl'][] = $value[0];
  345. if(!isset($existentimg[$hash])) {
  346. $existentimg[$hash] = $imageurl;
  347. $attach['ext'] = $upload->fileext($imageurl);
  348. if(!$upload->is_image_ext($attach['ext'])) {
  349. continue;
  350. }
  351. $content = '';
  352. if(preg_match('/^(http:\/\/|\.)/i', $imageurl)) {
  353. $content = dfsockopen($imageurl);
  354. } elseif(preg_match('/^('.preg_quote(getglobal('setting/attachurl'), '/').')/i', $imageurl)) {
  355. $imagereplace['newimageurl'][] = $value[0];
  356. }
  357. if(empty($content)) continue;
  358. $patharr = explode('/', $imageurl);
  359. $attach['name'] = trim($patharr[count($patharr)-1]);
  360. $attach['thumb'] = '';
  361. $attach['isimage'] = $upload -> is_image_ext($attach['ext']);
  362. $attach['extension'] = $upload -> get_target_extension($attach['ext']);
  363. $attach['attachdir'] = $upload -> get_target_dir('forum');
  364. $attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('forum').'.'.$attach['extension'];
  365. $attach['target'] = getglobal('setting/attachdir').'./forum/'.$attach['attachment'];
  366. if(!@$fp = fopen($attach['target'], 'wb')) {
  367. continue;
  368. } else {
  369. flock($fp, 2);
  370. fwrite($fp, $content);
  371. fclose($fp);
  372. }
  373. if(!$upload->get_image_info($attach['target'])) {
  374. @unlink($attach['target']);
  375. continue;
  376. }
  377. $attach['size'] = filesize($attach['target']);
  378. $upload->attach = $attach;
  379. $thumb = $width = 0;
  380. if($upload->attach['isimage']) {
  381. if($_G['setting']['thumbsource'] && $_G['setting']['sourcewidth'] && $_G['setting']['sourceheight']) {
  382. $image = new image();
  383. $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['sourcewidth'], $_G['setting']['sourceheight'], 1, 1) ? 1 : 0;
  384. $width = $image->imginfo['width'];
  385. $upload->attach['size'] = $image->imginfo['size'];
  386. }
  387. if($_G['setting']['thumbstatus']) {
  388. $image = new image();
  389. $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], 0) ? 1 : 0;
  390. $width = $image->imginfo['width'];
  391. }
  392. if($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) {
  393. list($width) = @getimagesize($upload->attach['target']);
  394. }
  395. if($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
  396. $image = new image();
  397. $image->Watermark($attach['target'], '', 'forum');
  398. $upload->attach['size'] = $image->imginfo['size'];
  399. }
  400. }
  401. $aids[] = $aid = getattachnewaid();
  402. $setarr = array(
  403. 'aid' => $aid,
  404. 'dateline' => $_G['timestamp'],
  405. 'filename' => $upload->attach['name'],
  406. 'filesize' => $upload->attach['size'],
  407. 'attachment' => $upload->attach['attachment'],
  408. 'isimage' => $upload->attach['isimage'],
  409. 'uid' => $_G['uid'],
  410. 'thumb' => $thumb,
  411. 'remote' => '0',
  412. 'width' => $width
  413. );
  414. C::t("forum_attachment_unused")->insert($setarr);
  415. $attachaids[$hash] = $imagereplace['newimageurl'][] = '[attachimg]'.$aid.'[/attachimg]';
  416. } else {
  417. $imagereplace['newimageurl'][] = $attachaids[$hash];
  418. }
  419. }
  420. }
  421. if(!empty($aids)) {
  422. require_once libfile('function/post');
  423. }
  424. $_GET['message'] = str_replace($imagereplace['oldimageurl'], $imagereplace['newimageurl'], $_GET['message']);
  425. }
  426. $_GET['message'] = addcslashes($_GET['message'], '/"\'');
  427. print <<<EOF
  428. <script type="text/javascript">
  429. parent.ATTACHORIMAGE = 1;
  430. parent.updateDownImageList('$_GET[message]');
  431. </script>
  432. EOF;
  433. dexit();
  434. } elseif($_GET['action'] == 'exif') {
  435. $exif = C::t('forum_attachment_exif')->fetch($_GET['aid']);
  436. $s = $exif['exif'];
  437. if(!$s) {
  438. require_once libfile('function/attachment');
  439. $s = getattachexif($_GET['aid']);
  440. C::t('forum_attachment_exif')->insert($_GET['aid'], $s);
  441. }
  442. include template('common/header_ajax');
  443. echo $s;
  444. include template('common/footer_ajax');
  445. exit;
  446. } elseif($_GET['action'] == 'getthreadclass') {
  447. $fid = intval($_GET['fid']);
  448. $threadclass = '';
  449. if($fid) {
  450. $option = array();
  451. $forumfield = C::t('forum_forumfield')->fetch($fid);
  452. if(!empty($forumfield['threadtypes'])) {
  453. foreach(C::t('forum_threadclass')->fetch_all_by_fid($fid) as $tc) {
  454. $option[] = '<option value="'.$tc['typeid'].'">'.$tc['name'].'</option>';
  455. }
  456. if(!empty($option)) {
  457. $threadclass .= '<option value="">'.lang('forum/template', 'modcp_select_threadclass').'</option>';
  458. $threadclass .= implode('', $option);
  459. }
  460. }
  461. }
  462. if(!empty($threadclass)) {
  463. $threadclass = '<select name="typeid" id="typeid" width="168" class="ps">'.$threadclass.'</select>';
  464. }
  465. include template('common/header_ajax');
  466. echo $threadclass;
  467. include template('common/footer_ajax');
  468. exit;
  469. } elseif($_GET['action'] == 'forumjump') {
  470. require_once libfile('function/forumlist');
  471. $favforums = C::t('home_favorite')->fetch_all_by_uid_idtype($_G['uid'], 'fid');
  472. $visitedforums = array();
  473. if($_G['cookie']['visitedfid']) {
  474. loadcache('forums');
  475. foreach(explode('D', $_G['cookie']['visitedfid']) as $fid) {
  476. $visitedforums[$fid] = $_G['cache']['forums'][$fid]['name'];
  477. }
  478. }
  479. $forumlist = forumselect(FALSE, 1);
  480. include template('forum/ajax_forumlist');
  481. } elseif($_GET['action'] == 'quickreply') {
  482. $tid = intval($_GET['tid']);
  483. $fid = intval($_GET['fid']);
  484. if($tid) {
  485. $thread = C::t('forum_thread')->fetch($tid);
  486. if($thread && !getstatus($thread['status'], 2)) {
  487. $list = C::t('forum_post')->fetch_all_by_tid('tid:'.$tid, $tid, true, 'DESC', 0, 10, null, 0);
  488. loadcache('smilies');
  489. foreach($list as $pid => $post) {
  490. if($post['first']) {
  491. unset($list[$pid]);
  492. } else {
  493. $post['message'] = preg_replace($_G['cache']['smilies']['searcharray'], '', $post['message']);
  494. $post['message'] = preg_replace("/\{\:soso_((e\d+)|(_\d+_\d))\:\}/e", '', $post['message']);
  495. $list[$pid]['message'] = cutstr(preg_replace("/\[.+?\]/ies", '', dhtmlspecialchars($post['message'])), 300) ;
  496. }
  497. }
  498. krsort($list);
  499. }
  500. }
  501. $seccodecheck = ($_G['setting']['seccodestatus'] & 4) && (!$_G['setting']['seccodedata']['minposts'] || getuserprofile('posts') < $_G['setting']['seccodedata']['minposts']);
  502. $secqaacheck = $_G['setting']['secqaa']['status'] & 2 && (!$_G['setting']['secqaa']['minposts'] || getuserprofile('posts') < $_G['setting']['secqaa']['minposts']);
  503. include template('forum/ajax_quickreply');
  504. } elseif($_GET['action'] == 'getpost') {
  505. $tid = intval($_GET['tid']);
  506. $fid = intval($_GET['fid']);
  507. $pid = intval($_GET['pid']);
  508. $thread = C::t('forum_thread')->fetch($tid);
  509. $post = C::t('forum_post')->fetch($thread['posttableid'], $pid);
  510. include template('forum/ajax_followpost');
  511. } elseif($_GET['action'] == 'quickclear') {
  512. $uid = intval($_GET['uid']);
  513. if($_G['adminid'] != 1) {
  514. showmessage('quickclear_noperm');
  515. }
  516. include_once libfile('function/misc');
  517. include_once libfile('function/member');
  518. if(!submitcheck('qclearsubmit')) {
  519. $crimenum_avatar = crime('getcount', $uid, 'crime_avatar');
  520. $crimenum_sightml = crime('getcount', $uid, 'crime_sightml');
  521. $crimenum_customstatus = crime('getcount', $uid, 'crime_customstatus');
  522. $crimeauthor = getuserbyuid($uid);
  523. $crimeauthor = $crimeauthor['username'];
  524. include template('forum/ajax');
  525. } else {
  526. if(empty($_GET['operations'])) {
  527. showmessage('quickclear_need_operation');
  528. }
  529. $reason = checkreasonpm();
  530. $allowop = array('avatar', 'sightml', 'customstatus');
  531. $cleartype = array();
  532. if(in_array('avatar', $_GET['operations'])) {
  533. C::t('common_member')->update($uid, array('avatarstatus'=>0));
  534. loaducenter();
  535. uc_user_deleteavatar($uid);
  536. $cleartype[] = lang('forum/misc', 'avatar');
  537. crime('recordaction', $uid, 'crime_avatar', lang('forum/misc', 'crime_reason', array('reason' => $reason)));
  538. }
  539. if(in_array('sightml', $_GET['operations'])) {
  540. C::t('common_member_field_forum')->update($uid, array('sightml' => ''), 'UNBUFFERED');
  541. $cleartype[] = lang('forum/misc', 'signature');
  542. crime('recordaction', $uid, 'crime_sightml', lang('forum/misc', 'crime_reason', array('reason' => $reason)));
  543. }
  544. if(in_array('customstatus', $_GET['operations'])) {
  545. C::t('common_member_field_forum')->update($uid, array('customstatus' => ''), 'UNBUFFERED');
  546. $cleartype[] = lang('forum/misc', 'custom_title');
  547. crime('recordaction', $uid, 'crime_customstatus', lang('forum/misc', 'crime_reason', array('reason' => $reason)));
  548. }
  549. if(($_G['group']['reasonpm'] == 2 || $_G['group']['reasonpm'] == 3) || !empty($_GET['sendreasonpm'])) {
  550. sendreasonpm(array('authorid' => $uid), 'reason_quickclear', array(
  551. 'cleartype' => implode(',', $cleartype),
  552. 'reason' => $reason,
  553. 'from_id' => 0,
  554. 'from_idtype' => 'quickclear'
  555. ));
  556. }
  557. showmessage('quickclear_success', $_POST['redirect'], array(), array('showdialog'=>1, 'closetime' => true, 'msgtype' => 2, 'locationtime' => 1));
  558. }
  559. } elseif($_GET['action'] == 'getpostfeed') {
  560. $tid = intval($_GET['tid']);
  561. $pid = intval($_GET['pid']);
  562. $flag = intval($_GET['flag']);
  563. $feed = $thread = array();
  564. if($tid) {
  565. $thread = C::t('forum_thread')->fetch($tid);
  566. if($flag) {
  567. $post = C::t('forum_post')->fetch($thread['posttableid'], $pid);
  568. require_once libfile('function/discuzcode');
  569. require_once libfile('function/followcode');
  570. $post['message'] = followcode($post['message'], $tid, $pid);
  571. } else {
  572. if(!isset($_G['cache']['forums'])) {
  573. loadcache('forums');
  574. }
  575. $feedid = intval($_GET['feedid']);
  576. $feed = C::t('forum_threadpreview')->fetch($tid);
  577. if($feedid) {
  578. $feed = array_merge($feed, C::t('home_follow_feed')->fetch_by_feedid($feedid));
  579. }
  580. $post['message'] = $feed['content'];
  581. }
  582. }
  583. include template('forum/ajax_followpost');
  584. } elseif($_GET['action'] == 'setnav') {
  585. if($_G['adminid'] != 1) {
  586. showmessage('quickclear_noperm');
  587. }
  588. $allowfuntype = array('portal', 'group', 'follow', 'collection', 'guide', 'feed', 'blog', 'doing', 'album', 'share', 'wall', 'homepage', 'ranklist');
  589. $type = in_array($_GET['type'], $allowfuntype) ? trim($_GET['type']) : '';
  590. $do = in_array($_GET['do'], array('open', 'close')) ? $_GET['do'] : 'close';
  591. if(!submitcheck('funcsubmit')) {
  592. $navtitle = lang('spacecp', $do == 'open' ? 'select_the_navigation_position' : 'close_module', array('type' => lang('spacecp', $type)));
  593. $closeprompt = lang('spacecp', 'close_module', array('type' => lang('spacecp', $type)));
  594. include template('forum/ajax');
  595. } else {
  596. if(!empty($type)) {
  597. $funkey = $type.'status';
  598. $funstatus = $do == 'open' ? 1 : 0;
  599. if($type != 'homepage') {
  600. $identifier = array('portal' => 1, 'group' => 3, 'feed' => 4, 'ranklist' => 8, 'follow' => 9, 'guide' => 10, 'collection' => 11, 'blog' => 12, 'album' => 13, 'share' => 14, 'doing' => 15);
  601. $navdata = array('available' => -1);
  602. $navtype = $do == 'open' ? array() : array(0, 3);
  603. if(in_array($type, array('blog', 'album', 'share', 'doing', 'follow'))) {
  604. $navtype[] = 2;
  605. }
  606. if($do == 'open') {
  607. if($_GET['location']['header']) {
  608. $navtype[] = 0;
  609. $navdata['available'] = 1;
  610. }
  611. if($_GET['location']['quick']) {
  612. $navtype[] = 3;
  613. $navdata['available'] = 1;
  614. }
  615. $navdata['available'] = $navdata['available'] == 1 ? 1 : 0;
  616. if(empty($_GET['location']['header']) || empty($_GET['location']['quick'])) {
  617. C::t('common_nav')->update_by_navtype_type_identifier(array(0, 2, 3), 0, array("$type", "$identifier[$type]"), array('available' => 0));
  618. }
  619. }
  620. if($navtype) {
  621. C::t('common_nav')->update_by_navtype_type_identifier($navtype, 0, array("$type", "$identifier[$type]"), $navdata);
  622. if(in_array($type, array('blog', 'album', 'share', 'doing', 'follow')) && !$navdata['available']) {
  623. C::t('common_nav')->update_by_navtype_type_identifier(array(2), 0, array("$type"), array('available' => 1));
  624. }
  625. }
  626. }
  627. C::t('common_setting')->update($funkey, $funstatus);
  628. $setting[$funkey] = $funstatus;
  629. include libfile('function/cache');
  630. updatecache('setting');
  631. }
  632. showmessage('do_success', dreferer(), array(), array('header'=>true));
  633. }
  634. exit;
  635. }
  636. function tmpiconv($s, $d, $str) {
  637. if(is_array($str)) {
  638. foreach($str as $k => $v) {
  639. $str[$k] = tmpiconv($s, $d, $v);
  640. }
  641. } else {
  642. $str = iconv($s, $d, $str);
  643. }
  644. return $str;
  645. }
  646. function modifynav($type, $flag) {
  647. }
  648. showmessage('succeed', '', array(), array('handle' => false));
  649. ?>