Subversion-Projekte lars-tiefland.ci

Revision

Revision 573 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
525 lars 1
<?php
2
 
3
/**
4
 *
5
 * @package WebanOS CI
6
 * @author Lars Tiefland <ltiefland@gmail.com>
7
 * @copyright 2016
8
 * @version $Rev: 573 $
9
 */
10
 
11
/**
12
 * Login
13
 *
14
 * @package WebanOS CI
15
 * @author Lars Tiefland
16
 * @copyright 2016
17
 * @version $Id: Login.php 573 2016-09-16 19:02:24Z lars $
18
 * @access public
19
 */
20
class Login extends CI_Controller
21
{
22
	/**
23
	 * Login::__construct()
24
	 *
25
	 * @return
26
	 */
27
	public function __construct()
28
	{
29
		parent::__construct();
537 lars 30
		$GLOBALS['order_db'] = $this->load->database('order_db', TRUE);
31
		$GLOBALS['db_red'] = $this->load->database('db_red', TRUE);
533 lars 32
		$this->load->model('login_model', 'login');
531 lars 33
		$this->smarty->assign('aktiverTab', 3);
525 lars 34
	}
531 lars 35
 
529 lars 36
	public function index()
37
	{
38
		$this->smarty->view('login_center.tpl');
39
	}
531 lars 40
 
525 lars 41
	/**
42
	 * Login::login()
43
	 *
44
	 * @return
45
	 */
46
	public function login()
47
	{
534 lars 48
		$this->form_validation->set_rules('email', 'Username',
535 lars 49
			'required|trim|valid_email');
534 lars 50
		$this->form_validation->set_rules('password', 'Password', 'required');
51
		if ($this->form_validation->run() == FALSE)
52
		{
53
			$errors = validation_errors();
54
			$this->smarty->assign('errors', $errors);
561 lars 55
			$this->smarty->view('login_center.tpl');
534 lars 56
		}
57
		else
58
		{
542 lars 59
			$res = $this->login->check();
537 lars 60
			if ($res['error'])
61
			{
561 lars 62
				$this->smarty->assign('login', $res);
63
				$this->smarty->view('login_meld.tpl');
537 lars 64
			}
547 lars 65
			else
66
			{
67
				$_SESSION['SHOP']['buy']['Persdata'] = $res['data'];
68
				$_SESSION['SHOP']['Login'] = true;
556 lars 69
				$ret['msg'] = nl2br(sprintf($GLOBALS['langstrings']['login']['login_success'], $_SESSION["SHOP"]['buy']['Persdata']['Vorname'],
70
					$_SESSION["SHOP"]['buy']['Persdata']['Nachname']));
71
 
557 lars 72
				$this->smarty->assign("login", $ret);
73
				$this->smarty->view("login_meld.tpl");
556 lars 74
 
75
 
571 lars 76
				if (isset($_POST['return']) && $_POST["return"] == "true" && $res["error"] === false)
556 lars 77
				{
573 lars 78
					header("Location: /order.html");
556 lars 79
				}
547 lars 80
			}
534 lars 81
		}
525 lars 82
	}
556 lars 83
 
552 lars 84
	public function logout()
85
	{
86
		unset($_SESSION['SHOP']['buy']['Persdata']);
87
		unset($_SESSION['SHOP']['Login']);
555 lars 88
		$this->smarty->view('logout.tpl');
552 lars 89
	}
531 lars 90
 
525 lars 91
	/**
92
	 * Login::save()
93
	 *
94
	 * @return
95
	 */
96
	public function save()
97
	{
98
		$this->login->create();
99
	}
100
}
101
 
102
?>