XPressME Integration Kit

Trac

Changeset 845


Ignore:
Timestamp:
Nov 9, 2013, 3:43:39 PM (10 years ago)
Author:
toemon
Message:

最終修正 fixed #427

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/pluggable-override.php

    r843 r845  
    3535                                if (function_exists('wp_validate_auth_cookie')){ 
    3636                                        if ( $user = wp_validate_auth_cookie() ) { 
    37                                                 // When the user meta prefix is different according to the change in the xoops data base prefix, it restores it.  
     37                                                // When the user meta prefix is different according to the change in the xoops data base prefix, it restores it. 
    3838                                                if (!check_user_meta_prefix($user)){ 
    3939                                                        repair_user_meta_prefix(); 
     
    4242                                                return ; 
    4343                                        } 
    44                                 } else { // for WP2.0                                    
     44                                } else { // for WP2.0 
    4545                                        if ( !empty($_COOKIE[USER_COOKIE]) && !empty($_COOKIE[PASS_COOKIE])){ 
    4646                                                if(wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) { 
     
    5151                                        } 
    5252                                } 
    53                         }                                
    54                         return xpress_login();   
     53                        } 
     54                        return xpress_login(); 
    5555                } else {                                                        // For the xoops guest 
    56                  
    57                         if (function_exists('wp_validate_auth_cookie')){ 
    58                                 if ( ! $user = wp_validate_auth_cookie() ) { 
    59                                          if ( empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) { 
    60                                                 wp_set_current_user(0); 
    61                                                 return false; 
    62                                          } 
    63                                 } 
    64                                 wp_set_current_user($user); 
    65                         } else { // for WP2.0 
    66                                 if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||  
    67                                         !wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) { 
    68                                         wp_set_current_user(0); 
    69                                         return false; 
    70                                 } 
    71                                 $user_login = $_COOKIE[USER_COOKIE]; 
    72                                 wp_set_current_user(0, $user_login); 
    73                         } 
     56                        wp_set_current_user(0); 
    7457                        return false; 
    7558                } 
     
    9174                        wp_set_current_user($user); 
    9275                } else { // for WP2.0 
    93                         if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||  
     76                        if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) || 
    9477                                !wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) { 
    9578                                wp_set_current_user(0); 
     
    10790        global $current_user; 
    10891        global $xoopsModule,$xoopsUser,$xoopsUserIsAdmin; 
    109          
     92 
    11093        if(is_object($xoopsUser)){ 
    11194                $u_name = $xoopsUser->getVar("uname"); 
     
    124107                                        return  true; 
    125108                                } 
    126                         }                        
     109                        } 
    127110                } 
    128111        } 
     
    147130                        return false; 
    148131        } 
    149                                          
     132 
    150133        if(is_object($GLOBALS["xoopsModule"])){ 
    151134//              && WP_BLOG_DIRNAME == $GLOBALS["xoopsModule"]->getVar("dirname")){ 
     
    162145                $needle = '/modules/' . $mydirname . '/wp-admin/'; 
    163146                if (strstr($org_url , $needle)){ 
    164                         return true;                             
     147                        return true; 
    165148                } 
    166149        } 
     
    176159 
    177160        // For attestation when password has been sent as hash value. (When having logged it in from Xoops and ImpressCMS) 
    178         if ($hash == $password){  
     161        if ($hash == $password){ 
    179162                return apply_filters('check_password', true, $password, $hash, $user_id); 
    180163        } 
    181          
    182         // Password authentication for Xoops  
     164 
     165        // Password authentication for Xoops 
    183166        if ( strlen($hash) <= 32 ) { 
    184167                $check = ( $hash == md5($password) ); 
    185                 return apply_filters('check_password', $check, $password, $hash, $user_id);      
    186         } 
    187          
    188         // Password authentication for ImpressCMS  
     168                return apply_filters('check_password', $check, $password, $hash, $user_id); 
     169        } 
     170 
     171        // Password authentication for ImpressCMS 
    189172        if($xoops_config->is_impress && function_exists('hash')){ 
    190173                $mainSalt = $xoops_config->xoops_db_salt; 
     
    195178                $user_salt = $xoops_db->get_var("SELECT salt FROM $xoops_user_db WHERE uname = '$login_name'"); 
    196179                $enc_type = intval( $xoops_db->get_var("SELECT enc_type FROM $xoops_user_db WHERE uname = '$login_name'") ); 
    197                  
    198                 // Make Impress hash  
     180 
     181                // Make Impress hash 
    199182                if($enc_type == 0) {$impress_hash = md5($password);} // no salt used for compatibility with external scripts such as ipb/phpbb etc. 
    200183                elseif($enc_type == 1) {$impress_hash = hash('sha256', $user_salt.md5($password).$mainSalt);} 
     
    218201                        return apply_filters('check_password', true, $password, $hash, $user_id); 
    219202                } 
    220         }        
     203        } 
    221204 
    222205        // If the hash is still md5... 
    223206        if ( strlen($hash) <= 32 ) { 
    224                 $check = ( $hash == md5($password) );    
    225 /* A new hash is not used because it differs from the hash on the XOOPS password.  
     207                $check = ( $hash == md5($password) ); 
     208/* A new hash is not used because it differs from the hash on the XOOPS password. 
    226209 *              if ( $check && $user_id ) { 
    227210 *                      // Rehash using new hash. 
     
    250233function wp_redirect($location, $status = 302) { 
    251234        global $is_IIS,$xoops_config,$action; 
    252          
     235 
    253236        if ($location == 'wp-login.php?loggedout=true') $location = $xoops_config->xoops_url.'/user.php?op=logout'; //xoops logout at wp logout 
    254237        if ($location == 'wp-login.php?action=register') $location = $xoops_config->xoops_url."/register.php";  //wp-register to xoops register 
     
    272255                        header("Location: $location"); 
    273256                } 
    274         } else {  // force redirect  
     257        } else {  // force redirect 
    275258                echo ("<HTML>"); 
    276259                echo("<META http-equiv=\"Refresh\" content=\"0;url=$location\">"); 
Note: See TracChangeset for help on using the changeset viewer.