[geeklog-cvs] geeklog: Added SFS and SNL modules and new config options for Sp...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sat Aug 20 11:32:02 EDT 2011


changeset 8353:5e31cccfe60d
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/5e31cccfe60d
user: Tom <websitemaster at cogeco.net>
date: Sat Aug 20 11:20:29 2011 -0400
description:
Added SFS and SNL modules and new config options for Spam-X. Increased version number to 1.3.0 (feature request #0001378)

diffstat:

 plugins/spamx/EditSFS.Admin.class.php      |  103 ++++++++++++++++++++
 plugins/spamx/SFS.Misc.class.php           |  135 ++++++++++++++++++++++++++
 plugins/spamx/SNL.Examine.class.php        |   65 ++++++++++++
 plugins/spamx/SNLbase.class.php            |  146 +++++++++++++++++++++++++++++
 plugins/spamx/SNLreport.Action.class.php   |   71 ++++++++++++++
 plugins/spamx/autoinstall.php              |    4 +-
 plugins/spamx/configuration_validation.php |    4 +
 plugins/spamx/functions.inc                |   39 +++++++
 plugins/spamx/install_defaults.php         |   18 +++
 plugins/spamx/install_updates.php          |   24 ++++
 public_html/docs/english/spamx.html        |   26 ++++-
 11 files changed, 632 insertions(+), 3 deletions(-)

diffs (truncated from 739 to 300 lines):

diff -r fc233fa7fa1d -r 5e31cccfe60d plugins/spamx/EditSFS.Admin.class.php
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/spamx/EditSFS.Admin.class.php	Sat Aug 20 11:20:29 2011 -0400
@@ -0,0 +1,103 @@
+<?php
+
+/**
+ * File: EditSFS.Admin.class.php
+ * This is the Edit Personal Blacklist Module for the glFusion Spam-X plugin
+ *
+ * Copyright (C) 2004-2009 by the following authors:
+ * Author   Tom Willett     tomw AT pigstye DOT net
+ *          Dirk Haun       dirk AT haun-online DOT de
+ *
+ * Licensed under GNU General Public License
+ *
+ * @package Spam-X
+ * @subpackage Modules
+ */
+
+if (strpos(strtolower($_SERVER['PHP_SELF']), 'editsfs.admin.class.php') !== false) {
+    die('This file can not be used on its own!');
+}
+
+/**
+* Include Abstract Base Class
+*/
+require_once $_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php';
+
+/**
+ * Personal SFS (StopForumSPAM) List Editor
+ *
+ * @package Spam-X
+ *
+ */
+class EditSFS extends BaseAdmin {
+    /**
+     * Constructor
+     */
+    function display()
+    {
+        global $_CONF, $_TABLES, $LANG_SX00;
+
+        $action = '';
+        if (isset($_GET['action'])) {
+            $action = $_GET['action'];
+        } elseif (isset($_POST['paction'])) {
+            $action = $_POST['paction'];
+        }
+
+        $entry = '';
+        if (isset($_GET['entry'])) {
+            $entry = COM_stripslashes($_GET['entry']);
+        } elseif (isset($_POST['pentry'])) {
+            $entry = COM_stripslashes($_POST['pentry']);
+        }
+
+        if (($action == 'delete') && SEC_checkToken()) {
+            $entry = addslashes($entry);
+            DB_delete($_TABLES['spamx'], array('name', 'value'),
+                                         array('email', $entry));
+        } elseif (($action == $LANG_SX00['addentry']) && SEC_checkToken()) {
+            if (!empty($entry)) {
+                $entry = addslashes($entry);
+                $result = DB_query("INSERT INTO {$_TABLES['spamx']} 
+                        VALUES ('email', '$entry')");
+            }
+        }
+
+        $token = SEC_createToken();
+        $display = '<hr' . XHTML . '>' . LB . '<p><b>';
+        $display .= $LANG_SX00['sfseblack'];
+        $display .= '</b></p>' . LB . '<ul>' . LB;
+        $result = DB_query("SELECT value FROM {$_TABLES['spamx']} 
+                    WHERE name = 'email'");
+        $nrows = DB_numRows($result);
+        for ($i = 0; $i < $nrows; $i++) {
+            $A = DB_fetchArray($result);
+            $e = $A['value'];
+            $display .= '<li>' . COM_createLink(htmlspecialchars($e),
+                $_CONF['site_admin_url']
+                . '/plugins/spamx/index.php?command=EditSFS&action=delete&entry=' . urlencode($e) . '&' . CSRF_TOKEN . '=' . $token) . '</li>' . LB;
+        }
+        $display .= '</ul>' . LB . '<p>' . $LANG_SX00['e1'] . '</p>' . LB;
+        $display .= '<p>' . $LANG_SX00['e2'] . '</p>' . LB;
+        $display .= '<form method="post" action="' . $_CONF['site_admin_url']
+                 . '/plugins/spamx/index.php?command=EditSFS">' . LB;
+        $display .= '<div><input type="text" size="30" name="pentry"' . XHTML
+                 . '>   ';
+        $display .= '<input type="submit" name="paction" value="'
+                 . $LANG_SX00['addentry'] . '"' . XHTML . '>' . LB;
+        $display .= '<input type="hidden" name="' . CSRF_TOKEN
+                 . "\" value=\"{$token}\"" . XHTML . '>' . LB;
+        $display .= '</div></form>' . LB;
+
+        return $display;
+    }
+
+    function link()
+    {
+        global $LANG_SX00;
+
+        return $LANG_SX00['edit_sfs_blacklist'];        
+    }
+}
+
+?>
diff -r fc233fa7fa1d -r 5e31cccfe60d plugins/spamx/SFS.Misc.class.php
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/spamx/SFS.Misc.class.php	Sat Aug 20 11:20:29 2011 -0400
@@ -0,0 +1,135 @@
+<?php
+/**
+*   SFS.Misc.class.php
+*   Special examiner to check email and IP addresses during registration.
+*   Checks stopforumspam.com and, if the result is positive, addes the
+*   email and/or IP address to the spamx table.
+*
+*   @author     Lee Garner <lee at leegarner.com>
+*   @copyright  Copyright (c) 2010 Lee Garner <lee at leegarner.com>
+*   @package    spamx
+*   @subpackage Modules
+*   @version    1.0.0
+*   @license    http://opensource.org/licenses/gpl-2.0.php 
+*               GNU Public License v2 or later
+*/
+
+if (strpos(strtolower($_SERVER['PHP_SELF']), 'sfs.misc.class.php') !== false) {
+    die('This file can not be used on its own!');
+}
+
+/**
+* Include Abstract Examine Class
+*/
+require_once $_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php';
+
+/**
+* Examines Email and IP
+*
+* @author Tom Willett, tomw AT pigstye DOT net
+*
+* @package Spam-X
+*
+*/
+class SFS extends BaseCommand {
+    /**
+     * No Constructor - use BaseCommand constructor
+     */
+
+    /**
+     * The execute method examines the Email address
+     *
+     * @param   string  $email      Email text to examine
+     * @return  int                 0: no spam, else: spam detected
+     */
+    function execute($email)
+    {
+        global $result;
+
+        $result = $this->_process($email, $_SERVER['REMOTE_ADDR']);
+        return $result;
+    }
+
+
+    /**
+     * Private internal method, 
+     *
+     * @param   string  $email  Email address of user
+     * @param   string  $ip     IP address of user
+     * @return  int             0: no spam, else: spam detected
+     * @access  private
+     */
+    function _process($email, $ip)
+    {
+        global $_TABLES, $LANG_SX00, $_SPX_CONF;
+
+        if (!isset ($_SPX_CONF['sfs_enabled'])) {
+            $_SPX_CONF['sfs_enabled'] = false;
+        }
+        
+        if (!$_SPX_CONF['sfs_enabled']) {
+            return 0;     // invalid data, assume ok
+        }
+        
+        $db_email = mysql_escape_string($email);
+        $db_ip = mysql_escape_string($ip);
+        //  Include Blacklist Data
+        //  Check for IP address
+        $result = DB_query("SELECT value FROM {$_TABLES['spamx']}
+                WHERE name='IP' AND value='$db_ip'
+                OR name='email' AND value='$db_email'", 1);
+        if (DB_numRows($result) > 0) {
+            return 1;
+        }
+
+        $em = urlencode($email);
+        $query = "http://www.stopforumspam.com/api?f=serial&email=$em";
+        if (!empty($ip)) {
+            $query .= "&ip=$ip";
+        }
+        
+        if (!isset ($_SPX_CONF['timeout'])) {
+            $_SPX_CONF['timeout'] = 5; // seconds
+        }
+
+        $ctx = stream_context_create(array( 
+            'http' => array( 
+                'timeout' => $_SPX_CONF['timeout'] 
+                ) 
+            ) 
+        );
+        
+        if ($this->_verbose) {
+            SPAMX_log ("Sending to SFS: $query");
+        }        
+
+        $result = file_get_contents($query, 0, $ctx);
+        $result = unserialize($result);
+        if (!$result) {
+            if ($this->_verbose) {
+                SPAMX_log ("SFS: no spam detected");
+            }
+            return 0;     // invalid data, assume ok
+        }
+
+        if ($result['email']['appears'] == 1)
+            $value_arr[] = "('email', '$db_email')";
+        if ($result['ip']['appears'] == 1)
+            $value_arr[] = "('IP', '$db_ip')";
+        if (!empty($value_arr)) {
+            $values = implode(',', $value_arr);
+            $sql = "INSERT INTO {$_TABLES['spamx']} (name, value) 
+                    VALUES $values";
+            DB_query($sql);
+            
+            $log_msg = sprintf($LANG_SX00['email_ip_spam'], $email, $ip);
+            SPAMX_log($log_msg);
+           
+            return 1;
+        }
+
+        return 0;
+    }
+}
+
+?>
diff -r fc233fa7fa1d -r 5e31cccfe60d plugins/spamx/SNL.Examine.class.php
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/spamx/SNL.Examine.class.php	Sat Aug 20 11:20:29 2011 -0400
@@ -0,0 +1,65 @@
+<?php
+
+/**
+* File: SNL.Examine.class.php
+* This is the Spam Number of Links Examine class for the Geeklog Spam-X plugin
+*
+* Copyright  (C) 2006 Tom Homer	 - WebSiteMaster AT cogeco DOT com     
+*
+* Licensed under the GNU General Public License
+*
+*
+*/
+
+if (strpos ($_SERVER['PHP_SELF'], 'SNL.Examine.class.php') !== false) {
+    die ('This file can not be used on its own!');
+}
+
+/**
+* Include Base Classes
+*/
+require_once ($_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php');
+require_once ($_CONF['path'] . 'plugins/spamx/' . 'SNLbase.class.php');
+
+/**
+* Checks number of links in post.
+*
+* based in large part on the works of Dirk Haun, Tom Willet (Spam-X) and Russ Jones (SLV)
+*/
+
+class SNL extends BaseCommand {
+    /**
+     * No Constructor Use BaseCommand constructor
+     */
+
+    /**
+     * Here we do the work
+     */
+    function execute ($comment)
+    {
+        global $_USER, $LANG_SX00;
+
+        $ans = 0;
+
+        if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
+            $uid = $_USER['uid'];
+        } else {
+            $uid = 1;
+        }
+
+        $SNL = new SNLbase();



More information about the geeklog-cvs mailing list