]> git.ipfire.org Git - thirdparty/sarg.git/blob - sarg-php/sarg-squidguard-block.php
May fix some errors in sarg-php
[thirdparty/sarg.git] / sarg-php / sarg-squidguard-block.php
1 <?php
2
3 /*
4 * AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
5 * 1998, 2006
6 * SARG Squid Analysis Report Generator http://sarg-squid.org
7 *
8 * SARG donations:
9 * please look at http://sarg.sourceforge.net/donations.php
10 * ---------------------------------------------------------------------
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
25 *
26 */
27
28 require_once "config.php.inc";
29
30 global $SargConf;
31 global $dbhome;
32
33 putenv("LANG=$language");
34 if (!setlocale(LC_ALL, $language))
35 {
36 echo "<p>";
37 printf(gettext("Invalid locale: %s"),$language);
38 echo "</p>\n";
39 exit;
40 }
41 $domain = 'messages';
42 bindtextdomain($domain, "./locale");
43 textdomain($domain);
44 include_once("style.php");
45
46 if (!isset($_GET['url']))
47 {
48 echo "<p>",gettext("No URL to block"),"</p>\n";
49 exit;
50 }
51
52 $url = $_GET['url'];
53
54 function parse_config($line,$clave) {
55 if (preg_match("/dbhome/i", $line)) {
56 global $dbhome;
57 $l = explode(' ', $line);
58 list(, $dbhome) = $l;
59 $dbhome=preg_replace('/\s+/','',$dbhome);
60 }
61 }
62
63 echo "<center>\n";
64 echo "<table>\n";
65 echo "<tr><td class=\"title\">";
66 print(gettext ("Sarg-SquidGuard - URL Blocking"));
67 echo "</td></tr>\n";
68 echo "<tr><td class=\"header2\">";
69 printf(gettext("Choose the rule set where %s will be added"),"<a href=\"http://$url\">$url</a> ");
70 echo "</td></tr>\n";
71 echo "</table>\n";
72 echo "<table>\n";
73
74 $lines=file($squidGuardConf);
75 array_walk($lines,'parse_config');
76
77 if (is_dir($dbhome)) {
78 if ($ha1 = opendir($dbhome)) {
79 while (false !== ($file = readdir($ha1))) {
80 if ($file == '.' || $file == '..') continue;
81 echo "<tr><td class=\"header\">$file</td></tr>\n";
82 $dir2 = $dbhome.'/'.$file;
83 if (is_dir($dir2)) {
84 if ($ha2 = opendir($dir2)) {
85 while (false !== ($file2 = readdir($ha2))) {
86 if ($file2 == '.' || $file2 == '..') continue;
87 echo "<tr><td class=\"data2\"><a href=\"sarg-squidguard-block2.php?file=$dir2/$file2&url=$url&lang=$language\">$file2</a></td></tr>\n";
88 }
89 }
90 closedir($ha2);
91 }
92 }
93 closedir($ha1);
94 }
95 }
96
97 echo "</table>\n";
98 echo "</html>\n";
99 ?>