Forum Moderators: coopster
echo "Setting the URL<br/>";
$URL="https://www.example.com/space_availability_map_outside.php";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "$URL");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
$contents = curl_exec($ch);
curl_close($ch);
echo $contents;
[edited by: not2easy at 4:25 pm (utc) on May 17, 2020]
You will see that the actual SVG file is missing.and it was edited because the links needed to be removed. Sorry, but I hope that clarifies your question.
<?php
class curl {
var $hndl; // Handle
var $opts = [
CURLOPT_USERAGENT => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0',
CURLOPT_ENCODING => '',
CURLOPT_HEADERFUNCTION => array('curl', 'head'),
CURLOPT_WRITEFUNCTION => array('curl', 'body'),
];
var $i = []; // Info
var $b = ''; // Response body
var $h = ''; // Response head
var $e = ''; // Last error
var $en = 0; // Last error number
function head($ch, $data) {
$this->h .= $data;
return strlen($data);
}
function body($ch, $data) {
$this->b .= $data;
return strlen($data);
}
function fetch($url, $opts = array(), $getinfo = true) {
$this->h = $this->b = '';
$this->i = [];
$this->hndl = curl_init($url);
curl_setopt_array($this->hndl, $opts);
$bool = curl_exec($this->hndl);
if ($getinfo)
$this->i = curl_getinfo($this->hndl);
$this->e = curl_error($this->hndl);
$this->en = curl_errno($this->hndl);
curl_close($this->hndl);
return $bool;
}
}
$curl = new curl;
// This URL will work
$curl->fetch('https://www.webmasterworld.com', $curl->opts, true);
var_dump($curl->i);
var_dump($curl->h);
var_dump($curl->b);
// This URL won't, why?
$curl->fetch('https://www.dsfjhdsfhdsf.com', $curl->opts, true);
var_dump($curl->i);
var_dump($curl->h);
var_dump($curl->b);
var_dump($curl->e);
var_dump($curl->en);
?>
<?php
$page_title = "cURL Testing";
// $URL="https://www.[domain_name].com/exhibitors_4_web_2.php?show_id=7";
$URL="https://www.[domain_name].com/space_availability_map_outside.php";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "$URL");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
$contents = curl_exec($ch);
echo 'Curl error: ' . curl_error($ch);
curl_close($ch);
echo $contents;
?>
ini_set('display_errors', 1);
error_reporting(-1); echo '<pre>'; print_r(curl_getinfo($ch)); You can't load an SVG file from another domain.
MapSVG loads SVG via an ajax call and loading data from other domains via ajax is prohibited in all browsers because of security reasons.
So you need to upload the SVG file to your new domain and then change the "source" option in MapSVG settings object to reflect the new file path.