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

613 lines 17.5 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 = 2.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 addDBInfoToPlugin($pdata, $plugin_file) {
49 switch ($plugin_file) {
50 case "woocommerce/woocommerce.php":
51 $pdata['current_db_version'] = $this->settings->getOption('woocommerce_db_version');
52 $pdata['latest_db_version'] = $this->bvinfo->getLatestWooCommerceDBVersion();
53 break;
54 case "elementor/elementor.php":
55 $pdata['current_db_version'] = $this->settings->getOption('elementor_version');
56 $pdata['latest_db_version'] = $this->bvinfo->getLatestElementorDBVersion($plugin_file);
57 break;
58 case "elementor-pro/elementor-pro.php":
59 $pdata['current_db_version'] = $this->settings->getOption('elementor_pro_version');
60 $pdata['latest_db_version'] = $this->bvinfo->getLatestElementorDBVersion($plugin_file);
61 break;
62 }
63
64 return $pdata;
65 }
66
67 public function getPlugins() {
68 if (!function_exists('get_plugins')) {
69 require_once (ABSPATH."wp-admin/includes/plugin.php");
70 }
71 $plugins = get_plugins();
72 $result = array();
73 foreach ($plugins as $plugin_file => $plugin_data) {
74 $pdata = array(
75 'file' => $plugin_file,
76 'title' => $plugin_data['Title'],
77 'version' => $plugin_data['Version'],
78 'active' => is_plugin_active($plugin_file),
79 'network' => $plugin_data['Network'],
80 "plugin_uri" => $plugin_data["PluginURI"],
81 "update_uri" => $plugin_data["UpdateURI"],
82 "author_uri" => $plugin_data["AuthorURI"],
83 "author" => $plugin_data["AuthorName"],
84 );
85 $pdata = $this->addDBInfoToPlugin($pdata, $plugin_file);
86 $result["plugins"][] = $pdata;
87 }
88 return $result;
89 }
90
91 public function themeToArray($theme) {
92 if (is_object($theme)) {
93 $pdata = array(
94 'name' => $theme->Name,
95 'title' => $theme->Title,
96 'stylesheet' => $theme->get_stylesheet(),
97 'template' => $theme->Template,
98 'version' => $theme->Version,
99 'theme_uri' => $theme->get('ThemeURI'),
100 'author' => $theme->get('Author'),
101 'author_uri' => $theme->get('AuthorURI'),
102 'update_uri' => $theme->get('UpdateURI'),
103 );
104 } else {
105 $pdata = array(
106 'name' => $theme["Name"],
107 'title' => $theme["Title"],
108 'stylesheet' => $theme["Stylesheet"],
109 'template' => $theme["Template"],
110 'version' => $theme["Version"],
111 'author' => $theme['Author'],
112 'author_uri' => $theme['Author URI'],
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 'themedir' => get_stylesheet_directory(),
182 'templatedir' => get_template_directory(),
183 'dbcharset' => defined('DB_CHARSET') ? DB_CHARSET : null,
184 'disallow_file_edit' => defined('DISALLOW_FILE_EDIT'),
185 'disallow_file_mods' => defined('DISALLOW_FILE_MODS'),
186 'custom_users' => defined('CUSTOM_USER_TABLE') ? CUSTOM_USER_TABLE : null,
187 'custom_usermeta' => defined('CUSTOM_USERMETA_TABLE') ? CUSTOM_USERMETA_TABLE : null,
188 'locale' => get_locale(),
189 'wp_local_string' => $wp_local_package,
190 'charset_collate' => $db->getCharsetCollate()
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 if (function_exists('openssl_encrypt')) {
232 $info['openssl_encrypt'] = "1";
233 }
234 if (function_exists('openssl_decrypt')) {
235 $info['openssl_decrypt'] = "1";
236 }
237 $info['sha1'] = "1";
238 $info['apissl'] = "1";
239 if (function_exists('base64_encode')) {
240 $info['b64encode'] = true;
241 }
242 if (function_exists('base64_decode')) {
243 $info['b64decode'] = true;
244 }
245 return $info;
246 }
247
248 public function servicesInfo(&$data) {
249 $settings = $this->settings;
250 $data['protect'] = $settings->getOption('bvptconf');
251 $data['brand'] = $settings->getOption($this->bvinfo->brand_option);
252 $data['badgeinfo'] = $settings->getOption($this->bvinfo->badgeinfo);
253 $data[$this->bvinfo->services_option_name] = $this->bvinfo->config;
254 }
255
256 public function dbconf(&$info) {
257 $db = $this->db;
258 if (defined('DB_CHARSET'))
259 $info['dbcharset'] = DB_CHARSET;
260 $info['dbprefix'] = $db->dbprefix();
261 $info['charset_collate'] = $db->getCharsetCollate();
262 return $info;
263 }
264
265 public function cookieInfo() {
266 $info = array();
267 if (defined('COOKIEPATH'))
268 $info['cookiepath'] = COOKIEPATH;
269 if (defined('COOKIE_DOMAIN'))
270 $info['cookiedomain'] = COOKIE_DOMAIN;
271 return $info;
272 }
273
274 public function activate() {
275 $info = array();
276 $this->siteinfo->basic($info);
277 $this->servicesInfo($info);
278 $this->dbconf($info);
279 $this->availableFunctions($info);
280 return $info;
281 }
282
283 public function getHostInfo() {
284 $host_info = $_SERVER;
285 $host_info['PHP_SERVER_NAME'] = php_uname('\n');
286 if (array_key_exists('IS_PRESSABLE', get_defined_constants())) {
287 $host_info['IS_PRESSABLE'] = true;
288 }
289
290 if (array_key_exists('GRIDPANE', get_defined_constants())) {
291 $host_info['IS_GRIDPANE'] = true;
292 }
293
294 if (defined('WPE_APIKEY')) {
295 $host_info['WPE_APIKEY'] = WPE_APIKEY;
296 }
297
298 if (defined('IS_ATOMIC')) {
299 $host_info['IS_ATOMIC'] = IS_ATOMIC;
300 }
301
302 return $host_info;
303 }
304
305 public function serverConfig() {
306 return array(
307 'software' => $_SERVER['SERVER_SOFTWARE'],
308 'sapi' => (function_exists('php_sapi_name')) ? php_sapi_name() : false,
309 'has_apache_get_modules' => function_exists('apache_get_modules'),
310 'posix_getuid' => (function_exists('posix_getuid')) ? posix_getuid() : null,
311 'uid' => (function_exists('getmyuid')) ? getmyuid() : null,
312 'user_ini' => ini_get('user_ini.filename'),
313 'php_major_version' => PHP_MAJOR_VERSION
314 );
315 }
316
317 function refreshUpdatesInfo() {
318 global $wp_current_filter;
319 $wp_current_filter[] = 'load-update-core.php';
320
321 if (function_exists('wp_clean_update_cache')) {
322 wp_clean_update_cache();
323 } else {
324 $this->settings->deleteTransient('update_plugins');
325 $this->settings->deleteTransient('update_themes');
326 $this->settings->deleteTransient('update_core');
327 }
328
329 wp_update_plugins();
330 wp_update_themes();
331
332 array_pop($wp_current_filter);
333
334 wp_update_plugins();
335 wp_update_themes();
336
337 wp_version_check();
338 wp_version_check(array(), true);
339
340 return true;
341 }
342
343 function getUsersHandler($args = array()) {
344 $db = $this->db;
345 $table = "{$db->dbprefix()}users";
346 $count = $db->rowsCount($table);
347 $result = array("count" => $count);
348
349 $max_users = array_key_exists('max_users', $args) ? $args['max_users'] : 500;
350 $roles = array_key_exists('roles', $args) ? $args['roles'] : array();
351
352 $users = array();
353 if (($count > $max_users) && !empty($roles)) {
354 foreach ($roles as $role) {
355 if ($max_users <= 0)
356 break;
357 $args['number'] = $max_users;
358 $args['role'] = $role;
359 $fetched = $this->getUsers($args['full'], $args);
360 $max_users -= sizeof($fetched);
361 $users = array_merge($users, $fetched);
362 }
363 } else {
364 $args['number'] = $max_users;
365 $users = $this->getUsers($args['full'], $args);
366 }
367 $result['users_info'] = $users;
368
369 return $result;
370 }
371
372 function getTransient($name, $asarray = true) {
373 $transient = $this->settings->getTransient($name);
374 if ($transient && $asarray)
375 $transient = $this->objectToArray($transient);
376 return array("transient" => $transient);
377 }
378
379 function getPluginsHandler($args = array()) {
380 $result = array_merge($this->getPlugins(), $this->getTransient('update_plugins'));
381
382 if (array_key_exists('clear_filters', $args)) {
383 $filters = $args['clear_filters'];
384 foreach ($filters as $filter)
385 remove_all_filters($filter);
386 $transient_without_filters = $this->getTransient('update_plugins');
387 $result['transient_without_filters'] = $transient_without_filters['transient'];
388 }
389
390 return $result;
391 }
392
393 function getThemesHandler($args = array()) {
394 $result = array_merge($this->getThemes(), $this->getTransient('update_themes'));
395
396 if (array_key_exists('clear_filters', $args)) {
397 $filters = $args['clear_filters'];
398 foreach ($filters as $filter)
399 remove_all_filters($filter);
400 $transient_without_filters = $this->getTransient('update_themes');
401 $result['transient_without_filters'] = $transient_without_filters['transient'];
402 }
403
404 return $result;
405 }
406
407 function getCoreHandler() {
408 global $wp_db_version, $wp_version;
409
410 $result = $this->getTransient('update_core');
411 $result['current_db_version'] = $this->settings->getOption('db_version');
412 $result['latest_db_version'] = $wp_db_version;
413 $result['wp_version'] = $wp_version;
414
415 return $result;
416 }
417
418 function getSiteInfo($args) {
419 $result = array();
420
421 if (array_key_exists('pre_refresh_get_options', $args)) {
422 $result['pre_refresh_get_options'] = $this->settings->getOptions(
423 $args['pre_refresh_get_options']
424 );
425 }
426
427 if (array_key_exists('refresh', $args))
428 $result['refreshed'] = $this->refreshUpdatesInfo();
429
430 if (array_key_exists('users', $args))
431 $result['users'] = $this->getUsersHandler($args['users']);
432
433 if (array_key_exists('plugins', $args))
434 $result['plugins'] = $this->getPluginsHandler($args['plugins']);
435
436 if (array_key_exists('themes', $args))
437 $result['themes'] = $this->getThemesHandler($args['themes']);
438
439 if (array_key_exists('core', $args))
440 $result['core'] = $this->getCoreHandler();
441
442 if (array_key_exists('sys', $args))
443 $result['sys'] = $this->getSystemInfo();
444
445 if (array_key_exists('get_options', $args))
446 $result['get_options'] = $this->settings->getOptions($args['get_options']);
447
448 return $result;
449 }
450
451 function pingBV() {
452 $info = array();
453 $this->siteinfo->basic($info);
454 $this->bvapi->pingbv('/bvapi/pingbv', $info);
455 return true;
456 }
457
458 function getPostActivateInfo($args) {
459 $result = array();
460
461 if (array_key_exists('pingbv', $args))
462 $result['pingbv'] = array('status' => $this->pingBV());
463
464 if (array_key_exists('activate_info', $args))
465 $result['activate_info'] = $this->activate();
466
467 if (array_key_exists('cookie_info', $args))
468 $result['cookie_info'] = $this->cookieInfo();
469
470 if (array_key_exists('get_host', $args))
471 $result['get_host'] = $this->getHostInfo();
472
473 if (array_key_exists('get_wp', $args))
474 $result['get_wp'] = $this->getWpInfo();
475
476 if (array_key_exists('get_options', $args))
477 $result['get_options'] = $this->settings->getOptions($args['get_options']);
478
479 if (array_key_exists('get_tables', $args))
480 $result['get_tables'] = $this->db->showTables();
481
482 $result['status'] = true;
483
484 return $result;
485 }
486
487 function getPluginServicesInfo($args) {
488 $result = array();
489
490 if (array_key_exists('get_options', $args))
491 $result['get_options'] = $this->settings->getOptions($args['get_options']);
492
493 if (array_key_exists('pingbv', $args))
494 $result['pingbv'] = array('status' => $this->pingBV());
495
496 if (array_key_exists('server_config', $args))
497 $result['server_config'] = $this->serverConfig();
498
499 return $result;
500 }
501
502 function getPluginFileData($plugin_file) {
503 $result = array();
504
505 if (!function_exists('get_plugin_data')) {
506 require_once ABSPATH . 'wp-admin/includes/plugin.php';
507 }
508 $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_file);
509 if ($plugin_data && isset($plugin_data['Version'])) {
510 $result['version'] = $plugin_data['Version'];
511 }
512
513 return $result;
514 }
515
516 function fetchPluginApiData($slug, $action) {
517 $args = array('slug' => wp_unslash($slug));
518 $args = (object) $args;
519 $args = apply_filters('plugins_api_args', $args, $action);
520 $data = apply_filters('plugins_api', false, $action, $args);
521
522 return $data;
523 }
524
525 public function process($request) {
526 $db = $this->db;
527 $params = $request->params;
528 switch ($request->method) {
529 case "activateinfo":
530 $resp = array('actinfo' => $this->activate());
531 break;
532 case "ckeyinfo":
533 $resp = array('cookieinfo' => $this->cookieInfo());
534 break;
535 case "gtpsts":
536 $count = 5;
537 if (array_key_exists('count', $params))
538 $count = $params['count'];
539 $resp = $this->getPosts($params['post_type'], $count);
540 break;
541 case "gtsts":
542 $resp = $this->getStats();
543 break;
544 case "gtdbvariables":
545 $variable = (array_key_exists('variable', $params)) ? $params['variable'] : "";
546 $resp = $this->db->showDbVariables($variable);
547 break;
548 case "gtplgs":
549 $resp = $this->getPlugins();
550 break;
551 case "gtthms":
552 $resp = $this->getThemes();
553 break;
554 case "gtsym":
555 $resp = array('sys' => $this->getSystemInfo());
556 break;
557 case "gtwp":
558 $resp = array('wp' => $this->getWpInfo());
559 break;
560 case "gtallhdrs":
561 $data = (function_exists('getallheaders')) ? getallheaders() : false;
562 $resp = array("allhdrs" => $data);
563 break;
564 case "gtsvr":
565 $resp = array("svr" => $_SERVER);
566 break;
567 case "getoption":
568 $resp = array("option" => $this->settings->getOption($params['name']));
569 break;
570 case "gtusrs":
571 $full = false;
572 if (array_key_exists('full', $params))
573 $full = true;
574 $resp = array('users' => $this->getUsers($full, $params['args']));
575 break;
576 case "gttrnsnt":
577 $resp = $this->getTransient($params['name'], array_key_exists('asarray', $params));
578 break;
579 case "gthost":
580 $resp = array('host_info' => $this->getHostInfo());
581 break;
582 case "gtplsinfo":
583 $resp = array("plugins_info" => array());
584 $file_by_slug = $params["file_by_slug"];
585 foreach ($params['slugs'] as $slug) {
586 $data = $this->fetchPluginApiData($slug, $params['action']);
587 if (is_object($data) && !property_exists($data, 'version') && isset($file_by_slug[$slug])) {
588 $plugin_data = $this->getPluginFileData($file_by_slug[$slug]);
589 $data->version = $plugin_data['version'];
590 }
591 $resp['plugins_info'][$slug] = $data;
592 }
593 break;
594 case "gtplinfo":
595 $data = $this->fetchPluginApiData($params['slug'], $params['action']);
596 $resp = array("plugins_info" => $data);
597 break;
598 case "gtpostactinfo":
599 $resp = $this->getPostActivateInfo($params);
600 break;
601 case "gtsteinfo":
602 $resp = $this->getSiteInfo($params);
603 break;
604 case "psinfo":
605 $resp = $this->getPluginServicesInfo($params);
606 break;
607 default:
608 $resp = false;
609 }
610 return $resp;
611 }
612 }
613 endif;