PluginProbe
The WP Remote WordPress Plugin / 5.38
The WP Remote WordPress Plugin v5.38
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 5.38, at callback/wings/info.php

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