예제 #1
0
                    $tpl->touchBlock('idled');
                    break;
                case LIVEUSER_STATUS_EXPIRED:
                    $tpl->touchBlock('expired');
                    break;
                default:
                    $tpl->touchBlock('failure');
                    break;
            }
        }
    }
    $tpl->show();
    exit;
}
// Create new LiveUser (LiveUser) object.
// We´ll only use the auth container, permissions are not used.
$LU =& LiveUser::factory($LUOptions);
$LU->dispatcher->addObserver('forceLogin', 'forceLogin');
if (!$LU->init()) {
    var_dump($LU->getErrors());
    die;
}
$logout = array_key_exists('logout', $_REQUEST) ? $_REQUEST['logout'] : false;
if ($logout) {
    $LU->logout(true);
    showLoginForm($LU);
}
define('AREA_NEWS', 1);
define('RIGHT_NEWS_NEW', 1);
define('RIGHT_NEWS_CHANGE', 2);
define('RIGHT_NEWS_DELETE', 3);
예제 #2
0
 /**
  * This uses the singleton pattern, making sure you have one and
  * only instance of the class.
  *
  * <b>In PHP4 you MUST call this method with the
  *  $var = &LiveUser::singleton() syntax.
  * Without the ampersand (&) in front of the method name, you will not get
  * a reference, you will get a copy.</b>
  *
  * @param  array    Config array to configure.
  * @param  string   Signature by which the given instance can be referenced later
  * @return LiveUser Returns an object of either LiveUser or false on failure
  *
  * @access public
  * @see    LiveUser::factory
  * @see    LiveUser::getErrors
  */
 function &singleton(&$conf, $signature = null)
 {
     static $instances;
     if (!isset($instances)) {
         $instances = array();
     }
     if (is_null($signature)) {
         if (empty($instances)) {
             $signature = uniqid('LU');
         } else {
             $signature = key($instances);
         }
     }
     if (!array_key_exists($signature, $instances)) {
         $instances[$signature] =& LiveUser::factory($conf);
     }
     return $instances[$signature];
 }
예제 #3
0
error_reporting(E_ALL);
// right definitions
define('ACCESS', 3);
define('LAUNCH_ATOMIC_BOMB', 4);
define('FLY_ALIEN_SPACE_CRAFT', 5);
// Include configuration.
require_once 'conf.php';
// The error handling stuff is not needed and used only for debugging
// while LiveUser is not yet mature
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'eHandler');
function eHandler($errObj)
{
    echo '<hr /><span style="color: red;">' . $errObj->getMessage() . ':<br />' . $errObj->getUserinfo() . '</span><hr />';
}
// Create new LiveUser object
$LU = LiveUser::factory($liveuserConfig);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>Example Area51</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <style type="text/css">
    <!--
    table {
        background-color: #CCCCCC;
        border-color: 1px solid #000;
    }
    body {
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 12px;
예제 #4
0
 /**
  * Makes your instance global.
  *
  * <b>You MUST call this method with the $var = &LiveUser::singleton() syntax.
  * Without the ampersand (&) in front of the method name, you will not get
  * a reference, you will get a copy.</b>
  *
  * @access public
  * @param  mixed    The config file or the config array to configure.
  * @param  string    Handle of the user trying to authenticate
  * @param  string    Password of the user trying to authenticate
  * @param  boolean  set to true if user wants to logout
  * @param  boolean  set if remember me is set
  * @param  mixed    Name of array containing the configuration.
  * @return object      Returns an object of either LiveUser or PEAR_Error type
  * @see    LiveUser::factory
  */
 function &singleton($conf, $handle = '', $passwd = '', $logout = false, $remember = false, $confName = 'liveuserConfig')
 {
     static $instances;
     if (!isset($instances)) {
         $instances = array();
     }
     $signature = serialize(array($handle, $passwd, $confName));
     if (!isset($instances[$signature])) {
         $instances[$signature] =& LiveUser::factory($conf, $handle, $passwd, $logout, $confName);
     }
     return $instances[$signature];
 }
예제 #5
0
    }
} else {
    $liveuserConfig['login']['username'] = '';
    $liveuserConfig['login']['password'] = '';
}
/*  Setting $liveuserConfig['login']['username'] and $liveuserConfig['login']['password']
*   to '' causes the login to be ignored by the LiveUser system.
*   In Liveuser.php during the tryLogin function on line 665,  
*   it sees the handle is empty.  It then tries to login based on a cookie,
*   but in line 171 that _options['cookie'] is not set so it goes to line 693
*   sees that _options['login']['username'] and _options['login']['password'] 
*   are empty, tries to run _options['login']['function'] which is also set to ''
*   so it fails out of the if and hits line 715 where it returns false negating the login.
*/
// instantiate a LiveUser object from the config array
$liveuser =& LiveUser::factory($liveuserConfig);
if (isset($_REQUEST['username']) && !isset($_REQUEST['cancel_login'])) {
    if ($totalDelay > EWIKI_LIVEUSER_LOGIN_SHUTDOWN_DELAY) {
        $liveuser->logout();
    } else {
        //Get data as we would for logging
        $loginData = ewiki_liveuser_get_login_data();
        liveuser_loglogin();
        //Tests login, updates $username
        if ($username = $liveuser->getHandle()) {
            //Clear delay flags with matching handle, php session, ssl session, and ip
            // (today only)
            $liveuserDB->query('
                UPDATE `liveweb_login_log` set delay=0 
                WHERE time> DATE_SUB(NOW(), INTERVAL 1 DAY) 
                AND auth_user_handle=? AND php_session_id=?
예제 #6
0
<?php

$dsn = 'mysql://*****:*****@localhost/lutest';
error_reporting(E_ALL);
$DOC_ROOT = $_SERVER['DOCUMENT_ROOT'];
$USER_DIR = '/martin';
$PROJECT_NAME = '/hem';
$APP_ROOT = $DOC_ROOT . $USER_DIR . $PROJECT_NAME;
$PEAR_DIR = $APP_ROOT . '/pear';
$APP_FRAMEWORK_DIR = $APP_ROOT . '/framework';
$PATH = $PEAR_DIR . ":" . $APP_FRAMEWORK_DIR;
ini_set('include_path', ':' . $PATH . ':' . ini_get('include_path'));
$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' => 'DB', 'name' => 'DB_Local', 'loginTimeout' => 0, 'expireTime' => 3600, 'idleTime' => 1800, 'dsn' => $dsn, 'allowDuplicateHandles' => 0, 'authTable' => 'liveuser_users', 'authTableCols' => array('required' => array('auth_user_id' => array('type' => 'text', 'name' => 'auth_user_id'), 'handle' => array('type' => 'text', 'name' => 'handle'), 'passwd' => array('type' => 'text', 'name' => 'passwd')), 'optional' => array('lastlogin' => array('type' => 'timestamp', 'name' => 'lastlogin'), 'is_active' => array('type' => 'boolean', 'name' => 'is_active'), 'owner_user_id' => array('type' => 'integer', 'name' => 'owner_user_id'), 'owner_group_id' => array('type' => 'integer', 'name' => 'owner_group_id')), 'custom' => array()))), 'permContainer' => array('dsn' => $dsn, 'type' => 'DB_Medium', 'prefix' => 'liveuser_'));
require_once 'LiveUser.php';
$LU =& LiveUser::factory($conf);