diff --git a/common/scripts/clean_empty_dirs.php b/common/scripts/clean_empty_dirs.php index faafdb135..3d25d89ba 100644 --- a/common/scripts/clean_empty_dirs.php +++ b/common/scripts/clean_empty_dirs.php @@ -1,58 +1,8 @@ isvalid = 'N'; -$args->list_count = 50; -$args->regdate_before = date('YmdHis', time() - ($days * 86400)); -while (true) -{ - $output = executeQueryArray('file.getFileList', $args); - if ($output->toBool()) - { - if ($output->data) - { - $oDB->begin(); - foreach ($output->data as $file_info) - { - $oFileController->deleteFile($file_info->file_srl); - } - $oDB->commit(); - - if ($output->page_navigation && $output->page_navigation->total_count == count($output->data)) - { - break; - } - } - else - { - break; - } - } - else - { - echo "Error while deleting garbage files older than $days days.\n"; - echo $output->getMessage() . "\n"; - $exit_status = 11; - break; - } -} -if ($exit_status == 0) -{ - echo "Successfully deleted all garbage files older than $days days.\n"; -} - -// Find and delete temporary chunks. -$dirname = RX_BASEDIR . 'files/attach/chunks'; -$threshold = time() - ($days * 86400); -$chunks = Rhymix\Framework\Storage::readDirectory($dirname); -if ($chunks) -{ - foreach ($chunks as $chunk) - { - if (@filemtime($chunk) < $threshold) - { - $result = Rhymix\Framework\Storage::delete($chunk); - if (!$result) - { - $exit_status = 12; - } - } - } -} -if ($exit_status == 0) -{ - echo "Successfully deleted aborted file chunks older than $days days.\n"; -} -else -{ - echo "Error while deleting aborted file chunks older than $days days.\n"; -} - -// Set the exit status if there were any errors. -if ($exit_status != 0) -{ - exit($exit_status); -} +require_once RX_BASEDIR . 'modules/file/scripts/cleanGarbageFiles.php'; diff --git a/common/scripts/clean_message_files.php b/common/scripts/clean_message_files.php index 2aa1dc012..d96bafbaa 100644 --- a/common/scripts/clean_message_files.php +++ b/common/scripts/clean_message_files.php @@ -1,63 +1,8 @@ upload_target_type = 'msg'; -$args->list_count = 50; -$args->regdate_before = date('YmdHis', time() - ($days * 86400)); -while (true) -{ - $output = executeQueryArray('file.getFileList', $args); - if ($output->toBool()) - { - if ($output->data) - { - $oDB->begin(); - foreach ($output->data as $file_info) - { - $oFileController->deleteFile($file_info->file_srl); - } - $oDB->commit(); - - if ($output->page_navigation && $output->page_navigation->total_count == count($output->data)) - { - break; - } - } - else - { - break; - } - } - else - { - echo "Error while deleting message attachments older than $days days.\n"; - echo $output->getMessage() . "\n"; - $exit_status = 11; - break; - } -} -if ($exit_status == 0) -{ - echo "Successfully deleted all message attachments older than $days days.\n"; -} +require_once RX_BASEDIR . 'modules/communication/scripts/cleanMessageFiles.php'; diff --git a/common/scripts/clean_old_logs.php b/common/scripts/clean_old_logs.php index a99eeb7a3..842eb2480 100644 --- a/common/scripts/clean_old_logs.php +++ b/common/scripts/clean_old_logs.php @@ -1,66 +1,8 @@ regdate = date('YmdHis', time() - ($days * 86400)); -$output = executeQuery('advanced_mailer.deleteMailLogs', $args); -if ($output->toBool()) -{ - echo "Successfully deleted all mail logs older than $days days.\n"; -} -else -{ - echo "Error while deleting mail logs older than $days days.\n"; - echo $output->getMessage() . "\n"; - $exit_status = 11; -} - -// Delete advanced mailer SMS logs. -$args = new stdClass; -$args->regdate = date('YmdHis', time() - ($days * 86400)); -$output = executeQuery('advanced_mailer.deleteSMSLogs', $args); -if ($output->toBool()) -{ - echo "Successfully deleted all SMS logs older than $days days.\n"; -} -else -{ - echo "Error while deleting SMS logs older than $days days.\n"; - echo $output->getMessage() . "\n"; - $exit_status = 12; -} - -// Delete spamfilter logs. -$args = new stdClass; -$args->regdate = date('YmdHis', time() - ($days * 86400)); -$output = executeQuery('spamfilter.deleteLog', $args); -if ($output->toBool()) -{ - echo "Successfully deleted all spamfilter logs older than $days days.\n"; -} -else -{ - echo "Error while deleting spamfilter logs older than $days days.\n"; - echo $output->getMessage() . "\n"; - $exit_status = 12; -} - -// Set the exit status if there were any errors. -if ($exit_status != 0) -{ - exit($exit_status); -} +require_once RX_BASEDIR . 'modules/module/scripts/cleanMiscLogs.php'; diff --git a/common/scripts/clean_old_notifications.php b/common/scripts/clean_old_notifications.php index 27a58efba..581fa74f6 100644 --- a/common/scripts/clean_old_notifications.php +++ b/common/scripts/clean_old_notifications.php @@ -1,40 +1,8 @@ old_date = date('YmdHis', time() - ($days * 86400)); -$output = executeQuery('ncenterlite.deleteNotifyAll', $args); -if ($output->toBool()) -{ - echo "Successfully deleted all notifications older than $days days.\n"; - $delete_obj = (object)array('regdate' => time()); - Rhymix\Framework\Cache::clearGroup('ncenterlite'); - Rhymix\Framework\Storage::writePHPData(\RX_BASEDIR . 'files/cache/ncenterlite/new_notify/delete_date.php', $delete_obj); -} -else -{ - echo "Error while deleting notifications older than $days days.\n"; - echo $output->getMessage() . "\n"; - $exit_status = 11; -} - -// Set the exit status if there were any errors. -if ($exit_status != 0) -{ - exit($exit_status); -} +require_once RX_BASEDIR . 'modules/ncenterlite/scripts/cleanNotifications.php'; diff --git a/common/scripts/clean_old_thumbnails.php b/common/scripts/clean_old_thumbnails.php index b36868973..52a27c087 100644 --- a/common/scripts/clean_old_thumbnails.php +++ b/common/scripts/clean_old_thumbnails.php @@ -1,41 +1,8 @@ getModuleList(); -$need_install = array(); -$need_update = array(); -foreach($module_list as $key => $value) -{ - if($value->need_install) - { - $need_install[] = $value->module; - } - if($value->need_update) - { - $need_update[] = $value->module; - } -} - -// Install all modules. -$oInstallController = InstallController::getInstance(); -foreach ($need_install as $module) -{ - try - { - echo 'Installing ' . $module . '...' . PHP_EOL; - $oInstallController->installModule($module, './modules/' . $module); - } - catch (\Exception $e) - { - echo 'Error: ' . $e->getMessage() . PHP_EOL; - } -} - -// Update all modules. -foreach ($need_update as $module) -{ - try - { - echo 'Updating ' . $module . '...' . PHP_EOL; - $oInstallController->updateModule($module); - } - catch (\Exception $e) - { - echo 'Error: ' . $e->getMessage() . PHP_EOL; - } -} - -// Set the exit status if there were any errors. -if ($exit_status != 0) -{ - exit($exit_status); -} +require_once RX_BASEDIR . 'modules/module/scripts/updateAllModules.php'; diff --git a/modules/communication/scripts/cleanMessageFiles.php b/modules/communication/scripts/cleanMessageFiles.php new file mode 100644 index 000000000..c56ee3094 --- /dev/null +++ b/modules/communication/scripts/cleanMessageFiles.php @@ -0,0 +1,67 @@ + 'msg', + 'list_count' => 50, + 'regdate_before' => date('YmdHis', time() - ($days * 86400)), + ]); + + if ($output->toBool()) + { + if ($output->data) + { + $oDB->begin(); + foreach ($output->data as $file_info) + { + $oFileController->deleteFile($file_info->file_srl); + } + $oDB->commit(); + + if ($output->page_navigation && $output->page_navigation->total_count == count($output->data)) + { + break; + } + } + else + { + break; + } + } + else + { + echo "Error while deleting message attachments older than $days days.\n"; + echo $output->getMessage() . "\n"; + $exit_status = 11; + break; + } +} +if ($exit_status == 0) +{ + echo "Successfully deleted all message attachments older than $days days.\n"; +} diff --git a/modules/file/scripts/cleanEmptyDirs.php b/modules/file/scripts/cleanEmptyDirs.php new file mode 100644 index 000000000..ced824662 --- /dev/null +++ b/modules/file/scripts/cleanEmptyDirs.php @@ -0,0 +1,61 @@ + 'N', + 'list_count' => 50, + 'regdate_before' => date('YmdHis', time() - ($days * 86400)), + ]); + + if ($output->toBool()) + { + if ($output->data) + { + $oDB->begin(); + foreach ($output->data as $file_info) + { + $oFileController->deleteFile($file_info->file_srl); + } + $oDB->commit(); + + if ($output->page_navigation && $output->page_navigation->total_count == count($output->data)) + { + break; + } + } + else + { + break; + } + } + else + { + echo "Error while deleting garbage files older than $days days.\n"; + echo $output->getMessage() . "\n"; + $exit_status = 11; + break; + } +} +if ($exit_status == 0) +{ + echo "Successfully deleted all garbage files older than $days days.\n"; +} + +// Find and delete temporary chunks. +$dirname = RX_BASEDIR . 'files/attach/chunks'; +$threshold = time() - ($days * 86400); +$chunks = Rhymix\Framework\Storage::readDirectory($dirname); +if ($chunks) +{ + foreach ($chunks as $chunk) + { + if (@filemtime($chunk) < $threshold) + { + $result = Rhymix\Framework\Storage::delete($chunk); + if (!$result) + { + $exit_status = 12; + } + } + } +} +if ($exit_status == 0) +{ + echo "Successfully deleted temporary file chunks older than $days days.\n"; +} +else +{ + echo "Error while deleting temporary file chunks older than $days days.\n"; +} + +// Set the exit status if there were any errors. +if ($exit_status != 0) +{ + exit($exit_status); +} diff --git a/modules/file/scripts/cleanThumbnails.php b/modules/file/scripts/cleanThumbnails.php new file mode 100644 index 000000000..20cda9a32 --- /dev/null +++ b/modules/file/scripts/cleanThumbnails.php @@ -0,0 +1,44 @@ + date('YmdHis', time() - ($days * 86400)), +]); +if ($output->toBool()) +{ + echo "Successfully deleted all email logs older than $days days.\n"; +} +else +{ + echo "Error while deleting email logs older than $days days.\n"; + echo $output->getMessage() . "\n"; + $exit_status = 11; +} + +// Delete advanced mailer SMS logs. +$output = executeQuery('advanced_mailer.deleteSMSLogs', [ + 'regdate' => date('YmdHis', time() - ($days * 86400)), +]); +if ($output->toBool()) +{ + echo "Successfully deleted all SMS logs older than $days days.\n"; +} +else +{ + echo "Error while deleting SMS logs older than $days days.\n"; + echo $output->getMessage() . "\n"; + $exit_status = 12; +} + +// Delete advanced mailer Push logs. +$output = executeQuery('advanced_mailer.deletePushLogs', [ + 'regdate' => date('YmdHis', time() - ($days * 86400)), +]); +if ($output->toBool()) +{ + echo "Successfully deleted all Push logs older than $days days.\n"; +} +else +{ + echo "Error while deleting Push logs older than $days days.\n"; + echo $output->getMessage() . "\n"; + $exit_status = 13; +} + +// Delete spamfilter logs. +$output = executeQuery('spamfilter.deleteLog', [ + 'regdate' => date('YmdHis', time() - ($days * 86400)), +]); +if ($output->toBool()) +{ + echo "Successfully deleted all spamfilter logs older than $days days.\n"; +} +else +{ + echo "Error while deleting spamfilter logs older than $days days.\n"; + echo $output->getMessage() . "\n"; + $exit_status = 21; +} + +// Set the exit status if there were any errors. +if ($exit_status != 0) +{ + exit($exit_status); +} diff --git a/modules/module/scripts/updateAllModules.php b/modules/module/scripts/updateAllModules.php new file mode 100644 index 000000000..37ea4c2f6 --- /dev/null +++ b/modules/module/scripts/updateAllModules.php @@ -0,0 +1,67 @@ + $value) +{ + if ($value->need_install) + { + $need_install[] = $value->module; + } + if ($value->need_update) + { + $need_update[] = $value->module; + } +} + +// Install all modules. +$oInstallController = InstallController::getInstance(); +foreach ($need_install as $module) +{ + try + { + echo 'Installing ' . $module . '...' . PHP_EOL; + $oInstallController->installModule($module, './modules/' . $module); + } + catch (\Exception $e) + { + echo 'Error: ' . $e->getMessage() . PHP_EOL; + } +} + +// Update all modules. +foreach ($need_update as $module) +{ + try + { + echo 'Updating ' . $module . '...' . PHP_EOL; + $oInstallController->updateModule($module); + } + catch (\Exception $e) + { + echo 'Error: ' . $e->getMessage() . PHP_EOL; + } +} + +// Set the exit status if there were any errors. +if ($exit_status != 0) +{ + exit($exit_status); +} diff --git a/modules/ncenterlite/scripts/cleanNotifications.php b/modules/ncenterlite/scripts/cleanNotifications.php new file mode 100644 index 000000000..49253175a --- /dev/null +++ b/modules/ncenterlite/scripts/cleanNotifications.php @@ -0,0 +1,44 @@ + date('YmdHis', time() - ($days * 86400)), +]); + +if ($output->toBool()) +{ + echo "Successfully deleted all notifications older than $days days.\n"; + $delete_obj = (object)array('regdate' => time()); + Rhymix\Framework\Cache::clearGroup('ncenterlite'); + Rhymix\Framework\Storage::writePHPData(\RX_BASEDIR . 'files/cache/ncenterlite/new_notify/delete_date.php', $delete_obj); +} +else +{ + echo "Error while deleting notifications older than $days days.\n"; + echo $output->getMessage() . "\n"; + $exit_status = 11; +} + +// Set the exit status if there were any errors. +if ($exit_status != 0) +{ + exit($exit_status); +}