| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
plugins are loaded. */ |
|---|
| 5 |
|
|---|
| 6 |
if ( !function_exists('set_current_user') ) : |
|---|
| 7 |
function set_current_user($id, $name = '') { |
|---|
| 8 |
global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user; |
|---|
| 9 |
|
|---|
| 10 |
$current_user = ''; |
|---|
| 11 |
|
|---|
| 12 |
$current_user = new WP_User($id, $name); |
|---|
| 13 |
|
|---|
| 14 |
$userdata = get_userdatabylogin($user_login); |
|---|
| 15 |
|
|---|
| 16 |
$user_login = $userdata->user_login; |
|---|
| 17 |
$user_level = $userdata->user_level; |
|---|
| 18 |
$user_ID = $userdata->ID; |
|---|
| 19 |
$user_email = $userdata->user_email; |
|---|
| 20 |
$user_url = $userdata->user_url; |
|---|
| 21 |
$user_pass_md5 = md5($userdata->user_pass); |
|---|
| 22 |
$user_identity = $userdata->display_name; |
|---|
| 23 |
|
|---|
| 24 |
do_action('set_current_user'); |
|---|
| 25 |
|
|---|
| 26 |
return $current_user; |
|---|
| 27 |
} |
|---|
| 28 |
endif; |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
if ( !function_exists('get_currentuserinfo') ) : |
|---|
| 32 |
function get_currentuserinfo() { |
|---|
| 33 |
global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user; |
|---|
| 34 |
|
|---|
| 35 |
if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) |
|---|
| 36 |
return false; |
|---|
| 37 |
|
|---|
| 38 |
if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) || |
|---|
| 39 |
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) { |
|---|
| 40 |
$current_user = new WP_User(0); |
|---|
| 41 |
return false; |
|---|
| 42 |
} |
|---|
| 43 |
$user_login = $_COOKIE[USER_COOKIE]; |
|---|
| 44 |
$userdata = get_userdatabylogin($user_login); |
|---|
| 45 |
$user_level = $userdata->user_level; |
|---|
| 46 |
$user_ID = $userdata->ID; |
|---|
| 47 |
$user_email = $userdata->user_email; |
|---|
| 48 |
$user_url = $userdata->user_url; |
|---|
| 49 |
$user_pass_md5 = md5($userdata->user_pass); |
|---|
| 50 |
$user_identity = $userdata->display_name; |
|---|
| 51 |
|
|---|
| 52 |
if ( empty($current_user) ) |
|---|
| 53 |
$current_user = new WP_User($user_ID); |
|---|
| 54 |
} |
|---|
| 55 |
endif; |
|---|
| 56 |
|
|---|
| 57 |
if ( !function_exists('get_userdata') ) : |
|---|
| 58 |
function get_userdata( $user_id ) { |
|---|
| 59 |
global $wpdb; |
|---|
| 60 |
global $blog; |
|---|
| 61 |
$user_id = (int) $user_id; |
|---|
| 62 |
if ( $user_id == 0 ) |
|---|
| 63 |
return false; |
|---|
| 64 |
|
|---|
| 65 |
$user = wp_cache_get($user_id, 'users'); |
|---|
| 66 |
|
|---|
| 67 |
if ( $user ) |
|---|
| 68 |
return $user; |
|---|
| 69 |
|
|---|
| 70 |
if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$user_id' LIMIT 1") ) |
|---|
| 71 |
return false; |
|---|
| 72 |
|
|---|
| 73 |
$wpdb->hide_errors(); |
|---|
| 74 |
$blog_metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE blog = '$blog' AND user_id = '$user_id'"); |
|---|
| 75 |
$Lyceum_metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE meta_domain = 'system' AND user_id = '$user_id'"); |
|---|
| 76 |
|
|---|
| 77 |
arrayify($Lyceum_metavalues); |
|---|
| 78 |
arrayify($blog_metavalues); |
|---|
| 79 |
$metavalues = array_merge($blog_metavalues, $Lyceum_metavalues); |
|---|
| 80 |
$wpdb->show_errors(); |
|---|
| 81 |
|
|---|
| 82 |
if ($metavalues) { |
|---|
| 83 |
foreach ( $metavalues as $meta ) { |
|---|
| 84 |
@ $value = unserialize($meta->meta_value); |
|---|
| 85 |
if ($value === FALSE) |
|---|
| 86 |
$value = $meta->meta_value; |
|---|
| 87 |
$user->{$meta->meta_key} = $value; |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) |
|---|
| 91 |
$user->user_level = $meta->meta_value; |
|---|
| 92 |
} |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
// For backwards compat. |
|---|
| 96 |
if ( isset($user->first_name) ) |
|---|
| 97 |
$user->user_firstname = $user->first_name; |
|---|
| 98 |
if ( isset($user->last_name) ) |
|---|
| 99 |
$user->user_lastname = $user->last_name; |
|---|
| 100 |
if ( isset($user->description) ) |
|---|
| 101 |
$user->user_description = $user->description; |
|---|
| 102 |
|
|---|
| 103 |
wp_cache_add($user_id, $user, 'users'); |
|---|
| 104 |
wp_cache_add($user->user_login, $user, 'userlogins'); |
|---|
| 105 |
|
|---|
| 106 |
return $user; |
|---|
| 107 |
} |
|---|
| 108 |
endif; |
|---|
| 109 |
|
|---|
| 110 |
if ( !function_exists('update_user_cache') ) : |
|---|
| 111 |
function update_user_cache() { |
|---|
| 112 |
return true; |
|---|
| 113 |
} |
|---|
| 114 |
endif; |
|---|
| 115 |
|
|---|
| 116 |
if ( !function_exists('get_userdatabylogin') ) : |
|---|
| 117 |
function get_userdatabylogin($user_login) { |
|---|
| 118 |
global $wpdb; |
|---|
| 119 |
global $blog; |
|---|
| 120 |
$user_login = sanitize_user( $user_login ); |
|---|
| 121 |
|
|---|
| 122 |
if ( empty( $user_login ) ) |
|---|
| 123 |
return false; |
|---|
| 124 |
|
|---|
| 125 |
$userdata = wp_cache_get($user_login, 'userlogins'); |
|---|
| 126 |
if ( $userdata ) |
|---|
| 127 |
return $userdata; |
|---|
| 128 |
|
|---|
| 129 |
if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") ) |
|---|
| 130 |
return false; |
|---|
| 131 |
|
|---|
| 132 |
$wpdb->hide_errors(); |
|---|
| 133 |
$metavalues = get_metavalues($user->ID); |
|---|
| 134 |
$wpdb->show_errors(); |
|---|
| 135 |
|
|---|
| 136 |
if ($metavalues) { |
|---|
| 137 |
foreach ( $metavalues as $meta ) { |
|---|
| 138 |
@ $value = unserialize($meta->meta_value); |
|---|
| 139 |
if ($value === FALSE) |
|---|
| 140 |
$value = $meta->meta_value; |
|---|
| 141 |
$user->{$meta->meta_key} = $value; |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) |
|---|
| 145 |
$user->user_level = $meta->meta_value; |
|---|
| 146 |
} |
|---|
| 147 |
} |
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
if ( isset($user->first_name) ) |
|---|
| 151 |
$user->user_firstname = $user->first_name; |
|---|
| 152 |
if ( isset($user->last_name) ) |
|---|
| 153 |
$user->user_lastname = $user->last_name; |
|---|
| 154 |
if ( isset($user->description) ) |
|---|
| 155 |
$user->user_description = $user->description; |
|---|
| 156 |
|
|---|
| 157 |
wp_cache_add($user->ID, $user, 'users'); |
|---|
| 158 |
wp_cache_add($user->user_login, $user, 'userlogins'); |
|---|
| 159 |
|
|---|
| 160 |
return $user; |
|---|
| 161 |
|
|---|
| 162 |
} |
|---|
| 163 |
endif; |
|---|
| 164 |
|
|---|
| 165 |
if ( !function_exists('wp_mail') ) : |
|---|
| 166 |
function wp_mail($to, $subject, $message, $headers = '') { |
|---|
| 167 |
if( $headers == '' ) { |
|---|
| 168 |
$headers = "MIME-Version: 1.0\n" . |
|---|
| 169 |
"From: wordpress@" . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])) . "\n" . |
|---|
| 170 |
"Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n"; |
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
return @mail($to, $subject, $message, $headers); |
|---|
| 174 |
} |
|---|
| 175 |
endif; |
|---|
| 176 |
|
|---|
| 177 |
if ( !function_exists('wp_login') ) : |
|---|
| 178 |
function wp_login($username, $password, $already_md5 = false) { |
|---|
| 179 |
global $wpdb, $error; |
|---|
| 180 |
|
|---|
| 181 |
if ( '' == $username ) |
|---|
| 182 |
return false; |
|---|
| 183 |
|
|---|
| 184 |
if ( '' == $password ) { |
|---|
| 185 |
$error = __('<strong>Error</strong>: The password field is empty.'); |
|---|
| 186 |
return false; |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
$login = get_userdatabylogin($username); |
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
if (!$login) { |
|---|
| 193 |
$error = __('<strong>Error</strong>: Wrong username.'); |
|---|
| 194 |
return false; |
|---|
| 195 |
} elseif( get_settings('restrict_admin_ip') && 1==$login->user_admin && false===check_admin_ip()) { |
|---|
| 196 |
$ip=$_SERVER['REMOTE_ADDR']; |
|---|
| 197 |
$error = "<strong>Error</strong>: An administrator cannot log in from your ip address: $ip"; |
|---|
| 198 |
return false; |
|---|
| 199 |
} elseif(1==$login->user_locked) { |
|---|
| 200 |
$error = "Your account is locked"; |
|---|
| 201 |
} else { |
|---|
| 202 |
|
|---|
| 203 |
// Otherwise, it is plain text. |
|---|
| 204 |
if ( ($already_md5 && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) { |
|---|
| 205 |
return true; |
|---|
| 206 |
} else { |
|---|
| 207 |
$error = __('<strong>Error</strong>: Incorrect password.'); |
|---|
| 208 |
$pwd = ''; |
|---|
| 209 |
return false; |
|---|
| 210 |
} |
|---|
| 211 |
} |
|---|
| 212 |
} |
|---|
| 213 |
endif; |
|---|
| 214 |
|
|---|
| 215 |
if ( !function_exists('is_user_logged_in') ) : |
|---|
| 216 |
function is_user_logged_in() { |
|---|
| 217 |
global $current_user; |
|---|
| 218 |
|
|---|
| 219 |
if ( $current_user->id == 0 ) |
|---|
| 220 |
return false; |
|---|
| 221 |
return true; |
|---|
| 222 |
} |
|---|
| 223 |
endif; |
|---|
| 224 |
|
|---|
| 225 |
if ( !function_exists('auth_redirect') ) : |
|---|
| 226 |
function auth_redirect() { |
|---|
| 227 |
|
|---|
| 228 |
if ( (!empty($_COOKIE[USER_COOKIE]) && |
|---|
| 229 |
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) || |
|---|
| 230 |
(empty($_COOKIE[USER_COOKIE])) ) { |
|---|
| 231 |
nocache_headers(); |
|---|
| 232 |
|
|---|
| 233 |
header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])); |
|---|
| 234 |
exit(); |
|---|
| 235 |
} |
|---|
| 236 |
} |
|---|
| 237 |
endif; |
|---|
| 238 |
|
|---|
| 239 |
if ( !function_exists('check_admin_referer') ) : |
|---|
| 240 |
function check_admin_referer() { |
|---|
| 241 |
|
|---|
| 242 |
$adminurl = '/admin'; |
|---|
| 243 |
$systemadminurl = strtolower(get_settings('siteurl')).'/system-admin'; |
|---|
| 244 |
$referer = strtolower($_SERVER['HTTP_REFERER']); |
|---|
| 245 |
strstr($referer, $adminurl) && strstr($referer, (get_settings('siteurl')))) && !strstr($referer, $systemadminurl)) |
|---|
| 246 |
__('Sorry, you need to <a href="http://codex.wordpress.org/Enable_Sending_Referrers">enable sending referrers</a> for this feature to work.')); |
|---|
| 247 |
do_action('check_admin_referer'); |
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
|
|---|
| 253 |
if ( !function_exists('wp_redirect') ) : |
|---|
| 254 |
function wp_redirect($location) { |
|---|
| 255 |
global $is_IIS; |
|---|
| 256 |
|
|---|
| 257 |
$location = str_replace( array("\n", "\r"), '', $location); |
|---|
| 258 |
|
|---|
| 259 |
if ($is_IIS) |
|---|
| 260 |
header("Refresh: 0;url=$location"); |
|---|
| 261 |
else |
|---|
| 262 |
header("Location: $location"); |
|---|
| 263 |
} |
|---|
| 264 |
endif; |
|---|
| 265 |
|
|---|
| 266 |
if ( !function_exists('wp_setcookie') ) : |
|---|
| 267 |
function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '', $remember = false) { |
|---|
| 268 |
if ( !$already_md5 ) |
|---|
| 269 |
$password = md5( md5($password) ); |
|---|
| 270 |
|
|---|
| 271 |
if ( empty($home) ) |
|---|
| 272 |
$cookiepath = COOKIEPATH; |
|---|
| 273 |
else |
|---|
| 274 |
$cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' ); |
|---|
| 275 |
|
|---|
| 276 |
if ( empty($siteurl) ) { |
|---|
| 277 |
$sitecookiepath = SITECOOKIEPATH; |
|---|
| 278 |
$cookiehash = COOKIEHASH; |
|---|
| 279 |
} else { |
|---|
| 280 |
$sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' ); |
|---|
| 281 |
$cookiehash = md5($siteurl); |
|---|
| 282 |
} |
|---|
| 283 |
|
|---|
| 284 |
if ( $remember ) |
|---|
| 285 |
$expire = time() + 31536000; |
|---|
| 286 |
else |
|---|
| 287 |
$expire = 0; |
|---|
| 288 |
|
|---|
| 289 |
setcookie(USER_COOKIE, $username, $expire, $cookiepath, COOKIE_DOMAIN); |
|---|
| 290 |
setcookie(PASS_COOKIE, $password, $expire, $cookiepath, COOKIE_DOMAIN); |
|---|
| 291 |
|
|---|
| 292 |
if ( $cookiepath != $sitecookiepath ) { |
|---|
| 293 |
setcookie(USER_COOKIE, $username, $expire, $sitecookiepath, COOKIE_DOMAIN); |
|---|
| 294 |
setcookie(PASS_COOKIE, $password, $expire, $sitecookiepath, COOKIE_DOMAIN); |
|---|
| 295 |
} |
|---|
| 296 |
} |
|---|
| 297 |
endif; |
|---|
| 298 |
|
|---|
| 299 |
if ( !function_exists('wp_clearcookie') ) : |
|---|
| 300 |
function wp_clearcookie() { |
|---|
| 301 |
setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); |
|---|
| 302 |
setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); |
|---|
| 303 |
setcookie(USER_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); |
|---|
| 304 |
setcookie(PASS_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); |
|---|
| 305 |
} |
|---|
| 306 |
endif; |
|---|
| 307 |
|
|---|
| 308 |
if ( ! function_exists('wp_notify_postauthor') ) : |
|---|
| 309 |
function wp_notify_postauthor($comment_id, $comment_type='') { |
|---|
| 310 |
global $wpdb; |
|---|
| 311 |
global $blog; |
|---|
| 312 |
$comment = get_comment($comment_id); |
|---|
| 313 |
$post = get_post($comment->comment_post_ID); |
|---|
| 314 |
$user = get_userdata( $post->post_author ); |
|---|
| 315 |
|
|---|
| 316 |
if ('' == $user->user_email) return false; |
|---|
| 317 |
|
|---|
| 318 |
$comment_author_domain = gethostbyaddr($comment->comment_author_IP); |
|---|
| 319 |
|
|---|
| 320 |
$blogname = get_settings('blogname'); |
|---|
| 321 |
|
|---|
| 322 |
if ( empty( $comment_type ) ) $comment_type = 'comment'; |
|---|
| 323 |
|
|---|
| 324 |
if ('comment' == $comment_type) { |
|---|
| 325 |
$notify_message = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; |
|---|
| 326 |
$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
|---|
| 327 |
$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; |
|---|
| 328 |
$notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
|---|
| 329 |
$notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; |
|---|
| 330 |
$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
|---|
| 331 |
$notify_message .= __('You can see all comments on this post here: ') . "\r\n"; |
|---|
| 332 |
$subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title ); |
|---|
| 333 |
} elseif ('trackback' == $comment_type) { |
|---|
| 334 |
$notify_message = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; |
|---|
| 335 |
$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
|---|
| 336 |
$notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
|---|
| 337 |
$notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
|---|
| 338 |
$notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n"; |
|---|
| 339 |
$subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title ); |
|---|
| 340 |
} elseif ('pingback' == $comment_type) { |
|---|
| 341 |
$notify_message = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; |
|---|
| 342 |
$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
|---|
| 343 |
$notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
|---|
| 344 |
$notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n"; |
|---|
| 345 |
$notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n"; |
|---|
| 346 |
$subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title ); |
|---|
| 347 |
} |
|---|
| 348 |
$notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n"; |
|---|
| 349 |
$notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('home')."/admin/post.php?action=confirmdeletecomment&p=".$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; |
|---|
| 350 |
|
|---|
| 351 |
$wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); |
|---|
| 352 |
|
|---|
| 353 |
if ( '' == $comment->comment_author ) { |
|---|
| 354 |
$from = "From: \"$blogname\" <$wp_email>"; |
|---|
| 355 |
if ( '' != $comment->comment_author_email ) |
|---|
| 356 |
$reply_to = "Reply-To: $comment->comment_author_email"; |
|---|
| 357 |
} else { |
|---|
| 358 |
$from = "From: \"$comment->comment_author\" <$wp_email>"; |
|---|
| 359 |
if ( '' != $comment->comment_author_email ) |
|---|
| 360 |
$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>"; |
|---|
| 361 |
} |
|---|
| 362 |
|
|---|
| 363 |
$message_headers = "MIME-Version: 1.0\n" |
|---|
| 364 |
. "$from\n" |
|---|
| 365 |
. "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n"; |
|---|
| 366 |
|
|---|
| 367 |
if ( isset($reply_to) ) |
|---|
| 368 |
$message_headers .= $reply_to . "\n"; |
|---|
| 369 |
|
|---|
| 370 |
$notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id); |
|---|
| 371 |
$subject = apply_filters('comment_notification_subject', $subject, $comment_id); |
|---|
| 372 |
$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id); |
|---|
| 373 |
|
|---|
| 374 |
@wp_mail($user->user_email, $subject, $notify_message, $message_headers); |
|---|
| 375 |
|
|---|
| 376 |
return true; |
|---|
| 377 |
} |
|---|
| 378 |
endif; |
|---|
| 379 |
|
|---|
| 380 |
|
|---|
| 381 |
|
|---|
| 382 |
|
|---|
| 383 |
|
|---|
| 384 |
|
|---|
| 385 |
if ( !function_exists('wp_notify_moderator') ) : |
|---|
| 386 |
function wp_notify_moderator($comment_id) { |
|---|
| 387 |
global $wpdb; |
|---|
| 388 |
global $blog; |
|---|
| 389 |
|
|---|
| 390 |
if( get_settings( "moderation_notify" ) == 0 ) |
|---|
| 391 |
return true; |
|---|
| 392 |
|
|---|
| 393 |
$comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); |
|---|
| 394 |
$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1"); |
|---|
| 395 |
|
|---|
| 396 |
$comment_author_domain = gethostbyaddr($comment->comment_author_IP); |
|---|
| 397 |
|
|---|
| 398 |
$comments_waiting = $wpdb->get_comment_var("count(comment_ID)", "comment_approved = '0'"); |
|---|
| 399 |
|
|---|
| 400 |
$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"; |
|---|
| 401 |
$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; |
|---|
| 402 |
$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
|---|
| 403 |
$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; |
|---|
| 404 |
$notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
|---|
| 405 |
$notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; |
|---|
| 406 |
$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
|---|
| 407 |
$notify_message .= sprintf( __('To approve this comment, visit: %s'), get_settings('home')."/admin/post.php?action=mailapprovecomment&p=".$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; |
|---|
| 408 |
$notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('home')."/admin/post.php?action=confirmdeletecomment&p=".$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; |
|---|
| 409 |
$notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n"; |
|---|
| 410 |
$notify_message .= get_settings('siteurl') . "/wp-admin/moderation.php\r\n"; |
|---|
| 411 |
|
|---|
| 412 |
$subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_settings('blogname'), $post->post_title ); |
|---|
| 413 |
$admin_email = get_settings('admin_email'); |
|---|
| 414 |
|
|---|
| 415 |
$notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id); |
|---|
| 416 |
$subject = apply_filters('comment_moderation_subject', $subject, $comment_id); |
|---|
| 417 |
|
|---|
| 418 |
@wp_mail($admin_email, $subject, $notify_message); |
|---|
| 419 |
|
|---|
| 420 |
return true; |
|---|
| 421 |
} |
|---|
| 422 |
endif; |
|---|
| 423 |
|
|---|
| 424 |
if ( !function_exists('wp_new_user_notification') ) : |
|---|
| 425 |
function wp_new_user_notification($blog, $user_id, $plaintext_pass = '') { |
|---|
| 426 |
assert('isset($blog)'); |
|---|
| 427 |
$user = new WP_User($user_id); |
|---|
| 428 |
|
|---|
| 429 |
$user_login = stripslashes($user->user_login); |
|---|
| 430 |
$user_email = stripslashes($user->user_email); |
|---|
| 431 |
|
|---|
| 432 |
$message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n"; |
|---|
| 433 |
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; |
|---|
| 434 |
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; |
|---|
| 435 |
|
|---|
| 436 |
@wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message); |
|---|
| 437 |
|
|---|
| 438 |
if ( empty($plaintext_pass) ) |
|---|
| 439 |
return; |
|---|
| 440 |
|
|---|
| 441 |
$message = sprintf(__('Username: %s'), $user_login) . "\r\n"; |
|---|
| 442 |
$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; |
|---|
| 443 |
$message .= get_settings('siteurl') . "/wp-login.php\r\n"; |
|---|
| 444 |
|
|---|
| 445 |
wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message); |
|---|
| 446 |
|
|---|
| 447 |
} |
|---|
| 448 |
endif; |
|---|
| 449 |
|
|---|
| 450 |
?> |
|---|
| 451 |
|
|---|