forked from poppyred/1.6.x
/
squid.nic.php
executable file
·128 lines (103 loc) · 3.37 KB
/
squid.nic.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
<?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');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.squid.inc');
include_once('ressources/class.system.network.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["popup"])){popup();exit;}
if(isset($_GET["perfs"])){perfs();exit;}
if(isset($_POST["SquidBinIpaddr"])){save();exit;}
js();
function js(){
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body("{listen_address}");
$page=CurrentPageName();
header("content-type: application/x-javascript");
$html="
YahooWin3('420','$page?popup=yes','$title');
";
echo $html;
}
function save(){
$sock=new sockets();
if($_POST["SquidBinIpaddr"]==null){$_POST["SquidBinIpaddr"]="0.0.0.0";}
$sock->SET_INFO("SquidBinIpaddr", $_POST["SquidBinIpaddr"]);
if(isset($_POST["tcp_outgoing_address"])){
$squid=new squidbee();
$squid->global_conf_array["tcp_outgoing_address"]=$_POST["tcp_outgoing_address"];
$squid->SaveToLdap(true);
}
}
function popup(){
$tpl=new templates();
$page=CurrentPageName();
$sock=new sockets();
$SquidBinIpaddr=$sock->GET_INFO("SquidBinIpaddr");
$MikrotikTransparent=intval($sock->GET_INFO('MikrotikTransparent'));
$ip=new networking();
$t=time();
$pfws=$ip->ALL_IPS_GET_ARRAY();
$pfws[null]="{none}";
if($MikrotikTransparent==0){
$squid=new squidbee();
$tcp_outgoing_address=$squid->global_conf_array["tcp_outgoing_address"];
$ips=$ip->ALL_IPS_GET_ARRAY();
$ips["0.0.0.0"]="{all}";
$ff1="<tr>
<td class=legend style='font-size:16px'>{forward_address}:</td>
<td style='font-size:16px'>". Field_array_Hash($pfws,"tcp_outgoing_address",$tcp_outgoing_address,"style:font-size:16px")."<td>
<td style='font-size:16px' width=1%><td>
</tr>";
}else{
$MikrotikVirtualIP=$sock->GET_INFO('MikrotikVirtualIP');
$ff1="
<tr>
<td class=legend style='font-size:16px'>{forward_address}:</td>
<td style='font-size:16px'><strong>MikroTik:$MikrotikVirtualIP</strong><td>
<td style='font-size:16px' width=1%><td>
</tr>";
}
$html="
<div id='$t'>
<table style='width:99%' class=form>
<tbody>
<tr>
<td class=legend style='font-size:16px'>{listen_address}:</td>
<td style='font-size:16px'>". Field_array_Hash($ips,"bindip-$t",$SquidBinIpaddr,"style:font-size:16px")."<td>
<td style='font-size:16px' width=1%><td>
</tr>
$ff1
<tr>
<td colspan=3 align='right'><hr>". button("{apply}","SaveSquidBinIpaddr()",16)."</td>
</tr>
</tbody>
</table>
</div>
<script>
var x_SaveSquidBinIpaddr=function (obj) {
var tempvalue=obj.responseText;
YahooWin3Hide();
Loadjs('squid.restart.php?onlySquid=yes&ask=yes');
}
function SaveSquidBinIpaddr(){
var XHR = new XHRConnection();
XHR.appendData('SquidBinIpaddr',document.getElementById('bindip-$t').value);
if(document.getElementById('tcp_outgoing_address')){
XHR.appendData('tcp_outgoing_address',document.getElementById('tcp_outgoing_address').value);
}
XHR.sendAndLoad('$page', 'POST',x_SaveSquidBinIpaddr);
}
</script>
";
echo $tpl->_ENGINE_parse_body($html);
}