alert(\"$message\"); history.go(-1);"; exit(); } print "
\n"; echo "

".sprintf($msg["sauv_misc_restaure"],$file_name)."

\n"; if ($critical==1) { mysql_connect($host,$user,$password) or abort($msg["sauv_misc_ract_cant_connect"]); mysql_select_db($db) or abort(sprintf($msg["sauv_misc_ract_db_dont_exists"],$db)); } //Récupération de la partie data $f=fopen($filename,"r") or abort($msg["sauv_misc_ract_cant_open_file"]); $line=fgets($f,4096); $line=rtrim($line); while ((!feof($f))&&($line!="#data-section")) { $line=fgets($f,4096); $line=rtrim($line); } if ($line!="#data-section") abort($msg["sauv_misc_ract_no_sauv"]); /*$datas=fread($f,filesize($filename)); fclose($f); //Si crypté if ($crypt==1) { echo "".$msg["sauv_misc_ract_decryt_msg"]."
"; flush(); $c=new Crypt(md5($phrase1),md5($phrase2)); $sign=substr($datas,0,8); $dSign=$c->getDecrypt($sign); if ($dSign!="PMBCrypt") abort($msg["sauv_misc_ract_bad_keys"]); $datas=substr($datas,8); $datas=$c->getDecrypt($datas); } */ //Copie des données dans un fichier temporaire $tempfile="temp_restaure"; $tempfiledest="../backup/backups/temp_restaure.sql"; //Si compressé if ($compress==1) { if ($decompress_type=="internal") $tempfile.=".bz2"; else $tempfile.=".sql.".$decompress_ext; } else $tempfile.=".sql"; $tempfile="../backup/backups/".$tempfile; $ftemp=fopen($tempfile,"w+") or abort($msg["sauv_misc_ract_create"]); while (!feof($f)) { fwrite($ftemp,fread($f,4096)); } //fwrite($ftemp,$datas); fclose($ftemp); fclose($f); //Décompression éventuelle if ($compress==1) { echo "".$msg["sauv_misc_ract_decompress"]."
"; flush(); if ($decompress_type=="external") { $decompress=str_replace("%s",$tempfile,$decompress); $decompress=str_replace("%sd",$tempfiledest,$decompress); exec($decompress); } else { $ftempin=bzopen($tempfile,"r") or abort($msg["sauv_misc_ract_not_bz2"]); $ftempout=fopen($tempfiledest,"w+") or abort($msg["sauv_misc_ract_create"]); while (!feof($ftempin)) { $datas=bzread($ftempin,2048); fwrite($ftempout,$datas); } bzclose($ftempin); fclose($ftempout); @unlink($tempfile); } } //Application des requêtes echo "".$msg["sauv_misc_ract_restaure_tables"]."

"; if (!is_array($tables)) $tables=array(); $fsql=fopen($tempfiledest,"r") or abort($msg["sauv_misc_ract_open_failed"]); $mod_query=0; while (!feof($fsql)) { $line=""; while ((substr($line,strlen($line)-1,1)!="\n")&&(!feof($fsql))) { $line.=fgets($fsql,4096); } $line=rtrim($line); if ($line!="") { if (substr($line,0,1)=="#") { if (($currentTable!="")&&($mod_query==1)) { echo sprintf($msg["sauv_misc_ract_restaured_t"],$currentTable)."
"; flush(); } $currentTable=substr($line,1); $as=array_search($currentTable,$tables); if (($as!==false)&&($as!==null)) { $mod_query=1; echo sprintf($msg["sauv_misc_ract_start_restaure"],$currentTable)."
"; } else { $mod_query=0; echo sprintf($msg["sauv_misc_ract_ignore"],$currentTable)."
"; } flush(); } else { if ($mod_query==1) { mysql_query($line) or abort(sprintf($msg["sauv_misc_ract_invalid_request"],$line)); } } } } fclose($fsql); @unlink($tempfiledest); /* Succeed - Gestion du cas particulier : * Dernière sauvegarde effectuée <=> sauv_log_succeed valorisé à 1 après sauvegarde * Lors de la restauration, on récupère la valeur 0, enregistrée avant la fin de la sauvegarde. */ $requete="update sauv_log set sauv_log_succeed=1 where sauv_log_id=".$logid; @mysql_query($requete); echo "

".$msg["sauv_misc_ract_correct"]."

"; echo "
"; if ($critical==1) unlink($filename); ?>