⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lovemail.cgi

📁 XYZ情书生成投递系统
💻 CGI
字号:
#!/usr/bin/perl

###########################################################################
#CGI脚本名称:XYZ情书生成投递系统0.9a版,用于WWW网站用于WWW网站发送电子邮件。
#Copyright (C) 2000  Yu Ning Chen
#
#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 2
#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, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#############################################################################


$EmailServer='smtp.21cn.com';	# 设置送信服务器
$cgiurl='http://zjxyz.uhome.net/cgi-bin/lovemail.cgi';

$iplock=1;       #设置ip锁定
$iplocktime=600; #设置ip锁定时间

$yourmsg="lovemail/yourmsg.txt";
$mailmsg="lovemail/mailmsg.txt";
$libpath="lovemail/letter.txt";
$mailrecord="lovemail/mailrecord.txt";
$iprecord="lovemail/iprecord.txt";

#以上需要手工设置


require "sendmail.pm";


$buffer=$ENV{'QUERY_STRING'};
@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;
    $A{$name} = $value;}

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;
    $A{$name} = $value;}

print "Content-type: text/html\n";
print "Pragma:no-cache\n\n";


open (MSG,"$yourmsg");
 @remsg=<MSG>;
close MSG;

if ($A{'E'} eq 'writemail'){
&writemail;
exit 0;
}

if ($A{'E'} eq 'sendmail'){
&sendmail;
exit 0;
}

sub sendmail{
($sec,$min,$hour,$mday,$mon,$year)=localtime(time); 
$mon=$mon+1;
$year=$year+1900;


if ( ($A{'EMAILTO'}=~/[\||<|>|\s+|\?|\*|\$|\n|\r|&]/)||($A{'YOURMAIL'}=~/[\||<|>|\s+|\?|\*|\$|\n|\r|&]/) ){
    print "<p align=center><br><br>输入的E-MAIL地址含有非法字符,请注意不要留有空格等非法字符。";
    exit 0;}

if (($A{'EMAILTO'}=~/(.*)@(.*)/)&&($A{'YOURMAIL'}=~/(.*)@(.*)/)){

if($iplock&&&iplock){
  print "<html><body bgcolor=#F36B9E text=#FFE8F3>";
  print "<p align=center><br><br>你在短时间内已经发过一次信了,请下次再来,谢谢!</p>";
  print "</body></html>";
  exit 0;}


$from=$A{'YOURMAIL'};
$to=$A{'EMAILTO'};
$subject=$A{'DC_NAME'}.',这是你的朋友'.$A{'DC_YOURNAME'}.'寄给你的一封信';

$message=qq|
$A{'mail'}
$A{'youwrite'}
<div align=center>
<p>声明:这封信是由XYZ情书生成投递系统根据发信人的选项及发信人补充而生成,<br>
以上信件的内容、观点仅代表发信人,与本系统及相关网站无关。<br>
不排除有人利用本系统来恶意发信,如造成对您干扰等不便,请原谅。<br>本系统的设计目的是为你带来欢乐。</p>
@remsg
<p>XYZ情书生成投递系统由<a href=http://zjxyz.yeah.net target=_blank>CGI编程设计室</a>制作;
<br><a href='http://prcname.com/piecewood/' target='_blank'>小木头</a>。提供发信的模块
</div>
</body></html>
|;
#以上版权信息在使用、传播本程序时不得删除修改,请尊重作者的劳动!

open(record,">>$mailrecord");
print record "EmailTo=$A{'EMAILTO'}&Reply=$A{'YOURMAIL'}&IP: $ENV{'REMOTE_ADDR'}&Time: $hour:$min:$sec,$mday-$mon-$year\n";
close(record);

&sendmailto($from,$to,$subject,$message);
     
print qq~
<html>
<body bgcolor="#F36B9E" text="#FFE8F3">
<title>为你传情达意--XYZ情书生成投递系统</title>
<div align=center>为你传情达意--情书生成投递系统
<H2>你的信件已经发送成功!</H2>
<p>感谢你的使用!</p>
@remsg
</div>
<html>
~;


}

else{
   print "<div align=center>输入的EMAIL不正确,请注意不要留有空格等非法字符。</div>"}

}


sub writemail{

if ($A{"F_COLOR"} eq "title"){$A{"F_COLOR"}="white";}
if ($A{"BG_COLOR"} eq "title"){$A{"BG_COLOR"}="#D075A3";}
if ($A{"NN_COLOR"} eq "title"){$A{"NN_COLOR"}="#FFFF99";}
if ($A{"TB_COLOR"} eq "title"){$A{"TB_COLOR"}="#CC99CC";}

open(lib,"$libpath");  
  @buffer=<lib>;
close (lib);

$c=1;
foreach $re(@buffer){
chop($re);
   ($h,$p)=split('##',$re);

if($h=~/ST/){
   ($p1,$p2)=split('#',$p);
   if ($A{$h} eq 'V1'){
      @records=split('&',$p1);}
   else {
      @records=split('&',$p2);}
  $n=@records;

  srtan;
  $text="$text$records[int(rand($n))]";
}
  
if($h eq 'r'){
  @records=split('&',$p);
  $n=@records;
  srtan;
  $text="$text\n$records[int(rand($n))]";
}

if($h eq 'DR'){
  $text="$text\n$p";
}

if($h=~/DC/){
    if ($h eq DC_NAME || $h eq "DC_YOURNAME"){
    	 $NICK="<i><font color=$A{'NN_COLOR'}>$A{$h}</font></i>";
    	 $text="$text$NICK";}
	else{
    $text="$text$A{$h}";}
}

}



print qq|
<html><head>
<meta content='text/html; charset=gb2312' http-equiv=Content-Type>
<style type="text/css">
table,tr,td{font-size: 9pt;color:$A{"F_COLOR"};}
body,select,input,textarea.{font-size: 9pt;color:navy;}
.big{font-size:14px}
</style>
</head>
<body><title>为你传情达意--情书生成投递系统</title>
<center>
<p>为你传情达意--情书生成投递系统</p>
<p>这是程序写的部分:</p>
<table border=2 cellpadding=10 cellspacing=2 width=75% bordercolor=$A{'TB_COLOR'}>
<tr bgcolor=$A{'BG_COLOR'}><td width=806>
$text
</td></tr></table>
</center>
<div align=center><form method=POST action='$cgiurl?E=sendmail'>
|;

print qq|
<textarea rows=11 name=mail cols=65>
<html><head>
<meta content='text/html; charset=gb2312' http-equiv=Content-Type>
<style type="text/css">
table,tr,td{font-size: 9pt;color:$A{"F_COLOR"};}
body,select,input,textarea.{font-size: 9pt;color:navy;}
.big{font-size:14px}
</style>
</head>
<body><title></title>
<center>
<table border=1 cellpadding=10 cellspacing=2 width=75% bordercolor=$A{'TB_COLOR'}>
<tr  bgcolor=$A{'BG_COLOR'}><td width=806>
$text</td></tr></table></center>
</textarea></p>
|;

print "<p>你还有什么话要补充的吗?<br>";
print "<textarea rows=5 name=youwrite cols=65></textarea></p>";
print "<p>再次检查一下你要寄到的信箱:<br>";
print "<input type=text name=EMAILTO size=20 value=$A{'EMAILTO'}></p>";
print "<p>回信信箱(你的信箱):<br>";
print "<input type=text name=YOURMAIL size=20 value=$A{'YOURMAIL'}></p>";
print "<input type=hidden name=DC_NAME size=20 value=$A{'DC_NAME'}></p>";
print "<input type=hidden name=DC_YOURNAME size=20 value=$A{'DC_YOURNAME'}></p>";
print "<p><input type=submit value='    发送    ' name=B1> <input type=reset value=复原 name=B2></p></form>";
print @remsg;

#此版权信息在使用、传播本程序时不得删除修改,请尊重作者的劳动!
print "<p>XYZ情书生成投递系统由<a href='http://zjxyz.yeah.net' target='_blank'>CGI编程设计室</a>制作";
print "<br>特别感谢:<a href='http://prcname.com/piecewood/' target='_blank'>小木头</a>。提供发信的模块";
#此版权信息在使用、传播本程序时不得删除修改,请尊重作者的劳动!
print "</div></body></html>";
}


sub iplock{
$check=0;
open (FILE,"$iprecord");
@LINES=<FILE>; 
close(FILE);
$SIZE=@LINES; 

open (FILE,">$iprecord");
 for ($i=0;$i<$SIZE;$i++){
     $_=$LINES[$i];
     ($addr,$come_hour,$come_min,$come_sec,$come_time)=split(/,/,$_);
     $flag=($hour-$come_hour)*3600+($min-$come_min)*60+($sec-$come_sec);

    if( $addr eq "$ENV{'REMOTE_ADDR'}" ){
      print FILE "$ENV{'REMOTE_ADDR'},$hour,$min,$sec,$come_time\n";
      $check=1;
    }
    
    elsif ($flag < $iplocktime && $flag > 0) {
     print FILE $_;

    }
 } 

 if ($check == 0){
   print FILE "$ENV{'REMOTE_ADDR'},$hour,$min,$sec,$hour:$min:$sec\n";
   close (FILE);
   return 0;
 }
return 1;
close (FILE); 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -