-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
86 lines (80 loc) · 2.09 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
<?php
require_once('autoload.php');
use \App\Controller\ActorController;
use \App\Controller\UserController;
use \App\Controller\CommentController;
use \App\Controller\VoteController;
$ActorController = new ActorController();
$UserController = new UserController();
$CommentController = new CommentController();
$VoteController = new VoteController();
try{
if(!empty($_SESSION)){
if(isset($_GET['action'])){
if($_GET['action'] == 'update_user'){
$UserController->update($_SESSION['user_id']);
}
elseif($_GET['action']== 'comment_form'){
if(isset($_GET['actor']) && isset($_SESSION['user_id'])){
$CommentController->getCommentForm($_GET['actor'], $_SESSION['user_id']);
}
}
elseif($_GET['action'] == 'add_comment' && !empty($_POST['id_actor']) && !empty($_POST['id_user']) && !empty(['content'])){
$CommentController->addNewComment(
$_POST['id_actor'],
$_POST['id_user'],
$_POST['content']);
}
}
elseif(isset($_GET['vote']) && isset($_GET['actor'])){
if($_GET['vote'] == 'like'){
$dolike = true;
}
if($_GET['vote'] == 'dislike'){
$dolike = false;
}
$VoteController->vote(
$_GET['actor'],
$_SESSION['user_id'],
$dolike);
}
elseif(isset($_GET['view'])){
if($_GET['view'] == 'profile'){
$UserController->getUser($_SESSION['user_id']);
}
}
elseif(isset($_GET['actorView'])){
$ActorController->getActor($_GET['actorView']);
}
else{
$ActorController->listActors();
}
}
elseif(isset($_GET['action'])){
if($_GET['action'] == 'connect'){
$UserController->login();
}
elseif($_GET['action'] == 'signup'){
require ('view/frontend/signup.php');
}
elseif($_GET['action'] == 'adduser'){
$UserController->newUser();
}
elseif($_GET['action']== 'forgot_pwd'){
$UserController->getUserQuestion($_POST['username']);
}
elseif($_GET['action']== 'change_pwd'){
$UserController->changePwd(
$_POST['username'],
$_POST['answer'],
$_POST['newpwd'],
$_POST['verif']);
}
}
else{
require ('view/frontend/login.php');
}
}
catch(Exception $e){
echo 'Erreur : ' .$e->getMessage();
}