[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-ocs/sources/www/ -> opt_frequency.php (source)

   1  <?
   2  //====================================================================================
   3  // OCS INVENTORY REPORTS
   4  // Copyleft Pierre LEMMET 2006
   5  // Web: http://ocsinventory.sourceforge.net
   6  //
   7  // This code is open source and may be copied and modified as long as the source
   8  // code is always made freely available.
   9  // Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
  10  //====================================================================================
  11  //Modified on 08/01/2006
  12  
  13  
  14  if( isset($_POST["systemid"]) )
  15      $_GET["systemid"] = $_POST["systemid"];
  16  
  17  if( isset($_POST["frequency"]) ) {
  18      
  19      $ok = true;
  20      if( $_POST["frequency"] == "SERVER DEFAULT" ) {
  21          $ok = resetFrequency();
  22      }
  23      else {
  24          $toBeSet = 0;
  25          switch($_POST["frequency"]) {
  26              case "NEVER" : $toBeSet = -1; break;
  27              case "ALWAYS": $toBeSet = 0; break;
  28              default: $toBeSet = $_POST["frequency_edit"];
  29          }
  30          resetFrequency();
  31          $ok = setFrequency( $toBeSet );        
  32      }
  33      if( $ok ) {
  34          if( ! isset( $_GET["systemid"] ) )
  35              echo "<script language='javascript'>window.location='index.php?redo=1".$_SESSION["queryString"]."';</script>";
  36          else
  37              echo "<script language='javascript'>history.go(-2);</script>";    
  38  
  39          die();
  40      }
  41  }
  42  
  43  if( isset($_GET["systemid"]))
  44      $nbMach = 1;
  45  else
  46      $nbMach = getCount($_SESSION["storedRequest"]);
  47  
  48  PrintEnTete( $l->g(484)." <font class='warn'>($nbMach ".$l->g(478).")</font>");
  49  
  50  if( ! isset( $_GET["systemid"] ) )
  51      echo "<br><center><a href='#' OnClick=\"window.location='index.php?redo=1".$_SESSION["queryString"]."';\"><= ".$l->g(188)."</a></center>";
  52  else
  53      echo "<br><center><a href='#' OnClick='history.go(-1);'><= ".$l->g(188)."</a></center>";
  54  ?>
  55  <script language='javascript'>
  56  	function modif(id, val) {
  57          if( document.getElementById(id).disabled == true )
  58              return;        
  59          var curVal = parseFloat(document.getElementById(id).value);
  60          curVal = curVal + parseFloat(val);
  61          if( curVal < 1 || isNaN(curVal) || curVal > 99 )
  62              curVal = 1;            
  63          document.getElementById(id).value = curVal;        
  64      }
  65      
  66  	function active(id, sens) {
  67          var mstyle = document.getElementById(id).style.display    = (sens!=0?"block" :"none");
  68      }
  69      
  70  	function checkNumbers() {
  71          if ( isNaN(document.getElementById('frequency_edit').value) ) {
  72              alert("<? echo $l->g(411); ?>");
  73          }
  74          else {
  75              document.getElementById('formopt').submit();
  76          }
  77      }
  78  </script>
  79  <br>
  80  <form action='index.php?multi=22' method='post'>
  81  <table align='center' BGCOLOR='#C7D9F5' BORDERCOLOR='#9894B5' width='20%'>
  82      <tr bgcolor='#F2F2F2'>
  83          <td width='90%'><input type='radio' name='frequency' value='ALWAYS' OnClick="active('frequency_div',0);"><? echo $l->g(485); ?></td>
  84          <td rowspan='4' width='0%'>
  85              <div id='frequency_div' style='display:none'>
  86                  <table>
  87                      <tr>
  88                          <td rowspan='4'><input type='text' size='3' maxlength='2' id='frequency_edit' name='frequency_edit' value='1'></td>
  89                          <td align='center'><a href='javascript:void(0);' Onclick="modif('frequency_edit','1');">
  90                          <b><font size='3'>+</font></b></a></td>
  91                      </tr>
  92                          <td align='center'><a href='javascript:void(0);' Onclick="modif('frequency_edit','-1');"><b>
  93                          <font size='3'>-</font></b></a></td>
  94                      </tr>
  95                  </table>
  96              </div>
  97          </td>
  98      </tr>
  99      <tr bgcolor='#FFFFFF'>
 100          <td><input type='radio' name='frequency' value='NEVER' OnClick="active('frequency_div',0);"><? echo $l->g(486); ?></td>
 101      </tr>
 102      <tr bgcolor='#F2F2F2'>
 103          <td><input type='radio' name='frequency' value='CUSTOM' OnClick="active('frequency_div',1);"><? echo $l->g(487); ?></td>
 104      </tr>
 105      <tr bgcolor='#FFFFFF'>
 106          <td><input checked type='radio' name='frequency' value='SERVER DEFAULT' OnClick="active('frequency_div',0);"><? echo $l->g(488); ?></td>
 107      </tr>
 108      <tr bgcolor='#FFFFFF'>
 109          <td>&nbsp;</td>
 110          <? if( isset($_GET["systemid"]) ) {
 111              echo "<input type='hidden' value='".$_GET["systemid"]."' name='systemid'>";
 112           } ?>
 113          <td><input type='Submit' value='<? echo $l->g(433); ?>'></td>
 114      </tr>
 115  </table>
 116  </form>
 117  
 118  <?
 119  	function setFrequency( $freq ) {
 120          global $_GET;
 121          if( isset($_GET["systemid"])) {
 122              $val["h.id"] = $_GET["systemid"];
 123              if( ! @mysql_query( "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE) VALUES('".$val["h.id"]."', 'FREQUENCY', $freq)", $_SESSION["writeServer"] )) {
 124                  echo "<br><center><font color=red><b>ERROR: MySql connection problem<br>".mysql_error($_SESSION["writeServer"])."</b></font></center>";
 125                  return false;
 126              }
 127          }
 128          else {
 129              $lareq = getPrelim( $_SESSION["storedRequest"] );
 130              if( ! $res = @mysql_query( $lareq, $_SESSION["readServer"] ))
 131                  return false;
 132              while( $val = @mysql_fetch_array($res)) {
 133                  if( ! @mysql_query( "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE) VALUES('".$val["h.id"]."', 'FREQUENCY', $freq)", $_SESSION["writeServer"] )) {
 134                      echo "<br><center><font color=red><b>ERROR: MySql connection problem<br>".mysql_error($_SESSION["writeServer"])."</b></font></center>";
 135                      return false;
 136                  }
 137              }
 138          }
 139          return true;    
 140      }
 141      
 142  	function resetFrequency( ) {
 143          
 144          global $_GET;
 145          if( isset($_GET["systemid"])) {
 146              $val["h.id"] = $_GET["systemid"];
 147              if( ! @mysql_query( "DELETE FROM devices WHERE name='FREQUENCY' AND hardware_id='".$val["h.id"]."'", $_SESSION["writeServer"] )) {
 148                  echo "<br><center><font color=red><b>ERROR: MySql connection problem<br>".mysql_error($_SESSION["writeServer"])."</b></font></center>";
 149                  return false;
 150              }
 151          }
 152          else {
 153              $lareq = getPrelim( $_SESSION["storedRequest"] );
 154              if( ! $res = @mysql_query( $lareq, $_SESSION["readServer"] ))
 155                  return false;
 156              while( $val = @mysql_fetch_array($res)) {
 157              
 158                  if( ! @mysql_query( "DELETE FROM devices WHERE name='FREQUENCY' AND hardware_id='".$val["h.id"]."'", $_SESSION["writeServer"] )) {
 159                      echo "<br><center><font color=red><b>ERROR: MySql connection problem<br>".mysql_error($_SESSION["writeServer"])."</b></font></center>";
 160                      return false;
 161                  }
 162              }
 163          }
 164  
 165          return true;        
 166          //TODO: comprends pas: echo "DELETE FROM devices WHERE name='FREQUENCY' AND hardware_id IN ($lareq)";flush();        
 167      }
 168  ?>
 169  


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1