spam.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:6k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: spam.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.17 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Spam filter maintenance (administration interface)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- require_once('./global.php');
- //Nullify WTN-WDYL Team
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "view";
- }
- // globalise variables
- $global = array (
- array('id', 'number')
- );
- rg($global);
- ############################### DELETE SPAM FILTER ###############################
- if ($_REQUEST['do'] == "delete") {
-
- $db->query("DELETE from gateway_spam WHERE id='$id'");
-
- jump('spam.php?do=view', 'Spam filter deleted');
- }
- ############################### CREATE SPAM FILTER ###############################
- if (($_REQUEST['do'] == "edit") OR ($_REQUEST['do'] == "add")) {
- if ($_REQUEST['do'] == 'add') {
- admin_header('Email Gateway', 'Add Spam Filter');
- } else {
- admin_header('Email Gateway', 'Edit Spam Filter');
- }
- if ($_REQUEST['do'] == "edit") {
- $db->query("SELECT * from gateway_spam WHERE id = '$id'");
- $spam = $db->row_array();
- }
- $type = array(
- 0 => 'Subject Match',
- 1 => 'Body Match',
- );
- $bit = form_select('type', $type, '', $spam[type]);
- $table[] = array('<b>Match type</b><br />Choose from a match against the email body or email subject', $bit);
-
- $bit = form_radio_yn('regex', '', $spam[regex]);
- $table[] = array('<b>Regex?</b><br />If you are using a regex instead of just a match on some text select yes.', $bit);
- $bit = form_textarea('textmatch', '40', '6', $spam[textmatch]);
- $table[] = array('<b>Words/Regex to match</b><br />The words or the regex you are using to match', $bit);
- $bit = form_radio_yn('is_delete', '', $spam[is_delete]);
- $table[] = array('<b>Delete?</b><br />If set to yes a message that is marked as spam will be deleted. If set to <b>No</b> the message will be stored in a type of recycle bin allowing you to ocassionaly check there are no messages improperly assigned as spam.', $bit);
- $width = array('60%', '40%');
- if ($_REQUEST['do'] == "edit") {
- table_header('Edit Spam Filter', 'spam.php', array('do' => 'edit2', 'id' => $id));
- } else {
- table_header('Create Spam Filter', 'spam.php', array('do' => 'add2'));
- }
- table_content('', $table, '', '', '', '', $width);
- if ($_REQUEST['do'] == "edit") {
- table_footer('Edit Filter');
- } else {
- table_footer('Create Filter');
- }
- unset($table, $width);
-
- }
- ############################### ADD/EDIT SPAM FILTER (PROCESS) ###############################
- if ($_REQUEST['do'] == "edit2") {
-
- if ($_REQUEST['regex']) {
- $match = @preg_match($_REQUEST['textmatch'], '');
- if (!is_int($match)) { // It's invalid unless $match is an integer
- mistake('The regular expression you specified is invalid. Refer to
- PHP's manual
- for current information about PHP's implementation of Perl-compatible
- Regular Expressions. This may assist you in building a valid regular
- expression. Please go back and correct the regular expression.');
- }
- }
- $db->query("UPDATE gateway_spam SET
- type = '" . mysql_escape_string($_REQUEST[type]) . "',
- regex = " . intval($_REQUEST[regex]) . ",
- textmatch = '" . mysql_escape_string($_REQUEST[textmatch]) . "',
- is_delete = " . intval($_REQUEST[is_delete]) . "
- WHERE id='$id'
- ");
- jump('spam.php?do=view', 'Spam Filter Updated');
- }
- ############################### ADD (2) SPAM ###############################
- if ($_REQUEST['do'] == "add2") {
-
- $db->query("INSERT into gateway_spam SET
- type = '" . mysql_escape_string($_REQUEST[type]) . "',
- regex = " . intval($_REQUEST[regex]) . ",
- textmatch = '" . mysql_escape_string($_REQUEST[textmatch]) . "',
- is_delete = " . intval($_REQUEST[is_delete]) . "
- ");
- jump('spam.php?do=view', 'New Spam Filter Created');
- }
- ############################### VIEW SPAM FILTERS ###############################
- if ($_REQUEST['do'] == "view") {
- admin_header('Email Gateway', 'View Spam Filters');
- $type = array(
- 0 => 'Subject Match',
- 1 => 'Body Match',
- );
-
- $db->query("SELECT * from gateway_spam");
- while ($spam = $db->row_array()) {
- $table[] = array(
- $type[$spam[type]],
- $spam[textmatch],
- ifynb($spam[regex]),
- ifynb($spam[is_delete]),
- jprompt('Please confirm you wish to delete this spam filter', "spam.php?do=delete&id=$spam[id]", 'Delete'),
- "<a href="spam.php?do=edit&id=$spam[id]">Edit</a>"
- );
- }
- $cols = array('Match Type', 'Match Text', 'Is Regex?', 'Delete?', 'Delete', 'Edit');
- table_header('Spam Filters');
- table_content($cols, $table);
- table_footer();
- unset($table);
- }
- ##############################################################
- admin_footer();
- php?>