This file is part of phpCF. phpCF is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. phpCF is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with phpCF; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ /** * NAMING CONVENTIONS: * Content check functions are prefixed with "c_" * Email check functions are prefixed with "ec_" * Failing to obey these simple naming conventions, will result * in the check never being run. */ require_once 'class.CFBase.php'; class CF extends CFBase { // Scanning methods function c_num_urls($text) { global $NUM_URLS; // The hardcore regex for url matching: preg_match_all("/((f|ht)tps?\:\/\/)([a-z0-9@:%_.~#\-\?&-]+)((\=|[a-z0-9]|\?|&|%|\/|\.|-|:|æ|ø|å)+){0,}/msi", $text, $matches); // And the light, but efficient: // preg_match_all("/(ht|f)tp(s?)\:\/\//msi", $text, $matches); $urls = count($matches[0]); if ($urls > 0) { $this->log[] = "num_urls: $urls URL(s) found"; } return ($NUM_URLS * $urls); } function c_poker_ref($text) { global $POKER_REF; preg_match_all("/\b(poker|texas(\s|-)hold(\s?)em|blackjack|gambling)\b/msi", $text, $matches); $ref = count($matches[0]); if ($ref > 0) { $this->log[] = "poker_ref: $ref poker reference(s) found."; } return ($POKER_REF * $ref); } function c_medic_ref($text) { global $MEDIC_REF; preg_match_all("/\b(viagra|phentermine)\b/msi", $text, $matches); $ref = count($matches[0]); if ($ref > 0) { $this->log[] = "medic_ref: $ref medicine reference(s) found."; } return ($MEDIC_REF * $ref); } function c_html_percentage($text) { global $HTML_PERCENTAGE; global $HTML_PERCENTAGE_ALLOW_TAGS; $orig = $text; $stripped = strip_tags($text, $HTML_PERCENTAGE_ALLOW_TAGS); $percent = round(((strlen($orig)-strlen($stripped)) / strlen($orig)) * 100); $return = $HTML_PERCENTAGE * $percent; if ($return > 0) { $this->log[] = "html_percentage: $percent%"; } return $return; } // Email checking methods: function ec_alpha_num($email) { global $ALPHA_NUM; if (preg_match("/^[a-z\_\-]+[0-9]+@/i", $email)) { $this->log[] = "alpha_num: Email username ending in numeric characters."; return $ALPHA_NUM; } else { return 0; } } // IP checking methods: function ic_ln_blacklisted($ip) { global $LN_BLACKLISTED; if ($LN_BLACKLISTED > 0) { $bl_url = "http://lillesvin.net/bl.txt"; $bl = array(); foreach (file($bl_url) as $l) { if (preg_match("/^HOST:\s/", $l)) { $bl[] = trim(preg_replace("/^HOST:\s(.*)$/", "\\1", $l)); } } if (in_array($ip, $bl)) { $this->log[] = "ln_blacklisted: IP is blacklisted by Lillesvin Networks."; $return = $LN_BLACKLISTED; } else { $return = 0; } return $return; } else { return 0; } } } ?>