-
Notifications
You must be signed in to change notification settings - Fork 6
/
login.php
executable file
·172 lines (160 loc) · 6.94 KB
/
login.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
/*
+--------------------------------------------------------------------------+
| phpMyBackupPro |
+--------------------------------------------------------------------------+
| Copyright (c) 2004-2015 by Dirk Randhahn |
| http://www.phpMyBackupPro.net |
| version information can be found in definitions.php. |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with this program; if not, write to the Free Software |
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.|
+--------------------------------------------------------------------------+
*/
if (!isset($_SESSION)) {
session_start();
}
// get password and username
require_once "definitions.php";
// login with http authentification
if ($CONF['login'] && !$_SESSION['multi_user_mode']) {
if (!isset($_SERVER['PHP_AUTH_USER'])
|| (isset($_GET["login"]) && !($_SERVER['PHP_AUTH_USER'] == $CONF['sql_user'] && $_SERVER['PHP_AUTH_PW'] == $CONF['sql_passwd']))
|| (isset($_GET["logout"]) && $_SERVER['PHP_AUTH_PW'] == $CONF['sql_passwd'])) {
header("WWW-Authenticate: Basic realm=\"phpMyBackupPro\"");
header("HTTP/1.0 401 Unauthorized");
echo LI_NOT_LOGED_OUT;
echo ": <a href=\"index.php?logout=TRUE\">" . F_LOGOUT . "</a><br>";
echo LI_MSG . ": <a href=\"index.php?login=TRUE\">" . LI_LOGIN . "</a>";
exit;
} else if ($_SERVER['PHP_AUTH_PW'] != $CONF['sql_passwd']) {
echo LI_LOGED_OUT . "<br>\n" . LI_MSG;
echo ": <a href=\"index.php?login=TRUE\">" . LI_LOGIN . "</a>";
unset($_SESSION['LOGGED_IN']);
unset($_SESSION['sql_host_org']);
unset($_SESSION['sql_user_org']);
unset($_SESSION['sql_passwd_org']);
@session_destroy();
exit;
}
// login with html authentification
} else {
// disable login functions if $CONF['no_login'] is true
if ($CONF['no_login'] != "1") {
if (!isset($_SESSION['LOGGED_IN'])) {
$_SESSION['LOGGED_IN'] = false;
}
// not logged in
if (!$_SESSION['LOGGED_IN']) {
if (!isset($_POST['password'])) {
$_POST['password'] = false;
}
if (!isset($_POST['username'])) {
$_POST['username'] = false;
}
// distinguish between multi and single user mode
if ($_SESSION['multi_user_mode']) {
$con = @mysqli_connect($PMBP_MU_CONF['sql_host_admin'], $PMBP_MU_CONF['sql_user_admin'], $PMBP_MU_CONF['sql_passwd_admin']);
mysqli_select_db($con, "mysql");
$_POST['username'] = mysqli_real_escape_string($con, $_POST['username']);
$_POST['password'] = mysqli_real_escape_string($con, $_POST['password']);
$res = mysqli_query($con, "select * from user where (User='" . $_POST['username'] . "' or User='') and password=password('" . $_POST['password'] . "')");
$success = mysqli_fetch_array($res);
@mysqli_close($con);
} else {
if ($CONF['sql_user'] == $_POST['username'] && $CONF['sql_passwd'] == $_POST['password']) {
$success = true;
} else {
$success = false;
}
}
// was the login successful?
if ($success) {
// login successful - set "LOGGED_IN"-bit
$_SESSION['LOGGED_IN'] = true;
$_GET['login'] = true;
// just make these settings for the first page after login, because definitions.php was already loaded
$_SESSION['sql_user'] = $_POST['username'];
$_SESSION['sql_passwd'] = $_POST['password'];
$_SESSION['sql_host'] = $PMBP_MU_CONF['sql_host_admin'];
$CONF['sql_user'] = $_SESSION['sql_user'];
$CONF['sql_passwd'] = $_SESSION['sql_passwd'];
$CONF['sql_host'] = $_SESSION['sql_host'];
$CONF['sql_db'] = "";
} else {
// login failed - print login form
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html<?php echo ARABIC_HTML; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" href="<?php echo PMBP_STYLESHEET_DIR . $CONF['stylesheet']; ?>.css" type="text/css">
<title>phpMyBackupPro <?php echo PMBP_VERSION; ?></title>
</head>
<body onLoad="document.login.username.focus()"><center>
<form name="login" action="" method="POST">
<table width="400">
<tr>
<th colspan="2" class="active">
<?php
echo PMBP_image_tag("logo.png", "phpMyBackupPro", "http://www.phpMyBackupPro.net", "http://www.phpMyBackupPro.net");
?>
</th>
</tr>
<tr>
<td colspan="2"><?php echo LI_MSG; ?>:</td>
</tr>
<tr>
<td><?php echo LI_USER; ?>:</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td><?php echo LI_PASSWD; ?>:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="login" value="<?php echo LI_LOGIN; ?>" class="button"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
<?php
$CONF = "";
// break loading page if not logged in
exit;
}
}
// logout
if (isset($_GET['logout'])) {
@session_start();
unset($_SESSION['PMBP_VERSION']);
unset($_SESSION['LOGGED_IN']);
unset($_SESSION['sql_host_org']);
unset($_SESSION['sql_user_org']);
unset($_SESSION['sql_passwd_org']);
unset($_SESSION['sql_user']);
unset($_SESSION['sql_passwd']);
unset($_SESSION['file_system']);
header("Location: index.php");
exit;
}
// when login functions is disabled
} else {
$_SESSION['LOGGED_IN'] = "Login deactivated!";
}
} // end type of auth
?>