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/tripsgateway/application/admin/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/tripsgateway/application/admin/controllers/BlogController(20_09_2018_multi).php
<?php
/***************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name     : StaticpageController.php
* File Desc.    : Staticpage controller managed all staic content pages
* Created By    : Ranvir Singh <ranvir@catpl.co.in>
* Created Date  : 23 May 2017
* Updated Date  : 23 May 2017
***************************************************************/



class Admin_BlogController 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->siteurl           = $aConfig['bootstrap']['siteUrl']; 
		$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->imageUrl     = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/blog/';

        
        $this->img_w_thumb  = 64;
        $this->img_h_thumb  = 64;
        $this->img_w_medium = 220;
        $this->img_h_medium = 180;

        $this->img_w_large = 427;
        $this->img_h_large = 326;
        $this->img_w_banner = 800;
        $this->img_h_banner = 300;
        
        
        $this->img_w_small  = 558;
        $this->img_h_small  = 438;

        $this->DIR_WRITE_MODE = 0777;
        
       $this->table =  'tbl_blog';
     
    }
    
    
    
    /**
    * index() method is used to admin login for form call
    * @param Null
    * @return Array 
    */
    
    public function indexAction()
    {
        //Check admin logedin or not
        $this->checklogin();
        $crud   = new Admin_Model_CRUD();
        $resultset  = $crud->rv_select_all($this->table, ['*'],  ['IsMarkForDel'=>0], ['BlogId'=>'DESC']);
//        echo "<pre>";print_r($resultset);die;
        $result_destination = $crud->rv_select_all("tb_tbb2c_destinations", ['*'] ,['IsPublish'=>1,'IsMarkForDel'=>0], ['Title'=>'ASC'] );     
              
        # Start : Pagination 
        $page       = $this->_getParam('page', 1);
        $resultset  = Zend_Paginator::factory($resultset);
        $resultset->setItemCountPerPage($this->per_page_record);
        $resultset->setCurrentPageNumber($page);
        # End : Pagination
        $this->view->page  = $page;
        $this->view->per_page_record  = $this->per_page_record;
        $this->view->resultset  = $resultset;
        $this->view->result_destination  = $result_destination;
        $this->view->messages   = $this->_helper->flashMessenger->getMessages();
    }
    
    
    
    /**
    * editpage() method is used to admin can edit cms static page
    * @param password string
    * @return ture 
    */
    
    public function editblogAction()
    {
        
//Check admin logedin or not
        $this->checklogin();
        $crud = new Admin_Model_CRUD();
        $form = new Admin_Form_Editblog();
        $pId = (int)$this->getRequest()->getParam("id");
        $form->setMethod("POST");
        $form->setAction("admin/blog/editblog/id/".$pId);
        
        $form->setName("edit_blog");
               
        if( $this->getRequest()->isPost() ) {
            $getData = $this->getRequest()->getPost();
          
            if($form->isValid($getData)) {
                
                //-------Start Code for Approve and Publish content---------//
               if(isset($getData['save'])=="Save") {
                  $result = $crud->getCmsdata($this->table, ['*'], ['BlogId'=>$pId], ['BlogId'=>'DESC']);
//                         echo "<pre>";print_r($getData);
                   $BlogId = $getData['BlogId'];
              $images = $_FILES['image']['name'];
                $orignalFIleName = $image = $_FILES["BlogImage"]["name"];

                  foreach($images as $key => $orignalMultiFileName) {
                    if (!empty($orignalMultiFileName)) {

                        $orignalMultiFolderName  = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrl . $BlogId . "/images"; // root folder for destination images


                        /* Get File Extension */
                       $fileExt1    = $this->_helper->General->getFileExtension($orignalMultiFileName);
                       $fileName1   = $BlogId . '_' . $this->current_time .'_'.$key.'.' . $fileExt1;
                        $originalMultiThumbFolder    = $orignalMultiFolderName. "/thumb";
                        $originalMultiMediumFolder   = $orignalMultiFolderName. "/medium";
                        $originalMultiLargeFolder    = $orignalMultiFolderName. "/large";


                        /* Create directory if not exists */
                        if (!file_exists($orignalMultiFolderName)) {
                            mkdir($orignalMultiFolderName, $this->DIR_WRITE_MODE, true);
                        }
                        if (!file_exists($originalMultiThumbFolder)) {
                            mkdir($originalMultiThumbFolder, $this->DIR_WRITE_MODE, true);
                        }
                        if (!file_exists($originalMultiMediumFolder)) {
                            mkdir($originalMultiMediumFolder, $this->DIR_WRITE_MODE, true);
                        }
                        if (!file_exists($originalMultiLargeFolder)) {
                            mkdir($originalMultiLargeFolder, $this->DIR_WRITE_MODE, true);
                        }
                        foreach($_FILES["image"]["tmp_name"] as $key1 => $image){
                            if($key == $key1){
                                            $temp_file_name1 =  $image;// temprary file name
                            } 
                        }
                        @move_uploaded_file($temp_file_name1, $orignalMultiFolderName . "/" . $fileName1);

                        @copy($orignalMultiFolderName . '/' . $fileName1, $originalMultiLargeFolder . "/" . $fileName1); // copy uploaded file into this location directory
                        $objImageResize4 = new Catabatic_Imageresize($originalMultiLargeFolder . '/' . $fileName1);
                        $objImageResize4->resizeImage($this->img_w_large, $this->img_h_large, 'exact'); // param : width , height , (exact|portrait|landscape|auto|crop)
                        $objImageResize4->saveImage($originalMultiLargeFolder . '/' . $fileName1);

                        @copy($orignalMultiFolderName . '/' . $fileName1, $originalMultiThumbFolder . "/" . $fileName1); // copy uploaded file into this location directory
                        $objImageResize1 = new Catabatic_Imageresize($originalMultiThumbFolder . '/' . $fileName1);
                        $objImageResize1->resizeImage($this->img_w_thumb, $this->img_h_thumb, 'exact'); // param : width , height , (exact|portrait|landscape|auto|crop)
                        $objImageResize1->saveImage($originalMultiThumbFolder . '/' . $fileName1);

                        @copy($orignalMultiFolderName . '/' . $fileName1, $originalMultiMediumFolder . "/" . $fileName1); // copy uploaded file into this location directory
                        $objImageResize2 = new Catabatic_Imageresize($originalMultiMediumFolder . '/' . $fileName1);
                        $objImageResize2->resizeImage($this->img_w_medium, $this->img_h_medium, 'exact'); // param : width , height , (exact|portrait|landscape|auto|crop)
                        $objImageResize2->saveImage($originalMultiMediumFolder . '/' . $fileName1);
                        
                        $path_image = "public/upload/blog/".$BlogId."/images/".$fileName1;
                        @unlink($path_image);
                    }
                    else {
    //                    echo 'else'; die;
                    }
                
                }
                
                if (!empty($orignalFIleName)) {
                                 $orignalFolderName  = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrl . $BlogId . "/images";
                                 $fileExt    = $this->_helper->General->getFileExtension($orignalFIleName);
                                 $fileName   = $BlogId . '_' . $this->current_time . '.' . $fileExt;
                                  $originalMainFolder    = $orignalFolderName. "/main";
                                    if (!file_exists($originalMainFolder)) {
                                        mkdir($originalMainFolder, $this->DIR_WRITE_MODE, true);
                                        }
                                  $temp_file_name = $_FILES["BlogImage"]["tmp_name"]; // temprary file name
                                    @move_uploaded_file($temp_file_name, $originalMainFolder . "/" . $fileName);
     
                             }

                            
                    $image_add = "";
                    $multiImage = "";
                            
                            
                            
                    if( $fileName1 ) 
                    {                
                        foreach($images as $key => $image){
                         
                            $fileExt1    = $this->_helper->General->getFileExtension($image);
                            $fileName1   = $BlogId . '_' . $this->current_time .'_'.$key.'.' . $fileExt1;
                        $editHotelsData[] = $fileName1;
                        }
                        $multiImage  = $newimagenames = @implode(",",$editHotelsData);
                    }
                    if( $fileName ) 
                    { 
                            $fileExt    = $this->_helper->General->getFileExtension($orignalFIleName);
                            $fileNamenew   = $BlogId . '_' . $this->current_time .'.' . $fileExt;
                        $image_add = $fileNamenew;
                    }
                    
                    
                    
                     $oldimagenames = $result['images'];
                    $editHotelsData = "$oldimagenames";
                      
                    if(trim($newimagenames)) 
                    $editHotelsData .= ",$newimagenames";
                    $editHotelsData = trim($editHotelsData, ',');
                 
                
                $editPageData = [                    
                    
                        'BlogTitle' => ($getData['BlogTitle']),                       

                        'BlogDate' => ($getData['BlogDate']),
                        'PostedBy' => ($getData['PostedBy']),                     
                        'BlogDescription' => ($getData['BlogDescription']),
                        'UpdateDate'=> date('Y-m-d H:i:s') ,
                        'status' => ($getData['status']),
                ];
                                
                     if( $fileName) {
                        $editPageData['BlogImage'] = $fileName;
                                }
                       if( $fileName1) {
                        $editPageData['images'] = $editHotelsData;
                                }
//                  echo "<pre>";print_r($editPageData);die;
                                $crud->rv_update($this->table, $editPageData, ['BlogId =?'=>$BlogId]);
                                $this->view->successMessage ="Page content has been saved successfully.";
                                $this->_helper->flashMessenger->addMessage("Page content has been updated successfully.");
                                $this->_redirect("/admin/blog/index");
                            }
                           
                       
  
              
             
          }
        }

        $result = $crud->getCmsdata($this->table, ['*'], ['BlogId'=>$pId], ['BlogId'=>'DESC']);
//        echo "<pre>";print_r($result);die;
        $editdata["BlogId"] = @$result->BlogId;
        $editdata["BlogTitle"] = @$result->BlogTitle;
         $editdata["BlogDate"] = @$result->BlogDate;
        $editdata["PostedBy"] = @$result->PostedBy;
        $editdata["BlogImage"] = @$result->BlogImage;
        $editdata["images"] = @$result->images;
        $editdata["BlogDescription"] = @$result->BlogDescription;
        $editdata["status"] = @$result->status;
//        echo "<pre>";print_r($editdata);die;
        $form->populate($editdata);        
        $this->view->BlogImage = @$result->BlogImage; 
//        echo "<pre>";print_r($result->images);die;
        $this->view->images = @$result->images; 
        $this->view->form = $form;
        $this->view->BlogId = $result->BlogId;
        
                    
    }
    
     
    public function addblogAction()
    {
       
//Check admin logedin or not
        $this->checklogin();
        $crud = new Admin_Model_CRUD();
        $resultsetBlog  = $crud->rv_select_all($this->table, ['BlogId'],  ['IsMarkForDel'], ['BlogId'=>'DESC'],1);
        $lastInsertId = $resultsetBlog[0]['BlogId'] + 1;
        $form = new Admin_Form_Editblog();
        $pId = (int)$this->getRequest()->getParam("id");
        $form->setMethod("POST");
        $form->setAction("admin/blog/addblog");
        $form->setName("edit_blog");
               
        if( $this->getRequest()->isPost() ) {
            $getData = $this->getRequest()->getPost(); 
           
            if($form->isValid($getData)) {
               
                //-------Start Code for Approve and Publish content---------//
               if (isset($getData['save']) == "Save") {
//                echo "<pre>";print_r($getData);die;
                $images = $_FILES['image']['name'];
                $orignalFIleName = $image = $_FILES["BlogImage"]["name"];

                  foreach($images as $key => $orignalMultiFileName) {
                    if (!empty($orignalMultiFileName)) {

                        $orignalMultiFolderName  = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrl . $lastInsertId . "/images"; // root folder for destination images


                        /* Get File Extension */
                       $fileExt1    = $this->_helper->General->getFileExtension($orignalMultiFileName);
                       $fileName1   = $lastInsertId . '_' . $this->current_time .'_'.$key.'.' . $fileExt1;
                        $originalMultiThumbFolder    = $orignalMultiFolderName. "/thumb";
                        $originalMultiMediumFolder   = $orignalMultiFolderName. "/medium";
                        $originalMultiLargeFolder    = $orignalMultiFolderName. "/large";


                        /* Create directory if not exists */
                        if (!file_exists($orignalMultiFolderName)) {
                            mkdir($orignalMultiFolderName, $this->DIR_WRITE_MODE, true);
                        }
                        if (!file_exists($originalMultiThumbFolder)) {
                            mkdir($originalMultiThumbFolder, $this->DIR_WRITE_MODE, true);
                        }
                        if (!file_exists($originalMultiMediumFolder)) {
                            mkdir($originalMultiMediumFolder, $this->DIR_WRITE_MODE, true);
                        }
                        if (!file_exists($originalMultiLargeFolder)) {
                            mkdir($originalMultiLargeFolder, $this->DIR_WRITE_MODE, true);
                        }
                        foreach($_FILES["image"]["tmp_name"] as $key1 => $image){
                            if($key == $key1){
                                            $temp_file_name1 =  $image;// temprary file name
                            } 
                        }
                        @move_uploaded_file($temp_file_name1, $orignalMultiFolderName . "/" . $fileName1);

                        @copy($orignalMultiFolderName . '/' . $fileName1, $originalMultiLargeFolder . "/" . $fileName1); // copy uploaded file into this location directory
                        $objImageResize4 = new Catabatic_Imageresize($originalMultiLargeFolder . '/' . $fileName1);
                        $objImageResize4->resizeImage($this->img_w_large, $this->img_h_large, 'exact'); // param : width , height , (exact|portrait|landscape|auto|crop)
                        $objImageResize4->saveImage($originalMultiLargeFolder . '/' . $fileName1);

                        @copy($orignalMultiFolderName . '/' . $fileName1, $originalMultiThumbFolder . "/" . $fileName1); // copy uploaded file into this location directory
                        $objImageResize1 = new Catabatic_Imageresize($originalMultiThumbFolder . '/' . $fileName1);
                        $objImageResize1->resizeImage($this->img_w_thumb, $this->img_h_thumb, 'exact'); // param : width , height , (exact|portrait|landscape|auto|crop)
                        $objImageResize1->saveImage($originalMultiThumbFolder . '/' . $fileName1);

                        @copy($orignalMultiFolderName . '/' . $fileName1, $originalMultiMediumFolder . "/" . $fileName1); // copy uploaded file into this location directory
                        $objImageResize2 = new Catabatic_Imageresize($originalMultiMediumFolder . '/' . $fileName1);
                        $objImageResize2->resizeImage($this->img_w_medium, $this->img_h_medium, 'exact'); // param : width , height , (exact|portrait|landscape|auto|crop)
                        $objImageResize2->saveImage($originalMultiMediumFolder . '/' . $fileName1);
                            $path_image = "public/upload/blog/".$lastInsertId."/images/".$fileName1;
                            @unlink($path_image);
                    }
                    else {
    //                    echo 'else'; die;
                    }
                
                }
                
                if (!empty($orignalFIleName)) {
                                 $orignalFolderName  = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrl . $lastInsertId . "/images";
                                 $fileExt    = $this->_helper->General->getFileExtension($orignalFIleName);
                                 $fileName   = $lastInsertId . '_' . $this->current_time . '.' . $fileExt;
                                  $originalMainFolder    = $orignalFolderName. "/main";
                                    if (!file_exists($originalMainFolder)) {
                                        mkdir($originalMainFolder, $this->DIR_WRITE_MODE, true);
                                        }
                                  $temp_file_name = $_FILES["BlogImage"]["tmp_name"]; // temprary file name
                                    @move_uploaded_file($temp_file_name, $originalMainFolder . "/" . $fileName);
     
                             }

                            
                    $image_add = "";
                    $multiImage = "";
                            
                            
                            
                    if( $fileName1 ) 
                    {                
                        foreach($images as $key => $image){
                         
                            $fileExt1    = $this->_helper->General->getFileExtension($image);
                            $fileName1   = $lastInsertId . '_' . $this->current_time .'_'.$key.'.' . $fileExt1;
                        $editHotelsData[] = $fileName1;
                        }
                        $multiImage  = @implode(",",$editHotelsData);
                    }
                    if( $fileName ) 
                    { 
                            $fileExt    = $this->_helper->General->getFileExtension($orignalFIleName);
                            $fileNamenew   = $lastInsertId . '_' . $this->current_time .'.' . $fileExt;
                        $image_add = $fileNamenew;
                    }
                    
      
//                $BlogDate1 = explode('/', $getData['BlogDate']);
//                $BlogDate = $BlogDate1[2]."-".$BlogDate1[1]."-".$BlogDate[0];
                
                $savePageData = [                    
                    'BlogTitle' => ($getData['BlogTitle']),
                    'BlogDate' => ($getData['BlogDate']),
                    'PostedBy' => ($getData['PostedBy']),
                    'BlogImage' =>   $image_add ,
                    'images' =>   $multiImage ,
                    'BlogDescription' => ($getData['BlogDescription']),
                    'CreateDate'=> date('Y-m-d H:i:s') ,
                    'status' => ($getData['status']),
                    '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/blog/index");
            
             }  
             
          }
        }

         $this->view->form = $form;
        $this->view->messages   = $this->_helper->flashMessenger->getMessages();
        
                    
    }
    
    
    
    public function deleteblogAction() {
        $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, ['BlogId'], ['BlogId' => $tId], ['BlogId' => 'asc']);
            if (count($checkdata) > 0) {
                $crud->rv_update($this->table, ['isMarkForDel'=> 1], ['BlogId =?'=>$tId]);
                $this->_helper->flashMessenger->addMessage("Delete successfully.");
                $this->_redirect("/admin/blog/index");
            } else {
                die('Oops some thing wrong!!.');
            }
        }
    }
    
    
    
    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