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

Source for file conf.php

Documentation is available at conf.php

  1. <?php
  2. // BC hack
  3. if (!defined('PATH_SEPARATOR')) {
  4.     if (defined('DIRECTORY_SEPARATOR'&& DIRECTORY_SEPARATOR == '\\'{
  5.         define('PATH_SEPARATOR'';');
  6.     else {
  7.         define('PATH_SEPARATOR'':');
  8.     }
  9. }
  10.  
  11. require_once 'PEAR.php';
  12.  
  13. // The error handling stuff is not needed and used only for debugging
  14. // while LiveUser is not yet mature
  15. PEAR::setErrorHandling(PEAR_ERROR_CALLBACK'eHandler');
  16.  
  17. function eHandler($errObj)
  18. {
  19.     echo('<hr /><span style="color: red">' $errObj->getMessage(':<br />'$errObj->getUserInfo('</span><hr />');
  20. }
  21.  
  22. // set this to the path in which the directory for liveuser resides
  23. // more remove the following two lines to test LiveUser in the standard
  24. // PEAR directory
  25. # $path_to_liveuser_dir = 'PEAR/'.PATH_SEPARATOR;
  26. # ini_set('include_path', $path_to_liveuser_dir.ini_get('include_path') );
  27.  
  28. $xml_is_readable is_readable('Auth_XML.xml');
  29. $xml_is_writable is_writable('Auth_XML.xml');
  30.  
  31. if ($xml_is_readable != false && $xml_is_writable != false{
  32.     $liveuserConfig = array(
  33.         'cookie'            => array(
  34.             'name' => 'loginInfo',
  35.             'path' => '',
  36.             'domain' => '',
  37.             'lifetime' => 30,
  38.             'savedir' => '.',
  39.             'secure' => false,
  40.         ),
  41.         'authContainers'    => array(
  42.             0 => array(
  43.                 'type' => 'XML',
  44.                 'expireTime'   => 3600,
  45.                 'idleTime'     => 1800,
  46.                 'passwordEncryptionMode' => 'MD5',
  47.                 'storage' => array(
  48.                     'file' => 'Auth_XML.xml',
  49.                     'alias' => array(
  50.                         'auth_user_id' =>   'userId',
  51.                         'passwd' =>         'password',
  52.                         'lastlogin' =>      'lastLogin',
  53.                         'is_active' =>      'isActive',
  54.                     ),
  55.                     'tables' => array(
  56.                         'users' => array(
  57.                             'fields' => array(
  58.                                 'lastlogin'         => false,
  59.                                 'is_active'         => false,
  60.                                 'owner_user_id'     => false,
  61.                                 'owner_group_id'    => false,
  62.                             ),
  63.                         ),
  64.                     ),
  65.                     'fields' => array(
  66.                         'lastlogin'         => 'timestamp',
  67.                         'is_active'         => 'boolean',
  68.                         'owner_user_id'     => 'integer',
  69.                         'owner_group_id'    => 'integer',
  70.                     ),
  71.                 ),
  72.            ),
  73.         ),
  74.         'permContainer'     => array(
  75.             'type'  => 'Simple',
  76.             'storage' => array('XML' => array('file' => 'Perm_XML.xml')),
  77.         ),
  78.     );
  79.     // Get LiveUser class definition
  80.     require_once 'LiveUser.php';
  81.  
  82.     // right definitions
  83.     define('COOKING',               1);
  84.     define('WASHTHEDISHES',         2);
  85.     define('WATCHTV',               3);
  86.     define('WATCHLATENIGHTTV',      4);
  87.     define('USETHECOMPUTER',        5);
  88.     define('CONNECTINGTHEINTERNET'6);
  89.  
  90.     // Create new LiveUser (LiveUser) object.
  91.     
  92.     $LU =LiveUser::factory($liveuserConfig);
  93.  
  94.     if (!$LU->init()) {
  95.         var_dump($LU->getErrors());
  96.         die();
  97.     }
  98.  
  99.     $handle array_key_exists('handle'$_REQUEST$_REQUEST['handle': null;
  100.     $password array_key_exists('password'$_REQUEST$_REQUEST['password': null;
  101.     $logout array_key_exists('logout'$_REQUEST$_REQUEST['logout': null;
  102.     $remember array_key_exists('remember'$_REQUEST$_REQUEST['remember': null;
  103.     if ($logout{
  104.         $LU->logout(true);
  105.     elseif(!$LU->isLoggedIn(|| ($handle && $LU->getProperty('handle'!= $handle)) {
  106.         if (!$handle{
  107.             $LU->login(nullnulltrue);
  108.         else {
  109.             $LU->login($handle$password$remember);
  110.         }
  111.     }
  112.  
  113.     var_dump($LU->statusMessage($LU->getStatus()));
  114. }
  115.  
  116. ?>

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