X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=lib%2Fwww.php;h=f38f5e8307f5d56c10d6da276e131a6f2eb2dd64;hb=9c4cfa21a5d947f40ce7aec2ea6f9a69857a9fcf;hp=70274f52b2e301bac1c11fb4dbc182d5cb3e92b4;hpb=671b623794ad8bd9d8a57f28436a46a62b12ef66;p=PHPIPManager.git diff --git a/lib/www.php b/lib/www.php index 70274f5..f38f5e8 100644 --- a/lib/www.php +++ b/lib/www.php @@ -3,8 +3,17 @@ $actionRegister["addsuper"] = "www_ip_addSuperRange"; $actionRegister["allocate"] = "www_ip_allocateRange"; $actionRegister["allocatesub"] = "www_ip_allocateSubRange"; +$actionRegister["deletesub"] = "www_ip_deleteSubRange"; +$actionRegister["modsubnet"] = "www_ip_modifySubnet"; $actionRegister["dumpdb"] = "www_db_dumpdb"; $actionRegister["restoredb"] = "www_db_restoredb"; +$actionRegister["changesubdetails"] = "www_ip_changesubdetails"; +$actionRegister["addhosts"] = "www_ip_addhost"; +$actionRegister["deletehost"] = "www_ip_deletehost"; +$actionRegister["modifyhost"] = "www_ip_modifyhost"; +$actionRegister["updatehost"] = "www_ip_updatehost"; +$actionRegister["scansub"] = "www_ip_scansub"; +$actionRegister["scansubreal"] = "www_ip_scansubReal"; class www { function Go() { @@ -70,12 +79,34 @@ Description $res = $db->dbobject->query("select * from supernet"); foreach($res as $row) { //echo "
";
-		//	print_r($row);
-		//	echo "

"; - echo ""; + // print_r($row); + // echo "
"; + if(ipversion($row["sn_ip"]) == 6) $ip6trans = "::0"; + else $ip6trans = ""; + echo "
".$row["sn_name"]."".$row["sn_ip"]."/".$row["sn_mask"]."".$row["sn_desc"]."
"; echo ""; echo ""; + echo ""; // now we search for sub's + $res2 = $db->dbobject->query("select * from subnet where snid_id='".$row["sn_id"]."'"); + foreach($res2 as $row2) { + // ("sn_id" INTEGER PRIMARY KEY AUTOINCREMENT,"snid_id" INTEGER,"sn_ip" TEXT,"sn_mask" TEXT,"sn_name" TEXT, "sn_desc" TEXT);'; + $name = $row2["sn_name"]; + $subid = $row2["sn_id"]; + $subnet = $row2["sn_ip"]; + $mask = $row2["sn_mask"]; + $desc = $row2["sn_desc"]; + + if(ipversion($row2["sn_ip"]) == 6) $ip6trans = "::0"; + else $ip6trans = ""; + + echo ""; + echo ""; + echo ""; + //echo ""; + if(ipversion($row2["sn_ip"]) == 4) echo ""; + echo ""; + } echo "
".$row["sn_name"]."".$row["sn_ip"]."$ip6trans/".$row["sn_mask"]."".$row["sn_desc"]."Allocate SubnetDelete Supernet
  • $name
  • $subnet$ip6trans/$mask$descDelete SubnetAdd HostScan Subnet

    "; } @@ -107,6 +138,13 @@ Description function footer() { + echo "
    ";
    +		//print_r($_SERVER);
    +		
    +		//print_r($_REQUEST);
    +		
    +		//print_r($GLOBALS);
    +		echo "
    "; ?> } } +function www_ip_scansub() +{ + global $db, $wwwConnector; + + $id = $_REQUEST["id"]; + + $res = $db->dbobject->query("select * from subnet where sn_id=='$id'"); + + foreach($res as $row) { + $snip = $row["sn_ip"]; + $snmask = $row["sn_mask"]; + $snname = $row["sn_name"]; + } + $wwwConnector->header(); + $wwwConnector->printError(); + +?> +You are about to scan the subnet how would you like entries added:
    +
  • Replace all default entries (i.e. where the name and the ip address are the same) where hosts are UP (reply to ping) +
  • Replace all entries where hosts are UP (reply to ping) +
  • Add any entries where hosts are UP (reply to ping) and an entry does not already exist in the database +
  • Add any entries where hosts are UP or Down and an entry does not already exist in the database, but the IP has a reverse hostname entry +
  • Delete all entries and replace with hosts that are Up or Down and have reverse hostname entries +footer(); +} + +function www_ip_scansubReal() +{ + global $db, $wwwConnector; + + $id = $_REQUEST["id"]; + + system("/usr/bin/php ../lib/runscan.php $id > /tmp/out.phpipman 2>&1 &"); + error_log("would exec... nmap -sP -oX $fname $sn/$sm"); + + header("Location: index.php?notice=Scan Initiated"); +} + function www_ip_addSuperRange() { global $db; @@ -166,6 +244,18 @@ function www_ip_allocateRange() $wwwConnector->footer(); } +function www_ip_deleteSubRange() +{ + global $db, $wwwConnector; + + $id = $_REQUEST["id"]; + //("sn_id" INTEGER PRIMARY KEY AUTOINCREMENT,"snid_id" INTEGER,"sn_ip" TEXT,"sn_mask" TEXT,"sn_name" TEXT, "sn_desc" TEXT);'; + $sql = "delete from subnet where sn_id=='$id'"; + $res = $db->dbobject->query($sql); + + header("Location: index.php?notice=Deleted\n"); +} + function www_ip_allocateSubRange() { global $db, $wwwConnector; @@ -184,8 +274,166 @@ function www_ip_allocateSubRange() } } +function www_ip_modifySubnet() +{ + global $db, $wwwConnector; + + $id = $_REQUEST["id"]; + //("sn_id" INTEGER PRIMARY KEY AUTOINCREMENT,"snid_id" INTEGER,"sn_ip" TEXT,"sn_mask" TEXT,"sn_name" TEXT, "sn_desc" TEXT);'; + $sql = "select sn_name,sn_desc,sn_ip from subnet where sn_id=='$id'"; + $res = $db->dbobject->query($sql); + + foreach($res as $row) { + $sn_name = $row["sn_name"]; + $sn_desc = $row["sn_desc"]; + $sn_ip = $row["sn_ip"]; + } + + $wwwConnector->header(); + $wwwConnector->printError(); + + // ("ho_id" INTEGER PRIMARY KEY AUTOINCREMENT,"ho_sn_id" INTEGER,"ho_ip" TEXT,"ho_name" TEXT,"ho_desc" TEXT) + ?> +
    +Subnet Name: +Subnet Description: + +
    + +
    +

    Add Host

    +Hostname +IP Address +Description + +
    + + + + + +dbobject->query($sql); + + foreach($res as $row) { + $name = $row["ho_name"]; + $desc = $row["ho_desc"]; + $ip = $row["ho_ip"]; + $hid = $row["ho_id"]; + echo ""; + } +?> +
    Host IPHostnameDescription
    $ip$name$descDelete
    + + +Back +footer(); +} + +function www_ip_updatehost() +{ + global $db, $wwwConnector; + + $hname = $_REQUEST["hostname"]; + $hip = $_REQUEST["hostip"]; + $hdesc = $_REQUEST["hostdesc"]; + $sid = $_REQUEST["superid"]; + $hid = $_REQUEST["hid"]; + + // ("ho_id" INTEGER PRIMARY KEY AUTOINCREMENT,"ho_sn_id" INTEGER,"ho_ip" TEXT,"ho_name" TEXT,"ho_desc" TEXT) + $sql = "update hosts set ho_name='$hname',ho_ip='$hip',ho_desc='$hdesc' where ho_id='$hid'"; + $db->dbobject->query($sql); + + header("Location: ?action=modsubnet&id=$sid"); +} + +function www_ip_modifyhost() +{ + global $db, $wwwConnector; + + $id = $_REQUEST["hid"]; + + $res = $db->dbobject->query("select * from hosts where ho_id=='$id'"); + + foreach($res as $row) { + $hname = $row["ho_name"]; + $hip = $row["ho_ip"]; + $sid = $row["ho_sn_id"]; + $hdesc = $row["ho_desc"]; + } + + $wwwConnector->header(); + $wwwConnector->printError(); + ?> +
    + + + + + + +
    Host Name
    Host IP
    Description
    +
    +">Back +footer(); +} + +function www_ip_deletehost() +{ + global $db, $wwwConnector; + + $id = $_REQUEST["hostid"]; + $sid = $_REQUEST["snid"]; + + $sql = "delete from hosts where ho_id=='$id'"; + $db->dbobject->query($sql); + + header("Location: ?action=modsubnet&id=$sid"); +} + +function www_ip_addhost() +{ + global $db, $wwwConnector; + + $id = $_REQUEST["id"]; + $hn = $_REQUEST["hostname"]; + $hip = $_REQUEST["hostip"]; + $desc = $_REQUEST["hostdesc"]; + + $sql = "insert into hosts values (NULL, '$id', '$hip', '$hn', '$desc')"; + $db->dbobject->query($sql); + + header("Location: ?action=modsubnet&id=$id"); +} + +function www_ip_changesubdetails() +{ + global $db, $wwwConnector; + + $id = $_REQUEST["id"]; + $name = $_REQUEST["subname"]; + $desc = $_REQUEST["subdesc"]; + + $sql = "update subnet set sn_name='$name', sn_desc='$desc' where sn_id=='$id'"; + $db->dbobject->query($sql); + + header("Location: ?action=modsubnet&id=$id"); +} + function www_db_dumpdb() { + global $db; + + $datestamp = strftime("%d-%m-%Y-%H.%M.%S"); + $name = "ipmandbdump-$datestamp.db"; + header("Content-type: application/octet-stream;\n"); + header("Content-Disposition: attachment; filename=\"$name\";\n\n"); + $db->dump(); } function www_db_restoredb()