|
Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/iatax.com.au/public_html/application/controllers/admin/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Configuration extends Admin_Controller {
function __construct() {
parent::__construct();
$this->load->model('configuration_m');
}
function index() {
redirect('admin/configuration/edit');
}
public function edit($id = 1) {
$this->data['configuration'] = $this->configuration_m->get($id);
//validation check in action
$config = array(
array(
'field' => 'website_name',
'label' => 'Website Name',
'rules' => 'trim|required'
),
array(
'field' => 'browser_title',
'label' => 'Browser Title',
'rules' => 'trim|required'
),
array(
'field' => 'meta_description',
'label' => 'Meta Description',
'rules' => 'trim|required'
),
array(
'field' => 'meta_keywords',
'label' => 'Meta Keywords',
'rules' => 'trim'
),
array(
'field' => 'from_email',
'label' => 'From Email',
'rules' => 'trim|valid_email'
),
array(
'field' => 'phone',
'label' => 'Phone',
'rules' => 'trim|required'
),
array(
'field' => 'email_smtp_host',
'label' => 'email_smtp_host',
'rules' => 'trim'
),
array(
'field' => 'email_smtp_port',
'label' => 'email_smtp_port',
'rules' => 'trim'
),
array(
'field' => 'email_smtp_password',
'label' => 'email_smtp_password',
'rules' => 'trim'
),
array(
'field' => 'email_smtp',
'label' => 'email_smtp',
'rules' => 'trim'
),
array(
'field' => 'website_ip',
'label' => 'primary_color_theme',
'rules' => 'trim'
)
);
$this->load->library('form_validation');
$this->form_validation->set_rules($config);
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
if($this->form_validation->run($this) == TRUE) {
//get max image width and height from configuration table
$this->db->select('logo_image_width, logo_image_height')->from('configuration')->where('id_configuration', 1);
$image_dimension = $this->db->get()->row();
//check & processing logo upload files
if ($_FILES['logo']['size'] !== 0) {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = '300';
// $config['max_width'] = $image_dimension->logo_image_width;
// $config['max_height'] = $image_dimension->logo_image_height;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('logo')) {
//echo $this->upload->display_errors(); die();
$this->session->set_flashdata('error', '<br>
<p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');
redirect('admin/configuration/edit/');
} else {
$logo = $this->upload->data();
$logo_filename = $logo['file_name'];
}
}
//check & processing website icon upload files
if ($_FILES['website_icon']['size'] !== 0) {
$config2['upload_path'] = './uploads/';
$config2['allowed_types'] = 'jpg|png';
$config2['max_size'] = '50';
$config2['max_width'] = '200';
$config2['max_height'] = '200';
$this->load->library('upload', $config2);
$this->upload->initialize($config2);
if ( ! $this->upload->do_upload('website_icon')) {
//echo $this->upload->display_errors(); die();
$this->session->set_flashdata('error2', '<br>
<p style="background:orange; color:white; padding:5px; font-weight:bold;">Website Icon Upload Error. Wrong format or size.</p>');
redirect('admin/configuration/edit/');
} else {
$website_icon = $this->upload->data();
$website_icon_filename = $website_icon['file_name'];
}
}
if ($_FILES['background_image']['size'] !== 0) {
$config3['upload_path'] = './uploads/';
$config3['allowed_types'] = 'jpg|png';
$config3['max_size'] = '500';
$config3['max_width'] = '300';
$config3['max_height'] = '300';
$this->load->library('upload', $config3);
$this->upload->initialize($config3);
if ( ! $this->upload->do_upload('background_image')) {
// echo $this->upload->display_errors(); die();
$this->session->set_flashdata('error3', '<br>
<p style="background:orange; color:white; padding:5px; font-weight:bold;">Website Icon Upload Error. Wrong format or size.</p>');
redirect('admin/configuration/edit/');
} else {
$background_image = $this->upload->data();
$background_image_filename = $background_image['file_name'];
}
}
$data = array(
'website_name' => $this->input->post('website_name'),
'from_email' => $this->input->post('from_email'),
'phone' => $this->input->post('phone'),
'browser_title' => $this->input->post('browser_title'),
'meta_description' => $this->input->post('meta_description'),
'meta_keywords' => $this->input->post('meta_keywords'),
'email_smtp_host' => $this->input->post('email_smtp_host'),
'email_smtp_port' => $this->input->post('email_smtp_port'),
'email_smtp' => $this->input->post('email_smtp'),
'email_smtp_password' => $this->input->post('email_smtp_password'),
'website_active' => $this->input->post('website_active'),
'website_ip' => str_replace(' ', '', $this->security->xss_clean($this->input->post('website_ip'))),
'website_default_language' => $this->input->post ('website_default_language'),
'contact_us_text' => $this->input->post('contact_us_text'),
'contact_us_text1' => $this->input->post('contact_us_text1'),
'contact_us_text2' => $this->input->post('contact_us_text2'),
'contactjudul' => $this->input->post('contactjudul'),
'facebook' => $this->input->post('facebook'),
'instagram' => $this->input->post('instagram'),
'linkedin' => $this->input->post('linkedin'),
'twitter' => $this->input->post('twitter')
);
//image upload
if (isset($logo_filename)) {
$data['logo'] = $logo_filename;
}
//image upload
if (isset($website_icon_filename)) {
$data['website_icon'] = $website_icon_filename;
}
if (isset($background_image_filename)) {
$data['background_image'] = $background_image_filename;
}
$this->configuration_m->edit_configuration($id, $data);
$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Configuration Edit Successful. Click "Dashboard" to go back</p>');
redirect('admin/configuration/edit');
}
$this->data['error'] = '';
$this->data['subview'] = 'admin/configuration/edit';
$this->load->view('admin/templates/header', $this->data_header);
$this->load->view('admin/_layout_main', $this->data);
$this->load->view('admin/templates/footer');
}
//To delete logo file from server, and from database
public function delete_logo() {
//get image file name for deletion
$this->db->select('logo')->from('configuration')->where('id_configuration', 1);
$image = $this->db->get()->row();
//Delete the actual image file from server. FCPATH is codeigniter base path
unlink(FCPATH .'/uploads/'. $image->logo);
//Delete logo field from configuration database
$data = array(
'logo' => '',
);
$this->db->where('id_configuration', 1);
$this->db->update('configuration', $data);
$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Logo Delete Successful</p>');
redirect('admin/configuration/edit');
}
public function delete_footer_logo() {
//get image file name for deletion
$this->db->select('background_image')->from('configuration')->where('id_configuration', 1);
$image = $this->db->get()->row();
//Delete the actual image file from server. FCPATH is codeigniter base path
unlink(FCPATH .'/uploads/'. $image->background_image);
//Delete logo field from configuration database
$data = array(
'background_image' => '',
);
$this->db->where('id_configuration', 1);
$this->db->update('configuration', $data);
$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Footer Logo Delete Successful</p>');
redirect('admin/configuration/edit');
}
//To delete website icon from server, and from database
public function delete_website_icon() {
//get image file name for deletion
$this->db->select('website_icon')->from('configuration')->where('id_configuration', 1);
$website_icon = $this->db->get()->row()->website_icon;
//Delete the actual image file from server. FCPATH is codeigniter base path
unlink(FCPATH .'/uploads/'. $website_icon);
//Delete website_icon field from configuration database
$data = array(
'website_icon' => '',
);
$this->db->where('id_configuration', 1);
$this->db->update('configuration', $data);
$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Website Icon Delete Successful</p>');
redirect('admin/configuration/edit');
}
}