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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2c.hellogtx.com/application/admin/controllers/HomepromotionController.php
<?php
/***************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name     : HomePromotionController.php
* File Desc.    : HomePromotion Controller  managed all Home Promotion content pages
* Created By    : Mangal katiyar <mangal.co.in>
* Created Date  : 19 Nov 2018
* Updated Date  : 19 Nov 2018
***************************************************************/



class Admin_HomepromotionController extends Zend_Controller_Action
{


    public $dbAdapter;
    public $perPageLimit;
    public $siteurl;
    public $DIR_WRITE_MODE;



    public function init()
    {
       /*Initialize db and session access */
        $aConfig = $this->getInvokeArg('bootstrap')->getOptions();
        $this->view->siteurl = $this->siteurl = $aConfig['bootstrap']['siteUrl'];
        $this->view->stylecss = $this->stylecss = $aConfig['bootstrap']['stylecss'];
        $this->appmode = $aConfig['bootstrap']['appmode'];
        $this->per_page_record   = 20;

        $this->dbAdapter = Zend_Db_Table::getDefaultAdapter();

        $auth        = Zend_Auth::getInstance();
        $authStorage = $auth->getStorage()->read();
        $this->username      = $authStorage->username;
        $this->admin_type    = $authStorage->role;

        $this->current_time = time();
        $this->promoimageUrl     = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/'.$this->stylecss.'/homepromotion/';
        $this->DIR_WRITE_MODE = 0777;

        $this->table =  'tbl_home_promotion';
	$this->large_image_width = $aConfig['bootstrap']['large_image_width'];
        $this->large_image_height = $aConfig['bootstrap']['large_image_height'];
        $this->medium_image_width = $aConfig['bootstrap']['medium_image_width'];
        $this->medium_image_height = $aConfig['bootstrap']['medium_image_height'];
        $this->small_image_width = $aConfig['bootstrap']['small_image_width'];
        $this->small_image_height = $aConfig['bootstrap']['small_image_height'];

    }
    public function indexAction()
    {
        $this->checklogin();
        $getData = array();
        if ($this->getRequest()->isPost()) {
            $getData = $this->getRequest()->getPost();
//            $searchArr = array(
//                'Title' => $getData['Title'],
//                'rows' => $getData['rows'],
//                'page' => $getData['page'],
//            );

            $crud = new Admin_Model_CRUD();
//            $crud->searchArrt = $searchArr;
            $resulsetold = $crud->getCount($this->table, ['IsmarkForDel' => 0], 'promotionId');

            $resultset = $crud->rv_select_all($this->table, ['*'], ['IsmarkForDel' => 0], ['promotionId' => 'DESC']);
            $resultCategory = $crud->getCmsdata('tbl_promotion_category', ['*'], ['prom_cat_id'], ['prom_cat_id'=>'DESC']);


            $resultsetArr = array();

            foreach ($resultset as $reskey => $resvalue) {
                if($resvalue['templatetype'] == 1){
                    $resultsetArr[] =   [
                                    'promotionId' =>$resvalue['promotionId'],
                                    'templatetype' => $resultCategory->prom_cat_one,
                                    'templatetypeId' => 1,

                                    'promotion_name' => $resvalue['promotion_name'],
                                    'tag_name' => '--',
                                    'promotion_image' =>  ($resvalue['promotion_image'] != '') ? '<img src="'.$this->siteurl.'public/upload/'.$this->stylecss.'/homepromotion/'.$resvalue["promotionId"].'/small/'.$resvalue['promotion_image'].'" style="width:176px;height:51px;" border="0" alt="banner image">' : '<img style="width:64px;height:50px;" src="public/images/icon-package.jpg" border="0">' ,
                                    'IsActive' => ($resvalue['IsActive'] == 1) ? 'Active' : 'Deactive',
                                    'IsFeatured' => $resvalue['IsFeatured'],
                                ];
                }else if($resvalue['templatetype'] == 2){

                    $tag_name = json_decode($resvalue['promotion_name']);

                    $tag_nameFin = $tag_name->promotion_tag1.'<br>'.$tag_name->promotion_tag2.'<br>'.$tag_name->promotion_tag3.'<br>'.$tag_name->promotion_tag4;
                    $resultsetArr[] =   [
                                    'promotionId' =>$resvalue['promotionId'],
                                    'templatetype' => $resultCategory->prom_cat_two,
                         'templatetypeId' => 2,
                                    'promotion_name' => '--',
                                    'tag_name' => $tag_nameFin,
                                    'promotion_image' =>  ($resvalue['promotion_image'] != '') ? '<img src="'.$this->siteurl.'public/upload/'.$this->stylecss.'/homepromotion/'.$resvalue["promotionId"].'/small/'.$resvalue['promotion_image'].'" style="width:176px;height:51px;" border="0" alt="banner image">' : '<img style="width:64px;height:50px;" src="public/images/icon-package.jpg" border="0">' ,
                                    'IsActive' => ($resvalue['IsActive'] == 1) ? 'Active' : 'Deactive',
                                    'IsFeatured' => $resvalue['IsFeatured'],
                                ];
                }else if($resvalue['templatetype'] == 3){
                     $resultsetArr[] =   [
                                    'promotionId' =>$resvalue['promotionId'],
                                     'templatetype' => $resultCategory->prom_cat_three,
                          'templatetypeId' => 3,
                                    'promotion_name' => '--',
                                    'tag_name' => '--',
                                    'promotion_image' => ($resvalue['promotion_image'] != '') ? '<img src="'.$this->siteurl.'public/upload/'.$this->stylecss.'/homepromotion/'.$resvalue["promotionId"].'/small/'.$resvalue['promotion_image'].'" style="width:176px;height:51px;" border="0" alt="banner image">' : '<img style="width:64px;height:50px;" src="public/images/icon-package.jpg" border="0">' ,
                                    'IsActive' => ($resvalue['IsActive'] == 1) ? 'Active' : 'Deactive',
                                    'IsFeatured' => $resvalue['IsFeatured'],
                                ];
                }

            }

            $result = Zend_Json::encode($resultsetArr);
            $newResult = Zend_Json::decode($result, false);
            $finalResult["total"] = $resulsetold[0]['promotionId'];
            $finalResult["rows"] = $newResult;
            echo json_encode($finalResult);
            exit;
        }
    }



    /**
    * editpage() method is used to admin can edit cms static page
    * @param password string
    * @return ture
    */

    public function editpromotionAction()
    {
//Check admin logedin or not
        $this->checklogin();
        $crud = new Admin_Model_CRUD();

        $pId = (int)$this->getRequest()->getParam("id");
          $resultCategory = $crud->getCmsdata('tbl_promotion_category', ['*'], ['prom_cat_id'], ['prom_cat_id'=>'DESC']);

         if( $this->getRequest()->isPost() ) {
            $getData = $this->getRequest()->getPost();
            if($getData) {
//                echo "<pre>"; print_r($getData); die;
                //-------Start Code for Approve and Publish content---------//
               if (isset($getData['save']) == "Save") {

                if($getData['templatetype'] == 1){

                    $promotion_image1 = $_FILES['promotion_image1']['name'];

                    if (!empty($promotion_image1)) {
                        $orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->promoimageUrl.$pId;
                        $fileExtion = $this->_helper->General->getFileExtension($promotion_image1);
                        $bfileName = $this->current_time . 'promo'.'_1.' . $fileExtion;
                        if (!file_exists($orignalFolderName)) {
                            mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
                        }

                        $temp_file_name = $_FILES["promotion_image1"]["tmp_name"]; // temprary file name

                        @move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $bfileName);

                        $originalLargeFolder = $orignalFolderName.'/large';
                        $originalMediumFolder = $orignalFolderName.'/medium';
                        $originalSmallFolder = $orignalFolderName.'/small';

                        Catabatic_Helper::resizeImages($orignalFolderName,$originalLargeFolder,$bfileName,$this->large_image_width,$this->large_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalMediumFolder,$bfileName,$this->medium_image_width,$this->medium_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalSmallFolder,$bfileName,$this->small_image_width,$this->small_image_height);


                    }

                  $editPageData = [
                      'templatetype' =>$getData['templatetype'],
                      'promotion_name' =>$getData['promotion_name1'],
                      'promotion_url' =>isset($getData['promotion_url1']) ? $getData['promotion_url1'] : '',
                      'tab_type' =>isset($getData['opt1']) ? $getData['opt1'] : 0 ,
                      'promotion_description' => $getData['promotion_description'],
                      'IsActive' =>1,
                      'IsmarkForDel' =>0,
                  ];
                  if($bfileName != ''){
                      $editPageData['promotion_image'] = $bfileName;
                  }

                }else if($getData['templatetype'] == 2){

                     $promotion_image2 = $_FILES['promotion_image2']['name'];

                    if (!empty($promotion_image2)) {
                        $orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->promoimageUrl.$pId;
                        $fileExtion = $this->_helper->General->getFileExtension($promotion_image2);
                        $bfileName = $this->current_time . 'promo'.'_2.' . $fileExtion;
                        if (!file_exists($orignalFolderName)) {
                            mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
                        }

                        $temp_file_name = $_FILES["promotion_image2"]["tmp_name"]; // temprary file name

                        @move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $bfileName);

                        $originalLargeFolder = $orignalFolderName.'/large';
                        $originalMediumFolder = $orignalFolderName.'/medium';
                        $originalSmallFolder = $orignalFolderName.'/small';

                        Catabatic_Helper::resizeImages($orignalFolderName,$originalLargeFolder,$bfileName,$this->large_image_width,$this->large_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalMediumFolder,$bfileName,$this->medium_image_width,$this->medium_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalSmallFolder,$bfileName,$this->small_image_width,$this->small_image_height);


                    }

                    $promotion_urlArr = ['promotion_tag_url1'=>$getData['promotion_tag_url1'],'promotion_tag_url2'=>$getData['promotion_tag_url2'],'promotion_tag_url3'=>$getData['promotion_tag_url3'],'promotion_tag_url4'=>$getData['promotion_tag_url4']];
                    $promotion_tagArr = ['promotion_tag1'=>$getData['promotion_tag1'],'promotion_tag2'=>$getData['promotion_tag2'],'promotion_tag3'=>$getData['promotion_tag3'],'promotion_tag4'=>$getData['promotion_tag4']];
                    $tabTypelArr = ['tagopt1'=>isset($getData['tagopt1']) ? 1:0,'tagopt2'=>isset($getData['tagopt2']) ? 1: 0,'tagopt3'=>isset($getData['tagopt3']) ? 1: 0,'tagopt4'=>isset($getData['tagopt4']) ? 1 :0];

                  $editPageData = [
                      'templatetype' =>$getData['templatetype'],
                      'promotion_name' =>  json_encode($promotion_tagArr),
                      'promotion_url' =>  json_encode($promotion_urlArr),
                      'tab_type' =>  json_encode($tabTypelArr) ,
                      'promotion_description' => '',
                      'IsActive' =>1,
                      'IsmarkForDel' =>0,
                  ];
                  if($bfileName != ''){
                      $editPageData['promotion_image'] = $bfileName;
                  }
                }else if($getData['templatetype'] == 3){
                    $promotion_image3 = $_FILES['promotion_image3']['name'];

                    if (!empty($promotion_image3)) {
                        $orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->promoimageUrl.$pId;
                        $fileExtion = $this->_helper->General->getFileExtension($promotion_image3);
                        $bfileName = $this->current_time . 'promo'.'_3.' . $fileExtion;
                        if (!file_exists($orignalFolderName)) {
                            mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
                        }

                        $temp_file_name = $_FILES["promotion_image3"]["tmp_name"]; // temprary file name

                        @move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $bfileName);

                       $originalLargeFolder = $orignalFolderName.'/large';
                        $originalMediumFolder = $orignalFolderName.'/medium';
                        $originalSmallFolder = $orignalFolderName.'/small';

                        Catabatic_Helper::resizeImages($orignalFolderName,$originalLargeFolder,$bfileName,$this->large_image_width,$this->large_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalMediumFolder,$bfileName,$this->medium_image_width,$this->medium_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalSmallFolder,$bfileName,$this->small_image_width,$this->small_image_height);


                    }


                  $editPageData = [
                      'templatetype' =>$getData['templatetype'],
                      'promotion_name' =>'',
                      'promotion_url' =>$getData['promotion_url3'],
                      'tab_type' =>isset($getData['opt3']) ? $getData['opt3'] : 0 ,
                       'promotion_description' => '',
                      'IsActive' =>1,
                      'IsmarkForDel' =>0,
                  ];
                    if($bfileName != ''){
                      $editPageData['promotion_image'] = $bfileName;
                    }
                }
//                                    echo "<pre>";print_r($savePageData);die;

                 //echo "<pre>"; print_r($editPageData); die;
                    $crud->rv_update($this->table, $editPageData, ['promotionId =?' => $pId]);
                $this->view->successMessage = "Page content has been saved successfully.";
                $this->_helper->flashMessenger->addMessage("Page content has been added successfully.");
                $this->_redirect("/admin/homepromotion/index");

             }

          }
        }

        $result = $crud->getCmsdata($this->table, ['*'], ['promotionId'=>$pId], ['promotionId'=>'DESC']);
//        echo "<pre>";print_r($result);die;
        if($result->templatetype == 2){


        $promotion_name = json_decode($result->promotion_name);
        $promotion_url = json_decode($result->promotion_url);
        $tab_type = json_decode($result->tab_type);
           $editdata["promotionId"] = @$result->promotionId;
        $editdata["templatetype"] = @$result->templatetype;
        foreach ($promotion_name as $prkey => $prvalue) {
            $editdata[$prkey] = $prvalue;
        }
        foreach ($promotion_url as $urkey => $urvalue) {
            $editdata[$urkey] = $urvalue;
        }

        foreach ($tab_type as $trkey => $trvalue) {
            $editdata[$trkey] = $trvalue;
        }
//        echo "<pre>";print_r($editdata);die;


        $editdata["promotion_image"] = @$result->promotion_image;

        $editdata["IsActive"] = @$result->IsActive;
        }else{
            $editdata["promotionId"] = @$result->promotionId;
        $editdata["templatetype"] = @$result->templatetype;
        $editdata["promotion_name"] = @$result->promotion_name;
        $editdata["promotion_description"] = @$result->promotion_description;
        $editdata["promotion_image"] = @$result->promotion_image;
        $editdata["promotion_url"] = @$result->promotion_url;
        $editdata["tab_type"] = @$result->tab_type;
        $editdata["IsActive"] = @$result->IsActive;
        }

//       echo "<pre>";print_r($editdata);die;
        $this->view->promotionId = @$result->promotionId;
        $this->view->promotion_image = @$result->promotion_image;
        $this->view->editdata = $editdata;
        $this->view->templatetype = $result->templatetype;

           $this->view->resultCategory   = $resultCategory;
    }


    public function addpromotionAction()
    {

//Check admin logedin or not
        $this->checklogin();
        $crud = new Admin_Model_CRUD();
        $pId = (int)$this->getRequest()->getParam("id");
        $resultCategory = $crud->getCmsdata('tbl_promotion_category', ['*'], ['prom_cat_id'], ['prom_cat_id'=>'DESC']);


        if( $this->getRequest()->isPost() ) {
            $getData = $this->getRequest()->getPost();
            if($getData) {

                //-------Start Code for Approve and Publish content---------//
               if (isset($getData['save']) == "Save") {
                $lastRow = $crud->getCmsdata($this->table, ['promotionId'], ['promotionId'], ['promotionId'=>'DESC']);
                $lastInsertId = $lastRow['promotionId']+1;
                if($getData['templatetype'] == 1){

                    $promotion_image1 = $_FILES['promotion_image1']['name'];

                    $bfileName = '';
                    if (!empty($promotion_image1)) {
                        $orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->promoimageUrl.$lastInsertId;
                        $fileExtion = $this->_helper->General->getFileExtension($promotion_image1);
                        $bfileName = $this->current_time . 'promo'.'_1.' . $fileExtion;
                        if (!file_exists($orignalFolderName)) {
                            mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
                        }

                        $temp_file_name = $_FILES["promotion_image1"]["tmp_name"]; // temprary file name

                        @move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $bfileName);

                        $originalLargeFolder = $orignalFolderName.'/large';
                        $originalMediumFolder = $orignalFolderName.'/medium';
                        $originalSmallFolder = $orignalFolderName.'/small';

                        Catabatic_Helper::resizeImages($orignalFolderName,$originalLargeFolder,$bfileName,$this->large_image_width,$this->large_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalMediumFolder,$bfileName,$this->medium_image_width,$this->medium_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalSmallFolder,$bfileName,$this->small_image_width,$this->small_image_height);
                    }

                  $savePageData = [
                      'templatetype' =>$getData['templatetype'],

                      'promotion_name' =>$getData['promotion_name1'],
                      'promotion_image' =>$bfileName,
                       'promotion_url' =>isset($getData['promotion_url1']) ? $getData['promotion_url1'] : '',
                      'tab_type' =>isset($getData['opt1']) ? $getData['opt1'] : 0 ,
                      'promotion_description' => $getData['promotion_description'],
                      'IsActive' =>1,
                      'IsmarkForDel' =>0,
                  ];
                }else if($getData['templatetype'] == 2){

                     $promotion_image2 = $_FILES['promotion_image2']['name'];
                    $bfileName = '';
                    if (!empty($promotion_image2)) {
                        $orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->promoimageUrl.$lastInsertId;
                        $fileExtion = $this->_helper->General->getFileExtension($promotion_image2);
                        $bfileName = $this->current_time . 'promo'.'_2.' . $fileExtion;
                        if (!file_exists($orignalFolderName)) {
                            mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
                        }
                        $temp_file_name = $_FILES["promotion_image2"]["tmp_name"]; // temprary file name

                        @move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $bfileName);

                        $originalLargeFolder = $orignalFolderName.'/large';
                        $originalMediumFolder = $orignalFolderName.'/medium';
                        $originalSmallFolder = $orignalFolderName.'/small';

                        Catabatic_Helper::resizeImages($orignalFolderName,$originalLargeFolder,$bfileName,$this->large_image_width,$this->large_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalMediumFolder,$bfileName,$this->medium_image_width,$this->medium_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalSmallFolder,$bfileName,$this->small_image_width,$this->small_image_height);


                    }

                    $promotion_urlArr = ['promotion_tag_url1'=>$getData['promotion_tag_url1'],'promotion_tag_url2'=>$getData['promotion_tag_url2'],'promotion_tag_url3'=>$getData['promotion_tag_url3'],'promotion_tag_url4'=>$getData['promotion_tag_url4']];
                    $promotion_tagArr = ['promotion_tag1'=>$getData['promotion_tag1'],'promotion_tag2'=>$getData['promotion_tag2'],'promotion_tag3'=>$getData['promotion_tag3'],'promotion_tag4'=>$getData['promotion_tag4']];
                    $tabTypelArr = ['tagopt1'=>isset($getData['tagopt1']) ? 1:0,'tagopt2'=>isset($getData['tagopt2']) ? 1: 0,'tagopt3'=>isset($getData['tagopt3']) ? 1: 0,'tagopt4'=>isset($getData['tagopt4']) ? 1 :0];

                  $savePageData = [
                      'templatetype' =>$getData['templatetype'],

                      'promotion_name' =>  json_encode($promotion_tagArr),
                      'promotion_image' =>$bfileName,
                      'promotion_url' =>  json_encode($promotion_urlArr),
                      'tab_type' =>  json_encode($tabTypelArr) ,
                      'promotion_description' =>'',
                      'IsActive' =>1,
                      'IsmarkForDel' =>0,
                  ];
                }else if($getData['templatetype'] == 3){
                    $promotion_image3 = $_FILES['promotion_image3']['name'];
                    $bfileName = '';
                    if (!empty($promotion_image3)) {
                        $orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->promoimageUrl.$lastInsertId;
                        $fileExtion = $this->_helper->General->getFileExtension($promotion_image3);
                        $bfileName = $this->current_time . 'promo'.'_3.' . $fileExtion;
                        if (!file_exists($orignalFolderName)) {
                            mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
                        }
                        $temp_file_name = $_FILES["promotion_image3"]["tmp_name"]; // temprary file name

                        @move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $bfileName);

                        $originalLargeFolder = $orignalFolderName.'/large';
                        $originalMediumFolder = $orignalFolderName.'/medium';
                        $originalSmallFolder = $orignalFolderName.'/small';

                        Catabatic_Helper::resizeImages($orignalFolderName,$originalLargeFolder,$bfileName,$this->large_image_width,$this->large_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalMediumFolder,$bfileName,$this->medium_image_width,$this->medium_image_height);
                        Catabatic_Helper::resizeImages($orignalFolderName,$originalSmallFolder,$bfileName,$this->small_image_width,$this->small_image_height);

                    }


                  $savePageData = [
                      'templatetype' =>$getData['templatetype'],

                      'promotion_name' =>'',
                      'promotion_image' =>$bfileName,
                      'promotion_url' =>$getData['promotion_url3'],
                      'tab_type' =>isset($getData['opt3']) ? $getData['opt3'] : 0 ,
                      'promotion_description' => '',
                      'IsActive' =>1,
                      'IsmarkForDel' =>0,
                  ];

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




                $crud->rv_insert($this->table, $savePageData);

                $this->view->successMessage = "Page content has been saved successfully.";
                $this->_helper->flashMessenger->addMessage("Page content has been added successfully.");
                $this->_redirect("/admin/homepromotion/index");

             }

          }
        }


        $this->view->messages   = $this->_helper->flashMessenger->getMessages();
        $this->view->resultCategory   = $resultCategory;


    }
    public function promotioncategoryAction(){

        $this->checklogin();
        $crud = new Admin_Model_CRUD();

        if( $this->getRequest()->isPost() ) {
            $getData = $this->getRequest()->getPost();
            if($getData) {
                //-------Start Code for Approve and Publish content---------//
        if (isset($getData['save']) == "Save") {
            $pId = $getData['prom_cat_id'];
            $editPageData = [
                      'prom_cat_one' =>$getData['categoryheadingOne'],
                      'prom_cat_two' =>$getData['categoryheadingTwo'],
                      'prom_cat_three' =>$getData['categoryheadingThree'],
                      'IsActive' =>1,
                      'IsmarkForDel' =>0,
                  ];

           $prom_cat_id = $crud->rv_update('tbl_promotion_category', $editPageData, ['prom_cat_id =?' => $pId]);


        }

        }
         $this->view->successMessage = "Page content has been updated successfully.";
        }
         $result = $crud->getCmsdata('tbl_promotion_category', ['*'], ['prom_cat_id'], ['prom_cat_id'=>'DESC']);
         $editdata["prom_cat_one"] = @$result->prom_cat_one;
         $editdata["prom_cat_two"] = @$result->prom_cat_two;
         $editdata["prom_cat_three"] = @$result->prom_cat_three;
         $editdata["prom_cat_id"] = @$result->prom_cat_id;
         $this->view->editdata = $editdata;
    }


    public function promotioncontantAction(){

        $this->checklogin();
        $crud = new Admin_Model_CRUD();

        if( $this->getRequest()->isPost() ) {
            $getData = $this->getRequest()->getPost();
            //echo "<pre>";print_r($getData);die;
            if($getData) {
                //-------Start Code for Approve and Publish content---------//
        if (isset($getData['save']) == "Save") {
            $pId = $getData['home_common_id'];

            $destinationTitle = isset($getData['destinationTitle']) ? trim($getData['destinationTitle']) : '';
            $destinationDescription = isset($getData['destinationDescription']) ? trim($getData['destinationDescription']) : '';
            $destinations_check = isset($getData['destinations_check']) ? trim($getData['destinations_check']) : 0;
            $destination_order_byhome = isset($getData['destination_order_byhome']) ? trim($getData['destination_order_byhome']) : '';
            $themeTitle = isset($getData['themeTitle']) ? trim($getData['themeTitle']) : '';
            $themeDescription = isset($getData['themeDescription']) ? trim($getData['themeDescription']) : '';
            $theme_check = isset($getData['theme_check']) ? trim($getData['theme_check']) : '';
            $theme_order_byhome = isset($getData['theme_order_byhome']) ? trim($getData['theme_order_byhome']) : '';
            $internationalTourTitle = isset($getData['internationalTourTitle']) ? trim($getData['internationalTourTitle']) : '';
            $internationalTourDescription = isset($getData['internationalTourDescription']) ? trim($getData['internationalTourDescription']) : '';
            $international_check = isset($getData['international_check']) ? trim($getData['international_check']) : '';
            $international_order_byhome = isset($getData['international_order_byhome']) ? trim($getData['international_order_byhome']) : '';
            $domesticTourTitle = isset($getData['domesticTourTitle']) ? trim($getData['domesticTourTitle']) : '';
            $domesticTourDescription = isset($getData['domesticTourDescription']) ? trim($getData['domesticTourDescription']) : '';
            $domestic_check = isset($getData['domestic_check']) ? trim($getData['domestic_check']) : '';
            $domestic_order_byhome = isset($getData['domestic_order_byhome']) ? trim($getData['domestic_order_byhome']) : '';
            $testimonialTitle = isset($getData['testimonialTitle']) ? trim($getData['testimonialTitle']) : '';
            $testimonialDescription = isset($getData['testimonialDescription']) ? trim($getData['testimonialDescription']) : '';
            $testmonial_check = isset($getData['testmonial_check']) ? trim($getData['testmonial_check']) : '';
            $testmonial_order_byhome = isset($getData['testmonial_order_byhome']) ? trim($getData['testmonial_order_byhome']) : '';

            $blogTitle = isset($getData['blogTitle']) ? trim($getData['blogTitle']) : '';
            $blogDescription = isset($getData['blogDescription']) ? trim($getData['blogDescription']) : '';
            $blog_check = isset($getData['blog_check']) ? trim($getData['blog_check']) : '';
            $blog_order_byhome = isset($getData['blog_order_byhome']) ? trim($getData['blog_order_byhome']) : '';

            $offersTitle = isset($getData['offersTitle']) ? trim($getData['offersTitle']) : '';
            $offersDescription = isset($getData['offersDescription']) ? trim($getData['offersDescription']) : '';
            $offers_check = isset($getData['offers_check']) ? trim($getData['offers_check']) : '';
            $offers_order_byhome = isset($getData['offers_order_byhome']) ? trim($getData['offers_order_byhome']) : '';
			
			    $countriesTitle = isset($getData['countriesTitle']) ? trim($getData['countriesTitle']) : '';
            $countriesDescription = isset($getData['countriesDescription']) ? trim($getData['countriesDescription']) : '';
            $countries_check = isset($getData['countries_check']) ? trim($getData['countries_check']) : '';
            $countries_order_byhome = isset($getData['countries_order_byhome']) ? trim($getData['countries_order_byhome']) : '';
			
			    $statesTitle = isset($getData['statesTitle']) ? trim($getData['statesTitle']) : '';
            $statesDescription = isset($getData['statesDescription']) ? trim($getData['statesDescription']) : '';
            $states_check = isset($getData['states_check']) ? trim($getData['states_check']) : '';
            $states_order_byhome = isset($getData['states_order_byhome']) ? trim($getData['states_order_byhome']) : '';
           
            $whychooseusTitle = isset($getData['whychooseusTitle']) ? trim($getData['whychooseusTitle']) : '';
            $whychooseus_check = isset($getData['whychooseus_check']) ? trim($getData['whychooseus_check']) : '';
            $whychooseus_order_byhome = isset($getData['whychooseus_order_byhome']) ? trim($getData['whychooseus_order_byhome']) : '';

            $happycustomerTitle = isset($getData['happycustomerTitle']) ? trim($getData['happycustomerTitle']) : '';
            $happycustomer_check = isset($getData['happycustomer_check']) ? trim($getData['happycustomer_check']) : '';
            $happycustomer_order_byhome = isset($getData['happycustomer_order_byhome']) ? trim($getData['happycustomer_order_byhome']) : '';

       
            $destinationContent = json_encode(array('destinationTitle'=>$destinationTitle,'destinationDescription'=>$destinationDescription,'destinations_check'=>$destinations_check,'destination_order_byhome'=>$destination_order_byhome));
            $popularTourContent = json_encode(array('internationalTourTitle'=>$internationalTourTitle,'internationalTourDescription'=>$internationalTourDescription,'international_check'=>$international_check,'international_order_byhome'=>$international_order_byhome));
            $perfectTourContent = json_encode(array('domesticTourTitle'=>$domesticTourTitle,'domesticTourDescription'=>$domesticTourDescription,'domestic_check'=>$domestic_check,'domestic_order_byhome'=>$domestic_order_byhome));
            $blogContent = json_encode(array('blogTitle'=>$blogTitle,'blogDescription'=>$blogDescription,'blogDescription'=>$blogDescription,'blog_check'=>$blog_check,'blog_order_byhome'=>$blog_order_byhome));

            $offersContent = json_encode(array('offersTitle'=>$offersTitle,'offersDescription'=>$offersDescription,'offersDescription'=>$offersDescription,'offers_check'=>$offers_check,'offers_order_byhome'=>$offers_order_byhome));
            $happycustomerContent = json_encode(array('happycustomerTitle'=>$happycustomerTitle,'happycustomer_check'=>$happycustomer_check,'happycustomer_order_byhome'=>$happycustomer_order_byhome));
            $whychooseusContent = json_encode(array('whychooseusTitle'=>$whychooseusTitle,'whychooseus_check'=>$whychooseus_check,'whychooseus_order_byhome'=>$whychooseus_order_byhome));
            $otherUsefulContent = json_encode(array('themeTitle'=>$themeTitle,'themeDescription'=>$themeDescription,'theme_check'=>$theme_check,'theme_order_byhome'=>$theme_order_byhome));
            $interestingFactsContent = json_encode(array('testimonialTitle'=>$testimonialTitle,'testimonialDescription'=>$testimonialDescription,'testmonial_check'=>$testmonial_check,'testmonial_order_byhome'=>$testmonial_order_byhome));
			
			$statesContent = json_encode(array('statesTitle'=>$statesTitle,'statesDescription'=>$statesDescription,'statesDescription'=>$statesDescription,'states_check'=>$states_check,'states_order_byhome'=>$states_order_byhome));
			
			$countriesContent = json_encode(array('countriesTitle'=>$countriesTitle,'countriesDescription'=>$countriesDescription,'countriesDescription'=>$countriesDescription,'countries_check'=>$countries_check,'countries_order_byhome'=>$countries_order_byhome));
			
			$qaArray = array();
                    foreach ($getData['faq_question'] as $qKey => $qValue) {
                        $qaArray[$qKey] = [
                            'question' => $qValue,
                            'answer' => $getData['faq_answer'][$qKey],
                        ];
                    }

            $editPageData = [
                      'popularTourContent' =>$popularTourContent,
                      'destinationContent' =>$destinationContent,
                      'perfectTourContent' =>$perfectTourContent,
                      'blogContent' =>$blogContent,
                      'offersContent' =>$offersContent,
                      'statesContent' =>$statesContent,
                      'countriesContent' =>$countriesContent,
                      'whychooseusContent' =>$whychooseusContent,
                      'happycustomerContent' => $happycustomerContent,
                      'otherUsefulContent' =>$otherUsefulContent,
                      'interestingFactsContent' =>$interestingFactsContent,
					  'FAQschema' => ($getData['FAQschema']), 
					  'HTagDescription' => ($getData['HTagDescription']), 
					   'FAQ' => (!empty($qaArray)) ? json_encode($qaArray) :'',
                      'status' =>1
                  ];

           $prom_cat_id=$crud->rv_update('tbl_home_common_box', $editPageData, ['home_common_id =?' =>1]);


        }

        }
         $this->view->successMessage = "Page content has been updated successfully.";
        }

$result = $crud->getCmsdata('tbl_home_common_box', ['*'], ['home_common_id'=>1], ['home_common_id'=>'DESC']);

         $popularTourContent = json_decode($result->popularTourContent,1);
         $destinationContent = json_decode($result->destinationContent,1);
         $perfectTourContent = json_decode($result->perfectTourContent,1);
         $blogContent = json_decode($result->blogContent,1);
         $offersContent = json_decode($result->offersContent,1);
         $statesContent = json_decode($result->statesContent,1);
         $countriesContent = json_decode($result->countriesContent,1);
         $whychooseusContent = json_decode($result->whychooseusContent,1);
         $happycustomerContent = json_decode($result->happycustomerContent,1);
         $otherUsefulContent = json_decode($result->otherUsefulContent,1);
         $interestingFactsContent = json_decode($result->interestingFactsContent,1);


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




         $editdata["internationalTourTitle"] = $popularTourContent['internationalTourTitle'];
         $editdata["internationalTourDescription"] = $popularTourContent['internationalTourDescription'];
         $editdata["international_check"] = $popularTourContent['international_check'];
         $editdata["international_order_byhome"] = $popularTourContent['international_order_byhome'];
         $editdata["destinationTitle"] = $destinationContent['destinationTitle'];
         $editdata["destinationDescription"] = $destinationContent['destinationDescription'];
         $editdata["destinations_check"] = $destinationContent['destinations_check'];
         $editdata["destination_order_byhome"] = $destinationContent['destination_order_byhome'];
         $editdata["domesticTourTitle"] = $perfectTourContent['domesticTourTitle'];
         $editdata["domesticTourDescription"] = $perfectTourContent['domesticTourDescription'];
         $editdata["domestic_check"] = $perfectTourContent['domestic_check'];
         $editdata["domestic_order_byhome"] = $perfectTourContent['domestic_order_byhome'];
        
         $editdata["blogTitle"] = $blogContent['blogTitle'];
         $editdata["blogDescription"] = $blogContent['blogDescription'];
         $editdata["blog_check"] = $blogContent['blog_check'];
         $editdata["blog_order_byhome"] = $blogContent['blog_order_byhome'];

         $editdata["offersTitle"] = $offersContent['offersTitle'];
         $editdata["offersDescription"] = $offersContent['offersDescription'];
         $editdata["offers_check"] = $offersContent['offers_check'];
         $editdata["offers_order_byhome"] = $offersContent['offers_order_byhome'];
		 
		 $editdata["statesTitle"] = $statesContent['statesTitle'];
         $editdata["statesDescription"] = $statesContent['statesDescription'];
         $editdata["states_check"] = $statesContent['states_check'];
         $editdata["states_order_byhome"] = $statesContent['states_order_byhome'];
		 
		 $editdata["countriesTitle"] = $countriesContent['countriesTitle'];
         $editdata["countriesDescription"] = $countriesContent['countriesDescription'];
         $editdata["countries_check"] = $countriesContent['countries_check'];
         $editdata["countries_order_byhome"] = $countriesContent['countries_order_byhome'];

         $editdata["whychooseusTitle"] = $whychooseusContent['whychooseusTitle'];
         $editdata["whychooseus_check"] = $whychooseusContent['whychooseus_check'];
         $editdata["whychooseus_order_byhome"] = $whychooseusContent['whychooseus_order_byhome'];


         $editdata["happycustomerTitle"] = $happycustomerContent['happycustomerTitle'];
         $editdata["happycustomer_check"] = $happycustomerContent['happycustomer_check'];
         $editdata["happycustomer_order_byhome"] = $happycustomerContent['happycustomer_order_byhome'];

         $editdata["themeTitle"] = $otherUsefulContent['themeTitle'];
         $editdata["themeDescription"] = $otherUsefulContent['themeDescription'];
         $editdata["theme_check"] = $otherUsefulContent['theme_check'];
         $editdata["theme_order_byhome"] = $otherUsefulContent['theme_order_byhome'];
         $editdata["testimonialTitle"] = $interestingFactsContent['testimonialTitle'];
         $editdata["testimonialDescription"] = $interestingFactsContent['testimonialDescription'];
         $editdata["testmonial_check"] = $interestingFactsContent['testmonial_check'];
         $editdata["testmonial_order_byhome"] = $interestingFactsContent['testmonial_order_byhome'];

         $editdata["FAQschema"] = @$result->FAQschema;
         $editdata["HTagDescription"] = @$result->HTagDescription;
		 $editdata["FAQ"] = $result->FAQ;

         $this->view->editdata = $editdata;





    }



    public function deletepromotionAction() {
        $this->checklogin();
        $crud = new Admin_Model_CRUD();
        $tId = (int) $this->getRequest()->getParam("id");
        //echo $tId;die;
        if ($tId) {
            $checkdata = $crud->rv_select_row($this->table, ['promotionId'], ['promotionId' => $tId], ['promotionId' => 'asc']);
            if (count($checkdata) > 0) {
                $crud->rv_update($this->table, ['IsMarkForDel'=> 1], ['promotionId =?'=>$tId]);
                $this->_helper->flashMessenger->addMessage("Deleted successfully.");
                $this->_redirect("/admin/homepromotion/index");
            } else {
                die('Oops some thing wrong!!.');
            }
        }
    }

    public function activeAction() {
        $this->checklogin();
        $crud = new Admin_Model_CRUD();
        $tId = (int) $this->getRequest()->getParam("id");
        $val = (int) $this->getRequest()->getParam("val");
        $type = (int) $this->getRequest()->getParam("type");
        if ($tId) {
            try {
                $updatedata = [
                    'IsFeatured' => $val
                ];

                $result = $crud->rv_update($this->table, $updatedata, ['promotionId =?' => $tId]);
                if($type == 1){
                    $resultset = $crud->rv_select_all($this->table, ['*'] ,['templatetype'=>$type,'IsFeatured'=>1,'IsMarkForDel'=>0], ['promotionId'=>'ASC'] );
                if(count($resultset)>10){
                   $result_message = ['status' => false, 'message' => 'Limit Exceed!!'];
                    echo Zend_Json::encode($result_message);
                    $updatedata = [
                    'IsFeatured' => 0
                ];
                    $result = $crud->rv_update($this->table, $updatedata, ['promotionId =?' => $tId]);
                    exit;
                }
                }elseif($type == 2){
                     $resultset = $crud->rv_select_all($this->table, ['*'] ,['templatetype'=>$type,'IsFeatured'=>1,'IsMarkForDel'=>0], ['promotionId'=>'ASC'] );
                if(count($resultset)>1){
                   $result_message = ['status' => false, 'message' => 'Limit Exceed!!'];
                    echo Zend_Json::encode($result_message);
                    $updatedata = [
                    'IsFeatured' => 0
                ];
                    $result = $crud->rv_update($this->table, $updatedata, ['promotionId =?' => $tId]);
                    exit;
                }
                }else if($type == 3){
                     $resultset = $crud->rv_select_all($this->table, ['*'] ,['templatetype'=>$type,'IsFeatured'=>1,'IsMarkForDel'=>0], ['promotionId'=>'ASC'] );
                if(count($resultset)>1){
                   $result_message = ['status' => false, 'message' => 'Limit Exceed!!'];
                    echo Zend_Json::encode($result_message);
                    $updatedata = [
                    'IsFeatured' => 0
                ];
                    $result = $crud->rv_update($this->table, $updatedata, ['promotionId =?' => $tId]);
                    exit;
                }
                }

                if (!$result) {
                    $result_message = ['status' => false, 'message' => 'Oops something wrong!!'];
                    echo Zend_Json::encode($result_message);
                    exit;
                } else {
                    $result_message = ['status' => true, 'message' => 'Active successfully'];
                    echo Zend_Json::encode($result_message);
                    exit;
                }
            } catch (Exception $ex) {
                $ex->getMessage();
            }
        }
    }

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



    /**
    * 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');
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit