<?php include('include/functions.php');  
   include ('include/login.php');
   if ($loggedIn) {
       $file = filter_input(INPUT_GET, 'file'); //$HTTP_GET_VARS['file'];
       $downloadfile = filter_input(INPUT_GET, 'download_file'); //$HTTP_GET_VARS['downloadfile'];
       if (!$downloadfile) $downloadfile = $file;
       $extension = substr($downloadfile,-4,5);
       if ($extension == '.xls' || $extension == '.csv') { 
           $contenttype = 'application/vnd.ms-excel; charset=ISO-8859-1';
       }

       if ($extension == '.pdf') {
           //$contenttype = 'application/x-pdf; charset=UTF-8';
           $contenttype = 'applications/pdf';
       }
       header('Content-Type: '. $contenttype);
       header('Content-Disposition: attachment; filename=' . basename($downloadfile));
       if (isset($_SERVER["HTTPS"])) {
           header("Pragma: cache"); 
       }
       readfile($exportpath . '/' .$downloadfile);
   } else {
?>
<html>
  <body>
  <?php print_r($loggedIn); ?>
  You are not logged in. Try Firefox.
  </body>
</html>
<? } 
