I have so far been running squid using the basic ncsa auth.
I now need to add some custom authentication for ncsa auth and also an IP address.
I would like to do this using a PHP script.
How can I check the ncsa auth file in the script:
Code:
if (! defined(STDIN)) {
define("STDIN", fopen("php://stdin", "r"));
}
while (!feof(STDIN)) {
$line = trim(fgets(STDIN));
$fields = explode(' ', $line);
$username = rawurldecode($fields[0]); //1738
$password = rawurldecode($fields[1]); //1738
#I need to check the squid_passwd file here?????
#how can PHP read the squid_passwd file, is it just a case of going through it line
#by line
if ($username == 'hello'
and $password == 'world') {
fwrite(STDOUT, "OK\n");
}
} else {
// failed miserably
fwrite(STDOUT, "ERR\n");
}
}