forked from torrage/Torrage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
73 lines (59 loc) · 1.81 KB
/
upload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
include_once dirname( __FILE__ ) . '/inc/main.inc.php';
// to allow for big files
set_time_limit( 0 );
ini_set( 'upload_max_filesize', 6 * 1048576 );
print_head();
echo "<h2>Upload:</h2>\n";
upload_error_handler( handle_upload( $_FILES['torrent']['tmp_name'] ) );
function upload_error_handler( $error )
{
global $SETTINGS;
// only do error check test if the value we get back is purely a number
if( is_numeric( $error ) && strlen( $error ) == 2 )
{
switch( $error )
{
case TORRAGE_FILE_NOT_FOUND:
echo <<< HTML
Error: File empty
<p>If you want to upload another file, go <a href="/">back</a> to the main page.</p>
HTML;
break;
case TORRAGE_FILE_EMPTY:
echo <<< HTML
Error: File empty
<p>If you want to upload another file, go <a href="/">back</a> to the main page.</p>
HTML;
break;
case TORRAGE_FILE_INVALID:
echo <<< HTML
Error: Broken torrent file, please recreate it and try again.
<p>If you want to upload another file, go <a href="/">back</a> to the main page.</p>
HTML;
break;
case TORRAGE_FILE_UNKNOWN:
echo <<< HTML
Error: Something didn't work, please try again later!
<p>If you want to upload another file, go <a href="/">back</a> to the main page.</p>
HTML;
break;
case TORRAGE_FILE_ERROR:
echo <<< HTML
Error: Something didn't work, please try again later!
<p>If you want to upload another file, go <a href="/">back</a> to the main page.</p>
HTML;
break;
}
}
else
{
echo <<< HTML
<p>Your torrentfile is now cached and can be downloaded at:<br />
<br /><a href="/torrent/{$error}.torrent">http://{$SETTINGS['torrstoredns']}/torrent/{$error}.torrent</a></p>
<p>If you want to upload another file, go <a href="/">back</a> to the main page.</p>
HTML;
}
print_foot();
exit( 0 );
}