'.HtmlInput::button_anchor(_("Retour"),"?action=restore","","smallbutton"); if ( ! isset($_REQUEST['t'])) { echo '
'; echo (""._("Vous devez préciser s'il s'agit d'un modèle ou d'un dossier").""); echo $retour; echo '
'; exit(); } if ( empty ($_FILES['file']['name']) || strlen(trim($_FILES['file']['name']))==0 ) { echo '
'; echo (""._('Vous devez donner un fichier')." "); echo $retour; echo '
'; exit(); } //--------------------------------------------------------------------------- // Restore a folder (dossier) if ( $_REQUEST['t']=='d') { echo '
'; $cn=new Database(); $id=$cn->get_next_seq('dossier_id'); if ( strlen(trim($_REQUEST['database'])) == 0 ) { $lname=$id." Restauration :".sql_string($_FILES['file']['name']); } else { $lname=$id." ".$_REQUEST['database']; } if (strlen(trim($_REQUEST['desc']))==0) { $ldesc=$lname; } else { $ldesc=sql_string($_REQUEST['desc']); } $sql="insert into ac_dossier (dos_id,dos_name,dos_description) values ($1,$2,$3)"; $cn->start(); try { $cn->get_value($sql,array($id,$lname,$ldesc)); } catch ( Exception $e) { echo ''._("Echec de la restauration ").''; $cn->rollback(); exit(); } $cn->commit(); $name=domaine."dossier".$id; echo $name; $cn->exec_sql("create database ".$name." encoding='utf8'"); $args=" --no-owner -d $name ".$_FILES['file']['tmp_name']; $cmd= escapeshellcmd(PG_RESTORE); exec($cmd.$args); $test=new Database($id); if ( $test->exist_table('version') ) { echo '

'._('Restauration réussie du dossier ').$lname.'

'; $test->close(); } else { $test->close(); echo '

'._('Problème lors de la restauration ').$lname.'

'; $cn->exec_sql('delete from ac_dossier where dos_id=$1',array($id)); $cn->exec_sql('drop database '.$name); exit(); } $new_cn=new Database($id); $new_cn->apply_patch($name); echo ''._('Ne pas recharger la page, sinon votre base de données sera restaurée une fois de plus').''; Dossier::synchro_admin($id); User::remove_inexistant_user($id); $new_cn->clean_orphan_lob(); echo $retour; echo '
'; } //--------------------------------------------------------------------------- // Restore a modele if ( $_REQUEST['t']=='m') { echo '
'; $cn=new Database(); $id=$cn->get_next_seq('s_modid'); if ( strlen(trim($_REQUEST['database'])) == 0 ) $lname=$id." Restauration :".$_FILES['file']['name']; else $lname=$id." ".$_REQUEST['database']; $ldesc=$http->post("desc"); $sql="insert into modeledef (mod_id,mod_name,mod_desc) values ($1,$2,$3)"; $cn->start(); try { $cn->exec_sql($sql,array($id,$lname,$ldesc)); } catch ( Exception $e) { echo ''._("Echec de la restauration ").''; $cn->rollback(); exit(); } $cn->commit(); $name=domaine."mod".$id; $cn->exec_sql("create database ".$name." encoding='utf8'"); $args=" -d $name ".$_FILES['file']['tmp_name']; $status=exec(PG_RESTORE.$args); $test=new Database($id,'mod'); if ( $test->exist_table('version') ) { echo '

'._('Restauration réussie du dossier ').$lname.'

'; $test->close(); } else { $test->close(); echo '

'._('Problème lors de la restauration ').$lname.'

'; $cn->exec_sql('delete from modeledef where mod_id=$1',array($id)); $cn->exec_sql('drop database '.$name); exit(); } $new_cn=new Database($id,'mod'); $new_cn->apply_patch($name); $new_cn->clean_orphan_lob(); echo ''._('Ne pas recharger la page, sinon votre base de données sera restaurée une fois de plus').''; echo $retour; echo '
'; } } else { echo '
'; echo '
'; echo HtmlInput::hidden('action','restore'); echo HtmlInput::hidden('sa','r'); echo ''; echo ''; $wNom=new IText(); $wNom->name="database"; $wNom->size=30; echo ''; echo ''; $chk=new IRadio(); $chk->name="t"; $chk->value="d"; echo ''; echo ''; $chk->name="t"; $chk->value="m"; echo ''; echo ''; $file=new IFile(); $file->name="file"; $file->value="mod"; echo td(_('Fichier ')). td($file->input()); $desc=new ITextarea('desc'); echo ''; echo '
'._("Nom de la base de donnée").Icon_Action::infobulle(29) .''.$wNom->input().'
'._("Type de backup")." :".' '.$chk->input()._("Dossier").'
'.$chk->input()._("Modele").'
'; echo "

Description

"; $desc->heigh=4;$desc->width=60; echo $desc->input(); echo '

'; echo HtmlInput::submit("",_("Restauration")); echo '

'; echo '
'; echo '
'; }