537 if ( $hmac != $hash ) { |
537 if ( $hmac != $hash ) { |
538 do_action('auth_cookie_bad_hash', $cookie_elements); |
538 do_action('auth_cookie_bad_hash', $cookie_elements); |
539 return false; |
539 return false; |
540 } |
540 } |
541 |
541 |
|
542 if ( $expiration < time() ) // AJAX/POST grace period set above |
|
543 $GLOBALS['login_grace_period'] = 1; |
|
544 |
542 do_action('auth_cookie_valid', $cookie_elements, $user); |
545 do_action('auth_cookie_valid', $cookie_elements, $user); |
543 |
546 |
544 return $user->ID; |
547 return $user->ID; |
545 } |
548 } |
546 endif; |
549 endif; |
748 wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
751 wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
749 exit(); |
752 exit(); |
750 } |
753 } |
751 } |
754 } |
752 |
755 |
753 if ( $user_id = wp_validate_auth_cookie() ) { |
756 if ( $user_id = wp_validate_auth_cookie( '', apply_filters( 'auth_redirect_scheme', '' ) ) ) { |
754 do_action('auth_redirect', $user_id); |
757 do_action('auth_redirect', $user_id); |
755 |
758 |
756 // If the user wants ssl but the session is not ssl, redirect. |
759 // If the user wants ssl but the session is not ssl, redirect. |
757 if ( !$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) { |
760 if ( !$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) { |
758 if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) { |
761 if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) { |
819 */ |
822 */ |
820 function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) { |
823 function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) { |
821 if ( $query_arg ) |
824 if ( $query_arg ) |
822 $nonce = $_REQUEST[$query_arg]; |
825 $nonce = $_REQUEST[$query_arg]; |
823 else |
826 else |
824 $nonce = $_REQUEST['_ajax_nonce'] ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce']; |
827 $nonce = isset($_REQUEST['_ajax_nonce']) ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce']; |
825 |
828 |
826 $result = wp_verify_nonce( $nonce, $action ); |
829 $result = wp_verify_nonce( $nonce, $action ); |
827 |
830 |
828 if ( $die && false == $result ) |
831 if ( $die && false == $result ) |
829 die('-1'); |
832 die('-1'); |
860 if ( $is_IIS ) { |
863 if ( $is_IIS ) { |
861 header("Refresh: 0;url=$location"); |
864 header("Refresh: 0;url=$location"); |
862 } else { |
865 } else { |
863 if ( php_sapi_name() != 'cgi-fcgi' ) |
866 if ( php_sapi_name() != 'cgi-fcgi' ) |
864 status_header($status); // This causes problems on IIS and some FastCGI setups |
867 status_header($status); // This causes problems on IIS and some FastCGI setups |
865 header("Location: $location"); |
868 header("Location: $location", true, $status); |
866 } |
869 } |
867 } |
870 } |
868 endif; |
871 endif; |
869 |
872 |
870 if ( !function_exists('wp_sanitize_redirect') ) : |
873 if ( !function_exists('wp_sanitize_redirect') ) : |
971 if ( $comment->user_id == $post->post_author ) return false; // The author moderated a comment on his own post |
974 if ( $comment->user_id == $post->post_author ) return false; // The author moderated a comment on his own post |
972 |
975 |
973 if ('' == $user->user_email) return false; // If there's no email to send the comment to |
976 if ('' == $user->user_email) return false; // If there's no email to send the comment to |
974 |
977 |
975 $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); |
978 $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); |
976 |
979 |
977 $blogname = get_option('blogname'); |
980 // 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. |
|
982 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
978 |
983 |
979 if ( empty( $comment_type ) ) $comment_type = 'comment'; |
984 if ( empty( $comment_type ) ) $comment_type = 'comment'; |
980 |
985 |
981 if ('comment' == $comment_type) { |
986 if ('comment' == $comment_type) { |
982 /* translators: 1: post id, 2: post title */ |
987 /* translators: 1: post id, 2: post title */ |
996 /* translators: 1: website name, 2: author IP, 3: author domain */ |
1001 /* translators: 1: website name, 2: author IP, 3: author domain */ |
997 $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
1002 $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
998 $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; |
1003 $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; |
999 $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
1004 $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
1000 $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n"; |
1005 $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n"; |
1001 /* translators: 1: blog name, 2: post title */ |
1006 /* translators: 1: blog name, 2: post title */ |
1002 $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title ); |
1007 $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title ); |
1003 } elseif ('pingback' == $comment_type) { |
1008 } elseif ('pingback' == $comment_type) { |
1004 /* translators: 1: post id, 2: post title */ |
1009 /* translators: 1: post id, 2: post title */ |
1005 $notify_message = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $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"; |
1006 /* translators: 1: comment author, 2: author IP, 3: author domain */ |
1011 /* translators: 1: comment author, 2: author IP, 3: author domain */ |
1010 $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n"; |
1015 $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n"; |
1011 /* translators: 1: blog name, 2: post title */ |
1016 /* translators: 1: blog name, 2: post title */ |
1012 $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title ); |
1017 $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title ); |
1013 } |
1018 } |
1014 $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n"; |
1019 $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n"; |
1015 $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=cdc&c=$comment_id") ) . "\r\n"; |
1020 if ( EMPTY_TRASH_DAYS ) |
1016 $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=cdc&dt=spam&c=$comment_id") ) . "\r\n"; |
1021 $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n"; |
|
1022 else |
|
1023 $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"; |
1017 |
1025 |
1018 $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); |
1026 $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); |
1019 |
1027 |
1020 if ( '' == $comment->comment_author ) { |
1028 if ( '' == $comment->comment_author ) { |
1021 $from = "From: \"$blogname\" <$wp_email>"; |
1029 $from = "From: \"$blogname\" <$wp_email>"; |
1062 $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID=%d LIMIT 1", $comment_id)); |
1070 $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID=%d LIMIT 1", $comment_id)); |
1063 $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID=%d LIMIT 1", $comment->comment_post_ID)); |
1071 $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID=%d LIMIT 1", $comment->comment_post_ID)); |
1064 |
1072 |
1065 $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); |
1073 $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); |
1066 $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); |
1074 $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); |
1067 |
1075 |
|
1076 // 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. |
|
1078 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
1079 |
1068 switch ($comment->comment_type) |
1080 switch ($comment->comment_type) |
1069 { |
1081 { |
1070 case 'trackback': |
1082 case 'trackback': |
1071 $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"; |
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"; |
1072 $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; |
1084 $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; |
1090 $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; |
1102 $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; |
1091 $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
1103 $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
1092 break; |
1104 break; |
1093 } |
1105 } |
1094 |
1106 |
1095 $notify_message .= sprintf( __('Approve it: %s'), admin_url("comment.php?action=mac&c=$comment_id") ) . "\r\n"; |
1107 $notify_message .= sprintf( __('Approve it: %s'), admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n"; |
1096 $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=cdc&c=$comment_id") ) . "\r\n"; |
1108 if ( EMPTY_TRASH_DAYS ) |
1097 $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=cdc&dt=spam&c=$comment_id") ) . "\r\n"; |
1109 $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n"; |
|
1110 else |
|
1111 $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n"; |
|
1112 $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n"; |
1098 |
1113 |
1099 $notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:', |
1114 $notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:', |
1100 'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n"; |
1115 'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n"; |
1101 $notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n"; |
1116 $notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n"; |
1102 |
1117 |
1103 $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_option('blogname'), $post->post_title ); |
1118 $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title ); |
1104 $admin_email = get_option('admin_email'); |
1119 $admin_email = get_option('admin_email'); |
1105 $message_headers = ''; |
1120 $message_headers = ''; |
1106 |
1121 |
1107 $notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id); |
1122 $notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id); |
1108 $subject = apply_filters('comment_moderation_subject', $subject, $comment_id); |
1123 $subject = apply_filters('comment_moderation_subject', $subject, $comment_id); |
1125 function wp_password_change_notification(&$user) { |
1140 function wp_password_change_notification(&$user) { |
1126 // send a copy of password change notification to the admin |
1141 // send a copy of password change notification to the admin |
1127 // but check to see if it's the admin whose password we're changing, and skip this |
1142 // but check to see if it's the admin whose password we're changing, and skip this |
1128 if ( $user->user_email != get_option('admin_email') ) { |
1143 if ( $user->user_email != get_option('admin_email') ) { |
1129 $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n"; |
1144 $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n"; |
1130 wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), get_option('blogname')), $message); |
1145 // The blogname option is escaped with esc_html on the way into the database in sanitize_option |
|
1146 // we want to reverse this for the plain text arena of emails. |
|
1147 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
1148 wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message); |
1131 } |
1149 } |
1132 } |
1150 } |
1133 endif; |
1151 endif; |
1134 |
1152 |
1135 if ( !function_exists('wp_new_user_notification') ) : |
1153 if ( !function_exists('wp_new_user_notification') ) : |
1144 function wp_new_user_notification($user_id, $plaintext_pass = '') { |
1162 function wp_new_user_notification($user_id, $plaintext_pass = '') { |
1145 $user = new WP_User($user_id); |
1163 $user = new WP_User($user_id); |
1146 |
1164 |
1147 $user_login = stripslashes($user->user_login); |
1165 $user_login = stripslashes($user->user_login); |
1148 $user_email = stripslashes($user->user_email); |
1166 $user_email = stripslashes($user->user_email); |
1149 |
1167 |
1150 $message = sprintf(__('New user registration on your blog %s:'), get_option('blogname')) . "\r\n\r\n"; |
1168 // 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. |
|
1170 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
1171 |
|
1172 $message = sprintf(__('New user registration on your blog %s:'), $blogname) . "\r\n\r\n"; |
1151 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; |
1173 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; |
1152 $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; |
1174 $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; |
1153 |
1175 |
1154 @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message); |
1176 @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message); |
1155 |
1177 |
1156 if ( empty($plaintext_pass) ) |
1178 if ( empty($plaintext_pass) ) |
1157 return; |
1179 return; |
1158 |
1180 |
1159 $message = sprintf(__('Username: %s'), $user_login) . "\r\n"; |
1181 $message = sprintf(__('Username: %s'), $user_login) . "\r\n"; |
1160 $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; |
1182 $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; |
1161 $message .= wp_login_url() . "\r\n"; |
1183 $message .= wp_login_url() . "\r\n"; |
1162 |
1184 |
1163 wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message); |
1185 wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message); |
1164 |
1186 |
1165 } |
1187 } |
1166 endif; |
1188 endif; |
1167 |
1189 |
1168 if ( !function_exists('wp_nonce_tick') ) : |
1190 if ( !function_exists('wp_nonce_tick') ) : |