SGINoticeAdapter.php
5 years ago
SGNotice.php
5 years ago
SGNoticeAdapterWordpress.php
5 years ago
SGNoticeHandler.php
5 years ago
SGNoticeHandler.php
79 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 | $this->checkTables(); |
| 12 | $this->checkPingFilePermission(); |
| 13 | } |
| 14 | |
| 15 | private function checkTimeoutError() |
| 16 | { |
| 17 | $pluginCapabilities = backupGuardGetCapabilities(); |
| 18 | if (SGConfig::get('SG_EXCEPTION_TIMEOUT_ERROR')) { |
| 19 | if ($pluginCapabilities != BACKUP_GUARD_CAPABILITIES_FREE) { |
| 20 | SGNotice::getInstance()->addNoticeFromTemplate('timeout_error', SG_NOTICE_ERROR, true); |
| 21 | } |
| 22 | else { |
| 23 | SGNotice::getInstance()->addNoticeFromTemplate('timeout_free_error', SG_NOTICE_ERROR, true); |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | public function checkTables() |
| 29 | { |
| 30 | if (!checkAllMissedTables()) { |
| 31 | SGNotice::getInstance()->addNoticeFromTemplate('missed_table', SG_NOTICE_ERROR, true); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | private function checkMigrationError() |
| 36 | { |
| 37 | if (SGConfig::get('SG_BACKUP_SHOW_MIGRATION_ERROR')) { |
| 38 | SGNotice::getInstance()->addNoticeFromTemplate('migration_error', SG_NOTICE_ERROR, true); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | private function checkRestoreNotWritableError() |
| 43 | { |
| 44 | if (SGConfig::get('SG_BACKUP_SHOW_NOT_WRITABLE_ERROR')) { |
| 45 | SGNotice::getInstance()->addNoticeFromTemplate('restore_notwritable_error', SG_NOTICE_ERROR, true); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | private function checkLiteSpeedWarning() |
| 50 | { |
| 51 | $server = ''; |
| 52 | if (isset($_SERVER['SERVER_SOFTWARE'])) { |
| 53 | $server = strtolower($_SERVER['SERVER_SOFTWARE']); |
| 54 | } |
| 55 | |
| 56 | //check if LiteSpeed server is running |
| 57 | if (strpos($server, 'litespeed') !== false) { |
| 58 | $htaccessContent = ''; |
| 59 | if (is_readable(ABSPATH.'.htaccess')) { |
| 60 | $htaccessContent = @file_get_contents(ABSPATH.'.htaccess'); |
| 61 | if (!$htaccessContent) { |
| 62 | $htaccessContent = ''; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | if (!$htaccessContent || !preg_match('/noabort/i', $htaccessContent)) { |
| 67 | SGNotice::getInstance()->addNoticeFromTemplate('litespeed_warning', SG_NOTICE_WARNING); |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | private function checkPingFilePermission() |
| 73 | { |
| 74 | if (file_exists(SG_PING_FILE_PATH) && !is_readable(SG_PING_FILE_PATH)) { |
| 75 | SGNotice::getInstance()->addNoticeFromTemplate('ping_permission', SG_NOTICE_ERROR, true); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 |