mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'w03_MDL-21992_m23_customscripts' of https://github.com/skodak/moodle
This commit is contained in:
commit
cd70d3c4a8
@ -10058,40 +10058,20 @@ function object_property_exists( $obj, $property ) {
|
||||
* Detect a custom script replacement in the data directory that will
|
||||
* replace an existing moodle script
|
||||
*
|
||||
* @param string $urlpath path to the original script
|
||||
* @return string|bool full path name if a custom script exists, false if no custom script exists
|
||||
*/
|
||||
function custom_script_path($urlpath='') {
|
||||
global $CFG;
|
||||
function custom_script_path() {
|
||||
global $CFG, $SCRIPT;
|
||||
|
||||
// set default $urlpath, if necessary
|
||||
if (empty($urlpath)) {
|
||||
$urlpath = qualified_me(); // e.g. http://www.this-server.com/moodle/this-script.php
|
||||
}
|
||||
|
||||
// $urlpath is invalid if it is empty or does not start with the Moodle wwwroot
|
||||
if (empty($urlpath) or (strpos($urlpath, $CFG->wwwroot) === false )) {
|
||||
if ($SCRIPT === null) {
|
||||
// Probably some weird external script
|
||||
return false;
|
||||
}
|
||||
|
||||
// replace wwwroot with the path to the customscripts folder and clean path
|
||||
$scriptpath = $CFG->customscripts . clean_param(substr($urlpath, strlen($CFG->wwwroot)), PARAM_PATH);
|
||||
|
||||
// remove the query string, if any
|
||||
if (($strpos = strpos($scriptpath, '?')) !== false) {
|
||||
$scriptpath = substr($scriptpath, 0, $strpos);
|
||||
}
|
||||
|
||||
// remove trailing slashes, if any
|
||||
$scriptpath = rtrim($scriptpath, '/\\');
|
||||
|
||||
// append index.php, if necessary
|
||||
if (is_dir($scriptpath)) {
|
||||
$scriptpath .= '/index.php';
|
||||
}
|
||||
$scriptpath = $CFG->customscripts . $SCRIPT;
|
||||
|
||||
// check the custom script exists
|
||||
if (file_exists($scriptpath)) {
|
||||
if (file_exists($scriptpath) and is_file($scriptpath)) {
|
||||
return $scriptpath;
|
||||
} else {
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user