403Webshell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2bzend/application/controllers/LoginController.php
<?php

class LoginController extends Catabatic_ValidateCustomer {

    public $siteUrl;
    public $smtpUserName;
    public $smtpPassword;
    public $smtpPort;
    public $smtpHost;
    public $fromEmail;
    public $fromName;
    public $SMSURL;
    public $SMSMETHOD;
    public $SMSAPIKEY;
    public $SMSSENDER;
    public $SMSFORMAT;
    public $_resetsession;
    public $_captcha;

    public function init() {
        parent::init();
        $aConfig = $this->getInvokeArg('bootstrap')->getOptions();
        $this->siteUrl = $aConfig['bootstrap']['siteUrl'];
        $this->smtpUserName = $aConfig['smtpUserName'];
        $this->smtpPassword = $aConfig['smtpPassword'];
        $this->smtpPort = $aConfig['smtpPort'];
        $this->smtpHost = $aConfig['smtpHost'];
        $this->fromEmail = $aConfig['fromEmail'];
        $this->fromName = $aConfig['fromName'];
        $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->_resetsession = new Zend_Session_Namespace('UserResetEmail');
        $this->_captcha = new Zend_Session_Namespace('Captcha');
    }

    public function indexAction() {
        $IsActive = isset(Travel_Model_AgencyAuth::getIdentity()->IsActive) ? Travel_Model_AgencyAuth::getIdentity()->IsActive : "0";
        $checkOtp = isset(Travel_Model_AgencyAuth::getIdentity()->checkOtp) ? Travel_Model_AgencyAuth::getIdentity()->checkOtp : '0';
        if (($IsActive == '1') && ($checkOtp == '1')) {
            $IsInsurance = Travel_Model_AgencyAuth::getIdentity()->IsInsurance;
            if ($IsInsurance == 1) {
                $this->_helper->redirector('index', 'insurance');
            } else {
                $this->_redirect('dashboard/agency');
            }
        } else {
            $this->_redirect('login/logout');
        }
        exit;
    }

    public function loginAction() {
        $IsAgencySysId = Catabatic_Helper::getIsAgencySysId();
        $getAgencyData = array();
        if ($IsAgencySysId != FALSE) {
            $getAgencySysId = Catabatic_Helper::getAgencySysId();
            $modelAgency = new Travel_Model_TblAgency();
            $getAgencyData = $modelAgency->getAgencyData($getAgencySysId);
        }
        $this->view->getAgencyMasterData = $getAgencyData;
        $IsActive = isset(Travel_Model_AgencyAuth::getIdentity()->IsActive) ? Travel_Model_AgencyAuth::getIdentity()->IsActive : "0";
        $checkOtp = isset(Travel_Model_AgencyAuth::getIdentity()->checkOtp) ? Travel_Model_AgencyAuth::getIdentity()->checkOtp : '0';
        if (($IsActive == '1') && ($checkOtp == '1')) {
            $IsInsurance = Travel_Model_AgencyAuth::getIdentity()->IsInsurance;
            if ($IsInsurance == 1) {
                $this->_helper->redirector('index', 'insurance');
            } else {
                $this->_redirect('dashboard/agency');
            }
        }
        $encryptData = (null !== $this->getRequest()->getParam('encId')) ? trim($this->getRequest()->getParam('encId')) : '';
        $this->view->encryptData = $encryptData;
        $this->_helper->layout->setLayout('layout-signup');
        $errorMessage = "";
        if ($this->getRequest()->isPost()) {
            $userName = $this->getRequest()->getParam('userName');
            $userPassword = $this->getRequest()->getParam('userPassword');
            $userrole = $this->getRequest()->getParam('userrole', 0);
            $decryptData = (NULL !== $this->getRequest()->getParam('encryptData')) ? base64_decode($this->getRequest()->getParam('encryptData')) : '';
            $updateData = new Payment_Model_Checkotp();
            $userPassword = md5($userPassword);
            $getIsAgencySysId = Catabatic_Helper::getIsAgencySysId();
            if ($getIsAgencySysId == False) {
                $auth = new Travel_Model_AgencyAuth($userName, $userPassword, $userrole);
            } else {
                $getAgencySysIdFromIni = Catabatic_Helper::getAgencySysId();
                $auth = new Travel_Model_AgencyAuth($userName, $userPassword, $getAgencySysIdFromIni, $userrole);
            }
            $result = $auth->authenticate();
            if (!$result) {
                $errorMessage = 'Invalid login credentials';
            } else {
                $IsMarkForDel = Travel_Model_AgencyAuth::getIdentity()->IsMarkForDel;
                $UserSysIdExist = Travel_Model_AgencyAuth::getIdentity()->UserSysId;
                $AgencySysIdExist = Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
                $ip = $this->getRealIpAddr();
                //$details = file_get_contents("http://ipinfo.io/{$ip}/json");
                $loginData = array(
                    'AgencySysId' => $AgencySysIdExist,
                    'AgentSysId' => $UserSysIdExist,
                    'Createdate' => date('Y-m-d H:i:s'),
                    'IPAddress' => $ip,
                    'LogString' => ''
                );
                $IsB2BAgent = Travel_Model_AgencyAuth::getIdentity()->IsB2BAgent;
                if ($decryptData == $UserSysIdExist) {
                    $IsB2BAgent = 0;
                }
                if (isset($IsMarkForDel) && $IsMarkForDel == 0) {
                    $IsUserActive = Travel_Model_AgencyAuth::getIdentity()->IsActive;
                    $IsUserApproved = Travel_Model_AgencyAuth::getIdentity()->IsApproved;
                    $IsAgencySysId = Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
                    if ($getIsAgencySysId == True) {
                        $tblAgencyModel = new Travel_Model_TblAgency();
                        $getAllAgencyIds = $tblAgencyModel->getb2bAgencyIdsWithMaster($IsAgencySysId);
                    } else {
                        $getAllAgencyIds = array(0 => $IsAgencySysId);
                    }
                    if ($getIsAgencySysId == False || in_array($IsAgencySysId, $getAllAgencyIds)) {
                        if (isset($IsUserActive) && $IsUserActive == 1 && isset($IsUserApproved) && $IsUserApproved == 1) {
                            $IsUserActive = $IsUserActive;
                            $IsUserApproved = $IsUserApproved;
                        }
                        if (isset($IsAgencySysId)) {
                            $objAgency = new Travel_Model_AgencyAuth();
                            $IsAgencyActive = $objAgency->select_query($IsAgencySysId);
                            foreach ($IsAgencyActive as $value) {
                                $IsAgencyActive = $value['IsActive'];
                                $IsAgencyApproved = $value['IsApproved'];
                                $IsActiveSubscription = $value['IsActiveSubscription'];
                                $IsSMSApi = (int) $value['IsSMSApi'];
                            }
                        }

                        if (isset($IsActiveSubscription) && $IsActiveSubscription == 1) {
                            if (isset($IsUserActive) && $IsUserActive == 1 && isset($IsUserApproved) && $IsUserApproved == 1 && isset($IsAgencyActive) && $IsAgencyActive == 1 && isset($IsAgencyApproved) && $IsAgencyApproved == 1) {
                                $mobile_no = Travel_Model_AgencyAuth::getIdentity()->ContactNo1;
                                $EmailId = Travel_Model_AgencyAuth::getIdentity()->EmailId;

                                $randomString = $updateData->randomString();
                                $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;

                                $IsAllowRandomCodeAccess = isset(Travel_Model_AgencyAuth::getIdentity()->IsAllowRandomCodeAccess) ? Travel_Model_AgencyAuth::getIdentity()->IsAllowRandomCodeAccess : "0";
                                if ($IsAllowRandomCodeAccess == 0) {
                                    $resultVal = array("status" => 'OK');
                                } else {
                                    $arrSMSStatisticsType = array_keys(unserialize(ARR_SMS_STATISTICS_TYPE));
                                    $arrSMSStatistics = array(
                                        "TPSysId" => 0,
                                        "TypeSysId" => 2, // 1 For Email 2 For SMS
                                        "AgencySysId" => (int) $IsAgencySysId,
                                        "AgentSysId" => (int) $UserSysIdExist,
                                        "Title" => $message,
                                        "Source" => $arrSMSStatisticsType[0], // 3 For Misc
                                        "Status" => 0,
                                        "RefSysId" => "",
                                        "RefSysStatus" => "",
                                        "CreateDate" => date('Y-m-d H:s:i')
                                    );

                                    $resultVal = $updateData->sendSmsDetails($postURL, $this->postFields, $arrSMSStatistics, $IsSMSApi);

                                    $objAgent = new Travel_Model_TblAgency();
                                    $getAgencyDataById = $objAgent->getAgencyDataById(Travel_Model_AgencyAuth::getIdentity()->AgencySysId);

                                    $DisplayName = (isset($getAgencyDataById['DisplayName']) && !empty(trim($getAgencyDataById['DisplayName']))) ? trim($getAgencyDataById['DisplayName']) : trim($getAgencyDataById['Title']);
                                    $PrimaryEmail = (isset($getAgencyDataById['PrimaryEmail']) && !empty(trim($getAgencyDataById['PrimaryEmail']))) ? trim($getAgencyDataById['PrimaryEmail']) : trim($getAgencyDataById['EmailIdForCustomer']);
                                    $subject = "OTP for CRM access";
                                    $html = new Zend_View();
                                    $html->setScriptPath(APPLICATION_PATH . '/views/emails/');
                                    $html->assign(array('randomString' => $randomString, 'agencyDetails' => $getAgencyDataById));
                                    $bodyText = $html->render('OTPEmailMaster.phtml');

                                    $emailData = array('fromEmail' => $PrimaryEmail, 'fromName' => $DisplayName, 'subject' => $subject, 'to' => array($EmailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
                                    $arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
                                    $arrEmailStatistics = array(
                                        "TPSysId" => 0,
                                        "TypeSysId" => 1, // 1 For Email 2 For SMS
                                        "AgencySysId" => (int) $IsAgencySysId,
                                        "AgentSysId" => (int) $UserSysIdExist,
                                        "Title" => $message,
                                        "Source" => $arrEmailStatisticsType[2], // 6 For Misc
                                        "Status" => 0,
                                        "RefSysId" => "",
                                        "RefSysStatus" => "",
                                        "CreateDate" => date('Y-m-d H:s:i')
                                    );
                                    $resultmail = $this->mailSentByElastice($emailData, $arrEmailStatistics);
                                }
                                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(
                                            "CanRefreshDashboard" => true,
                                            "LastActiveOn" => $currentDate,
                                            "LastLoginTime" => $currentDate,
                                            "IsLogInNow" => "1",
                                            "RandomCode" => $randomString,
                                            "RandomCodeValidFrom" => $currentDate,
                                            "RandomCodeValidTo" => $RandomCodeValidTo
                                        );
                                        try {
                                            $mdlAuth = new Travel_Model_AgencyAuth();
                                            $mdlAuth->loginlog($loginData);
                                            $where = array('UserSysId =?' => Travel_Model_AgencyAuth::getIdentity()->UserSysId);
                                            $updateData->updateTable("TB_Agency_User", $updatedArray, $where);
                                            $this->_helper->redirector('index', 'checkotp');
                                        } catch (Zend_Exception $e) {
                                            $errorMessage = $e->getMessage();
                                        }
                                    } else {
                                        if ($resultVal['status'] == 'Display') {
                                            $errorMessage = $resultVal['Message'];
                                        } else {
                                            $errorMessage = "Oops! Please try again";
                                        }
                                    }
                                } else {
                                    $errorMessage = "Oops! Please try again";
                                }
                            } else {
                                $errorMessage = "Oops! Your Account is not activate.if urgent Please call to GTX customer care";
                            }
                        } else {
                            $errorMessage = "Oops! Your Subscription Plan is expired. if urgent Please call to GTX customer care";
                        }
                    } else {
                        $errorMessage = "Oops! Your Account is not authorized";
                    }
                } else {
                    if ($IsB2BAgent == 1) {
                        $errorMessage = "Oops! Your Account is not authorized";
                    } else {
                        $errorMessage = "Oops! Your Account is suspended.If urgent Please call to GTX customer care";
                    }
                }
            }
        }
        $this->view->type = $this->getRequest()->getParam('type', null);
        $this->view->errorMessage = $errorMessage;
        $this->view->messages = $this->_helper->flashMessenger->getMessages();
    }

    public function logoutAction() {
        $updatedArray = array(
            "IsLogInNow" => "0"
        );
        $updateData = new Payment_Model_Checkotp();
        try {
            $where = array('UserSysId =?' => Travel_Model_AgencyAuth::getIdentity()->UserSysId);
            $updateData->updateTable("TB_Agency_User", $updatedArray, $where);
        } catch (Zend_Exception $e) {
            $errorMessage = $e->getMessage();
        }
        Travel_Model_AgencyAuth::destroy();
        Zend_Session::destroy();
        $this->_redirect('/login/login');
    }

    public function forgotpasswordAction() {

        if ($this->getRequest()->isXmlHttpRequest()) {
            $captcha = $this->getRequest()->getParam('captcha');
            if (strtolower($captcha) != $this->_captcha->sessionc['captcha']) {
                echo 3;
                exit;
            } else {
                $emailId = $this->getRequest()->getParam('emailId');
                $userrole = $this->getRequest()->getParam('userrole', 0);
                $objUser = new Travel_Model_TblUser();
                $getIsAgencySysId = Catabatic_Helper::getIsAgencySysId();
                $getMetaTitle = "helloGTX";
                if ($getIsAgencySysId == False) {
                    $getDataArr = $objUser->getAgencyUserDetail($emailId, $userrole);
                } else {
                    $getAgencySysIdFromIni = Catabatic_Helper::getAgencySysId();
                    $getMetaTitle = $this->fromName;
                    $getDataArr = $objUser->getAgencyUserDetail($emailId, $userrole, $getAgencySysIdFromIni);
                }
                if($AgencySysId == 136865){
                    $getMetaTitle = "Zourney.in";
                }
                if (count($getDataArr) == 0) {
                    echo 5;
                    exit;
                }
                $oRandStrPass = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->generateRandomString(5);
                $url = $this->siteUrl . "login";
                $params = array('agentName' => ucfirst($getDataArr['FirstName']), 'emailId' => $emailId, 'url' => $url, 'password' => $oRandStrPass, 'forgot' => 1);
                $name = ucfirst($getDataArr['FirstName']);
                $datetime = date('d-m-y h:i:s');
                $time_str = strtotime($datetime);
                $AgencySysId = trim($getDataArr['AgencySysId']);
                $token = md5($getDataArr['UserSysId']);
                $UserSysId = trim($getDataArr['UserSysId']);
                $urole = $getDataArr['UserRole'];
                $reseturlclick = $this->siteUrl . "login/checkresetlink?token=$token&ag=$AgencySysId&uid=$UserSysId&CTR=$time_str&urole=$urole";
                $subject = "Password Change Request";
                $bodyText = "Hello $name<br><br>";
                $bodyText .= "Greetings from $getMetaTitle team.<br><br>";
                $bodyText .= "It is our pleasure to fulfill your request for new password.<br><br>";
                $bodyText .= "To change your account password at $getMetaTitle please click this link or copy and paste the following link into your browser. This link expire within 10 minutes: <br><br>";
                $bodyText .= " <a href='$reseturlclick'>Click here to reset your password</a> <br><br><br>";
                $bodyText .= "Thank you for customer with us.<br><br>";
                $bodyText .= "$getMetaTitle Team.";
                if ($AgencySysId == 136865) {
                    $emailData = array('fromEmail' => 'sk@zourney.in', 'fromName' => 'Zourney.in', 'subject' => $subject, 'to' => array($emailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
                }else if ($AgencySysId == 14378) {
                    $emailData = array('fromEmail' => 'dmcuae@arabianjourneys.com', 'fromName' => 'Arabian Journeys', 'subject' => $subject, 'to' => array($emailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
                } else if ($AgencySysId == 33164) {
                    $emailData = array('fromEmail' => "ashok@ashoktravelworld.com", 'fromName' => 'Ashok Travel World', 'subject' => $subject, 'to' => array($emailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
                } else {
                    $emailData = array('fromEmail' => $this->fromEmail, 'fromName' => $this->fromName, 'subject' => $subject, 'to' => array($emailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
                }
                try {
                    $arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
                    if ($userrole == 2 && $getIsAgencySysId == True) {
                        $getDataArr['AgencySysId'] = $getAgencySysIdFromIni;
                    }
                    $arrEmailStatistics = array(
                        "TPSysId" => 0,
                        "TypeSysId" => 1, // 1 For Email 2 For SMS
                        "AgencySysId" => $getDataArr['AgencySysId'],
                        "AgentSysId" => $getDataArr['UserSysId'],
                        "Title" => '',
                        "Source" => $arrEmailStatisticsType[2], // 6 For Misc
                        "Status" => 0,
                        "RefSysId" => "",
                        "RefSysStatus" => "",
                        "CreateDate" => date('Y-m-d H:s:i')
                    );
                    $result = $this->mailSentByElastice($emailData, $arrEmailStatistics);
                    echo 1;
                    exit;
                } catch (Exception $err) {
                    echo 4;
                    exit;
                }
            }
        } else {
            $this->_captcha->sessionc = array('captcha' => rand(10000, 99999));
            $this->view->captcha = $this->_captcha->sessionc;
            $IsAgencySysId = Catabatic_Helper::getIsAgencySysId();
            $getAgencyData = array();
            if ($IsAgencySysId != FALSE) {
                $getAgencySysId = Catabatic_Helper::getAgencySysId();
                $modelAgency = new Travel_Model_TblAgency();
                $getAgencyData = $modelAgency->getAgencyData($getAgencySysId);
//echo "<pre>";print_r($getAgencyData);exit;
            }
            $this->view->getAgencyMasterData = $getAgencyData;
            $this->_helper->layout->setLayout('layout-signup');
        }
    }

    public function forgotpasswordMobileAction() {
        $data['status'] = false;
        $data['message'] = '';
        if ($this->getRequest()->isPost()) {
            $emailId = $this->getRequest()->getParam('emailId');
            $objUser = new Travel_Model_TblUser();
            $getDataArr = $objUser->getAgencyUserDetail($emailId);
            if (count($getDataArr) == 0) {
                $data['status'] = false;
                $data['message'] = "Please check Email ID";
            }
            $oRandStrPass = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->generateRandomString(5);
            $isUpdated = $objUser->updateChangePassword($getDataArr['UserRole'], $getDataArr['UserSysId'], $oRandStrPass);
            if ($isUpdated == 1) {
                $url = $this->siteUrl . "login";
                $params = array('agentName' => ucfirst($getDataArr['FirstName']), 'emailId' => $emailId, 'url' => $url, 'password' => $oRandStrPass, 'forgot' => 1);
                $html = new Zend_View();
                $html->setScriptPath(APPLICATION_PATH . '/views/emails/');
                $html->assign($params);
                $bodyText = $html->render('agent_login.phtml');
                $emailData = array('fromEmail' => $this->fromEmail, 'fromName' => $this->fromName, 'subject' => 'Reset Password Details', 'to' => array($emailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
                try {
                    $arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
                    $arrEmailStatistics = array(
                        "TPSysId" => 0,
                        "TypeSysId" => 1, // 1 For Email 2 For SMS
                        "AgencySysId" => $getDataArr['AgencySysId'],
                        "AgentSysId" => $getDataArr['UserSysId'],
                        "Title" => '',
                        "Source" => $arrEmailStatisticsType[2], // 6 For Misc
                        "Status" => 0,
                        "RefSysId" => "",
                        "RefSysStatus" => "",
                        "CreateDate" => date('Y-m-d H:s:i')
                    );
                    $this->mailSentByElastice($emailData, $arrEmailStatistics);
                    $data['status'] = true;
                    $data['message'] = "";
                } catch (Exception $err) {
                    $data['status'] = false;
                    $data['message'] = $err->getMessage();
                }
            } else {
                $data['status'] = false;
                $data['message'] = "Password not updated";
            }
        } else {
            $data['status'] = false;
            $data['message'] = "Please use post method";
        }
        echo json_encode($data);
        exit;
    }

    public function checkLoginForMobileUserAction() {
        $this->view->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        $requestPerameter = $this->getRequest()->getPost();
        $headers = getallheaders();
        $returnResponse = array(
            "status" => false,
            "errorMessage" => 'Please check and Username Or Password'
        );
        if (!empty($headers)) {
            $apiKey = isset($headers['securitykey']) ? trim($headers['securitykey']) : false;
            if (!empty($requestPerameter) && ($apiKey == 'F38C55F4-5771-4EED-AAB2-D1CE094AEB4E')) {
                $userName = $this->getRequest()->getPost('userName', null);
                $userPassword = $this->getRequest()->getPost('userPassword', null);
                if ($userName && $userPassword) {
                    $userPassword = md5($userPassword);
                    $auth = new Travel_Model_AgencyAuth($userName, $userPassword);
                    $result = $auth->authenticate();
                    if (!$result) {
                        $returnResponse = array(
                            "status" => false,
                            "errorMessage" => 'Please check and Username Or Password'
                        );
                    } else {
                        $IsMarkForDel = Travel_Model_AgencyAuth::getIdentity()->IsMarkForDel;
                        $IsB2BAgent = Travel_Model_AgencyAuth::getIdentity()->IsB2BAgent;
                        $UserSysId = Travel_Model_AgencyAuth::getIdentity()->UserSysId;
                        $AgencySysId = Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
                        $IsActive = Travel_Model_AgencyAuth::getIdentity()->IsActive;
                        if (isset($IsMarkForDel) && $IsMarkForDel == 0 && $IsB2BAgent == 0 && $IsActive == 1) {
                            $objAgency = new Travel_Model_TblAgency();
                            $arrAgentDetail = $objAgency->validateAgent($UserSysId, $AgencySysId);
                            $permissionModel = new Travel_Model_TblPermission();
                            $checkData = $permissionModel->getModuleDataForAclMobile($AgencySysId, $UserSysId, 1);
                            $returnResponse = array(
                                "status" => true,
                                "errorMessage" => '',
                                "data" => array(
                                    "FirstName" => trim($arrAgentDetail[0]['FirstName']),
                                    "AgencySysId" => $AgencySysId,
                                    "UserSysId" => $UserSysId,
                                    "SecurityKey" => trim($arrAgentDetail[0]['SecurityKey']),
                                    "LastName" => trim($arrAgentDetail[0]['LastName']),
                                    "Logo" => trim($arrAgentDetail[0]['Logo']),
                                    "UserRole" => ($arrAgentDetail[0]['UserRole']),
                                    "MenuArr" => $checkData
                                )
                            );
                        }
                    }
                }
            }
        }
        echo json_encode($returnResponse);
        exit;
    }

    public function loginMobileAction() {
        $keyVector = 'F38C55F4-5771-4EED-AAB2-D1CE094A';
        $ivVector = 'F38C55F4-5771-4E';
        $autosignup = $this->getRequest()->getParam('autosignin', null);
        if ($autosignup) {
            $modelEn = new Travel_Model_Encrytion(base64_decode($autosignup), $keyVector, $ivVector);
            $encodeData = json_decode($modelEn->decrypt(), true);
            $errorMessage = "";
            $userName = isset($encodeData['userName']) ? $encodeData['userName'] : null;
            $userPassword = isset($encodeData['userPassword']) ? $encodeData['userPassword'] : null;
        } else {
            $userName = $this->getRequest()->getParam('userName', null);
            $userPassword = $this->getRequest()->getParam('userPassword', null);
        }
        if ($userName && $userPassword) {
            $userPassword = md5($userPassword);
            $auth = new Travel_Model_AgencyAuth($userName, $userPassword);
            $result = $auth->authenticate();
            if (!$result) {
                $status = false;
                $errorMessage = 'Please check and Username Or Password';
            } else {
                $IsMarkForDel = Travel_Model_AgencyAuth::getIdentity()->IsMarkForDel;
                $IsB2BAgent = Travel_Model_AgencyAuth::getIdentity()->IsB2BAgent;
                $IsInsurance = Travel_Model_AgencyAuth::getIdentity()->IsInsurance;
                $UserSysId = Travel_Model_AgencyAuth::getIdentity()->UserSysId;
                $AgencySysId = Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
                $userName = Travel_Model_AgencyAuth::getIdentity()->EmailId;
                if (isset($IsMarkForDel) && $IsMarkForDel == 0 && $IsB2BAgent == 0) {
                    $status = true;
                    $sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
                    $_SESSION['AgencyUser']['user']->{"checkOtp"} = true;
                    $_SESSION['AgencyUser']['user']->{"IsApp"} = true;
                    $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->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->IsDemo = $arrAgentDetail[0]['IsDemo'];
                    $sessionLogin_user->IsApp = true;
                    $objAgent = new Travel_Model_TblAgency();
                    $intLoggedinUserTrxCurrency = $objAgent->getTrxCurrency($intLoggedinUserAgencySysId);
                    $getDefaultCampaignByAgencyId = $objAgency->getDefaultCampaignByAgencyId($intLoggedinUserAgencySysId);
                    $_SESSION['AgencyUser']['user']->{"SenderEmailSysId"} = (int) $arrAgentDetail[0]['SenderEmailSysId'];
                    $_SESSION['AgencyUser']['user']->{"IsSameEmailId"} = (int) $arrAgentDetail[0]['IsSameEmailId'];
                    $_SESSION['AgencyUser']['user']->{"DefaultCampaignId"} = (int) $getDefaultCampaignByAgencyId;
                    $_SESSION['AgencyUser']['user']->{"intLoggedinUserTrxCurrency"} = (int) $intLoggedinUserTrxCurrency;
                    $_SESSION['AgencyUser']['user']->{"AgencyTimeZone"} = trim($arrAgentDetail[0]['AgencyTimeZone']);
                    $_SESSION['AgencyUser']['user']->{"AgencydateFormat"} = trim($arrAgentDetail[0]['AgencydateFormat']);
                    $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->intLoggedinUserTrxCurrency = $intLoggedinUserTrxCurrency;
                    $sessionLogin_user->intLoggedinUserGroupSysId = $objAgent->getAgencyGroup($intLoggedinUserAgencySysId);
                    $sessionLogin_user->agencyDetails = $objAgent->getAgencyDataById($intLoggedinUserAgencySysId);
                    $objAgentStaff = new Travel_Model_TblAgencyStaff();

                    $checkExistingStaffDetail = $objAgentStaff->checkExistingStaffDetail($arrAgentDetail[0]['UserSysId'], $intLoggedinUserAgencySysId, 'nameid');
                    $sessionLogin_user->ReportingToSysId = isset($checkExistingStaffDetail['id']) ? $checkExistingStaffDetail['id'] : '';
                    $sessionLogin_user->ReportingToName = isset($checkExistingStaffDetail['name']) ? $checkExistingStaffDetail['name'] : '';

                    $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();
                    $checkData = $permissionModel->getModuleDataForAclMobile($AgencySysId, $UserSysId, 1);
                    $sessionLogin_user->getAgencyRolePermission = $objRole->GetAgencyRolePermission($AgencySysId, $UserSysId);
                    $sessionLogin_user->getAgencyRolePermission = $checkData;
                    $sessionLogin_user->getAgencyContentPermission = $objRole->GetAgencyContentPermission($AgencySysId, $UserSysId);
                    $sessionLogin_user->UserRoleTitle = trim($userRoleDesc['RoleTitle']);
                    $sessionLogin_user->IsManageMember = trim($userRoleDesc['IsAbleToManageMember']);

                    $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(
                        "CanRefreshDashboard" => true,
                        "LastActiveOn" => $currentDate,
                        "LastLoginTime" => $currentDate,
                        "IsLogInNow" => "1",
                        "RandomCode" => 1111,
                        "RandomCodeValidFrom" => $currentDate,
                        "RandomCodeValidTo" => $RandomCodeValidTo
                    );
                    try {
                        $updateData = new Payment_Model_Checkotp();
                        $where = array('UserSysId =?' => Travel_Model_AgencyAuth::getIdentity()->UserSysId);
                        $updateData->updateTable("TB_Agency_User", $updatedArray, $where);
                    } catch (Zend_Exception $e) {
                        $errorMessage = $e->getMessage();
                    }
                    $this->_redirect('dashboard/agency/index/ismobile/1');
                    exit;
                } else {
                    if ($IsB2BAgent == 1) {
                        $status = false;
                        $errorMessage = "Please check and Username Or Password";
                    } else {
                        $status = false;
                        $errorMessage = "Please check and Username Or Password";
                    }
                }
            }
        } else {
            $status = false;
            $errorMessage = "Please check and Username Or Password";
        }
        $responseArray = array("status" => $status, "message" => $errorMessage);
        echo json_encode($responseArray);
        exit;
    }

    public function checkresetlinkAction() {
        $this->_helper->layout()->disableLayout('');
        $this->_helper->viewRenderer->setNoRender(true);
        $param = $this->getRequest()->getParams();

        $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) {
            $SubmitData = array(
                "uid" => $param['uid'],
                "ag" => ($param['ag']),
                "token" => $param['token'],
                "CTR" => $param['CTR'],
                "urole" => $param['urole']
            );
            $this->_resetsession->resetpass = $SubmitData;
            if (trim($param['token']) != md5(trim($param['uid']))) {
                die('Do not change token.');
            }
            $this->_redirect('login/resetpassword');
        } else {
            die('Oops your reset password link is expired!! try again.');
        }
    }

    public function resetpasswordAction() {
//print_r($_SESSION['UserResetEmail']);die;
        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();
//            echo "<pre>";print_r($param);die;
                $password = $param['userPassword'];
                $cpassword = $param['userConfirmPassword'];
                if (trim($password) == '') {
                    echo json_encode(array('status' => false, 'msg' => 'Please enter new password'));
                    exit;
                }
                if (trim($cpassword) == '') {
                    echo json_encode(array('status' => false, 'msg' => 'Please enter confirm password'));
                    exit;
                }
                if ($password != $cpassword) {
                    echo json_encode(array('status' => false, 'msg' => 'Confirm password does not match with new password'));
                    exit;
                }
                $pattern = "/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})/";
                if (!preg_match($pattern, $password)) {
                    echo json_encode(array('status' => false, 'msg' => 'Week password EEEE'));
                    exit;
                }
                $oRandStrPass = $password;
                $UserRole = $_SESSION['UserResetEmail']['resetpass']['urole'];
                $UserSysId = $_SESSION['UserResetEmail']['resetpass']['uid'];

                try {
                    $objUser = new Travel_Model_TblUser();
                    $isUpdated = $objUser->updateChangePassword($UserRole, $UserSysId, $oRandStrPass);
                    if ($isUpdated == 1) {
                        $reply = ['status' => true, 'msg' => 'Password has been reset successfully. Now Login and continue.'];
                        echo Zend_Json::encode($reply);
                        exit;
                    }
                } catch (Exception $err) {
                    echo $err->getMessage();
                    die;
                }

                $reply = ['status' => false, 'msg' => "sadsadsa"];
                echo Zend_Json::encode($reply);
                exit;
            } else {
                $IsAgencySysId = Catabatic_Helper::getIsAgencySysId();
                $getAgencyData = array();
                if ($IsAgencySysId != FALSE) {
                    $getAgencySysId = Catabatic_Helper::getAgencySysId();
                    $modelAgency = new Travel_Model_TblAgency();
                    $getAgencyData = $modelAgency->getAgencyData($getAgencySysId);
//echo "<pre>";print_r($getAgencyData);exit;
                }
                $this->view->getAgencyMasterData = $getAgencyData;
                $this->_helper->layout->setLayout('layout-signup');
            }
        } else {
            echo('Oops! There seems to be some problem in processing your request!');
            exit;
        }
    }

    public function unsetresetdataAction() {
        $storage = new Zend_Session_Namespace('UserResetEmail');
        $storage->unsetAll();
        $this->_redirect('/');
    }

    public function setCaptchaImageAction() {

        if ($this->getRequest()->isPost()) {
            $param = $this->getRequest()->getParams();
            $randomNumber = rand(10000, 99999);
            $this->_captcha->sessionc = array('captcha' => $randomNumber);
            $result = ['status' => true, 'message' => 'Successfull.', 'img' => $randomNumber];
            echo Zend_Json::encode($result);
            exit;
        }
    }

    function getRealIpAddr() {
        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {   //check ip from share internet
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {   //to check ip is pass from proxy
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        return $ip;
    }

    public function phpinfoAction() {
        echo phpinfo();
        exit;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit