plugins/spamx/EditIPofURL.Admin.class.php
author Dirk Haun <dirk@haun-online.de>
Thu, 29 Oct 2009 13:00:11 +0100
branchHEAD
changeset 7397 c27e9026f22a
parent 6838 cb1ba8d99085
child 7857 aa35484e45c8
permissions -rw-r--r--
Fixed inclusion protection
     1 <?php
     2 
     3 /**
     4 * File: EditIPofURL.Admin.class.php
     5 * This is the Edit IPofURL Module for the Geeklog Spam-X plugin
     6 *
     7 * Copyright (C) 2004-2009 by the following authors:
     8 * Author    Tom Willett     tomw AT pigstye DOT net
     9 *           Dirk Haun       dirk AT haun-online DOT de
    10 *
    11 * Licensed under GNU General Public License
    12 *
    13 * @package Spam-X
    14 * @subpackage Modules
    15 */
    16 
    17 if (strpos(strtolower($_SERVER['PHP_SELF']), 'editipofurl.admin.class.php') !== false) {
    18     die('This file can not be used on its own!');
    19 }
    20 
    21 /**
    22 * Include Abstract Base Class
    23 */
    24 require_once $_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php';
    25 
    26 /**
    27 * IP of URL Black List Editor
    28 *
    29 * @package Spam-X
    30 *
    31 */
    32 class EditIPofUrl extends BaseAdmin {
    33     /**
    34      * Constructor
    35      */
    36     function display()
    37     {
    38         global $_CONF, $_TABLES, $LANG_SX00;
    39 
    40         $action = '';
    41         if (isset($_GET['action'])) {
    42             $action = $_GET['action'];
    43         } elseif (isset($_POST['paction'])) {
    44             $action = $_POST['paction'];
    45         }
    46 
    47         $entry = '';
    48         if (isset($_GET['entry'])) {
    49             $entry = COM_stripslashes($_GET['entry']);
    50         } elseif (isset($_POST['pentry'])) {
    51             $entry = COM_stripslashes($_POST['pentry']);
    52         }
    53 
    54         if (($action == 'delete') && SEC_checkToken()) {
    55             $entry = addslashes($entry);
    56             DB_delete($_TABLES['spamx'], array('name', 'value'),
    57                                          array('IPofUrl', $entry));
    58         } elseif (($action == $LANG_SX00['addentry']) && SEC_checkToken()) {
    59             if (!empty($entry)) {
    60                 $entry = addslashes($entry);
    61                 $result = DB_query("INSERT INTO {$_TABLES['spamx']} VALUES ('IPofUrl', '$entry')");
    62             }
    63         }
    64 
    65         $token = SEC_createToken();
    66         $display = '<hr' . XHTML . '>' . LB . '<p><b>';
    67         $display .= $LANG_SX00['ipofurlblack'];
    68         $display .= '</b></p>' . LB . '<ul>' . LB;
    69         $result = DB_query("SELECT value FROM {$_TABLES['spamx']} WHERE name = 'IPofUrl'");
    70         $nrows = DB_numRows($result);
    71         for ($i = 0; $i < $nrows; $i++) {
    72             list($e) = DB_fetchArray($result);
    73             $display .= '<li>'. COM_createLink(htmlspecialchars($e),
    74                 $_CONF['site_admin_url']
    75                 . '/plugins/spamx/index.php?command=EditIPofUrl&amp;action=delete&amp;entry=' . urlencode($e) . '&amp;' . CSRF_TOKEN . '=' . $token) .  '</li>' . LB;
    76         }
    77         $display .= '</ul>' . LB . '<p>' . $LANG_SX00['e1'] . '</p>' . LB;
    78         $display .= '<p>' . $LANG_SX00['e2'] . '</p>' . LB;
    79         $display .= '<form method="post" action="' . $_CONF['site_admin_url']
    80                  . '/plugins/spamx/index.php?command=EditIPofUrl">';
    81         $display .= '<div><input type="text" size="30" name="pentry"' . XHTML
    82                  . '>&nbsp;&nbsp;&nbsp;';
    83         $display .= '<input type="submit" name="paction" value="'
    84                  . $LANG_SX00['addentry'] . '"' . XHTML . '>' . LB;
    85         $display .= '<input type="hidden" name="' . CSRF_TOKEN
    86                  . "\" value=\"{$token}\"" . XHTML . '>' . LB;
    87         $display .= '</div></form>' . LB;
    88 
    89         return $display;
    90     }
    91 
    92     function link()
    93     {
    94         return 'Edit IP of URL Blacklist';
    95     }
    96 }
    97 
    98 ?>