PEAR CMS: Index and Delete Scripts - The code explained
(Page 4 of 4 )
All the scripts in the admin section of the site must have a security check that determines whether or not the currently logged-in user has administration level clearance. This page does exactly that, using PHP’s session information. If a user is not authenticated or does not have administrator level clearance, then the user will not be allowed to view the page. Instead, they will be redirected to the login page.
<?
session_start();
if($_SESSION['level']!=="admin"){
//redirect to login page
header(location:"login.php");
}
?>
The next part in this script creates the HTML portion of the page. The header part of the HTML includes a lot of elements, such as the style sheet and template definitions. Later on, a table is going to be created that will host the navigation panel. Also, a welcome message will be created and included in the HTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Don't forget to check back next week for the conclusion to this series!
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.