SGINoticeAdapter.php
6 years ago
SGNotice.php
6 years ago
SGNoticeAdapterWordpress.php
6 years ago
SGNoticeHandler.php
6 years ago
SGNoticeHandler.php
57 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 | if (SGConfig::get('SG_EXCEPTION_TIMEOUT_ERROR')) { |
| 16 | SGNotice::getInstance()->addNoticeFromTemplate('timeout_error', SG_NOTICE_ERROR, true); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | private function checkMigrationError() |
| 21 | { |
| 22 | if (SGConfig::get('SG_BACKUP_SHOW_MIGRATION_ERROR')) { |
| 23 | SGNotice::getInstance()->addNoticeFromTemplate('migration_error', SG_NOTICE_ERROR, true); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | private function checkRestoreNotWritableError() |
| 28 | { |
| 29 | if (SGConfig::get('SG_BACKUP_SHOW_NOT_WRITABLE_ERROR')) { |
| 30 | SGNotice::getInstance()->addNoticeFromTemplate('restore_notwritable_error', SG_NOTICE_ERROR, true); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | private function checkLiteSpeedWarning() |
| 35 | { |
| 36 | $server = ''; |
| 37 | if (isset($_SERVER['SERVER_SOFTWARE'])) { |
| 38 | $server = strtolower($_SERVER['SERVER_SOFTWARE']); |
| 39 | } |
| 40 | |
| 41 | //check if LiteSpeed server is running |
| 42 | if (strpos($server, 'litespeed') !== false) { |
| 43 | $htaccessContent = ''; |
| 44 | if (is_readable(ABSPATH.'.htaccess')) { |
| 45 | $htaccessContent = @file_get_contents(ABSPATH.'.htaccess'); |
| 46 | if (!$htaccessContent) { |
| 47 | $htaccessContent = ''; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | if (!$htaccessContent || !preg_match('/noabort/i', $htaccessContent)) { |
| 52 | SGNotice::getInstance()->addNoticeFromTemplate('litespeed_warning', SG_NOTICE_WARNING); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 |