forked from poppyred/1.6.x
/
squid.conf.php
executable file
·229 lines (183 loc) · 7.05 KB
/
squid.conf.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
225
226
227
228
229
<?php
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");
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
$user=new usersMenus();
if($user->AsSquidAdministrator==false){
$tpl=new templates();
echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
die();exit();
}
if(isset($_GET["tabs"])){tabs();exit;}
if(isset($_GET["acls"])){acls();exit;}
if(isset($_GET["caches"])){caches();exit;}
if(isset($_GET["popup"])){popup();exit;}
if(isset($_GET["show-content-group-js"])){show_content_group_js();exit;}
if(isset($_GET["show-content-group"])){show_content_group();exit;}
if(isset($_POST["DenySquidWriteConf"])){DenySquidWriteConf();exit;}
if(isset($_POST["SQUID_CONTENT"])){SQUID_CONTENT();exit;}
js();
function js(){
$page=CurrentPageName();
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body("{APP_SQUID}::{configuration_file}");
header("content-type: application/x-javascript");
$html="YahooWin4('1200','$page?tabs=yes','$title');";
echo $html;
}
function show_content_group_js(){
$page=CurrentPageName();
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body("{configuration_file}");
header("content-type: application/x-javascript");
$groupid=$_GET["show-content-group-js"];
$q=new mysql_squid_builder();
$ligne2=mysql_fetch_array($q->QUERY_SQL("SELECT GroupName FROM webfilters_sqgroups WHERE ID='$groupid'"));
$title=$ligne2["GroupName"];
$html="YahooWin5('700','$page?show-content-group=$groupid','$title');";
echo $html;
}
function show_content_group(){
$page=CurrentPageName();
$tpl=new templates();
$sock=new sockets();
$t=time();
$groupid=$_GET["show-content-group"];
$data=base64_decode($sock->getFrameWork("squid.php?show-content-group=$groupid"));
echo " <textarea
style='width:99%;height:350px;overflow:auto;border:5px solid #CCCCCC;font-size:14px !important;
font-weight:bold;padding:3px;font-family:Courier New;'
id='SQUID_CONTENT-$t'>$data</textarea>";
}
function tabs(){
$page=CurrentPageName();
$tpl=new templates();
$array["popup"]='{configuration_file}';
$array["acls"]='{ACLS}';
$array["caches"]='{caches}';
while (list ($num, $ligne) = each ($array) ){
$html[]= $tpl->_ENGINE_parse_body("<li style='font-size:18px'><a href=\"$page?$num=yes\"><span>$ligne</span></a></li>\n");
}
echo build_artica_tabs($html, "squid_conf_tabs");
}
function acls(){
$page=CurrentPageName();
$sock=new sockets();
$datas=base64_decode($sock->getFrameWork("cmd.php?squid-conf-view=yes"));
$sock=new sockets();
$tpl=new templates();
$table=explode("\n",$datas);
while (list ($num, $ligne) = each ($table) ){
$ligne=trim($ligne);
if(preg_match("#^acl#", $ligne,$re)){
$ACLS[]=$ligne;
}
if(preg_match("#^(http|reply|url_rewrite_).*?access#", $ligne,$re)){
$HTTP[]=$ligne;
}
}
echo "<center style='margin:10px'>".$tpl->_ENGINE_parse_body(button("{reconfigure}","Loadjs('squid.compile.progress.php');",32))."</center>";
$q=new mysql_squid_builder();
while (list ($num, $ligne) = each ($ACLS) ){
if(preg_match("#container_([0-9]+)\.txt#", $ligne,$re)){
$groupid=$re[1];
$ligne2=mysql_fetch_array($q->QUERY_SQL("SELECT GroupName FROM webfilters_sqgroups WHERE ID='$groupid'"));
$groupname=$ligne2["GroupName"];
$href="<a href=\"javascript:blur();\"
OnClick=\"javascript:Loadjs('$page?show-content-group-js=$groupid',true)\" style='font-size:16px;font-family:Courier New;text-decoration:underline'>";
$hrefGP="<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.acls.groups.php?AddGroup-js=yes&ID=$groupid',true);\"
style='font-size:16px;font-family:Courier New;text-decoration:underline'>";
echo "<div>$href$ligne</a> - $hrefGP$groupname</a></div>";
}else{
echo "<div style='font-size:16px;font-family:Courier New;'>$ligne</div>";
}
}
echo "<hr>";
while (list ($num, $ligne) = each ($HTTP) ){
echo "<div style='font-size:14px;font-family:Courier New;'>$ligne</div>";
}
}
function caches(){
$page=CurrentPageName();
$sock=new sockets();
$datas=base64_decode($sock->getFrameWork("cmd.php?squid-conf-view=yes"));
$sock=new sockets();
$tpl=new templates();
echo "<center style='margin:10px;margin-bottom:30px'>".$tpl->_ENGINE_parse_body(button("{reconfigure}","Loadjs('squid.compile.progress.php');",32))."</center>";
$table=explode("\n",$datas);
while (list ($num, $ligne) = each ($table) ){
$ligne=trim($ligne);
if(preg_match("#^cache_dir#", $ligne,$re)){
echo "<div style='font-size:16px;font-weight:bold;margin:10px;font-family:Courier New;'>$ligne</div>";
}
}
}
function popup(){
$sock=new sockets();
$sock->getFrameWork("squid.php?squid-conf-copy=yes");
$datas=@file_get_contents("/usr/share/artica-postfix/ressources/logs/web/squid.conf");
$tpl=new templates();
$DenySquidWriteConf=$sock->GET_INFO("DenySquidWriteConf");
if(!is_numeric($DenySquidWriteConf)){$DenySquidWriteConf=0;}
$t=time();
$page=CurrentPageName();
$html="
<div id='$t'></div>
<div style='width:98%' class=form>
<table>
<tr>
<td class=legend style='font-size:16px;font-weight:bold'>". $tpl->_ENGINE_parse_body("{deny_artica_to_write_config}")."</td>
<td>". Field_checkbox("DenySquidWriteConf", 1,$DenySquidWriteConf,"DenySquidWriteConfSave()")."</td>
</tr>
</table>
<textarea
style='width:99%;height:650px;overflow:auto;border:5px solid #CCCCCC;font-size:14px !important;
font-weight:normal;font-family:Courier New;color:black !important;padding:3px'
id='SQUID_CONTENT-$t'>$datas</textarea>
<center><hr>". $tpl->_ENGINE_parse_body(button("{apply}", "SaveUserConfFile()",22))."</center>
</div>
<script>
var x_DenySquidWriteConfSave= function (obj) {
var results=obj.responseText;
if(results.length>3){alert(results);return;}
}
function DenySquidWriteConfSave(){
var XHR = new XHRConnection();
var DenySquidWriteConf=0;
if(document.getElementById('DenySquidWriteConf').checked){
DenySquidWriteConf=1;
}
XHR.appendData('DenySquidWriteConf', DenySquidWriteConf);
XHR.sendAndLoad('$page', 'POST',x_DenySquidWriteConfSave);
}
var x_SaveUserConfFile= function (obj) {
var results=obj.responseText;
document.getElementById('$t').innerHTML='';
if(results.length>3){alert(results);return;}
}
function SaveUserConfFile(){
var XHR = new XHRConnection();
XHR.appendData('SQUID_CONTENT', encodeURIComponent(document.getElementById('SQUID_CONTENT-$t').value));
AnimateDiv('$t');
XHR.sendAndLoad('$page', 'POST',x_SaveUserConfFile);
}
</script>
";
echo $html;
}
function DenySquidWriteConf(){
$sock=new sockets();
$sock->SET_INFO("DenySquidWriteConf", $_POST["DenySquidWriteConf"]);
}
function SQUID_CONTENT(){
$_POST["SQUID_CONTENT"]=url_decode_special_tool($_POST["SQUID_CONTENT"]);
$sock=new sockets();
@mkdir("/usr/share/artica-postfix/ressources/logs/web",0755,true);
@file_put_contents("ressources/logs/web/squid.conf", $_POST["SQUID_CONTENT"]);
$datas=base64_decode($sock->getFrameWork("squid.php?saveSquidContent=yes"));
echo $datas;
}
?>