Help!

Discussion in 'PHP' started by randomthinker, Apr 8, 2008.

  1. #1
    I upgraded to the new version of wordpress and get this error when trying to access my control panel.


    Warning: Cannot modify header information - headers already sent by (output started at /home/jhyjek/public_html/random-thoughts-blog/wp-includes/functions.php:1785) in /home/jhyjek/public_html/random-thoughts-blog/wp-includes/pluggable.php on line 689

    Here's the script. Can anyone help?? The script is too long to ad the whole thing here, so I hope I copied enough.

    Thanks,


    if ( !function_exists( 'wp_mail' ) ) :
    /**
    * wp_mail() - Function to send mail, similar to PHP's mail
    *
    * A true return value does not automatically mean that the
    * user received the email successfully. It just only means
    * that the method used was able to process the request
    * without any errors.
    *
    * Using the two 'wp_mail_from' and 'wp_mail_from_name' hooks
    * allow from creating a from address like 'Name <email@address.com>'
    * when both are set. If just 'wp_mail_from' is set, then just
    * the email address will be used with no name.
    *
    * The default content type is 'text/plain' which does not
    * allow using HTML. However, you can set the content type
    * of the email by using the 'wp_mail_content_type' filter.
    *
    * The default charset is based on the charset used on the
    * blog. The charset can be set using the 'wp_mail_charset'
    * filter.
    *
    * @since 1.2.1
    * @uses apply_filters() Calls 'wp_mail' hook on an array of all of the parameters.
    * @uses apply_filters() Calls 'wp_mail_from' hook to get the from email address.
    * @uses apply_filters() Calls 'wp_mail_from_name' hook to get the from address name.
    * @uses apply_filters() Calls 'wp_mail_content_type' hook to get the email content type.
    * @uses apply_filters() Calls 'wp_mail_charset' hook to get the email charset
    * @uses do_action_ref_array() Calls 'phpmailer_init' hook on the reference to
    * phpmailer object.
    * @uses PHPMailer
    * @
    *
    * @param string $to Email address to send message
    * @param string $subject Email subject
    * @param string $message Message contents
    * @param string|array $headers Optional. Additional headers.
    * @return bool Whether the email contents were sent successfully.
    */
    function wp_mail( $to, $subject, $message, $headers = '' ) {
    // Compact the input, apply the filters, and extract them back out
    extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers' ) ) );

    global $phpmailer;

    // (Re)create it, if it's gone missing
    if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
    require_once ABSPATH . WPINC . '/class-phpmailer.php';
    require_once ABSPATH . WPINC . '/class-smtp.php';
    $phpmailer = new PHPMailer();
    }

    // Headers
    if ( empty( $headers ) ) {
    $headers = array();
    } elseif ( !is_array( $headers ) ) {
    // Explode the headers out, so this function can take both
    // string headers and an array of headers.
    $tempheaders = (array) explode( "\n", $headers );
    $headers = array();

    // If it's actually got contents
    if ( !empty( $tempheaders ) ) {
    // Iterate through the raw headers
    foreach ( $tempheaders as $header ) {
    if ( strpos($header, ':') === false )
    continue;
    // Explode them out
    list( $name, $content ) = explode( ':', trim( $header ), 2 );

    // Cleanup crew
    $name = trim( $name );
    $content = trim( $content );

    // Mainly for legacy -- process a From: header if it's there
    if ( 'from' == strtolower($name) ) {
    if ( strpos($content, '<' ) !== false ) {
    // So... making my life hard again?
    $from_name = substr( $content, 0, strpos( $content, '<' ) - 1 );
    $from_name = str_replace( '"', '', $from_name );
    $from_name = trim( $from_name );

    $from_email = substr( $content, strpos( $content, '<' ) + 1 );
    $from_email = str_replace( '>', '', $from_email );
    $from_email = trim( $from_email );
    } else {
    $from_name = trim( $content );
    }
    } elseif ( 'content-type' == strtolower($name) ) {
    if ( strpos( $content,';' ) !== false ) {
    list( $type, $charset ) = explode( ';', $content );
    $content_type = trim( $type );
    $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) );
    } else {
    $content_type = trim( $content );
    }
    } else {
    // Add it to our grand headers array
    $headers[trim( $name )] = trim( $content );
    }
    }
    }
    }

    // Empty out the values that may be set
    $phpmailer->ClearAddresses();
    $phpmailer->ClearAllRecipients();
    $phpmailer->ClearAttachments();
    $phpmailer->ClearBCCs();
    $phpmailer->ClearCCs();
    $phpmailer->ClearCustomHeaders();
    $phpmailer->ClearReplyTos();

    // From email and name
    // If we don't have a name from the input headers
    if ( !isset( $from_name ) ) {
    $from_name = 'WordPress';
    }

    // If we don't have an email from the input headers
    if ( !isset( $from_email ) ) {
    // Get the site domain and get rid of www.
    $sitename = strtolower( $_SERVER['SERVER_NAME'] );
    if ( substr( $sitename, 0, 4 ) == 'www.' ) {
    $sitename = substr( $sitename, 4 );
    }

    $from_email = 'wordpress@' . $sitename;
    }

    // Set the from name and email
    $phpmailer->From = apply_filters( 'wp_mail_from', $from_email );
    $phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name );

    // Set destination address
    $phpmailer->AddAddress( $to );

    // Set mail's subject and body
    $phpmailer->Subject = $subject;
    $phpmailer->Body = $message;

    // Set to use PHP's mail()
    $phpmailer->IsMail();

    // Set Content-Type and charset
    // If we don't have a content-type from the input headers
    if ( !isset( $content_type ) ) {
    $content_type = 'text/plain';
    }

    $content_type = apply_filters( 'wp_mail_content_type', $content_type );

    // Set whether it's plaintext or not, depending on $content_type
    if ( $content_type == 'text/html' ) {
    $phpmailer->IsHTML( true );
    } else {
    $phpmailer->IsHTML( false );
    }

    // If we don't have a charset from the input headers
    if ( !isset( $charset ) ) {
    $charset = get_bloginfo( 'charset' );
    }

    // Set the content-type and charset
    $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );

    // Set custom headers
    if ( !empty( $headers ) ) {
    foreach ( $headers as $name => $content ) {
    $phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
    }
    }

    do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );

    // Send!
    $result = @$phpmailer->Send();

    return $result;
    }
    endif;

    /**
    * wp_authenticate() - Checks a user's login information and logs them in if it checks out
    * @since 2.5
    *
    * @param string $username User's username
    * @param string $password User's password
    * @return WP_Error|WP_User WP_User object if login successful, otherwise WP_Error object.
    */
    if ( !function_exists('wp_authenticate') ) :
    function wp_authenticate($username, $password) {
    $username = sanitize_user($username);

    if ( '' == $username )
    return new WP_Error('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));

    if ( '' == $password )
    return new WP_Error('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));

    $user = get_userdatabylogin($username);

    if ( !$user || ($user->user_login != $username) ) {
    do_action( 'wp_login_failed', $username );
    return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Invalid username.'));
    }

    $user = apply_filters('wp_authenticate_user', $user, $password);
    if ( is_wp_error($user) ) {
    do_action( 'wp_login_failed', $username );
    return $user;
    }

    if ( !wp_check_password($password, $user->user_pass, $user->ID) ) {
    do_action( 'wp_login_failed', $username );
    return new WP_Error('incorrect_password', __('<strong>ERROR</strong>: Incorrect password.'));
    }

    return new WP_User($user->ID);
    }
    endif;

    /**
    * wp_logout() - Log the current user out
    * @since 2.5
    *
    */
    if ( !function_exists('wp_logout') ) :
    function wp_logout() {
    wp_clear_auth_cookie();
    do_action('wp_logout');
    }
    endif;

    if ( !function_exists('wp_validate_auth_cookie') ) :
    /**
    * wp_validate_auth_cookie() - Validates authentication cookie
    *
    * The checks include making sure that the authentication cookie
    * is set and pulling in the contents (if $cookie is not used).
    *
    * Makes sure the cookie is not expired. Verifies the hash in
    * cookie is what is should be and compares the two.
    *
    * @since 2.5
    *
    * @param string $cookie Optional. If used, will validate contents instead of cookie's
    * @return bool|int False if invalid cookie, User ID if valid.
    */
    function wp_validate_auth_cookie($cookie = '') {
    if ( empty($cookie) ) {
    if ( empty($_COOKIE[AUTH_COOKIE]) )
    return false;
    $cookie = $_COOKIE[AUTH_COOKIE];
    }

    list($username, $expiration, $hmac) = explode('|', $cookie);

    $expired = $expiration;

    // Allow a grace period for POST and AJAX requests
    if ( defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD'] )
    $expired += 3600;

    if ( $expired < time() )
    return false;

    $key = wp_hash($username . $expiration);
    $hash = hash_hmac('md5', $username . $expiration, $key);

    if ( $hmac != $hash )
    return false;

    $user = get_userdatabylogin($username);
    if ( ! $user )
    return false;

    return $user->ID;
    }
    endif;

    if ( !function_exists('wp_generate_auth_cookie') ) :
    /**
    * wp_generate_auth_cookie() - Generate authentication cookie contents
    *
    * @since 2.5
    * @uses apply_filters() Calls 'auth_cookie' hook on $cookie contents, User ID
    * and expiration of cookie.
    *
    * @param int $user_id User ID
    * @param int $expiration Cookie expiration in seconds
    * @return string Authentication cookie contents
    */
    function wp_generate_auth_cookie($user_id, $expiration) {
    $user = get_userdata($user_id);

    $key = wp_hash($user->user_login . $expiration);
    $hash = hash_hmac('md5', $user->user_login . $expiration, $key);

    $cookie = $user->user_login . '|' . $expiration . '|' . $hash;

    return apply_filters('auth_cookie', $cookie, $user_id, $expiration);
    }
    endif;

    if ( !function_exists('wp_set_auth_cookie') ) :
    /**
    * wp_set_auth_cookie() - Sets the authentication cookies based User ID
    *
    * The $remember parameter increases the time that the cookie will
    * be kept. The default the cookie is kept without remembering is
    * two days. When $remember is set, the cookies will be kept for
    * 14 days or two weeks.
    *
    * @since 2.5
    *
    * @param int $user_id User ID
    * @param bool $remember Whether to remember the user or not
    */
    function wp_set_auth_cookie($user_id, $remember = false) {
    if ( $remember ) {
    $expiration = $expire = time() + 1209600;
    } else {
    $expiration = time() + 172800;
    $expire = 0;
    }

    $cookie = wp_generate_auth_cookie($user_id, $expiration);

    do_action('set_auth_cookie', $cookie, $expire);

    setcookie(AUTH_COOKIE, $cookie, $expire, COOKIEPATH, COOKIE_DOMAIN);
    if ( COOKIEPATH != SITECOOKIEPATH )
    setcookie(AUTH_COOKIE, $cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN);
    }
    endif;

    if ( !function_exists('wp_clear_auth_cookie') ) :
    /**
    * wp_clear_auth_cookie() - Deletes all of the cookies associated with authentication
    *
    * @since 2.5
    */
    function wp_clear_auth_cookie() {
    setcookie(AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
    setcookie(AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);

    // Old cookies
    setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
    setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
    setcookie(USER_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
    setcookie(PASS_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
    }
    endif;

    if ( !function_exists('is_user_logged_in') ) :
    /**
    * is_user_logged_in() - Checks if the current visitor is a logged in user
    *
    * @since 2.0.0
    *
    * @return bool True if user is logged in, false if not logged in.
    */
    function is_user_logged_in() {
    $user = wp_get_current_user();

    if ( $user->id == 0 )
    return false;

    return true;
    }
    endif;

    if ( !function_exists('auth_redirect') ) :
    /**
    * auth_redirect() - Checks if a user is logged in, if not it redirects them to the login page
    *
    * @since 1.5
    */
    function auth_redirect() {
    // Checks if a user is logged in, if not redirects them to the login page
    if ( (!empty($_COOKIE[AUTH_COOKIE]) &&
    !wp_validate_auth_cookie($_COOKIE[AUTH_COOKIE])) ||
    (empty($_COOKIE[AUTH_COOKIE])) ) {
    nocache_headers();

    wp_redirect(get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
    exit();
    }
    }
    endif;

    if ( !function_exists('check_admin_referer') ) :
    /**
    * check_admin_referer() - Makes sure that a user was referred from another admin page, to avoid security exploits
    *
    * @since 1.2.0
    * @uses do_action() Calls 'check_admin_referer' on $action.
    *
    * @param string $action Action nonce
    * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
    */
    function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
    $adminurl = strtolower(get_option('siteurl')).'/wp-admin';
    $referer = strtolower(wp_get_referer());
    $result = wp_verify_nonce($_REQUEST[$query_arg], $action);
    if ( !$result && !(-1 == $action && strpos($referer, $adminurl) !== false) ) {
    wp_nonce_ays($action);
    die();
    }
    do_action('check_admin_referer', $action, $result);
    return $result;
    }endif;

    if ( !function_exists('check_ajax_referer') ) :
    /**
    * check_ajax_referer() - Verifies the AJAX request to prevent processing requests external of the blog.
    *
    * @since 2.0.4
    *
    * @param string $action Action nonce
    * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
    */
    function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
    if ( $query_arg )
    $nonce = $_REQUEST[$query_arg];
    else
    $nonce = $_REQUEST['_ajax_nonce'] ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce'];

    $result = wp_verify_nonce( $nonce, $action );

    if ( $die && false == $result )
    die('-1');

    do_action('check_ajax_referer', $action, $result);

    return $result;
    }
    endif;

    if ( !function_exists('wp_redirect') ) :
    /**
    * wp_redirect() - Redirects to another page, with a workaround for the IIS Set-Cookie bug
    *
    * @link http://support.microsoft.com/kb/q176113/
    * @since 1.5.1
    * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
    *
    * @param string $location The path to redirect to
    * @param int $status Status code to use
    * @return bool False if $location is not set
    */
    function wp_redirect($location, $status = 302) {
    global $is_IIS;

    $location = apply_filters('wp_redirect', $location, $status);
    $status = apply_filters('wp_redirect_status', $status, $location);

    if ( !$location ) // allows the wp_redirect filter to cancel a redirect
    return false;

    $location = wp_sanitize_redirect($location);

    if ( $is_IIS ) {
    header("Refresh: 0;url=$location");
    } else {
    if ( php_sapi_name() != 'cgi-fcgi' )
    status_header($status); // This causes problems on IIS and some FastCGI setups
    header("Location: $location");
    }
    }
    endif;

    if ( !function_exists('wp_sanitize_redirect') ) :
    /**
    * wp_sanitize_redirect() - Sanitizes a URL for use in a redirect
    *
    * @since 2.3
    *
    * @return string redirect-sanitized URL
    **/
    function wp_sanitize_redirect($location) {
    $location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%]|i', '', $location);
    $location = wp_kses_no_null($location);
     
    randomthinker, Apr 8, 2008 IP
  2. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #2
    LittleJonSupportSite, Apr 8, 2008 IP
  3. randomthinker

    randomthinker Active Member

    Messages:
    86
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #3
    thanks for the reply...but I don't know anything about PHP at all. Can anyone post the correction that I need to make?
     
    randomthinker, Apr 8, 2008 IP