| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/adeetie_hellogtx/application/controllers/ |
Upload File : |
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class FacilationUser extends CI_Controller {
function index() {
$this->load->view('facilation/layout/template', ['page'=> 'facilation/user/user-list']);
}
public function add() {
$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('package_desc', 'Detail', 'required');
$this->form_validation->set_rules('duration', 'Trip Duration', 'required');
$this->form_validation->set_rules('location', 'Trip locations', 'required');
$this->form_validation->set_rules('meta_title', 'Title', 'required');
$this->form_validation->set_rules('meta_desc', 'Description', 'required');
if ($this->form_validation->run() == false) {
$data['cats'] = $this->mcategory->get_all_category();
$this->load->vars($data);
$this->load->view('facilation/layout/template', ['page'=> 'facilation/user/user-add']);
} else {
$file = $this->uploadImage();
$this->mpackage->update_package($file['filename'], $id);
}
}
public function edit($id) {
$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('package_desc', 'Detail', 'required');
$this->form_validation->set_rules('duration', 'Trip Duration', 'required');
$this->form_validation->set_rules('location', 'Trip locations', 'required');
$this->form_validation->set_rules('meta_title', 'Title', 'required');
$this->form_validation->set_rules('meta_desc', 'Description', 'required');
if ($this->form_validation->run() == false) {
$data['cats'] = $this->mcategory->get_all_category();
$data['page'] = $this->mpackage->get_package_byid($id);
$this->load->vars($data);
$this->load->view('facilation/layout/template', ['page'=> 'facilation/user/user-add']);
} else {
$file = $this->uploadImage();
$this->mpackage->update_package($file['filename'], $id);
}
}
public function view($id) {
$data['pid'] = $id;
$data['page'] = $this->mpackage->get_package_byid($id);
$this->load->vars($data);
$this->load->view('facilation/layout/template', ['page'=> 'facilation/user/user-detail']);
}
public function delete($id) {
$this->db->where('id', $id);
$this->db->delete('app_product');
if ($this->db->affected_rows() > 0) {
$this->session->set_flashdata('success', 'Successfully deleted');
redirect('product', 'refresh');
} else {
$this->session->set_flashdata('error', 'Unknown error');
redirect('product', 'refresh');
}
}
function uploadImage() {
$config['upload_path'] = './static/user/';
$config['allowed_types'] = 'gif|jpg|png|JPG';
$config['max_size'] = '100000';
$config['max_width'] = '2100';
$config['max_height'] = '2100';
$this->load->library('upload', $config);
if (!$this->upload->do_upload()) {
$error = $this->upload->display_errors();
print_r($error);
return $data = ['status' => 'failed', 'filename' => ''];
} else {
$data = $this->upload->data();
return $ndata = ['status' => 'success', 'filename' => $data['file_name']];
}
}
}