Importation des clés"; // connexion(); if (ldap_get_right("computers_is_admin", $login) != "Y") die(gettext("Vous n'avez pas les droits suffisants pour accéder à cette fonction") . ""); // Aide $_SESSION["pageaide"] = "Gestion_des_clients_windows#Description_du_processus_de_configuration_du_registre_Windows"; $act = $_POST['action']; switch ($act) { default: break; case "file": if (isset($_POST['upload'])) { // si formulaire soumis if (file_exists("/tmp/import.reg")) unlink("/tmp/import.reg"); $content_dir = '/tmp/'; // dossier ou sera deplace le fichier $tmp_file = $_FILES['fichier']['tmp_name']; if (!is_uploaded_file($tmp_file)) { exit(gettext("Le fichier est introuvable")); } // on copie le fichier dans le dossier de destination $name_file = $_FILES['fichier']['name']; if (!move_uploaded_file($tmp_file, $content_dir . $name_file)) { exit(gettext("Impossible de copier le fichier dans") . " $content_dir"); } $fichier_reg = $content_dir . $name_file; echo gettext("Le fichier") . " $name_file " . gettext("a bien été uploadé"); print_nice(read_reg_file($content_dir . $name_file)); } break; case "valid": echo "a faire"; break; } function print_nice($elem,$max_level=10,$print_nice_stack=array()){ if(is_array($elem) || is_object($elem)){ if(in_array(&$elem,$print_nice_stack,true)){ echo "RECURSION"; return; } $print_nice_stack[]=&$elem; if($max_level<1){ echo "nivel maximo alcanzado"; return; } $max_level--; echo ""; if(is_array($elem)){ echo ''; }else{ echo ''; } $color=0; foreach($elem as $k => $v){ if($max_level%2){ $rgb=($color++%2)?"#888888":"#BBBBBB"; }else{ $rgb=($color++%2)?"#8888BB":"#BBBBFF"; } echo '"; } echo "
CLE
'; echo 'OBJECT Type: '.get_class($elem).'
'; echo ''.$k.""; print_nice($v,$max_level,$print_nice_stack); echo "
"; return; } if($elem === null){ echo "NULL"; }elseif($elem === 0){ echo "0"; }elseif($elem === true){ echo "TRUE"; }elseif($elem === false){ echo "FALSE"; }elseif($elem === ""){ echo "EMPTY STRING"; }else{ echo str_replace("\n","
\n",$elem); } } function read_reg_file($regfile) { $handle = fopen ($regfile,"r"); //echo "handle: " . $file . "
"; $row = 1; unset($n); $os = "TOUS"; $description = ""; $categorie = "appli"; $souscategorie = ""; while ((($data = fgets($handle, 1024)) !== FALSE) ) { $num = count($data); //echo "$num fields in line $row: $data
\n"; $reg_section = preg_replace("/\r/i", "", $data); if (preg_match("/^;categorie=(.+)$/", $reg_section, $res)) { $categorie = $res[1]; } else if (preg_match("/^;souscategorie=(.+)$/", $reg_section, $res)) { $souscategorie = $res[1]; } else if (preg_match("/^;description=(.+)$/", $reg_section, $res)) { $description = $res[1]; } else if (preg_match("/^;os=(.+)$/", $reg_section, $res)) { $os = $res[1]; } else if (preg_match("/^\[([^;\r\n]+)\]$/", $reg_section, $res)) { $path = $res[1]; unset($binary); } else if (preg_match("/^(.+)=(?:(dword|he[^:]+|dword):|)(.+)$/", $reg_section, $res)) { if (preg_match("/^(.+)\\\\$/", $res[3], $valeur)) { $binary = $valeur[1]; } else { $binary = preg_replace("/^\"(.+)\"$/", "\\1", $res[3]); } $n++; $cle[$n]['path']=$path; $cle[$n]['key'] = preg_replace("/^\"(.+)\"$/", "\\1", $res[1]); $cle[$n]['valeur'] = $binary; $cle[$n]['categorie'] = $categorie; $cle[$n]['souscategorie'] = $souscategorie; $cle[$n]['os'] = $os; $cle[$n]['description'] = $description; if ($res[2] == "dword") { $cle[$n]['type'] = "REG_DWORD"; } else if ($res[2] == "hex") { $cle[$n]['type'] = "REG_BINARY"; } else if ($res[2] == "hex(2)") { $cle[$n]['type'] = "REG_EXPAND_SZ"; $cle[$n]['valeur'] = hexToStr($binary); } else if ($res[2] == "hex(7)") { $cle[$n]['type'] = "REG_MULTI_SZ"; $cle[$n]['valeur'] = hexToStr($binary); } else { $cle[$n]['type'] = "REG_SZ"; } } else if (preg_match("/^\s+([A-Fa-f0-9,]+)(\\\\|)$/", $reg_section, $res)) { if ($res[2]) { $binary .= $res[1]; } else if ($cle[$n]['type'] == "REG_BINARY") { $cle[$n]['valeur'] = $binary.$res[1]; } else { $cle[$n]['valeur'] = hexToStr($binary.$res[1]); } } $row++; } //end while fclose($handle); return($cle); } function hexToStr($hexlist) { $string=''; foreach (preg_split("/,/", $hexlist) as $key=>$value) { // retour a la ligne if ($value == "00") { $value = "0a"; } $string .= chr(hexdec($value)); } return $string; } retour(); include("pdp.inc.php"); ?>