#!/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); } ?>