This repository has been archived by the owner on Apr 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
81 lines (72 loc) · 2.03 KB
/
index.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
73
74
75
76
77
78
79
80
81
<?php
session_start();
require_once 'config.php';
require_once 'header.html';
// In che modo siamo?
if(!isset($_SESSION['logged'])){
// Se non siamo loggati
$mode = 0;
} else {
if($_SESSION['token'] == md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'])){
// Siamo loggati
$mode = 1;
if(isset($_GET['mode'])){
// Abilita la navigazione
$mode = (int)$_GET['mode'];
}
} else {
// Ci stanno rubando la sessione?
$mode = 3;
}
}
// Gestione del menu
echo <<<_END
<ul class="nav nav-pills pull-right">
_END;
print_menu("Scarica", 1, $mode);
print_menu("Visualizza", 2, $mode);
print_menu("Esci", 3, 0);
echo <<<_END
</ul>
<h3 class="muted">phpMyDL</h3>
</div>
<hr>
_END;
switch($mode){
case '1':
// Scarica e converti
require_once 'download.php';
break;
case '2':
// Visualizza
require_once 'show.php';
break;
case '3':
// Termina la sessione
$_SESSION = array();
if(session_id() != "" || isset($_COOKIE[session_name()]))
setcookie(session_name(), '', time() - 2592000, '/');
session_destroy();
echo <<<_END
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>A presto!</strong> La sessione è stata terminata correttamente.
</div>
_END;
require_once 'login.php';
break;
default:
// Forza il login
require_once 'login.php';
break;
}
require_once 'footer.html';
function print_menu($name, $mode, $active){
if($active == $mode || ($mode == 2 && $active == 3)){
$string = sprintf("\t <li class=\"active\"><a href=\"index.php?mode=%d\">%s</a></li>\n", $mode, $name);
} else {
$string = sprintf("\t <li><a href=\"index.php?mode=%d\">%s</a></li>\n", $mode, $name);
}
echo $string;
}
?>