Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="he">
- <head>
- <meta charset="utf-8" />
- <title>
- מתחבר..
- </title>
- <link href="css/bootstrap.min.css" rel="stylesheet">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
- <?php
- require("mysql/connector.php");
- connector::openConnection();
- ?>
- <style>
- input {
- position: absolute;
- right: 200px;
- }
- </style>
- </head>
- <body>
- <div class="jumbotron" style="background-color: orange;">
- <div class="container text-center">
- <?php
- require "tools.php";
- if (tools::checkSession()) {
- die;
- }
- // group login (name & password)
- if (!is_null($_SESSION['id']) && !is_null($_SESSION['name']) && !is_null($_POST['groupName']) &&
- !is_null($_POST['password'])) {
- function err() {
- echo "<h2 dir=\"rtl\">
- שם קבוצה או סיסמה לא נכונים.
- </h2>";
- header("refresh:1;url=login.php");
- }
- $id = $_SESSION['id'];
- $name = $_SESSION['name'];
- $groupName = $_POST['groupName'];
- $password = $_POST['password'];
- $query = connector::executeStatement("SELECT normal, group_name FROM IDs WHERE id=$id");
- if (!$query || $query->num_rows != 1) {
- die("an error has occurred while the system was attempting to retrieve data from database.\n
- please reload this page and if this error continues showing contact an administrator." .
- mysql_errno());
- }
- $normal;
- while($r = $query->fetch_assoc()) {
- $normal = $r['normal'];
- if (strcasecmp($r['group_name'], $groupName) != 0) {
- err();
- return;
- }
- $groupName = $r['group_name'];
- }
- $sql = "SELECT * FROM ";
- if ($normal == 1) {
- $sql .= "groups_normal";
- }
- else if ($normal == 2) {
- $sql .= "groups_upper";
- }
- else if ($normal == 3) {
- $sql .= "management";
- }
- else {
- // if nothing is matched.
- return;
- }
- $sql .= " WHERE (name='$groupName' AND password='$password');";
- $query = connector::executeStatement($sql);
- if ($query->num_rows == 0) {
- err();
- return;
- }
- else if ($query->num_rows == 1) {
- echo "<h2 dir=\"rtl\">
- התחברת בהצלחה!
- </h2>";
- $_SESSION['groupName'] = $groupName;
- $_SESSION['normal'] = $normal;
- header("refresh:1;url=management.php");
- }
- else {
- err();
- }
- return;
- }
- // normal login (with id)
- $id = is_null($_POST["id"]) ? $_SESSION['id'] : $_POST["id"];
- if ($id == null || !is_numeric($id) || strlen($id) != 9) {
- header("refresh:1;url=index.php");
- die("
- <h2 lang=\"he\" dir=\"rtl\">
- תעודת זהות לא חוקית. תעודת זהות כוללת תשע ספרות.
- </h2>
- ");
- }
- $query = connector::executeStatement("SELECT id,name FROM IDs WHERE id=$id;");
- if (!$query) {
- header("refresh:1;url=index.php");
- die("
- <h2 lang=\"he\" dir=\"rtl\">
- חלה שגיאה.
- </h2>
- ");
- }
- if ($query->num_rows == 1) {
- echo "<h2 lang=\"he\" dir=\"rtl\">
- התחברת בהצלחה!
- </h2>";
- while($r = $query->fetch_assoc()) {
- $_SESSION['id']=$r['id'];
- $_SESSION['name']=$r['name'];
- }
- $_SESSION['temp'] = true;
- }
- else {
- echo "<h2 lang=\"he\" dir=\"rtl\">
- תעודת זהות שגויה.
- </h2>";
- header("refresh:1;url=index.php");
- }
- ?>
- </div>
- </div>
- <!-- login -->
- <div class="container">
- <?php
- session_start();
- if ($_SESSION['temp'] == null || $_SESSION['temp'] != true) {
- return;
- }
- $_SESSION['temp'] = null;
- echo "<h4 class=\"text-center\">
- אנא הזן את שם הקבוצה שלך ואת הסיסמה שלה
- </h4>";
- echo "<hr>";
- $echo =
- "<form action=\"login.php\" method=\"post\">
- <div class=\"form-group text-right form-inline\">
- <input type=\"text\" class=\"form-control\" name=\"groupName\" dir=\"rtl\"/>
- <label for=\"groupName\">
- שם קבוצה
- </label>
- </div>
- <div class=\"form-group form-inline text-right\">
- <input type=\"password\" class=\"form-control\" name=\"password\" dir=\"rtl\"/>
- <label for=\"password\">
- סיסמה
- </label>
- </div>
- <div class=\"form-group\">
- <input type=\"submit\" class=\"btn btn-success\" dir=\"rtl\" value=\"
- היכנס
- \" />
- </div>
- </form>";
- echo $echo;
- ?>
- </div>
- <br>
- <br>
- <br>
- <br>
- <footer>
- <div class="navbar navbar-default navbar-fixed-bottom">
- <div class="container">
- <div class="navbar-collapse collapse" id="footer-body">
- <ul class="nav navbar-nav">
- <li><a href="#_">© All rights reserved to Evyatar Itzhaki</a></li>
- </ul>
- </div>
- </div>
- </div>
- </footer>
- <script src="js/bootstrap.min.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement