|
4 | 4 |
|
5 | 5 | date_default_timezone_set('Asia/Taipei'); |
6 | 6 |
|
7 | | -$host = $_SERVER['HTTP_HOST']; |
8 | | -$ruta = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); |
9 | | -$url = "http://$host$ruta"; |
10 | | - |
11 | 7 | if (isset($_POST["cancel"])) { |
12 | | - header("Location: $url/index.php"); |
| 8 | + header("Location: ./index.php"); |
13 | 9 | die(); |
14 | 10 | } |
15 | 11 |
|
16 | 12 | if (isset($_COOKIE['email']) && isset($_COOKIE['password'])) { |
17 | | - unset($SESSION["username"]); |
18 | | - unset($SESSION["user_id"]); |
| 13 | + unset($_SESSION["username"]); |
| 14 | + unset($_SESSION["user_id"]); |
19 | 15 | session_destroy(); |
20 | 16 | session_start(); |
21 | 17 | $salt = getenv('SALT'); |
|
36 | 32 | if ($row['disabled'] === "True") { |
37 | 33 | $_SESSION["error"] = "Account disabled"; |
38 | 34 | error_log("Login fail disabled account " . $_COOKIE['email'] . " " . $ip . " (" . date(DATE_RFC2822) . ")\n", 3, "./logs/logs.log"); |
39 | | - header("Location: $url/login.php"); |
| 35 | + header("Location: ./login.php"); |
40 | 36 | die(); |
41 | 37 | } |
42 | 38 | if ($_COOKIE['email'] == 'g4o2@protonmail.com' || $_COOKIE['email'] == 'g4o3@protonmail.com' || $_POST["email"] == 'maxhu787@gmail.com') { |
|
48 | 44 | $_SESSION["username"] = $row["username"]; |
49 | 45 | $_SESSION['email'] = $row['email']; |
50 | 46 | $_SESSION["success"] = "Logged in."; |
51 | | - if(isset($_GET['page'])) { |
52 | | - if($_GET['page'] == 'chat') { |
53 | | - header("Location: $url/chat/chat.php"); |
| 47 | + if (isset($_GET['page'])) { |
| 48 | + if ($_GET['page'] == 'chat') { |
| 49 | + header("Location: ./chat/chat.php"); |
54 | 50 | } |
55 | 51 | } else { |
56 | | - header("Location: $url/index.php"); |
| 52 | + header("Location: ./index.php"); |
57 | 53 | } |
58 | 54 | die(); |
59 | 55 | } else { |
60 | 56 | $_SESSION["error"] = "Incorrect email or password"; |
61 | 57 | error_log("Login fail wrong password " . $_COOKIE['email'] . " " . $check . " " . $ip . " (" . date(DATE_RFC2822) . ")\n", 3, "./logs/logs.log"); |
62 | | - header("Location: $url/login.php"); |
| 58 | + header("Location: ./login.php"); |
63 | 59 | die(); |
64 | 60 | } |
65 | 61 | } |
66 | 62 |
|
67 | 63 | if (isset($_POST["email"]) && isset($_POST["pass"])) { |
68 | | - unset($SESSION["username"]); |
69 | | - unset($SESSION["user_id"]); |
| 64 | + unset($_SESSION["username"]); |
| 65 | + unset($_SESSION["user_id"]); |
70 | 66 | session_destroy(); |
71 | 67 | session_start(); |
72 | 68 | $salt = getenv('SALT'); |
|
87 | 83 | if ($row['disabled'] === "True") { |
88 | 84 | $_SESSION["error"] = "Account disabled"; |
89 | 85 | error_log("Login fail disabled account " . $_POST['email'] . " " . $ip . " (" . date(DATE_RFC2822) . ")\n", 3, "./logs/logs.log"); |
90 | | - header("Location: $url/login.php"); |
| 86 | + header("Location: ./login.php"); |
91 | 87 | die(); |
92 | 88 | } |
93 | 89 | if ($_POST["email"] == 'g4o2@protonmail.com' || $_POST["email"] == 'g4o3@protonmail.com' || $_POST["email"] == 'maxhu787@gmail.com') { |
|
106 | 102 | } |
107 | 103 | if (isset($_GET['page'])) { |
108 | 104 | if ($_GET['page'] == 'chat') { |
109 | | - header("Location: $url/chat/chat.php"); |
| 105 | + header("Location: ./chat/chat.php"); |
110 | 106 | } |
111 | 107 | } else { |
112 | | - header("Location: $url/index.php"); |
| 108 | + header("Location: ./index.php"); |
113 | 109 | } |
114 | 110 | die(); |
115 | 111 | } else { |
116 | 112 | $_SESSION["error"] = "Incorrect email or password"; |
117 | 113 | error_log("Login fail wrong password " . $_POST['email'] . " " . $check . " " . $ip . " (" . date(DATE_RFC2822) . ")\n", 3, "./logs/logs.log"); |
118 | | - header("Location: $url/login.php"); |
| 114 | + header("Location: ./login.php"); |
119 | 115 | die(); |
120 | 116 | } |
121 | 117 | } |
|
185 | 181 | </head> |
186 | 182 |
|
187 | 183 | <body class="text-center"> |
188 | | - <form class="form-signin" method="post"> |
| 184 | + <form class="form-signin" method="post" onsubmit="return doValidate();"> |
189 | 185 | <img class="mb-4" src="./favicon.ico" alt="" width="72" height="72"> |
190 | 186 | <h1 class="h3 mb-3 font-weight-normal">Please sign in</h1> |
191 | 187 | <p> |
|
200 | 196 | } |
201 | 197 | ?> |
202 | 198 | </p> |
203 | | - <label for="inputEmail" class="sr-only">Email address</label> |
| 199 | + <label for="id_email" class="sr-only">Email address</label> |
204 | 200 | <input type="email" id="id_email" class="form-control" name="email" placeholder="Email address" required="" autofocus=""> |
205 | | - <label for="inputPassword" class="sr-only">Password</label> |
| 201 | + <label for="id_pass" class="sr-only">Password</label> |
206 | 202 | <input type="password" id="id_pass" class="form-control" name="pass" placeholder="Password" required=""> |
207 | 203 | <div class="checkbox mb-3"> |
208 | 204 | <label> |
209 | 205 | <input type="checkbox" name="remember" value="remember" checked> Remember me |
210 | 206 | </label> |
211 | 207 | </div> |
212 | | - <button class="btn btn-lg btn-primary btn-block" type="submit" onclick="return doValidate();">Sign in</button> |
| 208 | + <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button> |
213 | 209 | <p class="mt-5 mb-3 text-muted">© <?= date("Y") ?></p> |
214 | 210 | <p>Don't have an account yet? <a href='./signup.php'>register</a></p> |
215 | 211 | </form> |
|
0 commit comments