forked from ArturSierzant/OMPD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache.php
79 lines (59 loc) · 3.32 KB
/
cache.php
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
// +------------------------------------------------------------------------+
// | netjukebox, Copyright © 2001-2012 Willem Bartels |
// | |
// | http://www.netjukebox.nl |
// | http://forum.netjukebox.nl |
// | |
// | This program is free software: you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation, either version 3 of the License, or |
// | (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program. If not, see <http://www.gnu.org/licenses/>. |
// +------------------------------------------------------------------------+
// +------------------------------------------------------------------------+
// | cache.php |
// +------------------------------------------------------------------------+
require_once('include/initialize.inc.php');
require_once('include/stream.inc.php');
$action = get('action');
if ($action == 'css') css();
elseif ($action == 'javascript') javascript();
exit();
// +------------------------------------------------------------------------+
// | css |
// +------------------------------------------------------------------------+
function css() {
global $cfg;
$skin = get('skin');
if (validateSkin($skin) == false)
exit('/* cache css error */');
$content = @file_get_contents('skin/' . $skin . '/styles.css') or exit('/* cache css error */');
$content = str_replace('img/', 'skin/' . rawurlencode($skin) . '/img/', $content);
$content = str_replace('flag/', 'skin/' . rawurlencode($skin) . '/flag/', $content);
header('Cache-Control: max-age=31536000');
streamData($content, 'text/css', false, false, '"never_expire"');
}
// +------------------------------------------------------------------------+
// | javascript |
// +------------------------------------------------------------------------+
function javascript() {
global $cfg;
$source = array('javascript-src/initialize.js',
'javascript-src/overlib.js',
'javascript-src/overlib_cssstyle.js',
'javascript-src/sha1.js');
$content = '';
foreach ($source as $file)
$content .= @file_get_contents($file) or exit('/* cache javascript error */');
header('Cache-Control: max-age=31536000');
streamData($content, 'application/javascript', false, false, '"never_expire"');
}
?>