Advertisement
rakhun

link_download_final

Mar 11th, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.09 KB | None | 0 0
  1. <?php
  2. $file="9276dac4e6735f8b50b6857414292b31";//ini diambil pake $_GET
  3. $_SESSION['authenticated']="download_pause";//ini ada di page sebelumnya
  4.  
  5. $query="SELECT * FROM com_download_dt";
  6. $query = mysql_query ($query) or die (mysql_error());
  7. while ($dataFile = mysql_fetch_array($query))
  8. {
  9.     if($file==md5($dataFile['file'])){
  10.                         if (!isset($_SESSION['authenticated']))
  11.                         {
  12. echo'                       <h1 class="page-header">Restricted</h1>
  13.                             <div class="progress">
  14.                               <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 0%;-webkit-transition: none !important;transition: none !important;"></div>
  15.                               <meta http-equiv="refresh" content="3; url=//localhost/website/folder/" />
  16.                             </div>';
  17.                         }
  18.                         elseif ($_SESSION['authenticated']=="download_pause")
  19.                         {
  20. echo'                       <h1 class="page-header">Downloading</h1>
  21.                             <div class="progress">
  22.                               <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 0%;-webkit-transition: none !important;transition: none !important;"></div>
  23.                               <meta http-equiv="refresh" content="3; url=//localhost/website/download/'.md5($dataFile['file']).'" />
  24.                             </div>';
  25.                         $_SESSION['authenticated']="download_start";
  26.                         }
  27.                         elseif ($_SESSION['authenticated']=="download_start")
  28.                         {
  29.                         session_destroy();
  30.                         $_SESSION['authenticated']="";
  31.                         $fileN = $_SERVER['DOCUMENT_ROOT'].'/hipki/uploads/files/'.$dataFile['file'];
  32.  
  33.                         header('Content-Description: File Transfer');
  34.                         header('Content-Type: application/octet-stream');
  35.                         header('Content-Disposition: attachment; filename=' . basename($fileN));
  36.                         header('Content-Transfer-Encoding: binary');
  37.                         header('Expires: 0');
  38.                         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  39.                         header('Pragma: public');
  40.                         header('Content-Length: ' . filesize($fileN));
  41.                         ob_clean();
  42.                         flush();
  43.                         readfile($fileN);
  44.                         exit;
  45.                         }
  46.     }
  47. }
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement