Login   Register  
PHP Classes
elePHPant
Icontem

File: guestbook.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Rafael Pinto  >  Spam Filter  >  guestbook.php  >  Download  
File: guestbook.php
Role: Example script
Content type: text/plain
Description: Guestbook Example with SpamFilter
Class: Spam Filter
Classify spam text messages using a knowlegde base
Author: By
Last change:
Date: 2005-05-02 20:24
Size: 1,266 bytes
 

Contents

Class file image Download
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>
<HEAD>
<TITLE>Guestbook</TITLE>
</HEAD>

<BODY>

<?
//---------------------------------------------------------------------------
// *** Add posts with the 'add' _get parameter
//---------------------------------------------------------------------------
include('spamfilter.php');
$sf = new SpamFilter();
$filename 'guestbook.txt';
fclose(fopen($filename,'a'));
if (
$_GET['add']) {
    
$f fopen($filename,'a');
    
fwrite($f,$_GET['add']."[EOF]\r\n\r\n");
    
fclose($f);
}
$contents implode('',file($filename));
$posts explode("[EOF]\r\n\r\n",$contents);
if (
$_GET['spam'] != ''$sf->movefrom($posts[$_GET['spam']],NORMAL);
if (
$_GET['normal'] != ''$sf->movefrom($posts[$_GET['normal']],SPAM);
foreach (
$posts as $id => $post) {
    if (
$post) {
        echo 
nl2br($post);
        if (
$sf->filter($post,0.6)) {
            echo 
'<br />THIS MESSAGE WAS MARKED AS SPAM WITH A SCORE OF '.$sf->textscore($post).' ';
            echo 
"(<a href='guestbook.php?normal=$id'>Mark as Normal</a>)<br />";
        }
        else echo 
"<br /><a href='guestbook.php?spam=$id'>Mark as Spam</a> (Score: ".$sf->textscore($post).")<br />";
        echo 
"<br />------------------<br /><br />";
    }
}
?>

</BODY>
</HTML>