-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
24 lines (22 loc) · 745 Bytes
/
admin.php
File metadata and controls
24 lines (22 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
session_start();
// verifica se o admin está logado
if(isset($_SESSION['admin']) && $_SESSION['admin'] == 1) {
$paginas = listaPaginas();
echo "<h2>Página de administração do site</h2>";
echo "<ul class='list-inline'>";
foreach($paginas as $pagina){
echo "<li><a href='/admin/{$pagina['path']}'>{$pagina['titulo']}</a></li>";
}
echo "<li><a href='/logout'>Sair</a></li>";
echo "</ul>";
$path2 = isset(getPath()[2]) ? getPath()[2] : null;
if($path2 != null) {
$pagina = getConteudo($path2);
require_once ('edita.php');
}
} else {
// Admin não está logado - redireciona para página de login
header("Location: http://{$_SERVER['HTTP_HOST']}/login");
exit;
}