<?php
ini_set('max_execution_time', 1200);
#### Local database settings
$dbhost   = "localhost";
$dbuser   = "root";
$dbpwd    = "nugsoft256";
$dbname   = "shop";

#### Remote database settings
#### Make sure to allow connections from localhost
#### on your remote server...
$dbServerName = "poscream.com";
$dbUsername = "poscream_poscream";
$dbPassword = "!@#$%12345qwert";
$dbName = "poscream_poscream";

###### file settings..
$dumpfile = "poscream_poscream". ".sql";

passthru("C:/wamp64/bin/mysql/mysql5.7.26/bin/mysqldump --opt --host=$dbhost --user=$dbuser --password=$dbpwd $dbname > $dumpfile");
// report - disable with // if not needed
// must look like "-- Dump completed on ..."

#### Check for internet connection...
$response = null;
system("ping -c 1 google.com", $response);
if($response == 0){
    exec("C:/wamp64/bin/mysql/mysql5.7.26/bin/mysql  --host=$dbServerName --user=$dbUsername --password=$dbPassword $dbName < $dumpfile");
      echo "<script type='text/javascript'>alert('Synchronisation Finished Successfully.Press Ok to redirect Home')</script>";
				   echo "<script>document.location='../main/dashboard.php'</script>";

}else{
   echo "<script type='text/javascript'>alert('Synchronisation Failed. Check your internet connection')</script>";
				   echo "<script>document.location='../main/dashboard.php'</script>";
}
?>
