Пример #1
0
<?php

if (!defined("PHORUM_ADMIN")) {
    return;
}
// Load the configuration
require_once './mods/b8_spam/b8/b8.php';
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;
Пример #2
0
<div>

<h1>example b8 interface</h1>


END;
$postedText = "";
if (isset($_POST['action']) and $_POST['text'] == "") {
    echo "<p style=\"color:red;\"><b>Please type in a text!</b></p>\n\n";
} elseif (isset($_POST['action']) and $_POST['text'] != "") {
    $time_start = microtimeFloat();
    # Include the b8 code
    require dirname(__FILE__) . "/../b8/b8.php";
    # Create a new b8 instance
    $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);
Пример #3
0
<div>

<h1>example b8 interface</h1>


END;
$postedText = '';
if (isset($_POST['action']) and $_POST['text'] == '') {
    echo "<p style=\"color:red;\"><b>Please type in a text!</b></p>\n\n";
} elseif (isset($_POST['action']) and $_POST['text'] != '') {
    $time_start = microtimeFloat();
    # Include the b8 code
    require dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'b8' . DIRECTORY_SEPARATOR . 'b8.php';
    # Create a new b8 instance
    try {
        $b8 = new b8($config_b8, $config_storage, $config_lexer, $config_degenerator);
    } catch (Exception $e) {
        echo "<b>example:</b> Could not initialize b8.<br />\n";
        echo "<b>Error message:</b> ", $e->getMessage();
        echo "\n\n</div>\n\n</body>\n\n</html>";
        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);