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

573 lines 15.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.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 'login_url' => wp_login_url(),
190 'admin_url' => get_admin_url()
191 );
192 return $wp_info;
193 }
194
195 public function getUsers($full, $args = array()) {
196 $results = array();
197 $users = get_users($args);
198 if ('true' == $full) {
199 $results = $this->objectToArray($users);
200 } else {
201 foreach( (array) $users as $user) {
202 $result = array();
203 $result['user_email'] = $user->user_email;
204 $result['ID'] = $user->ID;
205 $result['roles'] = $user->roles;
206 $result['user_login'] = $user->user_login;
207 $result['display_name'] = $user->display_name;
208 $result['user_registered'] = $user->user_registered;
209 $result['user_status'] = $user->user_status;
210 $result['user_url'] = $user->url;
211
212 $results[] = $result;
213 }
214 }
215 return $results;
216 }
217
218 public function availableFunctions(&$info) {
219 if (extension_loaded('openssl')) {
220 $info['openssl'] = "1";
221 }
222 if (function_exists('is_ssl') && is_ssl()) {
223 $info['https'] = "1";
224 }
225 if (function_exists('openssl_public_encrypt')) {
226 $info['openssl_public_encrypt'] = "1";
227 }
228 if (function_exists('openssl_public_decrypt')) {
229 $info['openssl_public_decrypt'] = "1";
230 }
231 $info['sha1'] = "1";
232 $info['apissl'] = "1";
233 if (function_exists('base64_encode')) {
234 $info['b64encode'] = true;
235 }
236 if (function_exists('base64_decode')) {
237 $info['b64decode'] = true;
238 }
239 return $info;
240 }
241
242 public function servicesInfo(&$data) {
243 $settings = $this->settings;
244 $data['protect'] = $settings->getOption('bvptconf');
245 $data['brand'] = $settings->getOption($this->bvinfo->brand_option);
246 $data['badgeinfo'] = $settings->getOption($this->bvinfo->badgeinfo);
247 $data[$this->bvinfo->services_option_name] = $this->bvinfo->config;
248 }
249
250 public function dbconf(&$info) {
251 $db = $this->db;
252 if (defined('DB_CHARSET'))
253 $info['dbcharset'] = DB_CHARSET;
254 $info['dbprefix'] = $db->dbprefix();
255 $info['charset_collate'] = $db->getCharsetCollate();
256 return $info;
257 }
258
259 public function cookieInfo() {
260 $info = array();
261 if (defined('COOKIEPATH'))
262 $info['cookiepath'] = COOKIEPATH;
263 if (defined('COOKIE_DOMAIN'))
264 $info['cookiedomain'] = COOKIE_DOMAIN;
265 return $info;
266 }
267
268 public function activate() {
269 $info = array();
270 $this->siteinfo->basic($info);
271 $this->servicesInfo($info);
272 $this->dbconf($info);
273 $this->availableFunctions($info);
274 return $info;
275 }
276
277 public function getHostInfo() {
278 $host_info = $_SERVER;
279 $host_info['PHP_SERVER_NAME'] = php_uname('\n');
280 if (array_key_exists('IS_PRESSABLE', get_defined_constants())) {
281 $host_info['IS_PRESSABLE'] = true;
282 }
283
284 if (array_key_exists('GRIDPANE', get_defined_constants())) {
285 $host_info['IS_GRIDPANE'] = true;
286 }
287
288 if (defined('WPE_APIKEY')) {
289 $host_info['WPE_APIKEY'] = WPE_APIKEY;
290 }
291
292 return $host_info;
293 }
294
295 public function serverConfig() {
296 return array(
297 'software' => $_SERVER['SERVER_SOFTWARE'],
298 'sapi' => (function_exists('php_sapi_name')) ? php_sapi_name() : false,
299 'has_apache_get_modules' => function_exists('apache_get_modules'),
300 'posix_getuid' => (function_exists('posix_getuid')) ? posix_getuid() : null,
301 'uid' => (function_exists('getmyuid')) ? getmyuid() : null,
302 'user_ini' => ini_get('user_ini.filename'),
303 'php_major_version' => PHP_MAJOR_VERSION
304 );
305 }
306
307 function refreshUpdatesInfo() {
308 global $wp_current_filter;
309 $wp_current_filter[] = 'load-update-core.php';
310
311 if (function_exists('wp_clean_update_cache')) {
312 wp_clean_update_cache();
313 } else {
314 $this->settings->deleteTransient('update_plugins');
315 $this->settings->deleteTransient('update_themes');
316 $this->settings->deleteTransient('update_core');
317 }
318
319 wp_update_plugins();
320 wp_update_themes();
321
322 array_pop($wp_current_filter);
323
324 wp_update_plugins();
325 wp_update_themes();
326
327 wp_version_check();
328 wp_version_check(array(), true);
329
330 return true;
331 }
332
333 function getUsersHandler($args = array()) {
334 $db = $this->db;
335 $table = "{$db->dbprefix()}users";
336 $count = $db->rowsCount($table);
337 $result = array("count" => $count);
338
339 $max_users = array_key_exists('max_users', $args) ? $args['max_users'] : 500;
340 $roles = array_key_exists('roles', $args) ? $args['roles'] : array();
341
342 $users = array();
343 if (($count > $max_users) && !empty($roles)) {
344 foreach ($roles as $role) {
345 if ($max_users <= 0)
346 break;
347 $args['number'] = $max_users;
348 $args['role'] = $role;
349 $fetched = $this->getUsers($args['full'], $args);
350 $max_users -= sizeof($fetched);
351 $users = array_merge($users, $fetched);
352 }
353 } else {
354 $args['number'] = $max_users;
355 $users = $this->getUsers($args['full'], $args);
356 }
357 $result['users_info'] = $users;
358
359 return $result;
360 }
361
362 function getTransient($name, $asarray = true) {
363 $transient = $this->settings->getTransient($name);
364 if ($transient && $asarray)
365 $transient = $this->objectToArray($transient);
366 return array("transient" => $transient);
367 }
368
369 function getPluginsHandler($args = array()) {
370 $result = array_merge($this->getPlugins(), $this->getTransient('update_plugins'));
371
372 if (array_key_exists('clear_filters', $args)) {
373 $filters = $args['clear_filters'];
374 foreach ($filters as $filter)
375 remove_all_filters($filter);
376 $transient_without_filters = $this->getTransient('update_plugins');
377 $result['transient_without_filters'] = $transient_without_filters['transient'];
378 }
379
380 return $result;
381 }
382
383 function getThemesHandler($args = array()) {
384 $result = array_merge($this->getThemes(), $this->getTransient('update_themes'));
385
386 if (array_key_exists('clear_filters', $args)) {
387 $filters = $args['clear_filters'];
388 foreach ($filters as $filter)
389 remove_all_filters($filter);
390 $transient_without_filters = $this->getTransient('update_themes');
391 $result['transient_without_filters'] = $transient_without_filters['transient'];
392 }
393
394 return $result;
395 }
396
397 function getCoreHandler() {
398 global $wp_db_version;
399
400 $result = $this->getTransient('update_core');
401 $result['current_db_version'] = $this->settings->getOption('db_version');
402 $result['latest_db_version'] = $wp_db_version;
403
404 return $result;
405 }
406
407 function getSiteInfo($args) {
408 $result = array();
409
410 if (array_key_exists('pre_refresh_get_options', $args)) {
411 $result['pre_refresh_get_options'] = $this->settings->getOptions(
412 $args['pre_refresh_get_options']
413 );
414 }
415
416 if (array_key_exists('refresh', $args))
417 $result['refreshed'] = $this->refreshUpdatesInfo();
418
419 if (array_key_exists('users', $args))
420 $result['users'] = $this->getUsersHandler($args['users']);
421
422 if (array_key_exists('plugins', $args))
423 $result['plugins'] = $this->getPluginsHandler($args['plugins']);
424
425 if (array_key_exists('themes', $args))
426 $result['themes'] = $this->getThemesHandler($args['themes']);
427
428 if (array_key_exists('core', $args))
429 $result['core'] = $this->getCoreHandler();
430
431 if (array_key_exists('sys', $args))
432 $result['sys'] = $this->getSystemInfo();
433
434 if (array_key_exists('get_options', $args))
435 $result['get_options'] = $this->settings->getOptions($args['get_options']);
436
437 return $result;
438 }
439
440 function pingBV() {
441 $info = array();
442 $this->siteinfo->basic($info);
443 $this->bvapi->pingbv('/bvapi/pingbv', $info);
444 return true;
445 }
446
447 function getPostActivateInfo($args) {
448 $result = array();
449
450 if (array_key_exists('pingbv', $args))
451 $result['pingbv'] = array('status' => $this->pingBV());
452
453 if (array_key_exists('activate_info', $args))
454 $result['activate_info'] = $this->activate();
455
456 if (array_key_exists('cookie_info', $args))
457 $result['cookie_info'] = $this->cookieInfo();
458
459 if (array_key_exists('get_host', $args))
460 $result['get_host'] = $this->getHostInfo();
461
462 if (array_key_exists('get_wp', $args))
463 $result['get_wp'] = $this->getWpInfo();
464
465 if (array_key_exists('get_options', $args))
466 $result['get_options'] = $this->settings->getOptions($args['get_options']);
467
468 if (array_key_exists('get_tables', $args))
469 $result['get_tables'] = $this->db->showTables();
470
471 $result['status'] = true;
472
473 return $result;
474 }
475
476 function getPluginServicesInfo($args) {
477 $result = array();
478
479 if (array_key_exists('get_options', $args))
480 $result['get_options'] = $this->settings->getOptions($args['get_options']);
481
482 if (array_key_exists('pingbv', $args))
483 $result['pingbv'] = array('status' => $this->pingBV());
484
485 if (array_key_exists('server_config', $args))
486 $result['server_config'] = $this->serverConfig();
487
488 return $result;
489 }
490
491 public function process($request) {
492 $db = $this->db;
493 $params = $request->params;
494 switch ($request->method) {
495 case "activateinfo":
496 $resp = array('actinfo' => $this->activate());
497 break;
498 case "ckeyinfo":
499 $resp = array('cookieinfo' => $this->cookieInfo());
500 break;
501 case "gtpsts":
502 $count = 5;
503 if (array_key_exists('count', $params))
504 $count = $params['count'];
505 $resp = $this->getPosts($params['post_type'], $count);
506 break;
507 case "gtsts":
508 $resp = $this->getStats();
509 break;
510 case "gtdbvariables":
511 $variable = (array_key_exists('variable', $params)) ? $variable : "";
512 $resp = $this->db->showDbVariables($variable);
513 break;
514 case "gtplgs":
515 $resp = $this->getPlugins();
516 break;
517 case "gtthms":
518 $resp = $this->getThemes();
519 break;
520 case "gtsym":
521 $resp = array('sys' => $this->getSystemInfo());
522 break;
523 case "gtwp":
524 $resp = array('wp' => $this->getWpInfo());
525 break;
526 case "gtallhdrs":
527 $data = (function_exists('getallheaders')) ? getallheaders() : false;
528 $resp = array("allhdrs" => $data);
529 break;
530 case "gtsvr":
531 $resp = array("svr" => $_SERVER);
532 break;
533 case "getoption":
534 $resp = array("option" => $this->settings->getOption($params['name']));
535 break;
536 case "gtusrs":
537 $full = false;
538 if (array_key_exists('full', $params))
539 $full = true;
540 $resp = array('users' => $this->getUsers($full, $params['args']));
541 break;
542 case "gttrnsnt":
543 $resp = $this->getTransient($params['name'], array_key_exists('asarray', $params));
544 break;
545 case "gthost":
546 $resp = array('host_info' => $this->getHostInfo());
547 break;
548 case "gtplinfo":
549 $args = array(
550 'slug' => wp_unslash($params['slug'])
551 );
552 $action = $params['action'];
553 $args = (object) $args;
554 $args = apply_filters('plugins_api_args', $args, $action);
555 $data = apply_filters('plugins_api', false, $action, $args);
556 $resp = array("plugins_info" => $data);
557 break;
558 case "gtpostactinfo":
559 $resp = $this->getPostActivateInfo($params);
560 break;
561 case "gtsteinfo":
562 $resp = $this->getSiteInfo($params);
563 break;
564 case "psinfo":
565 $resp = $this->getPluginServicesInfo($params);
566 break;
567 default:
568 $resp = false;
569 }
570 return $resp;
571 }
572 }
573 endif;