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.

415 lines
13 KiB

  1. <?php
  2. /**
  3. * @package µForum
  4. * @file admin/admin_scripts.php
  5. * @version 1.0.x, 06-07-2007, 14:59
  6. * @copyright 2008(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/dsf.html
  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/class_db.php');
  15. include('./../includes/class_error.php');
  16. //connect to database
  17. DataBase::db_connect();
  18. include('./../includes/sessions.php');
  19. include('./../includes/class_user.php');
  20. include('./../common.php');
  21. include('./../includes/admin/class_main.php');
  22. include('./../includes/class_forum.php');
  23. include('./../lngs/'.Admin_Over::DefaultLang().'/admin.php');
  24. sess_del_invalid($_SESSION['uid']);
  25. sess_register($_SESSION['uid']);
  26. sess_delete_old();
  27. if (User::UserInformation($_SESSION['uid'],'rank')!=2)
  28. {
  29. admin_message_forum($lng['yournotadmin'],'../index.php');
  30. }
  31. function AddSkins()
  32. {
  33. global $forum_config;
  34. $all='';
  35. $query = DataBase::sql_query("SELECT `name`, `s_id` FROM `".SKINS_TABLE."`",'GENERAL','Could not obtain skins information');
  36. while($t = @mysql_fetch_array($query))
  37. {
  38. if ($t['s_id']==$forum_config['defaultskin'])
  39. {
  40. $all .= '<option value="'.$t['s_id'].'" selected="selected">'.$t['name'].'</option>';
  41. }
  42. else
  43. {
  44. $all .= '<option value="'.$t['s_id'].'">'.$t['name'].'</option>';
  45. }
  46. }
  47. return $all;
  48. unset($t, $all);
  49. }
  50. function AddPages2($page)//for admin script, not used in limit!
  51. {
  52. $content = '';
  53. for ($i=1;$i<=50;$i++)
  54. {
  55. if ($i==$page)
  56. {
  57. $content .= '<option value="'.$i.'" selected="selected">'.$i.'</option>';
  58. }
  59. else
  60. {
  61. $content .= '<option value="'.$i.'">'.$i.'</option>';
  62. }
  63. }
  64. return $content;
  65. unset($content);
  66. }
  67. function AddLangs()
  68. {
  69. global $forum_config;
  70. $result='';
  71. $rep=opendir('./../lngs');
  72. while ($file = readdir($rep))
  73. {
  74. if($file != '..' && $file !='.' && $file !='')
  75. {
  76. if (is_dir('./../lngs/'.$file)){
  77. if ($file==$forum_config['defaultlang'])
  78. {
  79. $result .='<option value="'.$file.'" selected="selected">'.$file.'</option>';
  80. }
  81. else
  82. {
  83. $result .='<option value="'.$file.'">'.$file.'</option>';
  84. }
  85. }
  86. }
  87. }
  88. return $result;
  89. unset($rep, $file, $result);
  90. }
  91. $errors = true;
  92. if (isset($_POST['forum_path']))
  93. {
  94. if (!$_POST['forum_path'])
  95. {
  96. $message = $lng['no_path'];
  97. $ERROR = './template/in_error_body.tpl';
  98. }
  99. else
  100. {
  101. if ((strlen(trim($_POST['forum_name']))<3) or (strlen(trim($_POST['forum_name']))>30))
  102. {
  103. $message = $lng['invalid_forum_name'];
  104. $ERROR = './template/in_error_body.tpl';
  105. }
  106. else
  107. {
  108. if ($_POST['default_skin']!='-1')
  109. {
  110. if ($_POST['default_lang']!='-1')
  111. {
  112. if($_POST['limit_tpid']!='-1')
  113. {
  114. if($_POST['limit_ftid']!='-1')
  115. {
  116. if($_POST['limit_users']!='-1')
  117. {
  118. if((strlen($_POST['forum_desc'])>3) or (strlen($_POST['forum_desc'])<30))
  119. {
  120. $errors = false;
  121. }
  122. else
  123. {
  124. $message = $lng['invalid_forum_desc'];
  125. $ERROR = './template/in_error_body.tpl';
  126. }
  127. }
  128. else
  129. {
  130. $message = $lng['no_limit_users'];
  131. $ERROR = './template/in_error_body.tpl';
  132. }
  133. }
  134. else
  135. {
  136. $message = $lng['no_limit_ftid'];
  137. $ERROR = './template/in_error_body.tpl';
  138. }
  139. }
  140. else
  141. {
  142. $message = $lng['no_limit_tpid'];
  143. $ERROR = './template/in_error_body.tpl';
  144. }
  145. }
  146. else
  147. {
  148. $message = $lng['no_lang'];
  149. $ERROR = './template/in_error_body.tpl';
  150. }
  151. }
  152. else
  153. {
  154. $message = $lng['no_skin'];
  155. $ERROR = './template/in_error_body.tpl';
  156. }
  157. }
  158. }
  159. if (!$errors)
  160. {
  161. $name = array();
  162. $value = array();
  163. /* forum name */
  164. $name[] = 'forumname';
  165. $value[] = strip_tags($_POST['forum_name']);
  166. /* forum description */
  167. $name[] = 'forumdesc';
  168. $value[] = strip_tags($_POST['forum_desc']);
  169. /* forum path */
  170. $name[] = 'forumpatch';
  171. $value[] = strip_tags($_POST['forum_path']);
  172. /* forum disabled */
  173. $name[] = 'disable_forum';
  174. $value[] = strip_tags($_POST['forum_disabled']);
  175. /* default_skin */
  176. $name[] = 'defaultskin';
  177. $value[] = $_POST['default_skin'];
  178. /* default lang */
  179. $name[] = 'defaultlang';
  180. $value[] = $_POST['default_lang'];
  181. /* limit users */
  182. $name[] = 'limit_users';
  183. $value[] = $_POST['limit_users'];
  184. /* limit posts in topic */
  185. $name[] = 'limit_tpid';
  186. $value[] = $_POST['limit_tpid'];
  187. /* limit topics in forum*/
  188. $name[] = 'limit_ftid';
  189. $value[] = $_POST['limit_ftid'];
  190. /* meta keywords */
  191. $name[] = 'meta_keywords';
  192. $value[] = strip_tags($_POST['meta_keywords']);
  193. /* meta description */
  194. $name[] = 'meta_description';
  195. $value[] = strip_tags($_POST['meta_description']);
  196. /* show queries */
  197. $name[] = 'show_time_generation';
  198. $value[] = (!isset($_POST['allow_time_generation'])) ? 0 : 1;
  199. /* enable_confirms */
  200. $name[] = 'enable_confirms';
  201. $value[] = (!isset($_POST['enable_confirms'])) ? 0 : 1;
  202. /* enable_confirms */
  203. $name[] = 'ip_post_for_mod';
  204. $value[] = (!isset($_POST['allow_ip_for_mods'])) ? 0 : 1;
  205. /* use censorlist */
  206. $name[] = 'use_censorlist';
  207. $value[] = (!isset($_POST['enable_censorlist'])) ? 0 : 1;
  208. /* enable warns */
  209. $name[] = 'allow_warns';
  210. $value[] = (!isset($_POST['enable_warnings'])) ? 0 : 1;
  211. /* warns in topic */
  212. $name[] = 'warns_in_topic';
  213. $value[] = (!isset($_POST['warnings_in_topic'])) ? 0 : 1;
  214. //allow_email
  215. $name[] = 'allow_send_email';
  216. $value[] = (!isset($_POST['enable_send_email'])) ? 0 : 1;
  217. //allow_upload_avatars
  218. $name[] = 'allow_upload_avatars';
  219. $value[] = (!isset($_POST['allow_upload_avatars'])) ? 0 : 1;
  220. /* allow shoutbox */
  221. $name[] = 'view_shoutbox';
  222. $value[] = (!isset($_POST['allow_shoutbox'])) ? 0 : 1;
  223. /* shoutbox max time*/
  224. $name[] = 'shoutbox_max_time';
  225. $value[] = (!is_numeric($_POST['shoutbox_max_time'])) ? '14400' : $_POST['shoutbox_max_time'];
  226. /* color mod */
  227. $name[] = 'color_mod';
  228. $value[] = ($_POST['color_mod']=='') ? 'green' : strip_tags($_POST['color_mod']);
  229. /* color admin */
  230. $name[] = 'color_admin';
  231. $value[] = ($_POST['color_admin']=='') ? 'red' : strip_tags($_POST['color_admin']);
  232. /* av max x */
  233. $name[] = 'max_av_x';
  234. $value[] = (!is_numeric($_POST['max_av_x'])) ? '150' : $_POST['max_av_x'];
  235. /* av max y */
  236. $name[] = 'max_av_y';
  237. $value[] = (!is_numeric($_POST['max_av_y'])) ? '150' : $_POST['max_av_y'];
  238. /* av max filesize */
  239. $name[] = 'max_av_filesize';
  240. $value[] = (!is_numeric($_POST['max_av_filesize'])) ? '102400' : ($_POST['max_av_filesize'] * 1024);
  241. /* sig len */
  242. $name[] = 'sig_len';
  243. $value[] = (!is_numeric($_POST['sig_len'])) ? '200' : $_POST['sig_len'];
  244. /* antiflood time */
  245. $name[] = 'time_antiflood';
  246. $value[] = (!is_numeric($_POST['time_antiflood'])) ? '30' : $_POST['time_antiflood'];
  247. /* tables width */
  248. $name[] = 'tables_width';
  249. $value[] = (!is_numeric($_POST['tables_width'])) ? '900' : $_POST['tables_width'];
  250. /* sig len */
  251. $name[] = 'sig_len';
  252. $value[] = (!is_numeric($_POST['sig_len'])) ? '200' : $_POST['sig_len'];
  253. /* new password len */
  254. $name[] = 'newpasswd_len';
  255. $value[] = (!is_numeric($_POST['newpasswd_len'])) ? '6' : $_POST['newpasswd_len'];
  256. /* shoutbox_max_msgs */
  257. $name[] = 'shoutbox_max';
  258. $value[] = (!is_numeric($_POST['shoutbox_limit'])) ? '50' : $_POST['shoutbox_limit'];
  259. $count_o = count($name);
  260. for($i=0;$i<$count_o;$i++)
  261. {
  262. $sql = "UPDATE `".CONFIG_TABLE."` SET `value`='".$value[$i]."' WHERE `name`='".$name[$i]."'";
  263. DataBase::sql_query($sql, 'GENERAL', 'Could not update script config');
  264. }
  265. //end...
  266. unset($name, $value, $count_o, $sql);
  267. admin_message_forum($lng['forum_config_modernized'],'admin_script.php');
  268. }
  269. }
  270. else
  271. {
  272. $ERROR='./template/blank.tpl';
  273. }
  274. //add skin variables
  275. $skin = array(
  276. 'main_beam'=>$lng['scriptconfig'],
  277. 'L.submit'=>$lng['submit'],
  278. 'L.reset'=>$lng['reset'],
  279. 'L.general_preferences'=>$lng['general_preferences'],
  280. 'L.positioning'=>$lng['positioning_preferences'],
  281. 'L.other'=>$lng['other'],
  282. 'L.users'=>$lng['users_preferences'],
  283. 'L.forum_path'=>$lng['forum_path'],
  284. 'L.forum_path.D'=>$lng['t_forum_path'],
  285. 'forum_path'=>$forum_config['forumpatch'],
  286. 'L.forum_name'=>$lng['forum_name'],
  287. 'L.forum_desc'=>$lng['forum_description'],
  288. 'forum_desc'=>$forum_config['forumdesc'],
  289. 'forum_name'=>$forum_config['forumname'],
  290. 'L.forum_disabled'=>$lng['forum_disabled'],
  291. 'L.forum_disabled.D'=>$lng['t_forum_disabled'],
  292. 'forum_disabled'=>$forum_config['disable_forum'],
  293. 'L.default_skin'=>$lng['default_skin'],
  294. 'L2.default_skin'=>$lng['select_skin'],
  295. 'OPTIONS.default_skin'=>AddSkins(),
  296. 'L.default_lang'=>$lng['default_lang'],
  297. 'L2.default_lang'=>$lng['select_lang'],
  298. 'OPTIONS.default_lang'=>AddLangs(),
  299. 'L.meta_keywords'=>$lng['meta_keywords'],
  300. 'meta_keywords'=>$forum_config['meta_keywords'],
  301. 'L.meta_description'=>$lng['meta_description'],
  302. 'meta_description'=>$forum_config['meta_description'],
  303. 'L.allow'=>$lng['allow'],
  304. 'L.time_generation'=>$lng['show_time_generation'],
  305. 'OPTION.time_generation'=>($forum_config['show_time_generation']) ? 'checked="checked"' : '',
  306. 'L.enable_censorlist'=>$lng['enable_censorlist'],
  307. 'OPTION.enable_censorlist'=>($forum_config['use_censorlist']) ? 'checked="checked"' : '',
  308. 'L.enable_warnings'=>$lng['warns_enabled'],
  309. 'OPTION.enable_warnings'=>($forum_config['allow_warns']) ? 'checked="checked"' : '',
  310. 'L.allow_ip_for_mods'=>$lng['allow_ip_for_mods'],
  311. 'OPTION.allow_ip_for_mods'=>($forum_config['ip_post_for_mod']) ? 'checked="checked"' : '',
  312. 'L.warnings_in_topic'=>$lng['warns_in_topic'],
  313. 'OPTION.warnings_in_topic'=>($forum_config['warns_in_topic']) ? 'checked="checked"' : '',
  314. 'L.enable_confirms'=>$lng['enable_confirms'],
  315. 'OPTION.enable_confirms'=>($forum_config['enable_confirms']) ? 'checked="checked"' : '',
  316. 'L.enable_send_email'=>$lng['enable_send_email'],
  317. 'OPTION.enable_send_email'=>($forum_config['allow_send_email']) ? 'checked="checked"' : '',
  318. 'L.allow_upload_avatars'=>$lng['allow_upload_avatars'],
  319. 'OPTION.allow_upload_avatars'=>($forum_config['allow_upload_avatars']) ? 'checked="checked"' : '',
  320. 'L.select_value'=>$lng['select_value'],
  321. 'L.limit_users'=>$lng['limit_users'],
  322. 'OPTIONS.limit_users'=>AddPages2($forum_config['limit_users']),
  323. 'L.posts_in_topic'=>$lng['limit_posts'],
  324. 'L.scriptoptions'=>$lng['scriptconfig'],
  325. 'OPTIONS.limit_tpid'=>AddPages2($forum_config['limit_tpid']),
  326. 'L.topics_in_forum'=>$lng['limit_topics'],
  327. 'OPTIONS.limit_ftid'=>AddPages2($forum_config['limit_ftid']),
  328. 'L.admin_mod'=>$lng['admin_mod_preferences'],
  329. 'L.shoutbox'=>$lng['shoutbox_preferences'],
  330. 'L.allow_shoutbox'=>$lng['allow_shoutbox'],
  331. 'OPTION.allow_shoutbox'=>($forum_config['view_shoutbox']) ? 'checked="checked"' : '',
  332. 'L.shoutbox_max_time'=>$lng['shoutbox_time_clear'],
  333. 'OPTION.shoutbox_max_time'=>$forum_config['shoutbox_max_time'],
  334. 'L.shoutbox_limit'=>$lng['shoutbox_max_view'],
  335. 'OPTION.shoutbox_limit'=>$forum_config['shoutbox_max'],
  336. /* color mod */
  337. 'L.color_mod'=>$lng['color_mod'],
  338. 'OPTION.color_mod' => $forum_config['color_mod'],
  339. /* color admin */
  340. 'L.color_admin'=>$lng['color_admin'],
  341. 'OPTION.color_admin' => $forum_config['color_admin'],
  342. /* max avatar x */
  343. 'L.max_av_x'=>$lng['max_av_x'],
  344. 'OPTION.max_av_x' => $forum_config['max_av_x'],
  345. /* max avatar y */
  346. 'L.max_av_y'=>$lng['max_av_y'],
  347. 'OPTION.max_av_y' => $forum_config['max_av_y'],
  348. /* max avatar filesize */
  349. 'L.max_av_filesize'=>$lng['max_av_filesize'],
  350. 'OPTION.max_av_filesize' => ($forum_config['max_av_filesize'] / 1024),
  351. /* signature len */
  352. 'L.sig_len'=>$lng['sig_len'],
  353. 'OPTION.sig_len' => $forum_config['sig_len'],
  354. /* antiflood time */
  355. 'L.time_antiflood'=>$lng['time_antiflood'],
  356. 'OPTION.time_antiflood' => $forum_config['time_antiflood'],
  357. /* tables width */
  358. 'L.tables_width'=>$lng['tables_width'],
  359. 'OPTION.tables_width' => $forum_config['tables_width'],
  360. /* new password len */
  361. 'L.newpasswd_len'=>$lng['newpasswd_len'],
  362. 'OPTION.newpasswd_len' => $forum_config['newpasswd_len'],
  363. /* sig len */
  364. 'L.sig_len'=>$lng['sig_len'],
  365. 'OPTION.sig_len'=>$forum_config['sig_len']
  366. );
  367. //do it!
  368. Admin_Over::GenerateHeader();
  369. include('./template/admin_script.tpl');
  370. include('./template/overall_footer.tpl');
  371. ?>