| Server IP : 68.178.202.69 / Your IP : 216.73.216.122 Web Server : Apache System : Linux 69.202.178.68.host.secureserver.net 3.10.0-1160.139.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Nov 3 13:30:41 UTC 2025 x86_64 User : ikioworld ( 1005) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/ikioworld/public_html/application/controllers/admin/ |
Upload File : |
<?php
class down extends CI_Controller {
public function __construct() {
parent::__construct ();
$this->load->helper('download');
}
function index()
{
$this->load->helper(array('form', 'url','common'));
$this->load->library(array('session','pagination'));
$this->load->model('loginmodel','',TRUE);
$this->loginmodel->check_is_valid_user();
$this->load->model('downmodel','',TRUE);
$data = array(
'header' => $this->load->view('admin/assets/header', '', TRUE),
'footer' => $this->load->view('admin/assets/footer', '', TRUE),
);
$num_records = $this->downmodel->get_total_records();
$data['num_records'] = $num_records;
$base_url=base_url().'admin/down/index';
$start_index=$this->uri->segment($this->uri->total_segments());
$default_page_size = 10;
if( $this->input->get('per_page') != '' ){
$per_page = $this->input->get('per_page');
}
else{
$per_page=$default_page_size;
}
$data['default_page_size'] = $default_page_size;
$content_array=$this->downmodel->get_contents($per_page,$start_index);
$data['content_array']=$content_array;
$data['start_index']=$start_index;
$data['pagination_links']=paging($base_url,$this->input->server("QUERY_STRING"),$num_records,$per_page,$this->uri->total_segments());
$this->load->view('admin/down/index',$data);
}
function add(){
$this->load->helper(array('form', 'url'));
$this->load->library(array('session','pagination'));
$this->load->model('downmodel','',TRUE);
if(!empty($this->input->post())){
$insert_id=$this->downmodel->add($this->input->post());
if($insert_id!=''){
$postData=$this->input->post();
self::upload_file($insert_id,$_FILES,'document','add');
self::upload_file($insert_id,$_FILES,'download_icon','add');
$this->session->set_flashdata('message',"down has been added.");
{
redirect('admin/down');
}
}
}
$data = array(
'header' => $this->load->view('admin/assets/header', '', TRUE),
'footer' => $this->load->view('admin/assets/footer', '', TRUE),
);
$this->load->view('admin/down/add',$data);
}
function edit($id){
$this->load->helper(array('form', 'url', 'common'));
$this->load->library(array('session','pagination'));
$this->load->model('downmodel','',TRUE);
$data = array(
'header' => $this->load->view('admin/assets/header', '', TRUE),
'footer' => $this->load->view('admin/assets/footer', '', TRUE),
);
$data['record']=$this->downmodel->fetch_details($id);
if(!empty($this->input->post())){
$res=$this->downmodel->edit($id,$this->input->post());
self::upload_file($id,$_FILES,'document','edit');
self::upload_file($id,$_FILES,'download_icon','edit');
$this->session->set_flashdata('message',"down has been updated.");
redirect("admin/down");
}
$this->load->view('admin/down/edit',$data);
}
function upload_file($id,$fileArray,$column,$for='add'){
if($id!='' && !empty($fileArray) && $fileArray[$column]['error']=="0" && $column!=''){
$record=$this->downmodel->fetch_details($id);
$file_name=$fileArray[$column]['name'];
if($for=="edit"){
@unlink(FCPATH."uploads/download/".$record->$column);
}
$ffdsf=$this->downmodel->edit($id,[$column=>$file_name]);
move_uploaded_file($fileArray[$column]['tmp_name'],FCPATH."uploads/download/".$file_name);
return true;
}
}
function delete($id){
$this->load->helper(array('form', 'url'));
$this->load->library(array('session','pagination'));
$this->load->model('downmodel','',TRUE);
if($id!=''){
$this->downmodel->deletedown($id);
$this->session->set_flashdata('message',"down has been deleted.");
redirect("admin/down");
}
}
function update_status(){
$this->load->helper(array('form', 'url'));
$this->load->library(array('session','pagination'));
$this->load->model('downmodel','',TRUE);
$id= $_GET['sid'];
$status= $_GET['svalue'];
if($status == 'active')
{
$sql=$this->db->query("UPDATE downloads set status='inactive' where id='$id'");
}else{
$sql=$this->db->query("UPDATE downloads set status='active' where id='$id'");
}
redirect("admin/down");
}
function delete_down()
{
$this->load->helper(array('form', 'url','common'));
$this->load->library(array('session','pagination'));
$this->load->model('loginmodel','',TRUE);
$this->loginmodel->check_is_valid_user();
$this->load->model('downmodel','',TRUE);
if($this->input->post('checkbox_value'))
{
$id = $this->input->post('checkbox_value');
for($count = 0; $count < count($id); $count++)
{
$this->downmodel->delete_down($id[$count]);
}
}
}
}