...

View Full Version : Very large logs recently on apache



zurih
01-03-2006, 08:35 AM
hello

I own a linux server, and recently I have lots of apache logs (Gigabytes).
The file creating the logs is a download script:

Code:


<?php
$err=array();
session_start();
if(!isset($_SESSION["valid"])) $err[]="<br /><br /><br />bla<br /><br /><br />";
else
{
$key=isset($_REQUEST["id"])?$_REQUEST["id"]:0;
$qry="SELECT file_name, size, dir, mime_type,no_of_dwnld, expire_time, max_dwnld FROM ".$db->tb("fileinfo")." WHERE idkey='$key' AND link_status=1";
$db->query($qry);
// ob_start();
if($db->getrownum()==0) $err[]="bla.";
else
{
$myfile=$db->getrow();
if($myfile[5]<time()) $err[]="bla.";
if($myfile[4]>=$myfile[6]) $err[]="bla".$myfile[4]."bla. bla.";
}
}
if(count($err)==0)
{
$qry="UPDATE ".$db->tb("fileinfo")." SET no_of_dwnld=no_of_dwnld+1 WHERE idkey='$key'";
$db->query($qry);
$filetype = $myfile[3];
if ($filetype == "" ) $filetype = "application/octet-stream";


//$dl_path=HostPath()."uploads/".$myfile[2]."/".$myfile[0];
$dl_path="uploads/".$myfile[2]."/".$myfile[0];
$fh = fopen( $dl_path, 'rb' );
if ($myfile[1] && PARTIAL_TRANSFER && isset($_SERVER['HTTP_RANGE']))
{
// Support for partial transfers enabled and browser requested a partial transfer
header("HTTP/1.1 206 Partial content\n");
$start = preg_replace(array("/(\040*|)bytes(\040*|)=(\040*|)/","/(\040*|)\-.*$/"),array("",""),$_SERVER['HTTP_RANGE']);
if ($myfile[1] < $start)
{
header("HTTP/1.1 411 Length Required\n");
echo "bla.";
}
$transfer_size = $myfile[1] - $start;
header("Accept-Ranges: bytes");
header("Content-Range: bytes ".$transfer_size."-".($myfile[1]-1)."/".$myfile[1]);
header("Content-Length:".$transfer_size."\n");
fseek($fh,$startat_byte);
}
else
{
header("HTTP/1.1 200 OK\n");
if ( $myfile[1] )
header("Content-Length: ".(string)($myfile[1]) );
}

//Print the http header
header("Cache-control: private\n");
header("Pragma: no-cache\n");
header("Content-Type: ".$filetype);
header("Content-Disposition: attachment; filename=".$myfile[0]);
header("Content-Transfer-Encoding: binary");
if ($CONFIG['nopassthrough'])
{
if ($CONFIG['speedlimit'] != 0)
{
$chunk = $CONFIG['speedlimit'] * 1024;
while(!feof($fh))
{
echo fread($fh, $chunk);
flush();
sleep(1);
}
}
else
{
while(!feof($fh))
{
echo fread($fh, 4096);
}
}
}
else
{
fpassthru($fh);
}
fclose($fh);
}
else
{
?>


Can anyone think why its creating any errors\logs?

thanks

Velox Letum
01-03-2006, 08:56 AM
Most of them are probably warnings...can we see a sample of the error log?

zurih
01-03-2006, 09:00 AM
right now have no access to the server but the error was something like:

wrong supplied argument, line 76, 78

the lines are:
{
while(!feof($fh))
{
echo fread($fh, 4096);
}

zurih
01-03-2006, 09:05 AM
ok now I have the full log:

[client 84.94.100.191] PHP Warning: feof(): supplied argument is not a valid stream resource
[client 84.94.100.191] PHP Warning: fread(): supplied argument is not a valid stream resource
[client 84.94.100.191] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush.

tons of those lines

Velox Letum
01-03-2006, 09:17 AM
Well, the code you gave us has an unclosed bracket at the end for one...ob_flush() isn't needed as you never started a buffer, and the not a valid stream resource would probably be a 'file not found' or something.

zurih
01-03-2006, 09:28 AM
// ob_start();
thats what you mean?
I need to delete the bracket to "ob_start();" ?

and the second thing cannot be 'file not found' error because the file is found and can be downloaded.....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum