Make WordPress Core

Changeset 2516


Ignore:
Timestamp:
04/04/2005 11:25:51 PM (20 years ago)
Author:
ryan
Message:

Move plugin replacebale functions to pluggable-functions.php. http://mosquito.wordpress.org/view.php?id=1211

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment-functions.php

    r2498 r2516  
    615615}
    616616
    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 to
    626 
    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_moderator
    677    notifies the moderator of the blog (usually the admin)
    678    about a new comment that waits for approval
    679    always returns true
    680  */
    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 
    716617function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
    717618    global $wpdb;
  • trunk/wp-includes/functions.php

    r2515 r2516  
    157157}
    158158
    159 if ( !function_exists('get_currentuserinfo') ) {
    160 function get_currentuserinfo() { // a bit like get_userdata(), on steroids
    161     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 spoofing
    163 
    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 }
    211159
    212160function get_usernumposts($userid) {
     
    17951743}
    17961744
    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 
    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 page
    1843     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     else
    1866         header("Location: $location");
    1867 }
    1868 endif;
    18691745
    18701746function is_plugin_page() {
     
    19661842}
    19671843
    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     else
    1976         $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;
    20041844?>
  • trunk/wp-settings.php

    r2501 r2516  
    119119}
    120120
     121require (ABSPATH . WPINC . '/pluggable-functions.php');
     122
    121123if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
    122124    wp_cache_postload();
Note: See TracChangeset for help on using the changeset viewer.