PluginProbe
The WP Remote WordPress Plugin / 4.84
The WP Remote WordPress Plugin v4.84
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 4.84, at callback/wings/info.php

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