[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-clonage/sources/www/tftp/ -> visu_svg.php (source)

   1  <?php
   2  /* $Id: visu_svg.php 6411 2011-06-19 09:50:22Z crob $
   3  ===========================================
   4     Projet SE3
   5     Dispositif SE3+TFTP+Sauvegarde/Restauration/Clonage
   6     Stephane Boireau
   7     Distribué selon les termes de la licence GPL
   8  =============================================
   9  */
  10  
  11  // loading libs and init
  12  include  "entete.inc.php";
  13  include  "ldap.inc.php";
  14  include  "ihm.inc.php";
  15  //require_once "../dhcp/dhcpd.inc.php";
  16  include  "printers.inc.php";
  17  
  18  require ("lib_action_tftp.php");
  19  
  20  //aide
  21  $_SESSION["pageaide"]="Le_module_Clonage_des_stations#Programmer_une_sauvegarde";
  22  
  23  // CSS pour mes tableaux:
  24  echo "<link type='text/css' rel='stylesheet' href='tftp.css' />\n";
  25  
  26  if ((is_admin("system_is_admin",$login)=="Y")||(ldap_get_right("parc_can_clone",$login)=="Y"))
  27  {
  28      $id_machine=isset($_POST['id_machine']) ? $_POST['id_machine'] : (isset($_GET['id_machine']) ? $_GET['id_machine'] : NULL);
  29      $suppr=isset($_POST['suppr']) ? $_POST['suppr'] : NULL;
  30  
  31      if(!isset($id_machine)) {
  32          echo "<p style='color:red'>Aucune machine n'est choisie.</p>";
  33          include ("pdp.inc.php");
  34          die();
  35      }
  36  
  37      $restriction_parcs="n";
  38      if(is_admin("system_is_admin",$login)!="Y") {
  39          $restriction_parcs="y";
  40          $tab_delegated_parcs=list_delegated_parcs($login);
  41          if(count($tab_delegated_parcs)==0) {
  42              echo "<p style='color:red'>Aucun parc ne vous a été délégué.</p>\n";
  43              include ("pdp.inc.php");
  44              die();
  45          }
  46  
  47          $temoin_erreur="y";
  48          $nom="";
  49  
  50          $sql="SELECT name FROM se3_dhcp WHERE id='$id_machine';";
  51          $res=mysql_query($sql);
  52          if(mysql_num_rows($res)>0) {
  53              $lig=mysql_fetch_object($res);
  54              $nom=$lig->name;
  55  
  56              for($loop=0;$loop<count($tab_delegated_parcs);$loop++) {
  57                  // La machine est-elle dans un des parcs délégués?
  58                  if(is_machine_in_parc($nom,$tab_delegated_parcs[$loop])) {
  59                      $temoin_erreur='n';
  60                      break;
  61                  }
  62              }
  63          }
  64          if($temoin_erreur=="y") {
  65              echo "<p style='color:red'>La machine $nom n'est pas dans un de vos parcs delegues.</p>\n";
  66              include ("pdp.inc.php");
  67              die();
  68          }
  69  
  70      }
  71  
  72      if(isset($suppr)) {
  73          $chaine="";
  74          for($i=0;$i<count($suppr);$i++) {
  75              $sql="DELETE FROM se3_tftp_sauvegardes WHERE id='$id_machine' AND identifiant='$suppr[$i]';";
  76              $res=mysql_query($sql);
  77              if(!$res) {
  78                  $chaine.="<span style='color:red;'>Erreur lors de la suppression du rapport de sauvegarde n°$suppr[$i].</span><br />\n";
  79              }
  80          }
  81          echo $chaine;
  82      }
  83  
  84      //$sql="SELECT * FROM se3_tftp_action WHERE id='".$id_machine."';";
  85      $sql="SELECT * FROM se3_dhcp WHERE id='".$id_machine."';";
  86      $res=mysql_query($sql);
  87      if(mysql_num_rows($res)>0) {
  88          $lig=mysql_fetch_object($res);
  89          $mac_machine=$lig->mac;
  90          $nom_machine=$lig->name;
  91          echo "<h1>Sauvegarde(s) sur $nom_machine</h1>\n";
  92  
  93          $sql="SELECT * FROM se3_tftp_sauvegardes WHERE id='$id_machine' ORDER BY date DESC;";
  94          $res2=mysql_query($sql);
  95          if(mysql_num_rows($res2)==0) {
  96              echo "<p>Aucune sauvegarde trouvée.</p>\n";
  97          }
  98          else {
  99              echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>\n";
 100              echo "<table class='crob'>\n";
 101              echo "<tr>\n";
 102              echo "<th>Nom</th>\n";
 103              echo "<th>Date</th>\n";
 104              echo "<th>Partition<br />sauvegardée</th>\n";
 105              echo "<th>Image</th>\n";
 106              //echo "<th>Statut</th>\n";
 107              echo "<th>Descriptif</th>\n";
 108              echo "<th>Partitionnement</th>\n";
 109              //echo "<th>Supprimer</th>\n";
 110              echo "<th><input type='submit' name='supprimer' value='Supprimer' /><br />\n";
 111              echo "<a href='#' onclick='check_suppr(\"check\");return false'><img src=\"../elements/images/enabled.gif\" border='0' alt=\"Tout cocher\" title=\"Tout cocher\" /></a>\n";
 112              echo " / <a href='#' onclick='check_suppr(\"uncheck\");return false'><img src=\"../elements/images/disabled.gif\" border='0' alt=\"Tout décocher\" title=\"Tout décocher\" /></a>\n";
 113              echo "</th>\n";
 114              echo "</tr>\n";
 115              $cpt=0;
 116              while($lig2=mysql_fetch_object($res2)) {
 117                  echo "<tr>\n";
 118                  echo "<td>$lig2->name</td>\n";
 119                  echo "<td>".mysql_date_to_fr_date($lig2->date)."</td>\n";
 120                  echo "<td>".$lig2->partition."</td>\n";
 121                  echo "<td>".$lig2->image."</td>\n";
 122                  /*
 123                  echo "<td>\n";
 124                  $tmp=ucfirst(strtolower($lig2->statut));
 125                  if($tmp=="Succes") {
 126                      echo "<span style='color:green;'>Succès</span>";
 127                  }
 128                  elseif($tmp=="Echec") {
 129                      echo "<span style='color:red;'>Echec</span>";
 130                  }
 131                  else{
 132                      echo $tmp;
 133                  }
 134                  echo "</td>\n";
 135                  */
 136                  echo "<td>\n";
 137  
 138                      //echo nl2br(htmlentities($lig2->descriptif));
 139  
 140                      //if(!preg_match("/Infos sur ".$lig2->image."\n/",$lig2->descriptif)){
 141                      if(!mb_ereg("Infos sur ".$lig2->image."\n",$lig2->descriptif)){
 142                          echo nl2br(htmlentities($lig2->descriptif));
 143                      }
 144                      else {
 145                          //echo "<table border='1'>\n";
 146                          echo "<table class='crob' style='margin:1px;'>\n";
 147                          $temoin_infos_image=0;
 148                          $temoin_volume_image=0;
 149                          $temoin_espace_dispo=0;
 150                          $infos_complementaires_svg="";
 151                          $tab_descr=explode("\n",$lig2->descriptif);
 152                          for($i=0;$i<count($tab_descr);$i++){
 153                              //if(preg_match("/^Infos sur ".$lig2->image."$/",$tab_descr[$i])){
 154                              if(mb_ereg("^Infos sur ".$lig2->image."$",$tab_descr[$i])){
 155                                  $temoin_infos_image++;
 156                              }
 157  
 158                              //if(preg_match("/^Volume:$/",$tab_descr[$i])) {
 159                              if(preg_match("/^Volume de la sauvegarde:$/",$tab_descr[$i])) {
 160                                  echo "</td></tr>\n";
 161                                  $temoin_infos_image=-100000;
 162                                  $temoin_volume_image++;
 163                              }
 164  
 165                              if(preg_match("/^Espace total\/occupé\/encore disponible:$/",$tab_descr[$i])) {
 166                                  break;
 167                              }
 168  
 169                              /*
 170                              //if(preg_match("/^___+\*+___$/",$tab_descr[$i])) {
 171                              //if(preg_match("/___+\*+___/",trim($tab_descr[$i]))) {
 172                              //if(preg_match("/^___+/",trim($tab_descr[$i]))) {
 173                              if(preg_match("/^___\+\*\+___$/",trim($tab_descr[$i]))) {
 174                                  echo "</table>\n";
 175                                  //echo "aaaaaaa";
 176                                  echo "</td></tr>\n";
 177                                  $temoin_infos_image=-100000;
 178                                  $temoin_volume_image=-100000;
 179                                  $temoin_espace_dispo++;
 180                              }
 181                              */
 182  
 183                              if($temoin_infos_image==1) {
 184                                  //echo "<tr><th>Infos</th><td colspan='2'>";
 185                                  echo "<tr><th>Infos</th><td>";
 186                                  //echo htmlentities($tab_descr[$i])."<br />\n";
 187                                  $temoin_infos_image++;
 188                              }
 189                              elseif($temoin_infos_image>1) {
 190                                  //echo nl2br(htmlentities($tab_descr[$i]));
 191                                  echo htmlentities($tab_descr[$i])."<br />\n";
 192                                  $temoin_infos_image++;
 193                              }
 194  
 195                              if($temoin_volume_image==1) {
 196                                  //echo "</td></tr>\n";
 197                                  echo "<tr><th>Volume</th><td>";
 198                                  //echo htmlentities($tab_descr[$i])."<br />\n";
 199                                  echo "<table class='crob' style='margin:1px;'>\n";
 200                                  $temoin_volume_image++;
 201                              }
 202                              elseif($temoin_volume_image>1) {
 203                                  //echo nl2br(htmlentities($tab_descr[$i]));
 204                                  //echo htmlentities($tab_descr[$i])."<br />\n";
 205                                  //if(trim($tab_descr[$i])!=""){
 206                                  if(($infos_complementaires_svg=="")&&(trim($tab_descr[$i])!="")) {
 207                                      unset($tab_vol);
 208                                      $tab_vol=explode(" ",preg_replace("/\t/"," ",$tab_descr[$i]));
 209                                      echo "<tr><td>".htmlentities($tab_vol[0])."</td><td>".basename(htmlentities($tab_vol[1]))."</td></tr>\n";
 210                                  }
 211                                  else {
 212                                      $infos_complementaires_svg.=$tab_descr[$i]."\n";
 213                                  }
 214                                  $temoin_volume_image++;
 215                              }
 216  
 217                              /*
 218                              if($temoin_espace_dispo==1) {
 219                                  $temoin_espace_dispo++;
 220                              }
 221                              elseif($temoin_espace_dispo>1) {
 222                                  if(trim($tab_descr[$i])!="") {
 223                                      unset($tab_esp);
 224                                      $tab_esp=explode(" ",preg_replace("/ {2,}/"," ",preg_replace("/\t/"," ",$tab_descr[$i])));
 225                                      echo "<tr><th>V.total partition</th><td>".$tab_esp[1]."</td></tr>\n";
 226                                      echo "<tr><th>V.occupé</th><td>".$tab_esp[2]."</td></tr>\n";
 227                                      echo "<tr><th>V.libre</th><td>".$tab_esp[3]."</td></tr>\n";
 228                                  }
 229                                  $temoin_espace_dispo++;
 230                              }
 231                              */
 232                          }
 233                          if($temoin_volume_image!=0) {
 234                              echo "</table>\n";
 235                              if($infos_complementaires_svg!='') {echo "<pre style='text-align:left;'>$infos_complementaires_svg</pre>";}
 236                          }
 237  
 238                          //echo "";
 239  
 240                          echo "</td></tr>\n";
 241                          if($lig2->df!="") {
 242                              unset($tab_esp);
 243                              $tab_esp=explode(" ",preg_replace("/ {2,}/"," ",preg_replace("/\t/"," ",$lig2->df)));
 244                              echo "<tr><th>V.total partition</th><td>".$tab_esp[1]."</td></tr>\n";
 245                              echo "<tr><th>V.occupé</th><td>".$tab_esp[2]."</td></tr>\n";
 246                              echo "<tr><th>V.libre</th><td>".$tab_esp[3]."</td></tr>\n";
 247                          }
 248                          //echo "</td></tr>\n";
 249                          echo "</table>\n";
 250                      }
 251  
 252                  echo "</td>\n";
 253  
 254                  echo "<td>\n";
 255                  echo "<pre>".htmlentities($lig2->partitionnement)."</pre>";
 256                  echo "</td>\n";
 257  
 258                  echo "<td>\n";
 259                  echo "<input type='checkbox' name='suppr[]' id='suppr_$cpt' value='$lig2->identifiant' />\n";
 260                  //echo  $lig2->identifiant;
 261                  echo "</td>\n";
 262                  echo "</tr>\n";
 263                  $cpt++;
 264              }
 265              echo "</table>\n";
 266              echo "<input type='hidden' name='id_machine' value='$id_machine' />\n";
 267              //echo "<input type='submit' name='supprimer' value='Supprimer' />\n";
 268              echo "</form>\n";
 269  
 270              echo "<script type='text/javascript'>
 271  	function check_suppr(mode) {
 272          for(i=0;i<$cpt;i++){
 273              if(document.getElementById('suppr_'+i)){
 274                  if(mode=='check'){
 275                      document.getElementById('suppr_'+i).checked=true;
 276                  }
 277                  else{
 278                      document.getElementById('suppr_'+i).checked=false;
 279                  }
 280              }
 281          }
 282      }
 283  </script>\n";
 284          }
 285  
 286          echo "<p><i>NOTE:</i></p>
 287  <ul>\n";
 288      //echo "<li>Modifier le traitement sur le descriptif pour extraire/mettre en valeur les infos.</li>\n";
 289      echo "<li>Permettre de supprimer un rapport de sauvegarde: FAIT.<br />
 290      En revanche, rien ne permet actuellement de gérer les doublons.</li>
 291  </ul>\n";
 292      }
 293      else {
 294          echo "<h1>Visualisation de sauvegardes</h1>\n";
 295          echo "<p>ERREUR: Machine $id_machine inconnue dans la table 'se3_dhcp'.</p>\n";
 296      }
 297  }
 298  
 299  // Footer
 300  include ("pdp.inc.php");
 301  
 302  ?>


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