-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_auth.php
More file actions
171 lines (158 loc) · 6.01 KB
/
test_auth.php
File metadata and controls
171 lines (158 loc) · 6.01 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
/**
* Fichier de test - Affiche les infos d'authentification actuelles
* Accéder à: http://localhost/Notepad+/test_auth.php
*/
include 'api/auth_helper.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test Authentification</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.box { padding: 15px; margin: 10px 0; border: 1px solid #ddd; border-radius: 4px; background: #f9f9f9; }
.success { background: #d4edda; border-color: #28a745; }
.error { background: #f8d7da; border-color: #dc3545; }
.info { background: #d1ecf1; border-color: #17a2b8; }
code { background: #f4f4f4; padding: 2px 6px; border-radius: 3px; }
table { border-collapse: collapse; width: 100%; margin: 10px 0; }
th, td { border: 1px solid #ddd; padding: 10px; text-align: left; }
th { background: #f0f0f0; }
</style>
</head>
<body>
<h1>🔐 Test Authentification</h1>
<div class="box <?php echo isUserAuthenticated() ? 'success' : 'error'; ?>">
<h2>État d'authentification</h2>
<?php if (isUserAuthenticated()): ?>
<p>✓ <strong>Utilisateur authentifié</strong></p>
<table>
<tr>
<th>Propriété</th>
<th>Valeur</th>
</tr>
<tr>
<td><code>user_id</code></td>
<td><strong><?php echo getCurrentUserId(); ?></strong></td>
</tr>
<tr>
<td><code>user_pseudo</code></td>
<td><strong><?php echo getCurrentUserPseudo(); ?></strong></td>
</tr>
</table>
<?php else: ?>
<p>✗ <strong>Aucun utilisateur authentifié</strong></p>
<p><a href="login.php">Cliquez ici pour vous connecter</a></p>
<?php endif; ?>
</div>
<div class="box info">
<h2>📊 Cookies actuels</h2>
<?php if (!empty($_COOKIE)): ?>
<table>
<tr>
<th>Nom</th>
<th>Valeur</th>
</tr>
<?php foreach ($_COOKIE as $name => $value): ?>
<tr>
<td><code><?php echo htmlspecialchars($name); ?></code></td>
<td><code><?php echo htmlspecialchars(substr($value, 0, 50)) . (strlen($value) > 50 ? '...' : ''); ?></code></td>
</tr>
<?php endforeach; ?>
</table>
<?php else: ?>
<p>Aucun cookie trouvé</p>
<?php endif; ?>
</div>
<div class="box info">
<h2>🔧 Tests API</h2>
<h3>1. Test de chargement de roadmap</h3>
<button onclick="testGetRoadmap()">Tester get_roadmap.php</button>
<pre id="test-get-result" style="background: #f4f4f4; padding: 10px; margin: 10px 0; display: none;"></pre>
<h3>2. Test de sauvegarde de roadmap</h3>
<button onclick="testCreateRoadmap()">Tester create_roadmap.php</button>
<pre id="test-create-result" style="background: #f4f4f4; padding: 10px; margin: 10px 0; display: none;"></pre>
<h3>3. Test de déconnexion</h3>
<button onclick="testLogout()">Tester logout.php</button>
<p id="test-logout-result"></p>
</div>
<div class="box">
<h2>📝 Informations serveur</h2>
<table>
<tr>
<th>Clé</th>
<th>Valeur</th>
</tr>
<tr>
<td>Adresse IP</td>
<td><?php echo $_SERVER['REMOTE_ADDR']; ?></td>
</tr>
<tr>
<td>User Agent</td>
<td><?php echo substr($_SERVER['HTTP_USER_AGENT'], 0, 60); ?>...</td>
</tr>
<tr>
<td>Heure serveur</td>
<td><?php echo date('Y-m-d H:i:s'); ?></td>
</tr>
<tr>
<td>PHP Version</td>
<td><?php echo PHP_VERSION; ?></td>
</tr>
</table>
</div>
<script>
function testGetRoadmap() {
const resultEl = document.getElementById('test-get-result');
resultEl.style.display = 'block';
resultEl.textContent = 'Chargement...';
fetch('api/get_roadmap.php', {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
.then(res => res.json())
.then(data => {
resultEl.textContent = JSON.stringify(data, null, 2);
})
.catch(err => {
resultEl.textContent = 'Erreur: ' + err.message;
});
}
function testCreateRoadmap() {
const resultEl = document.getElementById('test-create-result');
resultEl.style.display = 'block';
resultEl.textContent = 'Chargement...';
const testData = {
nodes: [
{ id: 1, type: 'rect', text: 'Test Node', status: 'planned', color: 'blue' }
],
edges: []
};
fetch('api/create_roadmap.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(testData)
})
.then(res => {
resultEl.textContent = 'Status: ' + res.status + '\n' + JSON.stringify(res, null, 2);
return res.json();
})
.then(data => {
resultEl.textContent = JSON.stringify(data, null, 2);
})
.catch(err => {
resultEl.textContent = 'Erreur: ' + err.message;
});
}
function testLogout() {
const resultEl = document.getElementById('test-logout-result');
resultEl.innerHTML = '<em>Redirection vers logout.php...</em>';
setTimeout(() => {
window.location.href = 'api/logout.php';
}, 1000);
}
</script>
</body>
</html>