Apache Downloads überwachen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Apache Downloads überwachen

    moinmoin

    ein Kumpel hat mir folgendes Script geschrieben.
    Damit werden verlinkte Downloads mit mehr als 50MB erst zu einer Vorschaltseite geleitet.

    Nur frisst das Script den RAM auf... nach ein paar Stunden knapp 600MB...

    Hat jemand eine Idee wie man das Problem lösen könnte?

    Wenn man die Zahl an dieser Stelle erhöht wird der RAM-fraß zwar besser, aber die Downloads laufen nicht komplett durch > print fread($fp, 16384); // guckst du hier ... ob sich dann was ändert wegen RAM <

    PHP-Code:
    <?php
    set_time_limit
    (0);

    function 
    _DL($f$s)
    {
      
    $e explode('/'$f);
      
    $c count($e) - 1;
      
    $x strtolower(substr(strrchr($f'.'), 1));

      switch(
    $x)
      {
        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':
        case 
    'jpg':
          
    $ctype 'image/jpg';
        break;
        case 
    'mp3':
          
    $ctype 'audio/mpeg';
        break;
        case 
    'wav':
          
    $ctype 'audio/x-wav';
        break;

        case 
    'mpeg':
        case 
    'mpg':
        case 
    'mpe':
          
    $ctype 'video/mpeg';
        break;

        case 
    'mov':
          
    $ctype 'video/quicktime';
        break;

        case 
    'avi':
          
    $ctype 'video/x-msvideo';
        break;

        case 
    'css':
          
    $ctype 'text/css';
        break;

        case 
    'txt':
          
    $ctype 'text/plain';
        break;

        case 
    'php':
        case 
    'htm':
        case 
    'html':
          die(
    "<b>illegal request</b>");
        break;

        default:
          
    $ctype 'application/force-download';
      }

      if(!
    $fp = @fopen($f'r'))
        die(
    '<h1>Illegal Request!</h1>Please send an email to <b>error@openFTP.de</b> with this failed link...');

      
    header('Content-Type: '.$ctype);
      
    header('Content-Length: '.$s);

      if(
    $x == 'application/force-download')
        
    header('Content-Disposition: attachment; filename="'.$e[$c].'"');

      while(!
    feof($fp))
        print 
    fread($fp16384); // guckst du hier ... ob sich dann was ändert wegen RAM

      
    fclose($fp);
    }

    function 
    dl_hash($s)
    {
      
    define('MAGIC_CODE'1);

      
    $ip $_SERVER['REMOTE_ADDR'];
      
    $e explode('.'$ip);

      return 
    md5($e[0] + $e[1] - $e[2] - $e[3] * MAGIC_CODE $s);
    }


    //print htmlentities($_SERVER['QUERY_STRING']);

    $q urlencode($_SERVER['QUERY_STRING']);
    //print $_SERVER['QUERY_STRING'].'<br />'.$q;

    $q str_replace('%C3%B6''ö'$q);
    $q str_replace('%C3%96''Ö'$q);
    $q str_replace('%C3%BC''ü'$q);
    $q str_replace('%C3%9C''Ü'$q);
    $q str_replace('%C3%A4''ä'$q);
    $q str_replace('%C3%84''Ä'$q);
    $q str_replace('%C3%9F''ß'$q);
    $q str_replace('%C3%A1''á'$q);
    $q str_replace('%C3%81''Á'$q);
    $q str_replace('%C3%A0''à'$q);
    $q str_replace('%C3%80''À'$q);
    $q str_replace('%C3%A9''é'$q);
    $q str_replace('%C3%89''É'$q);
    $q str_replace('%C3%A8''è'$q);
    $q str_replace('%C3%88''È'$q);
    $q str_replace('%26f2%3D''#'$q);

    $q urldecode($q);

    preg_match('/f=(.*?)(&i=)/'$q$match);
    $f 'openFTP/STUFF/'.$match[1];

    //print $f;

    $i strip_tags($_REQUEST['i']);
    $s filesize($f);

    if(
    $s >= (50 1024 1024) && $i != dl_hash($s))
    {
      print 
    '
    <center>
    WERBUNG UND TEXT
    </center>'
    ;

    }
    else
    {
      
    _DL($f$s);
    }
    ?>
    danke für eure hilfe

    cya
    trojan
    Zuletzt geändert von trojan; 12.04.2006, 10:09.

  • #2
    Regeln Lesen!!!

    Kommentar


    • #3
      farbig und gekürzt ok so?

      Kommentar


      • #4
        Schau dir mal folgende UserNote im Manual an. Hatte bei grösseren Downloads dasselbe Problem und konnte es mit dieser Fkt lösen.

        Gruss

        tobi
        Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

        [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
        Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

        Kommentar


        • #5
          moinmoin

          leider kommen wir damit nicht weiter

          ich hab 0 ahnung von php und der kollege kann damit auch (noch ) nix anfangen...

          hat wer evtl ne idee wie man da was einbauen könnte damits flüssiger rennt?

          thx & cya
          trojan

          Kommentar


          • #6
            dann ist das hier das falsche forum. *move* nach Projekthilfe

            Kommentar


            • #7
              gibt es keine andere möglichkeit bei files über xx MB Größe eine Vorschaltseite anzeigen zu lassen?

              Kommentar

              Lädt...
              X