//====================================================================================
// OCS INVENTORY REPORTS
// Copyleft Pierre LEMMET 2006
// Web: http://ocsinventory.sourceforge.net
//
// This code is open source and may be copied and modified as long as the source
// code is always made freely available.
// Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
//====================================================================================
//Modified on 06/23/2006
if( isset($_POST["systemid"]) )
$_GET["systemid"] = $_POST["systemid"];
if( !isset($_GET["systemid"]) ) {
$lareq = getPrelim( $_SESSION["storedRequest"] );
$res = @mysql_query( $lareq, $_SESSION["readServer"] ) or die(mysql_error());
$val = mysql_fetch_array( $res );
$id = $val["h.id"];
}
else {
$id = $_GET["systemid"];
}
if( isset($_POST["ipdiscover"]) ){
$ok = resetIpdiscover( $id );
if( $_POST["ipdiscover"]=="never" ){
$ok = makeIpdiscover( $id, 0 );
}
else if( $_POST["ipdiscover"]!="des" ) {
$ok = makeIpdiscover( $id, 2, $_POST["ipdiscover"] );
}
if( $ok ) {
echo "";
die();
}
}
$nbMach = getCount($_SESSION["storedRequest"]);
if( $nbMach != 1 && ! isset($_GET["systemid"])) {
echo "";
die();
}
PrintEnTete( $l->g(518) );
echo "
<= ".$l->g(188)."";
$resIpd = mysql_query("SELECT tvalue, ivalue FROM devices WHERE name='IPDISCOVER' AND hardware_id=$id",$_SESSION["readServer"] );
$valIpd = mysql_fetch_array( $resIpd );
$resInt = mysql_query("SELECT ipaddress FROM networks WHERE hardware_id=$id",$_SESSION["readServer"] );
while( $valInt = mysql_fetch_array( $resInt ))
$lesRez[] = $valInt["ipaddress"];
$mode = 0;
if( $valIpd["tvalue"] && $valIpd["ivalue"]==1 ) {
echo "
".$l->g(519).": ".$valIpd["tvalue"]."";
$mode = 1;
}
else if( $valIpd["ivalue"]==2 ) {
echo "
".$l->g(520).": ".$valIpd["tvalue"]."";
$mode = 3;
}
else if( $valIpd["ivalue"]==="0" ) {
echo "
".$l->g(521)."";
$mode = 2;
}
else {
echo "
".$l->g(522)."";
}
?>
function makeIpdiscover($id, $sens, $ip=NULL) {
if( $ip != NULL )
$ipsubnet = getSub( $id, $ip );
else
$ipsubnet = NULL;
if( ! @mysql_query( "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE".($ipsubnet!=NULL?",TVALUE":"").") VALUES('$id', 'IPDISCOVER', '$sens'".($ipsubnet!=NULL?",'$ipsubnet'":"").")", $_SESSION["writeServer"] )) {
echo "
ERROR: MySql problem
".mysql_error($_SESSION["writeServer"])."";
return false;
}
return true;
}
function resetIpdiscover( $id ) {
if( ! @mysql_query( "DELETE FROM devices WHERE name='IPDISCOVER' AND hardware_id='$id'", $_SESSION["writeServer"] )) {
echo "
ERROR: MySql problem
".mysql_error($_SESSION["writeServer"])."";
return false;
}
return true;
}
function getSub( $id, $ip ) {
if( ! ($res = @mysql_query( "SELECT ipsubnet FROM networks WHERE ipaddress='$ip' AND hardware_id='$id'", $_SESSION["readServer"] ))) {
echo "
ERROR: MySql problem
".mysql_error($_SESSION["readServer"])."";
}
$val = mysql_fetch_array( $res );
return $val["ipsubnet"];
}
?>