fix uncomplete url

This commit is contained in:
Jean-Christian Denis 2021-11-05 00:58:34 +01:00
parent 81c6cee481
commit 8984f759ed
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951

View file

@ -77,18 +77,22 @@ class tweakStoresBehaviors
$file_content = __('This module has no repository set in its _define.php file.');
} else {
try {
$url = $modules[$_POST['checkxml_id']]['repository'];
if (false === strpos($url, 'dcstore.xml')) {
$url .= '/dcstore.xml';
}
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $modules[$_POST['checkxml_id']]['repository']);
curl_setopt($ch, CURLOPT_REFERER, $modules[$_POST['checkxml_id']]['repository']);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$file_content = curl_exec($ch);
curl_close($ch);
} else {
$file_content = file_get_contents($modules[$_POST['checkxml_id']]['repository']);
$file_content = file_get_contents($url);
}
} catch (Exception $e) {
$file_content = __('Failed to read third party repository');