//====================================================================================
// 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 08/01/2006
if( isset($_POST["systemid"]) )
$_GET["systemid"] = $_POST["systemid"];
if( isset($_POST["frequency"]) ) {
$ok = true;
if( $_POST["frequency"] == "SERVER DEFAULT" ) {
$ok = resetFrequency();
}
else {
$toBeSet = 0;
switch($_POST["frequency"]) {
case "NEVER" : $toBeSet = -1; break;
case "ALWAYS": $toBeSet = 0; break;
default: $toBeSet = $_POST["frequency_edit"];
}
resetFrequency();
$ok = setFrequency( $toBeSet );
}
if( $ok ) {
if( ! isset( $_GET["systemid"] ) )
echo "";
else
echo "";
die();
}
}
if( isset($_GET["systemid"]))
$nbMach = 1;
else
$nbMach = getCount($_SESSION["storedRequest"]);
PrintEnTete( $l->g(484)." ($nbMach ".$l->g(478).")");
if( ! isset( $_GET["systemid"] ) )
echo "
<= ".$l->g(188)."";
else
echo "
<= ".$l->g(188)."";
?>
function setFrequency( $freq ) {
global $_GET;
if( isset($_GET["systemid"])) {
$val["h.id"] = $_GET["systemid"];
if( ! @mysql_query( "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE) VALUES('".$val["h.id"]."', 'FREQUENCY', $freq)", $_SESSION["writeServer"] )) {
echo "
ERROR: MySql connection problem
".mysql_error($_SESSION["writeServer"])."";
return false;
}
}
else {
$lareq = getPrelim( $_SESSION["storedRequest"] );
if( ! $res = @mysql_query( $lareq, $_SESSION["readServer"] ))
return false;
while( $val = @mysql_fetch_array($res)) {
if( ! @mysql_query( "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE) VALUES('".$val["h.id"]."', 'FREQUENCY', $freq)", $_SESSION["writeServer"] )) {
echo "
ERROR: MySql connection problem
".mysql_error($_SESSION["writeServer"])."";
return false;
}
}
}
return true;
}
function resetFrequency( ) {
global $_GET;
if( isset($_GET["systemid"])) {
$val["h.id"] = $_GET["systemid"];
if( ! @mysql_query( "DELETE FROM devices WHERE name='FREQUENCY' AND hardware_id='".$val["h.id"]."'", $_SESSION["writeServer"] )) {
echo "
ERROR: MySql connection problem
".mysql_error($_SESSION["writeServer"])."";
return false;
}
}
else {
$lareq = getPrelim( $_SESSION["storedRequest"] );
if( ! $res = @mysql_query( $lareq, $_SESSION["readServer"] ))
return false;
while( $val = @mysql_fetch_array($res)) {
if( ! @mysql_query( "DELETE FROM devices WHERE name='FREQUENCY' AND hardware_id='".$val["h.id"]."'", $_SESSION["writeServer"] )) {
echo "
ERROR: MySql connection problem
".mysql_error($_SESSION["writeServer"])."";
return false;
}
}
}
return true;
//TODO: comprends pas: echo "DELETE FROM devices WHERE name='FREQUENCY' AND hardware_id IN ($lareq)";flush();
}
?>