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

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