<?php
	
		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;

		//$fichier = '/homez.65/analogde/www/Massage/Backup/auto_db-backup-v3_'.$infos.'.sql';
		
		$fichier = "/homez.65/analogde/www/" .$appli_path ."/Backup/auto_db_backup_v3_" .$infos. ".sql";
		echo $fichier;
		
		$current_year = date('Y'); 
		$table = "reservation" .$current_year ."_v3";
		
		$cmd = "mysqldump --host=analogdepat.mysql.db --user=analogdepat --password=Un92pac007 --default-character-set=utf8 analogdepat configuration_v3 client gestion_v3 " .$table ." > $fichier";
		
		
		//system("mysqldump --host=analogdepat.mysql.db --user=analogdepat --password=Un92pac007 --default-character-set=utf8 //analogdepat configuration_v3 client gestion_v3 reservation2017_v3 > $fichier");
	
		system($cmd);
	
?>