From b6dfef6b62c67be807d07b726989c4aebca3b69c Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 6 Apr 2015 13:59:15 -0700 Subject: [PATCH] Scheduled Tasks: Database Backup now zips up the .sql file. --- e107_handlers/cron_class.php | 23 ++++++++++++++++++++--- e107_handlers/file_class.php | 8 +++++--- e107_handlers/pref_class.php | 8 ++++++++ e107_plugins/faqs/e_cron.php | 2 +- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/e107_handlers/cron_class.php b/e107_handlers/cron_class.php index 376fac7ca..9f8a78af9 100644 --- a/e107_handlers/cron_class.php +++ b/e107_handlers/cron_class.php @@ -231,9 +231,26 @@ class _system_cron { $sql = e107::getDb(); - $sql->backup('*'); - - + $file = $sql->backup('*'); + + if(empty($file)) + { + e107::getLog()->addError('Database Backup Failed:'.basename($file))->save('BACKUP'); + return; + } + + $zipFile = $file.".zip"; + e107::getFile()->zip(array($file),$zipFile, array('remove_path'=>e_BACKUP)); + + if(file_exists($zipFile)) + { + e107::getLog()->addSuccess('Database Backup Complete:'.basename($zipFile))->save('BACKUP'); + + if(is_file($file)) + { + unlink($file); + } + } return; diff --git a/e107_handlers/file_class.php b/e107_handlers/file_class.php index cf722375c..018f4f446 100644 --- a/e107_handlers/file_class.php +++ b/e107_handlers/file_class.php @@ -970,7 +970,7 @@ class e_file * @param string $newFile */ - public function zip($filePaths=null, $newFile='') + public function zip($filePaths=null, $newFile='', $options=array()) { if(empty($newFile)) { @@ -984,8 +984,10 @@ class e_file require_once(e_HANDLER.'pclzip.lib.php'); $archive = new PclZip($newFile); - - if ($archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH,e_BASE) == 0) + + $removePath = (!empty($options['remove_path'])) ? $options['remove_path'] : e_BASE; + + if ($archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH, $removePath) == 0) { $error = $archive->errorInfo(true); e107::getAdminLog()->addError($error)->save('FILE',E_LOG_NOTICE); diff --git a/e107_handlers/pref_class.php b/e107_handlers/pref_class.php index 388179526..770e0ef72 100644 --- a/e107_handlers/pref_class.php +++ b/e107_handlers/pref_class.php @@ -600,6 +600,14 @@ class e_pref extends e_front_model } $log->addSuccess('Settings successfully saved.', ($session_messages === null || $session_messages === true)); + + $uid = USERID; + + if(empty($uid)) // Log extra details of any pref changes made by a non-user. + { + $log->addWarning(print_r(debug_backtrace(null,2), true), false); + } + $log->save($logId); // if(!$disallow_logs) $log->logSuccess('Settings successfully saved.', true, $session_messages)->flushMessages($logId, E_LOG_INFORMATIVE, '', $this->prefid); diff --git a/e107_plugins/faqs/e_cron.php b/e107_plugins/faqs/e_cron.php index 94dbe96aa..e05f01d13 100644 --- a/e107_plugins/faqs/e_cron.php +++ b/e107_plugins/faqs/e_cron.php @@ -21,7 +21,7 @@ $cron[] = array( 'name' => "Unanswered Questions Report", //TODO LAN 'function' => "unanswered", - 'category' => "report", + 'category' => "notify", 'description' => "Mails a report of unanswered questions to ".e107::pref('core','siteadminemail').'.' // TODO LAN );