- 12, May 2024
- #1
Этот скрипт ограничивает загрузку, но проблема при загрузке не показывает размер файла. Кто-нибудь, пожалуйста, помогите мне.
<?php
// Set the maximum number of downloads (actually, the number of page loads)
$maxdownloads = "5";
// Set the key's viable duration in seconds (86400 seconds = 24 hours)
$maxtime = "3600";
require ('dbconnect.php');
if(get_magic_quotes_gpc()) {
$id = stripslashes($_GET['id']);
}else{
$id = $_GET['id'];
}
// Get the key, timestamp, and number of downloads from the database
$query = sprintf("SELECT * FROM downloadkey WHERE uniqueid= '%s'",
mysql_real_escape_string($id, $link));
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
if (!$row) {
echo "The download key you are using is invalid.";
}else{
$timecheck = date('U') - $row['timestamp'];
if ($timecheck >= $maxtime) {
echo "This key has expired (exceeded time allotted).<br />";
}else{
$downloads = $row['downloads'];
$downloads += 1;
if ($downloads > $maxdownloads) {
echo "This key has expired (exceeded allowed downloads).<br />";
}else{
$sql = sprintf("UPDATE downloadkey SET downloads = '".$downloads."' WHERE uniqueid= '%s'",
mysql_real_escape_string($id, $link));
$incrementdownloads = mysql_query($sql) or die(mysql_error());
// Debug echo "Key validated.";
// Force the browser to start the download automatically
/*
Variables:
$file = real name of actual download file on the server
$filename = new name of local download file - this is what the visitor's file will actually be called when he/she saves it
*/
ob_start();
$mm_type="application/octet-stream";
$file = "[URL='https://lumtu.com/yti/acWWcaC9odHRwOi8vbXlzaXRlLmNvbS9rZ2JraJ2Z']http://mysite.com/kgbkigh/".$_GET['ids'].".mp4[/URL]";
$filename = "mysite-".$_GET['ids']."(mysite.com).mp4";
header("Cache-Control: public, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($file)) );
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary\n");
ob_end_clean();
readfile($file);
}
}
}
?>
PHP: