A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

586 lines
21 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file admin/admin_forums.php
  5. * @version $Id$
  6. * @copyright 2009(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/
  8. * @license GNU GPL v3
  9. **/
  10. define('IN_uF', true);
  11. //include files
  12. include('./../config.php');
  13. include('./../includes/constants.php');
  14. include('./../includes/db.php');
  15. include('./../includes/errors.php');
  16. //connect to database
  17. DataBase::db_connect();
  18. include('./../includes/sessions.php');
  19. include('./../includes/classes/class_user.php');
  20. include('./../common.php');
  21. include('./../includes/admin/class_main.php');
  22. include('./../includes/classes/class_forum.php');
  23. include('./../includes/admin/class_forum.php');
  24. include('./../lngs/'.Admin_Over::DefaultLang().'/admin.php');
  25. SessDelInvalid();
  26. SessRegister();
  27. SessDeleteOld();
  28. if (User::UserInformation($_SESSION['uid'],'rank')!=2)
  29. {
  30. admin_message_forum($lng['yournotadmin'],'../index.php');
  31. }
  32. function GenerateDefaultDisplay()
  33. {
  34. //cache forums --don't modify!!!
  35. $cache_id=1;
  36. $sql = "SELECT * FROM ".FORUMS_TABLE." ORDER BY `c_id`, `sort`";
  37. $query = DataBase::sql_query($sql,CRITICAL,'Could not obtain forum information.');
  38. while($result = DataBase::fetch($query))
  39. {
  40. $forum[$cache_id]['f_id'] = $result['f_id'];
  41. $forum[$cache_id]['name'] = $result['name'];
  42. $forum[$cache_id]['desc'] = $result['desc'];
  43. $forum[$cache_id]['c_id'] = $result['c_id'];
  44. $forum[$cache_id]['sort'] = $result['sort'];
  45. $cache_id+=1;
  46. }
  47. global $lng;
  48. global $default_skin;
  49. global $forum_config;
  50. //add skin variables
  51. $skin = array(
  52. 'forums&cats'=>$lng['forums_and_cats'],
  53. 'here_write_name_forum'=>$lng['here_write_name_forum'],
  54. 'new_forum_submit'=>$lng['new_forum_submit'],
  55. );
  56. Admin_Over::GenerateHeader();
  57. include('./template/forums_beam_body.tpl');
  58. //add forums and categories
  59. $sql = "SELECT * FROM `".CATS_TABLE."` ORDER BY `sort`";
  60. $query = DataBase::sql_query($sql,CRITICAL,'Could not obtain categories information.');
  61. while($result = DataBase::fetch($query))
  62. {
  63. $skin = array(
  64. 'category' => $result['name'],
  65. 'c_id'=>$result['c_id'],
  66. 'edit_cat'=>$lng['edit_cat'],
  67. 'move_up'=>$lng['moveup'],
  68. 'move_down'=>$lng['movedown'],
  69. 'delete'=>$lng['delete'],
  70. 'del_cat'=>$lng['c_del_cat']
  71. );
  72. include('./template/forum_category_add.tpl');
  73. for ($i=1; $i<=count($forum); $i++)
  74. {
  75. if ($forum[$i]['c_id']==$result['c_id'])
  76. {
  77. $skin = array(
  78. 'forum_name' => $forum[$i]['name'],
  79. 'forum_id' => $forum[$i]['f_id'],
  80. 'description' => $forum[$i]['desc'],
  81. 'move_up'=>$lng['moveup'],
  82. 'edit_forum'=>$lng['edit_forum'],
  83. 'del_forum'=>$lng['c_del_forum'],
  84. 'move_down'=>$lng['movedown'],
  85. 'delete'=>$lng['delete']
  86. );
  87. include('./template/forum_forum_add.tpl');
  88. }
  89. }
  90. echo '<span class="fsmall">&nbsp;<br></span>';
  91. }
  92. $skin = array(
  93. 'here_write_name_cat'=>$lng['here_write_name_cat'],
  94. 'new_cat_submit'=>$lng['new_cat_submit']
  95. );
  96. include('./template/forums_view_end_body.tpl');
  97. include('./template/overall_footer.tpl');
  98. }
  99. if (!isset($_GET['mode']))
  100. {
  101. header('Location: admin_forums.php?mode=view');
  102. }
  103. switch($_GET['mode'])
  104. {
  105. case 'new':
  106. {
  107. switch($_GET['submode'])
  108. {
  109. case 'cat':
  110. {
  111. if (isset($_POST['cat_name']))
  112. {
  113. if (strlen($_POST['cat_name'])>=5)
  114. {
  115. $cat_name = strip_tags($_POST['cat_name']);
  116. $sql = "SELECT `sort` FROM `".CATS_TABLE."` ORDER BY `sort` DESC LIMIT 1";
  117. $last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last category sort id'));
  118. $sort = $last ['sort'];
  119. $sort = $sort+1;
  120. $sql = "SELECT `c_id` FROM `".CATS_TABLE."` ORDER BY `c_id` DESC LIMIT 1";
  121. $last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last category id'));
  122. $last = $last['c_id'];
  123. $last = $last +1;
  124. $sql = "INSERT INTO `".CATS_TABLE."` VALUES ('$last','$cat_name','$sort')";
  125. DataBase::sql_query($sql,GENERAL,'Could not add category');
  126. $msg='./template/blank.tpl';
  127. admin_message_forum($lng['cat_saved'],'admin_forums.php');
  128. }
  129. else
  130. {
  131. $msg = './../skins/'.$default_skin.'/post_error_body.tpl';
  132. $message = $lng['to_short_cat_name'];
  133. }
  134. }
  135. else
  136. {
  137. $_POST['cat_name'] = '';
  138. $msg='./../skins/'.$default_skin.'/blank.tpl';
  139. }
  140. $skin = array(
  141. 'here_write_name_forum'=>$lng['here_write_name_forum'],
  142. 'here_write_name_cat'=>$lng['here_write_name_cat'],
  143. 'new_forum_submit'=>$lng['new_forum_submit'],
  144. 'new_cat_submit'=>$lng['new_cat_submit'],
  145. 'L.save'=>$lng['submit'],
  146. 'L.reset'=>$lng['reset'],
  147. 'L.cat_name'=>$lng['cat_name'],
  148. 'forums&cats'=>$lng['forums_and_cats'],
  149. 'L.main_beam'=>$lng['new_cat'],
  150. 'action'=>'admin_forums.php?mode=new&submode=cat'
  151. );
  152. Admin_Over::GenerateHeader();
  153. include('./template/cat_new_edit_body.tpl');
  154. include('./template/overall_footer.tpl');
  155. break;
  156. }
  157. case 'forum':
  158. {
  159. if (isset($_POST['forum_name'], $_POST['forum_desc']))
  160. {
  161. if (strlen($_POST['forum_name'])>=5)
  162. {
  163. if (strlen($_POST['forum_desc'])>=5)
  164. {
  165. $forum_name = strip_tags($_POST['forum_name']);
  166. $forum_desc = strip_tags($_POST['forum_desc']);
  167. $forum_cat = $_POST['forum_cat'];
  168. $forum_lock = (isset($_POST['forum_locked'])) ? 1 : 0;
  169. $allow_moderate = (isset($_POST['allow_moderate'])) ? 1 : 0;
  170. $sql = "SELECT `sort`, `c_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$forum_cat' ORDER BY `sort` DESC LIMIT 1";
  171. $last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last forum sort id'));
  172. $sort = $last ['sort'];
  173. $sort = $sort+1;
  174. $sql = "SELECT `f_id` FROM `".FORUMS_TABLE."` ORDER BY `f_id` DESC LIMIT 1";
  175. $last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last forum id'));
  176. $last = $last['f_id'];
  177. $last = $last +1;
  178. $sql = "INSERT INTO `".FORUMS_TABLE."` VALUES ('$last','$forum_lock','$allow_moderate', '$forum_name', '$forum_desc', '0', '','$forum_cat','$sort')";
  179. DataBase::sql_query($sql,GENERAL,'Could not add forum');
  180. $msg='./../skins/'.$default_skin.'/blank.tpl';
  181. admin_message_forum($lng['forum_saved'],'admin_forums.php');
  182. }
  183. else
  184. {
  185. $msg = './../skins/'.$default_skin.'/post_error_body.tpl';
  186. $message = $lng['to_short_forum_desc'];
  187. }
  188. }
  189. else
  190. {
  191. $msg = './../skins/'.$default_skin.'/post_error_body.tpl';
  192. $message = $lng['to_short_forum_name'];
  193. }
  194. }
  195. else
  196. {
  197. if (!isset($_POST['forum_name'])) { $_POST['forum_name'] = ''; }
  198. if (!isset($_POST['forum_desc'])) { $_POST['forum_desc'] = ''; }
  199. $msg='./../skins/'.$default_skin.'/blank.tpl';
  200. }
  201. $skin = array(
  202. 'here_write_name_forum'=>$lng['here_write_name_forum'],
  203. 'here_write_name_cat'=>$lng['here_write_name_cat'],
  204. 'new_forum_submit'=>$lng['new_forum_submit'],
  205. 'new_cat_submit'=>$lng['new_cat_submit'],
  206. 'L.save'=>$lng['submit'],
  207. 'L.reset'=>$lng['reset'],
  208. 'L.forum_name'=>$lng['forum_name'],
  209. 'L.change_cat'=>$lng['change_cat'],
  210. 'L.forum_locked'=>$lng['forum_locked'],
  211. 'on'=>$lng['allow'],
  212. 'OPTION.forum_locked'=> '',
  213. 'L.allow_moderate'=>$lng['moderate_posts'],
  214. 'forums&cats'=>$lng['forums_and_cats'],
  215. 'OPTION.allow_moderate'=>'',
  216. 'OPTIONS.forum_cat'=>Admin_Forum::AddCats(0),
  217. 'L.forum_desc'=>$lng['forum_desc'],
  218. 'L.main_beam'=>$lng['new_forum'],
  219. 'action'=>'admin_forums.php?mode=new&submode=forum'
  220. );
  221. Admin_Over::GenerateHeader();
  222. include('./template/forum_new_edit_body.tpl');
  223. include('./template/overall_footer.tpl');
  224. break;
  225. }
  226. }
  227. break;
  228. }
  229. case 'moveup':
  230. {
  231. //temp variables
  232. $i1 = 0;
  233. $i2 = 0;
  234. $r1 = 0;
  235. $r2 = 0;
  236. //BEGIN switch - submode
  237. switch($_GET['submode'])
  238. {
  239. case 'cat':
  240. {
  241. if (isset($_GET['c']))
  242. {
  243. $i1 = $_GET['c'];
  244. $sql = "SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `c_id`='$i1'";
  245. $s1 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain category information.'));
  246. $s1 = $s1['sort'];
  247. $s2 = $s1 -1;
  248. if ($s1>1)
  249. {
  250. $sql = "SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `sort`='$s2'";
  251. $s2 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain category information.'));
  252. $i2 = $s2['c_id'];
  253. $s2 = $s2['sort'];
  254. $sql = "UPDATE ".CATS_TABLE." SET `sort`='$s2' WHERE `c_id`='$i1'";
  255. DataBase::sql_query($sql,GENERAL,'Could not update category position');
  256. $sql = "UPDATE ".CATS_TABLE." SET `sort`='$s1' WHERE `c_id`='$i2'";
  257. DataBase::sql_query($sql,GENERAL,'Could not update category position');
  258. }
  259. }
  260. break;
  261. }
  262. case 'forum':
  263. {
  264. if (isset($_GET['f']))
  265. {
  266. $i1 = $_GET['f'];
  267. $sql = "SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `f_id`='$i1'";
  268. $s1 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain forum information.'));
  269. $cid = $s1['c_id'];
  270. $s1 = $s1['sort'];
  271. $s2 = $s1 -1;
  272. if ($s1>1)
  273. {
  274. $sql = "SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `sort`='$s2' AND `c_id`='$cid'";
  275. $s2 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not forum forum information.'));
  276. $i2 = $s2['f_id'];
  277. $s2 = $s2['sort'];
  278. $sql = "UPDATE ".FORUMS_TABLE." SET `sort`='$s2' WHERE `f_id`='$i1'";
  279. DataBase::sql_query($sql,GENERAL,'Could not update forum position');
  280. $sql = "UPDATE ".FORUMS_TABLE." SET `sort`='$s1' WHERE `f_id`='$i2'";
  281. DataBase::sql_query($sql,GENERAL,'Could not update forum position');
  282. }
  283. }
  284. break;
  285. }
  286. }
  287. //END switch - submode
  288. GenerateDefaultDisplay();
  289. break;
  290. }
  291. case 'movedown':
  292. {
  293. //temp variables
  294. $i1 = 0;
  295. $i2 = 0;
  296. $r1 = 0;
  297. $r2 = 0;
  298. //BEGIN switch - submode
  299. switch($_GET['submode'])
  300. {
  301. case 'cat':
  302. {
  303. if (isset($_GET['c']))
  304. {
  305. $i1 = $_GET['c'];
  306. $i2 = $i1 +1;
  307. $sql = "SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `c_id`='$i1'";
  308. $s1 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain category information.'));
  309. $s1 = $s1['sort'];
  310. $s2 = $s1 +1;
  311. $sql = "SELECT `c_id` FROM ".CATS_TABLE;
  312. $count = DataBase::num_rows(DataBase::sql_query($sql,CRITICAL,'Could not obtain category information.'));
  313. if ($s1<$count)
  314. {
  315. $sql = "SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `sort`='$s2'";
  316. $s2 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain category information.'));
  317. $i2 = $s2['c_id'];
  318. $s2 = $s2['sort'];
  319. $sql = "UPDATE ".CATS_TABLE." SET `sort`='$s2' WHERE `c_id`='$i1'";
  320. DataBase::sql_query($sql,GENERAL,'Could not update category position');
  321. $sql = "UPDATE ".CATS_TABLE." SET `sort`='$s1' WHERE `c_id`='$i2'";
  322. DataBase::sql_query($sql,GENERAL,'Could not update category position');
  323. }
  324. }
  325. break;
  326. }
  327. case 'forum':
  328. {
  329. if (isset($_GET['f']))
  330. {
  331. $i1 = $_GET['f'];
  332. $i2 = $i1 +1;
  333. $sql = "SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `f_id`='$i1'";
  334. $s1 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain forum information.'));
  335. $cid = $s1['c_id'];
  336. $s1 = $s1['sort'];
  337. $s2 = $s1 +1;
  338. $sql = "SELECT `f_id` FROM ".FORUMS_TABLE." WHERE `c_id`='$cid'";
  339. $count = DataBase::num_rows(DataBase::sql_query($sql,CRITICAL,'Could not obtain forum information.'));
  340. if ($s1<$count)
  341. {
  342. $sql = "SELECT `sort`, `f_id` FROM ".FORUMS_TABLE." WHERE `sort`='$s2'";
  343. $s2 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain forum information.'));
  344. $i2 = $s2['f_id'];
  345. $s2 = $s2['sort'];
  346. $sql = "UPDATE ".FORUMS_TABLE." SET `sort`='$s2' WHERE `f_id`='$i1'";
  347. DataBase::sql_query($sql,GENERAL,'Could not update forum position');
  348. $sql = "UPDATE ".FORUMS_TABLE." SET `sort`='$s1' WHERE `f_id`='$i2'";
  349. DataBase::sql_query($sql,GENERAL,'Could not update forum position');
  350. }
  351. }
  352. break;
  353. }
  354. }
  355. //END switch - submode
  356. GenerateDefaultDisplay();
  357. break;
  358. }
  359. case 'delete':
  360. {
  361. //BEGIN switch - submode
  362. switch($_GET['submode'])
  363. {
  364. case 'cat':
  365. {
  366. if (isset($_GET['c']))
  367. {
  368. $cid = intval($_GET['c']);
  369. $sql = "SELECT * FROM `".CATS_TABLE."` WHERE `c_id`='$cid'";
  370. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain category information');
  371. $result = DataBase::fetch($query);
  372. $sort = $result['sort'];
  373. $sql = "SELECT * FROM `".CATS_TABLE."` WHERE `sort`>'$sort'";
  374. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain categories information');
  375. while($item = DataBase::fetch($query))
  376. {
  377. $new_sort = $item['sort']-1;
  378. $cid2 = $item['c_id'];
  379. $sql2 = "UPDATE `".CATS_TABLE."` SET `sort`='$new_sort' WHERE `c_id`='$cid2'";
  380. DataBase::sql_query($sql,GENERAL,'Could not update category');
  381. }
  382. $sql = "SELECT `f_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$cid'";
  383. $query = DataBase::sql_query($sql, GENERAL,'Could not obtain forum information.');
  384. while($item = DataBase::fetch($query))
  385. {
  386. $fid = $item['f_id'];
  387. $sql="DELETE FROM `".POSTS_TABLE."` WHERE `f_id`='$fid'";
  388. DataBase::sql_query($sql, GENERAL,'Could not delete post.');
  389. $sql = "DELETE FROM `".TOPICS_TABLE."` WHERE `f_id`='$fid'";
  390. DataBase::sql_query($sql, GENERAL,'Could not delete topic');
  391. }
  392. $sql = "DELETE FROM `".FORUMS_TABLE."` WHERE `c_id`='$cid'";
  393. DataBase::sql_query($sql, GENERAL,'Could not delete topic');
  394. $sql = "DELETE FROM `".CATS_TABLE."` WHERE `c_id`='$cid'";
  395. DataBase::sql_query($sql,GENERAL,'Could not delete category.');
  396. }
  397. }
  398. case 'forum':
  399. {
  400. if (isset($_GET['f']))
  401. {
  402. $fid = intval($_GET['f']);
  403. $sql = "SELECT * FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
  404. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain forum information');
  405. $result = DataBase::fetch($query);
  406. $sort = $result['sort'];
  407. $sql = "SELECT * FROM `".FORUMS_TABLE."` WHERE `sort`>'$sort'";
  408. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain forums information');
  409. while($item = DataBase::fetch($query))
  410. {
  411. $new_sort = $item['sort']-1;
  412. $fid1 = $item['f_id'];
  413. $sql2 = "UPDATE `".FORUMS_TABLE."` SET `sort`='$new_sort' WHERE `f_id`='$fid1'";
  414. DataBase::sql_query($sql,GENERAL,'Could not update forum');
  415. }
  416. $sql="DELETE FROM `".POSTS_TABLE."` WHERE `f_id`='$fid'";
  417. DataBase::sql_query($sql, GENERAL,'Could not delete post.');
  418. $sql = "DELETE FROM `".TOPICS_TABLE."` WHERE `f_id`='$fid'";
  419. DataBase::sql_query($sql, GENERAL,'Could not delete topic');
  420. $sql = "DELETE FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
  421. DataBase::sql_query($sql, GENERAL,'Could not delete forum');
  422. }
  423. }
  424. }
  425. GenerateDefaultDisplay();
  426. break;
  427. }
  428. case 'edit':
  429. {
  430. switch($_GET['submode'])
  431. {
  432. case 'cat':
  433. {
  434. $cid = intval($_GET['c']);
  435. if (isset($_POST['cat_name']))
  436. {
  437. if (strlen($_POST['cat_name'])>=5)
  438. {
  439. $cat_name = strip_tags($_POST['cat_name']);
  440. $sql = "SELECT `sort`, `c_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$cat_name' ORDER BY `sort` DESC LIMIT 1";
  441. $last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last forum sort id'));
  442. $sort = $last ['sort'];
  443. $sort = $sort+1;
  444. $sql = "UPDATE `".CATS_TABLE."` SET `name`='$cat_name', `sort`='$sort' WHERE `c_id`='$cid'";
  445. DataBase::sql_query($sql,GENERAL,'Could not update category');
  446. $msg='./../skins/'.$default_skin.'/blank.tpl';
  447. admin_message_forum($lng['cat_saved'],'admin_forums.php');
  448. }
  449. else
  450. {
  451. $msg = './../skins/'.$default_skin.'/post_error_body.tpl';
  452. $message = $lng['to_short_cat_name'];
  453. }
  454. }
  455. else
  456. {
  457. $tmp = DataBase::fetch(DataBase::sql_query("SELECT `name` FROM `".CATS_TABLE."` WHERE `c_id`='$cid'",GENERAL,'Could not obtain category information'));
  458. $tmp = $tmp['name'];
  459. $_POST['cat_name'] = $tmp;
  460. if($tmp['name']=='')
  461. {
  462. admin_message_forum($lng['no_category'],'admin_forums.php?mode=view');
  463. }
  464. unset($tmp);
  465. $msg='./../skins/'.$default_skin.'/blank.tpl';
  466. }
  467. $skin = array(
  468. 'here_write_name_forum'=>$lng['here_write_name_forum'],
  469. 'here_write_name_cat'=>$lng['here_write_name_cat'],
  470. 'new_forum_submit'=>$lng['new_forum_submit'],
  471. 'new_cat_submit'=>$lng['new_cat_submit'],
  472. 'L.save'=>$lng['submit'],
  473. 'forums&cats'=>$lng['forums_and_cats'],
  474. 'L.reset'=>$lng['reset'],
  475. 'L.cat_name'=>$lng['cat_name'],
  476. 'L.main_beam'=>$lng['edit_cat'],
  477. 'action'=>'admin_forums.php?mode=edit&submode=cat&c='.$cid
  478. );
  479. Admin_Over::GenerateHeader();
  480. include('./template/cat_new_edit_body.tpl');
  481. include('./template/overall_footer.tpl');
  482. break;
  483. }
  484. case 'forum':
  485. {
  486. $fid = intval($_GET['f']);
  487. if (isset($_POST['forum_name'],$_POST['forum_desc']))
  488. {
  489. if (strlen($_POST['forum_name'])>=5)
  490. {
  491. if (strlen($_POST['forum_desc'])>=5)
  492. {
  493. $forum_name = strip_tags($_POST['forum_name']);
  494. $forum_desc = strip_tags($_POST['forum_desc']);
  495. $forum_cat = $_POST['forum_cat'];
  496. $sql = "SELECT * FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
  497. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain forum information');
  498. $result = DataBase::fetch($query);
  499. $actual_cid = $result['c_id'];
  500. $sort = $result['sort'];
  501. if ($actual_cid != $forum_cat)
  502. {
  503. $sql = "SELECT * FROM `".FORUMS_TABLE."` WHERE `c_id`='$forum_cat' ORDER BY `sort` DESC LIMIT 1";
  504. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain forums information');
  505. $result = DataBase::fetch($query);
  506. $sort = $result['sort']+1;
  507. }
  508. $forum_lock = (isset($_POST['forum_locked'])) ? 1 : 0;
  509. $forum_moderate = (isset($_POST['allow_moderate'])) ? 1 : 0;
  510. $sql = "UPDATE `".FORUMS_TABLE."` SET
  511. `name`='$forum_name',
  512. `desc`='$forum_desc',
  513. `lock`='$forum_lock',
  514. `moderate`='$forum_moderate',
  515. `c_id`='$forum_cat',
  516. `sort`='$sort'
  517. WHERE `f_id`='$fid'";
  518. DataBase::sql_query($sql,GENERAL,'Could not update forum');
  519. $msg='./../skins/'.$default_skin.'/blank.tpl';
  520. admin_message_forum($lng['forum_saved'],'admin_forums.php');
  521. }
  522. else
  523. {
  524. $msg = './../skins/'.$default_skin.'/post_error_body.tpl';
  525. $message = $lng['to_short_forum_desc'];
  526. }
  527. }
  528. else
  529. {
  530. $msg = './../skins/'.$default_skin.'/post_error_body.tpl';
  531. $message = $lng['to_short_forum_name'];
  532. }
  533. }
  534. else
  535. {
  536. $tmp = DataBase::fetch(DataBase::sql_query("SELECT `name`, `desc` FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'",GENERAL,'Could not obtain forum information'));
  537. $_POST['forum_name'] = $tmp['name'];
  538. $msg='./../skins/'.$default_skin.'/blank.tpl';
  539. $_POST['forum_desc'] = $tmp['desc'];
  540. if($tmp['name']=='')
  541. {
  542. admin_message_forum($lng['no_forum'],'admin_forums.php?mode=view');
  543. }
  544. unset($tmp);
  545. }
  546. $skin = array(
  547. 'here_write_name_forum'=>$lng['here_write_name_forum'],
  548. 'here_write_name_cat'=>$lng['here_write_name_cat'],
  549. 'new_forum_submit'=>$lng['new_forum_submit'],
  550. 'new_cat_submit'=>$lng['new_cat_submit'],
  551. 'L.save'=>$lng['submit'],
  552. 'forums&cats'=>$lng['forums_and_cats'],
  553. 'L.reset'=>$lng['reset'],
  554. 'L.forum_name'=>$lng['forum_name'],
  555. 'L.change_cat'=>$lng['change_cat'],
  556. 'L.forum_locked'=>$lng['forum_locked'],
  557. 'on'=>$lng['allow'],
  558. 'OPTION.forum_locked'=>(Forum::ForumInformation($fid,'lock')==1) ? 'checked="checked"' : '',
  559. 'OPTIONS.forum_cat'=>Admin_Forum::AddCats($fid),
  560. 'L.allow_moderate'=>$lng['moderate_posts'],
  561. 'OPTION.allow_moderate'=>(Forum::ForumInformation($fid,'moderate')==1) ? 'checked="checked"' : '',
  562. 'L.forum_desc'=>$lng['forum_desc'],
  563. 'L.main_beam'=>$lng['edit_forum'],
  564. 'action'=>'admin_forums.php?mode=edit&submode=forum&f='.$fid
  565. );
  566. Admin_Over::GenerateHeader();
  567. include('./template/forum_new_edit_body.tpl');
  568. include('./template/overall_footer.tpl');
  569. break;
  570. }
  571. }
  572. break;
  573. }
  574. case 'view':
  575. {
  576. GenerateDefaultDisplay();
  577. break;
  578. }
  579. default:
  580. {
  581. header('Location: admin_forums.php?mode=view');
  582. break;
  583. }
  584. }
  585. ?>