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

📄 messanger.cgi

📁 一个linux论坛
💻 CGI
字号:
#!/usr/bin/perl
#######################################################
#  LB5000MX 源程序版权所有:CGI编程者之家 (CGIer.com)
#
#  程序编写:山鹰糊 (Shining Hu)、花无缺 (Ifairy Han)
#
#  程序修改:BigJim (94Cool.Net)
#######################################################

BEGIN
{
	$LBPATH = '.';
	my $pgm = $0;
	$pgm =~ s/\\/\//g;
	$pgm =~ s/^.*\/([^\/]+)$/$1/g;
	unless (-e $LBPATH.'/'.$pgm)
	{
		foreach ($0, $ENV{'SCRIPT_FILENAME'}, $ENV{'PATH_TRANSLATED'})
		{
			s!\\!/!g;
			s/^(.*)\/[^\/]+$/$1/g;
			if (-e $_ . '/' .$pgm)
			{
				$LBPATH = $_;
				last;
			}
		}
	}
	unshift(@INC, "$LBPATH");
}

use LBCGI;
$LBCGI::POST_MAX = 50000;
$LBCGI::DISABLE_UPLOADS = 1;
$LBCGI::HEADERS_ONCE = 1;
require "code.cgi";
require "data/boardinfo.cgi";
require "data/styles.cgi";
require "lb.lib.pl";

$|++;
$thisprog = "messanger.cgi";
$query = new LBCGI;
&ipbanned;
if (($mainoff == 1)||($mainonoff == 1)) { &InMaintenance; }

&error("短消息禁止使用&很抱歉,坛主由于某种原因已禁止所有用户使用短消息功能&msg") if ($allowusemsg eq "off");

$action = $query->param("action");
$inwhere = $query->param("where");
$inmsg = $query->param("msg");
$inmembername = $query->cookie("amembernamecookie");
$inpassword = $query->cookie("apasswordcookie");
$inmembername =~ s/[\a\f\n\e\0\r\t\`\~\!\@\#\$\%\^\&\*\(\)\+\=\\\{\}\;\'\:\"\,\.\/\<\>\?]//isg;
$inpassword =~ s/[\a\f\n\e\0\r\t\|\@\;\#\{\}\$]//isg;

if ($action eq "send" || $action eq "new")
{
	$intouser = $query->param("touser");
	$intouser =~ s/\; /\;/ig;
	$intouser =~ s/ \;/\;/ig;
	$intouser =~ s/\;$//ig;
	$intouser =~ s/^\;//ig;
	$inmsgtitle = $query->param("msgtitle");
	$inmessage = $query->param("message");
	$inmessage = &cleaninput($inmessage);
	$inmsgtitle = &cleaninput($inmsgtitle);
}
&error("普通错误&老大,别乱黑我的程序呀!") if ($inmembername =~  m/\// || $inmembername =~ m/\\/ || $inmembername =~ m/\.\./);
&error("普通错误&请不要修改生成的 URL!") if ($inmsg =~ /[^0-9]/);

if ($inmembername eq "" || $inmembername eq "客人")
{
	&error("普通错误&你还没登录呢?请先登录论坛!&msg");
}
else
{
	&getmember($inmembername);
	&error("普通错误&此用户根本不存在!&msg") if ($userregistered eq "no");
	&error("普通错误&密码与用户名不相符,请重新登录!&msg") if ($inpassword ne $password);
}

$action = "inbox" if ($action eq "");
$inmembername = &stripMETA($inmembername);
$memberfilename = $inmembername;
$memberfilename =~ s/ /\_/g;
$memberfilename =~ tr/A-Z/a-z/;

$output .= qq~<script language="JavaScript">
function openscript(url, width, height)
{
	var Win = window.open(url, "openwindow", "width=" + width + ",height=" + height + ",resizable=1,scrollbars=yes,menubar=yes,status=yes");
}
function enable(btn)
{
	btn.filters.gray.enabled = 0;
}
function disable(btn)
{
	btn.filters.gray.enabled = 1;
}
</script>
<style>
.gray	{cursor: hand; filter:gray}
</style>~;

$inboxpm = qq~<img src=$imagesurl/images/inboxpm.gif border=0 alt="收件箱" class=gray OnMouseOver="enable(this)" onmouseout="disable(this)" width=50 height=40>~;
$outboxpm = qq~<img src=$imagesurl/images/outboxpm.gif border=0 alt="发件箱" class=gray OnMouseOver="enable(this)" onmouseout="disable(this)" width=50 height=40>~;
$newpm = qq~<img src=$imagesurl/images/newpm.gif border=0 alt="发送消息" class=gray OnMouseOver="enable(this)" onmouseout="disable(this)" width=50 height=40>~;
$replypm = qq~<img src=$imagesurl/images/replypm.gif border=0 alt="回复消息" class=gray OnMouseOver="enable(this)" onmouseout="disable(this)" width=50 height=40>~;
$fwpm = qq~<img src=$imagesurl/images/fwpm.gif border=0 alt="转发消息" class=gray OnMouseOver="enable(this)" onmouseout="disable(this)" width=50 height=40>~;
$deletepm = qq~<img src=$imagesurl/images/deletepm.gif border=0 alt="删除消息" class=gray OnMouseOver="enable(this)" onmouseout="disable(this)" width=50 height=40>~;
$friendpm = qq~<img src=$imagesurl/images/friendpm.gif border=0 alt="打开好友录" class=gray OnMouseOver="enable(this)" onmouseout="disable(this)" width=50 height=40>~;
$blockpm = qq~<img src=$imagesurl/images/blockpm.gif border=0 alt="打开黑名单" class=gray OnMouseOver="enable(this)" onmouseout="disable(this)" width=50 height=40>~;

print header(-charset=>gb2312);
$output .= qq~
<table cellPadding=0 cellSpacing=0 border=0 width=95% bgColor=$tablebordercolor align=center><tr><td><table cellPadding=3 cellSpacing=1 border=0 width=100%>~;

my $filetoopens = "${lbdir}data/onlinedata.cgi";
$filetoopens = &lockfilename($filetoopens);
&whosonline("$inmembername\t短消息\tnone\t收发短消息") unless (-e "${filetoopens}.lck");

if ($action eq "new")
{
	my $messfilename = "${lbdir}${msgdir}/main/${memberfilename}_mian.cgi";
	&error("不允许发送短信息&您设置了短信息免打扰,这样你是无法接受短消息的,所以你也无法发送短消息!<br><font color=$fonthighlight>请重登录并取消短信息免打扰,然后再重新发送短消息!</font><br><br>&msg") if (-e $messfilename && $membercode ne "ad");

	my $cleanname = $intouser;
	$cleanname =~ tr/A-Z/a-z/;
	$cleanname =~ s/\_/ /g;
	$inmessage =~ s/<p>/\n\n/ig;
	$inmessage =~ s/<br>/\n/ig;

	if (open(FILE, "${lbdir}memfriend/${memberfilename}.cgi"))
	{
		@currentlist = <FILE>;
		close(FILE);
	}
	my $friendlist = "";
	foreach (@currentlist)
	{
		chomp;
		s/^*#!&*//isg;
		$friendlist .= qq~<option value="$_">$_</option>~;
	}

	$output .= qq~
<tr><td bgColor=$miscbacktwo align=center colSpan=2><font color=$fontcolormisc><b>发送短消息</b></td></tr>
<tr><td bgColor=$miscbackone align=center colSpan=2><a href=$thisprog?action=inbox>$inboxpm</a> <a href=$thisprog?action=outbox>$outboxpm</a> <a href=$thisprog?action=new>$newpm</a> <a href="javascript:openscript('friendlist.cgi', 420, 320)">$friendpm</a> <a href="javascript:openscript('blocklist.cgi', 420, 320)">$blockpm</a></td></tr>
<tr><td bgColor=$miscbacktwo colSpan=2 align=center><form action=$thisprog method=POST name=FORM><input type=hidden name=action value="send"><font color=$fontcolormisc><b>请完整输入下列信息</b></td></tr>
<script language="JavaScript">
function friendls()
{
	var myfriend = document.FORM.friend.options[document.FORM.friend.selectedIndex].value;
	if (myfriend != "") document.FORM.touser.value = document.FORM.touser.value == "" ? myfriend : document.FORM.touser.value + ";" + myfriend;
}
</script>
<tr>
<td bgColor=$miscbackone><font color=$fontcolormisc><b>收件人:</b></font></td>
<td bgColor=$miscbackone><input type=text name=touser value="$cleanname" size=16>  <select name=friend OnChange="friendls()"><option>好友名单</option>$friendlist</select></td>
</tr>
<tr><td bgColor=$miscbacktwo colSpan=2 align=center><font color=$fontcolormisc><b>可以用;分开各个收件人</b></font></td></tr>
<tr>
<td bgColor=$miscbackone valign=top width=30%><font color=$fontcolormisc><b>标题:</b></font></td>
<td bgColor=$miscbackone><input type=text name=msgtitle size=36 maxlength=80 value="$inmsgtitle"></td>
</tr>
<tr>
<td bgColor=$miscbackone valign=top width=30%><font color=$fontcolormisc><b>内容:</b></td>
<td bgColor=$miscbackone><textarea cols=35 rows=6 name=message OnKeyDown=ctlent()>$inmessage</textarea><br><input type=checkbox name=backup value="yes" class=1><font color=$fontcolormisc>是否复制一份消息至发件箱?</font></td>
</tr>
<tr><td bgColor=$miscbacktwo colSpan=2 align=center><input type=submit value="发 送" name=Submit>  <input type=reset name=Clear value="清 除"></td></form></tr>~;
}

elsif ($action eq "exportall")
{
	my $filetotrash = $inwhere eq "inbox" ? "${lbdir}${msgdir}/in/${memberfilename}_msg.cgi" : "${lbdir}${msgdir}/out/${memberfilename}_out.cgi";

	if (-e $filetotrash)
	{
		open(FILE, $filetotrash);
		my @messanges = <FILE>;
		close(FILE);

		$output .= qq~
<script language="JavaScript">
function HighlightAll(theField)
{
	var tempval = eval("document." + theField);
	tempval.focus();
	tempval.select();
	therange = tempval.createTextRange();
	therange.execCommand("Copy");
}
</script>
<tr><td bgColor=$miscbacktwo align=center><font color=$fontcolormisc><b>导出短消息</b></td></tr>
<tr><td bgColor=$miscbackone align=center><a href=$thisprog?action=inbox>$inboxpm</a> <a href=$thisprog?action=outbox>$outboxpm</a> <a href=$thisprog?action=new>$newpm</a> <a href="javascript:openscript('friendlist.cgi', 420, 320)">$friendpm</a> <a href="javascript:openscript('blocklist.cgi', 420, 320)">$blockpm</a></td></tr>
<tr><td bgColor=$miscbackone align=center><form name=FORM2><textarea name=inpost rows=12 style="width=90%">~;
	my $boxname = $inwhere eq "inbox" ? "收件箱" : "发件箱";
	$current_time = localtime;
	$output .= qq~
$boardname中$inmembername的短信息$boxname导出内容
(导出时间:$current_time)
----------------------------------------
~;
	my $addtime = ($timedifferencevalue + $timezone) * 3600;
	foreach (@messanges)
	{
		($usrname, $msgread, $msgtime, $msgtitle, $msgwords) = split(/\t/, $_);
		$usrname =~ s/^*#!&*//isg;
		if ($dofilter eq "no" || $dofilter eq "all")
		{
			my $temp = &postwordfilter("$msgtitle\t$msgwords");
			($msgtitle, $msgwords) = split(/\t/, $temp);
		}
		$msgwords =~ s/\r//ig;
		$msgwords =~ s/&nbsp;/ /g;
		$msgwords =~ s/"/\&quot;/g;
		$msgwords =~ s/\s+/ /g;
		$msgwords =~ s/<br>/\n/g;
		$msgwords =~ s/<p>/\n/g;
		$msgtime = &dateformat($msgtime + $addtime);
		$output .= "\n[收发对象]:$usrname\n[收发时间]:$msgtime\n[短信标题]:$msgtitle\n[短信内容]:$msgwords\n";
	}
	$output .= qq~</textarea><br>>> <a href="javascript:HighlightAll('FORM2.inpost')">复制到剪贴板 <<</a></form>
<font color=red>您在$boxname中的短消息已全部导出,这些短信息并未被真正删除!<br>为减少服务器压力,请尽早<a href=$thisprog?action=deleteall&where=$inwhere>[清空]</a>您在$boxname中的短消息!<br><br></td></tr>~;
	}
	else
	{
		&error("短消息&文件没有找到,请重复刚才步骤!&msg");
	}
}

elsif ($action eq "markall")
{	    
	$filetoopen = "${lbdir}${msgdir}/in/${memberfilename}_msg.cgi";
	if (-e $filetoopen)
	{
		&winlock($filetoopen) if ($OS_USED eq "Unix" || $OS_USED eq "Nt");
		open(FILE, $filetoopen);
		flock(FILE, 1) if ($OS_USED eq "Unix");
		my @inboxmessages = <FILE>;
		close(FILE);

		open(FILE, ">$filetoopen");
		flock(FILE, 2) if ($OS_USED eq "Unix");
		foreach (@inboxmessages)
		{
			chomp;
			next if ($_ eq "");
			($from, $readstate, $date, $messagetitle, $post) = split(/\t/, $_);
			print FILE "$from\tyes\t$date\t$messagetitle\t$post\n";
		}
		close(FILE);
		&winunlock($filetoopen) if ($OS_USED eq "Unix" || $OS_USED eq "Nt");
	}
	$output .= qq~
<tr><td bgColor=$miscbacktwo align=center><font color=$fontcolormisc><b>所有的短消息已被标记为已读</b></td></tr>
<tr><td bgColor=$miscbackone align=center><a href=$thisprog?action=inbox>$inboxpm</a> <a href=$thisprog?action=outbox>$outboxpm</a> <a href=$thisprog?action=new>$newpm</a> <a href="javascript:openscript('friendlist.cgi', 420, 320)">$friendpm</a> <a href="javascript:openscript('blocklist.cgi', 420, 320)">$blockpm</a></td></tr>
<tr><td bgColor=$miscbackone align=center><font color=$fontcolormisc><b>您在$inwhere中的短消息已经全部标记为已读</b><br><br></td></tr>~;
}

elsif ($action eq "send")
{
	&error("普通错误&老大,别乱黑我的程序呀!&msg") if ($intouser =~  m/\// || $intouser =~ m/\\/ || $intouser =~ m/\.\./);
	&error("短消息&您被禁止发言!&msg") if ($membercode eq "banned" || $membercode eq "masked");
	if (($onlinetime + $onlinetimeadd) < $onlinemessage && $onlinemessage ne "" && $membercode ne "ad" && $membercode ne "smo" && $membercode ne "cmo" && $membercode ne "mo" && $membercode ne "rz") { $onlinetime = $onlinetime + $onlinetimeadd; &error("短消息&本论坛不允许在线时间少于 $onlinemessage 秒的用户发送短消息!你目前已经在线 $onlinetime 秒!&msg"); }
	my @sendtouserlist = split(/\;/, $intouser);
	&error("短消息禁止发送&很抱歉,一次群发讯息最高数量是 7 条!&msg") if (@sendtouserlist > 7 && $membercode ne "ad" && $membercode ne "smo" && $membercode ne "cmo" && $membercode ne "mo");
	$inbackup = $query->param("backup");
	&error("短消息&没有指定收件人!&msg") if (@sendtouserlist == 0);

	undef @NoRegUser; undef @Max; undef @NoPM;
	my $noadmin = $membercode ne "ad" && $membercode ne "smo" && $membercode ne "cmo" && $membercode ne "mo" ? 1 : 0;
	my $currenttime = time;
	foreach (@sendtouserlist)
	{
		undef @inboxmessages; undef @allmessages; undef @blacklist;

		chomp;
		next if ($_ eq "");
		$cleanintouser = $_;
		$cleanintouser =~ s/ /\_/g;
		$cleanintouser =~ tr/A-Z/a-z/;
		$cleanintouser = &stripMETA($cleanintouser);

		&getmembernolock($_);
		if ($userregistered eq "no")
		{
			push(@NoRegUser, "发送短信息错误-没有找到用户「$_」");
			next;
		}

		if ($noadmin)
		{
			if ($membercode ne "ad" && $membercode ne "smo" && $membercode ne "cmo" && $membercode ne "mo")
			{
				my $filetoopen = "${lbdir}${msgdir}/in/${cleanintouser}_msg.cgi";
				if (open(FILE, $filetoopen))
				{
					@allmessages = <FILE>;
					close(FILE);
				}
				if (@allmessages >= 40)
				{
					push(@Max, "无法发送短信息给对方-$_的短消息收件箱已容纳 40 条消息,空间已满");
					next;
				}
			}

			my $filetoopen = "${lbdir}memblock/${cleanintouser}.cgi";
			if (open(FILE, $filetoopen))
			{
				@blacklist = <FILE>;
				close(FILE);
				chomp(@blacklist);
				if (grep(/^*#!&*$inmembername$/i, @blacklist))
				{
					push(@Max, "无法发送短信息给对方-$_已将你纳入其黑名单内,不接受你的任何短信息!");
					next;
				}
			}

			my $messfilename = "${lbdir}${msgdir}/main/${cleanintouser}_mian.cgi";
			if (open(FILE, $messfilename))
			{
				$mess = <FILE>;
				close(FILE);	
				push(@NoPM, "无法发送短信息-$_设置了短消息免打扰功能 <br><br>自动免打扰回覆 <font color=$fonthighlight>$mess</font><br><br>");
				next;
			}
		}

		&dofilter("$inmsgtitle\t$inmessage") if ($dofilter eq "yes" || $dofilter eq "all");
		$inmsgtitle =~ s/()+//isg;
		my $tempinmsgtitle = $inmsgtitle;
		$tempinmsgtitle =~ s/ //g;
		$tempinmsgtitle =~ s/\&nbsp\;//g;
		$tempinmsgtitle =~ s/ //isg;
		$tempinmsgtitle =~ s/

⌨️ 快捷键说明

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