|
1
|
|
|
<?php |
|
2
|
|
|
/* * ********************************************************************************* |
|
3
|
|
|
* (c) 2011-15 GÉANT on behalf of the GN3, GN3plus and GN4 consortia |
|
4
|
|
|
* License: see the LICENSE file in the root directory |
|
5
|
|
|
* ********************************************************************************* */ |
|
6
|
|
|
?> |
|
7
|
|
|
<?php |
|
8
|
|
|
require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/config/_config.php"); |
|
9
|
|
|
|
|
10
|
|
|
require_once("Helper.php"); |
|
11
|
|
|
require_once("CAT.php"); |
|
12
|
|
|
require_once(dirname(dirname(dirname(__FILE__))) . "/admin/inc/input_validation.inc.php"); |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* This starts HTML in a default way. Most pages would call this. |
|
16
|
|
|
* Exception: if you need to add extra code in <head> or modify the <body> tag |
|
17
|
|
|
* (e.g. onload) then you should call defaultPagePrelude, close head, open body, |
|
18
|
|
|
* and then call productheader. |
|
19
|
|
|
* |
|
20
|
|
|
* @param type $pagetitle |
|
21
|
|
|
* @param type $area |
|
22
|
|
|
* @param type $authRequired |
|
23
|
|
|
*/ |
|
24
|
|
|
function pageheader($pagetitle, $area, $authRequired = TRUE) { |
|
25
|
|
|
$cat = defaultPagePrelude($pagetitle, $authRequired); |
|
|
|
|
|
|
26
|
|
|
echo "</head></body>"; |
|
27
|
|
|
productheader($area, CAT::get_lang()); |
|
28
|
|
|
return $cat; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
function defaultPagePrelude($pagetitle, $auth_required = TRUE) { |
|
32
|
|
|
if ($auth_required == TRUE) { |
|
|
|
|
|
|
33
|
|
|
require_once(dirname(dirname(dirname(__FILE__))) . "/admin/inc/auth.inc.php"); |
|
34
|
|
|
authenticate(); |
|
35
|
|
|
} |
|
36
|
|
|
$cat = new CAT(); |
|
37
|
|
|
$cat->set_locale("web_admin"); |
|
38
|
|
|
$ourlocale = CAT::get_lang(); |
|
39
|
|
|
header("Content-Type:text/html;charset=utf-8"); |
|
40
|
|
|
echo "<!DOCTYPE html> |
|
41
|
|
|
<html xmlns='http://www.w3.org/1999/xhtml' lang='<?php echo $ourlocale;?>'> |
|
42
|
|
|
<head lang='<?php echo $ourlocale;?>'> |
|
43
|
|
|
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>"; |
|
44
|
|
|
|
|
45
|
|
|
$cssUrl = valid_host($_SERVER['HTTP_HOST']); |
|
46
|
|
|
if ($cssUrl === FALSE) { |
|
47
|
|
|
throw new Exception("We don't know our own hostname?!"); |
|
48
|
|
|
} |
|
49
|
|
|
// we need to construct the right path to the consortium logo; we are either |
|
50
|
|
|
// in the admin area or on the main index.php ... |
|
51
|
|
|
if (strpos($_SERVER['PHP_SELF'], "admin/") !== FALSE) { |
|
52
|
|
|
$cssUrl .= substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], "/admin/")) . "/resources/css/cat.css.php"; |
|
53
|
|
View Code Duplication |
} else if (strpos($_SERVER['PHP_SELF'], "diag/") !== FALSE) { |
|
|
|
|
|
|
54
|
|
|
$cssUrl .= substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], "/diag/")) . "/resources/css/cat.css.php"; |
|
55
|
|
|
} else { |
|
56
|
|
|
$cssUrl .= substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], "/")) . "/resources/css/cat.css.php"; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$cssUrl = "//" . $cssUrl; // omitting http or https means "on same protocol |
|
60
|
|
|
|
|
61
|
|
|
echo "<link rel='stylesheet' type='text/css' href='$cssUrl' />"; |
|
62
|
|
|
echo "<title>" . htmlspecialchars($pagetitle) . "</title>"; |
|
63
|
|
|
|
|
64
|
|
|
return $cat; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
function headerDiv($cap1) { |
|
68
|
|
|
$place = parse_url($_SERVER['REQUEST_URI']); |
|
69
|
|
|
?> |
|
70
|
|
|
<div class='header'> |
|
71
|
|
|
<div id='header_toprow'> |
|
72
|
|
|
<div id='header_captions' style='display:inline-block; float:left; min-width:400px;'> |
|
73
|
|
|
<h1><?php echo $cap1; ?></h1> |
|
74
|
|
|
</div><!--header_captions--> |
|
75
|
|
|
<div id='langselection' style='padding-top:20px; padding-left:10px;'> |
|
76
|
|
|
<form action='<?php echo $place['path']; ?>' method='GET' accept-charset='UTF-8'><?php echo _("View this page in"); ?> |
|
|
|
|
|
|
77
|
|
|
<select id='lang' name='lang' onchange='this.form.submit()'> |
|
78
|
|
|
<?php |
|
79
|
|
|
foreach (Config::$LANGUAGES as $lang => $value) { |
|
80
|
|
|
echo "<option value='$lang' " . (strtoupper($language) == strtoupper($lang) ? "selected" : "" ) . " >" . $value['display'] . "</option> "; |
|
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
?> |
|
83
|
|
|
</select> |
|
84
|
|
|
<?php |
|
85
|
|
|
foreach ($_GET as $var => $value) { |
|
86
|
|
|
if ($var != "lang" && $value != "") { |
|
87
|
|
|
echo "<input type='hidden' name='" . htmlspecialchars($var) . "' value='" . htmlspecialchars($value) . "'>"; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
?> |
|
91
|
|
|
</form> |
|
92
|
|
|
</div><!--langselection--> |
|
93
|
|
|
<?php |
|
94
|
|
|
$logoUrl = valid_host($_SERVER['HTTP_HOST']); |
|
95
|
|
|
if ($logoUrl === FALSE) { |
|
96
|
|
|
throw new Exception("We don't know our own hostname?!"); |
|
97
|
|
|
} |
|
98
|
|
|
// we need to construct the right path to the consortium logo; we are either |
|
99
|
|
|
// in the admin area or on the main index.php ... |
|
100
|
|
View Code Duplication |
if (strpos($_SERVER['PHP_SELF'], "admin/") === FALSE) { |
|
|
|
|
|
|
101
|
|
|
$logoUrl .= substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], "/")) . "/resources/images/consortium_logo.png"; |
|
102
|
|
|
} |
|
103
|
|
|
else { |
|
104
|
|
|
$logoUrl .= substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], "/admin/")) . "/resources/images/consortium_logo.png"; |
|
105
|
|
|
} |
|
106
|
|
|
$logoUrl = "//" . $logoUrl; |
|
|
|
|
|
|
107
|
|
|
?> |
|
108
|
|
|
<div class='consortium_logo'> |
|
109
|
|
|
<img id='test_locate' src='$logoUrl' alt='Consortium Logo'> |
|
110
|
|
|
</div> <!-- consortium_logo --> |
|
111
|
|
|
|
|
112
|
|
|
</div><!--header_toprow--> |
|
113
|
|
|
</div> <!-- header --> |
|
114
|
|
|
<?php |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
function productheader($area, $language) { |
|
|
|
|
|
|
118
|
|
|
// this <div is closing in footer, keep it in PHP for Netbeans syntax |
|
119
|
|
|
// highlighting to work |
|
120
|
|
|
echo "<div class='maincontent'>"; |
|
121
|
|
|
|
|
122
|
|
|
switch ($area) { |
|
123
|
|
View Code Duplication |
case "ADMIN-IDP": |
|
|
|
|
|
|
124
|
|
|
$cap1 = Config::$APPEARANCE['productname_long']; |
|
125
|
|
|
$cap2 = _("Administrator Interface - Identity Provider"); |
|
126
|
|
|
$advanced_controls = TRUE; |
|
127
|
|
|
break; |
|
128
|
|
View Code Duplication |
case "ADMIN": |
|
|
|
|
|
|
129
|
|
|
$cap1 = Config::$APPEARANCE['productname_long']; |
|
130
|
|
|
$cap2 = _("Administrator Interface"); |
|
131
|
|
|
$advanced_controls = TRUE; |
|
132
|
|
|
break; |
|
133
|
|
View Code Duplication |
case "USERMGMT": |
|
|
|
|
|
|
134
|
|
|
$cap1 = Config::$APPEARANCE['productname_long']; |
|
135
|
|
|
$cap2 = _("Management of User Details"); |
|
136
|
|
|
$advanced_controls = TRUE; |
|
137
|
|
|
break; |
|
138
|
|
View Code Duplication |
case "FEDERATION": |
|
|
|
|
|
|
139
|
|
|
$cap1 = Config::$APPEARANCE['productname_long']; |
|
140
|
|
|
$cap2 = _("Administrator Interface - Federation Management"); |
|
141
|
|
|
$advanced_controls = TRUE; |
|
142
|
|
|
break; |
|
143
|
|
View Code Duplication |
case "USER": |
|
|
|
|
|
|
144
|
|
|
$cap1 = sprintf(_("Welcome to %s"), Config::$APPEARANCE['productname']); |
|
145
|
|
|
$cap2 = Config::$APPEARANCE['productname_long']; |
|
146
|
|
|
$advanced_controls = FALSE; |
|
147
|
|
|
break; |
|
148
|
|
View Code Duplication |
case "SUPERADMIN": |
|
|
|
|
|
|
149
|
|
|
$cap1 = Config::$APPEARANCE['productname_long']; |
|
150
|
|
|
$cap2 = _("CIC"); |
|
151
|
|
|
$advanced_controls = TRUE; |
|
152
|
|
|
break; |
|
153
|
|
|
default: |
|
154
|
|
|
$cap1 = Config::$APPEARANCE['productname_long']; |
|
155
|
|
|
$cap2 = "It is an error if you ever see this string."; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
|
|
159
|
|
|
echo headerDiv($cap1); |
|
160
|
|
|
// content from here on will SCROLL instead of being fixed at the top |
|
161
|
|
|
echo "<div class='pagecontent'>"; // closes in footer again |
|
162
|
|
|
echo "<div class='trick'>"; // closes in footer again |
|
163
|
|
|
?> |
|
164
|
|
|
<div id='secondrow' style='border-bottom:5px solid <?php echo Config::$APPEARANCE['colour1']; ?>; min-height:100px;'> |
|
165
|
|
|
<div id='secondarycaptions' style='display:inline-block; float:left'> |
|
166
|
|
|
<h2><?php echo $cap2; ?></h2> |
|
167
|
|
|
</div><!--secondarycaptions-->"; |
|
168
|
|
|
<?php |
|
169
|
|
|
if (isset(Config::$APPEARANCE['MOTD']) && Config::$APPEARANCE['MOTD'] != "") { |
|
170
|
|
|
echo "<div id='header_MOTD' style='display:inline-block; padding-left:20px;vertical-align:top;'> |
|
171
|
|
|
<p class='MOTD'>" . Config::$APPEARANCE['MOTD'] . "</p> |
|
172
|
|
|
</div><!--header_MOTD-->"; |
|
173
|
|
|
} |
|
174
|
|
|
?> |
|
175
|
|
|
<div class='sidebar'><p> |
|
176
|
|
|
<?php |
|
177
|
|
|
if ($advanced_controls) { |
|
|
|
|
|
|
178
|
|
|
echo "<strong>" . _("You are:") . "</strong> " |
|
179
|
|
|
. (isset($_SESSION['name']) ? $_SESSION['name'] : _("Unnamed User")) . " |
|
180
|
|
|
<br/> |
|
181
|
|
|
<br/> |
|
182
|
|
|
<a href='overview_user.php'>" . _("Go to your Profile page") . "</a> |
|
183
|
|
|
<a href='inc/logout.php'>" . _("Logout") . "</a> "; |
|
184
|
|
|
} |
|
185
|
|
|
if (strpos($_SERVER['PHP_SELF'], "admin/") === FALSE) |
|
186
|
|
|
echo "<a href='" . dirname($_SERVER['SCRIPT_NAME']) . "/'>" . _("Start page") . "</a>"; |
|
187
|
|
|
else |
|
188
|
|
|
echo "<a href='../'>" . _("Start page") . "</a>"; |
|
189
|
|
|
?> |
|
190
|
|
|
</p> |
|
191
|
|
|
</div> <!-- sidebar --> |
|
192
|
|
|
</div><!--secondrow--> |
|
193
|
|
|
<?php |
|
194
|
|
|
} |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.