コード例 #1
0
ファイル: Admin.php プロジェクト: ookwudili/chisimba
 /**
  *
  * @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
<?php

// $Id: admin_example_mdb2.php,v 1.1 2004/07/16 13:59:08 mloitzl Exp $
require_once 'config_mdb2.inc.php';
require_once 'LiveUser/Admin.php';
$increment = time();
$admin = new LiveUser_Admin($conf, 'FR');
$custom = array('name' => 'asdfMDB22', 'email' => 'fleh@example.comMDB23');
$user_id = $admin->addUser('johndoe' . $increment, 'dummypass', null, true, null, null, null, $custom);
echo 'Created Perm User Id ' . $user_id . '<br />';
if (MDB2::isError($user_id)) {
    var_dump($user_id);
}
if (!MDB2::isError($user_id) && $user_id > 2) {
    $echo_user_id = $user_id - 2;
    $admin->removeUser($echo_user_id);
    echo 'Removed Perm User Id ' . $echo_user_id . '<br />';
}
if (!MDB2::isError($user_id) && $user_id > 1) {
    $custom = array('name' => 'asdfMDBUpdated22', 'email' => 'fleh@example.comMDBUpdated22');
    $update_id = $user_id - 1;
    $admin->updateUser($update_id, 'johndoe' . $increment, 'dummypass', null, true, null, null, $custom);
    echo 'Updated Perm User Id ' . $update_id . '<br />';
}
$foo = $admin->getUser($user_id);
if (empty($foo)) {
    echo 'No user with that Perm ID was found ' . $user_id;
} else {
    print_r($foo);
}
echo '<br />';
コード例 #3
0
<?php

require_once 'config.inc.php';
require_once 'LiveUser/Admin/Admin.php';
//require_once 'LiveUser/LiveUser.php';
//require_once 'LiveUser/Admin/Perm/Container/DB_Medium.php';
//require_once 'LiveUser/Admin/Auth/Container/DB.php';
$admin = new LiveUser_Admin($conf, 'en');
$res = $admin->perm->setCurrentLanguage('en');
//$res = $admin->perm->addLanguage('en', 'english', 'English language');
$ts = time();
// ADD User
//function addUser($handle, $password, $type = null, $active = true, $id = null, $owner_user_id = null,
//                    $owner_group_id = null, $customFields = array())
$user_id = $admin->addUser('martin', 'dummypass', null, true, getUniqueId(), null, null, null);
if (PEAR::isError($user_id)) {
    echo "<pre>";
    print_r($user_id);
    echo "</pre>";
} else {
    echo 'Created User Id ' . $user_id . '<br />';
}
/*
// GET User
$user = $admin->getUser($user_id);
if(PEAR::isError($user))
  {
    echo "<pre>";
    print_r($user);
    echo "</pre>";
  }
コード例 #4
0
                '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');

?>
コード例 #5
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;
 }
コード例 #6
0
ファイル: init.php プロジェクト: BackupTheBerlios/flushcms
        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"));
}
コード例 #7
0
ファイル: config.inc.php プロジェクト: laiello/coopcrucial
$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();
コード例 #8
0
ファイル: Admin.php プロジェクト: BackupTheBerlios/hem
 /**
  * Makes your instance global.
  *
  * <b>You MUST call this method with the $var = &LiveUser_Admin::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  array  liveuser conf array
  * @param  string two letters language code
  * @return object      Returns an object of either LiveUser or PEAR_Error type
  * @see    LiveUser_Admin::LiveUser_Admin
  */
 function &singleton($conf, $lang)
 {
     static $instances;
     if (!isset($instances)) {
         $instances = array();
     }
     $signature = serialize(array($conf, $lang));
     if (!isset($instances[$signature])) {
         $obj =& LiveUser_Admin::LiveUser_Admin($conf, $lang);
         if (PEAR::isError($obj)) {
             return $obj;
         }
         $instances[$signature] =& $obj;
     }
     return $instances[$signature];
 }
コード例 #9
0
<?php

require_once 'config.inc.php';
require_once 'LiveUser/Admin/Admin.php';
$admin = new LiveUser_Admin($conf, 'FR');
$custom = array(array('name' => 'name', 'value' => 'asdf', 'type' => 'text'), array('name' => 'email', 'value' => '*****@*****.**', 'type' => 'text'));
$user_id = $admin->addUser('johndoe', 'dummypass', true, null, null, null, $custom);
echo 'Created User Id ' . $user_id . '<br />';
if ($user_id > 2) {
    $admin->removeUser($user_id - 2);
    echo 'Removed User Id ' . ($user_id - 2) . '<br />';
}
if ($user_id > 1) {
    $custom = array(array('name' => 'name', 'value' => 'asdfUpdated', 'type' => 'text'), array('name' => 'email', 'value' => '*****@*****.**', 'type' => 'text'));
    $admin->updateUser($user_id, 'johndoe', 'dummypass', true, null, null, $custom);
    echo 'Updated User Id ' . ($user_id - 1) . '<br />';
}
$custom = array('name', 'email');
$foo = $admin->getUser($user_id, $custom);
if (empty($foo)) {
    echo 'No user with that ID was found';
} else {
    print_r($foo);
}
echo '<br />';
$cols = array('name', 'email');
$filters = array('email' => array('op' => '=', 'value' => '*****@*****.**', 'cond' => 'AND'), 'name' => array('op' => '=', 'value' => 'asdfUpdated', 'cond' => ''));
$foo1 = $admin->searchUsers($filters, $cols);
echo 'These Users were found: <br />';
print_r($foo1);