forked from GDRCD/GDRCD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotezione.php
71 lines (66 loc) · 2.23 KB
/
protezione.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
<?php
/*************************************************
* Max's Site Protector
*
* Version: 1.0
* Date: 2007-11-27
*
****************************************************/
class maxProtector{
var $password = 'gdrcd';
function showLoginForm(){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GDRCD 5.2</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header"><div id="header_left"></div>
<div id="header_main">Pagina di protezione GDRCD 5.2</div><div id="header_right"></div></div>
<div id="content">
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<center>
<label>Password:
<input name="passwd" type="password" size="20" />
</label><br/>
<label>
<input type="submit" name="submitBtn" class="sbtn" value="Login" />
</label>
</center>
</form>
</div>
<div id="footer"></div>
</div>
</body>
<?php
}
/**
* Checks if the user is logged-in and performs login. If not a login form is shown, if the submit button was pressed it checks if the passowrd is correct and logs the user in.
*/
function login(){
$loggedin = isset($_SESSION['loggedin']) ? $_SESSION['loggedin'] : false;
if ( (!isset($_POST['submitBtn'])) && (!($loggedin))){
$_SESSION['loggedin'] = false;
$this->showLoginForm();
exit();
} else if (isset($_POST['submitBtn'])) {
$pass = isset($_POST['passwd']) ? $_POST['passwd'] : '';
if ($pass != $this->password) {
$_SESSION['loggedin'] = false;
$this->showLoginForm();
exit();
} else {
$_SESSION['loggedin'] = true;
}
}
}
}
// Auto create
session_start();
$protector = new maxProtector();
$protector->login();
?>