This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbitbucket-upload.php
87 lines (75 loc) · 3.84 KB
/
bitbucket-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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/*
+------------------------------------------------
| TBDev.net BitTorrent Tracker PHP
| =============================================
| by CoLdFuSiOn
| (c) 2003 - 2011 TBDev.Net
| http://www.tbdev.net
| =============================================
| svn: http://sourceforge.net/projects/tbdevnet/
| Licence Info: GPL
+------------------------------------------------
| $Date$
| $Revision$
| $Author$
| $URL$
+------------------------------------------------
*/
require_once "include/bittorrent.php";
require_once "include/user_functions.php";
dbconn();
loggedinorreturn();
$lang = array_merge( load_language('global'), load_language('bitbucket') );
$HTMLOUT = '';
$TBDEV['bb_upload_size'] = 256 * 1024;
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$file = $_FILES["file"];
if (!isset($file) || $file["size"] < 1)
stderr("{$lang['bitbucket_failed']}", "{$lang['bitbucket_not_received']}");
if ($file["size"] > $TBDEV['bb_upload_size'])
stderr("{$lang['bitbucket_failed']}", "{$lang['bitbucket_too_large']}");
$filename = $file["name"];
if (strpos($filename, "..") !== false || strpos($filename, "/") !== false)
stderr("{$lang['bitbucket_failed']}", "{$lang['bitbucket_bad_name']}");
$tgtfile = "bitbucket/$filename";
if (file_exists($tgtfile))
stderr("{$lang['bitbucket_failed']}", "{$lang['bitbucket_no_name']}<b>" . htmlsafechars($filename) . "</b> {$lang['bitbucket_exists']}");
$it = @exif_imagetype($file["tmp_name"]);
if ($it != IMAGETYPE_GIF && $it != IMAGETYPE_JPEG && $it != IMAGETYPE_PNG)
stderr("{$lang['bitbucket_failed']}", "{$lang['bitbucket_not_recognized']}");
$i = strrpos($filename, ".");
if ($i !== false)
{
$ext = strtolower(substr($filename, $i));
if (($it == IMAGETYPE_GIF && $ext != ".gif") || ($it == IMAGETYPE_JPEG && $ext != ".jpg") || ($it == IMAGETYPE_PNG && $ext != ".png"))
stderr("{$lang['bitbucket_error']}", "{$lang['bitbucket_invalid_extension']}");
}
else
stderr("{$lang['bitbucket_error']}", "{$lang['bitbucket_need_extension']}");
move_uploaded_file($file["tmp_name"], $tgtfile) or stderr("{$lang['bitbucket_error']}", "{$lang['bitbucket_internal_error2']}");
$url = str_replace(" ", "%20", htmlsafechars("{$TBDEV['baseurl']}/bitbucket/$filename"));
stderr("{$lang['bitbucket_success']}", "{$lang['bitbucket_url']}<b><a href=\"$url\">$url</a></b><p><a href='bitbucket-upload.php'>{$lang['bitbucket_upload_another']}</a>.");
}
$HTMLOUT .= "
<div class='cblock'>
<div class='cblock-header'>{$lang['bitbucket_bbupload']}</div>
<div class='cblock-lb'><b>{$lang['bitbucket_maximum']}".number_format($TBDEV['bb_upload_size'])."{$lang['bitbucket_bytes']}</b></div>
<div class='cblock-content'>
<form method='post' action='{$TBDEV['baseurl']}/bitbucket-upload.php' enctype='multipart/form-data'>
<table border='1' cellspacing='0' cellpadding='5'>
<tr><td class='rowhead'>{$lang['bitbucket_upload_file']}</td><td><input type='file' name='file' size='60' /></td></tr>
<tr><td colspan='2' align='center'><input type='submit' value='{$lang['bitbucket_upload']}' class='btn' /></td></tr>
</table>
</form>
<br />
<table class='main' width='410' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td class='embedded'><div class='small'>{$lang['bitbucket_disclaimer']}</div></td>
</tr>
</table>
</div>
</div>";
print stdhead("{$lang['bitbucket_bbupload']}") . $HTMLOUT .stdfoot();
?>