Header / Download Problem

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

  • Header / Download Problem

    Ich hab mir ein DownloadScript gebastelt. Die Files sind in einer DB gespeichert. Um die Datei herunterzuladen übergibt man die ID an das Script (download.php?id=12)

    Soweit alles gut und funktioniert auch.

    Nun habe ich noch was eingebaut, damit man manche Files mit einem Passwort schützen kann.

    Das Script schaut ob ein Passwort eingegeben werden muss.
    Wenn ja dann zeigt er ein Passwortfeld.
    Wenn man dieses dann abschickt und das Passwort ist richtig dann öffnet sich auch das Download Fenster aber die Datei hat 0Byte.

    hier das Script:

    PHP-Code:
        $download = new dbconnect();

        
    $query "SELECT `name` , `password` , `ext` , `type` , `size` , `binary`
                  FROM `files`
                  WHERE `did` = '
    $HTTP_GET_VARS[id]'";

        
    $download->query($query);
        
    $download->fetch_array();

        
    $name $download->row['name'];
        
    $ext $download->row['ext'];
        
    $type $download->row['type'];
        
    $size $download->row['size'];
        
    $binary $download->row['binary'];


        
    //überprüfen ob der User die Rechte hat um die datei herunter zu laden
        
    $filepw $HTTP_POST_VARS['filepw'];
        if((
    $filepw != $download->row['password']) && $download->row['password'] != 'false')
        {

        echo 
    "<form action=\"$PHP_SELF?id=$HTTP_GET_VARS[id]\" method=\"POST\" target=\"_blank\">\n";
        echo 
    "<input type=\"password\" name=\"filepw\" value=\"\" size=\"\" maxlength=\"20\">\n";
        echo 
    "<input type=\"submit\" value=\"authenticate\">\n";
        echo 
    "</form>\n";
        exit;

        }


        
    //Download Fenster
        
    $query "UPDATE files
                  SET counter = counter+1
                  WHERE did = '
    $HTTP_GET_VARS[id]'";

        
    $download->query($query);

        
    header("Content-type: $type");
        
    header("Content-length: $size");
        
    header("Content-disposition: attachment; filename=$name.$ext");
        
    header("Content-transfer-encoding: binary");
        
    header("Pragma: no-cache");
        
    header("Expires: 0");


        
    //Datei Inhalt senden
        
    echo $binary;

      }
    ?> 
    Wahrscheinlich hatu dann irgendwas mit den Headern nicht hin. Nur was??
    Und wie kann ich das dann umgehen??

    Danke für eure Hilfe
    Zuletzt geändert von is_real; 09.04.2003, 14:03.
    [font=tahoma]
    Agentursoftware
    Zend Framework Resource
    FM4 Sammelalbum


    "The most important part of the work is the beginning" - Plato
    "..so dance while you still have feet and smile while you still have teeth.." - Caesars[/font]

  • #2
    nimm al die ' um false weg...
    Beantworte nie Threads mit mehr als 15 followups...
    Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25

    Kommentar


    • #3
      Danke.
      Das is nicht das Problem.

      Das 'false' steht Standardmäßig in der DB, wenn kein Passwort eingegeben werden muss.

      Screenshot:
      Angehängte Dateien
      [font=tahoma]
      Agentursoftware
      Zend Framework Resource
      FM4 Sammelalbum


      "The most important part of the work is the beginning" - Plato
      "..so dance while you still have feet and smile while you still have teeth.." - Caesars[/font]

      Kommentar


      • #4
        hi,

        ich denke auch dass es mit den Headern zusammenhängt.
        ich hatte gerade dass problem, dass ich in meinem Download-skript ein session_start() vor den Headern hatte, da gings auch nicht.
        Ich habs so gelöst, dass ich die Sessionvariablen serialisiert, urlencoded und verschlüsselt habe und an download.php angehängt habe.
        dann gings.

        Was passiert bei dir denn alles in dbconnect()?

        Kommentar


        • #5
          header!!

          ist ganz sicher wegen den Headern. Ich Depp ich.

          Wenn ich Daten per POST an das eigene Script schick. Na in welchem Teil werden sie übertragen??? Ja Richtig im Header.


          Würd mich interessieren was ihh davon haltet ein Passwort zu verschlüsseln und per get zu übertragen??
          Sicher / Unsicher?
          [font=tahoma]
          Agentursoftware
          Zend Framework Resource
          FM4 Sammelalbum


          "The most important part of the work is the beginning" - Plato
          "..so dance while you still have feet and smile while you still have teeth.." - Caesars[/font]

          Kommentar


          • #6
            naja, also n md5 reicht da nicht. da muss schon was hin, was irgendwie nur im moment gilt, und später nicht mehr.

            Kommentar


            • #7
              Cookie

              Ich könnt das Formular auf einer neuen Seite machen wenn passwort richtig Cookie setzten mit Verschlüsseltem PW dann im Script abfragen ob gesetzt und ob PW == DB_PW

              MMMHHHH.

              Ob das funktioniert!? Denke schon
              [font=tahoma]
              Agentursoftware
              Zend Framework Resource
              FM4 Sammelalbum


              "The most important part of the work is the beginning" - Plato
              "..so dance while you still have feet and smile while you still have teeth.." - Caesars[/font]

              Kommentar

              Lädt...
              X