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/UserController_backup.php
<?php
/**
 * Class User
 *
 * @name		User
 * @author		Ravi Khare
 * @version 	1.0
 * @copyright 	Catabatic India Pvt Ltd
 *  Handle Front User Related function
 *
 */
class UserController extends Zend_Controller_Action
{
    
    /**
    * Class variables
    */
    public $baseUrl = '';
    
    public $imageServerUrl = NULL;
    
    public $isAgentLoggedin = false;
    
    public function init() {
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
         
        $registry = Zend_Registry::getInstance();
        $this->imageServerUrl = $registry->imageServerURL;
        
      //  require_once ( $_SERVER['DOCUMENT_ROOT'] . '/public/google/libraries/Google/autoload.php' );
        require_once ($_SERVER['DOCUMENT_ROOT']  . '/public/fb/inc/facebook.php' ); //include facebook SDK
    }
    
//    public function customerFacebookAuthorizeAction() {
//        
//        
////        $sessionLogin_user				= new Zend_Session_Namespace('sessionLogin_user');
////        Zend_Session::rememberMe(60*60*24*7);
////        $sessionLogin_user->inTest = 3;
////        
////        $this->_redirect('/search/test');
////        exit;
//                    
//                    
//                  
//        
//       // $objAgent = new Travel_Model_TblAgentInfo();
//       // $objAgent->deleteLoginSession();
//        
//        
//        $fbPermissions = 'email';  //Required facebook permissions
//
//        //Call Facebook API
//        $facebook = new Facebook(array(
//            'appId'  => FACEBOOK_APP_ID,
//            'secret' => FACEBOOK_APP_SECRET_KEY
//        ));
//        
//        $facebook->destroySession();
//        
//        $fbuser = $facebook->getUser();
//        
//        
//        echo $token = $facebook->getAccessToken();
//        echo "<pre>";
//        print_r($fbuser);
//        //exit;
////        
//        try {
//            
//        
//        if($fbuser){
//            
//            //$user_profile = $facebook->api('/me?fields=id,first_name,last_name,email,gender,picture,hometown');
//             $user_profile = $facebook->api('/me');
//             //$user_profile = $facebook->api('/me');
//            
////            echo "<pre>";
////            print_r($user_profile);
////            exit;
////            
//            $date = new Zend_Date();
//            $currentDate = $date->toString('yyyy-MM-dd HH:mm:ss');
//                
//            $objUser = new Travel_Model_TblUser();
//
//            if(!  $objUser->isEmailExists(trim($user_profile['email'])) ) {
//                $userPassword = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->generateRandomString(10);
//                
//                $userData = array(
//                                'fname' => $user_profile['first_name']." ".$user_profile['last_name'],
//                                'email_id' => $user_profile['email'],
//                                'password' => md5($userPassword),
//                                'actual_password' => $userPassword,  
//                                'gender' => $user_profile['gender'],
//                                'profile_image' => $user_profile['picture']['data']['url'],
//                                'facebook_id' => $user_profile['id'],
//                                'fb_city'     => isset($user_profile['hometown']['name']) ?  $user_profile['hometown']['name'] : '',
//                                'registration_date' => $currentDate,
//                                'last_login'        => $currentDate,
//                                'login_ip'          => $_SERVER['REMOTE_ADDR']
//                            );
//
////                echo "<pre>";
////                print_r($userData);
////                exit;
//                
//                $objUser = new Travel_Model_TblUser();
//                $result = $objUser->registerUser($userData);
//            } 
//            
//            $this->_redirect('/search/create-customer-session-for-facebook-login/email/' . trim($user_profile['email']));
//            exit;
//        }else {
//            
//             $redirectURI = SITE_URL . '/user/customer-facebook-authorize/' ;
//                        $agentFacebookLoginUrl = $facebook->getLoginUrl(array ( 
//                            'scope'   => 'email',
//                            'display' => 'popup',
//                            'redirect_uri' => $redirectURI
//                        ));
//                        
//                        
////            echo $facebook->getLoginUrl(array('req_perms' => 'id,first_name,last_name,email,gender,picture,hometown'));
//            die("There has been an error while fetching information via Facebook.");
//            exit;
//            
//           // $this->_redirect($agentFacebookLoginUrl);
//           // header("Location:{$facebook->getLoginUrl(array('req_perms' => 'id,first_name,last_name,email,gender,picture,hometown'))}");
//            exit;
//        }
//        
//        } catch (FacebookApiException $ex) {
//            die($ex->getMessage());
//        }
//    }
    
    
    public function customerLoginViaFacebookAction() {
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        
        if ($this->getRequest()->isXmlHttpRequest()) { 
            
//            echo "<pre>";
//            print_r($this->getRequest()->getPost());
//            exit;
            
            $email      = $this->getRequest()->getPost('fbEmail');
            $facebookId = $this->getRequest()->getPost('facebookId');
            $name       = $this->getRequest()->getPost('fbName');
            $city       = $this->getRequest()->getPost('city');
            $reason     = $this->getRequest()->getPost('reason');
            
            $date = new Zend_Date();
            $currentDate = $date->toString('yyyy-MM-dd HH:mm:ss');
                
            $objUser = new Travel_Model_TblUser();

            if(!  $objUser->isEmailExists(trim($email)) ) {
                
                $userPassword = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->generateRandomString(10);
                
                $userData = array(
                                'fname' => $name,
                                'email_id' => $email,
                                'password' => md5($userPassword),
                                'actual_password' => $userPassword,  
                               // 'gender' => $user_profile['gender'],
                              //  'profile_image' => $user_profile['picture']['data']['url'],
                                'facebook_id' => $facebookId,
                                'fb_city'      => $city,
                                'registration_date' => $currentDate,
                                'last_login'        => $currentDate,
                                'login_ip'          => $_SERVER['REMOTE_ADDR']
                            );

//                echo "<pre>";
//                print_r($userData);
//                exit;
                
                $objUser = new Travel_Model_TblUser();
                $result = $objUser->registerUser($userData);
                
               // $this->_redirect('/search/create-customer-session-for-facebook-login/email/' . trim($email));
               // exit;
            
            } else {
                
             
                $objUser = new Travel_Model_TblUser();
                $objUser->createGuestUserSessionForLogin(trim($email));
                
                $userData = array(
                'last_login'  => $currentDate,
                'login_ip'    => $_SERVER['REMOTE_ADDR'],
                'fb_city'     => $city,
               // 'profile_image'     => $user_profile['picture']['data']['url'],
              //  'fb_city'           => isset($user_profile['hometown']['name']) ?  $user_profile['hometown']['name'] : '',
                );


                $result = $objUser->update($userData, $email);

                //$sessionLogin_user		  = new Zend_Session_Namespace('sessionLogin_user');
               // $sessionLogin_user->loginRequired = false;

//                if(!empty($sessionLogin_user->redirectPostLoginUrl)) {
//                    $response = array('success' => true, 'reason' => $reason); 
//                    echo json_encode($response);
//                    exit;
//                }
                
            }
        }
        
        $response = array('success' => true, 'loggedIn' => true, 'reason' => $reason ); 
        echo json_encode($response);
        exit;
    }
    
    
    
    public function agentLoginViaFacebookAction() {
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        
        if ($this->getRequest()->isXmlHttpRequest()) { 
            
//            echo "<pre>";
//            print_r($this->getRequest()->getPost());
//            exit;
            
            $agentEmail = $this->getRequest()->getPost('fbEmail');
            $facebookId = $this->getRequest()->getPost('facebookId');
            $name = $this->getRequest()->getPost('fbName');
            
             
            $userProfile = array('id' => $facebookId, 'first_name' => $name, 'email' => $agentEmail );
            
            $date = new Zend_Date();
            $currentDate = $date->toString('yyyy-MM-dd HH:mm:ss');
            
            $objAgent = new Travel_Model_TblAgentInfo();
            $objAgent->strCondition = " AND admin_user.email = '" . $agentEmail ."'";
            $arrAgentList = $objAgent->getAgentTable();
            
            
            if( count($arrAgentList) > 0 ) {
                
                $sessionLogin_error   = new Zend_Session_Namespace('sessionLogin_error');
                $active               = $arrAgentList[0]['active'];
                $role                 = $arrAgentList[0]['role'];
                
                if($active <> 1) {
                    
                    $sessionLogin_error->errorMsg      = "Your account is not yet active. Please contact Tripsbank for further assistance.";
                    
                    $response = array('success' => false, 'msg' => $sessionLogin_error->errorMsg); 
                    echo json_encode($response);
                    exit;

        
                }else if($role <> 2) {
                    $sessionLogin_error->errorMsg      = "You are not registered as an Agent with Tripsbank. Please contact Tripsbank for further assistance.";
                    
                    $response = array('success' => false, 'msg' => $sessionLogin_error->errorMsg); 
                    echo json_encode($response);
                    exit;
                }
                
//                if(empty($sessionLogin_error->errorMsg)) {
//                    $this->_redirect('/search/create-agent-session-for-facebook-login/email/'.$agentEmail);
//                }else {
//                    $this->_redirect('login');
//                }
               
            }else {
                $objAgent = new Travel_Model_TblAgentInfo();
                $objAgent->createAccountViaFacebook($userProfile);
               // $this->_redirect('/search/create-agent-session-for-facebook-login/email/'.$agentEmail);
               // exit;
            }
        }
        $response = array('success' => true); 
        echo json_encode($response);
        exit;
    }
    
    
    public function agentFacebookAuthorizeAction() {
        
       // $objAgent = new Travel_Model_TblAgentInfo();
       // $objAgent->deleteLoginSession();
        
        $fbPermissions = 'email';  //Required facebook permissions

        //Call Facebook API
        $facebook = new Facebook(array(
          'appId'  => FACEBOOK_APP_ID,
          'secret' => FACEBOOK_APP_SECRET_KEY,
          'default_graph_version' => 'v2.2',
//          'cookie' => TRUE, /* Optional */
//          'oath'   => TRUE  /* Optional */
        ));
        $facebook->destroySession();
        $fbuser = $facebook->getUser();
        
        if($fbuser){
            $user_profile = $facebook->api('/me?fields=id,first_name,last_name,email,gender,locale,picture,hometown');
            
//            echo "<pre>";
//            print_r($user_profile);
           // exit;
            
            $date = new Zend_Date();
            $currentDate = $date->toString('yyyy-MM-dd HH:mm:ss');
                
            $agentEmail = $user_profile['email'];
                     
            $objAgent = new Travel_Model_TblAgentInfo();
            $objAgent->strCondition = " AND admin_user.email = '" . $agentEmail ."'";
            $arrAgentList = $objAgent->getAgentTable();
            
//            echo "<pre>";
//            print_r($arrAgentList);
//            exit;
//            
            
            if( count($arrAgentList) > 0 ) {
                
                $sessionLogin_error   = new Zend_Session_Namespace('sessionLogin_error');
                $active               = $arrAgentList[0]['active'];
                $role                 = $arrAgentList[0]['role'];
                
//                echo "<pre>";
//                print_r($arrAgentList);
//                exit;
                
              
                
                if($active <> 1) {
                    $sessionLogin_error->errorMsg      = "Your account is not yet active. Please contact Tripsbank for further assistance.";
                }else if($role <> 2) {
                    $sessionLogin_error->errorMsg      = "You are not registered as an Agent with Tripsbank. Please contact Tripsbank for further assistance.";
                }
                
                if(empty($sessionLogin_error->errorMsg)) {
                    $this->_redirect('/search/create-agent-session-for-facebook-login/email/'.$agentEmail);
                }else {
                    $this->_redirect('login');
                }
               
            }else {
                $objAgent = new Travel_Model_TblAgentInfo();
                $objAgent->createAccountViaFacebook($user_profile);
                $agentEmail = $user_profile['email'];
                //$objAgent = new Travel_Model_TblAgentInfo();
                
                $this->_redirect('/search/create-agent-session-for-facebook-login/email/'.$agentEmail);
                exit;
            }

            }else {
                echo "There has been an error while fetching information via Facebook.";
                exit;
//               header("Location:{$facebook->getLoginUrl(array('req_perms' => 'id,first_name,last_name,email,gender,picture,hometown'))}");
//               exit;
            }

//            if($objUser->createGuestUserSessionForLogin(trim($user_profile['email']))) {
//                
//                $userData = array(
//                            'last_login'        => $currentDate,
//                            'login_ip'          => $_SERVER['REMOTE_ADDR']
//                    );
//
//                $objUser = new Travel_Model_TblUser();
//                $result = $objUser->update($userData, $user_profile['email']);
//                
//                
//                $sessionLogin_user				= new Zend_Session_Namespace('sessionLogin_user');
//                $sessionLogin_user->loginRequired = false;
//
//                if(!empty($sessionLogin_user->redirectPostLoginUrl)) {
//                    $this->_redirect($sessionLogin_user->redirectPostLoginUrl);
//                }else {
//                    $this->_redirect('/');
//                }
//            }
//            
//            $this->_redirect('/');
        //}
    }
    
    
    public function googlePlusRegisterAction() {
        
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $redirect_uri = $this->baseUrl . '/user/google-plus-register';
        $client = new Google_Client();
        $client->setClientId(GOOGLE_PLUS_APP_ID);
        $client->setClientSecret(GOOGLE_PLUS_CLIENT_SECRET_KEY);
        $client->setRedirectUri($redirect_uri);
        $client->addScope("email");

        
        /************************************************
          When we create the service here, we pass the
          client to it. The client then queries the service
          for the required scopes, and uses that when
          generating the authentication URL later.
         ************************************************/
        $service = new Google_Service_Oauth2($client);


        //If code is empty, redirect user to google authentication page for code.
        //Code is required to aquire Access Token from google
        //Once we have access token, assign token to session variable
        //and we can redirect user back to page and login.
        if (isset($_GET['code'])) {
            $client->authenticate($_GET['code']);
            $_SESSION['access_token'] = $client->getAccessToken();
            header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
            exit;
        }else {
            //$this->_redirect($this->baseUrl . '/user/register/');
        }
        
        if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
            $client->setAccessToken($_SESSION['access_token']);
        }else { 
            //$this->_redirect($this->baseUrl . '/user/register/');
        }
        
        if($client->isAccessTokenExpired()) {
            $client->refreshToken($_SESSION['access_token']);
        }

                    
        if(!empty($_SESSION['access_token'])){
            
            $user = $service->userinfo->get(); //get user info 
            
            $objUser = new Travel_Model_TblUser();
            
            if(!$objUser->isEmailExists(trim($user->email)) ) {

                $userPassword = Zend_Controller_Action_HelperBroker::getStaticHelper("User")->genrateRandomPassword(10);
                $userData = array(
                                'fname' => $user->name,
                                'gender' => $user->gender,
                                'email_id' => $user->email,
                                'password' => md5($userPassword),
                                'gmail_id' => $user->id,
                                'profile_image' => $user->picture,
                                'actual_password' => $userPassword
                             );
                
                $result = $objUser->registerUser($userData);
            }
            
            if($objUser->createGuestUserSessionForLogin(trim($user->email))) {
                $sessionLogin_user				= new Zend_Session_Namespace('sessionLogin_user');
                $sessionLogin_user->loginRequired = false;

                if(!empty($sessionLogin_user->redirectPostLoginUrl)) {
                    $this->_redirect($sessionLogin_user->redirectPostLoginUrl);
                }else {
                    $this->_redirect('/');
                }
            }
            
            $this->_redirect('/');
        }
    }
    
    
    
    public function registerAction() {
        
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        
        
        if($this->getRequest()->isPost()){
            
            
            
            
//            print_r($this->getRequest()->getParams());
//            exit;
            
            $strName = $this->getRequest()->getParam('name'); 
            $mobileNo = $this->getRequest()->getParam('customer_signup_mobile');
            $emailId = $this->getRequest()->getParam('customer_signup_email');
            $password = md5($this->getRequest()->getParam('password'));
            $actualPassword = $this->getRequest()->getParam('password');
            $confPassword = $this->getRequest()->getParam('confPassword');
            
            
            if(empty($strName)) {
                $msg =  "Please enter your name.";
                $response = array('success' => false, 'msg' => $msg, 'errorCtrl' => 'customer_signup_name');
                echo json_encode($response);
                exit;
            }
            
           
            
            
            if(empty($emailId)) {
                $msg =  "Please enter your email ID.";
                $response = array('success' => false, 'msg' => $msg, 'errorCtrl' => 'customer_signup_email');
                echo json_encode($response);
                exit;
            }
            
            if (!filter_var($emailId, FILTER_VALIDATE_EMAIL)) {
                $msg =  "Email address is either empty or not valid.";
                $response = array('success' => false, 'msg' => $msg, 'errorCtrl' => 'customer_signup_email');
                echo json_encode($response);
                exit;
            }
            
            if(empty($actualPassword)) {
                $msg =  "Please enter your password.";
                $response = array('success' => false, 'msg' => $msg, 'errorCtrl' => 'customer_signup_password');
                echo json_encode($response);
                exit;
            }
            
            if(empty($actualPassword)) {
                $msg =  "Please enter confirm password.";
                $response = array('success' => false, 'msg' => $msg, 'errorCtrl' => 'customer_signup_confirm_password');
                echo json_encode($response);
                exit;
            }
            
            if($actualPassword != $confPassword) {
                $msg =  "Password and Confirm Password does not match.";
                $response = array('success' => false, 'msg' => $msg, 'errorCtrl' => 'customer_signup_confirm_password');
                echo json_encode($response);
                exit;
            }
            
            if(empty($mobileNo)) {
                $msg =  "Please enter your mobile number.";
                $response = array('success' => false, 'msg' => $msg, 'errorCtrl' => 'customer_signup_mobile');
                echo json_encode($response);
                exit;
            }
                
            /*
            $objUser = new Travel_Model_TblUser();
            if($objUser->isEmailExists(trim($emailId))) {
                $msg =  "This email id already registered with us.";
                $response = array('success' => false, 'msg' => $msg);
                echo json_encode($response);
                exit;
            }*/
            
            $objUser = new Travel_Model_TblUser();
            if(!  $objUser->isEmailExists(trim($emailId)) ) {

                $date = new Zend_Date();
                $currentDate = $date->toString('yyyy-MM-dd HH:mm:ss');
                
                $userData = array(
                    'fname' => $strName,
                    'mobile_number' => $mobileNo,
                    'email_id' => $emailId,
                    'password' => $password,
                    'actual_password' => $actualPassword,
                    'registration_date' => $currentDate
                );

            
                $result = $objUser->registerUser($userData);
            } else {
                
                $msg =  "This email id already registered with us.";
                $response = array('success' => false, 'msg' => $msg, 'errorCtrl' => 'customer_signup_email');
                echo json_encode($response);
                exit;
                
            }
            
            if($objUser->createGuestUserSessionForLogin(trim($emailId))) {
                
                $sessionLogin_user				= new Zend_Session_Namespace('sessionLogin_user');
                $sessionLogin_user->loginRequired = false;
                
                if(!empty($sessionLogin_user->redirectPostLoginUrl)) {
                    //$this->_redirect($sessionLogin_user->redirectPostLoginUrl);
                    $redirectPostLoginUrl = $sessionLogin_user->redirectPostLoginUrl;
                }else {
//                    $this->_redirect('/');
                    $redirectPostLoginUrl = '/';
                }
                
                
                $msg =  "Thanks for your registeration with us.";
                $response = array('success' => true, 'msg' => $msg, 'redirectPostLoginUrl' => $redirectPostLoginUrl);
                echo json_encode($response);
                exit;
            }
            
            echo json_encode($response);
            exit;
        }
    }
    
    public function addReviewAction() {
        
        /* Disable layout */
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
        
         /* If ajax request */
        if ($this->_request->isXmlHttpRequest()) {
            
            $post = $this->getRequest()->getPost();
            
            if (  empty($post['isAtleastOneReviewSelected']) || ($post['isAtleastOneReviewSelected'] == 'N') ) {
                $msg =  "Please choose the rating.";
                $response = array('success' => false, 'msg' => $msg);
                echo json_encode($response);
                exit;
            }
            
            if (  empty($post['feedback']) ) {
                $msg =  "Please give us your Additional feedback.";
                $response = array('success' => false, 'msg' => $msg);
                echo json_encode($response);
                exit;
            }
            
            
            
            
            $sessionLogin_user	= new Zend_Session_Namespace('sessionLogin_user');
            $sessionLogin_user->reviewDetailPendingToShow = true;
            
            if(!Zend_Controller_Action_HelperBroker::getStaticHelper('User')->isGuestUserLoggedin()) {
                /* Save the review data in session */
               
                $sessionLogin_user->arrReviewDetail = $post;
                $sessionLogin_user->reviewPendingToSave = true;
                
                /* Create redirect URI */
                $sessionLogin_user->redirectPostLoginUrl = $post['currentPageUrl'];
                $sessionLogin_user->loginRequired = true;
                
                $response = array('success' => false, 'msg' => '', 'errorcode' => '1', 'redirectPostLoginUrl' => $sessionLogin_user->redirectPostLoginUrl);
                echo json_encode($response);
                exit;
            }else {
                $sessionLogin_user->redirectPostLoginUrl = $post['currentPageUrl'];
                $objUser = new Travel_Model_TblUser();
                $objUser->addReview($post);
                $msg =  "Thanks for your reviews.";
                $response = array('success' => true, 'msg' => $msg, 'errorcode' => '0','redirectPostLoginUrl' => $sessionLogin_user->redirectPostLoginUrl);
                echo json_encode($response);
                exit;
            }
        }
    }
    
    public function loginAction() {
        
        
        /* Get Facebook Login URL */
        include_once("public/fb/inc/facebook.php"); //include facebook SDK
        ######### Facebook API Configuration ##########
        $fbPermissions = 'email';  //Required facebook permissions

        //Call Facebook API
        $facebook = new Facebook(array(
          'appId'  => FACEBOOK_APP_ID,
          'secret' => FACEBOOK_APP_SECRET_KEY
        ));
        
        
        $fbuser = null;
	$this->view->facebookLoginUrl = $facebook->getLoginUrl(array('redirect_uri'=> $this->baseUrl .'/user/facebook-authorize','scope'=>$fbPermissions));
        /********************************************************************************************************/
        
        /* Get Google Plus URL */
        $client = new Google_Client();
        $client->setClientId(GOOGLE_PLUS_APP_ID);
        $client->setClientSecret(GOOGLE_PLUS_CLIENT_SECRET_KEY);
        $client->setRedirectUri($this->baseUrl . '/user/google-plus-register');
        $client->addScope("email");
        $client->addScope("profile");

        /************************************************
        When we create the service here, we pass the
        client to it. The client then queries the service
        for the required scopes, and uses that when
        generating the authentication URL later.
        ************************************************/
        $service = new Google_Service_Oauth2($client);


        //If code is empty, redirect user to google authentication page for code.
        //Code is required to aquire Access Token from google
        //Once we have access token, assign token to session variable
        //and we can redirect user back to page and login.
//        if (isset($_GET['code'])) {
//          $client->authenticate($_GET['code']);
//          $_SESSION['access_token'] = $client->getAccessToken();
//          header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
//          exit;
//        }

        //if we have access_token continue, or else get login URL for user
//        if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
//              $client->setAccessToken($_SESSION['access_token']);
//        } else {
//              $authUrl = $client->createAuthUrl();
//        }

        $authUrl = $client->createAuthUrl();
        $this->view->gmailAuthUrl     = $authUrl;
	//echo $output = '<a href="'.$loginUrl.'"><img src="images/fb_login.png"></a>'; 
    }
    
    
    public function validateLoginAction() {
        
        if ($this->getRequest()->isXmlHttpRequest()) {
            $userName     = $this->getRequest()->getParam('userName');
            $userPassword = $this->getRequest()->getParam('userPassword');
            $isAgent      = $this->getRequest()->getParam('isAgent');

            if(empty($userName)) {
                $response = array('success' => false, 'msg' => 'Please enter your user name.') ;
                echo json_encode($response);
                exit;
            }

            if(empty($userPassword)) {
                $response = array('success' => false, 'msg' => 'Please enter your password.') ;
                echo json_encode($response);
                exit;
            }
            
            $userPassword = md5($userPassword);
            
            if($isAgent == 'Y') {

                $objAgent = new Travel_Model_TblAgentInfo();
                

                $arrAgentDetail = $objAgent->getDetail4Login($userName);
                
             

                if(!empty($arrAgentDetail) ) {

                    if($arrAgentDetail[0]['active'] != '1') {
                        $response = array('success' => false, 'msg' => 'Your account is not active.') ;
                        echo json_encode($response);
                        exit;
                    }

                    if($arrAgentDetail[0]['password'] != $userPassword) {
                        $response = array('success' => false, 'msg' => 'Incorrect Password') ;
                        echo json_encode($response);
                        exit;
                    }

                    $passKey = md5(uniqid(rand())); 
                    $objAgent->updatePassKeyForLogin($arrAgentDetail[0]['user_id'], $passKey);

                    $objAgent = new Travel_Model_TblAgentInfo();
                    $objAgent->intUserId = $arrAgentDetail[0]['user_id'];
                    $arrAgentInfo = $objAgent->getAgentList();

                
                    $agentCity = $arrAgentInfo[0]['city_name'];

                    #create session
                    Zend_Session::start();

                    $sessionLogin_user				= new Zend_Session_Namespace('sessionLogin_user');
                    Zend_Session::rememberMe(60*60*24*7);

                    #set session variable
                    $sessionLogin_user->intLoginUserId              = $arrAgentDetail[0]['user_id'];
                    $sessionLogin_user->intLoginAgentId             = $arrAgentDetail[0]['agent_id'];
                    $sessionLogin_user->strLoginUserFirstName       = $arrAgentDetail[0]['firstname'];
                    $sessionLogin_user->strCompanyName              = $arrAgentDetail[0]['company_name'];
                    $sessionLogin_user->strLoginUserEmail           = $arrAgentDetail[0]['email'];
                    $sessionLogin_user->strContactNo                = $arrAgentDetail[0]['mobile_no'];
                    $sessionLogin_user->strAgentCity                = $agentCity;
                    $sessionLogin_user->strAutoLoginPassKey         = $passKey;
                    $sessionLogin_user->arrAgencyType               = explode(",", $arrAgentDetail[0]['agency_type']);
                    
                    $response = array('success' => true, 'msg' => '', 'redirectPostLoginUrl' => '/') ;
                    echo json_encode($response);
                    exit;
                } 
            }else {
                $sessionLogin_user				= new Zend_Session_Namespace('sessionLogin_user');
//                echo "<pre>";
//                print_r( $sessionLogin_user->arrReviewDetail);
//                exit;             
                
                
                $objUser = new Travel_Model_TblUser();
                $arrUserDetail = $objUser->getDetail4Login($userName);

                if(!empty($arrUserDetail) ) {
                    
                    if($arrUserDetail[0]['password'] != $userPassword) {
                        $response = array('success' => false, 'msg' => 'Incorrect Password') ;
                        echo json_encode($response);
                        exit;
                    }

                    if($arrUserDetail[0]['status'] != '1') {
                        $response = array('success' => false, 'msg' => 'Your account is not active.') ;
                        echo json_encode($response);
                        exit;
                    }
                    
                    if($objUser->createGuestUserSessionForLogin(trim($userName))) {
                        $sessionLogin_user				= new Zend_Session_Namespace('sessionLogin_user');
                        $redirectPostLoginUrl = '/';
                        if(!empty($sessionLogin_user->redirectPostLoginUrl)){
                            $redirectPostLoginUrl = $sessionLogin_user->redirectPostLoginUrl;
                        }
                         
                        $response = array('success' => true, 'msg' => '', 'redirectPostLoginUrl' => $redirectPostLoginUrl);
                        echo json_encode($response);
                        exit;
                    }

                    echo json_encode($response);
                    exit;
                }
            }
            
            $response = array('success' => false, 'msg' => 'User Id does not exist.') ;
            echo json_encode($response);
            exit;
        }
    }
    
    public function resendEmailVerificationLinkAction() {
      
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
        
        if ($this->getRequest()->isXmlHttpRequest()) { 

            $email = $this->getRequest()->getParam('email');
  
            $objAgent = new Travel_Model_TblAgentInfo();
            $arrDetail = $objAgent->getAgentDetailFromRegistrationTable($email);
            
            if(count($arrDetail)!=1) {
                throw new Exception("We are not able to process your request this time. Please try again later.");
            }
            
            $strAgentName = $arrDetail[0]['agent_name'];
            $passKey      = $arrDetail[0]['pass_key'];
        
            $partnerSiteUrl   = PARTNERS_WEBSITE;

            $verificationLink = $partnerSiteUrl . 'agent/email/confirm/key/'.$passKey;

            $arrVars = array('verification_link' => $verificationLink, 'agent_name' => $strAgentName);

            $response = Zend_Controller_Action_HelperBroker::getStaticHelper('EmailTemplate')->resendEmailVerificationlink($email, $arrVars);
            
            
            if(!$response){
                //echo "Error in sending email.";
                //exit;
            }
        
            $response = array('success' => true) ;
            echo json_encode($response);
            exit;
            
            
//            echo "<pre>";
//            print_r($arrDetail);
//            exit;
        }
    }
    
    public function updateReviewFromSessionAction() {
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
        
        if ($this->getRequest()->isXmlHttpRequest()) { 
            
            $sessionLogin_user	= new Zend_Session_Namespace('sessionLogin_user');
            $sessionLogin_user->reviewDetailPendingToShow = true;
            
            if(!empty($sessionLogin_user->arrReviewDetail)) {
                $objUser = new Travel_Model_TblUser();
                $objUser->addReview($sessionLogin_user->arrReviewDetail);
                
                $msg =  "Thanks for your reviews.";
                                $response = array('success' => true, 'msg' => $msg, 'errorcode' => '0', 'redirectPostLoginUrl' => $sessionLogin_user->redirectPostLoginUrl);

                unset($sessionLogin_user->arrReviewDetail);
                unset($sessionLogin_user->reviewPendingToSave);
                unset($sessionLogin_user->redirectPostLoginUrl);
                
                echo json_encode($response);
                exit;
            }
            
        }
    }
    
    public function validateCustomerLoginAction() {
        
        if ($this->getRequest()->isXmlHttpRequest()) {
            $userName     = $this->getRequest()->getParam('userName');
            $userPassword = $this->getRequest()->getParam('userPassword');
            
//            echo "<pre>";
//            print_r($this->getRequest()->getParams());
//            exit;
            

            if(empty($userName)) {
                $response = array('success' => false, 'msg' => 'Please enter your user name.', 
                        'errorCtrl' => 'customer_userLoginUser') ;
                echo json_encode($response);
                exit;
            }

            if(empty($userPassword)) {
                $response = array('success' => false, 'msg' => 'Please enter your password.', 'errorCtrl' => 'customer_userLoginPassword') ;
                echo json_encode($response);
                exit;
            }
            
            $userPassword = md5($userPassword);
            $sessionLogin_user				= new Zend_Session_Namespace('sessionLogin_user');
    //                echo "<pre>";
    //                print_r( $sessionLogin_user->arrReviewDetail);
    //                exit;             
            $objUser = new Travel_Model_TblUser();
            $arrUserDetail = $objUser->getDetail4Login($userName);

            if(!empty($arrUserDetail) ) {

                if($arrUserDetail[0]['password'] != $userPassword) {
                    $response = array('success' => false, 'msg' => 'Incorrect Password','errorCtrl' => 'customer_userLoginUser') ;
                    echo json_encode($response);
                    exit;
                }

                if($arrUserDetail[0]['status'] != '1') {
                    $response = array('success' => false, 'msg' => 'Your account is not active.') ;
                    echo json_encode($response);
                    exit;
                }

                if($objUser->createGuestUserSessionForLogin(trim($userName))) {
                    /*  $sessionLogin_user				= new Zend_Session_Namespace('sessionLogin_user');
                    $redirectPostLoginUrl = '/';
                    if(!empty($sessionLogin_user->redirectPostLoginUrl)){
                        $redirectPostLoginUrl = $sessionLogin_user->redirectPostLoginUrl;
                    }
                    */
                    
                   
                        
                    
                    $sessionLogin_user	= new Zend_Session_Namespace('sessionLogin_user');
                    $redirectPostLoginUrl = '/';
                    if(!empty($sessionLogin_user->redirectPostLoginUrl)){
                        $redirectPostLoginUrl = $sessionLogin_user->redirectPostLoginUrl;
                    }
                    
                    $response = array('success' => true, 'msg' => '', 'pendingReview' => $sessionLogin_user->reviewPendingToSave,
                        'redirectPostLoginUrl' => $redirectPostLoginUrl);
                    echo json_encode($response);
                    exit;
                }

                echo json_encode($response);
                exit;
            }
        }
    }
    
    public function viewReviewsAction() {
        
        
        $this->_helper->layout->disableLayout();
        
        if ($this->getRequest()->isXmlHttpRequest()) {
            
            $this->view->intPage = $intPage     = $this->getRequest()->getParam('intPageId');
            $intAgentId         = $this->getRequest()->getParam('intAgentId');
            
          

            $objAgent        = new Travel_Model_TblAgentInfo();
            $objAgent->intId = $intAgentId;
            
            
            $this->view->limit = $limit = 2; //how many items to show per page
            
            if($intPage) 
                $intQueryOffset = ($intPage - 1) * $limit; 	//first item to display on this page
            else
                $intQueryOffset = 0; //if no page var is given, set start to 0
        
        
            /* First get total number of rows in data table. */
            $objAgent->strSelectedView = 'count';
            $result = $objAgent->getCustomerReviews();
            $this->view->intTotalRecords = $intTotalRecords = $result[0]['total'];
            
            
            $objAgent->strSelectedView = 'list';
            $objAgent->intQueryOffset = $intQueryOffset;
            $objAgent->intListPerPage = $limit;
            $this->view->arrCustomerReviews = $objAgent->getCustomerReviews();
        }
    }

    
    
}

Youez - 2016 - github.com/yon3zu
LinuXploit