From 536d61533e58b95935c9682820ad8b5a2545ede4 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Thu, 24 Sep 2015 15:46:49 +0200 Subject: squid3 - code style fixes --- config/squid3/34/check_ip.php | 68 +++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'config/squid3') diff --git a/config/squid3/34/check_ip.php b/config/squid3/34/check_ip.php index 5865037b..68deb02c 100644 --- a/config/squid3/34/check_ip.php +++ b/config/squid3/34/check_ip.php @@ -1,9 +1,10 @@ #!/usr/local/bin/php -q $row){ - $cp_db[$rownum]=implode(",",$row); +$files = scandir($g['vardb_path']); +foreach ($files as $file) { + if (preg_match("/captive.*db/", $file)) { + $result = squid_cp_read_db("{$g['vardb_path']}/{$file}"); + foreach ($result as $rownum => $row) { + $cp_db[$rownum] = implode(",", $row); } } } - $usuario=""; - //1419045939,1419045939,2000,2000,192.168.10.11,192.168.10.11,08:00:27:5c:e1:ee,08:00:27:5c:e1:ee,marcello,marcello,605a1f46e2d64556,605a1f46e2d64556,,,,,,,,,,,first,first - if (is_array($cp_db)){ - foreach ($cp_db as $cpl){ - $fields=explode(",",$cpl); - if ($fields[4] != "" && $fields[4]==$line) - $usuario=$fields[8]; - } - } - if ($usuario !="") - $resposta="OK user={$usuario}"; - else - $resposta="ERR"; - fwrite (STDOUT, "{$resposta}\n"); - unset($cp_db); + $usuario = ""; + //1419045939,1419045939,2000,2000,192.168.10.11,192.168.10.11,08:00:27:5c:e1:ee,08:00:27:5c:e1:ee,marcello,marcello,605a1f46e2d64556,605a1f46e2d64556,,,,,,,,,,,first,first + if (is_array($cp_db)) { + foreach ($cp_db as $cpl) { + $fields = explode(",", $cpl); + if ($fields[4] != "" && $fields[4] == $line) { + $usuario = $fields[8]; + } + } + } + if ($usuario != "") { + $resposta = "OK user={$usuario}"; + } else { + $resposta = "ERR"; + } + fwrite(STDOUT, "{$resposta}\n"); + unset($cp_db); } /* read captive portal DB into array */ @@ -75,8 +79,9 @@ function squid_cp_read_db($file) { if ($DB) { $response = $DB->query("SELECT * FROM captiveportal"); if ($response != FALSE) { - while ($row = $response->fetchArray()) + while ($row = $response->fetchArray()) { $cpdb[] = $row; + } } $DB->close(); } @@ -85,4 +90,3 @@ function squid_cp_read_db($file) { } ?> - -- cgit v1.2.3