I Love PHPMaker

... because it gets even more powerful and flexible!!

  • About
  • Terms and Conditions
  • Membership Options
  • Sitemap
  • Downloads
    • PHPMaker Extensions Download
    • PHPMaker Projects Download
    • PHP Report Maker Extensions Download
I Love PHPMaker » Tips and Trick » How to Restrict Login Time in Web Applications that Generated by PHPMaker 9.2.0
How to Change the Date Format of Calendar in Web Applications that Generated by PHPMaker 10.0.1
How to Compress Javascript and CSS Files in Websites that Generated by PHPMaker 9.2.0

July 31, 2013

How to Restrict Login Time in Web Applications that Generated by PHPMaker 9.2.0

This following trick will show you how to restrict login time in web applications that generated by PHPMaker. Let' say, you don't want your web application users login before 03.00 AM and after 11.00 PM (for example, since there are additional back-end process in the server after 11.00 PM and before 03.00 AM). If users are trying login after 11.00 PM and before 03.00 AM, then system will automatically reject them. Also, let system logs them to the Audit Trail.

Fortunately, PHPMaker has the server event for this, which is called with User_LoggingIn. We can implement it very easy. In other words, we will not modify any generated script files for this, as I always avoid it all the time. By using this trick, then you will learn how to check whether the current time is located between two different time in that day. If this criteria is fulfiled, then the current time is a valid time, so the users are able to login to your system. You will also learn how to concat the current time with the current date, so the result can be used to compare with the beginning and the end of your desired date and time.

I have implemented this trick in one of my many web applications (also for the same reason above), and it works perfectly.

[hidepost]

  1. Insert the following code to the Server Events -> Global -> All Pages -> Global Code of PHPMaker application:

    function VerifyMyTime($current_time) {
        $begin_time = "03:00:00";
        $end_time = "23:00:00";
        $current_date = DateTime::createFromFormat("H:i:s", $current_time);
        $begin_date = DateTime::createFromFormat("H:i:s", $begin_time);
        $end_date = DateTime::createFromFormat("H:i:s", $end_time);
        if ($current_date > $begin_date && $current_date < $end_date) {
            return true;
        } else {
            return false;
        }
    }
    &#91;/code&#93;
    </li>
    
    <li>
    The next step, insert the code below to your <strong>Server Events</strong> -> <strong>Other</strong> -> <strong>Login Page</strong> -> <strong>User_LoggingIn</strong> function, so you will have the complete code just like the following:
    [code lang="php"]
    // User Logging In event
    function User_LoggingIn($usr, &$pwd) {
        // Enter your code here
        // To cancel, set return value to FALSE
        $my_current_time = date("H:i:s");
        if (VerifyMyTime($my_current_time)==false) {
           ew_WriteAuditTrail("log", ew_StdCurrentDateTime(), ew_ScriptName(), $usr, "login is not allowed at this time.", ew_CurrentUserIP(), "", "", "", "");
           $this->setFailureMessage("Sorry, you are not allowed login at ".$my_current_time.".<br><br>You will be allowed after 03:00 AM.");
           return FALSE;
        }
        return TRUE;
    } 
    
  2. Finally, re-generate your script files using PHPMaker, as always.

[/hidepost]

Article by Masino Sinaga / Tips and Trick / audit trail, every day, login, login time, PHPMaker 9.2.0, restrict, Server Events, User_LoggingIn Leave a Comment

How to Change the Date Format of Calendar in Web Applications that Generated by PHPMaker 10.0.1
How to Compress Javascript and CSS Files in Websites that Generated by PHPMaker 9.2.0

Leave a Reply Cancel reply

You must be logged in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • A New PHPMaker 2025 Project File Is Released
  • PHPMaker 2025 Demo Project File Is Released
  • Masino Extensions for PHPMaker 2025 Is Released!
  • A New PHPMaker 2024 Project File Is Released
  • PHPMaker 2024 Demo Project File Is Released
  • Masino Extensions for PHPMaker 2024 Is Released!
  • PHPMakerProjects.com, For Those Who Need PHPMaker Project Sample
  • A New PHPMaker 2023 Project File Is Released
  • PHPMaker 2023 Demo Project File Is Released
  • Masino Extensions for PHPMaker 2023 Is Released!

Search

Recent Comments

  • Masino Sinaga on Masino Extensions for PHPMaker 2024 Is Released!
  • Masino Sinaga on A New PHPMaker 2024 Project File Is Released
  • Masino Sinaga on PHPMaker 2023 Demo Project File Is Released
  • Edward Babatunde on PHPMaker 2023 Demo Project File Is Released
  • Edward Babatunde on Masino Extensions for PHPMaker 2024 Is Released!

Demo Website

  • Demo of I Love PHPMaker 2025 (MasinoExtensions).
  • Stock Inventory Management for PHPMaker 2025.

Another Demo

The following template are not available in this site (must be purchased separately)

  • PHPMaker v2018 Horizontal Vertical Template.
  • PHPMaker v2017 Horizontal Vertical Template.

Demo Explanation

Stock Inventory Management is the good project for your reference, since it uses the real example in the real world. Many useful features you can use from this project, such as how to add the Thousand and Decimal separator character, and also how to calculate multiple row in Grid-Add when End-Users are entering data into the Grid-Add mode.

Categories

  • Customize Template (103)
  • General (4)
  • PHP Report Maker (17)
  • PHP Report Maker Extensions (2)
  • PHPMaker Extensions (84)
  • PHPMaker Projects (7)
  • Tips and Trick (72)

Articles based on version

  • PHPMaker 2025
  • PHPMaker 2024
  • PHPMaker 2023
  • PHPMaker 2022
  • PHPMaker 2021
  • PHPMaker 2020
  • PHPMaker 2019
  • PHPMaker 2018
  • PHPMaker 2017.0.7
  • PHPMaker 12.0.7
  • PHPMaker 11.0.6
  • PHPMaker 10.0.5
  • PHPMaker 9.2.0
  • PHPMaker 8.0.3
  • PHP Report Maker 12

(c) I Love PHPMaker 2010 - 2025 by Masino Sinaga | WordPress | Log in | Back to top