Projet

Général

Profil

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

univnautes / usr / local / www / status_filter_reload.php @ 0fab7eb1

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" name="status" style="padding:5px; border:1px dashed #990000; background-color: #ffffff; color: #000000;">
81
	<?php echo $status; ?>
82
</div>
83

    
84
<div id="doneurl" name="doneurl">
85
</div>
86

    
87
<p>
88

    
89
<div id="reloadinfo" name="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
/* 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"> ' + result_text + '...');
106
	} else {
107
		jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif"> Obtaining filter status...');
108
	}
109
	if(result_text == "Initializing") {
110
		jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif"> 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
</script>
121

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

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

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

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

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

    
171
</body>
172
</html>
(185-185/254)