54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
$title = "Utils";
|
|
require_once("includes/config.php");
|
|
require_once("includes/header.php");
|
|
require_once("includes/nav.php");
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] === 'ping' || $_POST['action'] === 'traceroute') && isset($_POST['host']) && !empty($_POST['host'])) {
|
|
switch ($_POST['action']) {
|
|
case 'ping':
|
|
$cmd = '/usr/bin/'.$_POST['action']. ' -c 4';
|
|
break;
|
|
case 'traceroute':
|
|
$cmd = '/usr/bin/'.$_POST['action'];
|
|
break;
|
|
|
|
}
|
|
$action = $_POST['action'];
|
|
$host = str_replace($blacklist, '', $_POST['host']);
|
|
exec($cmd.' '.$host, $result);
|
|
}
|
|
|
|
?>
|
|
<div class="container">
|
|
<h2>Utils</h2>
|
|
<h3>Ping</h3>
|
|
<form id="ping" method="post" action="">
|
|
<fieldset>
|
|
<input type="hidden" name="action" value="ping">
|
|
<input type="text" name="host" required>
|
|
<input type="submit" class="btn btn-b btn-sm smooth" value="Run">
|
|
</fieldset>
|
|
</form>
|
|
<?php
|
|
if (isset($action) && $action === "ping" && isset($result)) {
|
|
echo '<pre>'; foreach($result as $line) { echo $line."\n"; } echo '</pre>';
|
|
}
|
|
?>
|
|
<h3>Traceroute</h3>
|
|
<form id="traceroute" method="post" action="">
|
|
<fieldset>
|
|
<input type="hidden" name="action" value="traceroute" required>
|
|
<input type="text" name="host">
|
|
<input type="submit" class="btn btn-b btn-sm smooth" value="Run">
|
|
</fieldset>
|
|
</form>
|
|
<?php
|
|
if (isset($action) && $action === "traceroute" && isset($result)) {
|
|
echo '<pre>'; foreach($result as $line) { echo $line."\n"; } echo '</pre>';
|
|
}
|
|
?>
|
|
</div>
|
|
</body>
|
|
</html>
|