Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/15/2015 07:57:03 PM (8 years ago)
Author:
tw2113
Message:

[Samus Aran]
I first battled the documentation inconsistencies on planet Zebes. It was there that I foiled the plans of the
Space Pirate leader Mother Brain to use the issues to attack galactic civilization...

I next fought the inconsistencies on their homeworld SR388. I completely eradicated them except for an @since tag,
which after hatching followed me like a confused child...

I personally delivered it to the Galactic Research Station at Ceres so scientists could study its energy production qualities...

The scientists' findings were astounding! They discovered that the powers of the docs inconsistencies
might be harnessed for the good of galactic civilization!

Satisfied that all was well, I left the station to seek a new bounty to hunt. But, I had hardly gone beyond the asteroid
belt when I picked up a distress signal!

Ceres station was under attack!

More documentation cleanup for part of BP-Core component.

See #6398.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-moderation.php

    r10108 r10356  
    2727 *
    2828 * @param int $user_id User id to check for flood.
    29  *
    3029 * @return bool True if there is no flooding, false if there is.
    3130 */
     
    3736    }
    3837
    39     // Bail if no user ID passed
     38    // Bail if no user ID passed.
    4039    if ( empty( $user_id ) ) {
    4140        return false;
     
    6261 * @param string $title   The title of the content.
    6362 * @param string $content The content being posted.
    64  *
    6563 * @return bool True if test is passed, false if fail.
    6664 */
     
    8179    }
    8280
    83     // Bail if super admin is author
     81    // Bail if super admin is author.
    8482    if ( is_super_admin( $user_id ) ) {
    8583        return true;
    8684    }
    8785
    88     // Define local variable(s)
     86    // Define local variable(s).
    8987    $_post     = array();
    9088    $match_out = '';
    9189
    92     /** User Data *************************************************************/
     90    /** User Data ************************************************************
     91     */
    9392
    9493    if ( ! empty( $user_id ) ) {
    9594
    96         // Get author data
     95        // Get author data.
    9796        $user = get_userdata( $user_id );
    9897
    99         // If data exists, map it
     98        // If data exists, map it.
    10099        if ( ! empty( $user ) ) {
    101100            $_post['author'] = $user->display_name;
     
    105104    }
    106105
    107     // Current user IP and user agent
     106    // Current user IP and user agent.
    108107    $_post['user_ip'] = bp_core_current_user_ip();
    109108    $_post['user_ua'] = bp_core_current_user_ua();
    110109
    111     // Post title and content
     110    // Post title and content.
    112111    $_post['title']   = $title;
    113112    $_post['content'] = $content;
    114113
    115     /** Max Links *************************************************************/
     114    /** Max Links ************************************************************
     115     */
    116116
    117117    $max_links = get_option( 'comment_max_links' );
     
    121121        $num_links = preg_match_all( '/(http|ftp|https):\/\//i', $content, $match_out );
    122122
    123         // Allow for bumping the max to include the user's URL
     123        // Allow for bumping the max to include the user's URL.
    124124        if ( ! empty( $_post['url'] ) ) {
    125125
     
    141141    }
    142142
    143     /** Blacklist *************************************************************/
    144 
    145     // Get the moderation keys
     143    /** Blacklist ************************************************************
     144     */
     145
     146    // Get the moderation keys.
    146147    $blacklist = trim( get_option( 'moderation_keys' ) );
    147148
    148     // Bail if blacklist is empty
     149    // Bail if blacklist is empty.
    149150    if ( ! empty( $blacklist ) ) {
    150151
    151         // Get words separated by new lines
     152        // Get words separated by new lines.
    152153        $words = explode( "\n", $blacklist );
    153154
    154         // Loop through words
     155        // Loop through words.
    155156        foreach ( (array) $words as $word ) {
    156157
    157             // Trim the whitespace from the word
     158            // Trim the whitespace from the word.
    158159            $word = trim( $word );
    159160
    160             // Skip empty lines
     161            // Skip empty lines.
    161162            if ( empty( $word ) ) {
    162163                continue;
     
    164165
    165166            // Do some escaping magic so that '#' chars in the
    166             // spam words don't break things:
     167            // spam words don't break things.
    167168            $word    = preg_quote( $word, '#' );
    168169            $pattern = "#$word#i";
    169170
    170             // Loop through post data
     171            // Loop through post data.
    171172            foreach ( $_post as $post_data ) {
    172173
    173                 // Check each user data for current word
     174                // Check each user data for current word.
    174175                if ( preg_match( $pattern, $post_data ) ) {
    175176
    176                     // Post does not pass
     177                    // Post does not pass.
    177178                    return false;
    178179                }
     
    181182    }
    182183
    183     // Check passed successfully
     184    // Check passed successfully.
    184185    return true;
    185186}
     
    197198 * @param string $title   The title of the content.
    198199 * @param string $content The content being posted.
    199  *
    200200 * @return bool True if test is passed, false if fail.
    201201 */
     
    216216    }
    217217
    218     // Bail if super admin is author
     218    // Bail if super admin is author.
    219219    if ( is_super_admin( $user_id ) ) {
    220220        return true;
    221221    }
    222222
    223     // Define local variable
     223    // Define local variable.
    224224    $_post = array();
    225225
    226     /** Blacklist *************************************************************/
    227 
    228     // Get the moderation keys
     226    /** Blacklist ************************************************************
     227     */
     228
     229    // Get the moderation keys.
    229230    $blacklist = trim( get_option( 'blacklist_keys' ) );
    230231
    231     // Bail if blacklist is empty
     232    // Bail if blacklist is empty.
    232233    if ( empty( $blacklist ) ) {
    233234        return true;
    234235    }
    235236
    236     /** User Data *************************************************************/
    237 
    238     // Map current user data
     237    /** User Data ************************************************************
     238     */
     239
     240    // Map current user data.
    239241    if ( ! empty( $user_id ) ) {
    240242
    241         // Get author data
     243        // Get author data.
    242244        $user = get_userdata( $user_id );
    243245
    244         // If data exists, map it
     246        // If data exists, map it.
    245247        if ( ! empty( $user ) ) {
    246248            $_post['author'] = $user->display_name;
     
    250252    }
    251253
    252     // Current user IP and user agent
     254    // Current user IP and user agent.
    253255    $_post['user_ip'] = bp_core_current_user_ip();
    254256    $_post['user_ua'] = bp_core_current_user_ua();
    255257
    256     // Post title and content
     258    // Post title and content.
    257259    $_post['title']   = $title;
    258260    $_post['content'] = $content;
    259261
    260     /** Words *****************************************************************/
    261 
    262     // Get words separated by new lines
     262    /** Words ****************************************************************
     263     */
     264
     265    // Get words separated by new lines.
    263266    $words = explode( "\n", $blacklist );
    264267
    265     // Loop through words
     268    // Loop through words.
    266269    foreach ( (array) $words as $word ) {
    267270
    268         // Trim the whitespace from the word
     271        // Trim the whitespace from the word.
    269272        $word = trim( $word );
    270273
    271         // Skip empty lines
     274        // Skip empty lines.
    272275        if ( empty( $word ) ) { continue; }
    273276
    274277        // Do some escaping magic so that '#' chars in the
    275         // spam words don't break things:
     278        // spam words don't break things.
    276279        $word    = preg_quote( $word, '#' );
    277280        $pattern = "#$word#i";
    278281
    279         // Loop through post data
     282        // Loop through post data.
    280283        foreach( $_post as $post_data ) {
    281284
    282             // Check each user data for current word
     285            // Check each user data for current word.
    283286            if ( preg_match( $pattern, $post_data ) ) {
    284287
    285                 // Post does not pass
     288                // Post does not pass.
    286289                return false;
    287290            }
     
    289292    }
    290293
    291     // Check passed successfully
     294    // Check passed successfully.
    292295    return true;
    293296}
     
    322325function bp_core_current_user_ua() {
    323326
    324     // Sanity check the user agent
     327    // Sanity check the user agent.
    325328    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
    326329        $retval = substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 );
Note: See TracChangeset for help on using the changeset viewer.