-
Notifications
You must be signed in to change notification settings - Fork 0
/
dl.php~
76 lines (69 loc) · 2.03 KB
/
dl.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
<?php
include 'database.inc.php';
include 'login_status.inc.php';
include 'vars.inc.php';
if ($auth) {
$fileid = $_GET['plik']; // file to be send to the client
$speed = 50; // 8,5 kb/s download rate limit
$query = "SELECT * FROM files WHERE id='".$fileid."'";
$result = mysql_query($query);
$num=mysql_numrows($result);
if ($num==0) {
die("File not found.");
}
$filehash = mysql_result($result,0,"hash");
$filename = mysql_result($result,0,"name");
$filedowns = mysql_result($result,0,"downs");
$query = "SELECT * FROM clients WHERE ip='".$down_ip_addr."'";
$result = mysql_query($query);
$num=mysql_numrows($result);
if ($num>0) {
if ($zalogowany==false) {
$lasttime = mysql_result($result,0,"time");
$diff = time() - $lasttime;
if ($diff<10) {
die("WAIT!".time());
}}else{
$query = "UPDATE clients SET time='".time()."', fid='$fileid' WHERE ip='$down_ip_addr'";
mysql_query($query);
}}else{
$query = "INSERT INTO clients VALUES ('".$down_ip_addr."','".time()."','".$fileid."')";
mysql_query($query);}
$filedowns++;
$query = "UPDATE files SET downs='".$filedowns."', lastdown='".time()."' WHERE id='".$fileid."'";
mysql_query($query);
$file = $storagepath.$filehash;
If ($zalogowany==false) {
mysql_close();}
if(file_exists($file) && is_file($file)) {
header("Cache-control: private");
header("Content-Type: application/octet-stream");
header("Content-Length: ".filesize($file));
header("Content-Disposition: filename=$filename");
flush();
$fd = fopen($file, "r");
if ($zalogowany==true & $bw>0) {
while(!feof($fd)) {
echo fread($fd, round(1024*1024));
flush();
$bw--;
$ppoints++;
$query = "UPDATE users SET bandwidth='".$bw."', premiumpoints='".$ppoints."' WHERE uid='$uid'";
mysql_query($query);
sleep(1);
}
//if ($bw<0) {
//$bw=0;
//}
//$query = "UPDATE users SET bandwidth='".$bw."', premiumpoints='".$ppoints."' WHERE uid='$uid'";
//mysql_query($query);
mysql_close();
}else{
while(!feof($fd)) {
echo fread($fd, round($speed*1024));
flush();
sleep(1);
}}
fclose ($fd);
}}else{echo "NO AUTH ";}
?>