<?
#############################################################
#  XYListmail Version 多用户4.0版  ( 星原邮件列表程序 )
#
#  版权所有: 星原商务网络
#
#  制作人  : cxrich   (星原浪子)
#
#  主页地址: http://www.exyweb.com/      星原商务网络
#
####################任何人不得删除此版权部分####################
require("mailset.php");

$cookie_setupname=$_REQUEST['cookie_setupname'];
$cookie_setuppassword=$_REQUEST['cookie_setuppassword'];

$mailphp_name=basename($REQUEST_URI);
if($mailphp_name=="$setupname" or $mailphp_name=="$setupname?" or $mailphp_name=="$setupname?i" or $mailphp_name=="$setupname?id" or $mailphp_name=="$setupname?id="){
//调用不正确，没有用户名
?>
<html>
<head>
<title><? echo $titlename; ?>邮件列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="750" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td>
      <div align="center">
        <p>&nbsp;</p>
        <p><b><font size="6">文件调用错误！</font></b></p>
        <p><font size="4">请先申请邮件列表</font></p>
        <p>申请邮件列表请联系：<a href="mailto=<? echo $masteremail;?>"><? echo $masteremail;?></a></p>
      </div>
    </td>
  </tr>
</table>
</body>
</html>
<?
exit;
}

switch($id or $method or $managemail){
case($id=="$id" and $method=="" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
//调用正确，但用户名不存在
if(!file_exists($set_datauser)){
	showerror("没有邮件列表，请先申请邮件列表！");
}else{
echo $mail_top;
//调用正确，用户名存在
?>
<center><br><br>
        <form action=<? echo "$filepath/$setupname?id=$name&method=add";?> method=post target=_blank>
          请输入您的E-mail： 
          <input name=mail tabIndex=3 size=20>
          <br>
          <input type=radio value=add name=listmail checked>
          加入订阅 
          <input type=radio value=del name=listmail>
          取消订阅　 
          <input class="new_input" tabIndex=10 type=submit name="submit" value=确定>
        </form>
      </center><br>
<?
echo $mail_bottom;
}
break;
case($id=="$id" and $method=="add" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
//订阅/退订处理
$mail=$_REQUEST['mail'];
$listmail=$_REQUEST['listmail'];
if (!checkEmail($mail)){
	showview("邮件地址格式不正确，请重新输入邮件地址！");
exit;}
$mail=trim($mail);
if($listmail=="add"){
	if($validata_file[0]==1)
	{
		if ($set_data_count>0){
			for ($j=0; $j<$set_data_count; $j++)
			{
				if (trim($set_data_file[$j])==$mail)
				{
				$ok=1;
				showview("邮件地址已经存在，请重新输入邮件地址！");
				exit;
				}
			}
		}
		if ($ok!=1)
			//先读出原有数据
			$f = fopen("$set_data_name","r");
			$line_has = fread($f,filesize("$set_data_name"));
			fclose($f);
			//用覆盖方式(w)将原数据及新数据写回去
			if(!is_writeable($set_data_name)){
			chmod("$set_data_name", 0777);
			}
			$f = fopen("$set_data_name","w");
			fwrite($f,"$mail\n");        #写进去,要加 \n
			fwrite($f,"$line_has");
			fclose($f);
			showview("$msginfo_1");
	}else{
		if ($mailtemp_count>0){
			for ($i=0; $i<$mailtemp_count; $i++)
			{
				if (trim($mailtemp_file[$i])==$mail)
				{
					$ok=1;
					showview("邮件地址已经存在，请重新输入邮件地址！");
					exit;
				}
			}
			if($set_data_count>0){
				for ($j=0; $j<$set_data_count; $j++)
				{
					if (trim($set_data_file[$j])==$mail)
					{
						$ok=1;
						showview("邮件地址已经存在，请重新输入邮件地址！");
						exit;
					}
				}
			}
			for ($j=0; $j<$mailtemp_count; $j++)
			{
				if (trim($mailtemp_file[$j])!=$mail)
				{
					$tt=trim($tt.$mailtemp_file[$j])."\n";
				}
			}
		}
		if($ok!=1)
			//先读出原有数据
			if(!file_exists($mailtemp_filepath)){
				fopen("$mailtemp_filepath","w");
				chmod("$mailtemp_filepath",0777);
				system("chmod 0777 $mailtemp_filepath");
			}
			$f = fopen("$mailtemp_filepath","r");
			$line_has = fread($f,filesize("$mailtemp_filepath"));
			fclose($f);
			//用覆盖方式(w)将原数据及新数据写回去
			$f = fopen("$mailtemp_filepath","w");
			fwrite($f,"$mail\n");        #写进去,要加 \n
			fwrite($f,"$line_has");
			fclose($f);
			//发送邮件
			$fname="$titlename 邮件列表";
			$from="$masteremail";
			$mailadd=$mail;
			$subject="订阅确认";
			$body="$mail_info_1<br><br>$take_link_add";
			include("funmail.php");
			$m=new Email;
			$m->sent_mailtake($fname,$from,$mailadd,$subject,$body,$sent_type);
			showview("$msginfo_1");
	}
}else{
	if($validata_file[0]==1)
	{
		if ($set_data_count>0){
			for ($j=0; $j<$set_data_count; $j++)
			{
				if (trim($set_data_file[$j])!=$mail)
				{
					$tt=trim($tt.$set_data_file[$j])."\n";
				}
			}
			for ($i=0; $i<$set_data_count; $i++)
			{
				if (trim($set_data_file[$i])==$mail)
				{
					$tt2=trim($set_data_file[$i])."\n";
				}
			}
		}
		if($tt2=="")
		{
			showview("列表中不存在该邮件地址，请确认你的邮件地址正确！");
		}else{
			$exitfileuser=fopen("$set_data_name",'w+');
			fwrite($exitfileuser,"$tt");
			fclose($exitfileuser);
			showview("$msginfo_2");
		}
	}else{
		if ($set_data_count>0){
/*			for ($j=0; $j<$set_data_count; $j++)
			{
				if (trim($set_data_file[$j])!=$mail)
				{
					$tt=trim($tt.$set_data_file[$j])."\n";
				}
			}*/
			for ($i=0; $i<$set_data_count; $i++)
			{
				if (trim($set_data_file[$i])==$mail)
				{
					$tt2=trim($set_data_file[$i])."\n";
				}
			}
		}
		if($tt2=="")
		{
			showview("列表中不存在该邮件地址，请确认你的邮件地址正确！");
		}else{
		//先读出原有数据
		$f = fopen("$mailtemp_filepath","r");
		$line_has = fread($f,filesize("$mailtemp_filepath"));
		fclose($f);
		//用覆盖方式(w)将原数据及新数据写回去
		if(!is_writeable($mailtemp_filepath)){
		chmod("$mailtemp_filepath", 0777);
		}
		$f = fopen("$mailtemp_filepath","w");
		fwrite($f,"$mail\n");        #写进去,要加 \n
		fwrite($f,"$line_has");
		fclose($f);
		$fname="$titlename 邮件列表";
		$from="$masteremail";
		$mailadd=$mail;
		$subject="退订确认";
		$body="$mail_info_2<br><br>$take_link_del";
		include("funmail.php");
		$m=new Email;
		$m->sent_mailtake($fname,$from,$mailadd,$subject,$body,$sent_type);
		showview("$msginfo_2");
		}
	}
}

break;
case($id=="$id" and $method=="take_link" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type!="" and $mailadd!=""):
//订/退邮件确认
$mailadd=trim($mailadd);
if($type=="add")
{
	if ($mailtemp_count>0){
		for ($j=0; $j<$mailtemp_count; $j++)
		{
			if (trim($mailtemp_file[$j])!=$mailadd)
			{
				$tt=trim($tt.$mailtemp_file[$j])."\n";
			}
		}
		for ($i=0; $i<$mailtemp_count; $i++)
		{
			if (trim($mailtemp_file[$i])==$mailadd)
			{
				$tt2=trim($mailtemp_file[$i])."\n";
			}
		}
	}
	if($tt2=="")
	{
		showerror("确认失败，你的邮件地址不存在！");
	}else{
		$fp_mailtemp=fopen("$mailtemp_filepath",'w+');
		fwrite($fp_mailtemp,"$tt");
		fclose($fp_mailtemp);
	//先读出原有数据
	$fp_data = fopen("$set_data_name","r");
	$line_has = fread($fp_data,filesize("$set_data_name"));
	fclose($fp_data);
	//用覆盖方式(w)将原数据及新数据写回去
	if(!is_writeable($set_data_name)){
	chmod("$set_data_name", 0777);
	}
	$fp_data = fopen("$set_data_name","w");
	fwrite($fp_data,"$mailadd\n");        #写进去,要加 \n
	fwrite($fp_data,"$line_has");
	fclose($fp_data);
	}
	showview("$takemsg_info_1");
}elseif($type=="del"){
	if ($mailtemp_count>0){
		for ($j=0; $j<$mailtemp_count; $j++)
		{
			if (trim($mailtemp_file[$j])!=$mailadd)
			{
				$tt=trim($tt.$mailtemp_file[$j])."\n";
			}
		}
		for ($i=0; $i<$mailtemp_count; $i++)
		{
			if (trim($mailtemp_file[$i])==$mailadd)
			{
				$tt2=trim($mailtemp_file[$i])."\n";
			}
		}
	}
	if($tt2=="")
	{
		showerror("退订错误，你的邮件地址不存在！");
	}else{
		$fp_mailtemp=fopen("$mailtemp_filepath",'w+');
		fwrite($fp_mailtemp,"$tt");
		fclose($fp_mailtemp);
	}
	if ($set_data_count>0){
		for ($j=0; $j<$set_data_count; $j++)
		{
			if (trim($set_data_file[$j])!=$mailadd)
			{
				$tt=trim($tt.$set_data_file[$j])."\n";
			}
		}
		for ($i=0; $i<$set_data_count; $i++)
		{
			if (trim($set_data_file[$i])==$mailadd)
			{
				$tt2=trim($set_data_file[$i])."\n";
			}
		}
	}
	if($tt2=="")
	{
		showerror("退订错误，你的邮件地址不存在！");
	}else{
		$fp_data=fopen("$set_data_name",'w+');
		fwrite($fp_data,"$tt");
		fclose($fp_data);
	}
		showview("$takemsg_info_2");
}else{
	showerror("错误，参数丢失！");
}

break;
case($id=="$id" and $method=="setup" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
//管理者登录
	$setupsub=$_REQUEST['setupsub'];
	if($setupsub)
	{
	$setup=$_REQUEST['setup'];
	$setuppwd=$_REQUEST['setuppwd'];
	$setup=md5($setup);
	$setuppwd=md5($setuppwd);
	if(($setup!=md5($infouser_1))&&($setup!=md5($infouser_1))) showerror("用户名输入有误");
	if(($setuppwd!=md5($infouser_2))&&($setuppwd!=md5($infouser_2))) showerror("密码输入有误");
	setcookie("cookie_setupname","$infouser_1");
	setcookie("cookie_setuppassword","$infouser_2");
	echo "<meta http-equiv=refresh content=0;url='$filepath/$setupname?id=$name&method=manage&page=1'>";
	}else{
echo "$mail_top";
?>
<center>
<br><br><br>
<form action="<? echo $filepath;?>/<? echo $setupname;?>?id=<? echo $name;?>&method=setup" method=post>
  <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr> 
      <td width="50%"> 
        <div align="right">版主用户名：</div>
      </td>
      <td width="50%"> 
        <input type="text" name="setup">
      </td>
    </tr>
    <tr> 
      <td width="50%"> 
        <div align="right">密码：</div>
      </td>
      <td width="50%"> 
        <input type="password" name="setuppwd">
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <div align="center"> 
          <input class="new_input" type="submit" name="setupsub" value="登录">
        </div>
      </td>
    </tr>
  </table>
  </form>
      </center>
<br><br>
<?
echo $mail_bottom;
	}

break;
case($id=="$id" and $method=="sendmailto" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
//发送邮件界面
if ($cookie_setupname or $cookie_setuppassword)
{
echo $mail_setup_menu;
$if=filesize("$set_data_name");
if($if==0)
{
echo $set_return;
}elseif($mastersend=="确定"){
 	$type=$body;
	$type=str_replace("\\","",$type);
	if(!file_exists($set_list_name)){
		fopen("$set_list_name","w");
		chmod("$set_list_name",0777);
		system("chmod 0777 $set_list_name");
	}
	$year=date("y");
	$mon1=date("m");
	$day1=date("d");
	$time="20".$year."-".$mon1."-".$day1;
	$list_temp_name=$set_list_name;
	$list_temp_file=file($list_temp_name);
	$list_temp_count=count($list_temp_file);
	$noteid=0;
	if ($list_temp_count>0){
		$info=split(' ‖‖ ',$list_temp_file[0]);
		$noteid=trim($info[0])+1;
		}
	$datanamelistvar="$noteid ‖‖ $subject ‖‖ $type ‖‖ $time";
	//先读出原有数据
	$f = fopen("$set_list_name","r");
	$line_has = fread($f,filesize("$set_list_name"));
	fclose($f);
	//用覆盖方式(w)将原数据及新数据写回去
	if(!is_writeable($set_data_name)){
	chmod("$set_list_name", 0755);
	}
	$f = fopen("$set_list_name","w");
	fwrite($f,"$datanamelistvar\n");        #写进去,要加 \n
	fwrite($f,"$line_has");
	fclose($f);
	copy($mailincladd,"$mailincladd_name");
	$cc=trim($cc);
	$bcc=trim($bcc);
	$fname=trim($fname);
	$from=trim($from);
	$subject=trim($subject);
	$body=trim($body);
	$bodytype=trim($mailincladd_name);
	$mailincladd_name=trim($mailincladd_name);
	$dataemail=$set_data_name;
	include("funmail.php");
	$m=new Email;
	$m->sent_mail($cc,$bcc,$fname,$from,$subject,$body,$sent_type,$dataemail,$mailincladd_name);
	echo "<br><center><a href=$filepath/$setupname?id=$name>返回邮件列表</a><center><br>";
	unlink($mailincladd_name);
 }else{
?>
<center><br>
  <p>发送邮件<br>
  </p>
</center>
   <form action="<? echo $filepath;?>/<? echo $setupname;?>?id=<? echo $name;?>&method=sendmailto" method=post enctype="multipart/form-data">
  <table cellspacing="0" cellpadding="0" align="center" border="1" bgcolor="#FFEEEE" bordercolorlight="#008000" bordercolordark="#FFFFFF">
    <tr> 
      <td width="179"> </td>
    </tr>
    <tr> 
      <td width="179">抄送人地址：</td>
      <td width="236"> 
        <input type="text" name="cc" size="30" onkeydown="if(event.keyCode==13)event.keyCode=9">
      </td>
      <td width="237"> 
        <input type=radio checked name=sent_type value=txt>
        文本格式 
        <input type=radio name=sent_type value=html>
        HTML格式</td>
    </tr>
    <tr> 
      <td width="179">秘密抄送地址：</td>
      <td width="473" colspan="2"> 
        <input type="text" name="bcc" size="30" onkeydown="if(event.keyCode==13)event.keyCode=9">
      </td>
    </tr>
    <tr> 
      <td width="179">发件人地址：</td>
      <td width="473" colspan="2"> 
        <input type="text" name="from" size="30" onkeydown="if(event.keyCode==13)event.keyCode=9">
      </td>
    </tr>
    <tr> 
      <td width="179">发件人姓名：</td>
      <td width="473" colspan="2"> 
        <input type="text" name="fname" size="30" onkeydown="if(event.keyCode==13)event.keyCode=9">
      </td>
    </tr>
	<tr> 
      <td width="179">邮件主题：<font color="#FF0000">*</font></td>
      <td width="473" colspan="2"> 
        <input type="text" name="subject" size="30" onkeydown="if(event.keyCode==13)event.keyCode=9">
      </td>
    </tr>
    <tr> 
      <td colspan="3">邮件内容：<font color="#FF0000">*</font><br>
        <textarea name="body" cols="70" rows="7"></textarea onkeydown="if(event.keyCode==13)event.keyCode=9">
		<input type="hidden" name="bodytype" value="">
      </td>
    </tr>
    <tr> 
      <td width="179">附件：</td>
      <td width="473" colspan="2"> 
        <input type="file" name="mailincladd" size="50">
      </td>
    </tr>
    <tr> 
      <td align="center" colspan="3"> 
        <input class="new_input" type="submit" name="mastersend" value="确定">
        <input class="new_input" type=reset value=重写 name=B2>
      </td>
    </tr>
  </table>
</form>
<?
}
echo $mail_setup_bottom;
}
else
{
showerror("帐号闲置过长或你无此权限、请勿越权操作！");
}

break;
case($id=="$id" and $method=="manage" and $managemail=="" and $page!="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
//列表管理显示界面
if ($cookie_setupname or $cookie_setuppassword)
{
$if=filesize("$set_data_name");
if($if==0){
	echo $mail_setup_menu;
	echo $set_return;
}else{
echo $mail_setup_menu;
$name=$id;
if (!isset($page)) $page=1;
$pageno=$pageno;
$managedata="$set_data_name";
?>
<center>
  <p>&nbsp;</p>
  <p>列表管理<br>
  </p>
  <form name="form1" method="post" action=<? echo "$filepath/$setupname?id=$name&method=manage&select=select";?>>
    <center>
      <table width="100%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFEEEE" bordercolorlight="#008000" bordercolordark="#FFFFFF">
        <tr> 
          <td width="7%"> 
            <div align="center">选择</div>
          </td>
          <td width="81%"> 
            <div align="center">邮 件 地 址</div>
          </td>
          <td width="12%"> 
            <div align="center">删除</div>
          </td>
        </tr>
<?
$i=($page-1)*$pageno;
$nn=1;
$line_array=file($managedata);
$linenum=count($line_array);
while($i<$linenum){
$line="$line_array[$i]";
$manageinfo=split("\n",$line);
?>
        <tr> 
          <td width="7%"> 
            <center>
              <input type="checkbox" name=manageall[] value="<? echo $manageinfo[0];?>">
            </center>
          </td>
          <td width="81%"> 
            <center>
              <? echo $manageinfo[0]; ?>
            </center>
          </td>
          <td width="12%"> 
            <div align="center">
              <?echo "<a href=$filepath/$setupname?id=$name&method=manage&managemail=$manageinfo[0]>";?>
              <img src="img/del.gif" width="16" height="16" border="0"></a></div>
          </td>
        </tr>
<?
$i++;
$nn++;
if($nn>$pageno){break;}
}
//计算页面
if($linenum%$pageno==0)
{
 $countsum=$linenum/$pageno;
}
else
{
$countsum=floor($linenum/$pageno)+1;
}
?>
      </table>
    </center>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <td width="33%"> 
          <input class="new_input" type="submit" name="managesub" value="删除所选邮件">
        </td>
        <td width="33%"> 
          <div align="cntent">
		  <?echo "<a href=$filepath/$setupname?id=$name&method=manage&managealldata=managealldata>";?>删除该列表中所有邮件</a></div>
        </td>
        <td width="34%"> 
          <div align="right">
		  <?echo "<a href=$filepath/$setupname?id=$name>";?>返回邮件列表</a></div>
        </td>
	  </tr>
    </table>
  </form>
<?
//分页显示数据
print "<center><a href=$filepath/$setupname?id=$name&method=manage&page=1>首 页</a>";
$up=$page-1;
$dn=$page+1;
if($page >1){
print " <a href=$filepath/$setupname?id=$name&method=manage&page=$up>上一页</a> ";
}
else{
echo " 上一页 ";
}
if($page >= $countsum){
print " 下一页 ";
}else{
print " <a href=$filepath/$setupname?id=$name&method=manage&page=$dn>下一页</a> ";
}
print " <a href=$filepath/$setupname?id=$name&method=manage&page=$countsum>尾 页</a>";
?>
    共<font color="#FF0000"> 
    <?php echo "$linenum" ?>
    </font>条 每页<font color="#FF0000"> 
    <?php echo "$pageno" ?>
    </font>条记录 
  </center><br>
<?
	}
echo $mail_setup_bottom;
}
else
{
showerror("帐号闲置过长或你无此权限、请勿越权操作！");
}
break;
case($id=="$id" and $method=="admend" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
//列表版主修改资料
if ($cookie_setupname or $cookie_setuppassword)
{
	if ($set_user_count>0)
	{
		$admendinfo=split(' ‖‖ ',$set_user_file[0]);
	}
echo $mail_setup_menu;
?>
<script src="admend.js"></script>
<form name="form1" method="post" action="<? echo "$filepath/$setupname?id=$name&method=admend&admend=admend";?>" onSubmit="return UserValidator(this)">
<table width="100%" border="1" cellspacing="1" cellpadding="1" align="center" bgcolor="#FFCC66" bordercolorlight="#008000" bordercolordark="#FFFFFF">
  <tr> 
      <td bgcolor="#6666FF"> 
        <div align="center"><b><font color=red>
          </font><font color="#FFFFFF" size="3"><? echo $id;?> 邮 件 列 表 版 主 资 料 修 改</font></b></div>
      </td>
    </tr>
    <tr> 
      <td> 
        <table width="99%" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor="#9999FF">
          <tr> 
            <td width="22%"> 
              
            <div align="right"><font color="#FF0000">*</font> 邮件列表名称：</div>
            </td>
            <td width="78%" colspan="2"> 
              <input type="text" name="mailname" size="50" value="<? echo $admendinfo[0];?>">
              (最多25个汉字) </td>
          </tr>
          <tr> 
            <td width="22%"> 
              <div align="right">管理员名称：</div>
            </td>
            <td width="39%"><b><font color=red>
              <? echo $admendinfo[1];?>
              </font></b> </td>
            <td width="39%">(管理员名称不可修改)</td>
          </tr>
          <tr> 
            <td width="22%"> 
              <div align="right"><font color="#FF0000">*</font> 管理员密码：</div>
            </td>
            <td width="78%" colspan="2"> 
              <input type="text" name="password" size="20" value="<? echo $admendinfo[2];?>">
              (最多20个字符，不要用汉字) </td>
          </tr>
          <tr> 
            <td width="22%"> 
              <div align="right"><font color="#FF0000">*</font> Email地址：</div>
            </td>
            <td width="78%" colspan="2"> 
              <input type="text" name="email" size="50" value="<? echo $admendinfo[3];?>">
            </td>
          </tr>
          <tr> 
            <td width="22%"> 
              <div align="right">主页名称：</div>
            </td>
            <td width="78%" colspan="2"> 
              <input type="text" name="urlname" size="50" value="<? echo $admendinfo[4];?>">
            </td>
          </tr>
          <tr> 
            <td width="22%"> 
              <div align="right">主页的URL：</div>
            </td>
            <td width="78%" colspan="2"> 
              <input type="text" name="urladd" size="50" value="<? echo $admendinfo[5];?>">
            </td>
          </tr>
          <tr> 
            <td width="22%"> 
              <div align="right"><font color="#FF0000">*</font> 邮件列表简介：</div>
            </td>
            <td width="78%" colspan="2"> 
              
            <textarea name="mailtext" cols="50" rows="4"><? echo $admendinfo[6];?></textarea>
            </td>
          </tr>
          <tr> 
            <td width="22%"> 
              
            <div align="right">头部显示信息：<br>
                （支持 html）</div>
            </td>
            <td width="78%" colspan="2"> 
              
            <textarea name="mailtopinfo" cols="50" rows="4"><? echo $admendinfo[7];?></textarea>
            </td>
          </tr>
          <tr> 
            <td width="22%"> 
              
            <div align="right">尾部显示信息：<br>
                （支持 html）</div>
            </td>
            <td width="78%" colspan="2"> 
              
            <textarea name="mailbminfo" cols="50" rows="4"><? echo $admendinfo[8];?></textarea>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr> 
      <td> 
        <input class="new_input" type="submit" name="Submit" value=" 修改完成 提交信息 ">   <FORM><INPUT class="new_input" TYPE=button VALUE=不作修改返回 onClick=history.go(-1)></FORM>
      </td>
    </tr>
    <tr> 
      <td>注意事项：<br>
        1、不得使用本邮件列表系统建立任何包含色情、非法、以及危害国家安全的内容的邮件列表;<br>
        2、不得在本系统用户所拥有的邮件列表内发布任何色情、非法、或者危害国家安全的邮件列表;<br>
        3、以上规则违者责任自负，本站有权删除该类用户或者内容，并追究其法律责任。</td>
    </tr>
  </table>
</form>
</body>
</html>
<?
echo $mail_setup_bottom;
}
else
{
showerror("帐号闲置过长或你无此权限、请勿越权操作！");
}

break;
case($id=="$id" and $method=="manage" and $managemail!="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
//列表管理界面删除邮件地址
if ($cookie_setupname or $cookie_setuppassword)
{
	if ($set_data_count>0){
				for ($j=0; $j<$set_data_count; $j++)
				{
					if (trim($set_data_file[$j])!=$managemail)
					{
						$managett=trim($managett.$set_data_file[$j])."\n";
					}
				}
				$fileuser=fopen("$set_data_name",'w+');
				fwrite($fileuser,"$managett");
				fclose($fileuser);
				showerror("邮件地址已经删除！");
	}
}
else
{
showerror("帐号闲置过长或你无此权限、请勿越权操作！");
}
break;
case($id=="$id" and $method=="manage" and $managemail=="" and $page=="" and $managealldata=="managealldata" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
//列表管理界面删除列表中全部邮件地址
if ($cookie_setupname or $cookie_setuppassword)
{
	if ($set_data_count<0){
		showerror("该列表中没有邮件");
	}else{
		$managealldatatt="";
		$fileuser=fopen("$set_data_name",'w+');
		fwrite($fileuser,"$managealldatatt");
		fclose($fileuser);
		showerror("该列表中邮件地址已经全部删除！");
	}
}
else
{
showerror("帐号闲置过长或你无此权限、请勿越权操作！");
}
break;
case($id=="$id" and $method=="manage" and $managemail=="" and $page=="" and $managealldata=="" and $select=="select" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
//列表管理界面按选择项删除邮件地址
if ($cookie_setupname or $cookie_setuppassword)
{
	$jj=count($manageall);
	if ($jj==0)
	{
		showerror("没有选择删除项，请选择！");
	}
	else
	{
			for ($i=0; $i<$set_data_count; $i++)
			{
				if (trim($manageall[$i])==$jj[$i])
			{
				$tt=trim($tt.$set_data_file[$i])."\n";
			}
			}
		$fileuser=fopen("$set_data_name",'w+');
		fwrite($fileuser,"$tt");
		fclose($fileuser);
		showerror("操作完成！");
	}
}
else
{
showerror("帐号闲置过长或你无此权限、请勿越权操作！");
}
break;
case($id=="$id" and $method=="admend" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="admend" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
//列表版主修改资料处理界面
$mailname=trim($mailname);
$name=trim($name);
$password=trim($password);
$email=trim($email);
$urlname=trim($urlname);
$urladd=trim($urladd);
$mailtext=trim($mailtext);
$mailtopinfo=trim($mailtopinfo);
$mailbminfo=trim($mailbminfo);

$year=date("y");
$mon1=date("m");
$day1=date("d");
$time="20".$year."-".$mon1."-".$day1;

$admendvar="$mailname ‖‖ $name ‖‖ $password ‖‖ $email ‖‖ $urlname ‖‖ $urladd ‖‖ $mailtext ‖‖ $mailtopinfo ‖‖ $mailbminfo ‖‖ $time";
if(!is_writeable($set_datauser)){
chmod("$set_datauser", 0755);
}
$f = fopen("$set_datauser","w");
fwrite($f,"$admendvar");
fclose($f);
echo "<meta http-equiv=refresh content=0;url='$filepath/$setupname?id=$name&method=admend'>";

break;
case($id=="$id" and $method=="note" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage!="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
//历史记录显示界面
if ($cookie_setupname or $cookie_setuppassword)
{
if(!file_exists($set_listuser)){
	echo $mail_setup_menu;
	echo $set_return;
	echo $mail_setup_bottom;
}else{
echo $mail_setup_menu;
if (!isset($topage)) $topage=1;  //设置没有TOPAGE参数,TOPAGE自动为1
$pageno=$pageno;
$notedata="$set_list_name";
$notefileuser=file("$notedata");
$notecounte=count($notefileuser);
?>
<center>
  <p>&nbsp;</p>
  <p>历史记录<br>
  </p>
  <table width="750" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFEEEE" bordercolorlight="#008000" bordercolordark="#FFFFFF">
    <tr> 
      <td width="37"> 
        <div align="center">序号</div>
      </td>
      <td width="66"> 
        <div align="center">时 间</div>
      </td>
      <td width="587"> 
        <div align="center">邮 件 标 题</div>
      </td>
      <td width="50">
        <div align="center">删除</div>
      </td>
    </tr>
    <?
$i=($topage-1)*$pageno;
$nn=1;
$line_array=file($notedata);
$linenum=count($line_array);
while($i<$linenum){
$line="$line_array[$i]";
$noteinfo=split(" ‖‖ ",$line);
?>
    <tr> 
      <td width="37"> 
        <center>
          <? echo $noteinfo[0]; ?>
        </center>
      </td>
      <td width="66"> 
        <center>
          <? echo $noteinfo[3]; ?>
        </center>
      </td>
      <td width="587"> 
        <? echo $noteinfo[1]; ?>
      </td>
      <td width="50">
        <div align="center"><?echo "<a href=$filepath/$setupname?id=$name&method=note&notemail=$noteinfo[1]>";?>删除</a></div>
      </td>
    </tr>
<?
$i++;
$nn++;
if($nn>$pageno){break;}
}
?>
  </table>
  <table width="750" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="375">
        <div align="right"><?echo "<a href=$filepath/$setupname?id=$name&method=note&noteall=noteall>";?>删除全部历史记录</a></div>
      </td>
      <td width="375">
        <div align="right"><?echo "<a href=$filepath/$setupname?id=$name>";?>返回邮件列表</a></div>
      </td>
    </tr>
  </table><br>
<?
//计算页面
if($linenum%$pageno==0)
{
 $countsum=$linenum/$pageno;
}
else
{
$countsum=floor($linenum/$pageno)+1;
}
//分页显示数据
print "<center><a href=$filepath/$setupname?id=$name&method=note&topage=1>首 页</a>";
$up=$topage-1;
$dn=$topage+1;
if($topage >1){
print " <a href=$filepath/$setupname?id=$name&method=note&topage=$up>上一页</a> ";
}
else{
echo " 上一页 ";
}
if($topage >= $countsum){
print " 下一页 ";
}else{
print " <a href=$filepath/$setupname?id=$name&method=note&topage=$dn>下一页</a> ";
}
print " <a href=$filepath/$setupname?id=$name&method=note&topage=$countsum>尾 页</a>";
?>
                    共<font color="#FF0000"> 
                    <?php echo "$linenum" ?>
                    </font>条 每页<font color="#FF0000"> 
                    <?php echo "$pageno" ?>
                    </font>条记录 </center><br>
<?
echo $mail_setup_bottom;
}
}
else
{
showerror("帐号闲置过长或你无此权限、请勿越权操作！");
}

break;
case($id=="$id" and $method=="note" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail!="" and $noteall=="" and $type=="" and $mailadd==""):
//按选择删除历史记录
if ($cookie_note1 or $cookie_note2)
{
$notemail=trim($notemail);
	for ($j=0; $j<$set_list_count; $j++)
	{
		$notedelinfo=split(' ‖‖ ',$set_lise_file[$j]);
		if (trim($notedelinfo[1])!=$notemail)
		{
			$notett=trim($notett.$set_lise_file[$j])."\n";
		}
	}
	$notedelfileuser=fopen("$set_list_name",'w+');
	fwrite($notedelfileuser,"$notett");
	fclose($notedelfileuser);
	showerror("历史记录已经删除！");
}
else
{
showerror("帐号闲置过长或你无此权限、请勿越权操作！");
}

break;
case($id=="$id" and $method=="note" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="noteall" and $type=="" and $mailadd==""):
//删除全部历史记录
if ($cookie_setupname or $cookie_setuppassword)
{
$name=$id;
	if ($set_list_count<0){
		showerror("没有历史记录");
	}else{
		$notedelalltt="";
		$notedelallfileuser=fopen("$set_list_name",'w+');
		fwrite($notedelallfileuser,"$notedelalltt");
		fclose($notedelallfileuser);
		unlink($set_list_name);
		showerror("历史记录已经全部删除！");
	}
}
else
{
showerror("帐号闲置过长或你无此权限、请勿越权操作！");
}

break;
case($id=="$id" and $method=="validata" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
if ($cookie_setupname or $cookie_setuppassword)
{

//订阅退订设置
if(!$takesub)
{
echo "$mail_setup_menu";
?>
<form name=exyweb action=<? echo "$filepath/$setupname?id=$name&method=validata";?> method=post>
<table width="100%" border="0" cellspacing="0" cellpadding="5" align="center">
  <tr> 
    <td width="100%"> 
      <div align="center"><b><font color="#FF0000" size="3">订阅/退订功能设置</font></b></div>
    </td>
  </tr>
  <tr> 
    <td width="100%"> 
      <?
if($validata_file[0]==1){
echo"<p>现在状态：<font color=red>无需邮件验证</font></p>";
}else{
echo"<p>现在状态：<font color=red>需要邮件验证</font></p>";
}
?>
      <p>订/退是否需要邮件验证： 
		<input id=yes type=checkbox name=validata value=va_yes onClick=javascript:fnShowHide()>
        (打上勾为需要验证，默认订阅/退订无需邮件验证)</p>
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr bgcolor="#FFEEEE"> 
          <td colspan="2">注册显示信息设置(最多50个字符且不允许HTML代码)</td>
        </tr>
        <tr> 
          <td width="50%">订阅显示信息：</td>
          <td width="50%">退订显示信息：</td>
        </tr>
        <tr> 
          <td width="50%"> 
            <input type="text" name="take_hit" size="30" value="<?echo $msginfo_1;?>" maxlength="50">
          </td>
          <td width="50%"> 
            <input type="text" name="slip_hit" size="30" value="<?echo $msginfo_2;?>" maxlength="50">
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td width="100%">
      <table width="100%" border="0" cellspacing="0" cellpadding="5" id="hiddenbody" style="border-collapse: collapse; DISPLAY: none">
        <tr> 
          <td colspan="2"><font color=red><b>需要验证时上面可填写：你的邮件地址需要经过我们的验证，请查收信件并完成确认！</b></font></td>
        </tr>
        <tr> 
          <td colspan="2" bgcolor="ffeeee">需要验证时订/退邮件内容设置(最多300个字符且不允许HTML代码)</td>
        </tr>
        <tr> 
          <td colspan="2">订阅时发送的邮件内容(确认链接无需输入，由系统提供！)：</td>
        </tr>
        <tr> 
          <td colspan="2"> 
<?
if($validata_file[0]==1)
	{
?>
            <textarea name="mail_take" rows="4" cols="70" maxlength="300" style="behavior:url(maxlength.htc)"></textarea>
<?
	}else{
?>
            <textarea name="mail_take" rows="4" cols="70" maxlength="300" style="behavior:url(maxlength.htc)"><?echo $mail_info_1;?></textarea>
<?
	}
?>
          </td>
        </tr>
        <tr> 
          <td colspan="2">退订时发送的邮件内容(确认链接无需输入，由系统提供！)：</td>
        </tr>
        <tr> 
          <td colspan="2"> 
<?
if($validata_file[0]==1)
	{
?>
            <textarea name="mail_slip" rows="4" cols="70" maxlength="300" style="behavior:url(maxlength.htc)"></textarea>
<?
	}else{
?>
            <textarea name="mail_slip" rows="4" cols="70" maxlength="300" style="behavior:url(maxlength.htc)"><?echo $mail_info_2;?></textarea>
<?
	}
?>
          </td>
        </tr>
        <tr bgcolor="ffeeee"> 
          <td colspan="2">需要验证时确认显示信息最多50个字符且不允许HTML代码)</td>
        </tr>
        <tr> 
          <td width="50%">确认订阅显示信息</td>
          <td width="50%">确认退订显示信息</td>
        </tr>
        <tr> 
          <td width="50%"> 
<?
if($validata_file[0]==1)
	{
?>
            <input type="text" name="take_add" size="30" maxlength="50">
<?
	}else{
?>
            <input type="text" name="take_add" size="30" maxlength="50" value="<?echo $takemsg_info_1;?>">
<?
	}
?>
          </td>
          <td width="50%"> 
<?
if($validata_file[0]==1)
	{
?>
            <input type="text" name="take_del" size="30" maxlength="50">
<?
	}else{
?>
            <input type="text" name="take_del" size="30" maxlength="50" value="<?echo $takemsg_info_2;?>">
<?
	}
?>
          </td>
        </tr>
        <tr> 
          <td width="50%">参考：确认成功，邮件地址已经加入列表！</td>
          <td width="50%">参考：退订成功，欢迎你再次加入！</td>
        </tr>
      </table>
<SCRIPT LANGUAGE=javascript>
function fnShowHide(){
	if (document.exyweb.validata.checked==true)
	{
		hiddenbody.style.display="block";
	}	
	else
	{	
		hiddenbody.style.display="none";
	}
}
</SCRIPT>
    </td>
  </tr>
  <tr> 
    <td width="100%"> 
      <p align="center"> 
        <input class=new_input type="submit" name="takesub" value=" 提交 "><FORM>
  <INPUT class=new_input TYPE=button VALUE=不作修改返回 onClick=history.go(-1)></FORM></p></td></tr>
</table>
</form>
<?
	echo "$mail_setup_bottom";
}else{
	if($take_hit=="" and $slip_hit="" or $take_hit=="" or $slip_hit=="")
	{
		showerror("订阅/退订显示信息为必填项!");
	}else{
	//注册显示信息
	$take_hit=strip_tags(trim($take_hit));
	$slip_hit=strip_tags(trim($slip_hit));
	$take_var="$take_hit ‖‖ $slip_hit";
	$fp_take=fopen($set_msg_filepath,"w");
	fwrite($fp_take,"$take_var");
	fclose($fp_take);
	//是否需要邮件验证
	}
	if($validata=="va_yes")
	{
		$validata="0";
		$fp_validata=fopen($validata_filename,"w");
		fwrite($fp_validata,"$validata");
		fclose($fp_validata);
		if($mail_take=="" and $mail_slip=="" or $mail_take=="" or $mail_slip=="")
		{
			showerror("使用邮件验证功能必须输入订/退邮件内容!");
		}elseif($take_add=="" and $take_del=="" or $take_add=="" or $take_del=="")
		{
			showerror("使用邮件验证功能必须输入确认信息!");
		}else{
			//订退邮件内容与确认信息
			$mail_take=strip_tags(trim($mail_take));
			$mail_slip=strip_tags(trim($mail_slip));
			$take_add=strip_tags(trim($take_add));
			$take_del=strip_tags(trim($take_del));
			$mail_var="$mail_take ‖‖ $mail_slip";
			$takemsg_var="$take_add ‖‖ $take_del";
			$fp_mail=fopen($set_mail_filepath,"w");
			fwrite($fp_mail,"$mail_var");
			fclose($fp_mail);
			$fp_takemsg=fopen($set_takemsg_filepath,"w");
			fwrite($fp_takemsg,"$takemsg_var");
			fclose($fp_takemsg);
		}
	}else{
		$validata="1";
		$fp_validata=fopen($validata_filename,"w");
		fwrite($fp_validata,"$validata");
		fclose($fp_validata);
		@unlink($set_mail_filepath);
		@unlink($set_takemsg_filepath);
		@unlink($mailtemp_filepath);
	}
	echo "<meta http-equiv=refresh content=0;url='$filepath/$setupname?id=$name&method=validata'>";
}
}
else
{
showerror("帐号闲置过长或你无此权限、请勿越权操作！");
}

break;
case($id=="$id" and $method=="input" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
if ($cookie_setupname or $cookie_setuppassword)
{
//批量输入
echo "$mail_setup_menu";
if($submitinput)
{
	if($mailaddinput=="")
	{
		showviewtop("你没有输入任何邮件地址！");
		echo "$mail_setup_bottom";
		exit;
	}
	$mailaddinput=strip_tags(trim($mailaddinput));
	$addinputinfo=split("\r",$mailaddinput);
	$addinput_count=count($addinputinfo);
	for($i=0;$i<$addinput_count;$i++)
	{
		if (!checkEmail($addinputinfo[$i])){
			showviewtop("邮件地址$addinputinfo[$i]格式不正确，请重新输入邮件地址！");
			echo "$mail_setup_bottom";
			exit;}
	}
	if ($set_data_count>0){
		for ($j=0; $j<$set_data_count; $j++)
		{
			if (trim($set_data_file[$j])==trim($addinputinfo[$j]))
			{
			$ok=1;
			showviewtop("邮件地址$addinputinfo[$j]已经存在，请重新输入邮件地址！");
			echo "$mail_setup_bottom";
			exit;
			}
		}
	}
	if ($ok!=1)
		//先读出原有数据
		$f = fopen("$set_data_name","r");
		$line_has = fread($f,filesize("$set_data_name"));
		fclose($f);
		//用覆盖方式(w)将原数据及新数据写回去
		if(!is_writeable($set_data_name)){
		chmod("$set_data_name", 0777);
		}
		$f = fopen("$set_data_name","w");
		for($i=0;$i<$addinput_count;$i++)
		{
			$addinputinfo_trim=trim($addinputinfo[$i]);
			fwrite($f,"$addinputinfo_trim\n");        #写进去,要加 \n
		}
		fwrite($f,"$line_has");
		fclose($f);
		showviewtop("你输入的邮件地址已经全部加入");
}else{
?>
<center>
  <p>&nbsp;</p>
  <p>批量输入<br>
  </p>
  <form name="form1" method="post" action=<? echo "$filepath/$setupname?id=$name&method=input";?>>
    <center>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="74%" valign="top"> 
            <div align="center">
              <textarea name="mailaddinput" cols="50" rows="8"></textarea>
            </div>
          </td>
          <td width="26%" valign="top">提示：<br>
            <font color=red>每行输入一个邮件地址！</font><br>
			请确认你所输入的邮件地址与列表中现有邮件地址不重复！</td>
        </tr>
        <tr> 
          <td colspan="2"> 
            <div align="center"> 
              <input class=new_input type="submit" name="submitinput" value=" 提交邮件地址 ">
            </div>
          </td>
        </tr>
      </table>
    </center>
  </form>
</center>
<?
}
echo "$mail_setup_bottom";
}
else
{
showerror("帐号闲置过长或你无此权限、请勿越权操作！");
}

break;
case($id=="$id" and $method=="loginout" and $managemail=="" and $page=="" and $managealldata=="" and $select=="" and $admend=="" and $topage=="" and $notemail=="" and $noteall=="" and $type=="" and $mailadd==""):
if ($cookie_setupname or $cookie_setuppassword)

setcookie("$cookie_setupname","");
setcookie("$cookie_setupname","");

echo "<meta http-equiv=refresh content='0;url=$filepath/$setupname?id=$name'>";

}//end switch
####################星原商务网络--版权所有#####################
?>