Merge branch 'MDL-49360-master' of git://github.com/lameze/moodle

This commit is contained in:
Dan Poltawski 2015-07-27 12:08:46 +01:00
commit 5dee13ee92
20 changed files with 72 additions and 51 deletions

View file

@ -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.
*