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/noithattinnguyen.vn/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/noithattinnguyen.vn/app/Http/Controllers/ProductController.php
<?php

namespace App\Http\Controllers;


use Illuminate\Http\Request;
use DB;
use File;
use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Http\Requests;
use App\Models\Product;
use App\Models\Attr;
use App\Models\Gallery;
use App\Models\Post;
use App\Models\Slider;
use App\Models\Category;
use App\Models\CatePost;
use App\Models\CatePost2;
use App\Models\Cate;
use App\Imports\ImportsProduct;  
use App\Exports\ExportsProduct;
use Excel;
use Session;
use Illuminate\Support\Facades\Redirect; 
use App\Http\Controllers\Controller;
session_start();

class ProductController 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_product(){

        $cate=Cate::orderby('cate_id','desc')->get();
        $cate_product=DB::table('tbl_category_product')->orderby('category_id','desc')->get();
        $brand_product=DB::table('tbl_brand')->orderby('brand_id','desc')->get();
        $country_product=DB::table('tbl_country')->orderby('country_id','desc')->get();
        return view('admin.product.add_product')->with(compact('cate_product','brand_product','cate','country_product'));
    }
        public function all_product(){
            $this->AuthLogin();  
              // $all_product= DB::table('tbl_product')
               //  ->join('tbl_category_product','tbl_category_product.category_id','=','tbl_product.category_id')
               // ->join('tbl_brand','tbl_brand.brand_id','=','tbl_product.brand_id')-> orderby('tbl_product.product_id','desc')->get();
            $all_product=Product::orderby('product_id','DESC')->join('tbl_category_product','tbl_category_product.category_id','=','tbl_product.category_id')->join('tbl_brand','tbl_brand.brand_id','=','tbl_product.brand_id')->join('tbl_country','tbl_country.country_id','=','tbl_product.country_id')->paginate(8);  
               
            //$manager_product = view('admin.all_product')->with('all_product',$all_product);

        return view('admin.product.all_product')->with(compact('all_product'));
    }
        public function save_product(Request $Request){
        $data = request()->except(['_token']);
        $Product=new Product();
        $Product->product_name=$data['product_name'];
         $Product->product_price=$data['product_price'];
        $Product->product_tag=$data['product_tag'];
        $Product->slug_product=$data['slug_product'];
        $Product->product_desc=$data['product_desc'];
        $Product->product_status=$data['product_status'];
        $Product->meta_keywords=$data['meta_keywords'];
        $Product->category_id=$data['category_id']; 
        $Product->brand_id=$data['brand_id'];
        $Product->country_id=$data['country_id'];
        $Product->product_content=$data['product_content'];
       //$Product->product_image=$data['product_image'];
    

        $get_image=$Request->file('product_image');

        $path='public/uploads/product/';
        $path_gallery='public/uploads/gallery/';
        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/product',$new_image);
        file::copy($path.$new_image,$path_gallery.$new_image);
        $data['product_image']=$new_image;
        // $Product->save();
    
        }

             // $pro_id= DB::table('tbl_product')->nsertGetId($data);
             $pro_id= Product::insertGetId($data);
             $gallery=new Gallery();
             $gallery->gallery_image=$new_image;
             $gallery->gallery_name=$new_image;
             $gallery->product_id=$pro_id;
             $gallery->timestamps=false;
             $gallery->save();
        Session::put('message', 'Thêm sản phẩm thành công');
        return Redirect::to('all-product');
        }
    





// trạng thái 

    public function unactive_product($product_id){
DB::table('tbl_product')->where('product_id',$product_id)->update(['product_status'=>1]);
Session::put('message', 'Kích hoạt thành công trạng thái');
        return Redirect::to('all-product');
    }
         public function active_product($product_id){

    DB::table('tbl_product')->where('product_id',$product_id)->update(['product_status'=>0]);
Session::put('message', 'Kích hoạt thành công trạng thái');
        return Redirect::to('all-product');
    }



    public function unactive_hot_product($product_id){
DB::table('tbl_product')->where('product_id',$product_id)->update(['product_hot'=>1]);
Session::put('message', 'Kích hoạt thành công trạng thái');
        return Redirect::to('all-product');
    }
         public function active_hot_product($product_id){

    DB::table('tbl_product')->where('product_id',$product_id)->update(['product_hot'=>0]);
Session::put('message', 'Kích hoạt thành công trạng thái');
        return Redirect::to('all-product');
    }


    public function unactive_spe_product($product_id){
DB::table('tbl_product')->where('product_id',$product_id)->update(['product_spe'=>1]);
Session::put('message', 'Kích hoạt thành công trạng thái');
        return Redirect::to('all-product');
    }
         public function active_spe_product($product_id){

    DB::table('tbl_product')->where('product_id',$product_id)->update(['product_spe'=>0]);
Session::put('message', 'Kích hoạt thành công trạng thái');
        return Redirect::to('all-product');
    }


    public function unactive_like_product($product_id){
DB::table('tbl_product')->where('product_id',$product_id)->update(['product_like'=>1]);
Session::put('message', 'Kích hoạt thành công trạng thái');
        return Redirect::to('all-product');
    }
         public function active_like_product($product_id){

    DB::table('tbl_product')->where('product_id',$product_id)->update(['product_like'=>0]);
Session::put('message', 'Kích hoạt thành công trạng thái');
        return Redirect::to('all-product');
    }




      public function edit_product($product_id){
      $cate=Cate::orderby('cate_id','desc')->get();  
      $cate_product =DB::table('tbl_category_product')->orderby('category_id','desc')->get();  
      $brand_product=DB::table('tbl_brand')->orderby('brand_id','desc')->get();  
     $edit_product= DB::table('tbl_product')->where('product_id',$product_id)->get();
               $manager_product = view('admin.product.edit_product')->with('edit_product',$edit_product)->with('cate_product',$cate_product)->with('brand_product',$brand_product)->with('cate',$cate);


        return view('admin_layout')->with('admin.product.edit_product', $manager_product);
    } 
    public function update_product(Request $Request, $product_id){
        $data=array();
        $data['product_name']=$Request->product_name;
          $data['product_tag']=$Request->product_tag;
          $data['product_price']=$Request->product_price;
        $data['product_quantity']=$Request->product_quantity;
        $data['slug_product']=$Request->slug_product;
        $data['meta_keywords']=$Request->product_keywords;
        $data['product_desc']=$Request->product_desc;
        $data['product_content']=$Request->product_content;
        $data['category_id']=$Request->product_cate;
        $data['brand_id']=$Request->product_brand;  
        $data['product_status']=$Request->product_status;
        $get_image=$Request->file('product_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();
        //$extension;
        $get_image->move('public/uploads/product',$new_image);
        $data['product_image']=$new_image;
            DB::table('tbl_product')->where('product_id',$product_id) ->update($data);
        Session::put('message', 'cập nhật phẩm thành công');
        return Redirect::to('all-product');
        }
        
        DB::table('tbl_product')->where('product_id',$product_id)->update($data);
        Session::put('message', 'cập nhật phẩm thành công');
        return Redirect::to('all-product');
    }   
     public function delete_product($product_id) {
      $product=Product::find($product_id);  
    // DB::table('tbl_product')->where('product_id',$product_id)->delete();
     unlink('public/uploads/product/'.$product->product_image);
     $product->delete();
        Session::put('message', 'xóa thành thành công');
        return Redirect::to('/all-product');
     }  



    // end admin function 
    // 
    // chi tiết sản phẩm 
      public function details_product(Request $request, $slug_product) {
        $slide =Slider::orderby('slider_id','desc')->get();
        $category_post = CatePost::orderBy('cate_post_id','DESC')->get();
    $cate_product=Category::where('category_status','1')->orderby('category_id','desc')->with('cate')->get();
    $brand_product=DB::table('tbl_brand')->orderby('brand_id','desc')->get();  
    $all_product=DB::table('tbl_product')->where('product_status','1')->orderby('product_id','desc')->get();
    $details_product= DB::table('tbl_product')
               ->join('tbl_category_product','tbl_category_product.category_id','=','tbl_product.category_id')
               ->join('tbl_brand','tbl_brand.brand_id','=','tbl_product.brand_id')->where('tbl_product.slug_product',$slug_product)->get();
    $meta_desc=collect();
    $meta_keywords=collect();
    $meta_title=collect();
    $url_canonical=collect();
        foreach($details_product as $key => $value){
        $category_id=$value->category_id;
        $pro_id= $value->product_id;
        $meta_desc=$value->product_desc;
        $meta_keywords=$value->meta_keywords;
        $meta_title=$value->product_name;
        $url_canonical= $request->url();
        $imageG = Gallery::where('product_id',$pro_id)->get();
        $all_attr =Attr::where('product_id',$pro_id)->with('product')->get();
        }
    
     $related_product= DB::table('tbl_product')
               ->join('tbl_category_product','tbl_category_product.category_id','=','tbl_product.category_id')
               ->join('tbl_brand','tbl_brand.brand_id','=','tbl_product.brand_id')->where('tbl_category_product.category_id',$category_id)->whereNotIn('tbl_product.slug_product',[$slug_product])->where('tbl_product.product_status','1')->get();
    $all_post=Post::orderby('post_id','desc')->get();
    $categorypost = CatePost2::orderBy('categorypost_id','DESC')->get();
     // return view('pages.sanpham.show_details')->with('category',$cate_product)->with('brand',$brand_product)->with('product_details',$details_product)->with('related',$related_product); cách 1 
               return view('pages.sanpham.show_details')->with(compact('cate_product','brand_product','details_product','related_product','meta_keywords','meta_desc','meta_title','url_canonical','imageG','all_attr','all_product','slide','category_post','all_post','categorypost'));
    }

      public function exportproduct_csv(){
        return Excel::download(new ExportsProduct , 'product.xlsx');
    }

    public function importproduct_csv(Request $request){
        // $path = $request->file('file')->getRealPath();
        $path1 = $request->file('file')->store('temp'); 
        $path=storage_path('app').'/'.$path1;  
        $data=Excel::import(new ImportsProduct, $path);
        return back();
    }

     public function tag(Request $request, $product_tag){

    $cate=Cate::orderby('cate_id','ASC')->get(); 
    $slide =Slider::orderby('slider_id','desc')->get();
    $cate_product=Category::where('category_status','1')->orderby('category_id','desc')->with('cate')->get();
    $brand_product=DB::table('tbl_brand')->orderby('brand_id','desc')->get();  
    $all_product=DB::table('tbl_product')->where('product_status','1')->orderby('product_id','desc')->get();
    
    // $details_product= DB::table('tbl_product')
    //            ->join('tbl_category_product','tbl_category_product.category_id','=','tbl_product.category_id')
    //            ->join('tbl_brand','tbl_brand.brand_id','=','tbl_product.brand_id')->where('tbl_product.slug_product',$slug_product)->get();
        $meta_desc = 'Tags tìm kiếm::'.$product_tag;
        $meta_keywords = 'Tags tìm kiếm:'.$product_tag;
        $meta_title = 'Tags tìm kiếm:'.$product_tag;
        $url_canonical = $request->url();
        // foreach($details_product as $key => $value){
        // $category_id=$value->category_id;
        // $pro_id= $value->product_id;
        // $all_attr =Attr::where('product_id',$pro_id)->with('product')->get();
        // }
    
    $tag = str_replace("-"," ",$product_tag);
        
    $pro_tag = Product::where('product_status',1)->where('product_name','Like','%'.$tag.'%')->orWhere('product_tag','Like','%'.$tag.'%')->orWhere('slug_product','Like','%'.$tag.'%')->get();
    $all_attr =Attr::orderby('attr_id','desc')->with('product')->get();

     // echo '<pre>';
     //    print_r($pro_tag);
     //    echo '</pre>';


     // return view('pages.sanpham.show_details')->with('category',$cate_product)->with('brand',$brand_product)->with('product_details',$details_product)->with('related',$related_product); cách 1 
     return view('pages.sanpham.tag')->with(compact('cate_product','brand_product','meta_keywords','meta_desc','meta_title','url_canonical','all_attr','all_product','slide','product_tag','pro_tag','cate'));
    
    }




}

Youez - 2016 - github.com/yon3zu
LinuXploit