Make WordPress Core


Ignore:
Timestamp:
03/29/2006 01:51:55 AM (19 years ago)
Author:
ryan
Message:

AJAX, cause you love it. Props mdawaffe. fixes #2561

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/pluggable-functions.php

    r3566 r3660  
    235235        die(__('Sorry, you need to <a href="http://codex.wordpress.org/Enable_Sending_Referrers">enable sending referrers</a> for this feature to work.'));
    236236    do_action('check_admin_referer');
     237}
     238endif;
     239
     240if ( !function_exists('check_ajax_referer') ) :
     241function check_ajax_referer() {
     242    $cookie = explode(';', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie
     243    foreach ( $cookie as $tasty ) {
     244        if ( false !== strpos($tasty, USER_COOKIE) )
     245            $user = substr(strstr($tasty, '='), 1);
     246        if ( false !== strpos($tasty, PASS_COOKIE) )
     247            $pass = substr(strstr($tasty, '='), 1);
     248    }
     249    if ( !wp_login( $user, $pass, true ) )
     250        die('-1');
     251    do_action('check_ajax_referer');
    237252}
    238253endif;
Note: See TracChangeset for help on using the changeset viewer.