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 *****************************************************************************/ require_once 'phpCF.config.php'; define("PHPCF_VERSION", 0.2); class CFBase { var $error = array(); var $log = array(); var $score; // Main methods. function CFBase($text, $email = false) { $this->score = $this->scan($text, $email); } function isSpam() { global $SPAM_THRESHOLD; if ($this->score > $SPAM_THRESHOLD) { return true; } else { return false; } } function scan($text, $email = false) { $points = 0.0; $checks = $this->availableChecks(); foreach ($checks as $c) { if (method_exists($this, "c_" . $c)) { $funct = "c_$c"; $points += $this->$funct($text); } else { $this->error[] = "\"$c\": No such checking method."; } } if ($email != false) { $email_checks = $this->availableEmailChecks(); foreach ($email_checks as $ec) { if (method_exists($this, "ec_" . $ec)) { $funct = "ec_$ec"; $points += $this->$funct($email); } else { $this->error[] = "\"$ec\": No such email checking method."; } } } return $points; } // Error functions. function hasError() { if (!empty($this->error)) { return true; } else { return false; } } function printErrorList() { if (!empty($this->error)) { echo "\n"; } } function getLastError() { if (!empty($this->error) && is_array($this->error)) { return $this->error[count($this->error) - 1]; } } // Logging functions. function printLog() { if (!empty($this->log)) { echo "\n"; } } function availableChecks() { $ret = array(); foreach (get_class_methods($this) as $m) { if (preg_match("/^c_/", $m)) { $ret[] = preg_replace("/^(c_)(.+)$/", "\\2", $m); } } return $ret; } function availableEmailChecks() { $ret = array(); foreach (get_class_methods($this) as $m) { if (preg_match("/^ec_/", $m)) { $ret[] = preg_replace("/^(ec_)(.+)$/", "\\2", $m); } } return $ret; } function getThreshold() { global $SPAM_THRESHOLD; return $SPAM_THRESHOLD; } } ?>