web/wp-includes/pluggable.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
child 204 09a1c134465b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
     3  * These functions can be replaced via plugins. If plugins do not redefine these
     3  * These functions can be replaced via plugins. If plugins do not redefine these
     4  * functions, then these will be used instead.
     4  * functions, then these will be used instead.
     5  *
     5  *
     6  * @package WordPress
     6  * @package WordPress
     7  */
     7  */
     8 
       
     9 if ( !function_exists('set_current_user') ) :
       
    10 /**
       
    11  * Changes the current user by ID or name.
       
    12  *
       
    13  * Set $id to null and specify a name if you do not know a user's ID.
       
    14  *
       
    15  * @since 2.0.1
       
    16  * @see wp_set_current_user() An alias of wp_set_current_user()
       
    17  *
       
    18  * @param int|null $id User ID.
       
    19  * @param string $name Optional. The user's username
       
    20  * @return object returns wp_set_current_user()
       
    21  */
       
    22 function set_current_user($id, $name = '') {
       
    23 	return wp_set_current_user($id, $name);
       
    24 }
       
    25 endif;
       
    26 
     8 
    27 if ( !function_exists('wp_set_current_user') ) :
     9 if ( !function_exists('wp_set_current_user') ) :
    28 /**
    10 /**
    29  * Changes the current user by ID or name.
    11  * Changes the current user by ID or name.
    30  *
    12  *
    43  * @return WP_User Current user User object
    25  * @return WP_User Current user User object
    44  */
    26  */
    45 function wp_set_current_user($id, $name = '') {
    27 function wp_set_current_user($id, $name = '') {
    46 	global $current_user;
    28 	global $current_user;
    47 
    29 
    48 	if ( isset($current_user) && ($id == $current_user->ID) )
    30 	if ( isset( $current_user ) && ( $current_user instanceof WP_User ) && ( $id == $current_user->ID ) )
    49 		return $current_user;
    31 		return $current_user;
    50 
    32 
    51 	$current_user = new WP_User($id, $name);
    33 	$current_user = new WP_User( $id, $name );
    52 
    34 
    53 	setup_userdata($current_user->ID);
    35 	setup_userdata( $current_user->ID );
    54 
    36 
    55 	do_action('set_current_user');
    37 	do_action('set_current_user');
    56 
    38 
    57 	return $current_user;
    39 	return $current_user;
    58 }
    40 }
    90  * @return bool|null False on XMLRPC Request and invalid auth cookie. Null when current user set
    72  * @return bool|null False on XMLRPC Request and invalid auth cookie. Null when current user set
    91  */
    73  */
    92 function get_currentuserinfo() {
    74 function get_currentuserinfo() {
    93 	global $current_user;
    75 	global $current_user;
    94 
    76 
    95 	if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
    77 	if ( ! empty( $current_user ) ) {
       
    78 		if ( $current_user instanceof WP_User )
       
    79 			return;
       
    80 
       
    81 		// Upgrade stdClass to WP_User
       
    82 		if ( is_object( $current_user ) && isset( $current_user->ID ) ) {
       
    83 			$cur_id = $current_user->ID;
       
    84 			$current_user = null;
       
    85 			wp_set_current_user( $cur_id );
       
    86 			return;
       
    87 		}
       
    88 
       
    89 		// $current_user has a junk value. Force to WP_User with ID 0.
       
    90 		$current_user = null;
       
    91 		wp_set_current_user( 0 );
    96 		return false;
    92 		return false;
    97 
    93 	}
    98 	if ( ! empty($current_user) )
    94 
    99 		return;
    95 	if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) {
       
    96 		wp_set_current_user( 0 );
       
    97 		return false;
       
    98 	}
   100 
    99 
   101 	if ( ! $user = wp_validate_auth_cookie() ) {
   100 	if ( ! $user = wp_validate_auth_cookie() ) {
   102 		 if ( is_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) {
   101 		 if ( is_blog_admin() || is_network_admin() || empty( $_COOKIE[LOGGED_IN_COOKIE] ) || !$user = wp_validate_auth_cookie( $_COOKIE[LOGGED_IN_COOKIE], 'logged_in' ) ) {
   103 		 	wp_set_current_user(0);
   102 		 	wp_set_current_user( 0 );
   104 		 	return false;
   103 		 	return false;
   105 		 }
   104 		 }
   106 	}
   105 	}
   107 
   106 
   108 	wp_set_current_user($user);
   107 	wp_set_current_user( $user );
   109 }
   108 }
   110 endif;
   109 endif;
   111 
   110 
   112 if ( !function_exists('get_userdata') ) :
   111 if ( !function_exists('get_userdata') ) :
   113 /**
   112 /**
   114  * Retrieve user info by user ID.
   113  * Retrieve user info by user ID.
   115  *
   114  *
   116  * @since 0.71
   115  * @since 0.71
   117  *
   116  *
   118  * @param int $user_id User ID
   117  * @param int $user_id User ID
   119  * @return bool|object False on failure, User DB row object
   118  * @return bool|object False on failure, WP_User object on success
   120  */
   119  */
   121 function get_userdata( $user_id ) {
   120 function get_userdata( $user_id ) {
       
   121 	return get_user_by( 'id', $user_id );
       
   122 }
       
   123 endif;
       
   124 
       
   125 if ( !function_exists('get_user_by') ) :
       
   126 /**
       
   127  * Retrieve user info by a given field
       
   128  *
       
   129  * @since 2.8.0
       
   130  *
       
   131  * @param string $field The field to retrieve the user with. id | slug | email | login
       
   132  * @param int|string $value A value for $field. A user ID, slug, email address, or login name.
       
   133  * @return bool|object False on failure, WP_User object on success
       
   134  */
       
   135 function get_user_by( $field, $value ) {
       
   136 	$userdata = WP_User::get_data_by( $field, $value );
       
   137 
       
   138 	if ( !$userdata )
       
   139 		return false;
       
   140 
       
   141 	$user = new WP_User;
       
   142 	$user->init( $userdata );
       
   143 
       
   144 	return $user;
       
   145 }
       
   146 endif;
       
   147 
       
   148 if ( !function_exists('cache_users') ) :
       
   149 /**
       
   150  * Retrieve info for user lists to prevent multiple queries by get_userdata()
       
   151  *
       
   152  * @since 3.0.0
       
   153  *
       
   154  * @param array $user_ids User ID numbers list
       
   155  */
       
   156 function cache_users( $user_ids ) {
   122 	global $wpdb;
   157 	global $wpdb;
   123 
   158 
   124 	$user_id = absint($user_id);
   159 	$clean = _get_non_cached_ids( $user_ids, 'users' );
   125 	if ( $user_id == 0 )
   160 
   126 		return false;
   161 	if ( empty( $clean ) )
   127 
   162 		return;
   128 	$user = wp_cache_get($user_id, 'users');
   163 
   129 
   164 	$list = implode( ',', $clean );
   130 	if ( $user )
   165 
   131 		return $user;
   166 	$users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" );
   132 
   167 
   133 	if ( !$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE ID = %d LIMIT 1", $user_id)) )
   168 	$ids = array();
   134 		return false;
   169 	foreach ( $users as $user ) {
   135 
   170 		update_user_caches( $user );
   136 	_fill_user($user);
   171 		$ids[] = $user->ID;
   137 
   172 	}
   138 	return $user;
   173 	update_meta_cache( 'user', $ids );
   139 }
       
   140 endif;
       
   141 
       
   142 if ( !function_exists('get_user_by') ) :
       
   143 /**
       
   144  * Retrieve user info by a given field
       
   145  *
       
   146  * @since 2.8.0
       
   147  *
       
   148  * @param string $field The field to retrieve the user with.  id | slug | email | login
       
   149  * @param int|string $value A value for $field.  A user ID, slug, email address, or login name.
       
   150  * @return bool|object False on failure, User DB row object
       
   151  */
       
   152 function get_user_by($field, $value) {
       
   153 	global $wpdb;
       
   154 
       
   155 	switch ($field) {
       
   156 		case 'id':
       
   157 			return get_userdata($value);
       
   158 			break;
       
   159 		case 'slug':
       
   160 			$user_id = wp_cache_get($value, 'userslugs');
       
   161 			$field = 'user_nicename';
       
   162 			break;
       
   163 		case 'email':
       
   164 			$user_id = wp_cache_get($value, 'useremail');
       
   165 			$field = 'user_email';
       
   166 			break;
       
   167 		case 'login':
       
   168 			$value = sanitize_user( $value );
       
   169 			$user_id = wp_cache_get($value, 'userlogins');
       
   170 			$field = 'user_login';
       
   171 			break;
       
   172 		default:
       
   173 			return false;
       
   174 	}
       
   175 
       
   176 	 if ( false !== $user_id )
       
   177 		return get_userdata($user_id);
       
   178 
       
   179 	if ( !$user = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->users WHERE $field = %s", $value) ) )
       
   180 		return false;
       
   181 
       
   182 	_fill_user($user);
       
   183 
       
   184 	return $user;
       
   185 }
       
   186 endif;
       
   187 
       
   188 if ( !function_exists('get_userdatabylogin') ) :
       
   189 /**
       
   190  * Retrieve user info by login name.
       
   191  *
       
   192  * @since 0.71
       
   193  *
       
   194  * @param string $user_login User's username
       
   195  * @return bool|object False on failure, User DB row object
       
   196  */
       
   197 function get_userdatabylogin($user_login) {
       
   198 	return get_user_by('login', $user_login);
       
   199 }
       
   200 endif;
       
   201 
       
   202 if ( !function_exists('get_user_by_email') ) :
       
   203 /**
       
   204  * Retrieve user info by email.
       
   205  *
       
   206  * @since 2.5
       
   207  *
       
   208  * @param string $email User's email address
       
   209  * @return bool|object False on failure, User DB row object
       
   210  */
       
   211 function get_user_by_email($email) {
       
   212 	return get_user_by('email', $email);
       
   213 }
   174 }
   214 endif;
   175 endif;
   215 
   176 
   216 if ( !function_exists( 'wp_mail' ) ) :
   177 if ( !function_exists( 'wp_mail' ) ) :
   217 /**
   178 /**
   240  * @uses apply_filters() Calls 'wp_mail_content_type' hook to get the email content type.
   201  * @uses apply_filters() Calls 'wp_mail_content_type' hook to get the email content type.
   241  * @uses apply_filters() Calls 'wp_mail_charset' hook to get the email charset
   202  * @uses apply_filters() Calls 'wp_mail_charset' hook to get the email charset
   242  * @uses do_action_ref_array() Calls 'phpmailer_init' hook on the reference to
   203  * @uses do_action_ref_array() Calls 'phpmailer_init' hook on the reference to
   243  *		phpmailer object.
   204  *		phpmailer object.
   244  * @uses PHPMailer
   205  * @uses PHPMailer
   245  * @
   206  *
   246  *
   207  * @param string|array $to Array or comma-separated list of email addresses to send message.
   247  * @param string $to Email address to send message
       
   248  * @param string $subject Email subject
   208  * @param string $subject Email subject
   249  * @param string $message Message contents
   209  * @param string $message Message contents
   250  * @param string|array $headers Optional. Additional headers.
   210  * @param string|array $headers Optional. Additional headers.
   251  * @param string|array $attachments Optional. Files to attach.
   211  * @param string|array $attachments Optional. Files to attach.
   252  * @return bool Whether the email contents were sent successfully.
   212  * @return bool Whether the email contents were sent successfully.
   254 function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
   214 function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
   255 	// Compact the input, apply the filters, and extract them back out
   215 	// Compact the input, apply the filters, and extract them back out
   256 	extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
   216 	extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
   257 
   217 
   258 	if ( !is_array($attachments) )
   218 	if ( !is_array($attachments) )
   259 		$attachments = explode( "\n", $attachments );
   219 		$attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );
   260 
   220 
   261 	global $phpmailer;
   221 	global $phpmailer;
   262 
   222 
   263 	// (Re)create it, if it's gone missing
   223 	// (Re)create it, if it's gone missing
   264 	if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
   224 	if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
   265 		require_once ABSPATH . WPINC . '/class-phpmailer.php';
   225 		require_once ABSPATH . WPINC . '/class-phpmailer.php';
   266 		require_once ABSPATH . WPINC . '/class-smtp.php';
   226 		require_once ABSPATH . WPINC . '/class-smtp.php';
   267 		$phpmailer = new PHPMailer();
   227 		$phpmailer = new PHPMailer( true );
   268 	}
   228 	}
   269 
   229 
   270 	// Headers
   230 	// Headers
   271 	if ( empty( $headers ) ) {
   231 	if ( empty( $headers ) ) {
   272 		$headers = array();
   232 		$headers = array();
   273 	} else {
   233 	} else {
   274 		if ( !is_array( $headers ) ) {
   234 		if ( !is_array( $headers ) ) {
   275 			// Explode the headers out, so this function can take both
   235 			// Explode the headers out, so this function can take both
   276 			// string headers and an array of headers.
   236 			// string headers and an array of headers.
   277 			$tempheaders = (array) explode( "\n", $headers );
   237 			$tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
   278 		} else {
   238 		} else {
   279 			$tempheaders = $headers;
   239 			$tempheaders = $headers;
   280 		}
   240 		}
   281 		$headers = array();
   241 		$headers = array();
       
   242 		$cc = array();
       
   243 		$bcc = array();
   282 
   244 
   283 		// If it's actually got contents
   245 		// If it's actually got contents
   284 		if ( !empty( $tempheaders ) ) {
   246 		if ( !empty( $tempheaders ) ) {
   285 			// Iterate through the raw headers
   247 			// Iterate through the raw headers
   286 			foreach ( (array) $tempheaders as $header ) {
   248 			foreach ( (array) $tempheaders as $header ) {
   293 				}
   255 				}
   294 				// Explode them out
   256 				// Explode them out
   295 				list( $name, $content ) = explode( ':', trim( $header ), 2 );
   257 				list( $name, $content ) = explode( ':', trim( $header ), 2 );
   296 
   258 
   297 				// Cleanup crew
   259 				// Cleanup crew
   298 				$name = trim( $name );
   260 				$name    = trim( $name    );
   299 				$content = trim( $content );
   261 				$content = trim( $content );
   300 
   262 
   301 				// Mainly for legacy -- process a From: header if it's there
   263 				switch ( strtolower( $name ) ) {
   302 				if ( 'from' == strtolower($name) ) {
   264 					// Mainly for legacy -- process a From: header if it's there
   303 					if ( strpos($content, '<' ) !== false ) {
   265 					case 'from':
   304 						// So... making my life hard again?
   266 						if ( strpos($content, '<' ) !== false ) {
   305 						$from_name = substr( $content, 0, strpos( $content, '<' ) - 1 );
   267 							// So... making my life hard again?
   306 						$from_name = str_replace( '"', '', $from_name );
   268 							$from_name = substr( $content, 0, strpos( $content, '<' ) - 1 );
   307 						$from_name = trim( $from_name );
   269 							$from_name = str_replace( '"', '', $from_name );
   308 
   270 							$from_name = trim( $from_name );
   309 						$from_email = substr( $content, strpos( $content, '<' ) + 1 );
   271 
   310 						$from_email = str_replace( '>', '', $from_email );
   272 							$from_email = substr( $content, strpos( $content, '<' ) + 1 );
   311 						$from_email = trim( $from_email );
   273 							$from_email = str_replace( '>', '', $from_email );
   312 					} else {
   274 							$from_email = trim( $from_email );
   313 						$from_email = trim( $content );
   275 						} else {
   314 					}
   276 							$from_email = trim( $content );
   315 				} elseif ( 'content-type' == strtolower($name) ) {
       
   316 					if ( strpos( $content,';' ) !== false ) {
       
   317 						list( $type, $charset ) = explode( ';', $content );
       
   318 						$content_type = trim( $type );
       
   319 						if ( false !== stripos( $charset, 'charset=' ) ) {
       
   320 							$charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) );
       
   321 						} elseif ( false !== stripos( $charset, 'boundary=' ) ) {
       
   322 							$boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset ) );
       
   323 							$charset = '';
       
   324 						}
   277 						}
   325 					} else {
   278 						break;
   326 						$content_type = trim( $content );
   279 					case 'content-type':
   327 					}
   280 						if ( strpos( $content, ';' ) !== false ) {
   328 				} elseif ( 'cc' == strtolower($name) ) {
   281 							list( $type, $charset ) = explode( ';', $content );
   329 					$cc = explode(",", $content);
   282 							$content_type = trim( $type );
   330 				} elseif ( 'bcc' == strtolower($name) ) {
   283 							if ( false !== stripos( $charset, 'charset=' ) ) {
   331 					$bcc = explode(",", $content);
   284 								$charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) );
   332 				} else {
   285 							} elseif ( false !== stripos( $charset, 'boundary=' ) ) {
   333 					// Add it to our grand headers array
   286 								$boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset ) );
   334 					$headers[trim( $name )] = trim( $content );
   287 								$charset = '';
       
   288 							}
       
   289 						} else {
       
   290 							$content_type = trim( $content );
       
   291 						}
       
   292 						break;
       
   293 					case 'cc':
       
   294 						$cc = array_merge( (array) $cc, explode( ',', $content ) );
       
   295 						break;
       
   296 					case 'bcc':
       
   297 						$bcc = array_merge( (array) $bcc, explode( ',', $content ) );
       
   298 						break;
       
   299 					default:
       
   300 						// Add it to our grand headers array
       
   301 						$headers[trim( $name )] = trim( $content );
       
   302 						break;
   335 				}
   303 				}
   336 			}
   304 			}
   337 		}
   305 		}
   338 	}
   306 	}
   339 
   307 
   346 	$phpmailer->ClearCustomHeaders();
   314 	$phpmailer->ClearCustomHeaders();
   347 	$phpmailer->ClearReplyTos();
   315 	$phpmailer->ClearReplyTos();
   348 
   316 
   349 	// From email and name
   317 	// From email and name
   350 	// If we don't have a name from the input headers
   318 	// If we don't have a name from the input headers
   351 	if ( !isset( $from_name ) ) {
   319 	if ( !isset( $from_name ) )
   352 		$from_name = 'WordPress';
   320 		$from_name = 'WordPress';
   353 	}
       
   354 
   321 
   355 	/* If we don't have an email from the input headers default to wordpress@$sitename
   322 	/* If we don't have an email from the input headers default to wordpress@$sitename
   356 	 * Some hosts will block outgoing mail from this address if it doesn't exist but
   323 	 * Some hosts will block outgoing mail from this address if it doesn't exist but
   357 	 * there's no easy alternative. Defaulting to admin_email might appear to be another
   324 	 * there's no easy alternative. Defaulting to admin_email might appear to be another
   358 	 * option but some hosts may refuse to relay mail from an unknown domain. See
   325 	 * option but some hosts may refuse to relay mail from an unknown domain. See
   368 
   335 
   369 		$from_email = 'wordpress@' . $sitename;
   336 		$from_email = 'wordpress@' . $sitename;
   370 	}
   337 	}
   371 
   338 
   372 	// Plugin authors can override the potentially troublesome default
   339 	// Plugin authors can override the potentially troublesome default
   373 	$phpmailer->From = apply_filters( 'wp_mail_from', $from_email );
   340 	$phpmailer->From     = apply_filters( 'wp_mail_from'     , $from_email );
   374 	$phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name );
   341 	$phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name  );
   375 
   342 
   376 	// Set destination address
   343 	// Set destination addresses
   377 	$phpmailer->AddAddress( $to );
   344 	if ( !is_array( $to ) )
       
   345 		$to = explode( ',', $to );
       
   346 
       
   347 	foreach ( (array) $to as $recipient ) {
       
   348 		try {
       
   349 			// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
       
   350 			$recipient_name = '';
       
   351 			if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
       
   352 				if ( count( $matches ) == 3 ) {
       
   353 					$recipient_name = $matches[1];
       
   354 					$recipient = $matches[2];
       
   355 				}
       
   356 			}
       
   357 			$phpmailer->AddAddress( $recipient, $recipient_name);
       
   358 		} catch ( phpmailerException $e ) {
       
   359 			continue;
       
   360 		}
       
   361 	}
   378 
   362 
   379 	// Set mail's subject and body
   363 	// Set mail's subject and body
   380 	$phpmailer->Subject = $subject;
   364 	$phpmailer->Subject = $subject;
   381 	$phpmailer->Body = $message;
   365 	$phpmailer->Body    = $message;
   382 
   366 
   383 	// Add any CC and BCC recipients
   367 	// Add any CC and BCC recipients
   384 	if ( !empty($cc) ) {
   368 	if ( !empty( $cc ) ) {
   385 		foreach ( (array) $cc as $recipient ) {
   369 		foreach ( (array) $cc as $recipient ) {
   386 			$phpmailer->AddCc( trim($recipient) );
   370 			try {
       
   371 				// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
       
   372 				$recipient_name = '';
       
   373 				if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
       
   374 					if ( count( $matches ) == 3 ) {
       
   375 						$recipient_name = $matches[1];
       
   376 						$recipient = $matches[2];
       
   377 					}
       
   378 				}
       
   379 				$phpmailer->AddCc( $recipient, $recipient_name );
       
   380 			} catch ( phpmailerException $e ) {
       
   381 				continue;
       
   382 			}
   387 		}
   383 		}
   388 	}
   384 	}
   389 	if ( !empty($bcc) ) {
   385 
       
   386 	if ( !empty( $bcc ) ) {
   390 		foreach ( (array) $bcc as $recipient) {
   387 		foreach ( (array) $bcc as $recipient) {
   391 			$phpmailer->AddBcc( trim($recipient) );
   388 			try {
       
   389 				// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
       
   390 				$recipient_name = '';
       
   391 				if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
       
   392 					if ( count( $matches ) == 3 ) {
       
   393 						$recipient_name = $matches[1];
       
   394 						$recipient = $matches[2];
       
   395 					}
       
   396 				}
       
   397 				$phpmailer->AddBcc( $recipient, $recipient_name );
       
   398 			} catch ( phpmailerException $e ) {
       
   399 				continue;
       
   400 			}
   392 		}
   401 		}
   393 	}
   402 	}
   394 
   403 
   395 	// Set to use PHP's mail()
   404 	// Set to use PHP's mail()
   396 	$phpmailer->IsMail();
   405 	$phpmailer->IsMail();
   397 
   406 
   398 	// Set Content-Type and charset
   407 	// Set Content-Type and charset
   399 	// If we don't have a content-type from the input headers
   408 	// If we don't have a content-type from the input headers
   400 	if ( !isset( $content_type ) ) {
   409 	if ( !isset( $content_type ) )
   401 		$content_type = 'text/plain';
   410 		$content_type = 'text/plain';
   402 	}
       
   403 
   411 
   404 	$content_type = apply_filters( 'wp_mail_content_type', $content_type );
   412 	$content_type = apply_filters( 'wp_mail_content_type', $content_type );
   405 
   413 
   406 	$phpmailer->ContentType = $content_type;
   414 	$phpmailer->ContentType = $content_type;
   407 
   415 
   408 	// Set whether it's plaintext or not, depending on $content_type
   416 	// Set whether it's plaintext, depending on $content_type
   409 	if ( $content_type == 'text/html' ) {
   417 	if ( 'text/html' == $content_type )
   410 		$phpmailer->IsHTML( true );
   418 		$phpmailer->IsHTML( true );
   411 	}
       
   412 
   419 
   413 	// If we don't have a charset from the input headers
   420 	// If we don't have a charset from the input headers
   414 	if ( !isset( $charset ) ) {
   421 	if ( !isset( $charset ) )
   415 		$charset = get_bloginfo( 'charset' );
   422 		$charset = get_bloginfo( 'charset' );
   416 	}
       
   417 
   423 
   418 	// Set the content-type and charset
   424 	// Set the content-type and charset
   419 	$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
   425 	$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
   420 
   426 
   421 	// Set custom headers
   427 	// Set custom headers
   422 	if ( !empty( $headers ) ) {
   428 	if ( !empty( $headers ) ) {
   423 		foreach( (array) $headers as $name => $content ) {
   429 		foreach( (array) $headers as $name => $content ) {
   424 			$phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
   430 			$phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
   425 		}
   431 		}
   426 		if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) ) {
   432 
       
   433 		if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
   427 			$phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
   434 			$phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
   428 		}
       
   429 	}
   435 	}
   430 
   436 
   431 	if ( !empty( $attachments ) ) {
   437 	if ( !empty( $attachments ) ) {
   432 		foreach ( $attachments as $attachment ) {
   438 		foreach ( $attachments as $attachment ) {
   433 			$phpmailer->AddAttachment($attachment);
   439 			try {
       
   440 				$phpmailer->AddAttachment($attachment);
       
   441 			} catch ( phpmailerException $e ) {
       
   442 				continue;
       
   443 			}
   434 		}
   444 		}
   435 	}
   445 	}
   436 
   446 
   437 	do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
   447 	do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
   438 
   448 
   439 	// Send!
   449 	// Send!
   440 	$result = @$phpmailer->Send();
   450 	try {
   441 
   451 		$phpmailer->Send();
   442 	return $result;
   452 	} catch ( phpmailerException $e ) {
       
   453 		return false;
       
   454 	}
       
   455 
       
   456 	return true;
   443 }
   457 }
   444 endif;
   458 endif;
   445 
   459 
   446 if ( !function_exists('wp_authenticate') ) :
   460 if ( !function_exists('wp_authenticate') ) :
   447 /**
   461 /**
   521 	if ( $expired < time() ) {
   535 	if ( $expired < time() ) {
   522 		do_action('auth_cookie_expired', $cookie_elements);
   536 		do_action('auth_cookie_expired', $cookie_elements);
   523 		return false;
   537 		return false;
   524 	}
   538 	}
   525 
   539 
   526 	$user = get_userdatabylogin($username);
   540 	$user = get_user_by('login', $username);
   527 	if ( ! $user ) {
   541 	if ( ! $user ) {
   528 		do_action('auth_cookie_bad_username', $cookie_elements);
   542 		do_action('auth_cookie_bad_username', $cookie_elements);
   529 		return false;
   543 		return false;
   530 	}
   544 	}
   531 
   545 
   631  * set, the cookies will be kept for 14 days or two weeks.
   645  * set, the cookies will be kept for 14 days or two weeks.
   632  *
   646  *
   633  * @since 2.5
   647  * @since 2.5
   634  *
   648  *
   635  * @param int $user_id User ID
   649  * @param int $user_id User ID
   636  * @param bool $remember Whether to remember the user or not
   650  * @param bool $remember Whether to remember the user
   637  */
   651  */
   638 function wp_set_auth_cookie($user_id, $remember = false, $secure = '') {
   652 function wp_set_auth_cookie($user_id, $remember = false, $secure = '') {
   639 	if ( $remember ) {
   653 	if ( $remember ) {
   640 		$expiration = $expire = time() + apply_filters('auth_cookie_expiration', 1209600, $user_id, $remember);
   654 		$expiration = $expire = time() + apply_filters('auth_cookie_expiration', 1209600, $user_id, $remember);
   641 	} else {
   655 	} else {
   642 		$expiration = time() + apply_filters('auth_cookie_expiration', 172800, $user_id, $remember);
   656 		$expiration = time() + apply_filters('auth_cookie_expiration', 172800, $user_id, $remember);
   643 		$expire = 0;
   657 		$expire = 0;
   644 	}
   658 	}
   645 
   659 
   646 	if ( '' === $secure )
   660 	if ( '' === $secure )
   647 		$secure = is_ssl() ? true : false;
   661 		$secure = is_ssl();
       
   662 
       
   663 	$secure = apply_filters('secure_auth_cookie', $secure, $user_id);
       
   664 	$secure_logged_in_cookie = apply_filters('secure_logged_in_cookie', false, $user_id, $secure);
   648 
   665 
   649 	if ( $secure ) {
   666 	if ( $secure ) {
   650 		$auth_cookie_name = SECURE_AUTH_COOKIE;
   667 		$auth_cookie_name = SECURE_AUTH_COOKIE;
   651 		$scheme = 'secure_auth';
   668 		$scheme = 'secure_auth';
   652 	} else {
   669 	} else {
   658 	$logged_in_cookie = wp_generate_auth_cookie($user_id, $expiration, 'logged_in');
   675 	$logged_in_cookie = wp_generate_auth_cookie($user_id, $expiration, 'logged_in');
   659 
   676 
   660 	do_action('set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme);
   677 	do_action('set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme);
   661 	do_action('set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in');
   678 	do_action('set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in');
   662 
   679 
   663 	// Set httponly if the php version is >= 5.2.0
   680 	setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
   664 	if ( version_compare(phpversion(), '5.2.0', 'ge') ) {
   681 	setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
   665 		setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
   682 	setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
   666 		setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
   683 	if ( COOKIEPATH != SITECOOKIEPATH )
   667 		setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, false, true);
   684 		setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
   668 		if ( COOKIEPATH != SITECOOKIEPATH )
       
   669 			setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, false, true);
       
   670 	} else {
       
   671 		$cookie_domain = COOKIE_DOMAIN;
       
   672 		if ( !empty($cookie_domain) )
       
   673 			$cookie_domain .= '; HttpOnly';
       
   674 		setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, $cookie_domain, $secure);
       
   675 		setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, $cookie_domain, $secure);
       
   676 		setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, $cookie_domain);
       
   677 		if ( COOKIEPATH != SITECOOKIEPATH )
       
   678 			setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, $cookie_domain);
       
   679 	}
       
   680 }
   685 }
   681 endif;
   686 endif;
   682 
   687 
   683 if ( !function_exists('wp_clear_auth_cookie') ) :
   688 if ( !function_exists('wp_clear_auth_cookie') ) :
   684 /**
   689 /**
   719  * @return bool True if user is logged in, false if not logged in.
   724  * @return bool True if user is logged in, false if not logged in.
   720  */
   725  */
   721 function is_user_logged_in() {
   726 function is_user_logged_in() {
   722 	$user = wp_get_current_user();
   727 	$user = wp_get_current_user();
   723 
   728 
   724 	if ( $user->id == 0 )
   729 	if ( ! $user->exists() )
   725 		return false;
   730 		return false;
   726 
   731 
   727 	return true;
   732 	return true;
   728 }
   733 }
   729 endif;
   734 endif;
   735  * @since 1.5
   740  * @since 1.5
   736  */
   741  */
   737 function auth_redirect() {
   742 function auth_redirect() {
   738 	// Checks if a user is logged in, if not redirects them to the login page
   743 	// Checks if a user is logged in, if not redirects them to the login page
   739 
   744 
   740 	if ( is_ssl() || force_ssl_admin() )
   745 	$secure = ( is_ssl() || force_ssl_admin() );
   741 		$secure = true;
   746 
   742 	else
   747 	$secure = apply_filters('secure_auth_redirect', $secure);
   743 		$secure = false;
       
   744 
   748 
   745 	// If https is required and request is http, redirect
   749 	// If https is required and request is http, redirect
   746 	if ( $secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
   750 	if ( $secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
   747 		if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
   751 		if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
   748 			wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
   752 			wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
   751 			wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
   755 			wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
   752 			exit();
   756 			exit();
   753 		}
   757 		}
   754 	}
   758 	}
   755 
   759 
   756 	if ( $user_id = wp_validate_auth_cookie( '', apply_filters( 'auth_redirect_scheme', '' ) ) ) {
   760 	if ( is_user_admin() )
       
   761 		$scheme = 'logged_in';
       
   762 	else
       
   763 		$scheme = apply_filters( 'auth_redirect_scheme', '' );
       
   764 
       
   765 	if ( $user_id = wp_validate_auth_cookie( '',  $scheme) ) {
   757 		do_action('auth_redirect', $user_id);
   766 		do_action('auth_redirect', $user_id);
   758 
   767 
   759 		// If the user wants ssl but the session is not ssl, redirect.
   768 		// If the user wants ssl but the session is not ssl, redirect.
   760 		if ( !$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
   769 		if ( !$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
   761 			if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
   770 			if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
   778 	else
   787 	else
   779 		$proto = 'http://';
   788 		$proto = 'http://';
   780 
   789 
   781 	$redirect = ( strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer() ) ? wp_get_referer() : $proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
   790 	$redirect = ( strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer() ) ? wp_get_referer() : $proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
   782 
   791 
   783 	$login_url = wp_login_url($redirect);
   792 	$login_url = wp_login_url($redirect, true);
   784 
   793 
   785 	wp_redirect($login_url);
   794 	wp_redirect($login_url);
   786 	exit();
   795 	exit();
   787 }
   796 }
   788 endif;
   797 endif;
   798  *
   807  *
   799  * @param string $action Action nonce
   808  * @param string $action Action nonce
   800  * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
   809  * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
   801  */
   810  */
   802 function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
   811 function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
       
   812 	if ( -1 == $action )
       
   813 		_doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2' );
       
   814 
   803 	$adminurl = strtolower(admin_url());
   815 	$adminurl = strtolower(admin_url());
   804 	$referer = strtolower(wp_get_referer());
   816 	$referer = strtolower(wp_get_referer());
   805 	$result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false;
   817 	$result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false;
   806 	if ( !$result && !(-1 == $action && strpos($referer, $adminurl) !== false) ) {
   818 	if ( !$result && !(-1 == $action && strpos($referer, $adminurl) === 0) ) {
   807 		wp_nonce_ays($action);
   819 		wp_nonce_ays($action);
   808 		die();
   820 		die();
   809 	}
   821 	}
   810 	do_action('check_admin_referer', $action, $result);
   822 	do_action('check_admin_referer', $action, $result);
   811 	return $result;
   823 	return $result;
   826 	else
   838 	else
   827 		$nonce = isset($_REQUEST['_ajax_nonce']) ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce'];
   839 		$nonce = isset($_REQUEST['_ajax_nonce']) ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce'];
   828 
   840 
   829 	$result = wp_verify_nonce( $nonce, $action );
   841 	$result = wp_verify_nonce( $nonce, $action );
   830 
   842 
   831 	if ( $die && false == $result )
   843 	if ( $die && false == $result ) {
   832 		die('-1');
   844 		if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
       
   845 			wp_die( -1 );
       
   846 		else
       
   847 			die( '-1' );
       
   848 	}
   833 
   849 
   834 	do_action('check_ajax_referer', $action, $result);
   850 	do_action('check_ajax_referer', $action, $result);
   835 
   851 
   836 	return $result;
   852 	return $result;
   837 }
   853 }
   838 endif;
   854 endif;
   839 
   855 
   840 if ( !function_exists('wp_redirect') ) :
   856 if ( !function_exists('wp_redirect') ) :
   841 /**
   857 /**
   842  * Redirects to another page, with a workaround for the IIS Set-Cookie bug.
   858  * Redirects to another page.
   843  *
   859  *
   844  * @link http://support.microsoft.com/kb/q176113/
       
   845  * @since 1.5.1
   860  * @since 1.5.1
   846  * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
   861  * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
   847  *
   862  *
   848  * @param string $location The path to redirect to
   863  * @param string $location The path to redirect to
   849  * @param int $status Status code to use
   864  * @param int $status Status code to use
   858 	if ( !$location ) // allows the wp_redirect filter to cancel a redirect
   873 	if ( !$location ) // allows the wp_redirect filter to cancel a redirect
   859 		return false;
   874 		return false;
   860 
   875 
   861 	$location = wp_sanitize_redirect($location);
   876 	$location = wp_sanitize_redirect($location);
   862 
   877 
   863 	if ( $is_IIS ) {
   878 	if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
   864 		header("Refresh: 0;url=$location");
   879 		status_header($status); // This causes problems on IIS and some FastCGI setups
   865 	} else {
   880 
   866 		if ( php_sapi_name() != 'cgi-fcgi' )
   881 	header("Location: $location", true, $status);
   867 			status_header($status); // This causes problems on IIS and some FastCGI setups
       
   868 		header("Location: $location", true, $status);
       
   869 	}
       
   870 }
   882 }
   871 endif;
   883 endif;
   872 
   884 
   873 if ( !function_exists('wp_sanitize_redirect') ) :
   885 if ( !function_exists('wp_sanitize_redirect') ) :
   874 /**
   886 /**
   930  * @since 2.8.1
   942  * @since 2.8.1
   931  * @uses apply_filters() Calls 'allowed_redirect_hosts' on an array containing
   943  * @uses apply_filters() Calls 'allowed_redirect_hosts' on an array containing
   932  *		WordPress host string and $location host string.
   944  *		WordPress host string and $location host string.
   933  *
   945  *
   934  * @param string $location The redirect to validate
   946  * @param string $location The redirect to validate
   935  * @param string $default The value to return is $location is not allowed
   947  * @param string $default The value to return if $location is not allowed
   936  * @return string redirect-sanitized URL
   948  * @return string redirect-sanitized URL
   937  **/
   949  **/
   938 function wp_validate_redirect($location, $default = '') {
   950 function wp_validate_redirect($location, $default = '') {
   939 	// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
   951 	// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
   940 	if ( substr($location, 0, 2) == '//' )
   952 	if ( substr($location, 0, 2) == '//' )
   942 
   954 
   943 	// In php 5 parse_url may fail if the URL query part contains http://, bug #38143
   955 	// In php 5 parse_url may fail if the URL query part contains http://, bug #38143
   944 	$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
   956 	$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
   945 
   957 
   946 	$lp  = parse_url($test);
   958 	$lp  = parse_url($test);
   947 	$wpp = parse_url(get_option('home'));
   959 
       
   960 	// Give up if malformed URL
       
   961 	if ( false === $lp )
       
   962 		return $default;
       
   963 
       
   964 	// Allow only http and https schemes. No data:, etc.
       
   965 	if ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) )
       
   966 		return $default;
       
   967 
       
   968 	// Reject if scheme is set but host is not. This catches urls like https:host.com for which parse_url does not set the host field.
       
   969 	if ( isset($lp['scheme'])  && !isset($lp['host']) )
       
   970 		return $default;
       
   971 
       
   972 	$wpp = parse_url(home_url());
   948 
   973 
   949 	$allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');
   974 	$allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');
   950 
   975 
   951 	if ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) )
   976 	if ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) )
   952 		$location = $default;
   977 		$location = $default;
   963  *
   988  *
   964  * @param int $comment_id Comment ID
   989  * @param int $comment_id Comment ID
   965  * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback'
   990  * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback'
   966  * @return bool False if user email does not exist. True on completion.
   991  * @return bool False if user email does not exist. True on completion.
   967  */
   992  */
   968 function wp_notify_postauthor($comment_id, $comment_type='') {
   993 function wp_notify_postauthor( $comment_id, $comment_type = '' ) {
   969 	$comment = get_comment($comment_id);
   994 	$comment = get_comment( $comment_id );
   970 	$post    = get_post($comment->comment_post_ID);
   995 	$post    = get_post( $comment->comment_post_ID );
   971 	$user    = get_userdata( $post->post_author );
   996 	$author  = get_userdata( $post->post_author );
   972 	$current_user = wp_get_current_user();
   997 
   973 
   998 	// The comment was left by the author
   974 	if ( $comment->user_id == $post->post_author ) return false; // The author moderated a comment on his own post
   999 	if ( $comment->user_id == $post->post_author )
   975 
  1000 		return false;
   976 	if ('' == $user->user_email) return false; // If there's no email to send the comment to
  1001 
       
  1002 	// The author moderated a comment on his own post
       
  1003 	if ( $post->post_author == get_current_user_id() )
       
  1004 		return false;
       
  1005 
       
  1006 	// If there's no email to send the comment to
       
  1007 	if ( '' == $author->user_email )
       
  1008 		return false;
   977 
  1009 
   978 	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
  1010 	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
   979 	
  1011 
   980 	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
  1012 	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
   981 	// we want to reverse this for the plain text arena of emails.
  1013 	// we want to reverse this for the plain text arena of emails.
   982 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  1014 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
   983 
  1015 
   984 	if ( empty( $comment_type ) ) $comment_type = 'comment';
  1016 	if ( empty( $comment_type ) ) $comment_type = 'comment';
   985 
  1017 
   986 	if ('comment' == $comment_type) {
  1018 	if ('comment' == $comment_type) {
   987 		/* translators: 1: post id, 2: post title */
  1019 		$notify_message  = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
   988 		$notify_message  = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
       
   989 		/* translators: 1: comment author, 2: author IP, 3: author domain */
  1020 		/* translators: 1: comment author, 2: author IP, 3: author domain */
   990 		$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  1021 		$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
   991 		$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
  1022 		$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
   992 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  1023 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
   993 		$notify_message .= sprintf( __('Whois  : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
  1024 		$notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
   994 		$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
  1025 		$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
   995 		$notify_message .= __('You can see all comments on this post here: ') . "\r\n";
  1026 		$notify_message .= __('You can see all comments on this post here: ') . "\r\n";
   996 		/* translators: 1: blog name, 2: post title */
  1027 		/* translators: 1: blog name, 2: post title */
   997 		$subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
  1028 		$subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
   998 	} elseif ('trackback' == $comment_type) {
  1029 	} elseif ('trackback' == $comment_type) {
   999 		/* translators: 1: post id, 2: post title */
  1030 		$notify_message  = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
  1000 		$notify_message  = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
       
  1001 		/* translators: 1: website name, 2: author IP, 3: author domain */
  1031 		/* translators: 1: website name, 2: author IP, 3: author domain */
  1002 		$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  1032 		$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  1003 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  1033 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  1004 		$notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
  1034 		$notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
  1005 		$notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
  1035 		$notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
  1006 		/* translators: 1: blog name, 2: post title */
  1036 		/* translators: 1: blog name, 2: post title */
  1007 		$subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
  1037 		$subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
  1008 	} elseif ('pingback' == $comment_type) {
  1038 	} elseif ('pingback' == $comment_type) {
  1009 		/* translators: 1: post id, 2: post title */
  1039 		$notify_message  = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
  1010 		$notify_message  = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
       
  1011 		/* translators: 1: comment author, 2: author IP, 3: author domain */
  1040 		/* translators: 1: comment author, 2: author IP, 3: author domain */
  1012 		$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  1041 		$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  1013 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  1042 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  1014 		$notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n";
  1043 		$notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n";
  1015 		$notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
  1044 		$notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
  1016 		/* translators: 1: blog name, 2: post title */
  1045 		/* translators: 1: blog name, 2: post title */
  1017 		$subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
  1046 		$subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
  1018 	}
  1047 	}
  1019 	$notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
  1048 	$notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
       
  1049 	$notify_message .= sprintf( __('Permalink: %s'), get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id ) . "\r\n";
  1020 	if ( EMPTY_TRASH_DAYS )
  1050 	if ( EMPTY_TRASH_DAYS )
  1021 		$notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
  1051 		$notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
  1022 	else
  1052 	else
  1023 		$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
  1053 		$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
  1024 	$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
  1054 	$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
  1043 
  1073 
  1044 	$notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
  1074 	$notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
  1045 	$subject = apply_filters('comment_notification_subject', $subject, $comment_id);
  1075 	$subject = apply_filters('comment_notification_subject', $subject, $comment_id);
  1046 	$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
  1076 	$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
  1047 
  1077 
  1048 	@wp_mail($user->user_email, $subject, $notify_message, $message_headers);
  1078 	@wp_mail( $author->user_email, $subject, $notify_message, $message_headers );
  1049 
  1079 
  1050 	return true;
  1080 	return true;
  1051 }
  1081 }
  1052 endif;
  1082 endif;
  1053 
  1083 
  1062  * @return bool Always returns true
  1092  * @return bool Always returns true
  1063  */
  1093  */
  1064 function wp_notify_moderator($comment_id) {
  1094 function wp_notify_moderator($comment_id) {
  1065 	global $wpdb;
  1095 	global $wpdb;
  1066 
  1096 
  1067 	if( get_option( "moderation_notify" ) == 0 )
  1097 	if ( 0 == get_option( 'moderation_notify' ) )
  1068 		return true;
  1098 		return true;
  1069 
  1099 
  1070 	$comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID=%d LIMIT 1", $comment_id));
  1100 	$comment = get_comment($comment_id);
  1071 	$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID=%d LIMIT 1", $comment->comment_post_ID));
  1101 	$post = get_post($comment->comment_post_ID);
       
  1102 	$user = get_userdata( $post->post_author );
       
  1103 	// Send to the administration and to the post author if the author can modify the comment.
       
  1104 	$email_to = array( get_option('admin_email') );
       
  1105 	if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) )
       
  1106 		$email_to[] = $user->user_email;
  1072 
  1107 
  1073 	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
  1108 	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
  1074 	$comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
  1109 	$comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
  1075 	
  1110 
  1076 	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
  1111 	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
  1077 	// we want to reverse this for the plain text arena of emails.
  1112 	// we want to reverse this for the plain text arena of emails.
  1078 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  1113 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  1079 	
  1114 
  1080 	switch ($comment->comment_type)
  1115 	switch ($comment->comment_type)
  1081 	{
  1116 	{
  1082 		case 'trackback':
  1117 		case 'trackback':
  1083 			$notify_message  = sprintf( __('A new trackback on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n";
  1118 			$notify_message  = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
  1084 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
  1119 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
  1085 			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  1120 			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  1086 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  1121 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  1087 			$notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
  1122 			$notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
  1088 			break;
  1123 			break;
  1089 		case 'pingback':
  1124 		case 'pingback':
  1090 			$notify_message  = sprintf( __('A new pingback on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n";
  1125 			$notify_message  = sprintf( __('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
  1091 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
  1126 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
  1092 			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  1127 			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  1093 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  1128 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  1094 			$notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
  1129 			$notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
  1095 			break;
  1130 			break;
  1096 		default: //Comments
  1131 		default: //Comments
  1097 			$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";
  1132 			$notify_message  = sprintf( __('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
  1098 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
  1133 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
  1099 			$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  1134 			$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  1100 			$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
  1135 			$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
  1101 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  1136 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  1102 			$notify_message .= sprintf( __('Whois  : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
  1137 			$notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
  1103 			$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
  1138 			$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
  1104 			break;
  1139 			break;
  1105 	}
  1140 	}
  1106 
  1141 
  1107 	$notify_message .= sprintf( __('Approve it: %s'),  admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n";
  1142 	$notify_message .= sprintf( __('Approve it: %s'),  admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n";
  1114 	$notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
  1149 	$notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
  1115  		'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
  1150  		'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
  1116 	$notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n";
  1151 	$notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n";
  1117 
  1152 
  1118 	$subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title );
  1153 	$subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title );
  1119 	$admin_email = get_option('admin_email');
       
  1120 	$message_headers = '';
  1154 	$message_headers = '';
  1121 
  1155 
  1122 	$notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id);
  1156 	$notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id);
  1123 	$subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
  1157 	$subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
  1124 	$message_headers = apply_filters('comment_moderation_headers', $message_headers);
  1158 	$message_headers = apply_filters('comment_moderation_headers', $message_headers);
  1125 
  1159 
  1126 	@wp_mail($admin_email, $subject, $notify_message, $message_headers);
  1160 	foreach ( $email_to as $email )
       
  1161 		@wp_mail($email, $subject, $notify_message, $message_headers);
  1127 
  1162 
  1128 	return true;
  1163 	return true;
  1129 }
  1164 }
  1130 endif;
  1165 endif;
  1131 
  1166 
  1162 function wp_new_user_notification($user_id, $plaintext_pass = '') {
  1197 function wp_new_user_notification($user_id, $plaintext_pass = '') {
  1163 	$user = new WP_User($user_id);
  1198 	$user = new WP_User($user_id);
  1164 
  1199 
  1165 	$user_login = stripslashes($user->user_login);
  1200 	$user_login = stripslashes($user->user_login);
  1166 	$user_email = stripslashes($user->user_email);
  1201 	$user_email = stripslashes($user->user_email);
  1167 	
  1202 
  1168 	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
  1203 	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
  1169 	// we want to reverse this for the plain text arena of emails.
  1204 	// we want to reverse this for the plain text arena of emails.
  1170 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  1205 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  1171 
  1206 
  1172 	$message  = sprintf(__('New user registration on your blog %s:'), $blogname) . "\r\n\r\n";
  1207 	$message  = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
  1173 	$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
  1208 	$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
  1174 	$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
  1209 	$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
  1175 
  1210 
  1176 	@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
  1211 	@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
  1177 
  1212 
  1218  * @param string|int $action Should give context to what is taking place and be the same when nonce was created.
  1253  * @param string|int $action Should give context to what is taking place and be the same when nonce was created.
  1219  * @return bool Whether the nonce check passed or failed.
  1254  * @return bool Whether the nonce check passed or failed.
  1220  */
  1255  */
  1221 function wp_verify_nonce($nonce, $action = -1) {
  1256 function wp_verify_nonce($nonce, $action = -1) {
  1222 	$user = wp_get_current_user();
  1257 	$user = wp_get_current_user();
  1223 	$uid = (int) $user->id;
  1258 	$uid = (int) $user->ID;
  1224 
  1259 
  1225 	$i = wp_nonce_tick();
  1260 	$i = wp_nonce_tick();
  1226 
  1261 
  1227 	// Nonce generated 0-12 hours ago
  1262 	// Nonce generated 0-12 hours ago
  1228 	if ( substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10) == $nonce )
  1263 	if ( substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10) == $nonce )
  1244  * @param string|int $action Scalar value to add context to the nonce.
  1279  * @param string|int $action Scalar value to add context to the nonce.
  1245  * @return string The one use form token
  1280  * @return string The one use form token
  1246  */
  1281  */
  1247 function wp_create_nonce($action = -1) {
  1282 function wp_create_nonce($action = -1) {
  1248 	$user = wp_get_current_user();
  1283 	$user = wp_get_current_user();
  1249 	$uid = (int) $user->id;
  1284 	$uid = (int) $user->ID;
  1250 
  1285 
  1251 	$i = wp_nonce_tick();
  1286 	$i = wp_nonce_tick();
  1252 
  1287 
  1253 	return substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10);
  1288 	return substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10);
  1254 }
  1289 }
  1255 endif;
  1290 endif;
  1256 
  1291 
  1257 if ( !function_exists('wp_salt') ) :
  1292 if ( !function_exists('wp_salt') ) :
  1258 /**
  1293 /**
  1259  * Get salt to add to hashes to help prevent attacks.
  1294  * Get salt to add to hashes.
  1260  *
  1295  *
  1261  * The secret key is located in two places: the database in case the secret key
  1296  * Salts are created using secret keys. Secret keys are located in two places:
  1262  * isn't defined in the second place, which is in the wp-config.php file. If you
  1297  * in the database and in the wp-config.php file. The secret key in the database
  1263  * are going to set the secret key, then you must do so in the wp-config.php
  1298  * is randomly generated and will be appended to the secret keys in wp-config.php.
  1264  * file.
  1299  *
  1265  *
  1300  * The secret keys in wp-config.php should be updated to strong, random keys to maximize
  1266  * The secret key in the database is randomly generated and will be appended to
  1301  * security. Below is an example of how the secret key constants are defined.
  1267  * the secret key that is in wp-config.php file in some instances. It is
  1302  * Do not paste this example directly into wp-config.php. Instead, have a
  1268  * important to have the secret key defined or changed in wp-config.php.
  1303  * {@link https://api.wordpress.org/secret-key/1.1/salt/ secret key created} just
  1269  *
  1304  * for you.
  1270  * If you have installed WordPress 2.5 or later, then you will have the
       
  1271  * SECRET_KEY defined in the wp-config.php already. You will want to change the
       
  1272  * value in it because hackers will know what it is. If you have upgraded to
       
  1273  * WordPress 2.5 or later version from a version before WordPress 2.5, then you
       
  1274  * should add the constant to your wp-config.php file.
       
  1275  *
       
  1276  * Below is an example of how the SECRET_KEY constant is defined with a value.
       
  1277  * You must not copy the below example and paste into your wp-config.php. If you
       
  1278  * need an example, then you can have a
       
  1279  * {@link https://api.wordpress.org/secret-key/1.1/ secret key created} for you.
       
  1280  *
  1305  *
  1281  * <code>
  1306  * <code>
  1282  * define('SECRET_KEY', 'mAry1HadA15|\/|b17w55w1t3asSn09w');
  1307  * define('AUTH_KEY',         ' Xakm<o xQy rw4EMsLKM-?!T+,PFF})H4lzcW57AF0U@N@< >M%G4Yt>f`z]MON');
       
  1308  * define('SECURE_AUTH_KEY',  'LzJ}op]mr|6+![P}Ak:uNdJCJZd>(Hx.-Mh#Tz)pCIU#uGEnfFz|f ;;eU%/U^O~');
       
  1309  * define('LOGGED_IN_KEY',    '|i|Ux`9<p-h$aFf(qnT:sDO:D1P^wZ$$/Ra@miTJi9G;ddp_<q}6H1)o|a +&JCM');
       
  1310  * define('NONCE_KEY',        '%:R{[P|,s.KuMltH5}cI;/k<Gx~j!f0I)m_sIyu+&NJZ)-iO>z7X>QYR0Z_XnZ@|');
       
  1311  * define('AUTH_SALT',        'eZyT)-Naw]F8CwA*VaW#q*|.)g@o}||wf~@C-YSt}(dh_r6EbI#A,y|nU2{B#JBW');
       
  1312  * define('SECURE_AUTH_SALT', '!=oLUTXh,QW=H `}`L|9/^4-3 STz},T(w}W<I`.JjPi)<Bmf1v,HpGe}T1:Xt7n');
       
  1313  * define('LOGGED_IN_SALT',   '+XSqHc;@Q*K_b|Z?NC[3H!!EONbh.n<+=uKR:>*c(u`g~EJBf#8u#R{mUEZrozmm');
       
  1314  * define('NONCE_SALT',       'h`GXHhD>SLWVfg1(1(N{;.V!MoE(SfbA_ksP@&`+AycHcAV$+?@3q+rxV{%^VyKT');
  1283  * </code>
  1315  * </code>
  1284  *
  1316  *
  1285  * Salting passwords helps against tools which has stored hashed values of
  1317  * Salting passwords helps against tools which has stored hashed values of
  1286  * common dictionary strings. The added values makes it harder to crack if given
  1318  * common dictionary strings. The added values makes it harder to crack.
  1287  * salt string is not weak.
       
  1288  *
  1319  *
  1289  * @since 2.5
  1320  * @since 2.5
  1290  * @link https://api.wordpress.org/secret-key/1.1/ Create a Secret Key for wp-config.php
  1321  *
  1291  *
  1322  * @link https://api.wordpress.org/secret-key/1.1/salt/ Create secrets for wp-config.php
  1292  * @return string Salt value from either 'SECRET_KEY' or 'secret' option
  1323  *
  1293  */
  1324  * @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce)
  1294 function wp_salt($scheme = 'auth') {
  1325  * @return string Salt value
  1295 	global $wp_default_secret_key;
  1326  */
  1296 	$secret_key = '';
  1327 function wp_salt( $scheme = 'auth' ) {
  1297 	if ( defined('SECRET_KEY') && ('' != SECRET_KEY) && ( $wp_default_secret_key != SECRET_KEY) )
  1328 	static $cached_salts = array();
  1298 		$secret_key = SECRET_KEY;
  1329 	if ( isset( $cached_salts[ $scheme ] ) )
  1299 
  1330 		return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme );
  1300 	if ( 'auth' == $scheme ) {
  1331 
  1301 		if ( defined('AUTH_KEY') && ('' != AUTH_KEY) && ( $wp_default_secret_key != AUTH_KEY) )
  1332 	static $duplicated_keys;
  1302 			$secret_key = AUTH_KEY;
  1333 	if ( null === $duplicated_keys ) {
  1303 
  1334 		$duplicated_keys = array( 'put your unique phrase here' => true );
  1304 		if ( defined('AUTH_SALT') ) {
  1335 		foreach ( array( 'AUTH', 'SECURE_AUTH', 'LOGGED_IN', 'NONCE', 'SECRET' ) as $first ) {
  1305 			$salt = AUTH_SALT;
  1336 			foreach ( array( 'KEY', 'SALT' ) as $second ) {
  1306 		} elseif ( defined('SECRET_SALT') ) {
  1337 				if ( ! defined( "{$first}_{$second}" ) )
  1307 			$salt = SECRET_SALT;
  1338 					continue;
  1308 		} else {
  1339 				$value = constant( "{$first}_{$second}" );
  1309 			$salt = get_option('auth_salt');
  1340 				$duplicated_keys[ $value ] = isset( $duplicated_keys[ $value ] );
  1310 			if ( empty($salt) ) {
       
  1311 				$salt = wp_generate_password(64);
       
  1312 				update_option('auth_salt', $salt);
       
  1313 			}
  1341 			}
  1314 		}
  1342 		}
  1315 	} elseif ( 'secure_auth' == $scheme ) {
  1343 	}
  1316 		if ( defined('SECURE_AUTH_KEY') && ('' != SECURE_AUTH_KEY) && ( $wp_default_secret_key != SECURE_AUTH_KEY) )
  1344 
  1317 			$secret_key = SECURE_AUTH_KEY;
  1345 	$key = $salt = '';
  1318 
  1346 	if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) )
  1319 		if ( defined('SECURE_AUTH_SALT') ) {
  1347 		$key = SECRET_KEY;
  1320 			$salt = SECURE_AUTH_SALT;
  1348 	if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) )
  1321 		} else {
  1349 		$salt = SECRET_SALT;
  1322 			$salt = get_option('secure_auth_salt');
  1350 
  1323 			if ( empty($salt) ) {
  1351 	if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ) ) ) {
  1324 				$salt = wp_generate_password(64);
  1352 		foreach ( array( 'key', 'salt' ) as $type ) {
  1325 				update_option('secure_auth_salt', $salt);
  1353 			$const = strtoupper( "{$scheme}_{$type}" );
  1326 			}
  1354 			if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) {
  1327 		}
  1355 				$$type = constant( $const );
  1328 	} elseif ( 'logged_in' == $scheme ) {
  1356 			} elseif ( ! $$type ) {
  1329 		if ( defined('LOGGED_IN_KEY') && ('' != LOGGED_IN_KEY) && ( $wp_default_secret_key != LOGGED_IN_KEY) )
  1357 				$$type = get_site_option( "{$scheme}_{$type}" );
  1330 			$secret_key = LOGGED_IN_KEY;
  1358 				if ( ! $$type ) {
  1331 
  1359 					$$type = wp_generate_password( 64, true, true );
  1332 		if ( defined('LOGGED_IN_SALT') ) {
  1360 					update_site_option( "{$scheme}_{$type}", $$type );
  1333 			$salt = LOGGED_IN_SALT;
  1361 				}
  1334 		} else {
       
  1335 			$salt = get_option('logged_in_salt');
       
  1336 			if ( empty($salt) ) {
       
  1337 				$salt = wp_generate_password(64);
       
  1338 				update_option('logged_in_salt', $salt);
       
  1339 			}
       
  1340 		}
       
  1341 	} elseif ( 'nonce' == $scheme ) {
       
  1342 		if ( defined('NONCE_KEY') && ('' != NONCE_KEY) && ( $wp_default_secret_key != NONCE_KEY) )
       
  1343 			$secret_key = NONCE_KEY;
       
  1344 
       
  1345 		if ( defined('NONCE_SALT') ) {
       
  1346 			$salt = NONCE_SALT;
       
  1347 		} else {
       
  1348 			$salt = get_option('nonce_salt');
       
  1349 			if ( empty($salt) ) {
       
  1350 				$salt = wp_generate_password(64);
       
  1351 				update_option('nonce_salt', $salt);
       
  1352 			}
  1362 			}
  1353 		}
  1363 		}
  1354 	} else {
  1364 	} else {
  1355 		// ensure each auth scheme has its own unique salt
  1365 		if ( ! $key ) {
  1356 		$salt = hash_hmac('md5', $scheme, $secret_key);
  1366 			$key = get_site_option( 'secret_key' );
  1357 	}
  1367 			if ( ! $key ) {
  1358 
  1368 				$key = wp_generate_password( 64, true, true );
  1359 	return apply_filters('salt', $secret_key . $salt, $scheme);
  1369 				update_site_option( 'secret_key', $key );
       
  1370 			}
       
  1371 		}
       
  1372 		$salt = hash_hmac( 'md5', $scheme, $key );
       
  1373 	}
       
  1374 
       
  1375 	$cached_salts[ $scheme ] = $key . $salt;
       
  1376 	return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme );
  1360 }
  1377 }
  1361 endif;
  1378 endif;
  1362 
  1379 
  1363 if ( !function_exists('wp_hash') ) :
  1380 if ( !function_exists('wp_hash') ) :
  1364 /**
  1381 /**
  1395 	global $wp_hasher;
  1412 	global $wp_hasher;
  1396 
  1413 
  1397 	if ( empty($wp_hasher) ) {
  1414 	if ( empty($wp_hasher) ) {
  1398 		require_once( ABSPATH . 'wp-includes/class-phpass.php');
  1415 		require_once( ABSPATH . 'wp-includes/class-phpass.php');
  1399 		// By default, use the portable hash from phpass
  1416 		// By default, use the portable hash from phpass
  1400 		$wp_hasher = new PasswordHash(8, TRUE);
  1417 		$wp_hasher = new PasswordHash(8, true);
  1401 	}
  1418 	}
  1402 
  1419 
  1403 	return $wp_hasher->HashPassword($password);
  1420 	return $wp_hasher->HashPassword($password);
  1404 }
  1421 }
  1405 endif;
  1422 endif;
  1408 /**
  1425 /**
  1409  * Checks the plaintext password against the encrypted Password.
  1426  * Checks the plaintext password against the encrypted Password.
  1410  *
  1427  *
  1411  * Maintains compatibility between old version and the new cookie authentication
  1428  * Maintains compatibility between old version and the new cookie authentication
  1412  * protocol using PHPass library. The $hash parameter is the encrypted password
  1429  * protocol using PHPass library. The $hash parameter is the encrypted password
  1413  * and the function compares the plain text password when encypted similarly
  1430  * and the function compares the plain text password when encrypted similarly
  1414  * against the already encrypted password to see if they match.
  1431  * against the already encrypted password to see if they match.
  1415  *
  1432  *
  1416  * For integration with other applications, this function can be overwritten to
  1433  * For integration with other applications, this function can be overwritten to
  1417  * instead use the other package password checking algorithm.
  1434  * instead use the other package password checking algorithm.
  1418  *
  1435  *
  1443 	// If the stored hash is longer than an MD5, presume the
  1460 	// If the stored hash is longer than an MD5, presume the
  1444 	// new style phpass portable hash.
  1461 	// new style phpass portable hash.
  1445 	if ( empty($wp_hasher) ) {
  1462 	if ( empty($wp_hasher) ) {
  1446 		require_once( ABSPATH . 'wp-includes/class-phpass.php');
  1463 		require_once( ABSPATH . 'wp-includes/class-phpass.php');
  1447 		// By default, use the portable hash from phpass
  1464 		// By default, use the portable hash from phpass
  1448 		$wp_hasher = new PasswordHash(8, TRUE);
  1465 		$wp_hasher = new PasswordHash(8, true);
  1449 	}
  1466 	}
  1450 
  1467 
  1451 	$check = $wp_hasher->CheckPassword($password, $hash);
  1468 	$check = $wp_hasher->CheckPassword($password, $hash);
  1452 
  1469 
  1453 	return apply_filters('check_password', $check, $password, $hash, $user_id);
  1470 	return apply_filters('check_password', $check, $password, $hash, $user_id);
  1459  * Generates a random password drawn from the defined set of characters.
  1476  * Generates a random password drawn from the defined set of characters.
  1460  *
  1477  *
  1461  * @since 2.5
  1478  * @since 2.5
  1462  *
  1479  *
  1463  * @param int $length The length of password to generate
  1480  * @param int $length The length of password to generate
  1464  * @param bool $special_chars Whether to include standard special characters
  1481  * @param bool $special_chars Whether to include standard special characters. Default true.
       
  1482  * @param bool $extra_special_chars Whether to include other special characters. Used when
       
  1483  *   generating secret keys and salts. Default false.
  1465  * @return string The random password
  1484  * @return string The random password
  1466  **/
  1485  **/
  1467 function wp_generate_password($length = 12, $special_chars = true) {
  1486 function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) {
  1468 	$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  1487 	$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  1469 	if ( $special_chars )
  1488 	if ( $special_chars )
  1470 		$chars .= '!@#$%^&*()';
  1489 		$chars .= '!@#$%^&*()';
       
  1490 	if ( $extra_special_chars )
       
  1491 		$chars .= '-_ []{}<>~`+=,.;:/?|';
  1471 
  1492 
  1472 	$password = '';
  1493 	$password = '';
  1473 	for ( $i = 0; $i < $length; $i++ )
  1494 	for ( $i = 0; $i < $length; $i++ ) {
  1474 		$password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
  1495 		$password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
  1475 	return $password;
  1496 	}
       
  1497 
       
  1498 	// random_password filter was previously in random_password function which was deprecated
       
  1499 	return apply_filters('random_password', $password);
  1476 }
  1500 }
  1477 endif;
  1501 endif;
  1478 
  1502 
  1479 if ( !function_exists('wp_rand') ) :
  1503 if ( !function_exists('wp_rand') ) :
  1480  /**
  1504  /**
  1487  * @return int A random number between min and max
  1511  * @return int A random number between min and max
  1488  */
  1512  */
  1489 function wp_rand( $min = 0, $max = 0 ) {
  1513 function wp_rand( $min = 0, $max = 0 ) {
  1490 	global $rnd_value;
  1514 	global $rnd_value;
  1491 
  1515 
  1492 	$seed = get_transient('random_seed');
       
  1493 
       
  1494 	// Reset $rnd_value after 14 uses
  1516 	// Reset $rnd_value after 14 uses
  1495 	// 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value
  1517 	// 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value
  1496 	if ( strlen($rnd_value) < 8 ) {
  1518 	if ( strlen($rnd_value) < 8 ) {
       
  1519 		if ( defined( 'WP_SETUP_CONFIG' ) )
       
  1520 			static $seed = '';
       
  1521 		else
       
  1522 			$seed = get_transient('random_seed');
  1497 		$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
  1523 		$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
  1498 		$rnd_value .= sha1($rnd_value);
  1524 		$rnd_value .= sha1($rnd_value);
  1499 		$rnd_value .= sha1($rnd_value . $seed);
  1525 		$rnd_value .= sha1($rnd_value . $seed);
  1500 		$seed = md5($seed . $rnd_value);
  1526 		$seed = md5($seed . $rnd_value);
  1501 		set_transient('random_seed', $seed);
  1527 		if ( ! defined( 'WP_SETUP_CONFIG' ) )
       
  1528 			set_transient('random_seed', $seed);
  1502 	}
  1529 	}
  1503 
  1530 
  1504 	// Take the first 8 digits for our value
  1531 	// Take the first 8 digits for our value
  1505 	$value = substr($rnd_value, 0, 8);
  1532 	$value = substr($rnd_value, 0, 8);
  1506 
  1533 
  1570 		$id = (int) $id_or_email;
  1597 		$id = (int) $id_or_email;
  1571 		$user = get_userdata($id);
  1598 		$user = get_userdata($id);
  1572 		if ( $user )
  1599 		if ( $user )
  1573 			$email = $user->user_email;
  1600 			$email = $user->user_email;
  1574 	} elseif ( is_object($id_or_email) ) {
  1601 	} elseif ( is_object($id_or_email) ) {
  1575 		if ( isset($id_or_email->comment_type) && '' != $id_or_email->comment_type && 'comment' != $id_or_email->comment_type )
  1602 		// No avatar for pingbacks or trackbacks
  1576 			return false; // No avatar for pingbacks or trackbacks
  1603 		$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
       
  1604 		if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) )
       
  1605 			return false;
  1577 
  1606 
  1578 		if ( !empty($id_or_email->user_id) ) {
  1607 		if ( !empty($id_or_email->user_id) ) {
  1579 			$id = (int) $id_or_email->user_id;
  1608 			$id = (int) $id_or_email->user_id;
  1580 			$user = get_userdata($id);
  1609 			$user = get_userdata($id);
  1581 			if ( $user)
  1610 			if ( $user)
  1593 			$default = 'mystery';
  1622 			$default = 'mystery';
  1594 		else
  1623 		else
  1595 			$default = $avatar_default;
  1624 			$default = $avatar_default;
  1596 	}
  1625 	}
  1597 
  1626 
  1598  	if ( is_ssl() )
  1627 	if ( !empty($email) )
       
  1628 		$email_hash = md5( strtolower( trim( $email ) ) );
       
  1629 
       
  1630 	if ( is_ssl() ) {
  1599 		$host = 'https://secure.gravatar.com';
  1631 		$host = 'https://secure.gravatar.com';
  1600 	else
  1632 	} else {
  1601 		$host = 'http://www.gravatar.com';
  1633 		if ( !empty($email) )
       
  1634 			$host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash[0] ) % 2 ) );
       
  1635 		else
       
  1636 			$host = 'http://0.gravatar.com';
       
  1637 	}
  1602 
  1638 
  1603 	if ( 'mystery' == $default )
  1639 	if ( 'mystery' == $default )
  1604 		$default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
  1640 		$default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
  1605 	elseif ( 'blank' == $default )
  1641 	elseif ( 'blank' == $default )
  1606 		$default = includes_url('images/blank.gif');
  1642 		$default = includes_url('images/blank.gif');
  1607 	elseif ( !empty($email) && 'gravatar_default' == $default )
  1643 	elseif ( !empty($email) && 'gravatar_default' == $default )
  1608 		$default = '';
  1644 		$default = '';
  1609 	elseif ( 'gravatar_default' == $default )
  1645 	elseif ( 'gravatar_default' == $default )
  1610 		$default = "$host/avatar/s={$size}";
  1646 		$default = "$host/avatar/?s={$size}";
  1611 	elseif ( empty($email) )
  1647 	elseif ( empty($email) )
  1612 		$default = "$host/avatar/?d=$default&amp;s={$size}";
  1648 		$default = "$host/avatar/?d=$default&amp;s={$size}";
  1613 	elseif ( strpos($default, 'http://') === 0 )
  1649 	elseif ( strpos($default, 'http://') === 0 )
  1614 		$default = add_query_arg( 's', $size, $default );
  1650 		$default = add_query_arg( 's', $size, $default );
  1615 
  1651 
  1616 	if ( !empty($email) ) {
  1652 	if ( !empty($email) ) {
  1617 		$out = "$host/avatar/";
  1653 		$out = "$host/avatar/";
  1618 		$out .= md5( strtolower( $email ) );
  1654 		$out .= $email_hash;
  1619 		$out .= '?s='.$size;
  1655 		$out .= '?s='.$size;
  1620 		$out .= '&amp;d=' . urlencode( $default );
  1656 		$out .= '&amp;d=' . urlencode( $default );
  1621 
  1657 
  1622 		$rating = get_option('avatar_rating');
  1658 		$rating = get_option('avatar_rating');
  1623 		if ( !empty( $rating ) )
  1659 		if ( !empty( $rating ) )
  1627 	} else {
  1663 	} else {
  1628 		$avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
  1664 		$avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
  1629 	}
  1665 	}
  1630 
  1666 
  1631 	return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
  1667 	return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
  1632 }
       
  1633 endif;
       
  1634 
       
  1635 if ( !function_exists('wp_setcookie') ) :
       
  1636 /**
       
  1637  * Sets a cookie for a user who just logged in.
       
  1638  *
       
  1639  * @since 1.5
       
  1640  * @deprecated Use wp_set_auth_cookie()
       
  1641  * @see wp_set_auth_cookie()
       
  1642  *
       
  1643  * @param string  $username The user's username
       
  1644  * @param string  $password Optional. The user's password
       
  1645  * @param bool $already_md5 Optional. Whether the password has already been through MD5
       
  1646  * @param string $home Optional. Will be used instead of COOKIEPATH if set
       
  1647  * @param string $siteurl Optional. Will be used instead of SITECOOKIEPATH if set
       
  1648  * @param bool $remember Optional. Remember that the user is logged in
       
  1649  */
       
  1650 function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
       
  1651 	_deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' );
       
  1652 	$user = get_userdatabylogin($username);
       
  1653 	wp_set_auth_cookie($user->ID, $remember);
       
  1654 }
       
  1655 endif;
       
  1656 
       
  1657 if ( !function_exists('wp_clearcookie') ) :
       
  1658 /**
       
  1659  * Clears the authentication cookie, logging the user out.
       
  1660  *
       
  1661  * @since 1.5
       
  1662  * @deprecated Use wp_clear_auth_cookie()
       
  1663  * @see wp_clear_auth_cookie()
       
  1664  */
       
  1665 function wp_clearcookie() {
       
  1666 	_deprecated_function( __FUNCTION__, '2.5', 'wp_clear_auth_cookie()' );
       
  1667 	wp_clear_auth_cookie();
       
  1668 }
       
  1669 endif;
       
  1670 
       
  1671 if ( !function_exists('wp_get_cookie_login') ):
       
  1672 /**
       
  1673  * Gets the user cookie login.
       
  1674  *
       
  1675  * This function is deprecated and should no longer be extended as it won't be
       
  1676  * used anywhere in WordPress. Also, plugins shouldn't use it either.
       
  1677  *
       
  1678  * @since 2.0.3
       
  1679  * @deprecated No alternative
       
  1680  *
       
  1681  * @return bool Always returns false
       
  1682  */
       
  1683 function wp_get_cookie_login() {
       
  1684 	_deprecated_function( __FUNCTION__, '2.5', '' );
       
  1685 	return false;
       
  1686 }
       
  1687 endif;
       
  1688 
       
  1689 if ( !function_exists('wp_login') ) :
       
  1690 /**
       
  1691  * Checks a users login information and logs them in if it checks out.
       
  1692  *
       
  1693  * Use the global $error to get the reason why the login failed. If the username
       
  1694  * is blank, no error will be set, so assume blank username on that case.
       
  1695  *
       
  1696  * Plugins extending this function should also provide the global $error and set
       
  1697  * what the error is, so that those checking the global for why there was a
       
  1698  * failure can utilize it later.
       
  1699  *
       
  1700  * @since 1.2.2
       
  1701  * @deprecated Use wp_signon()
       
  1702  * @global string $error Error when false is returned
       
  1703  *
       
  1704  * @param string $username User's username
       
  1705  * @param string $password User's password
       
  1706  * @param bool $deprecated Not used
       
  1707  * @return bool False on login failure, true on successful check
       
  1708  */
       
  1709 function wp_login($username, $password, $deprecated = '') {
       
  1710 	global $error;
       
  1711 
       
  1712 	$user = wp_authenticate($username, $password);
       
  1713 
       
  1714 	if ( ! is_wp_error($user) )
       
  1715 		return true;
       
  1716 
       
  1717 	$error = $user->get_error_message();
       
  1718 	return false;
       
  1719 }
  1668 }
  1720 endif;
  1669 endif;
  1721 
  1670 
  1722 if ( !function_exists( 'wp_text_diff' ) ) :
  1671 if ( !function_exists( 'wp_text_diff' ) ) :
  1723 /**
  1672 /**
  1754 		require( ABSPATH . WPINC . '/wp-diff.php' );
  1703 		require( ABSPATH . WPINC . '/wp-diff.php' );
  1755 
  1704 
  1756 	$left_string  = normalize_whitespace($left_string);
  1705 	$left_string  = normalize_whitespace($left_string);
  1757 	$right_string = normalize_whitespace($right_string);
  1706 	$right_string = normalize_whitespace($right_string);
  1758 
  1707 
  1759 	$left_lines  = split("\n", $left_string);
  1708 	$left_lines  = explode("\n", $left_string);
  1760 	$right_lines = split("\n", $right_string);
  1709 	$right_lines = explode("\n", $right_string);
  1761 
  1710 
  1762 	$text_diff = new Text_Diff($left_lines, $right_lines);
  1711 	$text_diff = new Text_Diff($left_lines, $right_lines);
  1763 	$renderer  = new WP_Text_Diff_Renderer_Table();
  1712 	$renderer  = new WP_Text_Diff_Renderer_Table();
  1764 	$diff = $renderer->render($text_diff);
  1713 	$diff = $renderer->render($text_diff);
  1765 
  1714 
  1786 	$r .= "</table>";
  1735 	$r .= "</table>";
  1787 
  1736 
  1788 	return $r;
  1737 	return $r;
  1789 }
  1738 }
  1790 endif;
  1739 endif;
  1791