<?
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;
readclass($myclass);
if(!haveclass($myclass)){errorview("对不起，没有该班级！！");exit;}
if(!ynjoinclass($myclass,$user_login_id)){errorview("对不起，你没有加入该班！！");exit;}
include"header.php";
if($droppage=="yesno")yesno();
if($droppage=="idrop")idrop();
function yesno()
{
global $user_login_id,$myclass;
print<<<eot
<table width="300" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;</td></tr></table>
<table width="300" border="1" cellspacing="0" cellpadding="3" align="center" bordercolorlight="#B5E1F7" bordercolordark="#FFFFFF">
 <tr>
  <td bgcolor="#B5E1F7" align="center"><b><font color="#FF0000">真的要退出该班吗？</font></b></td>
 </tr>
 <tr>
  <td height="50" align="center">[<a href=withdraw.php?droppage=idrop&drop_id=$user_login_id&myclass=$myclass>确定</a>]　　　　[<a href=javascript:history.back(1)>取消</a>]</td>
 </tr>
</table>

eot;
}
#########
function idrop()
{
global $user_login_id,$drop_id,$myclass,$cjadmin;
if($drop_id==$cjadmin){errorview("对不起，你是班级管理员，不能退出本班！");exit;}
if($user_login_id!=$drop_id){errorview("对不起，操作非法！");exit;}
   $hastitles = file("class/$myclass/list");
   $ccc=count($hastitles);
   $fp = fopen("class/$myclass/list","w");
   for ($i=0;$i<$ccc;$i++){
    list($class_user,$user_date,$user_enter)=explode("\t",$hastitles[$i]);
    if($drop_id!=$class_user){fputs($fp,$hastitles[$i]);}
      }
    fclose($fp);
   $hastitles1 = file("user/$user_login_id.cla");
   $ccc1=count($hastitles1);
   $fp1 = fopen("user/$user_login_id.cla","w");
   for ($i=0;$i<$ccc1;$i++){
    list($class_id,$class_date,$class_enter)=explode("\t",$hastitles1[$i]);
    if($class_id!=$myclass){fputs($fp1,$hastitles1[$i]);}
      }
    fclose($fp1);
if(file_exists("class/$myclass/msg/$user_login_id.rec"))
unlink("class/$myclass/msg/$user_login_id.rec");
if(file_exists("class/$myclass/msg/$user_login_id.snd"))
unlink("class/$myclass/msg/$user_login_id.snd");
print"<META HTTP-EQUIV=REFRESH CONTENT=0;URL=login.php>";
}
include"footer.php";
?>