Ticket #1211: pluggable.diff
File pluggable.diff, 26.0 KB (added by , 20 years ago) |
---|
-
wp-includes/functions.php
156 156 return (md5($user_pass) == $userdata->user_pass); 157 157 } 158 158 159 if ( !function_exists('get_currentuserinfo') ) {160 function get_currentuserinfo() { // a bit like get_userdata(), on steroids161 global $user_login, $userdata, $user_level, $user_ID, $user_nickname, $user_email, $user_url, $user_pass_md5, $user_identity;162 // *** retrieving user's data from cookies and db - no spoofing163 159 164 if (isset($_COOKIE['wordpressuser_' . COOKIEHASH]))165 $user_login = $_COOKIE['wordpressuser_' . COOKIEHASH];166 $userdata = get_userdatabylogin($user_login);167 $user_level = $userdata->user_level;168 $user_ID = $userdata->ID;169 $user_nickname = $userdata->user_nickname;170 $user_email = $userdata->user_email;171 $user_url = $userdata->user_url;172 $user_pass_md5 = md5($userdata->user_pass);173 174 $idmode = $userdata->user_idmode;175 if ($idmode == 'nickname') $user_identity = $userdata->user_nickname;176 if ($idmode == 'login') $user_identity = $userdata->user_login;177 if ($idmode == 'firstname') $user_identity = $userdata->user_firstname;178 if ($idmode == 'lastname') $user_identity = $userdata->user_lastname;179 if ($idmode == 'namefl') $user_identity = $userdata->user_firstname.' '.$userdata->user_lastname;180 if ($idmode == 'namelf') $user_identity = $userdata->user_lastname.' '.$userdata->user_firstname;181 if (!$idmode) $user_identity = $userdata->user_nickname;182 }183 }184 185 if ( !function_exists('get_userdata') ) {186 function get_userdata($userid) {187 global $wpdb, $cache_userdata;188 $userid = (int) $userid;189 if ( empty($cache_userdata[$userid]) && $userid != 0) {190 $cache_userdata[$userid] = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = $userid");191 $cache_userdata[$cache_userdata[$userid]->user_login] =& $cache_userdata[$userid];192 }193 194 return $cache_userdata[$userid];195 }196 }197 198 if ( !function_exists('get_userdatabylogin') ) {199 function get_userdatabylogin($user_login) {200 global $cache_userdata, $wpdb;201 if ( !empty($user_login) && empty($cache_userdata[$user_login]) ) {202 $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'"); /* todo: get rid of this intermediate var */203 $cache_userdata[$user->ID] = $user;204 $cache_userdata[$user_login] =& $cache_userdata[$user->ID];205 } else {206 $user = $cache_userdata[$user_login];207 }208 return $user;209 }210 }211 212 160 function get_usernumposts($userid) { 213 161 global $wpdb; 214 162 return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_status = 'publish'"); … … 1794 1742 return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($myHTML, $translation_table)); 1795 1743 } 1796 1744 1797 if ( !function_exists('wp_mail') ) :1798 function wp_mail($to, $subject, $message, $headers = '') {1799 if( $headers == '' ) {1800 $headers = "MIME-Version: 1.0\r\n" .1801 "From: " . get_settings('admin_email') . "\r\n" .1802 "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n";1803 }1804 1745 1805 return @mail($to, $subject, $message, $headers);1806 }1807 endif;1808 1809 if ( !function_exists('wp_login') ) :1810 function wp_login($username, $password, $already_md5 = false) {1811 global $wpdb, $error;1812 1813 if ( !$username )1814 return false;1815 1816 if ( !$password ) {1817 $error = __('<strong>Error</strong>: The password field is empty.');1818 return false;1819 }1820 1821 $login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'");1822 1823 if (!$login) {1824 $error = __('<strong>Error</strong>: Wrong username.');1825 return false;1826 } else {1827 // If the password is already_md5, it has been double hashed.1828 // Otherwise, it is plain text.1829 if ( ($already_md5 && $login->user_login == $username && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) {1830 return true;1831 } else {1832 $error = __('<strong>Error</strong>: Incorrect password.');1833 $pwd = '';1834 return false;1835 }1836 }1837 }1838 endif;1839 1840 if ( !function_exists('auth_redirect') ) :1841 function auth_redirect() {1842 // Checks if a user is logged in, if not redirects them to the login page1843 if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) &&1844 !wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) ||1845 (empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) {1846 header('Expires: Mon, 11 Jan 1984 05:00:00 GMT');1847 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');1848 header('Cache-Control: no-cache, must-revalidate, max-age=0');1849 header('Pragma: no-cache');1850 1851 header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));1852 exit();1853 }1854 }1855 endif;1856 1857 // Cookie safe redirect. Works around IIS Set-Cookie bug.1858 // http://support.microsoft.com/kb/q176113/1859 if ( !function_exists('wp_redirect') ) :1860 function wp_redirect($location) {1861 global $is_IIS;1862 1863 if ($is_IIS)1864 header("Refresh: 0;url=$location");1865 else1866 header("Location: $location");1867 }1868 endif;1869 1870 1746 function is_plugin_page() { 1871 1747 global $plugin_page; 1872 1748 … … 1965 1841 return $array; 1966 1842 } 1967 1843 1968 if ( !function_exists('wp_setcookie') ) :1969 function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '') {1970 if ( !$already_md5 )1971 $password = md5( md5($password) ); // Double hash the password in the cookie.1972 1973 if ( empty($home) )1974 $cookiepath = COOKIEPATH;1975 else1976 $cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' );1977 1978 if ( empty($siteurl) ) {1979 $sitecookiepath = SITECOOKIEPATH;1980 $cookiehash = COOKIEHASH;1981 } else {1982 $sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' );1983 $cookiehash = md5($siteurl);1984 }1985 1986 setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $cookiepath);1987 setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $cookiepath);1988 1989 if ( $cookiepath != $sitecookiepath ) {1990 setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $sitecookiepath);1991 setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $sitecookiepath);1992 }1993 }1994 endif;1995 1996 if ( !function_exists('wp_clearcookie') ) :1997 function wp_clearcookie() {1998 setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH);1999 setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH);2000 setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH);2001 setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH);2002 }2003 endif;2004 1844 ?> -
wp-includes/comment-functions.php
614 614 } 615 615 } 616 616 617 if ( ! function_exists('wp_notify_postauthor') ) {618 function wp_notify_postauthor($comment_id, $comment_type='') {619 global $wpdb;620 621 $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");622 $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");623 $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1");624 625 if ('' == $user->user_email) return false; // If there's no email to send the comment to626 627 $comment_author_domain = gethostbyaddr($comment->comment_author_IP);628 629 $blogname = get_settings('blogname');630 631 if ( empty( $comment_type ) ) $comment_type = 'comment';632 633 if ('comment' == $comment_type) {634 $notify_message = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";635 $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";636 $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";637 $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";638 $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";639 $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";640 $notify_message .= __('You can see all comments on this post here: ') . "\r\n";641 $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );642 } elseif ('trackback' == $comment_type) {643 $notify_message = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";644 $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";645 $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";646 $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";647 $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";648 $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );649 } elseif ('pingback' == $comment_type) {650 $notify_message = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";651 $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";652 $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";653 $notify_message .= __('Excerpt: ') . "\r\n" . sprintf( __('[...] %s [...]'), $comment->comment_content ) . "\r\n\r\n";654 $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";655 $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );656 }657 $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";658 $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n";659 660 if ('' == $comment->comment_author_email || '' == $comment->comment_author) {661 $from = "From: \"$blogname\" <wordpress@" . $_SERVER['SERVER_NAME'] . '>';662 } else {663 $from = 'From: "' . $comment->comment_author . "\" <$comment->comment_author_email>";664 }665 666 $message_headers = "MIME-Version: 1.0\r\n"667 . "$from\r\n"668 . "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n";669 670 @wp_mail($user->user_email, $subject, $notify_message, $message_headers);671 672 return true;673 }674 }675 676 /* wp_notify_moderator677 notifies the moderator of the blog (usually the admin)678 about a new comment that waits for approval679 always returns true680 */681 if ( !function_exists('wp_notify_moderator') ) {682 function wp_notify_moderator($comment_id) {683 global $wpdb;684 685 if( get_settings( "moderation_notify" ) == 0 )686 return true;687 688 $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");689 $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");690 $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1");691 692 $comment_author_domain = gethostbyaddr($comment->comment_author_IP);693 $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");694 695 $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";696 $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";697 $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";698 $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";699 $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";700 $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";701 $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";702 $notify_message .= sprintf( __('To approve this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=mailapprovecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n";703 $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n";704 $notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n";705 $notify_message .= get_settings('siteurl') . "/wp-admin/moderation.php\r\n";706 707 $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_settings('blogname'), $post->post_title );708 $admin_email = get_settings("admin_email");709 710 @wp_mail($admin_email, $subject, $notify_message);711 712 return true;713 }714 }715 716 617 function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) { 717 618 global $wpdb; 718 619 -
wp-includes/pluggable-functions.php
1 <?php 2 3 /* These functions can be replaced via plugins. They are loaded after 4 plugins are loaded. */ 5 6 7 if ( !function_exists('get_currentuserinfo') ) : 8 function get_currentuserinfo() { 9 global $user_login, $userdata, $user_level, $user_ID, $user_nickname, $user_email, $user_url, $user_pass_md5, $user_identity; 10 // *** retrieving user's data from cookies and db - no spoofing 11 12 if (isset($_COOKIE['wordpressuser_' . COOKIEHASH])) 13 $user_login = $_COOKIE['wordpressuser_' . COOKIEHASH]; 14 $userdata = get_userdatabylogin($user_login); 15 $user_level = $userdata->user_level; 16 $user_ID = $userdata->ID; 17 $user_nickname = $userdata->user_nickname; 18 $user_email = $userdata->user_email; 19 $user_url = $userdata->user_url; 20 $user_pass_md5 = md5($userdata->user_pass); 21 22 $idmode = $userdata->user_idmode; 23 if ($idmode == 'nickname') $user_identity = $userdata->user_nickname; 24 if ($idmode == 'login') $user_identity = $userdata->user_login; 25 if ($idmode == 'firstname') $user_identity = $userdata->user_firstname; 26 if ($idmode == 'lastname') $user_identity = $userdata->user_lastname; 27 if ($idmode == 'namefl') $user_identity = $userdata->user_firstname.' '.$userdata->user_lastname; 28 if ($idmode == 'namelf') $user_identity = $userdata->user_lastname.' '.$userdata->user_firstname; 29 if (!$idmode) $user_identity = $userdata->user_nickname; 30 } 31 endif; 32 33 if ( !function_exists('get_userdata') ) : 34 function get_userdata($userid) { 35 global $wpdb, $cache_userdata; 36 $userid = (int) $userid; 37 if ( empty($cache_userdata[$userid]) && $userid != 0) { 38 $cache_userdata[$userid] = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = $userid"); 39 $cache_userdata[$cache_userdata[$userid]->user_login] =& $cache_userdata[$userid]; 40 } 41 42 return $cache_userdata[$userid]; 43 } 44 endif; 45 46 if ( !function_exists('get_userdatabylogin') ) : 47 function get_userdatabylogin($user_login) { 48 global $cache_userdata, $wpdb; 49 if ( !empty($user_login) && empty($cache_userdata[$user_login]) ) { 50 $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'"); /* todo: get rid of this intermediate var */ 51 $cache_userdata[$user->ID] = $user; 52 $cache_userdata[$user_login] =& $cache_userdata[$user->ID]; 53 } else { 54 $user = $cache_userdata[$user_login]; 55 } 56 return $user; 57 } 58 endif; 59 60 if ( !function_exists('wp_mail') ) : 61 function wp_mail($to, $subject, $message, $headers = '') { 62 if( $headers == '' ) { 63 $headers = "MIME-Version: 1.0\r\n" . 64 "From: " . get_settings('admin_email') . "\r\n" . 65 "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n"; 66 } 67 68 return @mail($to, $subject, $message, $headers); 69 } 70 endif; 71 72 if ( !function_exists('wp_login') ) : 73 function wp_login($username, $password, $already_md5 = false) { 74 global $wpdb, $error; 75 76 if ( !$username ) 77 return false; 78 79 if ( !$password ) { 80 $error = __('<strong>Error</strong>: The password field is empty.'); 81 return false; 82 } 83 84 $login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'"); 85 86 if (!$login) { 87 $error = __('<strong>Error</strong>: Wrong username.'); 88 return false; 89 } else { 90 // If the password is already_md5, it has been double hashed. 91 // Otherwise, it is plain text. 92 if ( ($already_md5 && $login->user_login == $username && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) { 93 return true; 94 } else { 95 $error = __('<strong>Error</strong>: Incorrect password.'); 96 $pwd = ''; 97 return false; 98 } 99 } 100 } 101 endif; 102 103 if ( !function_exists('auth_redirect') ) : 104 function auth_redirect() { 105 // Checks if a user is logged in, if not redirects them to the login page 106 if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) && 107 !wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) || 108 (empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) { 109 header('Expires: Mon, 11 Jan 1984 05:00:00 GMT'); 110 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 111 header('Cache-Control: no-cache, must-revalidate, max-age=0'); 112 header('Pragma: no-cache'); 113 114 header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])); 115 exit(); 116 } 117 } 118 endif; 119 120 // Cookie safe redirect. Works around IIS Set-Cookie bug. 121 // http://support.microsoft.com/kb/q176113/ 122 if ( !function_exists('wp_redirect') ) : 123 function wp_redirect($location) { 124 global $is_IIS; 125 126 if ($is_IIS) 127 header("Refresh: 0;url=$location"); 128 else 129 header("Location: $location"); 130 } 131 endif; 132 133 if ( !function_exists('wp_setcookie') ) : 134 function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '') { 135 if ( !$already_md5 ) 136 $password = md5( md5($password) ); // Double hash the password in the cookie. 137 138 if ( empty($home) ) 139 $cookiepath = COOKIEPATH; 140 else 141 $cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' ); 142 143 if ( empty($siteurl) ) { 144 $sitecookiepath = SITECOOKIEPATH; 145 $cookiehash = COOKIEHASH; 146 } else { 147 $sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' ); 148 $cookiehash = md5($siteurl); 149 } 150 151 setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $cookiepath); 152 setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $cookiepath); 153 154 if ( $cookiepath != $sitecookiepath ) { 155 setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $sitecookiepath); 156 setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $sitecookiepath); 157 } 158 } 159 endif; 160 161 if ( !function_exists('wp_clearcookie') ) : 162 function wp_clearcookie() { 163 setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH); 164 setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH); 165 setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH); 166 setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH); 167 } 168 endif; 169 170 if ( ! function_exists('wp_notify_postauthor') ) : 171 function wp_notify_postauthor($comment_id, $comment_type='') { 172 global $wpdb; 173 174 $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); 175 $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1"); 176 $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1"); 177 178 if ('' == $user->user_email) return false; // If there's no email to send the comment to 179 180 $comment_author_domain = gethostbyaddr($comment->comment_author_IP); 181 182 $blogname = get_settings('blogname'); 183 184 if ( empty( $comment_type ) ) $comment_type = 'comment'; 185 186 if ('comment' == $comment_type) { 187 $notify_message = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; 188 $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; 189 $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; 190 $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; 191 $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; 192 $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; 193 $notify_message .= __('You can see all comments on this post here: ') . "\r\n"; 194 $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title ); 195 } elseif ('trackback' == $comment_type) { 196 $notify_message = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; 197 $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; 198 $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; 199 $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; 200 $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n"; 201 $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title ); 202 } elseif ('pingback' == $comment_type) { 203 $notify_message = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; 204 $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; 205 $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; 206 $notify_message .= __('Excerpt: ') . "\r\n" . sprintf( __('[...] %s [...]'), $comment->comment_content ) . "\r\n\r\n"; 207 $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n"; 208 $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title ); 209 } 210 $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n"; 211 $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; 212 213 if ('' == $comment->comment_author_email || '' == $comment->comment_author) { 214 $from = "From: \"$blogname\" <wordpress@" . $_SERVER['SERVER_NAME'] . '>'; 215 } else { 216 $from = 'From: "' . $comment->comment_author . "\" <$comment->comment_author_email>"; 217 } 218 219 $message_headers = "MIME-Version: 1.0\r\n" 220 . "$from\r\n" 221 . "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n"; 222 223 @wp_mail($user->user_email, $subject, $notify_message, $message_headers); 224 225 return true; 226 } 227 endif; 228 229 /* wp_notify_moderator 230 notifies the moderator of the blog (usually the admin) 231 about a new comment that waits for approval 232 always returns true 233 */ 234 if ( !function_exists('wp_notify_moderator') ) : 235 function wp_notify_moderator($comment_id) { 236 global $wpdb; 237 238 if( get_settings( "moderation_notify" ) == 0 ) 239 return true; 240 241 $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); 242 $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1"); 243 $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1"); 244 245 $comment_author_domain = gethostbyaddr($comment->comment_author_IP); 246 $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); 247 248 $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"; 249 $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; 250 $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; 251 $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; 252 $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; 253 $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; 254 $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; 255 $notify_message .= sprintf( __('To approve this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=mailapprovecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; 256 $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; 257 $notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n"; 258 $notify_message .= get_settings('siteurl') . "/wp-admin/moderation.php\r\n"; 259 260 $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_settings('blogname'), $post->post_title ); 261 $admin_email = get_settings("admin_email"); 262 263 @wp_mail($admin_email, $subject, $notify_message); 264 265 return true; 266 } 267 endif; 268 269 ?> 270 No newline at end of file -
wp-settings.php
118 118 } 119 119 } 120 120 121 require (ABSPATH . WPINC . '/pluggable-functions.php'); 122 121 123 if ( defined('WP_CACHE') && function_exists('wp_cache_postload') ) 122 124 wp_cache_postload(); 123 125