Changeset 69 for trunk/include
- Timestamp:
- Jan 27, 2009, 8:52:57 AM (16 years ago)
- Location:
- trunk/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/pluggable-override.php
r65 r69 19 19 global $current_user; 20 20 21 if (is_root_index_page_call()){22 if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )23 return false;24 21 25 if ( ! empty($current_user))26 return;22 if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) 23 return false; 27 24 28 if (check_xpress_auth_cookie()){ 25 if ( ! empty($current_user) ) 26 return; 27 28 if (is_xpress_index_page_call()){ 29 if (check_xpress_auth_cookie()){ //The cookie is login user's or it checks it 29 30 if ( $user = wp_validate_auth_cookie() ) { 30 31 wp_set_current_user($user); … … 33 34 } 34 35 xpress_login(); 35 }else { 36 37 } else { 36 38 // WP2.7 original 37 39 if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) … … 60 62 $u_pass_md5 = $GLOBALS["xoopsUser"]->getVar("pass"); 61 63 if ( ! empty($u_name) && ! empty($u_pass_md5) ) { 62 // include_once dirname( __FILE__ ).'/xpress_user.php'; 63 // $mess = xpress_user_sync($GLOBALS["xoopsUser"]->getVar("uid")); 64 // if ($mess != 'NOT XPRESS USER'){ 64 include_once dirname( __FILE__ ).'/user_sync.php'; 65 $messege = ''; 66 $ret = xpress_user_sync($GLOBALS["xoopsUser"]->getVar("uid"),$messege); 67 if ($ret){ 65 68 $user = new WP_User(0, $u_name); 66 if ( wp_login($u_name, $u_pass_md5 , true) ) {69 if ( wp_login($u_name, $u_pass_md5) ) { 67 70 wp_setcookie($u_name, $u_pass_md5, true, '', '', false); 68 71 do_action('wp_login', $u_name); … … 70 73 return true; 71 74 } 72 // } 75 }else { 76 echo $messege; 77 } 73 78 } 74 79 } … … 88 93 } 89 94 90 if(is_object($GLOBALS["xoopsModule"]) && WP_BLOG_DIRNAME == $GLOBALS["xoopsModule"]->getVar("dirname")){ 95 if(is_object($GLOBALS["xoopsModule"])){ 96 // && WP_BLOG_DIRNAME == $GLOBALS["xoopsModule"]->getVar("dirname")){ 91 97 if(is_object($GLOBALS["xoopsUser"])){ 92 98 $u_name = $GLOBALS["xoopsUser"]->getVar("uname"); … … 107 113 } 108 114 109 110 /*111 112 function wp_login($username, $password, $already_md5 = false) {113 global $wpdb, $error;114 115 $username = sanitize_user($username);116 117 if ( '' == $username )118 return false;119 120 if ( '' == $password ) {121 $error = __('<strong>ERROR</strong>: The password field is empty.');122 return false;123 }124 125 $login = get_userdatabylogin($username);126 //$login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'");127 128 if (!$login) {129 $error = __('<strong>ERROR</strong>: Invalid username.');130 return false;131 } else {132 if ($login->user_login == $username) {133 if ($login->user_pass == $password) return true;134 if ($login->user_pass == md5($password)) return true;135 }136 137 $error = __('<strong>ERROR</strong>: Incorrect password.');138 $pwd = '';139 return false;140 }141 }142 */143 115 144 116 // for wordpress2.5 … … 177 149 } 178 150 179 180 /*181 182 function wp_mail($to, $subject, $message, $from_email="", $from_name="") {183 $xoopsMailer =& getMailer();184 $xoopsMailer->useMail();185 $xoopsMailer->setToEmails($to);186 $xoopsMailer->setFromEmail( empty($from_email) ? $GLOBALS["xoopsConfig"]['adminmail'] : $from_email);187 $xoopsMailer->setFromName( empty($from_name) ? $GLOBALS["xoopsConfig"]['sitename'] : $from_name );188 $xoopsMailer->setSubject($subject);189 $xoopsMailer->setBody($message);190 return $xoopsMailer->send();191 }192 193 */194 /*195 function auth_redirect($force = false, $message = "") {196 if(!is_object($GLOBALS["xoopsUser"])){197 header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');198 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');199 header('Cache-Control: no-cache, must-revalidate, max-age=0');200 header('Pragma: no-cache');201 202 header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));203 exit();204 }elseif(!empty($force)){205 $redirect = xoops_getenv("HTTP_REFERER");206 $redirect = (strpos($redirect, XOOPS_URL) === 0)? $redirect: XOOPS_URL."/".$redirect;207 redirect_header($redirect, 2, $message);208 }209 }210 */211 151 // *********************************** End Of Pluggable Function Edit (wp-include/pluggable.php) ************************************ 212 152 -
trunk/include/user_sync.php
r1 r69 54 54 // 55 55 56 include_once dirname( __FILE__ ).'/../../../mainfile.php'; 57 $path = dirname(dirname(__FILE__)) . '/'; 58 if (file_exists($path . 'wp-load.php')) { 59 require_once $path . 'wp-load.php'; 60 } else { 61 require_once $path . 'wp-config.php'; 62 } 63 64 //if( ! function_exists( 'get_xpress_mid' ) ) : 56 65 57 function get_xpress_mid($mydirname){ 66 58 $xoopsDB =& Database::getInstance(); … … 77 69 return $module_id; 78 70 } 79 //endif; 80 81 82 //if( ! function_exists( 'get_xpress_user_level' ) ) : 83 function get_xpress_user_level($mydirname , $uid=0){ 71 72 73 function get_xoops_group_capabillities_name($mydirname , $uid=0){ 84 74 if ($uid == 0){ 85 return 0;75 return ''; 86 76 } 87 77 … … 97 87 $result = $xoopsDB->query($sql, 0, 0); 98 88 if ($xoopsDB->getRowsNum($result) > 0){ 99 return 5;89 return 'administrator'; 100 90 } 101 91 … … 107 97 $result = $xoopsDB->query($sql, 0, 0); 108 98 if ($result === false){ 109 return 0;99 return ''; 110 100 }else{ 111 101 if ($xoopsDB->getRowsNum($result) > 0){ 112 102 $row = $xoopsDB->fetchArray($result); 113 103 $level = $row['user_level']; 114 return $level; 104 switch($level) { 105 case 5: 106 return 'administrator'; 107 case 4: 108 return 'editor'; 109 case 3: 110 return 'author'; 111 case 2: 112 return 'contributor'; 113 case 1: 114 return 'subscriber'; 115 default: 116 return ''; 117 } 115 118 } else { 116 return 0; 117 } 118 } 119 } 120 //endif; 121 122 //if( ! function_exists( 'get_now_user_level' ) ) : 123 function get_now_user_level(){ 124 125 global $xoopsModule; 126 127 if(empty($GLOBALS['user_level'])){ 128 return 0; 129 } else { 130 //$user_id = $GLOBALS["xoopsUser"]->getVar("uid"); 131 //$level = xpress2wp_user_level(get_xpress_user_level($mydirname , $user_id)); 132 //$level = get_wp_user_level($mydirname,$user_id); 133 $level = $GLOBALS['user_level']; 134 return $level; 135 } 136 } 137 //endif; 138 139 //if( ! function_exists( 'get_wp_user_leve' ) ) : 140 function get_wp_user_level($mydirname,$uid=0){ 141 $wp_prefix = get_xpress_prefix($mydirname); 142 $xoopsDB =& Database::getInstance(); 143 $db_xpress_usermeta = $xoopsDB->prefix($wp_prefix . 'usermeta'); 144 $meta_key_str = $xoopsDB->prefix($wp_prefix . 'user_level'); 145 $sql = "SELECT meta_value FROM $db_xpress_usermeta WHERE (user_id = $uid) AND (meta_key = $meta_key)"; 146 $res = $xoopsDB->query($sql, 0, 0); 147 if ($res === false){ 148 return 0; 149 }else{ 150 if ($xoopsDB->getRowsNum($res) > 0){ 151 $row = $xoopsDB->fetchArray($res); 152 $level = $row['meta_value']; 153 return $level; 154 } else { 155 return 0; 156 } 157 } 158 159 } 160 //endif; 119 return ''; 120 } 121 } 122 } 123 124 //endif; 161 125 162 126 //if( ! function_exists( 'get_xpress_prefix' ) ) : … … 191 155 //endif; 192 156 193 //if( ! function_exists( 'xpress2wp_user_level' ) ) :194 function xpress2wp_user_level($level){195 switch($level) {196 case 5:197 return 10;198 case 4:199 return 7;200 case 3:201 return 2;202 case 2:203 return 1;204 case 1:205 return 0;206 default:207 return 0;208 }209 }210 //endif;211 212 //if( ! function_exists( 'get_capabillities_name' ) ) :213 function get_capabillities_name($level){214 switch($level) {215 case 10:216 return 'administrator';217 case 7:218 return 'editor';219 case 2:220 return 'author';221 case 1:222 return 'contributor';223 case 0:224 return 'subscriber';225 default:226 return 'subscriber';227 }228 }229 //endif;230 157 231 158 //if( ! function_exists( 'xpress_usermeta_sync' ) ) : 232 function xpress_usermeta_sync($mydirname , $uid,$meta_key,$meta_value ){159 function xpress_usermeta_sync($mydirname , $uid,$meta_key,$meta_value, &$message){ 233 160 $wp_prefix = get_xpress_prefix($mydirname); 234 $xoopsDB =& Database::getInstance(); 161 $meta_key = "'" . $meta_key . "'"; 162 $xoopsDB =& Database::getInstance(); 235 163 $db_xpress_usermeta = $xoopsDB->prefix($wp_prefix . 'usermeta'); 236 164 $sql = "SELECT user_id FROM $db_xpress_usermeta WHERE (user_id = $uid) AND (meta_key = $meta_key)"; … … 249 177 $res = $xoopsDB->queryF($sql2, 0, 0); 250 178 if ($res === false) { 251 $ ret= "...ERR($sql2)";252 return $ret;179 $message .= "...ERR($sql2)"; 180 return false; 253 181 } else { 254 return ''; 255 } 256 257 } 258 //endif; 259 260 //if( ! function_exists( 'sql_str' ) ) : 182 return true; 183 } 184 185 } 186 //endif; 187 261 188 function sql_str($text = ''){ 262 189 return "'" . $text . "'"; 263 190 } 264 //endif;265 191 266 192 //if( ! function_exists( 'xpress_user_sync' ) ) : 267 function xpress_user_sync($sync_uid = 0 ){193 function xpress_user_sync($sync_uid = 0, &$message){ 268 194 $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; 269 195 … … 274 200 $db_xpress_users = $xoopsDB->prefix($wp_prefix . 'users'); 275 201 276 $ ret_str= 'Do Sync';202 $message = 'Do Sync'; 277 203 278 204 if ($sync_uid == 0) { … … 284 210 $xu_res = $xoopsDB->query($xu_sql, 0, 0); 285 211 if ($xu_res === false){ 286 $ ret_str.= '...ERR ('. $xu_sql . ')';287 return $ret_str;212 $message .= '...ERR ('. $xu_sql . ')'; 213 return false; 288 214 }else { 289 215 while($xu_row = $xoopsDB->fetchArray($xu_res)){ 290 $ xpress_user_level = get_xpress_user_level($mydirname , $xu_row['uid']);291 if ( $xpress_user_level < 1){292 $ ret_str.= "...PASS '" . $xu_row['uname'] ."'[uid=".$xu_row['uid'] ."](not xpress user)";216 $capabillities_name = get_xoops_group_capabillities_name($mydirname , $xu_row['uid']); 217 if (empty($capabillities_name)){ 218 $message .= "...PASS '" . $xu_row['uname'] ."'[uid=".$xu_row['uid'] ."](not xpress user)"; 293 219 if ($sync_uid != 0){ 294 $ ret_str.= '...NOT XPRESS USER ' . $xu_row['uname'];295 return $ret_str;220 $message .= '...NOT XPRESS USER ' . $xu_row['uname']; 221 return false; 296 222 } 297 223 } else { 298 224 $user_ID = $xu_row['uid']; 299 $user_level = xpress2wp_user_level($xpress_user_level); 300 if ($user_level == 10 ){ 301 $capabillities_name = 'administrator'; 302 }else { 225 if ($capabillities_name != 'administrator' ){ 303 226 if (!empty($GLOBALS["xoopsModuleConfig"]["use_wp_userlevel"])){ 304 $capabillities_name = get_option('default_role'); 305 }else { 306 $capabillities_name = get_capabillities_name($user_level); 227 $capabillities_name = get_option('default_role'); 307 228 } 308 229 } … … 325 246 326 247 $is_update = false; 327 328 // $capabillities = sql_str(get_capabillities($user_level));329 330 248 if (xpress_user_found($mydirname, $user_ID)){ 331 249 $wu_sql = "UPDATE $db_xpress_users "; … … 340 258 $wu_sql .= "WHERE (ID = $user_ID )"; 341 259 if (!empty($GLOBALS["xoopsModuleConfig"]["use_wp_userlevel"])){ 342 $ ret_str.= '...UPDATE ' . $user_login_name . '(Level Not Change)';260 $message .= '...UPDATE ' . $user_login_name . '(Level Not Change)'; 343 261 } else { 344 $ ret_str.= '...UPDATE ' . $user_login_name . '(' . $capabillities_name . ')';262 $message .= '...UPDATE ' . $user_login_name . '(' . $capabillities_name . ')'; 345 263 } 346 264 $is_update = true; … … 353 271 $wu_sql .= " , $user_regist_time, $user_status, $user_display_name)"; 354 272 if (!empty($GLOBALS["xoopsModuleConfig"]["use_wp_userlevel"])){ 355 $ ret_str.= '...INSERT ' . $user_login_name . '(' . $capabillities_name . '-WP Default)';273 $message .= '...INSERT ' . $user_login_name . '(' . $capabillities_name . '-WP Default)'; 356 274 } else { 357 $ ret_str.= '...INSERT ' . $user_login_name . '(' . $capabillities_name . ')';275 $message .= '...INSERT ' . $user_login_name . '(' . $capabillities_name . ')'; 358 276 } 359 277 } … … 362 280 363 281 if ($wu_res === false){ 364 $ ret_str.= '...ERR(' . $wu_sql . ')';365 return $ret_str;282 $message .= '...ERR(' . $wu_sql . ')'; 283 return false; 366 284 } 367 285 … … 376 294 } 377 295 378 if( $is_update === false){ 379 $meta_key = sql_str('nickname'); 380 $ans =xpress_usermeta_sync($mydirname, $user_ID,$meta_key,$user_nickname); 381 if(!empty($ans)){ 382 $ret_str .= $ans; 383 return $ret_str; 384 } 385 $meta_key = sql_str('first_name'); 386 $ans =xpress_usermeta_sync($mydirname, $user_ID,$meta_key,$user_first_name); 387 if(!empty($ans)){ 388 $ret_str .= $ans; 389 return $ret_str; 390 } 391 $meta_key = sql_str('last_name'); 392 $ans =xpress_usermeta_sync($mydirname, $user_ID,$meta_key,$user_last_name); 393 if(!empty($ans)){ 394 $ret_str .= $ans; 395 return $ret_str; 396 } 397 $meta_key = sql_str('description'); 398 $ans =xpress_usermeta_sync($mydirname, $user_ID,$meta_key,$user_description); 399 if(!empty($ans)){ 400 $ret_str .= $ans; 401 return $ret_str; 402 } 403 $meta_key = sql_str('jabber'); 404 $ans =xpress_usermeta_sync($mydirname, $user_ID,$meta_key,$user_jabber); 405 if(!empty($ans)){ 406 $ret_str .= $ans; 407 return $ret_str; 408 } 409 } 410 $meta_key = sql_str('aim'); 411 $ans =xpress_usermeta_sync($mydirname, $user_ID,$meta_key,$user_aim); 412 if(!empty($ans)){ 413 $ret_str .= $ans; 414 return $ret_str; 415 } 416 $meta_key = sql_str('yim'); 417 $ans =xpress_usermeta_sync($mydirname, $user_ID,$meta_key,$user_yim); 418 if(!empty($ans)){ 419 $ret_str .= $ans; 420 return $ret_str; 421 } 296 // if( $is_update === false){ 297 if(!xpress_usermeta_sync($mydirname, $user_ID,'nickname',$user_nickname,$message) )return false; 298 if(!xpress_usermeta_sync($mydirname, $user_ID,'first_name',$user_first_name,$message) )return false; 299 if(!xpress_usermeta_sync($mydirname, $user_ID,'last_name',$user_last_name,$message) )return false; 300 if(!xpress_usermeta_sync($mydirname, $user_ID,'description',$user_description,$message) )return false; 301 if(!xpress_usermeta_sync($mydirname, $user_ID,'jabber',$user_jabber,$message) )return false; 302 // } 303 if(!xpress_usermeta_sync($mydirname, $user_ID,'aim',$user_aim,$message) )return false; 304 if(!xpress_usermeta_sync($mydirname, $user_ID,'yim',$user_yim,$message) )return false; 422 305 if ($is_update === false ) { 423 $meta_key = sql_str('rich_editing'); 424 $ans =xpress_usermeta_sync($mydirname, $user_ID,$meta_key,$user_rich_editing); 425 if(!empty($ans)){ 426 $ret_str .= $ans; 427 return $ret_str; 428 } 306 if(!xpress_usermeta_sync($mydirname, $user_ID,'rich_editing',$user_rich_editing,$message) )return false; 429 307 } 430 308 } 431 309 } 432 310 } 433 $ret_str .= "...END"; 434 return $ret_str; 435 } 436 } 437 //endif; 311 $message .= "...END"; 312 return true; 313 } 314 } 315 //endif; 316 317 438 318 439 319 //if( ! function_exists( 'check_user_role_prefix' ) ) :
Note: See TracChangeset
for help on using the changeset viewer.