cvs: pear /Perm_LiveUser/examples example.htm example.php
| From: | Markus Wolff | Date: | Wed, 21 Aug 2002 22:44:30 +0000 |
| Subject: | cvs: pear /Perm_LiveUser/examples example.htm example.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-5872@lists.php.net to get a copy of this message | ||
mw21st Wed Aug 21 18:44:30 2002 EDT
Added files:
/pear/Perm_LiveUser/examples example.htm example.php
Log:
Initial commit, second try with the now correct package name Perm_LiveUser
Index: pear/Perm_LiveUser/examples/example.htm
+++ pear/Perm_LiveUser/examples/example.htm
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
table { background-color: #CCCCCC; border-color: #000000 #000000 #000000 black; border-style:
solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width:
1px}
body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: #000000;
background-color: #FFFFFF}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="loginform" method="post" action="example.php">
<table width="300" border="0" cellspacing="0"
cellpadding="5" align="center">
<tr>
<td colspan="2">Example login</td>
</tr>
<tr>
<td>Handle:</td>
<td>
<input type="text" name="handle" maxlength="80"
value="mwolff">
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<input type="password" name="passwd" maxlength="80"
value="lappoid">
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="Submit" value="Login">
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
Index: pear/Perm_LiveUser/examples/example.php
+++ pear/Perm_LiveUser/examples/example.php
<?php
/**
* Test for the LoginManager class
* ===============================
*
* This example sets up an authorization system using the LoginManager
* 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...
*
**/
error_reporting(E_ALL);
// Get LoginManager class definition
require_once("../LoginManager.php");
// Create new LoginManager object, providing an XML file that contains
// configuration information
$LoMa = new LoginManager("../demoConf.xml");
// Set the name of our application
$LoMa->setApplication("DemoApp");
// Trigger the login process
$LoMa->init();
// Check if the user has logged in successfully
if ($LoMa->isLoggedIn()) {
// Okay, he's in. Now let's display some content dependent of
// his access rights in our application. Let's pretend the current
// AuthArea of our application is the Coffeemaker section...
if ($level = $LoMa->checkRight(LIVEUSER_AREA_COFFEEMAKER, LIVEUSER_RIGHT_MAKE_COFFEE)) {
echo "Congrats, you're in the Coffeemaker section and have ";
echo "the right to make coffee at level $level!";
} else {
echo "Your coffee tastes so bad, I won't allow you to make some";
}
} else {
// The user couldn't login, so let's check if the reason was that
// he's not yet been declared "valid" by an administrator.
if ($LoMa->userNotActive()) {
echo "Sorry kid, but one of our admins has yet to approve ";
echo "your user status. Please be patient. Don't call us - ";
echo "we'll call you.";
} else {
echo "Sorry, we can't let you in. Check if the spelling of ";
echo "your handle and password is correct.";
}
}
echo "<br>User Type:";
print_r($LoMa->user->user_type);
echo "<br>Checking Level:";
print_r($LoMa->user->checkRightLevel(LIVEUSER_AREA_COFFEEMAKER, LIVEUSER_RIGHT_MAKE_COFFEE, 2,
2));
echo "<hr><pre>";
print_r($LoMa);
echo "<hr>";
print_r($_SESSION);
echo "</pre>";
?>