sarg
2.4.0
About:
SARG
ia a Squid Analysis Report Generator.
Fossies
Dox
:
sarg-2.4.0.tar.gz
("unofficial" and yet experimental doxygen-generated source code documentation)
sarg-squidguard-block2.php
Go to the documentation of this file.
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>
gettext
#define gettext(Msgid)
Definition:
gettext.h:68
$ha
$ha
Definition:
sarg-block-it.php:38
$written
if($ha==false) $written
Definition:
sarg-squidguard-block2.php:95
parse_config
parse_config($line, $clave)
Definition:
sarg-squidguard-block2.php:62
bindtextdomain
#define bindtextdomain(Domainname, Dirname)
Definition:
gettext.h:88
$dbhome
global $dbhome
Definition:
sarg-squidguard-block2.php:71
textdomain
#define textdomain(Domainname)
Definition:
gettext.h:86
$lines
$lines
Definition:
sarg-squidguard-block2.php:72
$squidGuardConf
$squidGuardConf
Definition:
config.php.inc:5
$domain
if(!setlocale(LC_ALL, $language)) $domain
Definition:
sarg-squidguard-block2.php:58
$url
if(!isset($_GET['url'])) $url
Definition:
sarg-squidguard-block2.php:42
html
char html[20000]
Definition:
conf.h:317
$language
$language
Definition:
config.php.inc:11
check_url
check_url($url)
Definition:
url_validator.php.inc:3
$file
if(!isset($_GET['file'])) $file
Definition:
sarg-squidguard-block2.php:36
sarg-php
sarg-squidguard-block2.php
Generated by
1.8.18