<?php
/*=======================================================================
 *
 * statistic_data_download.php
 *
 * Autor: Marc Vollmann
 *
 =======================================================================*/


include_once ("../include/mcglobal.inc.php");
include_once ("../include/auth.inc.php");


getSecHttpVars("1",array("f_fileName","cscIdRoot","customerId","cscIdActual"));

$usrAccessArray["hq"] = "1"; $usrAccessArray["cs"] = "1";
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
authCheckEmployeeRights($emp_id, "8", "1");


if ($f_fileName != "") :

   $mimeType = "text/plain";
   $mode = "r";
   if (ENCRYPT_EXPORTDATA == "1") : 
      $mimeType = "application/octet-stream";
      $mode = "rb";
   endif;

   $gmnow = gmdate('D, d M Y H:i:s') . ' GMT';
   header("Content-type: " . $mimeType);
   header('Expires: ' . $gmnow);
   header('Content-Disposition: attachment; filename="' . $f_fileName . '"');
   header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
   header('Pragma: public');

   $fileContent = readFromFile(STATISTIC_PATH . $f_fileName, "", $mode);
   echo $fileContent;

endif;
?>
