4 * File: MailAdmin.Action.class.php
5 * This is the Mail Admin Action for the Geeklog Spam-X plugin
7 * Copyright (C) 2004-2008 by the following authors:
8 * Author Tom Willett tomw AT pigstye DOT net
10 * Licensed under GNU General Public License
16 if (strpos(strtolower($_SERVER['PHP_SELF']), 'mailadmin.action.class.php') !== false) {
17 die('This file can not be used on its own!');
21 * Include Abstract Action Class
23 require_once $_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php';
26 * Action Class which emails the spam post to the site admin
28 * @author Tom Willett tomw@pigstye.net
33 class MailAdmin extends BaseCommand {
44 function execute($comment)
46 global $result, $_CONF, $_USER, $LANG_SX00, $_SPX_CONF;
48 if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
53 $uid .= '@' . $_SERVER['REMOTE_ADDR'];
54 $msg = sprintf ($LANG_SX00['emailmsg'],
55 $_CONF['site_name'], $uid, $comment);
57 // Add headers of the spam post to help track down the source.
58 // Function 'getallheaders' is not available when PHP is running as
59 // CGI. Print the HTTP_... headers from $_SERVER array instead then.
60 $msg .= "\n\n" . $LANG_SX00['headers'] . "\n";
61 if (function_exists ('getallheaders')) {
62 $headers = getallheaders ();
63 foreach ($headers as $key => $content) {
64 if (strcasecmp ($key, 'Cookie') != 0) {
65 $msg .= $key . ': ' . $content . "\n";
69 foreach ($_SERVER as $key => $content) {
70 if (substr ($key, 0, 4) == 'HTTP') {
71 if ($key != 'HTTP_COOKIE') {
72 $msg .= $key . ': ' . $content . "\n";
78 $subject = sprintf($LANG_SX00['emailsubject'], $_CONF['site_name']);
79 if (empty($_SPX_CONF['notification_email'])) {
80 $email_address = $_CONF['site_mail'];
82 $email_address = $_SPX_CONF['notification_email'];
84 COM_mail($email_address, $subject, $msg);
86 SPAMX_log('Mail Sent to Admin');