PluginProbe
The WP Remote WordPress Plugin / 4.76
The WP Remote WordPress Plugin v4.76
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
wpremote / callback / wings / info.php

info.php in The WP Remote WordPress Plugin 4.76, at callback/wings/info.php

507 lines 13.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4 if (!class_exists('BVInfoCallback')) :
5
6 class BVInfoCallback extends BVCallbackBase {
7 public $db;
8 public $settings;
9 public $siteinfo;
10 public $bvinfo;
11 public $bvapi;
12
13 const INFO_WING_VERSION = 1.4;
14
15 public function __construct($callback_handler) {
16 $this->db = $callback_handler->db;
17 $this->siteinfo = $callback_handler->siteinfo;
18 $this->settings = $callback_handler->settings;
19 $this->bvinfo = new WPRInfo($this->settings);
20 $this->bvapi = new WPRWPAPI($this->settings);
21 }
22
23 public function getPosts($post_type, $count = 5) {
24 $output = array();
25 $args = array('numberposts' => $count, 'post_type' => $post_type);
26 $posts = get_posts($args);
27 $keys = array('post_title', 'guid', 'ID', 'post_date');
28 $result = array();
29 foreach ($posts as $post) {
30 $pdata = array();
31 $post_array = get_object_vars($post);
32 foreach ($keys as $key) {
33 $pdata[$key] = $post_array[$key];
34 }
35 $result["posts"][] = $pdata;
36 }
37 return $result;
38 }
39
40 public function getStats() {
41 return array(
42 "posts" => get_object_vars(wp_count_posts()),
43 "pages" => get_object_vars(wp_count_posts("page")),
44 "comments" => get_object_vars(wp_count_comments())
45 );
46 }
47
48 public function getPlugins() {
49 if (!function_exists('get_plugins')) {
50 require_once (ABSPATH."wp-admin/includes/plugin.php");
51 }
52 $plugins = get_plugins();
53 $result = array();
54 foreach ($plugins as $plugin_file => $plugin_data) {
55 $pdata = array(
56 'file' => $plugin_file,
57 'title' => $plugin_data['Title'],
58 'version' => $plugin_data['Version'],
59 'active' => is_plugin_active($plugin_file),
60 'network' => $plugin_data['Network']
61 );
62 $result["plugins"][] = $pdata;
63 }
64 return $result;
65 }
66
67 public function themeToArray($theme) {
68 if (is_object($theme)) {
69 $pdata = array(
70 'name' => $theme->Name,
71 'title' => $theme->Title,
72 'stylesheet' => $theme->get_stylesheet(),
73 'template' => $theme->Template,
74 'version' => $theme->Version
75 );
76 } else {
77 $pdata = array(
78 'name' => $theme["Name"],
79 'title' => $theme["Title"],
80 'stylesheet' => $theme["Stylesheet"],
81 'template' => $theme["Template"],
82 'version' => $theme["Version"]
83 );
84 }
85 return $pdata;
86 }
87
88 public function getThemes() {
89 $result = array();
90 $themes = function_exists('wp_get_themes') ? wp_get_themes() : get_themes();
91 foreach($themes as $theme) {
92 $pdata = $this->themeToArray($theme);
93 $result["themes"][] = $pdata;
94 }
95 $theme = function_exists('wp_get_theme') ? wp_get_theme() : get_current_theme();
96 $pdata = $this->themeToArray($theme);
97 $result["currenttheme"] = $pdata;
98 return $result;
99 }
100
101 public function getSystemInfo() {
102 $sys_info = array(
103 'host' => $_SERVER['HTTP_HOST'],
104 'phpversion' => phpversion(),
105 'AF_INET6' => defined('AF_INET6')
106 );
107 if (array_key_exists('SERVER_ADDR', $_SERVER)) {
108 $sys_info['serverip'] = $_SERVER['SERVER_ADDR'];
109 }
110 if (function_exists('get_current_user')) {
111 $sys_info['user'] = get_current_user();
112 }
113 if (function_exists('getmygid')) {
114 $sys_info['gid'] = getmygid();
115 }
116 if (function_exists('getmyuid')) {
117 $sys_info['uid'] = getmyuid();
118 }
119 if (function_exists('posix_getuid')) {
120 $sys_info['webuid'] = posix_getuid();
121 $sys_info['webgid'] = posix_getgid();
122 }
123 return $sys_info;
124 }
125
126 public function getWpInfo() {
127 global $wp_version, $wp_db_version, $wp_local_package;
128 $siteinfo = $this->siteinfo;
129 $db = $this->db;
130 $upload_dir = wp_upload_dir();
131
132 $wp_info = array(
133 'dbprefix' => $db->dbprefix(),
134 'wpmu' => $siteinfo->isMultisite(),
135 'mainsite' => $siteinfo->isMainSite(),
136 'main_site_id' => $siteinfo->getMainSiteId(),
137 'name' => get_bloginfo('name'),
138 'siteurl' => $siteinfo->siteurl(),
139 'homeurl' => $siteinfo->homeurl(),
140 'charset' => get_bloginfo('charset'),
141 'wpversion' => $wp_version,
142 'dbversion' => $wp_db_version,
143 'mysql_version' => $db->getMysqlVersion(),
144 'abspath' => ABSPATH,
145 'bvpluginpath' => defined('WPRBASEPATH') ? WPRBASEPATH : null,
146 'uploadpath' => $upload_dir['basedir'],
147 'uploaddir' => wp_upload_dir(),
148 'contentdir' => defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : null,
149 'contenturl' => defined('WP_CONTENT_URL') ? WP_CONTENT_URL : null,
150 'plugindir' => defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : null,
151 'dbcharset' => defined('DB_CHARSET') ? DB_CHARSET : null,
152 'disallow_file_edit' => defined('DISALLOW_FILE_EDIT'),
153 'disallow_file_mods' => defined('DISALLOW_FILE_MODS'),
154 'custom_users' => defined('CUSTOM_USER_TABLE') ? CUSTOM_USER_TABLE : null,
155 'custom_usermeta' => defined('CUSTOM_USERMETA_TABLE') ? CUSTOM_USERMETA_TABLE : null,
156 'locale' => get_locale(),
157 'wp_local_string' => $wp_local_package,
158 'charset_collate' => $db->getCharsetCollate()
159 );
160 return $wp_info;
161 }
162
163 public function getUsers($full, $args = array()) {
164 $results = array();
165 $users = get_users($args);
166 if ('true' == $full) {
167 $results = $this->objectToArray($users);
168 } else {
169 foreach( (array) $users as $user) {
170 $result = array();
171 $result['user_email'] = $user->user_email;
172 $result['ID'] = $user->ID;
173 $result['roles'] = $user->roles;
174 $result['user_login'] = $user->user_login;
175 $result['display_name'] = $user->display_name;
176 $result['user_registered'] = $user->user_registered;
177 $result['user_status'] = $user->user_status;
178 $result['user_url'] = $user->url;
179
180 $results[] = $result;
181 }
182 }
183 return $results;
184 }
185
186 public function availableFunctions(&$info) {
187 if (extension_loaded('openssl')) {
188 $info['openssl'] = "1";
189 }
190 if (function_exists('is_ssl') && is_ssl()) {
191 $info['https'] = "1";
192 }
193 if (function_exists('openssl_public_encrypt')) {
194 $info['openssl_public_encrypt'] = "1";
195 }
196 if (function_exists('openssl_public_decrypt')) {
197 $info['openssl_public_decrypt'] = "1";
198 }
199 $info['sha1'] = "1";
200 $info['apissl'] = "1";
201 if (function_exists('base64_encode')) {
202 $info['b64encode'] = true;
203 }
204 if (function_exists('base64_decode')) {
205 $info['b64decode'] = true;
206 }
207 return $info;
208 }
209
210 public function servicesInfo(&$data) {
211 $settings = $this->settings;
212 $data['protect'] = $settings->getOption('bvptconf');
213 $data['brand'] = $settings->getOption($this->bvinfo->brand_option);
214 $data['badgeinfo'] = $settings->getOption($this->bvinfo->badgeinfo);
215 $data[$this->bvinfo->services_option_name] = $this->bvinfo->config;
216 }
217
218 public function dbconf(&$info) {
219 $db = $this->db;
220 if (defined('DB_CHARSET'))
221 $info['dbcharset'] = DB_CHARSET;
222 $info['dbprefix'] = $db->dbprefix();
223 $info['charset_collate'] = $db->getCharsetCollate();
224 return $info;
225 }
226
227 public function cookieInfo() {
228 $info = array();
229 if (defined('COOKIEPATH'))
230 $info['cookiepath'] = COOKIEPATH;
231 if (defined('COOKIE_DOMAIN'))
232 $info['cookiedomain'] = COOKIE_DOMAIN;
233 return $info;
234 }
235
236 public function activate() {
237 $info = array();
238 $this->siteinfo->basic($info);
239 $this->servicesInfo($info);
240 $this->dbconf($info);
241 $this->availableFunctions($info);
242 return $info;
243 }
244
245 public function getHostInfo() {
246 $host_info = $_SERVER;
247 $host_info['PHP_SERVER_NAME'] = php_uname('\n');
248 if (array_key_exists('IS_PRESSABLE', get_defined_constants())) {
249 $host_info['IS_PRESSABLE'] = true;
250 }
251
252 if (array_key_exists('GRIDPANE', get_defined_constants())) {
253 $host_info['IS_GRIDPANE'] = true;
254 }
255
256 if (defined('WPE_APIKEY')) {
257 $host_info['WPE_APIKEY'] = WPE_APIKEY;
258 }
259
260 return $host_info;
261 }
262
263 public function serverConfig() {
264 return array(
265 'software' => $_SERVER['SERVER_SOFTWARE'],
266 'sapi' => (function_exists('php_sapi_name')) ? php_sapi_name() : false,
267 'has_apache_get_modules' => function_exists('apache_get_modules'),
268 'posix_getuid' => (function_exists('posix_getuid')) ? posix_getuid() : null,
269 'uid' => (function_exists('getmyuid')) ? getmyuid() : null,
270 'user_ini' => ini_get('user_ini.filename'),
271 'php_major_version' => PHP_MAJOR_VERSION
272 );
273 }
274
275 function refreshUpdatesInfo() {
276 global $wp_current_filter;
277 $wp_current_filter[] = 'load-update-core.php';
278
279 if (function_exists('wp_clean_update_cache')) {
280 wp_clean_update_cache();
281 } else {
282 $this->settings->deleteTransient('update_plugins');
283 $this->settings->deleteTransient('update_themes');
284 $this->settings->deleteTransient('update_core');
285 }
286
287 wp_update_plugins();
288 wp_update_themes();
289
290 array_pop($wp_current_filter);
291
292 wp_update_plugins();
293 wp_update_themes();
294
295 wp_version_check();
296 wp_version_check(array(), true);
297
298 return true;
299 }
300
301 function getUsersHandler($args = array()) {
302 $db = $this->db;
303 $table = "{$db->dbprefix()}users";
304 $count = $db->rowsCount($table);
305 $result = array("count" => $count);
306
307 $max_users = array_key_exists('max_users', $args) ? $args['max_users'] : 500;
308 $roles = array_key_exists('roles', $args) ? $args['roles'] : array();
309
310 $users = array();
311 if (($count > $max_users) && !empty($roles)) {
312 foreach ($roles as $role) {
313 if ($max_users <= 0)
314 break;
315 $args['number'] = $max_users;
316 $args['role'] = $role;
317 $fetched = $this->getUsers($args['full'], $args);
318 $max_users -= sizeof($fetched);
319 $users = array_merge($users, $fetched);
320 }
321 } else {
322 $args['number'] = $max_users;
323 $users = $this->getUsers($args['full'], $args);
324 }
325 $result['users_info'] = $users;
326
327 return $result;
328 }
329
330 function getTransient($name, $asarray = true) {
331 $transient = $this->settings->getTransient($name);
332 if ($transient && $asarray)
333 $transient = $this->objectToArray($transient);
334 return array("transient" => $transient);
335 }
336
337 function getPluginsHandler() {
338 return array_merge($this->getPlugins(), $this->getTransient('update_plugins'));
339 }
340
341 function getThemesHandler() {
342 return array_merge($this->getThemes(), $this->getTransient('update_themes'));
343 }
344
345 function getSiteInfo($args) {
346 $result = array();
347
348 if (array_key_exists('pre_refresh_get_options', $args)) {
349 $result['pre_refresh_get_options'] = $this->settings->getOptions(
350 $args['pre_refresh_get_options']
351 );
352 }
353
354 if (array_key_exists('refresh', $args))
355 $result['refreshed'] = $this->refreshUpdatesInfo();
356
357 if (array_key_exists('users', $args))
358 $result['users'] = $this->getUsersHandler($args['users']);
359
360 if (array_key_exists('plugins', $args))
361 $result['plugins'] = $this->getPluginsHandler();
362
363 if (array_key_exists('themes', $args))
364 $result['themes'] = $this->getThemesHandler();
365
366 if (array_key_exists('core', $args))
367 $result['core'] = $this->getTransient('update_core');
368
369 if (array_key_exists('sys', $args))
370 $result['sys'] = $this->getSystemInfo();
371
372 if (array_key_exists('get_options', $args))
373 $result['get_options'] = $this->settings->getOptions($args['get_options']);
374
375 return $result;
376 }
377
378 function pingBV() {
379 $info = array();
380 $this->siteinfo->basic($info);
381 $this->bvapi->pingbv('/bvapi/pingbv', $info);
382 return true;
383 }
384
385 function getPostActivateInfo($args) {
386 $result = array();
387
388 if (array_key_exists('pingbv', $args))
389 $result['pingbv'] = array('status' => $this->pingBV());
390
391 if (array_key_exists('activate_info', $args))
392 $result['activate_info'] = $this->activate();
393
394 if (array_key_exists('cookie_info', $args))
395 $result['cookie_info'] = $this->cookieInfo();
396
397 if (array_key_exists('get_host', $args))
398 $result['get_host'] = $this->getHostInfo();
399
400 if (array_key_exists('get_wp', $args))
401 $result['get_wp'] = $this->getWpInfo();
402
403 if (array_key_exists('get_options', $args))
404 $result['get_options'] = $this->settings->getOptions($args['get_options']);
405
406 if (array_key_exists('get_tables', $args))
407 $result['get_tables'] = $this->db->showTables();
408
409 $result['status'] = true;
410
411 return $result;
412 }
413
414 function getPluginServicesInfo($args) {
415 $result = array();
416
417 if (array_key_exists('get_options', $args))
418 $result['get_options'] = $this->settings->getOptions($args['get_options']);
419
420 if (array_key_exists('pingbv', $args))
421 $result['pingbv'] = array('status' => $this->pingBV());
422
423 if (array_key_exists('server_config', $args))
424 $result['server_config'] = $this->serverConfig();
425
426 return $result;
427 }
428
429 public function process($request) {
430 $db = $this->db;
431 $params = $request->params;
432 switch ($request->method) {
433 case "activateinfo":
434 $resp = array('actinfo' => $this->activate());
435 break;
436 case "ckeyinfo":
437 $resp = array('cookieinfo' => $this->cookieInfo());
438 break;
439 case "gtpsts":
440 $count = 5;
441 if (array_key_exists('count', $params))
442 $count = $params['count'];
443 $resp = $this->getPosts($params['post_type'], $count);
444 break;
445 case "gtsts":
446 $resp = $this->getStats();
447 break;
448 case "gtplgs":
449 $resp = $this->getPlugins();
450 break;
451 case "gtthms":
452 $resp = $this->getThemes();
453 break;
454 case "gtsym":
455 $resp = array('sys' => $this->getSystemInfo());
456 break;
457 case "gtwp":
458 $resp = array('wp' => $this->getWpInfo());
459 break;
460 case "gtallhdrs":
461 $data = (function_exists('getallheaders')) ? getallheaders() : false;
462 $resp = array("allhdrs" => $data);
463 break;
464 case "gtsvr":
465 $resp = array("svr" => $_SERVER);
466 break;
467 case "getoption":
468 $resp = array("option" => $this->settings->getOption($params['name']));
469 break;
470 case "gtusrs":
471 $full = false;
472 if (array_key_exists('full', $params))
473 $full = true;
474 $resp = array('users' => $this->getUsers($full, $params['args']));
475 break;
476 case "gttrnsnt":
477 $resp = $this->getTransient($params['name'], array_key_exists('asarray', $params));
478 break;
479 case "gthost":
480 $resp = array('host_info' => $this->getHostInfo());
481 break;
482 case "gtplinfo":
483 $args = array(
484 'slug' => wp_unslash($params['slug'])
485 );
486 $action = $params['action'];
487 $args = (object) $args;
488 $args = apply_filters('plugins_api_args', $args, $action);
489 $data = apply_filters('plugins_api', false, $action, $args);
490 $resp = array("plugins_info" => $data);
491 break;
492 case "gtpostactinfo":
493 $resp = $this->getPostActivateInfo($params);
494 break;
495 case "gtsteinfo":
496 $resp = $this->getSiteInfo($params);
497 break;
498 case "psinfo":
499 $resp = $this->getPluginServicesInfo($params);
500 break;
501 default:
502 $resp = false;
503 }
504 return $resp;
505 }
506 }
507 endif;