/
index.php
64 lines (63 loc) · 2.22 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
<?php
require('controller/frontend.php');
require('controller/backend.php');
try {
if (isset($_GET['action'])) {
if ($_GET['action'] == '' || $_GET['action'] == 'listProjects') {
listProjects();
}
else if ($_GET['action'] == 'project') {
if (isset($_GET['id']) && $_GET['id'] > 0) {
project();
}
else {
throw new Exception('Veuillez renseigner un numéro de projet.<br><a class="center" href="?action=listProjects">Retourner à la liste des projets ?</a>');
}
}
// Blog
else if ($_GET['action'] == 'listPosts') {
listPosts();
}
else if ($_GET['action'] == 'post') {
if (isset($_GET['id']) && $_GET['id'] > 0) {
post();
}
else {
throw new Exception('Veuillez renseigner un numéro d\'article.<br><a class="center" href="?action=listPosts">Retourner à la liste des articles ?</a>');
}
}
elseif ($_GET['action'] == 'addComment') {
if (isset($_GET['id']) && $_GET['id'] > 0) {
if (!empty($_POST['author']) && !empty($_POST['comment'])) {
addComment($_GET['id'], $_POST['author'], $_POST['comment']);
}
else {
throw new Exception('Tous les champs ne sont pas remplis !<br><a class="center" href="?action=post&id=' . $_GET['id'] . '">Retourner à l\'article ?</a>');
}
}
else {
throw new Exception('Aucun identifiant d\'article.<br><a class="center" href="?action=listPosts">Retourner à la liste des articles ?</a>');
}
}
// End BLog
else if ($_GET['action'] == 'cv') {
cv();
}
else if ($_GET['action'] == 'contact') {
contact();
}
else if ($_GET['action'] == 'sendMail') {
sendMail();
}
else {
throw new Exception('Error 404 : action not found');
}
}
else { // Default page
listProjects();
}
}
catch(Exception $e) {
$errorMessage = $e->getMessage();
require('view/frontend/errorView.php');
}