Project

General

Profile

Download (15.1 KB) Statistics
| Branch: | Tag: | Revision:
1 91bf75df Scott Ullrich
<?php
2 2900e518 Scott Ullrich
/*
3 aaec5634 Renato Botelho
 * diag_command.php
4 cb41dd63 Renato Botelho
 *
5 aaec5634 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 2a2396a6 Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 aaec5634 Renato Botelho
 * All rights reserved.
8 fd9ebcd5 Stephen Beaver
 *
9 aaec5634 Renato Botelho
 * Exec+ v1.02-000 - Copyright 2001-2003, All rights reserved
10
 * Created by technologEase (http://www.technologEase.com)
11
 * (modified for m0n0wall by Manuel Kasper <mk@neon1.net>)\
12 9da2cf1c Stephen Beaver
 *
13 aaec5634 Renato Botelho
 * originally based on m0n0wall (http://m0n0.ch/wall)
14
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
15
 * All rights reserved.
16 fd9ebcd5 Stephen Beaver
 *
17 aaec5634 Renato Botelho
 * Redistribution and use in source and binary forms, with or without
18
 * modification, are permitted provided that the following conditions are met:
19 fd9ebcd5 Stephen Beaver
 *
20 aaec5634 Renato Botelho
 * 1. Redistributions of source code must retain the above copyright notice,
21
 *    this list of conditions and the following disclaimer.
22 fd9ebcd5 Stephen Beaver
 *
23 aaec5634 Renato Botelho
 * 2. Redistributions in binary form must reproduce the above copyright
24
 *    notice, this list of conditions and the following disclaimer in
25
 *    the documentation and/or other materials provided with the
26
 *    distribution.
27 fd9ebcd5 Stephen Beaver
 *
28 aaec5634 Renato Botelho
 * 3. All advertising materials mentioning features or use of this software
29
 *    must display the following acknowledgment:
30
 *    "This product includes software developed by the pfSense Project
31
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
32 fd9ebcd5 Stephen Beaver
 *
33 aaec5634 Renato Botelho
 * 4. The names "pfSense" and "pfSense Project" must not be used to
34
 *    endorse or promote products derived from this software without
35
 *    prior written permission. For written permission, please contact
36
 *    coreteam@pfsense.org.
37 fd9ebcd5 Stephen Beaver
 *
38 aaec5634 Renato Botelho
 * 5. Products derived from this software may not be called "pfSense"
39
 *    nor may "pfSense" appear in their names without prior written
40
 *    permission of the Electric Sheep Fencing, LLC.
41 fd9ebcd5 Stephen Beaver
 *
42 aaec5634 Renato Botelho
 * 6. Redistributions of any form whatsoever must retain the following
43
 *    acknowledgment:
44 919d91f9 Phil Davis
 *
45 aaec5634 Renato Botelho
 * "This product includes software developed by the pfSense Project
46
 * for use in the pfSense software distribution (http://www.pfsense.org/).
47 fd9ebcd5 Stephen Beaver
 *
48 aaec5634 Renato Botelho
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
49
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
51
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
52
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
53
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
54
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
55
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
57
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
58
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59
 * OF THE POSSIBILITY OF SUCH DAMAGE.
60 fd9ebcd5 Stephen Beaver
 */
61 2900e518 Scott Ullrich
62 6b07c15a Matthew Grooms
##|+PRIV
63
##|*IDENT=page-diagnostics-command
64 5230f468 jim-p
##|*NAME=Diagnostics: Command
65 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Diagnostics: Command' page.
66 36a844df Stephen Beaver
##|*MATCH=diag_command.php*
67 6b07c15a Matthew Grooms
##|-PRIV
68
69 7c9a30c8 jim-p
$allowautocomplete = true;
70
71 aceaf18c Phil Davis
require_once("guiconfig.inc");
72 458e0e0b Scott Ullrich
73 6102c368 NewEraCracker
if ($_POST['submit'] == "DOWNLOAD" && file_exists($_POST['dlPath'])) {
74 5b237745 Scott Ullrich
	session_cache_limiter('public');
75
	$fd = fopen($_POST['dlPath'], "rb");
76
	header("Content-Type: application/octet-stream");
77
	header("Content-Length: " . filesize($_POST['dlPath']));
78 be4b8e72 Scott Ullrich
	header("Content-Disposition: attachment; filename=\"" .
79 5b237745 Scott Ullrich
		trim(htmlentities(basename($_POST['dlPath']))) . "\"");
80 2d181b70 jim-p
	if (isset($_SERVER['HTTPS'])) {
81
		header('Pragma: ');
82
		header('Cache-Control: ');
83
	} else {
84
		header("Pragma: private");
85
		header("Cache-Control: private, must-revalidate");
86
	}
87 be4b8e72 Scott Ullrich
88 5b237745 Scott Ullrich
	fpassthru($fd);
89
	exit;
90 6102c368 NewEraCracker
} else if ($_POST['submit'] == "UPLOAD" && is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
91 5b237745 Scott Ullrich
	move_uploaded_file($_FILES['ulfile']['tmp_name'], "/tmp/" . $_FILES['ulfile']['name']);
92 8545adde k-paulius
	$ulmsg = sprintf(gettext('Uploaded file to /tmp/%s.'), htmlentities($_FILES['ulfile']['name']));
93 5b237745 Scott Ullrich
}
94 2900e518 Scott Ullrich
95 41b1ff89 Phil Davis
if ($_POST) {
96 61a90ed5 Scott Ullrich
	conf_mount_rw();
97 41b1ff89 Phil Davis
}
98 74285e13 Scott Ullrich
99 5b237745 Scott Ullrich
// Function: is Blank
100
// Returns true or false depending on blankness of argument.
101
102 41b1ff89 Phil Davis
function isBlank($arg) {
103 6c07db48 Phil Davis
	return preg_match("/^\s*$/", $arg);
104 41b1ff89 Phil Davis
}
105 5b237745 Scott Ullrich
106
// Function: Puts
107
// Put string, Ruby-style.
108
109 41b1ff89 Phil Davis
function puts($arg) {
110
	echo "$arg\n";
111
}
112 5b237745 Scott Ullrich
113
// "Constants".
114
115 45d6ada5 Sjon Hortensius
$Version = '';
116 aa205c3b Ermal
$ScriptName = $REQUEST['SCRIPT_NAME'];
117 5b237745 Scott Ullrich
118
// Get year.
119
120 45d6ada5 Sjon Hortensius
$arrDT = localtime();
121 5b237745 Scott Ullrich
$intYear = $arrDT[5] + 1900;
122
123 a6a6ee00 k-paulius
$pgtitle = array(gettext("Diagnostics"), gettext("Command Prompt"));
124 998abf60 Bill Marquette
include("head.inc");
125 5b237745 Scott Ullrich
?>
126 8fd9052f Colin Fleming
<script type="text/javascript">
127
//<![CDATA[
128 45d6ada5 Sjon Hortensius
	// Create recall buffer array (of encoded strings).
129 5b237745 Scott Ullrich
<?php
130
131 6c07db48 Phil Davis
if (isBlank($_POST['txtRecallBuffer'])) {
132 6aef15f8 Stephen Beaver
	puts("	 var arrRecallBuffer = new Array;");
133 5b237745 Scott Ullrich
} else {
134 6aef15f8 Stephen Beaver
	puts("	 var arrRecallBuffer = new Array(");
135 6c07db48 Phil Davis
	$arrBuffer = explode("&", $_POST['txtRecallBuffer']);
136
	for ($i = 0; $i < (count($arrBuffer) - 1); $i++) {
137 6aef15f8 Stephen Beaver
		puts("		'" . htmlspecialchars($arrBuffer[$i], ENT_QUOTES | ENT_HTML401) . "',");
138 41b1ff89 Phil Davis
	}
139 6aef15f8 Stephen Beaver
	puts("		'" . htmlspecialchars($arrBuffer[count($arrBuffer) - 1], ENT_QUOTES | ENT_HTML401) . "'");
140
	puts("	 );");
141 5b237745 Scott Ullrich
}
142
?>
143 45d6ada5 Sjon Hortensius
144 41b1ff89 Phil Davis
	// Set pointer to end of recall buffer.
145
	var intRecallPtr = arrRecallBuffer.length-1;
146 5b237745 Scott Ullrich
147 45d6ada5 Sjon Hortensius
	// Functions to extend String class.
148
	function str_encode() { return escape( this ) }
149
	function str_decode() { return unescape( this ) }
150
151
	// Extend string class to include encode() and decode() functions.
152
	String.prototype.encode = str_encode
153
	String.prototype.decode = str_decode
154
155
	// Function: is Blank
156
	// Returns boolean true or false if argument is blank.
157
	function isBlank( strArg ) { return strArg.match( /^\s*$/ ) }
158
159
	// Function: frmExecPlus onSubmit (event handler)
160
	// Builds the recall buffer from the command string on submit.
161
	function frmExecPlus_onSubmit( form ) {
162 5b237745 Scott Ullrich
163 45d6ada5 Sjon Hortensius
		if (!isBlank(form.txtCommand.value)) {
164
			// If this command is repeat of last command, then do not store command.
165
			if (form.txtCommand.value.encode() == arrRecallBuffer[arrRecallBuffer.length-1]) { return true }
166
167
			// Stuff encoded command string into the recall buffer.
168 41b1ff89 Phil Davis
			if (isBlank(form.txtRecallBuffer.value)) {
169 45d6ada5 Sjon Hortensius
				form.txtRecallBuffer.value = form.txtCommand.value.encode();
170 41b1ff89 Phil Davis
			} else {
171 45d6ada5 Sjon Hortensius
				form.txtRecallBuffer.value += '&' + form.txtCommand.value.encode();
172 41b1ff89 Phil Davis
			}
173 45d6ada5 Sjon Hortensius
		}
174
175
		return true;
176
	}
177 5b237745 Scott Ullrich
178 45d6ada5 Sjon Hortensius
	// Function: btnRecall onClick (event handler)
179
	// Recalls command buffer going either up or down.
180
	function btnRecall_onClick( form, n ) {
181 5b237745 Scott Ullrich
182 45d6ada5 Sjon Hortensius
		// If nothing in recall buffer, then error.
183
		if (!arrRecallBuffer.length) {
184 6c07db48 Phil Davis
			alert('<?=gettext("Nothing to recall"); ?>!');
185 45d6ada5 Sjon Hortensius
			form.txtCommand.focus();
186
			return;
187
		}
188 5b237745 Scott Ullrich
189 45d6ada5 Sjon Hortensius
		// Increment recall buffer pointer in positive or negative direction
190
		// according to <n>.
191
		intRecallPtr += n;
192 5b237745 Scott Ullrich
193 45d6ada5 Sjon Hortensius
		// Make sure the buffer stays circular.
194
		if (intRecallPtr < 0) { intRecallPtr = arrRecallBuffer.length - 1 }
195
		if (intRecallPtr > (arrRecallBuffer.length - 1)) { intRecallPtr = 0 }
196 5b237745 Scott Ullrich
197 45d6ada5 Sjon Hortensius
		// Recall the command.
198
		form.txtCommand.value = arrRecallBuffer[intRecallPtr].decode();
199
	}
200 5b237745 Scott Ullrich
201 45d6ada5 Sjon Hortensius
	// Function: Reset onClick (event handler)
202
	// Resets form on reset button click event.
203
	function Reset_onClick( form ) {
204 5b237745 Scott Ullrich
205 45d6ada5 Sjon Hortensius
		// Reset recall buffer pointer.
206
		intRecallPtr = arrRecallBuffer.length;
207 5b237745 Scott Ullrich
208 45d6ada5 Sjon Hortensius
		// Clear form (could have spaces in it) and return focus ready for cmd.
209
		form.txtCommand.value = '';
210
		form.txtCommand.focus();
211 5b237745 Scott Ullrich
212 45d6ada5 Sjon Hortensius
		return true;
213
	}
214 fa7855f3 Colin Fleming
//]]>
215 5b237745 Scott Ullrich
</script>
216 45d6ada5 Sjon Hortensius
<?php
217 5b237745 Scott Ullrich
218 947141fd Phil Davis
if (isBlank($_POST['txtCommand']) && isBlank($_POST['txtPHPCommand']) && isBlank($ulmsg)) {
219 7457ba51 k-paulius
	print_callout(gettext("The capabilities offered here can be dangerous. No support is available. Use them at your own risk!"), 'danger', gettext('Advanced Users Only'));
220 947141fd Phil Davis
}
221 5b237745 Scott Ullrich
222 6102c368 NewEraCracker
if ($_POST['submit'] == "EXEC" && !isBlank($_POST['txtCommand'])):?>
223 45d6ada5 Sjon Hortensius
	<div class="panel panel-success responsive">
224 b7edfd3c Phil Davis
		<div class="panel-heading"><h2 class="panel-title"><?=sprintf(gettext('Shell Output - %s'), htmlspecialchars($_POST['txtCommand']))?></h2></div>
225 45d6ada5 Sjon Hortensius
		<div class="panel-body">
226 7b91ab09 Jared Dillard
			<div class="content">
227 5b237745 Scott Ullrich
<?php
228 45d6ada5 Sjon Hortensius
	putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
229
	putenv("SCRIPT_FILENAME=" . strtok($_POST['txtCommand'], " "));
230 6aef15f8 Stephen Beaver
	$output = array();
231
	exec($_POST['txtCommand'] . ' 2>&1', $output);
232 5eb9f6ad NewEraCracker
233
	$output = implode("\n", $output);
234
	print("<pre>" . htmlspecialchars($output) . "</pre>");
235 7b91ab09 Jared Dillard
?>
236
			</div>
237 45d6ada5 Sjon Hortensius
		</div>
238
	</div>
239 fa172bc5 NewEraCracker
<?php endif; ?>
240 5b237745 Scott Ullrich
241 36a844df Stephen Beaver
<form action="diag_command.php" method="post" enctype="multipart/form-data" name="frmExecPlus" onsubmit="return frmExecPlus_onSubmit( this );">
242 45d6ada5 Sjon Hortensius
	<div class="panel panel-default">
243 f17594c7 Sjon Hortensius
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('Execute Shell Command')?></h2></div>
244 45d6ada5 Sjon Hortensius
		<div class="panel-body">
245 7b91ab09 Jared Dillard
			<div class="content">
246 37676f4e jim-p
				<input id="txtCommand" name="txtCommand" placeholder="Command" type="text" class="col-sm-7"	 value="<?=htmlspecialchars($_POST['txtCommand'])?>" />
247 7b91ab09 Jared Dillard
				<br /><br />
248
				<input type="hidden" name="txtRecallBuffer" value="<?=htmlspecialchars($_POST['txtRecallBuffer']) ?>" />
249 37676f4e jim-p
250
				<div class="btn-group">
251 b8ce3e91 jim-p
					<button type="button" class="btn btn-success btn-sm" name="btnRecallPrev" onclick="btnRecall_onClick( this.form, -1 );" title="<?=gettext("Recall Previous Command")?>">
252 37676f4e jim-p
						<i class="fa fa-angle-double-left"></i>
253
					</button>
254 6102c368 NewEraCracker
					<button name="submit" type="submit" class="btn btn-warning btn-sm" value="EXEC" title="<?=gettext("Execute the entered command")?>">
255 df2aa83e Stephen Beaver
						<i class="fa fa-bolt"></i>
256 37676f4e jim-p
						<?=gettext("Execute"); ?>
257
					</button>
258 b8ce3e91 jim-p
					<button type="button" class="btn btn-success btn-sm" name="btnRecallNext" onclick="btnRecall_onClick( this.form,  1 );" title="<?=gettext("Recall Next Command")?>">
259 37676f4e jim-p
						<i class="fa fa-angle-double-right"></i>
260 6fe069a4 jim-p
					</button>
261 050624e7 Jared Dillard
					<button style="margin-left: 10px;" type="button" class="btn btn-default btn-sm" onclick="return Reset_onClick( this.form );" title="<?=gettext("Clear command entry")?>">
262 37676f4e jim-p
						<i class="fa fa-undo"></i>
263
						<?=gettext("Clear"); ?>
264
					</button>
265
				</div>
266 7b91ab09 Jared Dillard
			</div>
267 45d6ada5 Sjon Hortensius
		</div>
268
	</div>
269
270
	<div class="panel panel-default">
271 3d7a8696 k-paulius
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('Download File')?></h2></div>
272 45d6ada5 Sjon Hortensius
		<div class="panel-body">
273 7b91ab09 Jared Dillard
			<div class="content">
274 5c0ab3cd NewEraCracker
				<input name="dlPath" type="text" id="dlPath" placeholder="File to download" class="col-sm-4" value="<?=htmlspecialchars($_GET['dlPath']);?>"/>
275 7b91ab09 Jared Dillard
				<br /><br />
276 37676f4e jim-p
				<button name="submit" type="submit" class="btn btn-primary btn-sm" id="download" value="DOWNLOAD">
277
					<i class="fa fa-download icon-embed-btn"></i>
278
					<?=gettext("Download")?>
279
				</button>
280 7b91ab09 Jared Dillard
			</div>
281 45d6ada5 Sjon Hortensius
		</div>
282
	</div>
283 fbcf0037 Scott Ullrich
284 45d6ada5 Sjon Hortensius
<?php
285 947141fd Phil Davis
	if ($ulmsg) {
286 7c945f74 k-paulius
		print_info_box($ulmsg, 'success', false);
287 947141fd Phil Davis
	}
288 45d6ada5 Sjon Hortensius
?>
289
	<div class="panel panel-default">
290 3d7a8696 k-paulius
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('Upload File')?></h2></div>
291 45d6ada5 Sjon Hortensius
		<div class="panel-body">
292 7b91ab09 Jared Dillard
			<div class="content">
293
				<input name="ulfile" type="file" class="btn btn-default btn-sm btn-file" id="ulfile" />
294
				<br />
295 37676f4e jim-p
				<button name="submit" type="submit" class="btn btn-primary btn-sm" id="upload" value="UPLOAD">
296
					<i class="fa fa-upload icon-embed-btn"></i>
297
					<?=gettext("Upload")?>
298
				</button>
299 7b91ab09 Jared Dillard
			</div>
300 45d6ada5 Sjon Hortensius
		</div>
301
	</div>
302
<?php
303 5c1fea17 stilez
	
304 f5ba2db3 Stephen Beaver
	// Experimental version. Writes the user's php code to a file and executes it via a new instance of PHP
305
	// This is intended to prevent bad code from breaking the GUI
306 6102c368 NewEraCracker
	if ($_POST['submit'] == "EXECPHP" && !isBlank($_POST['txtPHPCommand'])) {
307 5eb9f6ad NewEraCracker
308 39dc4fc5 stilez
		safe_mkdir($g[tmp_path_user_code]);     //create if doesn't exist
309
		$tmpfile = tempnam($g[tmp_path_user_code], "");
310 5c1fea17 stilez
		$phpcode = <<<END_FILE
311
<?php
312
require_once("/etc/inc/config.inc");
313
require_once("/etc/inc/functions.inc");
314 3e115dbf Stephen Beaver
315 5c1fea17 stilez
// USER CODE STARTS HERE:
316 3e115dbf Stephen Beaver
317 5c1fea17 stilez
%s
318
?>
319
END_FILE;
320
		$lineno_correction = 6;  // line numbering correction, this should be the number of lines added above, BEFORE the user's code
321
322
		file_put_contents($tmpfile, sprintf($phpcode, $_POST['txtPHPCommand']));
323
324
		$output = $matches = array();
325
		$retval = 0;
326 1ca0f7f7 stilez
		exec("/usr/local/bin/php -d log_errors=off {$tmpfile}", $output, $retval);
327 5c1fea17 stilez
328
		puts('<div class="panel panel-success responsive"><div class="panel-heading"><h2 class="panel-title">PHP Response</h2></div>');
329
330
		// Help user to find bad code line, if it gave an error
331 39dc4fc5 stilez
		$errmsg_found = preg_match("`error.*:.* (?:in|File:) {$tmpfile}(?:\(| on line |, Line: )(\d+)(?:, Message:|\).* eval\(\)'d code|$)`i", implode("\n", $output), $matches);
332 5c1fea17 stilez
		if ($retval || $errmsg_found) {
333
			/* Trap failed code - test both retval and output message
334
			 * Typical messages as at 2.3.x:
335
			 *   "Parse error: syntax error, ERR_DETAILS in FILE on line NN"
336
			 *   "PHP ERROR: Type: NN, File: FILE, Line: NN, Message: ERR_DETAILS" 
337 39dc4fc5 stilez
			 *   "Parse error: syntax error, unexpected end of file in FILE(NN) : eval()'d code on line 1" [the number in (..) is the error line]
338 5c1fea17 stilez
			*/
339 39dc4fc5 stilez
			if ($matches[1] > $lineno_correction) {
340
				$errline = $matches[1] - $lineno_correction;
341
				$errtext = sprintf(gettext('Line %s appears to have generated an error, and has been highlighted. The full response is below.'), $errline);
342
			} else {
343
				$errline = -1;
344
				$errtext = gettext('The code appears to have generated an error, but the line responsible cannot be identified. The full response is below.');
345
			}
346
			$errtext .= '<br/>' . sprintf(gettext('Note that the line number in the full PHP response will be %s lines too large. Nested code and eval() errors may incorrectly point to "line 1".'), $lineno_correction);
347 5c1fea17 stilez
			$syntax_output = array();
348
			$html = "";
349
			exec("/usr/local/bin/php -s -d log_errors=off {$tmpfile}", $syntax_output);
350
			// Lines 0, 2 and 3 are CSS wrapper for the syntax highlighted code which is at line 1 <br> separated.
351
			$syntax_output = explode("<br />", $syntax_output[1]);
352 39dc4fc5 stilez
			$margin_layout = '%3s %' . strlen(count($syntax_output)) . 'd:';
353 5c1fea17 stilez
			for ($lineno = 1; $lineno < count($syntax_output) - $lineno_correction; $lineno++) {
354 39dc4fc5 stilez
				$margin = str_replace(' ', '&nbsp;', sprintf($margin_layout, ($lineno == $errline ? '&gt;&gt;&gt;' : ''), $lineno));
355
				$html .= "<span style='color:black;backgroundcolor:lightgrey'><tt>{$margin}</tt></span>&nbsp;&nbsp;{$syntax_output[$lineno + $lineno_correction - 1]}<br/>\n";
356 5c1fea17 stilez
			}
357 39dc4fc5 stilez
			print_info_box($errtext, 'danger');
358
			print "<div style='margin:20px'><b>" . gettext("Error locator:") . "</b>\n";
359
			print "<div id='errdiv' style='height:7em; width:60%; overflow:auto; white-space: nowrap; border:darkgrey solid 1px; margin-top: 20px'>\n";
360
			print $html . "\n</div></div>\n";
361 5c1fea17 stilez
		}
362 3e115dbf Stephen Beaver
363 5eb9f6ad NewEraCracker
		$output = implode("\n", $output);
364
		print("<pre>" . htmlspecialchars($output) . "</pre>");
365
366 3e115dbf Stephen Beaver
//		echo eval($_POST['txtPHPCommand']);
367 5c1fea17 stilez
368 45d6ada5 Sjon Hortensius
		puts("</div>");
369 5c1fea17 stilez
370
		unlink($tmpfile);
371 bd8eeef9 Stephen Beaver
?>
372 8fd9052f Colin Fleming
<script type="text/javascript">
373
//<![CDATA[
374 947141fd Phil Davis
	events.push(function() {
375 5c1fea17 stilez
		// scroll error locator if needed (does nothing if no error)
376
		$('#errdiv').scrollTop(<?=max($errline - ($lineno_correction - 3.5), 0);?> * parseFloat($('#errdiv').css('line-height')));
377
378 bd8eeef9 Stephen Beaver
		// Scroll to the bottom of the page to more easily see the results of a PHP exec command
379
		$("html, body").animate({ scrollTop: $(document).height() }, 1000);
380
	});
381 8fd9052f Colin Fleming
//]]>
382 bd8eeef9 Stephen Beaver
</script>
383
<?php
384 fbcf0037 Scott Ullrich
}
385 5b237745 Scott Ullrich
?>
386 45d6ada5 Sjon Hortensius
	<div class="panel panel-default responsive">
387 f17594c7 Sjon Hortensius
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('Execute PHP Commands')?></h2></div>
388 45d6ada5 Sjon Hortensius
		<div class="panel-body">
389 7b91ab09 Jared Dillard
			<div class="content">
390
				<textarea id="txtPHPCommand" placeholder="Command" name="txtPHPCommand" rows="9" cols="80"><?=htmlspecialchars($_POST['txtPHPCommand'])?></textarea>
391
				<br />
392 6102c368 NewEraCracker
				<button name="submit" type="submit" class="btn btn-warning btn-sm" value="EXECPHP" title="<?=gettext("Execute this PHP Code")?>">
393 df2aa83e Stephen Beaver
					<i class="fa fa-bolt"></i>
394 37676f4e jim-p
					<?=gettext("Execute")?>
395
				</button>
396 7b91ab09 Jared Dillard
				<?=gettext("Example"); ?>: <code>print("Hello World!");</code>
397
			</div>
398 45d6ada5 Sjon Hortensius
		</div>
399
	</div>
400 fa7855f3 Colin Fleming
</form>
401 74285e13 Scott Ullrich
402
<?php
403 45d6ada5 Sjon Hortensius
include("foot.inc");
404 74285e13 Scott Ullrich
405 947141fd Phil Davis
if ($_POST) {
406 0bbbafc4 Phil Davis
	conf_mount_ro();
407 947141fd Phil Davis
}