<?
$C_126cmsadmin_tname = 'sort_config';

include(dirname(__FILE__)."/global.php");




@$job = $submitted_vars["job"];

if($job == "del"){
   
   $id = $_GET['id'];
   $query="DELETE FROM `w6_sort` WHERE `id`='$id' ";
   $result=mysql_query($query) or die( mysql_error() );
   if ($result)
     {
       $showmsg = "栏目删除成功！";
	   $formurl = "sort.php";
     }
  else
     {
       $showmsg = "栏目删除失败！";
	   $formurl = "sort.php";
     }
	 
  include('showmsg.php');
  exit;
  
}
if($job == "modifylist"){
   
   $order = $_POST['order'];
   
   foreach( $order AS $key=>$value)
	{
		$result = mysql_query("UPDATE w6_sort SET list='$value' WHERE id='$key'");
	}
	$showmsg = "修改成功！";
	$formurl = "sort.php";
    include('showmsg.php');
    exit;
  
}

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>后台管理</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link {
	text-decoration: none;
	color: #000000;
}
a:visited {
	text-decoration: none;
	color: #000000;
}
a:hover {
	text-decoration: underline;
	color: #FF0000;
}
a:active {
	text-decoration: none;
	color: #000000;
}
-->
</style>

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_popupMsg(msg) { //v1.0
  return confirm(msg);
}
//-->
</script>

</head>

<body>
<div align="center" class="font12">
  <table width="100%"  border="0" cellpadding="3" cellspacing="1" bgcolor="#A4B6D7">
    <tr>
      <td width="100%" height="22" align="center" background="images/titlebg.jpg">&nbsp;</td>
    </tr>
  </table>
  <br />
  <table width="100%" height="25" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
      <td align="left" bgcolor="#FFFFFF"> [<a 
      href="sort.php" class="a_bt">栏目管理</a>] 
      [<a 
      href="sort_add.php" class="a_bt">创建栏目</a>] </td>
    </tr>
  </table>
  <br />
  <br />
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table">
    <tr>
      <td height="22" align="left" class="head">编辑栏目</td>
    </tr>
    <tr>
      <td height="24" align="left">
	  <br />
      <UL>
      <LI>注意:<FONT color=#ff0000>排序的规则是,数值大的排在前面</FONT> </LI>
      </UL>
</td>
    </tr>
    <tr>
      <td align="center">
	  <FORM name="formlist" action="" method="post">
  <table width="99%" border="0" cellspacing="1" cellpadding="0">
        <tr>
         <td width="6%" height="30" align="center" background="images/titlebg.jpg">FID</td>
          <td width="4%" align="center" background="images/titlebg.jpg">&nbsp;</td>
          <td width="30%" align="center" background="images/titlebg.jpg">栏目名称</td>
          <td width="14%" align="center" background="images/titlebg.jpg">发表</td>
          <td width="13%" align="center" background="images/titlebg.jpg">排序</td>
          <td width="11%" align="center" background="images/titlebg.jpg">状态</td>
          <td width="11%" align="center" background="images/titlebg.jpg">修改</td>
          <td width="11%" align="center" background="images/titlebg.jpg">删除</td>
        </tr>
		<?
	list_allsort('w6_sort');
	
	foreach($sortdb AS $key=>$rs){
	
	if($rs['hide'] == "1"){
	$rs['hide']="<font color=\"#0000FF\">隐藏</font>";
	}elseif($rs['hide'] == "0"){
	$rs['hide']="显示";
	}

?>
        <tr class=trA onMouseOver="this.className='trB'" 
        onmouseout="this.className='trA'">
          <td align="center" class="td" style="color: #FF0000;"><?=$rs['id']?></td>
          <td align="center" class="td" style="color: #FF0000;"><input type="checkbox" name="fiddb[]" value="<?=$rs['id']?>" style="border:0px;" checked /></td>
          <td align="left" class="td" style="color:<? if($rs['color']) echo $rs['color'];?>;"><?=$rs['icon']?>【<?=$rs['name']?>】</td>
          <td align="center" class="td">
		  
		  <?
		  
		  if( $rs['type'] == "2" ){ 
		  	echo  '<a href="post_info/post.php?id='.$rs['id'].'&mid='.$rs['mid'].'"><font color="#0000FF">修改内容</font></a>';
			}elseif( $rs['type'] == "0" ){
			echo '<a href="post_info/post.php?id='.$rs['id'].'&mid='.$rs['mid'].'"><font color="#0000FF">发表</font></a>';
			}elseif( $rs['type'] == "1" ){
			echo '&nbsp;';//不显示
			}
			
		  ?>		  </td>
          <td align="center" class="td">
            <input maxlength="4" size="5" value="<?=$rs['list']?>" name="order[<?=$rs['id']?>]" />          </td>
          <td align="center" class="td"><?=$rs['hide']?></td>
          <td align="center" class="td"><a href="sort_modify.php?id=<?=$rs['id']?>">修改</a></td>
          <td align="center" class="td"><a href="?job=del&amp;id=<?=$rs['id']?>" onClick="return MM_popupMsg('确定要删除吗！删除后无法恢复！')">删除</a></td>
        </tr>
		<?
		}
		?>
        <tr>
          <td height="30" colspan="7" align="center">
          [<a href="javascript:CheckAll('all');">全选</a>] [<a href="javascript:CheckAll('');">反选</a>] 
                  <script language="JavaScript">
<!--
function CheckAll(va){
	form=document.formlist
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if(e.name=='maketype'||e.name=='webdbs[TheSameMakeIndexHtml]')continue;
		if(va=='all'){
			e.checked = true;
		}else{
			e.checked == true ? e.checked = false : e.checked = true;
		}
	}
}
//-->
</script>
                  
          <input type="submit" value="修改排序" name="Submit22" onclick="postlist('list')" />
            <input name="job" type="hidden" id="job" value="modifylist" />
            <input type="button" name="Submit55" value="批量修改栏目" onclick="postlist('edit')">

<SCRIPT LANGUAGE="JavaScript">
<!--
function postlist(t){
	if(t=='list'){
		document.formlist.action="sort.php";
	}else if(t=='edit'){
		//document.formlist.target='_blank';
		document.formlist.action="sort_modify_batch.php";
	}
	document.formlist.submit();
}


//-->
</SCRIPT>            
            </td>
        </tr>
      </table>
	  </form></td>
    </tr>
  </table>
  </div>
</body>
</html>
