summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-includes/pluggable-functions.php
diff options
context:
space:
mode:
authormatt <matt@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-05-15 03:19:56 +0000
committermatt <matt@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-05-15 03:19:56 +0000
commit034694eb53dd71a980745f5594509890fd761998 (patch)
treec85517e8af3fce163f1d183afdf7c9ac7094d84e /wp-inst/wp-includes/pluggable-functions.php
parenta72266931b88c8fa300d2e29a69a2bb38a70654a (diff)
downloadwordpress-mu-034694eb53dd71a980745f5594509890fd761998.tar.gz
wordpress-mu-034694eb53dd71a980745f5594509890fd761998.tar.xz
wordpress-mu-034694eb53dd71a980745f5594509890fd761998.zip
Lots and lots of changes.
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@543 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-includes/pluggable-functions.php')
-rw-r--r--wp-inst/wp-includes/pluggable-functions.php72
1 files changed, 45 insertions, 27 deletions
diff --git a/wp-inst/wp-includes/pluggable-functions.php b/wp-inst/wp-includes/pluggable-functions.php
index 2643342..b1b78f4 100644
--- a/wp-inst/wp-includes/pluggable-functions.php
+++ b/wp-inst/wp-includes/pluggable-functions.php
@@ -5,21 +5,20 @@
if ( !function_exists('set_current_user') ) :
function set_current_user($id, $name = '') {
- global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
+ return wp_set_current_user($id, $name);
+}
+endif;
- $current_user = '';
+if ( !function_exists('wp_set_current_user') ) :
+function wp_set_current_user($id, $name = '') {
+ global $current_user;
- $current_user = new WP_User($id, $name);
+ if ( isset($current_user) && ($id == $current_user->ID) )
+ return $current_user;
- $userdata = get_userdatabylogin($user_login);
+ $current_user = new WP_User($id, $name);
- $user_login = $userdata->user_login;
- $user_level = $userdata->user_level;
- $user_ID = $userdata->ID;
- $user_email = $userdata->user_email;
- $user_url = $userdata->user_url;
- $user_pass_md5 = md5($userdata->user_pass);
- $user_identity = $userdata->display_name;
+ setup_userdata($current_user->ID);
do_action('set_current_user');
@@ -27,30 +26,34 @@ function set_current_user($id, $name = '') {
}
endif;
+if ( !function_exists('current_user') ) :
+function wp_get_current_user() {
+ global $current_user;
+
+ get_currentuserinfo();
+
+ return $current_user;
+}
+endif;
if ( !function_exists('get_currentuserinfo') ) :
function get_currentuserinfo() {
- global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
+ global $current_user;
if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
return false;
+ if ( ! empty($current_user) )
+ return;
+
if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) {
- $current_user = new WP_User(0);
+ wp_set_current_user(0);
return false;
}
- $user_login = $_COOKIE[USER_COOKIE];
- $userdata = get_userdatabylogin($user_login);
- $user_level = $userdata->user_level;
- $user_ID = $userdata->ID;
- $user_email = $userdata->user_email;
- $user_url = $userdata->user_url;
- $user_pass_md5 = md5($userdata->user_pass);
- $user_identity = $userdata->display_name;
-
- if ( empty($current_user) )
- $current_user = new WP_User($user_ID);
+
+ $user_login = $_COOKIE[USER_COOKIE];
+ wp_set_current_user(0, $user_login);
}
endif;
@@ -207,10 +210,11 @@ endif;
if ( !function_exists('is_user_logged_in') ) :
function is_user_logged_in() {
- global $current_user;
+ $user = wp_get_current_user();
- if ( $current_user->id == 0 )
+ if ( $user->id == 0 )
return false;
+
return true;
}
endif;
@@ -222,7 +226,6 @@ function auth_redirect() {
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) ||
(empty($_COOKIE[USER_COOKIE])) ) {
nocache_headers();
-
header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
exit();
}
@@ -239,6 +242,21 @@ function check_admin_referer() {
}
endif;
+if ( !function_exists('check_ajax_referer') ) :
+function check_ajax_referer() {
+ $cookie = explode(';', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie
+ foreach ( $cookie as $tasty ) {
+ if ( false !== strpos($tasty, USER_COOKIE) )
+ $user = substr(strstr($tasty, '='), 1);
+ if ( false !== strpos($tasty, PASS_COOKIE) )
+ $pass = substr(strstr($tasty, '='), 1);
+ }
+ if ( !wp_login( $user, $pass, true ) )
+ die('-1');
+ do_action('check_ajax_referer');
+}
+endif;
+
// Cookie safe redirect. Works around IIS Set-Cookie bug.
// http://support.microsoft.com/kb/q176113/
if ( !function_exists('wp_redirect') ) :