| 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/holidays.tripjack.com/application/controllers/ |
Upload File : |
<?php
/***************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : CustomerController.php
* File Desc. : Customer controller for home page front end
* Created By : Md Sabir <sabir@catpl.co.in>
* Created Date : 06 July 2017
* Updated Date : 06 July 2017
***************************************************************/
class CustomerController extends Zend_Controller_Action
{
protected $objMdl;
protected $tablename;
protected $objHelperGeneral;
protected $per_page_record;
protected $_session;
protected $_sessionSocial;
protected $_sessionSocialFB;
public $customerbookinglistAPIUrl;
protected $objHelperLoginwithGoogle;
// protected $objHelperLoginwithFacebook;
public $contactEmail;
public function init() {
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$BootStrap = $aConfig['bootstrap'];
$this->siteName = $BootStrap['siteName'];
$this->baseUrl = $BootStrap['siteUrl'];
$this->gtxbaseUrl = $BootStrap['gtxBtoBsite'];
$this->contactEmail = $BootStrap['contactEmail'];
$this->gtxagencysysid = $BootStrap['gtxagencysysid']; // get gtxagencysysid from application config
$this->gtxagentsysid = $BootStrap['gtxagentsysid']; // get gtxagentsysid from application config
$this->objMdl = new Admin_Model_CRUD();
$this->_user = new Zend_Session_Namespace('User');
$this->_sessionSocial = new Zend_Session_Namespace('SocialGoogle');
$this->_sessionSocialFB = new Zend_Session_Namespace('SocialFacebook');
$this->tablename = "tb_tbb2c_packages_master";
$this->tablenameTes = "tbl_testimonials";
$this->hotelTypeArr = ['Standard','Deluxe','Luxury'];
$this->objHelperGeneral = $this->_helper->General;
// $this->objHelperLoginwithGoogle = $this->_helper->LoginwithGoogle;
// $this->objHelperLoginwithFacebook = $this->_helper->LoginwithFacebook;
$this->per_page_record = 10;
$this->_resetsession = new Zend_Session_Namespace('UserResetEmail');
$this->agentauthlogin = API_AGENT_AUTH_LOGIN; // from constant file
$this->customerauthsignup = API_CUSTOMER_AUTH_SIGNUP; // from constant file
$this->agentprofileAPIUrl = API_AGENT_PROFILE; // from constant file
$this->customerprofilebyemailMobileAPIUrl = API_CUSTOMER_PROFILE_BYEMAIL_MOBILE; // from constant file
$this->customerchangepasswordAPIUrl = API_CUSTOMER_CHANGEPASSWORD; // from constant file
$this->agentforgotpasswordAPIUrl = API_AGENT_FORGOTPASSWORD; // from constant file
$this->agentupdateforgotpasswordAPIUrl = API_AGENT_UPDATE_FORGOTPASSWORD; // from constant file
$this->agentupdateprofilePIUrl = API_AGENT_UPDATE_PROFILE; // from constant file
$this->getcitylistAPIUrl = API_CUSTOMER_CITYLIST; // from constant file
$this->salutation = ARR_SALUTION; // from constant file
}
public function indexAction()
{
$this->_helper->layout->setLayout('login-layout');
$this->view->baseUrl = $this->baseUrl;
// die('index');
}
public function getcitylistAction(){
if ($this->getRequest()->isPost()) {
$this->checklogin();
$param = $this->getRequest()->getParams();
$apiData = array(
"country" => $param['country']
);
try {
$curl = curl_init($this->getcitylistAPIUrl);
curl_setopt($curl, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
//echo '<pre>';print_r($response);exit;
curl_close($curl);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$ResponseDecode = Zend_Json::decode($response, true);
$reply = ['status' => true, 'message' => 'Getting city list please wait...','countryId'=>$ResponseDecode];
echo Zend_Json::encode($reply);exit;
}
}
/**
* forgotpassword() method is used to B2B customer can forgot password
* @param Null
* @return Array
*/
public function checkresetlinkAction(){
if($_SESSION['User']['data'])
{
$this->_redirect('index/dashboard');
}
$param = $this->getRequest()->getParams();
// echo "<pre>";print_r($param);die;
$datetime = date('d-m-y h:i:s');
$seconds = strtotime($datetime) - ($param['CTR']);
$days = floor($seconds / 86400);
$hours = floor(($seconds - ($days * 86400)) / 3600);
$minutes = floor(($seconds - ($days * 86400) - ($hours * 3600))/60);
if($minutes <= 10){
$eid = base64_decode($param['eid']);
$ud = base64_decode($param['ud']);
$token = ($param['token']);
$mag = ($param['mag']);
$SubmitData = array(
"eid" => $eid,
"ud" => $ud,
"mag" => $mag,
"token" => $token,
"CTR" => $param['CTR']
);
$this->_resetsession->resetpass = $SubmitData;
$this->_redirect('customer/resetpassword');
}else{
die('Oops your reset password link is expired!! try again.');
}
}
public function resetpasswordAction(){
if(isset($_SESSION['UserResetEmail']['resetpass'])){
$datetime = date('d-m-y h:i:s');
$seconds = strtotime($datetime) - ($_SESSION['UserResetEmail']['resetpass']['CTR']);
$days = floor($seconds / 86400);
$hours = floor(($seconds - ($days * 86400)) / 3600);
$minutes = floor(($seconds - ($days * 86400) - ($hours * 3600))/60);
if($minutes <= 10){
$this->view->data = $_SESSION['UserResetEmail']['resetpass'];
}else{
$this->_redirect('customer/unsetresetdata');
}
if($this->getRequest()->isPost()){
$param = $this->getRequest()->getParams();
$apiData = array(
"npass" => $param['npass'],
"copass" => $param['copass'],
"email" => $_SESSION['UserResetEmail']['resetpass']['eid'],
"UserSysId" => $_SESSION['UserResetEmail']['resetpass']['ud'],
"MasterAgencySysId" => $_SESSION['UserResetEmail']['resetpass']['mag']
);
try {
$curl = curl_init($this->agentupdateforgotpasswordAPIUrl);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
if($response == 4){
$reply = ['status' => false, 'message' => 'All field required!!'];
echo Zend_Json::encode($reply);exit;
}elseif($response == 3){
$reply = ['status' => false, 'message' => 'Confirm password does not match with new password'];
echo Zend_Json::encode($reply);exit;
}elseif($response == 2){
$reply = ['status' => false, 'message' => 'Password update not response!!'];
echo Zend_Json::encode($reply);exit;
}elseif($response == 1){
$reply = ['status' => true, 'message' => 'Password has been reset successfully. Now Login and continue.'];
echo Zend_Json::encode($reply);exit;
}else{
$reply = ['status' => false, 'message' => 'Oops there is no response'];
echo Zend_Json::encode($reply);exit;
}
//print_r($response);die;
}
}else{
echo('Oops! There seems to be some problem in processing your request!');exit;
}
//print_r($_SESSION['UserResetEmail']['resetpass']);
//exit;
//print_r($param);die;
}
public function unsetresetdataAction()
{
$storage = new Zend_Session_Namespace('UserResetEmail');
$storage->unsetAll();
$this->_redirect('index/index');
}
/**
* checklogin() method is used to check admin logedin or not
* @param Null
* @return Array
*/
public function checklogin()
{
/*************** check admin identity ************/
if(!$_SESSION['User']['data'])
{
$this->_redirect('/');
}
}
/******Google authentication code by sibo*****/
public function loginwithGoogleAction()
{
$Loginwithgoogle = $this->objHelperLoginwithGoogle->Loginwithgoogle();
//print_r($Loginwithgoogle);die('dd');
$this->_redirect($Loginwithgoogle);
}
public function googleAuthenticationAction()
{
$userData = $this->objHelperLoginwithGoogle->redirectgoogle();
$apiData = array(
'id' => $userData['id'],
'email' => $userData['email'],
'gender' => $userData['gender'],
'picture' => $userData['picture'],
'familyName' => $userData['familyName'],
'givenName' => $userData['givenName'],
);
$this->_sessionSocial->sessionSocial = $apiData;
$this->_redirect('customer/login');
}
public function loginAction(){
if(isset($this->_sessionSocial->sessionSocial) && !empty($this->_sessionSocial->sessionSocial)){
// $storage = new Zend_Session_Namespace('Social');
// $storage->unsetAll();
// $this->_redirect('/');
$apiData = array(
'fname' => $this->_sessionSocial->sessionSocial['givenName'],
'lname' => $this->_sessionSocial->sessionSocial['familyName'],
'customerEmail' => $this->_sessionSocial->sessionSocial['email'],
'countrycode' => '',
'mobilenumber' => '',
'source' => '',
'password' => date('d-m-y h:s:i'),
'AgencySysId' => $this->gtxagencysysid,
'AgentSysId' => $this->gtxagentsysid
);
$this->view->apiData = $apiData;
//echo '<pre>';print_r($apiData);die;
if($this->getRequest()->isPost()){
$param = $this->getRequest()->getParams();
$apiDataLogin = array(
'fname' => $this->_sessionSocial->sessionSocial['givenName'],
'lname' => $this->_sessionSocial->sessionSocial['familyName'],
'customerEmail' => $this->_sessionSocial->sessionSocial['email'],
'countrycode' => isset($param['ountryCode'])?$param['ountryCode']:'',
'mobilenumber' => isset($param['mobilenumber'])?$param['mobilenumber']:'',
'source' => '',
'password' => date('d-m-y h:s:i'),
'AgencySysId' => $this->gtxagencysysid,
'AgentSysId' => $this->gtxagentsysid
);
try {
$curl_p = curl_init($this->customerauthsignup);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($apiDataLogin));
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);
curl_close($curl_p);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$response_decode = Zend_Json::decode($response, true);
//echo '<pre>';print_r($response_decode);die('ff');
if($response_decode['CustomerSysId'] == '' || empty($response_decode['CustomerSysId'])){
$datas = array(
'CustomerEmail'=> $response_decode['customerEmail'],
'CustomerMobile'=> $response_decode['mobilenumber'],
'AgencySysId'=> $this->gtxagencysysid,
);
try {
$curl_p = curl_init($this->customerprofilebyemailMobileAPIUrl);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($datas));
curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
$response_user = curl_exec($curl_p);
curl_close($curl_p);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$users_decode = Zend_Json::decode($response_user, true);
if($users_decode['status']=='1'){
$Login_Data = array(
'userName' => $users_decode['profile']['EmailId'],
'userPassword' => $users_decode['profile']['Password'],
'AgencySysId' => $this->gtxagencysysid
);
}
}else{
//echo '<pre>';print_r($response_decode);die('ff');
if($response_decode['status']=='success'){
$Login_Data = array(
'userName' => $response_decode['customerEmail'],
'userPassword' => $response_decode['_token'],
'AgencySysId' => $this->gtxagencysysid
);
}
}
try {
$curl_p = curl_init($this->customerauthloginSocial);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($Login_Data));
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);
curl_close($curl_p);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$response_login_decode = Zend_Json::decode($response, true);
if($response_login_decode == 2){
$reply = ['status' => false, 'message' => 'Oops! Your Account is not activate.if urgent Please call to GTX customer care'];
echo Zend_Json::encode($reply);exit;
}else{
echo Zend_Json::encode($response_login_decode);exit;
}
}
//echo '<pre>';print_r($response_decode);die('ff');
}else{
echo 'Access Denied! <a href="/">Continue</a>';
exit;
}
}
public function loginfacebookAction(){
if(isset($this->_sessionSocialFB->_sessionSocialFB) && !empty($this->_sessionSocialFB->_sessionSocialFB)){
// $storage = new Zend_Session_Namespace('Social');
// $storage->unsetAll();
// $this->_redirect('/');
$apiData = array(
'fname' => $this->_sessionSocialFB->_sessionSocialFB['givenName'],
'lname' => $this->_sessionSocialFB->_sessionSocialFB['familyName'],
'customerEmail' => $this->_sessionSocialFB->_sessionSocialFB['email'],
'countrycode' => '',
'mobilenumber' => '',
'source' => '',
'password' => date('d-m-y h:s:i'),
'AgencySysId' => $this->gtxagencysysid,
'AgentSysId' => $this->gtxagentsysid
);
$this->view->apiData = $apiData;
//echo '<pre>';print_r($apiData);die;
if($this->getRequest()->isPost()){
$param = $this->getRequest()->getParams();
$apiDataLogin = array(
'fname' => $this->_sessionSocialFB->_sessionSocialFB['givenName'],
'lname' => $this->_sessionSocialFB->_sessionSocialFB['familyName'],
'customerEmail' => $this->_sessionSocialFB->_sessionSocialFB['email'],
'countrycode' => isset($param['ountryCode'])?$param['ountryCode']:'',
'mobilenumber' => isset($param['mobilenumber'])?$param['mobilenumber']:'',
'source' => '',
'password' => date('d-m-y h:s:i'),
'AgencySysId' => $this->gtxagencysysid,
'AgentSysId' => $this->gtxagentsysid
);
try {
$curl_p = curl_init($this->customerauthsignup);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($apiDataLogin));
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);
curl_close($curl_p);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$response_decode = Zend_Json::decode($response, true);
//echo '<pre>';print_r($response_decode);die('ff');
if($response_decode['CustomerSysId'] == '' || empty($response_decode['CustomerSysId'])){
$datas = array(
'CustomerEmail'=> $response_decode['customerEmail'],
'CustomerMobile'=> $response_decode['mobilenumber'],
'AgencySysId'=> $this->gtxagencysysid,
);
try {
$curl_p = curl_init($this->customerprofilebyemailMobileAPIUrl);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($datas));
curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
$response_user = curl_exec($curl_p);
curl_close($curl_p);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$users_decode = Zend_Json::decode($response_user, true);
if($users_decode['status']=='1'){
$Login_Data = array(
'userName' => $users_decode['profile']['EmailId'],
'userPassword' => $users_decode['profile']['Password'],
'AgencySysId' => $this->gtxagencysysid
);
}
}else{
//echo '<pre>';print_r($response_decode);die('ff');
if($response_decode['status']=='success'){
$Login_Data = array(
'userName' => $response_decode['customerEmail'],
'userPassword' => $response_decode['_token'],
'AgencySysId' => $this->gtxagencysysid
);
}
}
try {
$curl_p = curl_init($this->customerauthloginSocial);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($Login_Data));
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);
curl_close($curl_p);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$response_login_decode = Zend_Json::decode($response, true);
if($response_login_decode == 2){
$reply = ['status' => false, 'message' => 'Oops! Your Account is not activate.if urgent Please call to GTX customer care'];
echo Zend_Json::encode($reply);exit;
}else{
echo Zend_Json::encode($response_login_decode);exit;
}
}
//echo '<pre>';print_r($response_decode);die('ff');
}else{
die('Access Denied');
}
}
/*******Login with Facebook*********/
// public function loginwithFacebookAction()
// {
// $Loginwithgoogle = $this->objHelperLoginwithFacebook->Loginwithfacebook();
// print_r($Loginwithgoogle);die('dd');
// $this->_redirect($Loginwithgoogle);
// }
// public function loginwithFacebookAction()
// {
// $Loginwithgoogle = $this->objHelperLoginwithFacebook->Loginwithfacebook();
// print_r($Loginwithgoogle);die('dd');
// $this->_redirect($Loginwithgoogle);
// }
public function facebookAuthenticationAction(){
if($this->getRequest()->isPost()){
$param = $this->getRequest()->getParams();
$apiDatalogin = array(
'id' => $param['fbid'],
'email' => $param['femail'],
'picture' => $param['profilephoto'],
'familyName' => $param['flast_name'],
'givenName' => $param['ffirst_name'],
);
$this->_sessionSocialFB->_sessionSocialFB = $apiDatalogin;
$this->_redirect('customer/loginfacebook');
echo '<pre>';print_r( $apiDatalogin);die('dd');
}
// if(isset($_SESSION['Fbdata']) && !empty($_SESSION['Fbdata'])){
// $apiData = array(
// 'id' => $_SESSION['Fbdata']['fbid'],
// 'email' => $_SESSION['Fbdata']['femail'],
// 'picture' => $_SESSION['Fbdata']['profilephoto'],
// 'familyName' => $_SESSION['Fbdata']['flast_name'],
// 'givenName' => $_SESSION['Fbdata']['ffirst_name'],
//
// );
// //$this->_redirect('customer/login');
// //echo '<pre>';print_r( $apiData);die('dd');
// $this->sessionSocial->sessionSocial = $apiData;
// $this->_redirect('customer/login');
// }else{
// die('Access Denied');
// }
}
}