Example #1
0
     if (cmtx_setting('security_key') != $_POST['cmtx_security_key']) {
         //security key incorrect
         cmtx_ban(CMTX_BAN_REASON_INCORRECT_SECURITY_KEY);
         //ban user for incorrect security key
     }
 }
 /* Resubmit Key */
 if (!isset($_POST['cmtx_resubmit_key'])) {
     //no resubmit key submitted
     cmtx_ban(CMTX_BAN_REASON_NO_RESUBMIT_KEY);
     //ban user for no resubmit key
 } else {
     //if resubmit key submitted
     if (!ctype_alnum($_POST['cmtx_resubmit_key']) || cmtx_strlen($_POST['cmtx_resubmit_key']) != 20) {
         //if resubmit key invalid
         cmtx_ban(CMTX_BAN_REASON_INVALID_RESUBMIT_KEY);
         //ban user for invalid resubmit key
     }
 }
 /* Check Honeypot */
 if (cmtx_setting('check_honeypot')) {
     //if honeypot-check enabled
     if (!isset($_POST['cmtx_honeypot'])) {
         //if honeypot not submitted
         cmtx_error(CMTX_ERROR_MESSAGE_MISSING_DATA);
         //reject user for no honeypot
     } else {
         //if honeypot submitted
         if (!empty($_POST['cmtx_honeypot'])) {
             //if honeypot has a value
             cmtx_error(CMTX_ERROR_MESSAGE_HONEYPOT);
Example #2
0
function cmtx_comment_check_capitals($comment)
{
    //checks comment for too many capital letters
    if (cmtx_is_encoding_iso($comment)) {
        //if encoding is ISO-8859-1
        $comment = preg_replace('/[^a-z]/i', '', $comment);
        //remove non-letters
        $number_of_letters = cmtx_strlen($comment);
        //number of letters
        $number_of_capitals = cmtx_strlen(preg_replace('/[^A-Z]/', '', $comment));
        //number of capitals
        if ($number_of_letters != 0 && $number_of_letters > 3 && $number_of_capitals != 0) {
            //if check is appropriate
            $percentage_of_capitals = $number_of_capitals / $number_of_letters * 100;
            //percentage of capitals
            if ($percentage_of_capitals >= cmtx_setting('check_capitals_percentage')) {
                //if too many capitals
                if (cmtx_setting('check_capitals_action') == 'approve') {
                    //if entering too many capitals should require approval
                    cmtx_approve(CMTX_APPROVE_REASON_CAPITALS);
                    //approve user for too many capitals
                } else {
                    if (cmtx_setting('check_capitals_action') == 'reject') {
                        //if entering too many capitals should be rejected
                        cmtx_error(CMTX_ERROR_MESSAGE_CAPITALS);
                        //reject user for too many capitals
                    } else {
                        if (cmtx_setting('check_capitals_action') == 'ban') {
                            //if entering too many capitals should result in a ban
                            cmtx_ban(CMTX_BAN_REASON_CAPITALS);
                            //ban user for too many capitals
                        }
                    }
                }
            }
            //end of if-too-many-capitals
        }
    }
}