-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
246 lines (233 loc) · 8.48 KB
/
index.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
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
<?php session_start();
/*========================================================================
* Open eClass 2.3
* E-learning and Course Management System
* ========================================================================
* Copyright(c) 2003-2010 Greek Universities Network - GUnet
* A full copyright notice can be read in "/info/copyright.txt".
*
* Developers Group: Costas Tsibanis <[email protected]>
* Yannis Exidaridis <[email protected]>
* Alexandros Diamantidis <[email protected]>
* Tilemachos Raptis <[email protected]>
*
* 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
* eMail: [email protected]
* =========================================================================*/
/*
* Index
*
* @version $Id: index.php,v 1.71 2009-12-15 12:45:02 jexi Exp $
*
* @abstract This file serves as the home page of eclass when the user
* is not logged in.
*
*/
/***************************************************************
* HOME PAGE OF ECLASS *
****************************************************************
*/
define ("INDEX_START", 1);
$guest_allowed = true;
$path2add = 0;
include "include/baseTheme.php";
include "modules/auth/auth.inc.php";
//$homePage is used by baseTheme.php to parse correctly the breadcrumb
$homePage = true;
$tool_content = "";
// first check
// check if we can connect to database. If not then eclass is most likely not installed
if (isset($mysqlServer) and isset($mysqlUser) and isset($mysqlPassword)) {
$db = mysql_connect($mysqlServer, $mysqlUser, $mysqlPassword);
if (mysql_version()) mysql_query("SET NAMES utf8");
}
if (!$db) {
include "include/not_installed.php";
}
// unset system that records visitor only once by course for statistics
include('include/action.php');
if (isset($dbname)) {
mysql_select_db($dbname);
$action = new action();
$action->record('MODULE_ID_UNITS', 'exit');
}
unset($dbname);
// second check
// can we select a database? if not then there is some sort of a problem
if (isset($mysqlMainDb)) $selectResult = mysql_select_db($mysqlMainDb,$db);
if (!isset($selectResult)) {
include "include/not_installed.php";
}
//if platform admin allows usage of eclass personalised
//create a session so that each user can activate it for himself.
if (isset($persoIsActive)) {
$_SESSION["perso_is_active"] = $persoIsActive;
}
// if we try to login... then authenticate user.
$warning = '';
if (isset($_SESSION['shib_uname'])) { // authenticate via shibboleth
include 'include/shib_login.php';
} else { // normal authentication
if (isset($_POST['uname'])) {
$uname = escapeSimple(preg_replace('/ +/', ' ', trim($_POST['uname'])));
} else {
$uname = '';
}
$pass = isset($_POST['pass'])?$_POST['pass']:'';
$submit = isset($_POST['submit'])?$_POST['submit']:'';
$auth = get_auth_active_methods();
$is_eclass_unique = is_eclass_unique();
if(!empty($submit)) {
unset($uid);
$sqlLogin= "SELECT user_id, nom, username, password, prenom, statut, email, perso, lang
FROM user WHERE username='".$uname."'";
$result = mysql_query($sqlLogin);
$check_passwords = array("pop3","imap","ldap","db");
$warning = "";
$auth_allow = 0;
$exists = 0;
if (!isset($_COOKIE) or count($_COOKIE) == 0) {
// Disallow login when cookies are disabled
$auth_allow = 5;
} elseif (empty($pass)) {
// Disallow login with empty password
$auth_allow = 4;
} else {
while ($myrow = mysql_fetch_array($result)) {
$exists = 1;
if(!empty($auth)) {
if(!in_array($myrow["password"],$check_passwords)) {
// eclass login
include "include/login.php";
} else {
// alternate methods login
include "include/alt_login.php";
}
} else {
$tool_content .= "<br>$langInvalidAuth<br>";
}
}
}
if(empty($exists) and !$auth_allow) {
$auth_allow = 4;
}
if (!isset($uid)) {
switch($auth_allow) {
case 1 : $warning .= "";
break;
case 2 : $warning .= "<br /><font color='red'>".$langInvalidId ."</font><br />";
break;
case 3 : $warning .= "<br />".$langAccountInactive1." <a href='modules/auth/contactadmin.php?userid=".$user."'>".$langAccountInactive2."</a><br /><br />";
break;
case 4 : $warning .= "<br /><font color='red'>". $langInvalidId . "</font><br />";
break;
case 5 : $warning .= "<br /><font color='red'>". $langNoCookies . "</font><br />";
break;
default:
break;
}
} else {
$warning = '';
$log='yes';
$_SESSION['nom'] = $nom;
$_SESSION['prenom'] = $prenom;
$_SESSION['email'] = $email;
$_SESSION['statut'] = $statut;
$_SESSION['is_admin'] = $is_admin;
$_SESSION['uid'] = $uid;
mysql_query("INSERT INTO loginout (loginout.idLog, loginout.id_user, loginout.ip, loginout.when, loginout.action)
VALUES ('', '$uid', '$_SERVER[REMOTE_ADDR]', NOW(), 'LOGIN')");
}
##[BEGIN personalisation modification]############
//if user has activated the personalised interface
//register a control session for it
if (isset($_SESSION['perso_is_active']) and (isset($userPerso))) {
$_SESSION['user_perso_active'] = $userPerso;
}
##[END personalisation modification]############
} // end of user authentication
}
if (isset($_SESSION['uid'])) {
$uid = $_SESSION['uid'];
} else {
unset($uid);
}
// 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("${webDir}modules/lang/$language/common.inc.php");
$extra_messages = "${webDir}/config/$language.inc.php";
if (file_exists($extra_messages)) {
include $extra_messages;
} else {
$extra_messages = false;
}
include("${webDir}modules/lang/$language/messages.inc.php");
if ($extra_messages) {
include $extra_messages;
}
}
$nameTools = $langWelcomeToEclass;
//----------------------------------------------------------------
// if login succesful display courses lists
// --------------------------------------------------------------
if (isset($uid) AND !isset($logout)) {
$nameTools = $langWelcomeToPortfolio;
$require_help = true;
$helpTopic="Portfolio";
if (isset($_SESSION['user_perso_active']) and $_SESSION['user_perso_active'] == 'no') {
if (!check_guest()){
//if the user is not a guest, load classic view
include "include/logged_in_content.php";
draw($tool_content,1,null,null,null,null,$perso_tool_content);
} else {
//if the user is a guest send him straight to the corresponding lesson
$guestSQL = db_query("SELECT code FROM cours_user, cours
WHERE cours.cours_id = cours_user.cours_id AND
user_id = '". escapeSimple($uid). "'", $mysqlMainDb);
if (mysql_num_rows($guestSQL) > 0) {
$sql_row = mysql_fetch_row($guestSQL);
$dbname=$sql_row[0];
session_register("dbname");
header("location:".$urlServer."courses/$dbname/index.php");
} else { // if course has deleted stop guest account
$warning = "<br><font color='red'>".$langInvalidGuestAccount."</font><br>";
include "include/logged_out_content.php";
draw($tool_content, 0,'index');
}
}
} else {
//load classic view
include "include/classic.php";
draw($tool_content, 1, 'index');
}
} // end of if login
// -------------------------------------------------------------------------------------
// display login page
// -------------------------------------------------------------------------------------
elseif ((isset($logout) && isset($uid)) OR (1==1)) {
if (isset($logout) && isset($uid)) {
mysql_query("INSERT INTO loginout (loginout.idLog, loginout.id_user,
loginout.ip, loginout.when, loginout.action)
VALUES ('', '$uid', '$REMOTE_ADDR', NOW(), 'LOGOUT')");
unset($prenom);
unset($nom);
unset($statut);
unset($_SESSION['uid']);
session_destroy();
}
$require_help = true;
$helpTopic="Init";
include "include/logged_out_content.php";
draw($tool_content, 0,'index');
} // end of display