[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-ocs/sources/www/ -> reqRegistre.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 10/8/2005 Didier Liroulet
  12  require  ('fichierConf.class.php');
  13  
  14  if( ! $_GET["multi"] )
  15  {
  16      include ('req.class.php');
  17      include ('preferences.php');    
  18  }
  19  
  20  switch ($_GET["typeDemande"]) :
  21      
  22      case "ajout" : formulaire("","","","","");
  23                          break;
  24      case "modif" : modifier();
  25                          break;
  26      case "suppr" : supprimer();
  27                          break;
  28      case "enreModif"  : enregistrer();    
  29                          break;
  30      case "enreAjout"  : enregistrer();
  31                          break;                    
  32      default :
  33          
  34          if($_GET["id"])
  35              mysql_query("delete from regconfig where id='".$_GET["id"]."'", $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));
  36              
  37          echo "&nbsp;";
  38          $lbl=$l->g(2);        //Nom de la requete    
  39      
  40      $sql = "";
  41      $whereId = "id";
  42      $linkId = "id";
  43      $select = array("name"=>"name" ,"regtree"=>"regtree", "regkey"=>"regkey", "regvalue"=>"regvalue");    
  44      $selectPrelim = array( "id"=>"id" );
  45      $from = "regconfig";
  46      $fromPrelim = "";
  47      $group = "";
  48      $order = "";
  49      $countId = "id";
  50      
  51      $req=new Req($lbl,$whereId,$linkId,$sql,$select,$selectPrelim,$from,$fromPrelim,$group,$order,$countId);
  52      
  53      printEnTete($requete->label);
  54      ShowResults($req,true);
  55          
  56          echo "<br><br><table align='right'><tr><td>";
  57          echo "<input  class='bouton' name='ajout' type='submit' value='".$l->g(116)."' onClick='window.location=\"index.php?multi=5&typeDemande=ajout\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  58          echo "<input  class='bouton' name='modif' type='submit' value='".$l->g(115)."' onClick='window.location=\"index.php?multi=5&typeDemande=modif\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  59          echo "<input  class='bouton' name='suppr' type='submit' value='".$l->g(122)."' onClick='window.location=\"index.php?multi=5&typeDemande=suppr\"'>";
  60          echo "</td></tr></table><br>&nbsp;";
  61              break;
  62      endswitch;
  63  
  64  function formulaire($id,$name,$regtree,$regkey,$regvalue)
  65  {    
  66      global $l;
  67      $readonly = "";
  68      $modif    = "";
  69      $label    = $ajreq;
  70      $demande  = "enreAjout";
  71  
  72      if($_GET["typeDemande"]== "modif") // c'est une modification
  73      {
  74          $label       = $name;
  75          $modif    = 1;
  76          $readonly = "readonly"; // pour qu'on ne puisse pas modifier le ID
  77          $demande  = "enreModif";
  78      }
  79      
  80      $tr =  " <tr><td align='right'><font face=Verdana size=-1>";
  81      //echo   " <center><font face='Arial' color='#330033' size=4><b><center>OCS INVENTORY</center></b></font><hr>";
  82      printEnTete($l->g(108));
  83      echo   "<center><br><form name='ajouter_reg' method='POST' action='index.php?multi=5&typeDemande=$demande'>
  84           <input type='hidden' name='ID' value='".urldecode($id)."'>
  85           <table>
  86           <tr><td align='left'><font face=Verdana size=-1>".$l->g(252)." :</font> </td>
  87           <td><input size=40 name='NAME' value='".urldecode($name)."'></td></tr>
  88           <tr><td align='left'><font face=Verdana size=-1>".$l->g(253)." :</font></td>
  89               <td align='left'><select size='1' name='REGTREE' id='REGTREE'>";
  90      if (urldecode($regtree) == 0)
  91          echo "               <option value='0' selected>HKEY_CLASSES_ROOT</option>";
  92      else
  93          echo "               <option value='0' selected>HKEY_CLASSES_ROOT</option>";
  94      if (urldecode($regtree) == 1)
  95          echo "               <option value='1' selected>HKEY_CURRENT_USER</option>";
  96      else
  97          echo "               <option value='1'>HKEY_CURRENT_USER</option>";
  98      if (urldecode($regtree) == 2)
  99          echo "               <option value='2' selected>HKEY_LOCAL_MACHINE</option>";
 100      else
 101          echo "               <option value='2'>HKEY_LOCAL_MACHINE</option>";
 102      if (urldecode($regtree) == 3)
 103          echo "               <option value='3' selected>HKEY_USERS</option>";
 104      else
 105          echo "               <option value='3'>HKEY_USERS</option>";
 106      if (urldecode($regtree) == 4)
 107          echo "               <option value='4' selected>HKEY_CURRENT_CONFIG</option>";
 108      else
 109          echo "               <option value='4'>HKEY_CURRENT_CONFIG</option>";
 110      if (urldecode($regtree) == 5)
 111          echo "               <option value='5' selected>HKEY_DYN_DATA (Windows 9X only)</option>";
 112      else
 113          echo "               <option value='5'>HKEY_DYN_DATA (Windows 9X only)</option>";
 114      echo     "            </select></td></tr>
 115           <tr><td align='left'><font face=Verdana size=-1>".$l->g(254)." :</font></td>
 116           <td><input size=40 name='REGKEY' value='".urldecode($regkey)."'> </td></tr>             
 117           <tr><td align='left'><font face=Verdana size=-1>".$l->g(255)." :</font>  </td>
 118           <td><input size= 40 name='REGVALUE' value=".urldecode($regvalue)."></td></tr>
 119           </table><br><br>
 120           <table><tr><td>
 121           <input class='bouton' name='enre'    type='submit' value=".$l->g(13)."> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 122           </form>
 123           <input class='bouton' name='annuler' type='submit' value=".$l->g(113)." onClick='window.location=\"index.php?multi=5\"'></td></tr>
 124           <input type='hidden' size=40 name='ID' value='$id'>
 125           </table>";
 126  }
 127  function modifier()
 128  {
 129      global $l;
 130      $tr =  "<tr><td align='right'><font face=Verdana size=-1>";
 131  
 132      if ($_GET["id"]) // on a récupéré le ID de la ligne que l'on veut modifier 
 133      {
 134          $requete = "select ID,NAME,REGTREE,REGKEY,REGVALUE from regconfig where ID='".$_GET["id"]."';";
 135          $result  = mysql_query($requete, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
 136          $item    = mysql_fetch_object($result);
 137          formulaire($item->ID,$item->NAME,$item->REGTREE,$item->REGKEY,$item->REGVALUE);
 138      } 
 139      else // on demande quelle ligne on veut modifier
 140      {    
 141          //echo   "<center><font face='Arial' color='#330033' size=4><b><center>OCS INVENTORY</center></b></font><hr>";
 142          echo   "<center>".$l->g(256)." :<BR><BR><BR>";
 143      
 144          $requete = "SELECT ID,NAME,REGVALUE FROM regconfig";
 145          $result  = mysql_query($requete, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
 146          echo "<table BORDER='0' WIDTH = '55%' ALIGN = 'Center' CELLPADDING='0' BORDERCOLOR='#9894B5'>
 147          <tr BGCOLOR='#C7D9F5'>";    
 148          while($colname = mysql_fetch_field($result))
 149                  echo"<td align='center'><B>$colname->name</td></b>";
 150      
 151          echo "</tr>";
 152              while($item = mysql_fetch_object($result))
 153              {
 154                  echo "<tr><td align='center'><FONT FACE='Verdana' size=2><a href='index.php?multi=5&typeDemande=modif&id=$item->ID'>$item->ID&nbsp;&nbsp;&nbsp;</a></td> 
 155                            <td align='center'>$item->NAME</td></font></tr>";
 156              }
 157              
 158          echo"</table>";
 159          echo "<br><br><r><a align='right' href='index.php?multi=5'>".$l->g(113)."</a>";
 160  
 161  }// fin else
 162  }// fin function
 163  
 164  function enregistrer()
 165  {
 166      if($_GET["typeDemande"]== "enreModif") // enregistrer une modififcation
 167      {
 168          $req = "UPDATE regconfig SET ".    
 169              "NAME='".$_POST["NAME"]."',".
 170              "REGTREE='".$_POST["REGTREE"]."',".
 171              "REGKEY='".$_POST["REGKEY"]."',".
 172              "REGVALUE='".$_POST["REGVALUE"]."' ".
 173              "where ID='".$_POST["ID"]."'";
 174  
 175          $result = mysql_query($req, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));
 176      }    
 177      else // enregistrer un ajout
 178      {    
 179          $req    = "INSERT INTO regconfig VALUES(\"\",\"".$_POST["NAME"]."\",\"".$_POST["REGTREE"]."\",\"".$_POST["REGKEY"]."\",\"".$_POST["REGVALUE"]."\")";
 180          
 181          $result = mysql_query($req, $_SESSION["writeServer"]);
 182      }//fin else
 183      ?>
 184          <script language="javascript">
 185              window.location="index.php?multi=5";
 186          </script>
 187      <?php
 188          return;
 189  }//fin function
 190  
 191  function supprimer()
 192  {
 193      global $l;
 194      
 195      if ($_GET["id"])
 196          { ?>
 197              <script language="javascript">
 198                  if(confirm ("<?echo trim($l->g(119))?><?=$_GET["id"]?> ?")) 
 199                      window.location="index.php?multi=5&id=<?=$_GET["id"]?>";
 200                  else    
 201                      window.location="index.php?multi=5";
 202              </script>
 203              <?php
 204          }
 205      else
 206      {    
 207          //echo   "<center><font face='Arial' color='#330033' size=4><b><center>OCS INVENTORY</center></b></font><hr>";
 208          echo   "<center>sélectionner la requête registre que vous voulez supprimer :<BR><BR><BR>";
 209      
 210          $requete = "SELECT ID,NAME,REGVALUE FROM regconfig";
 211          $result  = mysql_query($requete, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
 212          echo "<table BORDER='0' WIDTH = '55%' ALIGN = 'Center' CELLPADDING='0' BORDERCOLOR='#9894B5'>
 213          <tr BGCOLOR='#C7D9F5'>";    
 214      
 215          while($colname = mysql_fetch_field($result))
 216                  echo"<td align='center'><B>$colname->name</td></b>";
 217      
 218          echo "</tr>";
 219          while($item = mysql_fetch_object($result))
 220          {
 221              echo "<tr><td align='center'><FONT FACE='Verdana' size=2><a href='index.php?multi=5&typeDemande=suppr&id=$item->ID'>$item->ID&nbsp;&nbsp;&nbsp;</a></td> 
 222                        <td align='center'>$item->NAME</td></font></tr>";
 223          }
 224          echo"</table>";
 225          echo "<br><br><r><a align='right' href='index.php?multi=5'>".$l->g(113)."</a>";
 226          
 227      }// fin else    
 228  }// fin supprimer
 229  ?>


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