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

477 lines 12.9 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.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 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 function refreshUpdatesInfo() {
264 global $wp_current_filter;
265 $wp_current_filter[] = 'load-update-core.php';
266
267 if (function_exists('wp_clean_update_cache')) {
268 wp_clean_update_cache();
269 } else {
270 $this->settings->deleteTransient('update_plugins');
271 $this->settings->deleteTransient('update_themes');
272 $this->settings->deleteTransient('update_core');
273 }
274
275 wp_update_plugins();
276 wp_update_themes();
277
278 array_pop($wp_current_filter);
279
280 wp_update_plugins();
281 wp_update_themes();
282
283 wp_version_check();
284 wp_version_check(array(), true);
285
286 return true;
287 }
288
289 function getUsersHandler($args = array()) {
290 $db = $this->db;
291 $table = "{$db->dbprefix()}users";
292 $count = $db->rowsCount($table);
293 $result = array("count" => $count);
294
295 $max_users = array_key_exists('max_users', $args) ? $args['max_users'] : 500;
296 $roles = array_key_exists('roles', $args) ? $args['roles'] : array();
297
298 $users = array();
299 if (($count > $max_users) && !empty($roles)) {
300 foreach ($roles as $role) {
301 if ($max_users <= 0)
302 break;
303 $args['number'] = $max_users;
304 $args['role'] = $role;
305 $fetched = $this->getUsers($args['full'], $args);
306 $max_users -= sizeof($fetched);
307 $users = array_merge($users, $fetched);
308 }
309 } else {
310 $args['number'] = $max_users;
311 $users = $this->getUsers($args['full'], $args);
312 }
313 $result['users_info'] = $users;
314
315 return $result;
316 }
317
318 function getTransient($name, $asarray = true) {
319 $transient = $this->settings->getTransient($name);
320 if ($transient && $asarray)
321 $transient = $this->objectToArray($transient);
322 return array("transient" => $transient);
323 }
324
325 function getPluginsHandler() {
326 return array_merge($this->getPlugins(), $this->getTransient('update_plugins'));
327 }
328
329 function getThemesHandler() {
330 return array_merge($this->getThemes(), $this->getTransient('update_themes'));
331 }
332
333 function getSiteInfo($args) {
334 $result = array();
335
336 if (array_key_exists('pre_refresh_get_options', $args)) {
337 $result['pre_refresh_get_options'] = $this->settings->getOptions(
338 $args['pre_refresh_get_options']
339 );
340 }
341
342 if (array_key_exists('refresh', $args))
343 $result['refreshed'] = $this->refreshUpdatesInfo();
344
345 if (array_key_exists('users', $args))
346 $result['users'] = $this->getUsersHandler($args['users']);
347
348 if (array_key_exists('plugins', $args))
349 $result['plugins'] = $this->getPluginsHandler();
350
351 if (array_key_exists('themes', $args))
352 $result['themes'] = $this->getThemesHandler();
353
354 if (array_key_exists('core', $args))
355 $result['core'] = $this->getTransient('update_core');
356
357 if (array_key_exists('sys', $args))
358 $result['sys'] = $this->getSystemInfo();
359
360 if (array_key_exists('get_options', $args))
361 $result['get_options'] = $this->settings->getOptions($args['get_options']);
362
363 return $result;
364 }
365
366 function pingBV() {
367 $info = array();
368 $this->siteinfo->basic($info);
369 $this->bvapi->pingbv('/bvapi/pingbv', $info);
370 return true;
371 }
372
373 function getPostActivateInfo($args) {
374 $result = array();
375
376 if (array_key_exists('pingbv', $args))
377 $result['pingbv'] = array('status' => $this->pingBV());
378
379 if (array_key_exists('activate_info', $args))
380 $result['activate_info'] = $this->activate();
381
382 if (array_key_exists('cookie_info', $args))
383 $result['cookie_info'] = $this->cookieInfo();
384
385 if (array_key_exists('get_host', $args))
386 $result['get_host'] = $this->getHostInfo();
387
388 if (array_key_exists('get_wp', $args))
389 $result['get_wp'] = $this->getWpInfo();
390
391 if (array_key_exists('get_options', $args))
392 $result['get_options'] = $this->settings->getOptions($args['get_options']);
393
394 if (array_key_exists('get_tables', $args))
395 $result['get_tables'] = $this->db->showTables();
396
397 $result['status'] = true;
398
399 return $result;
400 }
401
402 public function process($request) {
403 $db = $this->db;
404 $params = $request->params;
405 switch ($request->method) {
406 case "activateinfo":
407 $resp = array('actinfo' => $this->activate());
408 break;
409 case "ckeyinfo":
410 $resp = array('cookieinfo' => $this->cookieInfo());
411 break;
412 case "gtpsts":
413 $count = 5;
414 if (array_key_exists('count', $params))
415 $count = $params['count'];
416 $resp = $this->getPosts($params['post_type'], $count);
417 break;
418 case "gtsts":
419 $resp = $this->getStats();
420 break;
421 case "gtplgs":
422 $resp = $this->getPlugins();
423 break;
424 case "gtthms":
425 $resp = $this->getThemes();
426 break;
427 case "gtsym":
428 $resp = array('sys' => $this->getSystemInfo());
429 break;
430 case "gtwp":
431 $resp = array('wp' => $this->getWpInfo());
432 break;
433 case "gtallhdrs":
434 $data = (function_exists('getallheaders')) ? getallheaders() : false;
435 $resp = array("allhdrs" => $data);
436 break;
437 case "gtsvr":
438 $resp = array("svr" => $_SERVER);
439 break;
440 case "getoption":
441 $resp = array("option" => $this->settings->getOption($params['name']));
442 break;
443 case "gtusrs":
444 $full = false;
445 if (array_key_exists('full', $params))
446 $full = true;
447 $resp = array('users' => $this->getUsers($full, $params['args']));
448 break;
449 case "gttrnsnt":
450 $resp = $this->getTransient($params['name'], array_key_exists('asarray', $params));
451 break;
452 case "gthost":
453 $resp = array('host_info' => $this->getHostInfo());
454 break;
455 case "gtplinfo":
456 $args = array(
457 'slug' => wp_unslash($params['slug'])
458 );
459 $action = $params['action'];
460 $args = (object) $args;
461 $args = apply_filters('plugins_api_args', $args, $action);
462 $data = apply_filters('plugins_api', false, $action, $args);
463 $resp = array("plugins_info" => $data);
464 break;
465 case "gtpostactinfo":
466 $resp = $this->getPostActivateInfo($params);
467 break;
468 case "gtsteinfo":
469 $resp = $this->getSiteInfo($params);
470 break;
471 default:
472 $resp = false;
473 }
474 return $resp;
475 }
476 }
477 endif;