-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.php
134 lines (119 loc) · 4.68 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
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
<?php
$configfile = 'config.php';
if (!file_exists($configfile)) {
echo '<meta http-equiv="refresh" content="0; url=install" />';
exit();
}
include "config.php";
session_start();
if (isset($_SESSION['sec-username'])) {
$uname = $_SESSION['sec-username'];
$table = $prefix . 'users';
$suser = $mysqli->query("SELECT * FROM `$table` WHERE username='$uname'");
$count = mysqli_num_rows($suser);
if ($count > 0) {
echo '<meta http-equiv="refresh" content="0; url=dashboard.php" />';
exit;
}
}
$_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
$_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
$error = 0;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<meta name="theme-color" content="#4b545c">
<title>BeFree › Admin Panel</title>
<!-- CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css">
<link href="assets/css/admin.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
<!-- Favicon -->
<link rel="shortcut icon" href="assets/img/favicon.png">
</head>
<body class="login-page">
<div class="login-box">
<form action="" method="post">
<div class="login-logo">
<a href="#"><i class="fab fa-get-pocket"></i> Welcome to <b>BeFree</b></a>
<h5 class="alert-danger">Please login with your admin credentials</h5>
</div>
<div class="card">
<div class="card-body login-card-body">
<?php
if (isset($_POST['signin'])) {
$ip = $_SERVER['REMOTE_ADDR'];
@$date = @date("d F Y");
@$time = @date("H:i");
$username = mysqli_real_escape_string($mysqli, $_POST['username']);
$password = hash('sha256', $_POST['password']);
$table = $prefix . "users";
$check = $mysqli->query("SELECT username, password FROM `$table` WHERE `username`='$username' AND password='$password'");
if (mysqli_num_rows($check) > 0) {
$table = $prefix . "logins";
$checklh = $mysqli->query("SELECT id FROM `$table` WHERE `username`='$username' AND ip='$ip' AND date='$date' AND time='$time' AND successful='1'");
if (mysqli_num_rows($checklh) == 0) {
$log = $mysqli->query("INSERT INTO `$table` (username, ip, date, time, successful) VALUES ('$username', '$ip', '$date', '$time', '1')");
}
$_SESSION['sec-username'] = $username;
echo '<meta http-equiv="refresh" content="0;url=dashboard.php">';
} else {
$table = $prefix . "logins";
$checklh = $mysqli->query("SELECT id FROM `$table` WHERE `username`='$username' AND ip='$ip' AND date='$date' AND time='$time' AND successful='0'");
if (mysqli_num_rows($checklh) == 0) {
$log = $mysqli->query("INSERT INTO `$table` (username, ip, date, time, successful) VALUES ('$username', '$ip', '$date', '$time', '0')");
}
echo '
<div class="alert alert-danger">
<i class="fas fa-exclamation-circle"></i> The entered <strong>Username</strong> or <strong>Password</strong> is incorrect.
</div>';
$error = 1;
}
}
?>
<div class="form-group has-feedback <?php
if ($error == 1) {
echo 'has-danger';
}
?>">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text"><em class="fa fa-fw fa-user"></em></div>
</div>
<input type="username" name="username" class="form-control <?php
if ($error == 1) {
echo 'is-invalid';
}
?>" placeholder="Username" <?php
if ($error == 1) {
echo 'autofocus';
}
?> required>
</div>
</div>
<div class="form-group has-feedback">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text"><em class="fa fa-fw fa-key"></em></div>
</div>
<input type="password" name="password" class="form-control" placeholder="Password" required>
</div>
</div>
<div class="row">
<div class="col-md-12">
<button type="submit" name="signin" class="btn btn-md btn-primary btn-block btn-flat"><i class="fas fa-sign-in-alt"></i>
Sign In</button>
</div>
</div>
</div>
</div>
</form>
</div>
</body>
</html>