本文整理汇总了PHP中Auth::is_logged_in方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::is_logged_in方法的具体用法?PHP Auth::is_logged_in怎么用?PHP Auth::is_logged_in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::is_logged_in方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
/**
*
*/
public function before()
{
parent::before();
if ($this->request->action() == 'login' && Auth::is_logged_in()) {
$this->go_home();
}
}
示例2: before
public function before()
{
parent::before();
if (file_exists(CMSPATH . FileSystem::normalize_path('media/js/i18n/' . I18n::lang() . '-message.js'))) {
Assets::js('i18n', ADMIN_RESOURCES . 'js/i18n/' . I18n::lang() . '-message.js', 'global');
}
if ($this->request->action() != 'logout' and Auth::is_logged_in()) {
$this->go_home();
}
}
示例3: _deny_access
/**
* Send response with error code.
*
* @param string $message
* @throws HTTP_Exception
*/
protected function _deny_access($message = null)
{
if (Auth::is_logged_in() || $this->request->is_ajax()) {
if ($message === null) {
$message = 'No tienes permisos para acceder a esta página';
}
throw HTTP_Exception::factory(403, $message);
} else {
throw HTTP_Exception::factory(401);
}
}
示例4: _deny_access
/**
*
* @param string $message
* @throws HTTP_Exception
*/
protected function _deny_access($message = NULL)
{
if (Auth::is_logged_in() or $this->request->is_ajax()) {
if ($message === NULL) {
$message = 'You don`t have permissions to acces this page';
}
// Forbidden
throw HTTP_Exception::factory(403, $message);
} else {
// Unauthorized / Login Requied
throw HTTP_Exception::factory(401);
}
}
示例5: _render
/**
*
* @param type Model_Page_Front
*/
private function _render(Model_Page_Front $page)
{
View::set_global('page_object', $page);
View::set_global('page', $page);
$this->_ctx->set_page($page);
// If page needs login, redirect to login
if ($page->needs_login() == Model_Page::LOGIN_REQUIRED) {
Observer::notify('frontpage_login_required', $page);
if (!Auth::is_logged_in()) {
Flash::set('redirect', $page->url());
$this->redirect(Route::get('user')->uri(array('action' => 'login')));
}
}
Observer::notify('frontpage_found', $page);
$this->_ctx->set_crumbs($page);
$this->_ctx->build_crumbs();
// Если установлен статус 404, то выводим страницу 404
// Страницу 404 могут выкидывать также Виджеты
if (Request::current()->is_initial() and $this->response->status() == 404) {
$message = $this->_ctx->get('throw_message');
$this->_ctx = NULL;
if (!$message) {
$message = 'Page not found';
}
Model_Page_Front::not_found($message);
}
$html = (string) $page->render_layout();
// Если пользователь Администраторо или девелопер, в конец шаблона
// добавляем View 'system/blocks/toolbar', в котором можно добавлять
// собственный HTML, например панель администратора
if (Auth::is_logged_in() and Auth::has_permissions(array('administrator', 'developer'))) {
$inject_html = (string) View::factory('system/blocks/toolbar');
// Insert system HTML before closed tag body
$matches = preg_split('/(<\\/body>)/i', $html, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
if (count($matches) > 1) {
/* assemble the HTML output back with the iframe code in it */
$html = $matches[0] . $inject_html . $matches[1] . $matches[2];
}
}
// Если в наcтройках выключен режим отладки, то выключить etag кеширование
if (Config::get('site', 'debug') == Config::NO) {
$this->check_cache(sha1($html));
$this->response->headers('last-modified', date('r', strtotime($page->updated_on)));
}
$this->response->headers('Content-Type', $page->mime());
if (Config::get('global', 'x_powered_header') == Config::YES) {
$this->response->headers('X-Powered-CMS', CMS_NAME . '/' . CMS_VERSION);
}
$this->response->body($html);
}
示例6: printHTMLHeader
/**
* Print all XHTML headers
* This function prints the HTML header code, CSS link, and JavaScript link
*
* DOCTYPE is XHTML 1.0 Transitional
* @param none
*/
function printHTMLHeader()
{
global $conf;
global $languages;
global $lang;
global $charset;
$path = $this->dir_path;
echo "<?xml version=\"1.0\" encoding=\"{$charset}\"?" . ">\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php
echo $languages[$lang][2];
?>
" lang="<?php
echo $languages[$lang][2];
?>
">
<head>
<title> Room Reservation System
</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php
echo $charset;
?>
" />
<?php
if ((bool) $conf['app']['allowRss'] && Auth::is_logged_in()) {
echo '<link rel="alternate" type="application/rss+xml" title="phpScheduleIt" href=" ' . CmnFns::getScriptURL() . '/rss.php?id=' . Auth::getCurrentID() . "\"/>\n";
}
?>
<link rel="shortcut icon" href="favicon.ico"/>
<link rel="icon" href="favicon.ico"/>
<style type="text/css">
@import url(<?php
echo $path;
?>
jscalendar/calendar-blue-custom.css);
@import url(<?php
echo $path;
?>
css.css);
</style>
</head>
<body>
<?php
}
示例7: action_profile
public function action_profile()
{
$id = $this->request->param('id');
if (empty($id) and Auth::is_logged_in()) {
$id = Auth::get_id();
}
$user = ORM::factory('user', $id);
if (!$user->loaded()) {
Messages::errors(__('User not found!'));
$this->go();
}
$this->template->title = __(':user profile', array(':user' => $user->username));
$this->breadcrumbs->add($this->template->title);
$this->template_js_params['USER_ID'] = $user->id;
$this->template->content = View::factory('users/profile', array('user' => $user, 'permissions' => $user->permissions_list()));
}
示例8: filtered_fields
/**
*
* @global type $table_name
* @param array $fields
* @param array $related_columns
* @param array $remove_fields
* @return array
* @throws HTTP_API_Exception
*/
public function filtered_fields($fields, $remove_fields = array())
{
if (!is_array($fields)) {
$fields = array($fields);
}
$secured_fields = array_intersect($this->_secured_columns, $fields);
// Exclude fields
$fields = array_diff($fields, $remove_fields);
// TODO сделать проверку токена, выдаваемого под API
if (!empty($secured_fields) and !Auth::is_logged_in('login')) {
throw HTTP_API_Exception::factory(API::ERROR_PERMISSIONS, 'You don`t have permissions to access to this fields (:fields).', array(':fields' => implode(', ', $secured_fields)));
}
$fields = array_intersect(array_keys($this->_table_columns), $fields);
foreach ($fields as $i => $field) {
$fields[$i] = $this->table_name() . '.' . $field;
}
return $fields;
}
示例9: character
public function character($id = false)
{
// load the models
$this->load->model('ranks_model', 'ranks');
$this->load->model('positions_model', 'pos');
$this->load->model('posts_model', 'posts');
$this->load->model('personallogs_model', 'logs');
$this->load->model('news_model', 'news');
$this->load->model('awards_model', 'awards');
$this->load->helper('utility');
$id = is_numeric($id) ? $id : false;
$character = $this->char->get_character($id);
$data['postcount'] = 0;
$data['logcount'] = 0;
$data['newscount'] = 0;
$data['awardcount'] = 0;
if ($character !== false) {
$data['postcount'] = $this->posts->count_character_posts($id);
$data['logcount'] = $this->logs->count_character_logs($id);
$data['newscount'] = $this->news->count_character_news($id);
$data['awardcount'] = $this->awards->count_character_awards($id);
$data['last_post'] = mdate($this->options['date_format'], gmt_to_local($character->last_post, $this->timezone, $this->dst));
$name_array = array('first_name' => $character->first_name, 'middle_name' => $character->middle_name, 'last_name' => $character->last_name, 'suffix' => $character->suffix);
$name = parse_name($name_array);
$abbr_name = parse_name(array('first_name' => $character->first_name, 'last_name' => $character->last_name));
$rank = $this->ranks->get_rank($character->rank, 'rank_name');
$data['character_info'] = array(array('label' => ucfirst(lang('labels_name')), 'value' => $name), array('label' => ucfirst(lang('global_position')), 'value' => $this->pos->get_position($character->position_1, 'pos_name')), array('label' => ucwords(lang('order_second') . ' ' . lang('global_position')), 'value' => $this->pos->get_position($character->position_2, 'pos_name')), array('label' => ucfirst(lang('global_rank')), 'value' => $rank));
$data['character']['id'] = $id;
$data['character']['name'] = $name;
$data['character']['rank'] = $character->rank;
$data['character']['position_1'] = $character->position_1;
$data['character']['position_2'] = $character->position_2;
$data['character']['user'] = $character->user;
if ($character->images > '') {
$images = explode(',', $character->images);
$images_count = count($images);
$src = strstr($images[0], 'http://') !== false ? $images[0] : base_url() . Location::asset('images/characters', trim($images[0]));
$data['character']['image'] = array('src' => $src, 'alt' => $name, 'class' => 'image', 'width' => 200);
$data['character']['image_array'] = array();
for ($i = 1; $i < $images_count; $i++) {
$src = strstr($images[$i], 'http://') !== false ? trim($images[$i]) : base_url() . Location::asset('images/characters', trim($images[$i]));
$data['character']['image_array'][] = array('src' => $src, 'alt' => $name, 'class' => 'image');
}
} else {
$data['character']['noavatar'] = array('src' => Location::img('no-avatar.png', $this->skin, 'main'), 'alt' => '', 'class' => 'image', 'width' => 200);
}
$tabs = $this->char->get_bio_tabs();
$sections = $this->char->get_bio_sections();
if ($tabs->num_rows() > 0) {
$i = 1;
foreach ($tabs->result() as $tab) {
$data['tabs'][$i]['id'] = $tab->tab_id;
$data['tabs'][$i]['name'] = $tab->tab_name;
$data['tabs'][$i]['link'] = $tab->tab_link_id;
++$i;
}
}
if ($sections->num_rows() > 0) {
$i = 1;
foreach ($sections->result() as $sec) {
$fields = $this->char->get_bio_fields($sec->section_id);
if ($fields->num_rows() > 0) {
$j = 1;
foreach ($fields->result() as $field) {
$data['fields'][$sec->section_id][$j]['label'] = $field->field_label_page;
$data['fields'][$sec->section_id][$j]['value'] = false;
$info = $this->char->get_field_data($field->field_id, $id);
if ($info->num_rows() > 0) {
foreach ($info->result() as $item) {
$data['fields'][$sec->section_id][$j]['value'] = $item->data_value;
}
}
++$j;
}
}
if ($tabs->num_rows() > 0) {
$data['sections'][$sec->section_tab][$i]['id'] = $sec->section_id;
$data['sections'][$sec->section_tab][$i]['name'] = $sec->section_name;
} else {
$data['sections'][$i]['id'] = $sec->section_id;
$data['sections'][$i]['name'] = $sec->section_name;
}
++$i;
}
}
// set the header
$data['header'] = $rank . ' ' . $abbr_name;
$this->_regions['title'] .= ucfirst(lang('labels_biography')) . ' - ' . $abbr_name;
} else {
$data['header'] = sprintf(lang('error_title_invalid_char'), ucfirst(lang('global_character')));
$data['msg_error'] = sprintf(lang_output('error_msg_invalid_char'), lang('global_character'));
$this->_regions['title'] .= lang('error_pagetitle');
}
if (Auth::is_logged_in()) {
$data['edit_valid_form'] = Auth::check_access('site/bioform', false) ? true : false;
if (Auth::check_access('characters/bio', false) === true) {
if (Auth::get_access_level('characters/bio') == 3) {
$data['edit_valid'] = true;
} elseif (Auth::get_access_level('characters/bio') == 2) {
$characters = $this->char->get_user_characters($this->session->userdata('userid'), '', 'array');
//.........这里部分代码省略.........
示例10: list
*
* Copyright (C) 2003 - 2007 phpScheduleIt
* License: GPL, see LICENSE
*/
list($s_sec, $s_msec) = explode(' ', microtime());
// Start execution timer
/**
* Include Template class
*/
include_once 'lib/Template1.class.php';
/**
* Include scheduler-specific output functions
*/
include_once 'lib/Schedule1.class.php';
// Check that the user is logged in
if (!Auth::is_logged_in()) {
Auth::print_login_msg();
}
$t = new Template1(translate('Online Scheduler'));
$s = new Schedule(isset($_GET['scheduleid']) ? $_GET['scheduleid'] : null);
// Print HTML headers
$t->printHTMLHeader();
// Print welcome box
$t->printWelcome();
// Begin main table
$t->startMain();
ob_start();
// The schedule may take a long time to print out, so buffer all of that HTML data
if ($s->isValid) {
// Print Calendar Navigation on the left side
$t->startNavLinkTable();
示例11: execute
/**
*
* @return Response
* @throws HTTP_API_Exception
*/
public function execute()
{
$this->_model = ORM::factory('Api_Key');
if ($this->request->action() == 'index' or $this->request->action() == '') {
$action = 'rest_' . $this->request->method();
} else {
// Determine the action to use
$action = $this->request->method() . '_' . $this->request->action();
}
$action = strtolower($action);
$is_logged_in = Auth::is_logged_in();
try {
/**
* Если выключено API, запретить доступ не авторизованным пользователям к нему
*/
if (Config::get('api', 'mode') == 'no' and (!$is_logged_in and $this->is_backend())) {
throw new HTTP_Exception_403('Public API is disabled');
}
/**
* Если невалидный ключ и пользователь не авторизован
* или экшен не публичный то запретить доступ к API
*/
if (!$is_logged_in and !in_array($action, $this->public_actions)) {
if (!$this->_model->is_valid($this->param('api_key'))) {
throw new HTTP_Exception_403('API key not valid');
}
}
// Execute the "before action" method
$this->before();
/**
* Проверка токена на валидность, если этого требует экшен или контроллер
*/
if ($this->_check_token !== FALSE) {
$this->_check_token();
}
// If the action doesn't exist, it's a 404
if (!method_exists($this, $action)) {
throw HTTP_API_Exception::factory(API::ERROR_PAGE_NOT_FOUND, 'The requested method ":method" was not found on this server.', array(':method' => $action))->request($this->request);
}
// Execute the action itself
$this->{$action}();
} catch (HTTP_API_Exception $e) {
$this->json = $e->get_response();
} catch (API_Validation_Exception $e) {
$this->json = $e->get_response();
} catch (ORM_Validation_Exception $e) {
$this->json = array('code' => API::ERROR_VALIDATION, 'message' => rawurlencode($e->getMessage()), 'response' => NULL, 'errors' => $e->errors('validation'));
} catch (Validation_Exception $e) {
$this->json = array('code' => API::ERROR_VALIDATION, 'message' => rawurlencode($e->getMessage()), 'response' => NULL, 'errors' => $e->errors('validation'));
} catch (Exception $e) {
$this->json['code'] = $e->getCode();
$this->json['line'] = $e->getLine();
$this->json['file'] = $e->getFile();
$this->json['message'] = $e->getMessage();
$this->json['response'] = NULL;
}
// Execute the "after action" method
$this->after();
// Return the response
return $this->response;
}
示例12: defined
<?php
defined('SYSPATH') or die('No direct access allowed.');
if (IS_BACKEND) {
Route::set('datasources', ADMIN_DIR_NAME . '/<directory>(/<controller>(/<action>(/<id>)))', array('directory' => '(datasources|' . implode('|', array_keys(Datasource_Data_Manager::types())) . ')'))->defaults(array('directory' => 'datasources', 'controller' => 'data', 'action' => 'index'));
}
Observer::observe('modules::after_load', function () {
if (!IS_BACKEND or !Auth::is_logged_in()) {
return;
}
$types = Datasource_Data_Manager::types();
if (empty($types)) {
return;
}
try {
$ds_section = Model_Navigation::get_section('Datasources');
$ds_section->icon = 'tasks';
$sections_list = Datasource_Data_Manager::get_tree(array_keys($types));
$datasource_is_empty = empty($sections_list);
$folders = Datasource_Folder::get_all();
$root_sections = array();
foreach ($sections_list as $type => $sections) {
foreach ($sections as $id => $section) {
if ($section->show_in_root_menu()) {
$root_sections[] = $section;
unset($sections_list[$type][$id]);
continue;
}
if (array_key_exists($section->folder_id(), $folders)) {
$folders[$section->folder_id()]['sections'][] = $section;
unset($sections_list[$type][$id]);
示例13: print_join_form
/**
* Prints out the textboxes and buttons for the self registration
* @param bool $allow_participation if self registration is allowed for registered users
* @param bool $allow_anon_participation if self registration is allowed for non registered users
*/
function print_join_form($allow_participation, $allow_anon_participation, $parentid)
{
$join = translate('Join');
$allow_participation = $allow_participation && Auth::is_logged_in();
$allow_anon_participation = $allow_anon_participation && !Auth::is_logged_in();
?>
</tr><tr><td colspan="3">
<p align="center" style="margin-top:10px;"><a href="javascript:showHide('join_options');"><?php
echo translate('My Participation Options');
?>
</a></p>
<div id="join_options" style="display:none;">
<?php
if ($allow_participation) {
echo '<input type="hidden" name="join_userid" id="join_userid" value="' . Auth::getCurrentID() . '"/>';
} else {
if ($allow_anon_participation) {
?>
<table width="100%" border="0" style="border: dashed 1px #DDDDDD;background-color:#FFFFFF;" align="center">
<tr>
<td align="right" width="20%"><?php
echo translate('First Name');
?>
</td>
<td><input type="text" name="join_fname" id="join_fname" class="textbox" maxlength="30"/></td>
</tr>
<tr>
<td align="right"><?php
echo translate('Last Name');
?>
</td>
<td><input type="text" name="join_lname" id="join_lname" class="textbox" maxlength="30"/></td>
</tr>
<tr>
<td align="right"><?php
echo translate('Email');
?>
</td>
<td><input type="text" name="join_email" id="join_email" class="textbox" maxlength="75"/></td>
</tr>
</table>
<?php
}
}
if ($allow_participation || $allow_anon_participation) {
echo '<p align="center">';
echo '<button type="button" name="btn_join" value="' . $join . '" class="button" onclick="submitJoinForm(' . (int) $allow_participation . ');">' . $join . '</button>';
//echo ($parentid != null) ? ' <input type="checkbox" name="join_parentid"/> ' . translate('Join All Recurring') : '';
echo '</p>';
}
?>
</div>
</td>
<?php
}
示例14: render
/**
* Рендер виджета во Frontend
*
* Отключение комментариев для блока
*
* Block::run('block_name', array('comments' => FALSE));
*
* Отключение кеширования виджетов в блоке
*
* Block::run('block_name', array('caching' => FALSE));
*
* @param array $params Дополнительные параметры
*/
public function render(array $params = array())
{
// Проверка прав на видимость виджета
if (!empty($this->roles)) {
if (Auth::is_logged_in()) {
if (!Auth::has_permissions($this->roles, FALSE)) {
return;
}
} else {
return;
}
}
if (Kohana::$profiling === TRUE) {
$benchmark = Profiler::start('Widget render', $this->name);
}
$this->_fetch_template();
$this->set_params($params);
$allow_omments = (bool) Arr::get($this->template_params, 'comments', TRUE);
$caching = (bool) Arr::get($this->template_params, 'caching', $this->caching);
if ($this->block == 'PRE' or $this->block == 'POST') {
$allow_omments = FALSE;
}
if (Kohana::$caching === FALSE or $caching === FALSE) {
$this->caching = FALSE;
}
if (Arr::get($this->template_params, 'return') === TRUE) {
return $this->_fetch_render();
}
if ($allow_omments) {
echo "<!--{Widget: {$this->name}}-->";
}
if ($this->caching === TRUE and !Fragment::load($this->get_cache_id(), $this->cache_lifetime, TRUE)) {
echo $this->_fetch_render();
Fragment::save_with_tags($this->cache_lifetime, $this->cache_tags);
} else {
if (!$this->caching) {
echo $this->_fetch_render();
}
}
if ($allow_omments) {
echo "<!--{/Widget: {$this->name}}-->";
}
if (isset($benchmark)) {
Profiler::stop($benchmark);
}
}
示例15: is_admin
self::create_user();
return $_SESSION[Config::$sitename]['user']['id'];
}
public static function is_admin()
{
self::create_user();
return !!$_SESSION[Config::$sitename]['user']['is_admin'];
}
public static function is_logged_in()
{
self::create_user();
return !!$_SESSION[Config::$sitename]['user']['logged_in'];
}
public static function user()
{
return self::$user;
}
private static function create_user()
{
if (!isset($_SESSION[Config::$sitename]['user'])) {
$_SESSION[Config::$sitename]['user'] = array();
$_SESSION[Config::$sitename]['user']['id'] = 0;
$_SESSION[Config::$sitename]['user']['is_admin'] = false;
$_SESSION[Config::$sitename]['user']['logged_in'] = false;
}
}
}
if (Config::$auth_table && Auth::is_logged_in()) {
Auth::$user = new Model(Config::$auth_table);
Auth::$user->load(Auth::user_id());
}