Protected Page
This scripts allows to protect any php in your site.
All php pages that include the protectedPage script will be protected, and final users only will be allowed to enter if uses a correct link.
The correct link are generated by generateKeys, it's very easy to use.
Once the final user click the link, protectedPage generates a cookie, and all other pages that includes protectedPage.php will be allowed also.
protectedPage.php have a small conf on top:
private $conf = array(
'secretCookie' => 'myAccessCookie', // Cookie name to store auth
'cookieTTL' => 600, // Cookie time to live, will be refreshed each time a page is accessed.
'expiresOnClose' => false, // Expires on navigator close true/false
'securePath' => '/', // Path for the cookie
'redirectKO' => 'http://www.google.es' // Url for not allowed users
);
Add require_once of protectedPage.php in top of your index.php or any other php of your own
Remember to specify correct path for protectedPage.php (better not to be on document_root path)
Generated url will be as this (see generateKeys.php example file):
http://SERVER/index.php?xid=USER&xtk=$TOKEN
Where:
$TOKEN = md5($SECRET_KEY . '-' . $USER . '-' . $SERVER);
$SECRET_KEY = Secret key defined in protectedPage.php
$USER - Use an ID, a name or an email
$SERVER - Ever use $_SERVER['HTTP_HOST'] (in this case, set document_root to the public_html directory)
Then compose the url:
Once the token it's validated, the php redirects to base url without params.
|