| Line 92... |
Line 92... |
| 92 |
$username = $_POST['username'];
|
92 |
$username = $_POST['username'];
|
| 93 |
$password = $_POST['password'];
|
93 |
$password = $_POST['password'];
|
| 94 |
$router = $_POST['router'];
|
94 |
$router = $_POST['router'];
|
| 95 |
|
95 |
|
| 96 |
if ( $configData ) {
|
96 |
if ( $configData ) {
|
| 97 |
$isValidUser = false;
|
97 |
$isValidUser = false;
|
| 98 |
if ( isset( $configData[$router]) && isset( $configData[$router]['users'][$username] ) ) {
|
98 |
if ( isset( $configData[$router]) && isset( $configData[$router]['users'][$username] ) ) {
|
| 99 |
$data = $configData[$router]['users'][$username];
|
99 |
$data = $configData[$router]['users'][$username];
|
| 100 |
if ( password_verify( $password, $data['password'] ) ) {
|
100 |
if ( password_verify( $password, $data['password'] ) ) {
|
| 101 |
$isValidUser = true;
|
101 |
$isValidUser = true;
|
| 102 |
$code = $data['otp_seed'] ?? 'unknown';
|
102 |
$code = $data['otp_seed'];
|
| 103 |
$imageFileName = $data['qrFile'];
|
103 |
$imageFileName = $data['qrFile'];
|
| 104 |
$ovpnFileName = $data['ovpnFile'];
|
104 |
$ovpnFileName = $data['ovpnFile'];
|
| 105 |
$log = date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . "\t" .
|
105 |
$log = date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . "\t" .
|
| 106 |
"Success\t" . $username."\t" .PHP_EOL;
|
106 |
"Success\t" . $username."\t" .PHP_EOL;
|
| 107 |
file_put_contents( './log_'.date("j.n.Y").'.log', $log, FILE_APPEND );
|
107 |
file_put_contents( './log_'.date("j.n.Y").'.log', $log, FILE_APPEND );
|
| Line 123... |
Line 123... |
| 123 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
123 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 124 |
<title>Get QR Code</title>
|
124 |
<title>Get QR Code</title>
|
| 125 |
</head>
|
125 |
</head>
|
| 126 |
<body>
|
126 |
<body>
|
| 127 |
<?php
|
127 |
<?php
|
| 128 |
if ( ! empty( $imageFileName ) && ! empty( $code ) ) {
|
128 |
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
| 129 |
print "<div style='text-align: center;'>";
|
129 |
print "<div style='text-align: center;'>";
|
| 130 |
if ( empty($imageFileName) || !file_exists($imageFileName)) {
|
130 |
if ( empty( $code ) || empty($imageFileName) || !file_exists($imageFileName)) {
|
| 131 |
print "<p><b>QR Code image file not found</b></p>";
|
131 |
print "<p><b>QR Code image file not found</b></p>";
|
| - |
|
132 |
print "<p>You may not be set up with a TOTP code on $router, talk to an administrator</p>";
|
| 132 |
} else {
|
133 |
} else {
|
| 133 |
// all good
|
134 |
// all good
|
| 134 |
print "<img src='$imageFileName' alt='$code'>";
|
135 |
print "<img src='$imageFileName' alt='$code'>";
|
| 135 |
}
|
- |
|
| 136 |
print "<br />Your code for $router is<br /><b>$code</b>";
|
136 |
print "<br />Your code for $router is<br /><b>$code</b>";
|
| - |
|
137 |
}
|
| 137 |
if ( empty( $ovpnFileName ) ) {
|
138 |
if ( empty( $ovpnFileName ) ) {
|
| 138 |
print "<br />No OpenVPN configuration file available";
|
139 |
print "<br />No OpenVPN configuration file available";
|
| 139 |
} else {
|
140 |
} else {
|
| 140 |
print "<br /><a href='$ovpnFileName' download>Download your OpenVPN Config File</a>";
|
141 |
print "<br /><a href='$ovpnFileName' download>Download your OpenVPN Config File</a>";
|
| 141 |
}
|
142 |
}
|
| 142 |
print '</div>';
|
143 |
print '</div>';
|
| 143 |
}
|
144 |
}
|
| 144 |
?>
|
145 |
?>
|
| 145 |
<p>This page is updated hourly. If change your password, it will not be reflected here for an hour</p>
|
146 |
<p>This page is updated hourly. If change your password, it will not be reflected here for an hour</p>
|
| 146 |
<form method="POST" action="">
|
147 |
<form method="POST" action="">
|