Skip to content
Snippets Groups Projects
Commit 2f6ee106 authored by Rasmus Fuhse's avatar Rasmus Fuhse
Browse files

Resolve "OER Campus: HTTP_PROXY wird nicht genutzt"

Closes #2427

Merge request studip/studip!1623
parent 89d3ea61
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,8 @@ class Oer_AddfileController extends AuthenticatedController ...@@ -25,7 +25,8 @@ class Oer_AddfileController extends AuthenticatedController
]; ];
if ($material['host_id']) { if ($material['host_id']) {
$tmp_name = $GLOBALS['TMP_PATH']."/oer_".$material->getId(); $tmp_name = $GLOBALS['TMP_PATH']."/oer_".$material->getId();
file_put_contents($tmp_name, file_get_contents($material->getDownloadUrl())); $url = $material->getDownloadUrl();
file_put_contents($tmp_name, file_get_contents($url, false, get_default_http_stream_context($url)));
$uploaded_file['tmp_name'] = $tmp_name; $uploaded_file['tmp_name'] = $tmp_name;
$uploaded_file['type'] = filesize($tmp_name); $uploaded_file['type'] = filesize($tmp_name);
} else { } else {
......
...@@ -93,7 +93,8 @@ class Oer_EndpointsController extends StudipController ...@@ -93,7 +93,8 @@ class Oer_EndpointsController extends StudipController
if (!$host) { if (!$host) {
return; return;
} }
$host_data = file_get_contents($url."fetch_public_host_key"); $url = $url."fetch_public_host_key";
$host_data = @file_get_contents($url, false, get_default_http_stream_context($url));
if ($host_data) { if ($host_data) {
$host_data = json_decode($host_data, true); $host_data = json_decode($host_data, true);
if ($host_data) { if ($host_data) {
......
...@@ -13,7 +13,9 @@ class OERDownloadcounter extends SimpleORMap ...@@ -13,7 +13,9 @@ class OERDownloadcounter extends SimpleORMap
$counter['material_id'] = $material_id; $counter['material_id'] = $material_id;
if (Config::get()->oer_GEOLOCATOR_API) { if (Config::get()->oer_GEOLOCATOR_API) {
list($url, $lon, $lat) = explode(" ", Config::get()->oer_GEOLOCATOR_API); list($url, $lon, $lat) = explode(" ", Config::get()->oer_GEOLOCATOR_API);
$output = json_decode(file_get_contents(sprintf($url, $_SERVER['REMOTE_ADDR'])), true); $url = sprintf($url, $_SERVER['REMOTE_ADDR']);
$output = @file_get_contents($url, false, get_default_http_stream_context($url));
$output = json_decode($output, true);
if (isset($output[$lon])) { if (isset($output[$lon])) {
$counter['longitude'] = $output[$lon]; $counter['longitude'] = $output[$lon];
} }
......
...@@ -100,7 +100,7 @@ class OERHost extends OERIdentity ...@@ -100,7 +100,7 @@ class OERHost extends OERIdentity
{ {
$endpoint_url = $this['url']."fetch_public_host_key"; $endpoint_url = $this['url']."fetch_public_host_key";
$endpoint_url .= "?from=".urlencode($GLOBALS['oer_PREFERRED_URI'] ?: $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/"); $endpoint_url .= "?from=".urlencode($GLOBALS['oer_PREFERRED_URI'] ?: $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/");
$host_data = @file_get_contents($endpoint_url); $host_data = @file_get_contents($endpoint_url, false, get_default_http_stream_context($endpoint_url));
if ($host_data) { if ($host_data) {
$host_data = json_decode($host_data, true); $host_data = json_decode($host_data, true);
if ($host_data) { if ($host_data) {
...@@ -124,7 +124,7 @@ class OERHost extends OERIdentity ...@@ -124,7 +124,7 @@ class OERHost extends OERIdentity
{ {
$endpoint_url = $this['url']."fetch_known_hosts" $endpoint_url = $this['url']."fetch_known_hosts"
."?from=".urlencode(!empty($GLOBALS['oer_PREFERRED_URI']) ?: $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/"); ."?from=".urlencode(!empty($GLOBALS['oer_PREFERRED_URI']) ?: $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/");
$output = @file_get_contents($endpoint_url); $output = @file_get_contents($endpoint_url, false, get_default_http_stream_context($endpoint_url));
if (!empty($output)) { if (!empty($output)) {
$output = json_decode($output, true); $output = json_decode($output, true);
foreach ((array) $output['hosts'] as $host_data) { foreach ((array) $output['hosts'] as $host_data) {
...@@ -157,7 +157,7 @@ class OERHost extends OERIdentity ...@@ -157,7 +157,7 @@ class OERHost extends OERIdentity
} else { } else {
$endpoint_url .= "?text=".urlencode($text); $endpoint_url .= "?text=".urlencode($text);
} }
$output = @file_get_contents($endpoint_url); $output = @file_get_contents($endpoint_url, false, get_default_http_stream_context($endpoint_url));
if ($output) { if ($output) {
$output = json_decode($output, true); $output = json_decode($output, true);
foreach ((array) $output['results'] as $material_data) { foreach ((array) $output['results'] as $material_data) {
...@@ -241,7 +241,7 @@ class OERHost extends OERIdentity ...@@ -241,7 +241,7 @@ class OERHost extends OERIdentity
public function fetchItemData(OERMaterial $material) public function fetchItemData(OERMaterial $material)
{ {
$endpoint_url = $this['url']."get_item_data/".urlencode($material['foreign_material_id']); $endpoint_url = $this['url']."get_item_data/".urlencode($material['foreign_material_id']);
$output = @file_get_contents($endpoint_url); $output = @file_get_contents($endpoint_url, false, get_default_http_stream_context($endpoint_url));
if ($output) { if ($output) {
$output = json_decode($output, true); $output = json_decode($output, true);
if ($output) { if ($output) {
......
...@@ -17,7 +17,7 @@ class OERHostOERSI extends OERHost ...@@ -17,7 +17,7 @@ class OERHostOERSI extends OERHost
} else { } else {
$endpoint_url .= '?q=' . urlencode($text . $appendix); $endpoint_url .= '?q=' . urlencode($text . $appendix);
} }
$output = @file_get_contents($endpoint_url); $output = @file_get_contents($endpoint_url, false, get_default_http_stream_context($endpoint_url));
if ($output) { if ($output) {
$output = json_decode($output, true); $output = json_decode($output, true);
foreach ((array) $output['hits']['hits'] as $material_data) { foreach ((array) $output['hits']['hits'] as $material_data) {
...@@ -88,7 +88,7 @@ class OERHostOERSI extends OERHost ...@@ -88,7 +88,7 @@ class OERHostOERSI extends OERHost
public function fetchItemData(OERMaterial $material) public function fetchItemData(OERMaterial $material)
{ {
$endpoint_url = 'https://oersi.de/resources/' . urlencode($material['data']['id']) . '?format=json'; $endpoint_url = 'https://oersi.de/resources/' . urlencode($material['data']['id']) . '?format=json';
$output = @file_get_contents($endpoint_url); $output = @file_get_contents($endpoint_url, false, get_default_http_stream_context($endpoint_url));
if ($output) { if ($output) {
$output = json_decode($output, true); $output = json_decode($output, true);
if ($output) { if ($output) {
......
...@@ -54,7 +54,7 @@ class CoreDocuments extends CorePlugin implements StudipModule, OERModule ...@@ -54,7 +54,7 @@ class CoreDocuments extends CorePlugin implements StudipModule, OERModule
if ($url) { if ($url) {
if ($material['host_id']) { if ($material['host_id']) {
$tmp_name = $GLOBALS['TMP_PATH'] . '/oer_' . $material->getId(); $tmp_name = $GLOBALS['TMP_PATH'] . '/oer_' . $material->getId();
file_put_contents($tmp_name, file_get_contents($url)); file_put_contents($tmp_name, file_get_contents($url, false, get_default_http_stream_context($url)));
$uploaded_file['tmp_name'] = $tmp_name; $uploaded_file['tmp_name'] = $tmp_name;
$uploaded_file['type'] = filesize($tmp_name); $uploaded_file['type'] = filesize($tmp_name);
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment