forked from joeroberts234/phpMyBitTorrent
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadmindownload.php
117 lines (112 loc) · 4.59 KB
/
admindownload.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/*
*----------------------------phpMyBitTorrent V 2.0.5---------------------------*
*--- The Ultimate BitTorrent Tracker and BMS (Bittorrent Management System) ---*
*-------------- Created By Antonio Anzivino (aka DJ Echelon) --------------*
*------------------- And Joe Robertson (aka joeroberts) -------------------*
*------------- http://www.p2pmania.it -------------*
*------------ Based on the Bit Torrent Protocol made by Bram Cohen ------------*
*------------- http://www.bittorrent.com -------------*
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*-- This program is free software; you can redistribute it and/or modify --*
*-- it under the terms of the GNU General Public License as published by --*
*-- the Free Software Foundation; either version 2 of the License, or --*
*-- (at your option) any later version. --*
*-- --*
*-- This program is distributed in the hope that it will be useful, --*
*-- but WITHOUT ANY WARRANTY; without even the implied warranty of --*
*-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --*
*-- GNU General Public License for more details. --*
*-- --*
*-- You should have received a copy of the GNU General Public License --*
*-- along with this program; if not, write to the Free Software --*
*-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --*
*-- --*
*------------------------------------------------------------------------------*
*------ ©2010 phpMyBitTorrent Development Team ------*
*----------- http://phpmybittorrent.com -----------*
*------------------------------------------------------------------------------*
*-------------------- Sunday, May 17, 2009 1:05 AM ------------------------*
*/
die();
require_once("include/config_lite.php");
if ($use_rsa) require_once("include/rsalib.php");
require_once("include/functions.php");
require_once("include/class.user.php");
if ($use_rsa) $rsa = new RSA($rsa_modulo, $rsa_public, $rsa_private);
$user = @new User($_COOKIE["btuser"]);
if (isset($btlanguage) AND is_readable("language/".$btlanguage.".php")) $language = $btlanguage;
if (isset($bttheme) AND is_readable("themes/".$bttheme."/main.php")) $theme = $bttheme;
if (is_readable("language/".$language.".php"))
require_once("language/".$language.".php");
else
require_once("language/english.php");
if (file_exists("./themes/".$theme."/main.php")) {
require_once("./themes/".$theme."/main.php");
} elseif (file_exists("./themes/pmbt/main.php")) {
$theme = "pmbt";
require_once("./themes/pmbt/main.php");
} else {
die("Cannot run without theme! Reinstall phpMyBitTorrent NOW!!");
}
if(!isset($conferm) || $conferm == '' || $conferm != md5($user->name.$user->act_key.$name)){
OpenErrTable(_btaccdenied);
echo _btnoautherizeddownload;
CloseErrTable();
die();
}
if(!isset($backup) || !isset($name) || !isset($method)){
OpenErrTable(_btaccdenied);
echo "Missing Input Please Try again";
CloseErrTable();
}
if(!checkaccess("download")){
OpenErrTable(_btaccdenied);
echo _btnoautherizeddownload;
CloseErrTable();
die();
}
if(!isset($conferm) || $conferm == '' || $conferm != md5($user->name.$user->act_key.$name)){
OpenErrTable(_bterror);
echo _btnoautherizeddownload;
CloseErrTable();
die();
}
if (!is_file($backup) OR !is_readable($backup)) {
header("HTTP/1.0 500 Internal Server Error");
themeheader();
bterror(_bttorrentunavailable);
}
$size = @filesize($backup);
$handle = @fopen($backup, 'rb');
if($handle){
switch ($method)
{
case 'text':
$mimetype = 'text/x-sql';
break;
case 'zip':
$mimetype = 'application/zip';
break;
case 'gz':
$mimetype = 'application/x-gzip';
break;
}
header("Content-Type: $mimetype; name=\"$name\"");
header("Content-Disposition: attachment; filename=\"$name\"");
header('X-Download-Options: noopen');
if ($size)
{
header("Content-Length: $size");
}
while(!feof($handle)) {
echo fread($handle, 8192);
}
fclose($handle);
unlink($backup);
die();
}else{
echo 'error';
}
?>