<?php

include "../../include/conn.php";

include "../../include/function.php";

include "../admin_loginstate.php";

include "../admin_version.php";

include "../../include/userset.php";

include "../../include/emailadd.php";

/*

'**************************************************************************************************

' 软件名称: 黑色幻想舞曲管理系统CMS2.0

' 版本编号: hshxsdj 2.0

' 官方网站: http://www.hshxs.com

' 官方论坛：http://bbs.hshxs.com

' 版权所有: 黑色幻想开发团队    噬己翼(QQ:532917920)

' 郑重声明:

'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；

'    2、黑色幻想网络事业部保留此软件的法律追究权利

'**************************************************************************************************

*/


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>站内信管理</title>

<script type="text/javascript" language="javascript">var tentpath='<?php echo S_SitePath;?>';</script>

<script src="../js/jquery.js"></script>

<script src="../js/alerts.js"></script>

<link href="../images/alerts.css" rel="stylesheet" type="text/css" media="screen" />

<link  href="../images/style.css" rel="stylesheet" type="text/css" />

<script language="javascript"> 

	$(document).ready(function(){

		$("#submit1").click(function(){

			var S_Title=$("#S_Title").val();

			var S_Content=$("#S_Content").val();

			$("#S_Title").css("border-color","#666 #ccc #ccc #666");

			$("#S_Content").css("border-color","#666 #ccc #ccc #666");

			if(S_Title==""){

				$("#tishi").text("请您输入邮件标题！");

				$("#S_Title").css("border","1px solid red");

				return false;}

			if(S_Content==""){

				$("#tishi").text("请您请输入邮件内容！");

				$("#S_Content").css("border","1px solid red");

				return false;}

		});

		

	});

</script>

</head>

<body>

<?php

$action=SafeRequest("action","get");

switch($action){

	case "saveadd" :

		SaveAdd();

		break;

	default:

		Main();

		break;

}

function Main(){

?>

<form method="post" action="?action=saveadd">

	<table width="100%" border="0" cellpadding="0" cellspacing="0"  class="tb_style">

    	<tr>

    	  <td colspan="2" class="td_title">&nbsp;会员邮件发送</td>

    	</tr>

        <tr id="geren">

        	<td height="30" class="td_border">

            &nbsp;&nbsp;邮件标题：

            </td>

          <td height="30" class="td_border">

              <input name="S_Title" type="text" id="S_Title" style="width:500px;" value="" />

            <font color="#FF0000">＊</font></td>

        </tr>

    	<tr>

        	<td height="30" class="td_border">

            &nbsp;&nbsp;邮件内容：

            </td>

            <td height="30" class="td_border">

            <textarea name="S_Content" id="S_Content" style="display:none;"></textarea>

	    <iframe src="../../images/edit/editor.htm?id=S_Content&ReadCookie=0" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" width="650" height="465"></iframe>

            </td>

        </tr>

        <tr>

        	<td height="30" class="td_border">

            &nbsp;&nbsp;发送方式：

            </td>

            <td height="30" class="td_border">

            <input type="radio" name="type" id="type" value="0" class="radio" checked='checked' onClick="javascript:document.getElementById('opssss').style.display=''"/>指定会员&nbsp;&nbsp;&nbsp;

            <input type="radio" name="type" id="type" value="1" class="radio" onClick="javascript:document.getElementById('opssss').style.display='none'"/>全部会员

            </td>

        </tr>

        <tr id="opssss">

        	<td height="30" class="td_border">

            &nbsp;&nbsp;会员名称：

            </td>

          <td height="30" class="td_border">

              <input name="S_Name" type="text" id="S_Name" style="width:500px;" value="" />

            <font color="#FF0000">＊</font><br />

          <font color="#FF0000">  注意：多个会员请使用,号间隔分开　如：会员１号,会员２号</font></td>

        </tr>

        <tr>

        	<td height="40" class="td_border" align="right">&nbsp;</td>

            <td height="40" class="td_border" align="left"><input type="submit" name="submit1" id="submit1" value="确 定 发 送" class="rb1"/>

              &nbsp; &nbsp; <font color="red" id="tishi"></font>

          </td>

        </tr>

    </table>

    </label>

<?php

}

function SaveAdd(){

	global $db;

	$S_Title=SafeRequest("S_Title","post");

	$S_Content=SafeRequest("S_Content","post");

	$S_Name=SafeRequest("S_Name","post");

	$type=SafeRequest("type","post");

	if($type=="0"){

                $Email="";

		$S_Vip=$S_Name;

                $Arr=explode(",",$S_Vip);

		$ArrUnt=count($Arr);

		for($i=0;$i<$ArrUnt;$i++){

                    $row=$db->getrow("select * from s_users where S_Name='".$Arr[$i]."'");

                    $Email=$Email.$row["S_Email"].",";

		}

		if($S_Vip==""){

			echo "<script>jAlert('请输入要发送的对象!','操作提示',function(R){history.back();})</script>";

                        exit();

		}

	}else{

                        $Email="";

			$sqlu="select * from s_users";

			$resultu=$db->query($sqlu);

			while($rowu=$db->fetch_array($resultu)){

				$Email=$Email.$rowu["S_Email"].",";

			}

	}



        $Arr=explode(",",$Email);

        $ArrUnt=count($Arr)-1;

        $smtp =   new smtp(S_Smtp,'25',true,S_Mailuser,S_Mailpass,S_Mail); 

	for($i=0;$i<$ArrUnt;$i++){

            $smtp->sendmail($Arr[$i],S_Mail,$S_Title,$S_Content,'HTML');

        }

      	     echo "<script>jAlert('邮件发送已成功!','操作提示',function(R){history.back();})</script>";

             exit();

}

include "../admin_bottom.php";

?>

</body>

</html>

