PageRenderTime 61ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/forumcp.php

https://bitbucket.org/johnroyer/phpwind8.7
PHP | 1720 lines | 1513 code | 125 blank | 82 comment | 434 complexity | 5f8a25f112a170b528b44a5c3eb6ed20 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. require_once('global.php');
  3. require_once(R_P.'require/functions.php');
  4. require_once(R_P.'require/forum.php');
  5. require_once(R_P.'require/bbscode.php');
  6. //* include_once pwCache::getPath(D_P.'data/bbscache/forum_cache.php');
  7. pwCache::getData(D_P.'data/bbscache/forum_cache.php');
  8. $groupid == 'guest' && Showmsg('not_login');
  9. $fiddb = array();
  10. S::gp(array('action'));
  11. if ($db_mode != 'bbs' && $db_bfn == 'index.php') {
  12. $db_bfn_temp = $db_bbsurl."/index.php?m=bbs";
  13. } else {
  14. $db_bfn_temp = $db_bfn;
  15. }
  16. $isGM = S::inArray($windid,$manager);
  17. $forumcp_type = $db->get_value("SELECT forumset FROM pw_forumsextra WHERE fid=".S::sqlEscape($fid));
  18. $forumcp_type = $forumcp_type ? unserialize($forumcp_type) : array();
  19. if ($action) {
  20. !$fid && Showmsg('data_error');
  21. if (!($forums = L::forum($fid))) {
  22. Showmsg('data_error');
  23. }
  24. (!$forums || $forums['type'] == 'category') && Showmsg('data_error');
  25. $isBM = admincheck($forums['forumadmin'],$forums['fupadmin'],$windid);
  26. if (!in_array($groupid,array('3','4')) && !$isBM && !$isGM) {
  27. Showmsg('not_forumadmin');
  28. }
  29. $forumset = $forums['forumset'];
  30. $first_admin = $db_adminset && strpos($forums['forumadmin'],','.$windid.',')===0 ? 1 : 0;
  31. } else {
  32. $query = $db->query("SELECT fid,forumadmin,fupadmin FROM pw_forums WHERE cms=0 AND type!='category'");
  33. while ($rt = $db->fetch_array($query)) {
  34. if (in_array($groupid,array('3','4')) || admincheck($rt['forumadmin'],$rt['fupadmin'],$windid) || $isGM) {
  35. $fiddb[] = $rt['fid'];
  36. }
  37. }
  38. !$fiddb && Showmsg('not_forumadmin');
  39. }
  40. require_once(R_P.'require/header.php');
  41. if (!$action) {
  42. $forum_name = '';
  43. $fids = S::sqlImplode($fiddb);
  44. $froumdb = array();
  45. $query = $db->query("SELECT * FROM pw_forums f LEFT JOIN pw_forumdata fd USING(fid) WHERE f.fid IN($fids)");
  46. while ($rt = $db->fetch_array($query)) {
  47. $forumdb[] = $rt;
  48. }
  49. $i = count($forumdb);
  50. if ($i > 4) {
  51. $j_sum = 4;
  52. $j_wid = '25%';
  53. } else {
  54. $j_sum = $i;
  55. $j_wid = (100/$i).'%';
  56. }
  57. require_once(PrintEot('forumcp'));footer();
  58. } elseif ($action == 'edit') {
  59. $forum_name = S::striptags($forums['name']);
  60. S::gp(array('type'));
  61. !$type && $type = 'msg';
  62. if ($type == 'notice') {
  63. if(!$isGM && $forumcp_type['addnotice'] == 0){
  64. showMsg('您沒有管理權限!');
  65. }
  66. $annoucedb = array();
  67. $pages = ''; $page = (int)$_GET['page']; (int)$page<1 && $page = 1;
  68. $query = $db->query('SELECT aid,ifopen,vieworder,author,subject,startdate,enddate FROM pw_announce WHERE fid='.S::sqlEscape($fid).' ORDER BY fid,vieworder,startdate DESC '.S::sqlLimit(($page-1)*$db_perpage,$db_perpage));
  69. while ($rt = $db->fetch_array($query)) {
  70. $rt['subject'] = substrs($rt['subject'],30);
  71. $rt['starttime'] = $rt['startdate'] ? get_date($rt['startdate'],'Y-m-d H:i') : '--';
  72. $rt['endtime'] = $rt['enddate'] ? get_date($rt['enddate'],'Y-m-d H:i') : '--';
  73. $annoucedb[] = $rt;
  74. }
  75. $db->free_result($query);
  76. $count = $db->get_value('SELECT COUNT(*) FROM pw_announce WHERE fid='.S::sqlEscape($fid));
  77. if ($count > $db_perpage) {
  78. require_once(R_P.'require/forum.php');
  79. $pages = numofpage($count,$page,ceil($count/$db_perpage), "forumcp.php?action=edit&fid=$fid&type=$type&");
  80. }
  81. require_once(PrintEot('forumcp'));footer();
  82. } elseif ($type == 'n_del') {
  83. PostCheck();
  84. $aid = (int)$_GET['aid'];
  85. $rt = $db->get_one('SELECT aid,fid,ifopen FROM pw_announce WHERE aid='.S::sqlEscape($aid));
  86. (!$rt['aid'] || $rt['fid']!=$fid) && Showmsg('data_error');
  87. //* $db->update('DELETE FROM pw_announce WHERE aid='.S::sqlEscape($aid));
  88. pwQuery::delete('pw_announce', 'aid=:aid', array($aid));
  89. if ($rt['ifopen']) {
  90. require_once(R_P.'require/updatenotice.php');
  91. updatecache_i_i($fid);
  92. }
  93. refreshto("forumcp.php?action=edit&fid=$fid&type=notice",'operate_success');
  94. } elseif ($type == 'n_order') {
  95. PostCheck();
  96. !is_array($vieworder = $_POST['vieworder']) && $vieworder = array();
  97. $updatedb = array();
  98. foreach ($vieworder as $key => $value) {
  99. if (is_numeric($key)) {
  100. $value = (int)$value;
  101. $updatedb[$value] .= ",'$key'";
  102. }
  103. }
  104. foreach ($updatedb as $key => $value) {
  105. //* $value && $db->update("UPDATE pw_announce SET vieworder='$key' WHERE aid IN (".substr($value,1).')');
  106. $value && $db->update(pwQuery::buildClause("UPDATE :pw_table SET vieworder=:vieworder WHERE aid IN (".substr($value,1).')', array('pw_announce',$key)));
  107. }
  108. require_once(R_P.'require/updatenotice.php');
  109. updatecache_i_i($fid);
  110. refreshto("forumcp.php?action=edit&type=notice&fid=$fid",'operate_success');
  111. } elseif ($type == 'add' || $type == 'edit') {
  112. S::gp(array('aid'),'GP',2);
  113. if(!$isGM && $forumcp_type['addnotice'] == 0){
  114. showMsg('您沒有管理權限!');
  115. }
  116. if (empty($_POST['step'])) {
  117. $ifopen_Y = 'CHECKED'; $vieworder = (int)$vieworder;
  118. $ifopen_N = $subject = $atc_content = $enddate = '';
  119. $startdate = get_date($timestamp,'Y-m-d H:i');
  120. if ($type == 'edit') {
  121. $db_redundancy = 0;
  122. $rt = $db->get_one('SELECT aid,fid,ifopen,vieworder,startdate,enddate,subject,content FROM pw_announce WHERE aid='.S::sqlEscape($aid));
  123. !$rt['aid'] && Showmsg('data_error');
  124. extract($rt,EXTR_OVERWRITE);
  125. if (!$ifopen) {
  126. $ifopen_Y = '';
  127. $ifopen_N = 'CHECKED';
  128. }
  129. $startdate && $startdate = get_date($startdate,'Y-m-d H:i'); $enddate && $enddate = get_date($enddate,'Y-m-d H:i');
  130. $atc_content = $content;
  131. }
  132. require_once(PrintEot('forumcp'));footer();
  133. } else {
  134. PostCheck();
  135. !$fid && Showmsg('annouce_fid');
  136. S::gp(array('startdate','enddate','atc_title'),'P');
  137. $startdate = $startdate ? PwStrtoTime($startdate) : $timestamp;
  138. $enddate = $enddate ? PwStrtoTime($enddate) : '';
  139. $enddate && $enddate<=$startdate && Showmsg('annouce_time');
  140. S::gp(array('ifopen','vieworder'),'P',2);
  141. $atc_content = trim(S::escapeChar($_POST['atc_content']));
  142. if ($type == 'add') {
  143. (!$atc_title || strlen(trim($atc_title)) == 0) && Showmsg('annouce_title');
  144. (!$atc_content || strlen($atc_content) == 0) && Showmsg('annouce_content');
  145. /**
  146. $pwSQL = S::sqlSingle(array(
  147. 'fid' => $fid,
  148. 'ifopen' => $ifopen,
  149. 'vieworder' => $vieworder,
  150. 'author' => $windid,
  151. 'startdate' => $startdate,
  152. 'enddate' => $enddate,
  153. 'url' => $url,
  154. 'subject' => $atc_title,
  155. 'content' => $atc_content
  156. ));
  157. $db->update("INSERT INTO pw_announce SET $pwSQL");
  158. **/
  159. pwQuery::insert('pw_announce', array(
  160. 'fid' => $fid,
  161. 'ifopen' => $ifopen,
  162. 'vieworder' => $vieworder,
  163. 'author' => $windid,
  164. 'startdate' => $startdate,
  165. 'enddate' => $enddate,
  166. 'url' => $url,
  167. 'subject' => $atc_title,
  168. 'content' => $atc_content
  169. ));
  170. if ($ifopen && (!$enddate || $enddate>=$timestamp)) {
  171. require_once(R_P.'require/updatenotice.php');
  172. updatecache_i_i($fid);
  173. }
  174. } else {
  175. $rt = $db->get_one('SELECT aid,fid,content FROM pw_announce WHERE aid='.S::sqlEscape($aid));
  176. !$atc_title && Showmsg('annouce_title');
  177. !$atc_content && Showmsg('annouce_content');
  178. (!$rt['aid'] || $rt['fid']!=$fid) && Showmsg('data_error');
  179. $pwSQL = array(
  180. 'ifopen' => $ifopen,
  181. 'vieworder' => $vieworder,
  182. 'startdate' => $startdate,
  183. 'enddate' => $enddate,
  184. 'url' => $url,
  185. 'subject' => $atc_title,
  186. 'content' => $atc_content
  187. );
  188. //* $db->update("UPDATE pw_announce SET $pwSQL WHERE aid=".S::sqlEscape($aid));
  189. pwQuery::update('pw_announce','aid=:aid', array($aid), $pwSQL);
  190. require_once(R_P.'require/updatenotice.php');
  191. updatecache_i_i($fid);
  192. }
  193. refreshto("forumcp.php?action=edit&type=notice&fid=$fid",'operate_success');
  194. }
  195. } elseif ($type == 'report') {
  196. S::gp(array('page'),'GP',2);
  197. $page < 1 && $page = 1;
  198. $limit = S::sqlLimit(($page-1)*$db_perpage,$db_perpage);
  199. if($forums['childid'] == 1) {
  200. foreach ($forum as $key => $value) {
  201. if($value['fup'] == $fid){
  202. $fiddb[] = $key;
  203. }
  204. if(in_array($value['fup'],$fiddb)) {
  205. $fiddb[] = $key;
  206. }
  207. }
  208. }
  209. $fiddb = array_merge(array($fid),$fiddb);
  210. $rt = $db->get_one('SELECT COUNT(*) AS count FROM pw_report r LEFT JOIN pw_threads t ON t.tid=r.tid WHERE t.fid IN('.S::sqlImplode($fiddb).')');
  211. $sum = $rt['count'];
  212. $numofpage = ceil($sum/$db_perpage);
  213. $pages = numofpage($sum,$page,$numofpage,"forumcp.php?action=edit&type=report&fid=$fid&");
  214. $query = $db->query('SELECT r.*,m.username,t.fid FROM pw_report r LEFT JOIN pw_members m ON m.uid=r.uid LEFT JOIN pw_threads t ON t.tid=r.tid WHERE t.fid IN ('.S::sqlImplode($fiddb).') ORDER BY id '.$limit);
  215. while ($rt = $db->fetch_array($query)) {
  216. $rt['fname'] = $forum[$rt['fid']]['name'];
  217. $reportdb[] = $rt;
  218. }
  219. require_once(PrintEot('forumcp'));footer();
  220. } elseif ($type == 'f_type') {
  221. if(!$isGM && $forumcp_type['allowtpctype'] == 0){
  222. showMsg('您沒有管理權限。');
  223. }
  224. if (!($foruminfo = L::forum($fid))) {
  225. Showmsg('data_error');
  226. }
  227. $forumset = $foruminfo['forumset'];
  228. S::gp(array('dodel'));
  229. if ($dodel == 'delttype') {
  230. S::gp(array('typename','id'));
  231. $id_array = array();
  232. if ($typename == 'top') {
  233. $query = $db->query("SELECT id FROM pw_topictype WHERE upid=".S::sqlEscape($id));
  234. while ($rt = $db->fetch_array($query)) {
  235. $id_array[] = $rt['id'];
  236. }
  237. }
  238. $id_array = array_merge($id_array,array($id));
  239. if (!empty($id_array)) {
  240. require_once (R_P.'admin/cache.php');
  241. $db->update("DELETE FROM pw_topictype WHERE id IN (".S::sqlImplode($id_array).")");
  242. updatecache_f();
  243. refreshto("forumcp.php?action=edit&type=f_type&fid=$fid", '刪除成功!');
  244. } else {
  245. Showmsg('data_error');
  246. }
  247. }
  248. if (empty($_POST['step'])) {
  249. $basename = "forumcp.php?action=edit&type=f_type&fid=$fid";
  250. $forumset['addtpctype'] ? $addtpctype_Y='checked' : $addtpctype_N='checked';
  251. $t_type = (int)$foruminfo['t_type'];
  252. ${'t_type_'.$t_type}='checked';
  253. //主題分類
  254. $query = $db->query("SELECT id,name,vieworder,upid,logo,ifsys FROM pw_topictype WHERE fid=".S::sqlEscape($fid)." ORDER BY vieworder");
  255. while ($rt = $db->fetch_array($query)) {
  256. $rt['name'] = str_replace(array('<','>','"',"'"),array("&lt;","&gt;","&quot;","&#39;"),$rt['name']);
  257. if($rt['upid'] == 0) {
  258. $typedb[$rt['id']] = $rt;
  259. } else {
  260. $subtypedb[$rt['id']] = $rt;
  261. }
  262. }
  263. require_once(PrintEot('forumcp'));footer();
  264. } else {
  265. PostCheck();
  266. S::slashes($forumset);
  267. S::gp(array('t_view_db','t_logo_db','new_t_view_db','new_t_logo_db','t_sys_db','new_t_sub_logo_db','new_t_sub_view_db','addtpctype'),'P');
  268. S::gp(array('t_db','new_t_db','new_t_sub_db','f_type','t_type'),'P',0);
  269. $temptype = array('t_db','new_t_db','new_t_logo_db','new_t_sub_db');
  270. empty($t_db) && $t_db = array();
  271. empty($new_t_db) && $new_t_db = array();
  272. empty($new_t_sub_db) && $new_t_sub_db = array();
  273. foreach ($t_db as $key => $value) {
  274. $value = str_replace(array('&#46;&#46;','&#41;','&#60;','&#61;'),array('..',')','<','='),$value);
  275. $t_db[$key] = $value;
  276. }
  277. //主題分類
  278. empty($t_db) && $t_db = array();
  279. empty($new_t_db) && $new_t_db = array();
  280. empty($new_t_sub_db) && $new_t_sub_db = array();
  281. //更新原有的分類
  282. foreach ($t_db as $key => $value) {
  283. if(empty($value)) continue;
  284. $db->update("UPDATE pw_topictype SET " . S::sqlSingle(array(
  285. 'name' => $value,
  286. 'logo' => $t_logo_db[$key],
  287. 'vieworder' => $t_view_db[$key],
  288. 'ifsys' => isset($t_sys_db[$key]) ? $t_sys_db[$key] : 0,
  289. )) . " WHERE id=".S::sqlEscape($key));
  290. }
  291. //增加新分類
  292. foreach ($new_t_db as $key => $value) {
  293. if(empty($value)) continue;
  294. $value = str_replace(array('&#46;&#46;','&#41;','&#60;','&#61;'),array('..',')','<','='),$value);
  295. $typedb[] = array (
  296. 'fid' => $fid,
  297. 'name' => $value,
  298. 'logo'=>$new_t_logo_db[$key],
  299. 'vieworder'=>$new_t_view_db[$key],
  300. 'ifsys' => isset($new_t_sys_db[$key]) ? $new_t_sys_db[$key] : 0
  301. );
  302. }
  303. if ($typedb) {
  304. $db->update("REPLACE INTO pw_topictype (fid,name,logo,vieworder,ifsys) VALUES " . S::sqlMulti($typedb));
  305. }
  306. //增加二級新分類
  307. foreach ($new_t_sub_db as $key => $value) {
  308. foreach ($value as $k => $v) {
  309. if (empty($v)) continue;
  310. $v = str_replace(array('&#46;&#46;','&#41;','&#60;','&#61;'),array('..',')','<','='),$v);
  311. $subtypedb[] = array (
  312. 'fid' => $fid,
  313. 'name' => $v,
  314. 'logo'=>$new_t_sub_logo_db[$key][$k],
  315. 'vieworder'=>$new_t_sub_view_db[$key][$k],
  316. 'upid'=>$key,
  317. 'ifsys' => isset($new_t_sub_sys_db[$key][$k]) ? $new_t_sub_sys_db[$key][$k] : 0
  318. );
  319. }
  320. }
  321. if ($subtypedb) {
  322. $db->update("REPLACE INTO pw_topictype (fid,name,logo,vieworder,upid,ifsys) VALUES " . S::sqlMulti($subtypedb));
  323. }
  324. require_once (R_P.'admin/cache.php');
  325. if ($addtpctype != $forumset['addtpctype']) {
  326. $forumset['addtpctype'] = $addtpctype;
  327. $forumset = serialize($forumset);
  328. if ($foruminfo['fid']) {
  329. $db->update('UPDATE pw_forumsextra SET forumset='.S::sqlEscape($forumset).' WHERE fid='.S::sqlEscape($fid));
  330. } else {
  331. $db->update('INSERT INTO pw_forumsextra SET '.S::sqlSingle(array('fid'=>$fid,'forumset'=>$forumset)));
  332. }
  333. updatecache_forums($fid);
  334. }
  335. $foruminfo = L::forum($fid);
  336. if($t_type != $foruminfo['t_type']){
  337. //$db->update("UPDATE pw_forums SET " . S::sqlSingle(array('t_type'=> $t_type)) . "WHERE fid=".S::sqlEscape($fid));
  338. pwQuery::update('pw_forums', 'fid =:fid', array($fid), array('t_type' => $t_type));
  339. }
  340. updatecache_f();
  341. refreshto("forumcp.php?action=edit&type=f_type&fid=$fid",'operate_success');
  342. }
  343. } elseif ($type == 'reward') {
  344. S::gp(array('starttime','endtime','username'));
  345. S::gp(array('page'),'GP',2);
  346. $page < 1 && $page=1;
  347. $limit = "LIMIT ".($page-1)*$db_perpage.",$db_perpage";
  348. $sql = $url_a = '';
  349. $_POST['starttime'] && $starttime= PwStrtoTime($starttime);
  350. $_POST['endtime'] && $endtime = PwStrtoTime($endtime);
  351. if ($username) {
  352. $sql.=' AND t.author='.S::sqlEscape($username);
  353. $url_a.="username=".rawurlencode($username)."&";
  354. }
  355. if ($starttime) {
  356. $sql.=' AND t.postdate>'.S::sqlEscape($starttime);
  357. $url_a.="starttime=$starttime&";
  358. }
  359. if ($endtime) {
  360. $sql.=' AND t.postdate<'.S::sqlEscape($endtime);
  361. $url_a.="endtime=$endtime&";
  362. }
  363. $rt = $db->get_one("SELECT COUNT(*) AS count FROM pw_threads t LEFT JOIN pw_reward r USING(tid) WHERE t.fid=".S::sqlEscape($fid)." AND t.special='3' AND t.state='0' AND r.timelimit<".S::sqlEscape($timestamp).$sql);
  364. $sum = $rt['count'];
  365. $numofpage = ceil($sum/$db_perpage);
  366. $pages = numofpage($sum,$page,$numofpage,"forumcp.php?action=edit&type=reward&fid=$fid&$url_a");
  367. $threaddb = array();
  368. $query = $db->query("SELECT t.tid,t.fid,t.subject,t.author,t.authorid,t.postdate,r.cbtype,r.cbval,r.catype,r.caval FROM pw_threads t LEFT JOIN pw_reward r USING(tid) WHERE t.fid=".S::sqlEscape($fid)." AND t.special='3' AND t.state='0' AND r.timelimit>".S::sqlEscape($timestamp).$sql." ORDER BY t.postdate $limit");
  369. while ($rt = $db->fetch_array($query)) {
  370. $rt['postdate'] = get_date($rt['postdate'],'Y-m-d');
  371. $rt['cbtype'] = is_numeric($rt['cbtype']) ? $_CREDITDB[$rt['cbtype']][0] : ${'db_'.$rt['cbtype'].'name'};
  372. $rt['catype'] = is_numeric($rt['catype']) ? $_CREDITDB[$rt['catype']][0] : ${'db_'.$rt['catype'].'name'};
  373. $rt['binfo'] = $rt['cbval']."&nbsp;".$rt['cbtype'];
  374. $rt['ainfo'] = $rt['caval']."&nbsp;".$rt['catype'];
  375. $threaddb[] = $rt;
  376. }
  377. require_once(PrintEot('forumcp'));footer();
  378. } elseif ($type == 'thread') {
  379. if(!$isGM && $forumcp_type['allowtpctype'] == 0)
  380. showMsg('您沒有管理權限!');
  381. S::gp(array('starttime','endtime','username','t_type'));
  382. S::gp(array('page'),'GP',2);
  383. $page < 1 && $page=1;
  384. $limit="LIMIT ".($page-1)*$db_perpage.",$db_perpage";
  385. $sql = $url_a = '';
  386. $_POST['starttime'] && $starttime= PwStrtoTime($starttime);
  387. $_POST['endtime'] && $endtime = PwStrtoTime($endtime);
  388. if ($username) {
  389. $sql.=' AND author='.S::sqlEscape($username);
  390. $url_a.="username=".rawurlencode($username)."&";
  391. }
  392. if ($starttime) {
  393. $sql.=' AND postdate>'.S::sqlEscape($starttime);
  394. $url_a.="starttime=$starttime&";
  395. }
  396. if ($endtime) {
  397. $sql.=' AND postdate<'.S::sqlEscape($endtime);
  398. $url_a.="endtime=$endtime&";
  399. }
  400. if ($t_type) {
  401. switch($t_type) {
  402. case 'digest':
  403. $sql.=" AND digest>'0'";
  404. break;
  405. case 'active':
  406. $sql.=" AND special='2'";
  407. break;
  408. case 'reward':
  409. $sql.=" AND special='3'";
  410. break;
  411. case 'sale':
  412. $sql.=" AND special='4'";
  413. break;
  414. default :
  415. $sql.=" AND digest>'0'";
  416. }
  417. $url_a.="t_type=$t_type&";
  418. }
  419. if ($sql) {
  420. $rt = $db->get_one("SELECT COUNT(*) AS sum FROM pw_threads WHERE fid=".S::sqlEscape($fid)." AND ifcheck=1 $sql");
  421. } else {
  422. $rt = $db->get_one('SELECT topic AS sum FROM pw_forumdata WHERE fid='.S::sqlEscape($fid));
  423. }
  424. $pages = numofpage($rt['sum'],$page,ceil($rt['sum']/$db_perpage), "forumcp.php?action=edit&type=thread&fid=$fid&$url_a");
  425. $query = $db->query("SELECT tid,subject,author,authorid,postdate,titlefont,topped,digest,specialsort FROM pw_threads WHERE fid=".S::sqlEscape($fid)." AND ifcheck='1' $sql ORDER BY specialsort DESC,lastpost DESC $limit");
  426. $threaddb = $toppedThread = array();
  427. while ($rt = $db->fetch_array($query)) {
  428. $rt['subject'] = substrs($rt['subject'],35);
  429. if ($rt['titlefont']) {
  430. $titledetail = explode("~",$rt['titlefont']);
  431. if ($titledetail[0])$rt['subject'] = "<font color=\"$titledetail[0]\">$rt[subject]</font>";
  432. if ($titledetail[1])$rt['subject'] = "<b>$rt[subject]</b>";
  433. if ($titledetail[2])$rt['subject'] = "<i>$rt[subject]</i>";
  434. if ($titledetail[3])$rt['subject'] = "<u>$rt[subject]</u>";
  435. }
  436. $rt['postdate'] = get_date($rt['postdate']);
  437. if (!$rt['specialsort']) {
  438. $threaddb[] = $rt;
  439. continue;
  440. }
  441. $rt['specialsort'] && $toppedThread[] = $rt;
  442. }
  443. S::isArray($toppedThread) && $threaddb = array_merge($toppedThread, $threaddb);
  444. require_once PrintEot('forumcp');footer();
  445. } elseif ($type == 'tcheck') {
  446. if(!$isGM && !pwRights($isBM,'viewcheck')) Showmsg('not_forumadmin');
  447. if (empty($_POST['step'])) {
  448. S::gp(array('starttime','endtime','username','t_type'));
  449. S::gp(array('page'),'GP',2);
  450. $page < 1 && $page=1;
  451. $limit = "LIMIT ".($page-1)*$db_perpage.",$db_perpage";
  452. $sql = $url_a = '';
  453. $_POST['starttime'] && $starttime= PwStrtoTime($starttime);
  454. $_POST['endtime'] && $endtime = PwStrtoTime($endtime);
  455. if ($username) {
  456. $sql.=' AND author='.S::sqlEscape($username);
  457. $url_a.="username=".rawurlencode($username)."&";
  458. }
  459. if ($starttime) {
  460. $sql.=' AND postdate>'.S::sqlEscape($starttime);
  461. $url_a.="starttime=$starttime&";
  462. }
  463. if ($endtime) {
  464. $sql.=' AND postdate<'.S::sqlEscape($endtime);
  465. $url_a.="endtime=$endtime&";
  466. }
  467. if ($t_type) {
  468. switch($t_type) {
  469. case 'digest':
  470. $sql.=" AND digest>'0'";
  471. break;
  472. case 'active':
  473. $sql.=" AND special='2'";
  474. break;
  475. case 'reward':
  476. $sql.=" AND special='3'";
  477. break;
  478. case 'sale':
  479. $sql.=" AND special='4'";
  480. break;
  481. default :
  482. $sql.=" AND digest>'0'";
  483. }
  484. $url_a .= "t_type=$t_type&";
  485. ${'t_type_' . $t_type} = 'selected';
  486. }
  487. $rt = $db->get_one("SELECT COUNT(*) AS sum FROM pw_threads WHERE fid=".S::sqlEscape($fid)." AND ifcheck='0' $sql");
  488. $pages = numofpage($rt['sum'],$page,ceil($rt['sum']/$db_perpage), "forumcp.php?action=edit&type=tcheck&fid=$fid&$url_a");
  489. $threaddb = $ttable_a = $attachs = array();
  490. $query = $db->query("SELECT tid,subject,author,authorid,postdate FROM pw_threads WHERE fid=".S::sqlEscape($fid)." AND ifcheck='0' $sql ORDER BY specialsort DESC,lastpost DESC $limit");
  491. while ($rt = $db->fetch_array($query)) {
  492. $rt['subject'] = substrs($rt['subject'],35);
  493. $rt['postdate'] = get_date($rt['postdate']);
  494. $threaddb[$rt['tid']] = $rt;
  495. $ttable_a[GetTtable($rt['tid'])][] = $rt['tid'];
  496. }
  497. if ($threaddb) {
  498. $pw_attachs = L::loadDB('attachs', 'forum');
  499. $attachs = $pw_attachs->gets(array('tid' => array_keys($threaddb), 'pid' => 0));
  500. $attachShow = new attachShow(true);
  501. $attachShow->setData($attachs, 'tid');
  502. }
  503. //* include_once pwCache::getPath(D_P.'data/bbscache/wordsfb.php');
  504. pwCache::getData(D_P.'data/bbscache/wordsfb.php');
  505. foreach ($ttable_a as $pw_tmsgs => $value) {
  506. $value = S::sqlImplode($value);
  507. $query = $db->query("SELECT tid,content,ifconvert,aid FROM $pw_tmsgs WHERE tid IN($value)");
  508. while ($rt = $db->fetch_array($query)) {
  509. $rt['content'] = str_replace("\n","<br>",$rt['content']);
  510. $rt['ifconvert'] == 2 && $rt['content'] = convert($rt['content'], $db_windpost);
  511. if ($rt['aid']) {
  512. $rt += $attachShow->parseAttachs($rt['tid'], $rt['content'], 0);
  513. if ($rt['pic']) {
  514. foreach ($rt['pic'] as $k => $v) {
  515. $rt['content'] .= '<br />' . $v['img'];
  516. }
  517. }
  518. if ($rt['downattach']) {
  519. foreach ($rt['downattach'] as $k => $v) {
  520. $rt['content'] .= "<br />附件:<a href=\"job.php?action=download&aid=$v[aid]\" onclick=\"return ajaxurl(this);\"> <font color=\"red\">$v[name]</font></a> ($v[size] K)";
  521. }
  522. }
  523. }
  524. foreach ($alarm as $key => $value) {
  525. $rt['content'] = str_replace($key,'<span style="background-color:#ffff66">'.$key.'</span>',$rt['content']);
  526. }
  527. $threaddb[$rt['tid']]['content'] = $rt['content'];
  528. }
  529. }
  530. require_once PrintEot('forumcp');footer();
  531. } elseif ($_POST['step'] == 3) {
  532. PostCheck();
  533. S::gp(array('selid','ifmsg'));
  534. $tids = array();
  535. foreach ($selid as $key=>$value) {
  536. is_numeric($value) && $tids[] = $value;
  537. }
  538. !$tids && Showmsg('id_error');
  539. //$db->update("UPDATE pw_threads SET ifcheck='1' WHERE tid IN(".S::sqlImplode($tids).") AND fid=".S::sqlEscape($fid));
  540. pwQuery::update('pw_threads', "tid IN (:tid) AND fid=:fid", array($tids, $fid), array("ifcheck"=>1));
  541. $checkarticle = L::loadClass('DelArticle', 'forum');
  542. $readdb = $checkarticle->getTopicDb("tid ".$checkarticle->sqlFormatByIds($tids));
  543. foreach ($readdb as $tpcData) {
  544. if ($ifmsg) {
  545. M::sendNotice(
  546. array($tpcData['author']),
  547. array(
  548. 'title' => getLangInfo('writemsg','check_title'),
  549. 'content' => getLangInfo('writemsg','check_content',array(
  550. 'manager' => $windid,
  551. 'fid' => $tpcData['fid'],
  552. 'tid' => $tpcData['tid'],
  553. 'subject' => $tpcData['subject'],
  554. 'postdate' => get_date($tpcData['postdate']),
  555. 'forum' => strip_tags($forum[$fid]['name']),
  556. 'affect' => "",
  557. 'admindate' => get_date($timestamp),
  558. 'reason' => stripslashes($atc_content)
  559. )),
  560. )
  561. );
  562. }
  563. }
  564. // $threadList = L::loadClass("threadlist", 'forum');
  565. // $threadList->refreshThreadIdsByForumId($fid);
  566. Perf::gatherInfo('changeThreadWithForumIds', array('fid'=>$fid));
  567. $todayTopicNum = count((array)$tids);
  568. require_once(R_P.'require/updateforum.php');
  569. updateforum($fid);
  570. refreshto("forumcp.php?action=edit&type=$type&fid=$fid",'operate_success');
  571. } else {
  572. PostCheck();
  573. S::gp(array('selid','ifmsg'));
  574. $delids = '';
  575. foreach ($selid as $key => $value) {
  576. if (is_numeric($value)) {
  577. $delids .= $value.',';
  578. }
  579. }
  580. !$delids && Showmsg('mawhole_nodata');
  581. $delids = substr($delids,0,-1);
  582. $readdb = array();
  583. $delarticle = L::loadClass('DelArticle', 'forum');
  584. $readdb = $delarticle->getTopicDb("tid ".$delarticle->sqlFormatByIds($delids));
  585. //積分操作
  586. require_once(R_P.'require/credit.php');
  587. $creditOpKey = "Delete";
  588. $foruminfo = L::forum($fid);
  589. $creditset = $credit->creditset($foruminfo['creditset'],$db_creditset);
  590. $msg_delrvrc = abs($creditset['Delete']['rvrc']);
  591. $msg_delmoney = abs($creditset['Delete']['money']);
  592. foreach ($readdb as $tpcData) {
  593. if ($ifmsg) {
  594. isset($msg_delrvrc) && $tmp_msg_delrvrc = ($msg_delrvrc != 0) ? "-{$msg_delrvrc}" : 0;
  595. isset($msg_delmoney) && $tmp_msg_delmoney = ($msg_delmoney != 0) ? "-{$msg_delmoney}" : 0;
  596. M::sendNotice(
  597. array($tpcData['author']),
  598. array(
  599. 'title' => getLangInfo('writemsg','del_title'),
  600. 'content' => getLangInfo('writemsg','del_content',array(
  601. 'manager' => $windid,
  602. 'fid' => $tpcData['fid'],
  603. 'tid' => $tpcData['tid'],
  604. 'subject' => $tpcData['subject'],
  605. 'postdate' => get_date($tpcData['postdate']),
  606. 'forum' => strip_tags($forum[$fid]['name']),
  607. 'affect' => "{$db_rvrcname}:{$tmp_msg_delrvrc},{$db_moneyname}:{$tmp_msg_delmoney}",
  608. 'admindate' => get_date($timestamp),
  609. 'reason' => stripslashes($atc_content)
  610. )),
  611. )
  612. );
  613. }
  614. }
  615. $delarticle->delTopic($readdb, false, true, array('reason' => $atc_content));
  616. # memcache refresh
  617. // $threadList = L::loadClass("threadlist", 'forum');
  618. // $threadList->refreshThreadIdsByForumId($fid);
  619. Perf::gatherInfo('changeThreadWithForumIds', array('fid'=>$fid));
  620. refreshto("forumcp.php?action=edit&type=$type&fid=$fid",'operate_success');
  621. }
  622. } elseif ($type == 'pcheck') {
  623. if(!$isGM && !pwRights($isBM,'viewcheck')) Showmsg('not_forumadmin');
  624. if (empty($_POST['step'])) {
  625. S::gp(array('starttime','endtime','username','ptable'));
  626. S::gp(array('page'),'GP',2);
  627. $page < 1 && $page=1;
  628. $limit = S::sqlLimit(($page-1)*$db_perpage,$db_perpage);
  629. $sql = $url_a = '';
  630. $_POST['starttime'] && $starttime= PwStrtoTime($starttime);
  631. $_POST['endtime'] && $endtime = PwStrtoTime($endtime);
  632. if ($username) {
  633. $sql.=' AND author='.S::sqlEscape($username);
  634. $url_a.="username=".rawurlencode($username)."&";
  635. }
  636. if ($starttime) {
  637. $sql.=' AND postdate>'.S::sqlEscape($starttime);
  638. $url_a.="starttime=$starttime&";
  639. }
  640. if ($endtime) {
  641. $sql.=' AND postdate<'.S::sqlEscape($endtime);
  642. $url_a.="endtime=$endtime&";
  643. }
  644. if ($db_plist && count($db_plist)>1) {
  645. !is_numeric($ptable) && $ptable = $db_ptable;
  646. foreach ($db_plist as $key=>$val) {
  647. $name = $val ? $val : ($key != 0 ? getLangInfo('other','posttable').$key : getLangInfo('other','posttable'));
  648. $p_table .= "<option value=\"$key\">".$name."</option>";
  649. }
  650. $p_table = str_replace("<option value=\"$ptable\">","<option value=\"$ptable\" selected>",$p_table);
  651. $url_a .= "ptable=$ptable&";
  652. $pw_posts = GetPtable($ptable);
  653. } else {
  654. $pw_posts = 'pw_posts';
  655. }
  656. $rt = $db->get_one("SELECT COUNT(*) AS sum FROM $pw_posts WHERE fid=".S::sqlEscape($fid)." AND ifcheck='0' $sql");
  657. $pages = numofpage($rt['sum'],$page,ceil($rt['sum']/$db_perpage), "forumcp.php?action=edit&type=$type&fid=$fid&$url_a");
  658. $postdb = $tids = array();
  659. //* include_once pwCache::getPath(D_P.'data/bbscache/wordsfb.php');
  660. pwCache::getData(D_P.'data/bbscache/wordsfb.php');
  661. $query = $db->query("SELECT pid,tid,subject,author,authorid,postdate,content,aid,ifconvert FROM $pw_posts WHERE fid=".S::sqlEscape($fid)." AND ifcheck='0' $sql $limit");
  662. while ($rt = $db->fetch_array($query)) {
  663. if ($rt['subject']) {
  664. $rt['subject'] = substrs($rt['subject'],35);
  665. } else {
  666. $rt['subject'] = substrs($rt['content'],35);
  667. }
  668. $rt['postdate'] = get_date($rt['postdate']);
  669. $rt['content'] = str_replace("\n","<br>",$rt['content']);
  670. $rt['ifconvert'] == 2 && $rt['content'] = convert($rt['content'], $db_windpost);
  671. foreach ($alarm as $key => $value) {
  672. $rt['content'] = str_replace($key,'<span style="background-color:#ffff66">'.$key.'</span>',$rt['content']);
  673. }
  674. $postdb[$rt['pid']] = $rt;
  675. if ($rt['aid']) {
  676. $tids[] = $rt['tid'];
  677. }
  678. }
  679. if ($tids) {
  680. $pw_attachs = L::loadDB('attachs', 'forum');
  681. $attachs = $pw_attachs->gets(array('tid' => $tids, 'pid' => array_keys($postdb)));
  682. $attachShow = new attachShow(true);
  683. $attachShow->setData($attachs);
  684. foreach ($postdb as $key => $rt) {
  685. if (!$rt['aid']) continue;
  686. $rt += $attachShow->parseAttachs($rt['pid'], $rt['content'], 0);
  687. if ($rt['pic']) {
  688. foreach ($rt['pic'] as $k => $v) {
  689. $rt['content'] .= '<br />' . $v['img'];
  690. }
  691. }
  692. if ($rt['downattach']) {
  693. foreach ($rt['downattach'] as $k => $v) {
  694. $rt['content'] .= "<br />附件:<a href=\"job.php?action=download&aid=$v[aid]\" onclick=\"return ajaxurl(this);\"> <font color=\"red\">$v[name]</font></a> ($v[size] K)";
  695. }
  696. }
  697. $postdb[$rt['pid']] = $rt;
  698. }
  699. }
  700. require_once PrintEot('forumcp');footer();
  701. } elseif ($_POST['step'] == 3) {
  702. PostCheck();
  703. S::gp(array('selid','ptable'));
  704. /*
  705. $pids = '';
  706. foreach ($selid as $key => $value) {
  707. is_numeric($value) && $pids .= ($pids ? ',' : '').$value;
  708. }
  709. !$pids && Showmsg('id_error');
  710. */
  711. $pids = array();
  712. foreach ($selid as $key => $value) {
  713. is_numeric($value) && $pids[] = $value;
  714. }
  715. !$pids && Showmsg('id_error');
  716. $pw_posts = GetPtable($ptable);
  717. $update_tids = array();
  718. $query = $db->query("SELECT tid,pid,fid,aid,author,authorid,postdate,subject,content FROM $pw_posts WHERE fid='$fid' AND pid IN(".S::sqlImplode($pids).")");
  719. while ($rt = $db->fetch_array($query)) {
  720. $update_tids[$rt['tid']] ++;
  721. if ($_POST['ifmsg']) {
  722. if (!$rt['subject']) {
  723. $rt['subject'] = substrs($rt['content'],35);
  724. }
  725. M::sendNotice(
  726. array($rt['author']),
  727. array(
  728. 'title' => getLangInfo('writemsg','check_title'),
  729. 'content' => getLangInfo('writemsg','check_content',array(
  730. 'manager' => $windid,
  731. 'fid' => $fid,
  732. 'tid' => $rt['tid'],
  733. 'subject' => substrs($rt['subject'],28),
  734. 'postdate' => get_date($rt['postdate']),
  735. 'forum' => strip_tags($forum[$fid]['name']),
  736. 'affect' => "",
  737. 'admindate' => get_date($timestamp),
  738. 'reason' => stripslashes($atc_content)
  739. )),
  740. )
  741. );
  742. }
  743. }
  744. foreach ($update_tids as $key => $value) {
  745. $rt = $db->get_one("SELECT postdate,author FROM $pw_posts WHERE tid=".S::sqlEscape($key)."ORDER BY postdate DESC LIMIT 1");
  746. //$db->update("UPDATE pw_threads SET replies=replies+".S::sqlEscape($value).",lastpost=".S::sqlEscape($rt['postdate'],false).",lastposter =".S::sqlEscape($rt['author'],false)."WHERE tid=".S::sqlEscape($key));
  747. $db->update(pwQuery::buildClause("UPDATE :pw_table SET replies=replies+:replies, lastpost=:lastpost, lastposter=:lastposter WHERE tid=:tid", array('pw_threads', $value, $rt['postdate'], $rt['author'], $key)));
  748. # memcache refresh
  749. // $threadList = L::loadClass("threadlist", 'forum');
  750. // $threadList->updateThreadIdsByForumId($fid,$tid);
  751. Perf::gatherInfo('changeThreadWithForumIds', array('fid'=>$fid));
  752. }
  753. //$db->update("UPDATE $pw_posts SET ifcheck='1' WHERE pid IN(" . S::sqlImplode($pids) . ") AND fid='$fid'");
  754. pwQuery::update($pw_posts, 'pid IN(:pid) AND fid=:fid', array($pids, $fid), array('ifcheck' => '1'));
  755. require_once(R_P.'require/updateforum.php');
  756. updateforum($fid);
  757. refreshto("forumcp.php?action=edit&type=$type&fid=$fid",'operate_success');
  758. } else {
  759. PostCheck();
  760. S::gp(array('selid','ptable'));
  761. require_once(R_P.'require/credit.php');
  762. $creditOpKey = "Deleterp";
  763. $foruminfo = L::forum($fid);
  764. $creditset = $credit->creditset($foruminfo['creditset'],$db_creditset);
  765. //$tids = '';
  766. $_tids = $_pids = $deluids = array();
  767. /*foreach ($selid as $key => $value) {
  768. is_numeric($value) && $tids .= ($tids ? ',' : '').$value;
  769. }
  770. !$tids && Showmsg('id_error');*/
  771. $pidArr = array();
  772. foreach ($selid as $key => $value) {
  773. is_numeric($value) && $pidArr[] = $value;
  774. }
  775. !$pidArr && Showmsg('id_error');
  776. $msg_delrvrc = abs($creditset['Deleterp']['rvrc']);
  777. $msg_delmoney = abs($creditset['Deleterp']['money']);
  778. $pw_posts = GetPtable($ptable);
  779. $query = $db->query("SELECT tid,pid,fid,aid,author,authorid,postdate,subject,content FROM $pw_posts WHERE fid='$fid' AND pid IN(" . S::sqlImplode($pidArr) . ")");
  780. while ($rt = $db->fetch_array($query)) {
  781. $rt['fid'] != $fid && Showmsg('admin_forum_right');
  782. $deluids[$rt['authorid']] = isset($deluids[$rt['authorid']]) ? $deluids[$rt['authorid']] + 1 : 1;
  783. //積分操作
  784. $credit->addLog("topic_$creditOpKey", $creditset[$creditOpKey], array(
  785. 'uid' => $rt['authorid'],
  786. 'username' => $rt['author'],
  787. 'ip' => $onlineip,
  788. 'fname' => strip_tags($foruminfo['name']),
  789. 'operator' => $windid,
  790. ));
  791. $credit->sets($rt['authorid'],$creditset[$creditOpKey],false);
  792. if ($rt['aid']) {
  793. $_tids[$rt['tid']] = $rt['tid'];
  794. $_pids[$rt['pid']] = $rt['pid'];
  795. }
  796. if ($_POST['ifmsg']) {
  797. if (!$rt['subject']) {
  798. $rt['subject'] = substrs($rt['content'],35);
  799. }
  800. M::sendNotice(
  801. array($rt['author']),
  802. array(
  803. 'title' => getLangInfo('writemsg','delrp_title'),
  804. 'content' => getLangInfo('writemsg','delrp_content',array(
  805. 'manager' => $windid,
  806. 'fid' => $fid,
  807. 'tid' => $rt['tid'],
  808. 'subject' => substrs($rt['subject'],28),
  809. 'postdate' => get_date($rt['postdate']),
  810. 'forum' => strip_tags($forum[$fid]['name']),
  811. 'affect' => "{$db_rvrcname}:-{$msg_delrvrc},{$db_moneyname}:-{$msg_delmoney}",
  812. 'admindate' => get_date($timestamp),
  813. 'reason' => stripslashes($atc_content)
  814. )),
  815. )
  816. );
  817. }
  818. }
  819. $credit->runsql();
  820. //$db->update("DELETE FROM $pw_posts WHERE pid IN($tids)");
  821. pwQuery::delete($pw_posts, 'pid IN(:pid)', array($pidArr));
  822. if ($_tids && $_pids) {
  823. $pw_attachs = L::loadDB('attachs', 'forum');
  824. $attachdb = $pw_attachs->getByTid($_tids,$_pids);
  825. require_once(R_P.'require/updateforum.php');
  826. delete_att($attachdb);
  827. pwFtpClose($ftp);
  828. }
  829. $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */
  830. foreach ($deluids as $uid => $value) {
  831. $userService->updateByIncrement($uid, array(), array('postnum' => -$value));
  832. }
  833. refreshto("forumcp.php?action=edit&type=$type&fid=$fid",'operate_success');
  834. }
  835. } elseif ($type == 'commend') {
  836. if (empty($_POST['step'])) {
  837. $commendThread = array();
  838. if ($forumset['commendlist']) {
  839. $query = $db->query("SELECT tid,authorid,author,postdate,subject FROM pw_threads WHERE tid IN($forumset[commendlist])");
  840. while ($rt=$db->fetch_array($query)) {
  841. $rt['postdate'] = get_date($rt['postdate']);
  842. $commendThread[] = $rt;
  843. }
  844. }
  845. require_once PrintEot('forumcp');footer();
  846. } else {
  847. PostCheck();
  848. S::gp(array('selid'));
  849. foreach ($selid as $key => $value) {
  850. if (is_numeric($value)) {
  851. $forumset['commendlist'] = trim(str_replace(",$value,",",",",$forumset[commendlist],"),',');
  852. }
  853. }
  854. updatecommend($fid,$forumset);
  855. refreshto("forumcp.php?action=edit&type=$type&fid=$fid",'operate_success');
  856. }
  857. } elseif ($type == 'adminset') {
  858. !$first_admin && Showmsg('undefined_action');
  859. $admin_a = explode(',',trim($forums['forumadmin'],','));
  860. $firstadmin = $admin_a[0];
  861. $firstadmin != $windid && Showmsg('undefined_action');
  862. if (empty($_POST['step'])) {
  863. $s_admin = trim(str_replace(",$firstadmin,",',',$forums['forumadmin']),',');
  864. require_once(PrintEot('forumcp'));footer();
  865. } else {
  866. PostCheck();
  867. S::gp(array('forumadmin'),'P');
  868. $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */
  869. $errorname = '';
  870. if ($forums['forumadmin'] != stripslashes(",".$windid.",$forumadmin,")) {
  871. $newadmin = array('0'=>$windid);
  872. $newadmin_a = array_unique(explode(",",$forumadmin));
  873. foreach ($newadmin_a as $aid => $value) {
  874. $value = trim($value);
  875. if ($value && !in_array($value,$newadmin)) {
  876. $mb = $userService->getByUserName($value);
  877. if ($mb) {
  878. $newadmin[] = $value;
  879. if ($mb['groupid'] == -1) {
  880. $userService->update($mb['uid'], array('groupid' => 5));
  881. $pwSQL = S::sqlSingle(array(
  882. 'uid' => $mb['uid'],
  883. 'username' => $value,
  884. 'groupid' => 5,
  885. 'groups' => $mb['groups']
  886. ));
  887. $db->update("REPLACE INTO pw_administrators SET $pwSQL");
  888. } elseif ($mb['groupid'] <> 5 && strpos($mb['groups'],',5,')===false) {
  889. $mb['groups'] = $mb['groups'] ? $mb['groups'].'5,' : ",5,";
  890. $userService->update($mb['uid'], array('groups' => $mb['groups']));
  891. $pwSQL = S::sqlSingle(array(
  892. 'uid' => $mb['uid'],
  893. 'username' => $value,
  894. 'groupid' => $mb['groupid'],
  895. 'groups' => $mb['groups']
  896. ));
  897. $db->update("REPLACE INTO pw_administrators SET $pwSQL");
  898. }
  899. } else {
  900. $errorname .= ','.$value;
  901. }
  902. }
  903. }
  904. $oldfadmin = explode(',',trim($forums['forumadmin'],','));
  905. if ($oldfadmin) {
  906. $f_admin = array();
  907. $query = $db->query("SELECT forumadmin FROM pw_forums WHERE fid<>".S::sqlEscape($fid)." AND forumadmin<>''");
  908. while ($rt = $db->fetch_array($query)) {
  909. foreach (explode(",",$rt['forumadmin']) as $key=>$value) {
  910. if ($value = trim($value)) {
  911. $f_admin[] = $value;
  912. }
  913. }
  914. }
  915. $f_admin = array_unique($f_admin);
  916. foreach ($userService->getByUserNames($oldfadmin) as $rt) {
  917. if (!in_array($rt['username'],$newadmin) && !in_array($rt['username'],$f_admin)) {
  918. if ($rt['groupid']=='5') {
  919. $userService->update($rt['uid'], array('groupid' => -1));
  920. $rt['groupid'] = -1;
  921. } else {
  922. $rt['groups'] = str_replace(',5,',',',$rt['groups']);
  923. $rt['groups']==',' && $rt['groups'] = '';
  924. $userService->update($rt['uid'], array('groups' => $rt['groups']));
  925. }
  926. if (in_array($rt['groupid'],array('-1','6','7')) && $rt['groups']=='') {
  927. $db->update("DELETE FROM pw_administrators WHERE uid=".S::sqlEscape($rt['uid'],false));
  928. } else {
  929. $db->update("REPLACE INTO pw_administrators SET".S::sqlSingle(array(
  930. 'uid' => $rt['uid'],
  931. 'username' => $rt['username'],
  932. 'groupid' => $rt['groupid'],
  933. 'groups' => $rt['groups']
  934. ),false));
  935. }
  936. }
  937. }
  938. }
  939. $newadmin = addslashes(implode(',',$newadmin));
  940. //$db->update("UPDATE pw_forums SET forumadmin=',$newadmin,' WHERE fid=".S::sqlEscape($fid));
  941. pwQuery::update('pw_forums', 'fid=:fid', array($fid), array('forumadmin'=>",$newadmin,"));
  942. require_once R_P.'admin/cache.php';
  943. updatecache_forums($fid);
  944. updatecache_fd(true);
  945. }
  946. if ($errorname) {
  947. $errorname = S::escapeChar(substr($errorname,1));
  948. Showmsg('user_not_exists');
  949. } else {
  950. refreshto("forumcp.php?action=edit&type=$type&fid=$fid",'operate_success');
  951. }
  952. }
  953. } elseif ($type == 'trecycle' && $db_recycle) {
  954. require_once(R_P.'require/updateforum.php');
  955. require_once(R_P.'require/writelog.php');
  956. S::gp(array('page','step'),'GP',2);
  957. if (empty($step)) {
  958. S::gp(array('username','starttime','endtime','t_type'));
  959. $page<1 && $page = 1;
  960. $limit = S::sqlLimit(($page-1)*$db_perpage,$db_perpage);
  961. $sql = $url_a = '';
  962. $starttime && $starttime= PwStrtoTime($starttime);
  963. $endtime && $endtime = PwStrtoTime($endtime);
  964. if ($username) {
  965. $sql.=' AND t.author='.S::sqlEscape($username);
  966. $url_a.="username=".rawurlencode($username)."&";
  967. }
  968. if ($starttime) {
  969. $sql.=' AND t.postdate>'.S::sqlEscape($starttime);
  970. $url_a.="starttime=$starttime&";
  971. }
  972. if ($endtime) {
  973. $sql.=' AND t.postdate<'.S::sqlEscape($endtime);
  974. $url_a.="endtime=$endtime&";
  975. }
  976. if ($t_type) {
  977. switch($t_type) {
  978. case 'digest':
  979. $sql.=" AND t.digest>'0'";
  980. break;
  981. case 'active':
  982. $sql.=" AND t.special='2'";
  983. break;
  984. case 'reward':
  985. $sql.=" AND t.special='3'";
  986. break;
  987. case 'sale':
  988. $sql.=" AND t.special='4'";
  989. break;
  990. default :
  991. }
  992. ${'t_type_'.$t_type} = 'selected';
  993. $url_a.="t_type=$t_type&";
  994. }
  995. $rt = $db->get_one("SELECT COUNT(*) AS sum FROM pw_recycle r LEFT JOIN pw_threads t USING(tid) WHERE r.pid='0' AND r.fid=".S::sqlEscape($fid).$sql);
  996. $pages = numofpage($rt['sum'],$page,ceil($rt['sum']/$db_perpage), "forumcp.php?action=edit&type=trecycle&fid=$fid&$url_a");
  997. $ttable_a = array();
  998. $query = $db->query("SELECT r.*,t.subject,t.author,t.authorid,t.postdate FROM pw_recycle r LEFT JOIN pw_threads t USING(tid) WHERE r.pid='0' AND r.fid=".S::sqlEscape($fid).$sql." ORDER BY deltime DESC $limit");
  999. while ($rt = $db->fetch_array($query)) {
  1000. $rt['deltime'] = get_date($rt['deltime']);
  1001. $rt['subject'] = substrs($rt['subject'],40);
  1002. $rt['fname'] = $forum[$rt['fid']]['name'];
  1003. $rt['postdate'] = get_date($rt['postdate'], 'Y-m-d H:i:s');
  1004. $recycledb[$rt['tid']] = $rt;
  1005. $ttable_a[GetTtable($rt['tid'])][] = $rt['tid'];
  1006. }
  1007. foreach ($ttable_a as $pw_tmsgs => $value) {
  1008. $value = S::sqlImplode($value);
  1009. $query = $db->query("SELECT tid,content,userip FROM $pw_tmsgs WHERE tid IN($value)");
  1010. while ($rt = $db->fetch_array($query)) {
  1011. $rt['content'] = str_replace("\n","<br>",$rt['content']);
  1012. $recycledb[$rt['tid']]['content'] = convert($rt['content'], $db_windpost);
  1013. $recycledb[$rt['tid']]['userip'] = $rt['userip'];
  1014. }
  1015. }
  1016. require_once(PrintEot('forumcp'));footer();
  1017. } elseif ($_POST['step'] == '1' && $forumset['recycle'] & 2) {
  1018. PostCheck();
  1019. S::gp(array('ids'),'P');
  1020. count($ids) > 500 && Showmsg('forumcp_recycle_maxcount');
  1021. recycle($ids);
  1022. $logdb = array(
  1023. 'type' => 'recycle',
  1024. 'username1' => '',
  1025. 'username2' => $windid,
  1026. 'field1' => $fid,
  1027. 'field2' => '',
  1028. 'field3' => '',
  1029. 'descrip' => 'recycle_topic_delete',
  1030. 'timestamp' => $timestamp,
  1031. 'ip' => $onlineip,
  1032. 'affect' => '',
  1033. 'forum' => $forum[$fid]['name'],
  1034. 'reason' => ''
  1035. );
  1036. writelog($logdb);
  1037. refreshto("forumcp.php?action=edit&type=trecycle&fid=$fid",'operate_success');
  1038. } elseif ($_POST['step'] == '2' && $forumset['recycle'] & 4) {
  1039. PostCheck();
  1040. S::gp(array('ids'),'P');
  1041. count($ids) > 500 && Showmsg('forumcp_recycle_maxcount');
  1042. $reids = $logdb = $ptable_a = array();
  1043. foreach ($ids as $key => $value) {
  1044. if (is_numeric($value)) {
  1045. $reids[] = $value;
  1046. }
  1047. }
  1048. !$reids && Showmsg('forumcp_recycle_nodata');
  1049. $reids = S::sqlImplode($reids);
  1050. $query = $db->query("SELECT r.*,t.ptable FROM pw_recycle r LEFT JOIN pw_threads t ON r.tid=t.tid WHERE r.pid='0' AND r.tid IN ($reids)");
  1051. $reids = $ptable_a = array();
  1052. while ($read = $db->fetch_array($query)) {
  1053. $read['fid'] != $fid && Showmsg('admin_forum_right');
  1054. $ptable_a[$read['ptable']] = 1;
  1055. $reids[] = $read['tid'];
  1056. }
  1057. if ($reids) {
  1058. $pw_attachs = L::loadDB('attachs', 'forum');
  1059. $pw_attachs->updateByTid($reids,array('fid'=>$fid));
  1060. //* $reids = S::sqlImplode($reids);
  1061. //* $db->update("UPDATE pw_threads SET ".S::sqlSingle(array('fid'=>$fid,'ifshield'=>0))."WHERE tid IN($reids)");
  1062. pwQuery::update('pw_threads', 'tid IN (:tid)' , array($reids), array('fid'=>$fid,'ifshield'=>0));
  1063. $db->update("DELETE FROM pw_recycle WHERE tid IN (" . S::sqlImplode($reids) . ")");
  1064. foreach ($ptable_a as $key => $val) {
  1065. $pw_posts = GetPtable($key);
  1066. //$db->update("UPDATE $pw_posts SET fid=".S::sqlEscape($fid)."WHERE tid IN($reids)");
  1067. pwQuery::update($pw_posts, 'tid IN(:tid)', array($reids), array('fid' => $fid));
  1068. }
  1069. }
  1070. updateforum($fid);
  1071. $logdb = array(
  1072. 'type' => 'recycle',
  1073. 'username1' => '',
  1074. 'username2' => $windid,
  1075. 'field1' => $fid,
  1076. 'field2' => '',
  1077. 'field3' => '',
  1078. 'descrip' => 'recycle_topic_restore',
  1079. 'timestamp' => $timestamp,
  1080. 'ip' => $onlineip,
  1081. 'affect' => '',
  1082. 'forum' => $forum[$fid]['name'],
  1083. 'reason' => ''
  1084. );
  1085. writelog($logdb);
  1086. refreshto("forumcp.php?action=edit&type=trecycle&fid=$fid",'operate_success');
  1087. } elseif ($step == '3' && $forumset['recycle'] & 8) {
  1088. PostCheck();
  1089. $ids = array();
  1090. $flag = false;
  1091. $query = $db->query("SELECT * FROM pw_recycle WHERE fid=".S::sqlEscape($fid)." AND pid='0' LIMIT 100");
  1092. while ($rt = $db->fetch_array($query)) {
  1093. $flag || $flag = true;
  1094. $ids[] = $rt['tid'];
  1095. }
  1096. if ($flag) {
  1097. recycle($ids);
  1098. refreshto("forumcp.php?action=edit&type=trecycle&fid=$fid&step=3&verify=$verifyhash", 'delete_recycle');
  1099. } else {
  1100. $logdb = array(
  1101. 'type' => 'recycle',
  1102. 'username1' => '',
  1103. 'username2' => $windid,
  1104. 'field1' => $fid,
  1105. 'field2' => '',
  1106. 'field3' => '',
  1107. 'descrip' => 'recycle_topic_empty',
  1108. 'timestamp' => $timestamp,
  1109. 'ip' => $onlineip,
  1110. 'affect' => '',
  1111. 'forum' => $forum[$fid]['name'],
  1112. 'reason' => ''
  1113. );
  1114. writelog($logdb);
  1115. refreshto("forumcp.php?action=edit&type=trecycle&fid=$fid",'operate_success');
  1116. }
  1117. }
  1118. } elseif ($type == 'precycle' && $db_recycle) {
  1119. require_once(R_P.'require/updateforum.php');
  1120. require_once(R_P.'require/writelog.php');
  1121. S::gp(array('ptable'));
  1122. S::gp(array('step','page'),'GP',2);
  1123. $db_perpage = 10;
  1124. if (empty($step)) {
  1125. S::gp(array('username','starttime','endtime','t_type'));
  1126. $sql = $url_a = '';
  1127. if ($db_plist && count($db_plist)>1) {
  1128. !is_numeric($ptable) && $ptable = $db_ptable;
  1129. foreach ($db_plist as $key=>$val) {
  1130. $name = $val ? $val : ($key != 0 ? getLangInfo('other','posttable').$key : getLangInfo('other','posttable'));
  1131. $p_table .= "<option value=\"$key\">".$name."</option>";
  1132. }
  1133. $p_table = str_replace("<option value=\"$ptable\">","<option value=\"$ptable\" selected>",$p_table);
  1134. $url_a .= "ptable=$ptable&";
  1135. $pw_posts = GetPtable($ptable);
  1136. } else {
  1137. $pw_posts = 'pw_posts';
  1138. }
  1139. $starttime && $starttime= PwStrtoTime($starttime);
  1140. $endtime && $endtime = PwStrtoTime($endtime);
  1141. if ($username) {
  1142. $sql.=' AND p.author='.S::sqlEscape($username);
  1143. $url_a.="username=".rawurlencode($username)."&";
  1144. }
  1145. if ($starttime) {
  1146. $sql.=' AND p.postdate>'.S::sqlEscape($starttime);
  1147. $url_a.="starttime=$starttime&";
  1148. }
  1149. if ($endtime) {
  1150. $sql.=' AND p.postdate<'.S::sqlEscape($endtime);
  1151. $url_a.="endtime=$endtime&";
  1152. }
  1153. if ($t_type) {
  1154. switch($t_type) {
  1155. case 'digest':
  1156. $sql.=" AND t.digest>'0'";
  1157. break;
  1158. case 'active':
  1159. $sql.=" AND t.special='2'";
  1160. break;
  1161. case 'reward':
  1162. $sql.=" AND t.special='3'";
  1163. break;
  1164. case 'sale':
  1165. $sql.=" AND t.special='4'";
  1166. break;
  1167. default :
  1168. $sql.="";
  1169. }
  1170. ${'t_type_'.$t_type} = 'selected';
  1171. $url_a.="t_type=$t_type&";
  1172. }
  1173. (!is_numeric($page) || $page<1) && $page = 1;
  1174. $limit = "LIMIT ".($page-1)*$db_perpage.",$db_perpage";
  1175. $rt = $db->get_one("SELECT COUNT(*) AS sum FROM pw_recycle r LEFT JOIN $pw_posts p USING(pid) LEFT JOIN pw_threads t ON r.tid=t.tid WHERE r.fid=".S::sqlEscape($fid)." AND r.pid>'0' AND p.fid='0' $sql");
  1176. $pages = numofpage($rt['sum'],$page,ceil($rt['sum']/$db_perpage), "forumcp.php?action=edit&type=precycle&fid=$fid&$url_a");
  1177. $query = $db->query("SELECT r.*,p.author,p.authorid,p.content,p.postdate,t.subject FROM pw_recycle r LEFT JOIN $pw_posts p ON r.pid=p.pid LEFT JOIN pw_threads t ON r.tid=t.tid WHERE r.fid=".S::sqlEscape($fid)." AND r.pid>'0' AND p.fid='0' $sql ORDER BY r.deltime DESC $limit");
  1178. while ($rt = $db->fetch_array($query)) {
  1179. $rt['deltime'] = get_date($rt['deltime']);
  1180. $rt['postdate'] = get_date($rt['postdate']);
  1181. $rt['subject'] = substrs($rt['subject'],40);
  1182. $rt['content'] = str_replace("\n","<br>",$rt['content']);
  1183. $rt['content'] = convert($rt['content'], $db_windpost);
  1184. $rt['fname'] = $forum[$rt['fid']]['name'];
  1185. $recycledb[] = $rt;
  1186. }
  1187. require_once(PrintEot('forumcp'));footer();
  1188. } elseif ($_POST['step'] == '1' && $forumset['recycle'] & 2) {
  1189. PostCheck();
  1190. S::gp(array('ids'),'P');
  1191. count($ids) > 500 && Showmsg('forumcp_recycle_maxcount');
  1192. $delids = array();
  1193. foreach ($ids as $key => $value) {
  1194. if (is_numeric($value)) {
  1195. $delids[] = $value;
  1196. }
  1197. }
  1198. $delids && $delids = S::sqlImplode($delids);
  1199. !$delids && Showmsg('forumcp_recycle_nodata');
  1200. !is_numeric($ptable) && $ptable = $db_ptable;
  1201. $pw_posts = GetPtable($ptable);
  1202. $_pids = $_tids = array();
  1203. $query = $db->query("SELECT * FROM pw_recycle WHERE pid IN($delids)");
  1204. while ($read = $db->fetch_array($query)) {
  1205. $read['fid'] != $fid && Showmsg('admin_forum_right');
  1206. $_tids[$read['tid']] = $read['tid'];
  1207. $_pids[$read['pid']] = $read['pid'];
  1208. }
  1209. if ($_pids) {
  1210. $pw_attachs = L::loadDB('attachs', 'forum');
  1211. $atta

Large files files are truncated, but you can click here to view the full file