-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
78 lines (72 loc) · 2.54 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
final class Index {
function init() {
error_reporting(E_ERROR | E_STRICT);
mb_internal_encoding('UTF-8');
spl_autoload_register(array($this, 'loadClass'));
}
function loadClass($name) {
$classes = array(
'UsuarioDAO' => 'dao/UsuarioDAO.php',
'Usuario' => 'model/Usuario.php',
'iAction' => 'action/iAction.php',
'BaseAction' => 'action/BaseAction.php',
'LoginAction' => 'action/LoginAction.php',
'LogoutAction' => 'action/LogoutAction.php',
'EditarUsuarioAction' => 'action/EditarUsuarioAction.php',
'AtualizarUsuarioAction' => 'action/AtualizarUsuarioAction.php',
'CriarUsuarioAction' => 'action/CriarUsuarioAction.php',
'SalvarUsuarioAction' => 'action/SalvarUsuarioAction.php',
'DeletarUsuarioAction' => 'action/DeletarUsuarioAction.php',
'ListarUsuariosAction' => 'action/ListarUsuariosAction.php',
);
if (!array_key_exists($name, $classes)) {
die('Class "' . $name . '" not found.');
}
require_once $classes[$name];
}
function run() {
$page = $_REQUEST["page"];
switch ($page) {
case "login":
$action = new LoginAction();
$action->execute();
break;
case "listarUsuarios":
$action = new ListarUsuariosAction();
$action->execute();
break;
case "logout":
$action = new LogoutAction();
$action->execute();
break;
case "editarUsuario":
$action = new EditarUsuarioAction();
$action->execute();
break;
case "atualizarUsuario":
$action = new AtualizarUsuarioAction();
$action->execute();
break;
case "criarUsuario":
$action = new CriarUsuarioAction();
$action->execute();
break;
case "salvarUsuario":
$action = new SalvarUsuarioAction();
$action->execute();
break;
case "deletarUsuario":
$action = new DeletarUsuarioAction();
$action->execute();
break;
default:
$titulo = "Login";
require __DIR__ . "/view/login.phtml";
break;
}
}
}
$index = new Index();
$index->init();
$index->run();