]> git.ipfire.org Git - thirdparty/sarg.git/blob - sarg-php/sarg-squidguard-block.php
c403a0d324a931cb2528f68040929e3d88461bf2
[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 // Change to squidGuard and sarg config file paths
29 $SargConf = "/usr/local/sarg/sarg.conf";
30 $squidGuardConf = "/usr/local/squidGuard/squidGuard.conf";
31
32 global $SargConf;
33 global $dbhome;
34 global $language;
35
36 include_once("language.php");
37 include_once("style.php");
38
39 $url = $_GET['url'];
40 $squidGuard_conf = '/usr/local/squidGuard/squidGuard.conf';
41
42 function parse_config($line,$clave) {
43 if (preg_match("/dbhome/i", $line)) {
44 global $dbhome;
45 $l = explode(' ', $line);
46 list(, $dbhome) = $l;
47 $dbhome=preg_replace('/\s+/','',$dbhome);
48 }
49 }
50
51 echo "<center>\n";
52 echo "<table>\n";
53 echo "<tr><td class=\"title\">";
54 print(gettext ("Sarg-SquidGuard - URL Blocking"));
55 echo "</td></tr>\n";
56 echo "<tr><td class=\"header2\">";
57 print(gettext ("Choose the rule set where"));
58 echo "<a href=\"http://$url\">&nbsp;$url</a> ";
59 print(gettext ("will by added"));
60 echo "</td></tr>\n";
61 echo "</table>\n";
62 echo "<table>\n";
63
64 $lines=file($squidGuardConf);
65 array_walk($lines,'parse_config');
66
67 if (is_dir($dbhome)) {
68 if ($ha1 = opendir($dbhome)) {
69 while (false !== ($file = readdir($ha1))) {
70 if ($file == '.' || $file == '..') continue;
71 echo "<tr><td class=\"header\">$file</td></tr>\n";
72 $dir2 = $dbhome.'/'.$file;
73 if (is_dir($dir2)) {
74 if ($ha2 = opendir($dir2)) {
75 while (false !== ($file2 = readdir($ha2))) {
76 if ($file2 == '.' || $file2 == '..') continue;
77 echo "<tr><td class=\"data2\"><a href=\"sarg-squidguard-block2.php?file=$dir2/$file2&url=$url&lang=$language\">$file2</a></td></tr>\n";
78 }
79 }
80 closedir($ha2);
81 }
82 }
83 closedir($ha1);
84 }
85 }
86
87 echo "</table>\n";
88 echo "</html>\n";
89 ?>