forked from dtouzeau/artica-1.5
/
webfilter.community.php
executable file
·224 lines (166 loc) · 5.94 KB
/
webfilter.community.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.artica.inc');
include_once('ressources/class.ini.inc');
include_once('ressources/class.squid.inc');
include_once('ressources/class.dansguardian.inc');
header("Pragma: no-cache");
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
$user=new usersMenus();
if(!$user->AsSquidAdministrator){
$tpl=new templates();
echo "alert('".$tpl->javascript_parse_text("{ERROR_NO_PRIVS}").");";
exit;
}
if(isset($_GET["popup"])){popup();exit;}
if(isset($_GET["status"])){status();exit;}
if(isset($_GET["categories"])){categories();exit;}
if(isset($_GET["cat-search"])){categories_search();exit;}
js();
function status(){
$q=new mysql();
$page=CurrentPageName();
$tpl=new templates();
$total=FormatNumber($q->COUNT_ROWS("dansguardian_community_categories","artica_backup"),0,'.',' ',3);
$sql="SELECT count(*) as tcount FROM `dansguardian_sitesinfos` WHERE `dbpath` = ''";
$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_backup'));
$pp=Paragraphe("64-categories.png",$ligne["tcount"]." {websites_not_categorized}",
"{websites_not_categorized_text}","javascript:Loadjs('squid.visited.php')",null,300,76);
$html="
<table style='width:100%'>
<tr>
<td valign='top'><img src='img/webfilter-community-128.png'></td>
<td valign='top' width=99%'>
<div class=explain>{APP_WEBFILTER_COMMUNITY_EXPLAIN}</div>
<div style='font-size:14px;font-weight:bold'>$total {websites} ({community})</div>
$pp
</td>
</tr>
</table>
";
echo $tpl->_ENGINE_parse_body($html);
}
function FormatNumber($number, $decimals = 0, $thousand_separator = ' ', $decimal_point = '.'){
$tmp1 = round((float) $number, $decimals);
while (($tmp2 = preg_replace('/(\d+)(\d\d\d)/', '\1 \2', $tmp1)) != $tmp1)
$tmp1 = $tmp2;
return strtr($tmp1, array(' ' => $thousand_separator, '.' => $decimal_point));
}
function categories(){
$page=CurrentPageName();
$tpl=new templates();
$array_cats=categories_list();
$html="
<table style='width:100%'>
<td class=legend>{category}:</td>
<td>". Field_array_Hash($array_cats,"AR_CAT",null,"CatSearch()",null,0,"font-size:13px;padding:3px")."</td>
</tr>
<td class=legend>{search}:</td>
<td>". Field_text("AR_CAT_SE",null,"font-size:13px;padding:3px;width:220px",null,null,null,false,"CatSearchCheck(event)")."</td>
</tr>
</table>
<div style='margin:5px;padding:5px;height:350px;overflow:auto' id='AR_CAT_LIST'></div>
<script>
function CatSearch(){
var cat=escape(document.getElementById('AR_CAT').value);
var search=escape(document.getElementById('AR_CAT_SE').value);
LoadAjax('AR_CAT_LIST','$page?cat-search=yes&category='+cat+'&search='+search);
}
function CatSearchCheck(e){
if(checkEnter(e)){CatSearch();}
}
CatSearch();
</script>";
echo $tpl->_ENGINE_parse_body($html);
}
function categories_list(){
if(count($_SESSION["ARC-CAT-LIST"])>1){return $_SESSION["ARC-CAT-LIST"];}
$sql="SELECT category,COUNT(pattern) as tcount FROM dansguardian_community_categories GROUP BY category";
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo("$q->mysql_error");}
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
$array[$ligne["category"]]="{$ligne["category"]} ({$ligne["tcount"]} {items})";
}
$array[null]="{select}";
$_SESSION["ARC-CAT-LIST"]=$array;
return $_SESSION["ARC-CAT-LIST"];
}
function categories_search(){
$q=new mysql();
$page=CurrentPageName();
$tpl=new templates();
$pattern=$_GET["search"];
$category=$_GET["category"];
if($pattern<>null){
$pattern=str_replace("*","%",$pattern);
$pattern=" AND pattern LIKE '$pattern'";
}
if($category<>null){
$category=" AND category='$category'";
}
$sql="SELECT category,zDate,pattern FROM dansguardian_community_categories WHERE 1 $pattern $category ORDER BY zDate DESC LIMIT 0,150";
$results=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo("$q->mysql_error");}
$html="
<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>
<thead class='thead'>
<tr>
<th > </th>
<th colspan=2>{website}</th>
</tr>
</thead>
<tbody class='tbody'>";
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";}
$html=$html."
<tr class=$classtr>
<td width=1%><img src='img/fw_bold.gif'></td>
<td width=100%><strong style='font-size:14px'>{$ligne["pattern"]}</strong></td>
<td width=1% nowrap style='font-size:14px'><div style='font-size:11px'><i>{date}:{$ligne["zDate"]}<br>{category}:{$ligne["category"]}</i></strong></td>
</tr>
";
}
$html=$html."</tbody></table>";
echo $tpl->_ENGINE_parse_body($html);
}
function js(){
$page=CurrentPageName();
if(isset($_GET["in-front-ajax"])){
echo "document.getElementById('BodyContent').innerHTML='<center><img src=img/wait_verybig.gif></center>';
$('#BodyContent').load('$page?popup=yes');";
return;
}
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body("{community}");
echo "YahooWin2(650,'$page?popup=yes','$title');";
}
function popup(){
$tpl=new templates();
$page=CurrentPageName();
$array["status"]="{status}";
$array["categories"]="{categories}";
while (list ($num, $ligne) = each ($array) ){
$html[]=$tpl->_ENGINE_parse_body("<li><a href=\"$page?$num=yes\"><span>$ligne</span></a></li>\n");
}
echo "
<div id='articacat_tabs' style='width:100%;height:550px;overflow:auto'>
<ul>". implode("\n",$html)."</ul>
</div>
<script>
$(document).ready(function(){
$('#articacat_tabs').tabs({
load: function(event, ui) {
$('a', ui.panel).click(function() {
$(ui.panel).load(this.href);
return false;
});
}
});
});
</script>";
}