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

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