Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function portal_reply_page($redirurl, $type = null, $message = null, $clientmac = null, $clientip = null, $username = null, $password = null) {
- global $g, $config, $cpzone;
- /* Get captive portal layout */
- if ($type == "redir") {
- header("Location: {$redirurl}");
- return;
- } else if ($type == "login")
- $htmltext = get_include_contents("{$g['varetc_path']}/captiveportal_{$cpzone}.html");
- else if ($type == "already_connected") {
- $sessionid = $_COOKIE['cookie_portal'];
- $htmltext = get_include_contents("{$g['captiveportal_path']}/captiveportal-{$cpzone}-already-connected.html");
- } else
- $htmltext = get_include_contents("{$g['varetc_path']}/captiveportal-{$cpzone}-error.html");
- $cpcfg = $config['captiveportal'][$cpzone];
- /* substitute the PORTAL_REDIRURL variable */
- if ($cpcfg['preauthurl']) {
- $htmltext = str_replace("\$PORTAL_REDIRURL\$", "{$cpcfg['preauthurl']}", $htmltext);
- $htmltext = str_replace("#PORTAL_REDIRURL#", "{$cpcfg['preauthurl']}", $htmltext);
- }
- /* substitute other variables */
- $ourhostname = portal_hostname_from_client_ip($clientip);
- $protocol = (isset($cpcfg['httpslogin'])) ? 'https://' : 'http://';
- $htmltext = str_replace("\$PORTAL_ACTION\$", "{$protocol}{$ourhostname}/", $htmltext);
- $htmltext = str_replace("#PORTAL_ACTION#", "{$protocol}{$ourhostname}/", $htmltext);
- $htmltext = str_replace("\$PORTAL_ZONE\$", htmlspecialchars($cpzone), $htmltext);
- $htmltext = str_replace("\$PORTAL_REDIRURL\$", htmlspecialchars($redirurl), $htmltext);
- $htmltext = str_replace("\$PORTAL_MESSAGE\$", htmlspecialchars($message), $htmltext);
- $htmltext = str_replace("\$CLIENT_MAC\$", htmlspecialchars($clientmac), $htmltext);
- $htmltext = str_replace("\$CLIENT_IP\$", htmlspecialchars($clientip), $htmltext);
- $htmltext = str_replace("\$PORTAL_SESSION\$", htmlspecialchars($sessionid), $htmltext);
- // Special handling case for captive portal master page so that it can be ran
- // through the PHP interpreter using the include method above. We convert the
- // $VARIABLE$ case to #VARIABLE# in /etc/inc/captiveportal.inc before writing out.
- $htmltext = str_replace("#PORTAL_ZONE#", htmlspecialchars($cpzone), $htmltext);
- $htmltext = str_replace("#PORTAL_REDIRURL#", htmlspecialchars($redirurl), $htmltext);
- $htmltext = str_replace("#PORTAL_MESSAGE#", htmlspecialchars($message), $htmltext);
- $htmltext = str_replace("#CLIENT_MAC#", htmlspecialchars($clientmac), $htmltext);
- $htmltext = str_replace("#CLIENT_IP#", htmlspecialchars($clientip), $htmltext);
- $htmltext = str_replace("#PORTAL_SESSION#", htmlspecialchars($sessionid), $htmltext);
- $htmltext = str_replace("#USERNAME#", htmlspecialchars($username), $htmltext);
- $htmltext = str_replace("#PASSWORD#", htmlspecialchars($password), $htmltext);
- echo $htmltext;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement