?? mail.cgi
字號:
#!/usr/bin/perl
#------------------------------------------------------#
# 本程序為Yuzi工作室提供 #
# Yuzi論壇3000(BBS3000)v4.00 #
#------------------------------------------------------#
$cgipa="."; # CGI程序文件的絕對路徑
######################
## 以下部分不需修改 ##
######################
require "$cgipa/setup.cgi";
$listfile="$filepath/data/maillist.cgi";
$thisurl = $ENV{'SCRIPT_NAME'};
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value=~tr/+/ /;
$value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
else { $INPUT{$name} = $value; }}
unless ($INPUT{'email'}) {
print "Content-type: text/html;CHARSET=gb2312 \n\n";
&Top;
}
$temp=0;
$temp=$ENV{'QUERY_STRING'};
if ($temp) {
$INPUT{'address'} = $temp;
&remove;
}
if ($INPUT{'email'}) { &email; }
elsif ($INPUT{'action'} eq "subscribe") { &subscribe; }
elsif ($INPUT{'action'} eq "remove") { &remove; }
elsif ($INPUT{'newpass'}) { &newpass; }
elsif ($INPUT{'add'}) { &add; }
elsif ($INPUT{'delete_select'}) { &delete_select; }
elsif ($INPUT{'delete_final'}) { &delete_final; }
elsif ($INPUT{'sendemail'}) { &sendemail; }
else { &admin; }
exit;
sub admin {
print <<EOF;
<TABLE bordercolor=ffffff cellSpacing=1 cellPadding=8 width=490 bgColor=00416b><TBODY><tr bgColor=e4e4e4><TD bgColor=e4e4e4 height=22><CENTER><form action="$thisurl" method=post><SPAN>您的E-Mail</SPAN> <INPUT size=30 name=address> <BR><INPUT type=radio CHECKED value=subscribe name=action> <FONT size=-1>加入 | 退出</FONT> <INPUT type=radio value=remove name=action> <BR><INPUT type=submit value=確定></CENTER></TD></TR> </TBODY></FORM></TABLE><IMG src="$imagurl/mail3000.gif"><BR>
<TABLE cellSpacing=1 cellPadding=5 width=316 bgColor=00416b border=0><TBODY><TABLE cellSpacing=1 cellPadding=5 width=316 bgColor=00416b border=0><form action="$thisurl" method=post><TBODY>
<TR align=middle bgColor=e4e4e4><TD bgColor=e4e4e4 width="95"><SPAN><font face="隸書" size="4"><b>管理專區</b></font> </SPAN></TD>
<TD bgColor=e4e4e4 width="191">請輸入管理密碼 <INPUT
type=password name=password size="10"></TD></TR><TR align=middle bgColor=e4e4e4><TD bgColor=e4e4e4 height=2 colspan="2" width="300"> <SPAN><INPUT type=submit value='發送信件'name=sendemail> <INPUT type=submit value='刪除用戶' name=delete_select>
</SPAN> </TD></TR></TBODY></TABLE><BR>
EOF
&Bottom;
exit;
}
sub subscribe {
unless ($INPUT{'address'}=~/\@/) {
print "<font color=FFFFFF>您的E-Mail輸入有問題,請回 <a href=javascript:history.back()><font color=FFFFFF>上一頁</a> 重新輸入</font><br>";
&Bottom;
exit;
}
open(LIST,"$listfile");
@addresses=<LIST>;
close(LIST);
@add = grep{ /$INPUT{'address'}/i } @addresses;
if (@add) {
print <<EOF;
<table cellspacing =1 bgcolor =#00416B border=0 cellpadding =8><TR bgColor=E4E4E4 align=center><TD>
這個E-Mail已經輸入過了 ,確定已經在我們的郵件列表中
</td></TR></TABLE>
EOF
&Bottom;
exit;
}
open(LIST,">>$listfile") || &error("無法寫入$listfile");
print LIST "$INPUT{'address'}\n";
close(LIST);
print <<EOF;
<table cellspacing =1 bgcolor =#00416B border=0 cellpadding =8 width=400><TR bgColor=E4E4E4 align=center><TD><FONT SIZE=-1>
謝謝您的加入<BR><BR>您的信箱 <font color=red>$INPUT{'address'}</font> 已經加入到我們的列表中</td></tr></table>
EOF
&Bottom;
exit;
}
sub remove{
unless ($INPUT{'address'}) {
print <<EOF;
<table cellspacing =1 bgcolor =#E4E4E4 border=0 cellpadding =8><TR align=center><TD><FONT SIZE="-1">
您沒有輸入信箱位址</font></td></TR></TABLE>
EOF
&Bottom;
exit;
}
open(LIST,"$listfile");
@addresses=<LIST>;
close(LIST);
@add = grep{ !(/$INPUT{'address'}/i) } @addresses;
open(LIST,">$listfile") || &error("無法寫入$listfile");
print LIST @add;
close(LIST);
print <<EOF;
<table cellspacing =1 bgcolor =#00416B border=0 cellpadding =8><TR bgColor=E4E4E4 align=center><TD><FONT SIZE="-1">
很遺憾您的退出<BR><BR>您的信箱 <font color=red>$INPUT{'address'}</font> 已經從我們的列表中刪除
</font></td></TR></TABLE>
EOF
&Bottom;
exit;
}
sub email {
&checkpassword;
print "Content-type: text/html \n\n";
&Top;
print <<EOF;
<table cellspacing =1 bgcolor =#00416B border=0 cellpadding =8><TR bgColor=E4E4E4 align=center><TD><FONT SIZE="-1">
郵件已經寄出
</font></td></TR></TABLE>
EOF
&Bottom;
open(LIST,"$listfile");
@addresses=<LIST>;
close(LIST);
$num_email=0;
foreach $line(@addresses) {
chomp($line);
$sendto="$line";
$subject="$INPUT{'subject'}";
if ($INPUT{'zchtml'} eq "1") {
$message="Content-Type: text/html;charset=gb2312\n\n$INPUT{'body'}<br><br>服務提供:<a href=$zyurl>$zyname</a> 程序制作:<a href=http://www.yuzi.net target=_blank>Yuzi工作室</a><BR>--------------------------------------------------<BR>如果您不想再收到我們的訊息,請按下列網址直接刪除<BR><a href=$ym/mail.cgi?$line>$ym/mail.cgi?$line</a>\n";
}else{
$message="\n$INPUT{'body'}\n\n服務提供:$zyname($zyurl) 程序制作:Yuzi工作室(http://www.yuzi.net)\n-----------------------------------------------------------------\n如果您不想再收到我們的訊息\n請按下列網址直接刪除 \n$ym/mail.cgi?$line\n\n\n";
}
if(-e $mailprg){&sendmail;}else{do "$cgipa/sub/smtp.cgi";}
$num_email++;
}
$sendto="$adminmail";
$subject="$INPUT{'subject'}";
if ($INPUT{'zchtml'} eq "1") {
$message="Content-Type: text/html;charset=gb2312\n\n共發出 <font color=FF0000>$num_email</font> 封郵件,送出了以下訊息<BR>--------------------------------------------------<BR>$INPUT{'body'}";
}else{
$message="\n共發出 $num_email 封郵件,送出了以下訊息\n\n--------------------------------------------------\n$INPUT{'body'}";
}
if(-e $mailprg){&sendmail;}else{do "$cgipa/sub/smtp.cgi";}
exit;
}
sub delete_select {
&checkpassword;
open(LIST,"$listfile");
@addresses=<LIST>;
close(LIST);
@addresses = sort(@addresses);
print <<EOF;
<SCRIPT>
function clean(){
if (confirm("該項操作將會清除現在郵件列表中所有的EMAIL,您確定要繼續進行嗎?")){
return true;
}
return false;
}
</SCRIPT><B><font color=FFFFFF>選擇要刪除的信箱</font></B><br><br><FORM METHOD=POST ACTION="$thisurl"><INPUT type="hidden" NAME=password VALUE=$INPUT{'password'}><INPUT TYPE="SUBMIT" NAME="add" VALUE="點擊此將社區內所有的用戶Email導入到郵件列表" onclick="return clean()"></form>
<table cellspacing =1 bgcolor =#00416B border=0 cellpadding =3><TR bgColor=E4E4E4 align=left>
<FORM METHOD=POST ACTION="$thisurl">
EOF
$num_email=0;
foreach $line(@addresses) {
chomp($line);
if ($num_email == 3) {
print "</TR><TR bgcolor=\#E4E4E4 align=left>";
$num_email=0;
}
print "<TD><FONT SIZE=-1><INPUT TYPE=CHECKBOX NAME=delete VALUE=$line>$line</TD>";
$num_email++;
}
print <<EOF;
</TD></TR></TABLE><BR><table cellspacing =1 bgcolor =#00416B border=0 cellpadding =8>
<TR bgColor=E4E4E4 align=center><TD><FONT SIZE=-1>
輸入您的管理密碼<BR><input type=password name="password"><BR><INPUT TYPE="SUBMIT" NAME="delete_final" VALUE="刪除信箱">
</TD></TR></TABLE></form>
EOF
&Bottom;
exit;
}
sub delete_final {
&checkpassword;
open(LIST,"$listfile");
@addresses=<LIST>;
close(LIST);
@deleting = split(/\,/,$INPUT{'delete'});
foreach $line(@deleting) {
@addresses = grep{ !(/$line/i) } @addresses;
}
open(LIST,">$listfile") || &error("無法寫入 $listfile");
print LIST @addresses;
close(LIST);
print <<EOF;
<table cellspacing =1 bgcolor =#00416B border=0 cellpadding =8 width=400><TR bgColor=E4E4E4 align=center>
<TD><FONT SIZE=-1>已經刪除</font><BR><BR><FONT SIZE=-1 color=red>
$INPUT{'delete'}
</TD></TR></TABLE>
EOF
&Bottom;
exit;
}
sub sendemail {
&checkpassword;
print <<EOF;
<table cellspacing =1 bgcolor =#00416B border=0 cellpadding =8 width=400><TR bgColor=E4E4E4>
<TD><FORM METHOD=POST ACTION=$thisurl>
主題 <input type = text name=subject size=45><table border="0" width="95%"><tr><td width="50%">信件內容</td>
<td width="50%" align="right"><input type="checkbox" name="zchtml" value="1">HTML格式</td>
</tr></table><TEXTAREA NAME=body ROWS=14 COLS=50></TEXTAREA><BR><BR><INPUT type="hidden" NAME=password VALUE=$INPUT{'password'}><center><INPUT TYPE=SUBMIT NAME=email VALUE="發送郵件">
</TD></TR></FORM></TABLE>
EOF
&Bottom;
exit;
}
sub checkpassword {
if ($INPUT{'password'}) {
unless ($delpsd eq $INPUT{'password'}) {
print <<EOF;
<table cellspacing =1 bgcolor =#00416B border=0 cellpadding =8><TR bgColor=E4E4E4 align=center><TD>錯誤的密碼
</TD></TR></TABLE>
EOF
&Bottom;
exit;
}}
else {
print <<EOF;
<table cellspacing =1 bgcolor =#00416B border=0 cellpadding =8><TR bgColor=E4E4E4 align=center><TD>您必須輸入密碼
</TD></TR></TABLE>
EOF
&Bottom;
exit;
}}
sub Top {
print <<EOF;
<HTML><HEAD><TITLE>BBS3000郵件列表</TITLE><META http-equiv=Content-Type content="text/html; charset=gb2312"><style>
a:visited { text-decoration: none}
td {font-size: 9pt}
body {font-size: 9pt}
</style></HEAD><BODY text=#000000 bgColor=4f6984 leftMargin=0 background=$imagurl/mailbg.gif
topMargin=0><DIV align=center><IMG height=82 src="$imagurl/mailtiele.gif"
width=663><BR><BR></DIV><CENTER>
EOF
}
sub Bottom {
print <<EOF;
<BR><font color="#ffffff">[ <a href="javascript:history.back()"><font color="#ffffff">BACK</font></a> ]
<BR><HR width="80%" color=e4e4e4 noShade SIZE=1><SPAN><FONT color=e0e4e0>Powered by www.yuzi.net ©1998-2001<BR>Yuzi Bulletin Board Version 3000</FONT> </SPAN></CENTER></BODY></HTML>
EOF
}
sub error{
$errors = $_[0] ;
print <<EOF;
<table cellspacing =1 bgcolor =#00416B border=0 cellpadding =8><TR bgColor=E4E4E4 align=center><TD><B>錯誤發生</B><BR><BR>
錯誤: <font color=red>$errors</font><br><br><font color=red>$!</FONT></TD></TR></TABLE>
EOF
&Bottom;
exit;
}
sub add {
&checkpassword;
opendir (MEMBERDIR2, "$filepath/yhzl");
@members2 = readdir(MEMBERDIR2);
closedir (MEMBERDIR2);
foreach $m (@members2){
open(PSD,"$filepath/yhzl/$m");
$line=<PSD>;
close(PSD);
($rpassword,$rname,$mail)=split(/\t/,$line);
if($mail ne ""){
$all="$mail\n$all";
$totle++;
}}
open(LIST,">$listfile");
print LIST "$all";
close(LIST);
print <<EOF;
<HTML><head><META HTTP-EQUIV=Content-Type CONTENT=text/html; charset=gb2312><meta HTTP-EQUIV="REFRESH" CONTENT="10;URL=mail.cgi">
<LINK href="$imagurl/bbs.css" rel=stylesheet></head><font color=FFFFFF>您已經成功地將社區內 <font color=FF0000>$totle</font> 位用戶的EMAIL全部導入到郵件列表中了,請稍候,系統將自動返回......
<BR><BR><A HREF="mail.cgi">如果系統沒有反應,請點擊這里返回!</A></html>
EOF
}
######################### END OF SCRIPT #########################
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -