<?php
!function_exists('html') && exit('ERR');

ck_power('sort');


if($job=="listsort")
{
	$query = $db->query("SELECT * FROM {$pre}count_site ORDER BY list DESC");
	while($rs = $db->fetch_array($query)){
		$sortdb[]=$rs;
	}
	
	get_admin_html('sort');
}
elseif($action=="addsort")
{

	$db->query("INSERT INTO {$pre}count_site (name) VALUES ('$name') ");


	jump("创建成功",$FROMURL);
}

//修改栏目信息
elseif($job=="editsort")
{
	$rsdb=$db->get_one("SELECT * FROM {$pre}count_site WHERE fid='$fid'");

	get_admin_html('editsort');
}
elseif($action=="editsort")
{

	$db->query("UPDATE {$pre}count_site SET name='$postdb[name]' WHERE fid='$postdb[fid]' ");

	jump("修改成功","$FROMURL");
}

elseif($action=="delete")
{
	if($fid==1){
		showmsg('站点一不能删除');
	}
	$db->query(" DELETE FROM `{$pre}count_site` WHERE fid='$fid' ");
	$db->query(" DELETE FROM `{$pre}count_user` WHERE fid='$fid' ");
	$db->query(" DELETE FROM `{$pre}count_stat` WHERE fid='$fid' ");
	jump("删除成功",$FROMURL);
}
elseif($action=='clear'){
	$db->query(" DELETE FROM `{$pre}count_user` WHERE fid='$fid' ");
	$db->query(" DELETE FROM `{$pre}count_stat` WHERE fid='$fid' ");
	jump("清除成功",$FROMURL);
}
elseif($action=="editlist")
{
	foreach( $order AS $key=>$value){
		$db->query("UPDATE {$pre}count_site SET list='$value' WHERE fid='$key' ");
	}
	jump("修改成功","$FROMURL",1);
}



?>