Ejemplo n.º 1
0
                                //check against local user manager
                                $loginok = local_backed($_POST['auth_user'], $_POST['auth_pass']);
                                if ($loginok && isset($cpcfg['localauth_priv'])) {
                                    $loginok = userHasPrivilege(getUserEntry($_POST['auth_user']), "user-services-captiveportal-login");
                                }
                                if ($loginok) {
                                    captiveportal_logportalauth($_POST['auth_user'], $clientmac, $clientip, "LOGIN");
                                    portal_allow($clientip, $clientmac, $_POST['auth_user']);
                                } else {
                                    captiveportal_logportalauth($_POST['auth_user'], $clientmac, $clientip, "FAILURE");
                                    portal_reply_page($redirurl, "error", $errormsg);
                                }
                            } else {
                                portal_reply_page($redirurl, "error", $errormsg);
                            }
                        } else {
                            if ($_POST['accept'] && $clientip && $cpcfg['auth_method'] == "none") {
                                captiveportal_logportalauth("unauthenticated", $clientmac, $clientip, "ACCEPT");
                                portal_allow($clientip, $clientmac, "unauthenticated");
                            } else {
                                /* display captive portal page */
                                portal_reply_page($redirurl, "login", null, $clientmac, $clientip);
                            }
                        }
                    }
                }
            }
        }
    }
}
ob_flush();
		    </div>
		</div>
	</form>

</div> 
</body>
</html>

<?php 
//PFSense functions to resolve mac
$clientip = $_SERVER['REMOTE_ADDR'];
if (!$clientip) {
    /* not good - bail out */
    log_error("Zone: {$cpzone} - Captive portal could not determine client's IP address.");
    $error_message = "An error occurred.  Please check the system logs for more information.";
    portal_reply_page($redirurl, "error", $errormsg);
    ob_flush();
    return;
}
$macfilter = !isset($cpcfg['nomacfilter']);
$passthrumac = isset($cpcfg['passthrumacadd']);
/* find MAC address for client */
if ($macfilter || $passthrumac) {
    $tmpres = pfSense_ip_to_mac($clientip);
    if (!is_array($tmpres)) {
        /* unable to find MAC address - shouldn't happen! - bail out */
        captiveportal_logportalauth("unauthenticated", "noclientmac", $clientip, "ERROR");
        echo "An error occurred.  Please check the system logs for more information.";
        log_error("Zone: {$cpzone} - Captive portal could not determine client's MAC address.  Disable MAC address filtering in captive portal if you do not need this functionality.");
        ob_flush();
        return;