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

Source for file testarea.php

Documentation is available at testarea.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: testarea.php,v 1.8 2004/09/18 19:28:15 dufuz Exp $
  14.  ***/
  15.  
  16. // right definitions
  17. define('READ_TESTS'1);
  18. define('WRITE_TESTS'2);
  19.  
  20. // Include configuration.
  21. require_once 'conf.php';
  22.  
  23. // The error handling stuff is not needed and used only for debugging
  24. // while LiveUser is not yet mature
  25. PEAR::setErrorHandling(PEAR_ERROR_CALLBACK'eHandler');
  26.  
  27. function eHandler($errObj)
  28. {
  29.     echo('<hr /><span style="color: red;">' $errObj->getMessage(':<br />' $errObj->getUserinfo('</span><hr />');
  30. }
  31.  
  32. // Create new LiveUser object
  33. $LU LiveUser::factory($liveuserConfig);
  34. ?>
  35. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  36. <html>
  37. <head>
  38.     <title>Example Testarea</title>
  39.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  40.     <style type="text/css">
  41.     <!--
  42.     table {
  43.         background-color: #CCCCCC;
  44.         border-color: 1px solid #000;
  45.     }
  46.     body {
  47.         font-family: Verdana, Arial, Helvetica, sans-serif;
  48.         font-size: 12px;
  49.         color: #000000;
  50.         background-color: #FFFFFF
  51.     }
  52.  
  53.     .center {
  54.         text-align: center;
  55.     }
  56.     .center table {
  57.         margin: auto;
  58.     }
  59.     -->
  60.     </style>
  61. </head>
  62.  
  63. <body>
  64.     <h1>Testarea</h1>
  65.     <p>&nbsp;</p>
  66. <?php
  67. if (!$LU->isLoggedIn()) {
  68.     $target 'testarea.php';
  69.     include_once 'loginscreen.php';
  70.     exit();
  71. else {
  72.     if (!$LU->checkRight(READ_TESTS&& !$LU->checkRight(WRITE_TESTS)) {
  73. ?>
  74.         <p>Sorry, but you don't have any rights in this section</p>
  75. <?php
  76.     else {
  77.         if ($LU->checkRight(READ_TESTS)) {
  78. ?>
  79.            <p>Wow, you've the right to <b>read</b> the latest posting in this list!<br>
  80.            OK, let's search the database for the last entry ...</p>
  81.            <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>
  82.            <pre>Hi!<br>I'm just testing whether this really cool LiveUser program works :-)<br>
  83.            Hmm, think it runs perfect!</pre>
  84. <?php
  85.         }
  86.     }
  87. }
  88. ?>
  89.     <p>&nbsp;</p>
  90.     <p>
  91. <?php
  92.   // let's see if the user is allowed to post something
  93.   if ($LU->checkRight(WRITE_TESTS)) {
  94.      $disabled =  ''# end the textarea tag
  95.      $text 'Type something.';
  96.   else {
  97.      $disabled 'disabled="disabled"'# disable the textarea tag
  98.      $text 'No, you don\'t have the right to post something in this list.';
  99.   }
  100.  
  101. ?>
  102.         <textarea name="textfield" cols="80" rows="10" <?php echo $disabled ?>>
  103.             <?php echo $text?>
  104.         </textarea>
  105.     </p>
  106.     <p>&nbsp;</p>
  107.     <p class="center"><a href="testarea.php?logout=1">Logout</a></p>
  108. </body>
  109. </html>

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