-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathadmin.php
177 lines (145 loc) · 6.68 KB
/
admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
/*
**************************************************************************************************************************
** CORAL Authentication Module v. 1.0
**
** Copyright (c) 2011 University of Notre Dame
**
** This file is part of CORAL.
**
** CORAL is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
**
** CORAL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along with CORAL. If not, see <http://www.gnu.org/licenses/>.
**
**************************************************************************************************************************
*/
session_start();
include_once 'directory.php';
if (isset($_SESSION['loginID'])){
$loginID=$_SESSION['loginID'];
$user = new User(new NamedArguments(array('primaryKey' => $loginID)));
}
if (isset($user) && ($user->isAdmin) && ($user->getOpenSession())){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CORAL Authentication</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/thickbox.css" type="text/css" media="screen" />
<link rel="SHORTCUT ICON" href="images/clownfishfavicon.ico" />
<script type="text/javascript" src="js/plugins/jquery.js"></script>
<script type="text/javascript" src="js/plugins/thickbox.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/plugins/Gettext.js"></script>
<?php
// Add translation for the JavaScript files
global $http_lang;
$str = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2);
$default_l = $lang_name->getLanguage($str);
if($default_l==null || empty($default_l)){$default_l=$str;}
if(isset($_COOKIE["lang"])){
if($_COOKIE["lang"]==$http_lang && $_COOKIE["lang"] != "en_US"){
echo "<link rel='gettext' type='application/x-po' href='./locale/".$http_lang."/LC_MESSAGES/messages.po' />";
}
}else if($default_l==$http_lang && $default_l != "en_US"){
echo "<link rel='gettext' type='application/x-po' href='./locale/".$http_lang."/LC_MESSAGES/messages.po' />";
}
?>
</head>
<body>
<noscript><font face=arial><?= _("JavaScript must be enabled in order for you to use CORAL. However, it seems JavaScript is either disabled or not supported by your browser. To use CORAL, enable JavaScript by changing your browser options, then")." <a href=''>"._("try again")."</a>."?></font></noscript>
<center>
<form name="reportlist" method="post" action="report.php">
<br />
<div style="width:451px; height:91px;background-image:url('images/authtitle.gif');background-repeat:no-repeat;text-align:right;">
</div>
<div class='bordered' style='width:447px;margin-left:2px;'>
<br />
<div class='headerText' style='text-align: left;margin:0px 60px 3px 60px;'><?= _("Users")?></div>
<div class='smallDarkRedText' style='margin-bottom:5px;'>* <?= _("Login ID must match the login ID set up in the modules")?></div>
<div style='text-align:left;margin:0px 60px 60px 60px;' id='div_users'>
<br />
<br />
<img src='images/circle.gif'> <span style='font-size:90%'><?= _("Processing...")?></span>
</div>
</div>
<div class='boxRight'>
<p class="fontText"><?= _("Change language:");?></p>
<select name="lang" id="lang" class="dropDownLang">
<?php
// Get all translations on the 'locale' folder
$route='locale';
$lang[]="en_US"; // add default language
if (is_dir($route)) {
if ($dh = opendir($route)) {
while (($file = readdir($dh)) !== false) {
if (is_dir("$route/$file") && $file!="." && $file!=".."){
$lang[]=$file;
}
}
closedir($dh);
}
}else {
echo "<br>"._("Invalid translation route!");
}
// Get language of navigator
$defLang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2);
// Show an ordered list
sort($lang);
for($i=0; $i<count($lang); $i++){
if(isset($_COOKIE["lang"])){
if($_COOKIE["lang"]==$lang[$i]){
echo "<option value='".$lang[$i]."' selected='selected'>".$lang_name->getNameLang(substr($lang[$i],0,2))."</option>";
}else{
echo "<option value='".$lang[$i]."'>".$lang_name->getNameLang(substr($lang[$i],0,2))."</option>";
}
}else{
if($defLang==substr($lang[$i],0,2)){
echo "<option value='".$lang[$i]."' selected='selected'>".$lang_name->getNameLang(substr($lang[$i],0,2))."</option>";
}else{
echo "<option value='".$lang[$i]."'>".$lang_name->getNameLang(substr($lang[$i],0,2))."</option>";
}
}
}
?>
</select>
</div>
<div class='smallerText' style='text-align:center; margin-top:13px;'><a href='index.php'><?= _("Login page")?></a></div>
</form>
<br />
<br />
</center>
<br />
<br />
<script>
/*
* Functions to change the language with the dropdown
*/
$("#lang").change(function() {
setLanguage($("#lang").val());
location.reload();
});
// Create a cookie with the code of language
function setLanguage(lang) {
var wl = window.location, now = new Date(), time = now.getTime();
var cookievalid=2592000000; // 30 days (1000*60*60*24*30)
time += cookievalid;
now.setTime(time);
document.cookie ='lang='+lang+';path=/'+';domain='+wl.host+';expires='+now;
}
</script>
<script type="text/javascript" src="js/admin.js"></script>
<?php include 'templates/footer.php'; ?>
<?php
}else{
if (isset($user) && $user->getOpenSession()){
header('Location: index.php?service=admin.php&invalid');
}else{
header('Location: index.php?service=admin.php&admin');
}
}
?>