<?
require"ygl.php";
if(!isset($myclass)){errorview("对不起，没有该班级！！");exit;}
if(!isset($ses_user_id)||!isset($ses_user_psd)){errorview("对不起，你没有登陆！！");exit;}
$user_login_id=$ses_user_id;
$user_login_psd=$ses_user_psd;
if(!haveclass($myclass)){errorview("对不起，没有该班级！！");exit;}
if(!ynjoinclass($myclass,$user_login_id)){errorview("对不起，你没有加入该班！！");exit;}
readclass($myclass);
read_user_zl($user_login_id);
if($invitesend!="")invitesend();
if($sendlist!="")sendlist();
############
function invitesend()
{
global $email1,$email2,$email3,$email4,$email5,$content,$txladdr;
global $schooln,$classn,$username,$myclass,$mymail;
$email[0]=$email1;
$email[1]=$email2;
$email[2]=$email3;
$email[3]=$email4;
$email[4]=$email5;
$message=$username."同学给你送来了邀请函：\n";
$message.=$content."\n";
$message.="\n".$txladdr;
$message.="\n\n\n\n欢迎访问时尚同学录http://sstxl.yeah.net";
for($j=0;$j<5;$j++)
    {
    if(!empty($email[$j])){$havemail=1;break;}else{errorview("请填写E-main！");exit;}
    }
if($havemail==1)
{
for($i=0;$i<5;$i++)
    {
    if($email[$i]!="")if(!ereg(".*\@.*\..*",$email[$i])){errorview("您的Email输入错误！");exit;}
    if(!empty($email[$i]))
        {
        mail($email[$i],"时尚同学录邀请函",$message,"From: ".$mymail);
        }
    }
}
$ynrefresh="1";
$gopage="classindex.php?myclass=$myclass";
include"header.php";
print<<<EOT
<table width="500" border="1" cellspacing="0" cellpadding="4"  bordercolorlight="#B5E1F7" bordercolordark="#FFFFFF" align="center">
  <tr>
    <td height="70">
      <div align="left"><a href="classindex.php?myclass=$myclass">&gt;&gt;发送邀请函成功，点击返回.</a></div>
    </td>
  </tr>
</table>
EOT;
include"footer.php";
}
########
function sendlist()
{
global $mailtitle,$mcontent,$schooln,$classn,$username;
global $myclass,$mymail,$txlurl,$mymail,$classurl;
if(empty($mailtitle)||empty($mcontent)){errorview("邮件标题和内容！！");exit;}
$message=$mailtitle."\n";
$message.=$mcontent;
$message.="\n本班地址：".$classurl."?myclass=".$myclass;
$message.="\n\n\n\n欢迎访问时尚同学录http://sstxl.yeah.net";
$mailfile=file("class/$myclass/maillist");
$mailsize=count($mailfile);
for($i=0; $i<$mailsize; $i++)
{
 $linea=$mailfile[$i];
 $linea=ereg_replace("\n", "", $linea);
 if ($linea != "") {
 $lines1a=file("class/$myclass/maillist");
 while (list($tmpkey, $line1a) = each($lines1a))
  {
  $line1=ereg_replace("\n", "", $line1);
  list($ccmail)=split("\t",$linea);
   }
    if(!empty($ccmail))
        {
        mail($ccmail,$schooln.$classn."的群体信",$message,"From: ".$mymail);
        }
 }
}
$ynrefresh="1";
$gopage="classindex.php?myclass=$myclass";
include"header.php";
print<<<EOT
<table width="500" border="1" cellspacing="0" cellpadding="4"  bordercolorlight="#B5E1F7" bordercolordark="#FFFFFF" align="center">
  <tr>
    <td height="70">
      <div align="left"><a href="classindex.php?myclass=$myclass">&gt;&gt;群体信已发出，点击返回.</a></div>
    </td>
  </tr>
</table>
EOT;
include"footer.php";

}
?>