Skip to content
Snippets Groups Projects
Commit 1f532c2c authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Use Moodle file download functions to respect proxy settings.

parent cf0950fa
No related branches found
No related tags found
No related merge requests found
......@@ -225,7 +225,7 @@ function question_display_options() {
*
* Returns the string content of the URL/file. If failign return false.
*/
function stack_fetch_included_content(string $url): string | bool {
function stack_fetch_included_content(string $url) {
static $cache = [];
$lc = trim(strtolower($url));
$good = false;
......@@ -272,11 +272,13 @@ function stack_fetch_included_content(string $url): string | bool {
// Just remember that $islocalfile might be true and you might do
// something else then.
if ($islocalfile) {
$translated = clean_param($translated, PARAM_SAFEPATH);
$cache[$translated] = file_get_contents($translated);
} else {
$translated = clean_param($translated, PARAM_URL);
$headers = get_headers($translated);
if (strpos($headers[0], '404') === false) {
$cache[$translated] = file_get_contents($translated);
$cache[$translated] = download_file_content($translated);
} else {
$cache[$translated] = false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment