| 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/b2b.hellogtx.com/library/Helper/ |
Upload File : |
<?php
/* * *************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : Flight.php
* File Desc. : Flight helper to including supporting functions/methods for Flight
* Created By : Md Sabir <sabir@catpl.co.in>
* Created Date : 14 Feb 2020
* Updated Date : 07 Aug 2020
* ************************************************************* */
class Zend_Controller_Action_Helper_Flightapi extends Zend_Controller_Action_Helper_Abstract
{
public $baseUrl;
public $APIMode;
public $IsTJFlightAPI;
public $IsRIYAFlightAPI;
public $IsETRAVFlightAPI;
public $IsVIAFlightAPI;
public $IsAKASAFlightAPI;
public $IsTJPFlightAPI;
public $IsTBOPFlightAPI;
public $IsJUSTCLICKFlightAPI;
public $IsFLYSHOPFlightAPI;
public $IsTRAVTECHFlightAPI;
public $IsTRAVELOPEDIAFlightAPI;
public $IsAIRIQFlightAPI;
public $IsNEXTRAFlightAPI;
public $IsYATRAFlightAPI;
public $IsFLY24HRSFlightAPI;
public $IsTRAVCLANFlightAPI;
public $IsSeriesFareByDate;
public $gtxagencysysid;
public $IsBOTHFlightAPI;
public $IsFareBoutiqueAPI;
public $travel_z_gear;
public $book_n_travel;
public $IsGoFlySmartAPI;
public $gtxBtoBsite;
public $Series_Fare_Url;
public $siteName;
public $_session;
public $postFields;
public $db;
public $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'];
$this->gtxBtoBsite = $BootStrap['gtxBtoBsite'];
$this->gtxagencysysid = $BootStrap['gtxagencysysid'];
$this->IsSeriesFareByDate = isset($BootStrap['IsSeriesFareByDate']) ? $BootStrap['IsSeriesFareByDate'] : 0;
$this->_session = new Zend_Session_Namespace('User');
$this->Series_Fare_Url = 'https://gtxapi.hellogtx.com/api/v2/';
}
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 apiHttpRequest($Request, $arrData, $url)
{
if ($Request) {
$data_stringh = json_encode($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_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);
// echo "<pre>";
// print_r($outputH);
// die();
return $response;
} else {
return $response = [];
}
exit;
}
function BNPLWallaetBalance($SecurityKey)
{
if ($SecurityKey) {
$apiDataIV = array(
"B2BAgencySysIdKey" => SECURITYKEY,
"B2CAgencySysIdKey" => $SecurityKey,
);
$curl_IV = curl_init(BNPL_GET_BALANCE);
curl_setopt($curl_IV, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl_IV, CURLOPT_POSTFIELDS, ($apiDataIV));
curl_setopt($curl_IV, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_IV, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_IV, CURLOPT_TIMEOUT, 300);
$responseIV = curl_exec($curl_IV);
curl_close($curl_IV);
return Zend_Json::decode($responseIV, true);
} else {
return 'Bad request';
}
}
public function CreateSessionSearchParams($getData, $TraceId)
{
// echo("hello"); die('jajajaj');from_des
Zend_Session::namespaceUnset('sessionFlightSearchParams');
// Zend_Session::namespaceUnset('recentSearch');die; PreferredAirline
if (!empty($getData)) {
$recentSearch = new Zend_Session_Namespace('recentSearch');
$uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
$uriExp = explode('?', $uri);
$recentSearch->params = [];
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$getData['from_city'] = $getData['from_des'];
$getData['to_city'] = $getData['to_des'];
$SearchFlightTraceId = new Zend_Session_Namespace('SearchFlightTraceId');
// Putting all form data to Session
$SearchFlightTraceId->params = $TraceId;
$url = $this->baseUrl . "public/data/dynamic/flight_destinations.json";
$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);
$str = curl_exec($ch);
//$str = file_get_contents($this->baseUrl . 'public/data/dynamic/flight_destinations.json',FILE_USE_INCLUDE_PATH);
$Destinationjson = json_decode($str, true);
$departure_dates = $getData['departure_date'];
$departure_datesf = isset($getData['departure_datesf'][0]) ? $getData['departure_datesf'][0] : '00/00/0000';
if (isset($departure_datesf)) {
$arrDepatureDateSF = explode("/", $departure_datesf);
$strDepatureDateSF = !empty($arrDepatureDateSF[2]) . "-" . !empty($arrDepatureDateSF[1]) . "-" . !empty($arrDepatureDateSF[0]);
}
$route = $getData['route'];
$return_dates = isset($getData['return_date']) ? $getData['return_date'] : '';
$source_city = $getData['source_city']; // or DEL,BLR etc.
$destination_city = $getData['destination_city']; // or DEL,BLR etc.
$PreferredAirline = isset($getData['PreferredAirline']) ? $getData['PreferredAirline'] : [];
if ($route == 4) {
$from_des = explode('__', $getData['from_des'][0]);
$from_des_1 = explode('-', $from_des[1]);
$getData['TripType'] = $from_des[0];
$source_city[0] = $getData['source_city'][0] = $from_des_1[0];
$destination_city[0] = $getData['destination_city'][0] = $from_des_1[1];
// echo '<pre>';print_r($source_city);
// echo '<pre>';print_r($destination_city);departure_dates
// die;
}
$sessionFlightSearchParams->params = $getData;
$DepDate = [];
$DepDateMobile = [];
$RetDate = [];
$RetDateMobile = [];
$intSourceCityId = [];
$Fromlabel = [];
$Tolabel = [];
$intCountryCode_ = [];
$intdestinationCityId = [];
$interNationalSearchArray = [];
if ($departure_dates) {
foreach ($departure_dates as $DEDate) {
if (!empty($DEDate)) {
$arrDepatureDate = explode("/", $DEDate);
if (count($arrDepatureDate) > 0) {
$strDepatureDate = $arrDepatureDate[2] . "-" . $arrDepatureDate[1] . "-" . $arrDepatureDate[0];
$DepDate[] = $strDepatureDate;
$DepDateMobile[] = date('d M D', strtotime($strDepatureDate));
}
}
}
}
if ($return_dates) {
foreach ($return_dates as $REDate) {
if (!empty($REDate)) {
$strReturnDate = explode("/", $REDate);
if (count($strReturnDate) > 0) {
$strReturnDate = $strReturnDate[2] . "-" . $strReturnDate[1] . "-" . $strReturnDate[0];
$RetDate[] = $strReturnDate;
$RetDateMobile[] = date('d M D', strtotime($strReturnDate));
}
}
}
}
$IsSfS = 0;
if ($route == 4) {
$DepDate = [];
$DepDate = !empty($getData['departure_dateG']) ? $getData['departure_dateG'] : [];
$IsSfS = 1;
}
// echo '<pre>';print_r($getData);;
// die;
if ($source_city) {
foreach ($source_city as $key => $filterByFrom) {
$filterByTo = $destination_city[$key];
$arrSourceCityId_ = array_filter($Destinationjson, function ($var) use ($filterByFrom) {
return ($var['AirportCode'] == $filterByFrom);
});
$arrdestinationCityId_ = array_filter($Destinationjson, function ($var) use ($filterByTo) {
return ($var['AirportCode'] == $filterByTo);
});
$arrSourceCityId = array_values($arrSourceCityId_);
$arrdestinationCityId = array_values($arrdestinationCityId_);
if (count($arrSourceCityId) > 0) {
$intSourceCityId[] = $arrSourceCityId[0]['CityID'];
$Fromlabel_ = isset($arrSourceCityId[0]['label']) ? $arrSourceCityId[0]['label'] : '';
$Fromlabel[] = substr($Fromlabel_, 0, strpos($Fromlabel_, ','));
$intCountryCode = trim($arrSourceCityId[0]['CountryCode']);
$intOriginCountryCode = trim($arrSourceCityId[0]['CountryCode']);
if ($route == 4) {
$sessionFlightSearchParams->params['source'] = $Fromlabel;
}
} else {
$intSourceCityId[] = "";
$intCountryCode = "";
$intOriginCountryCode = "";
}
// echo "<pre>arrdestinationCityId";print_r($arrdestinationCityId);die("arrdestinationCityId");
if (count($arrdestinationCityId) > 0) {
$intdestinationCityId[] = $arrdestinationCityId[0]['CityID'];
$Tolabel_ = isset($arrdestinationCityId[0]['label']) ? $arrdestinationCityId[0]['label'] : '';
$Tolabel[] = substr($Tolabel_, 0, strpos($Tolabel_, ','));
$intdestinationCountryCode = trim($arrdestinationCityId[0]['CountryCode']);
$intDestinaionCountryCode = trim($arrdestinationCityId[0]['CountryCode']);
if ($route == 4) {
$sessionFlightSearchParams->params['destination'] = $Tolabel;
}
} else {
$intdestinationCityId[] = "";
$intdestinationCountryCode = "";
}
if ($intCountryCode == $intdestinationCountryCode) {
$intCountryCode_[] = 'IN';
} else {
$intCountryCode_[] = 'INT';
}
if ($intOriginCountryCode != "IN" || empty($intOriginCountryCode)) {
$sessionFlightSearchParams->params['intCountryCodeOrigin'] = isset($arrSourceCityId[0]['CountryCode']) ? trim($arrSourceCityId[0]['CountryCode']) :'';
$interNationalSearchArray[] = $sessionFlightSearchParams->params['interNationalSearch'] = true;
} else if ($intdestinationCountryCode != "IN" || empty($intdestinationCountryCode)) {
$sessionFlightSearchParams->params['intCountryCodeReturn'] = isset($arrdestinationCityId[0]['CountryCode']) ? trim($arrdestinationCityId[0]['CountryCode']) : '';
$interNationalSearchArray[] = $sessionFlightSearchParams->params['interNationalSearch'] = true;
} else {
$interNationalSearchArray[] = $sessionFlightSearchParams->params['interNationalSearch'] = false;
}
}
}
if (in_array(1, $interNationalSearchArray)) {
$sessionFlightSearchParams->params['interNationalSearch'] = true;
}
$sessionFlightSearchParams->params['IsSfS'] = $IsSfS;
$sessionFlightSearchParams->params['strDepatureDateSF'] = $strDepatureDateSF;
$sessionFlightSearchParams->params['strDepatureDate'] = $DepDate;
$sessionFlightSearchParams->params['strReturnDate'] = !empty($RetDate) ? $RetDate : '';
$sessionFlightSearchParams->params['sourceCityId'] = !empty($intSourceCityId) ? $intSourceCityId : '';
$sessionFlightSearchParams->params['intCountryCode'] = !empty($intCountryCode_) ? $intCountryCode_ : '';
$sessionFlightSearchParams->params['destinationCityId'] = !empty($intdestinationCityId) ? $intdestinationCityId : '';
$sessionFlightSearchParams->params['interNationalSearchArray'] = !empty($interNationalSearchArray) ? $interNationalSearchArray : '';
$sessionFlightSearchParams->params['FlightTraceId'] = $TraceId;
$sessionFlightSearchParams->params['sourceCityAirportCode'] = ($route == 4) ? [$source_city[0]] : $getData['source_city'];
$sessionFlightSearchParams->params['destinationCityAirportCode'] = ($route == 4) ? [$destination_city[0]] : $getData['destination_city'];
$sessionFlightSearchParams->params['from'] = $getData['source_city'];
$sessionFlightSearchParams->params['to'] = $getData['destination_city'];
$sessionFlightSearchParams->params['Fromlabel'] = $Fromlabel;
$sessionFlightSearchParams->params['Tolabel'] = $Tolabel;
$sessionFlightSearchParams->params['sourceCityText'] = $getData['source'];
$sessionFlightSearchParams->params['destinationCityText'] = $getData['destination'];
$sessionFlightSearchParams->params['sourceCityId'] = $intSourceCityId;
$sessionFlightSearchParams->params['destinationCityId'] = $intdestinationCityId;
$sessionFlightSearchParams->params['intCountryCode'] = $intCountryCode;
$sessionFlightSearchParams->params['route'] = $getData['route'];
$sessionFlightSearchParams->params['TripType'] = isset($getData['TripType']) ? $getData['TripType'] : 0;
$sessionFlightSearchParams->params['SearchRoute'] = $getData['route'];
$sessionFlightSearchParams->params['flight_class'] = $getData['class'];
$sessionFlightSearchParams->params['adults'] = $getData['adults'];
$sessionFlightSearchParams->params['child'] = $getData['childs'];
$sessionFlightSearchParams->params['infant'] = $getData['infants'];
$sessionFlightSearchParams->params['departure_dates'] = !empty($getData['departure_date'][0])?$getData['departure_date']:[date('d/m/Y',strtotime($getData['departure_dateG'][0]))];
$sessionFlightSearchParams->params['return_dates'] = !empty($getData['return_date']) ? $getData['return_date'] : '';
// $sessionFlightSearchParams->params['departure_dateG'] = !empty($getData['departure_dateG']) ? $getData['departure_dateG'] : '';
$sessionFlightSearchParams->params['PreferredAirline'] = $PreferredAirline;
$sessionFlightSearchParams->params['DepatureDateMobile'] = ($DepDateMobile);
$sessionFlightSearchParams->params['ReturnDateMobile'] = !empty($RetDateMobile) ? $RetDateMobile : '';
$sessionFlightSearchParams->params['SearchTime'] = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
$sessionFlightSearchParams->params['apisource'] = isset($getData['apisource']) ? $getData['apisource'] : '';
$sessionFlightSearchParams->params['ContSysId'] = $getData['ContSysId'];
$source_cityC = $sessionFlightSearchParams->params['source_city'];
$destination_cityC = $sessionFlightSearchParams->params['destination_city'];
$strDepatureDate = $sessionFlightSearchParams->params['strDepatureDate'];
$departure_dates = $sessionFlightSearchParams->params['departure_dates'];
$strReturnDate = $sessionFlightSearchParams->params['strReturnDate'];
$return_dates = $sessionFlightSearchParams->params['return_dates'];
// if($this->gtxagencysysid == '50490'){
// echo '<pre>';print_r($getData);
// echo '<pre>';print_r($sessionFlightSearchParams->params);
// die;
// }
$NewArray = false;
if (!empty($recentSearch->params)) {
foreach ($recentSearch->params as $k => $val) {
$source_city = $val['source_city'];
$destination_city = $val['destination_city'];
if ($source_cityC == $source_city && $destination_cityC == $destination_city) {
$NewArray = false;
$recentSearch->params[$k] = $val;
} else {
$NewArray = true;
$recentSearch->params[$k] = $val;
//$recentSearch->params[$k]['searchUrl'] = $uriExp[1];
}
//
}
} else {
$recentSearch->params[0] = $sessionFlightSearchParams->params;
$recentSearch->params[0]['searchUrl'] = isset($uriExp[1]);
}
if ($NewArray) {
$recentSearch->params[$k + 1] = $sessionFlightSearchParams->params;
$recentSearch->params[$k + 1]['searchUrl'] = $uriExp[1];
}
return $sessionFlightSearchParams->params;
} else {
die('Oops something went wrong');
}
}
}