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.

432 lines
13 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('./../lngs/'.Admin_Over::DefaultLang().'/admin.php');
  24. SessDelInvalid();
  25. SessRegister();
  26. SessDeleteOld();
  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 = DataBase::fetch($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. /* pm inbox max */
  260. $name[] = 'pm_inbox_max';
  261. $value[] = (!is_numeric($_POST['pm_inbox_max'])) ? '10' : $_POST['pm_inbox_max'];
  262. /* pm sentbox max */
  263. $name[] = 'pm_sentbox_max';
  264. $value[] = (!is_numeric($_POST['pm_sentbox_max'])) ? '10' : $_POST['pm_sentbox_max'];
  265. $count_o = count($name);
  266. for($i=0;$i<$count_o;$i++)
  267. {
  268. $sql = "UPDATE `".CONFIG_TABLE."` SET `value`='".$value[$i]."' WHERE `name`='".$name[$i]."'";
  269. DataBase::sql_query($sql, GENERAL, 'Could not update script config');
  270. }
  271. //end...
  272. unset($name, $value, $count_o, $sql);
  273. admin_message_forum($lng['forum_config_modernized'],'admin_script.php');
  274. }
  275. }
  276. else
  277. {
  278. $ERROR='./template/blank.tpl';
  279. }
  280. //add skin variables
  281. $skin = array(
  282. 'main_beam'=>$lng['scriptconfig'],
  283. 'L.submit'=>$lng['submit'],
  284. 'L.reset'=>$lng['reset'],
  285. 'L.general_preferences'=>$lng['general_preferences'],
  286. 'L.positioning'=>$lng['positioning_preferences'],
  287. 'L.other'=>$lng['other'],
  288. 'L.users'=>$lng['users_preferences'],
  289. 'L.forum_path'=>$lng['forum_path'],
  290. 'L.forum_path.D'=>$lng['t_forum_path'],
  291. 'forum_path'=>$forum_config['forumpatch'],
  292. 'L.forum_name'=>$lng['forum_name'],
  293. 'L.forum_desc'=>$lng['forum_description'],
  294. 'forum_desc'=>$forum_config['forumdesc'],
  295. 'forum_name'=>$forum_config['forumname'],
  296. 'L.forum_disabled'=>$lng['forum_disabled'],
  297. 'L.forum_disabled.D'=>$lng['t_forum_disabled'],
  298. 'forum_disabled'=>$forum_config['disable_forum'],
  299. 'L.default_skin'=>$lng['default_skin'],
  300. 'L2.default_skin'=>$lng['select_skin'],
  301. 'OPTIONS.default_skin'=>ListDir('skins', $forum_config['default_skin']),
  302. 'L.default_lang'=>$lng['default_lang'],
  303. 'L2.default_lang'=>$lng['select_lang'],
  304. 'OPTIONS.default_lang'=>ListDir('lngs', $forum_config['default_lang']),
  305. 'L.meta_keywords'=>$lng['meta_keywords'],
  306. 'meta_keywords'=>$forum_config['meta_keywords'],
  307. 'L.meta_description'=>$lng['meta_description'],
  308. 'meta_description'=>$forum_config['meta_description'],
  309. 'L.allow'=>$lng['allow'],
  310. 'L.time_generation'=>$lng['show_time_generation'],
  311. 'OPTION.time_generation'=>($forum_config['show_time_generation']) ? 'checked="checked"' : '',
  312. 'L.enable_censorlist'=>$lng['enable_censorlist'],
  313. 'OPTION.enable_censorlist'=>($forum_config['use_censorlist']) ? 'checked="checked"' : '',
  314. 'L.enable_warnings'=>$lng['warns_enabled'],
  315. 'OPTION.enable_warnings'=>($forum_config['allow_warns']) ? 'checked="checked"' : '',
  316. 'L.allow_ip_for_mods'=>$lng['allow_ip_for_mods'],
  317. 'OPTION.allow_ip_for_mods'=>($forum_config['ip_post_for_mod']) ? 'checked="checked"' : '',
  318. 'L.warnings_in_topic'=>$lng['warns_in_topic'],
  319. 'OPTION.warnings_in_topic'=>($forum_config['warns_in_topic']) ? 'checked="checked"' : '',
  320. 'L.enable_confirms'=>$lng['enable_confirms'],
  321. 'OPTION.enable_confirms'=>($forum_config['enable_confirms']) ? 'checked="checked"' : '',
  322. 'L.enable_send_email'=>$lng['enable_send_email'],
  323. 'OPTION.enable_send_email'=>($forum_config['allow_send_email']) ? 'checked="checked"' : '',
  324. 'L.allow_upload_avatars'=>$lng['allow_upload_avatars'],
  325. 'OPTION.allow_upload_avatars'=>($forum_config['allow_upload_avatars']) ? 'checked="checked"' : '',
  326. 'L.select_value'=>$lng['select_value'],
  327. 'L.limit_users'=>$lng['limit_users'],
  328. 'OPTIONS.limit_users'=>ListPages($forum_config['limit_users']),
  329. 'L.posts_in_topic'=>$lng['limit_posts'],
  330. 'L.scriptoptions'=>$lng['scriptconfig'],
  331. 'OPTIONS.limit_tpid'=>ListPages($forum_config['limit_tpid']),
  332. 'L.topics_in_forum'=>$lng['limit_topics'],
  333. 'OPTIONS.limit_ftid'=>ListPages($forum_config['limit_ftid']),
  334. 'L.admin_mod'=>$lng['admin_mod_preferences'],
  335. 'L.shoutbox'=>$lng['shoutbox_preferences'],
  336. 'L.allow_shoutbox'=>$lng['allow_shoutbox'],
  337. 'OPTION.allow_shoutbox'=>($forum_config['view_shoutbox']) ? 'checked="checked"' : '',
  338. 'L.shoutbox_max_time'=>$lng['shoutbox_time_clear'],
  339. 'OPTION.shoutbox_max_time'=>$forum_config['shoutbox_max_time'],
  340. 'L.shoutbox_limit'=>$lng['shoutbox_max_view'],
  341. 'OPTION.shoutbox_limit'=>$forum_config['shoutbox_max'],
  342. /* pm sentbox max */
  343. 'L.pm_sentbox_max'=>$lng['pm_sentbox_max'],
  344. 'OPTION.pm_sentbox_max'=>$forum_config['pm_sentbox_max'],
  345. /* pm inbox max */
  346. 'L.pm_inbox_max'=>$lng['pm_inbox_max'],
  347. 'OPTION.pm_inbox_max'=>$forum_config['pm_inbox_max'],
  348. /* color mod */
  349. 'L.color_mod'=>$lng['color_mod'],
  350. 'OPTION.color_mod' => $forum_config['color_mod'],
  351. /* color admin */
  352. 'L.color_admin'=>$lng['color_admin'],
  353. 'OPTION.color_admin' => $forum_config['color_admin'],
  354. /* max avatar x */
  355. 'L.max_av_x'=>$lng['max_av_x'],
  356. 'OPTION.max_av_x' => $forum_config['max_av_x'],
  357. /* max avatar y */
  358. 'L.max_av_y'=>$lng['max_av_y'],
  359. 'OPTION.max_av_y' => $forum_config['max_av_y'],
  360. /* max avatar filesize */
  361. 'L.max_av_filesize'=>$lng['max_av_filesize'],
  362. 'OPTION.max_av_filesize' => ($forum_config['max_av_filesize'] / 1024),
  363. /* signature len */
  364. 'L.sig_len'=>$lng['sig_len'],
  365. 'OPTION.sig_len' => $forum_config['sig_len'],
  366. /* antiflood time */
  367. 'L.time_antiflood'=>$lng['time_antiflood'],
  368. 'OPTION.time_antiflood' => $forum_config['time_antiflood'],
  369. /* tables width */
  370. 'L.tables_width'=>$lng['tables_width'],
  371. 'OPTION.tables_width' => $forum_config['tables_width'],
  372. /* new password len */
  373. 'L.newpasswd_len'=>$lng['newpasswd_len'],
  374. 'OPTION.newpasswd_len' => $forum_config['newpasswd_len'],
  375. /* sig len */
  376. 'L.sig_len'=>$lng['sig_len'],
  377. 'OPTION.sig_len'=>$forum_config['sig_len']
  378. );
  379. //do it!
  380. Admin_Over::GenerateHeader();
  381. include('./template/admin_script.tpl');
  382. include('./template/overall_footer.tpl');
  383. ?>