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

Source for file conf_pdo.php

Documentation is available at conf_pdo.php

  1. <?php
  2. require_once 'MDB2.php';
  3. require_once 'LiveUser.php';
  4. // Plase configure the following file according to your environment
  5.  
  6. $dsn 'mysql:host=localhost;dbname=liveuser_test_example5';
  7.  
  8. $dsn_2 'mysqli://root:@localhost/liveuser_test_example5';
  9.  
  10. $db = MDB2::connect($dsn_2);
  11.  
  12. if (PEAR::isError($db)) {
  13.     echo $db->getMessage(' ' $db->getUserInfo();
  14. }
  15.  
  16. $db->setFetchMode(MDB2_FETCHMODE_ASSOC);
  17.  
  18. $conf =
  19.     array(
  20.         'debug' => true,
  21.         'session'  => array(
  22.             'name'     => 'PHPSESSION',
  23.             'varname'  => 'ludata'
  24.         ),
  25.         'login' => array(
  26.             'force'    => false,
  27.         ),
  28.         'logout' => array(
  29.             'destroy'  => true,
  30.         ),
  31.         'authContainers' => array(
  32.             'DB' => array(
  33.                 'type'          => 'PDO',
  34.                 'expireTime'    => 3600,
  35.                 'idleTime'      => 1800,
  36.                 'storage' => array(
  37.                     'dsn' => $dsn,
  38.                     'options' => array(
  39.                         'username'   => 'root',
  40.                         'password' => ''
  41.                     ),
  42.                     'alias' => array(
  43.                         'lastlogin' => 'lastlogin',
  44.                         'is_active' => 'is_active',
  45.                     ),
  46.                     'fields' => array(
  47.                         'lastlogin' => 'timestamp',
  48.                         'is_active' => 'boolean',
  49.                     ),
  50.                     'tables' => array(
  51.                         'users' => array(
  52.                             'fields' => array(
  53.                                 'lastlogin' => false,
  54.                                 'is_active' => false,
  55.                             ),
  56.                         ),
  57.                     ),
  58.                 )
  59.             )
  60.         ),
  61.     'permContainer' => array(
  62.         'type' => 'Medium',
  63.         'storage' => array(
  64.             'PDO' => array(
  65.                 'dsn'    => $dsn,
  66.                 'prefix' => 'liveuser_',
  67.                 'options' => array(
  68.                     'username'   => 'root',
  69.                     'password' => ''
  70.                 )
  71.              )
  72.         ),
  73.     ),
  74. );
  75.  
  76. PEAR::setErrorHandling(PEAR_ERROR_RETURN);
  77.  
  78. $usr LiveUser::singleton($conf);
  79.  
  80. $handle (array_key_exists('handle'$_REQUEST)) $_REQUEST['handle': null;
  81. $passwd (array_key_exists('passwd'$_REQUEST)) $_REQUEST['passwd': null;
  82. $logout (array_key_exists('logout'$_REQUEST)) $_REQUEST['logout': false;
  83. $remember (array_key_exists('rememberMe'$_REQUEST)) $_REQUEST['rememberMe': false;
  84.  
  85. if (!$usr->init()) {
  86.     var_dump($usr->getErrors());
  87.     die();
  88. }
  89.  
  90. if ($logout{
  91.     $usr->logout(true);
  92. elseif(!$usr->isLoggedIn(|| ($handle && $usr->getProperty('handle'!= $handle)) {
  93.     if (!$handle{
  94.         $usr->login(nullnulltrue);
  95.     else {
  96.         $usr->login($handle$passwd$remember);
  97.     }
  98. }

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