Skip to content

Instantly share code, notes, and snippets.

@nansenat16
Created March 13, 2016 09:01
Show Gist options
  • Save nansenat16/5cff1cccdcfcf85b8f23 to your computer and use it in GitHub Desktop.
Save nansenat16/5cff1cccdcfcf85b8f23 to your computer and use it in GitHub Desktop.
EFA Release SPAM non-Auth Version
#!/usr/bin/perl
# +--------------------------------------------------------------------+
# EFA release spam message script version 20140105
# This script is an modification of the previous ESVA release-msg.cgi
# +--------------------------------------------------------------------+
# Copyright (C) 2013~2015 http://www.efa-project.org
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# +--------------------------------------------------------------------+
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use utf8;
#binmode(STDOUT, ':encoding(utf8)');
print "Content-type: text/html; charset=UTF-8 \n\n";
my $release_success =<<'RE_SUCCESS';
<html><head></head>
<body style="text-align:center;">
<p>&nbsp;</p>
<p><h1>已解除隔離,將郵件寄到您的信箱中。</h1></p>
</body></html>
RE_SUCCESS
my $release_error =<<'RE_ERR';
<html><head></head>
<body style="text-align:center;">
<p>&nbsp;</p>
<p><h1>解除隔離失敗,請聯絡系統管理員。</h1></p>
</body></html>
RE_ERR
$query = new CGI;
$id = param("id");
$datenumber = param("datenumber");
# Check if the variables contain data if one of them is not we die and not even check the syntax..
if ($id eq "" ){
die "Error variable is empty"
}
if ($datenumber eq "" ){
die "Error variable is empty"
}
# First check the ID variable
if ($id =~ /^[A-F0-9]{8}\.[A-F0-9]{5}|[A-F0-9]{9}\.[A-F0-9]{5}|[A-F0-9]{10}\.[A-F0-9]{5}|[A-F0-9]{11}\.[A-F0-9]{5}$/){
if ($datenumber =~ /^([2-9]\d{3}((0[1-9]|1[012])(0[1-9]|1\d|2[0-8])|(0[13456789]|1[012])(29|30)|(0[13578]|1[02])31)|(([2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00))0229)$/){
$sendmail = "/usr/sbin/sendmail.postfix";
$msgtorelease = "/var/spool/MailScanner/quarantine/$datenumber/spam/$id";
if (-e $msgtorelease){
open(MAIL, "|$sendmail -t <$msgtorelease") or die "Cannot open $sendmail: $!";
close(MAIL);
print $release_success;
} else {
print $release_error;
}
} else {
print "Error in datanumber syntax";
}
} else {
print "Error in id syntax";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment