本文整理汇总了PHP中Auth::getAuth方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::getAuth方法的具体用法?PHP Auth::getAuth怎么用?PHP Auth::getAuth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::getAuth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGroupMemberships
/**
* Get a list of every group that $user is in.
*
* @param string $user The user to get groups for.
* @param boolean $parentGroups Also return the parents of any groups?
*
* @return array An array of all groups the user is in.
*/
function getGroupMemberships($user, $parentGroups = false)
{
Horde::logMessage('getGroupMemberships', __FILE__, __LINE__, PEAR_LOG_DEBUG);
if ($this->_server->connect(Auth::getAuth(), Auth::getCredential('password'))) {
$groups = array();
$criteria = array();
array_push($criteria, array('conjunction' => 'AND', 'key' => 'login', 'value' => strtolower($user), 'expression' => 'EQUALS'));
array_push($criteria, array('conjunction' => 'AND', 'key' => 'isAccount', 'value' => 1, 'expression' => 'EQUALS'));
$flags = array('limit' => 1, 'revolve' => 'NO');
$result = $this->_server->search('Contact', $criteria, 128, $flags);
if (is_array($result)) {
$result = $result[0];
if (is_array($result['_MEMBERSHIP'])) {
foreach ($result['_MEMBERSHIP'] as $assignment) {
$teamId = $assignment['targetObjectId'];
$team = $this->_getGroup($teamId);
if (isset($team['name'])) {
array_push($groups, $team['name']);
} else {
PEAR::raiseError(_("Invalid object in zOGI response."));
}
}
}
} else {
PEAR::raiseError(_("Invalid zOGI server version detected."));
}
} else {
PEAR::raiseError(_("Cannot retrieve contacts teams."));
}
Horde::logMessage(sprintf('User a member of %d groups', count($groups)), __FILE__, __LINE__, PEAR_LOG_DEBUG);
return $groups;
}
示例2: runWhen
/**
* Handle a "when" step.
*
* @param array &$world Joined "world" of variables.
* @param string $action The description of the step.
* @param array $arguments Additional arguments to the step.
*
* @return mixed The outcome of the step.
*/
public function runWhen(&$world, $action, $arguments)
{
switch ($action) {
case 'create a Kolab default calendar with name':
$folder = $world['storage']->getNewFolder();
$folder->setName($arguments[0]);
$world['folder_creation'] = $folder->save(array('type' => 'event', 'default' => true));
$folder->setACL(Auth::getAuth(), 'alrid');
break;
case 'allow a group full access to a folder':
$folder = $world['storage']->getFolder($arguments[1]);
$folder->setACL($arguments[0], 'alrid');
break;
case 'retrieving the list of shares for the application':
$shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($arguments[0], 'kolab');
$world['list'] = $shares->listShares(Auth::getAuth());
break;
case 'logging in as a user with a password':
$world['login'] = $world['auth']->authenticate($arguments[0], array('password' => $arguments[1]));
$world['storage'] = $this->prepareEmptyKolabStorage();
return parent::runWhen($world, $action, $arguments);
default:
return parent::runWhen($world, $action, $arguments);
}
}
示例3: login
/**
* リクエストからログイン処理をおこなう
*
* @param bool $is_save_cookie クッキーの保存期限を設定するかどうか
* @return bool
*/
function login($is_save_cookie = false)
{
$this->auth =& $this->factory(true);
if ($this->is_lowercase_username) {
$this->auth->post[$this->auth->_postUsername] = strtolower($this->auth->post[$this->auth->_postUsername]);
}
if ($this->is_encrypt_username) {
$this->auth->post[$this->auth->_postUsername] = t_encrypt($this->auth->post[$this->auth->_postUsername]);
}
$this->auth->start();
if ($this->auth->getAuth()) {
if (OPENPNE_SESSION_CHECK_URL) {
$this->auth->setAuthData('OPENPNE_URL', OPENPNE_URL);
}
if ($this->is_check_user_agent) {
$this->auth->setAuthData('USER_AGENT', $_SERVER['HTTP_USER_AGENT']);
}
$this->sess_id = session_id();
if (!$this->is_ktai) {
if ($is_save_cookie) {
$expire = time() + 2592000;
// 30 days
} else {
$expire = 0;
}
setcookie(session_name(), session_id(), $expire, $this->cookie_path);
}
return true;
} else {
return false;
}
}
示例4: _init
function _init()
{
$this->_server = new ZOGI();
$this->_limit = $this->_params['limit'];
$this->_entity = $this->_params['entity'];
if (!$this->_server->connect(Auth::getAuth(), Auth::getCredential('password'))) {
return PEAR::raiseError(_('Connection failure'));
}
return;
}
示例5: readUserData
/**
* Starts and verifies the PEAR::Auth login process
*
* @return boolean true upon success or false on failure
*
* @access private
*/
function readUserData()
{
$this->pearAuth->start();
// If a user was found, read data into class variables and set
// return value to true
if (!$this->pearAuth->getAuth()) {
return null;
}
$this->propertyValues['handle'] = $this->pearAuth->getUsername();
$this->propertyValues['passwd'] = $this->encryptPW($this->pearAuth->password);
$this->propertyValues['is_active'] = true;
$this->propertyValues['auth_user_id'] = $this->pearAuth->getUsername();
$this->propertyValues['lastlogin'] = '';
return true;
}
示例6: buildMenu
/**
* Builds the menu structure depending on application permissions.
*/
function buildMenu()
{
global $registry, $perms;
$children = array();
foreach ($registry->applications as $app => $params) {
if (isset($params['menu_parent'])) {
/* Make sure the is a $children entry for each parent
* group. */
if (!isset($children[$params['menu_parent']])) {
$children[$params['menu_parent']] = array();
}
}
/* Check if the current user has permisson to see this
* application, and if the application is
* active. Administrators always see all applications. Anyone
* with SHOW permissions can see an application, but READ is
* needed to actually use the application. You can use this
* distinction to show applications to guests that they need
* to log in to use. If you don't want them to see apps they
* can't use, then don't give guests SHOW permissions to
* anything. */
if (Auth::isAdmin() && ($params['status'] == 'active' || $params['status'] == 'admin') || ($perms->exists($app) ? $perms->hasPermission($app, Auth::getAuth(), PERMS_SHOW) : Auth::getAuth()) && $params['status'] == 'active') {
if (isset($params['menu_parent'])) {
$children[$params['menu_parent']][$app] = $params;
}
} else {
if ($params['status'] != 'heading') {
$registry->applications[$app]['status'] = 'inactive';
}
}
}
$tmp = array();
foreach ($registry->applications as $app => $params) {
/* Filter out all parents without children. */
if (isset($children[$app])) {
if (count($children[$app])) {
$tmp[$app] = $params;
$tmp[$app]['children'] = true;
}
} else {
$tmp[$app] = $params;
}
}
$registry->applications = $tmp;
}
示例7: readUserData
/**
* Reads user data from the given data source
* Starts and verifies the PEAR::Auth login process
*
* @param string user handle
* @param string user password
* @param bool|int if the user data should be read using the auth user id
* @return bool true on success or false on failure
*
* @access public
*/
function readUserData($handle = '', $passwd = '', $auth_user_id = false)
{
$this->pearAuth->username = $auth_user_id !== false ? $auth_user_id : $handle;
$this->pearAuth->password = $passwd;
$this->pearAuth->start();
if (!$this->pearAuth->getAuth()) {
return null;
}
// User was found, read data into class variables and set return value to true
$this->propertyValues['auth_user_id'] = $this->pearAuth->getUsername();
$this->propertyValues['handle'] = $this->pearAuth->getUsername();
$this->propertyValues['passwd'] = $this->encryptPW($this->pearAuth->password);
if (!array_key_exists('is_active', $this->tables['users']['fields'])) {
$this->propertyValues['is_active'] = true;
}
if (!array_key_exists('lastlogin', $this->tables['users']['fields'])) {
$this->propertyValues['lastlogin'] = null;
}
return true;
}
示例8: dirname
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*/
@define('HORDE_BASE', dirname(__FILE__) . '/../..');
require_once HORDE_BASE . '/lib/base.php';
require_once HORDE_LIBS . 'Horde/Block.php';
require_once HORDE_LIBS . 'Horde/Identity.php';
require_once HORDE_LIBS . 'Horde/Menu.php';
require_once HORDE_LIBS . 'Horde/Help.php';
if (!Auth::isAuthenticated()) {
Horde::authenticationFailureRedirect();
}
// Get full name for title
$identity =& Identity::singleton();
$fullname = $identity->getValue('fullname');
if (empty($fullname)) {
$fullname = Auth::getAuth();
}
// Get refresh interval.
if ($prefs->getValue('summary_refresh_time')) {
$refresh_time = $prefs->getValue('summary_refresh_time');
$refresh_url = Horde::applicationUrl('services/portal/');
}
// Load layout from preferences.
$layout_pref = @unserialize($prefs->getValue('portal_layout'));
if (!is_array($layout_pref)) {
$layout_pref = array();
}
// Store the apps we need to load stylesheets for.
$cssApps = array();
foreach ($layout_pref as $row) {
foreach ($row as $item) {
示例9: _setValuesToKeys
}
$auth =& Auth::singleton($conf['auth']['driver']);
function _setValuesToKeys($in)
{
$out = array();
foreach ($in as $value) {
$out[$value] = $value;
}
asort($out);
return $out;
}
/* Set up VFS. */
require_once HORDE_LIBS . 'VFS.php';
$vfs_type = $conf['vfs']['type'];
$vfs_args = Horde::getDriverConfig('vfs', $vfs_type);
$vfs_args['user'] = Auth::getAuth();
$vfs =& VFS::singleton($vfs_type, $vfs_args);
@define('TEMPLATES_VFS_PATH', '.horde_templates');
/* Require Horde_Form libs. */
require_once HORDE_LIBS . 'Horde/Form.php';
require_once HORDE_LIBS . 'Horde/Form/Renderer.php';
require_once HORDE_LIBS . 'Horde/Form/Action.php';
/* Set up Horde_Form. */
$vars =& Variables::getDefaultVariables();
$form =& Horde_Form::singleton('TemplatesForm', $vars);
$action =& Horde_Form_Action::factory('submit');
/* Set up form fields. */
$apps = _setValuesToKeys($registry->listApps());
$select_app =& $form->addVariable(_("Application"), 'app', 'enum', true, false, null, array($apps));
$select_app->setAction($action);
$form->addHidden('', 'old_app', 'text', false, false);
示例10:
?>
<!-- Produced By Ron Royston, ron@stndip.com -->
<html lang="en">
<body class="">
<!-- Uses a header that scrolls with the text, rather than staying locked at the top -->
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
<header class="mdl-layout__header mdl-layout__header--scroll mdl-color--white mdl-color--grey-600 ">
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-title font1 xl">rack!</span>
<!-- Add spacer, to align navigation to the right -->
<div class="mdl-layout-spacer"></div>
<!-- Navigation -->
<nav class="mdl-navigation">
<?php
if ($a->getAuth()) {
echo "<a class=\"mdl-navigation__link\" href=\"profile\">" . $a->getUsername() . "</a>";
echo '<a class="mdl-navigation__link" href="includes/logout">logout</a>';
} else {
echo '<a class="mdl-navigation__link" href="access">Login / Register</a>';
}
?>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable">
<label class="mdl-button mdl-js-button mdl-button--icon" for="search">
<i class="material-icons">search</i>
</label>
<div class="mdl-textfield__expandable-holder">
<input class="mdl-textfield__input" type="text" id="search" />
<label class="mdl-textfield__label" for="search">Enter your query...</label>
</div>
</div>
示例11: elseif
exit;
} else {
$url = Util::getFormData('url');
$initial_app = $prefs->getValue('initial_application');
if (!empty($url)) {
$main_page = $url;
} elseif (!empty($initial_app) && !($GLOBALS['perms']->exists($initial_app) && !$GLOBALS['perms']->hasPermission($initial_app, Auth::getAuth(), PERMS_READ))) {
$main_page = Horde::url($registry->getInitialPage($initial_app));
} elseif (isset($registry->applications['horde']['initial_page'])) {
$main_page = Horde::applicationUrl($registry->applications['horde']['initial_page']);
} elseif (Auth::getAuth()) {
$main_page = Horde::applicationUrl('services/portal/');
} else {
$main_page = Horde::applicationUrl('login.php');
}
if (!Util::getFormData('frameset') && ($conf['menu']['always'] || $conf['menu']['display'] && Auth::getAuth() && $prefs->getValue('show_sidebar'))) {
if ($browser->hasQuirk('scrollbar_in_way')) {
$scrollbar = 'yes';
} else {
$scrollbar = 'auto';
}
$main_page = Util::addParameter($main_page, 'frameset', 1);
require HORDE_TEMPLATES . '/index/frames_index.inc';
} else {
header('Location: ' . $main_page);
exit;
}
}
} else {
define('HORDE_LIBS', '');
require HORDE_BASE . '/lib/Test.php';
示例12: download
public function download()
{
// remove session
if (isset($_SESSION['showDownload'])) {
// reset session variable for next time
$_SESSION['showDownload'] = null;
unset($_SESSION['showDownload']);
session_write_close();
}
// php script timeout for long downloads (2 days!)
set_time_limit(60 * 60 * 24 * 2);
// load the server the file is on
$storageType = 'local';
$storageLocation = _CONFIG_FILE_STORAGE_PATH;
$uploadServerDetails = $this->loadServer();
if ($uploadServerDetails != false) {
$storageLocation = $uploadServerDetails['storagePath'];
$storageType = $uploadServerDetails['serverType'];
// if no storage path set & local, use system default
if (strlen($storageLocation) == 0 && $storageType == 'local') {
$storageLocation = _CONFIG_FILE_STORAGE_PATH;
}
}
// get file path
$fullPath = $this->getFullFilePath($storageLocation);
// open file - via ftp
if ($storageType == 'remote') {
// connect via ftp
$conn_id = ftp_connect($uploadServerDetails['ipAddress'], $uploadServerDetails['ftpPort'], 30);
if ($conn_id === false) {
$this->errorMsg = 'Could not connect to ' . $uploadServerDetails['ipAddress'] . ' to upload file.';
return false;
}
// authenticate
$login_result = ftp_login($conn_id, $uploadServerDetails['ftpUsername'], $uploadServerDetails['ftpPassword']);
if ($login_result === false) {
$this->errorMsg = 'Could not login to ' . $uploadServerDetails['ipAddress'] . ' with supplied credentials.';
return false;
}
// prepare the stream of data
$pipes = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
if ($pipes === false) {
$this->errorMsg = 'Could not create stream to download file on ' . $uploadServerDetails['ipAddress'];
return false;
}
stream_set_write_buffer($pipes[0], 10000);
stream_set_timeout($pipes[1], 10);
stream_set_blocking($pipes[1], 0);
$fail = false;
$ret = ftp_nb_fget($conn_id, $pipes[0], $fullPath, FTP_BINARY, FTP_AUTORESUME);
} else {
$handle = @fopen($fullPath, "r");
if (!$handle) {
$this->errorMsg = 'Could not open file for reading.';
return false;
}
}
// download speed
$speed = 0;
// if free/non user
$Auth = Auth::getAuth();
if ($Auth->loggedIn == false || $Auth->level == 'free user') {
$speed = (int) SITE_CONFIG_FREE_USER_MAX_DOWNLOAD_SPEED;
} else {
$speed = (int) SITE_CONFIG_PREMIUM_USER_MAX_DOWNLOAD_SPEED;
}
// do we need to throttle the speed?
if ($speed > 0) {
// create new throttle config
$config = new ThrottleConfig();
// set standard transfer rate (in bytes/second)
$config->burstLimit = $speed;
$config->rateLimit = $speed;
// enable module (this is a default value)
$config->enabled = true;
// start throttling
$x = new Throttle($config);
}
// output some headers
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-type: " . $this->fileType);
header("Pragma: public");
header("Content-Disposition: attachment; filename=\"" . str_replace("\"", "", $this->originalFilename) . "\"");
header("Content-Description: File Transfer");
header("Content-Length: " . $this->fileSize);
// output file - via ftp
if ($storageType == 'remote') {
while ($ret == FTP_MOREDATA) {
$contents = stream_get_contents($pipes[1]);
if ($contents !== false) {
echo $contents;
flush();
}
$ret = ftp_nb_continue($conn_id);
}
/*
$contents = stream_get_contents($pipes[1]);
if($contents !== false)
{
//.........这里部分代码省略.........
示例13: header
if (isset($registry->applications['logout']['initial_page']) && $registry->applications['logout']['initial_page'] != 'login.php?' . AUTH_REASON_PARAM . '=' . AUTH_REASON_LOGOUT) {
header('Location: ' . Horde::applicationUrl($registry->applications['logout']['initial_page']));
exit;
}
Horde::setupSessionHandler();
@session_start();
NLS::setLang($language);
/* Hook to preselect the correct language in the widget. */
$_GET['new_lang'] = $language;
}
if (isset($_POST['horde_user']) && isset($_POST['horde_pass'])) {
/* Destroy any existing session on login and make sure to use a
* new session ID, to avoid session fixation issues. */
Horde::getCleanSession();
if ($auth->authenticate(Util::getPost('horde_user'), array('password' => Util::getPost('horde_pass')))) {
$entry = sprintf('Login success for %s [%s] to Horde', Auth::getAuth(), $_SERVER['REMOTE_ADDR']);
Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO);
if ($url_param) {
$url = Horde::url(Util::removeParameter($url_param, session_name()), true);
$horde_url = Horde::applicationUrl($registry->getParam('webroot', 'horde') . '/index.php', true);
$horde_url = Util::addParameter($horde_url, 'url', $url);
} else {
$horde_url = Horde::applicationUrl('index.php', true);
}
$horde_url = Util::addParameter($horde_url, 'frameset', Util::getFormData('frameset') ? 1 : 0);
header('Location: ' . $horde_url);
exit;
} else {
$entry = sprintf('FAILED LOGIN for %s [%s] to Horde', Util::getFormData('horde_user'), $_SERVER['REMOTE_ADDR']);
Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_ERR);
if ($conf['menu']['always'] && !Util::getFormData('framed')) {
示例14: handle_file_upload
//.........这里部分代码省略.........
$file_path = $uploadPathDir . '/' . $newFilename;
clearstatcache();
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
// initiate ftp
$ret = ftp_nb_put($conn_id, $file_path, $uploaded_file, FTP_BINARY, FTP_AUTORESUME);
while ($ret == FTP_MOREDATA) {
// continue uploading
$ret = ftp_nb_continue($conn_id);
}
if ($ret != FTP_FINISHED) {
$fileUpload->error = 'There was a problem uploading the file to ' . $uploadServerDetails['ipAddress'];
} else {
$file_size = filesize($uploaded_file);
@unlink($uploaded_file);
}
}
}
// close ftp connection
ftp_close($conn_id);
} else {
// create the upload folder
$uploadPathDir = $this->options['upload_dir'] . substr($newFilename, 0, 2);
@mkdir($uploadPathDir);
$file_path = $uploadPathDir . '/' . $newFilename;
clearstatcache();
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
move_uploaded_file($uploaded_file, $file_path);
}
$file_size = filesize($file_path);
}
// check filesize uploaded matches tmp uploaded
if ($file_size === $fileUpload->size) {
$fileUpload->url = $this->options['upload_url'] . rawurlencode($fileUpload->name);
// insert into the db
$fileUpload->size = $file_size;
$fileUpload->delete_url = '~d?' . $this->options['delete_hash'];
$fileUpload->info_url = '~i?' . $this->options['delete_hash'];
$fileUpload->delete_type = 'DELETE';
// create delete hash, make sure it's unique
$deleteHash = md5($fileUpload->name . getUsersIPAddress() . microtime());
$existingFile = file::loadByDeleteHash($deleteHash);
while ($existingFile != false) {
$deleteHash = md5($fileUpload->name . getUsersIPAddress() . microtime());
$existingFile = file::loadByDeleteHash($deleteHash);
}
// store in db
$db = Database::getDatabase(true);
$dbInsert = new DBObject("file", array("originalFilename", "shortUrl", "fileType", "extension", "fileSize", "localFilePath", "userId", "totalDownload", "uploadedIP", "uploadedDate", "statusId", "deleteHash", "serverId"));
$dbInsert->originalFilename = $fileUpload->name;
$dbInsert->shortUrl = 'temp';
$dbInsert->fileType = $fileUpload->type;
$dbInsert->extension = $extension;
$dbInsert->fileSize = $fileUpload->size;
$dbInsert->localFilePath = substr($file_path, strlen($this->options['upload_dir']), 99999);
// add user id if user is logged in
$dbInsert->userId = NULL;
$Auth = Auth::getAuth();
if ($Auth->loggedIn()) {
$dbInsert->userId = (int) $Auth->id;
}
$dbInsert->totalDownload = 0;
$dbInsert->uploadedIP = getUsersIPAddress();
$dbInsert->uploadedDate = sqlDateTime();
$dbInsert->statusId = 1;
$dbInsert->deleteHash = $deleteHash;
$dbInsert->serverId = $uploadServerId;
if (!$dbInsert->insert()) {
$fileUpload->error = 'abort';
}
// create short url
$tracker = 1;
$shortUrl = file::createShortUrlPart($tracker . $dbInsert->id);
$fileTmp = file::loadByShortUrl($shortUrl);
while ($fileTmp) {
$shortUrl = file::createShortUrlPart($tracker . $dbInsert->id);
$fileTmp = file::loadByShortUrl($shortUrl);
$tracker++;
}
// update short url
file::updateShortUrl($dbInsert->id, $shortUrl);
// update fileUpload with file location
$file = file::loadByShortUrl($shortUrl);
$fileUpload->url = $file->getFullShortUrl();
$fileUpload->delete_url = $file->getDeleteUrl();
$fileUpload->info_url = $file->getInfoUrl();
$fileUpload->stats_url = $file->getStatisticsUrl();
$fileUpload->short_url = $shortUrl;
} else {
if ($this->options['discard_aborted_uploads']) {
//@TODO - made ftp compatible
@unlink($file_path);
@unlink($uploaded_file);
if (!isset($fileUpload->error)) {
$fileUpload->error = 'maxFileSize';
}
}
}
}
return $fileUpload;
}
示例15: array
require_once "Auth/Auth.php";
require_once "DB.php";
// Paramètres pour la base de données
require_once PATH_INCLUDE . 'database.inc.php';
$DSN = "mysql://{$dbuser}:{$dbpass}@{$dbhost}/{$dbbase}";
// Identification de l'utilisateur
$options = array('table' => 'uti_utilisateur', 'usernamecol' => 'uti_login', 'passwordcol' => 'uti_password', 'dsn' => $DSN);
require_once PATH_INC_BACKEND . 'logon.php';
$openwebAuth = new Auth("DB", $options, 'ow_html_login_box', true);
$openwebAuth->start();
if (isset($_GET['logon'])) {
$openwebAuth->logout();
session_destroy();
$openwebAuth->start();
}
if (!$openwebAuth->getAuth()) {
exit;
}
// Connexion à la base de données
$db = DB::Connect($DSN);
$db->setFetchMode(DB_FETCHMODE_ASSOC);
// Récuperation des données de l'utilisateur
if (!isset($_SESSION['utilisateur'])) {
require_once PATH_INC_BACKEND_SERVICE . 'UserManager.class.php';
$um = new UserManager($db);
if (($user = $um->getUserDatas($openwebAuth->username)) === null) {
session_destroy();
echo 'Problème de lecture de vos données personnelles';
exit;
}
// Vérifie si l'utilisateur est autorisé à se connecter