Skip to content
Snippets Groups Projects
Select Git revision
  • 6ca277e656513d60319a6e97acd43dc305553058
  • main default protected
2 results

service-worker.js

Blame
  • Forked from SOFT Core / SOFT 260 / React Redux Starter Code
    Source project has a limited visibility.
    admin.php 4.96 KiB
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Admin extends CI_Controller 
    {
        public function __construct()
        {
            parent::__construct();
            
            if (!$this->is_logged_in()) {
                redirect('adminlogin');
            }
        }
        
        public function index()
        {
            $users = $this->user_model->get_all();
            
            $this->load->view('admin', array(
                'users' => $users
            ));
        }
        
        public function add()
        {
            $this->load->view('admin_add');
        }
        
        public function add_user()
        {
            sleep(1);
            $this->load->library('form_validation');
            $this->form_validation->set_rules('email', 'Email', 'required|max_length[40]|valid_email');
            $this->form_validation->set_rules('pwd', 'Password', 'required|max_length[20]|alpha_numeric');
            
            if ($this->form_validation->run() == FALSE) {
                $message = "<strong>Adding</strong> failed!";
                $this->json_response(FALSE, $message);
            } else {
                $is_added = $this->user_model->add($this->input->post('email'), $this->input->post('pwd'));
                
                if ($is_added) {
                    $message = "<strong>".$this->input->post('email')."</strong> has been added!";
                    $this->json_response(TRUE, $message);
                } else {
                    $message = "<strong>".$this->input->post('email')."</strong> already exists!";
                    $this->json_response(FALSE, $message);
                }
            }
        }
        
        public function delete()
        {
            $users = $this->user_model->get_emails();
            
            $this->load->view('admin_delete', array(
                'users' => $users
            ));
        }
        
        public function delete_user()
        {
            sleep(1);
            $this->load->library('form_validation');
            $this->form_validation->set_rules('email', 'Email', 'required|max_length[40]|valid_email');
            
            if ($this->form_validation->run() == FALSE) {
                $message = "<strong>Deletion</strong> failed!";
                $this->json_response(FALSE, $message);
            } else {
                $email = $this->input->post('email');