From a7fe6c2432a8f0aee0ebb357e4c3e08f3ca61b62 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Tue, 1 Dec 2015 17:24:43 -0700 Subject: [PATCH] Added some helpers for the lockout function and a script for removing diacritics for the export file name. --- README.md | 4 ++ index.php | 27 +++++---- js/dictionaryBuilder.js | 3 +- js/removeDiacritics.js | 118 ++++++++++++++++++++++++++++++++++++++++ php/helpers.php | 30 ++++++++++ 5 files changed, 170 insertions(+), 12 deletions(-) create mode 100644 js/removeDiacritics.js diff --git a/README.md b/README.md index 913d58e..62bcc76 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,9 @@ The **Import Dictionary** button acts the same as before, but instead of overwri The **Delete Current Dictionary** button will permanently and irretrievably delete the currently loaded dictionary from your account! Be careful with that one. After deleting, you will then be prompted to either select another dictionary to load or create a new one, _or_ if you have no other dictionaries, immediately create a new one for you. +### Lockout +If you manage to enter your password wrong 10 times, you'll be locked out from logging in for an hour. Use this time to try to remember your password or something. You can get an idea of how long you've waited by refreshing the page and clicking the unfortunate "Can't Login" button. After an hour has passed, refresh the page again and you'll get another 10 tries. + ## Problems or Requests Please report any problems you come across to the [Dictionary Builder Issues page](https://github.com/Alamantus/DictionaryBuilder/issues). You can also submit enhancement requests to the same place if you have any requests for new features. @@ -92,3 +95,4 @@ I hope you enjoy Lexiconga and that it helps you build some awesome languages. ### Libraries Used * [Marked.js](https://github.com/chjj/marked) by Christopher Jeffrey (JJ) (a.k.a. chjj) * [Defiant.js](http://defiantjs.com) by Hakan Bilgin (a.k.a. hbi99) +* [removeDiacritics.js](http://stackoverflow.com/a/18391901/3508346) by [rdllopes](http://meta.stackoverflow.com/users/1879686/rdllopes) diff --git a/index.php b/index.php index 7f037d1..4da2989 100644 --- a/index.php +++ b/index.php @@ -6,6 +6,14 @@ $current_user = isset($_SESSION['user']) ? $_SESSION['user'] : 0; $notificationMessage = ""; +if (!isset($_SESSION['loginfailures']) || (isset($_SESSION['loginlockouttime']) && time() - $_SESSION['loginlockouttime'] >= 3600)) { + // If never failed or more than 1 hour has passed, reset login failures. + $_SESSION['loginfailures'] = 0; +} else { + $alertlockoutmessage = "You failed logging in 10 times. To prevent request flooding and hacking attempts, you may not log in or create an account for about an hour.\\n\\nThe last time this page was loaded, you had been locked out for " . time_elapsed(time() - $_SESSION['loginlockouttime']); + $hoverlockoutmessage = str_replace("\\n", "\n", $alertlockoutmessage); +} + if (isset($_GET['logout']) && $current_user > 0) { session_destroy(); header('Location: ./?loggedout'); @@ -54,13 +62,10 @@ elseif (isset($_GET['error']) && $current_user <= 0) { $notificationMessage = "The create account form somehow got submitted without some essential information.
Please try filling it out again."; } elseif ($_GET['error'] == "loginfailed") { $notificationMessage = "We couldn't log you in because your email or password was incorrect.
"; - if (!isset($_SESSION['loginfailures']) || (isset($_SESSION['loginlockouttime']) && time() - $_SESSION['loginlockouttime'] > 3600)) { - // If never failed or more than 1 hour has passed, reset login failures. - $_SESSION['loginfailures'] = 0; - } + $_SESSION['loginfailures'] += 1; if ($_SESSION['loginfailures'] < 10) { - $notificationMessage .= "This is your " . $_SESSION['loginfailures'] . " time. Please try again."; + $notificationMessage .= "This is your " . ordinal($_SESSION['loginfailures']) . " time. Please try again."; } else { $_SESSION['loginlockouttime'] = time(); $notificationMessage .= "Since you failed to log in successfully 10 times, you may not try again for about an hour."; @@ -96,17 +101,17 @@ elseif (isset($_GET['loggedout']) && $current_user <= 0) {
- +
About Lexiconga
0) { //If logged in, show the log out button. ?> Log Out - 3600)) { ?> + Log In/Create Account - Can't Login + Can't Login
@@ -178,7 +183,7 @@ elseif (isset($_GET['loggedout']) && $current_user <= 0) {