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

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