Skylar Ittner 1 year ago
parent
commit
6cf831eaf3
4 changed files with 70 additions and 15 deletions
  1. 8
    3
      app.php
  2. 8
    5
      index.php
  3. 1
    0
      lang/en_us.php
  4. 53
    7
      static/js/app.js

+ 8
- 3
app.php View File

@@ -92,9 +92,14 @@ header("Link: <static/js/bootstrap.min.js>; rel=preload; as=script", false);
92 92
             echo <<<END
93 93
             <div class="row justify-content-center" id="msg-alert-box">
94 94
                 <div class="col-11 col-sm-6 col-md-5 col-lg-4 col-xl-4">
95
-                    <div class="alert alert-dismissible alert-$alerttype">
96
-                        <button type="button" class="close">&times;</button>
97
-                        <i class="fas fa-$alerticon"></i> $alertmsg
95
+                    <div class="alert alert-dismissible alert-$alerttype mt-2 p-0 border-0 shadow">
96
+                        <div class="p-2 pl-3">
97
+                            <button type="button" class="close">&times;</button>
98
+                            <i class="fas fa-$alerticon"></i> $alertmsg
99
+                        </div>
100
+                        <div class="progress">
101
+                            <div class="progress-bar bg-$alerttype w-0" id="msg-alert-timeout-bar"></div>
102
+                        </div>
98 103
                     </div>
99 104
                 </div>
100 105
             </div>

+ 8
- 5
index.php View File

@@ -1,5 +1,4 @@
1 1
 <?php
2
-
3 2
 /* This Source Code Form is subject to the terms of the Mozilla Public
4 3
  * License, v. 2.0. If a copy of the MPL was not distributed with this
5 4
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -9,15 +8,19 @@ require_once __DIR__ . "/required.php";
9 8
 require_once __DIR__ . "/lib/login.php";
10 9
 
11 10
 // if we're logged in, we don't need to be here.
12
-if ($_SESSION['loggedin']) {
11
+if (!empty($_SESSION['loggedin']) && $_SESSION['loggedin'] === true && !isset($_GET['permissionerror'])) {
13 12
     header('Location: app.php');
14 13
 }
15 14
 
15
+if (isset($_GET['permissionerror'])) {
16
+    $alert = lang("no access permission", false);
17
+}
18
+
16 19
 /* Authenticate user */
17 20
 $userpass_ok = false;
18 21
 $multiauth = false;
19 22
 if (checkLoginServer()) {
20
-    if ($VARS['progress'] == "1") {
23
+    if (!empty($VARS['progress']) && $VARS['progress'] == "1") {
21 24
         if (!CAPTCHA_ENABLED || (CAPTCHA_ENABLED && verifyCaptcheck($VARS['captcheck_session_code'], $VARS['captcheck_selected_answer'], CAPTCHA_SERVER . "/api.php"))) {
22 25
             $errmsg = "";
23 26
             if (authenticate_user($VARS['username'], $VARS['password'], $errmsg)) {
@@ -58,7 +61,7 @@ if (checkLoginServer()) {
58 61
         } else {
59 62
             $alert = lang("captcha error", false);
60 63
         }
61
-    } else if ($VARS['progress'] == "2") {
64
+    } else if (!empty($VARS['progress']) && $VARS['progress'] == "2") {
62 65
         if ($_SESSION['passok'] !== true) {
63 66
             // stop logins using only username and authcode
64 67
             sendError("Password integrity check failed!");
@@ -114,7 +117,7 @@ header("Link: <static/js/bootstrap.min.js>; rel=preload; as=script", false);
114 117
                     <h5 class="card-title"><?php lang("sign in"); ?></h5>
115 118
                     <form action="" method="POST">
116 119
                         <?php
117
-                        if (!is_empty($alert)) {
120
+                        if (!empty($alert)) {
118 121
                             ?>
119 122
                             <div class="alert alert-danger">
120 123
                                 <i class="fa fa-fw fa-exclamation-triangle"></i> <?php echo $alert; ?>

+ 1
- 0
lang/en_us.php View File

@@ -30,6 +30,7 @@ define("STRINGS", [
30 30
     "login server error" => "The login server returned an error: {arg}",
31 31
     "login server user data error" => "The login server refused to provide account information.  Try again or contact technical support.",
32 32
     "captcha error" => "There was a problem with the CAPTCHA (robot test).  Try again.",
33
+    "no access permission" => "You do not have permission to access this system.",
33 34
     "home" => "Home",
34 35
     "more" => "More",
35 36
     "punch in out" => "Punch In/Out",

+ 53
- 7
static/js/app.js View File

@@ -8,13 +8,59 @@ $(document).ready(function () {
8 8
         $(this).parent().fadeOut("slow");
9 9
     });
10 10
 
11
-    try {
12
-        window.history.replaceState("", "", getniceurl());
13
-        if (window.location.hash) {
14
-            document.getElementById(window.location.hash.replace("#", "")).scrollIntoView();
15
-        }
16
-    } catch (ex) {
11
+    if ($("#msg-alert-box").length) {
12
+        $("#msg-alert-box .progress").css("height", "3px");
13
+        $("#msg-alert-box .progress").css("border-radius", "0px 0px .25rem .25rem");
14
+        $("#msg-alert-box .progress-bar").css("transition", "width 0.25s linear");
15
+        var msginteractiontick = 0;
16
+        var fifty = 10;
17
+        var gone = 20;
17 18
 
19
+        var msgticker = setInterval(function () {
20
+            if ($('#msg-alert-box .alert:hover').length) {
21
+                msginteractiontick = 0;
22
+            } else {
23
+                msginteractiontick++;
24
+            }
25
+            if (msginteractiontick > 0) {
26
+                function setBarWidth(offset) {
27
+                    $("#msg-alert-timeout-bar").css("width", (msginteractiontick + offset) / gone * 100 + "%");
28
+                }
29
+                setBarWidth(-1 + .25);
30
+                setTimeout(function () {
31
+                    setBarWidth(-1 + .5);
32
+                }, 250);
33
+                setTimeout(function () {
34
+                    setBarWidth(-1 + .75);
35
+                }, 500);
36
+                setTimeout(function () {
37
+                    setBarWidth(0);
38
+                }, 750);
39
+            } else {
40
+                $("#msg-alert-timeout-bar").css("width", "0%");
41
+            }
42
+
43
+            if (msginteractiontick < fifty) {
44
+                $("#msg-alert-box .alert").css("opacity", "1");
45
+            }
46
+            if (msginteractiontick == fifty) {
47
+                $("#msg-alert-box .alert").fadeTo(1000, 0.5);
48
+            }
49
+            if (msginteractiontick >= gone) {
50
+                setTimeout(function () {
51
+                    if (msginteractiontick >= gone) {
52
+                        $("#msg-alert-box .alert").fadeOut("slow");
53
+                        window.clearInterval(msgticker);
54
+                    }
55
+                }, 1000);
56
+            }
57
+        }, 1000 * 1);
58
+
59
+        $("#msg-alert-box").on("mouseenter", function () {
60
+            $("#msg-alert-box .alert").css("opacity", "1");
61
+            msginteractiontick = 0;
62
+            console.log("👈😎👈 zoop");
63
+        });
18 64
     }
19 65
 });
20 66
 
@@ -32,4 +78,4 @@ try {
32 78
     window.history.replaceState("", "", getniceurl());
33 79
 } catch (ex) {
34 80
 
35
-}
81
+}

Loading…
Cancel
Save