Files
librenms-librenms/html/netcmd.php
T

51 lines
1.2 KiB
PHP
Raw Normal View History

2007-04-03 14:10:23 +00:00
<?php
2008-11-13 17:28:13 +00:00
ini_set('allow_url_fopen', 0);
ini_set('display_errors', 0);
2008-11-13 17:19:43 +00:00
2008-11-13 17:28:13 +00:00
if($_GET[debug]) {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('log_errors', 1);
ini_set('error_reporting', E_ALL);
2008-11-13 17:19:43 +00:00
}
include("../includes/defaults.inc.php");
2008-11-13 17:28:13 +00:00
include("../config.php");
include("../includes/functions.php");
2010-02-20 17:37:42 +00:00
include("includes/authenticate.inc.php");
2009-03-11 14:50:24 +00:00
if(!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
2008-11-13 17:28:13 +00:00
if($_GET['query'] && $_GET['cmd']) {
$host = $_GET['query'];
2008-11-19 12:12:54 +00:00
if(Net_IPv6::checkIPv6($host)||Net_IPv4::validateip($host)||preg_match("/^[a-zA-Z0-9.-]*$/", $host)) {
2008-11-13 17:28:13 +00:00
switch ($_GET['cmd']) {
2008-11-13 17:19:43 +00:00
case 'whois':
2010-03-22 22:13:45 +00:00
$cmd = $config['whois'] . " $host | grep -v \%";
2008-11-13 17:19:43 +00:00
break;
case 'ping':
2010-03-22 22:13:45 +00:00
$cmd = $config['ping'] . " -c 5 $host";
2008-11-13 17:19:43 +00:00
break;
case 'tracert':
2010-03-22 22:13:45 +00:00
$cmd = $config['mtr'] . " -r -c 5 $host";
2008-11-13 17:19:43 +00:00
break;
case 'nmap':
2010-03-22 22:13:45 +00:00
if ($_SESSION['userlevel'] != '10') {
echo("insufficient privileges");
} else {
$cmd = $config['nmap'] . " $host";
}
2008-11-13 17:19:43 +00:00
break;
}
2010-03-22 22:13:45 +00:00
if (!empty($cmd)) {
$output = `$cmd`;
}
2008-11-13 17:19:43 +00:00
}
2007-04-03 14:10:23 +00:00
}
2008-11-13 17:19:43 +00:00
2007-04-03 14:10:23 +00:00
$output = trim($output);
echo("<pre>$output</pre>");
?>