forked from RafiqAli/Partage_photos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.php
executable file
·98 lines (73 loc) · 2.53 KB
/
routes.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
//function for removing special chars
function test_input($data)
{
$data=trim($data);//remove extra space
$data=stripslashes($data);//remove backslash
$data=htmlspecialchars($data);//remove special char
return $data;
}
// we're adding an entry for the new controller and its actions
$controllers = array( 'pages' => ['home',
'login',
'register',
'logout',
'error'],
'photos' => ['ajout_photo',
'mes_photos',
'affiche_photo',
'modif_photo',
'cherche_photo',
'neo_search'],
'groups' => ['my_groups',
'show_all',
'create'],
'api' => ['test']
);
function call($controller, $action)
{
require_once('controllers/' . $controller . '_controller.php');
switch($controller) {
//------------------------------------------------------------------------
case 'pages':
if($action=='login' || $action=='register')
{
require_once('Models/User.php');
}
$controller = new PagesController();
break;
//-------------------------------------------------------------------------
case 'photos':
// we need the model to query the database later in the controller
require_once('Models/Photo.php');
require_once('Models/User.php');
require_once('Models/Comment.php');
$controller = new PhotosController();
break;
//-------------------------------------------------------------------------
case 'groups':
// we need the model to query the database later in the controller
require_once('Models/Club.php');
require_once('Models/User.php');
$controller = new GroupsController();
break;
}
//---------------------------------------------------------------------------
$controller->{ $action }();
}
if (array_key_exists($controller, $controllers))
{
if (in_array($action, $controllers[$controller]))
{
call($controller, $action);
}
else
{
call('pages', 'error');
}
}
else
{
call('pages', 'error');
}
?>