-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.php
66 lines (51 loc) · 2.25 KB
/
global.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
<?php
//Les constantes du template
define("SITE", "http:https://localhost/MT_website/");
define("CSS", SITE."css/");
define("JS", SITE."js/");
define("IMG_ILE", SITE."img/iles/");
define("TPL", "./require/");
define('ROOTDIR', __DIR__);
define('CLASSDIR', ROOTDIR . '/class/');
define("ACTION", SITE."action/");
//Date en français
setlocale(LC_TIME, "fr_FR");
//Include des class
include CLASSDIR . 'Autoloader.php';
Autoloader::load();
//création des objets
$db = new Database();
$html = new Html();
$destination = new Destination();
$reservation = new Reservation();
$client = new Client();
//Inscription client avec vérifications de la saisie
if(isset($_GET['register'])){
if(isset($_POST['nom']) && isset($_POST['prenom']) && isset($_POST['email']) && isset($_POST['password']) && isset($_POST['adresse']) && isset($_POST['cp']) && isset($_POST['ville']) && Html::validStr($_POST['nom']) && Html::validStr($_POST['prenom']) && Html::validStr($_POST['email']) && Html::validStr($_POST['password']) && Html::validStr($_POST['adresse']) && Html::validStr($_POST['cp']) && Html::validStr($_POST['ville'])){
if(strlen($_POST['password']) < 5) {
$errorPopup = "Le mot de passe saisi est trop petit.";
} else if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$errorPopup = "L'email saisie n'est pas valide.";
} else if(!$client->register($_POST['nom'], $_POST['prenom'], $_POST['email'], $_POST['password'], $_POST['adresse'], $_POST['cp'], $_POST['ville'])){
$errorPopup = "L'adresse mail est déjà utilisée.";
} else {
header("location: ".Html::validUrlEspaceClient($_SERVER['HTTP_REFERER']));
}
}else{
$errorPopup = "Les données saisies ne sont pas correctes !";
}
}
//Connexion client
if(isset($_GET['connect'])){
if(isset($_POST['email']) && isset($_POST['password']) && Html::validStr($_POST['email']) && Html::validStr($_POST['password'])){
$client->checkConnexion(false, $_POST['email'], $_POST['password']);
if(!$client->getOnline()) {
$errorPopup = "E-mail ou mot de passe incorrect !";
} else {
header("location: ".Html::validUrlEspaceClient($_SERVER['HTTP_REFERER']));
}
}else{
$errorPopup = "Les données saisies ne sont pas correctes !";
}
}
?>