Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'w03_MDL-21992_m22_customscripts' of https://github.com/…

…skodak/moodle into MOODLE_22_STABLE
  • Loading branch information...
commit 7b3dae90968fc1d24635109ab9acc561cfea34ee 2 parents 6f96020 + 7991c4c
@nebgor nebgor authored
Showing with 6 additions and 26 deletions.
  1. +6 −26 lib/moodlelib.php
View
32 lib/moodlelib.php
@@ -10024,40 +10024,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;
-
- // set default $urlpath, if necessary
- if (empty($urlpath)) {
- $urlpath = qualified_me(); // e.g. http://www.this-server.com/moodle/this-script.php
- }
+function custom_script_path() {
+ global $CFG, $SCRIPT;
- // $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;
Please sign in to comment.
Something went wrong with that request. Please try again.