-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathindex.php
More file actions
290 lines (263 loc) · 11.9 KB
/
index.php
File metadata and controls
290 lines (263 loc) · 11.9 KB
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<?php
session_start();
/* ========================================================================
* Open eClass 3.0
* E-learning and Course Management System
* ========================================================================
* Copyright 2003-2014 Greek Universities Network - GUnet
* A full copyright notice can be read in "/info/copyright.txt".
* For a full list of contributors, see "credits.txt".
*
* Open eClass is an open platform distributed in the hope that it will
* be useful (without any warranty), under the terms of the GNU (General
* Public License) as published by the Free Software Foundation.
* The full license can be read in "/info/license/license_gpl.txt".
*
* Contact address: GUnet Asynchronous eLearning Group,
* Network Operations Center, University of Athens,
* Panepistimiopolis Ilissia, 15784, Athens, Greece
* e-mail: info@openeclass.org
* ======================================================================== */
/*
* @file index.php
*
* @abstract This file serves as the home page of eclass when the user
* is not logged in.
*
*/
define('HIDE_TOOL_TITLE', 1);
$guest_allowed = true;
require_once 'include/baseTheme.php';
require_once 'include/CAS/CAS.php';
require_once 'modules/auth/auth.inc.php';
require_once 'include/lib/textLib.inc.php';
require_once 'include/phpass/PasswordHash.php';
// unset system that records visitor only once by course for statistics
require_once 'include/action.php';
if (isset($dbname)) {
$action = new action();
$action->record('MODULE_ID_UNITS', 'exit');
}
unset($dbname);
// if we try to login... then authenticate user.
$warning = '';
if (isset($_SESSION['shib_uname'])) {
// authenticate via shibboleth
shib_cas_login('shibboleth');
} elseif (isset($_SESSION['cas_uname']) && !isset($_GET['logout'])) {
// authenticate via cas
shib_cas_login('cas');
} else {
// normal authentication
process_login();
}
if (isset($_SESSION['uid'])) {
$uid = $_SESSION['uid'];
} else {
$uid = 0;
}
if (isset($_GET['logout']) and $uid) {
Database::get()->query("INSERT INTO loginout (loginout.id_user,
loginout.ip, loginout.when, loginout.action)
VALUES (?d, ?s, NOW(), 'LOGOUT')", $uid, $_SERVER['REMOTE_ADDR']);
if (isset($_SESSION['cas_uname'])) { // if we are CAS user
define('CAS', true);
}
foreach (array_keys($_SESSION) as $key) {
unset($_SESSION[$key]);
}
session_destroy();
$uid = 0;
if (defined('CAS')) {
$cas = get_auth_settings(7);
if (isset($cas['cas_ssout']) and intval($cas['cas_ssout']) === 1) {
phpCAS::client(SAML_VERSION_1_1, $cas['cas_host'], intval($cas['cas_port']), $cas['cas_context'], FALSE);
phpCAS::logoutWithRedirectService($urlServer);
}
}
}
// if the user logged in include the correct language files
// in case he has a different language set in his/her profile
if (isset($language)) {
// include_messages
include "lang/$language/common.inc.php";
$extra_messages = "config/{$language_codes[$language]}.inc.php";
if (file_exists($extra_messages)) {
include $extra_messages;
} else {
$extra_messages = false;
}
include "lang/$language/messages.inc.php";
if ($extra_messages) {
include $extra_messages;
}
}
// check if we are guest user
if ($uid AND !isset($_GET['logout'])) {
if (check_guest()) {
// if the user is a guest send him straight to the corresponding lesson
$guest = Database::get()->querySingle("SELECT code FROM course_user, course
WHERE course.id = course_user.course_id AND
user_id = ?d", $uid);
if ($guest) {
$dbname = $guest->code;
$_SESSION['dbname'] = $dbname;
header("Location: {$urlServer}courses/$dbname/index.php");
exit;
}
}
// if user is not guest redirect him to portfolio
header("Location: {$urlServer}main/portfolio.php");
} else {
// check for shibboleth authentication
$shibboleth_link = "";
$shibactive = Database::get()->querySingle("SELECT auth_default FROM auth WHERE auth_name='shibboleth'");
if ($shibactive) {
if ($shibactive->auth_default == 1) {
$shibboleth_link = "<a href='{$urlSecure}secure/index.php'>$langShibboleth</a><br />";
}
}
// check for CAS authentication
$cas_link = "";
$casactive = Database::get()->querySingle("SELECT auth_default FROM auth WHERE auth_name='cas'");
if ($casactive) {
if ($casactive->auth_default == 1) {
$cas_link = "<a href='{$urlServer}secure/cas.php'>$langViaCAS</a><br />";
}
}
if (!get_config('dont_display_login_form')) {
$head_content .= "
<script>
$(function() {
$('#revealPass')
.mousedown(function() {
$('#pass').attr('type', 'text');
})
.mouseup(function() {
$('#pass').attr('type', 'password');
})
});
</script>
";
$tool_content .= "
<div class='row margin-top-fat'>
<div class='col-md-12 remove-gutter'>
<div class='jumbotron jumbotron-login'>
<div class='row'>
<div class='hidden-xs col-sm-6 col-md-7 graphic'>
</div>
<div class='login-form col-xs-12 col-sm-6 col-md-5 col-lg-4 pull-right'>
<h2>$langUserLogin</h2>
<form action='$urlSecure' method='post'>
<div class='form-group'>
<input autofocus type='text' name='uname' placeholder='$langUsername'><label class='col-xs-2 col-sm-2 col-md-2'><i class='fa fa-user'></i></label>
</div>
<div class='form-group'>
<input type='password' id='pass' name='pass' placeholder='$langPass'><i id='revealPass' class='fa fa-eye' style='margin-left:-20px;color:black;'></i>  <label class='col-xs-2 col-sm-2 col-md-2'><i class='fa fa-lock'></i></label>
</div>
<button type='submit' name='submit' class='btn btn-login'>$langEnter</button>
</form>
<div class='login-settings row'>
<div class='text-center'>
<a href='modules/auth/lostpass.php'>$lang_forgot_pass</a>
</div>
<hr>";
if (!empty($shibboleth_link) or !empty($cas_link)) {
$tool_content .= "<div class='alt_login text-center'>
<span>$langAlternateLogin :</span>";
if(!empty($cas_link)){ $tool_content.= "<span>$cas_link</span>";}
if(!empty($shibboleth_link)){ $tool_content.= "<span>$shibboleth_link</span>";}
$tool_content .= "</div>";
}
$tool_content .= " </div>";
if(!empty($warning)){ $tool_content.= "<br><span>$warning</span>";}
$tool_content .= "</div>
</div>
</div>
</div>
</div>";
$rss_link = "<link rel='alternate' type='application/rss+xml' title='RSS-Feed' href='" .
$urlServer . "rss.php'>";
$announceArr = Database::get()->queryArray("SELECT `id`, `date`, `title`, `body`, `order` FROM `admin_announcement`
WHERE `visible` = 1
AND lang=?s
AND (`begin` <= NOW() or `begin` IS null)
AND (NOW() <= `end` or `end` IS null)
ORDER BY `order` DESC", $language);
$ann_content = '';
if ($announceArr && sizeof($announceArr) > 0) {
$ann_content .= "<h4>$langAnnouncements <a href='${urlServer}rss.php' style='padding-left:5px;'>
<i class='fa fa-rss-square'></i>
</a></h4><ul class='front-announcements'>";
$numOfAnnouncements = sizeof($announceArr);
for ($i = 0; $i < $numOfAnnouncements; $i++) {
$aid = $announceArr[$i]->id;
$ann_content .= "
<li>
<div><a class='announcement-title' href='modules/announcements/main_ann.php?aid=$aid'>" . q($announceArr[$i]->title) . "</a></div>
<span class='announcement-date'>- " . claro_format_locale_date($dateFormatLong, strtotime($announceArr[$i]->date)) . " -</span>
" . standard_text_escape(ellipsize_html($announceArr[$i]->body, 500, "<div class='announcements-more'><a href='modules/announcements/main_ann.php?aid=$aid'>$langMore …</a></div>"))."</li>";
}
}
$tool_content .= "
<div class='row'>
<div class='col-md-8'>
<div class='panel'>
<div class='panel-body'>
$langInfoAbout
</div>
</div>
<div class='panel'>
<div class='panel-body'>";
if(!empty($ann_content)){
$tool_content .= $ann_content;
}else{
$tool_content .= "<li>$langNoRecentAnnounce</li>";
}
$tool_content.="</ul></div>
</div>
</div>
<div class='col-md-4'>
";
$online_users = getOnlineUsers();
$tool_content .= "
<div class='panel'>
<div class='panel-body'>
<i class='fa fa-group space-after-icon'></i>$langOnlineUsers: $online_users
</div>
</div>";
if (get_config('opencourses_enable')) {
$tool_content .= "<div class='panel'>
<div class='panel-body'>
<a href='http://opencourses.gr'>
<img class='img-responsive' src='$themeimg/open_courses_bnr.png'>
</a>
</div>
</div>";
}
if (get_config('enable_mobileapi')) {
$tool_content .= "<div class='panel mobile-apps'>
<div class='panel-body'>
<div class='row'>
<div class='col-xs-6'>
<a href='https://itunes.apple.com/us/app/open-eclass-mobile/id796936702' target=_blank><img src='appstore.png' class='img-responsive center-block' alt='Available on the App Store'></a>
</div>
<div class='col-xs-6'>
<a href='https://play.google.com/store/apps/details?id=gr.gunet.eclass' target=_blank><img src='playstore.png' class='img-responsive center-block' alt='Available on the Play Store'></a>
</div>
</div></div>
</div>";
}
$tool_content .= "
<div class='panel'>
<div class='panel-body'>
<a href='http://www.openeclass.org/'>
<img class='img-responsive center-block' src='$themeimg/open_eclass_bnr.png'>
</a>
</div>
</div>
</div>
</div>";
}
draw($tool_content, 0, null, $rss_link.$head_content);
}