<?
include_once "top.php";
include("function.php");
?>
<script language=javascript1.1>
<!--
function subchk(f)
{
if(!f.title.value)
{
alert("请填写标题!");
f.title.focus();
return false;
}
}
function MM_openBrWindow(theURL,winName,features)
{ //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
<table width="100%" height="100%" cellpadding="0" cellspacing="3">
<tr height="100%">
<td width="178" height="100%" valign="top"><? include_once "left.php"?></td>
<td width="100%" height="100%" valign="top">
<? include_once "main_top.php"?>
<table id="main" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="5" height="100%" class="main_left" valign="top"></td>
<td width="99%" height="100%" valign="top" bgcolor="#FFFFFF">
<?
$rowlanmu=mysql_fetch_array(mysql_query("select * from zizhu_type where typeid = '$_GET[typeid]'"));
?>
<p style="padding-left:20px; line-height:25px"><b>额外栏目</b> >> <?=$rowlanmu[zizhuname]?> >> <?=$_GET[type]=="C"?"修改":"添加"?>信息</font><span style="margin-left:30px">[ <a href="zizhu_main.php">查看额外栏目列表</a> ]</span></p>
<?
if($_GET[type]=="I" or $_GET[type]=="T")
{
if(empty($_GET[action]))
{
?>
<table cellspacing="1" cellpadding="4" width="98%" align="center" bgcolor="#94c2e6" border="0">
<form action="?action=Tadd" name="form88" method="post" enctype="multipart/form-data" onSubmit="return subchk(this)" >
<tr>
<td width="8%" align="center" bgcolor="#f6f6f6"><b>标 题</b></td>
<td width="92%" bgcolor="#ffffff"><input name="title" id="class4" style="width: 240px" maxlength="100"><font color="#FF0000">*必填项</font></td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6"><b>图片/附件</b></td>
<td bgcolor="#ffffff"><input name="img" type="file" id="img" size="30"><font color="#FF0000">文件名组成:英文或数字</font></td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6"><b>内<br><br>容 <font color="#FF0000"><br><br>*</font></b></td>
<td bgcolor="#ffffff">
<script type="text/javascript" charset="utf-8" src="editor/kindeditor.js"></script>
<script type="text/javascript">
KE.show({id : 'content',cssPath : 'css/css.css'});
</script>
<textarea id="content" name="content" style="width:100%;height:100%;visibility:hidden;"></textarea>
</td>
</tr>
<tr>
<td bgcolor="#ffffff" colspan="2" align="center">
<input style="margin-right:30px" name="addT" type="submit" id="addT" value="提 交">
<input type="reset" name="Submit2" value="重 置" onclick="javascript:location='news_main.php?classid=<?=$rowlanmu[classid]?>';">
<input type="hidden" name="page" value="<?=$_GET[page]?>">
<input type="hidden" name="typeid" value="<?=$rowlanmu[typeid]?>">
<input type="hidden" name="type" value="<?=$rowlanmu[type]?>">
</td>
</tr>
</form>
</table>
<?
}
}
if($_GET[action]=="Tadd")
{
?>
<table id="main_tab" cellspacing="1" width="98%" bgcolor="#94c2e6" border="0">
<tr bgcolor="#ffffff">
<td width="100%" height=100 align="center" bgcolor="#ffffff">
<?
if($_POST[addT])
{
$now=date('Ymdhis');
$oldimg=$_POST[img];
if($_FILES['img']["name"])
{
$aa=explode(".",$_FILES['img']["name"]);
$int=count($aa)-1;
$pt=$aa[$int];
if($pt!='zip' and $pt!='rar' and $pt!='txt' and $pt!='ppt' and $pt!='doc' and $pt!='xls' and $pt!='jpg' and $pt!='jpeg' and $pt!='gif' and $pt!='bmp' and $pt!='png')
echo ' <script language="javascript">alert("对不起,文件格式不正确,支持.zip .rar .txt .ppt .doc .xls .jpg .gif .jpeg .bmp .png 格式文件");location="zizhu_xiangxi.php?typeid='.$_POST[typeid].'&type='.$_POST[typeid].'";</script>';
elseif($_FILES["img"]["size"]>1000000)
echo ' <script language="javascript">alert("对不起,文件大小超过限制,请限制在1M以内");location="zizhu_xiangxi.php?typeid='.$_POST[typeid].'&type='.$_POST[typeid].'";</script>';
else
{
mt_srand((double)microtime()*1000000);//产生随机数
$mode = mt_rand(1,6);
$img_suiji=getrandom(5,$mode);
if(!file_exists($updir) or !is_dir($updir))
mkdir ($updir,0777);
$now=date("YmdHis");
$oldimg=$_SESSION[webuser].$now.$img_suiji.".".$pt;
copy($_FILES['img']['tmp_name'],"$updir/".$oldimg);
}
}
mysql_query("insert into zizhu (title,typeid,content,img)values('$_POST[title]','$_POST[typeid]','$_POST[content]','$oldimg')");
if(!mysql_error())
{
echo "<b><font color='#ff0000'>信息添加成功</font></b> <a href='zizhu_xiangxi.php?typeid=$_POST[typeid]&type=$_POST[type]'>[ 继续添加 ]<font size=1>>>></font></a> <a href='zizhu_xiangxi.php?typeid=$_POST[typeid]&type=$_POST[type]'>[ 查看信息列表 ]<font size=1>>>></font></a>";
}
else
{
echo mysql_error();
echo "<b><font color='#ff0000'>信息添加失败</font></b> <a href='#' onclick='javascript:histroy.back();'>返回<font size=1>>>></font></a>";
}
}
?>
</td>
</tr>
</table>
<?
}
elseif($_GET[action]=="Tdel")
{
?>
<table id="main_tab" cellspacing="1" width="98%" bgcolor="#94c2e6" border="0">
<tr bgcolor="#ffffff">
<td width="100%" height=100 align="center" bgcolor="#ffffff">
<?
foreach($_POST[delid] as $del)
{
$row=mysql_fetch_array(mysql_query("select * from zizhu where id='$del'"));
if($row[img]<>"")
{
$dir="$updir/$row[img]";
@unlink($dir) ;
}
mysql_query("delete from zizhu where id='$del'") or die(mysql_error());
}
if(!mysql_error())
{
echo "<b><font color='#ff0000'>信息已经删除</font>