Project

General

Profile

Download (5.4 KB) Statistics
| Branch: | Tag: | Revision:
1 47b051eb sbeaver
<?php
2 5b237745 Scott Ullrich
/*
3 aaec5634 Renato Botelho
 * diag_reboot.php
4 191cb31d Stephen Beaver
 *
5 aaec5634 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
7
 * All rights reserved.
8 d90a0e2d Stephen Beaver
 *
9 aaec5634 Renato Botelho
 * originally based on m0n0wall (http://m0n0.ch/wall)
10
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
 * All rights reserved.
12 d90a0e2d Stephen Beaver
 *
13 aaec5634 Renato Botelho
 * Redistribution and use in source and binary forms, with or without
14
 * modification, are permitted provided that the following conditions are met:
15 d90a0e2d Stephen Beaver
 *
16 aaec5634 Renato Botelho
 * 1. Redistributions of source code must retain the above copyright notice,
17
 *    this list of conditions and the following disclaimer.
18 d90a0e2d Stephen Beaver
 *
19 aaec5634 Renato Botelho
 * 2. Redistributions in binary form must reproduce the above copyright
20
 *    notice, this list of conditions and the following disclaimer in
21
 *    the documentation and/or other materials provided with the
22
 *    distribution.
23 d90a0e2d Stephen Beaver
 *
24 aaec5634 Renato Botelho
 * 3. All advertising materials mentioning features or use of this software
25
 *    must display the following acknowledgment:
26
 *    "This product includes software developed by the pfSense Project
27
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
28 d90a0e2d Stephen Beaver
 *
29 aaec5634 Renato Botelho
 * 4. The names "pfSense" and "pfSense Project" must not be used to
30
 *    endorse or promote products derived from this software without
31
 *    prior written permission. For written permission, please contact
32
 *    coreteam@pfsense.org.
33 d90a0e2d Stephen Beaver
 *
34 aaec5634 Renato Botelho
 * 5. Products derived from this software may not be called "pfSense"
35
 *    nor may "pfSense" appear in their names without prior written
36
 *    permission of the Electric Sheep Fencing, LLC.
37 d90a0e2d Stephen Beaver
 *
38 aaec5634 Renato Botelho
 * 6. Redistributions of any form whatsoever must retain the following
39
 *    acknowledgment:
40 d90a0e2d Stephen Beaver
 *
41 aaec5634 Renato Botelho
 * "This product includes software developed by the pfSense Project
42
 * for use in the pfSense software distribution (http://www.pfsense.org/).
43 d90a0e2d Stephen Beaver
 *
44 aaec5634 Renato Botelho
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
45
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
48
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55
 * OF THE POSSIBILITY OF SUCH DAMAGE.
56 d90a0e2d Stephen Beaver
 */
57 5b237745 Scott Ullrich
58 6b07c15a Matthew Grooms
##|+PRIV
59
##|*IDENT=page-diagnostics-rebootsystem
60 5230f468 jim-p
##|*NAME=Diagnostics: Reboot System
61 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Diagnostics: Reboot System' page.
62 1af5edbf Stephen Beaver
##|*MATCH=diag_reboot.php*
63 6b07c15a Matthew Grooms
##|-PRIV
64
65 47b051eb sbeaver
// Set DEBUG to true to prevent the system_reboot() function from being called
66 b191b7b1 Stephen Beaver
define("DEBUG", false);
67 47b051eb sbeaver
68 aceaf18c Phil Davis
require_once("guiconfig.inc");
69
require_once("functions.inc");
70
require_once("captiveportal.inc");
71 5b237745 Scott Ullrich
72 e226c360 Stephen Beaver
$guitimeout = 90;	// Seconds to wait before reloading the page after reboot
73
$guiretry = 20;		// Seconds to try again if $guitimeout was not long enough
74 59236c21 Stephen Beaver
75 a6a6ee00 k-paulius
$pgtitle = array(gettext("Diagnostics"), gettext("Reboot"));
76 5860dad1 Scott Ullrich
include("head.inc");
77
78 6ea2ea99 sbeaver
79 dc99feef Stephen Beaver
if (($_SERVER['REQUEST_METHOD'] == 'POST') && ($_POST['override'] != "yes")) {
80 947141fd Phil Davis
	if (DEBUG) {
81 8545adde k-paulius
		print_info_box(gettext("Not actually rebooting (DEBUG is set true)."), 'success');
82 947141fd Phil Davis
	} else {
83 89932a3d Stephen Beaver
		print('<div><pre>');
84 47b051eb sbeaver
		system_reboot();
85 89932a3d Stephen Beaver
		print('</pre></div>');
86 d90a0e2d Stephen Beaver
	}
87 99e2a6ce Stephen Beaver
88
?>
89 f9cc072d Stephen Beaver
90 b77cef66 Colin Fleming
<div id="countdown" class="text-center"></div>
91 99e2a6ce Stephen Beaver
92 8fd9052f Colin Fleming
<script type="text/javascript">
93 99e2a6ce Stephen Beaver
//<![CDATA[
94 947141fd Phil Davis
events.push(function() {
95 e226c360 Stephen Beaver
96
	var time = 0;
97
98
	function checkonline() {
99
		$.ajax({
100
			url	 : "/index.php", // or other resource
101
			type : "HEAD"
102
		})
103
		.done(function() {
104
			window.location="/index.php";
105
		});
106
	}
107
108
	function startCountdown() {
109 947141fd Phil Davis
		setInterval(function() {
110 be17381d Stephen Beaver
			if (time == "<?=$guitimeout?>") {
111 c818edc9 Stephen Beaver
				$('#countdown').html('<h4><?=sprintf(gettext("Rebooting%sPage will automatically reload in %s seconds"), "<br />", "<span id=\"secs\"></span>");?></h4>');
112 be17381d Stephen Beaver
			}
113
114 947141fd Phil Davis
			if (time > 0) {
115 be17381d Stephen Beaver
				$('#secs').html(time);
116 e226c360 Stephen Beaver
				time--;
117
			} else {
118
				time = "<?=$guiretry?>";
119 be17381d Stephen Beaver
				$('#countdown').html('<h4><?=sprintf(gettext("Not yet ready%s Retrying in another %s seconds"), "<br />", "<span id=\"secs\"></span>");?></h4>');
120
				$('#secs').html(time);
121 e226c360 Stephen Beaver
				checkonline();
122
			}
123
		}, 1000);
124 89932a3d Stephen Beaver
	}
125
126 e226c360 Stephen Beaver
	time = "<?=$guitimeout?>";
127
	startCountdown();
128
129 99e2a6ce Stephen Beaver
});
130
//]]>
131
</script>
132
<?php
133 47b051eb sbeaver
} else {
134
135 ad0bbc8b sbeaver
?>
136
137
<div class="panel panel-default">
138 162d86d1 Phil Davis
	<div class="panel-heading">
139 a16d923f NOYB
		<h2 class="panel-title"><?=gettext('System Reboot Confirmation')?></h2>
140 162d86d1 Phil Davis
	</div>
141 9239f765 Jared Dillard
	<div class="panel-body">
142
		<div class="content">
143 a11064ea Jared Dillard
			<p><?=gettext('Click "Reboot" to reboot the system immediately, or "Cancel" to go to the system dashboard without rebooting. (There will be a brief delay before the dashboard appears.)')?></p>
144 1af5edbf Stephen Beaver
			<form action="diag_reboot.php" method="post">
145 37676f4e jim-p
				<button type="submit" class="btn btn-danger pull-center" name="Submit" value="<?=gettext("Reboot")?>" title="<?=gettext("Reboot the system")?>">
146
					<i class="fa fa-refresh"></i>
147
					<?=gettext("Reboot")?>
148
				</button>
149 6400975d jim-p
				<a href="/" class="btn btn-info">
150
					<i class="fa fa-undo"></i>
151
					<?=gettext("Cancel")?>
152 37676f4e jim-p
				</a>
153 9239f765 Jared Dillard
			</form>
154
		</div>
155 6ea2ea99 sbeaver
	</div>
156 ad0bbc8b sbeaver
</div>
157
158 dc99feef Stephen Beaver
<script type="text/javascript">
159
//<![CDATA[
160
events.push(function() {
161
	//If we have been called with $_POST['override'] == "yes", then just reload the page to simulate the user clicking "Reboot"
162
	if ( "<?=$_POST['override']?>" == "yes") {
163
		$('form').submit();
164
	}
165
});
166
//]]>
167
</script>
168 ad0bbc8b sbeaver
<?php
169
170 47b051eb sbeaver
}
171 99e2a6ce Stephen Beaver
172 89932a3d Stephen Beaver
include("foot.inc");