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 'DB.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 =DB::connect($dsntrue);
  41. $db->setFetchMode(DB_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'          => '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' => 'authUserId''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' => 'isActive',    '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(&$notification)
  93. {
  94.     $tpl = new HTML_Template_IT();
  95.     $tpl->loadTemplatefile('loginform.tpl.php');
  96.  
  97.     $tpl->setVariable('form_action'$_SERVER['PHP_SELF']);
  98.  
  99.     $liveUserObj =$notification->getNotificationObject();
  100.     if (is_object($liveUserObj)) {
  101.         if ($liveUserObj->getStatus()) {
  102.             switch ($liveUserObj->getStatus()) {
  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. $LU->dispatcher->addObserver('showLoginForm''forceLogin');
  126.  
  127. $username (isset($_REQUEST['username'])) $_REQUEST['username': null;
  128. $password (isset($_REQUEST['password'])) $_REQUEST['password': null;
  129. $logout (isset($_REQUEST['logout'])) $_REQUEST['logout': false;
  130. $LU->init($username$password$logout);
  131.  
  132. define('AREA_NEWS',          1);
  133. define('RIGHT_NEWS_NEW',     1);
  134. define('RIGHT_NEWS_CHANGE',  2);
  135. define('RIGHT_NEWS_DELETE',  3);

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