PHP Classes

File: INSTALL.txt

Recommend this page to a friend!
  Classes of Xavier Pérez   PHP Protected Page   INSTALL.txt   Download  
File: INSTALL.txt
Role: Documentation
Content type: text/plain
Description: Readme
Class: PHP Protected Page
Block direct access to a page from external links
Author: By
Last change:
Date: 9 years ago
Size: 1,559 bytes
 

Contents

Class file image Download
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.