Ticket #1028: comment-functions.php.patch

File comment-functions.php.patch, 2.4 KB (added by ColdForged, 7 years ago)
  • comment-functions.php

     
    727727                return false; // Check # of external links 
    728728 
    729729        $mod_keys = trim( get_settings('moderation_keys') ); 
    730         if ('' == $mod_keys ) 
    731                 return true; // If moderation keys are empty 
    732         $words = explode("\n", $mod_keys ); 
     730        if ('' !== $mod_keys ) 
     731    { 
     732        $words = explode("\n", $mod_keys ); 
    733733 
    734         foreach ($words as $word) { 
    735                 $word = trim($word); 
     734            foreach ($words as $word) { 
     735                    $word = trim($word); 
    736736 
    737                 // Skip empty lines 
    738                 if (empty($word)) { continue; } 
     737            // Skip empty lines 
     738                if (empty($word)) { continue; } 
    739739 
    740                 // Do some escaping magic so that '#' chars in the  
    741                 // spam words don't break things: 
    742                 $word = preg_quote($word, '#'); 
     740                    // Do some escaping magic so that '#' chars in the  
     741                    // spam words don't break things: 
     742                    $word = preg_quote($word, '#'); 
    743743                 
    744                 $pattern = "#$word#i";  
    745                 if ( preg_match($pattern, $author) ) return false; 
    746                 if ( preg_match($pattern, $email) ) return false; 
    747                 if ( preg_match($pattern, $url) ) return false; 
    748                 if ( preg_match($pattern, $comment) ) return false; 
    749                 if ( preg_match($pattern, $user_ip) ) return false; 
    750                 if ( preg_match($pattern, $user_agent) ) return false; 
    751         } 
     744                $pattern = "#$word#i";  
     745                    if ( preg_match($pattern, $author) ) return false; 
     746                    if ( preg_match($pattern, $email) ) return false; 
     747                    if ( preg_match($pattern, $url) ) return false; 
     748                    if ( preg_match($pattern, $comment) ) return false; 
     749                    if ( preg_match($pattern, $user_ip) ) return false; 
     750                    if ( preg_match($pattern, $user_agent) ) return false; 
     751        } 
     752    }             
    752753 
    753754        // Comment whitelisting: 
    754755        if ( 1 == get_settings('comment_whitelist')) { 
     
    760761                        else 
    761762                                return false; 
    762763                } elseif( $author != '' && $email != '' ) { 
    763                         $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' "); 
     764                        $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1"); 
    764765                        if ( 1 == $ok_to_comment && false === strpos( $email, get_settings('moderation_keys')) ) 
    765766                                return true; 
    766767                        else