This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | //------------------------------------------------------------------------------ |
||
4 | // |
||
5 | // eTraxis - Records tracking web-based system |
||
6 | // Copyright (C) 2004-2015 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 | * XML |
||
25 | * |
||
26 | * This module is responsible for XML/HTML generation of eTraxis pages. |
||
27 | * |
||
28 | * @package Engine |
||
29 | * @subpackage XML |
||
30 | */ |
||
31 | |||
32 | /**#@+ |
||
33 | * Dependency. |
||
34 | */ |
||
35 | require_once('../engine/locale.php'); |
||
36 | require_once('../engine/debug.php'); |
||
37 | require_once('../engine/utility.php'); |
||
38 | require_once('../engine/themes.php'); |
||
39 | require_once('../engine/sessions.php'); |
||
40 | require_once('../dbo/reminders.php'); |
||
41 | /**#@-*/ |
||
42 | |||
43 | //------------------------------------------------------------------------------ |
||
44 | // Definitions. |
||
45 | //------------------------------------------------------------------------------ |
||
46 | |||
47 | /** |
||
48 | * Version info. |
||
49 | */ |
||
50 | define('VERSION', '3.9.1'); |
||
51 | |||
52 | /** |
||
53 | * Number of lines in a <textarea> control. |
||
54 | */ |
||
55 | define('HTML_TEXTBOX_DEFAULT_HEIGHT', 8); |
||
56 | define('HTML_TEXTBOX_MIN_HEIGHT', 2); |
||
57 | define('HTML_TEXTBOX_MAX_HEIGHT', 100); |
||
58 | |||
59 | //------------------------------------------------------------------------------ |
||
60 | // Functions. |
||
61 | //------------------------------------------------------------------------------ |
||
62 | |||
63 | /** |
||
64 | * Generates XML code for bookmarks of list. |
||
65 | * |
||
66 | * @param int &$curr_page Number of current page (from 1 to number of pages). |
||
67 | * @param int $rec_count Total number of records. |
||
68 | * @param int &$rec_from Number of first record being displayed (from 1 to number of records). |
||
69 | * @param int &$rec_to Number of last record being displayed (from 1 to number of records). |
||
70 | * @param string $url URL for using in bookmarks. |
||
71 | * @return string Generated XML code. |
||
72 | */ |
||
73 | function gen_xml_bookmarks (&$curr_page, $rec_count, &$rec_from, &$rec_to, $url = 'index.php?') |
||
74 | { |
||
75 | debug_write_log(DEBUG_TRACE, '[gen_xml_bookmarks]'); |
||
76 | debug_write_log(DEBUG_DUMP, '[gen_xml_bookmarks] $curr_page = ' . $curr_page); |
||
77 | debug_write_log(DEBUG_DUMP, '[gen_xml_bookmarks] $rec_count = ' . $rec_count); |
||
78 | debug_write_log(DEBUG_DUMP, '[gen_xml_bookmarks] $url = ' . $url); |
||
79 | |||
80 | $nav_count = (int)(($rec_count + $_SESSION[VAR_PAGEROWS] - 1) / $_SESSION[VAR_PAGEROWS]); |
||
81 | $curr_page = ustr2int($curr_page, 1, $nav_count); |
||
82 | |||
83 | debug_write_log(DEBUG_DUMP, '[gen_xml_bookmarks] $nav_count = ' . $nav_count); |
||
84 | debug_write_log(DEBUG_DUMP, '[gen_xml_bookmarks] $curr_page = ' . $curr_page); |
||
85 | |||
86 | $nav_from = (int)(($curr_page - 1) / $_SESSION[VAR_PAGEBKMS]) * $_SESSION[VAR_PAGEBKMS] + 1; |
||
87 | $nav_to = $nav_from + $_SESSION[VAR_PAGEBKMS] - 1; |
||
88 | |||
89 | if ($nav_to > $nav_count) |
||
90 | { |
||
91 | $nav_to = $nav_count; |
||
92 | } |
||
93 | |||
94 | debug_write_log(DEBUG_DUMP, '[gen_xml_bookmarks] $nav_from = ' . $nav_from); |
||
95 | debug_write_log(DEBUG_DUMP, '[gen_xml_bookmarks] $nav_to = ' . $nav_to); |
||
96 | |||
97 | $rec_from = ($curr_page - 1) * $_SESSION[VAR_PAGEROWS] + 1; |
||
98 | $rec_to = $rec_from + $_SESSION[VAR_PAGEROWS] - 1; |
||
99 | |||
100 | if ($rec_to > $rec_count) |
||
101 | { |
||
102 | $rec_to = $rec_count; |
||
103 | } |
||
104 | |||
105 | debug_write_log(DEBUG_DUMP, '[gen_xml_bookmarks] $rec_from = ' . $rec_from); |
||
106 | debug_write_log(DEBUG_DUMP, '[gen_xml_bookmarks] $rec_to = ' . $rec_to); |
||
107 | |||
108 | $xml = '<bookmarks total="' . get_html_resource(RES_TOTAL_ID) . ' ' . $rec_count . '">'; |
||
109 | |||
110 | if ($nav_from > 1) |
||
111 | { |
||
112 | $xml .= '<bookmark url="reloadTab(\'' . $url . 'page=1\')">%lt;%lt;</bookmark>' |
||
113 | . '<bookmark url="reloadTab(\'' . $url . 'page=' . ($nav_from - 1) . '\')">%lt;</bookmark>'; |
||
114 | } |
||
115 | |||
116 | for ($i = $nav_from; $i <= $nav_to; $i++) |
||
117 | { |
||
118 | $xml .= '<bookmark url="reloadTab(\'' . $url . 'page=' . $i . '\')" active="' . ($i == $curr_page ? 'true' : 'false') . '">' . $i . '</bookmark>'; |
||
119 | } |
||
120 | |||
121 | if ($nav_to < $nav_count) |
||
122 | { |
||
123 | $xml .= '<bookmark url="reloadTab(\'' . $url . 'page=' . ($nav_to + 1) . '\')">%gt;</bookmark>' |
||
124 | . '<bookmark url="reloadTab(\'' . $url . 'page=' . $nav_count . '\')">%gt;%gt;</bookmark>'; |
||
125 | } |
||
126 | |||
127 | $xml .= '</bookmarks>'; |
||
128 | |||
129 | return $xml; |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * Converts generated XML code to HTML. |
||
134 | * |
||
135 | * (by changing the default XSLT-file can convert to anything you want) |
||
136 | * |
||
137 | * @param string $xml Input XML code. |
||
138 | * @param string $title Title of page being generated (NULL is $xml contains only part of the page). |
||
139 | * @param string $xsl XSLT-file (path is related to "engine" directory). |
||
140 | * @return string Generated HTML code. |
||
141 | */ |
||
142 | function xml2html ($xml, $title = NULL, $xsl = 'engine.xsl') |
||
143 | { |
||
144 | debug_write_log(DEBUG_TRACE, '[xml2html]'); |
||
145 | debug_write_log(DEBUG_DUMP, '[xml2html] $title = ' . $title); |
||
146 | |||
147 | // a page is being generated |
||
148 | if (!is_null($title)) |
||
149 | { |
||
150 | // generate page parameters |
||
151 | |||
152 | $params = array('title' => $title, |
||
153 | 'version' => ustrprocess(get_html_resource(RES_VERSION_X_ID), VERSION), |
||
154 | 'username' => isset($_SESSION[VAR_FULLNAME]) ? ustr2html($_SESSION[VAR_FULLNAME]) : get_html_resource(RES_GUEST_ID), |
||
155 | 'logout' => get_html_resource(get_user_level() == USER_LEVEL_GUEST ? RES_LOGIN_ID : RES_LOGOUT_ID), |
||
156 | 'search' => get_html_resource(RES_SEARCH_ID)); |
||
157 | |||
158 | $script = '<script>' |
||
159 | . 'function onLogoutButton()' |
||
160 | . '{' |
||
161 | . (get_user_level() == USER_LEVEL_GUEST |
||
162 | ? 'window.open("../logon/index.php", "_parent");' |
||
163 | : sprintf('jqConfirm("%s","%s","%s","%s","logout()")', |
||
164 | get_html_resource(RES_QUESTION_ID), |
||
165 | get_html_resource(RES_CONFIRM_LOGOUT_ID), |
||
166 | get_html_resource(RES_OK_ID), |
||
167 | get_html_resource(RES_CANCEL_ID))) |
||
168 | . '}' |
||
169 | . '</script>'; |
||
170 | |||
171 | if (MAINTENANCE_BANNER) |
||
172 | { |
||
173 | list($year, $month, $day) = explode('-', MAINTENANCE_START_DATE); |
||
174 | list($hour, $minute) = explode(':', MAINTENANCE_START_TIME); |
||
175 | |||
176 | $date1 = mktime($hour, $minute, 0, $month, $day, $year); |
||
177 | |||
178 | list($year, $month, $day) = explode('-', MAINTENANCE_FINISH_DATE); |
||
179 | list($hour, $minute) = explode(':', MAINTENANCE_FINISH_TIME); |
||
180 | |||
181 | $date2 = mktime($hour, $minute, 0, $month, $day, $year); |
||
182 | |||
183 | if (version_compare(PHP_VERSION, '5.1.3') >= 0) |
||
184 | { |
||
185 | $timezone = date('P'); |
||
186 | } |
||
187 | else |
||
188 | { |
||
189 | $timezone = date('O'); |
||
190 | $timezone = usubstr($timezone, 0, ustrlen($timezone) - 2) . ':' . usubstr($timezone, ustrlen($timezone) - 2); |
||
191 | } |
||
192 | |||
193 | $params['banner'] = ustrprocess(get_html_resource(RES_BANNER_ID), get_datetime($date1), get_datetime($date2), 'GMT' . $timezone); |
||
194 | } |
||
195 | |||
196 | $header = '<?xml version="1.0" encoding="UTF-8"?>' |
||
197 | . '<page'; |
||
198 | |||
199 | foreach ($params as $name => $value) |
||
200 | { |
||
201 | $header .= sprintf(' %s="%s"', $name, $value); |
||
202 | } |
||
203 | |||
204 | $header .= '>'; |
||
205 | |||
206 | $theme = isset($_SESSION[VAR_THEME_NAME]) ? $_SESSION[VAR_THEME_NAME] : THEME_DEFAULT; |
||
207 | |||
208 | $header .= '<css>../themes/css.php?name=' . $theme . '/jquery-ui.css</css>' |
||
209 | . '<css>../themes/css.php?name=' . $theme . '/jquery.jqplot.css</css>' |
||
210 | . '<css>../themes/css.php?name=' . $theme . '/etraxis.css</css>' |
||
211 | . '<css>../themes/css.php?name=' . $theme . '/list.css</css>' |
||
212 | . '<css>../themes/css.php?name=' . $theme . '/combobox.css</css>' |
||
213 | . '<css>../themes/css.php?name=' . $theme . '/buttons.css</css>'; |
||
214 | |||
215 | // generate main menu |
||
216 | |||
217 | $menu = sprintf('<mainmenu logo="../%s" site="%s">', COMPANY_LOGO, COMPANY_SITE); |
||
218 | |||
219 | if (get_user_level() == USER_LEVEL_GUEST) |
||
220 | { |
||
221 | $menu .= '<menuitem url="../records/index.php">' . get_html_resource(RES_RECORDS_ID) . '</menuitem>' |
||
222 | . '<menuitem url="../projects/index.php">' . get_html_resource(RES_PROJECTS_ID) . '</menuitem>'; |
||
223 | } |
||
224 | else |
||
225 | { |
||
226 | $menu .= '<menuitem url="../records/index.php">' . get_html_resource(RES_RECORDS_ID) . '</menuitem>' |
||
227 | . '<menuitem url="../filters/index.php">' . get_html_resource(RES_FILTERS_ID) . '</menuitem>' |
||
228 | . '<menuitem url="../views/index.php">' . get_html_resource(RES_VIEWS_ID) . '</menuitem>'; |
||
229 | |||
230 | if (EMAIL_NOTIFICATIONS_ENABLED) |
||
231 | { |
||
232 | $menu .= '<menuitem url="../subscriptions/index.php">' . get_html_resource(RES_SUBSCRIPTIONS_ID) . '</menuitem>'; |
||
233 | |||
234 | if (can_reminder_be_created()) |
||
235 | { |
||
236 | $menu .= '<menuitem url="../reminders/index.php">' . get_html_resource(RES_REMINDERS_ID) . '</menuitem>'; |
||
237 | } |
||
238 | } |
||
239 | |||
240 | $menu .= '<menuitem url="../projects/index.php">' . get_html_resource(RES_PROJECTS_ID) . '</menuitem>'; |
||
241 | |||
242 | if (get_user_level() == USER_LEVEL_ADMIN) |
||
243 | { |
||
244 | $menu .= '<menuitem url="../accounts/index.php">' . get_html_resource(RES_ACCOUNTS_ID) . '</menuitem>' |
||
245 | . '<menuitem url="../groups/index.php">' . get_html_resource(RES_GLOBAL_GROUPS_ID) . '</menuitem>'; |
||
246 | |||
247 | if (file_exists('../config/index.php')) |
||
248 | { |
||
249 | $menu .= '<menuitem url="../config/index.php">' . get_html_resource(RES_CONFIGURATION_ID) . '</menuitem>'; |
||
250 | } |
||
251 | } |
||
252 | |||
253 | $menu .= '<menuitem url="../settings/index.php">' . get_html_resource(RES_SETTINGS_ID) . '</menuitem>'; |
||
254 | } |
||
255 | |||
256 | $menu .= '</mainmenu>'; |
||
257 | |||
258 | // select requested tab, if one was specified |
||
259 | |||
260 | $tab = '<onready>' |
||
261 | . '$("#tabs").tabs("option", "selected", ' . (try_request('tab', 1) - 1) . ');' |
||
262 | . '$.blockUI.defaults.message = "' . get_html_resource(RES_PLEASE_WAIT_ID) . '";' |
||
263 | . '</onready>'; |
||
264 | |||
265 | // join all pieces together |
||
266 | |||
267 | $xml = $header |
||
268 | . $script |
||
269 | . $menu |
||
270 | . $tab |
||
271 | . $xml |
||
272 | . '</page>'; |
||
273 | } |
||
274 | // a part of page is being generated |
||
275 | else |
||
276 | { |
||
277 | // generate parameters |
||
278 | |||
279 | $params = array('msgboxTitle' => get_html_resource(RES_QUESTION_ID), |
||
280 | 'btnOk' => get_html_resource(RES_OK_ID), |
||
281 | 'btnCancel' => get_html_resource(RES_CANCEL_ID)); |
||
282 | |||
283 | $header = '<tab-content'; |
||
284 | |||
285 | foreach ($params as $name => $value) |
||
286 | { |
||
287 | $header .= sprintf(' %s="%s"', $name, $value); |
||
288 | } |
||
289 | |||
290 | $header .= '>'; |
||
291 | |||
292 | // join all pieces together |
||
293 | |||
294 | $xml = $header |
||
295 | . $xml |
||
296 | . '</tab-content>'; |
||
297 | } |
||
298 | |||
299 | // process resulted XML |
||
300 | |||
301 | $page = new DOMDocument(); |
||
302 | $xslt = new XSLTProcessor(); |
||
303 | |||
304 | $page->load(get_theme_xsl_file($xsl)); |
||
305 | $xslt->importStyleSheet($page); |
||
306 | $page->loadXML($xml); |
||
307 | |||
308 | $html = $xslt->transformToXML($page); |
||
309 | |||
310 | if (extension_loaded('libxml')) |
||
311 | { |
||
312 | $error = libxml_get_last_error(); |
||
313 | |||
314 | if ($error) |
||
315 | { |
||
316 | debug_write_log(DEBUG_ERROR, '[xml2html] XML Error = ' . $error->message); |
||
317 | debug_write_log(DEBUG_DUMP, '[xml2html] $xml = ' . $xml); |
||
318 | } |
||
319 | } |
||
320 | |||
321 | $html = str_replace('%br;', '<br/>', $html); |
||
322 | |||
323 | // built-in compressions: check whether required extensions is available and PHP compression is turned off |
||
324 | if (!extension_loaded('zlib') || ini_get('zlib.output_compression') || ini_get('output_handler')) |
||
325 | { |
||
326 | $html = str_replace('scripts/get.php?name=', 'scripts/', $html); |
||
327 | } |
||
328 | |||
329 | // workaround: some PHP configurations insert CDATA tags which break the output |
||
330 | $html = preg_replace('/<!\[cdata\[(.*?)\]\]>/isu', '$1', $html); |
||
331 | $html = preg_replace('/%3C!\[cdata\[(.*?)\]\]%3E/isu', '$1', $html); |
||
332 | |||
333 | mb_regex_encoding('UTF-8'); |
||
334 | |||
335 | $html = mb_eregi_replace('%([A-Za-z]+);', '&\1;', $html); |
||
336 | $html = mb_eregi_replace('%(#[0-9]{1,4});', '&\1;', $html); |
||
337 | $html = mb_eregi_replace('%(#x[0-9A-Fa-f]{1,4});', '&\1;', $html); |
||
338 | |||
339 | debug_write_log(DEBUG_PERFORMANCE, 'page size = ' . strlen($html)); |
||
340 | |||
341 | return $html; |
||
342 | } |
||
343 | |||
344 | ?> |
||
0 ignored issues
–
show
|
|||
345 |
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.