PageRenderTime 86ms CodeModel.GetById 40ms RepoModel.GetById 0ms app.codeStats 0ms

/TBDev/installer_v4_1/events.php

https://github.com/cybernet/CyBerFuN-CoDeX
PHP | 272 lines | 245 code | 13 blank | 14 comment | 49 complexity | 1f0af4d38958a605672545b312f17467 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. require_once("include/bittorrent.php");
  3. require_once ("include/user_functions.php");
  4. require_once ("include/bbcode_functions.php");
  5. require_once("include/function_bonus.php");
  6. dbconn();
  7. maxcoder();
  8. if (!logged_in()) {
  9. header("HTTP/1.0 404 Not Found");
  10. // moddifed logginorreturn by retro//Remember to change the following line to match your server
  11. 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");
  12. die();
  13. }
  14. if (get_user_class() < UC_MODERATOR)
  15. hacker_dork("Events - Nosey Cunt !");
  16. $scheduled_events = mysql_fetch_all("SELECT * from `events` ORDER BY `startTime` DESC LIMIT 10;", array());
  17. if (is_array($scheduled_events)){
  18. foreach ($scheduled_events as $scheduled_event)
  19. {
  20. if (is_array($scheduled_event) && array_key_exists('startTime', $scheduled_event) &&
  21. array_key_exists('endTime', $scheduled_event))
  22. {
  23. $startTime = 0;
  24. $endTime = 0;
  25. $overlayText = "";
  26. $displayDates = true;
  27. //$freeleechEnabled = false;
  28. //$freeleech_enabled = false;//make false to disable free leech
  29. //$double_upload_enabled = false;
  30. //$invites_enabled = false;
  31. $startTime = $scheduled_event['startTime'];
  32. //if(!is_int($startTime))
  33. // $startTime = 0;
  34. $endTime = $scheduled_event['endTime'];
  35. //if(!is_int($endTime))
  36. // $endTime = 0;
  37. if (time() < $endTime && time() > $startTime)
  38. {
  39. if (array_key_exists('overlayText', $scheduled_event))
  40. $overlayText = $scheduled_event['overlayText'];
  41. if (!is_string($overlayText))
  42. $overlayText = "";
  43. if (array_key_exists('displayDates', $scheduled_event))
  44. $displayDates = (bool)(int)$scheduled_event['displayDates'];
  45. if (!is_bool($displayDates))
  46. $displayDates = false;
  47. if (array_key_exists('freeleechEnabled', $scheduled_event)) {
  48. $freeleechEnabled = $scheduled_event['freeleechEnabled'];
  49. }
  50. if (!is_bool($freeleechEnabled)){
  51. $freeleechEnabled = false;
  52. }
  53. if (array_key_exists('duploadEnabled', $scheduled_event)){
  54. $duploadEnabled = $scheduled_event['duploadEnabled'];
  55. }
  56. if (!is_bool($duploadEnabled)) {
  57. $duploadEnabled = false;
  58. }
  59. if (array_key_exists('hdownEnabled', $scheduled_event)) {
  60. $hdownEnabled = $scheduled_event['hdownEnabled'];
  61. }
  62. if (!is_bool($hdownEnabled)) {
  63. $hdownEnabled = false;
  64. }
  65. if ($freeleechEnabled){
  66. $freeleech_enabled = true;
  67. }
  68. if ($duploadEnabled){
  69. $double_upload_enabled = true;
  70. }
  71. if ($hdownEnabled){
  72. $hdown_enabled = true;
  73. }
  74. if ($displayDates) {
  75. $overlay_text = "<span style=\"font-size: 90%\">$overlayText</span><br/><span style=\"font-size: 60%\">" .
  76. date("d/m", $startTime) . " - " . date("d/m", $endTime) . "</span>\n";
  77. } else {
  78. $overlay_text = "<span style=\"font-size: 90%\">$overlayText</span>\n";
  79. }
  80. }
  81. }
  82. }
  83. }
  84. if (get_user_class() < UC_MODERATOR)
  85. stderr("Sorry", "Access denied.");
  86. if(array_key_exists('js', $_GET)){
  87. Header('Content-Type: text/javascript');
  88. ?>
  89. function checkAllGood(event){
  90. var result = confirm("Are you sure you want to remove '" + event + "' Event ?");
  91. if(result)
  92. return true;
  93. else
  94. return false;
  95. }
  96. <?php
  97. exit();
  98. }
  99. stdhead("Edit Events");
  100. echo "<script type=\"text/javascript\" src=\"?js\"></script>\n";
  101. if(!is_array($scheduled_events)){
  102. echo "Error: Events not loaded.";
  103. }else{
  104. foreach($_POST as $key => $value){
  105. if(gettype($pos = strpos($key, "_"))!=boolean){
  106. $id = (int)substr($key, $pos + 1);
  107. if(gettype(strpos($key, "removeEvent_"))!=boolean){
  108. $sql = "DELETE FROM `events` WHERE `id` = $id LIMIT 1;";
  109. $res = mysql_query($sql);
  110. if(mysql_error()!=0)
  111. echo "<p>Error Deleting Event: " . mysql_error() . "</p>\n";
  112. else{
  113. if(mysql_affected_rows()==0)
  114. echo "<p>Error Deleting Event: " . mysql_error() . "</p>\n";
  115. else{
  116. echo "<p>Deleted.</p>\n";
  117. //$scheduled_events = mysql_fetch_all("SELECT * from `events` WHERE `startTime` <= ". time() .";", null);
  118. //$scheduled_events = mysql_fetch_all("SELECT * from `events`", null);
  119. }
  120. }
  121. }elseif(gettype(strpos($key, "saveEvent_"))!=boolean){
  122. $text = "";
  123. $start = 0;
  124. $end = 0;
  125. $showDates = 0;
  126. $freeleech =0;
  127. $doubleUpload = 0;
  128. $hdown = 0;
  129. if(array_key_exists('editText', $_POST))
  130. $text = $_POST['editText'];
  131. if(array_key_exists('editStartTime', $_POST))
  132. $start = strtotime(trim($_POST['editStartTime']));
  133. if(array_key_exists('editEndTime', $_POST))
  134. $end = strtotime(trim($_POST['editEndTime']));
  135. if(array_key_exists('editFreeleech', $_POST))
  136. $freeleech = 1;
  137. if(array_key_exists('editShowDates', $_POST))
  138. $showDates = 1;
  139. if($id==-1)
  140. $sql = "INSERT INTO `events`(`overlayText`, `startTime`, `endTime`, `displayDates`, `freeleechEnabled`) VALUES ('$text', $start, $end, $showDates, $freeleech);";
  141. else
  142. $sql = "UPDATE `events` SET `overlayText` = '$text',`startTime` = $start, `endTime` = $end, `displayDates` = $showDates, `freeleechEnabled` = $freeleech WHERE `id` = $id;";
  143. //echo "<p>$sql</p>";
  144. $res = mysql_query($sql);
  145. if(mysql_error()!=0)
  146. echo "<p>Error Saving Event: " . mysql_error() . "</p>\n";
  147. else{
  148. if(mysql_affected_rows()==0)
  149. echo "<p>Possible Error Saving (No Changes)</p>\n";
  150. else{
  151. echo "<p>Saved.</p>\n";
  152. //$scheduled_events = mysql_fetch_all("SELECT * from `events` WHERE `startTime` <= ". time() .";", null);
  153. //$scheduled_events = mysql_fetch_all("SELECT * from `events` ;", null);
  154. }
  155. }
  156. }
  157. }
  158. }
  159. ?>
  160. <p><strong> Events Schedular </strong> (eZERO) - <strong> <font color=red>BETA</font> </strong> </p>
  161. <form action="" method="post">
  162. <table width="100%" cellpadding="6">
  163. <tr><th>User</th><th>Text</th><th>Start</th><th>End</th><th>Freeleech?</th><th>DUpload?</th><th>halfdownload?</th><th>Show Dates?</th><th>&nbsp;</th></tr>
  164. <?php
  165. foreach($scheduled_events as $scheduled_event){
  166. $id = $scheduled_event['id'];
  167. $username = get_user_name($scheduled_event['userid']);
  168. $text = $scheduled_event['overlayText'];
  169. $start = date("F j, Y, g:i a", (int)$scheduled_event['startTime']);
  170. $end = date("F j, Y, g:i a", (int)$scheduled_event['endTime']);
  171. $freeleech = (bool)(int)$scheduled_event['freeleechEnabled'];
  172. $doubleUpload = (bool)(int)$scheduled_event['duploadEnabled'];
  173. $hdown = (bool)(int)$scheduled_event['hdownEnabled'];
  174. if($freeleech){
  175. $freeleech = "<img src=\"".$pic_base_url."/on.gif\" alt=\"Freeleech Enabled\" title=\"Enabled\" />";
  176. }else{
  177. $freeleech = "<img src=\"".$pic_base_url."/off.gif\" alt=\"Freeleech Disabled\" title=\"Disabled\" />";
  178. }
  179. if($doubleUpload){
  180. $doubleUpload = "<img src=\"".$pic_base_url."/on.gif\" alt=\"Double Upload Enabled\" title=\"Enabled\" />";
  181. }else{
  182. $doubleUpload = "<img src=\"".$pic_base_url."/off.gif\" alt=\"Double Upload Disabled\" title=\"Disabled\" />";
  183. }
  184. if($hdown){
  185. $hdown = "<img src=\"".$pic_base_url."/on.gif\" alt=\"Halfdownload Enabled\" title=\"Enabled\" />";
  186. }else{
  187. $hdown = "<img src=\"".$pic_base_url."/off.gif\" alt=\"Halfdownload Disabled\" title=\"Disabled\" />";
  188. }
  189. $showdates = (bool)(int)$scheduled_event['displayDates'];
  190. if($showdates){
  191. $showdates = "<img src=\"".$pic_base_url."/on.gif\" alt=\"Showing of Dates Enabled\" title=\"Enabled\" />";
  192. }else{
  193. $showdates = "<img src=\"".$pic_base_url."/off.gif\" alt=\"Showing of Dates Disabled\" title=\"Disabled\" />";
  194. }
  195. echo "<tr><td align=\"center\">$username[username]</td><td align=\"center\">$text</td><td align=\"center\">$start</td><td align=\"center\">$end</td><td align=\"center\">$freeleech</td><td align=\"center\">$doubleUpload</td><td align=\"center\">$hdown</td><td align=\"center\">$showdates</td><td align=\"center\"><input type=\"submit\" name=\"editEvent_$id\" value=\"Edit\" /> <input type=\"submit\" onclick=\"return checkAllGood('$text')\" name=\"removeEvent_$id\" value=\"Remove\" /></td></tr>";
  196. }
  197. ?>
  198. <tr><td colspan="9" align="right"><input type="submit" name="editEvent_-1" value="Add Event" /></td></tr>
  199. </table>
  200. <?php
  201. foreach($_POST as $key => $value){
  202. if(gettype($pos = strpos($key, "_"))!=boolean){
  203. $id = (int)substr($key, $pos + 1);
  204. if(gettype(strpos($key, "editEvent_"))!=boolean){
  205. if($id==-1){
  206. ?>
  207. <table>
  208. <tr><th align="right">Text</th><td><input type="text" name="editText" /></td></tr>
  209. <tr><th align="right">Start Time</th><td><input type="text" name="editStartTime" /></td></tr>
  210. <tr><th align="right">End Time</th><td><input type="text" name="editEndTime" /></td></tr>
  211. <tr><th align="right">Freeleech</th><td><input type="checkbox" name="editFreeleech" /></td></tr>
  212. <tr><th align="right">DoubleUpload</th><td><input type="checkbox" name="editDUpload" /></td></tr>
  213. <tr><th align="right">halfdownload</th><td><input type="checkbox" name="edithalfdownload" /></td></tr>
  214. <tr><th align="right">Show Dates</th><td><input type="checkbox" name="editShowDates" /></td></tr>
  215. <tr><td colspan="2" align="center"><input type="submit" name="saveEvent_-1" value="Save Changes" /></td></tr>
  216. </table>
  217. <?php
  218. }else
  219. foreach($scheduled_events as $scheduled_event){
  220. if($id == $scheduled_event['id']){
  221. $text = $scheduled_event['overlayText'];
  222. $start = date("Y-m-d H:i:s O", (int)$scheduled_event['startTime']);
  223. $end = date("Y-m-d H:i:s O", (int)$scheduled_event['endTime']);
  224. $freeleech = (bool)(int)$scheduled_event['freeleechEnabled'];
  225. if($freeleech){
  226. $freeleech = " checked=\"checked\"";
  227. }else{
  228. $freeleech = "";
  229. }
  230. $showdates = (bool)(int)$scheduled_event['displayDates'];
  231. if($showdates){
  232. $showdates = " checked=\"checked\"";
  233. }else{
  234. $showdates = "";
  235. }?>
  236. <table>
  237. <tr><th align="right">Text</th><td><input type="text" name="editText" value="<?php echo $text; ?>" /></td></tr>
  238. <tr><th align="right">Start Time</th><td><input type="text" name="editStartTime" value="<?php echo $start; ?>" /></td></tr>
  239. <tr><th align="right">End Time</th><td><input type="text" name="editEndTime" value="<?php echo $end; ?>" /></td></tr>
  240. <tr><th align="right">Freeleech</th><td><input type="checkbox" name="editFreeleech" <?php echo $freeleech; ?>/></td></tr>
  241. <tr><th align="right">DoubleUpload</th><td><input type="checkbox" name="editDoubleupload" <?php echo $doubleUpload; ?>/></td></tr>
  242. <tr><th align="right">halfdownload</th><td><input type="checkbox" name="editHalfdownload" <?php echo $halfdownload; ?>/></td></tr>
  243. <tr><th align="right">Show Dates</th><td><input type="checkbox" name="editShowDates" <?php echo $showdates; ?>/></td></tr>
  244. <tr><td colspan="2" align="center"><input type="submit" name="saveEvent_<?php echo $id; ?>" value="Save Changes" /></td></tr>
  245. </table>
  246. <?php
  247. break;
  248. }
  249. }
  250. }
  251. }
  252. }
  253. ?>
  254. </form>
  255. <?php
  256. }
  257. stdfoot();
  258. die;
  259. ?>