Projet

Général

Profil

Télécharger (5,55 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / status_filter_reload.php @ 6b71ebb7

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
&nbsp;&nbsp;&nbsp;&nbsp;
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

    
88
<div id="reloadinfo"><?=gettext("This page will automatically refresh every 3 seconds until the filter is done reloading"); ?>.</div>
89

    
90

    
91

    
92
<script type="text/javascript">
93
//<![CDATA[
94
/* init update "thread */
95
function update_status_thread() {
96
	getURL('status_filter_reload.php?getstatus=true', update_data);
97
}
98
function update_data(obj) {
99
	var result_text = obj.content;
100
	var result_text_split = result_text.split("|");
101
	result_text = result_text_split[1];
102
	result_text = result_text.replace("\n","");
103
	result_text = result_text.replace("\r","");
104
	if (result_text) {
105
		jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="" /> ' + result_text + '...');
106
	} else {
107
		jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="" /> Obtaining filter status...');
108
	}
109
	if(result_text == "Initializing") {
110
		jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="" /> Initializing...');
111
	} else if(result_text == "Done") {
112
		jQuery('#status').effect('highlight');
113
		jQuery('#status').html('Done.  The filter rules have been reloaded.');
114
		jQuery('#reloadinfo').css("visibility","hidden");
115
		jQuery('#doneurl').css("visibility","visible");
116
		jQuery('#doneurl').html("<p/><a href='status_queues.php'>Queue Status</a>");
117
	}
118
	window.setTimeout('update_status_thread()', 2500);
119
}
120
//]]>
121
</script>
122

    
123
<script type="text/javascript">
124
/*
125
 * getURL is a proprietary Adobe function, but it's simplicity has made it very
126
 * popular. If getURL is undefined we spin our own by wrapping XMLHttpRequest.
127
 */
128
if (typeof getURL == 'undefined') {
129
  getURL = function(url, callback) {
130
    if (!url)
131
      throw 'No URL for getURL';
132

    
133
    try {
134
      if (typeof callback.operationComplete == 'function')
135
        callback = callback.operationComplete;
136
    } catch (e) {}
137
    if (typeof callback != 'function')
138
      throw 'No callback function for getURL';
139

    
140
    var http_request = null;
141
    if (typeof XMLHttpRequest != 'undefined') {
142
      http_request = new XMLHttpRequest();
143
    }
144
    else if (typeof ActiveXObject != 'undefined') {
145
      try {
146
        http_request = new ActiveXObject('Msxml2.XMLHTTP');
147
      } catch (e) {
148
        try {
149
          http_request = new ActiveXObject('Microsoft.XMLHTTP');
150
        } catch (e) {}
151
      }
152
    }
153
    if (!http_request)
154
      throw 'Both getURL and XMLHttpRequest are undefined';
155

    
156
    http_request.onreadystatechange = function() {
157
      if (http_request.readyState == 4) {
158
        callback( { success : true,
159
                    content : http_request.responseText,
160
                    contentType : http_request.getResponseHeader("Content-Type") } );
161
      }
162
    }
163
    http_request.open('GET', url, true);
164
    http_request.send(null);
165
  }
166
}
167
window.setTimeout('update_status_thread()', 2500);
168
</script>
169

    
170
<?php include("fend.inc"); ?>
171

    
172
</body>
173
</html>
(178-178/246)