| 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/b2bzend/application/controllers/ |
Upload File : |
<?php
class CheckotpController extends Catabatic_ValidateOtp {
private $SMSURL;
private $SMSMETHOD;
private $SMSAPIKEY;
private $SMSSENDER;
private $SMSFORMAT;
public $SENDSMSCONFIG;
public $paymentMdl;
public function init() {
parent::init();
$this->SMSURL = Catabatic_Helper::getSMSURL();
$this->SMSMETHOD = Catabatic_Helper::getSMSMETHOD();
$this->SMSAPIKEY = Catabatic_Helper::getSMSAPIKEY();
$this->SMSSENDER = Catabatic_Helper::getSMSSENDER();
$this->SMSFORMAT = Catabatic_Helper::getSMSFORMAT();
$this->paymentMdl = new Payment_Model_Payment();
$this->SENDSMSCONFIG = Catabatic_Helper::getSENDSMSCONFIG();
}
public function indexAction() {
$IsAllowRandomCodeAccess = isset(Travel_Model_AgencyAuth::getIdentity()->IsAllowRandomCodeAccess) ? Travel_Model_AgencyAuth::getIdentity()->IsAllowRandomCodeAccess : "0";
if ($IsAllowRandomCodeAccess == 0) {
$this->_helper->layout->disableLayout();
} else {
$this->_helper->layout->setLayout('layout-checkotp');
}
$mobile_no = Travel_Model_AgencyAuth::getIdentity()->ContactNo1;
$login_lastfourdigt_mobile_no = substr($mobile_no, -4);
$UserSysId = Travel_Model_AgencyAuth::getIdentity()->UserSysId;
$AgencySysId = Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
$col = array("RandomCode", "RandomCodeValidFrom", "RandomCodeValidTo");
$checkotpModel = new Payment_Model_Checkotp();
$getDetails = $checkotpModel->getDetails("TB_Agency_User", $col, $UserSysId, $AgencySysId);
$message = "One Time Password(OTP) has been sent your on mobile ******$login_lastfourdigt_mobile_no, Please enter the same OTP here to login.";
if ($this->getRequest()->isPost()) {
// $date = new Zend_Date();
$currentDate = date('Y-m-d H:i:s');
$RandomCode = $this->getRequest()->getPost("mobileotp");
$RandomCodeValidTo = $getDetails['RandomCodeValidTo']->format('Y-m-d H:i:s');
if (!empty($getDetails)) {
if ($RandomCode === $getDetails['RandomCode']) {
if ($RandomCodeValidTo >= $currentDate) {
$IsInsurance = Travel_Model_AgencyAuth::getIdentity()->IsInsurance;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$_SESSION['AgencyUser']['user']->{"checkOtp"} = true;
$userName = Travel_Model_AgencyAuth::getIdentity()->EmailId;
$objAgency = new Travel_Model_TblAgency();
$arrAgentDetail = $objAgency->validateAgent($UserSysId, $AgencySysId);
$sessionLogin_user->intLoggedinUserId = $arrAgentDetail[0]['UserSysId'];
$sessionLogin_user->intLoggedinUserAgencySysId = $intLoggedinUserAgencySysId = $arrAgentDetail[0]['AgencySysId'];
$sessionLogin_user->UserName = trim($arrAgentDetail[0]['UserName']);
$sessionLogin_user->UserRole = $arrAgentDetail[0]['UserRole'];
$sessionLogin_user->ShowAllWhatsAppData = $arrAgentDetail[0]['ShowAllWhatsAppData'];
$sessionLogin_user->FirstName = trim($arrAgentDetail[0]['FirstName']);
$sessionLogin_user->LastName = trim($arrAgentDetail[0]['LastName']);
$sessionLogin_user->contactnum = trim($arrAgentDetail[0]['ContactNo1']);
$sessionLogin_user->LastLoginTime = $arrAgentDetail[0]['LastLoginTime'];
$sessionLogin_user->IsInsurance = $arrAgentDetail[0]['IsInsurance'];
$sessionLogin_user->IsGTXNetworkWeb = $arrAgentDetail[0]['IsGTXNetworkWeb'];
$sessionLogin_user->IsWhatsApp = $arrAgentDetail[0]['IsWhatsApp'];
$sessionLogin_user->IsEnabledB2CWallet = $arrAgentDetail[0]['IsEnabledB2CWallet'];
$sessionLogin_user->IsB2BRewardsPoints = $arrAgentDetail[0]['IsB2BRewardsPoints'];
$sessionLogin_user->IsAgencySysId = Catabatic_Helper::getIsAgencySysId();
$sessionLogin_user->getMasterAgencySysId = Catabatic_Helper::getAgencySysId();
if (Catabatic_Helper::getIsAgencySysId() == True && $AgencySysId != Catabatic_Helper::getAgencySysId()) {
$objAgent = new Travel_Model_TblAgency();
$masterAgencyLogo = $objAgent->getAgencyLogo($sessionLogin_user->getMasterAgencySysId);
$sessionLogin_user->masterAgencyLogo = $masterAgencyLogo['Logo'];
}
$sessionLogin_user->IsDemo = $arrAgentDetail[0]['IsDemo'];
$objAgent = new Travel_Model_TblAgency();
$intLoggedinUserTrxCurrency = $objAgent->getTrxCurrency($intLoggedinUserAgencySysId);
$getDefaultCampaignByAgencyId = $objAgency->getDefaultCampaignByAgencyId($intLoggedinUserAgencySysId);
$getTcsSettingsByAgencyId = $objAgency->getTcsSettingsByAgencyId($intLoggedinUserAgencySysId);
$_SESSION['AgencyUser']['user']->{"TaxLabel"} = $objAgency->getTaxTypeLable($arrAgentDetail[0]['TaxLabelId']);
$_SESSION['AgencyUser']['user']->{"IsAllowFlightBooking"} = (int) $arrAgentDetail[0]['IsAllowFlightBooking'];
$_SESSION['AgencyUser']['user']->{"SenderEmailSysId"} = (int) $arrAgentDetail[0]['SenderEmailSysId'];
$_SESSION['AgencyUser']['user']->{"IsCheckWallet"} = (int) $arrAgentDetail[0]['IsCheckWallet'];
$_SESSION['AgencyUser']['user']->{"IsSameEmailId"} = (int) $arrAgentDetail[0]['IsSameEmailId'];
$_SESSION['AgencyUser']['user']->{"DefaultCampaignId"} = (int) $getDefaultCampaignByAgencyId;
$_SESSION['AgencyUser']['user']->{"IsTCS"} = (int) $getTcsSettingsByAgencyId;
$_SESSION['AgencyUser']['user']->{"intLoggedinUserTrxCurrency"} = (int) $intLoggedinUserTrxCurrency;
$_SESSION['AgencyUser']['user']->{"AgencyTimeZone"} = trim($arrAgentDetail[0]['AgencyTimeZone']);
$_SESSION['AgencyUser']['user']->{"AgencydateFormat"} = trim($arrAgentDetail[0]['AgencydateFormat']);
$_SESSION['AgencyUser']['user']->{"ExtensionNo"} = trim($arrAgentDetail[0]['ExtensionNo']);
$_SESSION['AgencyUser']['user']->{"IsMaskingOnEmailAndMobile"} = (int) ($arrAgentDetail[0]['IsMaskingOnEmailAndMobile']);
$_SESSION['AgencyUser']['user']->{"IsFullMaskingEnabled"} = (int) ($arrAgentDetail[0]['IsFullMaskingEnabled']);
$_SESSION['AgencyUser']['user']->{"IsCreditLimitActivate"} = (int) ($arrAgentDetail[0]['IsCreditLimitActivate']);
$_SESSION['AgencyUser']['user']->{"IsEnabledFlexiPay"} = (int) ($arrAgentDetail[0]['IsEnabledFlexiPay']);
$_SESSION['AgencyUser']['user']->{"IsAutoProposalOnFBLead"} = (int) ($arrAgentDetail[0]['IsAutoProposalOnFBLead']);
$_SESSION['AgencyUser']['user']->{"IsHotelInventory"} = (int) ($arrAgentDetail[0]['IsHotelInventory']);
$_SESSION['AgencyUser']['user']->{"IsSanKash"} = (int) ($arrAgentDetail[0]['IsSanKash']);
$_SESSION['AgencyUser']['user']->{"IsCallCenter"} = (int) ($arrAgentDetail[0]['IsCallCenter']);
$_SESSION['AgencyUser']['user']->{"IsArchivedPer"} = (int) ($arrAgentDetail[0]['IsArchivedPer']);
$_SESSION['AgencyUser']['user']->{"IsOps"} = (int) ($arrAgentDetail[0]['IsOps']);
$sessionLogin_user->ContactNo1 = trim($arrAgentDetail[0]['ContactNo1']);
$sessionLogin_user->Logo = trim($arrAgentDetail[0]['Logo']);
$sessionLogin_user->EmailId = trim($arrAgentDetail[0]['EmailId']);
$sessionLogin_user->IsB2CSite = trim($arrAgentDetail[0]['IsB2CSite']);
$sessionLogin_user->IsSiteType = (int) trim($arrAgentDetail[0]['IsSiteType']);
$sessionLogin_user->IsTG = trim($arrAgentDetail[0]['IsTG']);
$sessionLogin_user->IsGTXNetwork = trim($arrAgentDetail[0]['IsGTXNetwork']);
$sessionLogin_user->IsFranchise = trim($arrAgentDetail[0]['IsFranchise']);
$sessionLogin_user->intLoggedinUserTrxCurrency = $intLoggedinUserTrxCurrency;
$sessionLogin_user->intLoggedinUserGroupSysId = $objAgent->getAgencyGroup($intLoggedinUserAgencySysId);
$sessionLogin_user->agencyDetails = $objAgent->getAgencyDataById($intLoggedinUserAgencySysId);
if($intLoggedinUserAgencySysId == 4650){
$sessionLogin_user->ShowInternalSightseeing = 1;
}
// $sessionLogin_user->ReportingToSysId = $objAgent->getAgencyDeptUserMapById($arrAgentDetail[0]['UserSysId']);
$objAgentStaff = new Travel_Model_TblAgencyStaff();
$checkExistingStaffDetail = $objAgentStaff->checkExistingStaffDetail($UserSysId, $AgencySysId, 'nameid');
$sessionLogin_user->ReportingToSysId = isset($checkExistingStaffDetail['id']) ? $checkExistingStaffDetail['id'] : '';
$sessionLogin_user->ReportingToName = isset($checkExistingStaffDetail['name']) ? $checkExistingStaffDetail['name'] : '';
$sessionLogin_user->manageNotifications = $objAgentStaff->getAgencyWiseQueryAcknowledgement($AgencySysId);
$objRole = new Travel_Model_TblAgencyUserRole();
$userRoleDesc = $objRole->getRole(" RoleSysId={$arrAgentDetail[0]['UserRole']}");
$AgencySysId = Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
$UserSysId = Travel_Model_AgencyAuth::getIdentity()->UserSysId;
$permissionModel = new Travel_Model_TblPermission();
$SECURITYKEY = $sessionLogin_user->agencyDetails['SecurityKey'];
if (($SECURITYKEY == '369FB021-CF12-4627-AD0A-3C43AADA940A') || ($SECURITYKEY == '7A71DFD3-0E37-48FE-9CBC-EFAA154D0FB7')) {
$checkData = $permissionModel->getModuleDataForAcl($AgencySysId, $UserSysId);
//echo "<pre>";print_r($checkData);exit;
} else {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => GTXAPIURL . 'agency/get-master-permission-user-wise/?agent_id=' . $UserSysId . '&is_staff=1',
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,
'Content-Type: application/json'
),
));
$rightshortcuts = curl_exec($curl);
curl_close($curl);
if ($rightshortcuts == "") {
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->gotoUrl('login/logout');
return;
} else {
$checkData = json_decode($rightshortcuts, true);
}
}
$sessionLogin_user->getAgencyRolePermission = $checkData;
$sessionLogin_user->getAgencyContentPermission = $objRole->GetAgencyContentPermission($AgencySysId, $UserSysId);
$sessionLogin_user->UserRoleTitle = trim($userRoleDesc['RoleTitle']);
$sessionLogin_user->IsManageMember = trim($userRoleDesc['IsAbleToManageMember']);
$sessionLogin_user->IsAdmin = trim($userRoleDesc['IsAdmin']);
$sessionLogin_user->IsSuperAdmin = trim($userRoleDesc['IsSuperAdmin']);
if ($UserSysId == '76') {
$this->_helper->redirector('index', 'buyhotel');
} else {
if ($IsInsurance == 1) {
$this->_helper->redirector('index', 'insurance');
} else {
$this->_redirect('dashboard/agency');
}
}
} else {
$message = "Oops! Your OTP is expired. Please try again";
}
} else {
$message = "Oops! Your OTP is wrong. Please try again";
}
} else {
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->gotoUrl('login/logout');
return;
}
}
$this->view->SENDSMSCONFIG = $IsAllowRandomCodeAccess;
if ($IsAllowRandomCodeAccess == 0) {
$this->view->mobileotp = $getDetails['RandomCode'];
} else {
$this->view->mobileotp = "";
}
$this->view->errorMessage = $message;
$this->view->emailId = Travel_Model_AgencyAuth::getIdentity()->EmailId;
}
public function regenerateOtpAction() {
$this->_helper->layout->disableLayout();
$updateData = new Payment_Model_Checkotp();
$mobile_no = Travel_Model_AgencyAuth::getIdentity()->ContactNo1;
$randomString = $updateData->randomString();
$login_lastfourdigt_mobile_no = substr($mobile_no, -4);
$message = "OTP for CRM access is $randomString do not share it with anyone.\nTRVCRM";
$this->postFields = "";
$this->postFields .= "&method=$this->SMSMETHOD";
$this->postFields .= "&api_key=$this->SMSAPIKEY";
$this->postFields .= "&to=$mobile_no";
$this->postFields .= "&sender=$this->SMSSENDER";
$this->postFields .= "&message=$message";
$this->postFields .= "&format=$this->SMSFORMAT";
$postURL = $this->SMSURL;
$arrSMSStatisticsType = array_keys(unserialize(ARR_SMS_STATISTICS_TYPE));
$arrSMSStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 2, // 1 For Email 2 For SMS
"AgencySysId" => 0,
"AgentSysId" => 0,
"Title" => $message,
"Source" => $arrSMSStatisticsType[0], // 3 for misc
"Status" => '',
"RefSysId" => '',
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
$resultVal = $updateData->sendSmsDetails($postURL, $this->postFields, $arrSMSStatistics);
if (!empty($resultVal)) {
if (isset($resultVal['status']) && $resultVal['status'] == 'OK') {
$currentDate = date('Y-m-d H:i:s');
$dateTime = new DateTime($currentDate);
$dateTime->modify('+2 minutes');
$RandomCodeValidTo = $dateTime->format('Y-m-d H:i:s');
$updatedArray = array(
"LastLoginTime" => $currentDate,
"IsLogInNow" => "1",
"RandomCode" => $randomString,
"RandomCodeValidFrom" => $currentDate,
"RandomCodeValidTo" => $RandomCodeValidTo
);
try {
$where = array('UserSysId =?' => Travel_Model_AgencyAuth::getIdentity()->UserSysId);
$updateData->updateTable("TB_Agency_User", $updatedArray, $where);
$errorMessage = "One Time Password(OTP) has been sent your on mobile ******$login_lastfourdigt_mobile_no, Please enter the same OTP here to login.";
} catch (Zend_Exception $e) {
$errorMessage = $e->getMessage();
}
} else {
$errorMessage = "Oops! Please try again";
}
} else {
$errorMessage = "Oops! Please try again";
}
echo $errorMessage;
exit;
}
public function regenerateOtpforwalletAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isPost()) {
$this->_helper->viewRenderer->setNoRender(true);
$TrxSysId = $this->getRequest()->getParam('TrxSysId');
$reGenerateOTP = $this->getRequest()->getParam('reGenerateOTP');
$updateData = new Payment_Model_Checkotp();
$mobile_no = $updateData->getMobileNumberForSendSms(Travel_Model_AgencyAuth::getIdentity()->UserSysId);
$randomString = $updateData->randomString();
$login_lastfourdigt_mobile_no = substr($mobile_no, -4);
$checkOTP = $this->paymentMdl->getDetailsByUniqueId("TB_Trx", "TrxSysId", $TrxSysId);
$netAmount = $checkOTP['NetAmount'];
$massage = "OTP for GTX Txn is $randomString for Rs.$netAmount Please enter this code to approve the txn. Team HelloGTX";
$this->postFields = "";
$this->postFields .= "&method=$this->SMSMETHOD";
$this->postFields .= "&api_key=$this->SMSAPIKEY";
$this->postFields .= "&to=$mobile_no";
$this->postFields .= "&sender=$this->SMSSENDER";
$this->postFields .= "&message=$massage";
$this->postFields .= "&format=$this->SMSFORMAT";
$postURL = $this->SMSURL;
$arrSMSStatisticsType = array_keys(unserialize(ARR_SMS_STATISTICS_TYPE));
$arrSMSStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 2, // 1 For Email 2 For SMS
"AgencySysId" => 0,
"AgentSysId" => 0,
"Title" => $massage,
"Source" => $arrSMSStatisticsType[0], // 3 for misc
"Status" => '',
"RefSysId" => '',
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
$resultVal = $updateData->sendSmsDetails($postURL, $this->postFields, $arrSMSStatistics);
if (!empty($resultVal)) {
if (isset($resultVal['status']) && $resultVal['status'] == 'OK') {
$currentDate = date('Y-m-d H:i:s');
$dateTime = new DateTime($currentDate);
$dateTime->modify('+2 minutes');
$RandomCodeValidTo = $dateTime->format('Y-m-d H:i:s');
$addData_Trx = array(
"RandomCode" => $randomString,
"RandomCodeValidFrom" => $currentDate,
"RandomCodeValidTo" => $RandomCodeValidTo
);
try {
$whereTrx = array('TrxSysId =?' => $TrxSysId);
$TrxSysId = $this->paymentMdl->updateTable("TB_Trx", $addData_Trx, $whereTrx);
$errorMessage = "One Time Password(OTP) has been sent your on mobile ******$login_lastfourdigt_mobile_no, Please enter the same OTP here to login.";
} catch (Zend_Exception $e) {
$errorMessage = $e->getMessage();
}
} else {
$errorMessage = "Oops! Please try again";
}
} else {
$errorMessage = "Oops! Please try again";
}
echo $errorMessage;
exit;
}
}
public function sentOtpEmail($deviceBasePath, $smtpPort, $smtpUserName, $smtpPassword, $smtpHost, $fromEmail, $fromName, $user_email, $user_firstName, $user_otp_code) {
//Start code for smtp email details
$config_details = array(
'auth' => 'login',
'port' => $smtpPort,
'username' => $smtpUserName,
'password' => $smtpPassword
);
require_once $deviceBasePath . 'library/Zend/Mail.php';
require_once $deviceBasePath . 'library/Zend/Mail/Transport/Smtp.php';
$transport = new Zend_Mail_Transport_Smtp($smtpHost, $config_details);
$to = $user_email;
$user_login_name = ucfirst($user_firstName);
$subject = "IDP OTP One Time Password";
$message = "Hi $user_login_name, <br><br>";
$message .= "IDP User Login Details, For more detail please refer below:<br><br>";
$message .= "Email: $to <br><br>";
$message .= "OTP Password: $user_otp_code <br>";
$message .= "<br><br>";
$message .= "Thanks,<br>";
$message .= "IDP Team";
$mail = new Zend_Mail("utf-8");
$mail->setBodyHtml($message);
$mail->setFrom($fromEmail, $fromName);
$mail->addTo($to, $user_login_name);
//$mail->addBcc($this->ccEmail, $this->ccEmailName); //notice a different email address
$mail->setSubject($subject);
try {
$mail->send($transport);
} catch (Exception $ex) {
print_r($ex, true);
}
}
}