forked from poppyred/1.6.x
/
Kav4Proxy.License.php
executable file
·201 lines (156 loc) · 6.25 KB
/
Kav4Proxy.License.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
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.kav4proxy.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["Kav4proxy-license-popup"])){echo kav4proxy_license_popup();exit;}
if(isset($_GET["Kav4proxy-license-delete"])){echo kav4proxy_license_delete();exit;}
if(isset($_GET["kav4proxy-license-iframe"])){echo kav4proxy_license_iframe();exit;}
if(isset($_GET["Kav4ProxyLicenseInfos"])){license_info();exit;}
if( isset($_POST['InstallLicenseFile']) ){kav4proxy_license_upload();exit();}
kav4proxy_license_js();
function kav4proxy_license_delete(){
$sock=new sockets();
$datas=base64_decode($sock->getFrameWork('kav4proxy.php?license-infosDelete&type='.$_GET["license-type"]));
}
function kav4proxy_license_js(){
$page=CurrentPageName();
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body('{APP_KAV4PROXY}::{license_info}');
if($_GET["license-type"]=="milter"){$title=$tpl->_ENGINE_parse_body('{APP_KAVMILTER}::{license_info}','squid.index.php');}
if($_GET["license-type"]=="kas"){$title=$tpl->_ENGINE_parse_body('{APP_KAS3}::{license_info}','squid.index.php');}
$html="
function Kav4ProxyLicenseStart(){
YahooWin5('700','$page?Kav4proxy-license-popup=yes&license-type={$_GET["license-type"]}','$title');
}
var x_Kav4ProxyDeleteKey= function (obj) {
Kav4ProxyLicenseStart();
}
function Kav4ProxyDeleteKey(){
var XHR = new XHRConnection();
document.getElementById('kav4licenseDiv').innerHTML='<center><img src=\"img/wait_verybig.gif\"></center>';
XHR.appendData('Kav4proxy-license-delete','yes');
XHR.appendData('license-type','{$_GET["license-type"]}');
XHR.sendAndLoad('$page', 'GET',x_Kav4ProxyDeleteKey);
}
Kav4ProxyLicenseStart();
";
echo $html;
}
function kav4proxy_license_popup(){
$page=CurrentPageName();
$sock=new sockets();
$datas=base64_decode($sock->getFrameWork('kav4proxy.php?license-infos&type='.$_GET["license-type"]));
$html="
<table style='width:99%' class=form>
<tr>
<td width=1%>".imgtootltip("delete-32.png","{delete}","Kav4ProxyDeleteKey()")."</td>
<td align='center' width=100%><a href=\"javascript:blur();\"
OnClick=\"javascript:s_PopUp('http://proxy-appliance.org/index.php/about/kaspersky-trial/',1024,900,true);\"
style=\"font-size:16px;font-weight:bold;text-decoration:underline\">
{get_free_license_trial}</a>
<td width=1%>".imgtootltip("refresh-32.png","{refresh}","LicenseInfos()")."</td>
</tr>
</table>
<div style='width:100%;height:440px' id='kav4licenseDiv'>
<div id='kav4LicenseUploaded'></div>
<div id='Kav4ProxyLicenseInfos'></div>
</div>
<center>
".button("{upload_new_license}","Loadjs('Kav4Proxy.license.upload.php')",32)."</td>
</center>
<script>
function LicenseInfos(){
LoadAjax('Kav4ProxyLicenseInfos','$page?Kav4ProxyLicenseInfos=yes&license-type={$_GET["license-type"]}');
}
var x_AddKey=function(obj){
var tempvalue=obj.responseText;
document.getElementById('kav4LicenseUploaded').innerHTML=tempvalue;
LicenseInfos();
}
function AddKey(){
var XHR = new XHRConnection();
XHR.appendData('InstallLicenseFile',document.getElementById('license-path').value);
XHR.appendData('license-type','{$_GET["license-type"]}');
AnimateDiv('kav4LicenseUploaded');
XHR.sendAndLoad('$page', 'POST',x_AddKey);
}
LicenseInfos();
</script>
";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function license_info(){
$sock=new sockets();
$datas=base64_decode($sock->getFrameWork('kav4proxy.php?license-infos&type='.$_GET["license-type"]));
$tp=explode("\n",$datas);
$html="<center style='width:97%' class=form><table style='width:100%' >
<tbody>";
while (list ($num, $val) = each ($tp)){
if(trim($val)==null){continue;}
$val=htmlspecialchars($val);
if(strlen($val)>89){$val=texttooltip(substr($val,0,86).'...',$val,null,null,1);}
if(preg_match("#Error checking#", $val)){$val="<strong style='color:red'>$val</strong>";}
if(preg_match("#Expiration date#", $val)){$val="<strong style='color:blue'>$val</strong>";}
if(preg_match("#Count:#", $val)){$val="<strong style='color:blue'>$val</strong>";}
if(preg_match("#Lifespan:#", $val)){$val="<strong style='color:blue'>$val</strong>";}
if(preg_match("#Objs:#", $val)){$val="<strong style='color:blue'>$val</strong>";}
$html=$html . "
<tr>
<td style='font-size:12px'>
<code>$val</code>
</td>
</tr>";
}
$html=$html . "</tbody>
</table></center>";
echo $html;
}
function kav4proxy_license_iframe($error=null){
$page=CurrentPageName();
$html="
<span style='color:red;font-weight:bold;font-size:12px;padding-left:5px'>$error</span>
<input type=\"hidden\" name=\"upload\" value=\"1\">
<form method=\"post\" enctype=\"multipart/form-data\" action=\"$page\">
<table style='width:99%' class=form align='center'>
<tr>
<td class=legend valign='middle'>{upload_new_license}:</td>
<td>
<input type=\"file\" name=\"fichier\" size=\"30\">
<input type=\"hidden\" name=\"license-type\" value='{$_GET["license-type"]}'>
</td>
</tr>
<tr>
<td colspan=2 align='right'><hr>
<input type='submit' name='upload' value='{upload file} »' style='width:220px'>
</td>
</tr>
</table>
</form>
";
$tpl=new templates();
$html=$tpl->_ENGINE_parse_body($html);
echo iframe($html,0);
}
function kav4proxy_license_upload(){
$socket=new sockets();
writelogs("Kav4ProxyUploadLicense:{$_POST["InstallLicenseFile"]}",__FUNCTION__,__FILE__);
$res=base64_decode($socket->getFrameWork("cmd.php?Kav4ProxyUploadLicense={$_POST["InstallLicenseFile"]}&type={$_POST["license-type"]}"));
$tp=explode("\n",$res);
$tp[]="ltp:{$_POST["license-type"]}";
while (list ($num, $val) = each ($tp)){
if(trim($val)==null){continue;}
$val=htmlspecialchars($val);
$color="black";
if(preg_match("#Error#i", $val)){$color="red;font-weight:bold";}
if(preg_match("#successfully#i", $val)){$color="#55BE5D;font-weight:bold";}
$html=$html . "<div style='text-align:left'><code style='color:$color'>$val</code></div>";
}
echo "<center><div style='width:98%' class=form>$html</div></center>";
}