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

Source for file main.inc.php

Documentation is available at main.inc.php

  1. <?php
  2.     define('EMAIL_WEBMASTER''krausbn@php.net');
  3.  
  4.     // PEAR path
  5.     //$path_to_liveuser_dir = 'path/to/pear/'.PATH_SEPARATOR;
  6.     //ini_set('include_path', $path_to_liveuser_dir.ini_get('include_path'));
  7.  
  8.     error_reporting(E_ALL ^ E_NOTICE);
  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');
  15.  
  16.         $tpl->setVariable('error_msg'"<b>$errfile ($errline)</b><br />$errstr");
  17.  
  18.         $tpl->show();
  19.          exit();
  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.     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK'pear_error_handler');
  31.  
  32.  
  33.     function showLoginForm($liveUserObj = false)
  34.     {
  35.         include_once 'HTML/Template/IT.php';
  36.         $tpl = new HTML_Template_IT();
  37.         $tpl->loadTemplatefile('loginform.tpl.php');
  38.  
  39.         $tpl->setVariable('form_action'$_SERVER['PHP_SELF']);
  40.  
  41.         if (is_object($liveUserObj)) {
  42.             if ($liveUserObj->status{
  43.                 switch ($liveUserObj->status{
  44.                     case LIVEUSER_STATUS_ISINACTIVE:
  45.                         $tpl->touchBlock('inactive');
  46.                         break;
  47.                     case LIVEUSER_STATUS_IDLED:
  48.                         $tpl->touchBlock('idled');
  49.                         break;
  50.                     case LIVEUSER_STATUS_EXPIRED:
  51.                         $tpl->touchBlock('expired');
  52.                         break;
  53.                     default:
  54.                         $tpl->touchBlock('failure');
  55.                         break;
  56.                 }
  57.             }
  58.         }
  59.  
  60.         $tpl->show();
  61.         exit();
  62.     }
  63.  
  64.  
  65.     require_once 'DB.php';
  66.  
  67.     // Data Source Name (DSN)
  68.     $myDB = array('host' => 'localhost',
  69.                 'type' => 'mysql',
  70.                 'name' => 'pear_test',
  71.                 'user' => 'user',
  72.                 'pwd'  => 'pass'
  73.             );
  74.  
  75.  
  76.  
  77.     $dsn $myDB['type''://' .
  78.            $myDB['user'':'   .
  79.            $myDB['pwd']  '@'   .
  80.            $myDB['host''/'   .
  81.            $myDB['name'];
  82.  
  83.     $db =DB::connect($dsntrue);
  84.     $db->setFetchMode(DB_FETCHMODE_ASSOC);
  85.  
  86.  
  87.     require_once 'HTML/Template/IT.php';
  88.     $tpl = new HTML_Template_IT();
  89.  
  90.  
  91.     require_once 'LiveUser.php';
  92.     $LUOptions = array('autoInit'       => true,
  93.                        'login'          => array('function' => 'showLoginForm',
  94.                                                'force'    => true),
  95.                         'logout' => array(
  96.                             'trigger'  => 'logout',
  97.                             'redirect' => '',
  98.                             'destroy'  => true,
  99.                             'method'   => 'get',
  100.                             'function' => ''
  101.                              ),
  102.                         'authContainers' => array(array('type'          => 'DB',
  103.                                                         'connection'    => $db,
  104.                                                         'loginTimeout'  => 0,
  105.                                                         'expireTime'    => 3600,
  106.                                                         'idleTime'      => 1800,
  107.                                                         'allowDuplicateHandles' => 0,
  108.                                                         'authTable'     => 'liveuser_users',
  109.                                                         'authTableCols' => array('user_id'   => 'auth_user_id',
  110.                                                                                 'handle'     => 'handle',
  111.                                                                                 'passwd'     => 'passwd',
  112.                                                                                 'lastlogin'  => 'lastlogin',
  113.                                                                                 'is_active'  => 'is_active'
  114.                                                                             )
  115.                                                     )
  116.                                                 ),
  117.                         'permContainer'  => array('type'     => 'DB_Complex',
  118.                                                 'connection' => $db,
  119.                                                 'prefix'     => 'liveuser_')
  120.                     );
  121.     $LU LiveUser::factory($LUOptions);
  122.  
  123.     define('AREA_NEWS',          1);
  124.     define('RIGHT_NEWS_NEW',     1);
  125.     define('RIGHT_NEWS_CHANGE',  2);
  126.     define('RIGHT_NEWS_DELETE',  3);
  127. ?>

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