PHP Classes

How to use

Recommend this page to a friend!

      Spam Filter  >  All threads  >  How to use  >  (Un) Subscribe thread alerts  
Subject:How to use
Summary:question how to use
Date:2005-06-02 10:44:32
Update:2006-12-14 06:10:39

  1. How to use   Reply   Report abuse  
Picture of matthijs matthijs - 2005-06-02 10:44:32
Hi, I was wondering if someone has some more info on how to use this class. I uploaded everything, and got it working as it is. However, how could I implement this on an excisting guestbook script for example?

  2. Re: How to use   Reply   Report abuse  
Picture of Rafael Pinto Rafael Pinto - 2005-06-02 13:33:57 - In reply to message 1 from matthijs
Hi matthijs,
You must user the 'filter' method, like this:
$sf->filter($yourtext); //True if SPAM

The class will classify the text as spam or not-spam, while updating the knowledge base. ItŽs made by incrementing the word count of each word in the text in the selected class (spam or not-spam). So, if a text is recognized as spam, all of its words will be added to the spam knowledge base, so, new texts containing that words will be more likely to be recognized as spam. The same occurs to non-spam.

Now, for the guestbook:
YouŽll have to use 2 files/tables/etc. One for normal messages, that all users can see. The other will contain suspect messages, that were recognized as spam by the filter method returning true.
As an admin, you must have an option to unmark messages as spam. Use the method 'movefrom';
This will update the knowledge base, transfering the words from spam to not-spam. Also, youŽll have to transfer the message itself to the public area.
The same can be done to normal messages that are actually spam, using movefrom($normalmsg,NORMAL).

$sf->filter($yourtext) recognizes a message as spam (true) or not-spam (false) and updates the knowledge base.
$sf->movefrom($msg,SPAM) classify the words from $msg as not-spam, removing from spam.
$sf->movefrom($msg,NORMAL) classify the words from $msg as spam, removing from not-spam.

Still have questions?

Rafael C.P.

  3. Re: How to use   Reply   Report abuse  
Picture of matthijs matthijs - 2005-06-14 08:59:02 - In reply to message 2 from Rafael Pinto
Thanx a lot for your reply. (sorry for my late reply, it's hard to keep track of all the sites, discussions i'm following).

I'll start working with the tips you gave. As i'm a beginner, I'll probably have more questions, but better try something first.

Thanx again,

  4. Re: How to use   Reply   Report abuse  
Picture of Reunes Willy Reunes Willy - 2006-10-07 10:59:53 - In reply to message 3 from matthijs
I jusy dont figure it out.

my URL : www.pinguins.inf/bookg/

When somebody signes in, the message comes temp in a sql-file where i can approve or delete the post.

I'm getting a lot of spam lately, so i would add your spamfilter.
How can i include the spamfilter in my guestbook ?

Here my temp php :

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #336699;
a:link {
color: #336699;
font-weight: bold;
text-decoration: none;
a:visited {
text-decoration: none;
a:hover {
text-decoration: underline;
a:active {
text-decoration: none;

<p><strong>After selecting an option. You will need to refresh this page to see
results. </strong></p>
<p><strong><a href="index.php">&lt;&lt; back to Admin Panel</a></strong>
// SXD Guestbook
// Version 1.0
// Author: SXDesigns (Kris McGee)
// Date: 05/19/2003
// CopyRight 2003 by SXDesigns
// Installation: Please see the readme file for installation instructions. Or visit our website
// at
// Support:
// By using this script, you agree not to hold the author responsible for any damages, or loss
// of data, revenue, etc... This script has no warranty either expressed or implied. If you break
// it. Its your responsibility to fix it, not mine. Support is available at our website.
// If you have any questions, you can contact me by our feedback form at
// our website.
//This file will show posts wiating approval from admin if admin wants to approve every post

$connaq = @mysql_connect($db, $db_user, $db_pass);
mysql_select_db($selected_db, $connaq);

//$sql = "SELECT name,email,icq,aim,msn,message,messageid,location,date,host,website FROM sxdguest LIMIT 0,30";
$sql = "SELECT `name`,`email`,`icq`,`aim`,`msn`,`message`,`messageid`,`host`,`website`,`date`,`location` FROM `sxdguest_waiting` WHERE 1 ORDER BY `messageid` ASC LIMIT 0,30";
$resultID = mysql_query($sql);
for($x=0; $x<$num_rows; $x++)
$row = mysql_fetch_assoc($resultID);

$host = $row['host'];
$name = $row['name'];
$location = $row['location'];
$date = $row['date'];
$messageid = $row['messageid'];
$msn = $row['msn'];
$aim = $row['aim'];
$email = $row['email'];
$website = $row['website'];
$message = $row['message'];
$icq = $row['icq'];

//Start printing the table for each guestbook entry
print "<table width=\"100%\" border=\"2\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#000000\">";
print "<tr bordercolor =\"#000000\"> ";
print "<td width=\"27%\" height=\"18\" bgcolor=\"#eeeeee\"> $name </td>";
print "<td width=\"24%\" bgcolor=\"#eeeeee\">Location: $location </td>";
print "<td width=\"22%\" bgcolor=\"#eeeeee\"> $date</td>";
print "<td width=\"27%\" bgcolor=\"#eeeeee\">$messageid</td>";
print "</tr> <tr>";
print "<td height=\"87\" colspan=\"4\" bordercolor=\"#ffffff\"><blockquote> ";
print "<p> $message </p>";
print "</blockquote></td>";
print "</tr>";
print "<tr bordercolor=\"ffffff\"> ";
print "<td height=\"31\" colspan=\"2\">";
if($aim != ""){
echo "<img src=\"../images/collect.gif\" border=\"0\"> ";
if($icq > 2){
print "<a href=\"$icq \"><img src=\"../images/icq.jpg\" border=\"0\"></a>";
if($msn != ""){
echo "<a href=\"$email\"><img src=\"../images/msn.jpg\" border=\"0\"></a>";
if($email !=""){
echo "<a href=\"mailto:$email\"><img src=\"../images/email.gif\" border=\"0\"></a>";
if($website !=""){
echo "<a href=\"$website\" target=\"_blank\"><img src=\"../images/home.gif\" border=\"0\"></a>";
echo "</td>";
print "<td>&nbsp;</td>";
print "<td><div align=\"center\">$host </div></td>";
print "</tr></table>";
echo "<table width=\"100%\" border=\"2\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#000000\" bgcolor=\"#dddddd\"><tr>";
echo "<td><div align=\"center\"><a href=\"$PHP_SELF?ip=$host\" class=\"messagehead\">Ban This IP</a></div></td>";
echo "<td><div align=\"center\"><a href=\"$PHP_SELF?ap=$messageid\" class=\"messagehead\">Approve Post</a></div></td>";
echo "<td><div align=\"center\"><a href=\"$PHP_SELF?dp=$messageid\" class=\"messagehead\">Delete Post</a></div></td>";
//echo "<td><div align=\"center\" class=\"messagehead\"><a href=\"$PHP_SELF?mp=$messageid\" class=\"messagehead\">Edit Post</a></div></td>";
echo "</tr></table>";
echo "<br><br>";
//write post to database
//then delete it from waiting posts
$cppp = @mysql_connect($db, $db_user, $db_pass);
mysql_select_db($selected_db, $cppp);
$sql9 = "SELECT `name`,`email`,`icq`,`aim`,`msn`,`message`,`messageid`,`host`,`website`,`date`,`location` FROM `sxdguest_waiting` WHERE `messageid` = '$ap' LIMIT 1";
$row44 = mysql_query($sql9);
$row4 = mysql_fetch_assoc($row44);

$host = $row4['host'];
$name = $row4['name'];
$location = $row4['location'];
$date = $row4['date'];
$messageid = $row4['messageid'];
$msn = $row4['msn'];
$aim = $row4['aim'];
$email = $row4['email'];
$website = $row4['website'];
$message = $row4['message'];
$icq = $row4['icq'];
$sql8 ="INSERT INTO `sxdguest` (`name`, `email`, `icq`, `aim`, `msn`, `message`, `messageid`, `host`, `website`, `date`, `location`) VALUES ('$name', '$email', '$icq', '$aim', '$msn', '$message', '', '$host', '$website', '$date', '$location');";

$sql5 = "DELETE FROM `sxdguest_waiting` WHERE `messageid` = '$ap' LIMIT 1";


//add new IP to banned ip table
$cppp2 = @mysql_connect($db, $db_user, $db_pass);
mysql_select_db($selected_db, $cppp2);
$sql5 = "INSERT INTO `sxbanned_ip` (`ip`) VALUES ('$ip');";

$cppp3 = @mysql_connect($db, $db_user, $db_pass);
mysql_select_db($selected_db, $cppp3);
$sql6 = "DELETE FROM `sxdguest_waiting` WHERE `messageid` = '$dp' LIMIT 1";



  5. Re: How to use   Reply   Report abuse  
Picture of Ranjan Goyal Ranjan Goyal - 2006-12-14 06:10:39 - In reply to message 2 from Rafael Pinto

I am bit unclear about this and hence this post.

what my confusion is

1. Where I can put the words that I want to be considered as spam?

2. I don't understand the format in data.skb.

Say, I want to add some words in the knowledge base so that when ever those words appear in the mail content then mail sender came to know that these are the words that should not be in the content.

I hope you are getting me. If not then please let me know.

Please help me to understand this.