Revision 72b9e452
Added by Ermal LUÇI about 15 years ago
usr/local/captiveportal/index.php | ||
---|---|---|
194 | 194 |
|
195 | 195 |
exit; |
196 | 196 |
|
197 |
function portal_reply_page($redirurl, $type = null, $message = null, $clientmac = null, $clientip = null) { |
|
197 |
function portal_reply_page($redirurl, $type = null, $message = null, $clientmac = null, $clientip = null, $username = null, $password = null) {
|
|
198 | 198 |
global $g, $config; |
199 | 199 |
|
200 | 200 |
/* Get captive portal layout */ |
... | ... | |
232 | 232 |
$htmltext = str_replace("#PORTAL_MESSAGE#", htmlspecialchars($message), $htmltext); |
233 | 233 |
$htmltext = str_replace("#CLIENT_MAC#", htmlspecialchars($clientmac), $htmltext); |
234 | 234 |
$htmltext = str_replace("#CLIENT_IP#", htmlspecialchars($clientip), $htmltext); |
235 |
$htmltext = str_replace("#USERNAME#", htmlspecialchars($username), $htmltext); |
|
236 |
$htmltext = str_replace("#PASSWORD#", htmlspecialchars($password), $htmltext); |
|
235 | 237 |
|
236 | 238 |
echo $htmltext; |
237 | 239 |
} |
... | ... | |
254 | 256 |
|
255 | 257 |
function portal_allow($clientip,$clientmac,$username,$password = null, $attributes = null, $ruleno = null) { |
256 | 258 |
|
257 |
global $redirurl, $g, $config, $type, $passthrumac; |
|
259 |
global $redirurl, $g, $config, $type, $passthrumac, $_POST;
|
|
258 | 260 |
|
259 | 261 |
/* See if a ruleno is passed, if not start locking the sessions because this means there isn't one atm */ |
260 | 262 |
$captiveshouldunlock = false; |
... | ... | |
285 | 287 |
if ($attributes['voucher']) |
286 | 288 |
$remaining_time = $attributes['session_timeout']; |
287 | 289 |
|
290 |
$writecfg = false; |
|
288 | 291 |
/* Find an existing session */ |
289 | 292 |
if ((isset($config['captiveportal']['noconcurrentlogins'])) && $passthrumac) { |
290 | 293 |
if (isset($config['captiveportal']['passthrumacadd'])) { |
291 | 294 |
$mac = captiveportal_passthrumac_findbyname($username); |
292 | 295 |
if (!empty($mac)) { |
293 |
portal_reply_page($redirurl, "error", "Username: {$username} is known with another mac address."); |
|
294 |
exit; |
|
296 |
if ($_POST['replacemacpassthru']) { |
|
297 |
foreach ($a_passthrumacs as $idx => $macent) { |
|
298 |
if ($macent['mac'] == $mac['mac']) { |
|
299 |
unset($config['captiveportal']['passthrumac'][$idx]); |
|
300 |
$mac['mac'] = $clientmac; |
|
301 |
$config['captiveportal']['passthrumac'][] = $mac; |
|
302 |
$macrules = captiveportal_passthrumac_configure_entry($mac); |
|
303 |
file_put_contents("{$g['tmp_path']}/macentry.rules.tmp", $macrules); |
|
304 |
mwexec("/sbin/ipfw -q {$g['tmp_path']}/macentry.rules.tmp"); |
|
305 |
$writecfg = true; |
|
306 |
$sessionid = true; |
|
307 |
break; |
|
308 |
} |
|
309 |
} |
|
310 |
} else { |
|
311 |
portal_reply_page($redirurl, "error", "Username: {$username} is known with another mac address.", |
|
312 |
$clientmac, $clientip, $username, $password); |
|
313 |
exit; |
|
314 |
} |
|
295 | 315 |
} |
296 | 316 |
} |
297 | 317 |
} |
... | ... | |
334 | 354 |
return 0; // voucher already used and no time left |
335 | 355 |
} |
336 | 356 |
|
337 |
$writecfg = false; |
|
338 | 357 |
if (!isset($sessionid)) { |
339 | 358 |
|
340 | 359 |
/* generate unique session ID */ |
Also available in: Unified diff
Some configurations want to be able to ask users about replacing their existing mac during auto mac passthrough logins if they change equipment. Allow this in the backend by requiring the user to need posting a replacemacpassthru field with the post. Also add the possibility to send back with a portal_reply_page generated page the username and password posted.