Advertisement
darmariduan

Download.php

Jul 2nd, 2022
920
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2.  
  3. class Download extends Web_controller
  4. {
  5.     public function __construct()
  6.     {
  7.         parent::__construct();
  8.                
  9.         $this->load->model('web/Download_model');
  10.     }
  11.    
  12.     public function index()
  13.     {
  14.         $this->vars['download'] = $this->Download_model->CheckDownload()->result_array();
  15.         $this->render_view('download', $this->vars);
  16.     }
  17.  
  18.     public function dl($id)
  19.     {
  20.         $cek        = $this->Download_model->checkFile($id)->result_array();
  21.         $jml        = $cek[0]['hit']+1;
  22.  
  23.         $update     = [
  24.             'hit'   => $jml
  25.         ];
  26.  
  27.         if ($this->Download_model->update($id, $update)) {
  28.             $this->load->helper('download');
  29.  
  30.             $data   = file_get_contents("/content/file/");
  31.             $name   = $cek[0]['name'];
  32.             if (force_download($name, $data)) {
  33.                 redirect('download', 'refresh');
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
RAW Paste Data Copied
Advertisement