Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Admin extends CI_Controller {
  4.  
  5. /**
  6. * Index Page for this controller.
  7. *
  8. * Maps to the following URL
  9. * http://example.com/index.php/welcome
  10. * - or -
  11. * http://example.com/index.php/welcome/index
  12. * - or -
  13. * Since this controller is set as the default controller in
  14. * config/routes.php, it's displayed at http://example.com/
  15. *
  16. * So any other public methods not prefixed with an underscore will
  17. * map to /index.php/welcome/<method_name>
  18. * @see http://codeigniter.com/user_guide/general/urls.html
  19. */
  20.  
  21. public function __Construct() {
  22. parent::__construct();
  23. if($this->session->userdata('logged_in') == false) {
  24. redirect('login', 'refresh');
  25.  
  26. }
  27. $this->load->library('form_validation');
  28. }
  29.  
  30. public function index()
  31. {
  32. $session_data = $this->session->userdata('logged_in');
  33. $data['username'] = $session_data['username'];
  34. $this->load->view('admin/template/menu');
  35. $this->load->view('admin/dashboard', $data);
  36. $this->load->view('admin/template/footer');
  37. }
  38.  
  39. public function logout() {
  40. $this->session->unset_userdata('logged_in');
  41. redirect('admin', 'refresh');
  42. }
  43.  
  44. public function gebruikers() {
  45. $this->load->view('admin/template/menu');
  46. $this->load->view('admin/gebruikers');
  47. $this->load->view('admin/template/footer');
  48. }
  49.  
  50. public function dashboard() {
  51. $this->load->view('admin/template/menu');
  52. $this->load->view('admin/dashboard');
  53. $this->load->view('admin/template/footer');
  54. }
  55.  
  56. public function optredens() {
  57. $this->load->view('admin/template/menu');
  58. $this->load->view('admin/optredens');
  59. $this->load->view('admin/template/footer');
  60. }
  61.  
  62.  
  63. public function add_user() {
  64. $this->load->helper(array('form'));
  65. $this->form_validation->set_rules('username', 'Username', 'required');
  66. $this->form_validation->set_rules('password', 'Password', 'required');
  67. $data['message'] = "";
  68.  
  69. $this->load->model('user');
  70.  
  71. $input = array(
  72. 'username' => $this->input->post('username'),
  73. 'password' => sha1($this->input->post('username'))
  74. );
  75.  
  76. $this->user->add_user($input);
  77. if ($this->form_validation->run() == FALSE) {
  78.  
  79. } else {
  80. $data['message'] = 'Gefeliciteerd, de gebruiker is succesvol toegevoegd aan de database.';
  81. }
  82. $this->load->view('admin/template/menu');
  83. $this->load->view('admin/gebruikers',$data);
  84. $this->load->view('admin/template/footer');
  85. }
  86.  
  87. public function add_optreden() {
  88. $this->load->helper(array('form'));
  89. $this->$this->form_validation->set_rules('titel', 'Title', 'trim|required|xss_clean');
  90. $this->$this->form_validation->set_rules('data', 'Data', 'trim|required|xss_clean');
  91. $this->$this->form_validation->set_rules('locatie', 'Locatie', 'trim|required|xss_clean');
  92. $this->$this->form_validation->set_rules('beschrijving', 'Beschrijving', 'trim|required|xss_clean');
  93. $data['message'] = "";
  94.  
  95. $this->load->model('optredens')
  96.  
  97. $input = array(
  98. 'titel' => $this->input->post('titel'),
  99. 'data' => $this->input->post('data'),
  100. 'locatie' => $this->input->post('locatie'),
  101. 'beschrijving' => $this->input->post('beschrijving')
  102. );
  103.  
  104. $this->optredens->add_optreden($input);
  105. if($this->form_validation->run() == false) {
  106.  
  107. } else {
  108. $data['message'] = 'Het optreden is toegevoegd aan de database.';
  109. }
  110. $this->load->view('admin/template/menu');
  111. $this->load->view('admin/optredens',$data);
  112. $this->load->view('admin/template/footer');
  113. }
  114. }
  115.  
  116. /* End of file welcome.php */
  117. /* Location: ./application/controllers/welcome.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement