if (cmtx_session_set()) { //if there's a session $_SESSION['cmtx_captcha'] = cmtx_setting('session_key'); //add captcha completion to session } } } } } } } } /* Akismet */ if (cmtx_setting('akismet_enabled') && function_exists('fsockopen') && is_callable('fsockopen')) { if (cmtx_akismet($cmtx_name, $cmtx_email, $cmtx_website, $cmtx_comment)) { cmtx_approve(CMTX_APPROVE_REASON_AKISMET); //approve user for failing Akismet test } } cmtx_check_maximums(); //check field data does not exceed the maximum lengths if ($cmtx_is_admin) { $cmtx_is_admin = 1; } else { $cmtx_is_admin = 0; } //prepare for database if ($cmtx_error) { //if there were any errors //build the error box $cmtx_box = "<div class='cmtx_error_box'>";
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 } } }