PageRenderTime 85ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/TBDev/installer_v4_1/reputation_settings.php

https://github.com/cybernet/CyBerFuN-CoDeX
PHP | 286 lines | 238 code | 39 blank | 9 comment | 15 complexity | c5a1c1fe5f23d8f6e7c3a54afcc2b637 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. require_once "include/bittorrent.php";
  3. require_once "include/bbcode_functions.php";
  4. require_once "include/user_functions.php";
  5. dbconn( false );
  6. if (!logged_in()) {
  7. header("HTTP/1.0 404 Not Found");
  8. // moddifed logginorreturn by retro//Remember to change the following line to match your server
  9. print("<html><h1>Not Found</h1><p>The requested URL /{$_SERVER['PHP_SELF']} was not found on this server.</p><hr /><address>Apache/1.1.11 ".$SITENAME." Server at " . $_SERVER['SERVER_NAME'] . " Port 80</address></body></html>\n");
  10. die();
  11. }
  12. if ( get_user_class() < UC_ADMINISTRATOR )
  13. header( "Location: $BASEURL/index.php" );
  14. $rep_set_cache = "cache/rep_settings_cache.php";
  15. if ( 'POST' == $_SERVER['REQUEST_METHOD'] )
  16. {
  17. unset($_POST['submit']);
  18. //print_r($_POST);
  19. rep_cache();
  20. exit;
  21. }
  22. /////////////////////////////
  23. // cache rep function
  24. /////////////////////////////
  25. function rep_cache()
  26. {
  27. global $rep_set_cache;
  28. $rep_out = "<"."?php\n\n\$GVARS = array(\n";
  29. foreach( $_POST as $k => $v)
  30. {
  31. $rep_out .= ($k == 'rep_undefined') ? "\t'{$k}' => '".htmlentities($v, ENT_QUOTES)."',\n" : "\t'{$k}' => ".intval($v).",\n";
  32. }
  33. $rep_out .= "\t'g_rep_negative' => TRUE,\n";
  34. $rep_out .= "\t'g_rep_seeown' => TRUE,\n";
  35. $rep_out .= "\t'g_rep_use' => \$CURUSER['class'] > UC_USER ? TRUE : FALSE\n";
  36. $rep_out .= "\n);\n\n?".">";
  37. if( file_exists( $rep_set_cache ) && is_writable( pathinfo($rep_set_cache, PATHINFO_DIRNAME) ) )
  38. {
  39. $filenum = fopen ( $rep_set_cache, 'w' );
  40. ftruncate( $filenum, 0 );
  41. fwrite( $filenum, $rep_out );
  42. fclose( $filenum );
  43. //print '<pre>'.$rep_out.'</pre>';exit;
  44. }
  45. redirect('reputation_settings.php', 'Reputation Settings Have Been Updated!', 3);
  46. }
  47. function get_cache_array()
  48. {
  49. return array( 'rep_is_online' => 1,
  50. 'rep_adminpower' => 5,
  51. 'rep_minpost' => 50,
  52. 'rep_default' => 10,
  53. 'rep_userrates' => 5,
  54. 'rep_rdpower' => 365,
  55. 'rep_pcpower' => 1000,
  56. 'rep_kppower' => 100,
  57. 'rep_minrep' => 10,
  58. 'rep_minpost' => 50,
  59. 'rep_maxperday' => 10,
  60. 'rep_repeat' => 20,
  61. 'rep_undefined' => 'is off the scale',
  62. /*'g_rep_negative' => TRUE,
  63. 'g_rep_seeown' => TRUE,
  64. 'g_rep_use' => $CURUSER['class'] > UC_USER ? TRUE : FALSE*/
  65. );
  66. }
  67. if ( ! file_exists( $rep_set_cache ) )
  68. {
  69. $GVARS = get_cache_array();
  70. }
  71. else
  72. {
  73. require_once $rep_set_cache;
  74. if( ! is_array($GVARS) || ( count($GVARS) < 15 ) )
  75. {
  76. $GVARS = get_cache_array();
  77. }
  78. }
  79. $HTML_OUT = '<div>
  80. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  81. <tr>
  82. <td style="font-size: 12px; vertical-align: middle; font-weight: bold; color: rgb(0, 0, 0);" align="center">Reputation System Settings</td></tr>
  83. <tr><td>This section allows you to configure the User Reputation system.</td>
  84. </tr>
  85. </table>
  86. </div>
  87. <br />
  88. <div style="border: 1px solid rgb(131, 148, 178); padding: 5px;">
  89. <form action="reputation_settings.php" name="repoptions" method="post">
  90. <div>Reputation On/Off</div>
  91. <div style="padding: 5px; background-color: rgb(238, 242, 247);">
  92. <div style="border: 1px solid rgb(131, 148, 178);">
  93. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  94. <tr>
  95. <td width="30%"><b>Enable User Reputation system?</b><div style="color: gray;">Set this option to \'Yes\' if you want to enable the User Reputation system.</div></td>
  96. <td width="55%"><div style="width: auto;" align="left"><#rep_is_online#></div></td>
  97. </tr>
  98. </table>
  99. </div></div>
  100. <div>Default Reputation Level</div>
  101. <div style="padding: 5px; background-color: rgb(238, 242, 247);">
  102. <div>
  103. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  104. <tr>
  105. <td width="30%"><b>Default Reputation</b><div style="color: gray;">What reputation level shall new users receive upon registration? Make sure that you have a reputation level that is at least equal to or less than this value.</div></td>
  106. <td width="55%"><div style="width: auto;" align="left"><input name="rep_default" value="<#rep_default#>" size="30" type="text"></div></td>
  107. </tr>
  108. </table>
  109. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  110. <tr>
  111. <td width="30%"><b>Default Reputation Phrase</b><div style="color: gray;">If you have any user gain a reputation that exceeds your lowest negative level, then this phrase will be used for them. If you do not wish to use this phrase, make sure you set a negative reputation that is larger than the largest score (negative) that a user on your forum has.</div></td>
  112. <td width="55%"><div style="width: auto;" align="left"><input name="rep_undefined" value="<#rep_undefined#>" size="30" type="text"></div></td>
  113. </tr>
  114. </table>
  115. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  116. <tr>
  117. <td width="30%"><b>Number of Reputation Ratings to Display</b><div style="color: gray;">Controls how many ratings to display in the user&#39;s profile (userdetails).</div></td>
  118. <td width="55%"><div style="width: auto;" align="left"><input name="rep_userrates" value="<#rep_userrates#>" size="30" type="text"></div></td>
  119. </tr>
  120. </table>
  121. </div></div>
  122. <div>Reputation Powers</div>
  123. <div style="padding: 5px; background-color: rgb(238, 242, 247);">
  124. <div style="border: 1px solid rgb(131, 148, 178);">
  125. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  126. <tr>
  127. <td width="30%"><b>Administrator&#39;s Reputation Power</b><div style="color: gray;">How many reputation points does an administrator give or take away with each click?<br />Set to 0 to have administrators follow the same rules as everyone else.</div></td>
  128. <td class="tablerow2" width="55%"><div style="width: auto;" align="left"><input name="rep_adminpower" value="<#rep_adminpower#>" size="30" type="text"></div></td>
  129. </tr>
  130. </table>
  131. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  132. <tr>
  133. <td width="30%"><b>Register Date Factor</b><div style="color: gray;">For every X number of days, users gain 1 point of reputation-altering power.</div></td>
  134. <td width="55%"><div style="width: auto;" align="left"><input name="rep_rdpower" value="<#rep_rdpower#>" size="30" type="text">
  135. </div></td>
  136. </tr>
  137. </table>
  138. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  139. <tr>
  140. <td width="30%"><b>Post Count Factor</b><div style="color: gray;">For every X number of posts, users gain 1 point of reputation-altering power.</div></td>
  141. <td width="55%"><div style="width: auto;" align="left"><input name="rep_pcpower" value="<#rep_pcpower#>" size="30" type="text"></div></td>
  142. </tr>
  143. </table>
  144. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  145. <tr>
  146. <td width="30%"><b>Reputation Point Factor</b><div style="color: gray;">For every X points of reputation, users gain 1 point of reputation-altering power.</div></td>
  147. <td width="55%"><div style="width: auto;" align="left"><input name="rep_kppower" value="<#rep_kppower#>" size="30" type="text"></div></td>
  148. </tr>
  149. </table>
  150. </div></div>
  151. <div>User Reputation Settings</div>
  152. <div style="padding: 5px; background-color: rgb(238, 242, 247);">
  153. <div>
  154. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  155. <tr>
  156. <td width="30%"><b>Minimum Post Count</b><div style="color: gray;">How many posts must a user have before his reputation hits count on others?</div></td>
  157. <td width="55%"><div style="width: auto;" align="left"><input name="rep_minpost" value="<#rep_minpost#>" size="30" type="text"></div></td>
  158. </tr>
  159. </table>
  160. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  161. <tr>
  162. <td width="30%"><b>Minimum Reputation Count</b><div style="color: gray;">How much reputation must a user have before his reputation hits count on others?</div></td>
  163. <td width="55%"><div style="width: auto;" align="left"><input name="rep_minrep" value="<#rep_minrep#>" size="30" type="text"></div></td>
  164. </tr>
  165. </table>
  166. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  167. <tr>
  168. <td width="30%"><b>Daily Reputation Clicks Limit</b><div style="color: gray;">How many reputation clicks can a user give over each 24 hour period? Administrators are exempt from this limit.</div></td>
  169. <td width="55%"><div style="width: auto;" align="left"><input name="rep_maxperday" value="<#rep_maxperday#>" size="30" type="text"></div></td>
  170. </tr>
  171. </table>
  172. <table width="100%" border="0" cellpadding="5" cellspacing="0">
  173. <tr>
  174. <td width="30%"><b>Reputation User Spread</b><div style="color: gray;">How many different users must you give reputation to before you can hit the same person again? Administrators are exempt from this limit.</div></td>
  175. <td width="55%"><div style="width: auto;" align="left"><input name="rep_repeat" value="<#rep_repeat#>" size="30" type="text"></div></td>
  176. </tr>
  177. </table>
  178. </div></div>
  179. <input type="submit" name="submit" value="Add Reply" class="btn" tabindex="2" accesskey="s" />
  180. </form>
  181. </div>';
  182. $HTML_OUT = preg_replace_callback( "|<#(.*?)#>|", "template_out", $HTML_OUT);
  183. stdhead("Reputation Settings");
  184. echo $HTML_OUT;
  185. stdfoot();
  186. function template_out($matches)
  187. {
  188. global $GVARS;
  189. if ( $matches[1] == 'rep_is_online' )
  190. {
  191. return 'Yes &nbsp; <input name="rep_is_online" value="1" '.($GVARS['rep_is_online'] == 1 ? 'checked="checked"' : "").' type="radio">&nbsp;&nbsp;&nbsp;<input name="rep_is_online" value="0" '.($GVARS['rep_is_online'] == 1 ? "" : 'checked="checked"').' type="radio"> &nbsp; No';
  192. }
  193. else
  194. {
  195. return $GVARS[ $matches[1] ];
  196. }
  197. }
  198. function redirect($url, $text, $time=2)
  199. {
  200. global $BASEURL;
  201. $page_title = "Admin Rep Redirection";
  202. $page_detail = "<em>Redirecting...</em>";
  203. $html = "<meta http-equiv='refresh' content=\"{$time}; url={$BASEURL}/{$url}\">
  204. <div>
  205. <div>Redirecting</div>
  206. <div style='padding:8px'>
  207. <div style='font-size:12px'>$text
  208. <br />
  209. <br />
  210. <center><a href='{$BASEURL}/{$url}'>Click here if not redirected...</a></center>
  211. </div>
  212. </div>
  213. </div>";
  214. print $html;
  215. exit;
  216. }
  217. ?>