forked from poppyred/1.6.x
/
system.network.stunnel4.php
executable file
·139 lines (95 loc) · 3.12 KB
/
system.network.stunnel4.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
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.stunnel4.inc');
include_once('ressources/class.main_cf.inc');
if(!checkprivs_stunnel()){
echo FATAL_ERROR_SHOW_128("{ERROR_NO_PRIVS}");
die();
}
if(isset($_GET["status"])){status();exit;}
if(isset($_GET["stunnel-status"])){stunnel4_status();exit;}
tabs();
function tabs(){
$page=CurrentPageName();
$users=new usersMenus();
if(!$users->stunnel4_installed){
echo FATAL_ERROR_SHOW_128("{stunnel_not_installed}");
die();
}
$tpl=new templates();
$sock=new sockets();
$page=CurrentPageName();
$height="850px";
$array["status"]='{status}';
$array["rules"]='{rules}';
$style="style='font-size:20px'";
if(isset($_GET["font-size"])){
$style="style='font-size:22px'";
}
while (list ($num, $ligne) = each ($array) ){
if($num=="rules"){
$html[]= $tpl->_ENGINE_parse_body("<li $style>
<a href=\system.network.stunnel4.rules.php\">
<span>$ligne</span></a></li>\n");
continue;
}
if($num=="authentication"){
$html[]= "<li $style><a href=\"postfix.index.php?popup-auth=yes&hostname=$hostname\"><span>$ligne</span></a></li>\n";
continue;
}
$html[]= "<li $style><a href=\"$page?$num=yes\"><span>$ligne</span></a></li>\n";
}
echo build_artica_tabs($html, "main_tabs_stunnel4",1200)."<script>LeftDesign('ssl-256-white.png');</script>";
}
// smtps_relayhost_text
function status(){
$sock=new sockets();
$page=CurrentPageName();
$tpl=new templates();
$t=time();
$sTunnel4enabled=$sock->GET_INFO('sTunnel4enabled');
$enable=Paragraphe_switch_img('{enable_stunnel4}',"{enable_stunnel_gtext}",'sTunnel4enabled',$sTunnel4enabled,null,880);
$html="
<div style='width:98%' class=form>
<table style='width:100%' align=center>
<tr>
<td valign='top' style='width:260px'><div id='stunnel4-status'></div></td>
<td style='width:99%'>$enable
<hr><div style='margin-top:20px;text-align:right'>". button('{apply}',"Save$t()",32)."</div>
</td>
</tr>
</table>
</div>
<script>
function xSave$t(obj) {
var tempvalue=obj.responseText;
if(tempvalue.length>3){alert(tempvalue);}
LoadAjax('stunnel4-status','$page?stunnel-status=yes&hostname={$_GET["hostname"]}');
}
function Save$t(){
XHR.appendData('sTunnel4enabled',document.getElementById('sTunnel4enabled').value);
XHR.sendAndLoad('$page', 'POST',xSave$t);
}
LoadAjax('stunnel4-status','$page?stunnel-status=yes&hostname={$_GET["hostname"]}');
</script>";
echo $tpl->_ENGINE_parse_body($html);
}
function stunnel4_status(){
$users=new usersMenus();
$tpl=new templates();
$ini=new Bs_IniHandler();
$sock=new sockets();
$datas=base64_decode($sock->getFrameWork("cmd.php?stunnel-ini-status=yes"));
$ini->loadString($datas);
$status=DAEMON_STATUS_ROUND("STUNNEL",$ini);
echo $tpl->_ENGINE_parse_body($status);
}
function checkprivs_stunnel(){
$users=new usersMenus();
if($users->AsSquidAdministrator){return true;}
if($users->AsPostfixAdministrator){return true;}
if($users->AsWebMaster){return true;}
return false;
}