| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (!defined('ABSPATH')) exit; |
| 4 | -if (!class_exists('WPRCallbackHandler')) : | |
| 4 | +if (!class_exists('BVCallbackHandler')) : | |
| 5 | 5 | |
| 6 | - class WPRCallbackHandler { | |
| 6 | + class BVCallbackHandler { | |
| 7 | 7 | public $db; |
| 8 | 8 | public $settings; |
| 9 | 9 | public $siteinfo; |
| 10 | 10 | public $request; |
| @@ -46,133 +46,65 @@ | ||
| 46 | 46 | ); |
| 47 | 47 | $this->response->terminate($resp); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function deferExecutionUntilShutdown() { | |
| 51 | - if (function_exists('error_clear_last')) { | |
| 52 | - error_clear_last(); | |
| 53 | - } | |
| 54 | - ob_start(); | |
| 55 | - remove_action('shutdown', 'wp_ob_end_flush_all', 1); | |
| 56 | - add_action('shutdown', array($this, 'scheduleExecutionAfterShutdown'), PHP_INT_MAX); | |
| 57 | - } | |
| 58 | - | |
| 59 | - public function scheduleExecutionAfterShutdown() { | |
| 60 | - register_shutdown_function(array($this, 'executeAfterShutdown')); | |
| 61 | - } | |
| 62 | - | |
| 63 | - public function executeAfterShutdown() { | |
| 64 | - if ($this->request->keep_page_output) { | |
| 65 | - $this->removeContentLengthHeader(); | |
| 66 | - $this->execute(); | |
| 67 | - return; | |
| 68 | - } | |
| 69 | - if ($this->shouldPreserveFrontendResponse()) { | |
| 70 | - return; | |
| 71 | - } | |
| 72 | - $this->discardBufferedOutput(); | |
| 73 | - $this->clearFrontendResponseHeaders(); | |
| 74 | - $this->execute(); | |
| 75 | - } | |
| 76 | - | |
| 77 | - private function shouldPreserveFrontendResponse() { | |
| 78 | - if ($this->hasFatalError() || headers_sent()) { | |
| 79 | - return true; | |
| 80 | - } | |
| 81 | - if (!function_exists('http_response_code')) { | |
| 82 | - return false; | |
| 83 | - } | |
| 84 | - $response_code = http_response_code(); | |
| 85 | - return $response_code !== false && $response_code !== 200; | |
| 86 | - } | |
| 87 | - | |
| 88 | - private function hasFatalError() { | |
| 89 | - $error = error_get_last(); | |
| 90 | - $fatal_types = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR); | |
| 91 | - return is_array($error) && in_array($error['type'], $fatal_types, true); | |
| 92 | - } | |
| 93 | - | |
| 94 | - private function discardBufferedOutput() { | |
| 95 | - while (ob_get_level() > 0) { | |
| 96 | - if (!@ob_end_clean()) { | |
| 97 | - break; | |
| 98 | - } | |
| 99 | - } | |
| 100 | - } | |
| 101 | - | |
| 102 | - private function clearFrontendResponseHeaders() { | |
| 103 | - $this->removeContentLengthHeader(); | |
| 104 | - header_remove('Content-Encoding'); | |
| 105 | - header_remove('Location'); | |
| 106 | - } | |
| 107 | - | |
| 108 | - private function removeContentLengthHeader() { | |
| 109 | - if (!headers_sent()) { | |
| 110 | - header_remove('Content-Length'); | |
| 111 | - } | |
| 112 | - } | |
| 113 | - | |
| 114 | 50 | public function routeRequest() { |
| 115 | 51 | switch ($this->request->wing) { |
| 116 | 52 | case 'manage': |
| 117 | 53 | require_once dirname( __FILE__ ) . '/wings/manage.php'; |
| 118 | - $module = new WPRManageCallback($this); | |
| 54 | + $module = new BVManageCallback($this); | |
| 119 | 55 | break; |
| 120 | 56 | case 'fs': |
| 121 | 57 | require_once dirname( __FILE__ ) . '/wings/fs.php'; |
| 122 | - $module = new WPRFSCallback($this); | |
| 58 | + $module = new BVFSCallback($this); | |
| 123 | 59 | break; |
| 124 | 60 | case 'db': |
| 125 | 61 | require_once dirname( __FILE__ ) . '/wings/db.php'; |
| 126 | - $module = new WPRDBCallback($this); | |
| 62 | + $module = new BVDBCallback($this); | |
| 127 | 63 | break; |
| 128 | 64 | case 'info': |
| 129 | 65 | require_once dirname( __FILE__ ) . '/wings/info.php'; |
| 130 | - $module = new WPRInfoCallback($this); | |
| 66 | + $module = new BVInfoCallback($this); | |
| 131 | 67 | break; |
| 132 | 68 | case 'dynsync': |
| 133 | 69 | require_once dirname( __FILE__ ) . '/wings/dynsync.php'; |
| 134 | - $module = new WPRDynSyncCallback($this); | |
| 70 | + $module = new BVDynSyncCallback($this); | |
| 135 | 71 | break; |
| 136 | 72 | case 'ipstr': |
| 137 | 73 | require_once dirname( __FILE__ ) . '/wings/ipstore.php'; |
| 138 | - $module = new WPRIPStoreCallback($this); | |
| 74 | + $module = new BVIPStoreCallback($this); | |
| 139 | 75 | break; |
| 140 | 76 | case 'wtch': |
| 141 | 77 | require_once dirname( __FILE__ ) . '/wings/watch.php'; |
| 142 | - $module = new WPRWatchCallback($this); | |
| 78 | + $module = new BVWatchCallback($this); | |
| 143 | 79 | break; |
| 144 | 80 | case 'brand': |
| 145 | 81 | require_once dirname( __FILE__ ) . '/wings/brand.php'; |
| 146 | - $module = new WPRBrandCallback($this); | |
| 82 | + $module = new BVBrandCallback($this); | |
| 147 | 83 | break; |
| 148 | 84 | case 'pt': |
| 149 | 85 | require_once dirname( __FILE__ ) . '/wings/protect.php'; |
| 150 | - $module = new WPRProtectCallback($this); | |
| 86 | + $module = new BVProtectCallback($this); | |
| 151 | 87 | break; |
| 152 | 88 | case 'act': |
| 153 | 89 | require_once dirname( __FILE__ ) . '/wings/account.php'; |
| 154 | - $module = new WPRAccountCallback($this); | |
| 90 | + $module = new BVAccountCallback($this); | |
| 155 | 91 | break; |
| 156 | 92 | case 'fswrt': |
| 157 | 93 | require_once dirname( __FILE__ ) . '/wings/fs_write.php'; |
| 158 | - $module = new WPRFSWriteCallback(); | |
| 94 | + $module = new BVFSWriteCallback(); | |
| 159 | 95 | break; |
| 160 | 96 | case 'actlg': |
| 161 | 97 | require_once dirname( __FILE__ ) . '/wings/actlog.php'; |
| 162 | - $module = new WPRActLogCallback($this); | |
| 98 | + $module = new BVActLogCallback($this); | |
| 163 | 99 | break; |
| 164 | 100 | case 'speed': |
| 165 | 101 | require_once dirname( __FILE__ ) . '/wings/speed.php'; |
| 166 | - $module = new WPRSpeedCallback($this); | |
| 102 | + $module = new BVSpeedCallback($this); | |
| 167 | 103 | break; |
| 168 | - case 'scrty': | |
| 169 | - require_once dirname( __FILE__ ) . '/wings/security.php'; | |
| 170 | - $module = new WPRSecurityCallback($this); | |
| 171 | - break; | |
| 172 | 104 | default: |
| 173 | 105 | require_once dirname( __FILE__ ) . '/wings/misc.php'; |
| 174 | - $module = new WPRMiscCallback($this); | |
| 106 | + $module = new BVMiscCallback($this); | |
| 175 | 107 | break; |
| 176 | 108 | } |
| 177 | 109 | $resp = $module->process($this->request); |
| 178 | 110 | if ($resp === false) { |
| @@ -188,5 +120,5 @@ | ||
| 188 | 120 | $this->response->addStatus("callbackresponse", $resp); |
| 189 | 121 | return 1; |
| 190 | 122 | } |
| 191 | 123 | } |
| 192 | -endif; | |
| 124 | +endif; | |