Skip to content

Commit

Permalink
1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicola1971 committed Oct 19, 2017
1 parent 8834bbd commit d4a8029
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 2 deletions.
38 changes: 38 additions & 0 deletions assets/snippets/evobackup/download.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
// set this to YOUR modx backup directory, root directory is NOT secure
include_once(dirname(__FILE__).'/settings.php');


$filename = isset($_GET['filename']) ? $_GET['filename']:'';
$filename = $modx_backup_dir.$filename;
$file_extension = strtolower(substr(strrchr($filename,"."),1));

if (!file_exists( $filename ) )
{
die("NO FILE HERE ");
};
switch( $file_extension )
{
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpe": case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
}
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=".basename($filename).";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".@filesize($filename));
@readfile("$filename") or die("File not found.");
exit();
?>
38 changes: 38 additions & 0 deletions assets/snippets/evobackup/downloadsql.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
// set this to YOUR modx backup directory, root directory is NOT secure
include_once(dirname(__FILE__).'/settings.php');


$filename = isset($_GET['filename']) ? $_GET['filename']:'';
$filename = $modx_db_backup_dir.$filename;
$file_extension = strtolower(substr(strrchr($filename,"."),1));

if (!file_exists( $filename ) )
{
die("NO FILE HERE ");
};
switch( $file_extension )
{
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpe": case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
}
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=".basename($filename).";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".@filesize($filename));
@readfile("$filename") or die("File not found.");
exit();
?>
43 changes: 43 additions & 0 deletions assets/snippets/evobackup/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* EvoBackup Settings
* v1.2
*/

$modx_backup_dir = $_SERVER['DOCUMENT_ROOT'].'/_evobackup_archives/';
$modx_db_backup_dir = $_SERVER['DOCUMENT_ROOT'].'/assets/backup/';
// Generate Archive(s) within subdir of backup directory - ie /backup_dir/site1/site1_date1_db.zip
// /site1/site1_date2_db.zip
// /site2/site2_date1_db.zip

// ---- RETURN IF NO SITENAME------ USED FOR DOWNLOAD
if (!isset($site_name) || $site_name=='') {
return;
}

// Archive file name prefix - 5mar07 - change to default site name
$archive_prefix = (isset($archive_prefix))? $archive_prefix: @$site_name;

// Suffix to add to archive name (ie modxbackup12-11-2005-1735) .zip will be added to output file
$archive_suffix = (isset($archive_suffix))? $archive_suffix: '_'.date('Y-m-d-Hi');

// sql database filename
// 5mar07 - change from database_backup.sql to sitename.sql - robstemp
$database_filename = (isset($database_filename))? $database_filename:@$site_name.'.sql';

// Table Prefix
$table_prefix = (isset($table_prefix))? $table_prefix: @$GLOBALS['table_prefix'];

// include Log table data in database backup, these tables can be quite large, so default is to exclude them
$dump_log_tables = false;

// temporary file for archive, this is created and then renamed if zip is successfull
$tempfile = $modx_backup_dir.'tmpbackup.zip';

// memory / time settings
$zip_time_limit = 250;
$zip_memory_limit = '12M';
$db_time_limit = 250;
$db_memory_limit = '12M';

?>
8 changes: 6 additions & 2 deletions install/assets/snippets/RunEvoAutoBackup.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Execute a backup of Evo
*
* @author Nicola Lambathakis
* @version 1.3
* @version 1.4
* @category snippet
* @internal @modx_category admin
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL)
Expand Down Expand Up @@ -527,7 +527,11 @@ EOD;
if ($sendEmail == 'yes') {
$to = $SendTo;
$sitename = $modx->config['site_name'];
$txt = "<h1>".$subject."</h1><a href=\"".$modx->config['site_url']."assets/modules/evobackup/downloadsql.php?filename=".basename($database_filename)."\">Download Backup</a>";
if ($mode == 'dbonly') {
$txt = "<h1>".$subject."</h1><a href=\"".$modx->config['site_url']."assets/snippets/evobackup/downloadsql.php?filename=".basename($database_filename)."\">Download Database Backup</a>";
}
else {$txt = "<h1>".$subject."</h1><a href=\"".$modx->config['site_url']."assets/snippets/evobackup/download.php?filename=".basename($database_filename)."\">Download Site Backup</a>";
}
$msg = wordwrap($txt,255);
$headers = "From: ".$modx->config['emailsender']."" . "\r\n" .
"CC: ".$SendToCC."";
Expand Down

0 comments on commit d4a8029

Please sign in to comment.