Subversion-Projekte lars-tiefland.ci

Revision

Revision 932 | Revision 1334 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

/**
 *
 * @package WebanOS CI
 * @author Lars Tiefland <ltiefland@gmail.com> 
 * @copyright 2016
 * @version $Rev: 993 $
 */

class Login extends CI_Controller
{
        public function __construct()
        {
                parent::__construct();
                $this->load->model('Login_model', 'login');
        }
        public function index()
        {
                $this->login_form();
        }

        function execute()
        {
                if ($this->form_validation->run() === false)
                {
                        $this->login_form();
                }
                else
                {
                        $res = $this->login->check_user();
                        if (!$res)
                        {
                                $this->login_form();
                                exit;
                        }
                        $this->session->username = $this->input->post('user');
                        $this->session->user_data = $res;
                        header("Location:/backend/");
                }
        }

        private function login_form()
        {
                $data["errors"] = validation_errors();
                $data["title"] = "Anmeldung";
                $data["formstart"] = form_open("/login/execute/", array("class" => "login-form", ));
                $data["formend"] = "</form>";
                $this->smarty->view('login.tpl', $data);
        }

        public function logout()
        {
                unset($_SESSION["username"]);
                unset($_SESSION["user_data"]);
                unset($_SESSION["redirected"]);
                header("Location:/backend/");
        }
}

?>