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
|
|
|
/**#@-*/ |
34
|
|
|
|
35
|
|
|
// Check the requested name for validness. |
36
|
|
|
|
37
|
|
|
$name = isset($_REQUEST['name']) |
38
|
|
|
? $_REQUEST['name'] |
39
|
|
|
: NULL; |
40
|
|
|
|
41
|
|
|
mb_regex_encoding('UTF-8'); |
42
|
|
|
|
43
|
|
|
if (!mb_eregi('^([_0-9a-z\.\-])+$', $name) && |
44
|
|
|
!mb_eregi('^plugins/([_0-9a-z\.\-])+$', $name) && |
45
|
|
|
!mb_eregi('^jqplot/([_0-9a-z\.\-])+$', $name)) |
46
|
|
|
{ |
47
|
|
|
exit; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
// Check the script file for existance. |
51
|
|
|
|
52
|
|
|
$file = LOCALROOT . '/scripts/' . $name; |
53
|
|
|
|
54
|
|
|
if (!is_file($file)) |
55
|
|
|
{ |
56
|
|
|
exit; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
// Output requested script file. |
60
|
|
|
|
61
|
|
|
$output = file_get_contents($file); |
62
|
|
|
|
63
|
|
View Code Duplication |
if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) |
64
|
|
|
{ |
65
|
|
|
// Check whether a client's browser support gzip-compression. |
66
|
|
|
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) |
67
|
|
|
{ |
68
|
|
|
$output = gzencode($output); |
69
|
|
|
header('Content-Encoding: gzip'); |
70
|
|
|
} |
71
|
|
|
// Check whether a client's browser support deflate-compression. |
72
|
|
|
elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== FALSE) |
73
|
|
|
{ |
74
|
|
|
$output = gzdeflate($output); |
75
|
|
|
header('Content-Encoding: deflate'); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
header('Content-Type: text/javascript'); |
80
|
|
|
header('Content-Length: ' . strlen($output)); |
81
|
|
|
header(sprintf('Content-Range: bytes 0-%d/%d', strlen($output) - 1, strlen($output))); |
82
|
|
|
header('Pragma: cache'); |
83
|
|
|
header('Cache-Control: public'); |
84
|
|
|
header('Last-Modified: ' . date(DATE_RFC2822, filectime($file))); |
85
|
|
|
header('Expires: ' . date(DATE_RFC2822, time() + 86400)); |
86
|
|
|
header('ETag: "' . md5(sprintf('%s/%s', VERSION, $file)) . '"'); |
87
|
|
|
|
88
|
|
|
echo($output); |
89
|
|
|
|
90
|
|
|
?> |
|
|
|
|
91
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.