<?
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;
if(!ynjoinclass($user_login_id)){errorview("对不起，你没有加入该班！！");exit;}
readclass();
$ynhead1="1";
$ynhead2="1";
$ynhead3="1";
################
if($artpage==""||$artpage=="mainlist")mainlist();
if($artpage=="addart")addart();
if($artpage=="artxiu")artxiu();
if($artpage=="artshow")artshow();
#############
function mainlist()
{
global $ynhead1,$ynhead2,$ynhead3,$perpage,$page,$a_title,$a_date,$a_sendid;
global $mymail,$txlurl,$schooln,$classn,$user_login_id;
$title="班级阅览室目录";
include"header.php";
if(file_exists("data/read/list"))
$art_file=file("data/read/list");
$size=count($art_file);
$ii=1; $j=$size;
while ($j>0) {
 $j=$j-$perpage;
}
print<<<EOT
<table width="750" border="1" cellspacing="0" cellpadding="2" align="center" bordercolorlight="#B5E1F7" bordercolordark="#FFFFFF">
 <tr align="center" bgcolor="#B5E1F7">
  <td width="392">文章标题</td>
  <td width="111">发布时间</td>
  <td width="100">发布人</td>
  <td width="60">修改</td>
  <td width="55">删除</td>
 </tr>
EOT;
if ($page == "") {$page=$ii;}
$pages=$page-1;
$pages=$page*$perpage-$perpage;
for($i=$pages; $i<$pages+$perpage; $i++) {
    $linea=$art_file[$i];
    $linea=ereg_replace("\n","", $linea);
    if ($linea != "")
        {
        $lines1a=file("data/read/list");
        while(list($tmpkey, $line1a) = each($lines1a))
              {
              $line1=ereg_replace("\n","", $line1);
              list($a_id)=split("\t",$linea);
              }
   read_art($a_id);
 print"<tr><td width=392><a href=classart.php?artpage=artshow&artshowid=$a_id target=_blank>$a_title</a></td>
  <td width=111 align=center>$a_date</td>
  <td width=100 align=center>$a_sendid</td>
  <td width=60 align=center><a href=classart.php?artpage=artxiu&artxiuid=$a_id>修改</a></td>
  <td width=55 align=center><a href=artaction.php?delartid=$a_id>删除</a></td> </tr>";
  }
  }
print"<tr><td colspan=5><table><tr><td width=100><a href=classart.php?artpage=addart>发布文章</a></td><td align=right width=650>共有<font color=red>$size</font>篇文章　　　";
 $j=$size;
while ($j>0) {
 if ($page != $ii) {print "<a href=classart.php?page=$ii>";};
 print "[$ii]";
 if ($page != $ii) {print "</a>";};
 $j=$j-$perpage;
 $ii++;
}
 print<<<EOT
</td></tr></table></td>
 </tr>
</table>
EOT;
}
#####
function addart()
{
global $ynhead1,$ynhead2,$ynhead3;
global $mymail,$txlurl,$schooln,$classn,$user_login_id;
$title="添加文章";
include"header.php";
print<<<EOT
<form name="form1" method="post" action="artaction.php">
 <table width="500" border="1" cellspacing="0" cellpadding="2" align="center" bordercolorlight="#B5E1F7" bordercolordark="#FFFFFF">
  <tr align="center">
   <td><b><font color="#000066">发布文章</font></b></td>
  </tr>
  <tr>
   <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="3">
     <tr>
      <td width="17%">文章标题：</td>
      <td width="83%">
       <input type="text" name="arttitle" size="30" class=text>
      </td>
     </tr>
     <tr>
      <td width="17%">文章内容：</td>
      <td width="83%">
       <textarea name="artcontent" cols="60" rows="6" class=text></textarea>
      </td>
     </tr>
    </table>
   </td>
  </tr>
  <tr>
   <td align="center">
    <input type="submit" name="add_art" value="提 交" class=text>
    <input type="reset" name="Submit2" value="重 置" class=text>
   </td>
  </tr>
 </table>
</form>
EOT;
}
##########
function artxiu()
{
global $ynhead1,$ynhead2,$ynhead3,$artxiuid,$a_title,$a_date,$a_sendid,$a_content;
global $mymail,$txlurl,$schooln,$classn,$user_login_id;
$title="修改文章";
include"header.php";
if(file_exists("data/read/$artxiuid"))
read_art($artxiuid);
else {errorview("读取文章出错！");exit;}
print<<<EOT
<form name="form1" method="post" action="artaction.php">
 <input type="hidden" name="artxiuid" size="30" value=$artxiuid>
 <table width="500" border="1" cellspacing="0" cellpadding="2" align="center" bordercolorlight="#B5E1F7" bordercolordark="#FFFFFF">
  <tr align="center">
   <td><b><font color="#000066">修改文章</font></b></td>
  </tr>
  <tr>
   <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="3">
     <tr>
      <td width="17%">文章标题：</td>
      <td width="83%">
       <input type="text" name="arttitle" size="30" class=text value="$a_title">
      </td>
     </tr>
     <tr>
      <td width="17%">文章内容：</td>
      <td width="83%">
       <textarea name="artcontent" cols="60" rows="6" class=text>$a_content</textarea>
      </td>
     </tr>
    </table>
   </td>
  </tr>
  <tr>
   <td align="center">
    <input type="submit" name="xiu_art" value="提 交" class=text>
    <input type="reset" name="Submit2" value="重 置" class=text>
   </td>
  </tr>
 </table>
</form>
EOT;
}
#########
function artshow()
{
global $artshowid,$a_title,$a_date,$a_sendid,$a_content;
global $mymail,$txlurl,$schooln,$classn,$user_login_id;
if(file_exists("data/read/$artshowid"))
read_art($artshowid);
else errorview("读取文章出错！");
print<<<EOT
<html>
<head>
<title>$a_title</title>
<style>
<!--
a:link{text-decoration:none;color:#000000}
a:active{text-decoration:none}
a:visited{text-decoration:none;color:#004080}
a:hover{text-decoration:underline;color:#ff0000}
textarea,input,br,td,p,div,body,input,form {font-size:9pt;color:#000000;font-family:宋体,Arial}
.gb3{font-family: 宋体; font-size: 14px}
.text{background-color:#FEFEFF; border: 1 double #B4B4B4}
.3dfont{FILTER: glow(color=ffffff,strength=0) shadow(color=aaaaaa,direction:135); POSITION: relative; WIDTH: 100%;font-size: 14px}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" background="image/bgs.jpg">
<table width="600" border="0" cellspacing="0" cellpadding="0" align="center">
 <tr>
  <td align="center"><font size=3><b>$a_title</b></font></td>
 </tr>
 <tr>
  <td align="right">发布时间：$a_date   　　　　发布人：$a_sendid</td>
 </tr>
 <tr>
  <td align="center">
   <hr size="1" width="80%" noshade color=#B5E1F7>
  </td>
 </tr>
 <tr>
  <td>$a_content</td>
 </tr>
</table>
</body>
</html>
EOT;
}
include"footer.php";
?>