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

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