<?
require"ygl.php";
if(!isset($ses_user_id)||!isset($ses_user_psd)){errorview("对不起，你没有登陆！！");exit;}
$user_login_id=$ses_user_id;
$user_login_psd=$ses_user_psd;
read_user_zl($user_login_id);
if($userpass1!=$user_login_psd){errorview("非法登陆！");exit;}
if($classpage=="addpage")addpage();
if($classpage=="add")add();
$ynhead1="1";
$ynhead2="1";
$file_path="/virtual/lovelgh/shared_html/freetxl";
####################
function add()
{
global $schoolfrom,$schoolcity,$schoolname,$classname,$user_login_id,$schoolcity,$usermail;
if(!file_exists("$file_path/data/config.php"))
{
if ($schoolfrom=="请选择"||empty($schoolcity)||empty($schoolname)||empty($classname))
         {
         errorview("请认真填写好必需要填的资料！！");
         exit;
         }
$class_add_date=date("Y/n/j");
mkdir("data/msg",0777) or die("create class error");
mkdir("data/photo",0777) or die("create class error");
$fp1=fopen("data/photo/list", "a+");
fclose($fp1);
$fp2=fopen("data/gbook.gb", "a+");
fclose($fp2);
mkdir("data/read",0777) or die("create class error");
$fp3=fopen("data/read/list", "a+");
fclose($fp3);
$fp4=fopen("data/news", "a+");
         fwrite($fp4,"欢迎光临我们这一班！\n");
         fclose($fp4);
$fp5=fopen("data/maillist", "w+");
if(!empty($usermail))fwrite($fp5,$usermail."\n");else fwrite($fp5,"");
fclose($fp5);
$fp6=fopen("data/online", "w+");
fclose($fp6);
########
$admin1="未定";
$admin2="未定";
$admin3="未定";
$fp2=fopen("data/config.php", "a+");
         $writedata="<?exit;\t".$user_login_id."\t".$schoolfrom."\t".$schoolcity."\t".$schoolname."\t".$classname."\t".$class_add_date."\t".$admin1."\t".$admin2."\t".$admin3."\n";
         fwrite($fp2,"$writedata");
         fclose($fp2);
$ynrefresh="1";
$gopage="classindex.php";
$ynhead2="1";
$title="建立班级成功";
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="$gopage">&gt;&gt;点击返回同学录</a></div>
    </td>
  </tr>
</table>
eot;
include"footer.php";
}else {errorview("班级已存在，不能建立班级！");exit;}
}
###################
function addpage()
{
if(!file_exists("data/config.php"))
{
$ynhead2="1";
$title="建立班级";
include"header.php";
print<<<EOT
<form name="form1" method="post" action="addclass.php">
 <input type="hidden" name="classpage" value="add">
  <table width="500" border="1"  bordercolorlight="#B5E1F7" bordercolordark="#FFFFFF" align="center" cellpadding="2" cellspacing="0">
    <tr>
      <td colspan="3">
        <div align="center"><font size="3" color="#000099"><b>请输入学校资料</b></font></div>
      </td>
    </tr>
    <tr>
      <td width="114">学校所在省份</td>
      <td width="226">
        <select name=schoolfrom size=1>
          <option>请选择</option>
          <option VALUE="北京">北京</option>
          <option VALUE="安徽">安徽</option>
          <option VALUE="重庆">重庆</option>
          <option VALUE="福建">福建</option>
          <option VALUE="甘肃">甘肃</option>
          <option VALUE="广东">广东</option>
          <option VALUE="广西">广西</option>
          <option VALUE="贵州">贵州</option>
          <option VALUE="海南">海南</option>
          <option VALUE="河北">河北</option>
          <option VALUE="黑龙江">黑龙江</option>
          <option VALUE="河南">河南</option>
          <option VALUE="湖北">湖北</option>
          <option VALUE="湖南">湖南</option>
          <option VALUE="内蒙古">内蒙古</option>
          <option VALUE="江苏">江苏</option>
          <option VALUE="江西">江西</option>
          <option VALUE="吉林">吉林</option>
          <option VALUE="辽宁">辽宁</option>
          <option VALUE="宁夏">宁夏</option>
          <option VALUE="青海">青海</option>
          <option VALUE="山西">山西</option>
          <option VALUE="陕西">陕西</option>
          <option VALUE="山东">山东</option>
          <option VALUE="上海">上海</option>
          <option VALUE="四川">四川</option>
          <option VALUE="天津">天津</option>
          <option VALUE="西藏">西藏</option>
          <option VALUE="新疆">新疆</option>
          <option VALUE="云南">云南</option>
          <option VALUE="浙江">浙江</option>
          <option VALUE="其它">其他</option>
        </select>
      </td>
      <td rowspan="4" width="140"><font color="#FF0000">注意：该资料一定要真实，否则其它同学找不到你创建的班级</font></td>
    </tr>
    <tr>
      <td width="114">学校所在城市</td>
      <td width="226">
        <input type="text" name="schoolcity" class=text>
      </td>
    </tr>
    <tr>
      <td width="114">学校名称</td>
      <td width="226">
        <input type="text" name="schoolname" class=text>
      </td>
    </tr>
    <tr>
      <td width="114">要建立的班级名称</td>
      <td width="226">
        <input type="text" name="classname" class=text>
      </td>
    </tr>
    <tr>
      <td colspan="3"><font color="#FF0000">注意：请按实际填写！</font></td>
    </tr>
    <tr>
      <td colspan="3">
        <div align="center">
          <input type="submit" name="Submit" value="建  立" class=text>
          <input type="submit" name="Submit2" value="重  置" class=text>
        </div>
      </td>
    </tr>
  </table>
</form>
EOT;
include"footer.php";
}else {errorview("班级已存在，不能建立班级！");exit;}
}
?>