/** * Force the download of a file by the user's browser by preventing any * caching. Contains a workaround for Internet Explorer. * * @link http://support.microsoft.com/kb/316431 * @link http://support.microsoft.com/kb/812935 * * @uses download::dialog() * @uses download::send() * * @param string a file path or file name * @param mixed data to be sent if the filename does not exist * @param string suggested filename to display in the download * @return void */ public static function force($filename = NULL, $data = NULL, $nicename = NULL) { download::dialog(empty($nicename) ? $filename : $nicename); // Prevent caching header('Expires: Thu, 01 Jan 1970 00:00:00 GMT'); if (request::user_agent('browser') === 'Internet Explorer' and request::user_agent('version') <= '6.0') { // HTTP 1.0 header('Pragma:'); // HTTP 1.1 with IE extensions header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); } else { // HTTP 1.0 header('Pragma: no-cache'); // HTTP 1.1 header('Cache-Control: no-cache, max-age=0'); } if (is_file($filename)) { download::send($filename); } else { download::send($filename, $data); } }