noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
backup.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 require_once '../include/constant.php';
00022 require_once("constant.php");
00023 require_once('class_database.php');
00024 require_once  ("class_user.php");
00025 require_once ('ac_common.php');
00026 
00027 $rep=new Database();
00028 $User=new User($rep);
00029 $User->Check();
00030 
00031 
00032 if ($User->admin != 1)
00033 {
00034     echo "<script>alert('"._("Vous n\'êtes pas administrateur")."') </script>";
00035     return;
00036 }
00037 $dossier_number=HtmlInput::default_value_request("d", 0);
00038 if ($dossier_number == 0  
00039    || isNumber($dossier_number) ==0 ) {
00040     die ('Invalid folder number');
00041 }
00042 /*!\file
00043  * \brief Make and restore backup
00044  */
00045 if ( isset ($_REQUEST['sa']) )
00046 {
00047     if ( defined ('PG_PATH') )
00048         putenv("PATH=".PG_PATH);
00049 
00050 
00051     if ( ! isset($_REQUEST['t']))
00052     {
00053         echo "Erreur : paramètre manquant ";
00054         exit();
00055     }
00056 
00057     $sa=$_REQUEST['sa'];
00058     // backup
00059     if ( $sa=='b')
00060     {
00061         $cmd=escapeshellcmd (PG_DUMP);
00062         if ( defined ("noalyss_user"))
00063         {
00064             putenv("PGPASSWORD=".noalyss_password);
00065             putenv("PGUSER=".noalyss_user);
00066             putenv("PGHOST=".noalyss_psql_host);
00067             putenv("PGPORT=".noalyss_psql_port);
00068         }else if (defined ("phpcompta_user"))
00069         {
00070             putenv("PGPASSWORD=".phpcompta_password);
00071             putenv("PGUSER=".phpcompta_user);
00072             putenv("PGHOST=".phpcompta_psql_host);
00073             putenv("PGPORT=".phpcompta_psql_port);
00074         } else  {
00075         die ('Aucune connection');
00076         }
00077         
00078         if ( $_REQUEST['t'] == 'd' )
00079         {
00080             $database=domaine."dossier".$dossier_number;
00081             $args= " -Fc -Z9 --no-owner -h ".getenv("PGHOST")." -p ".getenv("PGPORT")." ".$database;
00082             header('Content-type: application/octet');
00083             header('Content-Disposition:attachment;filename="'.$database.'.bin"',FALSE);
00084 
00085             passthru ($cmd.$args,$a);
00086 
00087         }
00088 
00089         if ( $_REQUEST['t'] == 'm' )
00090         {
00091             $database=domaine."mod".$dossier_number;
00092             $args= " -Fc -Z9 --no-owner -h ".getenv("PGHOST")." -p ".getenv("PGPORT")." ".$database;
00093             header('Content-type: bin/x-application');
00094             header('Content-Disposition: attachment;filename="'.$database.'.bin"',FALSE);
00095             $a=passthru ($cmd.$args);
00096         }
00097     }
00098 }
00099 
 All Data Structures Namespaces Files Functions Variables Enumerations