PluginProbe
The WP Remote WordPress Plugin / 6.72
The WP Remote WordPress Plugin v6.72
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 6.72, at callback/wings/info.php

621 lines 17.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('WPRInfoCallback')) :
5
6 class WPRInfoCallback extends WPRCallbackBase {
7 public $db;
8 public $settings;
9 public $siteinfo;
10 public $bvinfo;
11 public $bvapi;
12
13 const INFO_WING_VERSION = 2.7;
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 = wp_get_themes();
121 foreach($themes as $theme) {
122 $pdata = $this->themeToArray($theme);
123 $result["themes"][] = $pdata;
124 }
125 $pdata = $this->themeToArray(wp_get_theme());
126 $result["currenttheme"] = $pdata;
127 return $result;
128 }
129
130 public function getSystemInfo() {
131 $sys_info = array(
132 'host' => WPRHelper::getRawParam('SERVER', 'HTTP_HOST'),
133 'phpversion' => phpversion(),
134 'AF_INET6' => defined('AF_INET6')
135 );
136 if (array_key_exists('SERVER_ADDR', $_SERVER)) {
137 $sys_info['serverip'] = WPRHelper::getRawParam('SERVER', 'SERVER_ADDR');
138 }
139 if (function_exists('get_current_user')) {
140 $sys_info['user'] = get_current_user();
141 }
142 if (function_exists('getmygid')) {
143 $sys_info['gid'] = getmygid();
144 }
145 if (function_exists('getmyuid')) {
146 $sys_info['uid'] = getmyuid();
147 }
148 if (function_exists('posix_getuid')) {
149 $sys_info['webuid'] = posix_getuid();
150 $sys_info['webgid'] = posix_getgid();
151 }
152 return $sys_info;
153 }
154
155 public function getWpInfo() {
156 global $wp_version, $wp_db_version, $wp_local_package;
157 $siteinfo = $this->siteinfo;
158 $db = $this->db;
159 $upload_dir = wp_upload_dir();
160
161 $wp_info = array(
162 'dbprefix' => $db->dbprefix(),
163 'wpmu' => $siteinfo->isMultisite(),
164 'mainsite' => $siteinfo->isMainSite(),
165 'main_site_id' => $siteinfo->getMainSiteId(),
166 'name' => get_bloginfo('name'),
167 'siteurl' => $siteinfo->siteurl(),
168 'homeurl' => $siteinfo->homeurl(),
169 'charset' => get_bloginfo('charset'),
170 'wpversion' => $wp_version,
171 'dbversion' => $wp_db_version,
172 'mysql_version' => $db->getMysqlVersion(),
173 'abspath' => ABSPATH,
174 'bvpluginpath' => defined('WPRBASEPATH') ? WPRBASEPATH : null,
175 'uploadpath' => $upload_dir['basedir'],
176 'uploaddir' => wp_upload_dir(),
177 'contentdir' => defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : null,
178 'contenturl' => defined('WP_CONTENT_URL') ? WP_CONTENT_URL : null,
179 'plugindir' => defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : null,
180 'themedir' => get_stylesheet_directory(),
181 'templatedir' => get_template_directory(),
182 'dbcharset' => defined('DB_CHARSET') ? DB_CHARSET : null,
183 'disallow_file_edit' => defined('DISALLOW_FILE_EDIT'),
184 'disallow_file_mods' => defined('DISALLOW_FILE_MODS'),
185 'custom_users' => defined('CUSTOM_USER_TABLE') ? CUSTOM_USER_TABLE : null,
186 'custom_usermeta' => defined('CUSTOM_USERMETA_TABLE') ? CUSTOM_USERMETA_TABLE : null,
187 'locale' => get_locale(),
188 'wp_local_string' => $wp_local_package,
189 'charset_collate' => $db->getCharsetCollate(),
190 'allowed_paths' => ini_get('open_basedir'),
191 'path_seprator' => PATH_SEPARATOR
192 );
193 return $wp_info;
194 }
195
196 public function getUsers($full, $args = array()) {
197 $results = array();
198 $users = get_users($args);
199 if ('true' == $full) {
200 $results = $this->objectToArray($users);
201 } else {
202 foreach( (array) $users as $user) {
203 $result = array();
204 $result['user_email'] = $user->user_email;
205 $result['ID'] = $user->ID;
206 $result['roles'] = $user->roles;
207 $result['user_login'] = $user->user_login;
208 $result['display_name'] = $user->display_name;
209 $result['user_registered'] = $user->user_registered;
210 $result['user_status'] = $user->user_status;
211 $result['user_url'] = $user->url;
212
213 $results[] = $result;
214 }
215 }
216 return $results;
217 }
218
219 public function availableFunctions(&$info) {
220 if (extension_loaded('openssl')) {
221 $info['openssl'] = "1";
222 }
223 if (function_exists('is_ssl') && is_ssl()) {
224 $info['https'] = "1";
225 }
226 if (function_exists('openssl_public_encrypt')) {
227 $info['openssl_public_encrypt'] = "1";
228 }
229 if (function_exists('openssl_public_decrypt')) {
230 $info['openssl_public_decrypt'] = "1";
231 }
232 if (function_exists('openssl_encrypt')) {
233 $info['openssl_encrypt'] = "1";
234 }
235 if (function_exists('openssl_decrypt')) {
236 $info['openssl_decrypt'] = "1";
237 }
238 $info['sha1'] = "1";
239 $info['apissl'] = "1";
240 if (function_exists('base64_encode')) {
241 $info['b64encode'] = true;
242 }
243 if (function_exists('base64_decode')) {
244 $info['b64decode'] = true;
245 }
246 return $info;
247 }
248
249 public function servicesInfo(&$data) {
250 $settings = $this->settings;
251 $data['protect'] = $settings->getOption('bvptconf');
252 $data['brand'] = $settings->getOption($this->bvinfo->brand_option);
253 $data['badgeinfo'] = $settings->getOption($this->bvinfo->badgeinfo);
254 $data[$this->bvinfo->services_option_name] = $this->bvinfo->config;
255 }
256
257 public function dbconf(&$info) {
258 $db = $this->db;
259 if (defined('DB_CHARSET'))
260 $info['dbcharset'] = DB_CHARSET;
261 $info['dbprefix'] = $db->dbprefix();
262 $info['charset_collate'] = $db->getCharsetCollate();
263 return $info;
264 }
265
266 public function cookieInfo() {
267 $info = array();
268 if (defined('COOKIEPATH'))
269 $info['cookiepath'] = COOKIEPATH;
270 if (defined('COOKIE_DOMAIN'))
271 $info['cookiedomain'] = COOKIE_DOMAIN;
272 return $info;
273 }
274
275 public function activate() {
276 $info = array();
277 $this->siteinfo->basic($info);
278 $this->servicesInfo($info);
279 $this->dbconf($info);
280 $this->availableFunctions($info);
281 return $info;
282 }
283
284 public function getHostInfo() {
285 $host_info = $_SERVER;
286 if (function_exists('php_uname')) {
287 $host_info['PHP_SERVER_NAME'] = php_uname();
288 }
289
290 if (isset($_SERVER['SERVER_ADDR']) && function_exists('gethostbyaddr')) {
291 $host_info['HOST_FROM_IP'] = gethostbyaddr(WPRHelper::getRawParam('SERVER', 'SERVER_ADDR'));
292 }
293
294 if (array_key_exists('IS_PRESSABLE', get_defined_constants())) {
295 $host_info['IS_PRESSABLE'] = true;
296 }
297
298 if (array_key_exists('GRIDPANE', get_defined_constants())) {
299 $host_info['IS_GRIDPANE'] = true;
300 }
301
302 if (defined('WPE_APIKEY')) {
303 $host_info['WPE_APIKEY'] = WPE_APIKEY;
304 }
305
306 if (defined('IS_ATOMIC')) {
307 $host_info['IS_ATOMIC'] = IS_ATOMIC;
308 }
309
310 return $host_info;
311 }
312
313 public function serverConfig() {
314 return array(
315 'software' => WPRHelper::getRawParam('SERVER', 'SERVER_SOFTWARE'),
316 'sapi' => (function_exists('php_sapi_name')) ? php_sapi_name() : false,
317 'has_apache_get_modules' => function_exists('apache_get_modules'),
318 'posix_getuid' => (function_exists('posix_getuid')) ? posix_getuid() : null,
319 'uid' => (function_exists('getmyuid')) ? getmyuid() : null,
320 'user_ini' => ini_get('user_ini.filename'),
321 'php_major_version' => PHP_MAJOR_VERSION
322 );
323 }
324
325 function refreshUpdatesInfo() {
326 global $wp_current_filter;
327 $wp_current_filter[] = 'load-update-core.php';
328
329 if (function_exists('wp_clean_update_cache')) {
330 wp_clean_update_cache();
331 } else {
332 $this->settings->deleteTransient('update_plugins');
333 $this->settings->deleteTransient('update_themes');
334 $this->settings->deleteTransient('update_core');
335 }
336
337 wp_update_plugins();
338 wp_update_themes();
339
340 array_pop($wp_current_filter);
341
342 wp_update_plugins();
343 wp_update_themes();
344
345 wp_version_check();
346 wp_version_check(array(), true);
347
348 return true;
349 }
350
351 function getUsersHandler($args = array()) {
352 $db = $this->db;
353 $table = "{$db->dbprefix()}users";
354 $count = $db->rowsCount($table);
355 $result = array("count" => $count);
356
357 $max_users = array_key_exists('max_users', $args) ? $args['max_users'] : 500;
358 $roles = array_key_exists('roles', $args) ? $args['roles'] : array();
359
360 $users = array();
361 if (($count > $max_users) && !empty($roles)) {
362 foreach ($roles as $role) {
363 if ($max_users <= 0)
364 break;
365 $args['number'] = $max_users;
366 $args['role'] = $role;
367 $fetched = $this->getUsers($args['full'], $args);
368 $max_users -= sizeof($fetched);
369 $users = array_merge($users, $fetched);
370 }
371 } else {
372 $args['number'] = $max_users;
373 $users = $this->getUsers($args['full'], $args);
374 }
375 $result['users_info'] = $users;
376
377 return $result;
378 }
379
380 function getTransient($name, $asarray = true) {
381 $transient = $this->settings->getTransient($name);
382 if ($transient && $asarray)
383 $transient = $this->objectToArray($transient);
384 return array("transient" => $transient);
385 }
386
387 function getPluginsHandler($args = array()) {
388 $result = array_merge($this->getPlugins(), $this->getTransient('update_plugins'));
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_plugins');
395 $result['transient_without_filters'] = $transient_without_filters['transient'];
396 }
397
398 return $result;
399 }
400
401 function getThemesHandler($args = array()) {
402 $result = array_merge($this->getThemes(), $this->getTransient('update_themes'));
403
404 if (array_key_exists('clear_filters', $args)) {
405 $filters = $args['clear_filters'];
406 foreach ($filters as $filter)
407 remove_all_filters($filter);
408 $transient_without_filters = $this->getTransient('update_themes');
409 $result['transient_without_filters'] = $transient_without_filters['transient'];
410 }
411
412 return $result;
413 }
414
415 function getCoreHandler() {
416 global $wp_db_version, $wp_version;
417
418 $result = $this->getTransient('update_core');
419 $result['current_db_version'] = $this->settings->getOption('db_version');
420 $result['latest_db_version'] = $wp_db_version;
421 $result['wp_version'] = $wp_version;
422
423 return $result;
424 }
425
426 function getSiteInfo($args) {
427 $result = array();
428
429 if (array_key_exists('pre_refresh_get_options', $args)) {
430 $result['pre_refresh_get_options'] = $this->settings->getOptions(
431 $args['pre_refresh_get_options']
432 );
433 }
434
435 if (array_key_exists('refresh', $args))
436 $result['refreshed'] = $this->refreshUpdatesInfo();
437
438 if (array_key_exists('users', $args))
439 $result['users'] = $this->getUsersHandler($args['users']);
440
441 if (array_key_exists('plugins', $args))
442 $result['plugins'] = $this->getPluginsHandler($args['plugins']);
443
444 if (array_key_exists('themes', $args))
445 $result['themes'] = $this->getThemesHandler($args['themes']);
446
447 if (array_key_exists('core', $args))
448 $result['core'] = $this->getCoreHandler();
449
450 if (array_key_exists('sys', $args))
451 $result['sys'] = $this->getSystemInfo();
452
453 if (array_key_exists('get_options', $args))
454 $result['get_options'] = $this->settings->getOptions($args['get_options']);
455
456 return $result;
457 }
458
459 function pingBV() {
460 $info = array();
461 $this->siteinfo->basic($info);
462 $this->bvapi->pingbv('/bvapi/pingbv', $info);
463 return true;
464 }
465
466 function getPostActivateInfo($args) {
467 $result = array();
468
469 if (array_key_exists('pingbv', $args))
470 $result['pingbv'] = array('status' => $this->pingBV());
471
472 if (array_key_exists('activate_info', $args))
473 $result['activate_info'] = $this->activate();
474
475 if (array_key_exists('cookie_info', $args))
476 $result['cookie_info'] = $this->cookieInfo();
477
478 if (array_key_exists('get_host', $args))
479 $result['get_host'] = $this->getHostInfo();
480
481 if (array_key_exists('get_wp', $args))
482 $result['get_wp'] = $this->getWpInfo();
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('get_tables', $args))
488 $result['get_tables'] = $this->db->showTables();
489
490 $result['status'] = true;
491
492 return $result;
493 }
494
495 function getPluginServicesInfo($args) {
496 $result = array();
497
498 if (array_key_exists('get_options', $args))
499 $result['get_options'] = $this->settings->getOptions($args['get_options']);
500
501 if (array_key_exists('pingbv', $args))
502 $result['pingbv'] = array('status' => $this->pingBV());
503
504 if (array_key_exists('server_config', $args))
505 $result['server_config'] = $this->serverConfig();
506
507 return $result;
508 }
509
510 function getPluginFileData($plugin_file) {
511 $result = array();
512
513 if (!function_exists('get_plugin_data')) {
514 require_once ABSPATH . 'wp-admin/includes/plugin.php';
515 }
516 $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_file);
517 if ($plugin_data && isset($plugin_data['Version'])) {
518 $result['version'] = $plugin_data['Version'];
519 }
520
521 return $result;
522 }
523
524 function fetchPluginApiData($slug, $action) {
525 $args = array('slug' => wp_unslash($slug));
526 $args = (object) $args;
527 $args = apply_filters('plugins_api_args', $args, $action);
528 $data = apply_filters('plugins_api', false, $action, $args);
529
530 return $data;
531 }
532
533 public function process($request) {
534 $db = $this->db;
535 $params = $request->params;
536 switch ($request->method) {
537 case "activateinfo":
538 $resp = array('actinfo' => $this->activate());
539 break;
540 case "ckeyinfo":
541 $resp = array('cookieinfo' => $this->cookieInfo());
542 break;
543 case "gtpsts":
544 $count = 5;
545 if (array_key_exists('count', $params))
546 $count = $params['count'];
547 $resp = $this->getPosts($params['post_type'], $count);
548 break;
549 case "gtsts":
550 $resp = $this->getStats();
551 break;
552 case "gtdbvariables":
553 $variable = (array_key_exists('variable', $params)) ? $params['variable'] : "";
554 $resp = $this->db->showDbVariables($variable);
555 break;
556 case "gtplgs":
557 $resp = $this->getPlugins();
558 break;
559 case "gtthms":
560 $resp = $this->getThemes();
561 break;
562 case "gtsym":
563 $resp = array('sys' => $this->getSystemInfo());
564 break;
565 case "gtwp":
566 $resp = array('wp' => $this->getWpInfo());
567 break;
568 case "gtallhdrs":
569 $data = (function_exists('getallheaders')) ? getallheaders() : false;
570 $resp = array("allhdrs" => $data);
571 break;
572 case "gtsvr":
573 $resp = array("svr" => $_SERVER);
574 break;
575 case "getoption":
576 $resp = array("option" => $this->settings->getOption($params['name']));
577 break;
578 case "gtusrs":
579 $full = false;
580 if (array_key_exists('full', $params))
581 $full = true;
582 $resp = array('users' => $this->getUsers($full, $params['args']));
583 break;
584 case "gttrnsnt":
585 $resp = $this->getTransient($params['name'], array_key_exists('asarray', $params));
586 break;
587 case "gthost":
588 $resp = array('host_info' => $this->getHostInfo());
589 break;
590 case "gtplsinfo":
591 $resp = array("plugins_info" => array());
592 $file_by_slug = $params["file_by_slug"];
593 foreach ($params['slugs'] as $slug) {
594 $data = $this->fetchPluginApiData($slug, $params['action']);
595 if (is_object($data) && !property_exists($data, 'version') && isset($file_by_slug[$slug])) {
596 $plugin_data = $this->getPluginFileData($file_by_slug[$slug]);
597 $data->version = $plugin_data['version'];
598 }
599 $resp['plugins_info'][$slug] = $data;
600 }
601 break;
602 case "gtplinfo":
603 $data = $this->fetchPluginApiData($params['slug'], $params['action']);
604 $resp = array("plugins_info" => $data);
605 break;
606 case "gtpostactinfo":
607 $resp = $this->getPostActivateInfo($params);
608 break;
609 case "gtsteinfo":
610 $resp = $this->getSiteInfo($params);
611 break;
612 case "psinfo":
613 $resp = $this->getPluginServicesInfo($params);
614 break;
615 default:
616 $resp = false;
617 }
618 return $resp;
619 }
620 }
621 endif;