- Joined
- Nov 28, 2004
- Messages
- 2,236
- Reaction score
- 0
$theFile = 'http://www.porno.com/downloads/alotpr0n.zip';
header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header ("Content-Type: application/octet-stream");
header ("Content-Length: " . filesize($theFile));
header ("Content-Disposition: attachment;");
readfile($theFile);
$fp = fopen($file,"r");
$buffer = fread($fp,filesize($file));
header("Content-type: application/x-unknown-content-type-text");
header("Content-Lenght: ".filesize($file));
header("Content-Disposition: inline; filename=\"" . basename($file) . "\"");
echo $buffer;
Warning: filesize(): Stat failed for http://www.fknevezis.lt/m.png (errno=2 - No such file or directory) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at C:\web\http_root\www\_learning\file_manipulation\12.php:7) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 9
Warning: filesize(): Stat failed for http://www.fknevezis.lt/m.png (errno=2 - No such file or directory) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at C:\web\http_root\www\_learning\file_manipulation\12.php:7) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at C:\web\http_root\www\_learning\file_manipulation\12.php:7) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 11
Warning: filesize(): Stat failed forYou must be registered to see links(errno=2 - No such file or directory) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at C:\web\http_root\www\_learning\file_manipulation\12.php:7) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 9
Warning: filesize(): Stat failed forYou must be registered to see links(errno=2 - No such file or directory) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at C:\web\http_root\www\_learning\file_manipulation\12.php:7) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at C:\web\http_root\www\_learning\file_manipulation\12.php:7) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 11
<?php
header("Location: foo.bar");
?>
<?php
include("index.php");
header("Location: foo.bar");
?>
<?php
$file = "http://www.fknevezis.lt/m.png";
$fp = fopen($file,"r");
$buffer = fread($fp,filesize($file));
header("Content-type: application/x-unknown-content-type-text");
header("Content-Lenght: ".filesize($file));
header("Content-Disposition: inline; filename=\"" . basename($file) . "\"");
echo $buffer;
?>
Warning: filesize(): Stat failed for http://www.fknevezis.lt/m.png (errno=2 - No such file or directory) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at C:\web\http_root\www\_learning\file_manipulation\12.php:7) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 9
Warning: filesize(): Stat failed for http://www.fknevezis.lt/m.png (errno=2 - No such file or directory) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at C:\web\http_root\www\_learning\file_manipulation\12.php:7) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at C:\web\http_root\www\_learning\file_manipulation\12.php:7) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 11
Warning: filesize(): Stat failed for http://www.fknevezis.lt/m.png (errno=2 - No such file or directory) in C:\web\http_root\www\_learning\file_manipulation\12.php on line 7
<?php
function filesize_url($url){
return ($data = @file_get_contents($url)) ? strlen($data) : false;
**
?>
<?php
//$file = "http://www.fknevezis.lt/m.png";
$file = "http://mamboforge.net/frs/download.php/7835/MamboV4.5.3h.tar.gz";
$fp = fopen($file,"r");
$filesize = filesize_url($file);
$buffer = fread($fp,$filesize);
header("Content-type: application/x-unknown-content-type-text");
header("Content-Lenght: ".$filesize);
header("Content-Disposition: inline; filename=\"" . basename($file) . "\"");
echo $buffer;
function filesize_url($url)
{
return ($data = @file_get_contents($url)) ? strlen($data) : false;
**
?>
<?php
///////////////////////////
//DATA
///////////////////////////
//$filename = "http://download.microsoft.com/download/f/0/3/f03c202d-1ce4-4267-9393-a8a4b400a982/Vs6sp6B.exe";
$filename = "http://mamboforge.net/frs/download.php/7835/MamboV4.5.3h.tar.gz";
$filesize = filesize_url($file);
// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
//filetype manipulation
$file_extension = file_type($filename);
$ctype = ctype($file_extension);
//output header
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$filesize);
readfile("$filename");
exit();
///////////////////////////
//FUNCTIONS
///////////////////////////
//function for finding out the file size
function filesize_url($url)
{
$filesize = ($data = @file_get_contents($url)) ? strlen($data) : false;
return $filesize;
**
//function for file type determination
function file_type($filename)
{
$file_extension = strtolower(substr(strrchr($filename,"."),1));
return $file_extension;
**
//function for the file ctype determination
function ctype($file_extension)
{
switch( $file_extension )
{
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg": $ctype="image/jpg"; break;
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
**
return $ctype;
**
?>
melo_yello said:use it to get the filesize... and enjoy.PHP:<?php function filesize_url($url){ return ($data = @file_get_contents($url)) ? strlen($data) : false; ** ?>
In other words, it can get remote filesize only because it loads the file into a string and then checks the string for its length.file_get_contents -- Reads entire file into a string
found a function for filesizejohn_d said:actually i dont see the reason for this.. not unless ur trying to make a proxy downloader from rapidshare that disables timelimit, bandwidth limit, etc etc.
function remote_file_size($url)
{
$head = "";
$url_p = parse_url($url);
$host = $url_p["host"];
$path = $url_p["path"];
$fp = fsockopen($host, 80, $errno, $errstr, 20);
if(!$fp)
{
return false;
**
else
{
fputs($fp, "HEAD ".$url." HTTP/1.1\r\n");
fputs($fp, "HOST: dummy\r\n");
fputs($fp, "Connection: close\r\n\r\n");
$headers = "";
while (!feof($fp))
{
$headers .= fgets ($fp, 128);
**
**
fclose ($fp);
$return = false;
$arr_headers = explode("\n", $headers);
foreach($arr_headers as $header)
{
$s = "Content-Length: ";
if(substr(strtolower ($header), 0, strlen($s)) == strtolower($s))
{
$return = substr($header, strlen($s));
break;
**
**
return $return;
**