Witam mam problem z uploadem b³ad jest mniej wiecej taki ze nie dodaje trakera,seedow,Peerów i ile razy pobrano torrenta i w tym zecz ze na innym trakerze to chodzi b.ladnie a na tym nie ;/ oto plik upload.php

  1. <?
  2. /* check if file is being accessed directly */
  3. if (eregi("upload.php",$_SERVER['PHP_SELF'])) 
  4. {
  5. Header("Location: index.php?idx=");
  6. die();
  7. }
  8.  
  9. require_once ("include/functions.php");
  10. require_once ("include/config.php");
  11. require_once ("include/BDecode.php");
  12. require_once ("include/BEncode.php");
  13.  
  14. dbconn();
  15.  
  16. if (isset($_FILES['torrent']))
  17. {
  18. if ($_FILES['torrent']['error'] != 4)
  19. {
  20. $fd = fopen($_FILES['torrent']['tmp_name'], "rb") or die("File upload error 1n");
  21. is_uploaded_file($_FILES['torrent']['tmp_name']) or die("File upload error 2n");
  22. $alltorrent = fread($fd, filesize($_FILES['torrent']['tmp_name']));
  23. $array = BDecode($alltorrent);
  24. if (!isset($array))
  25. {
  26. unlink($_FILES['torrent']['tmp_name']);
  27. echo "This is not a valid torrent file";
  28. require "stdfooter.php";
  29. }
  30. if (!$array)
  31. {
  32. unlink($_FILES['torrent']['tmp_name']);
  33. echo "This is not a valid torrent file";
  34. require "stdfooter.php";
  35. }
  36. $hash = sha1(BEncode($array['info']));
  37. fclose($fd);
  38. }
  39. $reqreg = $_POST['reg'];
  40. $reqreg = strip_tags($reqreg);
  41. if ($reqreg == "")
  42. {
  43. unlink($_FILES['torrent']['tmp_name']);
  44. echo "Tracker registration must be filled in";
  45. require "stdfooter.php";
  46. }
  47. $fname = $_POST['filename'];
  48. if ($fname == "")
  49. {
  50. unlink($_FILES['torrent']['tmp_name']);
  51. echo "Please enter a filename";
  52. require "stdfooter.php";
  53. }
  54. if (isset($_POST["filename"]))
  55.  $filename=$_POST["filename"];
  56. else
  57. $filename = StripSlashes($_FILES["torrent"]["name"]);
  58.  
  59. $url = $TORRENTSDIR . "/" . $hash . ".btf";
  60. if (isset($_POST['info']))
  61. $comment = $_POST['info'];
  62. else
  63. $comment = "";
  64. if (isset($_POST['autoset']))
  65. {
  66. if (strcmp($_POST['autoset'], "enabled") == 0)
  67. {
  68. if (strlen($filename) == 0 && isset($array['info']['name']))
  69. $filename = $array['info']['name'];
  70. if (isset($array['comment']))
  71. $info = $array['comment'];
  72. else
  73. $info = "";
  74. }
  75. }
  76. $upfile=$array['info'];
  77. if (isset($upfile['length']))
  78. {
  79. $size = $upfile['length'];
  80. }
  81. else if (isset($upfile['files']))
  82. {
  83. $size=0;
  84. foreach ($upfile['files'] as $file)
  85. {
  86. $size+=intval($file['length']);
  87. }
  88. }
  89. else
  90. $size = "0";
  91. $filename = strip_tags($filename);
  92. $url = strip_tags($url);
  93. $info = strip_tags($info);
  94. $categoria = 0+$_POST['type'];
  95. $categoria = strip_tags($categoria);
  96. $comment = strip_tags($comment);
  97. $announce=$array['announce'];
  98. $anonyme=$_POST['anonymous'];
  99. $hash = strip_tags ($hash);
  100. if ($categoria==0)
  101. {
  102. unlink($_FILES['torrent']['tmp_name']);
  103. echo "you did not fill in the category";
  104. require "stdfooter.php";
  105. exit();
  106. }
  107. if ((strlen($hash) != 40) || !verifyHash($hash))
  108. {
  109. unlink($_FILES['torrent']['tmp_name']);
  110. echo("<center><FONT COLOR="red">Hash error</FONT></center>");
  111. require "stdfooter.php";
  112. exit ();
  113. }
  114. if ($announce!=$BASEURL."/announce.php" && $EXTERNAL_TORRENTS==false)
  115. {
  116. unlink($_FILES['torrent']['tmp_name']);
  117. echo "external torrents are not allowed";
  118. require "stdfooter.php";
  119. exit();
  120. }
  121.  
  122. $query = "INSERT INTO namemap 
  123. (info_hash, filename, url, info, category, data, size, comment, uploader,ano
    nymous, userip, reqreg) VALUES 
  124. ("$hash", "$filename", "$url", "$info",0 + $categoria,NOW(), "$size", "$comment",'3','$anonyme','$userip', '$reqreg')";
  125.  
  126. mysql_query($query)
  127. or sqlerr();
  128.  
  129. $status = makeTorrent($hash, true);
  130. quickQuery($query);
  131. if ($status)
  132.  {
  133.  move_uploaded_file($_FILES["torrent"]["tmp_name"] , $TORRENTSDIR . "/" . $hash . ".btf") or die("Error moving torrent...");
  134.  if ($announce!=$BASEURL."/announce.php")
  135. {
  136. //print("<center>Please wait one moment...<br /></center>");
  137. require_once("./include/getscrape.php");
  138. scrape($announce,$hash);
  139. echo "file upload succes...You can view your upload <a href="index.php?idx=details&amp;id=$hash">here</a>. ";
  140. require "stdfooter.php";
  141. exit();
  142. }
  143. }
  144. else
  145. {
  146. echo "this torrent allready exists in our d-base";
  147. unlink($_FILES['torrent']['tmp_name']);
  148. require "stdfooter.php";
  149. exit();
  150. }
  151. }
  152. else
  153. {
  154. ?>
  155. <div class="navbar"><ul>
  156. <li>You can upload torrents that are tracked by any tracker</li>
  157. <li>Do not send us adult content (you will get banned)</li>
  158. <li>If you need a open tracker without registration, use <a href="http://owntracker.com" target="_blank">http://owntracker.com</a></li>
  159. <li>Be patient while the script retrieves the data from the tracker (this may take a while)</li>
  160. <li>All ip's are logged misuse will get you banned</li>
  161. </ul>
  162. </div>
  163. <FORM name="upload" METHOD="POST" ENCTYPE="multipart/form-data">
  164. <table width="100%" border="0" class="infotable">
  165. <tr>
  166. <td>Torrent</td>
  167. <td><input type="file" name="torrent"></td>
  168. </tr>
  169. <tr> 
  170. <td>File name</td>
  171. <td><input type=text name="filename" size=50 maxlength=200></td>
  172. </tr>
  173. <tr>
  174. <td>Category</td>
  175. <td><select name="type">
  176. <option value="0">(Choose)</option>
  177. <?php
  178. $result = mysql_query("SELECT id, name, sort_index FROM categories ORDER BY name ASC ") or sqlerr();
  179. while ($row = mysql_fetch_assoc($result))
  180. {
  181. echo "<option value="";
  182. echo $row['id'];
  183. echo "">";
  184. echo $row['name'];
  185. echo "</option>";
  186. } 
  187. ?>
  188. </select>
  189. <input type=hidden name=user_id size=50 value= >
  190. <input type= hidden "radio" name="anonymous2" value="false" checked />
  191. <input type= hidden "radio" name="anonymous" value="true" />
  192. <input type= hidden checkbox name="autoset" value="enabled" checked></td>
  193. </tr>
  194. <tr>
  195. <td>Tracker requires registration</td>
  196. <td> yes <input name="reg" type="radio" value="1" /> no <input name="reg" type="radio" value="0" /></td>
  197. </tr>
  198. <tr>
  199. <td>&nbsp;</td>
  200. <td><input class="form_button" name="submit" type=submit value="Send"></td>
  201. </tr>
  202. </table>
  203. </FORM>
  204. <?
  205. }
  206. ?>