From c194db668d8fc33aa09350d0a26329e79bbcf91a Mon Sep 17 00:00:00 2001 From: Marcello Coutinho Date: Wed, 18 Sep 2013 01:53:31 -0300 Subject: squid3-dev - external acl helper for captive portal authentication integration. --- config/squid3/33/check_ip.php | 85 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 config/squid3/33/check_ip.php diff --git a/config/squid3/33/check_ip.php b/config/squid3/33/check_ip.php new file mode 100644 index 00000000..b8f64256 --- /dev/null +++ b/config/squid3/33/check_ip.php @@ -0,0 +1,85 @@ +#!/usr/local/bin/php -q + 2.0){ + $dir="/var/db"; + $files=scandir($dir); + foreach ($files as $file){ + if (preg_match("/captive.*db/",$file)){ + $dbhandle = sqlite_open("$dir/$file", 0666, $error); + if ($dbhandle){ + $query = "select * from captiveportal"; + $result = sqlite_query($dbhandle, $query); + if ($result){ + $row = sqlite_fetch_array($result, SQLITE_ASSOC); + $cp_db[]=implode(",",$row); + sqlite_close($dbhandle); + } + } + } + } + } +else{ + $filename="/var/db/captiveportal.db"; + if (file_exists($filename)) + $cp_db=file($filename); +} + + $usuario=""; + // 1376630450,2,172.16.3.65,00:50:56:9c:00:c7,admin,e1779ea20d0a11c7,,,, + if (is_array($cp_db)){ + foreach ($cp_db as $cpl){ + $fields=explode(",",$cpl); + if ($fields[2] != "" && $fields[2]==$line) + $usuario=$fields[4]; + } + } + if ($usuario !="") + $resposta="OK user={$usuario}"; + else + $resposta="ERR"; + fwrite (STDOUT, "{$resposta}\n"); + unset($cp_db); +} +?> + -- cgit v1.2.3