1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
4
|
|
|
// |
5
|
|
|
// eTraxis - Records tracking web-based system |
6
|
|
|
// Copyright (C) 2010-2011 Artem Rodygin |
7
|
|
|
// |
8
|
|
|
// This program is free software: you can redistribute it and/or modify |
9
|
|
|
// it under the terms of the GNU General Public License as published by |
10
|
|
|
// the Free Software Foundation, either version 3 of the License, or |
11
|
|
|
// (at your option) any later version. |
12
|
|
|
// |
13
|
|
|
// This program is distributed in the hope that it will be useful, |
14
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
// GNU General Public License for more details. |
17
|
|
|
// |
18
|
|
|
// You should have received a copy of the GNU General Public License |
19
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
// |
21
|
|
|
//------------------------------------------------------------------------------ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @package eTraxis |
25
|
|
|
* @ignore |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
/**#@+ |
29
|
|
|
* Dependency. |
30
|
|
|
*/ |
31
|
|
|
require_once('../config.php'); |
32
|
|
|
require_once('../engine/xml.php'); |
33
|
|
|
require_once('../engine/themes.php'); |
34
|
|
|
/**#@-*/ |
35
|
|
|
|
36
|
|
|
@session_start(); |
37
|
|
|
|
38
|
|
|
$name = isset($_REQUEST['name']) |
39
|
|
|
? $_REQUEST['name'] |
40
|
|
|
: NULL; |
41
|
|
|
|
42
|
|
|
// Remove theme name from the specified path. |
43
|
|
|
|
44
|
|
|
list($theme, $name) = explode('/', $name); |
45
|
|
|
|
46
|
|
|
// Check the requested name for validness. |
47
|
|
|
|
48
|
|
|
mb_regex_encoding('UTF-8'); |
49
|
|
|
|
50
|
|
|
if (!mb_eregi('^([_0-9a-z\.\-])+$', $name)) |
51
|
|
|
{ |
52
|
|
|
exit; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
// Check the script file for existance. |
56
|
|
|
|
57
|
|
|
$file = get_theme_css_file($name); |
58
|
|
|
|
59
|
|
|
// Output requested script file. |
60
|
|
|
|
61
|
|
|
$output = file_get_contents($file); |
62
|
|
|
|
63
|
|
|
if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) |
64
|
|
|
{ |
65
|
|
|
// Check whether required extensions is available and PHP compression is turned off. |
66
|
|
|
if (extension_loaded('zlib') && !ini_get('zlib.output_compression') && !ini_get('output_handler')) |
67
|
|
|
{ |
68
|
|
|
// Check whether a client's browser support gzip-compression. |
69
|
|
View Code Duplication |
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) |
|
|
|
|
70
|
|
|
{ |
71
|
|
|
$output = gzencode($output); |
72
|
|
|
header('Content-Encoding: gzip'); |
73
|
|
|
} |
74
|
|
|
// Check whether a client's browser support deflate-compression. |
75
|
|
|
elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== FALSE) |
76
|
|
|
{ |
77
|
|
|
$output = gzdeflate($output); |
78
|
|
|
header('Content-Encoding: deflate'); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
header('Content-Type: text/css'); |
84
|
|
|
header('Content-Length: ' . strlen($output)); |
85
|
|
|
header(sprintf('Content-Range: bytes 0-%d/%d', strlen($output) - 1, strlen($output))); |
86
|
|
|
header('Pragma: cache'); |
87
|
|
|
header('Cache-Control: public'); |
88
|
|
|
header('Last-Modified: ' . date(DATE_RFC2822, filectime($file))); |
89
|
|
|
header('Expires: ' . date(DATE_RFC2822, time() + 86400)); |
90
|
|
|
header('ETag: "' . md5(sprintf('%s/%s', VERSION, $file)) . '"'); |
91
|
|
|
|
92
|
|
|
echo($output); |
93
|
|
|
|
94
|
|
|
?> |
95
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.