Пример #1
0
/* Check for POST data for any-origin. Please note all POST data passes. */
$ao_post = "";
$ao_post_active = 0;
if ($_POST) {
    $ao_post_active = 1;
    $ao_post = http_build_query($_POST);
}
/* Continue with any-origin request */
header('Access-Control-Allow-Origin: *');
/* Safety Feature */
header('Content-Type: text/plain');
/* Continue */
if (!$client_url || !$client_allowed) {
    die('[500] Unknown Error. Unable to continue.');
} else {
    echo _curl_get_data(urldecode($client_url));
}
function _curl_get_data($url)
{
    global $user_agent_full, $ao_post, $ao_post_active, $ao_user_origin;
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_POST, $ao_post_active);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $ao_post);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_REFERER, $ao_user_origin);
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent_full);
    $data = curl_exec($ch);
Пример #2
0
if (in_array(strtolower($client_host), $allowed_hosts) || $allowed_hosts[0] == '*') {
    $client_allowed = 1;
}
/* Check for POST data for any-origin. Please note all POST data passes. */
$ao_post = "";
$ao_post_active = 0;
if ($_POST) {
    $ao_post_active = 1;
    $ao_post = http_build_query($_POST);
}
/* Continue with any-origin request */
header('Access-Control-Allow-Origin: *');
/* Safety Feature */
header('Content-Type: text/plain');
/* Continue */
$xml_string = _curl_get_data(urldecode('http%3A//xmlfeed.laterooms.com/index.aspx' . $client_url));
$xml = simplexml_load_string($xml_string);
$json = json_encode($xml);
// $array = json_decode($json,TRUE);
echo $json;
function _curl_get_data($url)
{
    global $user_agent_full, $ao_post, $ao_post_active, $ao_user_origin;
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_POST, $ao_post_active);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $ao_post);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
Пример #3
0
function curl_cacher($url)
{
    global $user_cache_time, $user_cache_path, $ao_post, $ao_post_active;
    $url_hasher = md5($url);
    $post_hasher = md5($ao_post);
    $cache_file = $url_hasher;
    if ($ao_post_active) {
        $cache_file .= '_' . md5($ao_post);
    }
    /* Make a simpler shorter hash of the hashed data. Double hash */
    $cache_file = md5($cache_file);
    /* Create the full path */
    $cache_file = $user_cache_path . '/' . $cache_file . '.txt';
    /* Check the cache */
    $blaststop = use_cache($cache_file, $user_cache_time);
    /* Now see what to do cache, or not cache, etc */
    if ($blaststop) {
        $data = file_get_contents($cache_file);
        return $data;
    } else {
        $data = _curl_get_data($url);
        file_put_contents($cache_file, $data);
        return $data;
    }
    return "";
}
Пример #4
0
if (in_array(strtolower($client_host), $allowed_hosts) || $allowed_hosts[0] == '*') {
    $client_allowed = 1;
}
/* Check for POST data for any-origin. Please note all POST data passes. */
$ao_post = "";
$ao_post_active = 0;
if ($_POST) {
    $ao_post_active = 1;
    $ao_post = http_build_query($_POST);
}
/* Continue with any-origin request */
header('Access-Control-Allow-Origin: *');
/* Safety Feature */
header('Content-Type: text/plain');
/* Continue */
$xml_string = _curl_get_data(urldecode('https%3A//book.api.ean.com/ean-services/rs/hotel/v3/avail' . $client_url));
$xml = simplexml_load_string($xml_string);
$json = json_encode($xml);
// $array = json_decode($json,TRUE);
echo $json;
function _curl_get_data($url)
{
    global $user_agent_full, $ao_post, $ao_post_active, $ao_user_origin;
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_POST, $ao_post_active);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $ao_post);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);