一个不错表单处理

MK
@Ta 2014-01-18 2870点击
<?php 

if ($_POST['download'] and $_POST['was']) {

       if($_SESSION['login']) {  // Session gesetzt?

       

           $timestamp = time();
           $dateipdf = 'download/'.$_POST['dateinamenpdf'];
           $dateipptx = 'download/'.$_POST['dateinamenpptx'];
           $dateidocx = 'download/'.$_POST['dateinamendocx'];
           $dateizip = 'download/'.$_POST['dateinamenzip'];
           $thema = $_POST['th'];



           if (! isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {

               $ip = $_SERVER['REMOTE_ADDR'];
           }

           else 

           {

               $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];

           }


          $datei = $thema;

          if ($_POST['was'] == "pdf") {

               if(!file_exists($dateipdf)) {
                   
                   echo "<p>Download-Datei nicht gefunden - <b>Kontaktieren Sie einen Administrator</b></p>";
                   die;

               } 
            

            $Name = "TEST.pdf";
            $file = fopen($dateipdf,"r");
            header("Content-Type: application/pdf");
            header("Content-Disposition: attachment; filename=\"".$Name."\"");
            header("Content-Length: ".filesize(".".$datei)); 
            fpassthru($file); 
            fclose($file);  
              


          }

           if ($_POST['was'] == "zip") {

                   
               $trageein = mysql_query("INSERT INTO downloads(was,ip,time) VALUES ('$thema', '$ip', '$timestamp')");            
               $counter = mysql_query("UPDATE tehmen SET downloads = '$vl' WHERE name = '$thema'");     
               header('Content-Description: File Transfer');
                  header('Content-Type: application/zip');
                  header('Content-Disposition: attachment; filename='.basename("$thema.pdf"));
                  header('Content-Transfer-Encoding: binary');
                  header('Expires: 0');
                  header('Cache-Control: must-revalidate');
                  header('Pragma: public ');
                  header('Content-Length: ' . filesize($dateizip));
                  ob_clean();
                  flush();
                  readfile($dateizip);
                  exit;


           }

           if ($_POST['was'] == "pptx") {

               $trageein = mysql_query("INSERT INTO downloads(was,ip,time) VALUES ('$thema', '$ip', '$timestamp')");        
               $counter = mysql_query("UPDATE tehmen SET downloads = '$vl' WHERE name = '$thema'");    
               header('Content-Description: File Transfer');
                  header('Content-Type: application/octet-stream');
                  header('Content-Disposition: attachment; filename='.basename("$thema.pdf"));
                  header('Content-Transfer-Encoding: binary');
                  header('Expires: 0');
                  header('Cache-Control: must-revalidate');
                  header('Pragma: public');
                  header('Content-Length: ' . filesize($dateipptx));
                  ob_clean();
                  flush();
                  readfile($dateipptx);
                  exit;

           }

           if ($_POST['was'] == "docx") {

               $trageein = mysql_query("INSERT INTO downloads(was,ip,time) VALUES ('$thema', '$ip', '$timestamp')");        
               $counter = mysql_query("UPDATE tehmen SET downloads = '$vl' WHERE name = '$thema'");    
               header('Content-Description: File Transfer');
                  header('Content-Type: application/octet-stream');
                  header('Content-Disposition: attachment; filename='.basename("$thema.pdf"));
                  header('Content-Transfer-Encoding: binary');
                  header('Expires: 0');
                  header('Cache-Control: must-revalidate');
                  header('Pragma: public ');
                  header('Content-Length: ' . filesize($dateidocx));
                  ob_clean();
                  flush();
                  readfile($dateidocx);
                  exit;
                       



          }
        

   }  else {
      
            echo "Huhu";
            die;
            session_start();
            echo '<link rel="stylesheet" type="text/css" href="../src/style.css">';
            include("../user/login.php");
            exit;
            
          }
}
?>
回复列表(3|隐藏机器人聊天)
添加新回复
回复需要登录