Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Olaf Lederer  >  Access user Class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: An example how to protect a page
Class: Access user Class
Site user registration and page access restriction
Author: By
Last change: added exmple code to show the real name
Date: 8 years ago
Size: 1,629 bytes
 

Contents

Class file image Download
<?php 
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php"); 

$page_protect = new Access_user;
// $page_protect->login_page = "login.php"; // change this only if your login is on another page
$page_protect->access_page(); // only set this this method to protect your page
$page_protect->get_user_info();
$hello_name = ($page_protect->user_full_name != "") ? $page_protect->user_full_name $page_protect->user;

if (isset(
$_GET['action']) && $_GET['action'] == "log_out") {
    
$page_protect->log_out(); // the method to log off
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example page "access_user Class"</title>
</head>

<body>
<h2><?php echo "Hello ".$hello_name." !"?></h2>
<p>You are currently logged in.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<!-- Notice! you have to change this links here, if the files are not in the same folder -->
<p><a href="./update_user.php">Update user account</a></p>
<p><a href="./update_user_profile.php">Update user PROFILE</a></p>
<p><a href="/classes/access_user/test_access_level.php">test access level </a></p>
<?php if ($page_protect->access_level >= DEFAULT_ADMIN_LEVEL) { // this link is only visible for admin level user ?>
<p><a href="/classes/access_user/admin_user.php">Admin page (user / access level update) </a></p>
<?php // end hide admin menu link ?>
<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=log_out">Click here to log out.</a></p>
</body>

</html>