
<?php

	$SITE_ID				= $_POST['SITE_ID'];
	$remote_table_cible = $_POST['remote_table_cible'];
	$remote_backupFile  = $_POST['remote_backupFile'];

	$encoded_file       = $_POST['file'];
	$decoded_file       = base64_decode($encoded_file);

	file_put_contents($remote_backupFile, $decoded_file);

	include ("../_identifiants/sql_identification_sans_base.php");
	$mysql_base ='AQCM05_SITE_' . $SITE_ID ;

	$link = new mysqli($mysql_host, $mysql_user, $mysql_password, $mysql_base);
	
	if ( $link -> connect_errno > 0 ) {
		
		echo( "NOK1 : " . $mysql_base );
		
	} 
	else {
		
		$query = $decoded_file;

		$result = mysqli_query($link, $query);

		if ( $result ) {
			echo( "OK" );
		} else {
			echo( "NOK2 : " . $mysql_base );
		}

		mysqli_close($link);
		
	}

?>
