plugins/spamx/MailAdmin.Action.class.php
author Dirk Haun <dirk@haun-online.de>
Thu, 29 Oct 2009 13:00:11 +0100
branchHEAD
changeset 7397 c27e9026f22a
parent 6838 cb1ba8d99085
permissions -rw-r--r--
Fixed inclusion protection
     1 <?php
     2 
     3 /**
     4  * File: MailAdmin.Action.class.php
     5  * This is the Mail Admin Action for the Geeklog Spam-X plugin
     6  * 
     7  * Copyright (C) 2004-2008 by the following authors:
     8  * Author   Tom Willett     tomw AT pigstye DOT net
     9  * 
    10  * Licensed under GNU General Public License
    11  *
    12  * @package Spam-X
    13  * @subpackage Modules
    14  */
    15 
    16 if (strpos(strtolower($_SERVER['PHP_SELF']), 'mailadmin.action.class.php') !== false) {
    17     die('This file can not be used on its own!');
    18 }
    19 
    20 /**
    21  * Include Abstract Action Class
    22  */
    23 require_once $_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php';
    24 
    25 /**
    26  * Action Class which emails the spam post to the site admin
    27  * 
    28  * @author Tom Willett  tomw@pigstye.net 
    29  *
    30  * @package Spam-X
    31  *
    32  */
    33 class MailAdmin extends BaseCommand {
    34     /**
    35      * Constructor
    36      */
    37     function MailAdmin()
    38     {
    39         global $num;
    40 
    41         $num = 8;
    42     } 
    43 
    44     function execute($comment)
    45     {
    46         global $result, $_CONF, $_USER, $LANG_SX00, $_SPX_CONF;
    47 
    48         if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
    49             $uid = $_USER['uid'];
    50         } else {
    51             $uid = 1;
    52         }
    53         $uid .= '@' . $_SERVER['REMOTE_ADDR'];
    54         $msg = sprintf ($LANG_SX00['emailmsg'],
    55                         $_CONF['site_name'], $uid, $comment);
    56 
    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";
    66                 }
    67             }
    68         } else {
    69             foreach ($_SERVER as $key => $content) {
    70                 if (substr ($key, 0, 4) == 'HTTP') {
    71                     if ($key != 'HTTP_COOKIE') {
    72                         $msg .= $key . ': ' . $content . "\n";
    73                     }
    74                 }
    75             }
    76         }
    77 
    78         $subject = sprintf($LANG_SX00['emailsubject'], $_CONF['site_name']);
    79         if (empty($_SPX_CONF['notification_email'])) {
    80             $email_address = $_CONF['site_mail'];
    81         } else {
    82             $email_address = $_SPX_CONF['notification_email'];
    83         }
    84         COM_mail($email_address, $subject, $msg);
    85         $result = 8;
    86         SPAMX_log('Mail Sent to Admin');
    87 
    88         return 0;
    89     }
    90 }
    91 
    92 ?>