<?php
echo file_get_contents("http://accommodation.thedomainname.com/rentals/formularioMiniOptimized.php?bk=bk_thedomainname&Idioma=EN&Fajax=1");
?><?php
echo file_get_contents("http://accommodation.thedomainname.com/rentals/includeJs.php?bk=bk_thedomainname&tipo=formulario");
?>// $url - URL of remote site
// $path - location to save results
// $method - 'fopen' or 'curl' -- I find curl more reliable
// $certPath - path to local copy of the cert file - may be necessary if
function downloadFile($url, $path, $method, $certPath = null)
{
$newfname = $path;
if (file_exists($path)) {
unlink($path);
}
$newf = null;
$file = null;
if ($method == 'fopen') {
try {
$file = fopen($url, "rb");
if ($file) {
$newf = fopen($newfname, "wb");
if ($newf) {
set_time_limit(0);
while (!feof($file)) {
fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
}
} else {
return ('Could not open ' . $newf . ' for writing');
}
} else {
return ('fopen failed to open ' . $url);
}
} catch (Exception $e) {
return 'ERROR:Download ' . $e->getMessage();
}
if ($file) {
fclose($file);
}
if ($newf) {
fclose($newf);
}
} elseif ($method == 'curl') {
$newf = fopen($path, "wb");
if ($newf) {
set_time_limit(0);
$ch = curl_init(str_replace(" ", "%20", $url));
if ($certPath !== null) {
curl_setopt($ch, CURLOPT_CAINFO, $certPath);
}
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // uncomment for better security (may require $certPath)
// curl_setopt($ch, CURLOPT_SSL_PEER, 1); // uncomment for better security (may require $certPath)
curl_setopt($ch, CURLOPT_TIMEOUT, 180);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0)');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FILE, $newf);
$openBasedir = ini_get('open_basedir');
if (empty($openBasedir) && filter_var(ini_get('safe_mode'),
FILTER_VALIDATE_BOOLEAN) === false) {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
} else {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
$rch = curl_copy_handle($ch);
curl_setopt($rch, CURLOPT_URL, $url);
$header = curl_exec($rch);
if (!curl_errno($rch)) {
$newurl = $url;
$code = curl_getinfo($rch, CURLINFO_HTTP_CODE);
if ($code == 301 || $code == 302) {
if (version_compare(PHP_VERSION, '5.3.7') < 0) {
preg_match('/Location:(.*?)\n/i', $header, $matches);
$newurl = trim(array_pop($matches));
} else {
$newurl = curl_getinfo($rch, CURLINFO_REDIRECT_URL);
}
}
curl_close($rch);
curl_setopt($ch, CURLOPT_URL, $newurl);
}
}
$retVal = curl_exec($ch);
if ($retVal === false) {
return ('cUrl download failed ' . curl_error($ch));
}
curl_close($ch);
} else {
return ('Cannot open ' . $path . ' for writing');
}
} else {
return 'Invalid method in call to downloadFile()';
}
return file_get_contents($path);
}
return downloadFile(...);
{
$newfname = $path;
if (file_exists($path)) {
unlink($path);
}
$newf = null;
$file = null;
$method('fopen') {
...
}
}
{
$newfname = $path;
if (file_exists($path)) {
unlink($path);
}
$newf = null;
$file = null;
$method == 'fopen' {
...
}
}
return (downloadFile(...);
if ($method == 'fopen') {
/* code */
} elseif ($method == 'curl') {
/* code */
} else {
return 'Invalid method in call to downloadFile()';
}
// if ($method == 'fopen') {
/* code */
// } elseif ($method == 'curl') {
// /* code */
// } else {
// return 'Invalid method in call to downloadFile()';
// }
// if ($method == 'fopen') {
// /* code */
// } elseif ($method == 'curl') {
/* code */
// } else {
// return 'Invalid method in call to downloadFile()';
// }
return downloadFile(...);
$output = downloadFile(...); return $output;