PluginProbe
The WP Remote WordPress Plugin / 6.36
The WP Remote WordPress Plugin v6.36
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
← All changes | callback/wings/manage.php +163 -40 5.566.36 View file →
@@ -6,9 +6,9 @@
6 6 public $settings;
7 7 public $skin;
8 8 public $bvinfo;
9 9
10 - const MANAGE_WING_VERSION = 1.6;
10 + const MANAGE_WING_VERSION = 1.7;
11 11
12 12 public function __construct($callback_handler) {
13 13 $this->settings = $callback_handler->settings;
14 14 $this->bvinfo = new WPRInfo($this->settings);
@@ -44,9 +44,8 @@
44 44 @include_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php';
45 45 @include_once ABSPATH.'wp-admin/includes/class-theme-upgrader.php';
46 46 @include_once ABSPATH.'wp-admin/includes/class-plugin-upgrader.php';
47 47 @include_once ABSPATH.'wp-admin/includes/user.php';
48 - @include_once ABSPATH.'wp-includes/registration.php';
49 48 @include_once ABSPATH.'wp-admin/includes/upgrade.php';
50 49 @include_once ABSPATH.'wp-admin/includes/update.php';
51 50 @require_once ABSPATH.'wp-admin/includes/update-core.php';
52 51 }
@@ -282,18 +281,8 @@
282 281 } else {
283 282 return array('status' => 'Done');
284 283 }
285 284 } else {
286 - $resp = array("wp_update_core", function_exists('wp_update_core'));
287 - if (function_exists('wp_update_core')) {
288 - $result = wp_update_core($to_update);
289 - if (is_wp_error($result)) {
290 - return array('status' => "Error", "message" => $this->getError($result));
291 - } else {
292 - return array('status' => 'Done');
293 - }
294 - }
295 -
296 285 $resp = array("WP_Upgrader", class_exists('WP_Upgrader'));
297 286 if (class_exists('WP_Upgrader')) {
298 287 $upgrader = new WP_Upgrader();
299 288
@@ -342,8 +331,9 @@
342 331 }
343 332 }
344 333
345 334 function bv_plugin_bulk_upgrade($upgrader, $_plugins) {
335 + global $wp_version;
346 336 $plugins = array_keys($_plugins);
347 337 $args = array();
348 338 $defaults = array(
349 339 'clear_update_cache' => true,
@@ -373,20 +363,51 @@
373 363 foreach($plugins as $plugin) {
374 364 $upgrader->update_current++;
375 365 $upgrader->skin->plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin, false, true);
376 366 $upgrader->skin->plugin_active = is_plugin_active($plugin);
377 - $result = $upgrader->run(
378 - array(
379 - 'package' => $_plugins[$plugin],
380 - 'destination' => WP_PLUGIN_DIR,
381 - 'clear_destination' => true,
382 - 'clear_working' => true,
383 - 'is_multi' => true,
384 - 'hook_extra' => array(
385 - 'plugin' => $plugin,
386 - ),
387 - )
388 - );
367 + if ( isset( $_plugins[$plugin]['requires'] ) && function_exists('is_wp_version_compatible') && !is_wp_version_compatible( $_plugins[$plugin]['requires'] ) ) {
368 + $result = new WP_Error(
369 + 'incompatible_wp_required_version',
370 + sprintf(
371 + __( 'Your WordPress version is %1$s, however the new plugin version requires %2$s.' ),
372 + $wp_version,
373 + $_plugins[$plugin]['requires']
374 + )
375 + );
376 +
377 + $upgrader->skin->before( $result );
378 + $upgrader->skin->error( $result );
379 + $upgrader->skin->after();
380 + } elseif ( isset( $_plugins[$plugin]['requires_php'] ) && function_exists('is_php_version_compatible') && !is_php_version_compatible( $_plugins[$plugin]['requires_php'] ) ) {
381 +
382 + $result = new WP_Error(
383 + 'incompatible_php_required_version',
384 + sprintf(
385 + __( 'The PHP version on your server is %1$s, however the new plugin version requires %2$s.' ),
386 + PHP_VERSION,
387 + $_plugins[$plugin]['requires_php']
388 + )
389 + );
390 +
391 + $upgrader->skin->before( $result );
392 + $upgrader->skin->error( $result );
393 + $upgrader->skin->after();
394 + } else {
395 + add_filter('upgrader_source_selection', array($upgrader, 'check_package'));
396 + $result = $upgrader->run(
397 + array(
398 + 'package' => $_plugins[$plugin]['package'],
399 + 'destination' => WP_PLUGIN_DIR,
400 + 'clear_destination' => true,
401 + 'clear_working' => true,
402 + 'is_multi' => true,
403 + 'hook_extra' => array(
404 + 'plugin' => $plugin,
405 + ),
406 + )
407 + );
408 + remove_filter('upgrader_source_selection', array($upgrader, 'check_package'));
409 + }
389 410 $results[$plugin] = $result;
390 411 if (false === $result) {
391 412 break;
392 413 }
@@ -421,9 +442,18 @@
421 442 $result = array();
422 443 $_plugins = array();
423 444 $plugins_by_name = array();
424 445 foreach ($plugins as $plugin) {
425 - $_plugins[$plugin['file']] = $plugin['package'];
446 + $_plugins[$plugin['file']] = [
447 + 'package' => $plugin['package']
448 + ];
449 + if (isset($plugin['requires'])) {
450 + $_plugins[$plugin['file']]['requires'] = $plugin['requires'];
451 + }
452 +
453 + if (isset($plugin['requires_php'])) {
454 + $_plugins[$plugin['file']]['requires_php'] = $plugin['requires_php'];
455 + }
426 456 $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin['file'], false, true);
427 457 $plugins_by_name[$plugin_data['Name']] = $plugin['file'];
428 458 }
429 459 if (empty(array_keys($_plugins))) {
@@ -443,8 +473,11 @@
443 473 $result = $this->bv_plugin_bulk_upgrade($upgrader, $_plugins);
444 474 } else {
445 475 $result = $upgrader->bulk_upgrade(array_keys($_plugins));
446 476 }
477 + if (!is_array($result)) {
478 + return array('status' => "Error", 'message' =>'result is not an array');
479 + }
447 480 foreach (array_keys($_plugins) as $file) {
448 481 if (!array_key_exists($file, $result)) {
449 482 $result[$file] = array('status' => "Error");
450 483 } else {
@@ -460,8 +493,9 @@
460 493 return $result;
461 494 }
462 495
463 496 function bv_theme_bulk_upgrade($upgrader, $_themes) {
497 + global $wp_version;
464 498 $themes = array_keys($_themes);
465 499 $args = array();
466 500 $defaults = array(
467 501 'clear_update_cache' => true,
@@ -492,21 +526,50 @@
492 526 $upgrader->update_current = 0;
493 527 foreach ($themes as $theme) {
494 528 $upgrader->update_current++;
495 529 $upgrader->skin->theme_info = $upgrader->theme_info($theme);
496 - $result = $upgrader->run(
497 - array(
498 - 'package' => $_themes[$theme],
499 - 'destination' => get_theme_root($theme),
500 - 'clear_destination' => true,
501 - 'clear_working' => true,
502 - 'is_multi' => true,
503 - 'hook_extra' => array(
504 - 'theme' => $theme,
505 - ),
506 - )
507 - );
530 + if ( isset( $_themes[$theme]['requires'] ) && function_exists('is_wp_version_compatible') && !is_wp_version_compatible( $_themes[$theme]['requires'] ) ) {
531 + $result = new WP_Error(
532 + 'incompatible_wp_required_version',
533 + sprintf(
534 + __( 'Your WordPress version is %1$s, however the new theme version requires %2$s.' ),
535 + $wp_version,
536 + $_themes[$theme]['requires']
537 + )
538 + );
508 539
540 + $upgrader->skin->before( $result );
541 + $upgrader->skin->error( $result );
542 + $upgrader->skin->after();
543 + } elseif ( isset( $_themes[$theme]['requires_php'] ) && function_exists('is_php_version_compatible') && !is_php_version_compatible( $_themes[$theme]['requires_php'] ) ) {
544 + $result = new WP_Error(
545 + 'incompatible_php_required_version',
546 + sprintf(
547 + __( 'The PHP version on your server is %1$s, however the new theme version requires %2$s.' ),
548 + PHP_VERSION,
549 + $_themes[$theme]['requires_php']
550 + )
551 + );
552 +
553 + $upgrader->skin->before( $result );
554 + $upgrader->skin->error( $result );
555 + $upgrader->skin->after();
556 + } else {
557 + add_filter('upgrader_source_selection', array($upgrader, 'check_package'));
558 + $result = $upgrader->run(
559 + array(
560 + 'package' => $_themes[$theme]['package'],
561 + 'destination' => get_theme_root($theme),
562 + 'clear_destination' => true,
563 + 'clear_working' => true,
564 + 'is_multi' => true,
565 + 'hook_extra' => array(
566 + 'theme' => $theme,
567 + ),
568 + )
569 + );
570 + remove_filter('upgrader_source_selection', array($upgrader, 'check_package'));
571 + }
509 572 $results[$theme] = $result;
510 573 if (false === $result) {
511 574 break;
512 575 }
@@ -542,9 +605,17 @@
542 605 function upgradeThemes($themes, $has_bv_skin = false, $bv_bulk_upgrade = false) {
543 606 $result = array();
544 607 $_themes = array();
545 608 foreach ($themes as $theme) {
546 - $_themes[$theme['stylesheet']] = $theme['package'];
609 + $_themes[$theme['stylesheet']] = [
610 + 'package' => $theme['package']
611 + ];
612 + if (isset($theme['requires'])) {
613 + $_themes[$theme['stylesheet']]['requires'] = $theme['requires'];
614 + }
615 + if (isset($theme['requires_php'])) {
616 + $_themes[$theme['stylesheet']]['requires_php'] = $theme['requires_php'];
617 + }
547 618 }
548 619 if (empty(array_keys($_themes))) {
549 620 return $result;
550 621 }
@@ -561,8 +632,11 @@
561 632 $result = $this->bv_theme_bulk_upgrade($upgrader, $_themes);
562 633 } else {
563 634 $result = $upgrader->bulk_upgrade(array_keys($_themes));
564 635 }
636 + if (!is_array($result)) {
637 + return array('status' => "Error", 'message' =>'result is not an array');
638 + }
565 639 foreach (array_keys($_themes) as $stylesheet) {
566 640 if (!array_key_exists($stylesheet, $result)) {
567 641 $result[$stylesheet] = array('status' => "Error");
568 642 } else {
@@ -630,10 +704,14 @@
630 704 $upgrader->init();
631 705 $destination = $params['dest'];
632 706 $clear_destination = isset($params['cleardest']) ? $params['cleardest'] : false;
633 707 $package_url = $params['package'];
708 + $is_parent_theme_install_disabled = isset($params['is_parent_theme_install_disabled']) ? $params['is_parent_theme_install_disabled'] : false;
634 709 $key = basename($package_url);
635 710 add_filter('upgrader_source_selection', array($upgrader, 'check_package'));
711 + if ("theme" === $type && false === $is_parent_theme_install_disabled) {
712 + add_filter('upgrader_post_install', array($upgrader, 'check_parent_theme_filter'), 10, 3);
713 + }
636 714 $res = $upgrader->run(
637 715 array(
638 716 'package' => $package_url,
639 717 'destination' => $destination,
@@ -645,8 +723,11 @@
645 723 ),
646 724 )
647 725 );
648 726 remove_filter('upgrader_source_selection', array($upgrader, 'check_package'));
727 + if ("theme" === $type && false === $is_parent_theme_install_disabled) {
728 + remove_filter('upgrader_post_install', array($upgrader, 'check_parent_theme_filter'), 10);
729 + }
649 730 if (is_wp_error($res)) {
650 731 $res = array('status' => "Error", 'message' => $this->getError($res));
651 732 } else {
652 733 $res = array( 'status' => "Done");
@@ -661,9 +742,17 @@
661 742 function getPremiumUpgradesInfo() {
662 743 return apply_filters( 'mwp_premium_perform_update', array() );
663 744 }
664 745
665 - function autoLogin($username, $isHttps) {
746 + function autoLogin($username, $isHttps, $auto_login_token = null) {
747 + # Validate nonce if provided (other plugin compatibility: allow login if token missing)
748 + if ($auto_login_token !== null && $auto_login_token !== '') {
749 + $validation_result = $this->validateAutoLoginToken($auto_login_token);
750 + if ($validation_result !== true) {
751 + return $validation_result;
752 + }
753 + }
754 +
666 755 $user = get_user_by('login', $username);
667 756 if ($user != FALSE) {
668 757 wp_set_current_user( $user->ID );
669 758 if ($isHttps) {
@@ -678,8 +767,41 @@
678 767 exit;
679 768 }
680 769 }
681 770
771 + private function validateAutoLoginToken($auto_login_token) {
772 + # Get plugin name for transient key prefix
773 + $plugname = $this->bvinfo->plugname;
774 + if (empty($plugname)) {
775 + return array(
776 + 'status' => 'Error',
777 + 'message' => 'PLUGIN_NAME_NOT_FOUND',
778 + 'error_code' => 'PLUGIN_NAME_ERROR'
779 + );
780 + }
781 +
782 + # Construct transient key: {plugname}_auto_login_tk_{token}
783 + $transient_key = $plugname . '_auto_login_tk_' . $auto_login_token;
784 +
785 + # Check if token has already been used
786 + $used_token = $this->settings->getTransient($transient_key);
787 + if ($used_token !== false) {
788 + # Token already used - prevent replay attack
789 + return array(
790 + 'status' => 'Error',
791 + 'message' => 'AUTO_LOGIN_TOKEN_ALREADY_USED',
792 + 'error_code' => 'AUTO_LOGIN_TOKEN_ERROR'
793 + );
794 + }
795 +
796 + # Store token as used for 24 hours to prevent reuse
797 + # WordPress will automatically clean up expired transients
798 + $this->settings->setTransient($transient_key, true, DAY_IN_SECONDS);
799 +
800 + # Token is valid and has been marked as used
801 + return true;
802 + }
803 +
682 804 public function refreshPluginUpdates() {
683 805 global $wp_current_filter;
684 806 $wp_current_filter[] = 'load-update-core.php';
685 807
@@ -872,9 +994,10 @@
872 994 case "atolgn":
873 995 $isHttps = false;
874 996 if (array_key_exists('https', $params))
875 997 $isHttps = true;
876 - $resp = array("autologin" => $this->autoLogin($params['username'], $isHttps));
998 + $auto_login_token = array_key_exists('auto_login_token', $params) ? $params['auto_login_token'] : null;
999 + $resp = array("autologin" => $this->autoLogin($params['username'], $isHttps, $auto_login_token));
877 1000 break;
878 1001 case "updatedb":
879 1002 $resp = array("status" => $this->upgrade_db());
880 1003 break;