Location: PHPKode > projects > RosInfo > rosinfo-1.30/addnew.php
<? 
include_once('header.php');
include_once('include/config.inc');
include_once('include/functions.php');

//pet template
include_once('include/pet.class.php');

$post_name = isset($_POST["name"]) ? $_POST["name"] : "";
$post_category = isset($_POST["category"]) ? $_POST["category"] : "";
$post_ip = isset($_POST["ip"]) ? $_POST["ip"] : "";
$post_snmp = isset($_POST["snmp"]) ? $_POST["snmp"] : "";
$post_http = isset($_POST["http"]) ? $_POST["http"] : "";

$error = 0;
$error += (strlen($post_name) == 0);
$error += (strlen($post_category) == 0);
$error += (strlen($post_ip) == 0);
$error += (strlen($post_snmp) == 0);
$error += (strlen($post_http) == 0);

if ($error != 0)
{
  $pet = new pet('addnewform.tpl');
  echo $pet->fetch();
  include_once('footer.php');
  exit;
}
$pet = new pet('addnewtest.tpl');
$pet->post_name = $post_name;
$pet->post_category = $post_category;
$pet->post_ip = $post_ip;
$pet->post_snmp = $post_snmp;
$pet->post_http = $post_http;

$test_ip = @gethostbyname($post_ip);
$test_dns = @gethostbyaddr($test_ip) ? gethostbyaddr($test_ip) : "error";

if (!@snmpget($test_ip, $post_snmp, "SNMPv2-MIB::sysName.0"))
  $test_snmp = "error";
else
  $test_snmp = "ok";
  
if (!@fopen("http://".$test_ip.":".$post_http."/accounting/ip.cgi", "r"))
  $test_http = "error";
else
  $test_http = "ok";
@fclose(fp);

if ($test_snmp == "error" || $test_http == "error")
{
  $test_result = "Error";
}
else
{
  $test_result = "Ok";
  db_connect();
  
  
  
}


$pet->test_ip = $test_ip;
$pet->test_dns = $test_dns;
$pet->test_snmp = $test_snmp;
$pet->test_http = $test_http;
$pet->test_result = $test_result;

echo $pet->fetch();
include_once('footer.php');
?>      
Return current item: RosInfo