403Webshell
Server IP : 103.234.187.230  /  Your IP : 216.73.216.216
Web Server : Apache
System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/gtxapi.hellogtx.com/library/Helper/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/gtxapi.hellogtx.com/library/Helper/Hotel.php
<?php

/* * *************************************************************
 * Catabatic Technology Pvt. Ltd.
 * File Name     : Hotel.php
 * File Desc.    : Hotel helper to including supporting functions/methods for Hotels
 * Created By    : Md Sabir <sabir@catpl.co.in>
 * Created Date  : 03 Feb 2025
 * ************************************************************* */

class Zend_Controller_Action_Helper_Hotel extends Zend_Controller_Action_Helper_Abstract
{

    public $baseUrl;
    public $siteName;
    private $db;
    private $pluginLoader;

    public function __construct()
    {

        $this->pluginLoader = new Zend_Loader_PluginLoader();
        $this->db = Zend_Db_Table::getDefaultAdapter();
        $BootStrap = $this->config();
        $this->siteName = $BootStrap['siteName'];
        $this->baseUrl = $BootStrap['siteUrl'];
    }

    public function config()
    {
        $front = $this->getFrontController();
        $bootstrap = $front->getParam('bootstrap');
        if (null === $bootstrap) {
            throw new Exception('Unable to find bootstrap');
        }
        return $bootstrap->getOptions()['bootstrap'];
    }

    public function calculateNoOfDays($date1, $date2)
    {
        $diff = abs(strtotime($date2) - strtotime($date1));
        $years = floor($diff / (365 * 60 * 60 * 24));
        $months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));
        $days = ceil(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24) / (60 * 60 * 24)) + 1;
        $nightCount = ($days > 1) ? ($days - 1) : 1;
        return $nightCount;
    }

    public function tbocityMaster($keyword = null, $CountryId = 0)
    {  

        $query = urlencode(strtoupper($keyword));

        if (!empty(trim($query))) {
           
            $url          = 'https://hotels.globaltravelexchange.com/api/v1/tbo-hotel-cities/?keywords=' . $query;
            $data = array(
                'keywords' => $query
            );
            $data_stringh = json_encode($data);
            $ch           = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_ENCODING, "gzip");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'Accept: application/json',
                'Content-Type: application/json',
                'Accept-Encoding: gzip',
                'Content-Length: ' . strlen($data_stringh)
            ));

            $outputH      = curl_exec($ch);
            if (curl_errno($ch)) {
                print(curl_error($ch));
                exit;
            }
            curl_close($ch);
            $responseData = json_decode($outputH, true);
           
            $FilterData = array_filter($responseData, function ($var) use ($CountryId) {
                return ($var['CountryId'] == $CountryId);
            });
            $FilterData = array_values($FilterData);
           return (isset($FilterData[0]) && !empty($FilterData[0]))?$FilterData[0]:[];
        }
    }
    function getPageFromUrl($url) {
        $query = [];
        parse_str(parse_url($url, PHP_URL_QUERY), $query);
        return $query['page'] ?? 0;
    }



   public function tboDumpData(string $keyword = '', string $CountryId = '',$page = 1)
    {
        // Initialize curl
        $curl = curl_init();
        curl_setopt_array($curl, [
            CURLOPT_URL            => 'https://hotels.globaltravelexchange.com/tbo/v1/hotel/?country_code='.$CountryId.'&city_name='.$keyword.'&page='.$page,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT        => 20,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
            CURLOPT_FAILONERROR    => false,
        ]);
        $response = curl_exec($curl);
        // CURL error handling
        if ($error = curl_error($curl)) {
            curl_close($curl);
            return [
                "error" => true,
                "message" => $error
            ];
        }

        curl_close($curl);

        // Decode JSON
        $responseData = json_decode($response, true);

        if (!is_array($responseData) || empty($responseData['results'])) {
            return [];
        }

        // Prepare output
        // $dumpDataInfo = [
        //     'count' => $responseData['count'] ?? 0,
        //     'next'  => $responseData['next'] ?? '',
        // ];
        if($responseData['next'] != null){
            $pageNo = $this->getPageFromUrl($responseData['next']);
        }else{
            $pageNo = 0;
        }
        $hotelCodeArr = [];

        foreach ($responseData['results'] as $hotel) {

            // safety check
            if (!isset($hotel['hotel_code'])) {
                continue;
            }

            $code = $hotel['hotel_code'];

            $dumpDataInfo[$code] = $hotel;
            $hotelCodeArr[] = $code;
        }

        return [
            "staticData" => $dumpDataInfo,
            "hotelCode"  => implode(',', $hotelCodeArr),
            "pageNo"  => $pageNo,
            "count"  => $responseData['count'] ?? 0,
        ];
    }
    public function tboDumpDataTJ(string $keyword = '', string $CountryId = '',$page = 1)
    {
        // Initialize curl
        $curl = curl_init();
        curl_setopt_array($curl, [
            CURLOPT_URL            => 'https://hotels.globaltravelexchange.com/tripjack/v1/hotel/?country_code='.$CountryId.'&city_name='.$keyword.'&page='.$page,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT        => 20,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
            CURLOPT_FAILONERROR    => false,
        ]);
        $response = curl_exec($curl);
        // CURL error handling
        if ($error = curl_error($curl)) {
            curl_close($curl);
            return [
                "error" => true,
                "message" => $error
            ];
        }

        curl_close($curl);

        // Decode JSON
        $responseData = json_decode($response, true);

        if (!is_array($responseData) || empty($responseData['results'])) {
            return [];
        }

        // Prepare output
        // $dumpDataInfo = [
        //     'count' => $responseData['count'] ?? 0,
        //     'next'  => $responseData['next'] ?? '',
        // ];
        if($responseData['next'] != null){
            $pageNo = $this->getPageFromUrl($responseData['next']);
        }else{
            $pageNo = 0;
        }
        $hotelCodeArr = [];

        foreach ($responseData['results'] as $hotel) {

            // safety check
            if (!isset($hotel['hotel_code'])) {
                continue;
            }

            $code = $hotel['hotel_code'];

            $dumpDataInfo[$code] = $hotel;
            $hotelCodeArr[] = $code;
        }

        return [
            "staticData" => $dumpDataInfo,
            "hotelCode"  => $hotelCodeArr,
            "pageNo"  => $pageNo,
            "count"  => $responseData['count'] ?? 0,
        ];
    }
    // jyt my code
    // public function tboDumpData($keyword = '', $CountryId = '')
    // {  
    //     $curl = curl_init();
    //     curl_setopt_array($curl, array(
    //     CURLOPT_URL => 'https://hotels.globaltravelexchange.com/tbo/v1/hotel/?country_code='.$CountryId.'&city_name='.$keyword,
    //     CURLOPT_RETURNTRANSFER => true,
    //     CURLOPT_ENCODING => '',
    //     CURLOPT_MAXREDIRS => 10,
    //     CURLOPT_TIMEOUT => 0,
    //     CURLOPT_FOLLOWLOCATION => true,
    //     CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    //     CURLOPT_CUSTOMREQUEST => 'GET',
    //     ));

    //     $response = curl_exec($curl);
    //     if (curl_errno($curl)) {
    //         print(curl_error($curl));
    //         exit;
    //     }
    //     curl_close($curl);
    //     $responseData__ = json_decode($response, true);
    //     $responseData = ($responseData__['results']) ? $responseData__['results'] : [];
    //     $dumpDataInfo = [];
    //     if (!empty($responseData)) {
    //         $hotelCodeArr = [];
    //         $dumpDataInfo['count'] = ($responseData__['count']) ? $responseData__['count'] : '';
    //         $dumpDataInfo['next'] = ($responseData__['next']) ? $responseData__['next'] : '';
    //         foreach($responseData as $vl){
    //             $dumpDataInfo[$vl['hotel_code']] = $vl;
    //             $hotelCodeArr[] = $vl['hotel_code'];
    //         } 
    //         $hotelCode =  implode(',', $hotelCodeArr);
    //         // echo "hotelCodeArr<pre>";print_r($hotelCodeArr);
    //         // echo "hotelCode($hotelCode)";die;
    //         // $array_chunk = array_chunk($FilterData,100);
    //         // $hotelCode = (isset($array_chunk) && !empty($array_chunk))?$array_chunk:[];
    //         return ["staticData" => $dumpDataInfo, "hotelCode"=> $hotelCode]; 
    //     }else{
    //         return [];
    //     }
    // }
    public function HotelCodeMaster($data = null, $AgencySysId = null, $url=null)
    {  
       
        if($AgencySysId == 2656 || $AgencySysId == 206025 || $AgencySysId == 1){
             $Authorization = base64_encode("TBOStaticAPITest:Tbo@11530818");
        }else{
             $Authorization = base64_encode("travelcategory:Tra@59334536");
        }
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        // new code this
        curl_setopt($ch, CURLOPT_ENCODING, "gzip");
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'Accept: application/json',
                'Content-Type: application/json',
                'Authorization: Basic ' . $Authorization,
        ));
       
        $output = curl_exec($ch);
        curl_close($ch);
        $responseData = json_decode($output, true);
        
        $strFilePath = "hotel/" . time() . "/codeMaster_request.json";
        Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->createApiCallLogs($strFilePath, json_encode($data));
        $strFilePath = "hotel/" . time() . "/codeMaster_response.json";
        Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->createApiCallLogs($strFilePath, json_encode($responseData));

                
        if (!empty($responseData['Hotels'])) {
            $FilterData = array_column($responseData['Hotels'], 'HotelCode');    
            $array_chunk = array_chunk($FilterData,100);
            // echo '<pre>';
            // print_r(($array_chunk));
            // die;  
           return (isset($array_chunk) && !empty($array_chunk))?$array_chunk:[];
        }
    }
    public function ARR_SALUTIONTBO()
    {
        return array("1" => "Mr.", "2" => "Ms.", "3" => "Mrs.", "4" => "Mstr.", "5" => "Miss."
            // "1" => "Sr.",     // Mr
            // "2" => "Sra.",    // Ms
            // "3" => "Sra.",    // Mrs
            // "4" => "Srto.",   // Mstr (Master - young boy)
            // "5" => "Srta."    // Miss (young girl)
        );
    }
    public function apiHoteltBookingRESTEL($post, $AgencySysId, $Securitykey)
    {
        if ($post && $AgencySysId) {
            $BookingData = (isset($post['BookingData']) && !empty($post['BookingData'])) ? $post['BookingData'] : [];
            $email = (isset($post['BookingData']['email']) && !empty($post['BookingData']['email'])) ? $post['BookingData']['email'] : '';
            $mobile = (isset($post['BookingData']['mobile']) && !empty($post['BookingData']['mobile'])) ? $post['BookingData']['mobile'] : '';
            $HotelCode = (isset($post['BookingData']['HotelBookingData']['hotel_data']['HotelCode']) && !empty($post['BookingData']['HotelBookingData']['hotel_data']['HotelCode'])) ? $post['BookingData']['HotelBookingData']['hotel_data']['HotelCode'] : '';
            $booking_room_data = (isset($BookingData['HotelBookingData']['booking_room_data']) && !empty($BookingData['HotelBookingData']['booking_room_data'])) ? $BookingData['HotelBookingData']['booking_room_data'] : [];
            $HotelPassenger = [];
            $bookingCode = [];
            $ARR_SALUTIONTBO = $this->ARR_SALUTIONTBO();
            // echo "post<pre>";print_r(json_encode($post));die("post");
            if($booking_room_data){
                foreach($booking_room_data as  $roomKey => $roomVal){
                    $bookingCode[]['lin'] = isset($roomVal['TraceId']) ? $roomVal['TraceId'] : [];
                    foreach($roomVal['customer'] as $keyC => $customerVal){
                        $paxTitle          = $ARR_SALUTIONTBO[$customerVal['Salutation']];
                        $HotelPassenger["paxes"][$roomKey]["pax"][$keyC] = [
                            'titulo' => trim($paxTitle),
                            'nombrePax' => $customerVal['FirstName'],
                            'apellidos' => $customerVal['LastName'],
                            'edad' => isset($customerVal['Age']) ? $customerVal['Age'] : 20,
                        ];

                    }
                }
            }
            // echo "bookingCode<pre>";print_r($bookingCode);die;
            $bookingrequest = [
                "peticion" => [
                        "nombre" => "Servicio de pre-reserva", 
                        "agencia" => "Agencia prueba", 
                        "tipo" => "202", 
                        "parametros" => array_merge_recursive([
                            "codigo_hotel" => $HotelCode,
                            "nombre_cliente" => "CATABATIC TECHNOLOGY PRIVADA LIMITADA XML", 
                            "email" => $email, 
                            "telefono" => $mobile, 
                            "observaciones" => "Observaciones test", 
                            "num_expediente" => "00000000", 
                            "forma_pago" => "44", 
                            "res" => array_values(array_unique($bookingCode)), 
                            // "paxes" => ["pax" => $HotelPassenger],
                        ], $HotelPassenger)
                    ] 
                ];
                // echo "bookingrequest<pre>";print_r(json_encode($bookingrequest));die("bookingrequest====");
            $AdditionalInfor  = [
                "peticion" => [
                        "nombre" => "Observaciones hoteles", 
                        "agencia" => "Agencia Prueba", 
                        "tipo" => "24", 
                        "parametros" => $bookingCode
                    ] 
                ]; 
           
            $data = array('status' => true, 'message' => 'success', 'AdditionalInfor' => $AdditionalInfor, 'bookingrequest' => $bookingrequest);
           
            return ($data);
        } else {
            $data = array('status' => false, 'message' => 'Invalid request');
            return ($data);
        }
    }
    public function apiHoteltBookingHOTELBEDS($post, $AgencySysId, $Securitykey)
    {
        if ($post && $AgencySysId) {
            $BookingData = (isset($post['BookingData']) && !empty($post['BookingData'])) ? $post['BookingData'] : [];
            $email = (isset($post['BookingData']['email']) && !empty($post['BookingData']['email'])) ? $post['BookingData']['email'] : '';
            $mobile = (isset($post['BookingData']['mobile']) && !empty($post['BookingData']['mobile'])) ? $post['BookingData']['mobile'] : '';
            $HotelCode = (isset($post['BookingData']['HotelBookingData']['hotel_data']['HotelCode']) && !empty($post['BookingData']['HotelBookingData']['hotel_data']['HotelCode'])) ? $post['BookingData']['HotelBookingData']['hotel_data']['HotelCode'] : '';
            $booking_room_data = (isset($BookingData['HotelBookingData']['booking_room_data']) && !empty($BookingData['HotelBookingData']['booking_room_data'])) ? $BookingData['HotelBookingData']['booking_room_data'] : [];
            $HolderFirstName = (isset($booking_room_data[0]['customer'][0]['FirstName']) && !empty($booking_room_data[0]['customer'][0]['FirstName'])) ? $booking_room_data[0]['customer'][0]['FirstName'] : '';
            $HolderLastName = (isset($booking_room_data[0]['customer'][0]['LastName']) && !empty($booking_room_data[0]['customer'][0]['LastName'])) ? $booking_room_data[0]['customer'][0]['LastName'] : '';
          
            $rooms = [];
            if($booking_room_data){
                foreach($booking_room_data as  $roomKey => $roomVal){
                    $rooms[$roomKey]['rateKey'] = isset($roomVal['RoomTypeCode']) ? $roomVal['RoomTypeCode'] : [];
                    foreach($roomVal['customer'] as $keyC => $customerVal){
                        $rooms[$roomKey]['paxes'][$keyC] = [
                            "roomId" => 1, 
                            "type" => ($customerVal['paxType'] == 1) ? "AD" : "CH", 
                            "name" => $customerVal['FirstName'],
                            "surname" => $customerVal['LastName'], 
                        ];
                    }
                }
            }

            $bookingrequest = [
                "holder" => ["name" => $HolderFirstName, "surname" => $HolderLastName], 
                "rooms" => $rooms, 
                "clientReference" => "IntegrationAgency", 
                "remark" => "Booking remarks are to be written here." 
            ];
            return ($bookingrequest);
        } else {
            $data = array('status' => false, 'message' => 'Invalid request');
            return ($data);
        }
    }
    function getHttpRequestArray($data, $url, $AgencySysId = null)
    {

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        $output = curl_exec($ch);
        curl_close($ch);
        return $output;
    }
    public function apiHttpRequest($Request,  $url, $Securitykey)
	{
		if ($Request) {
			$data_stringh = json_encode($Request);
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, $url);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
			curl_setopt($ch, CURLOPT_HTTPHEADER, array(
				'Accept: application/json',
				'Content-Type: application/json',
				// 'Accept-Encoding: gzip',
				'SecurityKey: ' . $Securitykey,
				// 'Content-Length: ' . strlen($data_stringh)
			));
			$outputH = curl_exec($ch);
			$response = json_decode($outputH, true);
			return $response;
		} else {
			return $response = [];
		}
		exit;
	}
    public function httpBuildQuery($Request,$url)
	{
		if ($Request) {
            $jsonEncode = http_build_query($Request);
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_ENCODING, "gzip");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, ($jsonEncode));
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'SecurityKey: ' . SECURITYKEY,
                'Content-Length: ' . strlen($jsonEncode),
            ));
            $outputH = curl_exec($ch);
            // print_r($outputH);die;
            $response = json_decode($outputH, true);
            return $response;

		} else {
			return $response = [];
		}
		exit;
	}
     public function getStaticDataByCityId($HotelCode,$Securitykey)
    {
        
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://hotels.globaltravelexchange.com/tbo/v1/hotel/?hotelCode='.$HotelCode,
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_HTTPHEADER => array(
           'SecurityKey: ' . $Securitykey,
          ),
        ));
        $response = curl_exec($curl);
        curl_close($curl);
        $responseDecode__ = json_decode($response,true);
        $responseDecode = ($responseDecode__['results']) ? $responseDecode__['results'] :[];
        $cityResponsearra = [];
         if($responseDecode){
            foreach($responseDecode as $vl){
                $cityResponsearra[$vl['hotel_code']] = $vl;
            }
        }
        return $cityResponsearra;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit