forked from poppyred/1.6.x
/
streamget-params.php
executable file
·132 lines (107 loc) · 4.42 KB
/
streamget-params.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
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
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");
$user=new usersMenus();
if(!$user->AsSquidAdministrator){
$tpl=new templates();
echo "alert('".$tpl->javascript_parse_text("{ERROR_NO_PRIVS}").");";
exit;
}
if(isset($_POST["SquidGuardApachePort"])){save();exit;}
if(isset($_GET["popup"])){popup();exit;}
js();
function js(){
$tpl=new templates();
$page=CurrentPageName();
$title=$tpl->_ENGINE_parse_body("{streamGetService}");
$html="
YahooWin5('530','$page?popup=yes','$title');
";
echo $html;
}
function popup(){
$page=CurrentPageName();
$sock=new sockets();
$SquidGuardApachePort=$sock->GET_INFO("SquidGuardApachePort");
if(!is_numeric($SquidGuardApachePort)){$SquidGuardApachePort=9020;}
$SquidGuardServerName=$sock->GET_INFO("SquidGuardServerName");
$SquidGuardStorageDir=$sock->GET_INFO("SquidGuardStorageDir");
$SquidGuardMaxStorageDay=$sock->GET_INFO("SquidGuardMaxStorageDay");
$StreamCacheYoutubeEnable=$sock->GET_INFO("StreamCacheYoutubeEnable");
$t=time();
if($SquidGuardStorageDir==null){$SquidGuardStorageDir="/home/artica/cache";}
if(!is_numeric($SquidGuardMaxStorageDay)){$SquidGuardMaxStorageDay=30;}
if($SquidGuardServerName==null){$SquidGuardServerName=$_SERVER['SERVER_ADDR'];}
$html="
<div id='$t'>
<table style='width:99%' class=form>
<tr>
<td class=legend style='font-size:14px'>{enable_youtube_caching}:</td>
<td>". Field_checkbox("StreamCacheYoutubeEnable",1,$StreamCacheYoutubeEnable,"StreamCacheYoutubeEnableCheck()")."</td>
</tr>
<tr>
<td class=legend style='font-size:14px'>{listen_port}:</td>
<td>". Field_text("SquidGuardApachePort",$SquidGuardApachePort,"font-size:14px;padding:3px;width:60px",null,null,null,false,"")."</td>
</tr>
<tr>
<td class=legend style='font-size:14px'>{servername}:</td>
<td style='font-size:14px'>". Field_text("SquidGuardServerName",$SquidGuardServerName,"font-size:14px;padding:3px;width:180px",null,null,null,false,"")."</td>
</tr>
<tr>
<td class=legend style='font-size:14px'>{storage_directory}:</td>
<td style='font-size:14px'>". Field_text("SquidGuardStorageDir","$SquidGuardStorageDir","font-size:14px;padding:3px;width:290px",null,null,null,false,"")."</td>
</tr>
<tr>
<td class=legend style='font-size:14px'>{MaxStorageDay}:</td>
<td style='font-size:14px'>". Field_text("SquidGuardMaxStorageDay",$SquidGuardMaxStorageDay,"font-size:14px;padding:3px;width:60px",null,null,null,false,"")." {days}</td>
</tr>
<tr>
<td colspan=2 align='right'><hr>". button("{apply}","SaveStreamGet()")."</td>
</tr>
</table>
</div>
<script>
var x_SaveStreamGet=function(obj){
YahooWin5Hide();
Loadjs('$page');
}
function StreamCacheYoutubeEnableCheck(){
document.getElementById('SquidGuardApachePort').disabled=true;
document.getElementById('SquidGuardServerName').disabled=true;
document.getElementById('SquidGuardStorageDir').disabled=true;
document.getElementById('SquidGuardMaxStorageDay').disabled=true;
if(document.getElementById('StreamCacheYoutubeEnable').checked){
document.getElementById('SquidGuardApachePort').disabled=false;
document.getElementById('SquidGuardServerName').disabled=false;
document.getElementById('SquidGuardStorageDir').disabled=false;
document.getElementById('SquidGuardMaxStorageDay').disabled=false;
}
}
function SaveStreamGet(){
var XHR = new XHRConnection();
XHR.appendData('SquidGuardApachePort',document.getElementById('SquidGuardApachePort').value);
XHR.appendData('SquidGuardServerName',document.getElementById('SquidGuardServerName').value);
XHR.appendData('SquidGuardStorageDir',document.getElementById('SquidGuardStorageDir').value);
XHR.appendData('SquidGuardMaxStorageDay',document.getElementById('SquidGuardMaxStorageDay').value);
AnimateDiv('$t');
XHR.sendAndLoad('$page', 'POST',x_SaveStreamGet);
}
StreamCacheYoutubeEnableCheck();
";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function save(){
$sock=new sockets();
while (list ($num, $ligne) = each ($_POST) ){
$sock->SET_INFO($num, $ligne);
}
$sock->getFrameWork("cmd.php?reload-squidguardWEB=yes");
$sock->getFrameWork("squid.php?squid-reconfigure=yes");
}
?>