[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/var/www/se3/registre/ -> testreg.php (source)

   1  <?php
   2  
   3  /**
   4  
   5   * Test les restictions sur les clients windows en fonction du nom et de la machine
   6   * @Version $Id: testreg.php 2949 2008-05-04 18:45:49Z plouf $ 
   7  
   8   * @Projet LCS / SambaEdu 
   9  
  10   * @auteurs Sandrine Dangreville
  11  
  12   * @Licence Distribue selon les termes de la licence GPL
  13  
  14   * @note 
  15   */
  16  /**
  17   * @Repertoire: registre
  18   * file: testreg.php
  19   */
  20  include  "entete.inc.php";
  21  include  "ldap.inc.php";
  22  include  "ihm.inc.php";
  23  require  "include.inc.php";
  24  
  25  require_once  ("lang.inc.php");
  26  bindtextdomain('se3-registre', "/var/www/se3/locale");
  27  textdomain('se3-registre');
  28  
  29  foreach ($_GET as $key => $valeur)
  30      $$key = $valeur;
  31  
  32  
  33  connexion();
  34  if (test_bdd_registre() == false) {
  35      exit;
  36  }
  37  if (is_admin("computers_is_admin", $login) == "Y") {
  38  
  39      //aide
  40      $_SESSION["pageaide"] = "Gestion_des_clients_windowsNG#Test_des_restrictions";
  41  
  42      echo "<H1>" . gettext("Simulation de cl&#233s de registre appliqu&#233es") . "</H1>\n";
  43  
  44      if (!isset($tstlogin)) {
  45          echo "<FORM>\n";
  46          echo "<TABLE BORDER=0>\n";
  47          echo "<TR><TD>" . gettext("Nom d'utilisateur") . "</TD><TD><INPUT TYPE=text NAME=tstlogin></TD></TR>\n";
  48          echo "<TR><TD>" . gettext("Nom de l'ordinateur") . "</TD><TD><INPUT TYPE=text NAME=tstnetbios></TD></TR>\n";
  49          echo "</TABLE><INPUT TYPE=submit VALUE=\"" . gettext("Lancer le test") . "\"></FORM>\n";
  50      } else {
  51          // Affichage des groupes d'appartenance d'un utilisateur
  52          $templates = array();
  53          array_push($templates, trim($tstlogin));
  54          array_push($templates, trim($tstnetbios));
  55          list($user, $groups) = people_get_variables($tstlogin, true);
  56          echo "<H3>" . $user["fullname"] . "</H3>\n";
  57          if ($user["description"])
  58              echo "<p>" . $user["description"] . "</p>";
  59          if (count($groups)) {
  60              echo "<U>" . gettext("Membre des groupes") . "</U> :<BR><UL>\n";
  61              for ($loop = 0; $loop < count($groups); $loop++) {
  62                  if ($groups[$loop]["cn"]) {
  63                      $test = $groups[$loop]["cn"];
  64                      $query = "select groupe from restrictions where groupe='$test' group by groupe ;";
  65                      $resultat = mysql_query($query);
  66                      if (mysql_num_rows($resultat)) {
  67                          echo $groups[$loop]["cn"] . "<BR>\n";
  68                          array_push($templates, $test);
  69                      } else {
  70                          echo $groups[$loop]["cn"] . " ( " . gettext("pas de template d&#233fini pour ce groupe") . ") <BR>\n";
  71                      }
  72                  }
  73              }
  74              echo "</UL>\n";
  75          }
  76          // Affichage des parcs d'appartenance de la machine
  77          $parcs = search_parcs($tstnetbios);
  78          if (isset($parcs)) {
  79              echo "<U>" . gettext("La machine est dans les Parcs") . "</U> :<BR><UL>\n";
  80              foreach ($parcs as $test) {
  81                      $query = "select groupe from restrictions where groupe=\"".$test['cn']."\" group by groupe ;";
  82                      $resultat = mysql_query($query);
  83                      if (mysql_num_rows($resultat)) {
  84                          echo $test['cn'] . "<BR>\n";
  85                          array_push($templates, $test['cn']);
  86                      } else {
  87                          echo $test['cn'] . " (" . gettext("pas de template d&#233fini pour ce parc") . ") <BR>\n";
  88                      }
  89                  
  90              }
  91              echo "</UL>\n";
  92          }
  93          array_push($templates, "base");
  94          array_push($templates, "imposees");
  95          $templ = gettemplates($templates);
  96          foreach ($templ[0] as $key => $value) {
  97              $templates2[] = $key;
  98          }
  99      }
 100  }
 101  
 102  if ($test) {
 103      echo"<h3>" . gettext("R&#233sultat du test") . "</h3>";
 104      affichelistecat("testreg.php?tstlogin=$tstlogin&tstnetbios=$tstnetbios", $testniveau, $cat);
 105  
 106      if (($cat) and !($cat == "tout")) {
 107          $ajout = " and corresp.categorie = '$cat'";
 108          if ($sscat) {
 109              $ajoutsscat = " AND corresp.sscat='$sscat'";
 110              echo "<h3>" . gettext("Sous-cat&#233gorie :") . " $sscat</h3>";
 111          } else {
 112              $ajoutsscat = "";
 113          }
 114  
 115          if (($testniveau == 2) and !($sscat)) {
 116              $ajoutpasaffiche = " and corresp.sscat= '' ";
 117          }
 118      } else {
 119          echo gettext("Choisissez une cat&#233gorie ci-dessus");
 120      }
 121      if ($cat == "tout") {
 122          $ajout = "";
 123          if ($sscat) {
 124              $ajoutsscat = "";
 125          }
 126          $ajoutpasaffiche = "";
 127      }
 128      $query = "Select Intitule,corresp.CleID,corresp.valeur,corresp.genre,corresp.OS,corresp.antidote,corresp.type,corresp.chemin,restrictions.valeur,restrictions.groupe,restrictions.priorite
 129              from corresp,restrictions 
 130              where corresp.CleID = restrictions.cleID " . $ajout . $ajoutsscatvide . $ajoutsscat . " and ( ";
 131      for ($i = 0; $i < count($templates2); $i++) {
 132          $query.="restrictions.groupe  = '" . $templates2[$i] . "' ";
 133          if ($i < (count($templates2) - 1)) {
 134              $query.="or ";
 135          }
 136      }
 137      $query.=") GROUP BY CleID,restrictions.valeur ORDER BY priorite,groupe,genre,restrictions.valeur DESC,Intitule ASC";
 138      $resultat = mysql_query($query);
 139      if (mysql_num_rows($resultat)) {
 140          echo "<table border=\"1\"><tr>
 141                 <td><img src=\"/elements/images/system-help.png\" alt=\"" . gettext("Aide") . "\" title=\"" . gettext("Aide") . "\" width=\"16\" height=\"18\" border=\"0\" /></td>
 142                 <td>" . gettext("Template") . "</td>
 143                 <td>" . gettext("Intitul&#233") . "</td>
 144                 <td>" . gettext("Valeur") . "</td>
 145                 <td>" . gettext("Etat") . "</td>
 146                 <td><img src=\"/elements/images/edittrash.png\" alt=\"Supprimer\" title=\"" . gettext("Supprimer") . "\" width=\"15\" height=\"15\" border=\"0\"></td>
 147                 </tr>";
 148          while ($row = mysql_fetch_array($resultat)) {
 149              //bouton aide
 150              echo "<tr><td><a href=\"#\" onClick=\"window.open('aide_cle.php?cle=$row[1]','aide','scrollbars=yes,width=600,height=620')\">\n";
 151              echo "<img src=\"/elements/images/system-help.png\" alt=\"aide\" title=\"$row[7]\" width=\"15\" height=\"15\" border=\"0\"></a></td>\n";
 152              echo "<td><DIV ALIGN=CENTER>" . htmlentities($row[9]) . "</DIV></td>\n";
 153              echo "<td><DIV ALIGN=CENTER>" . htmlentities($row[0]) . "</DIV></td>\n";
 154              echo "<td><DIV ALIGN=CENTER>" . htmlentities($row[2]) . "</DIV></td>\n";
 155              $act = False;
 156              if ($row['type'] == "config") {
 157                  $state = 1;
 158                  echo "<td BGCOLOR=#a5d6ff><DIV ALIGN=CENTER>
 159                      <a href=\"#\" onClick=\"window.open('edit_cle.php?cle=$row[1]&template=$row[9]&state=$state','Editer','scrollbars=no,width=400,height=200')\">" . htmlentities($row[8]) . "</a></DIV></td>";
 160              } elseif ($row['type'] == "restrict") {
 161                  if ($row[8] == $row[5]) {
 162                      echo "<td BGCOLOR=#e0dfde><DIV ALIGN=CENTER>
 163                              <a href=\"#\" onClick=\"window.open('edit_cle.php?cle=$row[1]&template=$row[9]&state=0&choix=Active&value=$row[2]','Editer','scrollbars=no,width=400,height=200')\">
 164                              Inactive</a></DIV></td>";
 165                  } elseif ($row[8] == $row[2]) {
 166                      echo "<td BGCOLOR=#a5d6ff><DIV ALIGN=CENTER>
 167                          <a href=\"#\" onClick=\"window.open('edit_cle.php?cle=$row[1]&template=$row[9]&state=1&choix=Inactive&antidote=$row[5]','Editer','scrollbars=no,width=400,height=200')\">            
 168                          Active</a></DIV></td>";
 169                  } else {
 170                      echo "<td><DIV ALIGN=CENTER>Non configur&eacute;e</DIV></td>";
 171                      $state = -1;
 172                  }
 173              }
 174              echo "<td><DIV ALIGN=CENTER><a href=\"#\" onClick=\"window.open('edit_cle.php?cle=$row[1]&template=$row[9]&choix=del','Supprimer','scrollbars=yes,width=600,height=620')\">\n";
 175              echo "<img src=\"/elements/images/edittrash.png\" alt=\"Supprimer\" title=\"$row[7]\" width=\"15\" height=\"15\" border=\"0\"></a></DIV></td>\n";
 176          }
 177          echo "</table>";
 178      } else {
 179          echo gettext("Aucune entr&#233e trouv&#233e, pour utiliser cette fonctionnalit&#233 vous devez inscrire un template dans le menu 'Attribution des cl&#233s'");
 180      }
 181  }
 182  
 183  include ("pdp.inc.php");
 184  ?>


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