403Webshell
Server IP : 103.48.194.25  /  Your IP : 216.73.217.33
Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33
System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64
User : sieuthimay ( 1016)
PHP Version : 8.2.20
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/pundarikanail.com-bk/wadmin/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/pundarikanail.com-bk/wadmin/controllers/News.php
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class News extends MX_Controller
{
	protected $_templates;
	
	public function __construct()
	{
        parent::__construct();
		$this->load->model('news_model','news');
		
		$this->pre_message = "";
		$this->load->helper('img');
		$this->lang->load('news');
		
		//$this->load->library('ResizeImg');
		
		//$this->load->helper('search');
		//$this->permit_library->check_permit();
		//$this->session->set_userdata(array('Url'=>uri_string()));
	}
	
	function index()
	{
        /*Begin search*/
        $type = $this->input->post('type');
       
        $current_router = $this->router->fetch_class();
        if($this->session->userdata('current_router')&&($this->session->userdata('current_router')!=$current_router)){
            $this->session->set_userdata('key_search','');
        }
        $this->session->set_userdata('current_router',$current_router);

        $data['search_bar']= searchBar(array(),array('TT'=>'Title'),'news/index');
        if($type=='ajax')
        {
            $arr_search['key_search'] = $this->input->post('key_search');
            $arr_search['field_search'] = $this->input->post('field_search');
            $this->session->set_userdata('key_search',$arr_search['key_search']);
            $this->session->set_userdata('field_search',$arr_search['field_search']);
        }
        else{
            $arr_search['key_search']=$this->session->userdata('key_search');
            $arr_search['field_search']=$this->session->userdata('field_search');
        }
        /*End  search*/
		$start = (int)$this->uri->segment(4) ;
		$data['title'] = "Danh sách tin tức";
		$data['add'] = 'news/add';
		//$data['trash'] = 'news/trash';
		$config['base_url'] = base_url().'news/index/'.(int)$this->uri->segment(3);  
		$data['num'] = $this->news->get_num_news($arr_search);
		$config['total_rows']   =  $data['num'];
		$config['per_page']  =   '20';
		$config['uri_segment'] = 4;   
		$this->pagination->initialize($config);   
		$data['list'] =   $this->news->get_all_news($config['per_page'], $start,$arr_search);
		$data['pagination']    = $this->pagination->create_links();            
		$data['page'] = 'news/news_view';
        if($type=="ajax")
            echo $this->load->view($this->_templates['page'],$data,true);
        else
            $this->load->view('layout/skin',$data);
	}
  
	function add()
	{
		$data['title'] = lang('add_news');
		$data['list_cate'] = $this->news->getCatActive();
		
		$this->form_validation->set_rules('lb_title','Tiêu đề','trim|required');
		if($this->form_validation->run()== FALSE)
		{
			$this->pre_message = validation_errors();
		}
		else
		{
		  	$req = $this->build_data(1);
		  	if($this->news->save_news($req))
		  	{
			  	$this->session->set_flashdata('message',lang('save_success'));
			  	redirect('news/index');
		  	}
		}
		
		$data['message'] = $this->pre_message;
		$data['page'] = 'news/news_add_view';
		$this->load->view('layout/skin',$data);
	}
  
	function edit($id=0,$start=0)
	{
		$data['rs'] = $this->news->get_news_item($id);
		$data['title'] = lang('update').' '.$data['rs']->lb_title;
		$data['list_cate'] = $this->news->getCatActive();
		
		$this->form_validation->set_rules('lb_title',lang('title'),'trim|required');
		$this->form_validation->set_rules('lb_summary',lang('summary'),'trim|required');
		$this->form_validation->set_rules('lb_content','','');
		if($this->form_validation->run()== FALSE)
		{
			$this->pre_message = validation_errors();
		}
		else
		{
			$data = $this->build_data(); 
			if($this->news->save_news($data))
			{
				$this->session->set_flashdata('message',"Cập nhật thành công");
				redirect('news/index/0/'.$page);
			}
		}
		$data['message'] = $this->pre_message;
		$data['page'] = 'news/news_edit_view';
		$this->load->view('layout/skin',$data);
	}
  
	function build_data($flag=0)
	{
		//flag=10?insert:update
		$req["cat_id"] = $this->input->post("cat_id");
		$req["lb_title"] = $this->input->post("lb_title");
		$req["lb_summary"] = $this->input->post("lb_summary");
		$req["lb_content"] = $this->input->post("lb_content");
		
        //for SEO
		$metatitle = $this->input->post("metatitle");
		$metadesc = $this->input->post("metadesc");
		$metakey = $this->input->post("metakey");
        $req["metatitle"] = empty($metatitle)? $req["lb_title"] : $metatitle;
		$req["metadesc"] = empty($metadesc)? $req["lb_summary"] : $metadesc;
		$req["metakey"] = empty($metakey)? '' : mb_strtolower($metakey);
		
		if($flag) $req["dt_create"] = date('Y-m-d H:i:s') ;
		$req["dt_modify"] 	= date('Y-m-d H:i:s');
		$req["is_hot"] 		= (int) $this->input->post("is_hot") ;
		$req["is_home"] 	= (int) $this->input->post("is_home") ;
		$req["bl_active"] 	= (int) $this->input->post("bl_active") ;
		
		//upload hinh anh
		$img = $this->input->post("lb_image");
		if($img)
		{
			$img_name = get_img_name($img) ;
			if(file_exists(ROOT_IMG.'news/'.$img_name))
			{
				unlink(ROOT_IMG.'news/'.$img_name);
			}
			$this->resize(ROOT_IMG.$img, ROOT_IMG.'news/'.$img_name, 800) ;
			$this->resize(ROOT_IMG.$img, ROOT_IMG.'news/thumb/'.$img_name, 135) ;
			$req["lb_image"] = $img_name;
		}
				
		return $req;
	}
	
	function resize($src, $desc, $width)
	{
		$this->load->library('ResizeImg');
		$this->resizeimg->load($src);
		$this->resizeimg->resizeToWidth($width);
		$this->resizeimg->save($desc);
	}
	
	function del($id=0,$page=0)
	{
		
		//	if($this->news->del_news($id))
		if($this->news->del_updates($id))
			$this->session->set_flashdata('message',lang('delete_success'));
		else $this->session->set_flashdata('message',lang('delete_unsuccess'));
		
		$this->news->remove() ;
		redirect('news/index/0/'.$page);
	}
	
	function dels()
	{
		if(!empty($_POST['ar_id']))
		{
			$page = (int)$this->input->post('page');
			$ar_id = $this->input->post('ar_id');
			
			if(!empty($_POST['btn_submit']))
			{
				for($i = 0; $i < sizeof($ar_id); $i ++) {
					if ($ar_id[$i]){
						//del_updates($id)
						if($this->news->del_updates($ar_id[$i]))
						//if($this->news->del_news($ar_id[$i]))
							$this->session->set_flashdata('message',lang('delete_success'));
						else $this->session->set_flashdata('message',lang('delete_unsuccess'));
					}
				}
			}
		}
		redirect('news/index/0/'.$page);
	}    
  
 	//tritigi:14.06.2012:lay list tin lein quan
	function related()
	{
		$data['title'] = lang('list_spotlinght');
		$data['add'] = 'news/add';
		$config['base_url'] = base_url().'news/related/'.(int)$this->uri->segment(3);  
		$data['num'] = $this->news->get_num_news();
		$config['total_rows']   =  $data['num'];
		$config['per_page']  =   '20';
		$config['uri_segment'] = 4;   
		$this->pagination->initialize($config);   
		$data['list'] =   $this->news->get_all_news($config['per_page'],(int)$this->uri->segment('4'));
		$data['pagination']    = $this->pagination->create_links();            
		$data['page'] = 'news/news_related';
		$this->load->view('layout/skin',$data,'basic');
	}
	
	//tritigi:14.06.2012:get news title from list newsid
	function get_news_title_from_listid()
	{
		//use when edit, make how to list id is a array
		$mode = isset($_POST['mode']) ? $_POST['mode'] : 0 ; 
		if(empty($mode))
			$list_id = isset($_POST['arr_id']) ? $_POST['arr_id'] : 0 ;
		else
			$list_id = isset($_POST['arr_id']) ? explode(",",$_POST['arr_id']) : 0 ;
		
		$data['list'] = $this->news->get_news_by_listid($list_id);
		
		$data['page'] = 'news/table_news';
		echo $this->load->view($this->_templates['page'],$data);
	 }
	 
	function trash()
	{
		/*Begin search*/
		$type = $this->input->post('type');
		
		$current_router = $this->router->fetch_class();
		if($this->session->userdata('current_router')&&($this->session->userdata('current_router')!=$current_router)){
		$this->session->set_userdata('key_search','');
		}
		$this->session->set_userdata('current_router',$current_router);
		
		$data['search_bar']=searchBar(array(),array('TT'=>'Title'),'news/index');
		if($type=='ajax')
		{
		$arr_search['key_search'] = $this->input->post('key_search');
		$arr_search['field_search'] = $this->input->post('field_search');
		$this->session->set_userdata('key_search',$arr_search['key_search']);
		$this->session->set_userdata('field_search',$arr_search['field_search']);
		}
		else{
		$arr_search['key_search']=$this->session->userdata('key_search');
		$arr_search['field_search']=$this->session->userdata('field_search');
		}
		/*End  search*/
		$start = (int)$this->uri->segment(4) ;
		$data['title'] = lang('list_spotlinght');
		$data['add'] = 'news/add';
		$data['trash'] = 'news/trash';
		$config['base_url'] = base_url().'news/index/'.(int)$this->uri->segment(3);  
		$data['num'] = $this->news->get_num_trash($arr_search);
		$config['total_rows']   =  $data['num'];
		$config['per_page']  =   '20';
		$config['uri_segment'] = 4;   
		$this->pagination->initialize($config);   
		$data['list'] =   $this->news->get_all_trash($config['per_page'], $start,$arr_search);
		$data['pagination']    = $this->pagination->create_links();            
		$data['page'] = 'news/news_trash';
		if($type=="ajax")
		echo $this->load->view($this->_templates['page'],$data,true);
		else
		$this->load->view('layout/skin',$data);
	}
	
	// category
	function category($start=0)
	{
		$data['title'] = "Danh mục tin tức";
		$data['add'] 			= 'news/addcat';
		
		$config['base_url'] 	= site.'news/category/';  
		$config['total_rows'] = $this->news->getNumcat();
		$data['num'] 			= $config['total_rows'];
		$config['per_page']  	= 20;
		$config['uri_segment']= 3; 
		$this->pagination->initialize($config); 
		$data['pagination']    = $this->pagination->create_links(); 
		
		$data['list'] =   $this->news->getAllCat($config['per_page'],$start);
		
		$this->category_cache();
		
		$data['page'] = 'news/cat/index';
		$this->load->view('layout/skin',$data);         
	}
	
	function category_cache()
	{
		$str = '';
		$list_cat = $this->news->getCatActive();
		foreach ($list_cat as $cat) :
			$str .= '<li><a href="'.domain.'chuyen-muc/'.alias($cat->lb_category).'-'.$cat->category_id.'.html" title="'.$cat->lb_category.'"><i class="fa fa-square" aria-hidden="true"></i>'.$cat->lb_category.'</a></li>';
		endforeach;
		
		$str = '<ul>'.$str.'</ul>';
		write_file(ROOT_SITE.'cache/news-category.php', $str);
	}
	  
	function addcat()
	{
		$data['title'] = 'Thêm mới chuyên mục';
		$data['listcat'] = $this->news->get_Parent(0);
		if(!empty($_POST['bt_submit'])){
			$this->form_validation->set_rules('lb_category','Tên chủ đề','trim|required');
		
			if($this->form_validation->run() == FALSE){
				$this->pre_message = validation_errors();
			}else{
				if($this->news->saveUpdateCat()){
				$this->session->set_flashdata('message','Thêm mới chuyên mục thành công');
				redirect('news/category');
			}
		 }
		}       
		$data['page'] = 'news/cat/addcat';
		$this->load->view('layout/skin',$data);           
	}
      
      function editcat()
	  {                                          
          $data['rs'] = $this->news->getItemCat();
          $data['title'] = 'Cập nhật: '.$data['rs']->lb_category;
          $data['listcat'] = $this->news->get_Parent(0);
          if(!empty($_POST['bt_submit'])){
                $this->form_validation->set_rules('lb_category','Tên chủ đề','trim|required');
       
                if($this->form_validation->run() == FALSE){
                    $this->pre_message = validation_errors();
                }else{
                    if($this->news->saveUpdateCat()){
                    $this->session->set_flashdata('message','Cập nhật chuyên mục thành công');
                    redirect('news/category');
                }
             }
          }  
          $data['page'] = 'news/cat/editcat';
          $this->load->view('layout/skin',$data);
      }
	  
      function delcat()
	  {
          $id = $this->uri->segment(3);
          $page = $this->uri->segment(4);
            if($this->news->delcat($id))
                $this->session->set_flashdata('mesasge','Đã xóa thành công');
            else $this->session->set_flashdata('mesasge','Xóa không thành công');
          redirect('news/category/'.$page);
      }
      
      function delscat()
      {
            if(!empty($_POST['ar_id']))
            {
                $page = (int)$this->input->post('page');
                $ar_id = $this->input->post('ar_id');
                
                if(!empty($_POST['btn_submit']))
                {
                    for($i = 0; $i < sizeof($ar_id); $i ++) {
                        if ($ar_id[$i]){
                            if($this->news->delcat($ar_id[$i]))
                                $this->session->set_flashdata('mesasge','Đã xóa thành công');
                            else $this->session->set_flashdata('mesasge','Xóa không thành công');
                        }
                    }
                }
            }
            redirect('index.php/news/category/'.$page);
      }
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit