1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
status_filter_reload.php
|
5
|
Copyright (C) 2006 Scott Ullrich
|
6
|
All rights reserved.
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
/*
|
30
|
pfSense_MODULE: filter
|
31
|
*/
|
32
|
|
33
|
##|+PRIV
|
34
|
##|*IDENT=page-status-filterreloadstatus
|
35
|
##|*NAME=Status: Filter Reload Status page
|
36
|
##|*DESCR=Allow access to the 'Status: Filter Reload Status' page.
|
37
|
##|*MATCH=status_filter_reload.php*
|
38
|
##|-PRIV
|
39
|
|
40
|
require_once("globals.inc");
|
41
|
require_once("guiconfig.inc");
|
42
|
require_once("functions.inc");
|
43
|
|
44
|
$pgtitle = array(gettext("Status"),gettext("Filter Reload Status"));
|
45
|
$shortcut_section = "firewall";
|
46
|
|
47
|
if(file_exists("{$g['varrun_path']}/filter_reload_status"))
|
48
|
$status = file_get_contents("{$g['varrun_path']}/filter_reload_status");
|
49
|
|
50
|
if($_GET['getstatus']) {
|
51
|
echo "|{$status}|";
|
52
|
exit;
|
53
|
}
|
54
|
if($_POST['reloadfilter']) {
|
55
|
send_event("filter reload");
|
56
|
header("Location: status_filter_reload.php");
|
57
|
exit;
|
58
|
}
|
59
|
if($_POST['syncfilter']) {
|
60
|
send_event("filter sync");
|
61
|
header("Location: status_filter_reload.php");
|
62
|
exit;
|
63
|
}
|
64
|
|
65
|
include("head.inc");
|
66
|
?>
|
67
|
|
68
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
69
|
|
70
|
<?php include("fbegin.inc"); ?>
|
71
|
<br />
|
72
|
<form action="status_filter_reload.php" method="post" name="filter">
|
73
|
<input type="submit" value="Reload Filter" name="reloadfilter" id="reloadfilter" />
|
74
|
<?php if ($config['hasync'] && $config['hasync']["synchronizetoip"] != ""): ?>
|
75
|
|
76
|
<input type="submit" value="Force Config Sync" name="syncfilter" id="syncfilter" />
|
77
|
<?php endif; ?>
|
78
|
</form>
|
79
|
<br /><br /><br />
|
80
|
<div id="status" style="padding:5px; border:1px dashed #990000; background-color: #ffffff; color: #000000;">
|
81
|
<?php echo $status; ?>
|
82
|
</div>
|
83
|
|
84
|
<div id="doneurl">
|
85
|
</div>
|
86
|
|
87
|
<br/>
|
88
|
|
89
|
<div id="reloadinfo"><?=gettext("This page will automatically refresh every 3 seconds until the filter is done reloading"); ?>.</div>
|
90
|
|
91
|
|
92
|
|
93
|
<script type="text/javascript">
|
94
|
//<![CDATA[
|
95
|
/* init update "thread */
|
96
|
function update_status_thread() {
|
97
|
getURL('status_filter_reload.php?getstatus=true', update_data);
|
98
|
}
|
99
|
function update_data(obj) {
|
100
|
var result_text = obj.content;
|
101
|
var result_text_split = result_text.split("|");
|
102
|
result_text = result_text_split[1];
|
103
|
result_text = result_text.replace("\n","");
|
104
|
result_text = result_text.replace("\r","");
|
105
|
if (result_text) {
|
106
|
jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> ' + result_text + '...');
|
107
|
} else {
|
108
|
jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> Obtaining filter status...');
|
109
|
}
|
110
|
if(result_text == "Initializing") {
|
111
|
jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> Initializing...');
|
112
|
} else if(result_text == "Done") {
|
113
|
jQuery('#status').effect('highlight');
|
114
|
jQuery('#status').html('Done. The filter rules have been reloaded.');
|
115
|
jQuery('#reloadinfo').css("visibility","hidden");
|
116
|
jQuery('#doneurl').css("visibility","visible");
|
117
|
jQuery('#doneurl').html("<p><a href='status_queues.php'>Queue Status<\/a><\/p>");
|
118
|
}
|
119
|
window.setTimeout('update_status_thread()', 2500);
|
120
|
}
|
121
|
//]]>
|
122
|
</script>
|
123
|
|
124
|
<script type="text/javascript">
|
125
|
//<![CDATA[
|
126
|
/*
|
127
|
* getURL is a proprietary Adobe function, but it's simplicity has made it very
|
128
|
* popular. If getURL is undefined we spin our own by wrapping XMLHttpRequest.
|
129
|
*/
|
130
|
if (typeof getURL == 'undefined') {
|
131
|
getURL = function(url, callback) {
|
132
|
if (!url)
|
133
|
throw 'No URL for getURL';
|
134
|
|
135
|
try {
|
136
|
if (typeof callback.operationComplete == 'function')
|
137
|
callback = callback.operationComplete;
|
138
|
} catch (e) {}
|
139
|
if (typeof callback != 'function')
|
140
|
throw 'No callback function for getURL';
|
141
|
|
142
|
var http_request = null;
|
143
|
if (typeof XMLHttpRequest != 'undefined') {
|
144
|
http_request = new XMLHttpRequest();
|
145
|
}
|
146
|
else if (typeof ActiveXObject != 'undefined') {
|
147
|
try {
|
148
|
http_request = new ActiveXObject('Msxml2.XMLHTTP');
|
149
|
} catch (e) {
|
150
|
try {
|
151
|
http_request = new ActiveXObject('Microsoft.XMLHTTP');
|
152
|
} catch (e) {}
|
153
|
}
|
154
|
}
|
155
|
if (!http_request)
|
156
|
throw 'Both getURL and XMLHttpRequest are undefined';
|
157
|
|
158
|
http_request.onreadystatechange = function() {
|
159
|
if (http_request.readyState == 4) {
|
160
|
callback( { success : true,
|
161
|
content : http_request.responseText,
|
162
|
contentType : http_request.getResponseHeader("Content-Type") } );
|
163
|
}
|
164
|
}
|
165
|
http_request.open('GET', url, true);
|
166
|
http_request.send(null);
|
167
|
}
|
168
|
}
|
169
|
window.setTimeout('update_status_thread()', 2500);
|
170
|
//]]>
|
171
|
</script>
|
172
|
|
173
|
<?php include("fend.inc"); ?>
|
174
|
|
175
|
</body>
|
176
|
</html>
|