Advertisement
Guest User

Untitled

a guest
Apr 6th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.01 KB | None | 0 0
  1. <?php
  2. require_once('.' . DIRECTORY_SEPARATOR . "app" . DIRECTORY_SEPARATOR . "boot.php");
  3.  
  4.  
  5. /*if (isset($_SESSION['student'])) {
  6. header("Location: students/index.php");
  7. }
  8. if (isset($_SESSION['teacher'])) {
  9. header("Location: teachers/index.php");
  10. }
  11. if (isset($_SESSION['parent'])) {
  12. header("Location: parents/index.php");
  13. }*/
  14.  
  15. $stmt = $connect->query("SELECT close_site FROM control");
  16. $row = $stmt->fetch();
  17. $mode = $row['close_site'];
  18.  
  19. if ($mode == 0 ) {
  20. header("Location: close.php");
  21. die();
  22. }
  23.  
  24.  
  25. ?>
  26.  
  27.  
  28.  
  29. <!DOCTYPE html>
  30. <html>
  31. <head>
  32.  
  33. <meta charset="utf-8">
  34. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  35. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  36. <meta name="description" content="">
  37. <meta name="author" content="">
  38. <link rel="icon" href="../../favicon.ico">
  39.  
  40. <title><?php echo $language['main_title'];?></title>
  41. <!-- Bootstrap Core CSS -->
  42. <link href="css/bootstrap-theme.css" rel="stylesheet">
  43. <link href="css/bootstrap.min.css" rel="stylesheet">
  44. <link href="css/style.css" rel="stylesheet">
  45. <link href="css/home_style.css" rel="stylesheet">
  46.  
  47.  
  48. <!-- javascript -->
  49. <link href="libs/validationEngine/validationEngine.jquery.css" rel="stylesheet">
  50.  
  51. <?php
  52. if (isset($_SESSION['english'])) {
  53. echo '<link href="libs/validationEngine/languages/jquery.validationEngine-en.css" rel="stylesheet"/>';
  54. }
  55. if (isset($_SESSION['shqip'])) {
  56. echo '<link href="libs/validationEngine/languages/jquery.validationEngine-sq.css" rel="stylesheet"/>';
  57. }
  58.  
  59. ?>
  60. <script>
  61.  
  62. $(function()
  63. $("#login_students").validationEngine();
  64. $("#login_teachers").validationEngine();
  65. $("#login_parents").validationEngine();
  66.  
  67. });
  68.  
  69.  
  70. </script>
  71.  
  72.  
  73.  
  74. </head>
  75. <body>
  76.  
  77.  
  78. <div class="navbar navbar-default">
  79. <div class="container">
  80. <form id="language" action="" method="POST">
  81. <input type="submit" name="en" value="english" class="english">
  82. <input type="submit" name="sq" value="shqip" class="shqip">
  83. </form>
  84.  
  85. </div>
  86. </div>
  87.  
  88. <div class="container main">
  89.  
  90. <?php
  91. if(isset($_POST['submit_students'])){
  92. $student_name = htmlspecialchars($_POST['student_name']);
  93. $student_pass = htmlspecialchars(md5($_POST['student_pass']));
  94.  
  95. $stmt_login = $connect->prepare("SELECT * FROM students_users WHERE username = :student_name and password = :student_pass");
  96. $stmt_login->bindParam(':student_name', $student_name, PDO::PARAM_STR);
  97. $stmt_login->bindParam(':student_pass', $student_pass, PDO::PARAM_STR);
  98. $stmt_login->execute();
  99.  
  100.  
  101. if ($stmt_login->rowCount() == 1) {
  102. $row = $stmt_login->fetch();
  103. $user = $row['username'];
  104. $pass = $row['password'];
  105. $student_index = $row['student_index'];
  106.  
  107.  
  108. if ($user == $student_name and $pass == $student_pass) {
  109. $_SESSION['student'] = $user;
  110. $_SESSION['student_index'] = $student_index;
  111.  
  112. $token_rand = uniqid(rand());
  113. $_SESSION['token'] = $token_rand;
  114.  
  115. header("Location: students/index.php");
  116. }
  117.  
  118. }
  119. else {
  120. header("Location: index.php?login=error");
  121. }
  122.  
  123.  
  124.  
  125.  
  126. }
  127.  
  128.  
  129.  
  130.  
  131. if(isset($_POST['submit_teachers'])){
  132. $teacher_name = htmlspecialchars($_POST['teacher_name']);
  133. $teacher_pass = htmlspecialchars(md5($_POST['teacher_pass']));
  134.  
  135. $stmt_login = $connect->prepare("SELECT * FROM teachers_users WHERE username = :teacher_name and password = :teacher_pass");
  136. $stmt_login->bindParam(':teacher_name', $teacher_name, PDO::PARAM_STR);
  137. $stmt_login->bindParam(':teacher_pass', $teacher_pass, PDO::PARAM_STR);
  138. $stmt_login->execute();
  139.  
  140.  
  141. if ($stmt_login->rowCount() == 1) {
  142. $row = $stmt_login->fetch();
  143. $user = $row['username'];
  144. $pass = $row['password'];
  145. $teacher_index = $row['teacher_index'];
  146.  
  147.  
  148. if ($user == $teacher_name and $pass == $teacher_pass) {
  149. $_SESSION['teacher'] = $user;
  150. $_SESSION['teacher_index'] = $teacher_index;
  151.  
  152. $token_rand = uniqid(rand());
  153. $_SESSION['token'] = $token_rand;
  154.  
  155. header("Location: teachers/index.php");
  156. }
  157.  
  158. }
  159. else {
  160. header("Location: index.php?login=error");
  161. }
  162. }
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. if(isset($_POST['submit_parents'])){
  170. $parent_name = htmlspecialchars($_POST['parent_name']);
  171. $parent_pass = htmlspecialchars(md5($_POST['parent_pass']));
  172.  
  173. $stmt_login = $connect->prepare("SELECT * FROM parents_users WHERE username = :parent_name and password = :parent_pass");
  174. $stmt_login->bindParam(':parent_name', $parent_name, PDO::PARAM_STR);
  175. $stmt_login->bindParam(':parent_pass', $parent_pass, PDO::PARAM_STR);
  176. $stmt_login->execute();
  177.  
  178.  
  179. if ($stmt_login->rowCount() == 1) {
  180. $row = $stmt_login->fetch();
  181. $user = $row['username'];
  182. $pass = $row['password'];
  183. $parent_index = $row['parent_index'];
  184.  
  185.  
  186. if ($user == $parent_name and $pass == $parent_pass) {
  187. $_SESSION['parent'] = $user;
  188. $_SESSION['parent_index'] = $parent_index;
  189.  
  190. $token_rand = uniqid(rand());
  191. $_SESSION['token'] = $token_rand;
  192.  
  193. header("Location: parents/index.php");
  194. }
  195.  
  196. }
  197. else {
  198. header("Location: index.php?login=error");
  199. }
  200. }
  201.  
  202.  
  203. ?>
  204.  
  205.  
  206. <div class="clear"></div>
  207. <div class="col-md-8 col-md-offset-2">
  208. <center><h2><?php echo $language['main_title'];?></h2>
  209. <div class="login">
  210. <h1><?php echo $language['log-in'] ?> </h1>
  211. <?php
  212. if (isset($_GET['login']) == "error") {
  213. echo "<div class='alert alert-danger center'> <p>". $language['username_or_password_error']."</p></div>";
  214. }
  215.  
  216.  
  217. ?>
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224. <button class="button" data-toggle="modal" data-target="#TeacherLogin" ><span>Teacher </span></button>
  225. <button class="button" data-toggle="modal" data-target="#StudentLogin"><span>Student </span></button>
  226. <button class="button" data-toggle="modal" data-target="#ParentLogin"><span>Parent </span></button>
  227.  
  228. </center>
  229.  
  230. <div class="container main">
  231.  
  232. <div class="clear"></div>
  233.  
  234. <br>
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241. <!-- Teacher Login Form -->
  242.  
  243. <div class="modal fade" id="TeacherLogin" tabindex="-1" role="dialog" aria-labelledby="TeacherLogin" aria-hidden="true" style="display: none;">
  244. <div class="modal-dialog">
  245. <div class="loginmodal-container">
  246. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  247. <hr>
  248. <h1>Welcome to Teacher Login</h1><br>
  249. <form id="login_teacher" action="" method="post">
  250. <input type="text" name="teacher_name" class = "validate[required]" placeholder="<?php echo $language['username']; ?>"/>
  251. <input type="password" name="teacher_pass" class = "validate[required]" placeholder="<?php echo $language['password']; ?>"/>
  252. <input type="submit" name="submit_teachers" class="login loginmodal-submit" value="<?php echo $language['login']?>"/>
  253. </form>
  254. <div class="login-help">
  255. <a href="#">Forgot Password</a>
  256. </div>
  257. <hr>
  258. </div>
  259.  
  260. </div>
  261. </div>
  262.  
  263.  
  264. <!-- Student Login Form -->
  265.  
  266. <div class="modal fade" id="StudentLogin" tabindex="-1" role="dialog" aria-labelledby="StudentLogin" aria-hidden="true" style="display: none;">
  267. <div class="modal-dialog">
  268. <div class="loginmodal-container">
  269. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  270. <hr>
  271. <h1>Welcome to Student Login</h1><br>
  272. <form id="login_student" action="" method="post">
  273. <input type="text" name="student_name" class = "validate[required]" placeholder="<?php echo $language['username']; ?>"/>
  274. <input type="password" name="student_pass" placeholder="<?php echo $language['password']; ?>"/>
  275. <input type="submit" name="submit_students" class="login loginmodal-submit" value="<?php echo $language['login']?>"/>
  276. </form>
  277.  
  278. <div class="login-help">
  279. <a href="#">Forgot Password</a>
  280. </div>
  281. <hr>
  282. </div>
  283.  
  284. </div>
  285. </div>
  286. <!-- Parents Login Form -->
  287.  
  288. <div class="modal fade" id="ParentLogin" tabindex="-1" role="dialog" aria-labelledby="ParentLogin" aria-hidden="true" style="display: none;">
  289. <div class="modal-dialog">
  290. <div class="loginmodal-container">
  291. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  292. <hr>
  293. <h1>Welcome to Student Login</h1><br>
  294. <form id="login_parent" action="" method="post">
  295. <input type="text" name="parent_name" class = "validate[required]" placeholder="<?php echo $language['username']; ?>"/>
  296. <input type="password" name="parent_pass" placeholder="<?php echo $language['password']; ?>"/>
  297. <input type="submit" name="submit_parents" class="login loginmodal-submit" value="<?php echo $language['login']?>"/>
  298. </form>
  299.  
  300. <div class="login-help">
  301. <a href="#">Forgot Password</a>
  302. </div>
  303. <hr>
  304. </div>
  305.  
  306. </div>
  307.  
  308. </div>
  309.  
  310.  
  311.  
  312. <!-- jQuery -->
  313. <script src="js/jquery.min.js"></script>
  314.  
  315. <!-- Bootstrap Core JavaScript -->
  316. <script src="js/bootstrap.min.js"></script>
  317.  
  318. <!-- Initialize Bootstrap functionality -->
  319. <script>
  320. // Initialize tooltip component
  321. $(function () {
  322. $('[data-toggle="tooltip"]').tooltip()
  323. })
  324.  
  325. // Initialize popover component
  326. $(function () {
  327. $('[data-toggle="popover"]').popover()
  328. })
  329. </script>
  330.  
  331.  
  332.  
  333. </body>
  334. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement