示例#1
0
 /**
  *
  * @param array configuration array
  * @return LiveUser_Admin|bool
  *
  * @access public
  * @see factory
  */
 function &singleton(&$conf)
 {
     static $instance;
     if (!isset($instance)) {
         if (!$conf) {
             return false;
         }
         $obj =& LiveUser_Admin::factory($conf);
         $instance =& $obj;
     }
     return $instance;
 }
示例#2
0
        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;
    $remember = array_key_exists('remember', $_REQUEST) ? $_REQUEST['remember'] : false;
    //	Var_Dump::display($LU->isLoggedIn());
    if ($logout) {
        $LU->logout(true);
        header("location:" . getenv("SCRIPT_NAME"));
    } elseif (!$LU->isLoggedIn() || $handle && $LU->getProperty('handle') != $handle) {
        if (!$handle) {
            $LU->login(null, null, true);
        } else {
            $LU->login($handle, $passwd, $remember);
        }
    }
    require_once 'LiveUser/Admin.php';
    $luadmin =& LiveUser_Admin::factory($liveuserConfig);
    $luadmin->init();
    //Var_Dump::display($LU->readRememberCookie());
    if (!$LU->isLoggedIn() || $LU->getProperty('is_active') == "deleted") {
        $template->setFile(array("MAIN" => "login_screen.html"));
        $controller->parseTemplateLang();
        $template->parse("OUT", array("MAIN"));
        $template->p("OUT");
        exit;
    }
    //	$LU->getProperty("auth_user_id")
    //	Var_Dump::display($LU->getProperty("is_active"));
}
示例#3
0
 private function __createSuperAdmin($username, $passwd, $email)
 {
     $strReturn = "";
     //require_once("LiveUser/Admin.php");
     $liveuserConfig = array('cache_perm' => false, 'session' => array('name' => 'PHPSESSID', 'varname' => 'userSession'), 'logout' => array('destroy' => true), 'cookie' => array('name' => 'loginInfoPunch', 'lifetime' => 30, 'path' => null, 'domain' => null, 'secret' => 'extremlysecretkeycombination', 'savedir' => 'sessions', 'secure' => false), 'authContainers' => array('MDB2' => array('type' => 'MDB2', 'expireTime' => 0, 'idleTime' => 0, 'passwordEncryptionMode' => 'SHA1', 'secret' => 'Spice up your life with a little salt.', 'storage' => array('dsn' => $this->__getDsn(), 'prefix' => 'punch_liveuser_', 'tables' => array('users' => array('fields' => array('lastlogin' => false, 'is_active' => false, 'email' => false, 'name' => false, 'account_id' => false, 'time_zone_id' => false, 'owner_user_id' => false, 'owner_group_id' => false))), 'fields' => array('lastlogin' => 'timestamp', 'is_active' => 'boolean', 'email' => 'text', 'name' => 'text', 'account_id' => 'integer', 'time_zone_id' => 'integer', 'owner_user_id' => 'integer', 'owner_group_id' => 'integer'), 'alias' => array('auth_user_id' => 'authuserid', 'lastlogin' => 'lastlogin', 'is_active' => 'isactive', 'email' => 'email', 'name' => 'name', 'account_id' => 'account_id', 'time_zone_id' => 'time_zone_id', 'owner_user_id' => 'owner_user_id', 'owner_group_id' => 'owner_group_id')))), 'permContainer' => array('type' => 'Complex', 'storage' => array('MDB2' => array('dsn' => $this->__getDsn(), 'prefix' => 'punch_liveuser_', 'force_seq' => 'false', 'tables' => array('groups' => array('fields' => array('is_active' => false, 'account_id' => false, 'owner_user_id' => false, 'owner_group_id' => false)), 'areas' => array('fields' => array('account_id' => false)), 'applications' => array('fields' => array('account_id' => false)), 'rights' => array('fields' => array('account_id' => false)), 'grouprights' => array('fields' => array('account_id' => false)), 'userrights' => array('fields' => array('account_id' => false))), 'fields' => array('is_active' => 'boolean', 'account_id' => 'integer', 'owner_user_id' => 'integer', 'owner_group_id' => 'integer'), 'alias' => array('is_active' => 'isactive', 'account_id' => 'account_id', 'owner_user_id' => 'owner_user_id', 'owner_group_id' => 'owner_group_id')))));
     $objLiveAdmin =& LiveUser_Admin::factory($liveuserConfig);
     $objLiveAdmin->init();
     $data = array('handle' => $username, 'name' => "PunchCMS Super Admin", 'passwd' => $passwd, 'is_active' => true, 'email' => $email, 'time_zone_id' => 1, 'account_id' => 0, 'perm_type' => 5);
     $intPermId = $objLiveAdmin->addUser($data);
     if (!$intPermId) {
         $strReturn = "Error during Super Admin creation.";
     }
     return $strReturn;
 }
示例#4
0
$db_user = '******';
$db_pass = '';
$db_host = 'localhost';
$db_name = 'liveuser_admin_test_example1';
$dsn = "mysql://{$db_user}:{$db_pass}@{$db_host}/{$db_name}";
$backends = array('DB' => array('options' => array()), 'MDB' => array('options' => array()), 'MDB2' => array('options' => array('debug' => true, 'debug_handler' => 'echoQuery')));
if (!array_key_exists('storage', $_GET)) {
    $storage = 'MDB2';
} elseif (isset($backends[$_GET['storage']])) {
    $storage = strtoupper($_GET['storage']);
} else {
    exit('storage Backend not found.');
}
require_once $storage . '.php';
function echoQuery(&$db, $scope, $message)
{
    Var_Dump::display($scope . ': ' . $message);
}
$dummy = new $storage();
$db = $dummy->connect($dsn, $backends[$storage]['options']);
if (PEAR::isError($db)) {
    echo $db->getMessage() . ' ' . $db->getUserInfo();
    die;
}
$db->setFetchMode(constant($storage . '_FETCHMODE_ASSOC'));
$conf = array('debug' => true, 'session' => array('name' => 'PHPSESSION', 'varname' => 'ludata'), 'login' => array('force' => false), 'logout' => array('destroy' => true), 'authContainers' => array('DB_Local' => array('type' => $storage, 'expireTime' => 3600, 'idleTime' => 1800, 'storage' => array('dbc' => $db, 'dsn' => $dsn, 'prefix' => 'liveuser_', 'tables' => array('users' => array('fields' => array('name' => false, 'email' => false))), 'fields' => array('name' => 'text', 'email' => 'text'), 'alias' => array('name' => 'name', 'email' => 'email', 'auth_user_id' => 'user_id')))), 'permContainer' => array('type' => 'Complex', 'alias' => array(), 'storage' => array($storage => array('dbc' => $db, 'dsn' => $dsn, 'prefix' => 'liveuser_', 'tables' => array(), 'fields' => array(), 'alias' => array()))));
$admin =& LiveUser_Admin::factory($conf);
$logconf = array('mode' => 0666, 'timeFormat' => '%X %x');
$logger =& Log::factory('file', 'liveuser_test.log', 'ident', $logconf);
$admin->log->addChild($logger);
$admin->init();