Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Admin extends CI_Controller {
  4.  
  5. public function __Construct() {
  6. parent::__construct();
  7. if($this->session->userdata('logged_in') == false) {
  8. redirect('login', 'refresh');
  9. }
  10. $this->load->library('form_validation');
  11. $this->load->model('user');
  12. $this->load->model('optredens');
  13. }
  14.  
  15. public function index(){
  16. $session_data = $this->session->userdata('logged_in');
  17. $data['username'] = $session_data['username'];
  18. $this->load_template('admin/dashboard', $data);
  19. }
  20.  
  21. public function logout() {
  22. $this->session->unset_userdata('logged_in');
  23. redirect('admin', 'refresh');
  24. }
  25.  
  26. public function gebruikers() {
  27. $this->load_template('admin/gebruikers');
  28. }
  29.  
  30. public function dashboard() {
  31. $this->load_template('admin/dashboard');
  32. }
  33.  
  34. public function optredens() {
  35. $this->load_template('admin/optredens');
  36. }
  37.  
  38. public function add_user() {
  39. $data['message'] = "";
  40. $this->form_validation->set_rules('username', 'Username', 'required');
  41. $this->form_validation->set_rules('password', 'Password', 'required');
  42.  
  43. if ($this->form_validation->run()) {
  44. $input = $this->input->post(NULL, TRUE);
  45. $input['password'] = sha1($input['password']);
  46. $this->user->add_user($input);
  47. $data['message'] = 'Gefeliciteerd, de gebruiker is succesvol toegevoegd aan de database.';
  48. }
  49.  
  50. $this->load_template('admin/gebruikers', $data);
  51. }
  52.  
  53. public function add_optreden() {
  54. $data['message'] = "";
  55.  
  56. $this->form_validation->set_rules('titel', 'Title', 'trim|required|xss_clean');
  57. $this->form_validation->set_rules('data', 'Data', 'trim|required|xss_clean');
  58. $this->form_validation->set_rules('locatie', 'Locatie', 'trim|required|xss_clean');
  59. $this->form_validation->set_rules('beschrijving', 'Beschrijving', 'trim|required|xss_clean');
  60.  
  61. if($this->form_validation->run()) {
  62. $input = $this->input->post(NULL, TRUE);
  63. $this->optredens->add_optreden($input);
  64. $data['message'] = 'Het optreden is toegevoegd aan de database.';
  65. }
  66.  
  67. $this->load_template('admin/optredens', $data);
  68. }
  69.  
  70. private function load_template($view, $data = null){
  71. $this->load->view('admin/template/menu');
  72. $this->load->view($view, $data);
  73. $this->load->view('admin/template/footer');
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement