| 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/junkdata/b2b.hellogtx.comOLDSEP11bak/application/controllers/ |
Upload File : |
<?php
class AutosigninController extends Catabatic_ValidateCustomer {
public function init() {
$this->API_CHECK_B2B_AGENCY = "https://globaltravelexchange.com/gtxwebservices/check-b2b-agency/";
$this->objMdl = new Admin_Model_CRUD();
$this->_user = new Zend_Session_Namespace('User');
}
public function writeLog($data) {
$fileName = date("Y-m-d") . ".txt";
$fp = fopen("data/" . $fileName, 'a+');
$data = date("Y-m-d H:i:s") . " - " . $data;
fwrite($fp, $data);
fclose($fp);
}
public function indexAction() {
$SERVER_NAME = $_SERVER['SERVER_NAME'];
if ($SERVER_NAME == 'holiday.flycreative.in') {
$userlogin = isset($_REQUEST['userlogin']) ? $_REQUEST['userlogin'] : null;
if ($userlogin) {
$url = 'https://flycreative.in/b2bweb/account/validatesession?userlogin=' . $userlogin;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Content-Length: 0',
'Accept:application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
$responseArr = json_decode($response, true);
$UserId = isset($responseArr['agent_code']) ? $responseArr['agent_code'] : null;
$FirstName = isset($responseArr['first_name']) ? trim(ucfirst($responseArr['first_name'])) : '';
$LastName = isset($responseArr['last_name']) ? trim(ucfirst($responseArr['last_name'])) : '';
$AgencyName = isset($responseArr['agent_name']) ? $responseArr['agent_name'] : '';
$EmailId = isset($responseArr['email']) ? trim($responseArr['email']) : '';
$MobileNo = isset($responseArr['phone']) ? trim($responseArr['phone']) : '';
$CityId = 0;
$CountryId = 0;
$StateId = 0;
} else {
echo "Please check token Id";
exit;
}
} else if ($SERVER_NAME == 'holidays.fly24hrs.com') {
$userlogin = isset($_REQUEST['userlogin']) ? $_REQUEST['userlogin'] : null;
if ($userlogin) {
$url = 'https://api.fly24hrs.com/api/Accounts/GetSessionAgency?sessionKey=' . $userlogin;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Content-Length: 0',
'Accept:application/json'
),
));
$response = curl_exec($curl);
//echo "<pre>";print_r($response);exit;
curl_close($curl);
$responseArr = json_decode($response, true);
$ErrorInfo = isset($responseArr['ErrorInfo']) ? $responseArr['ErrorInfo'] : null;
if ($ErrorInfo === null) {
$UserId = isset($responseArr['ContactNo']) ? $responseArr['ContactNo'] : null;
$FirstName = isset($responseArr['FirstName']) ? trim(ucfirst($responseArr['FirstName'])) : '';
$LastName = isset($responseArr['LastName']) ? trim(ucfirst($responseArr['LastName'])) : '';
$AgencyName = isset($responseArr['AgencyName']) ? $responseArr['AgencyName'] : '';
$EmailId = isset($responseArr['EmailId']) ? trim($responseArr['EmailId']) : '';
$MobileNo = isset($responseArr['ContactNo']) ? trim($responseArr['ContactNo']) : '';
$CityId = 0;
$CountryId = 0;
$StateId = 0;
} else {
echo "Please check token Id";
exit;
}
} else {
echo "Please check token Id";
exit;
}
} else {
$userLoginToken = str_replace("userlogin=", "", $_SERVER["QUERY_STRING"]);
if ($userLoginToken) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.needtoday.com/api/getdata",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"token: " . $userLoginToken,
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$responseArr = json_decode($response, true);
$responseArray = isset($responseArr[0]) ? $responseArr[0] : array();
$UserId = isset($responseArray['id']) ? $responseArray['id'] : null;
$FirstName = isset($responseArray['first_name']) ? trim(ucfirst($responseArray['first_name'])) : '';
$LastName = isset($responseArray['last_name']) ? trim(ucfirst($responseArray['last_name'])) : '';
$AgencyName = $FirstName . ' ' . $LastName;
$EmailId = isset($responseArray['email']) ? trim(ucfirst($responseArray['email'])) : '';
$MobileNo = isset($responseArray['phone']) ? trim(ucfirst($responseArray['phone'])) : '';
$CityId = 0;
$CountryId = 0;
$StateId = 0;
} else {
echo "Please check token Id";
exit;
}
}
try {
if ($UserId) {
$url = $this->API_CHECK_B2B_AGENCY;
$apiData = [
'SecurityKey' => SECURITYKEY,
'AgencyName' => $AgencyName,
'FirstName' => $FirstName,
'LastName' => $LastName,
'EmailId' => $EmailId,
'MobileNo' => $MobileNo,
'CityId' => $CityId,
'CountryId' => $CountryId,
'StateId' => $StateId,
'NickId' => $UserId
];
try {
$curl_p = curl_init($url);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
$response = curl_exec($curl_p);
$this->writeLog($response);
curl_close($curl_p);
} catch (Exception $error) {
$responceArray = array('status' => false, 'message' => $error->getMessage());
echo json_encode($responceArray);
exit;
}
try {
$response_decode = Zend_Json::decode($response, true);
$WallaetBalance = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->AgencyWallaetBalance($response_decode['SecurityKey']);
$sessionWallaetBalance = new Zend_Session_Namespace('sessionWallaetBalance');
$sessionWallaetBalance->params = $WallaetBalance;
$getSupportContact = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->getSupportContact($response_decode['SecurityKey']);
$sessionSupportContact = new Zend_Session_Namespace('sessionSupportContact');
$sessionSupportContact->params = $getSupportContact;
$sessionRM = new Zend_Session_Namespace('sessionRM');
$sessionRM->params = $response_decode['RM'];
$AgencySysId = $response_decode['AgencySysId'];
$UserSysId = $response_decode['UserSysId'];
$checkData = array();
if (isset($AgencySysId) && !empty($AgencySysId)) {
$checkMappingData = $this->objMdl->getModuleMappingDataForAcl($AgencySysId, $UserSysId);
if (empty($checkMappingData)) {
$currentDate = date("Y-m-d H:i");
$moduleName = unserialize(MODULENAMEINSERT);
if (!empty($moduleName)) {
$insertData = array(
"AgencySysId" => $response_decode['AgencySysId'],
"AgentSysId" => $response_decode['UserSysId'],
"IsPermission" => 1,
"IsActive" => 1,
"IsMarkForDelete" => 0,
);
try {
$this->objMdl->rv_insert("tb_agency_userrole_mapping", $insertData);
} catch (Exception $e) {
$responceArray = array('status' => false, 'message' => $e->getMessage());
echo json_encode($responceArray);
exit;
}
foreach ($moduleName as $moduleKey => $moduleValue) {
$insertData = array(
"AgencySysId" => $response_decode['AgencySysId'],
"AgentSysId" => $response_decode['UserSysId'],
"Parent_Id" => 0,
"Title" => $moduleValue['Title'],
"ModuleName" => $moduleValue['moduleName'],
"ControllerName" => $moduleValue['ControllerName'],
"ModuleType" => $moduleValue['Type'],
"ParentCode" => $moduleValue['Category'],
"val" => $moduleKey,
"url" => $moduleValue['url'],
"UpdateDate" => $currentDate,
"CreateDate" => $currentDate,
"IsOrder" => $moduleValue['order'],
"IsDisplayLeftNev" => $moduleValue['isDisplay'],
"IsActive" => 1,
"IsMarkForDelete" => 0
);
if (trim($response_decode['B2BType']) == 2 && ($moduleValue['Title'] == 'Settings' || $moduleValue['Title'] == 'Markup')) {
$insertData['IsActive'] = 0;
}
try {
$this->objMdl->rv_insert("tb_agency_userrole_permission", $insertData);
} catch (Exception $e) {
$responceArray = array('status' => false, 'message' => $e->getMessage());
echo json_encode($responceArray);
exit;
}
}
}
}
$checkData = $this->objMdl->getModuleDataForAcl($AgencySysId, $UserSysId);
}
$this->_user = new Zend_Session_Namespace('User');
$this->_user->getAgencyRolePermission = $checkData;
$this->_user->B2BType = $response_decode['B2BType'];
$this->_user->UserPicPath = $response_decode['UserPicPath'];
$this->_user->data = $response_decode;
$this->_redirect('dashboard');
exit;
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
} else {
echo "Agent code not got from API End.";
exit;
}
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
}
}