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.

372 lines
12 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file admin/admin_scripts.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/misc_functions.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. $errors = true;
  33. if (isset($_POST['forum_path']))
  34. {
  35. if (!$_POST['forum_path'])
  36. {
  37. $message = $lng['no_path'];
  38. $ERROR = './template/in_error_body.tpl';
  39. }
  40. else
  41. {
  42. if ((strlen(trim($_POST['forum_name']))<3) or (strlen(trim($_POST['forum_name']))>30))
  43. {
  44. $message = $lng['invalid_forum_name'];
  45. $ERROR = './template/in_error_body.tpl';
  46. }
  47. else
  48. {
  49. if ($_POST['default_skin']!='-1')
  50. {
  51. if ($_POST['default_lang']!='-1')
  52. {
  53. if($_POST['limit_tpid']!='-1')
  54. {
  55. if($_POST['limit_ftid']!='-1')
  56. {
  57. if($_POST['limit_users']!='-1')
  58. {
  59. if((strlen($_POST['forum_desc'])>3) or (strlen($_POST['forum_desc'])<30))
  60. {
  61. $errors = false;
  62. }
  63. else
  64. {
  65. $message = $lng['invalid_forum_desc'];
  66. $ERROR = './template/in_error_body.tpl';
  67. }
  68. }
  69. else
  70. {
  71. $message = $lng['no_limit_users'];
  72. $ERROR = './template/in_error_body.tpl';
  73. }
  74. }
  75. else
  76. {
  77. $message = $lng['no_limit_ftid'];
  78. $ERROR = './template/in_error_body.tpl';
  79. }
  80. }
  81. else
  82. {
  83. $message = $lng['no_limit_tpid'];
  84. $ERROR = './template/in_error_body.tpl';
  85. }
  86. }
  87. else
  88. {
  89. $message = $lng['no_lang'];
  90. $ERROR = './template/in_error_body.tpl';
  91. }
  92. }
  93. else
  94. {
  95. $message = $lng['no_skin'];
  96. $ERROR = './template/in_error_body.tpl';
  97. }
  98. }
  99. }
  100. if (!$errors)
  101. {
  102. $name = array();
  103. $value = array();
  104. /* forum name */
  105. $name[] = 'forumname';
  106. $value[] = strip_tags($_POST['forum_name']);
  107. /* forum description */
  108. $name[] = 'forumdesc';
  109. $value[] = strip_tags($_POST['forum_desc']);
  110. /* forum path */
  111. $name[] = 'forumpatch';
  112. $value[] = strip_tags($_POST['forum_path']);
  113. /* forum disabled */
  114. $name[] = 'disable_forum';
  115. $value[] = strip_tags($_POST['forum_disabled']);
  116. /* default_skin */
  117. $name[] = 'defaultskin';
  118. $value[] = $_POST['default_skin'];
  119. /* default lang */
  120. $name[] = 'defaultlang';
  121. $value[] = $_POST['default_lang'];
  122. /* limit users */
  123. $name[] = 'limit_users';
  124. $value[] = $_POST['limit_users'];
  125. /* limit posts in topic */
  126. $name[] = 'limit_tpid';
  127. $value[] = $_POST['limit_tpid'];
  128. /* limit topics in forum*/
  129. $name[] = 'limit_ftid';
  130. $value[] = $_POST['limit_ftid'];
  131. /* meta keywords */
  132. $name[] = 'meta_keywords';
  133. $value[] = strip_tags($_POST['meta_keywords']);
  134. /* meta description */
  135. $name[] = 'meta_description';
  136. $value[] = strip_tags($_POST['meta_description']);
  137. /* show queries */
  138. $name[] = 'show_time_generation';
  139. $value[] = (!isset($_POST['allow_time_generation'])) ? 0 : 1;
  140. /* enable_confirms */
  141. $name[] = 'enable_confirms';
  142. $value[] = (!isset($_POST['enable_confirms'])) ? 0 : 1;
  143. /* enable_confirms */
  144. $name[] = 'ip_post_for_mod';
  145. $value[] = (!isset($_POST['allow_ip_for_mods'])) ? 0 : 1;
  146. /* use censorlist */
  147. $name[] = 'use_censorlist';
  148. $value[] = (!isset($_POST['enable_censorlist'])) ? 0 : 1;
  149. /* enable warns */
  150. $name[] = 'allow_warns';
  151. $value[] = (!isset($_POST['enable_warnings'])) ? 0 : 1;
  152. /* warns in topic */
  153. $name[] = 'warns_in_topic';
  154. $value[] = (!isset($_POST['warnings_in_topic'])) ? 0 : 1;
  155. //allow_email
  156. $name[] = 'allow_send_email';
  157. $value[] = (!isset($_POST['enable_send_email'])) ? 0 : 1;
  158. //allow_upload_avatars
  159. $name[] = 'allow_upload_avatars';
  160. $value[] = (!isset($_POST['allow_upload_avatars'])) ? 0 : 1;
  161. /* allow shoutbox */
  162. $name[] = 'view_shoutbox';
  163. $value[] = (!isset($_POST['allow_shoutbox'])) ? 0 : 1;
  164. /* shoutbox max time*/
  165. $name[] = 'shoutbox_max_time';
  166. $value[] = (!is_numeric($_POST['shoutbox_max_time'])) ? '14400' : $_POST['shoutbox_max_time'];
  167. /* color mod */
  168. $name[] = 'color_mod';
  169. $value[] = ($_POST['color_mod']=='') ? 'green' : strip_tags($_POST['color_mod']);
  170. /* color admin */
  171. $name[] = 'color_admin';
  172. $value[] = ($_POST['color_admin']=='') ? 'red' : strip_tags($_POST['color_admin']);
  173. /* av max x */
  174. $name[] = 'max_av_x';
  175. $value[] = (!is_numeric($_POST['max_av_x'])) ? '150' : $_POST['max_av_x'];
  176. /* av max y */
  177. $name[] = 'max_av_y';
  178. $value[] = (!is_numeric($_POST['max_av_y'])) ? '150' : $_POST['max_av_y'];
  179. /* av max filesize */
  180. $name[] = 'max_av_filesize';
  181. $value[] = (!is_numeric($_POST['max_av_filesize'])) ? '102400' : ($_POST['max_av_filesize'] * 1024);
  182. /* sig len */
  183. $name[] = 'sig_len';
  184. $value[] = (!is_numeric($_POST['sig_len'])) ? '200' : $_POST['sig_len'];
  185. /* antiflood time */
  186. $name[] = 'time_antiflood';
  187. $value[] = (!is_numeric($_POST['time_antiflood'])) ? '30' : $_POST['time_antiflood'];
  188. /* tables width */
  189. $name[] = 'tables_width';
  190. $value[] = (!is_numeric($_POST['tables_width'])) ? '900' : $_POST['tables_width'];
  191. /* sig len */
  192. $name[] = 'sig_len';
  193. $value[] = (!is_numeric($_POST['sig_len'])) ? '200' : $_POST['sig_len'];
  194. /* new password len */
  195. $name[] = 'newpasswd_len';
  196. $value[] = (!is_numeric($_POST['newpasswd_len'])) ? '6' : $_POST['newpasswd_len'];
  197. /* shoutbox_max_msgs */
  198. $name[] = 'shoutbox_max';
  199. $value[] = (!is_numeric($_POST['shoutbox_limit'])) ? '50' : $_POST['shoutbox_limit'];
  200. /* pm inbox max */
  201. $name[] = 'pm_inbox_max';
  202. $value[] = (!is_numeric($_POST['pm_inbox_max'])) ? '10' : $_POST['pm_inbox_max'];
  203. /* pm sentbox max */
  204. $name[] = 'pm_sentbox_max';
  205. $value[] = (!is_numeric($_POST['pm_sentbox_max'])) ? '10' : $_POST['pm_sentbox_max'];
  206. $count_o = count($name);
  207. for($i=0;$i<$count_o;$i++)
  208. {
  209. $sql = "UPDATE `".CONFIG_TABLE."` SET `value`='".$value[$i]."' WHERE `name`='".$name[$i]."'";
  210. DataBase::sql_query($sql, GENERAL, 'Could not update script config');
  211. }
  212. //end...
  213. unset($name, $value, $count_o, $sql);
  214. admin_message_forum($lng['forum_config_modernized'],'admin_script.php');
  215. }
  216. }
  217. else
  218. {
  219. $ERROR='./template/blank.tpl';
  220. }
  221. //add skin variables
  222. $skin = array(
  223. 'main_beam'=>$lng['scriptconfig'],
  224. 'L.submit'=>$lng['submit'],
  225. 'L.reset'=>$lng['reset'],
  226. 'L.general_preferences'=>$lng['general_preferences'],
  227. 'L.positioning'=>$lng['positioning_preferences'],
  228. 'L.other'=>$lng['other'],
  229. 'L.users'=>$lng['users_preferences'],
  230. 'L.forum_path'=>$lng['forum_path'],
  231. 'L.forum_path.D'=>$lng['t_forum_path'],
  232. 'forum_path'=>$forum_config['forumpatch'],
  233. 'L.forum_name'=>$lng['forum_name'],
  234. 'L.forum_desc'=>$lng['forum_description'],
  235. 'forum_desc'=>$forum_config['forumdesc'],
  236. 'forum_name'=>$forum_config['forumname'],
  237. 'L.forum_disabled'=>$lng['forum_disabled'],
  238. 'L.forum_disabled.D'=>$lng['t_forum_disabled'],
  239. 'forum_disabled'=>$forum_config['disable_forum'],
  240. 'L.default_skin'=>$lng['default_skin'],
  241. 'L2.default_skin'=>$lng['select_skin'],
  242. 'OPTIONS.default_skin'=>ListDir('../skins', $forum_config['defaultskin']),
  243. 'L.default_lang'=>$lng['default_lang'],
  244. 'L2.default_lang'=>$lng['select_lang'],
  245. 'OPTIONS.default_lang'=>ListDir('../lngs', $forum_config['defaultlang']),
  246. 'L.meta_keywords'=>$lng['meta_keywords'],
  247. 'meta_keywords'=>$forum_config['meta_keywords'],
  248. 'L.meta_description'=>$lng['meta_description'],
  249. 'meta_description'=>$forum_config['meta_description'],
  250. 'L.allow'=>$lng['allow'],
  251. 'L.time_generation'=>$lng['show_time_generation'],
  252. 'OPTION.time_generation'=>($forum_config['show_time_generation']) ? 'checked="checked"' : '',
  253. 'L.enable_censorlist'=>$lng['enable_censorlist'],
  254. 'OPTION.enable_censorlist'=>($forum_config['use_censorlist']) ? 'checked="checked"' : '',
  255. 'L.enable_warnings'=>$lng['warns_enabled'],
  256. 'OPTION.enable_warnings'=>($forum_config['allow_warns']) ? 'checked="checked"' : '',
  257. 'L.allow_ip_for_mods'=>$lng['allow_ip_for_mods'],
  258. 'OPTION.allow_ip_for_mods'=>($forum_config['ip_post_for_mod']) ? 'checked="checked"' : '',
  259. 'L.warnings_in_topic'=>$lng['warns_in_topic'],
  260. 'OPTION.warnings_in_topic'=>($forum_config['warns_in_topic']) ? 'checked="checked"' : '',
  261. 'L.enable_confirms'=>$lng['enable_confirms'],
  262. 'OPTION.enable_confirms'=>($forum_config['enable_confirms']) ? 'checked="checked"' : '',
  263. 'L.enable_send_email'=>$lng['enable_send_email'],
  264. 'OPTION.enable_send_email'=>($forum_config['allow_send_email']) ? 'checked="checked"' : '',
  265. 'L.allow_upload_avatars'=>$lng['allow_upload_avatars'],
  266. 'OPTION.allow_upload_avatars'=>($forum_config['allow_upload_avatars']) ? 'checked="checked"' : '',
  267. 'L.select_value'=>$lng['select_value'],
  268. 'L.limit_users'=>$lng['limit_users'],
  269. 'OPTIONS.limit_users'=>ListPages($forum_config['limit_users']),
  270. 'L.posts_in_topic'=>$lng['limit_posts'],
  271. 'L.scriptoptions'=>$lng['scriptconfig'],
  272. 'OPTIONS.limit_tpid'=>ListPages($forum_config['limit_tpid']),
  273. 'L.topics_in_forum'=>$lng['limit_topics'],
  274. 'OPTIONS.limit_ftid'=>ListPages($forum_config['limit_ftid']),
  275. 'L.admin_mod'=>$lng['admin_mod_preferences'],
  276. 'L.shoutbox'=>$lng['shoutbox_preferences'],
  277. 'L.allow_shoutbox'=>$lng['allow_shoutbox'],
  278. 'OPTION.allow_shoutbox'=>($forum_config['view_shoutbox']) ? 'checked="checked"' : '',
  279. 'L.shoutbox_max_time'=>$lng['shoutbox_time_clear'],
  280. 'OPTION.shoutbox_max_time'=>$forum_config['shoutbox_max_time'],
  281. 'L.shoutbox_limit'=>$lng['shoutbox_max_view'],
  282. 'OPTION.shoutbox_limit'=>$forum_config['shoutbox_max'],
  283. /* pm sentbox max */
  284. 'L.pm_sentbox_max'=>$lng['pm_sentbox_max'],
  285. 'OPTION.pm_sentbox_max'=>$forum_config['pm_sentbox_max'],
  286. /* pm inbox max */
  287. 'L.pm_inbox_max'=>$lng['pm_inbox_max'],
  288. 'OPTION.pm_inbox_max'=>$forum_config['pm_inbox_max'],
  289. /* color mod */
  290. 'L.color_mod'=>$lng['color_mod'],
  291. 'OPTION.color_mod' => $forum_config['color_mod'],
  292. /* color admin */
  293. 'L.color_admin'=>$lng['color_admin'],
  294. 'OPTION.color_admin' => $forum_config['color_admin'],
  295. /* max avatar x */
  296. 'L.max_av_x'=>$lng['max_av_x'],
  297. 'OPTION.max_av_x' => $forum_config['max_av_x'],
  298. /* max avatar y */
  299. 'L.max_av_y'=>$lng['max_av_y'],
  300. 'OPTION.max_av_y' => $forum_config['max_av_y'],
  301. /* max avatar filesize */
  302. 'L.max_av_filesize'=>$lng['max_av_filesize'],
  303. 'OPTION.max_av_filesize' => ($forum_config['max_av_filesize'] / 1024),
  304. /* signature len */
  305. 'L.sig_len'=>$lng['sig_len'],
  306. 'OPTION.sig_len' => $forum_config['sig_len'],
  307. /* antiflood time */
  308. 'L.time_antiflood'=>$lng['time_antiflood'],
  309. 'OPTION.time_antiflood' => $forum_config['time_antiflood'],
  310. /* tables width */
  311. 'L.tables_width'=>$lng['tables_width'],
  312. 'OPTION.tables_width' => $forum_config['tables_width'],
  313. /* new password len */
  314. 'L.newpasswd_len'=>$lng['newpasswd_len'],
  315. 'OPTION.newpasswd_len' => $forum_config['newpasswd_len'],
  316. /* sig len */
  317. 'L.sig_len'=>$lng['sig_len'],
  318. 'OPTION.sig_len'=>$forum_config['sig_len']
  319. );
  320. //do it!
  321. Admin_Over::GenerateHeader();
  322. include('./template/admin_script.tpl');
  323. include('./template/overall_footer.tpl');
  324. ?>