$url = $_GET['url'];
function parse_config($line,$clave) {
- if (preg_match("/dbhome/i", $line)) {
- global $dbhome;
- $l = explode(' ', $line);
- list(, $dbhome) = $l;
- $dbhome=preg_replace('/\s+/','',$dbhome);
- }
+ if (preg_match("/dbhome/i", $line)) {
+ global $dbhome;
+ $l = explode(' ', $line);
+ list(, $dbhome) = $l;
+ $dbhome=preg_replace('/\s+/','',$dbhome);
+ }
}
-echo "<center>\n";
-echo "<table>\n";
-echo "<tr><td class=\"title\">";
-print(gettext ("Sarg-SquidGuard - URL Blocking"));
-echo "</td></tr>\n";
-echo "<tr><td class=\"header2\">";
-printf(gettext("Choose the rule set where %s will be added"),"<a href=\"http://$url\">$url</a> ");
-echo "</td></tr>\n";
-echo "</table>\n";
-echo "<table>\n";
-
$lines=file($squidGuardConf);
array_walk($lines,'parse_config');
-if (is_dir($dbhome)) {
- if ($ha1 = opendir($dbhome)) {
- while (false !== ($file = readdir($ha1))) {
- if ($file == '.' || $file == '..') continue;
- echo "<tr><td class=\"header\">$file</td></tr>\n";
- $dir2 = $dbhome.'/'.$file;
- if (is_dir($dir2)) {
- if ($ha2 = opendir($dir2)) {
- while (false !== ($file2 = readdir($ha2))) {
- if ($file2 == '.' || $file2 == '..') continue;
- echo "<tr><td class=\"data2\"><a href=\"sarg-squidguard-block2.php?file=$dir2/$file2&url=$url&lang=$language\">$file2</a></td></tr>\n";
- }
- }
- closedir($ha2);
- }
- }
- closedir($ha1);
- }
-}
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+<title><?php echo gettext("Sarg-SquidGuard - URL Blocking")?></title>
+</head>
+<body>
+<center>
+<table>
+<tr><td class="title"><?php echo gettext("Sarg-SquidGuard - URL Blocking")?></td></tr>
+<tr><td class="header2">
+<?php printf(gettext("Choose the rule set where %s will be added"),"<a href=\"http://$url\">$url</a>")?></td></tr>
+</table>
+<?php
-echo "</table>\n";
-echo "</html>\n";
+if (!is_dir($dbhome))
+{
+ echo "<p>";
+ printf(gettext("The path <tt>%s</tt> (which is supposed to be the squidGuard DB home) is not a directory"),$dbhome);
+ echo "</p>\n";
+}
+else
+{
+ $ha1 = opendir($dbhome);
+ if ($ha1)
+ {
+ $table=false;
+ while (false !== ($file = readdir($ha1)))
+ {
+ if ($file == '.' || $file == '..') continue;
+ $dir2 = $dbhome.'/'.$file;
+ if (is_dir($dir2))
+ {
+ if ($ha2 = opendir($dir2))
+ {
+ $first=true;
+ while (false !== ($file2 = readdir($ha2)))
+ {
+ if ($file2 == '.' || $file2 == '..') continue;
+ if (!$table)
+ {
+ echo "<table>\n";
+ $table=true;
+ }
+ if ($first)
+ {
+ echo "<tr><td class=\"header\">$file</td></tr>\n";
+ $first=false;
+ }
+ echo "<tr><td class=\"data2\"><a href=\"sarg-squidguard-block2.php?file=",rawurlencode($file.'/'.$file2),"&url=$url\">$file2</a></td></tr>\n";
+ }
+ }
+ closedir($ha2);
+ }
+ }
+ closedir($ha1);
+ if ($table)
+ {
+ echo "</table>\n";
+ }
+ else
+ {
+ echo "<p>";
+ printf(gettext("No squidGuard rule found in <tt>%s</tt>"),$dbhome);
+ echo "</p>\n";
+ }
+ }
+ else
+ {
+ echo "<p>";
+ printf(gettext("Cannot read squidGuard DB home directory %s"),$dbhome);
+ echo "</p>\n";
+ }
+}
?>
+</html>
+</body>
}
$url = $_GET['url'];
$url = $url."\n";
-if (isset($_GET['lang']))
-{
- $language = $_GET['lang'];
-}
putenv("LANG=$language");
if (!setlocale(LC_ALL, $language))
bindtextdomain($domain, "./locale");
textdomain($domain);
+function parse_config($line,$clave) {
+ if (preg_match("/dbhome/i", $line)) {
+ global $dbhome;
+ $l = explode(' ', $line);
+ list(, $dbhome) = $l;
+ $dbhome=preg_replace('/\s+/','',$dbhome);
+ }
+}
+
+global $dbhome;
+$lines=file($squidGuardConf);
+array_walk($lines,'parse_config');
+$file=$dbhome.'/'.$file;
+
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+<title><?php echo gettext("Sarg-SquidGuard - URL Blocking")?></title>
+</head>
+<body>
+<?php
+
$ha = fopen($file, 'a');
-if ($ha == false) {
- printf(gettext("Could not open file: %s"),$file);
- exit;
+if ($ha == false)
+{
+ echo "<p>";
+ printf(gettext("Could not open file: %s"),$file);
+ echo "</p>\n";
+ exit;
}
-else {
- $written = fwrite($ha, $url);
- fclose($ha);
- if ($written != strlen($url)) {
- print (gettext ("Write error"));
- exit;
- }
- print (gettext ("Done!"));
- echo "<br><br>\n";
- printf(gettext("<a href=\"%s\">Return</a> to Sarg."),"javascript:history.go(-2)");
+
+$written = fwrite($ha, $url);
+fclose($ha);
+if ($written != strlen($url))
+{
+ echo "<p>";
+ echo gettext("Write error");
+ echo "</p>\n";
+ exit;
}
+
+echo "<p>",gettext("Done!"),"</p>\n<p>";
+printf(gettext("<a href=\"%s\">Return</a> to Sarg."),"javascript:history.go(-2)");
+echo "</p>\n";
+?>
+</body>