| | 85 | elseif (isset($_REQUEST['file']) && isset($_REQUEST['type'])) { |
| | 86 | $filename = $_REQUEST['file']; |
| | 87 | $type = $_REQUEST['type']; |
| | 88 | if (User :: getCurrentUser()->DEPRECATEDisSuperAdmin()) { |
| | 89 | // The file is valid for one hour, because it contains sensitive data and we don't want to open a security breach |
| | 90 | if (file_exists($filename) && (filectime($filename) > (time() - 60*60)) ) { |
| | 91 | header('Content-Type: application/octet-stream'); |
| | 92 | header('Content-Disposition: inline; filename="anonymised_'.$type.'.sql"'); |
| | 93 | header("Content-Transfer-Encoding: binary"); |
| | 94 | header("Pragma: no-cache"); |
| | 95 | header("Expires: 0"); |
| | 96 | $fp=fopen($filename,"r"); |
| | 97 | print fread($fp,filesize($filename)); |
| | 98 | fclose($fp); |
| | 99 | exit(); |
| | 100 | } else { |
| | 101 | if (!file_exists($filename)) { |
| | 102 | throw new Exception(sprintf(_("File %s does not exist"), $filename)); |
| | 103 | } |
| | 104 | if (filectime($filename) > (time() - 60*60)) { |
| | 105 | throw new Exception(sprintf(_("The statistics file for anonymised_%s.sql has expired."), $type)); |
| | 106 | } |
| | 107 | } |
| | 108 | } else { |
| | 109 | throw new Exception(_("These reports are only available to server administrators.")); |
| | 110 | } |
| | 111 | } |