PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/www/dl-2.php

https://github.com/kjk/web-arslexis
PHP | 41 lines | 23 code | 12 blank | 6 comment | 2 complexity | ec8e80177b0c3776ff56be755c6c9264 MD5 | raw file
  1. <?php
  2. # Author: Krzysztof Kowalczyk (krzysztofk@pobox.com)
  3. #
  4. # Script called from dl.php, just redirects the download
  5. # to the file if login/pwd/name of the product are valid
  6. require( "../phpinc/settings.inc" );
  7. error_reporting(E_ALL);
  8. set_error_handler( "errorHandler" );
  9. # make sure we got login, pwd, name variables
  10. verifyGetVarExists( 'login' );
  11. verifyGetVarExists( 'pwd' );
  12. verifyGetVarExists( 'name' );
  13. $login = stripQuotes( myUrlDecode(getGetVar( 'login' ) ));
  14. $pwd = stripQuotes( myUrlDecode(getGetVar( 'pwd' ) ));
  15. $productName = getGetVar( myUrlDecode('name') );
  16. if ( !canDownloadProduct( $login, $pwd, $productName ) )
  17. doError( "Cannot download for login=$login, pwd=$pwd, product=$productName\n" );
  18. $fullPath = getProductFilePath( $productName );
  19. $fileName = getProductFileName( $productName );
  20. verifyFileExists( $fullPath );
  21. updateDlCount( $login, $pwd, $productName );
  22. // and finally return the file
  23. header("Content-Type: application/octet-stream\n");
  24. header("Content-disposition: attachment; filename=$fileName\n");
  25. header("Content-transfer-encoding: binary\n");
  26. header("Content-Length: " . filesize( $fullPath ) . "\n" );
  27. $fp = fopen( $fullPath, "rb" );
  28. fpassthru($fp);
  29. ?>