Source for file example.php
Documentation is available at example.php
* Test for the LiveUser class
* ===============================
* This example sets up an authorization system using the LiveUser
* class. You don't have to use this to use the LiveUser class(es), but
* this way you don't need to take care of the login-process, storing
* the user object in a session and more...
* This example is intended to be used with the auth XML driver.
* No permission management is supported.
* @version $Id: example.php 191698 2005-07-28 11:21:32Z lsmith $
// Get LiveUser configuration array
if ($xml_is_readable == false || $xml_is_writable == false ) {
die ('<p style="color: red; text-align: center;">The XML file isn\'t readable/writable. Add the right permissions to it and then try again.</p>');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: #FFFFFF
border-collapse: collapse;
border-top: 1px solid #000;
border-right: 1px solid #000;
// Check if the user has logged in successfully
if (!$LU->isLoggedIn ()) {
<form name="loginform" method="post" action="example.php">
<table width="300" border="0" cellspacing="0" cellpadding="5">
<td colspan="2"><b>Example login</b></td>
<input type="text" name="handle" maxlength="80" value="" />
<input type="password" name="password" maxlength="80" value="" />
<input type="checkbox" name="remember" value="1" />
<input type="submit" value="Login" />
// The user couldn't login, so let's check if the reason was that
// he's not yet been declared "valid" by an administrator.
} else if ($LU->isInactive ()) {
<h3>Sorry kid, but one of our admins has yet approved
your user status. Please be patient. Don't call us -
<p align="center"><a href="example.php?logout=1">Logout</a></p>
<h3>Sorry, we can't let you in. Check if the spelling of
your handle and password is correct.</h3>
<p align="center"><a href="example.php?logout=1">Logout</a></p>
<p><i>Login Data for this Example:</i></p>
<td style="text-align: center; font-weight: bold;">Handle</th>
<td style="text-align: center; font-weight: bold;">Password</th>
<h2 style="text-align: center;">User logged in: <?php echo $LU->getProperty ('handle'); ?></h2>
<p>You can see user's rights in the table.</p>
//Let's check the rights in the kitchen.
// check whether the user has the required right
// check whether the user has the required right
//Let's check the rights in the livingroom.
// check whether the user has the required right
<td>watch latenight TV</td>
// check whether the user has the required right
//Let's check the rights in the office.
<td>use the computer</td>
// check whether the user has the required right
<td>connecting to the internet</td>
// check whether the user has the required right
<p align="center"><a href="example.php?logout=1">Logout</a></p>
// Just some more debug output with no further relevance
print_r($LU->getProperty ('handle'));
print_r($LU->getProperty ('perm_type'));
Documentation generated on Mon, 11 Mar 2019 15:40:12 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|