LiveUser
[ class tree: LiveUser ] [ index: LiveUser ] [ all elements ]

Source for file area51.php

Documentation is available at area51.php

  1. <?php
  2. /**
  3.  * Test for the LiveUser class
  4.  * ===============================
  5.  *
  6.  * This example sets up an authorization system using the LiveUser
  7.  * class. You don't have to use this to use the LiveUser class(es), but
  8.  * this way you don't need to take care of the login-process, storing
  9.  * the user object in a session and more...
  10.  *
  11.  * This example is intended to be used with the DB_Medium Perm driver.
  12.  *
  13.  * @version $Id: area51.php,v 1.8 2004/04/27 00:26:26 mscifo Exp $
  14.  ***/
  15.  
  16. // right definitions
  17. define('ACCESS'3);
  18. define('LAUNCH_ATOMIC_BOMB'4);
  19. define('FLY_ALIEN_SPACE_CRAFT'5);
  20.  
  21. // Include configuration.
  22. require_once 'conf.php';
  23.  
  24. // The error handling stuff is not needed and used only for debugging
  25. // while LiveUser is not yet mature
  26. PEAR::setErrorHandling(PEAR_ERROR_CALLBACK'eHandler');
  27.  
  28. function eHandler($errObj)
  29. {
  30.     echo('<hr /><span style="color: red;">' $errObj->getMessage(':<br />' $errObj->getUserinfo('</span><hr />');
  31. }
  32.  
  33. // Create new LiveUser object
  34. $LU LiveUser::factory($liveuserConfig);
  35. ?>
  36. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  37. <html>
  38. <head>
  39.     <title>Example Area51</title>
  40.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  41.     <style type="text/css">
  42.     <!--
  43.     table {
  44.         background-color: #CCCCCC;
  45.         border-color: 1px solid #000;
  46.     }
  47.     body {
  48.         font-family: Verdana, Arial, Helvetica, sans-serif;
  49.         font-size: 12px;
  50.         color: #000000;
  51.         background-color: #FFFFFF
  52.     }
  53.  
  54.     .center {
  55.            text-align: center;
  56.     }
  57.     .center table {
  58.            margin: auto;
  59.     }
  60.     -->
  61.     </style>
  62. </head>
  63.  
  64. <body>
  65.     <h1>Area51</h1>
  66.     <p>&nbsp;</p>
  67. <?php
  68. if (!$LU->isLoggedIn()) {
  69.     $target 'area51.php';
  70.     include_once 'loginscreen.php';
  71.     exit();
  72. else {
  73.     if (!$LU->checkRight(ACCESS)) {
  74. ?>
  75.         <p>Hey, this is a top secret area. Access denied.</p>
  76. <?php
  77.     else {
  78. ?>
  79.             <p>Live long and prosper, <b><?php echo $LU->getProperty('handle')?> </b>.</p>
  80.             <p>You have access at the necessary level <b><?php echo $LU->checkRightLevel(ACCESS10)?></b></p>
  81.             <p>Please wait ... checking some rights ...<br />
  82. <?php
  83.         // you can even check multiple rights with one checkright call
  84.         if ($LU->checkRight(array(LAUNCH_ATOMIC_BOMBFLY_ALIEN_SPACE_CRAFT))) {
  85. ?>
  86.             <p>OK, you're the boss. Let's take our alien space craft, launch the orbital atomic bombs and kick some ass! ;-)<br />
  87.             (Ehm, that was just to test our right system ...)<p>
  88. <?php
  89.         else {
  90. ?>
  91.             <p>Don't touch anything!</p>
  92. <?php
  93.         }
  94.     }
  95. }
  96. ?>
  97.     <p>&nbsp;</p>
  98.     <p class="center"><a href="area51.php?logout=1">Logout</a></p>
  99. </body>
  100. </html>

Documentation generated on Mon, 11 Mar 2019 13:56:15 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.