PluginProbe
The WP Remote WordPress Plugin / trunk
The WP Remote WordPress Plugin vtrunk
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
← All changes | callback/handler.php +85 -17 5.16trunk View file →
@@ -1,10 +1,10 @@
1 1 <?php
2 2
3 3 if (!defined('ABSPATH')) exit;
4 -if (!class_exists('BVCallbackHandler')) :
4 +if (!class_exists('WPRCallbackHandler')) :
5 5
6 - class BVCallbackHandler {
6 + class WPRCallbackHandler {
7 7 public $db;
8 8 public $settings;
9 9 public $siteinfo;
10 10 public $request;
@@ -46,65 +46,133 @@
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 +
50 114 public function routeRequest() {
51 115 switch ($this->request->wing) {
52 116 case 'manage':
53 117 require_once dirname( __FILE__ ) . '/wings/manage.php';
54 - $module = new BVManageCallback($this);
118 + $module = new WPRManageCallback($this);
55 119 break;
56 120 case 'fs':
57 121 require_once dirname( __FILE__ ) . '/wings/fs.php';
58 - $module = new BVFSCallback($this);
122 + $module = new WPRFSCallback($this);
59 123 break;
60 124 case 'db':
61 125 require_once dirname( __FILE__ ) . '/wings/db.php';
62 - $module = new BVDBCallback($this);
126 + $module = new WPRDBCallback($this);
63 127 break;
64 128 case 'info':
65 129 require_once dirname( __FILE__ ) . '/wings/info.php';
66 - $module = new BVInfoCallback($this);
130 + $module = new WPRInfoCallback($this);
67 131 break;
68 132 case 'dynsync':
69 133 require_once dirname( __FILE__ ) . '/wings/dynsync.php';
70 - $module = new BVDynSyncCallback($this);
134 + $module = new WPRDynSyncCallback($this);
71 135 break;
72 136 case 'ipstr':
73 137 require_once dirname( __FILE__ ) . '/wings/ipstore.php';
74 - $module = new BVIPStoreCallback($this);
138 + $module = new WPRIPStoreCallback($this);
75 139 break;
76 140 case 'wtch':
77 141 require_once dirname( __FILE__ ) . '/wings/watch.php';
78 - $module = new BVWatchCallback($this);
142 + $module = new WPRWatchCallback($this);
79 143 break;
80 144 case 'brand':
81 145 require_once dirname( __FILE__ ) . '/wings/brand.php';
82 - $module = new BVBrandCallback($this);
146 + $module = new WPRBrandCallback($this);
83 147 break;
84 148 case 'pt':
85 149 require_once dirname( __FILE__ ) . '/wings/protect.php';
86 - $module = new BVProtectCallback($this);
150 + $module = new WPRProtectCallback($this);
87 151 break;
88 152 case 'act':
89 153 require_once dirname( __FILE__ ) . '/wings/account.php';
90 - $module = new BVAccountCallback($this);
154 + $module = new WPRAccountCallback($this);
91 155 break;
92 156 case 'fswrt':
93 157 require_once dirname( __FILE__ ) . '/wings/fs_write.php';
94 - $module = new BVFSWriteCallback();
158 + $module = new WPRFSWriteCallback();
95 159 break;
96 160 case 'actlg':
97 161 require_once dirname( __FILE__ ) . '/wings/actlog.php';
98 - $module = new BVActLogCallback($this);
162 + $module = new WPRActLogCallback($this);
99 163 break;
100 164 case 'speed':
101 165 require_once dirname( __FILE__ ) . '/wings/speed.php';
102 - $module = new BVSpeedCallback($this);
166 + $module = new WPRSpeedCallback($this);
103 167 break;
168 + case 'scrty':
169 + require_once dirname( __FILE__ ) . '/wings/security.php';
170 + $module = new WPRSecurityCallback($this);
171 + break;
104 172 default:
105 173 require_once dirname( __FILE__ ) . '/wings/misc.php';
106 - $module = new BVMiscCallback($this);
174 + $module = new WPRMiscCallback($this);
107 175 break;
108 176 }
109 177 $resp = $module->process($this->request);
110 178 if ($resp === false) {
@@ -120,5 +188,5 @@
120 188 $this->response->addStatus("callbackresponse", $resp);
121 189 return 1;
122 190 }
123 191 }
124 -endif;
192 +endif;