Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Very large logs recently on apache

    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 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($fh4096);
    }
    }

    else 
    {
    fpassthru($fh);
    }
    fclose($fh);
    }
    else
    {
    ?>
    Can anyone think why its creating any errors\logs?

    thanks

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Most of them are probably warnings...can we see a sample of the error log?
    "$question = ( to() ) ? be() : ~be();"

  • #3
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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);
    }

  • #4
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    "$question = ( to() ) ? be() : ~be();"

  • #6
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    // 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.....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •