This repository was archived by the owner on Sep 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
107 lines (70 loc) · 2.34 KB
/
index.php
File metadata and controls
107 lines (70 loc) · 2.34 KB
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
<?php
// Initialisation
include 'global/init.php';
$error = null;
if($_POST != null && cleanGlobal($_POST, 'action') == "connect") {
require_once(PATH_MODEL."Right.php");
require_once(PATH_MODEL."User.php");
$login = cleanGlobal($_POST, 'login');
$password = cleanGlobal($_POST, 'password', false);
if(!is_null($login) && !is_null($password)) {
$connect = User::getUserByName($login);
if(!is_null($connect) && $connect->getPassword() == sha1($password)) {
session_name(SESSION_KEY);
$_SESSION['connected'] = 1;
$_SESSION['usr_id'] = $connect->getId();
$connect->setListRights(Right::getRightsForUser($connect->getId()));
$_SESSION['current_user'] = serialize($connect);
$usrid = $connect->getId();
$error = "OK";
} else {
if(is_null($connect)) {
$usrid = "NULL";
$error = "Wrong login.";
} else if ($connect->getPassword() != sha1($password)) {
$usrid = "NULL";
$error = "Wrong password.";
}
}
} else {
if(is_null($login)) {
$usrid = "NULL";
$error = "Login missing.";
} else if (is_null($password)) {
$usrid = "NULL";
$error = "Password missing.";
}
}
} else if($_POST != null && cleanGlobal($_POST, 'action') == "disconnect") {
session_name(SESSION_KEY);
session_destroy();
header('Location: '.$_SERVER['REQUEST_URI']);
}
// Début de la tamporisation de sortie
ob_start();
// Si un module est specifié, on regarde s'il existe
if (!empty($_GET['module'])) {
$module = dirname(__FILE__).'/modules/'.$_GET['module'].'/';
// Si l'action est specifiée, on l'utilise, sinon, on tente une action par défaut
$action = (!empty($_GET['action'])) ? $_GET['action'].'.php' : 'index.php';
// Si l'action existe, on l'exécute
if (is_file($module.$action)) {
include $module.$action;
// Sinon, on affiche la page d'accueil !
} else {
// header('Location: 404.php');
include '404.php';
}
} else if (!empty($_GET['action']) && $_GET['action'] == 'license') {
include 'global/license.php';
// Module non specifié ou invalide ? On affiche la page d'accueil !
} else {
header('Location: index.php?module=news');
}
// Fin de la tamporisation de sortie
$contenu = ob_get_clean();
// Début du code HTML
include 'global/header.php';
echo $contenu;
// Fin du code HTML
include 'global/footer.php';