Advertisement
Evyatar12

Untitled

Feb 6th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 7.79 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="he">
  3.  
  4.     <head>
  5.         <meta charset="utf-8" />
  6.  
  7.         <title>
  8.             מתחבר..
  9.         </title>
  10.  
  11.         <link href="css/bootstrap.min.css" rel="stylesheet">
  12.  
  13.         <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  14.  
  15.         <?php
  16.            require("mysql/connector.php");
  17.            connector::openConnection();
  18.        ?>
  19.  
  20.         <style>
  21.             input {
  22.                 position: absolute;
  23.                 right: 200px;
  24.             }
  25.         </style>
  26.     </head>
  27.  
  28.     <body>
  29.  
  30.         <div class="jumbotron" style="background-color: orange;">
  31.             <div class="container text-center">
  32.                 <?php
  33.                    require "tools.php";
  34.  
  35.                    if (tools::checkSession()) {
  36.                        die;
  37.                    }
  38.  
  39.                    // group login (name & password)
  40.                    if (!is_null($_SESSION['id']) && !is_null($_SESSION['name']) && !is_null($_POST['groupName']) &&
  41.                        !is_null($_POST['password'])) {
  42.  
  43.                        function err() {
  44.                            echo "<h2 dir=\"rtl\">
  45. שם קבוצה או סיסמה לא נכונים.
  46.                                 </h2>";
  47.                             header("refresh:1;url=login.php");
  48.                         }
  49.  
  50.                         $id = $_SESSION['id'];
  51.                         $name = $_SESSION['name'];
  52.                         $groupName = $_POST['groupName'];
  53.                         $password = $_POST['password'];
  54.  
  55.                         $query = connector::executeStatement("SELECT normal, group_name FROM IDs WHERE id=$id");
  56.  
  57.                         if (!$query || $query->num_rows != 1) {
  58.                             die("an error has occurred while the system was attempting to retrieve data from database.\n
  59.                                 please reload this page and if this error continues showing contact an administrator." .
  60.                                     mysql_errno());
  61.                         }
  62.  
  63.                         $normal;
  64.  
  65.                         while($r = $query->fetch_assoc()) {
  66.                             $normal = $r['normal'];
  67.  
  68.                             if (strcasecmp($r['group_name'], $groupName) != 0) {
  69.                                 err();
  70.                                 return;
  71.                             }
  72.                             $groupName = $r['group_name'];
  73.                         }
  74.  
  75.                         $sql = "SELECT * FROM ";
  76.  
  77.                         if ($normal == 1) {
  78.                             $sql .= "groups_normal";
  79.                         }
  80.                         else if ($normal == 2) {
  81.                             $sql .= "groups_upper";
  82.                         }
  83.                         else if ($normal == 3) {
  84.                             $sql .= "management";
  85.                         }
  86.                         else {
  87.                             // if nothing is matched.
  88.                             return;
  89.                         }
  90.  
  91.                         $sql .= " WHERE (name='$groupName' AND password='$password');";
  92.  
  93.                         $query = connector::executeStatement($sql);
  94.  
  95.                         if ($query->num_rows == 0) {
  96.                             err();
  97.                             return;
  98.                         }
  99.                         else if ($query->num_rows == 1) {
  100.                             echo "<h2 dir=\"rtl\">
  101.                         התחברת בהצלחה!
  102.                             </h2>";
  103.  
  104.                             $_SESSION['groupName'] = $groupName;
  105.                             $_SESSION['normal'] = $normal;
  106.  
  107.                             header("refresh:1;url=management.php");
  108.                         }
  109.                         else {
  110.                             err();
  111.                         }
  112.                         return;
  113.                     }
  114.  
  115.                     // normal login (with id)
  116.  
  117.                     $id = is_null($_POST["id"]) ? $_SESSION['id'] : $_POST["id"];
  118.  
  119.                     if ($id == null || !is_numeric($id) || strlen($id) != 9) {
  120.                         header("refresh:1;url=index.php");
  121.                         die("
  122.                         <h2 lang=\"he\" dir=\"rtl\">
  123.                         תעודת זהות לא חוקית. תעודת זהות כוללת תשע ספרות.
  124.                         </h2>
  125.                         ");
  126.                     }
  127.  
  128.  
  129.                     $query = connector::executeStatement("SELECT id,name FROM IDs WHERE id=$id;");
  130.  
  131.                     if (!$query) {
  132.                         header("refresh:1;url=index.php");
  133.                         die("
  134.                         <h2 lang=\"he\" dir=\"rtl\">
  135.         חלה שגיאה.
  136.                         </h2>
  137.                         ");
  138.                     }
  139.  
  140.                     if ($query->num_rows == 1) {
  141.                         echo "<h2 lang=\"he\" dir=\"rtl\">
  142.                                     התחברת בהצלחה!
  143.                                             </h2>";
  144.  
  145.                         while($r = $query->fetch_assoc()) {
  146.                             $_SESSION['id']=$r['id'];
  147.                             $_SESSION['name']=$r['name'];
  148.                         }
  149.  
  150.                         $_SESSION['temp'] = true;
  151.                     }
  152.                     else {
  153.                         echo "<h2 lang=\"he\" dir=\"rtl\">
  154.                                         תעודת זהות שגויה.
  155.                                         </h2>";
  156.                         header("refresh:1;url=index.php");
  157.                     }
  158.                 ?>
  159.             </div>
  160.         </div>
  161.  
  162.         <!--   login     -->
  163.  
  164.         <div class="container">
  165.             <?php
  166.                session_start();
  167.  
  168.                if ($_SESSION['temp'] == null || $_SESSION['temp'] != true) {
  169.                    return;
  170.                }
  171.  
  172.                $_SESSION['temp'] = null;
  173.  
  174.                echo "<h4 class=\"text-center\">
  175. אנא הזן את שם הקבוצה שלך ואת הסיסמה שלה
  176.                         </h4>";
  177.                 echo "<hr>";
  178.  
  179.                 $echo =
  180.                     "<form action=\"login.php\" method=\"post\">
  181.                     <div class=\"form-group text-right form-inline\">
  182.                         <input type=\"text\" class=\"form-control\" name=\"groupName\" dir=\"rtl\"/>
  183.                         <label for=\"groupName\">
  184.                         שם קבוצה
  185.                         </label>
  186.                     </div>
  187.  
  188.                     <div class=\"form-group form-inline text-right\">
  189.                      <input type=\"password\" class=\"form-control\" name=\"password\" dir=\"rtl\"/>
  190.  
  191.                         <label for=\"password\">
  192. סיסמה
  193.                         </label>
  194.                     </div>
  195.  
  196.                     <div class=\"form-group\">
  197.                         <input type=\"submit\" class=\"btn btn-success\" dir=\"rtl\" value=\"
  198.             היכנס
  199.            \" />
  200.                     </div>
  201.                 </form>";
  202.  
  203.                 echo $echo;
  204.  
  205.             ?>
  206.         </div>
  207.  
  208.         <br>
  209.         <br>
  210.         <br>
  211.         <br>
  212.  
  213.         <footer>
  214.             <div class="navbar navbar-default navbar-fixed-bottom">
  215.                 <div class="container">
  216.                     <div class="navbar-collapse collapse" id="footer-body">
  217.                         <ul class="nav navbar-nav">
  218.                             <li><a href="#_">&COPY; All rights reserved to Evyatar Itzhaki</a></li>
  219.                         </ul>
  220.                     </div>
  221.                 </div>
  222.             </div>
  223.         </footer>
  224.  
  225.         <script src="js/bootstrap.min.js"></script>
  226.     </body>
  227. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement