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.

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