"Fossies" - the Fresh Open Source Software Archive 
Member "sarg-2.4.0/sarg-php/sarg-squidguard-block2.php" (22 Dec 2019, 2822 Bytes) of package /linux/privat/sarg-2.4.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "sarg-squidguard-block2.php" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
2.3.11_vs_2.4.0.
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 require_once "url_validator.php.inc";
30
31 if (!isset($_GET['file']))
32 {
33 echo "<p>",gettext("No file passed as argument"),"</p>\n";
34 exit;
35 }
36 $file = $_GET['file'];
37 if (!isset($_GET['url']))
38 {
39 echo "<p>",gettext("No url passed as argument"),"</p>\n";
40 exit;
41 }
42 $url = $_GET['url'];
43 if (!check_url($url))
44 {
45 echo "<p>",gettext("Invalid URL to block"),"</p>\n";
46 exit;
47 }
48 $url = $url."\n";
49
50 putenv("LANG=$language");
51 if (!setlocale(LC_ALL, $language))
52 {
53 echo "<p>";
54 printf(gettext("Invalid locale %s"),$language);
55 echo "</p>\n";
56 exit;
57 }
58 $domain = 'messages';
59 bindtextdomain($domain, "./locale");
60 textdomain($domain);
61
62 function parse_config($line,$clave) {
63 if (preg_match("/dbhome/i", $line)) {
64 global $dbhome;
65 $l = explode(' ', $line);
66 list(, $dbhome) = $l;
67 $dbhome=preg_replace('/\s+/','',$dbhome);
68 }
69 }
70
71 global $dbhome;
72 $lines=file($squidGuardConf);
73 array_walk($lines,'parse_config');
74 $file=$dbhome.'/'.$file;
75
76 ?>
77 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
78 <html xmlns="http://www.w3.org/1999/xhtml">
79 <head>
80 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
81 <title><?php echo gettext("Sarg-SquidGuard - URL Blocking")?></title>
82 </head>
83 <body>
84 <?php
85
86 $ha = fopen($file, 'a');
87 if ($ha == false)
88 {
89 echo "<p>";
90 printf(gettext("Could not open file: %s"),$file);
91 echo "</p>\n";
92 exit;
93 }
94
95 $written = fwrite($ha, $url);
96 fclose($ha);
97 if ($written != strlen($url))
98 {
99 echo "<p>";
100 echo gettext("Write error");
101 echo "</p>\n";
102 exit;
103 }
104
105 echo "<p>",gettext("Done!"),"</p>\n<p>";
106 printf(gettext("<a href=\"%s\">Return</a> to Sarg."),"javascript:history.go(-2)");
107 echo "</p>\n";
108 ?>
109 </body>