PageRenderTime 62ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/forum_config.php

https://github.com/Bigjoos/U-232-V3
PHP | 142 lines | 128 code | 0 blank | 14 comment | 10 complexity | e46381d9b9ab2184d9cef5b089dcfb09 MD5 | raw file
  1. <?php
  2. /**
  3. * https://github.com/Bigjoos/
  4. * Licence Info: GPL
  5. * Copyright (C) 2010 U-232 v.3
  6. * A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
  7. * Project Leaders: Mindless, putyn.
  8. *
  9. */
  10. /**********************************************************
  11. New 2010 forums that don't suck for TB based sites....
  12. Powered by Bunnies!!!
  13. ***************************************************************/
  14. if (!defined('IN_INSTALLER09_ADMIN')) {
  15. $HTMLOUT.= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  16. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  17. <head>
  18. <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  19. <title>ERROR</title>
  20. </head><body>
  21. <h1 style="text-align:center;">ERROR</h1>
  22. <p style="text-align:center;">How did you get here? silly rabbit Trix are for kids!.</p>
  23. </body></html>';
  24. echo $HTMLOUT;
  25. exit();
  26. }
  27. require_once (INCL_DIR.'html_functions.php');
  28. require_once (CLASS_DIR.'class_check.php');
  29. class_check(UC_ADMINISTRATOR);
  30. $lang = array_merge($lang);
  31. $HTMLOUT = $time_drop_down = $accepted_file_extension = $accepted_file_types = $member_class_drop_down = '';
  32. $settings_saved = false;
  33. //=== be sure to set your id (below) in the DB. as well as setting your upload dir to something unique
  34. $config_id = 13;
  35. if (isset($_POST['do_it'])) {
  36. $delete_for_real = (isset($_POST['delete_for_real']) ? intval($_POST['delete_for_real']) : 0);
  37. $min_delete_view_class = ((isset($_POST['min_delete_view_class']) && valid_class($_POST['min_delete_view_class'])) ? intval($_POST['min_delete_view_class']) : 0);
  38. $readpost_expiry = (isset($_POST['readpost_expiry']) ? intval($_POST['readpost_expiry']) : 0);
  39. $min_upload_class = ((isset($_POST['min_upload_class']) && valid_class($_POST['min_upload_class'])) ? intval($_POST['min_upload_class']) : 0);
  40. $accepted_file_extension = (isset($_POST['accepted_file_extension']) ? preg_replace('/\s\s+/', ' ', $_POST['accepted_file_extension']) : '');
  41. $accepted_file_extension = explode(' ', $accepted_file_extension);
  42. $accepted_file_extension = serialize($accepted_file_extension);
  43. $accepted_file_types = (isset($_POST['accepted_file_types']) ? preg_replace('/\s\s+/', ' ', $_POST['accepted_file_types']) : '');
  44. $accepted_file_types = explode(' ', $accepted_file_types);
  45. $accepted_file_types = serialize($accepted_file_types);
  46. $max_file_size = (isset($_POST['max_file_size']) ? intval($_POST['max_file_size']) : 0);
  47. $upload_folder = (isset($_POST['upload_folder']) ? htmlsafechars(trim($_POST['upload_folder'])) : '');
  48. sql_query('UPDATE forum_config SET delete_for_real = '.sqlesc($delete_for_real).', min_delete_view_class = '.sqlesc($min_delete_view_class).', readpost_expiry = '.sqlesc($readpost_expiry).', min_upload_class = '.sqlesc($min_upload_class).', accepted_file_extension = '.sqlesc($accepted_file_extension).', accepted_file_types = '.sqlesc($accepted_file_types).', max_file_size = '.$max_file_size.', upload_folder = '.sqlesc($upload_folder).' WHERE id = '.sqlesc($config_id));
  49. header('Location: staffpanel.php?tool=forum_config&action=forum_config');
  50. die();
  51. }
  52. $main_links = '<p><a class="altlink" href="staffpanel.php?tool=over_forums&amp;action=over_forums">Over Forums</a> ::
  53. <a class="altlink" href="staffpanel.php?tool=forum_manage&amp;action=forum_manage">Forum Manager</a> ::
  54. <span style="font-weight: bold;">Configure Forums</span><br /></p>';
  55. $res = sql_query('SELECT delete_for_real, min_delete_view_class, readpost_expiry, min_upload_class, accepted_file_extension,
  56. accepted_file_types, max_file_size, upload_folder FROM forum_config WHERE id = '.sqlesc($config_id));
  57. $arr = mysqli_fetch_array($res);
  58. $weeks = 1;
  59. for ($i = 7; $i <= 365; $i = $i + 7) {
  60. $time_drop_down.= '<option class="body" value="'.$i.'"'.($arr['readpost_expiry'] == $i ? ' selected="selected"' : '').'>'.$weeks.($weeks === 1 ? ' week' : ' weeks').'</option>';
  61. $weeks = $weeks + 1;
  62. }
  63. $accepted_file_extension1 = (!empty($arr['accepted_file_extension'])) ? unserialize($arr['accepted_file_extension']) : array();
  64. foreach ($accepted_file_extension1 as $x) {
  65. $accepted_file_extension.= $x.' ';
  66. }
  67. $accepted_file_types1 = (!empty($arr['accepted_file_types'])) ? unserialize($arr['accepted_file_types']) : array();
  68. foreach ($accepted_file_types1 as $x) {
  69. $accepted_file_types.= $x.' ';
  70. }
  71. $HTMLOUT.= $main_links.'<form method="post" action="staffpanel.php?tool=forum_config&amp;action=forum_config">
  72. <input type="hidden" name="do_it" value="1" />
  73. <table border="0" cellspacing="0" cellpadding="3" align="center">
  74. <tr>
  75. <td colspan="2" class="forum_head_dark">Edit Forums Configure</td>
  76. </tr>
  77. <tr>
  78. <td align="right" class="three" valign="top"><span style="font-weight: bold;">Delete posts / topics:</span></td>
  79. <td align="left" class="three">
  80. <input type="radio" name="delete_for_real" value="1" '.($arr['delete_for_real'] == 1 ? 'checked="checked"' : '').' /> Yes
  81. <input type="radio" name="delete_for_real" value="0" '.($arr['delete_for_real'] == 0 ? 'checked="checked"' : '').' /> No<br />
  82. Setting this to No will give the option forselected class and above to see deleted posts and threads and decide if they should be deleted.</td>
  83. </tr>
  84. <tr>
  85. <td align="right" class="three" valign="top"><span style="font-weight: bold;">Min delete class:</span></td>
  86. <td align="left" class="three">
  87. <select name="min_delete_view_class"> '.member_class_drop_down($arr['min_delete_view_class']).'</select><br />
  88. Set this to the lowest member class you wish to be able to view deleted posts and threads.<br />[Default is Admin]</td>
  89. </tr>
  90. <tr>
  91. <td align="right" class="three" valign="top"><span style="font-weight: bold;">Read Post Expiry:</span></td>
  92. <td align="left" class="three">
  93. <select name="readpost_expiry"> '.$time_drop_down.'</select><br />
  94. All posts older then this are set as "read".<br />[Retro\'s code that is now default]</td>
  95. </tr>
  96. <tr>
  97. <td align="right" class="three" valign="top"><span style="font-weight: bold;">Min upload class:</span></td>
  98. <td align="left" class="three">
  99. <select name="min_upload_class"> '.member_class_drop_down($arr['min_upload_class']).'</select><br />
  100. Set this to the lowest member class you wish to give the right to add attachments to a post.</td>
  101. </tr>
  102. <tr>
  103. <td align="right" class="three"><span style="font-weight: bold;">Accepted file ext:</span> </td>
  104. <td align="left" class="three">
  105. <input name="accepted_file_extension" type="text" class="text_default" size="30" maxlength="200" value="'.htmlsafechars($accepted_file_extension).'" /><br />
  106. Defaults are: zip and rar. Add more at your own risk! Each entry must be separated by a single space.</td>
  107. </tr>
  108. <tr>
  109. <td align="right" class="three"><span style="font-weight: bold;">Accepted file types:</span> </td>
  110. <td align="left" class="three">
  111. <input name="accepted_file_types" type="text" class="text_default" size="30" maxlength="200" value="'.htmlsafechars($accepted_file_types).'" /><br />
  112. Must match the above accepted file ext\'s. Add more at your own risk! Each entry must be separated by a single space</td>
  113. </tr>
  114. <tr>
  115. <td align="right" class="three"><span style="font-weight: bold;">Max file size:</span> </td>
  116. <td align="left" class="three">
  117. <input name="max_file_size" type="text" class="text_default" size="30" maxlength="200" value="'.intval($arr['max_file_size']).'" /><br />
  118. Default is 2 MBs, currently set to: '.mksize($arr['max_file_size']).'.</td>
  119. </tr>
  120. <tr>
  121. <td align="right" class="three"><span style="font-weight: bold;">Upload folder:</span> </td>
  122. <td align="left" class="three">
  123. <input name="upload_folder" type="text" class="text_default" size="30" maxlength="200" value="'.htmlsafechars($arr['upload_folder']).'" /><br />
  124. Must be writable, and must be followed by a forward slash.<br />
  125. Name this something unique for added security, the location is never visible to members.</td>
  126. </tr>
  127. <tr>
  128. <td colspan="2" class="three" align="center">
  129. <input type="submit" name="button" class="button_big" value="Save Configuration Settings" onmouseover="this.className=\'button_big_hover\'" onmouseout="this.className=\'button_big\'" /></td>
  130. </tr>
  131. </table></form>';
  132. function member_class_drop_down($member_class)
  133. {
  134. $member_class_drop_down = '';
  135. for ($i = 0; $i <= UC_MAX; ++$i) {
  136. $member_class_drop_down.= '<option class="body" value="'.$i.'"'.($member_class == $i ? ' selected="selected"' : '').'>'.get_user_class_name($i).'</option>';
  137. }
  138. return $member_class_drop_down;
  139. }
  140. echo stdhead('Configure Forums').$HTMLOUT.stdfoot();
  141. ?>