27 private $currentAction = null;
43 'admin/plugins/disable',
48 if (!in_array(
$action, $exceptions)) {
53 $forwarder = str_replace(
_elgg_services()->config->getSiteUrl(),
"", $forwarder);
54 $forwarder = str_replace(
"http://",
"", $forwarder);
55 $forwarder = str_replace(
"@",
"", $forwarder);
56 if (substr($forwarder, 0, 1) ==
"/") {
57 $forwarder = substr($forwarder, 1);
60 if (!isset($this->actions[
$action])) {
62 } elseif (!
_elgg_services()->session->isAdminLoggedIn() && ($this->actions[
$action][
'access'] ===
'admin')) {
64 } elseif (!
_elgg_services()->session->isLoggedIn() && ($this->actions[
$action][
'access'] !==
'public')) {
68 if (
_elgg_services()->hooks->trigger(
'action', $action, null,
true)) {
69 if (is_file($this->actions[$action][
'file']) && is_readable($this->actions[$action][
'file'])) {
70 self::includeFile($this->actions[$action][
'file']);
77 $forwarder = empty($forwarder) ?
REFERER : $forwarder;
100 if (empty($filename)) {
103 if (
$path === null) {
110 $this->actions[
$action] = array(
122 if (isset($this->actions[
$action])) {
123 unset($this->actions[$action]);
145 if ((
$token) && (
$ts) && ($session_id)) {
146 if ($this->validateTokenOwnership(
$token,
$ts)) {
147 if ($this->validateTokenTimestamp(
$ts)) {
150 $returnval =
_elgg_services()->hooks->trigger(
'action_gatekeeper:permissions:check',
'all', array(
157 }
else if ($visible_errors) {
160 }
else if ($visible_errors) {
168 }
else if ($visible_errors) {
178 $length = $req->server->get(
'CONTENT_LENGTH');
179 $post_count = count($req->request);
180 if ($length && $post_count < 1) {
182 $error_msg =
_elgg_services()->hooks->trigger(
'action_gatekeeper:upload_exceeded_msg',
'all', array(
183 'post_size' => $length,
184 'visible_errors' => $visible_errors,
185 ),
_elgg_services()->translator->translate(
'actiongatekeeper:uploadexceeded'));
187 $error_msg =
_elgg_services()->translator->translate(
'actiongatekeeper:missingfields');
189 if ($visible_errors) {
205 $timeout = $this->getActionTokenTimeout();
207 return ($timeout == 0 || (
$ts > $now - $timeout) && (
$ts < $now + $timeout));
217 if (($timeout =
_elgg_services()->config->get(
'action_token_timeout')) === null) {
222 return (
int)((float)$timeout * $hour);
231 if ($this->validateActionToken(
false)) {
237 if (
$token && $this->validateTokenTimestamp(
$ts)) {
246 $this->validateActionToken();
248 }
else if ($this->validateActionToken()) {
266 $required_token = $this->generateActionToken(
$timestamp, $session_token);
283 if (!$session_token) {
285 if (!$session_token) {
299 return (isset($this->actions[
$action]) && file_exists($this->actions[$action][
'file']));
312 'system_messages' => array(
330 $system_messages =
_elgg_services()->systemMessages->dumpRegister();
332 if (isset($system_messages[
'success'])) {
333 $params[
'system_messages'][
'success'] = $system_messages[
'success'];
336 if (isset($system_messages[
'error'])) {
337 $params[
'system_messages'][
'error'] = $system_messages[
'error'];
341 $context = array(
'action' => $this->currentAction);
348 $http_accept =
_elgg_services()->request->server->get(
'HTTP_ACCEPT');
349 if (stripos($http_accept,
'application/json') ===
false) {
350 header(
"Content-type: text/plain");
352 header(
"Content-type: application/json");
elgg_is_xhr()
Checks whether the request was requested via ajax.
validateTokenOwnership($token, $timestamp, $session_token= '')
Was the given token generated for the session defined by session_token?
execute($action, $forwarder="")
static includeFile($file)
Include an action file with isolated scope.
elgg_get_session()
Gets Elgg's session object.
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
getAllActions()
Get all actions.
elgg echo
Translates a string.
validateActionToken($visible_errors=true, $token=null, $ts=null)
validateTokenTimestamp($ts)
Is the token timestamp within acceptable range?
elgg register_error
Wrapper function for system_messages.
ajaxForwardHook($hook, $reason, $return, $params)
clearfix elgg elgg elgg elgg page header
gatekeeper()
Alias of elgg_gatekeeper()
generateActionToken($timestamp, $session_token= '')
Generate a token from a session token (specifying the user), the timestamp, and the site key...