Browse code

Fixed typo in batch_upload.php

Clarissa Walker authored on 2015/09/14 09:01:32
Showing 1 changed files
... ...
@@ -118,7 +118,7 @@ if (isset($_FILES["zipfile"]) && $_FILES["zipfile"]["error"] != 4 && isset($_FIL
118 118
 					$filename = stripslashes($filename);
119 119
 					$filename = clean($filename);
120 120
 				
121
-					if (strlen($hash) != 40) || !verifyHash($hash))
121
+					if ((strlen($hash) != 40) || !verifyHash($hash))
122 122
 					{
123 123
 						echo errorMessage() . "Error: Info hash must be exactly 40 hex bytes.</p>\n";
124 124
 						$error_status = false;
Browse code

Fixed filtering with newtorrents.php dltorrent.php authentication behavior slightly changed batch_upload.php reverted

Clarissa Walker authored on 2015/09/14 08:55:30
Showing 1 changed files
... ...
@@ -118,7 +118,7 @@ if (isset($_FILES["zipfile"]) && $_FILES["zipfile"]["error"] != 4 && isset($_FIL
118 118
 					$filename = stripslashes($filename);
119 119
 					$filename = clean($filename);
120 120
 				
121
-					if ((strlen(htmlentities($_GET['hash'], ENT_QUOTES, UTF-8)) != 40) || !verifyHash($hash))
121
+					if (strlen($hash) != 40) || !verifyHash($hash))
122 122
 					{
123 123
 						echo errorMessage() . "Error: Info hash must be exactly 40 hex bytes.</p>\n";
124 124
 						$error_status = false;
Browse code

Continuation of reviewing filtering practices

Clarissa Walker authored on 2015/09/14 07:16:10
Showing 1 changed files
... ...
@@ -118,7 +118,7 @@ if (isset($_FILES["zipfile"]) && $_FILES["zipfile"]["error"] != 4 && isset($_FIL
118 118
 					$filename = stripslashes($filename);
119 119
 					$filename = clean($filename);
120 120
 				
121
-					if ((strlen($hash) != 40) || !verifyHash($hash))
121
+					if ((strlen(htmlentities($_GET['hash'], ENT_QUOTES, UTF-8)) != 40) || !verifyHash($hash))
122 122
 					{
123 123
 						echo errorMessage() . "Error: Info hash must be exactly 40 hex bytes.</p>\n";
124 124
 						$error_status = false;
Browse code

Checks added to some files: torrent_functions.php, tracker.php dltorrent.php's check changed to authenticate no matter what Some fixes and modifications from 2014: index.php, funcsv2.php, batch_upload.php, newtorrents.php, install.php, editconfig.php Version bumped up to 1.05

Clarissa Walker authored on 2015/08/30 00:06:28
Showing 1 changed files
... ...
@@ -56,7 +56,7 @@ if (isset($_FILES["zipfile"]) && $_FILES["zipfile"]["error"] != 4 && isset($_FIL
56 56
 					require_once ("BDecode.php");
57 57
 					require_once ("BEncode.php");
58 58
 					
59
-					$tracker_url = $website_url . substr($_SERVER['REQUEST_URI'], 0, -16) . $announceurl;
59
+					$tracker_url = $announce_url0 OR $announce_url1 OR $announce_url2 OR $announce_url3 OR $announce_url4;
60 60
 					
61 61
 					$array = BDecode($buffer);
62 62
 					if (!$array)
... ...
@@ -75,15 +75,16 @@ if (isset($_FILES["zipfile"]) && $_FILES["zipfile"]["error"] != 4 && isset($_FIL
75 75
 						}
76 76
 						if ($found_tracker == false)
77 77
 						{
78
-							echo errorMessage() . "Error: Multiple trackers were found but none of them match the
79
-								announce URL:<br>$tracker_url<br>Please re-create and re-upload the torrent.</p>\n";
78
+							echo errorMessage() . "Error: Multiple trackers were found but none of them match the primary
79
+								announce URL:<br>$tracker_url<br><br>or any alternate URLs:<br>$announce_url1<br>$announce_url2<br>$announce_url3<br>$announce_url4<br><br>Please re-create and re-upload the torrent.</p>\n";
80 80
 							$error_status = false;
81 81
 							exit;
82 82
 						}
83 83
 					} else {
84 84
 						//a single tracker is listed
85 85
 						if (strtolower($array["announce"]) != $tracker_url) {
86
-							echo errorMessage() . "Error: The tracker announce URL does not match this:<br>$tracker_url<br>Please re-create and re-upload the torrent.</p>\n";
86
+							echo errorMessage() . "Error: The tracker announce URL does not match the primary
87
+								announce URL:<br>$tracker_url<br><br>or any alternate URLs:<br>$announce_url1<br>$announce_url2<br>$announce_url3<br>$announce_url4<br><br>Please re-create and re-upload the torrent.</p>\n";
87 88
 							$error_status = false;
88 89
 							exit;
89 90
 						}
... ...
@@ -176,7 +177,7 @@ else
176 177
 {
177 178
 	//display upload box
178 179
 	?>
179
-	<?php require("config.php"); $tracker_url = $website_url . substr($_SERVER['REQUEST_URI'], 0, -16) . $announceurl; ?>
180
+	<?php require("config.php"); $tracker_url = $announce_url0; $alt_tracker_url1 = $announce_url1;	$alt_tracker_url2 = $announce_url2;	$alt_tracker_url3 = $announce_url3;	$alt_tracker_url4 = $announce_url4;?>
180 181
 	<p>This page lets you upload a zip file containing multiple torrents and add them into the database.  The
181 182
 	zip file cannot have any folders in it.  This requires that you are running PHP with compiled zip support.
182 183
 	If you are unsure, check with your system administrator or phpinfo().  Any torrents that already exist in
... ...
@@ -189,7 +190,8 @@ else
189 190
 	[1] Even if the custom title option is enabled, the torrents will have the same title as the filename.  If you
190 191
 	have the custom title option enabled, you may change the titles to your preference after the batch upload has
191 192
 	finished.<br>[2] The torrents you are batch uploading should include the following Tracker URL:
192
-	<b><?php echo $tracker_url ?></b></p>
193
+	<br><b><?php echo $tracker_url ?></b><br> or its alternate tracker URLs: <br><b><?php echo $alt_tracker_url1;?> <br>
194
+	<?php echo $alt_tracker_url2;?> <br> <?php echo $alt_tracker_url3;?> <br> <?php echo $alt_tracker_url4; ?></b></p>
193 195
 	
194 196
 	<?php
195 197
 	if (function_exists("zip_open"))
Browse code

Import from the old rivettracker git repository at sourceforge (amisaph/amisapphire branch)

Clarissa Walker (ami-sapphire) authored on 2014/01/24 14:02:23
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,214 @@
1
+<?php
2
+
3
+require ("config.php");
4
+require ("funcsv2.php"); //required for errorMessage() function
5
+//Check session
6
+session_start();
7
+
8
+if (!$_SESSION['admin_logged_in'])
9
+{
10
+	//check fails
11
+	header("Location: authenticate.php?status=session");
12
+	exit();
13
+}
14
+?>
15
+
16
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
17
+
18
+<html>
19
+<head>
20
+	<title>Batch Upload Torrents</title>
21
+	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
22
+	<link rel="stylesheet" href="./css/style.css" type="text/css" />
23
+</head>
24
+<body>
25
+<center>
26
+<h1>Batch Upload Torrents</h1>
27
+</center>
28
+<br>
29
+
30
+<?php
31
+
32
+if (isset($_FILES["zipfile"]) && $_FILES["zipfile"]["error"] != 4 && isset($_FILES["zipfile"]["tmp_name"])) //4 corresponds to the error no file uploaded
33
+{
34
+	?>
35
+	<a href="admin.php"><img src="images/admin.png" border="0" class="icon" alt="Admin Page" title="Admin Page" /></a><a href="admin.php">Return to Admin Page</a>
36
+	<br><br>
37
+	<?php
38
+	$zip = zip_open($_FILES["zipfile"]["tmp_name"]);
39
+	
40
+	if ($zip == true)
41
+	{
42
+		$db = mysql_connect($dbhost, $dbuser, $dbpass) or die(errorMessage() . "Couldn't connect to the database, contact the administrator</p>");
43
+		mysql_select_db($database) or die(errorMessage() . "Can't open the database.</p>");
44
+	
45
+	   while ($zip_entry = zip_read($zip))
46
+	   {
47
+	   	echo "Name: " . zip_entry_name($zip_entry) . "<br>\n";
48
+	      if (substr(zip_entry_name($zip_entry), -8) == ".torrent")
49
+			{
50
+				$error_status = true;
51
+				if (zip_entry_open($zip, $zip_entry, "r"))
52
+			   {
53
+			   	//read in file from zip
54
+			  		$buffer = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
55
+			      //go through each torrent file and add it if possible
56
+					require_once ("BDecode.php");
57
+					require_once ("BEncode.php");
58
+					
59
+					$tracker_url = $website_url . substr($_SERVER['REQUEST_URI'], 0, -16) . $announceurl;
60
+					
61
+					$array = BDecode($buffer);
62
+					if (!$array)
63
+					{
64
+						echo errorMessage() . "Error: The parser was unable to load this torrent.</p>\n";
65
+						$error_status = false;
66
+					}
67
+					if (isset($array["announce-list"])) {
68
+						//multiple trackers are listed
69
+						$found_tracker = false;
70
+						for ($i = 0; $i < count($array["announce-list"]); $i++) {
71
+							if (strtolower($array["announce-list"][$i][0]) == $tracker_url) {
72
+								$found_tracker = true;
73
+								break;
74
+							}
75
+						}
76
+						if ($found_tracker == false)
77
+						{
78
+							echo errorMessage() . "Error: Multiple trackers were found but none of them match the
79
+								announce URL:<br>$tracker_url<br>Please re-create and re-upload the torrent.</p>\n";
80
+							$error_status = false;
81
+							exit;
82
+						}
83
+					} else {
84
+						//a single tracker is listed
85
+						if (strtolower($array["announce"]) != $tracker_url) {
86
+							echo errorMessage() . "Error: The tracker announce URL does not match this:<br>$tracker_url<br>Please re-create and re-upload the torrent.</p>\n";
87
+							$error_status = false;
88
+							exit;
89
+						}
90
+					}
91
+					if (function_exists("sha1"))
92
+						$hash = @sha1(BEncode($array["info"]));
93
+					else
94
+					{
95
+						echo errorMessage() . "Error: It looks like you do not have a hash function available, this will not work.</p>\n";
96
+						$error_status = false;
97
+					}
98
+				
99
+					//figure out total size of all files in torrent, needed for insertion into database
100
+					$info = $array["info"];
101
+					$total_size = 0;
102
+					if (isset($info["files"]))
103
+					{
104
+						foreach ($info["files"] as $file)
105
+						{
106
+							$total_size = $total_size + $file["length"];
107
+						}
108
+					}
109
+					else
110
+					{
111
+						$total_size = $info["length"];
112
+					}
113
+					
114
+					//Validate torrent file, make sure everything is correct
115
+					$filename = $array["info"]["name"];
116
+					$filename = mysql_real_escape_string($filename);
117
+					$filename = stripslashes($filename);
118
+					$filename = clean($filename);
119
+				
120
+					if ((strlen($hash) != 40) || !verifyHash($hash))
121
+					{
122
+						echo errorMessage() . "Error: Info hash must be exactly 40 hex bytes.</p>\n";
123
+						$error_status = false;
124
+					}
125
+					
126
+				
127
+					if ($error_status == true)
128
+					{
129
+						$query = "INSERT INTO " . $prefix . "namemap (info_hash, title, filename, url, size, pubDate) VALUES (\"$hash\", \"$filename\", \"$filename\", \"$url\", \"$total_size\", \"" . date("$dateformat") . "\")";
130
+						$status = makeTorrent($hash, true);
131
+						quickQuery($query);
132
+						if ($status == true)
133
+						{
134
+							//create torrent file in folder, at this point we assume it's valid
135
+							if (!$handle = fopen("torrents/" . $filename . ".torrent", 'w'))
136
+							{
137
+	         				echo errorMessage() . "Error: Can't write to file.</p>\n";
138
+	        					break;
139
+	    					}
140
+							//populate file with contents
141
+					   	if (fwrite($handle, $buffer) === FALSE)
142
+					   	{
143
+					       	echo errorMessage() . "Error: Can't write to file.</p>\n";
144
+					      	break;
145
+					   	}
146
+					   	fclose($handle);
147
+							//make torrent file readable by all
148
+							chmod("torrents/" . $filename . ".torrent", 0644);
149
+							echo "<p class=\"success\">Torrent was added successfully.</p>\n";
150
+						}
151
+						else
152
+						{
153
+							echo errorMessage() . "There were some errors. Check if this torrent has been added previously.</p>\n";
154
+						}
155
+					}
156
+			
157
+			      zip_entry_close($zip_entry);
158
+			    }
159
+			} 
160
+			else
161
+				echo errorMessage() . "Unable to add torrent, it doesn't end in .torrent</p>\n";
162
+			
163
+		echo "<br>";
164
+	   }
165
+	   zip_close($zip);
166
+	}
167
+
168
+	//finished reading zip file
169
+	
170
+	//run RSS generator because we have new torrents in database
171
+	require_once("rss_generator.php");
172
+
173
+
174
+}
175
+else
176
+{
177
+	//display upload box
178
+	?>
179
+	<?php require("config.php"); $tracker_url = $website_url . substr($_SERVER['REQUEST_URI'], 0, -16) . $announceurl; ?>
180
+	<p>This page lets you upload a zip file containing multiple torrents and add them into the database.  The
181
+	zip file cannot have any folders in it.  This requires that you are running PHP with compiled zip support.
182
+	If you are unsure, check with your system administrator or phpinfo().  Any torrents that already exist in
183
+	the database will be skipped.  If you want to use HTTP seeding you'll need to add this feature to the torrent
184
+	files before you zip and upload the file.  If you are uploading a very large zip file this may take some time...
185
+	<br>
186
+	<br>
187
+	Notes:
188
+	<br>
189
+	[1] Even if the custom title option is enabled, the torrents will have the same title as the filename.  If you
190
+	have the custom title option enabled, you may change the titles to your preference after the batch upload has
191
+	finished.<br>[2] The torrents you are batch uploading should include the following Tracker URL:
192
+	<b><?php echo $tracker_url ?></b></p>
193
+	
194
+	<?php
195
+	if (function_exists("zip_open"))
196
+	{
197
+		?>
198
+		<form enctype="multipart/form-data" action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="post">
199
+		<b>Zip File:</b><input type="file" name="zipfile" size="50"/>
200
+		<input type="submit" value="Upload ZIP File"/>
201
+		</form>
202
+		<?php
203
+	}
204
+	else
205
+		echo errorMessage() . "Error: It looks like you don't have ZIP support compiled into PHP.</p>\n";
206
+}
207
+
208
+?>
209
+
210
+<br>
211
+<br>
212
+<a href="admin.php"><img src="images/admin.png" border="0" class="icon" alt="Admin Page" title="Admin Page" /></a><a href="admin.php">Return to Admin Page</a>
213
+</body>
214
+</html>