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. function php_error_handler($errno$errstr$errfile$errline)
  11. {
  12.     include_once 'HTML/Template/IT.php';
  13.     $tpl = new HTML_Template_IT();
  14.     $tpl->loadTemplatefile('error-page.tpl.php'falsefalse);
  15.  
  16.     $tpl->setVariable('error_msg'"<b>$errfile ($errline)</b><br />$errstr");
  17.     $tpl->show();
  18.     exit();
  19. }
  20.  
  21. set_error_handler('php_error_handler');
  22.  
  23. require_once 'PEAR.php';
  24.  
  25. function pear_error_handler($err_obj)
  26. {
  27.     $error_string $err_obj->getMessage('<br />' $err_obj->getUserInfo();
  28.     trigger_error($error_stringE_USER_ERROR);
  29. }
  30.  
  31. PEAR::setErrorHandling(PEAR_ERROR_CALLBACK'pear_error_handler');
  32.  
  33. require_once 'DB.php';
  34.  
  35. // Data Source Name (DSN)
  36. //$dsn = '{dbtype}://{user}:{passwd}@{dbhost}/{dbname}';
  37. $dsn 'mysql://root:@localhost/liveuser_test';
  38.  
  39. $db =DB::connect($dsntrue);
  40. $db->setFetchMode(DB_FETCHMODE_ASSOC);
  41.  
  42.  
  43. require_once 'HTML/Template/IT.php';
  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'          => 'DB',
  56.                                 'dsn'           => $dsn,
  57.                                 'loginTimeout'  => 0,
  58.                                 'expireTime'    => 3600,
  59.                                 'idleTime'      => 1800,
  60.                                 'allowDuplicateHandles' => 0,
  61.                                 'authTable'     => 'liveuser_users',
  62.                                 'authTableCols' => array(
  63.                                     'required'  => array(
  64.                                         'auth_user_id' => array('name' => 'auth_user_id''type' => 'text'),
  65.                                         'handle'       => array('name' => 'handle',       'type' => 'text'),
  66.                                         'passwd'       => array('name' => 'passwd',       'type' => 'text'),
  67.                                     ),
  68.                                     'optional' => array(
  69.                                         'lastlogin'    => array('name' => 'lastlogin',    'type' => 'timestamp'),
  70.                                         'is_active'    => array('name' => 'is_active',    'type' => 'boolean')
  71.                                     ),
  72.                                 ),
  73.                             ),
  74.                             array(
  75.                                 'type' => 'XML',
  76.                                 'file' => 'Auth_XML.xml',
  77.                                 'loginTimeout' => 0,
  78.                                 'expireTime'   => 3600,
  79.                                 'idleTime'     => 1800,
  80.                                 'allowDuplicateHandles'  => false,
  81.                                 'passwordEncryptionMode' => 'MD5'
  82.                             ),
  83.                         ),
  84.     'permContainer'  => array(
  85.                             'type'  => 'Complex',
  86.                             'storage' => array('DB' => array('dsn' => $dsn'prefix'     => 'liveuser_')),
  87.                         )
  88.     );
  89.  
  90. require_once 'LiveUser.php';
  91.  
  92. function showLoginForm(&$liveUserObj)
  93. {
  94.     include_once 'HTML/Template/IT.php';
  95.     $tpl = new HTML_Template_IT();
  96.     $tpl->loadTemplatefile('loginform.tpl.php');
  97.  
  98.     $tpl->setVariable('form_action'$_SERVER['PHP_SELF']);
  99.  
  100.     if (is_object($liveUserObj)) {
  101.         if ($liveUserObj->status{
  102.             switch ($liveUserObj->status{
  103.                 case LIVEUSER_STATUS_ISINACTIVE:
  104.                     $tpl->touchBlock('inactive');
  105.                     break;
  106.                 case LIVEUSER_STATUS_IDLED:
  107.                     $tpl->touchBlock('idled');
  108.                     break;
  109.                 case LIVEUSER_STATUS_EXPIRED:
  110.                     $tpl->touchBlock('expired');
  111.                     break;
  112.                 default:
  113.                     $tpl->touchBlock('failure');
  114.                     break;
  115.             }
  116.         }
  117.     }
  118.  
  119.     $tpl->show();
  120.     exit();
  121. }
  122.  
  123. // Create new LiveUser (LiveUser) object.
  124. $LU =LiveUser::factory($LUOptions);
  125. $function 'showLoginForm';
  126. $LU->attachObserver($function'forceLogin');
  127.  
  128. $username (isset($_REQUEST['username'])) $_REQUEST['username': null;
  129. $password (isset($_REQUEST['password'])) $_REQUEST['password': null;
  130. $logout (isset($_REQUEST['logout'])) $_REQUEST['logout': false;
  131. $LU->init($username$password$logout);
  132.  
  133. define('AREA_NEWS',          1);
  134. define('RIGHT_NEWS_NEW',     1);
  135. define('RIGHT_NEWS_CHANGE',  2);
  136. define('RIGHT_NEWS_DELETE',  3);

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