Elgg  Version 5.1
RedirectService.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg;
3 
8 
12  protected $session;
13 
17  protected $is_xhr;
18 
22  protected $site_url;
23 
27  protected $current_url;
28 
37  $this->session = $session;
38  $this->is_xhr = $request->isXmlHttpRequest();
39  $this->site_url = $config->wwwroot;
40  $this->current_url = $request->getCurrentURL();
41  }
42 
48  public function setLastForwardFrom() {
49  if ($this->is_xhr) {
50  return;
51  }
52 
53  if (elgg_strpos($this->current_url, $this->site_url) !== 0) {
54  return;
55  }
56 
57  $path = elgg_substr($this->current_url, elgg_strlen($this->site_url));
58 
59  $patterns = [
60  '~^action/~',
61  '~^cache/~',
62  '~^serve-file/~',
63  ];
64  foreach ($patterns as $pattern) {
65  if (preg_match($pattern, $path)) {
66  return;
67  }
68  }
69 
70  $this->session->set('last_forward_from', $this->current_url);
71  }
72 }
$request
Definition: livesearch.php:12
setLastForwardFrom()
Capture the URL the user requested when they were redirected.
Elgg Session Management.
Definition: ElggSession.php:19
elgg_strlen()
Wrapper function for mb_strlen().
Definition: mb_wrapper.php:53
$config
Advanced site settings, debugging section.
Definition: debugging.php:6
$path
Definition: details.php:70
Handles common tasks when redirecting a request.
elgg_strpos()
Wrapper function for mb_strpos().
Definition: mb_wrapper.php:71
__construct(\ElggSession $session,\Elgg\Http\Request $request,\Elgg\Config $config)
Constructor.
elgg_substr()
Wrapper function for mb_substr().
Definition: mb_wrapper.php:230
if(isset($_COOKIE['elggperm'])) $session
Definition: login_as.php:29
Request container.
Definition: Request.php:12