PageRenderTime 60ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/edit.php

https://github.com/Bigjoos/U-232-V2
PHP | 261 lines | 222 code | 27 blank | 12 comment | 56 complexity | e934c8366fba3ec7ef69a7b8dd79b4b0 MD5 | raw file
  1. <?php
  2. /**
  3. * https://09source.kicks-ass.net:8443/svn/installer09/
  4. * Licence Info: GPL
  5. * Copyright (C) 2010 Installer09 v.2
  6. * A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
  7. * Project Leaders: Mindless,putyn,kidvision.
  8. **/
  9. require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
  10. require_once(INCL_DIR.'user_functions.php');
  11. require_once INCL_DIR.'html_functions.php';
  12. require_once INCL_DIR.'bbcode_functions.php';
  13. require_once CLASS_DIR.'page_verify.php';
  14. global $CURUSER;
  15. if (!mkglobal("id"))
  16. die();
  17. $id = 0 + $id;
  18. if (!$id)
  19. die();
  20. /** who is modding by pdq **/
  21. if ((isset($_GET['unedit']) && $_GET['unedit'] == 1) && $CURUSER['class'] >= UC_MODERATOR)
  22. {
  23. $modfile = 'cache/details/'.$id.'_moddin.txt';
  24. if (file_exists($modfile))
  25. unlink($modfile);
  26. $returl = "details.php?id=$id";
  27. if (isset($_POST["returnto"]))
  28. $returl .= "&returnto=" . urlencode($_POST["returnto"]);
  29. header("Refresh: 0; url=$returl");
  30. exit();
  31. }
  32. dbconn();
  33. loggedinorreturn();
  34. $lang = array_merge( load_language('global'), load_language('edit') );
  35. $stdfoot = array(/** include js **/'js' => array('shout','FormManager'));
  36. $newpage = new page_verify();
  37. $newpage->create('teit');
  38. $res = sql_query("SELECT * FROM torrents WHERE id = $id");
  39. $row = mysql_fetch_assoc($res);
  40. if (!$row)
  41. stderr($lang['edit_user_error'], $lang['edit_no_torrent']);
  42. if (!isset($CURUSER) || ($CURUSER["id"] != $row["owner"] && $CURUSER["class"] < UC_STAFF))
  43. {
  44. stderr($lang['edit_user_error'], sprintf($lang['edit_no_permission'], urlencode($_SERVER['REQUEST_URI'])));
  45. }
  46. $HTMLOUT = '';
  47. $HTMLOUT ="<script type='text/javascript'>
  48. window.onload = function() {
  49. setupDependencies('edit'); //name of form(s). Seperate each with a comma (ie: 'weboptions', 'myotherform' )
  50. };
  51. </script>";
  52. if ($CURUSER['class'] >= UC_MODERATOR)
  53. {
  54. $expire = 300; // 5 minutes
  55. $modfile = 'cache/details/'.$id.'_moddin.txt';
  56. if (file_exists($modfile) && filemtime($modfile) > (time() - $expire)) {
  57. $modcache = fopen($modfile, "r");
  58. $ismoddin = fread($modcache, filesize($modfile));
  59. fclose($modcache);
  60. $HTMLOUT .= '<h1><font size="+1"><font color="#FF0000">'.$ismoddin.'</font> is currently editing this torrent!</font></h1>';
  61. }
  62. else
  63. {
  64. $modder = $CURUSER['username'];
  65. $fp = fopen($modfile, "w") or die('Couldn\'t open file for writing!');
  66. fwrite($fp, $modder) or die('Couldn\'t write values to file!');
  67. fclose($fp);
  68. }
  69. }
  70. $ismodd = '<tr><td align=\'center\' class=\'colhead\' colspan=\'2\'><b>Edit Torrent</b> '.(($CURUSER['class'] > UC_UPLOADER)?'<small><a href="edit.php?id='.$id.'&amp;unedit=1">Click here</a> to add temp edit notification while you edit this torrent</small>':'').'</td></tr>';
  71. $HTMLOUT .= "<form name='edit' method='post' action='takeedit.php' enctype='multipart/form-data'>
  72. <input type='hidden' name='id' value='$id' />";
  73. if (isset($_GET["returnto"]))
  74. $HTMLOUT .= "<input type='hidden' name='returnto' value='" . htmlspecialchars($_GET["returnto"]) . "' />\n";
  75. $HTMLOUT .= "<table border='1' cellspacing='0' cellpadding='10'>\n";
  76. $HTMLOUT .= $ismodd;
  77. $HTMLOUT .= tr("{$lang['edit_imdb_url']}", "<input type='text' name='url' size='80' value='".$row["url"]."' />", 1);
  78. $HTMLOUT .= tr($lang['edit_poster'], "<input type='text' name='poster' size='80' value='" . htmlspecialchars($row["poster"]) . "' /><br />{$lang['edit_poster1']}\n", 1);
  79. $HTMLOUT .= tr($lang['edit_torrent_name'], "<input type='text' name='name' value='" . htmlspecialchars($row["name"]) . "' size='80' />", 1);
  80. $HTMLOUT .= tr($lang['edit_nfo'], "<input type='radio' name='nfoaction' value='keep' checked='checked' />{$lang['edit_keep_current']}<br />".
  81. "<input type='radio' name='nfoaction' value='update' />{$lang['edit_update']}<br /><input type='file' name='nfo' size='80' />", 1);
  82. if ((strpos($row["ori_descr"], "<") === false) || (strpos($row["ori_descr"], "&lt;") !== false))
  83. {
  84. $c = "";
  85. }
  86. else
  87. {
  88. $c = " checked";
  89. }
  90. $HTMLOUT .= tr($lang['edit_description'], "". textbbcode("edit","descr","".htmlspecialchars($row['ori_descr'])."")."<br />({$lang['edit_tags']})", 1);
  91. $s = "<select name='type'>\n";
  92. $cats = genrelist();
  93. foreach ($cats as $subrow)
  94. {
  95. $s .= "<option value='" . $subrow["id"] . "'";
  96. if ($subrow["id"] == $row["category"])
  97. $s .= " selected='selected'";
  98. $s .= ">" . htmlspecialchars($subrow["name"]) . "</option>\n";
  99. }
  100. $s .= "</select>\n";
  101. $HTMLOUT .= tr($lang['edit_type'], $s, 1);
  102. require_once(CACHE_DIR.'subs.php');
  103. $subs_list='';
  104. $subs_list .= "<table border=\"1\"><tr>\n";
  105. $i = 0;
  106. foreach($subs as $s)
  107. {
  108. $subs_list .= ($i && $i % 2 == 0) ? "</tr><tr>" : "";
  109. $subs_list .= "<td style='padding-right: 5px'><input name=\"subs[]\" " . (strpos($row["subs"], $s["id"]) !== false ? " checked='checked'" : "") . " type=\"checkbox\" value=\"".$s["id"]."\" /> ".$s["name"]."</td>\n";
  110. ++$i;
  111. }
  112. $subs_list .= "</tr></table>\n";
  113. $HTMLOUT .= tr("Subtitiles",$subs_list,1);
  114. $rg = "<select name='release_group'>\n<option value='scene'".($row["release_group"] == "scene" ? " selected='selected'" : "").">Scene</option>\n<option value='p2p'".($row["release_group"] == "p2p" ? " selected='selected'" : "").">p2p</option>\n<option value='none'".($row["release_group"] == "none" ? " selected='selected'" : "").">None</option> \n</select>\n";
  115. $HTMLOUT .= tr("Release Group", $rg, 1);
  116. $HTMLOUT .= tr($lang['edit_visible'], "<input type='checkbox' name='visible'" . (($row["visible"] == "yes") ? " checked='checked'" : "" ) . " value='1' /> {$lang['edit_visible_mainpage']}<br /><table border='0' cellspacing='0' cellpadding='0' width='420'><tr><td class='embedded'>{$lang['edit_visible_info']}</td></tr></table>", 1);
  117. if ($CURUSER['class'] >= UC_STAFF)
  118. $HTMLOUT .= tr($lang['edit_banned'], "<input type='checkbox' name='banned'" . (($row["banned"] == "yes") ? " checked='checked'" : "" ) . " value='1' /> {$lang['edit_banned']}", 1);
  119. if ($CURUSER['class'] >= UC_UPLOADER){
  120. $HTMLOUT .= tr("Nuked", "<input type='radio' name='nuked'" . ($row["nuked"] == "yes" ? " checked='checked'" : "") . " value='yes' />Yes <input type='radio' name='nuked'" . ($row["nuked"] == "no" ? " checked='checked'" : "") . " value='no' />No",1);
  121. $HTMLOUT .= tr("Nuke Reason", "<input type='text' name='nukereason' value='" . htmlspecialchars($row["nukereason"]) . "' size='80' />", 1);
  122. }
  123. if ($CURUSER['class'] >= UC_STAFF)
  124. {
  125. $HTMLOUT .= tr("Free Leech", ($row['free'] != 0 ?
  126. "<input type='checkbox' name='fl' value='1' /> Remove Freeleech" : "
  127. <select name='free_length'>
  128. <option value='0'>------</option>
  129. <option value='42'>Free for 1 day</option>
  130. <option value='1'>Free for 1 week</option>
  131. <option value='2'>Free for 2 weeks</option>
  132. <option value='4'>Free for 4 weeks</option>
  133. <option value='8'>Free for 8 weeks</option>
  134. <option value='255'>Unlimited</option>
  135. </select>"), 1);
  136. }
  137. if ($row['free'] != 0) {
  138. $HTMLOUT .= tr("Free Leech Duration",
  139. ($row['free'] != 1 ? "Until ".get_date($row['free'],'DATE')."
  140. (".mkprettytime($row['free'] - time())." to go)" : 'Unlimited'), 1);
  141. }
  142. // ===09 Allow Comments
  143. if ($CURUSER['class'] >= UC_MODERATOR && $CURUSER['class'] <= UC_SYSOP) {
  144. if ($row["allow_comments"] == "yes")
  145. $messc = "&nbsp;Comments are allowed for everyone on this torrent!";
  146. else
  147. $messc = "&nbsp;Only staff members are able to comment on this torrent!";
  148. $HTMLOUT.="<tr>
  149. <td align='right'><font color='red'>&nbsp;*&nbsp;</font><b>&nbsp;{$lang['edit_comment']}</b></td>
  150. <td>
  151. <select name='allow_comments'>
  152. <option value='".htmlspecialchars($row["allow_comments"])."'>".htmlspecialchars($row["allow_comments"])."</option>
  153. <option value='yes'>Yes</option><option value='no'>No</option></select>{$messc}</td></tr>\n";
  154. }
  155. // ===end
  156. if($CURUSER['class'] >= UC_STAFF){
  157. $HTMLOUT .= tr("Sticky", "<input type='checkbox' name='sticky'" . (($row["sticky"] == "yes") ? " checked='checked'" : "" ) . " value='yes' />Sticky this torrent !", 1);
  158. $HTMLOUT .= tr($lang['edit_anonymous'], "<input type='checkbox' name='anonymous'" . (($row["anonymous"] == "yes") ? " checked='checked'" : "" ) . " value='1' />{$lang['edit_anonymous1']}", 1);
  159. $HTMLOUT .= tr("VIP Torrent?", "<input type='checkbox' name='vip'" . (($row["vip"] == "1") ? " checked='checked'" : "" ) . " value='1' /> If this one is checked, only VIPs can download this torrent", 1);
  160. }
  161. //==09 Genre mod no sql
  162. $HTMLOUT .= "
  163. <tr>
  164. <td class='heading' align='right'><b>Genre</b>&nbsp;&nbsp;&nbsp;<br />Optional&nbsp;&nbsp;&nbsp;
  165. </td>
  166. <td align='left'>
  167. <table>
  168. <tr>
  169. <td align='left'>
  170. <input type='radio' name='genre' value='keep' checked='checked' />Dont touch it [ Current: ".htmlspecialchars($row['newgenre'])." ]<br /></td>
  171. <td style='border:none'><input type='radio' name='genre' value='movie' />Movie</td>
  172. <td style='border:none'><input type='radio' name='genre' value='music' />Music</td>
  173. <td style='border:none'><input type='radio' name='genre' value='game' />Game</td>
  174. <td style='border:none'><input type='radio' name='genre' value='apps' />Apps</td>
  175. <td style='border:none'><input type='radio' name='genre' value='' />None</td>
  176. </tr>
  177. </table>
  178. <table>
  179. <tr>
  180. <td colspan='4' style='border:none'>
  181. <label style='margin-bottom: 1em; padding-bottom: 1em; border-bottom: 3px silver groove;'>
  182. <input type='hidden' class='Depends on genre being movie or genre being music' /></label>";
  183. $movie = array ('Action', 'Comedy', 'Thriller', 'Adventure', 'Family', 'Adult', 'Sci-fi');
  184. for ($x = 0; $x < count ($movie); $x++) {
  185. $HTMLOUT .= "<label><input type=\"checkbox\" value=\"$movie[$x]\" name=\"movie[]\" class=\"DEPENDS ON genre BEING movie\" />$movie[$x]</label>";
  186. }
  187. $music = array ('Hip Hop', 'Rock', 'Pop', 'House', 'Techno', 'Commercial');
  188. for ($x = 0; $x < count ($music); $x++) {
  189. $HTMLOUT .= "<label><input type=\"checkbox\" value=\"$music[$x]\" name=\"music[]\" class=\"DEPENDS ON genre BEING music\" />$music[$x]</label>";
  190. }
  191. $game = array ('Fps', 'Strategy', 'Adventure', '3rd Person', 'Acton');
  192. for ($x = 0; $x < count ($game); $x++) {
  193. $HTMLOUT .= "<label><input type=\"checkbox\" value=\"$game[$x]\" name=\"game[]\" class=\"DEPENDS ON genre BEING game\" />$game[$x]</label>";
  194. }
  195. $apps = array ('Burning', 'Encoding', 'Anti-Virus', 'Office', 'Os', 'Misc', 'Image');
  196. for ($x = 0; $x < count ($apps); $x++) {
  197. $HTMLOUT .= "<label><input type=\"checkbox\" value=\"$apps[$x]\" name=\"apps[]\" class=\"DEPENDS ON genre BEING apps\" />$apps[$x]</label>";
  198. }
  199. $HTMLOUT .= "</td></tr></table></td></tr>";
  200. $HTMLOUT .= "<tr><td colspan='2' align='center'><input type='submit' value='{$lang['edit_submit']}' class='btn' /> <input type='reset' value='{$lang['edit_revert']}' class='btn' /></td></tr>
  201. </table>
  202. </form>
  203. <br />
  204. <form method='post' action='delete.php'>
  205. <table align='center' border='1' cellspacing='0' cellpadding='5'>
  206. <tr>
  207. <td class='colhead' style='background-color: #F5F4EA;padding-bottom: 5px' colspan='2'><b>{$lang['edit_delete_torrent']}.</b> {$lang['edit_reason']}</td>
  208. </tr>
  209. <tr>
  210. <td><input name='reasontype' type='radio' value='1' />&nbsp;{$lang['edit_dead']} </td><td> {$lang['edit_peers']}</td>
  211. </tr>
  212. <tr>
  213. <td><input name='reasontype' type='radio' value='2' />&nbsp;{$lang['edit_dupe']}</td><td><input type='text' size='40' name='reason[]' /></td>
  214. </tr>
  215. <tr>
  216. <td><input name='reasontype' type='radio' value='3' />&nbsp;{$lang['edit_nuked']}</td><td><input type='text' size='40' name='reason[]' /></td>
  217. </tr>
  218. <tr>
  219. <td><input name='reasontype' type='radio' value='4' />&nbsp;{$lang['edit_rules']}</td><td><input type='text' size='40' name='reason[]' />({$lang['edit_req']})</td>
  220. </tr>
  221. <tr>
  222. <td><input name='reasontype' type='radio' value='5' checked='checked' />&nbsp;{$lang['edit_other']}</td><td><input type='text' size='40' name='reason[]' />({$lang['edit_req']})<input type='hidden' name='id' value='$id' /></td>
  223. </tr>";
  224. if (isset($_GET["returnto"]))
  225. {
  226. $HTMLOUT .= "<input type='hidden' name='returnto' value='" . htmlspecialchars($_GET["returnto"]) . "' />\n";
  227. }
  228. $HTMLOUT .= "<tr><td colspan='2' align='center'><input type='submit' value='{$lang['edit_delete']}' class='btn' /></td>
  229. </tr>
  230. </table>
  231. </form>";
  232. //////////////////////////// HTML OUTPIT ////////////////////////////////
  233. print stdhead("{$lang['edit_stdhead']} '{$row["name"]}'") . $HTMLOUT . stdfoot($stdfoot);
  234. ?>