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

Source for file conf.php

Documentation is available at conf.php

  1. <?php
  2.  
  3. define('EMAIL_WEBMASTER''krausbn@php.net');
  4.  
  5. // PEAR path
  6. //$path_to_liveuser_dir = 'path/to/pear/'.PATH_SEPARATOR;
  7. //ini_set('include_path', $path_to_liveuser_dir . ini_get('include_path'));
  8.  
  9.  
  10. require_once 'PEAR.php';
  11. include_once 'HTML/Template/IT.php';
  12. require_once 'MDB2.php';
  13.  
  14. function php_error_handler($errno$errstr$errfile$errline)
  15. {
  16. return;
  17.     if (error_reporting(&& $errno != 2048{
  18.         $tpl = new HTML_Template_IT();
  19.         $tpl->loadTemplatefile('error-page.tpl.php');
  20.  
  21.         $tpl->setVariable('error_msg'"<b>$errfile ($errline)</b><br />$errstr");
  22.         $tpl->show();
  23.         exit();
  24.     }
  25. }
  26.  
  27. set_error_handler('php_error_handler');
  28.  
  29. function pear_error_handler($err_obj)
  30. {
  31.     $error_string $err_obj->getMessage('<br />' $err_obj->getUserInfo();
  32.     trigger_error($error_stringE_USER_ERROR);
  33. }
  34.  
  35. PEAR::setErrorHandling(PEAR_ERROR_CALLBACK'pear_error_handler');
  36.  
  37. // Data Source Name (DSN)
  38. //$dsn = '{dbtype}://{user}:{passwd}@{dbhost}/{dbname}';
  39. $dsn 'mysql://root:@localhost/liveuser_test_example4';
  40.  
  41. $db =MDB2::connect($dsntrue);
  42. $db->setFetchMode(MDB2_FETCHMODE_ASSOC);
  43.  
  44.  
  45. $tpl = new HTML_Template_IT();
  46.  
  47. $LUOptions = array(
  48.     'login' => array(
  49.         'force'    => true
  50.      ),
  51.     'logout' => array(
  52.         'destroy'  => true,
  53.      ),
  54.     'authContainers' => array(
  55.         array(
  56.             'type'         => 'MDB2',
  57.             'loginTimeout' => 0,
  58.             'expireTime'   => 3600,
  59.             'idleTime'     => 1800,
  60.             'allowDuplicateHandles' => 0,
  61.             'storage' => array(
  62.                 'dsn' => $dsn,
  63.                 'alias' => array(
  64.                     'auth_user_id' => 'authUserId',
  65.                     'lastlogin' => 'lastLogin',
  66.                     'is_active' => 'isActive',
  67.                     'owner_user_id' => 'owner_user_id',
  68.                     'owner_group_id' => 'owner_group_id',
  69.                     'users' => 'peoples',
  70.                 ),
  71.                 'fields' => array(
  72.                     'lastlogin' => 'timestamp',
  73.                     'is_active' => 'boolean',
  74.                     'owner_user_id' => 'integer',
  75.                     'owner_group_id' => 'integer',
  76.                 ),
  77.                 'tables' => array(
  78.                     'users' => array(
  79.                         'fields' => array(
  80.                             'lastlogin' => false,
  81.                             'is_active' => false,
  82.                             'owner_user_id' => false,
  83.                             'owner_group_id' => false,
  84.                         ),
  85.                     ),
  86.                 ),
  87.             ),
  88.         ),
  89.         array(
  90.             'type' => 'XML',
  91.             'loginTimeout' => 0,
  92.             'expireTime'   => 3600,
  93.             'idleTime'     => 1800,
  94.             'allowDuplicateHandles'  => false,
  95.             'passwordEncryptionMode' => 'MD5',
  96.             'storage' => array(
  97.                 'file' => 'Auth_XML.xml',
  98.                 'alias' => array(
  99.                     'auth_user_id' => 'userId',
  100.                     'passwd' => 'password',
  101.                     'lastlogin' => 'lastLogin',
  102.                     'is_active' => 'isActive',
  103.                 ),
  104.             ),
  105.         ),
  106.     ),
  107.     'permContainer' => array(
  108.         'type' => 'Complex',
  109.         'storage' => array(
  110.             'MDB2' => array(
  111.                 'dsn' => $dsn,
  112.                 'prefix' => 'liveuser_',
  113.                 'alias' => array(
  114.                     'perm_users' => 'perm_peoples',
  115.                 ),
  116.             )
  117.          ),
  118.     ),
  119. );
  120.  
  121. require_once 'LiveUser.php';
  122.  
  123. function showLoginForm(&$notification)
  124. {
  125.     $tpl = new HTML_Template_IT();
  126.     $tpl->loadTemplatefile('loginform.tpl.php');
  127.  
  128.     $tpl->setVariable('form_action'$_SERVER['SCRIPT_NAME']);
  129.  
  130.     $liveUserObj =$notification->getNotificationObject();
  131.     if (is_object($liveUserObj)) {
  132.         if ($liveUserObj->getStatus()) {
  133.             switch ($liveUserObj->getStatus()) {
  134.                 case LIVEUSER_STATUS_ISINACTIVE:
  135.                     $tpl->touchBlock('inactive');
  136.                     break;
  137.                 case LIVEUSER_STATUS_IDLED:
  138.                     $tpl->touchBlock('idled');
  139.                     break;
  140.                 case LIVEUSER_STATUS_EXPIRED:
  141.                     $tpl->touchBlock('expired');
  142.                     break;
  143.                 default:
  144.                     $tpl->touchBlock('failure');
  145.                     break;
  146.             }
  147.         }
  148.     }
  149.  
  150.     $tpl->show();
  151.     exit();
  152. }
  153.  
  154. // Create new LiveUser (LiveUser) object.
  155. $LU =LiveUser::factory($LUOptions);
  156. $LU->dispatcher->addObserver('showLoginForm''forceLogin');
  157.  
  158. $username (isset($_REQUEST['username'])) $_REQUEST['username': null;
  159. $password (isset($_REQUEST['password'])) $_REQUEST['password': null;
  160. $logout (isset($_REQUEST['logout'])) $_REQUEST['logout': false;
  161. if (!$LU->init($username$password$logout)) {
  162.     var_dump($LU->getErrors());
  163.     die();
  164. }
  165.  
  166. define('AREA_NEWS',          1);
  167. define('RIGHT_NEWS_NEW',     1);
  168. define('RIGHT_NEWS_CHANGE',  2);
  169. define('RIGHT_NEWS_DELETE',  3);

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