aboutsummaryrefslogtreecommitdiffstats
path: root/config/squid3/34/check_ip.php
diff options
context:
space:
mode:
authordoktornotor <notordoktor@gmail.com>2015-09-24 15:46:49 +0200
committerdoktornotor <notordoktor@gmail.com>2015-09-24 15:46:49 +0200
commit536d61533e58b95935c9682820ad8b5a2545ede4 (patch)
tree1a1b03594112f42d3c92ebcac2b6da0f73759fc8 /config/squid3/34/check_ip.php
parent45432e46ab166d2b27f9bef4927cbe2f04b91e63 (diff)
downloadpfsense-packages-536d61533e58b95935c9682820ad8b5a2545ede4.tar.gz
pfsense-packages-536d61533e58b95935c9682820ad8b5a2545ede4.tar.bz2
pfsense-packages-536d61533e58b95935c9682820ad8b5a2545ede4.zip
squid3 - code style fixes
Diffstat (limited to 'config/squid3/34/check_ip.php')
-rw-r--r--config/squid3/34/check_ip.php68
1 files changed, 36 insertions, 32 deletions
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
<?php
-/* $Id$ */
/*
check_ip.php
+ part of pfSense (https://www.pfSense.org/)
Copyright (C) 2013-2015 Marcello Coutinho
+ Copyright (C) 2015 ESF, LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -29,43 +30,46 @@
*/
require_once("config.inc");
error_reporting(0);
+global $g;
// stdin loop
-if (! defined(STDIN)) {
- define("STDIN", fopen("php://stdin", "r"));
+if (!defined(STDIN)) {
+ define("STDIN", fopen("php://stdin", "r"));
+}
+if (!defined(STDOUT)) {
+ define("STDOUT", fopen('php://stdout', 'w'));
+}
+while (!feof(STDIN)) {
+ $line = trim(fgets(STDIN));
}
-if (! defined(STDOUT)){
- define("STDOUT", fopen('php://stdout', 'w'));
- }
-while( !feof(STDIN)){
- $line = trim(fgets(STDIN));
- // %SRC
unset($cp_db);
-$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);
+$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) {
}
?>
-