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 | * Copyright (c) STMicroelectronics, 2006. All Rights Reserved. |
||
4 | * |
||
5 | * Originally written by Manuel Vacelet, 2006 |
||
6 | * |
||
7 | * This file is a part of Codendi. |
||
8 | * |
||
9 | * Codendi is free software; you can redistribute it and/or modify |
||
10 | * it under the terms of the GNU General Public License as published by |
||
11 | * the Free Software Foundation; either version 2 of the License, or |
||
12 | * (at your option) any later version. |
||
13 | * |
||
14 | * Codendi is distributed in the hope that it will be useful, |
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
17 | * GNU General Public License for more details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU General Public License |
||
20 | * along with Codendi. If not, see <http://www.gnu.org/licenses/>. |
||
21 | */ |
||
22 | |||
23 | require_once('common/TreeNode/TreeNode.class.php'); |
||
24 | require_once('BuildMenuVisitor.class.php'); |
||
25 | require_once('common/layout/Layout.class.php'); |
||
26 | |||
27 | class DivBasedTabbedLayout extends Layout |
||
28 | { |
||
29 | /** |
||
30 | * The root location for images |
||
31 | * |
||
32 | * @var string $imgroot |
||
33 | */ |
||
34 | var $imgroot; |
||
35 | |||
36 | /** |
||
37 | * DivBasedTabbedLayout - Constructor |
||
38 | */ |
||
39 | function __construct($root) { |
||
40 | // Parent constructor |
||
41 | parent::__construct($root); |
||
42 | $this->imgroot = $root.'/images/'; |
||
43 | } |
||
44 | |||
45 | function getBodyHeader($params) { |
||
46 | /* A 2x2 table header |
||
47 | Organisation logo | users actions |
||
48 | Separator or any image | Search box |
||
49 | NB: Original OsdnNavBar has been removed from first cell. <td align="center">'.$this->getOsdnNavBar() |
||
50 | */ |
||
51 | $output = ' |
||
52 | <table cellpadding="0" cellspacing="0" border="0" width="100%"> |
||
53 | <tr> |
||
54 | <td class="header_logo">'. $this->getBodyHeaderLogo() .'</td> |
||
55 | <td class="header_actions">'; |
||
56 | $output .= $this->getBodyHeaderActions($params); |
||
57 | $output .= '<div class="header_searchbox">'.$this->getSearchBox().'</div> |
||
58 | </td> |
||
59 | </tr> |
||
60 | </table>'; |
||
61 | return $output; |
||
62 | } |
||
63 | function getBodyHeaderLogo() { |
||
64 | return '<a href="/"><img src="'.$this->imgroot.'organization_logo.png" /></a>'; |
||
65 | } |
||
66 | function getBodyHeaderActions($params) { |
||
67 | $html = ''; |
||
68 | $html .= '<ul>'; |
||
69 | if (user_isloggedin()) { |
||
70 | |||
71 | $html .= '<li class="header_actions_nolink">'.$GLOBALS['Language']->getText('include_menu','logged_in').': '.user_getname().'</li>'; |
||
72 | $html .= '<li><a href="/account/logout.php">'.$GLOBALS['Language']->getText('include_menu','logout').'</a></li>'; |
||
73 | if((isset($GLOBALS['sys_use_project_registration']) && $GLOBALS['sys_use_project_registration'] ==1) || !isset($GLOBALS['sys_use_project_registration'])) { |
||
74 | $html .= '<li><a href="/project/register.php">'.$GLOBALS['Language']->getText('include_menu','register_new_proj').'</a></li>'; |
||
75 | } |
||
76 | if (!HTTPRequest::instance()->isPost()) { |
||
77 | $add_bookmark_url = http_build_query(array( |
||
78 | 'bookmark_url' => $_SERVER['REQUEST_URI'], |
||
79 | 'bookmark_title' => str_replace($GLOBALS['sys_name'].': ', '', $params['title']) |
||
80 | )); |
||
81 | $html .= '<li class="bookmarkpage"><a href="/my/bookmark_add.php?'.$add_bookmark_url.'">'.$GLOBALS['Language']->getText('include_menu','bookmark_this_page').'</a></li>'; |
||
82 | } |
||
83 | } else { |
||
84 | $html .= '<li class="header_actions_nolink highlight">'.$GLOBALS['Language']->getText('include_menu','not_logged_in').'</li>'; |
||
85 | |||
86 | $login_url = '/account/login.php'; |
||
87 | if ($_SERVER['REQUEST_URI'] != $login_url) { |
||
88 | $login_url .= '?return_to='.urlencode($_SERVER['REQUEST_URI']); |
||
89 | } |
||
90 | |||
91 | $html .= '<li><a href="'.$this->purifier->purify($login_url).'">'.$GLOBALS['Language']->getText('include_menu','login').'</a></li>'; |
||
92 | $em =& EventManager::instance(); |
||
93 | $display_new_user = true; |
||
94 | $em->processEvent('display_newaccount', array('allow' => &$display_new_user)); |
||
95 | if ($display_new_user) { |
||
96 | $html .= '<li><a href="/account/register.php">'.$GLOBALS['Language']->getText('include_menu','new_user').'</a></li>'; |
||
97 | } |
||
98 | |||
99 | } |
||
100 | $html .= '</ul>'; |
||
101 | return $html; |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * header() - "steel theme" top of page |
||
106 | * |
||
107 | * @param array Header parameters array |
||
108 | */ |
||
109 | function header($params) { |
||
110 | global $Language; |
||
111 | |||
112 | $this->generic_header($params); |
||
113 | ?> |
||
114 | |||
115 | <body class="<?php echo $this->getClassnamesForBodyTag($params) ?>"> |
||
116 | <div id="wrapper"> |
||
117 | <?php |
||
118 | $deprecated = $this->getBrowserDeprecatedMessage(); |
||
119 | if ($deprecated) { |
||
120 | echo '<div id="browser_deprecated">'.$deprecated.'</div>'; |
||
121 | } |
||
122 | echo $this->getMOTD(); |
||
123 | ?> |
||
124 | |||
125 | <div id="header"><?php echo $this->getBodyHeader($params); ?></div> |
||
126 | |||
127 | <div id="navigation"> |
||
128 | <?php |
||
129 | echo $this->outerTabs($params); |
||
130 | |||
131 | $main_body_class = ''; |
||
132 | if (isset($params['toptab']) && is_string($params['toptab'])) { |
||
133 | $main_body_class = 'service-' . $params['toptab']; |
||
134 | } |
||
135 | |||
136 | ?> |
||
137 | </div> <!-- headertab --> |
||
138 | |||
139 | <div class="main_body_row <?= $main_body_class;?>"> |
||
140 | |||
141 | <div class="contenttable"> |
||
142 | <?php |
||
143 | echo $this->getBreadCrumbs(); |
||
144 | echo $this->getToolbar(); |
||
145 | echo $this->_getFeedback(); |
||
146 | $this->_feedback->display(); |
||
147 | echo $this->getNotificationPlaceholder(); |
||
148 | } |
||
149 | |||
150 | function footer($params) { |
||
151 | if (!isset($params['showfeedback']) || $params['showfeedback']) { |
||
152 | echo $this->_getFeedback(); |
||
153 | } |
||
154 | ?> |
||
155 | </div> <!-- class="contenttable"> --> |
||
156 | </div> <!-- class="main_body_row"> --> |
||
157 | </div> <!-- wrapper --> |
||
158 | <?php echo $this->getCustomFooter(); ?> |
||
159 | |||
160 | <?php |
||
161 | $this->generic_footer($params); |
||
162 | } |
||
163 | |||
164 | function getCustomFooter() { |
||
165 | return ''; |
||
166 | } |
||
167 | |||
168 | function _getTogglePlusForWidgets() { |
||
169 | return 'pointer_right.png'; |
||
170 | } |
||
171 | function _getToggleMinusForWidgets() { |
||
172 | return 'pointer_down.png'; |
||
173 | } |
||
174 | |||
175 | /** |
||
176 | * boxTop() - Top HTML box |
||
177 | * |
||
178 | * @param string Box title |
||
179 | * @param bool Whether to echo or return the results |
||
180 | * @param string The box background color |
||
181 | */ |
||
182 | function boxTop($title) { |
||
183 | return ' |
||
184 | <!-- Box Top Start --> |
||
185 | |||
186 | <table cellspacing="1" width="100%" border="0" class="boxtable"> |
||
187 | <tr class="boxtitle"> |
||
188 | <td class="boxtop_center" width="100%"><span class="titlebar">'.$title.'</span></td> |
||
189 | </tr> |
||
190 | <tr> |
||
191 | <td> |
||
192 | <table cellspacing="0" cellpadding="2" width="100%" border="0"> |
||
193 | <tr align="left""> |
||
194 | <td> |
||
195 | <!-- Box Top End -->'; |
||
196 | } |
||
197 | |||
198 | /** |
||
199 | * boxMiddle() - Middle HTML box |
||
200 | * |
||
201 | * @param string Box title |
||
202 | * @param string The box background color |
||
203 | */ |
||
204 | function boxMiddle($title) { |
||
205 | return ' |
||
206 | <!-- Box Middle Start --> |
||
207 | </td> |
||
208 | </tr> |
||
209 | <tr align="center" class="boxitem"> |
||
210 | <td><span class="titlebar">'.$title.'</span></td> |
||
211 | </tr> |
||
212 | <tr align="left"> |
||
213 | <td colspan="2"> |
||
214 | <!-- Box Middle End -->'; |
||
215 | } |
||
216 | |||
217 | /** |
||
218 | * boxBottom() - Bottom HTML box |
||
219 | * |
||
220 | * @param bool Whether to echo or return the results |
||
221 | */ |
||
222 | function boxBottom() { |
||
223 | return ' |
||
224 | </td> |
||
225 | </tr> |
||
226 | </table> |
||
227 | </td> |
||
228 | </tr> |
||
229 | <!-- Box Bottom Start --> |
||
230 | </table><br /> |
||
231 | <!-- Box Bottom End -->'; |
||
232 | } |
||
233 | |||
234 | /** |
||
235 | * boxGetAltRowStyle() - Get an alternating row style for tables |
||
236 | * |
||
237 | * @param int Row number |
||
238 | */ |
||
239 | function boxGetAltRowStyle($i) { |
||
240 | if ($i % 2 == 0) { |
||
241 | return 'background="'.$this->imgroot.'vert-grad.png"'; |
||
242 | } else { |
||
243 | return 'background="'.$this->imgroot.'box-grad.png"'; |
||
244 | } |
||
245 | } |
||
246 | |||
247 | function outerTabs($params) { |
||
248 | global $Language,$sys_use_trove,$sys_use_snippet; |
||
249 | $selected_top_tab = ''; |
||
250 | if (isset($params['selected_top_tab'])) { |
||
251 | $selected_top_tab = $params['selected_top_tab']; |
||
252 | } |
||
253 | $menuTree = new TreeNode(); |
||
254 | $sthSelected = false; |
||
255 | |||
256 | $menuTree->addChild(new TreeNode(array('link'=>'/' |
||
257 | ,'title'=>$Language->getText('menu','home')))); |
||
258 | // We need to keep a reference on this node in order to set the |
||
259 | // selected value in the data. See bottom of this function. |
||
260 | $homeNode =& $menuTree->getChild(0); |
||
261 | |||
262 | |||
263 | if (user_isloggedin()) { |
||
264 | $selected = ((isset($params['selected_top_tab']) && $params['selected_top_tab'] == '/my/') || |
||
265 | strstr(getStringFromServer('REQUEST_URI'),'/my/') || |
||
266 | strstr(getStringFromServer('REQUEST_URI'),'/account/')); |
||
267 | $sthSelected = ($sthSelected || $selected); |
||
268 | $mynode = new TreeNode(array('link'=>'/my/' |
||
269 | ,'title'=>$Language->getText('menu','my_personal_page') |
||
270 | ,'selected'=>$selected)); |
||
271 | |||
272 | if($selected) { |
||
273 | $selected = (isset($params['selected_top_tab']) && $params['selected_top_tab'] == '/my/') || (boolean) strstr(getStringFromServer('REQUEST_URI'),'/my/'); |
||
274 | $mynode->addChild(new TreeNode(array('link'=>'/my/' |
||
275 | ,'title'=>$Language->getText('my_index','my_dashboard') |
||
276 | ,'selected'=>$selected))); |
||
277 | |||
278 | $selected = (boolean) strstr(getStringFromServer('REQUEST_URI'),'/account/'); |
||
279 | |||
280 | $mynode->addChild(new TreeNode(array('link'=>'/account/' |
||
281 | ,'title'=>$Language->getText('my_index','account_maintenance') |
||
282 | ,'selected'=>$selected))); |
||
283 | } |
||
284 | $menuTree->addChild($mynode); |
||
285 | |||
286 | } else { |
||
287 | $selected = (boolean) strstr(getStringFromServer('REQUEST_URI'),'/my/'); |
||
288 | $sthSelected = ($sthSelected || $selected); |
||
289 | $menuTree->addChild(new TreeNode(array('link'=>'/my/' |
||
290 | ,'title'=>$Language->getText('menu','my_personal_page') |
||
291 | ,'selected'=>$selected))); |
||
292 | } |
||
293 | |||
294 | if ($GLOBALS['sys_use_trove'] != 0 || (isset($params['group']) && $params['group'])) { |
||
295 | $selected = false; |
||
296 | if (isset($params['group']) && $params['group']) { |
||
297 | // get group info using the common result set |
||
298 | $pm = ProjectManager::instance(); |
||
299 | $project = $pm->getProject($params['group']); |
||
300 | if ($project && is_object($project)) { |
||
301 | if ($project->isError()) { |
||
302 | die('is error'); |
||
0 ignored issues
–
show
|
|||
303 | } else { |
||
304 | $sthSelected = true; |
||
305 | |||
306 | $projTree = $this->project_tabs($params['toptab'],$params['group']); |
||
307 | |||
308 | $projTree->setData(array('link'=>'/softwaremap/' |
||
309 | ,'title'=>$Language->getText('menu','projectree') |
||
310 | ,'selected'=>true)); |
||
311 | //'link'=>'/projects/'.$project->getUnixName().'/' |
||
312 | //,'title'=>$project->getPublicName() |
||
313 | //,'selected' => true)); |
||
314 | |||
315 | $menuTree->addChild($projTree); |
||
316 | } |
||
317 | } |
||
318 | } else { |
||
319 | $selected = (boolean) strstr(getStringFromServer('REQUEST_URI'),'softwaremap'); |
||
320 | $sthSelected = ($sthSelected || $selected); |
||
321 | $menuTree->addChild(new TreeNode(array('link'=>'/softwaremap/' |
||
322 | ,'title'=>$Language->getText('menu','projectree') |
||
323 | ,'selected'=>$selected))); |
||
324 | } |
||
325 | } |
||
326 | if ($GLOBALS['sys_use_snippet'] != 0) { |
||
327 | $selected = (boolean) strstr(getStringFromServer('REQUEST_URI'),'/snippet/'); |
||
328 | $sthSelected = ($sthSelected || $selected); |
||
329 | $menuTree->addChild(new TreeNode(array('link'=>'/snippet/' |
||
330 | ,'title'=>$Language->getText('menu','code_snippet') |
||
331 | ,'selected'=>$selected))); |
||
332 | } |
||
333 | |||
334 | if (user_ismember(1,'A')) { |
||
335 | $selected = strpos(getStringFromServer('REQUEST_URI'),'/admin/') === 0 || $selected_top_tab === 'admin'; |
||
336 | $sthSelected = ($sthSelected || $selected); |
||
337 | $menuTree->addChild(new TreeNode(array('link'=>'/admin/' |
||
338 | ,'title'=>$Language->getText('menu','admin') |
||
339 | ,'selected'=>$selected))); |
||
340 | } |
||
341 | |||
342 | $selected = (boolean) (strstr(getStringFromServer('REQUEST_URI'),'/site/') || $selected_top_tab === 'site'); |
||
343 | $sthSelected = ($sthSelected || $selected); |
||
344 | $menuTree->addChild(new TreeNode(array('link'=>'/site/' |
||
345 | ,'title'=>$Language->getText('include_layout','Help') |
||
346 | ,'selected'=>$selected))); |
||
347 | |||
348 | $additional_tabs = array(); |
||
349 | include $GLOBALS['Language']->getContent('layout/extra_tabs', null, null, '.php'); |
||
350 | foreach ($additional_tabs as $t) { |
||
351 | $sthSelected = ($sthSelected || $t['selected']); |
||
352 | $menuTree->addChild(new TreeNode($t)); |
||
353 | } |
||
354 | |||
355 | // Set selected value for 'home' link (this is the selected tab |
||
356 | // if no other was previously selected) |
||
357 | $homeNodeData =& $homeNode->getData(); |
||
358 | $homeNodeData['selected'] = !$sthSelected; |
||
359 | |||
360 | $buildMenuVisitor = new BuildMenuVisitor(); |
||
361 | $menuTree->accept($buildMenuVisitor); |
||
362 | echo $buildMenuVisitor->getHtml(); |
||
363 | } |
||
364 | |||
365 | /** |
||
366 | * projectTabs() - Prints out the project tabs, contained here in case |
||
367 | * we want to allow it to be overriden |
||
368 | * |
||
369 | * @param string Is the tab currently selected |
||
370 | * @param string Is the group we should look up get title info |
||
371 | */ |
||
372 | function projectTabs($toptab,$group) { |
||
373 | $this->project_tabs($toptab,$group); |
||
374 | } |
||
375 | |||
376 | function project_tabs($toptab,$group_id) { |
||
377 | $pm = ProjectManager::instance(); |
||
378 | $project=$pm->getProject($group_id); |
||
379 | if ($project->isError()) { |
||
380 | //wasn't found or some other problem |
||
381 | return; |
||
382 | } |
||
383 | $menuTree = new TreeNode(); |
||
384 | $output = ''; |
||
385 | $tabs = $this->_getProjectTabs($toptab, $project); |
||
386 | $nb = count($tabs); |
||
387 | $selected = false; |
||
388 | for($i = 0; $i < $nb ; $i++) { |
||
389 | if ($tabs[$i]['enabled'] === true) { |
||
390 | $selected = true; |
||
391 | } |
||
392 | $menuTree->addChild(new TreeNode(array('link'=>$tabs[$i]['link'] |
||
393 | ,'title'=>$tabs[$i]['label'] |
||
394 | ,'selected'=>$tabs[$i]['enabled']))); |
||
395 | } |
||
396 | //$output .= $this->tabGenerator($TABS_DIRS,$TABS_TITLES,true,$selected, 2); |
||
397 | //echo $output; |
||
398 | return $menuTree; |
||
399 | } |
||
400 | |||
401 | /** |
||
402 | * @param sel_tab_bgcolor DEPRECATED |
||
403 | */ |
||
404 | function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$level) { |
||
405 | $count=count($TABS_DIRS); |
||
406 | $width=intval((100/$count)); |
||
407 | |||
408 | $return = ''; |
||
409 | |||
410 | $return .= ' |
||
411 | |||
412 | <!-- start tabs --> |
||
413 | <ul id="level_'.$level.'">'; |
||
414 | |||
415 | if ($nested) { |
||
416 | $inner='bottomtab'; |
||
417 | } else { |
||
418 | $inner='toptab'; |
||
419 | } |
||
420 | $rowspan = ''; |
||
421 | for ($i=0; $i<$count; $i++) { |
||
422 | // |
||
423 | // middle tabs |
||
424 | // |
||
425 | $wassel=($selected==$i-1); |
||
426 | $issel=($selected==$i); |
||
427 | |||
428 | if($issel) |
||
429 | $address = '<span>'.$TABS_TITLES[$i].'</span>'; |
||
430 | else |
||
431 | $address = '<a href="'.$TABS_DIRS[$i].'">'.$TABS_TITLES[$i].'</a>'; |
||
432 | |||
433 | $return .= ' |
||
434 | <li>'.$address.'</li>'; |
||
435 | |||
436 | } |
||
437 | $return .= ' |
||
438 | </ul> |
||
439 | <!-- end tabs --> |
||
440 | '; |
||
441 | return $return; |
||
442 | } |
||
443 | |||
444 | //diplaying search box in body |
||
445 | function bodySearchBox() { |
||
446 | } |
||
447 | } |
||
448 | |||
449 | ?> |
||
450 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.