[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

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

   1  <?
   2  //====================================================================================
   3  // OCS INVENTORY REPORTS
   4  // Copyleft Pierre LEMMET 2005
   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 9/30/2005
  12  require  ('fichierConf.class.php');
  13  printEnTete($l->g(107));
  14  
  15  $lesEdits = array("IPDISCOVER_MAX_ALIVE","DOWNLOAD_CYCLE_LATENCY","DOWNLOAD_FRAG_LATENCY","DOWNLOAD_PERIOD_LATENCY",
  16  "DOWNLOAD_PERIOD_LENGTH","DOWNLOAD_TIMEOUT","PROLOG_FREQ");
  17  
  18  if( isset($_POST["FREQUENCY"] ) ) {
  19      switch($_POST["FREQUENCY"]) {
  20          case "NEVER" : setOpt("FREQUENCY", -1); break;
  21          case "ALWAYS": setOpt("FREQUENCY", 0); break;
  22          default: setOpt("FREQUENCY", $_POST["FREQUENCY_edit"]);
  23      }    
  24  
  25      switch($_POST["IPDISCOVER"]) {
  26          case "OFF": setOpt("IPDISCOVER", 0); break;
  27          default: setOpt("IPDISCOVER", $_POST["IPDISCOVER_edit"]);
  28      }
  29      
  30      $autoDupLvl =  isset($_POST["AUTO_DUPLICATE_LVL_serial"])?$_POST["AUTO_DUPLICATE_LVL_serial"]:0;
  31      $autoDupLvl += isset($_POST["AUTO_DUPLICATE_LVL_host"])?$_POST["AUTO_DUPLICATE_LVL_host"]:0;
  32      $autoDupLvl += isset($_POST["AUTO_DUPLICATE_LVL_mac"])?$_POST["AUTO_DUPLICATE_LVL_mac"]:0;
  33      setOpt("AUTO_DUPLICATE_LVL", $autoDupLvl);
  34      
  35      $lesOnOff = array("REGISTRY","UPDATE","DEPLOY","TRACE_DELETED","LOGLEVEL","DOWNLOAD","INVENTORY_DIFF","INVENTORY_TRANSACTION");
  36  
  37      
  38      foreach($lesOnOff as $oo) 
  39          setOpt($oo, ($_POST[$oo]=="ON"?1:0));
  40          
  41      foreach($lesEdits as $ee)
  42          setOpt($ee, $_POST[$ee."_edit"]);
  43  }
  44  
  45  ?>
  46  <script language='javascript'>
  47  	function modif(id, val) {
  48          if( document.getElementById(id).disabled == true )
  49              return;        
  50          var curVal = parseFloat(document.getElementById(id).value);
  51          curVal = curVal + parseFloat(val);
  52          if( curVal < 1 || isNaN(curVal) || curVal > 99 )
  53              curVal = 1;            
  54          document.getElementById(id).value = curVal;        
  55      }
  56      
  57  	function active(id, sens) {
  58          var mstyle = document.getElementById(id).style.display    = (sens!=0?"block" :"none");
  59      }
  60      
  61  	function checkNumbers() {
  62          if ( 0 <? foreach($lesEdits as $ee) echo "|| isNaN(document.getElementById('{$ee}_edit').value)"; ?> ) {
  63              alert("<?echo $l->g(411);?>");
  64          }
  65          else {
  66              document.getElementById('formopt').submit();
  67          }
  68      }
  69  </script>
  70  <br><form name='formopt' id='formopt' action='index.php?multi=4' method='POST'><table cellspacing='5' width='80%' BORDER='0' ALIGN = 'Center' CELLPADDING='0' BGCOLOR='#C7D9F5' BORDERCOLOR='#9894B5'>
  71  <tr height=25px>
  72  <td width='27%' align='center'><b><? echo $l->g(49); ?></b></td><td  width='22%' align='center'><b><? echo $l->g(224); ?></b></td><td width='2%'>&nbsp;&nbsp;&nbsp;</td><td width='27%' align='center'><b><? echo $l->g(49); ?></b></td><td  width='22%' align='center'><b><? echo $l->g(224); ?></b></td>
  73  <?
  74  //><td  width='*' align='center'><b> echo $l->g(51); </b></td>
  75  $nbr = 0;
  76  $trad = array("REGISTRY"=>412,"UPDATE"=>413,"DEPLOY"=>414,"TRACE_DELETED"=>415,"LOGLEVEL"=>416,"DOWNLOAD"=>417,"INVENTORY_DIFF"=>418,
  77  "IPDISCOVER_MAX_ALIVE"=>419,"DOWNLOAD_CYCLE_LATENCY"=>420,"DOWNLOAD_FRAG_LATENCY"=>421,"DOWNLOAD_PERIOD_LATENCY"=>422,
  78  "DOWNLOAD_PERIOD_LENGTH"=>423,"DOWNLOAD_TIMEOUT"=>424,"IPDISCOVER"=>425,"FREQUENCY"=>426,"AUTO_DUPLICATE_LVL"=>427);
  79  
  80  $resConf = mysql_query("SELECT NAME,IVALUE FROM config WHERE NAME<>'GUI_VERSION' ORDER BY NAME", $_SESSION["readServer"]) or die(mysql_error());
  81  $decal = "&nbsp;&nbsp;&nbsp;";
  82  $ligne = 0;
  83  while( $conf = mysql_fetch_array($resConf) ) {
  84  
  85      $title = " title=\"".htmlspecialchars($l->g($trad[$conf["NAME"]]))."\" ";
  86      echo "<TR height=65px bgcolor='".($ligne%2==0 ? "#FFFFFF" : "#F2F2F2")."'>";
  87      //case 1
  88      echo "<td$title>$decal".$conf["NAME"]."</td>";
  89      
  90      //case 2
  91      echo "<td$title align='left' width='150px'>";
  92      showOption( $conf["NAME"], $conf["IVALUE"] );
  93      echo "</td>";
  94  
  95      //separator
  96      echo "<td bgcolor='#C7D9F5'>&nbsp;</td>";
  97  
  98      if( ! $conf = mysql_fetch_array($resConf) )
  99          break;
 100      
 101      $title = " title=\"".strtr($l->g($trad[$conf["NAME"]]), "\"","'")."\" ";
 102      //case 3
 103      echo "<td$title>$decal".$conf["NAME"]."</td>";
 104      
 105      //case 4
 106      echo "<td$title align='left' width='150px'>";
 107      showOption( $conf["NAME"], $conf["IVALUE"] );
 108      echo "</td>";
 109      $ligne++;
 110  }
 111          
 112  echo "</tr></table>";
 113  echo "<p align='center'><input type='button' height='60px' value='".$l->g(103)."' OnClick='checkNumbers();'></p></form>";        
 114  
 115  function showOption($nme, $val) {
 116      switch($nme) {
 117          case "REGISTRY":
 118          case "UPDATE":
 119          case "DEPLOY":
 120          case "TRACE_DELETED":
 121          case "LOGLEVEL":
 122          case "DOWNLOAD":
 123          case "INVENTORY_DIFF":
 124          case "INVENTORY_TRANSACTION":
 125              echo "<table><tr><td align='left'><input type='radio' name='$nme' value='ON' ".($val?"checked":"").">ON</td></tr>
 126              <tr><td align='left'><input type='radio' name='$nme' value='OFF' ".($val?"":"checked").">OFF</td></tr></table>";
 127              break;
 128          case "AUTO_DUPLICATE_LVL":
 129              echo "<table><tr><td align='left'><input type='checkbox' name='{$nme}_serial' value='2' ".(in_array($val,array(2,3,6,7))?"checked":"").">Serial</td></tr>
 130              <tr><td align='left'><input type='checkbox' name='{$nme}_host' value='1' ".(in_array($val,array(1,3,5,7))?"checked":"").">hostname</td></tr>
 131              <tr><td align='left'><input type='checkbox' name='{$nme}_mac' value='4' ".(in_array($val,array(4,5,6,7))?"checked":"").">macaddress</td></tr>
 132                      </table>";
 133              break;
 134          case "IPDISCOVER":
 135              echo "<table><tr height='25px'><td width='90px' align='left'><input type='radio' name='$nme' value='ON' ".($val?"checked":"")." OnClick=\"active('{$nme}_div',1);\">ON</td></td><td rowspan='2'>".edit($nme,$val)."</td></tr>
 136              <tr height='25px'><td align='left'><input type='radio' name='$nme' value='OFF' ".($val?"":"checked")." OnClick=\"active('{$nme}_div',0);\">OFF</td></tr></table>";
 137              break;
 138          case "FREQUENCY":
 139              echo "<table><tr><td width='90px'><input ".($val==0?"checked":"")." type='radio' name='$nme' value='ALWAYS' OnClick=\"active('{$nme}_div',0);\">ALWAYS</td><td rowspan='3'>".edit($nme,$val)."</td></tr>
 140              <tr><td><input ".($val==-1?"checked":"")." type='radio' name='$nme' value='NEVER' OnClick=\"active('{$nme}_div',0);\">NEVER</td></tr>
 141              <tr><td><input ".($val>0?"checked":"")." type='radio' name='$nme' value='CUSTOM' OnClick=\"active('{$nme}_div',1);\">CUSTOM</td></tr></table>";            
 142              break;
 143          default:
 144              echo edit($nme,$val);
 145              break;
 146      }
 147  }
 148  
 149  function edit($nme, $val) {
 150      $enabled = true;
 151      $valInit = $val;
 152      if( $nme == "FREQUENCY" && $val < 1 ) {
 153          $enabled = false;
 154          $valInit = 1;
 155      }
 156      else if( $nme == "IPDISCOVER" && $val <= 0 )
 157          $enabled = false;
 158          
 159      return "<div id='{$nme}_div' style='display:".($enabled?"block":"none")."'><table><tr><td rowspan='2'><input type='text' size='3' maxlength='2' id='{$nme}_edit' name='{$nme}_edit' value='$valInit'></td><td align='center'>
 160      <a href='javascript:void(0);' Onclick=\"modif('{$nme}_edit','1');\"><b><font size='3'>+</font></b></a></td></tr><td align='center'>
 161      <a href='javascript:void(0);' Onclick=\"modif('{$nme}_edit','-1');\"><b><font size='3'>-</font></b></a></td></tr></table></div>";
 162  }
 163  
 164  function setOpt($nme, $ivalue) {
 165      mysql_query("UPDATE config SET IVALUE=$ivalue WHERE name='$nme'", $_SESSION["writeServer"]) or die(mysql_error());
 166  }


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