-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
76 lines (45 loc) · 1.97 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
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
session_start();
$sections = array(
'default' => array('model' => 'HomeModel', 'view' => 'HomeView', 'controller' => 'HomeController'),
'subs' => array('model' => 'SubModel', 'view' => 'SubView', 'controller' => 'SubController'),
'reports' => array('model' => 'ReportsModel', 'view' => 'ReportsView', 'controller' => 'ReportsController'),
'training'=>array('model' => 'TrainingModel', 'view' => 'TrainingView', 'controller' => 'TrainingController'),
'studio'=>array('model' => 'StudioModel', 'view' => 'StudioView', 'controller' => 'StudioController'),
'app' => array('model' => 'AppModel', 'view' => 'AppView', 'controller' => 'AppController')
);
if (isset($_SESSION['trainer']) || isset($_COOKIE['trainer']))
{
$section="training";
}
else
{
if (isset($_GET['section']) && isset($sections[$_GET['section']]))
{
$section= $_GET['section'] ;
}
else
{
$section="default";
}
}
foreach($sections as $key => $components){
if ($section == $key) {
$model = $components['model'];
$view = $components['view'];
$controller = $components['controller'];
break;
}
}
include("controllers/".$controller.".php");
include("models/".$model.".php");
include("views/".$view.".php");
if (isset($model)) {
$m = new $model();
$v = new $view();
$c = new $controller($m,$v);
}
$c->{ (isset($_GET['action']) && method_exists($c, $_GET['action'])) ? $_GET['action'] : 'initSection'}();
?>