Jump to content

the server responded with a status of 406 (Not Acceptable)


oracle765

Recommended Posts

Hi Experts

 

I did not write this code so i am having trouble trying to resolve the issue

 

now our webpage has stopped working with the error message

 

Failed to load resource: the server responded with a status of 406 (Not Acceptable)

 

Its been running for over a year without any problems so not sure what or where it could exactly be

 

its on our site here is a url reference when we try to visit the details of the listed hotels

 

https://www.compareandchoose.com.au/hotel_details?hotel=140485&cc=AUD&q=%27%20https%3A%2F%2Fcompareandchoose.comencia.com%2Fhotel%2F140485%3Flang%3Den%26amp%3Bcurrency%3DAUD%26amp%3BarrivalDate%3D03%2F20%2F2017%26amp%3BdepartureDate%3D03%2F21%2F2017%26room1%3D2%27&price=215.00&tday=1&city=Sydney&country=AU&countryname=Australia&guest=%202&rooms=1&checkin=03/20/2017&checkout=03/21/2017&total_children=0&child=0&total_adult=2&skooshID=&getaroomID=4be1dbec-d9a8-5d05-bf2f-f6b3b34cdd81&expediaID=140485&lateroomID=164918&title=Metro%20Hotel%20On%20Pitt

<?php


error_reporting(0);


@session_start();


$ip=$_SERVER['REMOTE_ADDR'];


$conn = new mysqli('localhost', 'secret', 'secret', 'secretdatabase');


if(!isset($_SESSION['ip'])){
    $_SESSION['ip']=$ip;
}


if($_SESSION['ip']!==$ip){
    unset($_SESSION['ip']);
    $_SESSION['ip']=$ip;
    unset($_SESSION['user_currency1']);
}
if(isset($_SESSION['user_currency1']) && empty($_SESSION['user_currency1'])){
    unset($_SESSION['user_currency1']);
}
if(!isset($_SESSION['user_currency1']) && empty($_SESSION['user_currency1'])){
    $xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=".$ip);
    $ip_currency = (string)$xml->geoplugin_currencyCode ;
    $currency_symbol=(string)$xml->geoplugin_currencySymbol;
    $currency_code=(string)$xml->geoplugin_currencyCode;
    $geocountry=(string)$xml->geoplugin_countryName;
    $countrycode=(string)$xml->geoplugin_countryCode;
    $_SESSION['country_code'] = $countrycode;
    $_SESSION['user_country'] = $geocountry;
    $_SESSION['user_currency1'] = $ip_currency;
    $_SESSION['currency_symbol']=$currency_symbol;
    $_SESSION['currency_code']=$currency_code;
    if(empty($xml)){


        echo "<b>Geoplugin limit exceeded!</b>";
        // If GeoPlugin Limit Exceeds use default
        $_SESSION['user_currency1'] = 'AUD';
        $_SESSION['currency_symbol']='$';
        $_SESSION['currency_code']='AUD';
    }
}


function check_url($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch , CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    $headers = curl_getinfo($ch);
    curl_close($ch);
    return $headers['http_code'];
}


$hotel_id = $_GET['hotel'];


$pr = number_format($_GET['price'],2);


if($pr!=""){


    $h_price = $_SESSION['currency_code']." ".$_SESSION['currency_symbol'].$pr ;


}


$check_in=$_GET['checkin'];
$check_out=$_GET['checkout'];
$city=$_GET['city'];
$cntry=$_GET['country'];
$dStart = new DateTime($check_out);
$dEnd  = new DateTime($check_in);
$dDiff = $dStart->diff($dEnd);
$total_days = $dDiff->days;
$t_c=$t_a=0;


if(!empty($_GET['total_children'])){
    $t_c=$_GET['total_children'];
}
if(!empty($_GET['total_adult'])){


    $t_a=$_GET['total_adult'];


}


$u = urldecode($_GET["q"]);
$n_url = str_replace("'","",$u);
$store_url = "http://www.travelnow.com/templates/451536/hotels/".$n_url;
$timestamp = gmdate('U');
$secret = 'Mx9xYRWR';
$apiKey = 'hidden';
$cid = '451536';
$sig = md5($apiKey . $secret . $timestamp);
$url2 = 'http://api.ean.com/ean-services/rs/hotel/v3/info?minorRev=26';
$url2 .='&apiKey='.$apiKey.'';
$url2 .='&cid='.$cid.'&sig='.$sig.'';
$url2 .='&currencyCode='.$_SESSION['currency_code'].'&hotelId='.$hotel_id.'';
$header[] = "Accept: application/json";
$header[] = "Accept-Encoding: gzip";
$ch3 = curl_init();
curl_setopt( $ch3, CURLOPT_HTTPHEADER, $header );
curl_setopt($ch3,CURLOPT_ENCODING , "gzip");
curl_setopt($ch3, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt( $ch3, CURLOPT_URL, $url2 );
curl_setopt( $ch3, CURLOPT_RETURNTRANSFER, true );
$respon = json_decode(curl_exec($ch3), true);
// echo "<pre>";


// print_r($respon);
if(empty($_GET['expediaID'])){
    $respon=null;
}


if(!empty($respon)){
$res = "select CountryCode, CountryName from CountryList where `CountryCode` = '".$respon['HotelInformationResponse']['HotelSummary']['countryCode']."' limit 1";
$sql=mysql_query($res);
$row=mysql_fetch_array($sql);
$country_name = $row['CountryName'];


$title_tag = $respon['HotelInformationResponse']['HotelSummary']['name'] ;


$hotel_summary_name=$respon['HotelInformationResponse']['HotelSummary']['name'];


$rate = $respon['HotelInformationResponse']['HotelSummary']['hotelRating'];


$address=$respon['HotelInformationResponse']['HotelSummary']['address1'];


$city=$respon['HotelInformationResponse']['HotelSummary']['city'];


$image=$respon['HotelInformationResponse']['HotelImages']['HotelImage'][0]['url'];


$expediaimages=$respon['HotelInformationResponse']['HotelImages']['HotelImage'];


$hotel_description=html_entity_decode($respon['HotelInformationResponse']['HotelDetails']['propertyDescription']);


$hotel_policy=$respon['HotelInformationResponse']['HotelDetails']['hotelPolicy'];


$check_in_time=$respon['HotelInformationResponse']['HotelDetails']['checkInTime'];


$check_out_time=$respon['HotelInformationResponse']['HotelDetails']['checkOutTime'];


$property_info=$respon['HotelInformationResponse']['HotelDetails']['propertyInformation'];


$checkin_instructions=$respon['HotelInformationResponse']['HotelDetails']['checkInInstructions'];


$all_prices[]=$pr;


    // $store_url=urlencode($store_url);


foreach ($expediaimages as $expkey => $expdata) {
    $images[]=$expdata['url'];
    $thumbimages[]=$expdata['thumbnailUrl'];
}




foreach($images as $imgkey=> $imageurl){


          $check_url_status = check_url($imageurl);
            if ($check_url_status == '200'){
            }else{
                unset($images[$imgkey]);
            }
      }
}


if(empty($respon)){


// for skoosh hotels details //
    if(!empty($_GET['skooshID'])){
$skooshID=$_GET['skooshID'];
$skooshcurrenciesarray=array('GBP','AUD','CAD','EUR','NOK','CHF','USD');
$skoosh_flag=1;
if(empty($skooshID)){
   $skoosh_flag=0;
}


if($skoosh_flag==1){


/*Skoosh Api */


$skoosh_checkin=date('d/m/y',strtotime($check_in));
$skoosh_checkout=date('d/m/y',strtotime($check_out));
$skoosh_apikey="hidden";
$skoosh_url="http://www.skoosh.com/s/twibo/api/search.html?";
$skoosh_url.="adults_1=$t_a";
$skoosh_url.="&check_in=$skoosh_checkin";
$skoosh_url.="&check_out=$skoosh_checkout";
$skoosh_url.="&hotels=$skooshID";
if(!empty($_GET['total_children']) && $_GET['total_children']>0){
   $skoosh_url.="&children_1=".$_GET['total_children'];
   $child_age=explode(',', $_GET['child']);
   for($ttch=0;$ttch<$_GET['total_children'];$ttch++){
       $skoosh_url.="&child_age_1=".$child_age[$ttch+1];
   }
}


if(in_array($_SESSION['user_currency1'], $skooshcurrenciesarray)){
   $skoosh_url.="&currency=".$_SESSION['user_currency1'];
}else{
   $skoosh_url.="&currency=USD";
}


$skoosh_url.="&api_key=$skoosh_apikey";
$skoosh_curl = curl_init();
curl_setopt($skoosh_curl, CURLOPT_ENCODING, "gzip");
curl_setopt($skoosh_curl, CURLOPT_URL, $skoosh_url);
curl_setopt($skoosh_curl, CURLOPT_RETURNTRANSFER, true);
$skoosh_xml = new SimpleXMLElement(curl_exec($skoosh_curl));
$skoosherror_msg=$skoosh_xml->ErrorMessage;
}
if(!empty($skoosh_xml)){
   foreach ($skoosh_xml->Hotels->Hotel as $skoosh_hotel) {
       $skoosh_stdclass=json_decode(json_encode($skoosh_hotel->Rooms->Room));
       if(in_array($_SESSION['user_currency1'], $skooshcurrenciesarray)){
           $skoosh_price=$skoosh_stdclass->TotalRate;
           $all_prices[]=number_format($skoosh_price,2,'.','');
       }else{
           $skoosh_price=number_format(convertCurrency($skoosh_stdclass->TotalRate, 'AUD', $_SESSION['user_currency1']),2,'.',',');
           $all_prices[]=number_format(convertCurrency($skoosh_stdclass->TotalRate, 'AUD', $_SESSION['user_currency1']),2,'.','');
       }
   }
}


        $skoosh_sql="SELECT  Hotel_id, Description FROM `skoosh_hotel_descriptions` where Hotel_id='".$_GET['skooshID']."'";


        $skoosh_result=$conn->query($skoosh_sql);
        if ($skoosh_result->num_rows > 0) {
            while($skooshrows = $skoosh_result->fetch_assoc()) {
                $skoosh_description=$skooshrows['Description'];
            }
        }


            $skoosh_imgs_sql="SELECT Image_URL as images FROM `skoosh_images` where Hotel_id='".$_GET['skooshID']."'";
            $skoosh_img_result=$conn->query($skoosh_imgs_sql);
            if ($skoosh_img_result->num_rows > 0) {
               while($skooshimgrows = $skoosh_img_result->fetch_assoc()) {
                     $skoosh_images[]=$skooshimgrows['images'];
                }
            }


            $check_in_time=$_GET['checkin'];


            $check_out_time=$_GET['checkout'];


            $country_name=$_GET['countryname'];


            $title_tag=$_GET['title'];


            $city=$city_country_tag=$_GET['city'];


            $hotel_summary_name = $skoosh_xml->Hotels->Hotel->Name;


            $rate=$skoosh_xml->Hotels->Hotel->StarRating;


            $address=$skoosh_xml->Hotels->Hotel->Address;


            $image=$skoosh_xml->Hotels->Hotel->ImageBigURL;


            if(!empty($skoosh_images)){


                $images=$skoosh_images;


            }else{


                $images[]=$skoosh_xml->Hotels->Hotel->ImageSmallURL;


            }


            if(!empty($skoosh_description)){


                $hotel_description=$skoosh_description;


            }else{


                $hotel_description=$skoosh_xml->Hotels->Hotel->Description."<a target='_blank' href='".$skoosh_xml->Hotels->Hotel->MainURL."'>Read More</a>";


            }


            if(isset($skoosherror_msg) && !empty($skoosherror_msg)){


                $image=null;


                $title_tag="Hotel has been booked";


                $hotel_summary_name="Hotel has been Booked!";


                $city=$_GET['city'];


                $country_name=$_GET['countryname'];


                $address="Address";


                $_GET['price']=0.00;


            }


            foreach($images as $imgkey=> $imageurl){


                $check_url_status = check_url($imageurl);


                if ($check_url_status == '200'){


                }else{


                    unset($images[$imgkey]);


                }


            }


        }


// end of skoosh hotels details //






// Getaroom hotel details starts //






   if(!empty($_GET['getaroomID']) && empty($_GET['skooshID'])){






   $getaroom_sql="SELECT getaroom_price, getaroom_deeplink FROM `comparehotels` where getaroom_id='".$_GET['getaroomID']."' and rateCurrencyCode='".$_SESSION['user_currency1']."'  ";


   $getaroom_result=$conn->query($getaroom_sql);


   if ($getaroom_result->num_rows > 0) {


       while($getaroomrows = $getaroom_result->fetch_assoc()) {


           $getaroom_price=$getaroomrows['getaroom_price'];


           $getaroom_bookingurl=$getaroomrows['getaroom_deeplink'];


       }


   }






//$getaroom_bookingurl="http://www.getaroom.com/hotels/".$_GET['getaroomID']."?affiliate=0a10ca00&check_in=".$_GET['checkin']."&check_out=".$_GET['checkout']."";






include 'files/getaroom/getaroom.php';


   $getaroomobj=new Getaroom();


   $getaroominfo=$getaroomobj->gethotelsinfo($_GET['getaroomID']);


   if($getaroominfo[0]['short-description']['@attributes']['nil']=='true'){


       $getaroominfo[0]['short-description']=$getaroominfo[0]['title'];


   }


   $getaroomimage_path=$getaroominfo[0]['thumbnail'];


   $getaroom_hotel_name=$getaroominfo[0]['title'];


   $getaroom_address=$getaroominfo[0]['short-description'];


   $getaroom_description=$getaroominfo[0]['description'];


   $getaroom_ratings=$getaroominfo[0]['rating'];


   preg_match_all('/((?:\d+)(?:\.\d*)?)/', $getaroom_price, $pricematches);


   $newprice= round($pricematches[0][0]);


   $all_prices[]=number_format($newprice,2,'.','');






        $country_name=$_GET['countryname'];


        $city_country_tag=$_GET['city'];


        $title_tag=$_GET['title'];


        $hotel_description= $getaroom_description;


        $address=$getaroom_address;


        $image=$getaroomimage_path;


        $getaroom_images_sql="SELECT filename FROM `getaroom_images` where uuid='".$_GET['getaroomID']."' limit 15";


        $getaroom_imgresult=$conn->query($getaroom_images_sql);


        if ($getaroom_imgresult->num_rows > 0) {


            while($getaroomimgrows = $getaroom_imgresult->fetch_assoc()) {


                $getaroom_images[]=$getaroomimgrows['filename'];


            }


        }


        if(!empty($getaroom_images)){


            $images=$getaroom_images;


        }


        $rate=$getaroom_ratings;


        $hotel_policy="";


        $property_info="";


        $check_in_time=$_GET['checkin'];


        $check_out_time=$_GET['checkout'];


        foreach($images as $imgkey=> $imageurl){


          $check_url_status = check_url($imageurl);


            if ($check_url_status == '200'){


            }else{


                unset($images[$imgkey]);


            }


      }


    }


// End of Getaroom hotel details //






// Lateroom API Start //






    if(!empty($_GET['lateroomID']) && empty($_GET['getaroomID']) && empty($_GET['skooshID'])){






$startdate=date('Y-m-d',strtotime($check_in));


$lateroom_url="http://xmlfeed.laterooms.com/index.aspx?aid=15305&rtype=3&hids=".$_GET['lateroomID']."&cur=".$_SESSION['user_currency1']."&sdate=$startdate";


   $lateroom_curl = curl_init();


   curl_setopt($lateroom_curl, CURLOPT_ENCODING, "gzip");


   curl_setopt($lateroom_curl, CURLOPT_URL, $lateroom_url);


   curl_setopt($lateroom_curl, CURLOPT_RETURNTRANSFER, true);


   $lateroom_xml = new SimpleXMLElement(curl_exec($lateroom_curl));


   $lateroom_date = DateTime::createFromFormat("Y-m-d", $startdate);


   $l_date=$lateroom_date->format("Y").$lateroom_date->format("m").$lateroom_date->format("d");






   $lateroom_stdclass=json_decode(json_encode($lateroom_xml->hotel));






$lateroom_prices= $lateroom_stdclass->prices_from*$total_days;


   if($lateroom_prices>0){


       $all_prices[]=number_format($lateroom_prices,2,'.','');


   }






       $country_name=$_GET['countryname'];


       $title_tag=$_GET['name'];


       $city_country_tag=$lateroom_xml->hotel->hotel_city;


       $hotel_summary_name=$lateroom_xml->hotel->hotel_name;


       $rate=$lateroom_xml->hotel->hotel_star;


       $address=$lateroom_xml->hotel->hotel_address;


       $city=$_GET['c'];


       $image=$lateroom_xml->hotel->images->url[0];


       $lateroomimages=json_decode(json_encode($lateroom_xml->hotel->images->url));


       $hotel_description=$lateroom_xml->hotel->hotel_description;


       $hotel_policy="";


       $check_in_time=$lateroom_xml->hotel->check_in;


       $check_out_time=$lateroom_xml->hotel->check_out;


       $property_info="";


       $checkin_instructions=$lateroom_xml->hotel->conditions_of_booking;






       foreach ($lateroomimages as $key => $data) {


           if(strpos($data, 'gallery')){


               $images[]=$data;


           }


        }


    }


// End of lateroom api //


}


?>


            <div class="page-title">
                <h1><?php echo $hotel_summary_name; ?></h1>
            <div class="details_rating">
               <?php if($rate!="" && $rate!=0)
                        {
                          for($in = 1; $in<=$rate ;$in++)
                          { ?>
                            <img src="" alt="star-rating" data-src="images/star.png">
                    <?php }
                          if($f != $c)
                          {?>
                             <img src="" alt="half-star-rating" data-src="images/star_half.png">
                   <?php }
                        }
                    ?>
            </div>
            <div class="c1"></div>
            <p class="stay"><?php echo $address." , ".$city." , ".$_GET['countryname']?></p>
          </div>
          <div class="row dtlsGalleryPan">
              <div class="col-xs-12 col-md-6 col-lg-6 galImgDiv">
                  <div class="gallery">
                      <div class="image-preview">
                          <?php if($image!=""){ ?>
                              <img id="preview" src="" alt="image-display" data-src="<?php echo $image ;?>"/>
                          <?php }else { ?>
                              <img id="preview" src="" alt="preview-image" width="350" height="250" data-src="images/no_img.gif"/>
                          <?php } ?>
                      </div>
                      <!-- Elastislide Carousel -->
                      <ul id="carousel" class="elastislide-list">
                          <?php
                           if(!empty($images)){
                            foreach($images as $imgkey=> $imageurl){
                             ?>
                                 <li data-preview="<?php echo $imageurl; ?>" id="pr_<?php echo $imgkey;?>" style="vertical-align: middle;"><a href="javascript:void(0);" ><img src="" onMouseOver="div.show('div<?php echo $imgkey ;?>')" onMouseOut="div.hide('div<?php echo $imgkey ;?>')" data-src="<?php if(!empty($thumbimages)){echo $thumbimages[$imgkey]; }else{echo $imageurl;} ?>" alt="image-preview" id="anc_<?php echo $imgkey;?>"/></a></li>
                              <?php }} ?>
                      </ul>
                      <?php
                        foreach($images as $imgkey=> $imageurl){ ?>
                            <img src="" data-src="<?php echo $imageurl; ?>" class="zoom-image" id="div<?php echo $imgkey ;?>" alt="" style="visibility: hidden"/>
                       <?php } ?>
                       <!-- End Elastislide Carousel -->
                  </div>
              </div>
              <div class="col-xs-12 col-md-6 col-lg-6 dtlsPrice">
                <p class="night"><?php echo $_GET['tday']; ?> Night Stay</p>
                <div class="hotel-details">
                        <div class="price-box">
                        <div class="price" style="font-size: 24px;">from <?php echo $_SESSION['currency_code']." ".min($all_prices);?></div>
                    </div>
                    <a href="javascript:void(0)" class="book-now" onclick="pop_show();" >Book Now</a>
                </div>
            </div>
            <!-- Book Now pop up starts-->
            <div class="pop-up" id="pop" style="display: none;">
            </div>
           <!-- Book Now pop up ends-->
           <div class="c1"></div>
          </div>  <!--dtlsGalleryPan-->
          <div class="row hotel-topics">
            <div class="col-xs-12 col-md-12 col-lg-12">
             <?php echo $hotel_description; ?>
            </div>
         </div>
         <div class="row">
             <div class="col-xs-12 col-md-12 col-lg-12">
                 <div class="hotel-features">
                        <h2>Hotel Features</h2>
                        <div class="content">
                            <div class="hotel-topics">
                             <h3>Hotel Policy</h3>
                             <p><?php if(!empty($hotel_policy)){echo $hotel_policy;}else{echo "Not mentioned";} ?></p>
                             </div>
                             <div class="hotel-topics">
                                 <h3>Check-in</h3>
                                 <p>From <?php echo $check_in_time; ?></p>
                             </div>
                             <div class="hotel-topics">
                                <h3>Check-out</h3>
                                <p>Prior to <?php echo $check_out_time; ?></p>
                            </div>
                            <div class="hotel-topics">
                                <h3>Property Information</h3>
                                <p><?php if(!empty($property_info)) {echo $property_info;}else{echo "Not mentioned";} ?></p>
                            </div>
                            <div class="hotel-topics">
                                <h3>CheckIn Instructions</h3>
                                <p><?php if(!empty($checkin_instructions)){echo $checkin_instructions;}else{echo "Not mentioned";} ?></p>
                            </div>
                        </div> <!--content-->
                 </div><!--hotel-features-->
                 <div class="note">
                      Note : It is the responsibility of the hotel chain and/or the individual property to ensure the accuracy of the photos displayed. 'www.compareandchoose.com.au' is not responsible for any inaccuracies in the photos.
                </div>
             </div>
</div> <!--row-->
Edited by Barand
Link to comment
Share on other sites

I second Barand's request - please wrap your posted code properly in code tags: php & /php themselves wrapped in []

 

Also - try turning on error reporting which you are currently turning OFF at the top. That may show you some problems. Perhaps you could add some comments to the different blocks of code to help (you and ) us to follow what this script is trying to do when need to re-post.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.