cvs: pear /LiveUser_Admin/docs/examples/example3 area51.php coffeemaker.php conf.php demodata.sql example.php index.html loginscreen.php main.php
nav.php testarea.php
| From: | Lukas Smith | Date: | Wed, 15 Dec 2004 13:33:22 +0000 |
| Subject: | cvs: pear /LiveUser_Admin/docs/examples/example3 area51.php coffeemaker.php conf.php demodata.sql example.php index.html loginscreen.php main.php nav.php testarea.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-27435@lists.php.net to get a copy of this message | ||
lsmith Wed Dec 15 08:33:22 2004 EDT
Added files:
/pear/LiveUser_Admin/docs/examples/example3 area51.php
coffeemaker.php
conf.php demodata.sql
example.php index.html
loginscreen.php
main.php nav.php
testarea.php
Log:
- moved from client (broken)
http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/area51.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/area51.php +++ pear/LiveUser_Admin/docs/examples/example3/area51.php <?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 DB_Medium Perm driver. * * @version $Id: area51.php,v 1.1 2004/12/15 13:33:22 lsmith Exp $ **/ error_reporting(E_ALL); // right definitions define('ACCESS', 3); define('LAUNCH_ATOMIC_BOMB', 4); define('FLY_ALIEN_SPACE_CRAFT', 5); // Include configuration. require_once 'conf.php'; // The error handling stuff is not needed and used only for debugging // while LiveUser is not yet mature PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'eHandler'); function eHandler($errObj) { echo('<hr /><span style="color: red;">' . $errObj->getMessage() . ':<br />' . $errObj->getUserinfo() . '</span><hr />'); } // Create new LiveUser object $LU = LiveUser::factory($liveuserConfig); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Example Area51</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <body> <h1>Area51</h1> <p> </p> <?php if (!$LU->isLoggedIn()) { $target = 'area51.php'; include_once 'loginscreen.php'; exit(); } else { if (!$LU->checkRight(ACCESS)) { ?> <p>Hey, this is a top secret area. Access denied.</p> <?php } else { ?> <p>Live long and prosper, <b><?php echo $LU->getProperty('handle'); ?> </b>.</p> <p>You have access at the necessary level <b><?php echo $LU->checkRightLevel(ACCESS, 1, 0); ?></b></p> <p>Please wait ... checking some rights ...<br /> <?php // you can even check multiple rights with one checkright call if ($LU->checkRight(array(LAUNCH_ATOMIC_BOMB, FLY_ALIEN_SPACE_CRAFT))) { ?> <p>OK, you're the boss. Let's take our alien space craft, launch the orbital atomic bombs and kick some ass! ;-)<br /> (Ehm, that was just to test our right system ...)<p> <?php } else { ?> <p>Don't touch anything!</p> <?php } } } ?> <p> </p> <p class="center"><a href="area51.php?logout=1">Logout</a></p> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/coffeemaker.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/coffeemaker.php +++ pear/LiveUser_Admin/docs/examples/example3/coffeemaker.php <?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 DB_Medium Perm driver. * * @version $Id: coffeemaker.php,v 1.1 2004/12/15 13:33:22 lsmith Exp $ **/ error_reporting(E_ALL); // right definitions define('MAKE_COFFEE', 6); define('DRINK_COFFEE', 7); // Include configuration. require_once 'conf.php'; // The error handling stuff is not needed and used only for debugging // while LiveUser is not yet mature PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'eHandler'); function eHandler($errObj) { echo('<hr /><span style="color: red;">' . $errObj->getMessage() . ':<br />' . $errObj->getUserinfo() . '</span><hr />'); } // Create new LiveUser object $LU = LiveUser::factory($liveuserConfig); if (!$LU) { die('An unknown error occurred'); } // we have an error stack if (is_array($LU)) { echo 'One or more errors occurred, here is the array'; print_r($LU); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Example Coffeemaker</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <body> <h1>Welcome in the Coffeemaker section!</h1> <p> </p> <?php // check login status if (!$LU->isLoggedIn()) { $target = 'coffeemaker.php'; include_once 'loginscreen.php'; exit(); } else { if (!$LU->checkRight(MAKE_COFFEE) && !$LU->checkRight(DRINK_COFFEE)) { ?> <p>Sorry, but you don't have any rights in this section</p> <?php } else { // 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 and we want to // know whether to user is allowed to make some coffee // (the area is not needed until we won't know whether our user is an area // admin). if ($LU->checkRight(MAKE_COFFEE)) { ?> <p>Congrats, you're in the Coffeemaker section and have the right to make coffee!</p> <?php } else { ?> <p>Your coffee tastes so bad, I won't allow you to make some</p> <?php } // check if the user is allowed to drink coffee. checkRight will return the level. if ($LU->checkRight(DRINK_COFFEE) == 1) { ?> <p>Yey ! You can even drink some coffee (but perhaps you should ask your boss first ;-) ))</p> <?php } elseif ($LU->checkRight(DRINK_COFFEE) == 3) { ?> <p>Hi <?php echo $LU->getProperty('handle'); ?>! Taste this delicious coffee.</p> <?php } else { ?> <p>Well, sorry dude, you cannot drink in here</p> <?php } } } ?> <p> </p> <p class="center"><a href="coffeemaker.php?logout=1">Logout</a></p> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/conf.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/conf.php +++ pear/LiveUser_Admin/docs/examples/example3/conf.php <?php // BC hack if (!defined('PATH_SEPARATOR')) { if (defined('DIRECTORY_SEPARATOR') && DIRECTORY_SEPARATOR == "\\") { define('PATH_SEPARATOR', ';'); } else { define('PATH_SEPARATOR', ':'); } } // set this to the path in which the directory for liveuser resides // more remove the following two lines to test LiveUser in the standard // PEAR directory //$path_to_liveuser_dir = './pear/'.PATH_SEPARATOR; //ini_set('include_path', $path_to_liveuser_dir.ini_get('include_path')); // Data Source Name (DSN) $dsn = 'mysql://root@localhost/liveuser_test'; $liveuserConfig = array( 'session' => array('name' => 'PHPSESSID','varname' => 'loginInfo'), 'login' => array('username' => 'handle', 'password' => 'passwd', 'remember' => 'rememberMe'), 'logout' => array('trigger' => 'logout', 'destroy' => true, 'method' => 'get'), 'cookie' => array('name' => 'loginInfo', 'path' => '/', 'domain' => '', 'lifetime' => 30, 'secret' => 'mysecretkey'), 'autoInit' => true, 'authContainers' => array('DB' => array( 'type' => 'DB', 'dsn' => $dsn, 'loginTimeout' => 0, 'expireTime' => 0, 'idleTime' => 0, 'allowDuplicateHandles' => 1, 'passwordEncryptionMode' => 'PLAIN', 'authTableCols' => array( 'required' => array( 'auth_user_id' => array('name' => 'auth_user_id', 'type' => 'text'), 'handle' => array('name' => 'handle', 'type' => 'text'), 'passwd' => array('name' => 'passwd', 'type' => 'text'), ), 'optional' => array( 'lastlogin' => array('name' => 'lastlogin', 'type' => 'timestamp'), 'is_active' => array('name' => 'is_active', 'type' => 'boolean') ) ) ) ), 'permContainer' => array( 'type' => 'Complex', 'storage' => array( 'DB' => array( 'dsn' => $dsn, 'prefix' => 'liveuser_', 'groupTableCols' => array( 'required' => array( 'group_id' => array('type' => 'integer', 'name' => 'group_id'), 'group_define_name' => array('type' => 'text', 'name' => 'group_define_name') ), 'optional' => array( 'group_type' => array('type' => 'integer', 'name' => 'group_type'), 'is_active' => array('type' => 'boolean', 'name' => 'is_active'), 'owner_user_id' => array('type' => 'integer', 'name' => 'owner_user_id'), 'owner_group_id' => array('type' => 'integer', 'name' => 'owner_group_id') ) ) ) ) ) ); // Get LiveUser class definition require_once 'LiveUser.php'; http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/demodata.sql?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/demodata.sql +++ pear/LiveUser_Admin/docs/examples/example3/demodata.sql # $Id: demodata.sql,v 1.1 2004/12/15 13:33:22 lsmith Exp $ # # Table structure for table 'liveuser_languages' # CREATE TABLE `liveuser_languages` ( `language_id` smallint(5) unsigned NOT NULL default '0', `two_letter_name` char(2) NOT NULL default '', PRIMARY KEY (`language_id`), UNIQUE KEY `two_letter_name` (`two_letter_name`) ); # # Table structure for table 'liveuser_translations' # CREATE TABLE `liveuser_translations` ( `section_id` int(11) unsigned NOT NULL default '0', `section_type` tinyint(3) unsigned NOT NULL default '0', `language_id` smallint(5) unsigned NOT NULL default '0', `name` varchar(50) NOT NULL default '', `description` varchar(255) default NULL, PRIMARY KEY (`section_id`,`section_type`, `language_id`) ); # Dumping data for table `liveuser_users` # INSERT INTO liveuser_users (auth_user_id, handle, passwd, lastlogin, owner_user_id, owner_group_id, is_active) VALUES ('c4ca4238a0b923820dcc509a6f75849b', 'boss', 'test', NULL, NULL, 1, 'Y'); INSERT INTO liveuser_users (auth_user_id, handle, passwd, lastlogin, owner_user_id, owner_group_id, is_active) VALUES ('c81e728d9d4c2f636f067f89cc14862c', 'hoss', 'bonanza', NULL, 1, NULL, 'Y'); # # Dumping data for table `liveuser_areas` # INSERT INTO liveuser_areas (area_id, application_id, area_define_name) VALUES (1, 0, 'TestArea'); INSERT INTO liveuser_areas (area_id, application_id, area_define_name) VALUES (2, 0, 'Area51'); INSERT INTO liveuser_areas (area_id, application_id, area_define_name) VALUES (3, 0, 'Coffeemaker'); # # Dumping data for table `liveuser_grouprights` # INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (1, 1, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (1, 2, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (1, 7, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (2, 3, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (2, 4, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (2, 5, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (2, 6, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (2, 7, 1); # # Dumping data for table `liveuser_groups` # INSERT INTO liveuser_groups (group_id, owner_user_id, owner_group_id, is_active, group_define_name) VALUES (1, 1, 1, 'Y', 'Group1'); INSERT INTO liveuser_groups (group_id, owner_user_id, owner_group_id, is_active, group_define_name) VALUES (2, 1, 1, 'Y', 'Group2'); # # Dumping data for table `liveuser_groupusers` # INSERT INTO liveuser_groupusers (perm_user_id, group_id) VALUES (1, 1); INSERT INTO liveuser_groupusers (perm_user_id, group_id) VALUES (1, 2); INSERT INTO liveuser_groupusers (perm_user_id, group_id) VALUES (2, 1); # # Dumping data for table `liveuser_languages` # INSERT INTO liveuser_languages (language_id, two_letter_name) VALUES (1, 'de'); INSERT INTO liveuser_languages (language_id, two_letter_name) VALUES (2, 'en'); # # Dumping data for table `liveuser_perm_users` # INSERT INTO liveuser_perm_users (perm_user_id, auth_user_id, perm_type, auth_container_name) VALUES (1, 'c4ca4238a0b923820dcc509a6f75849b', 1, 'DB'); INSERT INTO liveuser_perm_users (perm_user_id, auth_user_id, perm_type, auth_container_name) VALUES (2, 'c81e728d9d4c2f636f067f89cc14862c', 1, 'DB'); # # Dumping data for table `liveuser_rights` # INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (1, 1, 'READ_TESTS', 'N', 'N'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (2, 1, 'WRITE_TESTS', 'N', 'N'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (3, 2, 'ACCESS', 'N', 'Y'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (4, 2, 'LAUNCH_ATOMIC_BOMB', 'N', 'N'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (5, 2, 'FLY_ALIEN_SPACE_CRAFT', 'N', 'N'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (6, 3, 'MAKE_COFFEE', 'N', 'N'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (7, 3, 'DRINK_COFFEE', 'N', 'Y'); # # Dumping data for table `liveuser_userrights` # INSERT INTO liveuser_userrights (perm_user_id, right_id, right_level) VALUES (1, 3, 3); INSERT INTO liveuser_userrights (perm_user_id, right_id, right_level) VALUES (1, 7, 3); # # Dumping data for table `liveuser_translations` # INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 2, 1, 'TestGebiet', 'Ein G ebiet zum testen.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 2, 2, 'TestArea', 'An Area for testing.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 2, 1, 'Area51', 'Jeder ken nt dieses Gebiet.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 2, 2, 'Area51', 'Everybody knows this area.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (3, 2, 1, 'Kaffeemaschine', 'K affeemaschine Typ 165-X'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (3, 2, 2, 'Coffeemaker', 'Coff eemaker type 165-X.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 3, 1, 'Dummies', 'Die Dumm y-Gruppe'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 3, 2, 'Dummies', 'The dummy group'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 3, 1, 'Genies', 'Die wahren Genies (verkannt, aber brilliant)'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 3, 2, 'Genies', 'The true genii (unrecognized but brilliant)'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 5, 1, 'Lesen', 'Der Benutzer darf etwas lesen.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 5, 1, 'Schreiben', 'Der Benutzer darf etwas schreiben.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (3, 5, 1, 'Zugangang', '"Sesam ?ffne dich"-Recht'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (4, 5, 1, 'Feuer', 'Atombombe z?nden'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (5, 5, 1, 'Lift up', 'Alien Raumschiff fliegen'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (6, 5, 1, 'Kaffee machen', 'Kaffeepulver, Wasser, einschalten, warten ...'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (7, 5, 1, 'Kaffee trinken', 'Ahh, Koffein'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 5, 2, 'Read', 'Read authority'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 5, 2, 'Write', 'Write something new'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (3, 5, 2, 'Access', 'Open the doors'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (4, 5, 2, 'Fire', 'Launch the atomic bombs'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (5, 5, 2, 'Lift up', 'Let\'s fly an alian space craft'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (6, 5, 2, 'Make coffee', 'coffee, water, switch it on, wait ...'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (7, 5, 2, 'Drink coffee', 'Ahh, caffeine'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 4, 1, 'Deutsch', 'Deutsche Sprache'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 4, 2, 'English', 'English language'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 4, 2, 'Englisch', 'Englische Sprache'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 4, 1, 'German', 'German language'); http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/example.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/example.php +++ pear/LiveUser_Admin/docs/examples/example3/example.php <?php $language = ''; session_start(); if (isset($_POST['language'])) { $language = $_POST['language']; } elseif (isset($_SESSION['language'])) { $language = $_SESSION['language']; } else { $language = 'en'; } $_SESSION['language'] = $language; session_write_close(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html> <head> <title>Example 3</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <frameset cols="200,*" rows="*"> <frame name="nav" frameborder="0" scrolling="no" noresize="noresize" src="nav.php?language=<?php echo $language; ?>" /> <frame name="main" frameborder="0" src="main.php" /> <noframes> <body>Your browser does not handle frames!</body> </noframes> </frameset> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/index.html?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/index.html +++ pear/LiveUser_Admin/docs/examples/example3/index.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Example 3</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } table { border: 1px solid #000; border-top: 0px; border-right: 0px; border-spacing: 0px; border-collapse: collapse; } table td { width: 100px; border-top: 1px solid #000; border-right: 1px solid #000; padding: 5px; } --> </style> </head> <body> <h1>Test for the LiveUser class</h1> <p>This example is intended to be used with the Auth/DB and the Perm/DB_Medium driver.</p> <p>To set this up follow these steps:</p> <ol> <li>Copy the files in this directory into your web root.</li> <li>Configure your DSN and the PEAR path in the conf.php.</li> <li>Make sure you read README in the examples root folder. <ul> <li>This example is a Complex example, thus it needs perm_db_(simple|medium|complex).sql</li> </ul> </li> <li>Importing demodata.sql to the test database</li> </ol> <p>If you want to test this example in your local path with out installing LiveUser in PEAR on your server then uncomment these two lines in <b>conf.php</b> and point $path_to_liveuser_dir to live user dir :)<br /> <br /> $path_to_liveuser_dir = './pear/'.PATH_SEPARATOR;<br /> ini_set('include_path', $path_to_liveuser_dir.ini_get('include_path'));<br /> </p> <p><a href="example.php">Go for it.</a></p> <hr /> <p><i>Login Data for this Example:</i></p> <table> <tr> <td style="text-align: center; font-weight: bold;">Handle</th> <td style="text-align: center; font-weight: bold;">Password</th> </tr> <tr> <td>boss</td> <td>test</td> </tr> <tr> <td>hoss</td> <td>bonanza</td> </tr> </table> <p> </p> <p> </p> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/loginscreen.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/loginscreen.php +++ pear/LiveUser_Admin/docs/examples/example3/loginscreen.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>LiveUser Login Screen</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <body> <form name="loginform" method="post" action="<?php echo !isset($target) ? 'example.php' : $target; ?>"> <div class="center"> <table width="300" border="0" cellspacing="0" cellpadding="5"> <tr> <td colspan="2"><b>Example login</b></td> </tr> <tr> <td>Handle:</td> <td> <input type="text" name="handle" maxlength="80" value="" /> </td> </tr> <tr> <td>Password:</td> <td> <input type="password" name="passwd" maxlength="80" value="" /> </td> </tr> <tr> <td>Remember me:</td> <td> <input type="checkbox" name="rememberMe" /> </td> </tr> <tr> <td colspan="2"> <div class="center"> <input type="submit" name="x" value="Login" /> <input type="hidden" name="Submit" value="1" /> </div> </td> </tr> </table> </div> </form> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/main.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/main.php +++ pear/LiveUser_Admin/docs/examples/example3/main.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Example 3</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } --> </style> </head> <body> <h1>Greetings!</h1> <h3> </h3> <h3>Use the navigation to go for some action!</h3> <h3>If you like can change the navigation language use the select option an the left.</h3> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/nav.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/nav.php +++ pear/LiveUser_Admin/docs/examples/example3/nav.php <?php require_once 'conf.php'; require_once 'LiveUser/Admin/Perm/Container/DB_Simple.php'; $luadmin = new LiveUser_Admin_Perm_Container_DB_Simple($liveuserConfig['permContainer']); $language = (isset($_GET['language'])) ? $_GET['language'] : 'en'; $luadmin->setCurrentLanguage($language); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Navigation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <body> <h3>Navigation</h3> <table border="0" cellpadding="5"> <?php // get the area_define_name and the area_name of each area in current language. $areas = $luadmin->getAreas(); // print navigation foreach ($areas as $row) { ?> <tr> <td><li></td> <td><a href="<?php echo strtolower($row['define_name']); ?>.php" target="main"><?php echo $row['name']; ?></a></td> </tr> <?php } ?> </table> <p> </p> <form method="POST" action="example.php" target="_parent"> <select name="language" size="1" onChange="submit()"> <?php // get a list of languages $languages = $luadmin->getLanguages(array('with_translations' => true)); // print language options foreach ($languages as $code => $language) { $code == $_GET['language'] ? $selected = ' selected' : $selected = ''; ?> <option value="<?php echo $code;?>"<?php echo $selected; ?>><?php echo $language['name']; ?></option>'; <?php } ?> </select> </form> <p> </p> <p> </p> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/testarea.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/testarea.php +++ pear/LiveUser_Admin/docs/examples/example3/testarea.php <?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 DB_Medium Perm driver. * * @version $Id: testarea.php,v 1.1 2004/12/15 13:33:22 lsmith Exp $ **/ error_reporting(E_ALL); // right definitions define('READ_TESTS', 1); define('WRITE_TESTS', 2); // Include configuration. require_once 'conf.php'; // The error handling stuff is not needed and used only for debugging // while LiveUser is not yet mature PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'eHandler'); function eHandler($errObj) { echo('<hr /><span style="color: red;">' . $errObj->getMessage() . ':<br />' . $errObj->getUserinfo() . '</span><hr />'); } // Create new LiveUser object $LU = LiveUser::factory($liveuserConfig); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Example Testarea</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <body> <h1>Testarea</h1> <p> </p> <?php if (!$LU->isLoggedIn()) { $target = 'testarea.php'; include_once 'loginscreen.php'; exit(); } else { if (!$LU->checkRight(READ_TESTS) && !$LU->checkRight(WRITE_TESTS)) { ?> <p>Sorry, but you don't have any rights in this section</p> <?php } else { if ($LU->checkRight(READ_TESTS)) { ?> <p>Wow, you've the right to <b>read</b> the latest posting in this list!<br> OK, let's search the database for the last entry ...</p> <p>User: <b><?php echo $LU->getProperty('handle'); ?></b><br>LastLogin: <b><?php echo strftime('%Y-%m-%d %H:%M', $LU->getProperty('lastLogin')); ?></b><br> <pre>Hi!<br>I'm just testing whether this really cool LiveUser program works :-)<br> Hmm, think it runs perfect!</pre> <?php } } } ?> <p> </p> <p> <?php // let's see if the user is allowed to post something if ($LU->checkRight(WRITE_TESTS)) { $disabled = ''; # end the textarea tag $text = 'Type something.'; } else { $disabled = 'disabled="disabled"'; # disable the textarea tag $text = 'No, you don\'t have the right to post something in this list.'; } ?> <textarea name="textfield" cols="80" rows="10" <?php echo $disabled ?>> <?php echo $text; ?> </textarea> </p> <p> </p> <p class="center"><a href="testarea.php?logout=1">Logout</a></p> </body> </html>
http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/area51.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/area51.php +++ pear/LiveUser_Admin/docs/examples/example3/area51.php <?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 DB_Medium Perm driver. * * @version $Id: area51.php,v 1.1 2004/12/15 13:33:22 lsmith Exp $ **/ error_reporting(E_ALL); // right definitions define('ACCESS', 3); define('LAUNCH_ATOMIC_BOMB', 4); define('FLY_ALIEN_SPACE_CRAFT', 5); // Include configuration. require_once 'conf.php'; // The error handling stuff is not needed and used only for debugging // while LiveUser is not yet mature PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'eHandler'); function eHandler($errObj) { echo('<hr /><span style="color: red;">' . $errObj->getMessage() . ':<br />' . $errObj->getUserinfo() . '</span><hr />'); } // Create new LiveUser object $LU = LiveUser::factory($liveuserConfig); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Example Area51</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <body> <h1>Area51</h1> <p> </p> <?php if (!$LU->isLoggedIn()) { $target = 'area51.php'; include_once 'loginscreen.php'; exit(); } else { if (!$LU->checkRight(ACCESS)) { ?> <p>Hey, this is a top secret area. Access denied.</p> <?php } else { ?> <p>Live long and prosper, <b><?php echo $LU->getProperty('handle'); ?> </b>.</p> <p>You have access at the necessary level <b><?php echo $LU->checkRightLevel(ACCESS, 1, 0); ?></b></p> <p>Please wait ... checking some rights ...<br /> <?php // you can even check multiple rights with one checkright call if ($LU->checkRight(array(LAUNCH_ATOMIC_BOMB, FLY_ALIEN_SPACE_CRAFT))) { ?> <p>OK, you're the boss. Let's take our alien space craft, launch the orbital atomic bombs and kick some ass! ;-)<br /> (Ehm, that was just to test our right system ...)<p> <?php } else { ?> <p>Don't touch anything!</p> <?php } } } ?> <p> </p> <p class="center"><a href="area51.php?logout=1">Logout</a></p> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/coffeemaker.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/coffeemaker.php +++ pear/LiveUser_Admin/docs/examples/example3/coffeemaker.php <?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 DB_Medium Perm driver. * * @version $Id: coffeemaker.php,v 1.1 2004/12/15 13:33:22 lsmith Exp $ **/ error_reporting(E_ALL); // right definitions define('MAKE_COFFEE', 6); define('DRINK_COFFEE', 7); // Include configuration. require_once 'conf.php'; // The error handling stuff is not needed and used only for debugging // while LiveUser is not yet mature PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'eHandler'); function eHandler($errObj) { echo('<hr /><span style="color: red;">' . $errObj->getMessage() . ':<br />' . $errObj->getUserinfo() . '</span><hr />'); } // Create new LiveUser object $LU = LiveUser::factory($liveuserConfig); if (!$LU) { die('An unknown error occurred'); } // we have an error stack if (is_array($LU)) { echo 'One or more errors occurred, here is the array'; print_r($LU); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Example Coffeemaker</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <body> <h1>Welcome in the Coffeemaker section!</h1> <p> </p> <?php // check login status if (!$LU->isLoggedIn()) { $target = 'coffeemaker.php'; include_once 'loginscreen.php'; exit(); } else { if (!$LU->checkRight(MAKE_COFFEE) && !$LU->checkRight(DRINK_COFFEE)) { ?> <p>Sorry, but you don't have any rights in this section</p> <?php } else { // 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 and we want to // know whether to user is allowed to make some coffee // (the area is not needed until we won't know whether our user is an area // admin). if ($LU->checkRight(MAKE_COFFEE)) { ?> <p>Congrats, you're in the Coffeemaker section and have the right to make coffee!</p> <?php } else { ?> <p>Your coffee tastes so bad, I won't allow you to make some</p> <?php } // check if the user is allowed to drink coffee. checkRight will return the level. if ($LU->checkRight(DRINK_COFFEE) == 1) { ?> <p>Yey ! You can even drink some coffee (but perhaps you should ask your boss first ;-) ))</p> <?php } elseif ($LU->checkRight(DRINK_COFFEE) == 3) { ?> <p>Hi <?php echo $LU->getProperty('handle'); ?>! Taste this delicious coffee.</p> <?php } else { ?> <p>Well, sorry dude, you cannot drink in here</p> <?php } } } ?> <p> </p> <p class="center"><a href="coffeemaker.php?logout=1">Logout</a></p> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/conf.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/conf.php +++ pear/LiveUser_Admin/docs/examples/example3/conf.php <?php // BC hack if (!defined('PATH_SEPARATOR')) { if (defined('DIRECTORY_SEPARATOR') && DIRECTORY_SEPARATOR == "\\") { define('PATH_SEPARATOR', ';'); } else { define('PATH_SEPARATOR', ':'); } } // set this to the path in which the directory for liveuser resides // more remove the following two lines to test LiveUser in the standard // PEAR directory //$path_to_liveuser_dir = './pear/'.PATH_SEPARATOR; //ini_set('include_path', $path_to_liveuser_dir.ini_get('include_path')); // Data Source Name (DSN) $dsn = 'mysql://root@localhost/liveuser_test'; $liveuserConfig = array( 'session' => array('name' => 'PHPSESSID','varname' => 'loginInfo'), 'login' => array('username' => 'handle', 'password' => 'passwd', 'remember' => 'rememberMe'), 'logout' => array('trigger' => 'logout', 'destroy' => true, 'method' => 'get'), 'cookie' => array('name' => 'loginInfo', 'path' => '/', 'domain' => '', 'lifetime' => 30, 'secret' => 'mysecretkey'), 'autoInit' => true, 'authContainers' => array('DB' => array( 'type' => 'DB', 'dsn' => $dsn, 'loginTimeout' => 0, 'expireTime' => 0, 'idleTime' => 0, 'allowDuplicateHandles' => 1, 'passwordEncryptionMode' => 'PLAIN', 'authTableCols' => array( 'required' => array( 'auth_user_id' => array('name' => 'auth_user_id', 'type' => 'text'), 'handle' => array('name' => 'handle', 'type' => 'text'), 'passwd' => array('name' => 'passwd', 'type' => 'text'), ), 'optional' => array( 'lastlogin' => array('name' => 'lastlogin', 'type' => 'timestamp'), 'is_active' => array('name' => 'is_active', 'type' => 'boolean') ) ) ) ), 'permContainer' => array( 'type' => 'Complex', 'storage' => array( 'DB' => array( 'dsn' => $dsn, 'prefix' => 'liveuser_', 'groupTableCols' => array( 'required' => array( 'group_id' => array('type' => 'integer', 'name' => 'group_id'), 'group_define_name' => array('type' => 'text', 'name' => 'group_define_name') ), 'optional' => array( 'group_type' => array('type' => 'integer', 'name' => 'group_type'), 'is_active' => array('type' => 'boolean', 'name' => 'is_active'), 'owner_user_id' => array('type' => 'integer', 'name' => 'owner_user_id'), 'owner_group_id' => array('type' => 'integer', 'name' => 'owner_group_id') ) ) ) ) ) ); // Get LiveUser class definition require_once 'LiveUser.php'; http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/demodata.sql?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/demodata.sql +++ pear/LiveUser_Admin/docs/examples/example3/demodata.sql # $Id: demodata.sql,v 1.1 2004/12/15 13:33:22 lsmith Exp $ # # Table structure for table 'liveuser_languages' # CREATE TABLE `liveuser_languages` ( `language_id` smallint(5) unsigned NOT NULL default '0', `two_letter_name` char(2) NOT NULL default '', PRIMARY KEY (`language_id`), UNIQUE KEY `two_letter_name` (`two_letter_name`) ); # # Table structure for table 'liveuser_translations' # CREATE TABLE `liveuser_translations` ( `section_id` int(11) unsigned NOT NULL default '0', `section_type` tinyint(3) unsigned NOT NULL default '0', `language_id` smallint(5) unsigned NOT NULL default '0', `name` varchar(50) NOT NULL default '', `description` varchar(255) default NULL, PRIMARY KEY (`section_id`,`section_type`, `language_id`) ); # Dumping data for table `liveuser_users` # INSERT INTO liveuser_users (auth_user_id, handle, passwd, lastlogin, owner_user_id, owner_group_id, is_active) VALUES ('c4ca4238a0b923820dcc509a6f75849b', 'boss', 'test', NULL, NULL, 1, 'Y'); INSERT INTO liveuser_users (auth_user_id, handle, passwd, lastlogin, owner_user_id, owner_group_id, is_active) VALUES ('c81e728d9d4c2f636f067f89cc14862c', 'hoss', 'bonanza', NULL, 1, NULL, 'Y'); # # Dumping data for table `liveuser_areas` # INSERT INTO liveuser_areas (area_id, application_id, area_define_name) VALUES (1, 0, 'TestArea'); INSERT INTO liveuser_areas (area_id, application_id, area_define_name) VALUES (2, 0, 'Area51'); INSERT INTO liveuser_areas (area_id, application_id, area_define_name) VALUES (3, 0, 'Coffeemaker'); # # Dumping data for table `liveuser_grouprights` # INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (1, 1, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (1, 2, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (1, 7, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (2, 3, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (2, 4, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (2, 5, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (2, 6, 1); INSERT INTO liveuser_grouprights (group_id, right_id, right_level) VALUES (2, 7, 1); # # Dumping data for table `liveuser_groups` # INSERT INTO liveuser_groups (group_id, owner_user_id, owner_group_id, is_active, group_define_name) VALUES (1, 1, 1, 'Y', 'Group1'); INSERT INTO liveuser_groups (group_id, owner_user_id, owner_group_id, is_active, group_define_name) VALUES (2, 1, 1, 'Y', 'Group2'); # # Dumping data for table `liveuser_groupusers` # INSERT INTO liveuser_groupusers (perm_user_id, group_id) VALUES (1, 1); INSERT INTO liveuser_groupusers (perm_user_id, group_id) VALUES (1, 2); INSERT INTO liveuser_groupusers (perm_user_id, group_id) VALUES (2, 1); # # Dumping data for table `liveuser_languages` # INSERT INTO liveuser_languages (language_id, two_letter_name) VALUES (1, 'de'); INSERT INTO liveuser_languages (language_id, two_letter_name) VALUES (2, 'en'); # # Dumping data for table `liveuser_perm_users` # INSERT INTO liveuser_perm_users (perm_user_id, auth_user_id, perm_type, auth_container_name) VALUES (1, 'c4ca4238a0b923820dcc509a6f75849b', 1, 'DB'); INSERT INTO liveuser_perm_users (perm_user_id, auth_user_id, perm_type, auth_container_name) VALUES (2, 'c81e728d9d4c2f636f067f89cc14862c', 1, 'DB'); # # Dumping data for table `liveuser_rights` # INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (1, 1, 'READ_TESTS', 'N', 'N'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (2, 1, 'WRITE_TESTS', 'N', 'N'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (3, 2, 'ACCESS', 'N', 'Y'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (4, 2, 'LAUNCH_ATOMIC_BOMB', 'N', 'N'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (5, 2, 'FLY_ALIEN_SPACE_CRAFT', 'N', 'N'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (6, 3, 'MAKE_COFFEE', 'N', 'N'); INSERT INTO liveuser_rights (right_id, area_id, right_define_name, has_implied, has_level) VALUES (7, 3, 'DRINK_COFFEE', 'N', 'Y'); # # Dumping data for table `liveuser_userrights` # INSERT INTO liveuser_userrights (perm_user_id, right_id, right_level) VALUES (1, 3, 3); INSERT INTO liveuser_userrights (perm_user_id, right_id, right_level) VALUES (1, 7, 3); # # Dumping data for table `liveuser_translations` # INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 2, 1, 'TestGebiet', 'Ein G ebiet zum testen.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 2, 2, 'TestArea', 'An Area for testing.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 2, 1, 'Area51', 'Jeder ken nt dieses Gebiet.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 2, 2, 'Area51', 'Everybody knows this area.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (3, 2, 1, 'Kaffeemaschine', 'K affeemaschine Typ 165-X'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (3, 2, 2, 'Coffeemaker', 'Coff eemaker type 165-X.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 3, 1, 'Dummies', 'Die Dumm y-Gruppe'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 3, 2, 'Dummies', 'The dummy group'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 3, 1, 'Genies', 'Die wahren Genies (verkannt, aber brilliant)'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 3, 2, 'Genies', 'The true genii (unrecognized but brilliant)'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 5, 1, 'Lesen', 'Der Benutzer darf etwas lesen.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 5, 1, 'Schreiben', 'Der Benutzer darf etwas schreiben.'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (3, 5, 1, 'Zugangang', '"Sesam ?ffne dich"-Recht'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (4, 5, 1, 'Feuer', 'Atombombe z?nden'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (5, 5, 1, 'Lift up', 'Alien Raumschiff fliegen'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (6, 5, 1, 'Kaffee machen', 'Kaffeepulver, Wasser, einschalten, warten ...'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (7, 5, 1, 'Kaffee trinken', 'Ahh, Koffein'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 5, 2, 'Read', 'Read authority'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 5, 2, 'Write', 'Write something new'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (3, 5, 2, 'Access', 'Open the doors'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (4, 5, 2, 'Fire', 'Launch the atomic bombs'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (5, 5, 2, 'Lift up', 'Let\'s fly an alian space craft'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (6, 5, 2, 'Make coffee', 'coffee, water, switch it on, wait ...'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (7, 5, 2, 'Drink coffee', 'Ahh, caffeine'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 4, 1, 'Deutsch', 'Deutsche Sprache'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 4, 2, 'English', 'English language'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (1, 4, 2, 'Englisch', 'Englische Sprache'); INSERT INTO liveuser_translations (section_id, section_type, language_id, name, description) VALUES (2, 4, 1, 'German', 'German language'); http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/example.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/example.php +++ pear/LiveUser_Admin/docs/examples/example3/example.php <?php $language = ''; session_start(); if (isset($_POST['language'])) { $language = $_POST['language']; } elseif (isset($_SESSION['language'])) { $language = $_SESSION['language']; } else { $language = 'en'; } $_SESSION['language'] = $language; session_write_close(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html> <head> <title>Example 3</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <frameset cols="200,*" rows="*"> <frame name="nav" frameborder="0" scrolling="no" noresize="noresize" src="nav.php?language=<?php echo $language; ?>" /> <frame name="main" frameborder="0" src="main.php" /> <noframes> <body>Your browser does not handle frames!</body> </noframes> </frameset> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/index.html?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/index.html +++ pear/LiveUser_Admin/docs/examples/example3/index.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Example 3</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } table { border: 1px solid #000; border-top: 0px; border-right: 0px; border-spacing: 0px; border-collapse: collapse; } table td { width: 100px; border-top: 1px solid #000; border-right: 1px solid #000; padding: 5px; } --> </style> </head> <body> <h1>Test for the LiveUser class</h1> <p>This example is intended to be used with the Auth/DB and the Perm/DB_Medium driver.</p> <p>To set this up follow these steps:</p> <ol> <li>Copy the files in this directory into your web root.</li> <li>Configure your DSN and the PEAR path in the conf.php.</li> <li>Make sure you read README in the examples root folder. <ul> <li>This example is a Complex example, thus it needs perm_db_(simple|medium|complex).sql</li> </ul> </li> <li>Importing demodata.sql to the test database</li> </ol> <p>If you want to test this example in your local path with out installing LiveUser in PEAR on your server then uncomment these two lines in <b>conf.php</b> and point $path_to_liveuser_dir to live user dir :)<br /> <br /> $path_to_liveuser_dir = './pear/'.PATH_SEPARATOR;<br /> ini_set('include_path', $path_to_liveuser_dir.ini_get('include_path'));<br /> </p> <p><a href="example.php">Go for it.</a></p> <hr /> <p><i>Login Data for this Example:</i></p> <table> <tr> <td style="text-align: center; font-weight: bold;">Handle</th> <td style="text-align: center; font-weight: bold;">Password</th> </tr> <tr> <td>boss</td> <td>test</td> </tr> <tr> <td>hoss</td> <td>bonanza</td> </tr> </table> <p> </p> <p> </p> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/loginscreen.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/loginscreen.php +++ pear/LiveUser_Admin/docs/examples/example3/loginscreen.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>LiveUser Login Screen</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <body> <form name="loginform" method="post" action="<?php echo !isset($target) ? 'example.php' : $target; ?>"> <div class="center"> <table width="300" border="0" cellspacing="0" cellpadding="5"> <tr> <td colspan="2"><b>Example login</b></td> </tr> <tr> <td>Handle:</td> <td> <input type="text" name="handle" maxlength="80" value="" /> </td> </tr> <tr> <td>Password:</td> <td> <input type="password" name="passwd" maxlength="80" value="" /> </td> </tr> <tr> <td>Remember me:</td> <td> <input type="checkbox" name="rememberMe" /> </td> </tr> <tr> <td colspan="2"> <div class="center"> <input type="submit" name="x" value="Login" /> <input type="hidden" name="Submit" value="1" /> </div> </td> </tr> </table> </div> </form> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/main.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/main.php +++ pear/LiveUser_Admin/docs/examples/example3/main.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Example 3</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } --> </style> </head> <body> <h1>Greetings!</h1> <h3> </h3> <h3>Use the navigation to go for some action!</h3> <h3>If you like can change the navigation language use the select option an the left.</h3> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/nav.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/nav.php +++ pear/LiveUser_Admin/docs/examples/example3/nav.php <?php require_once 'conf.php'; require_once 'LiveUser/Admin/Perm/Container/DB_Simple.php'; $luadmin = new LiveUser_Admin_Perm_Container_DB_Simple($liveuserConfig['permContainer']); $language = (isset($_GET['language'])) ? $_GET['language'] : 'en'; $luadmin->setCurrentLanguage($language); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Navigation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <body> <h3>Navigation</h3> <table border="0" cellpadding="5"> <?php // get the area_define_name and the area_name of each area in current language. $areas = $luadmin->getAreas(); // print navigation foreach ($areas as $row) { ?> <tr> <td><li></td> <td><a href="<?php echo strtolower($row['define_name']); ?>.php" target="main"><?php echo $row['name']; ?></a></td> </tr> <?php } ?> </table> <p> </p> <form method="POST" action="example.php" target="_parent"> <select name="language" size="1" onChange="submit()"> <?php // get a list of languages $languages = $luadmin->getLanguages(array('with_translations' => true)); // print language options foreach ($languages as $code => $language) { $code == $_GET['language'] ? $selected = ' selected' : $selected = ''; ?> <option value="<?php echo $code;?>"<?php echo $selected; ?>><?php echo $language['name']; ?></option>'; <?php } ?> </select> </form> <p> </p> <p> </p> </body> </html> http://cvs.php.net/co.php/pear/LiveUser_Admin/docs/examples/example3/testarea.php?r=1.1&p=1 Index: pear/LiveUser_Admin/docs/examples/example3/testarea.php +++ pear/LiveUser_Admin/docs/examples/example3/testarea.php <?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 DB_Medium Perm driver. * * @version $Id: testarea.php,v 1.1 2004/12/15 13:33:22 lsmith Exp $ **/ error_reporting(E_ALL); // right definitions define('READ_TESTS', 1); define('WRITE_TESTS', 2); // Include configuration. require_once 'conf.php'; // The error handling stuff is not needed and used only for debugging // while LiveUser is not yet mature PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'eHandler'); function eHandler($errObj) { echo('<hr /><span style="color: red;">' . $errObj->getMessage() . ':<br />' . $errObj->getUserinfo() . '</span><hr />'); } // Create new LiveUser object $LU = LiveUser::factory($liveuserConfig); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Example Testarea</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- table { background-color: #CCCCCC; border-color: 1px solid #000; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFFF } .center { text-align: center; } .center table { margin: auto; } --> </style> </head> <body> <h1>Testarea</h1> <p> </p> <?php if (!$LU->isLoggedIn()) { $target = 'testarea.php'; include_once 'loginscreen.php'; exit(); } else { if (!$LU->checkRight(READ_TESTS) && !$LU->checkRight(WRITE_TESTS)) { ?> <p>Sorry, but you don't have any rights in this section</p> <?php } else { if ($LU->checkRight(READ_TESTS)) { ?> <p>Wow, you've the right to <b>read</b> the latest posting in this list!<br> OK, let's search the database for the last entry ...</p> <p>User: <b><?php echo $LU->getProperty('handle'); ?></b><br>LastLogin: <b><?php echo strftime('%Y-%m-%d %H:%M', $LU->getProperty('lastLogin')); ?></b><br> <pre>Hi!<br>I'm just testing whether this really cool LiveUser program works :-)<br> Hmm, think it runs perfect!</pre> <?php } } } ?> <p> </p> <p> <?php // let's see if the user is allowed to post something if ($LU->checkRight(WRITE_TESTS)) { $disabled = ''; # end the textarea tag $text = 'Type something.'; } else { $disabled = 'disabled="disabled"'; # disable the textarea tag $text = 'No, you don\'t have the right to post something in this list.'; } ?> <textarea name="textfield" cols="80" rows="10" <?php echo $disabled ?>> <?php echo $text; ?> </textarea> </p> <p> </p> <p class="center"><a href="testarea.php?logout=1">Logout</a></p> </body> </html>