| 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 : |
<?php
/* * *************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : Flight.php
* File Desc. : Flight helper to including supporting functions/methods for Flights
* Created By : Md Sabir <sabir@catpl.co.in>
* Created Date : 17 Sep 2022
* ************************************************************* */
class Zend_Controller_Action_Helper_Flight extends Zend_Controller_Action_Helper_Abstract
{
public $baseUrl;
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 MinutesToHours($minutes)
{
if ($minutes) {
$hours = floor($minutes / 60);
$min = $minutes - ($hours * 60);
$LAYOVERTime = $hours . "h " . $min . 'm';
return $LAYOVERTime;
}
}
public function getTimeFromApiString($string)
{
if (empty($string))
return '';
$arr = explode("T", $string);
$date = new DateTime($arr[0]);
return substr(@$arr[1], 0, 5);
}
public function getTimeFromApiString2($string)
{
if (empty($string))
return '';
$arr = explode(" ", $string);
$date = new DateTime($arr[0]);
return substr(@$arr[1], 0, 5);
}
public function convertMinutesToHoursFormat($minutes)
{
if ($minutes < 1) {
//return;
}
$hours = floor($minutes / 60);
$minutes = ($minutes % 60);
return $hours . 'h ' . $minutes . 'm';
}
public function convertMinutes($fromtime, $totime)
{
$to_time = strtotime($totime);
$from_time = strtotime($fromtime);
return round(abs($to_time - $from_time) / 60,2);
}
public function CalculateTotalTime($time1, $time2)
{
$diff = abs(strtotime($time1) - strtotime($time2));
$tmins = $diff / 60;
$hours = floor($tmins / 60);
$mins = $tmins % 60;
return $hours . 'h ' . $mins . 'm';
}
public function GetFullUrl(){
$s = &$_SERVER;
$ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true : false;
$sp = strtolower($s['SERVER_PROTOCOL']);
$protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
$port = $s['SERVER_PORT'];
$port = ((!$ssl && $port == '80') || ($ssl && $port == '443')) ? '' : ':' . $port;
$host = isset($s['HTTP_X_FORWARDED_HOST']) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
$host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
$uri = $protocol . '://' . $host . $s['REQUEST_URI'];
$segments = explode('?', $uri, 2);
$url = $segments[0];
return $url;
}
public function getAirlinesName()
{
$url = $this->baseUrl . "public/data/airlinesName.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);
$output = curl_exec($ch);
curl_close($ch);
$response = json_decode($output, true);
$AirlinesName = [];
if($response){
foreach ($response as $key => $value) {
$AirlinesName[$value['AIRLINECODE']] = $value;
}
}
return $AirlinesName;
}
public function CreateLogs($data){
$agency_sys_id = isset($data['AgencySysId'])?$data['AgencySysId']:'';
$requests = $this->getRequest()->getParams();
$data = [
"user_id" => isset($data['user_id']) ? $data['user_id'] : 1,
"agency_sys_id" => isset($agency_sys_id) ? $agency_sys_id : '',
"application_name" => isset($data['siteName']) ? $data['siteName'] : $_SERVER['HTTP_HOST'],
"site_url" => $this->GetFullUrl(),
"module_name" => isset($requests['module']) ? ucfirst($requests['module']) : '',
"controller_name" => isset($requests['controller']) ? ucfirst($requests['controller']) : '',
"action_name" => isset($requests['action']) ? ucfirst($requests['action']) : '',
"custom_error" => isset($data['custom_error']) ? $data['custom_error'] : '',
"error" => isset($data['error']) ? $data['error'] : '',
"ip_address" => $_SERVER['REMOTE_ADDR'],
"text_udf" => isset($data['text_udf']) ? json_encode($data['text_udf']) : '', // Response
"char_udf" => isset($data['char_udf']) ? json_encode($data['char_udf']) : '', // Request
"udf1" => isset($data['udf1']) ? $data['udf1'] : '',
"udf2" => isset($data['udf2']) ? $data['udf2'] : '',
"udf5" => isset($data['udf5']) ? $data['udf5'] : '',
"from_destination" => isset($data['from_destination']) ? $data['from_destination'] : '',
"to_destination" => isset($data['to_destination']) ? $data['to_destination'] : '',
"Pax" => isset($data['Pax']) ? $data['Pax'] : '',
"flight_type" => isset($data['flight_type']) ? $data['flight_type'] :5,
"source" => isset($data['source']) ? $data['source'] :1,
"Supplier" => isset($data['Supplier']) ? $data['Supplier'] : '',
"Airline" => isset($data['Airline']) ? $data['Airline'] : '',
"status" => isset($data['status']) ? $data['status'] : 1, //
"created_on" => date('Y-m-d H:i:s'),
"updated_on" => date('Y-m-d'),
"is_active" => isset($data['is_active']) ? $data['is_active'] : true, //,
"is_mark_for_delete" => isset($data['is_mark_for_delete']) ? $data['is_mark_for_delete'] : false, //,
];
$url = 'https://logs.hellogtx.com/api/v1/create-logs/';
$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, "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_TIMEOUT, 3);
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);
$response = json_decode($outputH, true);
return $response;
}
public function getRangeByValue($ratearray, $input)
{
foreach ($ratearray as $key => $value) {
$keyex = explode('-', $value);
if ($keyex[0] <= $input && $keyex[1] >= $input) {
return $value;
}
}
}
public function createApiCallLogs($strDestination, $data)
{
$strPath = $_SERVER["DOCUMENT_ROOT"] . "/public/logs/" . $strDestination;
$strFolder = trim($strPath, basename($strPath)); //exit;
if (!file_exists($strFolder)) { // if folder does not exists...
mkdir($strFolder, 0777, true);
}
file_put_contents($strPath, $data); // wirte data to respective file...
}
public function createApiXMLLogs($strDestination, $data)
{
$strPath = $_SERVER["DOCUMENT_ROOT"] . "/public/logs/" . $strDestination;
$strFolder = trim($strPath, basename($strPath)); //exit;
if (!file_exists($strFolder)) { // if folder does not exists...
mkdir($strFolder, 0777, true);
}
$dom = new DOMDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->loadXML($data);
//Save XML as a file
$dom->save($strPath);
}
function AgencyMarketPlace($arrSessionData = array(), $URL, $SECURITYKEY = null)
{
$jsonEncode = json_encode($arrSessionData);
$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_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, ($jsonEncode));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if ($SECURITYKEY) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'SecurityKey: ' . $SECURITYKEY,
'Content-Length: ' . strlen($jsonEncode),
));
}
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
return $response;
}
public function agencyTermAndCondition($AgencySysId,$SecurityKey)
{
if ($AgencySysId) {
$API_URL = API_GET_AGENCY_TERMS_AND_CONDITION;
$apiData = array(
"AgencySysId" => $AgencySysId,
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $API_URL,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $apiData,
));
$output = curl_exec($curl);
$response = json_decode($output, true);
$apiDataIV = array(
"AgencySysId" => $AgencySysId,
"SecurityKey" => $SecurityKey
);
$curl_IV = curl_init(API_GET_IV_KEY);
curl_setopt($curl_IV, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl_IV, CURLOPT_POSTFIELDS, http_build_query($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);
$IVData = Zend_Json::decode($responseIV, true);
$agencyData = new GTX_Model_Encrytion($response['Message'], $apiDataIV['SecurityKey'], $IVData['Message']);
return Zend_Json::decode($agencyData->decrypt(), true);
} else {
$data = array('status' => false, 'message' => 'Invalid request');
return ($data);
}
}
}