PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
2.6.18 2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 All 73 releases
← All changes | includes/admin/converters/Vanilla.php +19 -87 trunk → 2.6.17 View file →
@@ -16,8 +16,16 @@
16 16 */
17 17 class Vanilla extends BBP_Converter_Base {
18 18
19 19 /**
20 + * Main Constructor
21 + *
22 + */
23 + public function __construct() {
24 + parent::__construct();
25 + }
26 +
27 + /**
20 28 * Sets up the field mappings
21 29 */
22 30 public function setup_globals() {
23 31
@@ -86,9 +94,9 @@
86 94 'to_type' => 'forum',
87 95 'to_fieldname' => 'post_title'
88 96 );
89 97
90 - // Forum slug (Clean name to avoid conflicts)
98 + // Forum slug (Clean name to avoid confilcts)
91 99 $this->field_map[] = array(
92 100 'from_tablename' => 'Category',
93 101 'from_fieldname' => 'Name',
94 102 'to_type' => 'forum',
@@ -460,30 +468,14 @@
460 468 );
461 469
462 470 // Store old user password (Stored in usermeta)
463 471 $this->field_map[] = array(
464 - 'from_tablename' => 'User',
465 - 'from_fieldname' => 'Password',
466 - 'to_type' => 'user',
467 - 'to_fieldname' => '_bbp_password',
468 - 'callback_method' => 'callback_savepass'
469 - );
470 -
471 - // Password hash method (Used by the password callback above)
472 - $this->field_map[] = array(
473 472 'from_tablename' => 'User',
474 - 'from_fieldname' => 'HashMethod',
473 + 'from_fieldname' => 'Password',
475 474 'to_type' => 'user',
476 - 'to_fieldname' => ''
475 + 'to_fieldname' => '_bbp_password'
477 476 );
478 477
479 - // User password verify class (Stored in usermeta for verifying password)
480 - $this->field_map[] = array(
481 - 'to_type' => 'user',
482 - 'to_fieldname' => '_bbp_class',
483 - 'default' => 'Vanilla'
484 - );
485 -
486 478 // User name.
487 479 $this->field_map[] = array(
488 480 'from_tablename' => 'User',
489 481 'from_fieldname' => 'Name',
@@ -574,9 +566,9 @@
574 566
575 567 /**
576 568 * Clean Root Parent ID -1 to 0
577 569 *
578 - * @param int $parent_id Vanilla v2.x Parent ID
570 + * @param int $parent Vanilla v2.x Parent ID
579 571 * @return int
580 572 */
581 573 public function callback_forum_parent( $parent_id = 0 ) {
582 574 if ( -1 === (int) $parent_id ) {
@@ -597,80 +589,20 @@
597 589 return $count;
598 590 }
599 591
600 592 /**
601 - * Store Vanilla's password hash with its hash method.
602 - *
603 - * WordPress unslashes metadata before storage, so pre-slash the source value
604 - * to preserve legacy plaintext passwords containing quotes or backslashes.
605 - *
606 - * @param string $field Password hash or legacy plaintext password.
607 - * @param array $row Source database row.
608 - * @return array|bool Password metadata, or false if invalid.
593 + * This method is to save the salt and password together. That
594 + * way when we authenticate it we can get it out of the database
595 + * as one value. Array values are auto sanitized by WordPress.
609 596 */
610 597 public function callback_savepass( $field, $row ) {
611 - if ( ! is_string( $field ) ) {
612 - return false;
613 - }
614 -
615 - $method = isset( $row['HashMethod'] ) && is_string( $row['HashMethod'] )
616 - ? $row['HashMethod']
617 - : '';
618 -
619 - return wp_slash(
620 - array(
621 - 'hash' => $field,
622 - 'method' => $method,
623 - )
624 - );
598 + return false;
625 599 }
626 600
627 601 /**
628 - * Check a password against Vanilla 2 authentication metadata.
629 - *
630 - * Vanilla 2.0.18.1 generated portable phpass hashes, while retaining
631 - * compatibility with legacy MD5 hashes and plaintext passwords.
632 - *
633 - * @param string $password Password in plain text.
634 - * @param string $serialized_pass Serialized authentication metadata.
635 - * @return bool Whether the password is correct.
602 + * This method is to take the pass out of the database and compare
603 + * to a pass the user has typed in.
636 604 */
637 605 public function authenticate_pass( $password, $serialized_pass ) {
638 -
639 - // Unserialize the password, with safeguards
640 - $pass_array = $this->unserialize_pass( $serialized_pass );
641 -
642 - // Bail if missing or invalid values
643 - if ( ! is_string( $password ) || ! is_array( $pass_array ) || ! isset( $pass_array['hash'], $pass_array['method'] ) || ! is_string( $pass_array['hash'] ) || ! is_string( $pass_array['method'] ) ) {
644 - return false;
645 - }
646 -
647 - // This converter targets Vanilla's native password formats only
648 - if ( '' !== $pass_array['method'] && 0 !== strcasecmp( 'Vanilla', $pass_array['method'] ) ) {
649 - return false;
650 - }
651 -
652 - $hash = $pass_array['hash'];
653 -
654 - if ( '' === $hash || '*' === $hash ) {
655 - return false;
656 - }
657 -
658 - // Vanilla used phpass for hashes beginning with "$" or "_"
659 - if ( '$' === $hash[0] || '_' === $hash[0] ) {
660 - require_once ABSPATH . WPINC . '/class-phpass.php';
661 -
662 - $hasher = new PasswordHash( 8, true );
663 -
664 - return $hasher->CheckPassword( $password, $hash );
665 - }
666 -
667 - if ( empty( $password ) ) {
668 - return false;
669 - }
670 -
671 - $plain_matches = hash_equals( $hash, $password );
672 - $md5_matches = hash_equals( $hash, md5( $password ) );
673 -
674 - return $plain_matches || $md5_matches;
606 + return false;
675 607 }
676 608 }