2005-04-19 23:37:23 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/* These functions can be replaced via plugins. They are loaded after
|
|
|
|
plugins are loaded. */
|
|
|
|
|
2006-01-13 14:19:09 -05:00
|
|
|
if ( !function_exists('set_current_user') ) :
|
|
|
|
function set_current_user($id, $name = '') {
|
2006-02-22 14:08:55 -05:00
|
|
|
return wp_set_current_user($id, $name);
|
|
|
|
}
|
|
|
|
endif;
|
2006-01-13 14:19:09 -05:00
|
|
|
|
2006-02-22 14:08:55 -05:00
|
|
|
if ( !function_exists('wp_set_current_user') ) :
|
|
|
|
function wp_set_current_user($id, $name = '') {
|
|
|
|
global $current_user;
|
2006-01-13 14:19:09 -05:00
|
|
|
|
2006-02-22 14:08:55 -05:00
|
|
|
if ( isset($current_user) && ($id == $current_user->ID) )
|
|
|
|
return $current_user;
|
2006-01-13 14:19:09 -05:00
|
|
|
|
2006-02-22 14:08:55 -05:00
|
|
|
$current_user = new WP_User($id, $name);
|
2006-01-13 14:19:09 -05:00
|
|
|
|
2006-02-22 14:08:55 -05:00
|
|
|
setup_userdata($current_user->ID);
|
2006-01-13 14:19:09 -05:00
|
|
|
|
|
|
|
do_action('set_current_user');
|
|
|
|
|
|
|
|
return $current_user;
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2006-05-31 02:27:10 -04:00
|
|
|
if ( !function_exists('wp_get_current_user') ) :
|
2006-02-22 14:08:55 -05:00
|
|
|
function wp_get_current_user() {
|
|
|
|
global $current_user;
|
|
|
|
|
|
|
|
get_currentuserinfo();
|
|
|
|
|
|
|
|
return $current_user;
|
|
|
|
}
|
|
|
|
endif;
|
2005-04-19 23:37:23 -04:00
|
|
|
|
|
|
|
if ( !function_exists('get_currentuserinfo') ) :
|
|
|
|
function get_currentuserinfo() {
|
2006-02-22 14:08:55 -05:00
|
|
|
global $current_user;
|
2005-06-12 20:05:41 -04:00
|
|
|
|
2006-01-13 14:19:09 -05:00
|
|
|
if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
|
|
|
|
return false;
|
|
|
|
|
2006-02-22 14:08:55 -05:00
|
|
|
if ( ! empty($current_user) )
|
|
|
|
return;
|
|
|
|
|
2006-11-19 02:56:05 -05:00
|
|
|
if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||
|
2005-12-13 13:18:07 -05:00
|
|
|
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) {
|
2006-02-22 14:08:55 -05:00
|
|
|
wp_set_current_user(0);
|
2005-06-12 20:05:41 -04:00
|
|
|
return false;
|
2005-12-12 22:46:40 -05:00
|
|
|
}
|
2006-02-22 14:08:55 -05:00
|
|
|
|
|
|
|
$user_login = $_COOKIE[USER_COOKIE];
|
|
|
|
wp_set_current_user(0, $user_login);
|
2005-04-19 23:37:23 -04:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if ( !function_exists('get_userdata') ) :
|
2005-06-12 16:49:13 -04:00
|
|
|
function get_userdata( $user_id ) {
|
2005-11-07 16:56:03 -05:00
|
|
|
global $wpdb;
|
2005-06-12 16:49:13 -04:00
|
|
|
$user_id = (int) $user_id;
|
|
|
|
if ( $user_id == 0 )
|
|
|
|
return false;
|
2005-07-12 11:53:13 -04:00
|
|
|
|
2005-11-07 16:56:03 -05:00
|
|
|
$user = wp_cache_get($user_id, 'users');
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2005-11-07 16:56:03 -05:00
|
|
|
if ( $user )
|
|
|
|
return $user;
|
2005-06-12 16:49:13 -04:00
|
|
|
|
2005-11-07 18:09:09 -05:00
|
|
|
if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$user_id' LIMIT 1") )
|
2005-11-07 16:56:03 -05:00
|
|
|
return false;
|
2005-06-12 16:49:13 -04:00
|
|
|
|
2005-12-22 19:32:15 -05:00
|
|
|
$wpdb->hide_errors();
|
2005-06-12 16:49:13 -04:00
|
|
|
$metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'");
|
2005-12-22 19:32:15 -05:00
|
|
|
$wpdb->show_errors();
|
2005-06-12 16:49:13 -04:00
|
|
|
|
2005-11-10 19:55:31 -05:00
|
|
|
if ($metavalues) {
|
|
|
|
foreach ( $metavalues as $meta ) {
|
2006-10-12 19:54:36 -04:00
|
|
|
$value = maybe_unserialize($meta->meta_value);
|
2005-11-10 19:55:31 -05:00
|
|
|
$user->{$meta->meta_key} = $value;
|
|
|
|
|
|
|
|
// We need to set user_level from meta, not row
|
|
|
|
if ( $wpdb->prefix . 'user_level' == $meta->meta_key )
|
|
|
|
$user->user_level = $meta->meta_value;
|
|
|
|
} // end foreach
|
|
|
|
} //end if
|
2005-04-19 23:37:23 -04:00
|
|
|
|
2006-01-27 13:14:33 -05:00
|
|
|
// For backwards compat.
|
|
|
|
if ( isset($user->first_name) )
|
|
|
|
$user->user_firstname = $user->first_name;
|
|
|
|
if ( isset($user->last_name) )
|
|
|
|
$user->user_lastname = $user->last_name;
|
|
|
|
if ( isset($user->description) )
|
|
|
|
$user->user_description = $user->description;
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2005-11-07 16:56:03 -05:00
|
|
|
wp_cache_add($user_id, $user, 'users');
|
2007-02-01 19:00:36 -05:00
|
|
|
wp_cache_add($user->user_login, $user_id, 'userlogins');
|
2005-11-07 16:56:03 -05:00
|
|
|
return $user;
|
2005-04-19 23:37:23 -04:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2005-07-12 11:53:13 -04:00
|
|
|
if ( !function_exists('update_user_cache') ) :
|
|
|
|
function update_user_cache() {
|
2005-11-17 13:15:59 -05:00
|
|
|
return true;
|
2005-07-12 11:53:13 -04:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2005-04-19 23:37:23 -04:00
|
|
|
if ( !function_exists('get_userdatabylogin') ) :
|
|
|
|
function get_userdatabylogin($user_login) {
|
2005-11-17 13:15:59 -05:00
|
|
|
global $wpdb;
|
2005-06-12 19:14:52 -04:00
|
|
|
$user_login = sanitize_user( $user_login );
|
2005-10-29 19:23:17 -04:00
|
|
|
|
2005-06-12 16:49:13 -04:00
|
|
|
if ( empty( $user_login ) )
|
|
|
|
return false;
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2007-02-01 19:00:36 -05:00
|
|
|
$user_id = wp_cache_get($user_login, 'userlogins');
|
|
|
|
$userdata = wp_cache_get($user_id, 'users');
|
|
|
|
|
2005-11-07 16:56:03 -05:00
|
|
|
if ( $userdata )
|
|
|
|
return $userdata;
|
2005-06-12 16:49:13 -04:00
|
|
|
|
2007-05-10 20:56:12 -04:00
|
|
|
$user_login = $wpdb->escape($user_login);
|
|
|
|
|
2005-10-29 19:23:17 -04:00
|
|
|
if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") )
|
2005-11-17 13:15:59 -05:00
|
|
|
return false;
|
2005-10-29 19:23:17 -04:00
|
|
|
|
2005-12-22 19:32:15 -05:00
|
|
|
$wpdb->hide_errors();
|
2005-10-29 19:23:17 -04:00
|
|
|
$metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user->ID'");
|
2005-12-22 19:32:15 -05:00
|
|
|
$wpdb->show_errors();
|
2005-10-29 19:23:17 -04:00
|
|
|
|
2005-11-17 13:15:59 -05:00
|
|
|
if ($metavalues) {
|
|
|
|
foreach ( $metavalues as $meta ) {
|
2006-10-12 19:54:36 -04:00
|
|
|
$value = maybe_unserialize($meta->meta_value);
|
2005-11-17 13:15:59 -05:00
|
|
|
$user->{$meta->meta_key} = $value;
|
2005-10-29 19:23:17 -04:00
|
|
|
|
2005-11-17 13:15:59 -05:00
|
|
|
// We need to set user_level from meta, not row
|
|
|
|
if ( $wpdb->prefix . 'user_level' == $meta->meta_key )
|
|
|
|
$user->user_level = $meta->meta_value;
|
|
|
|
}
|
2005-10-29 19:23:17 -04:00
|
|
|
}
|
|
|
|
|
2006-01-27 13:14:33 -05:00
|
|
|
// For backwards compat.
|
|
|
|
if ( isset($user->first_name) )
|
|
|
|
$user->user_firstname = $user->first_name;
|
|
|
|
if ( isset($user->last_name) )
|
|
|
|
$user->user_lastname = $user->last_name;
|
|
|
|
if ( isset($user->description) )
|
|
|
|
$user->user_description = $user->description;
|
|
|
|
|
2005-11-17 13:15:59 -05:00
|
|
|
wp_cache_add($user->ID, $user, 'users');
|
2007-02-01 19:00:36 -05:00
|
|
|
wp_cache_add($user->user_login, $user->ID, 'userlogins');
|
2005-11-17 13:15:59 -05:00
|
|
|
return $user;
|
2005-10-29 19:23:17 -04:00
|
|
|
|
2005-04-19 23:37:23 -04:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
if ( !function_exists( 'wp_mail' ) ) :
|
|
|
|
function wp_mail( $to, $subject, $message, $headers = '' ) {
|
2007-02-25 15:23:25 -05:00
|
|
|
global $phpmailer;
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// (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';
|
2007-02-25 15:23:25 -05:00
|
|
|
$phpmailer = new PHPMailer();
|
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// Compact the input, apply the filters, and extract them back out
|
2007-06-14 18:45:40 -04:00
|
|
|
extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers' ) ), EXTR_SKIP );
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-26 15:11:23 -04:00
|
|
|
// Headers
|
2007-06-01 23:18:24 -04:00
|
|
|
if ( empty( $headers ) ) {
|
2007-06-26 15:11:23 -04:00
|
|
|
$headers = array();
|
2007-06-01 23:18:24 -04:00
|
|
|
} 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();
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// If it's actually got contents
|
|
|
|
if ( !empty( $tempheaders ) ) {
|
|
|
|
// Iterate through the raw headers
|
|
|
|
foreach ( $tempheaders as $header ) {
|
2007-06-26 16:18:56 -04:00
|
|
|
if ( strpos($header, ':') === false )
|
|
|
|
continue;
|
2007-06-01 23:18:24 -04:00
|
|
|
// Explode them out
|
|
|
|
list( $name, $content ) = explode( ':', trim( $header ), 2 );
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// Cleanup crew
|
|
|
|
$name = trim( $name );
|
|
|
|
$content = trim( $content );
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// Mainly for legacy -- process a From: header if it's there
|
2007-06-26 14:28:56 -04:00
|
|
|
if ( 'from' == strtolower($name) ) {
|
2007-06-26 14:06:17 -04:00
|
|
|
if ( strpos($content, '<' ) !== false ) {
|
2007-06-01 23:18:24 -04:00
|
|
|
// So... making my life hard again?
|
2007-06-26 14:06:17 -04:00
|
|
|
$from_name = substr( $content, 0, strpos( $content, '<' ) - 1 );
|
2007-06-01 23:18:24 -04:00
|
|
|
$from_name = str_replace( '"', '', $from_name );
|
|
|
|
$from_name = trim( $from_name );
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-26 14:06:17 -04:00
|
|
|
$from_email = substr( $content, strpos( $content, '<' ) + 1 );
|
2007-06-01 23:18:24 -04:00
|
|
|
$from_email = str_replace( '>', '', $from_email );
|
|
|
|
$from_email = trim( $from_email );
|
|
|
|
} else {
|
|
|
|
$from_name = trim( $content );
|
|
|
|
}
|
2007-06-26 14:28:56 -04:00
|
|
|
} elseif ( 'content-type' == strtolower($name) ) {
|
2007-06-26 14:06:17 -04:00
|
|
|
if ( strpos( $content,';' ) !== false ) {
|
2007-06-01 23:18:24 -04:00
|
|
|
list( $type, $charset ) = explode( ';', $content );
|
2007-06-26 16:18:56 -04:00
|
|
|
$content_type = trim( $type );
|
2007-06-01 23:18:24 -04:00
|
|
|
$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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-04-19 23:37:23 -04:00
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// Empty out the values that may be set
|
2007-02-25 15:23:25 -05:00
|
|
|
$phpmailer->ClearAddresses();
|
|
|
|
$phpmailer->ClearAllRecipients();
|
2007-06-01 23:18:24 -04:00
|
|
|
$phpmailer->ClearAttachments();
|
|
|
|
$phpmailer->ClearBCCs();
|
|
|
|
$phpmailer->ClearCCs();
|
2007-02-25 15:23:25 -05:00
|
|
|
$phpmailer->ClearCustomHeaders();
|
2007-06-01 23:18:24 -04:00
|
|
|
$phpmailer->ClearReplyTos();
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// From email and name
|
|
|
|
// If we don't have a name from the input headers
|
|
|
|
if ( !isset( $from_name ) ) {
|
|
|
|
$from_name = 'WordPress';
|
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// 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 );
|
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
$from_email = 'wordpress@' . $sitename;
|
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// 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 );
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// Set destination address
|
|
|
|
$phpmailer->AddAddress( $to );
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// Set mail's subject and body
|
2007-02-25 15:23:25 -05:00
|
|
|
$phpmailer->Subject = $subject;
|
2007-06-01 23:18:24 -04:00
|
|
|
$phpmailer->Body = $message;
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// Set to use PHP's mail()
|
|
|
|
$phpmailer->IsMail();
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// 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';
|
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-26 16:18:56 -04:00
|
|
|
$content_type = apply_filters( 'wp_mail_content_type', $content_type );
|
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// Set whether it's plaintext or not, depending on $content_type
|
|
|
|
if ( $content_type == 'text/html' ) {
|
|
|
|
$phpmailer->IsHTML( true );
|
|
|
|
} else {
|
|
|
|
$phpmailer->IsHTML( false );
|
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// If we don't have a charset from the input headers
|
|
|
|
if ( !isset( $charset ) ) {
|
|
|
|
$charset = get_bloginfo( 'charset' );
|
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// Set the content-type and charset
|
|
|
|
$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// Set custom headers
|
|
|
|
if ( !empty( $headers ) ) {
|
|
|
|
foreach ( $headers as $name => $content ) {
|
|
|
|
$phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
|
2007-02-25 15:23:25 -05:00
|
|
|
}
|
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-06-01 23:18:24 -04:00
|
|
|
// Send!
|
2007-02-25 15:23:25 -05:00
|
|
|
$result = @$phpmailer->Send();
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2007-02-25 15:23:25 -05:00
|
|
|
return $result;
|
2005-04-19 23:37:23 -04:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if ( !function_exists('wp_login') ) :
|
|
|
|
function wp_login($username, $password, $already_md5 = false) {
|
|
|
|
global $wpdb, $error;
|
|
|
|
|
2007-06-12 14:11:06 -04:00
|
|
|
$username = sanitize_user($username);
|
|
|
|
|
2005-11-16 19:51:34 -05:00
|
|
|
if ( '' == $username )
|
2005-04-19 23:37:23 -04:00
|
|
|
return false;
|
|
|
|
|
2005-11-16 19:51:34 -05:00
|
|
|
if ( '' == $password ) {
|
2006-10-04 12:47:50 -04:00
|
|
|
$error = __('<strong>ERROR</strong>: The password field is empty.');
|
2005-04-19 23:37:23 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-11-07 16:56:03 -05:00
|
|
|
$login = get_userdatabylogin($username);
|
|
|
|
//$login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'");
|
2005-04-19 23:37:23 -04:00
|
|
|
|
|
|
|
if (!$login) {
|
2006-10-04 12:47:50 -04:00
|
|
|
$error = __('<strong>ERROR</strong>: Invalid username.');
|
2005-04-19 23:37:23 -04:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
// If the password is already_md5, it has been double hashed.
|
|
|
|
// Otherwise, it is plain text.
|
2005-08-23 03:51:14 -04:00
|
|
|
if ( ($already_md5 && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) {
|
2005-04-19 23:37:23 -04:00
|
|
|
return true;
|
|
|
|
} else {
|
2006-10-04 12:47:50 -04:00
|
|
|
$error = __('<strong>ERROR</strong>: Incorrect password.');
|
2005-04-19 23:37:23 -04:00
|
|
|
$pwd = '';
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2005-12-15 11:31:41 -05:00
|
|
|
if ( !function_exists('is_user_logged_in') ) :
|
|
|
|
function is_user_logged_in() {
|
2006-02-22 14:08:55 -05:00
|
|
|
$user = wp_get_current_user();
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2006-02-22 14:08:55 -05:00
|
|
|
if ( $user->id == 0 )
|
2005-12-15 11:31:41 -05:00
|
|
|
return false;
|
2006-02-22 14:08:55 -05:00
|
|
|
|
2005-12-15 11:31:41 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2005-04-19 23:37:23 -04:00
|
|
|
if ( !function_exists('auth_redirect') ) :
|
|
|
|
function auth_redirect() {
|
|
|
|
// Checks if a user is logged in, if not redirects them to the login page
|
2006-11-19 02:56:05 -05:00
|
|
|
if ( (!empty($_COOKIE[USER_COOKIE]) &&
|
2005-07-18 16:12:48 -04:00
|
|
|
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) ||
|
|
|
|
(empty($_COOKIE[USER_COOKIE])) ) {
|
2005-06-08 20:17:43 -04:00
|
|
|
nocache_headers();
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2006-08-30 17:46:31 -04:00
|
|
|
wp_redirect(get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
|
2005-04-19 23:37:23 -04:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2006-01-29 18:06:58 -05:00
|
|
|
if ( !function_exists('check_admin_referer') ) :
|
2006-05-02 18:08:34 -04:00
|
|
|
function check_admin_referer($action = -1) {
|
2006-08-30 17:46:31 -04:00
|
|
|
$adminurl = strtolower(get_option('siteurl')).'/wp-admin';
|
2006-06-24 01:38:37 -04:00
|
|
|
$referer = strtolower(wp_get_referer());
|
2006-05-16 20:28:26 -04:00
|
|
|
if ( !wp_verify_nonce($_REQUEST['_wpnonce'], $action) &&
|
2007-03-07 01:17:15 -05:00
|
|
|
!(-1 == $action && strpos($referer, $adminurl) !== false)) {
|
2006-06-27 04:06:00 -04:00
|
|
|
wp_nonce_ays($action);
|
2006-05-18 02:49:22 -04:00
|
|
|
die();
|
2006-05-02 18:08:34 -04:00
|
|
|
}
|
2006-05-04 05:23:17 -04:00
|
|
|
do_action('check_admin_referer', $action);
|
2006-05-02 18:08:34 -04:00
|
|
|
}endif;
|
2006-03-28 20:51:55 -05:00
|
|
|
|
|
|
|
if ( !function_exists('check_ajax_referer') ) :
|
|
|
|
function check_ajax_referer() {
|
2006-04-09 18:57:23 -04:00
|
|
|
$cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie
|
2006-03-28 20:51:55 -05:00
|
|
|
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;
|
2006-01-29 18:06:58 -05:00
|
|
|
|
2005-04-19 23:37:23 -04:00
|
|
|
// Cookie safe redirect. Works around IIS Set-Cookie bug.
|
|
|
|
// http://support.microsoft.com/kb/q176113/
|
|
|
|
if ( !function_exists('wp_redirect') ) :
|
2006-09-25 20:55:21 -04:00
|
|
|
function wp_redirect($location, $status = 302) {
|
2005-04-19 23:37:23 -04:00
|
|
|
global $is_IIS;
|
|
|
|
|
2006-10-18 18:02:30 -04:00
|
|
|
$location = apply_filters('wp_redirect', $location, $status);
|
|
|
|
|
|
|
|
if ( !$location ) // allows the wp_redirect filter to cancel a redirect
|
|
|
|
return false;
|
|
|
|
|
2007-08-30 11:42:26 -04:00
|
|
|
$location = preg_replace('|[^a-z0-9-~\+_\.\?#=&;,/:%]|i', '', $location);
|
2006-07-05 20:28:37 -04:00
|
|
|
$location = wp_kses_no_null($location);
|
2006-06-29 20:43:23 -04:00
|
|
|
|
2007-08-30 13:46:09 -04:00
|
|
|
// remove %0d and %0a from location
|
2006-06-29 20:43:23 -04:00
|
|
|
$strip = array('%0d', '%0a');
|
2007-08-30 13:46:09 -04:00
|
|
|
$found = true;
|
|
|
|
while($found) {
|
|
|
|
$found = false;
|
|
|
|
foreach($strip as $val) {
|
|
|
|
while(strpos($location, $val) !== false) {
|
|
|
|
$found = true;
|
|
|
|
$location = str_replace($val, '', $location);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-11-12 23:38:56 -05:00
|
|
|
|
2006-10-02 20:28:06 -04:00
|
|
|
if ( $is_IIS ) {
|
2005-04-19 23:37:23 -04:00
|
|
|
header("Refresh: 0;url=$location");
|
2006-10-02 20:28:06 -04:00
|
|
|
} else {
|
2006-11-21 23:58:31 -05:00
|
|
|
if ( php_sapi_name() != 'cgi-fcgi' )
|
|
|
|
status_header($status); // This causes problems on IIS and some FastCGI setups
|
2005-04-19 23:37:23 -04:00
|
|
|
header("Location: $location");
|
2006-10-02 20:28:06 -04:00
|
|
|
}
|
2005-04-19 23:37:23 -04:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2006-02-22 02:30:28 -05:00
|
|
|
if ( !function_exists('wp_get_cookie_login') ):
|
|
|
|
function wp_get_cookie_login() {
|
|
|
|
if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return array('login' => $_COOKIE[USER_COOKIE], 'password' => $_COOKIE[PASS_COOKIE]);
|
|
|
|
}
|
|
|
|
|
|
|
|
endif;
|
|
|
|
|
2005-04-19 23:37:23 -04:00
|
|
|
if ( !function_exists('wp_setcookie') ) :
|
2005-07-23 02:56:59 -04:00
|
|
|
function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
|
2005-04-19 23:37:23 -04:00
|
|
|
if ( !$already_md5 )
|
|
|
|
$password = md5( md5($password) ); // Double hash the password in the cookie.
|
|
|
|
|
|
|
|
if ( empty($home) )
|
|
|
|
$cookiepath = COOKIEPATH;
|
|
|
|
else
|
|
|
|
$cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' );
|
|
|
|
|
|
|
|
if ( empty($siteurl) ) {
|
|
|
|
$sitecookiepath = SITECOOKIEPATH;
|
|
|
|
$cookiehash = COOKIEHASH;
|
|
|
|
} else {
|
|
|
|
$sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' );
|
|
|
|
$cookiehash = md5($siteurl);
|
|
|
|
}
|
|
|
|
|
2005-07-23 02:56:59 -04:00
|
|
|
if ( $remember )
|
|
|
|
$expire = time() + 31536000;
|
|
|
|
else
|
|
|
|
$expire = 0;
|
|
|
|
|
|
|
|
setcookie(USER_COOKIE, $username, $expire, $cookiepath, COOKIE_DOMAIN);
|
|
|
|
setcookie(PASS_COOKIE, $password, $expire, $cookiepath, COOKIE_DOMAIN);
|
2005-04-19 23:37:23 -04:00
|
|
|
|
|
|
|
if ( $cookiepath != $sitecookiepath ) {
|
2005-07-23 02:56:59 -04:00
|
|
|
setcookie(USER_COOKIE, $username, $expire, $sitecookiepath, COOKIE_DOMAIN);
|
|
|
|
setcookie(PASS_COOKIE, $password, $expire, $sitecookiepath, COOKIE_DOMAIN);
|
2005-04-19 23:37:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if ( !function_exists('wp_clearcookie') ) :
|
|
|
|
function wp_clearcookie() {
|
2005-07-18 15:55:24 -04:00
|
|
|
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);
|
2005-04-19 23:37:23 -04:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if ( ! function_exists('wp_notify_postauthor') ) :
|
|
|
|
function wp_notify_postauthor($comment_id, $comment_type='') {
|
|
|
|
global $wpdb;
|
2006-11-19 02:56:05 -05:00
|
|
|
|
2005-11-07 18:15:21 -05:00
|
|
|
$comment = get_comment($comment_id);
|
|
|
|
$post = get_post($comment->comment_post_ID);
|
2005-11-07 03:58:37 -05:00
|
|
|
$user = get_userdata( $post->post_author );
|
2005-04-19 23:37:23 -04:00
|
|
|
|
|
|
|
if ('' == $user->user_email) return false; // If there's no email to send the comment to
|
|
|
|
|
2006-10-03 23:05:54 -04:00
|
|
|
$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
|
2005-04-19 23:37:23 -04:00
|
|
|
|
2006-08-30 17:46:31 -04:00
|
|
|
$blogname = get_option('blogname');
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2005-04-19 23:37:23 -04:00
|
|
|
if ( empty( $comment_type ) ) $comment_type = 'comment';
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2005-04-19 23:37:23 -04:00
|
|
|
if ('comment' == $comment_type) {
|
|
|
|
$notify_message = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
|
|
|
|
$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
|
|
|
|
$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
|
2006-08-30 12:40:17 -04:00
|
|
|
$notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n";
|
2005-04-19 23:37:23 -04:00
|
|
|
$notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
|
|
|
|
$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
|
|
|
|
$notify_message .= __('You can see all comments on this post here: ') . "\r\n";
|
|
|
|
$subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
|
|
|
|
} elseif ('trackback' == $comment_type) {
|
|
|
|
$notify_message = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
|
|
|
|
$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
|
2006-08-30 12:40:17 -04:00
|
|
|
$notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n";
|
2005-04-19 23:37:23 -04:00
|
|
|
$notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
|
|
|
|
$notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
|
|
|
|
$subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
|
|
|
|
} elseif ('pingback' == $comment_type) {
|
|
|
|
$notify_message = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
|
|
|
|
$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
|
2006-08-30 12:40:17 -04:00
|
|
|
$notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n";
|
2005-12-02 17:37:02 -05:00
|
|
|
$notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n";
|
2005-04-19 23:37:23 -04:00
|
|
|
$notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
|
|
|
|
$subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
|
|
|
|
}
|
|
|
|
$notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
|
2007-02-15 00:51:59 -05:00
|
|
|
$notify_message .= sprintf( __('Delete it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&c=$comment_id" ) . "\r\n";
|
|
|
|
$notify_message .= sprintf( __('Spam it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&dt=spam&c=$comment_id" ) . "\r\n";
|
2005-04-19 23:37:23 -04:00
|
|
|
|
2005-11-25 17:57:26 -05:00
|
|
|
$wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
|
2005-11-10 19:07:39 -05:00
|
|
|
|
|
|
|
if ( '' == $comment->comment_author ) {
|
2005-11-25 17:57:26 -05:00
|
|
|
$from = "From: \"$blogname\" <$wp_email>";
|
2005-11-10 19:07:39 -05:00
|
|
|
if ( '' != $comment->comment_author_email )
|
|
|
|
$reply_to = "Reply-To: $comment->comment_author_email";
|
2006-11-19 02:56:05 -05:00
|
|
|
} else {
|
2005-11-25 17:57:26 -05:00
|
|
|
$from = "From: \"$comment->comment_author\" <$wp_email>";
|
2005-11-10 19:07:39 -05:00
|
|
|
if ( '' != $comment->comment_author_email )
|
|
|
|
$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
|
2006-11-19 02:56:05 -05:00
|
|
|
}
|
2005-04-19 23:37:23 -04:00
|
|
|
|
2007-06-26 16:18:56 -04:00
|
|
|
$message_headers = "$from\n"
|
2006-08-30 17:46:31 -04:00
|
|
|
. "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
|
2005-04-19 23:37:23 -04:00
|
|
|
|
2005-11-10 21:00:06 -05:00
|
|
|
if ( isset($reply_to) )
|
|
|
|
$message_headers .= $reply_to . "\n";
|
|
|
|
|
2006-01-18 13:49:28 -05:00
|
|
|
$notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
|
|
|
|
$subject = apply_filters('comment_notification_subject', $subject, $comment_id);
|
|
|
|
$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
|
2005-08-30 19:17:42 -04:00
|
|
|
|
2005-04-19 23:37:23 -04:00
|
|
|
@wp_mail($user->user_email, $subject, $notify_message, $message_headers);
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-04-19 23:37:23 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
/* wp_notify_moderator
|
|
|
|
notifies the moderator of the blog (usually the admin)
|
|
|
|
about a new comment that waits for approval
|
|
|
|
always returns true
|
|
|
|
*/
|
|
|
|
if ( !function_exists('wp_notify_moderator') ) :
|
|
|
|
function wp_notify_moderator($comment_id) {
|
|
|
|
global $wpdb;
|
|
|
|
|
2006-08-30 17:46:31 -04:00
|
|
|
if( get_option( "moderation_notify" ) == 0 )
|
2005-04-19 23:37:23 -04:00
|
|
|
return true;
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-04-19 23:37:23 -04:00
|
|
|
$comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
|
|
|
|
$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
|
|
|
|
|
2006-10-03 23:05:54 -04:00
|
|
|
$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
|
2005-04-19 23:37:23 -04:00
|
|
|
$comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
|
|
|
|
|
|
|
|
$notify_message = sprintf( __('A new comment on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n";
|
|
|
|
$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
|
|
|
|
$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
|
|
|
|
$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
|
2006-08-30 12:40:17 -04:00
|
|
|
$notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n";
|
2005-04-19 23:37:23 -04:00
|
|
|
$notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
|
|
|
|
$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
|
2006-11-22 19:10:30 -05:00
|
|
|
$notify_message .= sprintf( __('Approve it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=mac&c=$comment_id" ) . "\r\n";
|
|
|
|
$notify_message .= sprintf( __('Delete it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&c=$comment_id" ) . "\r\n";
|
|
|
|
$notify_message .= sprintf( __('Spam it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&dt=spam&c=$comment_id" ) . "\r\n";
|
2005-04-19 23:37:23 -04:00
|
|
|
$notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n";
|
2006-08-30 17:46:31 -04:00
|
|
|
$notify_message .= get_option('siteurl') . "/wp-admin/moderation.php\r\n";
|
2005-04-19 23:37:23 -04:00
|
|
|
|
2006-08-30 17:46:31 -04:00
|
|
|
$subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_option('blogname'), $post->post_title );
|
|
|
|
$admin_email = get_option('admin_email');
|
2005-08-30 19:17:42 -04:00
|
|
|
|
2006-01-18 13:49:28 -05:00
|
|
|
$notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id);
|
|
|
|
$subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
|
2005-04-19 23:37:23 -04:00
|
|
|
|
|
|
|
@wp_mail($admin_email, $subject, $notify_message);
|
2006-11-19 02:56:05 -05:00
|
|
|
|
2005-04-19 23:37:23 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2005-09-13 20:03:02 -04:00
|
|
|
if ( !function_exists('wp_new_user_notification') ) :
|
|
|
|
function wp_new_user_notification($user_id, $plaintext_pass = '') {
|
|
|
|
$user = new WP_User($user_id);
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2005-11-15 21:54:23 -05:00
|
|
|
$user_login = stripslashes($user->user_login);
|
|
|
|
$user_email = stripslashes($user->user_email);
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2006-08-30 17:46:31 -04:00
|
|
|
$message = sprintf(__('New user registration on your blog %s:'), get_option('blogname')) . "\r\n\r\n";
|
2005-09-13 20:03:02 -04:00
|
|
|
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
|
|
|
|
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2006-08-30 17:46:31 -04:00
|
|
|
@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message);
|
2005-09-13 20:03:02 -04:00
|
|
|
|
|
|
|
if ( empty($plaintext_pass) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
$message = sprintf(__('Username: %s'), $user_login) . "\r\n";
|
|
|
|
$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
|
2006-08-30 17:46:31 -04:00
|
|
|
$message .= get_option('siteurl') . "/wp-login.php\r\n";
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2006-08-30 17:46:31 -04:00
|
|
|
wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message);
|
2006-02-12 02:53:23 -05:00
|
|
|
|
2005-09-13 20:03:02 -04:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2006-05-02 18:08:34 -04:00
|
|
|
if ( !function_exists('wp_verify_nonce') ) :
|
|
|
|
function wp_verify_nonce($nonce, $action = -1) {
|
|
|
|
$user = wp_get_current_user();
|
2007-03-22 20:59:21 -04:00
|
|
|
$uid = (int) $user->id;
|
2006-05-02 18:08:34 -04:00
|
|
|
|
|
|
|
$i = ceil(time() / 43200);
|
|
|
|
|
|
|
|
//Allow for expanding range, but only do one check if we can
|
2006-05-30 20:24:03 -04:00
|
|
|
if( substr(wp_hash($i . $action . $uid), -12, 10) == $nonce || substr(wp_hash(($i - 1) . $action . $uid), -12, 10) == $nonce )
|
2006-05-02 18:08:34 -04:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if ( !function_exists('wp_create_nonce') ) :
|
|
|
|
function wp_create_nonce($action = -1) {
|
|
|
|
$user = wp_get_current_user();
|
2007-03-22 20:59:21 -04:00
|
|
|
$uid = (int) $user->id;
|
2006-05-02 18:08:34 -04:00
|
|
|
|
|
|
|
$i = ceil(time() / 43200);
|
2006-11-19 02:56:05 -05:00
|
|
|
|
2006-05-30 20:24:03 -04:00
|
|
|
return substr(wp_hash($i . $action . $uid), -12, 10);
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2006-05-30 21:40:00 -04:00
|
|
|
if ( !function_exists('wp_salt') ) :
|
|
|
|
function wp_salt() {
|
|
|
|
$salt = get_option('secret');
|
|
|
|
if ( empty($salt) )
|
|
|
|
$salt = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
|
|
|
|
|
|
|
|
return $salt;
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2006-05-30 20:24:03 -04:00
|
|
|
if ( !function_exists('wp_hash') ) :
|
|
|
|
function wp_hash($data) {
|
2006-05-30 21:40:00 -04:00
|
|
|
$salt = wp_salt();
|
2006-05-30 20:24:03 -04:00
|
|
|
|
|
|
|
if ( function_exists('hash_hmac') ) {
|
2006-05-30 21:40:00 -04:00
|
|
|
return hash_hmac('md5', $data, $salt);
|
2006-05-30 20:24:03 -04:00
|
|
|
} else {
|
2006-05-30 21:40:00 -04:00
|
|
|
return md5($data . $salt);
|
2006-05-30 20:24:03 -04:00
|
|
|
}
|
2006-05-02 18:08:34 -04:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2005-07-12 11:53:13 -04:00
|
|
|
?>
|