commit 5c3812b29994a6ddc27a2498c3179bb89faa76b8
Author: root <root@anet>
Date:   Fri Aug 19 17:23:59 2011 +0200

    recette 11?08

diff --git a/htdocs/epack/export/checksum b/htdocs/epack/export/checksum
index 2b43d9a..116bb75 100644
Binary files a/htdocs/epack/export/checksum and b/htdocs/epack/export/checksum differ
diff --git a/htdocs/epack/export/checksum.md5 b/htdocs/epack/export/checksum.md5
index c05f43c..5fad238 100644
--- a/htdocs/epack/export/checksum.md5
+++ b/htdocs/epack/export/checksum.md5
@@ -1 +1 @@
-5826d5f26c71610ec0516f7ea3cf4d7d  checksum
+53577fbb5516790cfad56eca3b16241e  checksum
diff --git a/htdocs/epack/recette.php b/htdocs/epack/recette.php
index c11e07c..190b983 100644
--- a/htdocs/epack/recette.php
+++ b/htdocs/epack/recette.php
@@ -29,6 +29,7 @@ $code         = $_POST['code'];
 $pass         = $_POST['pass'];
 $anetlogin    = $_POST['anetlogin'];
 $anetpassword = $_POST['anetpassword'];
+$version      = $_POST['version'];
 $tab_postes   = unserialize(base64_decode($_POST['tab_postes']));
 $tab_server   = unserialize(base64_decode($_POST['tab_server']));
 $tab_hdd      = unserialize(base64_decode($_POST['tab_hdd']));
@@ -75,7 +76,10 @@ WHERE code='$code' AND password='$pass'";
       //print serialize($object);
       //print_r($_SERVER);
       require_once('lib/odf.php');
-      $odf = new odf("abuledu-recette.odt");
+      if($version == "1108")
+	$odf = new odf("abuledu-recette-1108.odt");
+      else
+	$odf = new odf("abuledu-recette.odt");
    
       //1ere page
       setlocale(LC_TIME, "fr_FR.UTF-8");
diff --git a/htdocs/epack/register.php b/htdocs/epack/register.php
index b69cdb1..55b1df6 100644
--- a/htdocs/epack/register.php
+++ b/htdocs/epack/register.php
@@ -299,6 +299,7 @@ function add_user_and_update_link($usermail,$identity,$userlastname,$userfirstna
     $iduser = $data['ID'];
     //existe dejà on fait juste le lien s'il n'existe pas déjà
     $query2 = "SELECT * FROM glpi_users_profiles WHERE FK_users='$iduser' AND FK_entities='$identity'";
+    //$message .= "$query2";
     $result2 = $DB->query($query2);
     if($DB->numrows($result2)<=0) {
       //pour eviter qu'un utilisateur se retrouve dans l'entite racine ...
diff --git a/scripts/net2dip.sendtohurlevent.php b/scripts/net2dip.sendtohurlevent.php
index c59ff01..16e975b 100755
--- a/scripts/net2dip.sendtohurlevent.php
+++ b/scripts/net2dip.sendtohurlevent.php
@@ -49,13 +49,33 @@ require_once "$base_dir/libraries/fonctions.php";
 //Creation automatique du fichier de mots de passe pour les restrictions de connexion
 //sur les depot apt and co
 $fic_htpass        = "/tmp/htpasswd-anet";
+$fic_htpass908     = "/tmp/htpasswd-anet908";
+$fic_htpass1108    = "/tmp/htpasswd-anet1108";
 //Avec un nom checksum pour ne pas eveiller l'attention
 $dir_htpass_public = "/home/webs/www.abuledu.net/htdocs/epack/export/";
-$fic_htpass_public = "checksum";
-$result = system("rm -f " . $fic_htpass . " " . $dir_htpass_public . $fic_htpass_public . "&& touch " . $fic_htpass);
+$fic_htpass_public     = "checksum";
+$fic_htpass_public908  = "checksum-908";
+$fic_htpass_public1108 = "checksum-1108";
+$result = system("rm -f "
+		 . " " . $fic_htpass
+		 . " " . $fic_htpass908
+		 . " " . $fic_htpass1108
+		 . " " . $dir_htpass_public . $fic_htpass_public
+		 . " " . $dir_htpass_public . $fic_htpass_public908
+		 . " " . $dir_htpass_public . $fic_htpass_public1108
+		 . "&& touch " . $fic_htpass
+		 . "&& touch " . $fic_htpass908
+		 . "&& touch " . $fic_htpass1108
+		 );
+
+function nettoyage($s) {
+  $texte = str_replace(" ","",$s);
+  $texte = str_replace("'","",$texte);
+  $texte = str_replace('"',"",$texte);
+  return $texte;
+}
 
-function make_htpass($login,$pass) {
-  global $fic_htpass;
+function make_htpass($fic, $login,$pass) {
   $l = $login;
   //debug
   //echo "login: $login / $pass\n";
@@ -68,11 +88,10 @@ function make_htpass($login,$pass) {
     $login = trim(str_replace(".dip.abuledu.net","",$login));
 
   //Et le login en MAG et MIN because a bug ou un truc a la con qqpart dans la chaine
-  $result = shell_exec("htpasswd -mb " . $fic_htpass . " " . trim(strtolower($login)) . " " . trim($pass) . " 2>&1");
-  $result = shell_exec("htpasswd -mb " . $fic_htpass . " " . trim(strtoupper($login)) . " " . trim($pass) . " 2>&1");
+  $result = shell_exec("htpasswd -mb " . $fic . " " . trim(strtolower($login)) . " " . trim(nettoyage($pass)) . " 2>&1");
+  $result = shell_exec("htpasswd -mb " . $fic . " " . trim(strtoupper($login)) . " " . trim(nettoyage($pass)) . " 2>&1");
 }
 
-
 //Les serveurs avant 2009 ne sont pas des epacks et leur mot de passe est stocke en crypte
 $query = "SELECT e.password as gnudip_pass,os_license_number as dns_alias0,os_license_id as dns_alias1 FROM glpi_computers AS c
 LEFT JOIN glpi_plugin_anet_epacks AS e ON e.FK_serveur=c.ID
@@ -88,7 +107,7 @@ for ( $i = 0; $i < $nb; $i++) {
   // dns a l autre bout ...
   //  $text .= implode(";",$row) . "\n";
   $text .= trim($row[0]) . ";" . trim($row[1]) . ";" . trim($row[2]) . ";\n";
-  make_htpass($row[1],$row[0]);
+  make_htpass($fic_htpass, $row[1],$row[0]);
 }
 
 //les serveurs post ENR sont des epacks reels et leur mot de passe n'est pas crypte
@@ -108,7 +127,7 @@ $nb = $result2->NumRows();
 for ( $i = 0; $i < $nb; $i++) {
   $row = $result2->fetchrow();
   $text .= implode(";",$row) . "\n";
-  make_htpass($row[1],$row[0]);
+  make_htpass($fic_htpass, $row[1],$row[0]);
  }
 
 //Et ensuite les comptes utilisateurs pour les espaces limites uniquement
@@ -118,7 +137,7 @@ LEFT JOIN glpi_users_profiles as gup ON gup.FK_users=gu.ID
 WHERE gup.FK_profiles = '5' OR gup.FK_profiles = '7'
 GROUP BY name";
 if ( DB::isError($result3 = $dbglpi->query($query3)) ) {
-  die ("***\n$query2\n" . DB::errorMessage($result3) . "\n***\n\n");
+  die ("***\n$query3\n" . DB::errorMessage($result3) . "\n***\n\n");
  }
 
 $nb = $result3->NumRows();
@@ -127,9 +146,46 @@ for ( $i = 0; $i < $nb; $i++) {
   //le nom en minuscule, sans accents et sans espaces
   $nom = anti_speciaux($row[1],2);
   $login = trim($row[0]);
-  make_htpass($login,$nom);
+  make_htpass($fic_htpass, $login,$nom);
+ }
+
+//Maintenant, les personnes qui ont suivies la formation 9.08 clé "493" dans la table glpi_groups
+$query4 = "SELECT name, realname FROM glpi_users as gu
+LEFT JOIN glpi_users_groups as gug ON gug.FK_users=gu.ID
+WHERE gug.FK_groups = '493' GROUP BY name";
+if ( DB::isError($result4 = $dbglpi->query($query4)) ) {
+  die ("***\n$query4\n" . DB::errorMessage($result4) . "\n***\n\n");
+ }
+
+$nb = $result4->NumRows();
+for ( $i = 0; $i < $nb; $i++) {
+  $row = $result4->fetchrow();
+  //le nom en minuscule, sans accents et sans espaces
+  $nom = anti_speciaux($row[1],2);
+  $login = trim($row[0]);
+  make_htpass($fic_htpass908, $login, $nom);
+  //echo "$fic_htpass908 ... $login : $nom\n";
+ }
+
+//Maintenant, les personnes qui ont suivies la formation 11.08 clé "494" dans la table glpi_groups
+$query5 = "SELECT name, realname FROM glpi_users as gu
+LEFT JOIN glpi_users_groups as gug ON gug.FK_users=gu.ID
+WHERE gug.FK_groups = '494' GROUP BY name";
+if ( DB::isError($result5 = $dbglpi->query($query5)) ) {
+  die ("***\n$query5\n" . DB::errorMessage($result5) . "\n***\n\n");
+ }
+
+$nb = $result5->NumRows();
+for ( $i = 0; $i < $nb; $i++) {
+  $row = $result5->fetchrow();
+  //le nom en minuscule, sans accents et sans espaces
+  $nom = anti_speciaux($row[1],2);
+  $login = trim($row[0]);
+  //echo "$fic_htpass1108 ... $login : $nom\n";
+  make_htpass($fic_htpass1108, $login, $nom);
  }
 
+
 /*
  *
  * EXPEDITION DES DONNEES POUR LE SERVEUR GNUDIP
@@ -148,6 +204,8 @@ $user_apt="APT Filtered server <ryxeo.apt@apt.ryxeo.com>";
 
 $command = 'echo "'.$text.'" | '.$gpg.' -a --always-trust --batch --no-secmem-warning -s -e -u "'.$user_from.'" -r "'.$user_dyndns.'"';
 $result = exec($command, $encrypted, $errorcode);
+//print $command . "\n";
+
 $message = implode("\n", $encrypted);
 /*
 if( ereg("-----BEGIN PGP MESSAGE-----.*-----END PGP MESSAGE-----",$message) ) {
@@ -167,9 +225,21 @@ mail($user_clear,$subject,$text,$header);
 //Ensuite on GPG Crypte le fichier de htpasswd avec la meme cle
 $encrypted = "";
 $message = "";
-$command = 'rm -f "' . $dir_htpass_public . $fic_htpass_public  . '" && cat "' . $fic_htpass . '" | ' . $gpg . ' --always-trust --batch --no-secmem-warning -s -e -u "' . $user_from . '" -r "' . $user_apt . '" > ' . $dir_htpass_public . $fic_htpass_public;
-//print $command;
+$command = 'rm -f "' . $dir_htpass_public . $fic_htpass_public      . '" && cat "' . $fic_htpass     . '" | ' . $gpg . ' --always-trust --batch --no-secmem-warning -s -e -u "' . $user_from . '" -r "' . $user_apt . '" > ' . $dir_htpass_public . $fic_htpass_public;
+$result = exec($command, $encrypted, $errorcode);
+//print $command . "\n";
+
+$encrypted = "";
+$message = "";
+$command = 'rm -f "' . $dir_htpass_public . $fic_htpass_public908   . '" && cat "' . $fic_htpass908  . '" | ' . $gpg . ' --always-trust --batch --no-secmem-warning -s -e -u "' . $user_from . '" -r "' . $user_apt . '" > ' . $dir_htpass_public . $fic_htpass_public908;
+$result = exec($command, $encrypted, $errorcode);
+//print $command . "\n";
+
+$encrypted = "";
+$message = "";
+$command = 'rm -f "' . $dir_htpass_public . $fic_htpass_public1108  . '" && cat "' . $fic_htpass1108 . '" | ' . $gpg . ' --always-trust --batch --no-secmem-warning -s -e -u "' . $user_from . '" -r "' . $user_apt . '" > ' . $dir_htpass_public . $fic_htpass_public1108;
 $result = exec($command, $encrypted, $errorcode);
+//print $command . "\n";
 
 //le fichier de checksum que les serveurs vont downloader pour verifier si y a une mise a jour
 $result = exec("cd " . $dir_htpass_public . " && md5sum " . $fic_htpass_public . " > " . $fic_htpass_public . ".md5");
