function init($conf) { $complex_conf = array('autoInit' => false, 'session' => array('name' => $conf['auth_session_name'], 'varname' => 'ludata'), 'login' => array('method' => 'post', 'username' => 'handle', 'password' => 'passwd', 'force' => false, 'function' => '', 'remember' => 'rememberMe'), 'logout' => array('trigger' => 'logout', 'redirect' => $conf['auth_exit_page'], 'destroy' => true, 'method' => 'get', 'function' => ''), 'authContainers' => array(array('type' => 'DB', 'name' => 'DB_Local', 'loginTimeout' => 0, 'expireTime' => 3600, 'idleTime' => 1800, 'dsn' => $conf['auth_dsn'], 'allowDuplicateHandles' => 0, 'authTable' => 'liveuser_users', 'authTableCols' => array('user_id' => 'auth_user_id', 'handle' => 'handle', 'passwd' => 'passwd', 'lastlogin' => 'lastlogin', 'is_active' => 'is_active'))), 'permContainer' => array('dsn' => $conf['auth_dsn'], 'type' => 'DB_Medium', 'prefix' => 'liveuser_')); $this->auth_handler_ = LiveUser::singleton($complex_conf); $error = $this->auth_handler_->init(); return $error; }
<?php require_once 'MDB.php'; require_once 'LiveUser.php'; // Plase configure the following file according to your environment $db_user = '******'; $db_pass = '******'; $db_host = 'localhost'; $db_name = 'pear_test'; $dsn = "mysql://{$db_user}:{$db_pass}@{$db_host}/{$db_name}"; $db = MDB::connect($dsn, array('sequence_col_name' => 'id')); if (MDB::isError($db)) { echo $db->getMessage() . ' ' . $db->getUserInfo(); } $db->setFetchMode(MDB_FETCHMODE_ASSOC); $conf = array('autoInit' => true, 'session' => array('name' => 'PHPSESSION', 'varname' => 'ludata'), 'login' => array('method' => 'post', 'username' => 'handle', 'password' => 'passwd', 'force' => false, 'function' => '', 'remember' => 'rememberMe'), 'logout' => array('trigger' => 'logout', 'redirect' => 'home.php', 'destroy' => true, 'method' => 'get', 'function' => ''), 'authContainers' => array(array('type' => 'MDB', 'name' => 'MDB_Local', 'loginTimeout' => 0, 'expireTime' => 3600, 'idleTime' => 1800, 'dsn' => $dsn, 'allowDuplicateHandles' => 0, 'authTable' => 'liveuser_users', 'authTableCols' => array('user_id' => array('name' => 'auth_user_id', 'type' => 'text'), 'handle' => array('name' => 'handle', 'type' => 'text'), 'passwd' => array('name' => 'passwd', 'type' => 'text'), 'lastlogin' => array('name' => 'lastlogin', 'type' => 'timestamp'), 'is_active' => array('name' => 'is_active', 'type' => 'boolean'), 'owner_user_id' => array('name' => 'owner_user_id', 'type' => 'integer'), 'owner_group_id' => array('name' => 'owner_group_id', 'type' => 'integer')))), 'permContainer' => array('dsn' => $dsn, 'type' => 'MDB_Medium', 'prefix' => 'liveuser_')); function logOut() { } function logIn() { } PEAR::setErrorHandling(PEAR_ERROR_RETURN); $usr = LiveUser::singleton($conf); $usr->setLoginFunction('logIn'); $usr->setLogOutFunction('logOut'); $e = $usr->init(); if (PEAR::isError($e)) { //var_dump($usr); die($e->getMessage() . ' ' . $e->getUserinfo()); }
<?php require_once dirname(__FILE__) . '/bundled-libs/MDB2/MDB2.php'; require_once dirname(__FILE__) . '/bundled-libs/LiveUser/LiveUser.php'; require_once 'config.php'; $dsn = array('phptype' => $config['database']['dbengine'], 'username' => $config['database']['dbusername'], 'password' => $config['database']['dbpassword'], 'hostspec' => $config['database']['dbhostname'], 'database' => $config['database']['dbname']); $db =& MDB2::connect($dsn); if (PEAR::isError($db)) { echo $db->getMessage() . ' ' . $db->getUserInfo(); } $db->setFetchMode(MDB2_FETCHMODE_ASSOC); $conf = array('debug' => true, 'session' => array('name' => 'PHPSESSION', 'varname' => 'ludata'), 'login' => array('force' => false), 'logout' => array('destroy' => true), 'authContainers' => array(array('type' => 'MDB2', 'expireTime' => 3600, 'idleTime' => 1800, 'allowDuplicateHandles' => 0, 'allowEmptyPasswords' => 0, 'passwordEncryptionMode' => 'MD5', 'storage' => array('dsn' => $dsn, 'alias' => array('lastlogin' => 'last_login', 'is_active' => 'is_active', 'owner_user_id' => 'owner_user_id', 'owner_group_id' => 'owner_group_id', 'email' => 'email'), 'fields' => array('lastlogin' => 'timestamp', 'is_active' => 'boolean', 'owner_user_id' => 'integer', 'owner_group_id' => 'integer', 'email' => 'text'), 'tables' => array('users' => array('fields' => array('lastlogin' => false, 'is_active' => false, 'owner_user_id' => false, 'owner_group_id' => false, 'email' => false))))))); PEAR::setErrorHandling(PEAR_ERROR_RETURN); $LU = LiveUser::singleton($conf); if (!$LU->init()) { var_dump($LU->getErrors()); die; } $handle = array_key_exists('handle', $_REQUEST) ? $_REQUEST['handle'] : null; $passwd = array_key_exists('passwd', $_REQUEST) ? $_REQUEST['passwd'] : null; $logout = array_key_exists('logout', $_REQUEST) ? $_REQUEST['logout'] : false; if ($logout) { // $LU->logout(true); $LU->logout(false); // does not delete the RememberMe cookie } elseif (!$LU->isLoggedIn() || $handle && $LU->getProperty('handle') != $handle) { if (!$handle) { $LU->login(null, null, true); } else { $LU->login($handle, $passwd, false); }
'dsn' => $dsn, 'prefix' => 'liveuser_', 'alias' => array(), 'fields' => array(), 'tables' => array() ) ) ) ); // load custom liveuser configuration $filename = CS_PATH_CONFIG.DIR_SEP.'liveuser_configuration_ext.php'; if (file_exists($filename)) { include($filename); } require_once(CS_PATH_PEAR_LOCAL.DIR_SEP.'LiveUser'.DIR_SEP.'Admin.php'); $GLOBALS['LiveUser'] = LiveUser::singleton($liveuserConfig); if (!$GLOBALS['LiveUser']->init()) { exit(0); } $GLOBALS['LiveUserAdmin'] = LiveUser_Admin::singleton($liveuserConfig); if (!$GLOBALS['LiveUserAdmin']->init()) { exit(0); } $g_permissions = $GLOBALS['LiveUserAdmin']->perm->outputRightsConstants('array'); ?>