$b8 = new b8($config_b8, $config_database); # Check if everything worked smoothly $started_up = $b8->validate(); if ($started_up !== TRUE) { echo "<b>example:</b> Could not initialize b8. error code: {$started_up}"; exit; } $text = stripslashes($_POST['text']); $postedText = htmlentities($text, ENT_QUOTES, 'UTF-8'); switch ($_POST['action']) { case "Classify": echo "<p><b>Spaminess: " . formatRating($b8->classify($text)) . "</b></p>\n"; break; case "Save as Spam": $ratingBefore = $b8->classify($text); $b8->learn($text, b8::SPAM); $ratingAfter = $b8->classify($text); echo "<p>Saved the text as Spam</p>\n\n"; echo "<div><table>\n"; echo "<tr><td>Classification before learning:</td><td>" . formatRating($ratingBefore) . "</td></tr>\n"; echo "<tr><td>Classification after learning:</td><td>" . formatRating($ratingAfter) . "</td></tr>\n"; echo "</table></div>\n\n"; break; case "Save as Ham": $ratingBefore = $b8->classify($text); $b8->learn($text, b8::HAM); $ratingAfter = $b8->classify($text); echo "<p>Saved the text as Ham</p>\n\n"; echo "<div><table>\n"; echo "<tr><td>Classification before learning:</td><td>" . formatRating($ratingBefore) . "</td></tr>\n"; echo "<tr><td>Classification after learning:</td><td>" . formatRating($ratingAfter) . "</td></tr>\n";
require_once "./mods/b8_spam/config.php"; //if(count($_POST) && $_POST["retrain"]!="") //{ // Create a new b8 instance $b8 = new b8($config_b8, $config_storage, $config_lexer, $config_degenerator); // Reset Word Classification $rows = phorum_db_interact(DB_RETURN_RES, "TRUNCATE TABLE b8_wordlist"); $rows = phorum_db_interact(DB_RETURN_RES, "INSERT INTO b8_wordlist (token, count_ham) VALUES ('b8*dbversion',3)"); // Build new Word Classification on Training Data $rows = phorum_db_interact(DB_RETURN_ASSOCS, "SELECT id,text,classification\n FROM b8_messages"); foreach ($rows as $row) { $classification = b8::SPAM; if ($row['classification'] == 'HAM') { $classification = b8::HAM; } $b8->learn($row['text'], $classification); } //} if (count($_POST) && $_POST["search"] != "" && $_POST["replace"] != "") { $item = array("search" => $_POST["search"], "replace" => $_POST["replace"], "pcre" => $_POST["pcre"]); if ($_POST["curr"] != "NEW") { $PHORUM["mod_replace"][$_POST["curr"]] = $item; } else { $PHORUM["mod_replace"][] = $item; } if (empty($error)) { if (!phorum_db_update_settings(array("mod_replace" => $PHORUM["mod_replace"]))) { $error = "Database error while updating settings."; } else { echo "Replacement Updated<br />"; }