Erreur lors de la création de la table d'après la requête:
$sql\n"; $retour=false; } $sql="CREATE TABLE IF NOT EXISTS se3_tftp_rapports ( `id` INT( 11 ) NOT NULL , `name` VARCHAR( 255 ) NOT NULL , `mac` VARCHAR( 255 ) NOT NULL , `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `tache` VARCHAR( 255 ) NOT NULL , `statut` VARCHAR( 255 ) NOT NULL , `descriptif` TEXT NOT NULL, identifiant int(11) NOT NULL auto_increment, PRIMARY KEY (identifiant) );"; $creation_table=mysql_query($sql); if(!$creation_table) { echo "Erreur lors de la création de la table d'après la requête:
$sql\n"; $retour=false; } $sql="CREATE TABLE IF NOT EXISTS se3_tftp_sauvegardes ( `id` INT( 11 ) NOT NULL , `name` VARCHAR( 255 ) NOT NULL , `mac` VARCHAR( 255 ) NOT NULL , `partition` VARCHAR( 255 ) NOT NULL , `image` VARCHAR( 255 ) NOT NULL , `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `descriptif` TEXT NOT NULL, `df` TEXT NOT NULL, `partitionnement` TEXT NOT NULL, identifiant int(11) NOT NULL auto_increment, PRIMARY KEY (identifiant) );"; $creation_table=mysql_query($sql); if(!$creation_table) { echo "Erreur lors de la création de la table d'après la requête:
$sql\n"; $retour=false; } $sql="CREATE TABLE IF NOT EXISTS se3_tftp_infos ( `id` INT( 11 ) NOT NULL , `name` VARCHAR( 255 ) NOT NULL , `mac` VARCHAR( 255 ) NOT NULL , `nom` VARCHAR( 255 ) NOT NULL , `valeur` VARCHAR( 255 ) NOT NULL , identifiant int(11) NOT NULL auto_increment, PRIMARY KEY (identifiant) );"; $creation_table=mysql_query($sql); if(!$creation_table) { echo "Erreur lors de la création de la table d'après la requête:
$sql\n"; $retour=false; } return $retour; } //==================================================== function decoupe_infos($texte) { $motif=array('disk','compr','port','udpcparam','src_part','dest_part','nom_image','auto_reboot','delais_reboot','enableDiskmodule','diskmodule','netmodule'); $tab_txt=explode("|",$texte); $tab_retour=array(); for($i=0;$i
Visualiser le fichier de configuration en /tftpboot/pxelinux.cfg/
\n"; echo "Voici le fichier en /tftpboot/pxelinux.cfg/ (Masquer):
\n"; echo $texte; echo "Voici les paramètres de l'action programmée:
";
}
$corrige_mac=strtolower(strtr($mac_machine,":","-"));
$type_action="";
$fich=fopen("/tftpboot/pxelinux.cfg/01-$corrige_mac","r");
if($fich) {
$infos="";
$chaine_fichier="
";
while(!feof($fich)) {
$ligne=fgets($fich,4096);
if(strstr($ligne, "# Date de generation du fichier: ")) {
$date_prog_action=preg_replace("/# Date de generation du fichier: /", "", $ligne);
}
//if(strstr($ligne, "default tazsvg")) {
if(strstr($ligne, "label tazsvg")) {
$type_action="Sauvegarde";
}
//elseif(strstr($ligne, "default tazrst")) {
elseif(strstr($ligne, "label tazrst")) {
$type_action="Restauration";
}
//elseif(strstr($ligne, "default u1auto")) {
elseif(strstr($ligne, "label u1auto")) {
$type_action="Emetteur UdpCast";
}
//elseif(strstr($ligne, "default u2auto")) {
elseif(strstr($ligne, "label u2auto")) {
$type_action="Récepteur UdpCast";
}
elseif(strstr($ligne, "label linuxinst")) {
$type_action="Installation client Linux";
}
elseif(strstr($ligne, "label install")) {
$type_action="Installation XP unattend";
}
if($type_action=="Sauvegarde") {
// append initrd=rootfs.gz rw root=/dev/null lang=fr_FR kmap=fr vga=normal sound=no src_part=$src_part dest_part=$dest_part auto_reboot=$auto_reboot delais_reboot=$delais_reboot work=/root/bin/sauve_part.sh
if(strstr($ligne, "append initrd=rootfs.gz rw root=/dev/null lang=fr_FR kmap=fr vga=normal sound=no src_part=")) {
//echo $ligne."
";
unset($tab);
$tab=explode(" ",$ligne);
for($i=0;$i ";
$infos.="Partition sauvegardée $src_part ";
}
elseif(preg_match("/^dest_part=/", $tab[$i])) {
$dest_part=preg_replace("/^dest_part=/", "", $tab[$i]);
//echo "\$dest_part=$dest_part
";
$infos.="Partition de stockage
de la sauvegarde $dest_part ";
}
elseif(preg_match("/^nom_image=/", $tab[$i])) {
$nom_image=preg_replace("/^nom_image=/", "", $tab[$i]);
//echo "\$nom_image=$nom_image
";
$infos.="Nom de l'image $nom_image ";
}
elseif(preg_match("/^auto_reboot=/", $tab[$i])) {
$auto_reboot=preg_replace("/^auto_reboot=/", "", $tab[$i]);
//echo "\$auto_reboot=$auto_reboot
";
$infos.="Auto-reboot $auto_reboot ";
}
elseif(preg_match("/^delais_reboot=/", $tab[$i])) {
$delais_reboot=preg_replace("/^delais_reboot=/", "", $tab[$i]);
//echo "\$delais_reboot=$delais_reboot
";
$infos.="Délai avant reboot $delais_reboot ";
}
}
}
}
elseif($type_action=="Restauration") {
if(strstr($ligne, "append initrd=rootfs.gz rw root=/dev/null lang=fr_FR kmap=fr vga=normal sound=no src_part=")) {
//echo $ligne."
";
unset($tab);
$tab=explode(" ",$ligne);
for($i=0;$iPartition de stockage $src_part ";
}
elseif(preg_match("/^dest_part=/", $tab[$i])) {
$dest_part=preg_replace("/^dest_part=/", "", $tab[$i]);
$infos.="Partition restaurée $dest_part ";
}
elseif(preg_match("/^nom_image=/", $tab[$i])) {
$nom_image=preg_replace("/^nom_image=/", "", $tab[$i]);
//echo "\$nom_image=$nom_image
";
$infos.="Nom de l'image $nom_image ";
}
elseif(preg_match("/^auto_reboot=/", $tab[$i])) {
$auto_reboot=preg_replace("/^auto_reboot=/", "", $tab[$i]);
$infos.="Auto-reboot $auto_reboot ";
}
elseif(preg_match("/^delais_reboot=/", $tab[$i])) {
$delais_reboot=preg_replace("/^delais_reboot=/", "", $tab[$i]);
$infos.="Délai avant reboot $delais_reboot ";
}
}
}
}
elseif($type_action=="Emetteur UdpCast") {
//append initrd=udprd root=01:00 persoparams=oui lang=FR kbmap=FR dhcp=yes compr=$compr port=$port umode=snd disk=$disk auto_reboot=$auto_reboot enableDiskmodule=$enableDiskmodule diskmodule=$diskmodule netmodule=$netmodule udpcparam=$udpcparam
if(strstr($ligne, "append initrd=udprd root=01:00 persoparams=oui lang=FR kbmap=FR dhcp=yes compr=")) {
unset($tab);
$tab=explode(" ",$ligne);
for($i=0;$iCompression $compr ";
}
elseif(preg_match("/^port=/", $tab[$i])) {
$port=preg_replace("/^port=/", "", $tab[$i]);
$infos.="Port $port ";
}
elseif(preg_match("/^disk=/", $tab[$i])) {
$disk=preg_replace("/^disk=/", "", $tab[$i]);
$infos.="Disque ou partition émis(e) $disk ";
}
elseif(preg_match("/^enableDiskmodule=/", $tab[$i])) {
$enableDiskmodule=preg_replace("/^enableDiskmodule=/", "", $tab[$i]);
$infos.="Chargement d'un module disque $enableDiskmodule ";
}
elseif(preg_match("/^diskmodule=/", $tab[$i])) {
$diskmodule=preg_replace("/^diskmodule=/", "", $tab[$i]);
$infos.="Module/pilote disque $diskmodule ";
}
elseif(preg_match("/^netmodule=/", $tab[$i])) {
$netmodule=preg_replace("/^netmodule=/", "", $tab[$i]);
$infos.="Pilote réseau $netmodule ";
}
elseif(preg_match("/^udpcparam=/", $tab[$i])) {
//$udpcparam="--max-wait=".$max_wait."--min-receivers=".$min_receivers;
$udpcparam=explode(",",preg_replace("/--/",",",preg_replace("/^udpcparam=/", "", $tab[$i])));
for($j=0;$jDélai maximum avant de lancer le clonage
même si un client fait défaut $max_wait ";
}
elseif(preg_match("/^min-receivers=/", $udpcparam[$j])) {
$min_receivers=preg_replace("/^min-receivers=/", "", $udpcparam[$j]);
$infos.="Nombre de clients à attendre $min_receivers ";
}
}
}
elseif(preg_match("/^auto_reboot=/", $tab[$i])) {
$auto_reboot=preg_replace("/^auto_reboot=/", "", $tab[$i]);
$infos.="Auto-reboot $auto_reboot ";
}
}
}
}
elseif($type_action=="Récepteur UdpCast") {
//append initrd=udprd root=01:00 persoparams=oui lang=FR kbmap=FR dhcp=yes compr=$compr port=$port umode=rcv disk=$disk auto_reboot=$auto_reboot enableDiskmodule=$enableDiskmodule diskmodule=$diskmodule netmodule=$netmodule udpcparam=$udpcparam
if(strstr($ligne, "append initrd=udprd root=01:00 persoparams=oui lang=FR kbmap=FR dhcp=yes compr=")) {
unset($tab);
$tab=explode(" ",$ligne);
for($i=0;$iCompression $compr ";
}
elseif(preg_match("/^port=/", $tab[$i])) {
$port=preg_replace("/^port=/", "", $tab[$i]);
$infos.="Port $port ";
}
elseif(preg_match("/^disk=/", $tab[$i])) {
$disk=preg_replace("/^disk=/", "", $tab[$i]);
$infos.="Disque ou partition écrasé(e) $disk ";
}
elseif(preg_match("/^enableDiskmodule=/", $tab[$i])) {
$enableDiskmodule=preg_replace("/^enableDiskmodule=/", "", $tab[$i]);
$infos.="Chargement d'un module disque $enableDiskmodule ";
}
elseif(preg_match("/^diskmodule=/", $tab[$i])) {
$diskmodule=preg_replace("/^diskmodule=/", "", $tab[$i]);
$infos.="Module/pilote disque $diskmodule ";
}
elseif(preg_match("/^netmodule=/", $tab[$i])) {
$netmodule=preg_replace("/^netmodule=/", "", $tab[$i]);
$infos.="Pilote réseau $netmodule ";
}
elseif(preg_match("/^udpcparam=/", $tab[$i])) {
//$udpcparam="--start-timeout=".$start_timeout;
$udpcparam=preg_replace("/^udpcparam=--start-timeout=/", "", $tab[$i]);
$infos.="Délai avant abandon
si le clonage ne démarre pas $udpcparam ";
}
elseif(preg_match("/^auto_reboot=/", $tab[$i])) {
$auto_reboot=preg_replace("/^auto_reboot=/", "", $tab[$i]);
$infos.="Auto-reboot $auto_reboot ";
}
}
}
}
elseif($type_action=="Installation XP unattend") {
$infos="Installation d'un systeme Windows XP via unattended \n";
}
$chaine_fichier.=htmlentities($ligne);
}
$chaine_fichier.="\n";
fclose($fich);
// On passe sinon un $mode=light
if(!isset($mode)) {
echo "Il n'a pas été possible d'ouvrir le fichier /tftpboot/pxelinux.cfg/01-$corrige_mac
\n"; } } // Fin de visu_tache() //==================================================== function crob_getParam($name) { $sql="SELECT value FROM params WHERE name='".addslashes($name)."';"; $res=mysql_query($sql); if(mysql_num_rows($res)>0) { $lig=mysql_fetch_object($res); return $lig->value; } else { return ""; } } //==================================================== function crob_setParam($name,$value,$descr) { $sql="DELETE FROM params WHERE name='".addslashes($name)."';"; $del=mysql_query($sql); $sql="INSERT INTO params SET name='$name', descr='$descr', cat='7', value='".addslashes($value)."';"; $insert=mysql_query($sql); if($insert) {return true;} else {return false;} } //==================================================== function check_sysresccd_files() { $tab_fichiers_sysresccd=array("/var/www/sysresccd/sysrcd.dat","/var/www/sysresccd/sysrcd.md5","/var/www/sysresccd/autorun2","/var/www/sysresccd/scripts.tar.gz", "/tftpboot/rescue32", "/tftpboot/initram.igz"); $temoin_sysresccd="n"; $cpt_sysresccd=0; foreach($tab_fichiers_sysresccd as $key => $value) { if(file_exists("$value")) { //echo "Le fichier /var/www/sysresccd/$value est present.
"; $cpt_sysresccd++; } } if($cpt_sysresccd==count($tab_fichiers_sysresccd)) { //echo "Tout est en place
"; $temoin_sysresccd="y"; } return $temoin_sysresccd; } //==================================================== function liste_sauvegardes($name,$id="",$mac="",$order_by='date DESC',$limit="") { $tab=array(); $champs=array('id', 'name', 'mac', 'partition', 'image', 'date', 'descriptif', 'df', 'partitionnement', 'identifiant'); // Une machine peut changer de nom // Une recherche par MAC ou ID donnera plus de réponses... mais peut-être avec des sauvegardes dans lesquelles la machine avait un autre nom if($mac!="") { $sql="select * from se3_tftp_sauvegardes WHERE mac='$mac' ORDER BY $order_by"; } elseif($id!="") { $sql="select * from se3_tftp_sauvegardes WHERE id='$id' ORDER BY $order_by"; } else { $sql="select * from se3_tftp_sauvegardes WHERE name='$name' ORDER BY $order_by"; } if($limit!="") {$sql.=" LIMIT $limit;";} $res=mysql_query($sql); if(mysql_num_rows($res)>0) { $cpt=0; while($lig=mysql_fetch_object($res)) { $tab[$cpt]=array(); for($loop=0;$loop| Id | \n"; $html.="Nom | \n"; $html.="Partition | \n"; $html.="Sauvegarde | \n"; $html.="Date | \n"; $html.="Descriptif | \n"; $html.="".$tab[$loop]['id']." | \n"; $html.="".$tab[$loop]['name']." | \n"; $html.="".$tab[$loop]['partition']." | \n"; $html.="".$tab[$loop]['image']." | \n"; $html.="".mysql_date_to_fr_date($tab[$loop]['date'])." | \n"; $html.="".$tab[$loop]['descriptif']." | \n";
$html.="\n";
}
$html.="
|---|
| Id | \n"; $html.="Nom | \n"; $html.="Partition | \n"; $html.="Sauvegarde | \n"; $html.="Date | \n"; $html.="Descriptif | \n"; $html.="".$tab[$loop]['id']." | \n"; $html.="".$tab[$loop]['name']." | \n"; $html.="".$tab[$loop]['partition']." | \n"; $html.="".$tab[$loop]['image']." | \n"; $html.="".mysql_date_to_fr_date($tab[$loop]['date'])." | \n"; $html.="".$tab[$loop]['descriptif']." | \n";
$html.="\n";
}
$html.="
|---|
ldap_search($ds,".$dn[$branche].",\"$filtre\",$attribut);
"; if ($result){ //echo "\$result=$result