[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/var/www/se3/parcs/ -> show_parc.php (source)

   1  <?php
   2  
   3  
   4     /**
   5     
   6     * affiche les parcs et le contenu
   7     * @Version $Id: show_parc.php 8559 2015-03-15 13:08:23Z plouf $ 
   8     
   9     * @Projet LCS / SambaEdu 
  10     
  11     * @auteurs Equipe Tice academie de Caen
  12     * @auteurs jLCF >:> jean-luc.chretien@tice.ac-caen.fr
  13     * @auteurs oluve olivier.le_monnier@crdp.ac-caen.fr
  14     * @auteurs wawa  olivier.lecluse@crdp.ac-caen.fr
  15     * @auteurs plouf
  16  
  17     * @Licence Distribue selon les termes de la licence GPL
  18     
  19     * @note 
  20     
  21     */
  22  
  23     /**
  24  
  25     * @Repertoire: parcs/
  26     * file: show_parc.php
  27     */        
  28  
  29  
  30                          
  31  
  32  
  33  include  "entete.inc.php";
  34  include  "ldap.inc.php";
  35  include  "ihm.inc.php";
  36  include  "printers.inc.php";
  37  require_once ("fonc_outils.inc.php");
  38  
  39  
  40  
  41  
  42  // Traduction
  43  require_once  ("lang.inc.php");
  44  bindtextdomain('se3-parcs',"/var/www/se3/locale");
  45  textdomain ('se3-parcs');
  46  
  47  $parc=isset($_POST['parc']) ? $_POST['parc'] : (isset($_GET['parc']) ? $_GET['parc'] : "");
  48  $parcs=isset($_POST['parcs']) ? $_POST['parcs'] : "";
  49  $mpenc=isset($_POST['mpenc']) ? $_POST['mpenc'] : "";
  50  $description=isset($_GET['description']) ? $_GET['description'] : "";
  51  $entree=isset($_GET['entree']) ? $_GET['entree'] : "";
  52  
  53  //aide
  54  $_SESSION["pageaide"]="Gestion_des_parcs";
  55  
  56  
  57  
  58  if (is_admin("computers_is_admin",$login)=="Y") {
  59  
  60      //titre
  61      echo "<h1>".gettext("Liste des parcs")."</h1>";
  62      
  63      if ($description=="0") {
  64          modif_description_parc ($parc,$entree);
  65          // On relance le script pour italc
  66          exec ("/usr/bin/sudo /usr/share/se3/scripts/italc_generate.sh");
  67      }
  68          
  69      echo "<h3>".gettext("S&#233;lectionnez un parc:")."</h3>";
  70      $list_parcs=search_machines("objectclass=groupOfNames","parcs");
  71      if ( count($list_parcs)>0) {
  72          sort($list_parcs);
  73          echo "<FORM method=\"post\" action=\"show_parc.php\">\n";
  74          echo "<SELECT NAME=\"parc\" SIZE=\"1\" onchange=submit()>";
  75          echo "<option value=\"\">S&#233;lectionner</option>";
  76          for ($loop=0; $loop < count($list_parcs); $loop++) {
  77              echo "<option value=\"".$list_parcs[$loop]["cn"]."\"";
  78              if ($parc==$list_parcs[$loop]["cn"]) { echo " selected"; }
  79              echo ">".$list_parcs[$loop]["cn"]."\n";
  80              echo "</option>";
  81          }
  82          echo "</SELECT>&nbsp;&nbsp;\n";
  83  
  84          echo "</FORM>\n";
  85      } else {
  86          echo "<center>";
  87          echo "Il n'existe encore aucun parc";
  88          echo "</center>";
  89          exit;
  90      }        
  91  
  92      // Test si le parc possede un template
  93      
  94      
  95      
  96      
  97      
  98      
  99      
 100      
 101  
 102      // Lecture des membres du parc
 103       $mp_all=gof_members($parc,"parcs",1);
 104      if ((!isset($filtrecomp))||("$filtrecomp"=="")) {$mp=$mp_all;}
 105      
 106      
 107      // Recherche de l'impra=imante par defaut
 108      $imprim_defaut = get_default_printer($parc);
 109              
 110      $nombre_machine=count($mp);
 111  
 112      /*************************************************************************/
 113      echo "<script language='javascript' type='text/javascript'>
 114          
 115          /**
 116  
 117          * Coche des boutons radio pour selection
 118          * @language Javascript    
 119          * @Parametres
 120          * @Return
 121          */
 122  
 123  		function coche_delete(mode,statut){
 124              for(k=0;k<$nombre_machine;k++){
 125                   if(document.getElementById(mode+'_'+k)){
 126                          document.getElementById(mode+'_'+k).checked=statut;
 127                          document.getElementById('del_'+k).checked=statut;
 128                   }
 129              }
 130          }
 131          
 132          
 133          /**
 134  
 135          * Coche des boutons radio pour selection de machine
 136          * @language Javascript
 137          * @Parametres
 138          * @Return
 139          */
 140  
 141  		function coche_machine(mode,statut){
 142               if(document.getElementById(mode)){
 143                         document.getElementById(mode).checked=statut;
 144               }
 145          }
 146      </script>\n";
 147      /*************************************************************************/
 148  
 149      if ( count($mp)>15) $size=15; else $size=count($mp);
 150      if ( count($mp)>0) {
 151          sort($mp);
 152          //    echo "<p>".gettext("Liste des machines dans le parc :")." (".count($mp).")</p>\n";
 153          echo "<center>\n";
 154          echo "<script type=\"text/javascript\" src=\"js/jquery.js\"></script>";
 155          echo "<script type=\"text/javascript\" src=\"js/interface.js\"></script>";
 156  ?>
 157  <script type="text/javascript">
 158      
 159      $(document).ready(
 160          function()
 161          {
 162              $('#dock').Fisheye(
 163                  {
 164                      maxWidth: 40,
 165                      items: 'a',
 166                      itemsText: 'span',
 167                      container: '.dock-container',
 168                      itemWidth: 40,
 169                      proximity: 50,
 170                      alignment : 'left',
 171                      halign : 'center'
 172                  }
 173              )
 174          }
 175      );
 176  
 177  </script>
 178  <?php
 179  
 180      
 181      
 182          echo "<div class=\"dock\" id=\"dock\">";
 183          echo "<div class=\"dock-container\">";
 184          echo "<a class=\"dock-item\" href=\"create_parc.php?parc=$parc\"><span>Ajouter une machine</span><img src=\"../elements/images/computer_large.png\" alt=\"Machine\" /></a>";
 185          echo "<a class=\"dock-item\" href=\"../printers/add_printer.php?parc=$parc&amp;list_parc=1\"><span>Ajouter une imprimante</span><img src=\"../elements/images/printer_large.png\" alt=\"Imprimante\" /></a>";
 186          echo "<a class=\"dock-item\" href=\"../parcs/wolstop_station.php?parc=$parc&amp;action=timing\"><span>Programmer l'arr&#234;t et l'allumage des machines</span><img src=\"../elements/images/xclock.png\" alt=\"Programmer\" /></a>";
 187          echo "<a class=\"dock-item\" href=\"../parcs/action_parc.php?parc=$parc\"><span>Action sur les machines</span><img src=\"../elements/images/system-run.png\" alt=\"Action\" /></a>";
 188  
 189          // Template 
 190          if(!file_exists("/home/templates/$parc")){
 191              echo "<a class=\"dock-item\" href=\"../parcs/create_parc.php?parc[]=$parc&amp;creationdossiertemplate=oui\"><span>Cr&#233;er le template pour ce parc</span><img src=\"../elements/images/folder-development.png\" alt=\"Template\" /></a>";
 192          } else {
 193              echo "<a class=\"dock-item\" href=\"../registre/affiche_restrictions.php?salles=$parc\"><span>G&#233;rer le template</span><img src=\"../elements/images/preferences-desktop-cryptography.png\" alt=\"Restrictions\" /></a>";
 194          }
 195  
 196          echo "<a class=\"dock-item\" href=\"../popup/index.php?parc=$parc\"><span>Envoyer un popup aux machines connect&#233;es</span><img src=\"../elements/images/konversation.png\" alt=\"Popup\" /></a>";
 197          echo "<a class=\"dock-item\" href=\"../parcs/delegate_parc.php?action=new&amp;salles=$parc\"><span>D&#233;l&#233;guer ce parc</span><img src=\"../elements/images/list-add-user.png\" alt=\"Deleguer\" /></a>";
 198  
 199          // Nomme une machine prof pour italc
 200          $parse=exec("cat /var/se3/unattended/install/wpkg/packages.xml | grep italc > /dev/null && echo 1");
 201          if($parse==1) {
 202              echo "&nbsp;&nbsp;&nbsp;";
 203              if ($description=="1") {
 204                  $description_prof="0";
 205              } else {
 206                  $description_prof="1";
 207              }    
 208              echo "<a class=\"dock-item\" href=\"../parcs/show_parc.php?parc=$parc&amp;description=$description_prof\"><span>Choisir la machine professeur</span><img src=\"../elements/images/preferences-desktop-user-password.png\" alt=\"italc\" /></a>";
 209          }
 210          echo "</div> ";
 211          echo "</div><br/><br/>";
 212      
 213          echo "<FORM action=\"delete_parc.php\" method=\"post\">\n";
 214          echo "<input type=\"hidden\" name=\"parc\" value=\"$parc\">\n";
 215          echo "<input type=\"hidden\" name=\"delparc\" value=\"0\">\n";
 216              
 217          echo "<input type=\"hidden\" name=\"delete_parc\" value=\"true\">\n";
 218  
 219          $module_clonage_actif="n";
 220          $sql="select 1=1 from params where name='clonage' AND value='1';";
 221          $test_clonage=mysql_query($sql);
 222          if(mysql_num_rows($test_clonage)>0) {
 223              $module_clonage_actif="y";
 224          }
 225  
 226          //echo "<TABLE border=1>";
 227                  echo "<TABLE border=1 width=\"60%\">\n<tr class=menuheader style=\"height: 30\">\n";
 228          
 229          if ($description=="1") {
 230              echo "Cliquer sur <img style=\"border: 0px solid ;\" width=\"20\" height=\"20\" src=\"../elements/images/notify.gif\" title=\"Choisir la machine professeur\"> pour choisir une  machine comme machine professeur";
 231              echo "<br>ou recliquer sur le menu pour ne plus en avoir";
 232              echo "<br><br>";
 233          }
 234  
 235          echo "<tr><td class='menuheader' align=\"center\"><img src='../elements/images/computer_ocs.png'></td>";
 236          echo "<td class='menuheader' align=\"center\">".gettext("Stations")."</td>";
 237                  echo "<td class='menuheader' align=\"center\">".gettext("Adresse IP")."</td>";
 238                  echo "<td class='menuheader' align=\"center\">".gettext("Derni&#232;re connexion")."</td>";
 239  
 240                  if($module_clonage_actif=='y') {
 241                      echo "<td class='menuheader' align=\"center\">".gettext("Dernier rapport TFTP")."</td>";
 242                  }
 243  
 244                  echo "<td class='menuheader' align=\"center\">".gettext("Supprimer du parc")."<br><a href=\"javascript:coche_delete('del',true)\">";
 245              echo "<img src='../elements/images/enabled.png' alt='Cocher tout' title='Cocher tout' border='0' /></a>";
 246              echo " / \n";
 247              echo "<a href=\"javascript:coche_delete('del',false)\">";
 248              echo "<img src='../elements/images/disabled.gif' alt='D&#233;cocher tout' title='D&#233;cocher tout' border='0' /></a>\n";
 249          echo "</td>";
 250                  echo "<td class='menuheader' align=\"center\">".gettext("Supprimer compl&#232;tement")."<br>";
 251                  echo "<a href=\"javascript:coche_delete('sup',true)\">";
 252              echo "<img src='../elements/images/enabled.png' alt='Cocher tout' title='Cocher tout' border='0' /></a>";
 253              echo " / \n";
 254              echo "<a href=\"javascript:coche_delete('sup',false)\">";
 255              echo "<img src='../elements/images/disabled.gif' alt='D&#233;cocher tout' title='D&#233;cocher tout' border='0' /></a>\n";
 256                  echo "</td></tr>\n";
 257  
 258  //                echo "<tr><td class='menuheader' align=\"center\"></td>";
 259  //        echo "<td class='menuheader' align=\"center\"></td>";
 260  //        echo "<td class='menuheader' align=\"center\"></td>";
 261  //        echo "<td class='menuheader' align=\"center\"></td>";
 262  //        echo "<td class='menuheader' align=\"center\">";
 263  //
 264  //
 265  //        echo "<td class='menuheader' align=\"center\">";
 266  //
 267  //        echo "</td></tr>\n";
 268  
 269          // Test la machine prof pour italc
 270          $machine_prof=search_description_parc("$parc");
 271                  $tableau_printer = "<br>";
 272                  $tableau_printer .= "\n<br>\n<CENTER>\n";
 273  
 274                  $tableau_printer .=  "<TABLE border=1 width=\"60%\">\n<tr class=menuheader style=\"height: 30\">\n";
 275          $tableau_printer .=  "<tr class='menuheader'>\n";
 276          $tableau_printer .=  "<td class='menuheader'></td>\n";
 277          $tableau_printer .=  "<td class='menuheader' align=\"center\">Imprimantes</td>\n";
 278          $tableau_printer .=  "<td class='menuheader' align=\"center\">Adresse IP</td>\n";
 279                  $tableau_printer .=  "<td class='menuheader' align=\"center\">".gettext("Supprimer du parc")."</td>\n";
 280                  $tableau_printer .=  "<td class='menuheader' align=\"center\">".gettext("Supprimer compl&#232;tement")."</td>\n";
 281                  $tableau_printer .=  "<td class='menuheader' align=\"center\">".gettext("Par d&#233;faut")."</td>";
 282          $tableau_printer .=  "</tr>\n";
 283  
 284          $suisje_printer="0";
 285  
 286          for ($loop=0; $loop < count($mp); $loop++) {
 287          
 288              $mpenc=urlencode($mp[$loop]);
 289  
 290              
 291              // Test si on a une imprimante ou une machine
 292              $resultat=search_imprimantes("printer-name=$mpenc","printers");
 293              $suisje_printer="non";
 294              for ($loopp=0; $loopp < count($resultat); $loopp++) {
 295                  if ($mpenc==$resultat[$loopp]['printer-name']) {
 296                      $suisje_printer="yes";
 297                                          $printer_in_parc++;
 298                                          $uri_printer = $resultat[$loopp]['printer-uri'];
 299                      continue;
 300                  }    
 301              }
 302              if (file_exists ("/var/www/se3/includes/dbconfig.inc.php")) {
 303                  include_once "fonc_parc.inc.php";
 304                  $sessid=session_id();
 305                              $systemid=avoir_systemid($mpenc);
 306              }
 307              else {
 308                  $inventaire=0;
 309              }
 310              if ($suisje_printer=="yes") {
 311                  //$uri_printer = $resultat[$loopp]['printer-uri'];
 312                                  
 313                                  if (preg_match("/socket:\/\//", $uri_printer)) {
 314                                      $uri_printer_modif = preg_replace("/socket:\/\//", "", $uri_printer);
 315                                      $printer_ip = explode(":", $uri_printer_modif);
 316                                     // echo $uri_printer;
 317                                     $printer_ip = $printer_ip[0];
 318                                  }
 319                                  else {
 320                                  $printer_ip="none";
 321                                  }
 322                                  // completion tableau par les donnees recuperees
 323                                  $tableau_printer .= "<tr>";
 324                  $tableau_printer .= "<td><img style=\"border: 0px solid ;\" src=\"../elements/images/printer.png\" title=\"Imprimante\" alt=\"Imprimante\" WIDTH=20 HEIGHT=20 ></td>";
 325                                  $tableau_printer .= "<td align=\"center\"><A href='../printers/view_printers.php?one_printer=$mpenc'>$mp[$loop]</A></td>\n";
 326                  $tableau_printer .= "<td align=\"center\">$printer_ip</td>";
 327                                  $tableau_printer .= "<td align=\"center\"><INPUT type=\"checkbox\" name=\"old_computers[]\" id=\"del_$loop\"  value=\"$mpenc\"></td>";
 328                                  $tableau_printer .= "<td align=\"center\"><INPUT type=\"checkbox\" name=\"supprime_all[]\" id=\"sup_$loop\"  value=\"$mpenc\" onClick=\"coche_machine('del_$loop',true)\"></td>\n";
 329                                  $tableau_printer .= "<td align=\"center\">";
 330                                  
 331                                  if ($imprim_defaut == $mp[$loop]) {
 332                                      $tableau_printer .= "<img style=\"border: 0px solid ;\" src=\"../elements/images/enabled.png\" title=\"par defaut\" alt=\"par defaut\" >";
 333                                  }
 334                                  
 335                                  $tableau_printer .= "</td>\n";
 336                                  $tableau_printer .= "</tr>";
 337              } else {
 338                                  echo "<tr>";
 339                  if($inventaire=="1") {
 340                                  // Type d'icone en fonction de l'OS
 341                                  $retourOs = type_os($mpenc);
 342                                  if($retourOs == "0") { $icone="computer_disable.png"; }
 343                                  elseif($retourOs == "Linux") { $icone="linux.png"; }
 344                                  elseif($retourOs == "XP") { $icone="winxp.png"; }
 345                                  elseif($retourOs == "7") { $icone="win7.png"; }
 346                                  elseif($retourOs == "98") { $icone="win.png"; }
 347                                  else { $icone="computer_disable.png"; }
 348                      $ip=avoir_ip($mpenc);
 349                      echo "<td><img style=\"border: 0px solid ;\" src=\"../elements/images/$icone\" title=\"".$retourOs." - ".$ip."\" alt=\"$retourOs\" WIDTH=20 HEIGHT=20 onclick=\"popuprecherche('../ocsreports/machine.php?sessid=$sessid&systemid=$systemid','popuprecherche','scrollbars=yes,width=500,height=500');\">";
 350                  }
 351                  else
 352                      echo "<td><img style=\"border: 0px solid ;\" src=\"../elements/images/computer.png\" alt=\"Ordinateur\" WIDTH=20 HEIGHT=20 >";
 353                  
 354                  
 355                  // On selectionne la machine prof
 356                  if ($description=="1") {
 357                      echo "&nbsp;";
 358                      echo "<A HREF=../parcs/show_parc.php?description=0&parc=$parc&entree=$mpenc><img style=\"border: 0px solid ;\" src=\"../elements/images/notify.gif\" title=\"Machine professeur\" alt=\"Cliquer pour choisir cette machine\" ></A></td>";
 359  
 360                  } else {
 361                      // la machine prof est connue    
 362                      if ($machine_prof==$mpenc) {
 363                          echo "&nbsp;";
 364  
 365                          echo "<img style=\"border: 0px solid ;\" src=\"../elements/images/notify.gif\" title=\"Machine professeur\" alt=\"Machine professeur\" ></td>";
 366                      }
 367                  }    
 368                  
 369                  echo "<td align=\"center\"><A href='show_histo.php?selectionne=2&amp;mpenc=$mpenc'>$mp[$loop]</A></td>\n";
 370                  $ip = avoir_ip($mpenc);
 371                  //mysql_close();
 372                  $authlink = mysql_connect($dbhost,$dbuser,$dbpass);
 373                  mysql_select_db($dbname,$authlink) or die("Impossible de se connecter &#224; la base $dbname.");
 374                  $query=" select logintime from connexions where netbios_name='$mpenc' order by id desc limit 1";
 375                  //$query .= $cnx_start;
 376                  //$query .= ",10";
 377                                  $last_cnx[0]="none";
 378                  $result = mysql_query($query) or die ('ERREUR '.$requete.' '.mysql_error());
 379                  if (($result)) {
 380                    while ($r=mysql_fetch_array($result)) {
 381                      $last_cnx_long=$r["logintime"];
 382                      $last_cnx = explode(" ", $last_cnx_long);
 383                      $time_old = mktime(0,0,0,date("m")-1,date("d"),date("Y"));
 384                      
 385                      $time_today= time();
 386                      //$date_today= date("Ymd",mktime(0,0,0,date("m")-1,date("d"),date("Y")));
 387                      $time_last_cnx_array = explode("-", $last_cnx_long);
 388                      $time_last_cnx_array2 = explode(" ", $last_cnx_long[2]);
 389                      //echo "\$time_last_cnx_array[1]=$time_last_cnx_array[1]<br />";
 390                      //echo "\$time_last_cnx_array[2]=$time_last_cnx_array[2]<br />";
 391                      //echo "\$time_last_cnx_array[0]=$time_last_cnx_array[0]<br />";
 392                      //$time_last_cnx = mktime(0,0,0,$time_last_cnx_array[1],$time_last_cnx_array[2],$time_last_cnx_array[0]);
 393                      $time_last_cnx = mktime(0,0,0,$time_last_cnx_array[1],$time_last_cnx_array2[0],$time_last_cnx_array[0]);
 394                      
 395                    }
 396                  } else echo gettext("erreur lors de la lecture de la base se3");
 397                  
 398              echo "<td align=\"center\">$ip</td>\n";
 399              if  ($time_last_cnx<$time_old) {
 400                  echo "<td align=\"center\"><STRONG><FONT color='red'>$last_cnx[0]</FONT></STRONG></td>\n";
 401                  }
 402              else    {
 403                  echo "<td align=\"center\">$last_cnx[0]</td>\n";
 404                  }
 405  
 406                  if($module_clonage_actif=='y') {
 407                      $sql="SELECT * FROM se3_tftp_rapports WHERE name='".$mp[$loop]."' ORDER BY date DESC LIMIT 1;";
 408                      $res_rapport_tftp=mysql_query($sql);
 409                      if(mysql_num_rows($res_rapport_tftp)>0) {
 410                          $lig=mysql_fetch_object($res_rapport_tftp);
 411                          echo "<td align=\"center\">";
 412                          echo "<span style='font-size: x-small;' title='Dernier rapport: $lig->tache ($lig->statut)'><a href=\"../tftp/visu_rapport.php?id_machine=$lig->id\" target='_blank'>".$lig->date."</a></span>\n";
 413                          $st="$lig->statut";
 414                          if($st=="SUCCES") {
 415                              $cl="green";
 416                              } else {
 417                              $cl="red";
 418                          }
 419                          echo "<FONT color=$cl size=1>"."$lig->statut"."</font>";
 420                          echo "</td>\n";
 421                      }
 422                      else {
 423                          echo "<td align=\"center\" style='color:purple'>".gettext("Aucun rapport")."</td>\n";
 424                      }
 425                  }
 426  
 427              echo "<td align=\"center\"><INPUT type=\"checkbox\" name=\"old_computers[]\" id=\"del_$loop\"  value=\"$mpenc\">";
 428              echo "</td>\n";
 429  
 430              echo "<td align=\"center\"><INPUT type=\"checkbox\" name=\"supprime_all[]\" id=\"sup_$loop\"  value=\"$mpenc\" onClick=\"coche_machine('del_$loop',true)\"></td>\n";
 431              echo "</tr>";
 432              }
 433              
 434              //    echo " $ip";
 435              
 436              
 437              
 438          }
 439          echo "</TABLE>\n";
 440  
 441                  $tableau_printer .=  "</table></center>";
 442          if (isset($printer_in_parc)) {
 443                      echo $tableau_printer;
 444                      echo "<br>";
 445                      $nb_machines = count($mp)-$printer_in_parc;
 446                      echo "<h3>".$nb_machines." station(s) et "."$printer_in_parc"." imprimante(s) ".gettext("dans le parc ")."$parc</h3>";
 447                  }
 448                  else {
 449  
 450                      echo "<h3>".count($mp)." station(s) dans le parc "."$parc</h3>";
 451                  }
 452                  
 453                  
 454                  echo "<input type=\"submit\" value=\"".gettext("Valider")."\">\n";
 455          echo "</FORM>\n";
 456          echo "</center>";
 457      } else {
 458          if ($parc!="") {
 459              echo "<br>";
 460              $message =  gettext("Il n'y a pas de machines dans ce parc &#224; afficher !");
 461              echo $message;
 462          }    
 463      }
 464  }  
 465  
 466  include ("pdp.inc.php");
 467  ?>


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