-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.php
72 lines (68 loc) · 1.97 KB
/
admin.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
<?php
$conf = include( dirname(__FILE__).'/conf.php' ); // importer la configuration
include ( dirname(__FILE__).'/lib/Weboai.php' ); // importer la logique d’importation OAI
$message = array();
session_start();
// logout
if (isset($_POST['logout'])) {
Weboai::logout();
}
// essai de login, par défaut, logout
else if (isset($_POST['user']) && isset($_POST['pass'])) {
// Weboai::logout(); // NO, will destroy cookie
$_SESSION = array();
$allowed = Weboai::allowed($_POST['user'], $_POST['pass']);
if ($allowed === '') {
$_SESSION['user'] = $_POST['user'];
// $_SESSION['pass'] = $_POST['pass'];
}
else $message[] = $allowed;
}
else {
}
/*
// faut-il revérifier l’authentification ?
else if ( isset($_SESSION['user']) && isset($_SESSION['pass']) ) {
$allowed = Weboai::allowed($_SESSION['user'], $_SESSION['pass']);
echo '<h1>Logged ? $allowed</h1>';
// Weboai::logout();
}
*/
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Admin “<?php echo $conf['repositoryName'] ?>”</title>
<link rel="stylesheet" type="text/css" href="<?php echo $conf['weboaihref'] ?>lib/weboai.css" />
</head>
<body class="oai">
<h1><?php echo $conf['repositoryName'] ?>, <a href="admin.php">administration</a></h1>
<?php
if (isset($_SESSION['user'])) {
echo '<form style="float: right" method="POST">
<a href=".">'.$conf['repositoryName'].' ▲</a><br/>
<button name="logout">Déconnexion</button>
</form>';
}
else {
echo '<form method="POST" style="float: right">
<a href=".">'.$conf['repositoryName'].' ▲</a><br/>
<input placeholder="Utilisateur" class="text" type="text" name="user"/>
<br/><input placeholder="Mot de passe" type="password" class="text" name="pass"/>
<div style="text-align: center; "><button name="login">Connexion</button></div>
</form>';
}
?>
<?php
echo implode("\n", $message);
// privé
if (isset($_SESSION['user'])) {
Weboai::formset();
}
// public
else {
Weboai::formpublic();
}
?>
</body>
</html>