¿Variables del portal cautivo?
-
Buenas a todos
En la parte de documentación no veo todas las variables que se puede usar en el login del portal cautivo, algunas las he encontrado por aquí, pero quisiera saber dónde puedo encontrar las demás variables que se pueden usar.
Por ejemplo, variables para mostrar tiempo de conexión, ip del usuario, mac del usuario etc..
-
Hola
En el fichero: /etc/inc/captiveportal.inc
Hay una función php, llamada: portal_reply_page.
Donde, creo, están algunas de las variables que necesitas sobre el portal cautivo.
$cpzone
$redirurl
$message
$clientmac
$clientip
$username
$passwordfunction 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 { $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}/index.php?zone={$cpzone}", $htmltext); $htmltext = str_replace("#PORTAL_ACTION#", "{$protocol}{$ourhostname}/index.php?zone={$cpzone}", $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); // 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("#USERNAME#", htmlspecialchars($username), $htmltext); $htmltext = str_replace("#PASSWORD#", htmlspecialchars($password), $htmltext); echo $htmltext; }
Referencia: https://forum.pfsense.org/index.php?topic=51095.0
Y en ese mismo fichero, en la función: function portal_allow , hay una variable llamada $remaining_time , que creo se refiere al tiempo de permanecia …
Bucea un poco en el código de ese fichero y creo que obtendrás la respuestas.
Salu2
-
Hola
Una aclaración
Las variables que te interesan para tu página del portal cautivo tendrán el formato:
$CLIENT_IP$ ( se correponderia a la variable en php $clientip )
$CLIENT_MAC$ ( idem $clientmac )
…
etcSalu2