[geeklog-cvs] geeklog-1.3/plugins/spamx ArrayWriter.class.php,NONE,1.1 BaseAdmin.class.php,NONE,1.1 BaseCommand.class.php,NONE,1.1 BlackList.Examine.class.php,NONE,1.1 Config.Admin.class.php,NONE,1.1 DeleteComment.Action.class.php,NONE,1.1 EditBlackList.Admin.class.php,NONE,1.1 INSTALL,NONE,1.1 Import.Admin.class.php,NONE,1.1 LogView.Admin.class.php,NONE,1.1 MTBlackList.Examine.class.php,NONE,1.1 MailAdmin.Action.class.php,NONE,1.1 README,NONE,1.1 ViewBlacklist.Admin.class.php,NONE,1.1 config.php,NONE,1.1 functions.inc,NONE,1.1 index.html,NONE,1.1 rss.inc.php,NONE,1.1

tony at iowaoutdoors.org tony at iowaoutdoors.org
Fri Sep 3 15:59:57 EDT 2004


Update of /var/cvs/geeklog-1.3/plugins/spamx
In directory www:/tmp/cvs-serv3542/plugins/spamx

Added Files:
	ArrayWriter.class.php BaseAdmin.class.php 
	BaseCommand.class.php BlackList.Examine.class.php 
	Config.Admin.class.php DeleteComment.Action.class.php 
	EditBlackList.Admin.class.php INSTALL Import.Admin.class.php 
	LogView.Admin.class.php MTBlackList.Examine.class.php 
	MailAdmin.Action.class.php README 
	ViewBlacklist.Admin.class.php config.php functions.inc 
	index.html rss.inc.php 
Log Message:
Spamx is officially part of Geeklog.  All should work fine minus the upgrade file...I'm still missing some key data that I will add yet this weekend


--- NEW FILE: index.html ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: BaseCommand.class.php ---
<?php

/**
* Basic Command Abstract class
*
* @author	Tom Willett	tomw AT pigstye DOT net
*
*/
class BaseCommand {
	/**
	* @access public
	*/
	
	var $comment;   //Comment array
	
	var $result = null;    //Result of execute command
	
	/**
	* Constructor
	*
	* @access public
	*
	*/
	function BaseCommand()
	{	
		global $comment;
		
		$comment = array();
	}
	
	function execute()
	{
		return 0;
	}
	
	function init($comm) {
		global $comment;
		
		$comment = $comm;
	}

	function getComment() {
		global $comment;
		return $comment;
	}
	function result()
	{
		global $result;
		
		return $result;
	}
}
?>
--- NEW FILE: MTBlackList.Examine.class.php ---
<?php
/**
* File: MTBlackList.Examine.class.php
* This module examines comments for entries on the MT-Blacklist for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
*
* @ Author		Tom Willett		tomw at pigstye.net
*
* Licensed under GNU General Public License
*
* The MT-Blacklist is maintained by Jay Allen
* http://www.jayallen.org/comment_spam/
*
*/

/**
*Include Abstract Examine Class
*
*/
require_once($_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php');


/**
* Examines Comment according to MT-BLacklist
*
* @author Tom Willett tomw AT pigstye DOT net
*
*/

class MTBlackList extends BaseCommand {
	/**
	* No Constructor Use BaseCommand constructor
	*
	*/
	/**
	* Here we do the work
	*
	*/
	function execute()
	{
		global $_CONF, $comment, $_USER, $_TABLES, $REMOTE_ADDR, $LANG_SX00;
		
		/**
		* Include Blacklist Data
		*
		*/
		$result = DB_Query("SELECT * FROM {$_TABLES['spamx']} WHERE name='MTBlacklist'",1);
		$nrows = DB_numRows($result);
		
		$ans = 0;   //Found Flag
		for ($i=1;$i<=$nrows;$i++) {
			$A=DB_fetchArray($result);
			$val=$A['value'];
			if (@preg_match("#$val#",$comment['comment'])) {
				$ans=1;  // quit on first positive match
				SPAMX_log($LANG_SX00['fsc'] . $val . $LANG_SX00['fsc1'] . $_USER['uid'] . $LANG_SX00['fsc2'] . $REMOTE_ADDR);
				break;
			}
		}				
		return $ans;
	}
}

?>
--- NEW FILE: INSTALL ---
Tom Willett    tomw at pigstye.net
Unionville, Indiana, USA
June 13, 2004

Install/Uninstall instruction for the Geeklog SpamX plugin.

INSTALL:

Step 1:  Back up your Geeklog Database.  

Step 2: Uncompress the SpamX plugin archive while in the <geeklog_dir>/plugins directory.  The archive will
create a directory called spamx in the plugins directory.

Step 3:  Create the public_html and admin directories.  Under your html directory (usually public_html) 
create a directory called spamx.  Under your admin/plugins/ directory create a directory called spamx.

Step 4:  Change to your <geeklog_dir>/plugins/spamx/ directory.  Copy the files in the admin directory 
to the admin/plugins/spamx/ directory your created in step 3.  Copy the files and directories in the 
public_html directory to the public_html/spamx/ directory your created in step 3.

Step 5: Make the files spamx_action.php, spamx_examine.php, blacklist.php and mtblacklist.php in the 
public_html/spamx directory writable by you webserver.  Either chmod 766 or preferably chown the files 
to the user the webserver runs under eg nobody or apache.  If you do not do this you will not be able 
to use the admin interface.

Step 6:  Log in to your Geeklog as a root user and run install.php in your admin/plugins/SpamX/ directory 
or run the plugin app in the admin interface and install from there. The install page will tell you if the 
install was successful or not.  If not examine Geeklog system errorlog for possible problems.

Step 7: The final thing you must do is edit your comment.php (in public_html directory) and change the 
function savecomment name to savecomment1.  The SpamX plugin should now be installed and functioning.  
Clicking on the SpamX Icon will take you to the admin page.  

Step 7: Set up security.  On install only the root users have access to SpamX administration.  
You can delegate control for admin through the user and group editors.

UNINSTALL:

Step 1:  Run the install.php page in your admin/plugins/SpamX directory.  This will remove all the data from
your database.

Step 2: Rename savecomment1 in comment.php back to savecomment.

Step 3:  Delete the three plugin directories created in the install process:  <geeklog-dir>plugins/SpamX/ 
<public_html>/SpamX/ and <admin>/plugins/SpamX/

Thats it.

--- NEW FILE: functions.inc ---
<?php
/**
* File: functions.inc
* This is the functions.inc for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
*
* @ Author		Tom Willett		tomw at pigstye.net
*
* Licensed under GNU General Public License
*
*/

/**
* Language file Include
*/
$langfile = $_CONF['path'] . 'plugins/spamx/language/' . $_CONF['language'] . '.php';

if (file_exists ($langfile)) 
{
    include_once ($langfile);
}
else 
{
    include_once ($_CONF['path'] . 'plugins/spamx/language/english.php');
}

/*
* Include spamx config files
*/
require_once ($_CONF['path'] . 'plugins/spamx/config.php');

// +---------------------------------------------------------------------------+
// | Geeklog Plugin API Implementations                                        |
// +---------------------------------------------------------------------------+

/**
* Returns the items for this plugin that should appear on the main menu
*
* NOTE: this MUST return the url/value pairs in the following format
* $<arrayname>[<label>] = <url>
*
* Universal Plugin:  Uncomment and fill in variables;
* 
* @return    array   Associative array of menu items to be added to menu
*
*/
function plugin_getmenuitems_spamx()
{
    return array();
}

/**
* Check to see if this Plugin uses comments
*
* Geeklog is checking to see if this plugin supports comments, tell it no!
* NOTE: to support comments you must use the same date/time based ID for your
* widget.  In other words, to make primary keys for your plugin you should call
* makesid().  Comments are keyed off of that...it is a limitation on how geeklog
* does comments.
*
* @return   boolean true or false
*
*/
function plugin_commentsupport_spamx() 
{
    return false;
}

/**
* Shows the statistics for the plugin on stats.php.  If
* $showsitestats is 1 then we are to only print the overall stats in the 'site
* statistics' box otherwise we show the detailed stats for the plugin
*
* Universal Plugin:  Modify/uncomment use it
*
* @param    int showsitestate   Flag to let us know which stats to get
* @return   string  returns formatted HTML to insert in stats page
*
*/
function plugin_showstats_spamx($showsitestats) 
{
    $retval='';
    return $retval;
}

/**
* This will put an option for the plugin in the command and control block on moderation.php
*
* Add the plugin name, icon and link to the command and control block in moderation.php
*
* @return   array   Array containing (plugin name, admin url, url of plugin icon)
*
*/
function plugin_cclabel_spamx() 
{
    global $_CONF;

    $retval = array();
    if (SEC_hasRights('spamx.admin')) {
        $retval = array('spamx',$_CONF['site_admin_url'] . '/plugins/spamx/index.php',$_CONF['site_url'] . '/spamx/images/spamx.gif');
    }
    return $retval;
}

/**
* Returns the administrative option for this plugin
*
* Adds the plugin to the Admin menu
*
* Universal Plugin:  Modify/Uncomment use it
*
* @return   array   Array containing (plugin name, plugin admin url, # of items in plugin or '')
*
*/
function plugin_getadminoption_spamx() 
{
    global $_CONF;

    if (SEC_hasRights('spamx.admin')) {
        return array('spamx', $_CONF['site_admin_url'] . '/plugins/spamx/index.php', 0);
    }
}

/**
* Returns the user option for this plugin
*
* Adds the plugin to the user menu
*
* Universal Plugin:  modify/uncomment use it
*
* @return   array   Array containing (plugin name, plugin user url, 0)
*
*/
function plugin_getuseroption_spamx() 
{
}

/**
* Actual Plugin Functions here.
*
*/

/**
*Replacement for savecomment function in comment.php
*
*/

function plugin_commentPreSave_spamx($uid, $title, $comment, $sid, $pid, $type, $postmode, $extra=null, $extra2=null)
{
	global $_TABLES, $_CONF;

	// Set up Spamx_Action and SpamX_Examine arrays
	$result=DB_query("SELECT * FROM {$_TABLES['spamx']} WHERE name='Action'");
	$nrows = DB_numRows($result);
	for ($i=1;$i<=$nrows;$i++) {
		$A=DB_fetchArray($result);
		$Spamx_Action[]=$A['value'];
	}
    $result=DB_query("SELECT * FROM {$_TABLES['spamx']} WHERE name='Examine'");
    $nrows = DB_numRows($result);
    for ($i=1;$i<=$nrows;$i++) {
        $A=DB_fetchArray($result);
        $Spamx_Examine[]=$A['value'];
    }   
 
   	if ($extra == null) {
		$commnt = array(
			'uid'     => $uid,
			'title'   => $title,
			'comment' => $comment,
			'sid'     => $sid,
			'pid'     => $pid,
		   	'type'    => $type,
			'postmode'=> $postmode);
	} else {
		$commnt = array(
			'uid'     => $uid,
			'title'   => $sid,
			'comment' => $pid,
			'sid'     => $type,
			'pid'     => $postmode,
		   	'type'    => $extra,
			'postmode'=> $extra2);
	}

	$res=0;
    foreach ($Spamx_Examine as $Examine) {
		$filename = $Examine . '.Examine.class.php';
        if (file_exists($_CONF['path'] . 'plugins/spamx/' . $filename)) {
			require_once $_CONF['path'] . 'plugins/spamx/' . $filename;
			$EX = new $Examine;
			$EX->init($commnt);
			$res = $EX->execute();
			$commnt = $EX->getComment();
			if ($res == 1) {
				break;
			}
		}
	}
	if ($res == 1) {
		foreach($Spamx_Action as $Action) {
			$filename = $Action . '.Action.class.php';
			if (file_exists($_CONF['path'] . 'plugins/spamx/' . $filename)) {
				require_once($_CONF['path'] . 'plugins/spamx/' . $filename);
				$AC = new $Action;
       	        $AC->init($commnt);
				$AC->execute();	
				$commnt=$AC->getComment();
			}
		}
		return $AC->result();
	}
	return false;
}

/**
* Logs message to spamx.log
*
* This will print a message to the spamx log
*
* @logentry        string      $string         Message to write to log
*
*/

$_SPAMX_log_flg = true;		// Set to false to turn of logging

function SPAMX_log( $logentry )
{
    global $_CONF, $LANG01, $_SPAMX_log_flg;
    
    if ($_SPAMX_log_flg == true) {
	$timestamp = strftime( "%c" );
	$logfile = $_CONF['path_log'] . 'spamx.log';
           
    	if( !$file = fopen( $logfile, "a" ))
    	{
        	COM_errorLog($LANG01[33] . $logfile . ' (' . $timestamp . ')',1);
    	}
               
    	fputs( $file, "$timestamp - $logentry \n" );
    }          
    return $retval;
}

/**
* Filter parameters passed per GET (URL) or POST.
*
* @param    string    $parameter   the parameter to test
* @param    boolean   $isnumeric   true if $parameter is supposed to be numeric
* @return   string    the filtered parameter (may now be empty or 0)
* Borrowed from geeklog 1.3.9
*/
function SPAMX_applyFilter( $parameter, $isnumeric = false )
{
    global $HTTP_SERVER_VARS;

    $log_manipulation = false; // set to true to log when the filter applied

    $p = COM_stripslashes( $parameter );
    $p = strip_tags( $p );
    $p = COM_killJS( $p ); // doesn't help a lot right now, but still ...

    if( $isnumeric )
    {
        // Note: PHP's is_numeric() accepts values like 4e4 as numeric
        if( !is_numeric( $p ) || ( preg_match( '/^([0-9]+)$/', $p ) == 0 ))
        {
            $p = 0;
        }
    }
    else
    {
        $p = preg_replace( '/\/\*.*/', '', $p );
        $pa = explode( "'", $p );
        $pa = explode( '"', $pa[0] );
        $pa = explode( '`', $pa[0] );
        $pa = explode( ';', $pa[0] );
        $pa = explode( '\\', $pa[0] );
        $p = $pa[0];
    }

    if( $log_manipulation )
    {
        if( strcmp( $p, $parameter ) != 0 )
        {
            COM_errorLog( "Filter applied: >> $parameter << filtered to $p [IP {$HTTP_SERVER_VARS['REMOTE_ADDR']}]", 1);
        }
    }

    return $p;
}
                                        

/**
* Removes the datastructures for this plugin from the Geeklog database.
* This routine will get called from the Plugin install program if user select De-Install or if Delete is used in the Plugin Editor.
* The Plugin Installer will also call this routine upon and install error to remove anything it has created.
* The Plugin installer will pass the optional parameter which will then double check that plugin has first been disabled. 
* 
* For this plugin, this routine will also remove the Block definition.
* 
* Returns True if all Plugin related data is removed without error
*
* @param    string   $installCheck     Defult is blank but if set, check if plugin is disabled first
* 
* @return   boolean True if successful false otherwise
*
*/  
function plugin_uninstall_spamx($installCheck='')
{
    global $_TABLES, $LANG_SX00;

    // The spamxs need to be changed to the name of your plugin
    //
    $pi_name='spamx';
    $FEATURES = array ( 'spamx.admin', 'spamx.view');
    $TABLES = array ('table1','table2');
    
    // Check and see if plugin is still enabled - if so display warning and exit
    if ($installCheck != '' && DB_getItem($_TABLES['plugins'],'pi_enabled', 'pi_name = "' .$pi_name. '"')) {
	    COM_errorLog("Plugin is installed and enabled. Disable first if you want to de-install it",1);
		$display .= COM_startBlock($LANG_SX00['warning']);
		$display .= $LANG_SX00['enabled'];
		$display .= COM_endBlock();
		echo $display;
		return false;
		exit;
	}
    	
	// Ok to proceed and delete plugin

    // Unregister the plugin with Geeklog
    COM_errorLog('Attempting to unregister the spamx plugin from Geeklog',1);
    DB_query("DELETE FROM {$_TABLES['plugins']} WHERE pi_name = 'spamx'",1);

    // Remove Security for this plugin
    $grp_id = DB_getItem($_TABLES['vars'], 'value', "name = '{$pi_name}_gid'");
    
    COM_errorLog("Removing $pi_name Admin Group", 1);
    DB_query("DELETE FROM {$_TABLES['groups']} WHERE grp_id = $grp_id",1);
    DB_query("DELETE FROM {$_TABLES['vars']} WHERE name = '{$pi_name}_gid'");
    COM_errorLog("Removing root users from admin of $pi_name");
    DB_query("DELETE FROM {$_TABLES['group_assignments']} WHERE ug_main_grp_id = $grp_id",1);
    
    // Remove all the associated features -- access rights
    foreach ($FEATURES as $feature) {
        COM_errorLog("Removing $feature feature and rights to it",1);
        $feat_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = '$feature'");
        DB_query("DELETE FROM {$_TABLES['access']} WHERE acc_ft_id = $feat_id",1);
        DB_query("DELETE FROM {$_TABLES['features']} WHERE ft_id = $feat_id",1);
    }
        
    COM_errorLog('...success',1);
    return true;
}

?>
--- NEW FILE: Import.Admin.class.php ---
<?php
/**
* file:  Import.Admin.class.php
* MTBlacklist refresh module
*
* Updates Sites MT Blacklist via Master MT Blacklist rss feed
* 
* Copyright (C) 2004 by the following authors:
*
* @ Author		Tom Willett		tomw at pigstye.net
*
* Licensed under GNU General Public License
*
* Based on MT-Blacklist Updater by
* Cheah Chu Yeow (http://blog.codefront.net/)
*
*/

require_once($_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php');


class Import extends BaseAdmin {
	/**
	* Constructor
	* 
	*/
	function display(){
		global $_CONF, $rss_url, $_TABLES, $LANG_SX00;
		
		require_once($_CONF['path'] . 'plugins/spamx/magpierss/rss_fetch.inc');
		require_once($_CONF['path'] . 'plugins/spamx/magpierss/rss_utils.inc');
		
		$rss = fetch_rss($rss_url);
		// entries to add and delete, according to the blacklist changes feed
		$to_add = array();
		$to_delete = array();

		foreach( $rss->items as $item ) {
			// time this entry was published (currently unused)
			//  $published_time = parse_w3cdtf( $item['dc']['date'] );

			$entry = substr( $item['description'], 0, -3 );  // blacklist entry
			$subject = $item['dc']['subject'];  // indicates addition or deletion

			// is this an addition or a deletion?
			if( strpos( $subject, 'addition' ) !== false ) {
				// save it to database
				$result = DB_query('SELECT * FROM ' . $_TABLES['spamx'] . ' WHERE name="MTBlacklist" AND value="' . $entry . '"');
				$nrows = DB_numRows($result);
				if ($nrows < 1) {
					$result = DB_query('INSERT INTO ' . $_TABLES['spamx'] . ' VALUES ("MTBlacklist","' . $entry . '")');
					$to_add[]=$entry;
				}
			} else if( strpos( $subject, 'deletion' ) !== false ) {
				// delete it from database
				$result = DB_query('SELECT * FROM ' . $_TABLES['spamx'] . ' where name="MTBlacklist" AND value="' . $entry . '"');
				$nrows = DB_numRows($result);
				if ($nrows >= 1) {
					$result = DB_query('DELETE FROM ' . $_TABLES['spamx'] . ' where name="MTBlacklist" AND value="' . $entry . '"');
					$to_delete[]=$entry;
				}
			}
		}
		$display = '<hr><p><b>' . $LANG_SX00['entriesadded'] . '</b></p><ul>';
		foreach ($to_add as $e) {
			$display .= "<li>$e</li>";
		}
		$display .= '</ul><p><b>' . $LANG_SX00['entriesdeleted'] . '</b></p><ul>';
		foreach ($to_delete as $e) {
			$display .= "<li>$e</li>";
		}
		$display .= '</ul>';
		SPAMX_log($LANG_SX00['uMTlist'] . $LANG_SX00['uMTlist2'] . count($to_add) . $LANG_SX00['uMTlist3'] . count($to_delete) . $LANG_SX00['entries']);
		return $display;
	}
	
	function link()
	{
		global $LANG_SX00;
		return $LANG_SX00['uMTlist'];
	}
}

?>
--- NEW FILE: BaseAdmin.class.php ---
<?php

/**
* Abstract class for Admin Duties for Spam comments
*
* @author	Tom Willett	tomw AT pigstye DOT net
*
*/
class BaseAdmin {
	/**
	* @access private
	*/
	
	/**
	* Constructor
	*
	* @access public
	*
	*/
	function BaseAdmin()
	{
	}
	
	function display()
	{
		return '';
	}
	
	function link()
	{
		return '';
	}
}
?>
--- NEW FILE: Config.Admin.class.php ---
<?php
/**
* File: Config.Admin.class.php
* This is configures the modules used by the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
*
* @ Author		Tom Willett		tomw at pigstye.net
*
* Licensed under GNU General Public License
*
*/
/**
* SpamX config module
*
*/

require_once($_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php');

class Config extends BaseAdmin {
	/**
	* Constructor
	* 
	*/
	function display(){
		global $_CONF, $HTTP_GET_VARS, $_TABLES, $LANG_SX00;
		
		require_once($_CONF['path'] . 'plugins/spamx/ArrayWriter.class.php');
		// Set up Spamx_Actiona dn SpamX_Examine arrays
		$result=DB_query("SELECT * FROM {$_TABLES['spamx']} WHERE name='Action'");
		$nrows = DB_numRows($result);
		for ($i=1;$i<=$nrows;$i++) {
			$A=DB_fetchArray($result);
			$Spamx_Action[]=$A['value'];
		}
	    $result=DB_query("SELECT * FROM {$_TABLES['spamx']} WHERE name='Examine'");
    	$nrows = DB_numRows($result);
	    for ($i=1;$i<=$nrows;$i++) {
    	    $A=DB_fetchArray($result);
        	$Spamx_Examine[]=$A['value'];
	    }   
 
		// Handle possible actions

		$action = SPAMX_applyFilter($HTTP_GET_VARS['action']);
		$item = SPAMX_applyFilter($HTTP_GET_VARS['item']);
		$Eflg=0;
		$Aflg=0;
		if ($action == 'Edel') {
			$ta = array();
			$Eflg=1;
			foreach($Spamx_Examine as $it) {
				if ($it != $item) {
					$ta[]=$it;
				} else {
					$result = DB_query('DELETE FROM ' . $_TABLES['spamx'] . ' where name="Examine" AND value="' . $item . '"');
				}
			}
			$Spamx_Examine=$ta;
		} elseif ($action == 'Eadd'){
			$Spamx_Examine[]=$item;
			$result = DB_query('INSERT INTO ' . $_TABLES['spamx'] . ' VALUES ("Examine","' . $item . '")');
		} elseif ($action == 'Adel') {
			$ta = array();
			$Aflg=1;
			foreach($Spamx_Action as $it) {
				if ($it != $item) {
					$ta[]=$it;
                } else {
                    $result = DB_query('DELETE FROM ' . $_TABLES['spamx'] . ' where name="Action" AND value="' . $item . '"');
                }
                                                    
			}
			$Spamx_Action=$ta;
		} elseif ($action == 'Aadd'){
			$Spamx_Action[]=$item;
			$result = DB_query('INSERT INTO ' . $_TABLES['spamx'] . ' VALUES ("Action","' . $item . '")');
		}
		//Make File array and display Examine Modules
		$sfiles = array();
		$self = $_CONF['site_admin_url'] . '/plugins/spamx/index.php';
		if ($dir = @opendir($_CONF['path'] . 'plugins/spamx/')) {
    			while(($file = readdir($dir)) !== false) {
        			if (is_file($_CONF['path'] . 'plugins/spamx/' . $file)) 
       				{ 
        				if (substr($file,-18) == '.Examine.class.php') {
	        				$sfiles[] = str_replace(".Examine.class.php","",$file);
	        			}
        			}
    			}
    			closedir($dir);
		}
		$cnt = count($sfiles) - count($Spamx_Examine);
		if ($cnt > 0) {
			do {
				$cnt = $cnt-1;
				$Spamx_Examine[]="";
			} while ($cnt>0);
		}
		if ($cnt < 0) {
			do {
				$cnt = $cnt+1;
				$sfiles[]="";
			} while ($cnt<0);
		}
		$display = $LANG_SX00['coninst'];
		$display .= '<p align="center"><b>';
		$display .= $LANG_SX00['exmod'];
		$display .= '</b></p><table width="100%" border="1">';
		$display .= '<tr><td><b>';
		$display .= $LANG_SX00['actmod'];
		$display .= '</b></td><td><b>';
		$display .= $LANG_SX00['avmod'];
		$display .= '</b></td></tr>';
		foreach($Spamx_Examine as $it) {
			$sfile = each($sfiles);
			$display .= '<tr><td><a href="' . $self . '?command=Config&action=Edel&item=' . urlencode($it) . '">' . $it . '</a></td>';
			$display .= '<td><a href="' . $self . '?command=Config&action=Eadd&item=' . urlencode($sfile[1]) . '">' . $sfile[1] . '</a></td></tr>';
		}
		$display .= '</table>';
		// Make Array and display Action Modules
		$sfiles = array();
		if ($dir = @opendir($_CONF['path'] . 'plugins/spamx/')) {
    			while(($file = readdir($dir)) !== false) {
        			if (is_file($_CONF['path'] . 'plugins/spamx/' . $file)) 
       				{ 
        				if (substr($file,-17) == '.Action.class.php') {
	        				$sfiles[] = str_replace(".Action.class.php","",$file);
	        			}
        			}
    			}
    			closedir($dir);
		}
		$cnt = count($sfiles) - count($Spamx_Action);
		if ($cnt > 0) {
			do {
				$cnt = $cnt-1;
				$Spamx_Action[]="";
			} while ($cnt>0);
		}
		if ($cnt < 0) {
			do {
				$cnt = $cnt+1;
				$sfiles[]="";
			} while ($cnt<0);
		}
		$display .= '<p>';
		$display .= $LANG_SX00['coninst'];
		$display .= '<p align="center"><b>';
		$display .= $LANG_SX00['acmod'];
		$display .= '</b></p><table width="100%" border="1">';
		$display .= '<tr><td><b>';
		$display .= $LANG_SX00['actmod'];
		$display .= '</b></td><td><b>';
		$display .= $LANG_SX00['avmod'];
		$display .= '</b></td></tr>';
		foreach($Spamx_Action as $it) {
			$sfile = each($sfiles);
			$display .= '<tr><td><a href="' . $self . '?command=Config&action=Adel&item=' . urlencode($it) . '">' . $it . '</a></td>';
			$display .= '<td><a href="' . $self . '?command=Config&action=Aadd&item=' . urlencode($sfile[1]) . '">' . $sfile[1] . '</a></td></tr>';
		}
		$display .= '</table>';
		return $display;

	}
	
	function link()
	{
        global $LANG_SX00;
		
		return $LANG_SX00['conmod'];
	}
}

?>
--- NEW FILE: ArrayWriter.class.php ---
<?php

class ArrayWriter {

	var $filename;		//file name
	var $AName;			//array name minus $
	var $buff;			//array
	
	/**
	*
	* Constructor
	*/
	function ArrayWriter($fname, $name , $Abuf) {
		$this->filename = $fname;
		$this->Aname = $name;
		$this->buff = $Abuf;
	}
	/**
	*
	* Here the work is done
	*
	* return true if successful false otherwise
	*/
	function WriteArray() {
		
		$fp = fopen($this->filename,"w");
		if ($fp) {
			fputs($fp,"<?php\n" . '$' . $this->Aname . ' = array(' . "\n");
			$comma="";
			foreach($this->buff as $e){
				if ($comma == "") {
					$comma=",\n";
				} else {
					fputs($fp,$comma);
				}
				if ($e != '') {
					fputs($fp,"'$e'");
				}
			}
			fputs($fp,");\n?>");
			fclose($fp);
			$ret = 1;
		} else {
			$ret = 0;
		}
		return $ret;
	}
}
?>
--- NEW FILE: config.php ---
<?php
/**
* File: config.php
* This is the config file for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
*
* @ Author		Tom Willett		tomw at pigstye.net
*
* Licensed under GNU General Public License
*
*/

// URL blacklist changes RSS feed (currently only RSS v1.0 is supported)
$rss_url = 'http://www.jayallen.org/comment_spam/feeds/blacklist-changes.rdf';

// Spamx urls
$rss_spamx_url = 'http://www.pigstye.net/backend/spamx_users.rdf';
$spamx_submit_url = 'http://www.pigstye.net/gplugs/spamx/submit.php';

// address which mail admin module will use
$spamx_notification_email = $_CONF['site_mail'];

// This sets Ban Plugin Table Prefix the Same as Geeklog
$_BAN_table_prefix = $_DB_table_prefix;

// DO NOT CHANGE THE STUFF BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
// Add Spamx Plugin table to $_TABLES array
$_TABLES['spamx']      = $_BAN_table_prefix . 'spamx';
?>
--- NEW FILE: EditBlackList.Admin.class.php ---
<?php
/**
* File: EditBlackList.Admin.class.php
* This is the Edit Personal Blacklist Module for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
*
* @ Author		Tom Willett		tomw at pigstye.net
*
* Licensed under GNU General Public License
*
*/

/**
* Personal Black List Editor
*
*/

require_once($_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php');

class EditBlackList extends BaseAdmin {
	/**
	* Constructor
	* 
	*/
	function display(){
		global $_CONF, $HTTP_GET_VARS, $HTTP_POST_VARS, $_TABLES, $LANG_SX00;

		require_once $_CONF['path'] . 'plugins/spamx/rss.inc.php';
		
		$action = SPAMX_applyFilter($HTTP_GET_VARS['action']);
		if (empty($action)) {
			$action = SPAMX_applyFilter($HTTP_POST_VARS['paction']);
		}

		$entry = SPAMX_applyFilter($HTTP_GET_VARS['entry']);
		if (empty($entry)) {
			$entry = SPAMX_applyFilter($HTTP_POST_VARS['pentry']);
		}

		if ($action == 'delete') {
			$result = DB_query('DELETE FROM ' . $_TABLES['spamx'] . ' where name="Personal" AND value="' . $entry . '"');
		} elseif ($action == $LANG_SX00['addentry']) {
			if ($entry != "") {
				$result = DB_query('INSERT INTO ' . $_TABLES['spamx'] . ' VALUES ("Personal","' . $entry . '")');
			}
		} elseif ($action == $LANG_SX00['addcen']) {
			foreach($_CONF['censorlist'] as $entry) {
				$result = DB_query('INSERT INTO ' . $_TABLES['spamx'] . ' VALUES ("Personal","' . $entry . '")');
			}
		}
		
		$display = '<hr><p><b>';
		$display .= $LANG_SX00['pblack'];
		$display .= '</b></p><ul>';
		$result = DB_query('SELECT * FROM ' . $_TABLES['spamx'] . ' WHERE name="Personal"');
        $nrows = DB_numRows($result);
        for($i=1;$i<=$nrows;$i++) {
        	$A=DB_fetchArray($result);
        	$e=$A['value'];
			$display .= '<li><a href="' . $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=EditBlackList&action=delete&entry=' . urlencode($e) . '">' . $e . '</a></li>';
		}
		$display .= '</ul><p>' . $LANG_SX00['e1'] . '</p>';
		$display .= '<p>' . $LANG_SX00['e2'] . '</p>';
		$display .= '<form method="post" action="' . $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=EditBlackList">';
		$display .= '<input type="text" size ="30" name="pentry">   ';
		$display .= '<input type="Submit" name="paction" value="' . $LANG_SX00['addentry'] . '">';
		$display .= '<p>' . $LANG_SX00['e3'] . '&nbsp&nbsp&nbsp';
		$display .= '<input type = "Submit" name="paction" value="' . $LANG_SX00['addcen'] . '">';
		$display .= '</form>';
		return $display;
	}
	
	function link()
	{
		return "Edit Personal Blacklist";
	}
}

?>
--- NEW FILE: MailAdmin.Action.class.php ---
<?php
/**
* File: DeleteComment.Action.class.php
* This is the Delete Comment Action  for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
*
* @ Author		Tom Willett		tomw at pigstye.net
*
* Licensed under GNU General Public License
*
*/

/**
* Include Abstract Action Class
*
*/
require_once($_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php');


/**
* Action Class which just discards comment
*
* @author Tom Willett  tomw at pigstye.net
*
*/
class MailAdmin extends BaseCommand {
	/**
	* No Constructor  Uses BaseCommand
	*
	*/

	function execute()
	{
		global $result, $_CONF, $LANG_SX00, $comment, $spamx_notification_email;
		$msg = 'A new comment has been posted at ' . $_CONF['site_name'] . ":\n";
		$msg .= "Title: {$comment['title']}\n";
		$msg .= "UID: {$comment['uid']}\n";
		$msg .= "Content: {$comment['comment']}";
		COM_mail($spamx_notification_email, 'Spam Comment at ' . $_CONF['site_name'], $msg);
		$result = '';
		SPAMX_log('Mail Sent to Admin');
		return 1;
	}
}
?>
--- NEW FILE: ViewBlacklist.Admin.class.php ---
<?php
/**
* File: ViewBlacklist.Admin.class.php
* This is a Module which allows you to view/import other blacklists. for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
*
* @ Author		Tom Willett		tomw at pigstye.net
*
* Licensed under GNU General Public License
*
*/

require_once($_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php');

class ViewBlacklist extends BaseAdmin {
	/**
	* Constructor
	* 
	*/
	function display(){
		global $_CONF, $rss_spamx_url, $HTTP_GET_VARS, $HTTP_POST_VARS, $_TABLES, $spamx_submit_url, $LANG_SX00;
		
		require_once($_CONF['path'] . 'plugins/spamx/magpierss/rss_fetch.inc');
		require_once($_CONF['path'] . 'plugins/spamx/magpierss/rss_utils.inc');
		require_once($_CONF['path'] . 'plugins/spamx/rss.inc.php');
		
		$result = DB_query("SELECT * FROM {$_TABLES['spamx']} where name='Personal'");
		$nrows=DB_numRows($result);
		for($i=1;$i<=$nrows;$i++) {
			$A=DB_fetchArray($result);
			$SPAMX_BLACKLIST[]=$A['value'];
		}
		$action = SPAMX_applyFilter($HTTP_GET_VARS['action']);
		$paction = SPAMX_applyFilter($HTTP_POST_VARS['paction']);
		$site = SPAMX_applyFilter($HTTP_GET_VARS['site']);
		$rss = fetch_rss($rss_spamx_url);
		if ($action == 'import') {
			$rdf='';
			foreach($rss->items as $item) {
				if ($item['title'] == $site) {
					$rdf = $item['rdf'];
					break;
				}
			}
			if ($rdf != '') {
				$rss=fetch_rss($rdf);
				$i=0;
				foreach($rss->items as $item){
					$result = DB_query('INSERT INTO ' . $_TABLES['spamx'] . ' VALUES ("Personal","' . $item['title'] . '")');
					$SPAMX_BLACKLIST[]=$item['title'];
					$i=$i+1;
				}
				Spamx_rss($SPAMX_BLACKLIST);
                SPAMX_log($LANG_SX00['add1'] . $i . $LANG_SX00['add2'] . $site . $LANG_SX00['add3']);
                return COM_refresh($_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=EditBlackList');
            }
		}
		if ($paction == 'Create Rss') {
			Spamx_rss($SPAMX_BLACKLIST);
			$display = $LANG_SX00['rsscreated'] . '<br>';
			$display .= '<form method="post" action="' . $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=ViewBlackList">';
			$display .= '<input type="submit" name="paction" value="' . $LANG_SX00['ok'] . '">';
			$display .= '</form>';
			DB_query("Replace INTO " . $_TABLES['vars'] . " set name='spamx', value=1");
					
		} elseif (DB_getItem($_TABLES['vars'],'value','name = "spamx"') == 1) {
			$display .= "<p><b>" . $LANG_SX00['availb'] . "</b></p><table border='1' cellpadding='4'>";
			$display .= '<tr><td>' . $LANG_SX00['clickv'] . '</td><td>' . $LANG_SX00['clicki'] . '</td></tr>';
			foreach($rss->items as $item) {
				$display .= '<tr><td><a href="' . $item['link'] . '">' . $item['title'] . '</a></td>';
				$display .= '<td><a href="' . $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=ViewBlackList&action=import&site=' . urlencode($item['title']) . '">Import ' . $item['title'] . '</a></td></tr>';
			}
			$display .= '</table>';

		} else {
			$display = '<p>' . $LANG_SX00['impinst1a'] . $LANG_SX00['impinst1b'] . '</p><p>';
			$display .= $LANG_SX00['impinst2'] . $LANG_SX00['impinst2a'] . $LANG_SX00['impinst2b'];
			$display .= $LANG_SX00['impinst2c'] . '</p>';
			$display .= $LANG_SX00['impinst3'];
			$display .= '<form method="post" action="' . $spamx_submit_url . '">';
			$display .= '<table>';
			$display .= '<tr><td>' . $LANG_SX00['sitename'] . '</td><td><input type="text" size="45" name="site" value="' . $_CONF['site_name'] . '"></td></tr>';
			$display .= '<tr><td>' . $LANG_SX00['URL'] . '</td><td><input type="text" size="45" name="url" value="' . $_CONF['site_url'] . '/spamx/index.php"></td></tr>';
			$rdfpath = str_replace($_CONF['path_html'],"",dirname($_CONF['rdf_file']));
			$display .= '<tr><td>' . $LANG_SX00['RDF'] . '</td><td><input type="text" size="45" name="rdf" value="' . $_CONF['site_url'] . '/' . $rdfpath . '/spamx.rdf"></td></tr>';
			$display .= '</table>';
			$display .= '<input type="submit" name="paction" value="' . $LANG_SX00['submit'] . '"> ' . $LANG_SX00['subthis'];
			$display .= '</form>';
			$display .= '<p>This second button creates an rdf feed so that others can import your list.</p>';
			$display .= '<form method="post" action="' . $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=ViewBlackList">';
			$display .= '<input type="submit" name="paction" value="Create Rss">';
			$display .= '</form>';
			$display .= $LANG_SX00['inst1'];
			$display .= $LANG_SX00['inst2'];
			$display .= $LANG_SX00['inst3'];
			$display .= $LANG_SX00['inst4'];
			$display .= $LANG_SX00['inst5'];
		}
		return $display;
	}
	
	function link()
	{
		return "View/Import Other SpamX Blacklists";
	}
}

?>
--- NEW FILE: README ---
Tom Willett     tomw at pigstye.net
Unionville, Indiana, USA
June 13, 2004

The Geeklog SpamX plugin was created to fight the problem of comment spam for 
Geeklog systems. If you are unfamiliar with comment spam you might see the
Comment Spam Manifesto at http://kalsey.com/2003/11/comment_spam_manifesto/.
The main mechanism SpamX uses to fight comment spam is to use the blacklist 
created by Jay Allen and Movable type Users - MT-Blacklist.  You can find out
info about this project at http://www.jayallen.org/comment_spam/. Jay has taken
it upon himself not only to write and support the plugin for movable type but
also to maintain the blacklist.  This requires human effort to review all the
submissions and determine which are really spam and which are just noise.  If
you have a few extra bucks drop by Jay's website above and drop a few dollars
in his paypal account to show your appreciation.  

The MT-Blacklist theory is that comment spammers do it to increase their google 
rankings and therefore the link is all important.  The MT-Blacklist therefore
only filters on urls.

The MT-Blacklist is only one part of the Geeklog SpamX plugin however.  The
SpamX plugin has its own personal blacklist that you can add to. You can
use it to filter anything from comments.  One option is to import the Geeklog
censor list and ban all comments which contain one of those words.  This or an
expanded list might be usefull for a website that caters to children.  Then no
comments with offensive language could be posted.

The SpamX plugin was built to be expandable to easily adapt to changes the
comment spammers might make.  There are three types of modules admin, examin
and action.  A new module is contained in a file and can simply be dropped in
and it will be added to the plugin.  The modules with which the plugin ships
are:  
Admin -> View SpamX log, 
	 Update MT-Blacklist, 
	 Edit Personal Blacklist,
	 View/Import Other Personal Blacklists, 
	 Configure Spamx Modules; 
Examine -> MT-Blacklist, 
	   Personal Blacklist; 
Action -> Delete Comment if on Blacklist,
	  Mail Admin if Comment Rejected. (requires 1.3.9)

Other modules can be just dropped into place.  Planned modules include:
Admin->  Easy mass deletion of spam comments.
	 Parsing comments and automatic adding spam links.
	 Comparing MT-Blacklist and personal blacklist to eliminate duplications.
Examine -> Other parsing of comments like making links clickable.
	 Specialized blacklists.  (These are in planning stages).
Action -> Save comment for review.

One feature of the SpamX plugin is the ability to share your blacklist and to
view and import the Blacklists of other SpamX plugin users.  Your participation
in this will help give early warning to other SpamX plugin users.  This
facility will also make it possible to create special blacklists for different
classes of users such as k-12 schools. The sharing of blacklists uses rss feeds 
to distibute the blacklists.  If anyone wants to create a special blacklist I 
will make the server and interface scripts to facilitate this.

TomW
--- NEW FILE: rss.inc.php ---
<?php

/** 
* Create the spamx rss feed
*
* @param items	array of blacklisted sites
*/

function Spamx_rss($items) {
	global $_CONF;

	// Basic Data
	$about = $_CONF['site_url'] . '/spamx/index.php';
	$title = 'SpamX Blacklist';
	$description = 'Personal Spamx Blacklist from site ' . $_CONF['site_name'];
	// Dublic Core Data
	$dc = array('dc:publisher' => $_CONF['site_name'],
				'dc:creator'   => $_CONF['site_name'],
				'dc:date'      => time());
	$rssfile = new RSSWriter($about, $title, $description, $dc);
	
	//  Add items
	foreach($items as $item) {
		$about = $_CONF['site_url'] . '/spamx/index.php';  
		$title = $item;
		$description = $item;
		$dc = array('dc:subject' => 'Personal Blacklist',
					'dc:author'  => $_CONF['site_name']);
		$rssfile->addItem($about, $title, $dc);
	}

	// Now write the file
	
	$buff = $rssfile->serialize();
	$rdfpath = dirname($_CONF['rdf_file']);
	$rdffile = $rdfpath . '/spamx.rdf';
	$fp = fopen($rdffile,"w");
	fputs($fp,$buff);
	fclose($fp);	
}

//
// A convenience class to make it easy to write RSS classes
// Edd Dumbill <mailto:edd+rsswriter at usefulinc.com>
//
// Revision 1.4  2004/06/11 11:00  towm
// Changed output to string
//
// Revision 1.3  2001/05/20 17:58:02  edmundd
// Final distribution tweaks.
//
// Revision 1.2  2001/05/20 17:41:30  edmundd
// Ready for distribution.
//
// Revision 1.1  2001/05/20 17:01:43  edmundd
// First functional draft of code working.
//
// Revision 1.1  2001/05/17 18:17:46  edmundd
// Start of a convenience library to help RSS1.0 creation
//

class RSSWriter {

function RSSWriter($uri, $title, $description, $meta=array()) {
	$this->chaninfo=array();
	$this->website=$uri;
	$this->chaninfo["link"]=$uri;
	$this->chaninfo["description"]=$description;
	$this->chaninfo["title"]=$title;
	$this->items=array();
	$this->modules=array("dc" => "http://purl.org/dc/elements/1.1/");
	$this->channelURI=str_replace("&", "&", "http://" . $GLOBALS["SERVER_NAME"] . $GLOBALS["REQUEST_URI"]);
	foreach ($meta as $key => $value) {
		$this->chaninfo[$key]=$value;
	}
}

function useModule($prefix, $uri) {
	$this->modules[$prefix]=$uri;
}

function setImage($imgURI, $imgAlt, $imgWidth=88, $imgHeight=31) {
	$this->image=array(
		"uri" => $imgURI, "title" => $imgAlt, "width" => $imgWidth,
		"height" => $imgHeight);
}

function addItem($uri, $title, $meta=array()) {
	$item=array("uri" => $uri, "link" => $uri, 
		"title" => $this->deTag($title));
	foreach ($meta as $key => $value) {
		if ($key == "description" || $key == "dc:description") {
			$value=$this->deTag($value);
		}
		$item[$key]=$value;
	}
	$this->items[]=$item;
}

function serialize() {
	$buff = $this->preamble();
	$buff.= $this->channelinfo();
	$buff.= $this->image();
	$buff.= $this->items();
	$buff.= $this->postamble();
	return $buff;
}

function deTag($in) {
  while(ereg('<[^>]+>', $in)) {
	$in=ereg_replace('<[^>]+>', '', $in);
  }
  return $in;
}

function preamble() {
	//header("Content-type: text/xml");
	$display = '<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF 
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns="http://purl.org/rss/1.0/"
         xmlns:mn="http://usefulinc.com/rss/manifest/"
';
	foreach ($this->modules as $prefix => $uri) {
		$display .= "         xmlns:${prefix}=\"${uri}\"\n";
	}
	$display .= ">\n\n";
	return $display;
}

function channelinfo() {
	$display = '  <channel rdf:about="' .  $this->channelURI . '">';
	$i=$this->chaninfo;
	foreach (array("title", "link", "dc:source", "description", "dc:language", "dc:publisher",
		"dc:creator", "dc:rights") as $f) {
		if (isset($i[$f])) {
			$display .= "    <${f}>" . htmlspecialchars($i[$f]) . "</${f}>\n";
		}
	}
	if (isset($this->image)) {
		$display .= "    <image rdf:resource=\"" . htmlspecialchars($this->image["uri"]) . "\" />\n";
	}
	$display .= "    <items>\n";
	$display .= "      <rdf:Seq>\n";
	foreach ($this->items as $i) {
		$display .= "        <rdf:li rdf:resource=\"" . htmlspecialchars($i["uri"]) . "\" />\n";
	}
	$display .= "      </rdf:Seq>\n";
	$display .= "    </items>\n";
	$display .= "  </channel>\n\n";
	return $display;
}

function image() {
	$display = '';
	if (isset($this->image)) {
	$display .= "  <image rdf:about=\"" . htmlspecialchars($this->image["uri"]) . "\">\n";
    $display .= "     <title>" . htmlspecialchars($this->image["title"]) . "</title>\n";
    $display .= "     <url>" . htmlspecialchars($this->image["uri"]) . "</url>\n";
    $display .= "     <link>" . htmlspecialchars($this->website) . "</link>\n";
    if ($this->chaninfo["description"]) 
   	 $display .= "     <dc:description>" . htmlspecialchars($this->chaninfo["description"]) . 
   	 	"</dc:description>\n";
	$display .= "  </image>\n\n";
	}
	return $display;
}

function postamble() {
	$display = '  <rdf:Description rdf:ID="manifest">
    <mn:channels>
      <rdf:Seq>
        <rdf:li rdf:resource="' . $this->channelURI . '" />
      </rdf:Seq>
    </mn:channels>
  </rdf:Description>

</rdf:RDF>
';
	return $display;
}

function items() {
	$display = '';
	foreach ($this->items as $item) {
		$display .= "  <item rdf:about=\"" .  htmlspecialchars($item["uri"]) . "\">\n";
		foreach ($item as $key => $value) {
			if ($key!="uri") {
				if (is_array($value)) {
					foreach ($value as $v1) {
						$display .= "    <${key}>" . htmlspecialchars($v1) . "</${key}>\n";
					}
				} else {
					$display .= "    <${key}>" . htmlspecialchars($value) . "</${key}>\n";
				}
			}
		}
		$display .= "  </item>\n\n";
	}
	return $display;
}

}

?>
--- NEW FILE: LogView.Admin.class.php ---
<?php
/**
* File: Logview.Admin.class.php
* This is the LogViewer for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
*
* @ Author		Tom Willett		tomw at pigstye.net
*
* Licensed under GNU General Public License
*
*/

require_once($_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php');

class LogView extends BaseAdmin {
	/**
	* Constructor
	* 
	*/
	function display(){
		global $_CONF, $HTTP_POST_VARS, $LANG_SX00;
		
		$action = SPAMX_applyFilter($HTTP_POST_VARS['action']);
		$path = $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=LogView';
		$log = 'spamx.log';
		$display .= "<form method=\"post\" action=\"{$path}\">";
		$display .= "<input type=\"submit\" name=\"action\" value=\"{$LANG_SX00['clearlog']}\">";
		$display .= "</form>";
		if ($action == $LANG_SX00['clearlog']) {
		    $timestamp = strftime( "%c" );
		    $fd = fopen( $_CONF['path_log'] . $log, "w");
		    fputs( $fd, "$timestamp {$LANG_SX00['logcleared']} \n" );
   		    fclose($fd);
		}
		$display .= "<hr><pre>";
    		$display .= implode('', file($_CONF['path_log'] . $log));
    		$display .= "</pre>";
		return $display;

	}
	
	function link()
	{
		global $LANG_SX00;
		
		return $LANG_SX00['viewlog'];
	}
}

?>
--- NEW FILE: DeleteComment.Action.class.php ---
<?php
/**
* File: DeleteComment.Action.class.php
* This is the Delete Comment Action  for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
*
* @ Author		Tom Willett		tomw at pigstye.net
*
* Licensed under GNU General Public License
*
*/

/**
* Include Abstract Action Class
*
*/
require_once($_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php');


/**
* Action Class which just discards comment
*
* @author Tom Willett  tomw at pigstye.net
*
*/
class DeleteComment extends BaseCommand {
	/**
	* No Constructor  Uses BaseCommand
	*
	*/

	function execute()
	{
		global $result, $_CONF, $LANG_SX00;
		$result = COM_refresh ($_CONF['site_url'] . '/index.php');
		SPAMX_log($LANG_SX00['spamdeleted']);
		return 1;
	}
}
?>
--- NEW FILE: BlackList.Examine.class.php ---
<?php
/**
* File: BlackList.Examine.class.php
* This is the Personal BlackList Examine class for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
*
* @ Author		Tom Willett		tomw at pigstye.net
*
* Licensed under GNU General Public License
*
*/

/**
*Include Abstract Examine Class
*
*/
require_once($_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php');


/**
* Examines Comment according to Personal BLacklist
*
* @author Tom Willett tomw AT pigstye DOT net
*
*/

class BlackList extends BaseCommand {
	/**
	* No Constructor Use BaseCommand constructor
	*
	*/
	/**
	* Here we do the work
	*
	*/
	function execute()
	{
		global $_CONF, $result, $comment, $_USER, $_TABLES, $REMOTE_ADDR, $LANG_SX00;
		
		/**
		* Include Blacklist Data
		*
		*/
		$result=DB_query("SELECT * FROM {$_TABLES['spamx']} WHERE name='Personal'",1);
		$nrows=DB_numRows($result);

		$ans = 0;
		for($i=1;$i<=$nrows;$i++) {
			$A=DB_fetchArray($result);
			$val=$A['value'];
			if (preg_match("#$val#",$comment['comment'])) {
				$ans=1;  // quit on first positive match
				SPAMX_log($LANG_SX00['foundspam'] . $val .$LANG_SX00['foundspam2'] . $_USER['uid'] . $LANG_SX00['foundspam3'] . $REMOTE_ADDR);
				break;
			}
		}				
		return $ans;
	}
}

?>



More information about the geeklog-cvs mailing list