71 lines
1.7 KiB
Perl
Executable File
71 lines
1.7 KiB
Perl
Executable File
#! /usr/bin/perl -w
|
|
# Emily Wu's Website
|
|
# mailto.cgi: The e-mail hyperlink redirector.
|
|
|
|
# Copyright (c) 2003-2021 imacat.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# Author: imacat <imacat@mail.imacat.idv.tw>
|
|
# First written: 2003-05-13
|
|
|
|
use 5.008;
|
|
use strict;
|
|
use warnings;
|
|
use lib $ENV{"DOCUMENT_ROOT"} . qw(/magicat/lib/perl5);
|
|
use Selima::emily;
|
|
local $SIG{"__DIE__"} = \&http_500;
|
|
my $d = new Selima::Destroy;
|
|
# Prototype declaration
|
|
sub main();
|
|
sub check_post();
|
|
|
|
use Fcntl qw(:seek);
|
|
|
|
initenv(-allowed => [qw(POST)],
|
|
-session => 0,
|
|
-dbi => DBI_NONE,
|
|
-lastmod => 0);
|
|
|
|
main;
|
|
exit 0;
|
|
|
|
sub main() {
|
|
local ($_, %_);
|
|
my $error;
|
|
|
|
# Only POSTed forms are allowed
|
|
$error = check_post;
|
|
# If an error occurs
|
|
if (defined $error) {
|
|
http_400;
|
|
|
|
# Else, save the data
|
|
} else {
|
|
http_303 "mailto:" . $POST->param("email");
|
|
}
|
|
return;
|
|
}
|
|
|
|
# check_post: Check the POSTed form
|
|
sub check_post() {
|
|
local ($_, %_);
|
|
my ($checker, $error);
|
|
# Run the checker
|
|
$checker = new Selima::Checker::MailTo(curform);
|
|
$error = $checker->check(qw(email));
|
|
return $error if defined $error;
|
|
# OK
|
|
return;
|
|
}
|