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 
00038 /*!\file
00039  * \brief Make and restore backup
00040  */
00041 if ( isset ($_REQUEST['sa']) )
00042 {
00043     if ( defined ('PG_PATH') )
00044         putenv("PATH=".PG_PATH);
00045 
00046 
00047     if ( ! isset ($_REQUEST['d']) ||
00048             ! isset($_REQUEST['t']))
00049     {
00050         echo "Erreur : paramètre manquant ";
00051         exit();
00052     }
00053 
00054     $sa=$_REQUEST['sa'];
00055     // backup
00056     if ( $sa=='b')
00057     {
00058         $cmd=escapeshellcmd (PG_DUMP);
00059         if ( defined ("noalyss_user"))
00060         {
00061             putenv("PGPASSWORD=".noalyss_password);
00062             putenv("PGUSER=".noalyss_user);
00063             putenv("PGHOST=".noalyss_psql_host);
00064             putenv("PGPORT=".noalyss_psql_port);
00065         }else if (defined ("phpcompta_user"))
00066         {
00067             putenv("PGPASSWORD=".phpcompta_password);
00068             putenv("PGUSER=".phpcompta_user);
00069             putenv("PGHOST=".phpcompta_psql_host);
00070             putenv("PGPORT=".phpcompta_psql_port);
00071         } else  {
00072         die ('Aucune connection');
00073         }
00074         
00075         if ( $_REQUEST['t'] == 'd' )
00076         {
00077             $database=domaine."dossier".$_REQUEST['d'];
00078             $args= " -Fc -Z9 --no-owner -h ".getenv("PGHOST")." -p ".getenv("PGPORT")." ".$database;
00079             header('Content-type: application/octet');
00080             header('Content-Disposition:attachment;filename="'.$database.'.bin"',FALSE);
00081 
00082             passthru ($cmd.$args,$a);
00083 
00084         }
00085 
00086         if ( $_REQUEST['t'] == 'm' )
00087         {
00088             $database=domaine."mod".$_REQUEST['d'];
00089             $args= " -Fc -Z9 --no-owner -h ".getenv("PGHOST")." -p ".getenv("PGPORT")." ".$database;
00090             header('Content-type: bin/x-application');
00091             header('Content-Disposition: attachment;filename="'.$database.'.bin"',FALSE);
00092             $a=passthru ($cmd.$args);
00093         }
00094     }
00095 }
00096 
 All Data Structures Namespaces Files Functions Variables Enumerations