/** * set session cookie params for path, domain, etc. */ protected static function setCookieParams() { global $ilSetting; include_once 'Services/Authentication/classes/class.ilAuthFactory.php'; if (ilAuthFactory::getContext() == ilAuthFactory::CONTEXT_HTTP) { $cookie_path = '/'; } elseif ($GLOBALS['COOKIE_PATH']) { // use a predefined cookie path from WebAccessChecker $cookie_path = $GLOBALS['COOKIE_PATH']; } else { $cookie_path = dirname($_SERVER['PHP_SELF']); } /* if ilias is called directly within the docroot $cookie_path is set to '/' expecting on servers running under windows.. here it is set to '\'. in both cases a further '/' won't be appended due to the following regex */ $cookie_path .= !preg_match("/[\\/|\\\\]\$/", $cookie_path) ? "/" : ""; if ($cookie_path == "\\") { $cookie_path = '/'; } include_once './Services/Http/classes/class.ilHTTPS.php'; $cookie_secure = !$ilSetting->get('https', 0) && ilHTTPS::getInstance()->isDetected(); define('IL_COOKIE_EXPIRE', 0); define('IL_COOKIE_PATH', $cookie_path); define('IL_COOKIE_DOMAIN', ''); define('IL_COOKIE_SECURE', $cookie_secure); // Default Value // session_set_cookie_params() supports 5th parameter // only for php version 5.2.0 and above if (version_compare(PHP_VERSION, '5.2.0', '>=')) { // PHP version >= 5.2.0 define('IL_COOKIE_HTTPONLY', true); // Default Value session_set_cookie_params(IL_COOKIE_EXPIRE, IL_COOKIE_PATH, IL_COOKIE_DOMAIN, IL_COOKIE_SECURE, IL_COOKIE_HTTPONLY); } else { // PHP version < 5.2.0 session_set_cookie_params(IL_COOKIE_EXPIRE, IL_COOKIE_PATH, IL_COOKIE_DOMAIN, IL_COOKIE_SECURE); } }
/** * deliver file for download via browser. * @param $mime Mime of the file * @param $isInline Set this to true, if the file shall be shown in browser * @static * */ public static function deliverFile($a_file, $a_filename, $a_mime = '', $isInline = false, $removeAfterDelivery = false, $a_exit_after = true) { // should we fail silently? if (!file_exists($a_file)) { return false; } if ($isInline) { $disposition = "inline"; // "inline" to view file in browser } else { $disposition = "attachment"; // "attachment" to download to hard disk //$a_mime = "application/octet-stream"; // override mime type to ensure that no browser tries to show the file anyway. } // END WebDAV: Show file in browser or provide it as attachment if (strlen($a_mime)) { $mime = $a_mime; } else { $mime = "application/octet-stream"; // or whatever the mime type is } // BEGIN WebDAV: Removed broken HTTPS code. // END WebDAV: Removed broken HTTPS code. if ($disposition == "attachment") { header("Cache-control: private"); } else { header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); } $ascii_filename = ilUtil::getASCIIFilename($a_filename); header("Content-Type: {$mime}"); header("Content-Disposition:{$disposition}; filename=\"" . $ascii_filename . "\""); header("Content-Description: " . $ascii_filename); // #7271: if notice gets thrown download will fail in IE $filesize = @filesize($a_file); if ($filesize) { header("Content-Length: " . (string) $filesize); } include_once './Services/Http/classes/class.ilHTTPS.php'; #if($_SERVER['HTTPS']) if (ilHTTPS::getInstance()->isDetected()) { header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } header("Connection: close"); ilUtil::readFile($a_file); if ($removeAfterDelivery) { unlink($a_file); } if ($a_exit_after) { exit; } }