<?php

	if ( $mode_simulation ) {
		
		echo("AQCM_create_firmware_to_PC : mode simulation..." . "</br>");
		
	}
	else {
		
		//--------------------------------------------------------------------------------------------------------
		$version_file_filename = '/var/www/html/v2/site_version.html' ;

		if (file_exists($version_file_filename)) {
			$cmd_1 = "sudo chmod 666 " . $version_file_filename ;
			$result_1 = exec($cmd_1, $exec_output_1, $exec_return_1);
		}
		
		$version_file = fopen($version_file_filename, 'w') or die("créationt du fichier de version du site : échec !");
		$version_texte = "_" . date("d_m_Y_H_i") ;
		fwrite($version_file, $version_texte . "\n");
		fclose($version_file);
		
		//-----------------------------------------------------------------------------------------
		// création du fichier AQCM05_firmware.zip dans /var/www/html/v2/tmp_files/
		//-----------------------------------------------------------------------------------------
		echo ('<b>→</b>&nbsp;&nbsp;&nbsp;création du fichier de firmware :'); flush() ;

		$cmd_1 = "sudo /home/scripts_shell/create_zipped_contabo.sh" ;
		
		$result_1 = exec($cmd_1, $exec_output_1, $exec_return_1);
		
		if ( $exec_return_1 ) {
			echo ('&nbsp;&nbsp;<font color="salmon" >échec !!!</font></br></br></br>'); flush() ;
		} 
		else {
			echo ('&nbsp;&nbsp;<font color="lime" >succès...</font></br></br></br>'); flush() ;
		}

		//-----------------------------------------------------------------------------------------
		// /home/firmware/CONTABO_server_v2.zip
		//-----------------------------------------------------------------------------------------
		echo ('<b>→</b>&nbsp;&nbsp;&nbsp;lien de téléchargement :'); flush() ;


		$fw_file_name_0	= "../tmp_files/CONTABO_server_v2.zip" ;
		$fw_file_name_1	= "AQCM05_SERVER_" . date("d_m_Y_H_i") . ".zip";
				
	 
		$koko_string = "<a href='" . $fw_file_name_0 . "' download='" . $fw_file_name_1 . "'  class='a_1' style='width:370px;margin-top:20px;margin-left:10px;margin-right:10px;text-align:center;' >" . $fw_file_name_1 . "</a>" ;
		
		echo( $koko_string ) ;

/*
*/

	}
	
?>
		
