mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
Merge branch 'MDL-49360-master' of git://github.com/lameze/moodle
This commit is contained in:
commit
5dee13ee92
20 changed files with 72 additions and 51 deletions
|
@ -380,11 +380,12 @@ class manager {
|
|||
if (is_web_crawler()) {
|
||||
$user = guest_user();
|
||||
}
|
||||
if (!empty($CFG->guestloginbutton) and !$user and !empty($_SERVER['HTTP_REFERER'])) {
|
||||
$referer = get_local_referer(false);
|
||||
if (!empty($CFG->guestloginbutton) and !$user and !empty($referer)) {
|
||||
// Automatically log in users coming from search engine results.
|
||||
if (strpos($_SERVER['HTTP_REFERER'], 'google') !== false ) {
|
||||
if (strpos($referer, 'google') !== false ) {
|
||||
$user = guest_user();
|
||||
} else if (strpos($_SERVER['HTTP_REFERER'], 'altavista') !== false ) {
|
||||
} else if (strpos($referer, 'altavista') !== false ) {
|
||||
$user = guest_user();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2549,8 +2549,10 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
|
|||
if ($setwantsurltome) {
|
||||
$SESSION->wantsurl = qualified_me();
|
||||
}
|
||||
if (!empty($_SERVER['HTTP_REFERER'])) {
|
||||
$SESSION->fromurl = $_SERVER['HTTP_REFERER'];
|
||||
|
||||
$referer = get_local_referer(false);
|
||||
if (!empty($referer)) {
|
||||
$SESSION->fromurl = $referer;
|
||||
}
|
||||
|
||||
// Give auth plugins an opportunity to authenticate or redirect to an external login page
|
||||
|
|
|
@ -216,6 +216,25 @@ function is_https() {
|
|||
return (strpos($CFG->httpswwwroot, 'https://') === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cleaned local URL of the HTTP_REFERER less the URL query string parameters if required.
|
||||
*
|
||||
* @param bool $stripquery if true, also removes the query part of the url.
|
||||
* @return string The resulting referer or empty string.
|
||||
*/
|
||||
function get_local_referer($stripquery = true) {
|
||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
||||
$referer = clean_param($_SERVER['HTTP_REFERER'], PARAM_LOCALURL);
|
||||
if ($stripquery) {
|
||||
return strip_querystring($referer);
|
||||
} else {
|
||||
return $referer;
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for creating and manipulating urls.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue