aboutsummaryrefslogtreecommitdiffstats
path: root/config/squid3/33/squid_cpauth.php
diff options
context:
space:
mode:
authorbmeeks8 <bmeeks8@bellsouth.net>2013-05-13 17:09:43 -0400
committerbmeeks8 <bmeeks8@bellsouth.net>2013-05-13 17:09:43 -0400
commit4a38b4b1a48b67baf997453227c9d4a1bb810523 (patch)
tree0321c07f5267806b55ad025df8c13968ac17ba94 /config/squid3/33/squid_cpauth.php
parent080fb922c15c959be4f0bd101d0cf3f529f0e866 (diff)
parent3eddd42b1d0da5bdf5faec0e5036ef30347fa0a3 (diff)
downloadpfsense-packages-4a38b4b1a48b67baf997453227c9d4a1bb810523.tar.gz
pfsense-packages-4a38b4b1a48b67baf997453227c9d4a1bb810523.tar.bz2
pfsense-packages-4a38b4b1a48b67baf997453227c9d4a1bb810523.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'config/squid3/33/squid_cpauth.php')
-rw-r--r--config/squid3/33/squid_cpauth.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/config/squid3/33/squid_cpauth.php b/config/squid3/33/squid_cpauth.php
new file mode 100644
index 00000000..e0971c5d
--- /dev/null
+++ b/config/squid3/33/squid_cpauth.php
@@ -0,0 +1,24 @@
+#!/usr/local/bin/php -q
+<?php
+
+$NONINTERACTIVE_SCRIPT = TRUE;
+
+$fp = fopen('php://stdin', 'r');
+while($args = split(" ",trim(fgets($fp, 4096)))){
+ print captive_ip_to_username($args);
+}
+
+function captive_ip_to_username($args){
+ $current_sessions = file("/var/db/captiveportal.db");
+ foreach($current_sessions as $session){
+ list($a, $b, $IP_Address, $Mac_Address, $Username) = explode(",", $session,5);
+ #this test allow access if user's ip is listed on captive portal
+ #args array has (ip, site, protocol and port) passed by squid helper
+ #include a more complex test here to allow or deny access based on username returned
+ # this script will not return username to squid logs
+ if($IP_Address == $args[0]) return "OK\n";
+ }
+ return "ERR\n";
+}
+
+?>