retrict access to a website login page between 2 times in the .user.ini

It can be done, but not from the .user.ini

You'd need to put the php code from your example site onto the login page. If it's WordPress, you'd add it to the /wp-login.php file. Other CMS system will likely have a similar named file somewhere.
These files will overwritten when you update your CMS so you'll need to remember and add the code again each time you update.
 
Thank you both for the input.

i am using youphptube, I have setup the website to only show the login screen.

I have edited this file /view/user.php

with this php
Code:
<?php

if(date('G')>=15 && date('G')<=18)
{
    // show your code/site/content.
    *****do i put the whole website code in here, i did try but didn't seem to work****
    }
else
{
    // Show the "Come back during opening hours..." sign.
    die("Sorry, you are not allowed to be here right now.");
}

?>

put the code at the top of the file above everything and it only shows the message sorry message... if when i change the times.

any guidance is appreciated.

Tim
 
Put it at the top of the file but change it so that the 'die' command runs if outside hours and that'll stop the rest of the code from executing.

Code:
<?php

if(date('G') < 15 || date('G') > 18)
{
    die("Come back during opening hours...");
}

?>

edit: Just looked up YouPHPtube, the login page is at /view/userLogin.php -that's what you need to edit.
 
Last edited:
Put it at the top of the file but change it so that the 'die' command runs if outside hours and that'll stop the rest of the code from executing.

Code:
<?php

if(date('G') < 15 || date('G') > 18)
{
    die("Come back during opening hours...");
}

?>

edit: Just looked up YouPHPtube, the login page is at /view/userLogin.php -that's what you need to edit.


thank you for looking.

I was trying to figure out which to use this one that you pointed out /view/userLogin.php or /view/user.php I was using the latter because when you go to the website to access it the url that shows up is mywebsite.com/user so i thought it would be the user.php I had to edit.

well i tried editing both files and it still doesn't seem to want to work. I am waiting to test this out on an different server as the hosting i am using at the moment seems to be quite strict or whether youphptube doesnt allow it, but i am not sure. i will test it on my own hosting then report back.

thanks again for your time.

Tim
 
update.

seems to be working now. the server, even though based in japan is using UTC time so I was using local times instead of UTC times.

Thanks for the help

Tim
 
Back
Top Bottom