|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* ****************************************************************************** |
|
5
|
|
|
* Copyright 2011-2017 DANTE Ltd. and GÉANT on behalf of the GN3, GN3+, GN4-1 |
|
6
|
|
|
* and GN4-2 consortia |
|
7
|
|
|
* |
|
8
|
|
|
* License: see the web/copyright.php file in the file structure |
|
9
|
|
|
* ****************************************************************************** |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace web\lib\admin; |
|
13
|
|
|
|
|
14
|
|
|
class PageDecoration { |
|
15
|
|
|
|
|
16
|
|
|
private $validator; |
|
17
|
|
|
private $ui; |
|
18
|
|
|
|
|
19
|
|
|
public function __construct() { |
|
20
|
|
|
$this->validator = new \web\lib\common\InputValidation(); |
|
21
|
|
|
$this->ui = new UIElements(); |
|
22
|
|
|
} |
|
23
|
|
|
/** |
|
24
|
|
|
* Our (very modest and light) sidebar. authenticated admins get more options, like logout |
|
25
|
|
|
* @param boolean $advancedControls |
|
26
|
|
|
*/ |
|
27
|
|
|
private function sidebar($advancedControls) { |
|
28
|
|
|
$retval = "<div class='sidebar'><p>"; |
|
29
|
|
|
|
|
30
|
|
|
if ($advancedControls) { |
|
31
|
|
|
$retval .= "<strong>" . _("You are:") . "</strong> " |
|
32
|
|
|
. (isset($_SESSION['name']) ? $_SESSION['name'] : _("Unnamed User")) . " |
|
33
|
|
|
<br/> |
|
34
|
|
|
<br/> |
|
35
|
|
|
<a href='" . \core\CAT::getRootUrlPath() . "/admin/overview_user.php'>" . _("Go to your Profile page") . "</a> |
|
36
|
|
|
<a href='" . \core\CAT::getRootUrlPath() . "/admin/inc/logout.php'>" . _("Logout") . "</a> "; |
|
37
|
|
|
} |
|
38
|
|
|
$host = $this->validator->hostname($_SERVER['SERVER_NAME']); |
|
39
|
|
|
if ($host === FALSE) { |
|
40
|
|
|
throw new \Exception("We don't know our own hostname?!? Giving up."); |
|
41
|
|
|
} |
|
42
|
|
|
$retval .= "<a href='" . \core\CAT::getRootUrlPath() . "'>" . _("Start page") . "</a> |
|
43
|
|
|
</p> |
|
44
|
|
|
</div> <!-- sidebar -->"; |
|
45
|
|
|
return $retval; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* constructs a <div> called 'header' for use on the top of the page |
|
50
|
|
|
* @param string $cap1 caption to display in this div |
|
51
|
|
|
* @param string $language current language (this one gets pre-set in the lang selector drop-down |
|
52
|
|
|
*/ |
|
53
|
|
|
private function headerDiv($cap1, $language) { |
|
54
|
|
|
|
|
55
|
|
|
$place = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); |
|
56
|
|
|
|
|
57
|
|
|
$retval = "<div class='header'> |
|
58
|
|
|
<div id='header_toprow'> |
|
59
|
|
|
<div id='header_captions' style='display:inline-block; float:left; min-width:400px;'> |
|
60
|
|
|
<h1>$cap1</h1> |
|
61
|
|
|
</div><!--header_captions--> |
|
62
|
|
|
<div id='langselection' style='padding-top:20px; padding-left:10px;'> |
|
63
|
|
|
<form action='$place' method='GET' accept-charset='UTF-8'>" . _("View this page in") . " |
|
64
|
|
|
<select id='lang' name='lang' onchange='this.form.submit()'>"; |
|
65
|
|
|
|
|
66
|
|
|
foreach (CONFIG['LANGUAGES'] as $lang => $value) { |
|
67
|
|
|
$retval .= "<option value='$lang' " . (strtoupper($language) == strtoupper($lang) ? "selected" : "" ) . " >" . $value['display'] . "</option> "; |
|
68
|
|
|
} |
|
69
|
|
|
$retval .= "</select>"; |
|
70
|
|
|
|
|
71
|
|
|
foreach ($_GET as $var => $value) { |
|
72
|
|
|
if ($var != "lang" && $value != "") { |
|
73
|
|
|
$retval .= "<input type='hidden' name='" . htmlspecialchars($var) . "' value='" . htmlspecialchars($value) . "'>"; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
$retval .= "</form> |
|
77
|
|
|
</div><!--langselection-->"; |
|
78
|
|
|
$host = $this->validator->hostname($_SERVER['SERVER_NAME']); |
|
79
|
|
|
if ($host === FALSE) { |
|
80
|
|
|
throw new \Exception("We don't know our own hostname?!? Giving up."); |
|
81
|
|
|
} |
|
82
|
|
|
$logoUrl = "//" . $host . CONFIG['PATHS']['cat_base_url'] . "/resources/images/consortium_logo.png"; |
|
83
|
|
|
$retval .= "<div class='consortium_logo'> |
|
84
|
|
|
<img id='test_locate' src='$logoUrl' alt='Consortium Logo'> |
|
85
|
|
|
</div> <!-- consortium_logo --> |
|
86
|
|
|
</div><!--header_toprow--> |
|
87
|
|
|
</div> <!-- header -->"; |
|
88
|
|
|
return $retval; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* This starts HTML in a default way. Most pages would call this. |
|
93
|
|
|
* Exception: if you need to add extra code in <head> or modify the <body> tag |
|
94
|
|
|
* (e.g. onload) then you should call defaultPagePrelude, close head, open body, |
|
95
|
|
|
* and then call productheader. |
|
96
|
|
|
* |
|
97
|
|
|
* @param string $pagetitle Title of the page to display |
|
98
|
|
|
* @param string $area the area in which this page is (displays some matching <h1>s) |
|
99
|
|
|
* @param boolean $authRequired |
|
100
|
|
|
*/ |
|
101
|
|
|
public function pageheader($pagetitle, $area, $authRequired = TRUE) { |
|
102
|
|
|
$retval = ""; |
|
103
|
|
|
$retval .= $this->defaultPagePrelude($pagetitle, $authRequired); |
|
104
|
|
|
$retval .= "</head></body>"; |
|
105
|
|
|
$retval .= $this->productheader($area); |
|
106
|
|
|
return $retval; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* the entire top of the page (<body> part) |
|
111
|
|
|
* |
|
112
|
|
|
* @param string $area the area we are in |
|
113
|
|
|
*/ |
|
114
|
|
|
public function productheader($area) { |
|
115
|
|
|
$langObject = new \core\common\Language(); |
|
116
|
|
|
$language = $langObject->getLang(); |
|
117
|
|
|
// this <div is closing in footer, keep it in PHP for Netbeans syntax |
|
118
|
|
|
// highlighting to work |
|
119
|
|
|
$retval = "<div class='maincontent'>"; |
|
120
|
|
|
// default values which match almost every case; override where needed |
|
121
|
|
|
$cap1 = CONFIG['APPEARANCE']['productname_long']; |
|
122
|
|
|
$advancedControls = TRUE; |
|
123
|
|
|
switch ($area) { |
|
124
|
|
|
case "ADMIN-IDP": |
|
125
|
|
|
$cap2 = sprintf(_("Administrator Interface - Identity Provider"),$this->ui->nomenclature_inst); |
|
126
|
|
|
break; |
|
127
|
|
|
case "ADMIN-IDP-USERS": |
|
128
|
|
|
$cap2 = sprintf(_("Administrator Interface - %s User Management"), \core\ProfileSilverbullet::PRODUCTNAME); |
|
129
|
|
|
break; |
|
130
|
|
|
case "ADMIN": |
|
131
|
|
|
$cap2 = _("Administrator Interface"); |
|
132
|
|
|
break; |
|
133
|
|
|
case "USERMGMT": |
|
134
|
|
|
$cap2 = _("Management of User Details"); |
|
135
|
|
|
break; |
|
136
|
|
|
case "FEDERATION": |
|
137
|
|
|
$cap2 = sprintf(_("Administrator Interface - %s Management"),$this->ui->nomenclature_fed); |
|
138
|
|
|
break; |
|
139
|
|
|
case "USER": |
|
140
|
|
|
$cap1 = sprintf(_("Welcome to %s"), CONFIG['APPEARANCE']['productname']); |
|
141
|
|
|
$cap2 = CONFIG['APPEARANCE']['productname_long']; |
|
142
|
|
|
$advancedControls = FALSE; |
|
143
|
|
|
break; |
|
144
|
|
|
case "SUPERADMIN": |
|
145
|
|
|
$cap2 = _("CIC"); |
|
146
|
|
|
break; |
|
147
|
|
|
case "DIAG": |
|
148
|
|
|
$cap2 = _("Diagnostics"); |
|
149
|
|
|
break; |
|
150
|
|
|
default: |
|
151
|
|
|
$cap2 = "It is an error if you ever see this string."; |
|
152
|
|
|
$advancedControls = FALSE; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
$retval .= $this->headerDiv($cap1, $language); |
|
156
|
|
|
// content from here on will SCROLL instead of being fixed at the top |
|
157
|
|
|
$retval .= "<div class='pagecontent'>"; // closes in footer again |
|
158
|
|
|
$retval .= "<div class='trick'>"; // closes in footer again |
|
159
|
|
|
$retval .= "<div id='secondrow' style='border-bottom:5px solid ".CONFIG['APPEARANCE']['colour1']."; min-height:100px;'> |
|
160
|
|
|
<div id='secondarycaptions' style='display:inline-block; float:left'> |
|
161
|
|
|
<h2>$cap2</h2> |
|
162
|
|
|
</div><!--secondarycaptions-->"; |
|
163
|
|
|
|
|
164
|
|
|
if (isset(CONFIG['APPEARANCE']['MOTD']) && CONFIG['APPEARANCE']['MOTD'] != "") { |
|
165
|
|
|
$retval .= "<div id='header_MOTD' style='display:inline-block; padding-left:20px;vertical-align:top;'> |
|
166
|
|
|
<p class='MOTD'>" . CONFIG['APPEARANCE']['MOTD'] . "</p> |
|
167
|
|
|
</div><!--header_MOTD-->"; |
|
168
|
|
|
} |
|
169
|
|
|
$retval .= $this->sidebar($advancedControls); |
|
170
|
|
|
$retval .= "</div><!--secondrow-->"; |
|
171
|
|
|
return $retval; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* |
|
176
|
|
|
* @param string $pagetitle Title of the page to display |
|
177
|
|
|
* @param boolean $authRequired does the user need to be autenticated to access this page? |
|
178
|
|
|
*/ |
|
179
|
|
|
public function defaultPagePrelude($pagetitle, $authRequired = TRUE) { |
|
180
|
|
|
if ($authRequired === TRUE) { |
|
181
|
|
|
$auth = new \web\lib\admin\Authentication(); |
|
182
|
|
|
$auth->authenticate(); |
|
183
|
|
|
} |
|
184
|
|
|
$langObject = new \core\common\Language(); |
|
185
|
|
|
$langObject->setTextDomain("web_admin"); |
|
186
|
|
|
$ourlocale = $langObject->getLang(); |
|
187
|
|
|
header("Content-Type:text/html;charset=utf-8"); |
|
188
|
|
|
$retval = "<!DOCTYPE html> |
|
189
|
|
|
<html xmlns='http://www.w3.org/1999/xhtml' lang='$ourlocale'> |
|
190
|
|
|
<head lang='$ourlocale'> |
|
191
|
|
|
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>"; |
|
192
|
|
|
|
|
193
|
|
|
if (strrpos($_SERVER['PHP_SELF'], "admin/")) { |
|
194
|
|
|
$cutoffPosition = strrpos($_SERVER['PHP_SELF'], "admin/"); |
|
195
|
|
|
} elseif (strrpos($_SERVER['PHP_SELF'], "accountstatus/")) { |
|
196
|
|
|
$cutoffPosition = strrpos($_SERVER['PHP_SELF'], "accountstatus/"); |
|
197
|
|
|
} elseif (strrpos($_SERVER['PHP_SELF'], "diag/")) { |
|
198
|
|
|
$cutoffPosition = strrpos($_SERVER['PHP_SELF'], "diag/"); |
|
199
|
|
|
} |
|
200
|
|
|
else { |
|
201
|
|
|
$cutoffPosition = strrpos($_SERVER['PHP_SELF'], "/"); |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
$host = $this->validator->hostname($_SERVER['SERVER_NAME']); |
|
205
|
|
|
if ($host === FALSE) { |
|
206
|
|
|
throw new \Exception("We don't know our own hostname!"); |
|
207
|
|
|
} |
|
208
|
|
|
$cssUrl = "//$host" . substr($_SERVER['PHP_SELF'], 0, $cutoffPosition )."/resources/css/cat.css.php"; |
|
209
|
|
|
|
|
210
|
|
|
$retval .= "<link rel='stylesheet' type='text/css' href='$cssUrl' />"; |
|
211
|
|
|
$retval .= "<title>" . htmlspecialchars($pagetitle) . "</title>"; |
|
212
|
|
|
return $retval; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* HTML code for the EU attribution |
|
217
|
|
|
* |
|
218
|
|
|
* @return string HTML code with GEANT Org and EU attribution as required for FP7 / H2020 projects |
|
219
|
|
|
*/ |
|
220
|
|
|
public function attributionEurope() { |
|
221
|
|
|
if (CONFIG_CONFASSISTANT['CONSORTIUM']['name'] == "eduroam" && isset(CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo']) && CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo'] == "Operations Team") {// SW: APPROVED |
|
222
|
|
|
// we may need to jump up one dir if we are either in admin/ or accountstatus/ |
|
223
|
|
|
// (accountstatus courtesy of my good mood. It's userspace not admin space so |
|
224
|
|
|
// it shouldn't be using this function any more.) |
|
225
|
|
|
|
|
226
|
|
|
if (strrpos($_SERVER['PHP_SELF'], "admin/")) { |
|
227
|
|
|
$cutoffPosition = strrpos($_SERVER['PHP_SELF'], "admin/"); |
|
228
|
|
|
} elseif (strrpos($_SERVER['PHP_SELF'], "accountstatus/")) { |
|
229
|
|
|
$cutoffPosition = strrpos($_SERVER['PHP_SELF'], "accountstatus/"); |
|
230
|
|
|
} elseif (strrpos($_SERVER['PHP_SELF'], "diag/")) { |
|
231
|
|
|
$cutoffPosition = strrpos($_SERVER['PHP_SELF'], "diag/"); |
|
232
|
|
|
} else { |
|
233
|
|
|
$cutoffPosition = strrpos($_SERVER['PHP_SELF'], "/"); |
|
234
|
|
|
} |
|
235
|
|
|
$host = $this->validator->hostname($_SERVER['SERVER_NAME']); |
|
236
|
|
|
if ($host === FALSE) { |
|
237
|
|
|
throw new \Exception("We don't know our own hostname!"); |
|
238
|
|
|
} |
|
239
|
|
|
$logoBase = "//$host" . substr($_SERVER['PHP_SELF'], 0, $cutoffPosition)."/resources/images"; |
|
240
|
|
|
|
|
241
|
|
|
return "<span id='logos' style='position:fixed; left:50%;'><img src='$logoBase/dante.png' alt='DANTE' style='height:23px;width:47px'/> |
|
242
|
|
|
<img src='$logoBase/eu.png' alt='EU' style='height:23px;width:27px;border-width:0px;'/></span> |
|
243
|
|
|
<span id='eu_text' style='text-align:right;'><a href='http://ec.europa.eu/dgs/connect/index_en.htm' style='text-decoration:none; vertical-align:top;'>European Commission Communications Networks, Content and Technology</a></span>"; |
|
244
|
|
|
} |
|
245
|
|
|
return " "; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
/** |
|
249
|
|
|
* displays the admin area footer |
|
250
|
|
|
*/ |
|
251
|
|
|
public function footer() { |
|
252
|
|
|
$cat = new \core\CAT(); |
|
253
|
|
|
$retval = "</div><!-- trick --> |
|
254
|
|
|
</div><!-- pagecontent --> |
|
255
|
|
|
<div class='footer'> |
|
256
|
|
|
<hr /> |
|
257
|
|
|
<table style='width:100%'> |
|
258
|
|
|
<tr> |
|
259
|
|
|
<td style='padding-left:20px; padding-right:20px; text-align:left; vertical-align:top;'> |
|
260
|
|
|
" . $cat->CAT_COPYRIGHT . "</td> |
|
261
|
|
|
<td style='padding-left:80px; padding-right:20px; text-align:right; vertical-align:top;'>"; |
|
262
|
|
|
|
|
263
|
|
|
if (CONFIG_CONFASSISTANT['CONSORTIUM']['name'] == "eduroam" && isset(CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo']) && CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo'] == "Operations Team") { // SW: APPROVED |
|
264
|
|
|
$retval .= $this->attributionEurope(); |
|
265
|
|
|
} else { |
|
266
|
|
|
$retval .= " "; |
|
267
|
|
|
} |
|
268
|
|
|
$retval .= " |
|
269
|
|
|
</td> |
|
270
|
|
|
</tr> |
|
271
|
|
|
</table> |
|
272
|
|
|
</div><!-- footer --> |
|
273
|
|
|
</div><!-- maincontent --> |
|
274
|
|
|
</body> |
|
275
|
|
|
</html>"; |
|
276
|
|
|
return $retval; |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
} |
|
280
|
|
|
|