PHPMaker has already provided the ability to prevent the user if the login attempt exceeds the maximum login retry count for the websites that created by it. If this condition occurs, then the user will get the message that inform her/him about it. Assuming system also have defined the next duration time user will be allowed again with value of 5 minutes, then the message will be look like this:
Exceed maximum login retry count. Account is locked. Please try again in 5 minutes
Unfortunately, if the user is still trying to login after he/she got that warning message, then the system will keep inform him/her about the "5 minutes" again and again. I think this message is not so smart, because that "5 minutes" message should be updated automatically in accordance with the real time at that time. So, instead of saying "5 minutes", we will make it auto-adjust to the real time. The result will be like this:
-
The first time user got the message at 08:00:00, it will show:
Exceed maximum login retry count. Account is locked. Please try again in 0 hour(s), 5 minute(s), and 0 second(s).
-
When that user is trying to login at 08:00:15, the time will be automatically updated become:
Exceed maximum login retry count. Account is locked. Please try again in 0 hour(s), 4 minute(s), and 45 second(s).
-
When that user is trying to login at 08:00:33, the time will be automatically updated become:
Exceed maximum login retry count. Account is locked. Please try again in 0 hour(s), 4 minute(s), and 27 second(s).
- And so on. Well, does it sound smarter than before, right?
All we have to do is customizing the PHPMaker template files and add some code into the Server Events section of PHPMaker. In other words, we will not customize the generated script files.
Please click on the following image to watch the demo:

[hidepost]
Let's get started. Follow these steps below:
-
Open your C:\Program Files\PHPMaker 8\languages\english.xml file, and find this code:
<phrase id="ExceedMaxRetry" value="Exceed maximum login retry count. Account is locked. Please try again in %t minutes"/>
then replace it with this following code:
<phrase id="ExceedMaxRetry" value="Exceed maximum login retry count. Account is locked. Please try again in %t."/>
Do the same way with your another .xml language file. For example, I am also using Indonesian language, so I add those phrases to my indonesian.xml file:
<phrase id="ExceedMaxRetry" value="Melebihi jumlah usaha maksimum login. Akun terkunci. Silahkan coba lagi dalam %t."/>
-
Open your /Script/login.php file, and find this code:
$this->setFailureMessage(str_replace("%t", EW_USER_PROFILE_RETRY_LOCKOUT, $Language->Phrase("ExceedMaxRetry")));then replace it with this following code:
$this->setFailureMessage(str_replace("%t", Duration( date("Y-m-d H:i:s"), CurrentDateTime_Add_Minutes( $UserProfile->getValue( EW_USER_PROFILE_LAST_BAD_LOGIN_DATE_TIME), EW_USER_PROFILE_RETRY_LOCKOUT)), $Language->Phrase("ExceedMaxRetry"))); -
Open your /Script/phpfn.php file, and find this code:
if (ew_DateDiff($dt, ew_StdCurrentDateTime(), "n") < $this->RetryLockoutTime) {then replace it with this following code:
if (ew_DateDiff($dt, ew_StdCurrentDateTime(), "n") < EW_USER_PROFILE_RETRY_LOCKOUT) { [/code] this step is important in order to check and validate whether the user is allowed login or not. </li> <li> Next step, still on your <strong>PHPMaker</strong> application, click on one of your tables from the left panel, and see in the right panel of your PHPMaker application, there are two tabs appear. They are: <strong>Fields</strong> and <strong>Server Events/Client Scripts</strong>. Click on the <strong>Server Events/Client Scripts</strong> tab, and then click on <strong>Server Events</strong> -> <strong>Global</strong> -> <strong>All Pages</strong> -> <strong>Global Code</strong>. Find this code: [code lang="php"] function CurrentDateTime_Add_Minutes($currentdate, $minute) { $timestamp = strtotime("$currentdate"); $addtime = strtotime("+$minute minutes", $timestamp); $next_time = date('Y/m/d H:i:s', $addtime); return $next_time; } - Re-generate your script files using PHPMaker.
[/hidepost]
Leave a Reply
You must be logged in to post a comment.