Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Admin extends CI_Controller {
- public function __Construct() {
- parent::__construct();
- if($this->session->userdata('logged_in') == false) {
- redirect('login', 'refresh');
- }
- $this->load->library('form_validation');
- $this->load->model('user');
- $this->load->model('optredens');
- }
- public function index(){
- $session_data = $this->session->userdata('logged_in');
- $data['username'] = $session_data['username'];
- $this->load_template('admin/dashboard', $data);
- }
- public function logout() {
- $this->session->unset_userdata('logged_in');
- redirect('admin', 'refresh');
- }
- public function gebruikers() {
- $this->load_template('admin/gebruikers');
- }
- public function dashboard() {
- $this->load_template('admin/dashboard');
- }
- public function optredens() {
- $this->load_template('admin/optredens');
- }
- public function add_user() {
- $data['message'] = "";
- $this->form_validation->set_rules('username', 'Username', 'required');
- $this->form_validation->set_rules('password', 'Password', 'required');
- if ($this->form_validation->run()) {
- $input = $this->input->post(NULL, TRUE);
- $input['password'] = sha1($input['password']);
- $this->user->add_user($input);
- $data['message'] = 'Gefeliciteerd, de gebruiker is succesvol toegevoegd aan de database.';
- }
- $this->load_template('admin/gebruikers', $data);
- }
- public function add_optreden() {
- $data['message'] = "";
- $this->form_validation->set_rules('titel', 'Title', 'trim|required|xss_clean');
- $this->form_validation->set_rules('data', 'Data', 'trim|required|xss_clean');
- $this->form_validation->set_rules('locatie', 'Locatie', 'trim|required|xss_clean');
- $this->form_validation->set_rules('beschrijving', 'Beschrijving', 'trim|required|xss_clean');
- if($this->form_validation->run()) {
- $input = $this->input->post(NULL, TRUE);
- $this->optredens->add_optreden($input);
- $data['message'] = 'Het optreden is toegevoegd aan de database.';
- }
- $this->load_template('admin/optredens', $data);
- }
- private function load_template($view, $data = null){
- $this->load->view('admin/template/menu');
- $this->load->view($view, $data);
- $this->load->view('admin/template/footer');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement