forked from poppyred/1.6.x
/
freeweb.edit.autentification.php
executable file
·207 lines (170 loc) · 7.8 KB
/
freeweb.edit.autentification.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
<?php
session_start();
if($_SESSION["uid"]==null){echo "window.location.href ='logoff.php';";die();}
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.pure-ftpd.inc');
include_once('ressources/class.apache.inc');
include_once('ressources/class.freeweb.inc');
include_once('ressources/class.user.inc');
include_once('ressources/class.system.network.inc');
$user=new usersMenus();
if($user->AsWebMaster==false){
$tpl=new templates();
echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
die();exit();
}
if(isset($_POST["enable_ldap_authentication"])){SaveConfig();exit;}
params();
function params(){
$sql="SELECT * FROM freeweb WHERE servername='{$_GET["servername"]}'";
$page=CurrentPageName();
$tpl=new templates();
$q=new mysql();
$sock=new sockets();
$FreeWebsEnableModSecurity=$sock->GET_INFO("FreeWebsEnableModSecurity");
$FreeWebsEnableModEvasive=$sock->GET_INFO("FreeWebsEnableModEvasive");
$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_backup'));
$free=new freeweb($_GET["servername"]);
$Params=$free->Params;
$apache_auth_ip_explain=$tpl->javascript_parse_text("{apache_auth_ip_explain}");
$users=new usersMenus();
$APACHE_MOD_AUTHNZ_LDAP=0;
$APACHE_MOD_GEOIP=0;
$PERL_AUTHNTLM=0;
$info=null;
if($users->APACHE_MOD_AUTHNZ_LDAP){$APACHE_MOD_AUTHNZ_LDAP=1;}
if($users->APACHE_MOD_GEOIP){$APACHE_MOD_GEOIP=1;}
if($users->APP_PYAUTHENNTLM){$PERL_AUTHNTLM=1;}
$ServerSignature=$sock->GET_INFO("ApacheServerSignature");
if(!is_numeric($ServerSignature)){$ServerSignature=1;}
if(!is_numeric($FreeWebsEnableModSecurity)){$FreeWebsEnableModSecurity=0;}
if(!is_numeric($FreeWebsEnableModEvasive)){$FreeWebsEnableModEvasive=0;}
$ZarafaWebNTLM=0;
$ZarafaWebNTLM=$sock->GET_INFO("ZarafaWebNTLM");
if(!is_numeric($ZarafaWebNTLM)){$ZarafaWebNTLM=0;}
if($ligne["groupware"]=="ZARAFA"){
$PARAMS=$free->Params["ZARAFAWEB_PARAMS"];
if(!isset($PARAMS["ZarafaWebNTLM"])){$PARAMS["ZarafaWebNTLM"]=$ZarafaWebNTLM;}
if(!is_numeric($PARAMS["ZarafaWebNTLM"])){$PARAMS["ZarafaWebNTLM"]=$ZarafaWebNTLM;}
$ZarafaWebNTLM=$PARAMS["ZarafaWebNTLM"];
}
$authentication_banner=$Params["LDAP"]["authentication_banner"];
$EnableLDAPAllSubDirectories=$Params["LDAP"]["EnableLDAPAllSubDirectories"];
if(strlen($authentication_banner)<3){
$authentication_banner=base64_encode($tpl->javascript_parse_text("{$_GET["servername"]}::{authentication}"));
}
$ApacheServerSignature=$Params["SECURITY"]["ServerSignature"];
$DisableHtAccess=$Params["SECURITY"]["DisableHtAccess"];
if(!is_numeric($ApacheServerSignature)){$ApacheServerSignature=$ServerSignature;}
if(!is_numeric($EnableLDAPAllSubDirectories)){$EnableLDAPAllSubDirectories=0;}
$t=time();
$FreeWebPerformances=unserialize(base64_decode($sock->GET_INFO("FreeWebPerformances")));
if(!isset($FreeWebPerformances["KeepAlive"])){$FreeWebPerformances["KeepAlive"]=0;}
if($FreeWebPerformances["KeepAlive"]==0){
$info=$info.FATAL_WARNING_SHOW_128("{KeepAlive_tlm_notset}");
}
if($PERL_AUTHNTLM==0){
$info=$info.FATAL_WARNING_SHOW_128("{pythonntlm_not_installed}");
}
//http://www.mail-appliance.org/index.php?cID=393
$onlineHelp="<a href=\"javascript:blur();\" OnClick=\"javascript:s_PopUpFull('http://mail-appliance.org/index.php?cID=393','1024','900');\"
style='font-size:12px;font-weight:bold;text-decoration:underline'>{online_help}</a>";
$html="
<div id='$t'>
<input type='hidden' id='EnableLDAPAllSubDirectories' value='$EnableLDAPAllSubDirectories'>
<table style='width:99%' class=form>
<tr>
<td class=legend style='font-size:14px'>{enable_ldap_authentication}:</td>
<td>". Field_checkbox("enable_ldap_authentication",1,$Params["LDAP"]["enabled"],"CheckApacheLdap$t()")."</td>
<td width=1%><span id='disabled-why' style='font-size:11px;color:red'></span>
</tr>
<tr>
<td class=legend style='font-size:14px'>{authentication_banner}:</td>
<td>". Field_text("authentication_banner",base64_decode($authentication_banner),"font-size:16px;padding:3px;width:280px")."</td>
<td> </td>
</tr>
<tr>
<td class=legend style='font-size:14px'>{members}:</td>
<td><input type='button' OnClick=\"javascript:Loadjs('freeweb.edit.ldap.users.php?servername={$_GET["servername"]}')\" value='{browse}...' style='font-size:13px'></td>
<td> </td>
</tr>
<tr>
<td class=legend style='font-size:14px'>{enable_ntlm_authentication}:</td>
<td>". Field_checkbox("enable_ntlm_authentication",1,$Params["NTLM"]["enabled"],"CheckApacheNTLM$t()")."</td>
<td width=1% nowrap>$onlineHelp</span>
</tr>
<tr>
<td class=legend style='font-size:14px'>{members}:</td>
<td><input type='button' OnClick=\"javascript:Loadjs('freeweb.edit.ldap.users.php?servername={$_GET["servername"]}')\" value='{browse}...' style='font-size:13px'></td>
<td> </td>
</tr>
</table>
<div style='text-align:right;width:100%'><hr>". button("{apply}","CheckApacheLdap$t()",16)."</div>
</div>
$info
<script>
var x_CheckApacheLdap$t=function (obj) {
var results=obj.responseText;
if(results.length>0){alert(results);}
RefreshTab('main_config_freewebeditsecu');
}
function CheckApacheForm$t(){
var ZarafaWebNTLM=$ZarafaWebNTLM;
var APACHE_MOD_AUTHNZ_LDAP=$APACHE_MOD_AUTHNZ_LDAP;
var PERL_AUTHNTLM=$PERL_AUTHNTLM;
document.getElementById('enable_ldap_authentication').disabled=true;
document.getElementById('authentication_banner').disabled=true;
document.getElementById('EnableLDAPAllSubDirectories').disabled=true;
document.getElementById('enable_ntlm_authentication').disabled=true;
if(APACHE_MOD_AUTHNZ_LDAP==1){
document.getElementById('enable_ldap_authentication').disabled=false;
document.getElementById('authentication_banner').disabled=false;
if(document.getElementById('enable_ldap_authentication').checked){
document.getElementById('EnableLDAPAllSubDirectories').disabled=false;
}
}
if(PERL_AUTHNTLM==1){
document.getElementById('enable_ntlm_authentication').disabled=false;
}
if(ZarafaWebNTLM==1){
document.getElementById('enable_ntlm_authentication').disabled=true;
document.getElementById('enable_ldap_authentication').disabled=true;
document.getElementById('enable_ldap_authentication').checked=true;
document.getElementById('disabled-why').innerHTML='NTLM enabled';
}
}
function CheckApacheLdap$t(){
var XHR = new XHRConnection();
if(document.getElementById('enable_ldap_authentication').checked){
XHR.appendData('enable_ldap_authentication',1);
document.getElementById('EnableLDAPAllSubDirectories').disabled=false;
}else{
XHR.appendData('enable_ldap_authentication',0);
document.getElementById('EnableLDAPAllSubDirectories').disabled=true;
}
if(document.getElementById('enable_ntlm_authentication').checked){
XHR.appendData('enable_ntlm_authentication',1);
}else{
XHR.appendData('enable_ntlm_authentication',0);
}
if(document.getElementById('EnableLDAPAllSubDirectories').checked){XHR.appendData('EnableLDAPAllSubDirectories',1);}else{XHR.appendData('EnableLDAPAllSubDirectories',0);}
XHR.appendData('servername','{$_GET["servername"]}');
AnimateDiv('$t');
XHR.sendAndLoad('$page', 'POST', x_CheckApacheLdap$t);
}
CheckApacheForm$t();
</script>";
echo $tpl->_ENGINE_parse_body($html);
}
function SaveConfig(){
$free=new freeweb($_POST["servername"]);
$page=CurrentPageName();
$tpl=new templates();
$free->Params["NTLM"]["enabled"]=$_POST["enable_ntlm_authentication"];
$free->Params["LDAP"]["enabled"]=$_POST["enable_ldap_authentication"];
$free->Params["LDAP"]["authentication_banner"]=base64_encode($_POST["authentication_banner"]);
$free->Params["LDAP"]["EnableLDAPAllSubDirectories"]=$_POST["EnableLDAPAllSubDirectories"];
$free->SaveParams();
}