$string
\r\n"; $mail_log .= $return; echo $return; return; } $clonerPath = $_CONFIG['clonerPath']; logxx("Starting XCloner for site $mosConfig_live_site at ".date("Y-m-d H:i")); $excludedFolders = array(); $d_arr = array(); $d = 0; $ds_arr = array(); $f_arr = array(); $f = 0; $s_arr = array(); $s = 0; $d_arr[$d] = $_CONFIG['backup_path']; #logxx("Reading the file structure"); #recurseFiles($d_arr, $ds_arr, $f_arr, $s_arr, $d, $f, $s, $excludefolders, ''); #$excludedFolders = confirmBackup('nohtml'); #logxx("Done"); if($_CONFIG['cron_btype']==0){ $_REQUEST[dbbackup] = 1; logxx("Creating a fullbackup"); $msg = 'full backup'; } if($_CONFIG['cron_btype']==1){ $_REQUEST[dbbackup] = 0; logxx("Creating a files only backup"); $msg = 'file backup'; } if($_CONFIG['cron_btype']==2){ $_REQUEST[dbbackup] = 1; #for ($i=0, $n=count($excludedFolders); $i < $n; $i++) { $_CONFIG['cron_exclude'] = $_CONFIG['backup_path']; $GLOBALS['_CONFIG'] = $_CONFIG; $_REQUEST[cron_dbonly] = 1; #} logxx("Creating an sql only backup"); $msg = "database backup"; } logxx("Generating Backup ..."); $file = generateBackup( $excludedFolders, 'nohtml' ); logxx("Backup Done"); $source_file = $clonerPath."/".$file; logxx("Backup file: ".$source_file); $bsize = getFileSizeText(filesize($source_file)); if($_CONFIG['cron_send']==1){ ######################################STARTING FTP TRANSFER################## logxx("Starting ftp transfer:"); $source_files[] = $source_file; $destination_files[] = $_CONFIG[cron_ftp_path]."/".$file; // set up basic connection details list($fhost, $fport) = explode(":",$_CONFIG[cron_ftp_server]); if($fport == "") $fport = '21'; $ftp_timeout = '3600'; // set up basic connection if(!$_CONFIG[secure_ftp]){ $conn_id = ftp_connect($fhost, (int)$fport, (int)$ftp_timeout); $connect = "Normal"; } else{ $conn_id = ftp_ssl_connect($fhost, (int)$fport, (int)$ftp_timeout); $connect = "Secure"; } //$conn_id = ftp_connect($_CONFIG[cron_ftp_server]) or die("Could not connect to the ftp server ".$_CONFIG[cron_ftp_server]); // login with username and password $login_result = ftp_login($conn_id, $_CONFIG[cron_ftp_user], $_CONFIG[cron_ftp_pass]) or die("Authentification failed when connecting to the ftp server for user ".$_CONFIG[cron_ftp_user]." with pass".$_CONFIG[cron_ftp_pass]); // check connection if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to ".$_CONFIG[cron_ftp_server]." for user ".$_CONFIG[cron_ftp_user].""; return; } else { #echo "Connected to $_REQUEST[ftp_server], for user $_REQUEST[ftp_user]"; } if($_CONFIG['system_ftptransfer']==1) { // turn passive mode on @ftp_pasv($conn_id, true); $mode = "Passive"; } else { // turn passive mode off @ftp_pasv($conn_id, false); $mode = "Active"; } echo "Connected to $connect $_CONFIG[cron_ftp_server] Mode: $mode
"; for($i=0;$iFTP upload has failed for file $source_files[$i] ! Stopping ....
";return; } else { echo "Upload success from file $source_files[$i]
to $destination_files[$i] ...
"; } } // close the FTP stream ftp_close($conn_id); logxx("Ftp transfer finished succesfully!"); if($_CONFIG[cron_ftp_delb]==1){ @unlink($source_file); logxx("Backup succesfully deleted from the original server!"); } ############################################################################## } elseif($_CONFIG['cron_send']==2){ #######################################STARTING Email TRANSFER################ logxx("Sending mail with backup"); $date = date("Y-m-d H:i"); $mode = '1'; $message = "
    Attached is the backup generated on $date
    Source Filename: $source_file
    Server: $mosConfig_live_site
    
    Powered by http://www.xcloner.com - XCloner - Backup and Restore made easy!
    
"; $ok = send_mail($mosConfig_mailfrom, "XCloner $msg", $message, $_CONFIG['cron_email_address'], $source_file); #echo mosMail( $mosConfig_mailfrom, $mosConfig_fromname, $_CONFIG['cron_email_address'], "XCloner $msg", $message, $mode, '', '' ); if($ok) logxx("Mail sent to ".$_CONFIG['cron_email_address']); else logxx("There was an error in sending the mail cron to ".$_CONFIG['cron_email_address']); ############################################################################## } logxx("Total backup size:".$bsize); ####### STARING AMAZON S3 MODE if($_CONFIG['cron_amazon_active']){ include_once("classes/S3.php"); logxx(); if(!$_CONFIG['cron_amazon_ssl']) $amazon_ssl = false; else $amazon_ssl = true; $s3 = new S3($_CONFIG['cron_amazon_awsAccessKey'], $_CONFIG['cron_amazon_awsSecretKey'], (int)$amazon_ssl); logxx("AMAZON S3: Starting communication with the Amazon S3 server...ssl mode ".$amazon_ssl); $buckets = $s3->listBuckets(); if (($s3->putBucket($_CONFIG['cron_amazon_bucket'], "private")) || (@in_array($_CONFIG['cron_amazon_bucket'], $buckets))) { if ($s3->putObjectFile($clonerPath."/".$file, $_CONFIG['cron_amazon_bucket'], $_CONFIG['cron_amazon_dirname']."/".baseName($file), "private")){ logxx("AMAZON S3: File copied to {".$_CONFIG['cron_amazon_bucket']."}/".$_CONFIG['cron_amazon_dirname']."/".$file); }else { logxx("AMAZON S3: Failed to copy file to {".$_CONFIG['cron_amazon_bucket']."}/".$_CONFIG['cron_amazon_dirname']."/".$file);exit; } }else{ logxx("AMAZON S3: Unable to create bucket ".$_CONFIG['cron_amazon_bucket']." (it may already exist and/or be owned by someone else)!");exit; } } ###### END ######## DELETING OLDER BACKUPS ############################################## if($_CONFIG['cron_file_delete_act']){ logxx("
\nDeleting older backups than ".$_CONFIG['cron_file_delete']." days: "); delete_older_backups($clonerPath); } ###################END OLDER BACKUPS $logemail = explode(";", $_CONFIG['cron_logemail']); if(sizeof($logemail)>0){ for($i=0; $i\n"; if(mail($email, $email_subject, strip_tags($mail_log), $headers)){ logxx ("Notification Mail was sent to $email"); } } } } logxx("
\n\nALL DONE! I will exit now from cron."); exit; ?> "; if($fileatt != ""){ if($file = @fopen($fileatt,'rb')){ $data = fread($file,filesize($fileatt)); fclose($file); } else{ logxx("Unable to open file $fileatt"); } } $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_txt . "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; $ok = mail($email_to, $email_subject, $email_message, $headers); return $ok; } ?>