-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspecialurls.php
More file actions
52 lines (47 loc) · 1.96 KB
/
specialurls.php
File metadata and controls
52 lines (47 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Handle special urls.
*
* @copyright Copyright (c) 2012, Tux Solbakk
* @license http://opensource.org/licenses/bsd-license.php BSD 2-Clause License
* @link http://gimlé.org/extensions/common/
* @package common
*/
namespace gimle\common;
if ((\gimle\core\page(1) !== false) && (\gimle\core\page(0) === 'css') || (\gimle\core\page(0) === 'js')) {
$file = new Cache('gimle' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . \gimle\core\page(0) . DIRECTORY_SEPARATOR . \gimle\core\page(1));
$cacheJS = false;
$cacheCSS = false;
if ((\gimle\core\page(0) === 'js') && (isset(System::$config['cache']['regenerate']['javascript'])) && (System::$config['cache']['regenerate']['javascript'] === true)) {
$cacheJS = true;
} elseif ((\gimle\core\page(0) === 'css') && (isset(System::$config['cache']['regenerate']['css'])) && (System::$config['cache']['regenerate']['css'] === true)) {
$cacheCSS = true;
}
if ($file->exists() === false) {
Canvas::_createCaches(true, true, \gimle\core\page(1));
} elseif (($cacheJS) || ($cacheCSS)) {
Canvas::_createCaches($cacheJS, $cacheCSS, \gimle\core\page(1));
}
if ($file->exists() === true) {
header_remove('Expires');
header_remove('Pragma');
header_remove('Cache-Control');
header_remove('X-Powered-By');
header_remove('Set-Cookie');
header_remove('Content-Language');
header('Accept-Ranges: bytes');
header('Server: ' . $_SERVER['SERVER_SOFTWARE']);
header('ETag: "' . md5_file($file->getFilename()) . '"');
header('Content-Length: ' . filesize($file->getFilename()));
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file->getFilename())) . ' GMT');
if (\gimle\core\page(0) === 'js') {
header('Content-Type: application/javascript; charset=' . mb_internal_encoding());
} elseif (\gimle\core\page(0) === 'css') {
header('Content-Type: text/css; charset=' . mb_internal_encoding());
}
readfile($file->getFilename());
} else {
header('HTTP/1.0 404 Not Found');
}
die();
}