-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
111 lines (95 loc) · 4.16 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
define('SYS',getcwd());
define('SITE_URL',"http://localhost/voicela/");
require_once('./libs/glue.php');
require_once('./libs/mysqlidb.php');
require_once('./libs/simplestview.php');
require_once('./Controller.php');
$urls = array(
'/voicela/index.php' => 'home',
'/voicela' => 'home',
'/voicela/vip/(\d+)' => 'vip',
'/voicela/films' => 'films',
'/voicela/film/(\d+)' => 'film',
'/voicela/photo/(\d+)' => 'photo',
);
class Home extends Controller {
function GET() {
$db = new MysqliDb($this->config["host"], $this->config["user"], $this->config["pass"], $this->config["base"]);
$results = $db->query('SELECT * from VIP ORDER BY prenom,nom;');
if(!empty($results) && count($results) > 0) {
SimplestView::render("header");
SimplestView::render('index',array("results" => $results));
SimplestView::render("footer");
}
}
}
class vip extends Controller {
function GET($matches) {
if ($matches[1]) {
$db = new MysqliDb($this->config["host"], $this->config["user"], $this->config["pass"], $this->config["base"]);
$result = $db->where('idVIP',$matches[1])->get('VIP',1);
$realisateur = $db->where('realisateur',$matches[1])->get('film');
$params = array($matches[1]);
$acteur = $db->rawQuery("SELECT * FROM joue, film WHERE joue.idfilm = film.idfilm AND joue.idVIP = ?", $params);
$photo = $db->rawQuery("SELECT * FROM vip_photo, photo WHERE photo.idphoto = vip_photo.idphoto AND vip_photo.idVIP = ?", $params);
$data = array();
$data["vip"] = $result[0];
$data["acteur"] = $acteur;
$data["realisateur"] = $realisateur;
$data["photo"] = $photo;
if(!empty($result) && count($result) > 0) {
SimplestView::render("header");
SimplestView::render('vip',$data);
SimplestView::render("footer");
}
}
}
}
class film extends Controller{
function GET($matches) {
if ($matches[1]) {
$db = new MysqliDb($this->config["host"], $this->config["user"], $this->config["pass"], $this->config["base"]);
$result = $db->where('idfilm',$matches[1])->get('film',1);
if(!empty($result) && count($result) > 0) {
SimplestView::render("header");
SimplestView::render('film',array("film" => $result[0]));
SimplestView::render("footer");
}
}
}
}
class films extends Controller{
function GET() {
$db = new MysqliDb($this->config["host"], $this->config["user"], $this->config["pass"], $this->config["base"]);
$results = $db->query('SELECT * from film ORDER BY titre;');
if(!empty($results) && count($results) > 0) {
SimplestView::render("header");
SimplestView::render('films',array("results"=>$results));
SimplestView::render("footer");
}
}
}
class photo extends Controller {
function GET($matches) {
if ($matches[1]) {
$db = new MysqliDb($this->config["host"], $this->config["user"], $this->config["pass"], $this->config["base"]);
$results = $db->where('idphoto', $matches[1])
->get('photo',1);
if(!empty($results) && count($results) > 0) {
header("Content-Type: image/jpg");
header("Content-Length: " . strlen($results[0]["contenu"]));
echo $results[0]["contenu"];
}
}
}
}
glue::stick($urls);
function site_url($url = false){
if(empty($url)){
return SITE_URL;
} else {
return SITE_URL.$url;
}
}
?>