<?php
/**
 * System Configuration
 *
 */
require_once (dirname(__FILE__) . "/SUPER_Controller.php");

class System extends SUPER_Controller {

    function System()
    {
        parent::SUPER_Controller();
        $this->load->model('Common_model');
    }
    
    public function index()
    {
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
        
        $this->form_validation->set_rules('ssl', 'SSL', 'required|trim|xss_clean');
        
        if (!$this->input->post('submit'))
        {
            $this->db->where('name', 'ssl');
            $query = $this->db->get('system', 1);
            if ($query->num_rows() > 0)
            {
                $row = $query->row_array();
                $data['ssl'] = $row['value'];
            }
            else
            {
                $data['ssl'] = 'false';
            }
            $this->load->vars($data);
        }
        
        if ($this->form_validation->run() == false)
        {
            $this->load->view('super/system/index');
        }
        else
        {
            $ssl = set_value('ssl');
            $data = array(
                           'value' => set_value('ssl'),
                           'type' => 'bool'
                        );
            $this->db->where('name', 'ssl');
            $this->db->update('system', $data);
            $this->load->view('super/system/index');
        }
    }
}

/* End of file system.php */
