<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<?php
require("../conn.php");
ob_start();
session_start();
require('login_user_check.php');
switch ($_GET['type_action']) {
       case "add":
	   sort_add();
	   break;
       case "del":
	   sort_del();
}

function sort_add()
{
$sort_name=str_sql($_POST['sort_name']);
$id=str_sql($_GET['id']);
date_default_timezone_set('Asia/Shanghai');
$submit_date=date("Y-m-d H:i:s,time()+8*3600");
$sort_check="select * from sort_info_manage where sort_title='$sort_name' and sort_id='$id'";
$rs_sort_check=mysql_query ($sort_check);
$order_check="select * from sort_info_manage where sort_id='$id' order by order_id desc";
$rs_order_check=mysql_query ($order_check);
if ($rs_order=mysql_fetch_object ($rs_order_check)) {
$order_id=$rs_order->order_id+1;
} else {
$order_id=1;
}
if(!mysql_fetch_object($rs_sort_check))
{
$sort_add="insert into sort_info_manage(sort_title,sort_id,order_id) values ('$sort_name','$id','$order_id')";
mysql_query ($sort_add);
}
else
{
?>
<script language="javascript">
alert('此类别名已存在，请另取个类别名!');
history.go(-1);
</script>
<?php } ?>
<script language="javascript">
location.href='sort_main.php?disp_type=<?=$_GET['disp_type']?>&id=<?=$_GET['id']?>';
</script>
<?php
}

function sort_del()
{
$id=str_sql($_GET['id']);
$sort_del="delete from sort_info_manage where id='$id'";
mysql_query ($sort_del);
?>
<script language="javascript">
location.href='sort_main.php?disp_list=<?=$_GET['disp_list']?>&disp_type=<?=$_GET['disp_type']?>&id=<?=$_GET['sort_id']?>&page=<?=$_GET['page']?>';
</script>
<?php
}
?>