本文整理汇总了PHP中gatekeeper函数的典型用法代码示例。如果您正苦于以下问题:PHP gatekeeper函数的具体用法?PHP gatekeeper怎么用?PHP gatekeeper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gatekeeper函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: customstyle_page_handler
function customstyle_page_handler($page)
{
gatekeeper();
elgg_set_context('customstyle');
elgg_set_page_owner_guid(elgg_get_logged_in_user_guid());
$title = elgg_echo('customstyle');
$base_dir = elgg_get_plugins_path() . 'customstyle/pages/customstyle';
switch ($page[0]) {
case 'colors':
$body = elgg_view('customstyle/colors');
break;
case 'background':
$body = elgg_view('customstyle/background');
break;
case 'personalize':
$body = elgg_view('customstyle/default');
break;
default:
$body = elgg_view('customstyle/default');
break;
}
$params = array('content' => $body, 'title' => $title);
$body = elgg_view_layout('one_sidebar', $params);
echo elgg_view_page($title, $body);
return true;
}
示例2: stripe_page_handler
/**
* Stripe related pages
*
* @param array $page
* @param string $handler
* @return boolean
*/
function stripe_page_handler($page, $handler)
{
gatekeeper();
$username = elgg_extract(0, $page, false);
if ($username) {
$user = get_user_by_username($username);
}
if (!elgg_instanceof($user) || !$user->canEdit()) {
$user = elgg_get_logged_in_user_entity();
forward("{$handler}/{$user->username}");
}
elgg_set_context('settings');
elgg_set_page_owner_guid($user->guid);
elgg_push_breadcrumb(elgg_echo('stripe:billing'), 'billing');
$context = elgg_extract(1, $page, 'cards');
$action = elgg_extract(2, $page, 'all');
$view = "stripe/pages/{$context}/{$action}";
if (elgg_view_exists($view)) {
$params = array('entity' => $user, 'id' => elgg_extract(3, $page, false), 'context' => $page);
$title = elgg_echo("stripe:{$context}:{$action}");
$content = elgg_view($view, $params);
$sidebar = elgg_view('stripe/sidebar', $params);
$filter = elgg_view("stripe/filters/{$context}/{$action}", $params);
}
if ($content) {
if (elgg_is_xhr()) {
echo $content;
} else {
$layout = elgg_view_layout('content', array('title' => $title, 'content' => $content, 'sidebar' => $sidebar, 'filter' => $filter));
echo elgg_view_page($title, $layout);
}
return true;
}
return false;
}
示例3: whoviewedme_page_handler
/**
* whoviewedme page handler
*
* @param array $page url segments
* @return bool
*/
function whoviewedme_page_handler($page)
{
gatekeeper();
$base = elgg_get_plugins_path() . 'whoviewedme/pages/whoviewedme';
require_once "{$base}/index.php";
return true;
}
示例4: twitter_api_pagehandler
/**
* Serves pages for twitter.
*
* @param array $page
*/
function twitter_api_pagehandler($page)
{
if (!isset($page[0])) {
forward();
}
switch ($page[0]) {
case 'authorize':
twitter_api_authorize();
break;
case 'revoke':
twitter_api_revoke();
break;
case 'forward':
twitter_api_forward();
break;
case 'login':
twitter_api_login();
break;
case 'interstitial':
gatekeeper();
// only let twitter users do this.
$guid = elgg_get_logged_in_user_guid();
$twitter_name = elgg_get_plugin_user_setting('twitter_name', $guid, 'twitter_api');
if (!$twitter_name) {
register_error(elgg_echo('twitter_api:invalid_page'));
forward();
}
$pages = dirname(__FILE__) . '/pages/twitter_api';
include "{$pages}/interstitial.php";
break;
default:
forward();
break;
}
}
示例5: set_notifier_page_handler
function set_notifier_page_handler($page, $identifier)
{
// select page based on first URL segment after /set_notifier/
switch ($page[0]) {
case 'set':
gatekeeper();
$num_users = 1;
$limit = 100;
$offset = 0;
while ($num_users != 0) {
$users = elgg_get_entities(array('types' => 'user', 'limit' => $limit, 'offset' => $offset));
if ($users != 0) {
foreach ($users as $user) {
$prefix = "notification:method:notifier";
$user->{$prefix} = true;
$user->collections_notifications_preferences_notifier = '-1';
$user->save();
}
}
$num_users = count($users);
$offset += $limit;
}
forward(REFERER);
break;
default:
echo "request for {$identifier} {$page['0']}";
break;
}
// return true to let Elgg know that a page was sent to browser
return true;
}
示例6: notifications_page_handler
/**
* Route page requests
*
* @param array $page Array of url parameters
* @return bool
*/
function notifications_page_handler($page)
{
gatekeeper();
$current_user = elgg_get_logged_in_user_entity();
// default to personal notifications
if (!isset($page[0])) {
$page[0] = 'personal';
}
if (!isset($page[1])) {
forward("notifications/{$page[0]}/{$current_user->username}");
}
$user = get_user_by_username($page[1]);
if ($user->guid != $current_user->guid && !$current_user->isAdmin()) {
forward();
}
$base = elgg_get_plugins_path() . 'notifications';
// note: $user passed in
switch ($page[0]) {
case 'group':
require "{$base}/groups.php";
break;
case 'personal':
require "{$base}/index.php";
break;
default:
return false;
}
return true;
}
示例7: page_handler
/**
* Serve pages. URLs in the form:
*
* pg/block_users/blocked_users/<username> - Users blocked by <username>. If not set, defaults to logged in.
* pg/block_users/blocked - The page to display when a user is blocked.
*
* @param array $page
* @return bool Depending on success
*/
function page_handler($page)
{
gatekeeper();
if (!isset($page[0])) {
$page[0] = 'blocked_users';
}
switch ($page[0]) {
case 'blocked_user_content':
$site = elgg_get_site_entity();
elgg_set_page_owner_guid($site->guid);
include dirname(__FILE__) . '/pages/block_users/blocked_user_content.php';
break;
case 'blocked_content':
$site = elgg_get_site_entity();
elgg_set_page_owner_guid($site->guid);
include dirname(__FILE__) . '/pages/block_users/blocked_content.php';
break;
default:
case 'blocked_users':
$logged_in_user = elgg_get_logged_in_user_entity();
if (!isset($page[1])) {
$page[1] = $logged_in_user->username;
}
set_input('blocking_username', $page[1]);
// only admins can see another user's block list
if ($page[1] != $logged_in_user->username) {
admin_gatekeeper();
}
include dirname(__FILE__) . '/pages/block_users/blocked_users.php';
}
return true;
}
示例8: staticsites_page_handler
/**
* Page handler for static sites
*
* This page handler will behave like a REST-ful api endpoint for GET request
* Since static sites 'containers' are groups, the resource naming and endpoints
* will look like:
*
* GET - {elgg_url}/staticsites/{group_guid}/page/{id}
* GET - {elgg_url}/staticsites/{group_guid}/pages
*
*/
function staticsites_page_handler($params)
{
// Logged in only
gatekeeper();
$is_xhr = elgg_is_xhr();
$is_xhr = 1;
// Debug
if ($is_xhr && $params[0]) {
// Check for container_guid as first param
if (is_numeric($params[0])) {
$container_guid = $params[0];
unset($params[0]);
$params = array_values($params);
}
switch ($params[0]) {
case "page":
staticsites_handle_page_request($params, $container_guid);
break;
case "pages":
staticsites_handle_pages_request($params, $container_guid);
break;
default:
return FALSE;
break;
}
} else {
return FALSE;
}
return TRUE;
}
示例9: loginrequired_init
function loginrequired_init()
{
global $CONFIG;
// No need to do all the checking below if the user is already logged in... performance is key :)
// if (elgg_is_logged_in()) return;
elgg_extend_view('css/elgg', 'loginrequired/css');
// elgg_unextend_view('page/elements/header', 'search/header');
elgg_register_plugin_hook_handler('index', 'system', 'loginrequired_index', 1);
elgg_register_plugin_hook_handler('login_required', 'login_required', 'login_required_default_allowed_list');
// Get the current page URL without any ? & parameters... this is required for the registration page to work properly
$current_url = current_page_url();
$parameters_start = strrpos($current_url, '?');
if ($parameters_start) {
$current_url = substr($current_url, 0, $parameters_start);
}
// Always allow index page
if ($current_url == $CONFIG->url) {
return;
}
$allow = array();
// Allow should have pages
$allow[] = '_graphics';
$allow[] = 'action/login';
$allow[] = 'register';
$allow[] = 'action/register';
$allow[] = 'forgotpassword';
$allow[] = 'resetpassword';
$allow[] = 'action/user/requestnewpassword';
$allow[] = 'action/user/passwordreset';
$allow[] = 'action/security/refreshtoken';
$allow[] = 'ajax/view/js/languages';
$allow[] = 'upgrade\\.php';
$allow[] = 'xml-rpc\\.php';
$allow[] = 'mt/mt-xmlrpc\\.cgi';
$allow[] = 'css/.*';
$allow[] = 'js/.*';
$allow[] = 'cache/css/.*';
$allow[] = 'cache/js/.*';
// Allow other plugin developers to edit the array values
$add_allow = elgg_trigger_plugin_hook('login_required', 'login_required');
// If more URL's are added... merge both with original list
if (is_array($add_allow)) {
$allow = array_merge($allow, $add_allow);
}
// Any public_pages defined via Elgg's walled garden plugin hook?
$plugins = elgg_trigger_plugin_hook('public_pages', 'walled_garden', NULL, array());
// If more URL's are added... merge both with original list
if (is_array($plugins)) {
$allow = array_merge($allow, $plugins);
}
// Check if current page is in allowed list... otherwise redirect to login
foreach ($allow as $public) {
$pattern = "`^{$CONFIG->url}{$public}/*\$`i";
if (preg_match($pattern, $current_url)) {
return;
}
}
gatekeeper();
}
示例10: logout
public function logout()
{
gatekeeper();
// Logout and redirect to frontpage
$this->Member_model->logout();
message('Successfully signed out.');
redirect('auth/login');
}
示例11: admin_gatekeeper
function admin_gatekeeper()
{
gatekeeper();
$CI =& get_instance();
if (!$CI->Group_model->member_of_group(member_id(), 'admins')) {
error('You have to be logged in as an administrator to access this page.');
redirect();
}
}
示例12: hj_framework_page_handlers
/**
* Page handlers for hypeFramework
*
*
* @param type $page
* @return type
*/
function hj_framework_page_handlers($page)
{
if (!isset($page[0])) {
forward();
}
$path_pages = elgg_get_root_path() . 'mod/hypeFramework/pages/';
switch ($page[0]) {
case 'edit':
set_input('guid', $page[1]);
include $path_pages . 'edit/object.php';
break;
case 'icon':
set_input('guid', $page[1]);
set_input('size', $page[2]);
include $path_pages . "icon/icon.php";
break;
case 'download':
set_input('guid', $page[1]);
include $path_pages . "file/download.php";
break;
case 'file':
switch ($page[1]) {
case 'create':
gatekeeper();
$container_guid = elgg_extract(2, $page, false);
if (!$container_guid) {
$container_guid = elgg_get_logged_in_user_guid();
}
elgg_set_page_owner_guid($container_guid);
set_input('container_guid', $container_guid);
include "{$path_pages}create/file.php";
break;
case 'edit':
gatekeeper();
set_input('guid', $page[2]);
include "{$path_pages}edit/object.php";
break;
case 'view':
if (!isset($page[2])) {
return false;
}
$entity = get_entity($page[2]);
if (!$entity) {
return false;
}
$sidebar = elgg_view('framework/file/dashboard/sidebar', array('entity' => $entity));
echo elgg_view_page($entity->title, elgg_view_layout('framework/entity', array('entity' => $entity, 'sidebar' => $sidebar)));
break;
}
break;
default:
return false;
break;
}
return true;
}
示例13: poll_get_page_edit
function poll_get_page_edit($page_type, $guid = 0)
{
gatekeeper();
// Get the current page's owner
$page_owner = elgg_get_page_owner_entity();
if ($page_owner === false || is_null($page_owner)) {
$page_owner = elgg_get_logged_in_user_entity();
elgg_set_page_owner_guid($page_owner->guid);
}
$form_vars = array('id' => 'poll-edit-form');
// Get the post, if it exists
if ($page_type == 'edit') {
$poll = get_entity($guid);
if ($poll instanceof Poll) {
$container_guid = $poll->container_guid;
elgg_set_page_owner_guid($container_guid);
$title = elgg_echo('poll:editpost', array($poll->title));
$body_vars = array('fd' => poll_prepare_edit_body_vars($poll), 'entity' => $poll);
if ($poll->canEdit()) {
$content = elgg_view_form("poll/edit", $form_vars, $body_vars);
} else {
$content = elgg_echo('poll:permission_error');
}
$container = get_entity($container_guid);
if (elgg_instanceof($container, 'group')) {
elgg_push_breadcrumb($container->name, 'poll/group/' . $container->getGUID());
} else {
elgg_push_breadcrumb($container->name, 'poll/owner/' . $container->username);
}
elgg_push_breadcrumb(elgg_echo("poll:edit"));
} else {
$title = elgg_echo('poll:error_title');
$content = elgg_echo('poll:no_such_poll');
}
} else {
if ($guid) {
elgg_set_page_owner_guid($guid);
$container = get_entity($guid);
elgg_push_breadcrumb($container->name, 'poll/group/' . $container->getGUID());
} else {
$user = elgg_get_logged_in_user_entity();
elgg_set_page_owner_guid($user->getGUID());
elgg_push_breadcrumb($user->name, 'poll/owner/' . $user->username);
}
elgg_push_breadcrumb(elgg_echo('poll:add'));
$title = elgg_echo('poll:addpost');
$body_vars = array('fd' => poll_prepare_edit_body_vars(), 'container_guid' => $guid);
$content = elgg_view_form("poll/edit", $form_vars, $body_vars);
}
$params = array('title' => $title, 'content' => $content, 'filter' => '');
$body = elgg_view_layout('content', $params);
// Display page
return elgg_view_page($title, $body);
}
示例14: invitefriends_page_handler
/**
* Page handler function
*
* @param array $page Page URL segments
*/
function invitefriends_page_handler($page)
{
gatekeeper();
elgg_set_context('friends');
set_page_owner(elgg_get_logged_in_user_guid());
$title = elgg_echo('friends:invite');
$body = elgg_view('invitefriends/form');
$params = array('content' => $body, 'title' => $title);
$body = elgg_view_layout('one_sidebar', $params);
echo elgg_view_page($title, $body);
}
示例15: reportedcontent_page_handler
/**
* Reported content page handler
*
* Serves the add report page
*
* @param array $page Array of page routing elements
*/
function reportedcontent_page_handler($page)
{
// only logged in users can report things
gatekeeper();
$content .= elgg_view_title(elgg_echo('reportedcontent:this'));
$content .= elgg_view_form('reportedcontent/add');
$sidebar = elgg_echo('reportedcontent:instructions');
$params = array('content' => $content, 'sidebar' => $sidebar);
$body = elgg_view_layout('one_sidebar', $params);
echo elgg_view_page(elgg_echo('reportedcontent:this'), $body);
}