4 * File: Header.Examine.class.php
5 * This is the HTTP Header Examine class for the Geeklog Spam-X plugin
7 * Copyright (C) 2005-2009 by the following authors:
8 * Author Dirk Haun <dirk AT haun-online DOT de>
10 * based on the works of Tom Willett <tomw AT pigstye DOT net>
12 * Licensed under the GNU General Public License
18 if (strpos(strtolower($_SERVER['PHP_SELF']), 'header.examine.class.php') !== false) {
19 die('This file can not be used on its own!');
23 * Include Abstract Examine Class
25 require_once $_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php';
28 * Examines Post according to HTTP Headers
30 * @author Dirk Haun, dirk AT haun-online DOT de
35 class Header extends BaseCommand {
37 * No Constructor Use BaseCommand constructor
42 function execute($comment)
44 global $_CONF, $_TABLES, $_USER, $LANG_SX00, $result;
46 if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
52 // get HTTP headers of the current request
53 if (function_exists ('getallheaders')) {
54 $headers = getallheaders ();
56 // if getallheaders() is not available, we have to fake it using
57 // the $_SERVER['HTTP_...'] values
59 foreach ($_SERVER as $key => $content) {
60 if (substr ($key, 0, 4) == 'HTTP') {
61 $name = str_replace ('_', '-', substr ($key, 5));
62 $headers[$name] = $content;
67 $result = DB_query ("SELECT value FROM {$_TABLES['spamx']} WHERE name='HTTPHeader'", 1);
68 $nrows = DB_numRows ($result);
71 for ($i = 0; $i < $nrows; $i++) {
72 list ($entry) = DB_fetchArray ($result);
74 $v = explode (':', $entry);
76 $value = trim ($v[1]);
77 $value = str_replace ('#', '\\#', $value);
79 foreach ($headers as $key => $content) {
80 if (strcasecmp ($name, $key) == 0) {
81 if (preg_match ("#$value#i", $content)) {
82 $ans = 1; // quit on first positive match
83 SPAMX_log ($LANG_SX00['foundspam'] . $entry .
84 $LANG_SX00['foundspam2'] . $uid .
85 $LANG_SX00['foundspam3'] .
86 $_SERVER['REMOTE_ADDR']);