PageRenderTime 56ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/edit.php

https://github.com/Bigjoos/U-232-V1
PHP | 201 lines | 165 code | 25 blank | 11 comment | 49 complexity | 0d9632b82a9fc06ccf7e0bdc726a1e40 MD5 | raw file
  1. <?php
  2. /**
  3. * http://btdev.net:1337/svn/test/Installer09_Beta
  4. * Licence Info: GPL
  5. * Copyright (C) 2010 BTDev Installer v.1
  6. * A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
  7. * Project Leaders: Mindless,putyn.
  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 INCL_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. $newpage = new page_verify();
  36. $newpage->create('teit');
  37. $res = sql_query("SELECT * FROM torrents WHERE id = $id");
  38. $row = mysql_fetch_assoc($res);
  39. if (!$row)
  40. stderr($lang['edit_user_error'], $lang['edit_no_torrent']);
  41. if (!isset($CURUSER) || ($CURUSER["id"] != $row["owner"] && $CURUSER["class"] < UC_STAFF))
  42. {
  43. stderr($lang['edit_user_error'], sprintf($lang['edit_no_permission'], urlencode($_SERVER['REQUEST_URI'])));
  44. }
  45. $HTMLOUT = '';
  46. if ($CURUSER['class'] >= UC_MODERATOR)
  47. {
  48. $expire = 300; // 5 minutes
  49. $modfile = 'cache/details/'.$id.'_moddin.txt';
  50. if (file_exists($modfile) && filemtime($modfile) > (time() - $expire)) {
  51. $modcache = fopen($modfile, "r");
  52. $ismoddin = fread($modcache, filesize($modfile));
  53. fclose($modcache);
  54. $HTMLOUT .= '<h1><font size="+1"><font color="#FF0000">'.$ismoddin.'</font> is currently editing this torrent!</font></h1>';
  55. }
  56. else
  57. {
  58. $modder = $CURUSER['username'];
  59. $fp = fopen($modfile, "w") or die('Couldn\'t open file for writing!');
  60. fwrite($fp, $modder) or die('Couldn\'t write values to file!');
  61. fclose($fp);
  62. }
  63. }
  64. $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>';
  65. $HTMLOUT .= "<form name='compose' method='post' action='takeedit.php' enctype='multipart/form-data'>
  66. <input type='hidden' name='id' value='$id' />";
  67. if (isset($_GET["returnto"]))
  68. $HTMLOUT .= "<input type='hidden' name='returnto' value='" . htmlspecialchars($_GET["returnto"]) . "' />\n";
  69. $HTMLOUT .= "<table border='1' cellspacing='0' cellpadding='10'>\n";
  70. $HTMLOUT .= $ismodd;
  71. $HTMLOUT .= tr("{$lang['edit_imdb_url']}", "<input type='text' name='url' size='80' value='".$row["url"]."' />", 1);
  72. $HTMLOUT .= tr($lang['edit_poster'], "<input type='text' name='poster' size='80' value='" . htmlspecialchars($row["poster"]) . "' /><br />{$lang['edit_poster1']}\n", 1);
  73. $HTMLOUT .= tr($lang['edit_torrent_name'], "<input type='text' name='name' value='" . htmlspecialchars($row["name"]) . "' size='80' />", 1);
  74. $HTMLOUT .= tr($lang['edit_nfo'], "<input type='radio' name='nfoaction' value='keep' checked='checked' />{$lang['edit_keep_current']}<br />".
  75. "<input type='radio' name='nfoaction' value='update' />{$lang['edit_update']}<br /><input type='file' name='nfo' size='80' />", 1);
  76. if ((strpos($row["ori_descr"], "<") === false) || (strpos($row["ori_descr"], "&lt;") !== false))
  77. {
  78. $c = "";
  79. }
  80. else
  81. {
  82. $c = " checked";
  83. }
  84. $HTMLOUT .= tr($lang['edit_description'], "". textbbcode("compose","descr","".htmlspecialchars($row['ori_descr'])."")."<br />({$lang['edit_tags']})", 1);
  85. $s = "<select name='type'>\n";
  86. $cats = genrelist();
  87. foreach ($cats as $subrow)
  88. {
  89. $s .= "<option value='" . $subrow["id"] . "'";
  90. if ($subrow["id"] == $row["category"])
  91. $s .= " selected='selected'";
  92. $s .= ">" . htmlspecialchars($subrow["name"]) . "</option>\n";
  93. }
  94. $s .= "</select>\n";
  95. $HTMLOUT .= tr($lang['edit_type'], $s, 1);
  96. $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";
  97. $HTMLOUT .= tr("Release Group", $rg, 1);
  98. $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);
  99. if ($CURUSER['class'] >= UC_STAFF)
  100. {
  101. $HTMLOUT .= tr($lang['edit_banned'], "<input type='checkbox' name='banned'" . (($row["banned"] == "yes") ? " checked='checked'" : "" ) . " value='1' /> {$lang['edit_banned']}", 1);
  102. }
  103. if ($CURUSER['class'] >= UC_VIP)
  104. $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);
  105. $HTMLOUT .= tr("Nuke Reason", "<input type='text' name='nukereason' value='" . htmlspecialchars($row["nukereason"]) . "' size='80' />", 1);
  106. if ($CURUSER['class'] >= UC_STAFF)
  107. {
  108. $HTMLOUT .= tr("Free Leech", ($row['free'] != 0 ?
  109. "<input type='checkbox' name='fl' value='1' /> Remove Freeleech" : "
  110. <select name='free_length'>
  111. <option value='0'>------</option>
  112. <option value='42'>Free for 1 day</option>
  113. <option value='1'>Free for 1 week</option>
  114. <option value='2'>Free for 2 weeks</option>
  115. <option value='4'>Free for 4 weeks</option>
  116. <option value='8'>Free for 8 weeks</option>
  117. <option value='255'>Unlimited</option>
  118. </select>"), 1);
  119. }
  120. if ($row['free'] != 0) {
  121. $HTMLOUT .= tr("Free Leech Duration",
  122. ($row['free'] != 1 ? "Until ".get_date($row['free'],'DATE')."
  123. (".mkprettytime($row['free'] - time())." to go)" : 'Unlimited'), 1);
  124. }
  125. // ===09 Allow Comments
  126. if ($CURUSER['class'] >= UC_MODERATOR && $CURUSER['class'] <= UC_SYSOP) {
  127. if ($row["allow_comments"] == "yes")
  128. $messc = "&nbsp;Comments are allowed for everyone on this torrent!";
  129. else
  130. $messc = "&nbsp;Only staff members are able to comment on this torrent!";
  131. $HTMLOUT.="<tr>
  132. <td align='right'><font color='red'>&nbsp;*&nbsp;</font><b>&nbsp;{$lang['edit_comment']}</b></td>
  133. <td>
  134. <select name='allow_comments'>
  135. <option value='".htmlspecialchars($row["allow_comments"])."'>".htmlspecialchars($row["allow_comments"])."</option>
  136. <option value='yes'>Yes</option><option value='no'>No</option></select>{$messc}</td></tr>\n";
  137. }
  138. // ===end
  139. if($CURUSER['class'] >= UC_STAFF)
  140. $HTMLOUT .= tr("Sticky", "<input type='checkbox' name='sticky'" . (($row["sticky"] == "yes") ? " checked='checked'" : "" ) . " value='yes' />Sticky this torrent !", 1);
  141. $HTMLOUT .= tr($lang['edit_anonymous'], "<input type='checkbox' name='anonymous'" . (($row["anonymous"] == "yes") ? " checked='checked'" : "" ) . " value='1' />{$lang['edit_anonymous1']}", 1);
  142. $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>
  143. </table>
  144. </form>
  145. <br />
  146. <form method='post' action='delete.php'>
  147. <table border='1' cellspacing='0' cellpadding='5'>
  148. <tr>
  149. <td class='embedded' style='background-color: #F5F4EA;padding-bottom: 5px' colspan='2'><b>{$lang['edit_delete_torrent']}.</b> {$lang['edit_reason']}</td>
  150. </tr>
  151. <tr>
  152. <td><input name='reasontype' type='radio' value='1' />&nbsp;{$lang['edit_dead']} </td><td> {$lang['edit_peers']}</td>
  153. </tr>
  154. <tr>
  155. <td><input name='reasontype' type='radio' value='2' />&nbsp;{$lang['edit_dupe']}</td><td><input type='text' size='40' name='reason[]' /></td>
  156. </tr>
  157. <tr>
  158. <td><input name='reasontype' type='radio' value='3' />&nbsp;{$lang['edit_nuked']}</td><td><input type='text' size='40' name='reason[]' /></td>
  159. </tr>
  160. <tr>
  161. <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>
  162. </tr>
  163. <tr>
  164. <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>
  165. </tr>";
  166. if (isset($_GET["returnto"]))
  167. {
  168. $HTMLOUT .= "<input type='hidden' name='returnto' value='" . htmlspecialchars($_GET["returnto"]) . "' />\n";
  169. }
  170. $HTMLOUT .= "<tr><td colspan='2' align='center'><input type='submit' value='{$lang['edit_delete']}' class='btn' /></td>
  171. </tr>
  172. </table>
  173. </form>";
  174. //////////////////////////// HTML OUTPIT ////////////////////////////////
  175. print stdhead("{$lang['edit_stdhead']} '{$row["name"]}'") . $HTMLOUT . stdfoot();
  176. ?>