Project

General

Profile

Download (3.78 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * diag_reboot.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * originally based on m0n0wall (http://m0n0.ch/wall)
10
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
 * All rights reserved.
12
 *
13
 * Licensed under the Apache License, Version 2.0 (the "License");
14
 * you may not use this file except in compliance with the License.
15
 * You may obtain a copy of the License at
16
 *
17
 * http://www.apache.org/licenses/LICENSE-2.0
18
 *
19
 * Unless required by applicable law or agreed to in writing, software
20
 * distributed under the License is distributed on an "AS IS" BASIS,
21
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
 * See the License for the specific language governing permissions and
23
 * limitations under the License.
24
 */
25

    
26
##|+PRIV
27
##|*IDENT=page-diagnostics-rebootsystem
28
##|*NAME=Diagnostics: Reboot System
29
##|*DESCR=Allow access to the 'Diagnostics: Reboot System' page.
30
##|*MATCH=diag_reboot.php*
31
##|-PRIV
32

    
33
// Set DEBUG to true to prevent the system_reboot() function from being called
34
define("DEBUG", false);
35

    
36
require_once("guiconfig.inc");
37
require_once("functions.inc");
38
require_once("captiveportal.inc");
39

    
40
$guitimeout = 90;	// Seconds to wait before reloading the page after reboot
41
$guiretry = 20;		// Seconds to try again if $guitimeout was not long enough
42

    
43
$pgtitle = array(gettext("Diagnostics"), gettext("Reboot"));
44
include("head.inc");
45

    
46
if (($_SERVER['REQUEST_METHOD'] == 'POST') && (empty($_POST['override']) ||
47
    ($_POST['override'] != "yes"))):
48
	if (DEBUG) {
49
		print_info_box(gettext("Not actually rebooting (DEBUG is set true)."), 'success');
50
	} else {
51
		print('<div><pre>');
52
		system_reboot();
53
		print('</pre></div>');
54
	}
55

    
56
?>
57

    
58
<div id="countdown" class="text-center"></div>
59

    
60
<script type="text/javascript">
61
//<![CDATA[
62
events.push(function() {
63

    
64
	var time = 0;
65

    
66
	function checkonline() {
67
		$.ajax({
68
			url	 : "/index.php", // or other resource
69
			type : "HEAD"
70
		})
71
		.done(function() {
72
			window.location="/index.php";
73
		});
74
	}
75

    
76
	function startCountdown() {
77
		setInterval(function() {
78
			if (time == "<?=$guitimeout?>") {
79
				$('#countdown').html('<h4><?=sprintf(gettext("Rebooting%sPage will automatically reload in %s seconds"), "<br />", "<span id=\"secs\"></span>");?></h4>');
80
			}
81

    
82
			if (time > 0) {
83
				$('#secs').html(time);
84
				time--;
85
			} else {
86
				time = "<?=$guiretry?>";
87
				$('#countdown').html('<h4><?=sprintf(gettext("Not yet ready%s Retrying in another %s seconds"), "<br />", "<span id=\"secs\"></span>");?></h4>');
88
				$('#secs').html(time);
89
				checkonline();
90
			}
91
		}, 1000);
92
	}
93

    
94
	time = "<?=$guitimeout?>";
95
	startCountdown();
96

    
97
});
98
//]]>
99
</script>
100
<?php
101
else:
102

    
103
?>
104

    
105
<div class="panel panel-default">
106
	<div class="panel-heading">
107
		<h2 class="panel-title"><?=gettext('System Reboot Confirmation')?></h2>
108
	</div>
109
	<div class="panel-body">
110
		<div class="content">
111
			<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>
112
			<form action="diag_reboot.php" method="post">
113
				<button type="submit" class="btn btn-danger pull-center" name="Submit" value="<?=gettext("Reboot")?>" title="<?=gettext("Reboot the system")?>">
114
					<i class="fa fa-refresh"></i>
115
					<?=gettext("Reboot")?>
116
				</button>
117
				<a href="/" class="btn btn-info">
118
					<i class="fa fa-undo"></i>
119
					<?=gettext("Cancel")?>
120
				</a>
121
			</form>
122
		</div>
123
	</div>
124
</div>
125

    
126
<script type="text/javascript">
127
//<![CDATA[
128
events.push(function() {
129
	//If we have been called with $_POST['override'] == "yes", then just reload the page to simulate the user clicking "Reboot"
130
	if ( "<?=$_POST['override']?>" == "yes") {
131
		$('form').submit();
132
	}
133
});
134
//]]>
135
</script>
136
<?php
137

    
138
endif;
139

    
140
include("foot.inc");
(22-22/225)