diff options
author | Marcello Coutinho <marcellocoutinho@gmail.com> | 2014-11-20 16:09:48 -0200 |
---|---|---|
committer | Marcello Coutinho <marcellocoutinho@gmail.com> | 2014-11-20 16:09:48 -0200 |
commit | c8539d3211d79c628b59bdcc3eb363cc00e93707 (patch) | |
tree | f7b27f153abe80be30a403ae1071a9e87bc88234 /config/squid3/34/squid_cpauth.php | |
parent | cb0e9496e3e0c541bcd1e6ccca4526a549f137d8 (diff) | |
download | pfsense-packages-c8539d3211d79c628b59bdcc3eb363cc00e93707.tar.gz pfsense-packages-c8539d3211d79c628b59bdcc3eb363cc00e93707.tar.bz2 pfsense-packages-c8539d3211d79c628b59bdcc3eb363cc00e93707.zip |
squid3.4 - first package files
Diffstat (limited to 'config/squid3/34/squid_cpauth.php')
-rw-r--r-- | config/squid3/34/squid_cpauth.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/config/squid3/34/squid_cpauth.php b/config/squid3/34/squid_cpauth.php new file mode 100644 index 00000000..98be9946 --- /dev/null +++ b/config/squid3/34/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"; +} + +?>
\ No newline at end of file |