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

607 lines 17.4 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.3;
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 $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 if (defined('IS_ATOMIC')) {
293 $host_info['IS_ATOMIC'] = IS_ATOMIC;
294 }
295
296 return $host_info;
297 }
298
299 public function serverConfig() {
300 return array(
301 'software' => $_SERVER['SERVER_SOFTWARE'],
302 'sapi' => (function_exists('php_sapi_name')) ? php_sapi_name() : false,
303 'has_apache_get_modules' => function_exists('apache_get_modules'),
304 'posix_getuid' => (function_exists('posix_getuid')) ? posix_getuid() : null,
305 'uid' => (function_exists('getmyuid')) ? getmyuid() : null,
306 'user_ini' => ini_get('user_ini.filename'),
307 'php_major_version' => PHP_MAJOR_VERSION
308 );
309 }
310
311 function refreshUpdatesInfo() {
312 global $wp_current_filter;
313 $wp_current_filter[] = 'load-update-core.php';
314
315 if (function_exists('wp_clean_update_cache')) {
316 wp_clean_update_cache();
317 } else {
318 $this->settings->deleteTransient('update_plugins');
319 $this->settings->deleteTransient('update_themes');
320 $this->settings->deleteTransient('update_core');
321 }
322
323 wp_update_plugins();
324 wp_update_themes();
325
326 array_pop($wp_current_filter);
327
328 wp_update_plugins();
329 wp_update_themes();
330
331 wp_version_check();
332 wp_version_check(array(), true);
333
334 return true;
335 }
336
337 function getUsersHandler($args = array()) {
338 $db = $this->db;
339 $table = "{$db->dbprefix()}users";
340 $count = $db->rowsCount($table);
341 $result = array("count" => $count);
342
343 $max_users = array_key_exists('max_users', $args) ? $args['max_users'] : 500;
344 $roles = array_key_exists('roles', $args) ? $args['roles'] : array();
345
346 $users = array();
347 if (($count > $max_users) && !empty($roles)) {
348 foreach ($roles as $role) {
349 if ($max_users <= 0)
350 break;
351 $args['number'] = $max_users;
352 $args['role'] = $role;
353 $fetched = $this->getUsers($args['full'], $args);
354 $max_users -= sizeof($fetched);
355 $users = array_merge($users, $fetched);
356 }
357 } else {
358 $args['number'] = $max_users;
359 $users = $this->getUsers($args['full'], $args);
360 }
361 $result['users_info'] = $users;
362
363 return $result;
364 }
365
366 function getTransient($name, $asarray = true) {
367 $transient = $this->settings->getTransient($name);
368 if ($transient && $asarray)
369 $transient = $this->objectToArray($transient);
370 return array("transient" => $transient);
371 }
372
373 function getPluginsHandler($args = array()) {
374 $result = array_merge($this->getPlugins(), $this->getTransient('update_plugins'));
375
376 if (array_key_exists('clear_filters', $args)) {
377 $filters = $args['clear_filters'];
378 foreach ($filters as $filter)
379 remove_all_filters($filter);
380 $transient_without_filters = $this->getTransient('update_plugins');
381 $result['transient_without_filters'] = $transient_without_filters['transient'];
382 }
383
384 return $result;
385 }
386
387 function getThemesHandler($args = array()) {
388 $result = array_merge($this->getThemes(), $this->getTransient('update_themes'));
389
390 if (array_key_exists('clear_filters', $args)) {
391 $filters = $args['clear_filters'];
392 foreach ($filters as $filter)
393 remove_all_filters($filter);
394 $transient_without_filters = $this->getTransient('update_themes');
395 $result['transient_without_filters'] = $transient_without_filters['transient'];
396 }
397
398 return $result;
399 }
400
401 function getCoreHandler() {
402 global $wp_db_version, $wp_version;
403
404 $result = $this->getTransient('update_core');
405 $result['current_db_version'] = $this->settings->getOption('db_version');
406 $result['latest_db_version'] = $wp_db_version;
407 $result['wp_version'] = $wp_version;
408
409 return $result;
410 }
411
412 function getSiteInfo($args) {
413 $result = array();
414
415 if (array_key_exists('pre_refresh_get_options', $args)) {
416 $result['pre_refresh_get_options'] = $this->settings->getOptions(
417 $args['pre_refresh_get_options']
418 );
419 }
420
421 if (array_key_exists('refresh', $args))
422 $result['refreshed'] = $this->refreshUpdatesInfo();
423
424 if (array_key_exists('users', $args))
425 $result['users'] = $this->getUsersHandler($args['users']);
426
427 if (array_key_exists('plugins', $args))
428 $result['plugins'] = $this->getPluginsHandler($args['plugins']);
429
430 if (array_key_exists('themes', $args))
431 $result['themes'] = $this->getThemesHandler($args['themes']);
432
433 if (array_key_exists('core', $args))
434 $result['core'] = $this->getCoreHandler();
435
436 if (array_key_exists('sys', $args))
437 $result['sys'] = $this->getSystemInfo();
438
439 if (array_key_exists('get_options', $args))
440 $result['get_options'] = $this->settings->getOptions($args['get_options']);
441
442 return $result;
443 }
444
445 function pingBV() {
446 $info = array();
447 $this->siteinfo->basic($info);
448 $this->bvapi->pingbv('/bvapi/pingbv', $info);
449 return true;
450 }
451
452 function getPostActivateInfo($args) {
453 $result = array();
454
455 if (array_key_exists('pingbv', $args))
456 $result['pingbv'] = array('status' => $this->pingBV());
457
458 if (array_key_exists('activate_info', $args))
459 $result['activate_info'] = $this->activate();
460
461 if (array_key_exists('cookie_info', $args))
462 $result['cookie_info'] = $this->cookieInfo();
463
464 if (array_key_exists('get_host', $args))
465 $result['get_host'] = $this->getHostInfo();
466
467 if (array_key_exists('get_wp', $args))
468 $result['get_wp'] = $this->getWpInfo();
469
470 if (array_key_exists('get_options', $args))
471 $result['get_options'] = $this->settings->getOptions($args['get_options']);
472
473 if (array_key_exists('get_tables', $args))
474 $result['get_tables'] = $this->db->showTables();
475
476 $result['status'] = true;
477
478 return $result;
479 }
480
481 function getPluginServicesInfo($args) {
482 $result = array();
483
484 if (array_key_exists('get_options', $args))
485 $result['get_options'] = $this->settings->getOptions($args['get_options']);
486
487 if (array_key_exists('pingbv', $args))
488 $result['pingbv'] = array('status' => $this->pingBV());
489
490 if (array_key_exists('server_config', $args))
491 $result['server_config'] = $this->serverConfig();
492
493 return $result;
494 }
495
496 function getPluginFileData($plugin_file) {
497 $result = array();
498
499 if (!function_exists('get_plugin_data')) {
500 require_once ABSPATH . 'wp-admin/includes/plugin.php';
501 }
502 $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_file);
503 if ($plugin_data && isset($plugin_data['Version'])) {
504 $result['version'] = $plugin_data['Version'];
505 }
506
507 return $result;
508 }
509
510 function fetchPluginApiData($slug, $action) {
511 $args = array('slug' => wp_unslash($slug));
512 $args = (object) $args;
513 $args = apply_filters('plugins_api_args', $args, $action);
514 $data = apply_filters('plugins_api', false, $action, $args);
515
516 return $data;
517 }
518
519 public function process($request) {
520 $db = $this->db;
521 $params = $request->params;
522 switch ($request->method) {
523 case "activateinfo":
524 $resp = array('actinfo' => $this->activate());
525 break;
526 case "ckeyinfo":
527 $resp = array('cookieinfo' => $this->cookieInfo());
528 break;
529 case "gtpsts":
530 $count = 5;
531 if (array_key_exists('count', $params))
532 $count = $params['count'];
533 $resp = $this->getPosts($params['post_type'], $count);
534 break;
535 case "gtsts":
536 $resp = $this->getStats();
537 break;
538 case "gtdbvariables":
539 $variable = (array_key_exists('variable', $params)) ? $params['variable'] : "";
540 $resp = $this->db->showDbVariables($variable);
541 break;
542 case "gtplgs":
543 $resp = $this->getPlugins();
544 break;
545 case "gtthms":
546 $resp = $this->getThemes();
547 break;
548 case "gtsym":
549 $resp = array('sys' => $this->getSystemInfo());
550 break;
551 case "gtwp":
552 $resp = array('wp' => $this->getWpInfo());
553 break;
554 case "gtallhdrs":
555 $data = (function_exists('getallheaders')) ? getallheaders() : false;
556 $resp = array("allhdrs" => $data);
557 break;
558 case "gtsvr":
559 $resp = array("svr" => $_SERVER);
560 break;
561 case "getoption":
562 $resp = array("option" => $this->settings->getOption($params['name']));
563 break;
564 case "gtusrs":
565 $full = false;
566 if (array_key_exists('full', $params))
567 $full = true;
568 $resp = array('users' => $this->getUsers($full, $params['args']));
569 break;
570 case "gttrnsnt":
571 $resp = $this->getTransient($params['name'], array_key_exists('asarray', $params));
572 break;
573 case "gthost":
574 $resp = array('host_info' => $this->getHostInfo());
575 break;
576 case "gtplsinfo":
577 $resp = array("plugins_info" => array());
578 $file_by_slug = $params["file_by_slug"];
579 foreach ($params['slugs'] as $slug) {
580 $data = $this->fetchPluginApiData($slug, $params['action']);
581 if (is_object($data) && !property_exists($data, 'version') && isset($file_by_slug[$slug])) {
582 $plugin_data = $this->getPluginFileData($file_by_slug[$slug]);
583 $data->version = $plugin_data['version'];
584 }
585 $resp['plugins_info'][$slug] = $data;
586 }
587 break;
588 case "gtplinfo":
589 $data = $this->fetchPluginApiData($params['slug'], $params['action']);
590 $resp = array("plugins_info" => $data);
591 break;
592 case "gtpostactinfo":
593 $resp = $this->getPostActivateInfo($params);
594 break;
595 case "gtsteinfo":
596 $resp = $this->getSiteInfo($params);
597 break;
598 case "psinfo":
599 $resp = $this->getPluginServicesInfo($params);
600 break;
601 default:
602 $resp = false;
603 }
604 return $resp;
605 }
606 }
607 endif;