By : betterphp Published On Tuesday, April 27, 2010, 23:03 In PHP Scripts
Example Useage:
Standard Mode
include('secure/security.class.inc.php');
$pass = new secure;
// Set the username and password, in this case as a sha1 hash
$pass->set_credentials('admin', '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8');
// set the hash type
$pass->set_hash_type('sha1');
// set some custom session keys
$pass->custom_session_keys('name', 'pass');
// enable brute force protection, disabled as default.
$pass->brute_force_protect();
// set a custom page for the user to be sent to if the password it entered incorrectly.
$pass->redirect_on_fail('http://yourdomain.com/denied.html');
// finally apply protection to the page.
$pass->protect();
echo 'protected content here.';
Single Line Mode
include('secure/security.class.inc.php');
echo 'protected content here.'
Documentation: http://jacekk.co.uk/code/page_protect/README.html
Example of the login page included
http://jacekk.co.uk/code/page_protect/example.php
Username: admin
Password: lemon
NOTE: this script will only work if you have PHP version greater than 5.1. I have had a few emails from people complaining of a blank page who were using PHP4. You can check you version by using the following code.
<?php echo phpversion(); ?>