SGINoticeAdapter.php
6 years ago
SGNotice.php
6 years ago
SGNoticeAdapterWordpress.php
6 years ago
SGNoticeHandler.php
6 years ago
SGNoticeHandler.php
63 lines
| 1 | <?php |
| 2 | |
| 3 | class SGNoticeHandler |
| 4 | { |
| 5 | public function run() |
| 6 | { |
| 7 | $this->checkTimeoutError(); |
| 8 | $this->checkMigrationError(); |
| 9 | $this->checkRestoreNotWritableError(); |
| 10 | $this->checkLiteSpeedWarning(); |
| 11 | } |
| 12 | |
| 13 | private function checkTimeoutError() |
| 14 | { |
| 15 | $pluginCapabilities = backupGuardGetCapabilities(); |
| 16 | if (SGConfig::get('SG_EXCEPTION_TIMEOUT_ERROR')) { |
| 17 | if ($pluginCapabilities != BACKUP_GUARD_CAPABILITIES_FREE) { |
| 18 | SGNotice::getInstance()->addNoticeFromTemplate('timeout_error', SG_NOTICE_ERROR, true); |
| 19 | } |
| 20 | else { |
| 21 | SGNotice::getInstance()->addNoticeFromTemplate('timeout_free_error', SG_NOTICE_ERROR, true); |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | private function checkMigrationError() |
| 27 | { |
| 28 | if (SGConfig::get('SG_BACKUP_SHOW_MIGRATION_ERROR')) { |
| 29 | SGNotice::getInstance()->addNoticeFromTemplate('migration_error', SG_NOTICE_ERROR, true); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | private function checkRestoreNotWritableError() |
| 34 | { |
| 35 | if (SGConfig::get('SG_BACKUP_SHOW_NOT_WRITABLE_ERROR')) { |
| 36 | SGNotice::getInstance()->addNoticeFromTemplate('restore_notwritable_error', SG_NOTICE_ERROR, true); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | private function checkLiteSpeedWarning() |
| 41 | { |
| 42 | $server = ''; |
| 43 | if (isset($_SERVER['SERVER_SOFTWARE'])) { |
| 44 | $server = strtolower($_SERVER['SERVER_SOFTWARE']); |
| 45 | } |
| 46 | |
| 47 | //check if LiteSpeed server is running |
| 48 | if (strpos($server, 'litespeed') !== false) { |
| 49 | $htaccessContent = ''; |
| 50 | if (is_readable(ABSPATH.'.htaccess')) { |
| 51 | $htaccessContent = @file_get_contents(ABSPATH.'.htaccess'); |
| 52 | if (!$htaccessContent) { |
| 53 | $htaccessContent = ''; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | if (!$htaccessContent || !preg_match('/noabort/i', $htaccessContent)) { |
| 58 | SGNotice::getInstance()->addNoticeFromTemplate('litespeed_warning', SG_NOTICE_WARNING); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 |