#!/usr/local/bin/php -q $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); } /* read captive portal DB into array */ function squid_cp_read_db($file) { $cpdb = array(); $DB = new SQLite3($file); if ($DB) { $response = $DB->query("SELECT * FROM captiveportal"); if ($response != FALSE) { while ($row = $response->fetchArray()) { $cpdb[] = $row; } } $DB->close(); } return $cpdb; } ?>