<?php
$conf_basedir	= "../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
//$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
include_once($conf_basedir."base.inc.php");
checkAuth('44');	//判断登录和权限
$tbl = 'navigation_common';

$title = "修改置顶链接";

if($action == 'modify'){ 
	if($id){
		$sql = "select k_name,k_link,k_id,k_order from ".$tbl." where id ='".$id."'";
		$data_info = $dbback->GetRow($sql);
	}
}elseif($action == 'update'){ 
	$id = trim($id);
	$k_name = trim($k_name);
	$k_link = trim($k_link);
    $k_id = trim($k_id);
    $k_order = trim($k_order);
	if($id == ''){
		echo "<script>alert('数据来源错误');history.back();</script>";
		die;
	}elseif($k_name == '')
    {
        echo "<script>alert('链接名称不能为空');history.back();</script>";
		die;
    }
 
	$ss = array();
	$ss['id'] = $id;
	$ss['k_name'] = $k_name;
	$ss['k_link'] = $k_link;
    $ss['k_id'] = $k_id;
    $ss['k_order'] = $k_order;
    //更新数据库
    $q = update_sql($tbl, $ss, " where id = '".$ss["id"]."'");
    $db->Execute($q);
 
    echo "<script>alert('更新成功');location = 'navigation_manage.php' </script>";
 
	
}elseif($action == 'insert'){//添加
	$k_name = trim($k_name);
	$k_link = trim($k_link);
    $k_id = trim($k_id);
    $k_order = trim($k_order);
    $kind = trim($kind);

    if($k_name == '')
    {
        echo "<script>alert('链接名称不能为空');history.back();</script>";
		die;
    }

	$ss = array();
	$ss['k_name'] = $k_name;
	$ss['k_link'] = $k_link;
    $ss['k_id'] = $k_id;
    $ss['k_order'] = $k_order;
    $ss['kind'] = $kind;
	$q = insert_sql($tbl, $ss);
    $db->Execute($q);

	echo "<script>alert('添加成功');location = 'navigation_manage.php' </script>";
	die;

}elseif($action == 'realdel'){
	$id = trim($id);
	if($id == ''){
		echo "<script>alert('数据来源错误');history.back();</script>";
		die;
	} 
 
	$sql = "delete from navigation_type where id = '".$id."'";
	$db->execute($sql);

    $sql = "delete from ".$tbl." where kind = '".$id."'";
	$db->execute($sql);

	echo "<script>alert('删除分类成功');location = 'navigation_manage.php' </script>";
	die;
}elseif($action == 'inserttype'){//添加
	$name = trim($name);

	if($name == ''){
		echo "<script>alert('名称不能为空');history.back();</script>";
		die;
	}
	$ss = array();
	$ss['name'] = $name;
    $q = insert_sql('navigation_type', $ss);
    $db->Execute($q);

	echo "<script>alert('添加成功');location = 'navigation_manage.php' </script>";
	die;

}elseif($action == 'delstat'){
	$id = trim($id);
	if($id == ''){
		echo "<script>alert('数据来源错误');history.back();</script>";
		die;
	} 
 
    $sql = "delete from ".$tbl." where id = '".$id."'";
	$db->execute($sql);

	echo "<script>alert('删除成功');location = 'navigation_manage.php' </script>";
	die;
}
 
 	//引用模版文件
	include_once(Template("header"));
    if($action == 'addtype')
    {
    include_once(Template("navigation/navigation_type_add"));
    }else{
    include_once(Template("navigation/navigation_add"));
    }
	
	include_once(Template("footer"));

 
 

?>