<?php
class AdminController { function __construct() { $GLOBALS['login'] = 0; $action = getIndex('action', 'index'); if (method_exists($this, $action)) $reflection = new ReflectionMethod($this, $action); if (!$reflection->isPublic()) { echo "Phuong thuc ko phai public!";exit; } $this->$action(); } else { echo "Chua xay dung..."; exit; } } function index() { include 'View/AdminIndex.php'; } function adminlogin() { $u= postIndex('u'); $p= md5(postIndex('p')) ; $m = new UserModel(); $data = $m->getAdmin($u, $p); if ($data==false) { if($GLOBALS['login']==0&&$u!=""){ $message = "sai pass hoac chua dk tai khoan"; echo "<script type='text/javascript'>alert('$message');</script>"; } include 'View/adminlogin.php'; } else { $_SESSION['admin']= $data; header('location:index.php?controller=AdminController'); } } function adminlogout() { $GLOBALS['login']=1; unset($_SESSION['admin']); $this->adminlogin(); }