Changeset 197

Show
Ignore:
Timestamp:
15/11/06 11:55:09 (2 years ago)
Author:
rollercow
Message:

Updates to comment filtering, should further cut down on spam.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • blog.lib.php

    r195 r197  
    579579                //sanitise comment 
    580580                if (isset($_POST['comment']) && trim($_POST['comment']) != "") { 
    581                         $comment = addslashes(nl2br(trim(strip_tags($_POST['comment'])))); 
    582                 }  
    583                 else { 
     581                        if(strip_tags($_POST['comment']) == $_POST['comment']) { 
     582                                $comment = addslashes(nl2br(trim($_POST['comment']))); 
     583                        } else { 
     584                                $this->commentError = _("HTML within comments is not allowed, Please remove all html tags and try again"); 
     585                                $element = "comment"; 
     586                        } 
     587                } else { 
    584588                        $this->commentError = _("Please check the comment field"); 
    585589                        $element = "comment"; 
     
    590594                        //force this comment though moderation 
    591595                        $this->comment_moderation = true; 
    592                 } 
    593                 else { 
     596                } else { 
    594597                        $spam = false; 
    595598                } 
    596  
    597599                //sanitise email 
    598600                if (isset($_POST['email']) && trim($_POST['email']) != "" && validEmail(trim($_POST['email']))) { 
    599601                        $email = addslashes(trim($_POST['email'])); 
    600                 } 
    601                 else { 
    602                         $this->commentError = _("Check email address"); 
     602                } else { 
     603                        $this->commentError = _("Check email address, it does not apear to be valid."); 
    603604                        $element = "email"; 
    604605                } 
    605606                //sanitse author 
    606607                if (isset($_POST['author']) && trim($_POST['author']) != "") { 
    607                         $author = addslashes(nl2br(trim(strip_tags($_POST['author'])))); 
     608                        if(eregi("^([a-z0-9]+ *)+$", $_POST['author'])) { 
     609                                $author = addslashes(nl2br(trim(strip_tags($_POST['author'])))); 
     610                        } else { 
     611                                $this->commentError = _("Invalid name. We only allow alphanumeric names!"); 
     612                                $element = "author"; 
     613                        } 
    608614                }  
    609615                else { 
    610                         $this->commentError = _("Check your name."); 
     616                        $this->commentError = _("Please give us your name."); 
    611617                        $element = "author"; 
    612618                } 
  • miscfunctions.lib.php

    r196 r197  
    8585                $two_level_tlds[trim($TLD)] = true; 
    8686        } 
     87        if (!$matches) 
     88                return; 
    8789        //for each url 
    8890        foreach ($matches as $url) { 
     
    98100                } 
    99101        } 
     102        if (!$URLstoTest) 
     103                return; 
    100104        //actualy test each of he domains against the surbl 
    101105        foreach($URLstoTest as $url) {