<?php

//extract to dbpub

include ('../core/connect.php');



if ($password==''){$passtoshow='';}

else {$passtoshow="-p".$password;}



if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {

exec("c:\wamp\bin\mysql\mysql5.6.17\bin\mysqldump -u root ".$passtoshow." --ignore-table=scf.useractivity ".$dbext." > c:\wamp\www\scf\main\dbup\scf.sql",$output,$return);

} else {

    echo 'This server is not using Windows!';

}



if(!$return){echo "<span style='color:#339900'><h3>||>>Local System Backup Completed Successfully!</h3></span>";}

else{echo "<span style='color:#FF0000'><h3>||>>Local System Backup has Failed!</h3></span>";}

// Ref : http://php.net/manual/en/function.ftp-put.php

set_time_limit(1200);

$path="dbup/";

$localname="scf";

$extension="sql";

$filename = $path.$localname.".".$extension;

$name = $localname.date('y-m-d_h-i-s').".".$extension;



$startTime = microtime(true);

//-- Code to Transfer File on Server Dt: 06-03-2008 by Aditya Bhatt --//

//-- Connection Settings

$ftp_server = "ftp.kinglinepress.com"; // Address of FTP server.

$ftp_user_name = "ksync@apps.kinglinepress.com"; // Username

$ftp_user_pass = '0703611691k1Kq'; // Password

$destination_file = "../shire/"; //where you want to throw the file on the webserver (relative to your login dir)

$conn_id = ftp_connect($ftp_server) or die("<span style='color:#FF0000'><h2>Couldn't connect to $ftp_server</h2></span>");        // set up basic connection

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die("<span style='color:#FF0000'><h2>You do not have access to this ftp server!</h2></span>");   // login with username and password, or give invalid user message

if ((!$conn_id) || (!$login_result)) {  // check connection

    // wont ever hit this, b/c of the die call on ftp_login

    echo "<span style='color:#FF0000'><h2>FTP connection has failed! <br />";

    echo "Attempted to connect to $ftp_server for user $ftp_user_name</h2></span>";

    exit;

} else {

    //echo "Connected to $ftp_server, for user $ftp_user_name <br />";

}

ftp_pasv($conn_id,true);



if (!$return){

$upload = ftp_put($conn_id, $destination_file.$name, $filename, FTP_BINARY);  // upload the file



if (!$upload) {  // check upload status

    echo "<span style='color:#FF0000'><h3>||>>Online System Backup has failed!</h3></span> ";

} else {

    echo "<span style='color:#339900'><h3>||>>Online System Backup Completed Successfully!</h3></span>";

}



/*stuff is going on*/



$secondstaken=(microtime(true) - $startTime);

$minutestaken=((microtime(true) - $startTime)/60);

echo "Elapsed time is: ". number_format((microtime(true) - $startTime),1) ." seconds<br />

That's approximately ". number_format($minutestaken,1). " minutes";

}

ftp_close($conn_id); // close the FTP stream    