forked from GDRCD/GDRCD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
protezione.php
85 lines (77 loc) · 2.59 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/*************************************************
* Breaker Site Protector
* From Max Site Protector
*
* Version: 2.0
* Date: 2020-05-27
*
****************************************************/
require_once('config.inc.php');
class Protector {
public $password;
public $appName;
public function __construct($PARAMETERS) {
$this->password = $PARAMETERS['settings']['protection_password'];
$this->appName = $PARAMETERS['info']['site_name'];
}
/**
* 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 password 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;
}
}
}
}
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><?php echo $this->appName; ?></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"><?php echo $this->appName; ?></div>
<div id="header_right"></div>
</div>
<div id="content">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>Password:
<input name="passwd" type="password" size="20" />
</label><br />
<label>
<input type="submit" name="submitBtn" class="sbtn" value="Login" />
</label>
</form>
</div>
<div id="footer"></div>
</div>
</body>
<?php
}
}
// Auto create
session_start();
$protector = new Protector($PARAMETERS);
$protector->login();
?>