-
Notifications
You must be signed in to change notification settings - Fork 68
Login & automatic membership system #108
Changes from 20 commits
5ea1852
d448786
833cfe6
7cd9984
9cf6a99
fa226a0
0a38249
ab35fc2
41505c3
6ba7ef5
c9fddaa
5cc7e4e
79f151b
e8d25aa
1156cff
32e2d90
1a1d146
ca1d738
416be1e
79c4ac6
8d351bc
4a29508
ba6a3cf
cfbf531
3e8f103
d4d8dd3
9c29415
927eea7
836252c
76fa9fe
62b22fa
87376fa
1501bd3
576bb5b
279fa20
5c8fb4f
917c554
6b2aff4
43c3a34
d9f27fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
| include('config/config.php'); | ||
| header('Content-Type: application/json'); | ||
| $info = array(); | ||
|
|
||
| if ($enableLogin === true) { | ||
| $info['enableLogin'] = true; | ||
| if (isset($_SESSION['user'])) { | ||
| $info['isLoggedIn'] = true; | ||
| $info['current_timestamp'] = time(); | ||
| $info['user'] = $_SESSION['user']; | ||
| } else { | ||
| $info['isLoggedIn'] = false; | ||
| } | ||
| } else { | ||
| $info['enableLogin'] = false; | ||
| } | ||
|
|
||
| print json_encode($info); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| <?php | ||
| include('config/config.php'); | ||
| if ($enableLogin === true) { | ||
| if (isset($_POST['submit_updatePwd'])) { | ||
| if (!empty($_POST["password"]) && ($_POST["password"] == $_POST["repassword"])) { | ||
| $passwordErr = ''; | ||
| $password = $_POST["password"]; | ||
|
|
||
| if (strlen($_POST["password"]) <= '5') { | ||
| $passwordErr = "<b>Your password must contain at least 8 characters!</b><br>"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| } elseif (!preg_match("#[0-9]#", $password)) { | ||
| $passwordErr = "<b>Your password must contain at least 1 number!</b><br>"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| } elseif (!preg_match("#[A-Z]#", $password)) { | ||
| $passwordErr = "<b>Your password must contain at least 1 capital letter!</b><br>"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| } elseif (!preg_match("#[a-z]#", $password)) { | ||
| $passwordErr = "<b>Your password must contain at least 1 lowercase letter!</b><br>"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| } | ||
| } else { | ||
| $passwordErr = "<b>Your passwords didn't match!</b><br>"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| } | ||
|
|
||
| if (empty($passwordErr)) { | ||
| $db->update("users", [ | ||
| "password" => sha1($_POST['password'] . $salt), | ||
| "updatePwd" => 0 | ||
| ], [ | ||
| "email" => $_SESSION['user']->email | ||
| ]); | ||
|
|
||
| header("Location: ."); | ||
| die(); | ||
| } else { | ||
| echo $passwordErr; | ||
| } | ||
| } | ||
|
|
||
| if (isset($_POST['submit_login'])) { | ||
| $info = $db->query( | ||
| "SELECT email, expire_timestamp, updatePwd FROM users WHERE email = :email AND password = :password", [ | ||
| ":email" => $_POST['email'], | ||
| ":password" => sha1($_POST['password'] . $salt), | ||
| ] | ||
| )->fetch(); | ||
|
|
||
| if ($info['email']) { | ||
| $_SESSION['user']->email = $info['email']; | ||
| $_SESSION['user']->expire_timestamp = $info['expire_timestamp']; | ||
| $_SESSION['user']->updatePwd = $info['updatePwd']; | ||
| if ($info['updatePwd'] == 1) { | ||
| header("Location: /login.php"); | ||
| die(); | ||
| } else { | ||
| header("Location: ."); | ||
| die(); | ||
| } | ||
| } else { | ||
| echo "Incorrect username or password."; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| } | ||
| } | ||
|
|
||
| if ($_SESSION['user']->updatePwd == 1) { | ||
| ?> | ||
| Please change your password. | ||
| <form action='' method='POST'> | ||
| <table> | ||
| <tr> | ||
| <th>New password</th><td><input type="password" name="password" required></td> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| </tr> | ||
| <tr> | ||
| <th>Confirm password</th><td><input type="password" name="repassword" required></td> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| </tr> | ||
| <tr> | ||
| <td><input type="submit" name="submit_updatePwd"></td><td></td> | ||
| </tr> | ||
| </table> | ||
| </form> | ||
| <?php | ||
| } else { | ||
| ?> | ||
| <form action='' method='POST'> | ||
| <table> | ||
| <tr> | ||
| <th>E-mail</th><td><input type="text" name="email" required></td> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| </tr> | ||
| <tr> | ||
| <th>Password</th><td><input type="password" name="password" required></td> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| </tr> | ||
| <tr> | ||
| <td><input type="submit" name="submit_login"></td><td></td> | ||
| </tr> | ||
| </table> | ||
| </form> | ||
| <?php | ||
| } | ||
| } else { | ||
| header("Location: ."); | ||
| } | ||
| ?> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?php | ||
| session_start(); | ||
| unset($_SESSION); | ||
| session_destroy(); | ||
| session_write_close(); | ||
| header('Location: .'); | ||
| die; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,7 +81,7 @@ function pokemonFilterImages($noPokemonNumbers) | |
| $i = -1; | ||
| $z = $z + 48.25; | ||
| } | ||
| $i++; | ||
| $i; | ||
| } | ||
| echo '</div>'; | ||
| } | ||
|
|
@@ -92,7 +92,7 @@ function pokemonFilterImages($noPokemonNumbers) | |
| if ($gAnalyticsId != "") { | ||
| echo '<!-- Google Analytics --> | ||
| <script> | ||
| window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; | ||
| window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=new Date; | ||
| ga("create", "' . $gAnalyticsId . '", "auto"); | ||
| ga("send", "pageview"); | ||
| </script> | ||
|
|
@@ -109,10 +109,10 @@ function pokemonFilterImages($noPokemonNumbers) | |
| _paq.push(["enableLinkTracking"]); | ||
| (function() { | ||
| var u="//' . $piwikUrl . '/"; | ||
| _paq.push(["setTrackerUrl", u+"piwik.php"]); | ||
| _paq.push(["setTrackerUrl", u"piwik.php"]); | ||
| _paq.push(["setSiteId", "' . $piwikSiteId . '"]); | ||
| var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; | ||
| g.type="text/javascript"; g.async=true; g.defer=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s); | ||
| g.type="text/javascript"; g.async=true; g.defer=true; g.src=u"piwik.js"; s.parentNode.insertBefore(g,s); | ||
| })(); | ||
| </script> | ||
| <!-- End Piwik Code -->'; | ||
|
|
@@ -153,6 +153,35 @@ function pokemonFilterImages($noPokemonNumbers) | |
| <div id="currentWeather"></div> | ||
| <?php | ||
| } ?> | ||
|
|
||
| <?php | ||
| if ($enableLogin === true) { | ||
| if ($_SESSION['user']->email) { | ||
| $info = $db->query( | ||
| "SELECT expire_timestamp, updatePwd FROM users WHERE email = :email", [ | ||
| ":email" => $_SESSION['user']->email, | ||
| ] | ||
| )->fetch(); | ||
|
|
||
| $_SESSION['user']->expire_timestamp = $info['expire_timestamp']; | ||
| $_SESSION['user']->updatePwd = $info['updatePwd']; | ||
|
|
||
| if ($info['updatePwd'] == 1) { | ||
| header("Location: /login.php"); | ||
| } | ||
|
|
||
| $time = date("m-d", $_SESSION['user']->expire_timestamp); | ||
|
|
||
| if ($info['expire_timestamp'] > time()) { | ||
| echo "<span style='color: green;'>{$time}</span>"; | ||
| } else { | ||
| echo "<span style='color: red;'>{$time}</span>"; | ||
| } | ||
| } else { | ||
| echo "<a href='/login.php'>Login</a>"; | ||
| } | ||
| } | ||
| ?> | ||
| <a href="#stats" id="statsToggle" class="statsNav" style="float: right;"><span | ||
| class="label"><?php echo i8ln('Stats') ?></span></a> | ||
| </header> | ||
|
|
@@ -815,7 +844,7 @@ class="onoffswitch-checkbox"/> | |
| $count = sizeof($areas); | ||
| if ($count > 0) { | ||
| echo '<div class="form-control switch-container area-container"><ul>'; | ||
| for ($i = 0; $i <= $count - 1; $i++) { | ||
| for ($i = 0; $i <= $count - 1; $i) { | ||
| echo '<li><a href="" data-lat="' . $areas[$i][0] . '" data-lng="' . $areas[$i][1] . '" data-zoom="' . $areas[$i][2] . '" class="area-go-to">' . $areas[$i][3] . '</a></li>'; | ||
| } | ||
| echo '</ul></div>'; | ||
|
|
@@ -848,6 +877,35 @@ class="onoffswitch-checkbox"/> | |
| </button> | ||
| </center> | ||
| </div> | ||
| <?php | ||
| if ($enableLogin === true && $_SESSION['user']->email) { | ||
| ?> | ||
| <div> | ||
| <center> | ||
| <button class="settings" | ||
| onclick="document.location.href='logout.php'"> | ||
| <i class="fa" aria-hidden="true"></i> Logout | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| </button> | ||
| </center> | ||
| </div><br> | ||
| <div> | ||
| <center> | ||
| <p> | ||
| <?php | ||
| $time = date("Y-m-d", $_SESSION['user']->expire_timestamp); | ||
|
|
||
| echo $_SESSION['user']->email . "<br>"; | ||
| if ($_SESSION['user']->expire_timestamp > time()) { | ||
| echo "<span style='color: green;'>Account expires on {$time}</span>"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| } else { | ||
| echo "<span style='color: green;'>Account expired on {$time}</span>"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be translatable |
||
| } ?> | ||
| </p> | ||
| </center> | ||
| </div> | ||
| <?php | ||
| } | ||
| ?> | ||
| </nav> | ||
| <nav id="stats"> | ||
| <div class="switch-container"> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesnt make sense. Says Less than or equal to 5 and the error says 8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved. Forgot to update the error message. Min character set to 6.