#!/usr/local/bin/php
<?php
		header( 'content-type: text/html; charset=utf-8' );

		error_reporting(0);
		date_default_timezone_set('Europe/Paris');

		$site = $_SERVER["SERVER_NAME"];
		if( ($site == "localhost") || ($site == "127.0.0.1") ) 
		{

			$db_host    = "localhost";
			$db_user   = "root";
			$db_pass   = ""; 
			$db_name   = "test";
		}
		else
		{

			$db_host    = "analogdepat.mysql.db";
			$db_user   = "analogdepat";
			$db_pass   = "Un92pac007";
			$db_name   = "analogdepat";
		}

		$jour = date('d-m-Y');
		$heure = date("H_i_s");
		$infos = $jour.'-'.$heure;
		$fichier = 'db-backup-v3-'.$infos.'.sql';
	
		$path = getcwd();
		$dirs = explode('/', $path);
		$size = sizeof($dirs);
		$appli_path = $dirs[$size - 1];
			
		// Chemin absolu de l'emplacement du site
		//$chemin_absolu_site = 'www' ;
		
		//$repertoire_sauvegardes = $chemin_absolu_site."/".$appli_path."/Backup/" ; 
		//echo $repertoire_sauvegardes;

		
		//echo $fichier;
		
/*	12 Novembre	

		$current_year = date('Y'); 
		$table = "reservation" .$current_year ."_v3";
		
		// on sauvegarde la table reservation de l'année en court car les années précédentes ne sont plus modifiables
		// met uniquement consultables
		
		// essai
		
		// code 1
		$fichier = "/homez.65/analogde/www/" .$appli_path ."/Backup/auto_db_backup_v3_" .$infos. ".sql";

		$cmd = "mysqldump --host=analogdepat.mysql.db --user=analogdepat --password=Un92pac007 --default-character-set=utf8 analogdepat configuration_v3 client gestion_v3 " .$table ." > $fichier";
		//system($cmd);

		/// code 2
		$fichier = '/homez.65/analogde/www/Massage/Backup/auto_db-backup-v3_'.$infos.'.sql';
		system("mysqldump --host=analogdepat.mysql.db --user=analogdepat --password=Un92pac007 --default-character-set=utf8 analogdepat configuration_v3 client gestion_v3 reservation2017_v3 > $fichier");

/*	12 Novembre	 */

	
	///// essai du 12 Novembre
		$fichier = '/homez.65/analogde/www/Massage/Backup/auto_db-backup-v3_'.$infos.'.sql';
		system("mysqldump --host=analogdepat.mysql.db --user=analogdepat --password=Un92pac007 --default-character-set=utf8 analogdepat configuration_v3 client gestion_v3 reservation2015_v3 reservation2016_v3 reservation2017_v3 > $fichier");
	
	
		
	
?>