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

$title = "添加房产热词-网络推广管理";
$admin = trim($admin);
$search_flag = 0;
 

if($action == 'add'){ 
    $action = 'insert';
	//引用模版文件
	include_once(Template("header"));
	include_once(Template("promotion/add"));
	include_once(Template("footer"));
	
}elseif($action == 'modify'){ 
	if($id){
		$sql = "select id,name,url from ".$tbl." where id ='".$id."'";
		$data_info = $dbback->GetRow($sql);
	}
	$action = 'update';
	//引用模版文件
	include_once(Template("header"));
	include_once(Template("promotion/add"));
	include_once(Template("footer"));
	
}elseif($action == 'update'){ 
	$id = trim($id);
	$name = trim($name);
	$url = trim($url);
	if($id == ''){
		echo "<script>alert('数据来源错误');history.back();</script>";
		die;
	}elseif($name == ''){
		echo "<script>alert('房产热词不能为空');history.back();</script>";
		die;
	}elseif($url == ''){
		echo "<script>alert('房产热词URL不能为空');history.back();</script>";
		die;
	}
 
	$ss = array();
	$ss['id'] = $id;
	$ss['name'] = $name;
	$ss['url'] = $url;
    //更新数据库
    $q = update_sql($tbl, $ss, " where id = '".$ss["id"]."'");
    $db->Execute($q);
 
    echo "<script>alert('更新成功');location = 'hotword_manage.php' </script>";
 
	
}elseif($action == 'insert'){//添加
	$name = trim($name);
	$url = trim($url);
	if($name == ''){
		echo "<script>alert('房产热词不能为空');history.back();</script>";
		die;
	}elseif($url == ''){
		echo "<script>alert('房产热词URL不能为空');history.back();</script>";
		die;
	}
 
	$ss = array();
	$ss['name'] = $name;
	$ss['url'] = $url;
	$q = insert_sql($tbl, $ss);
    $db->Execute($q);

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

}elseif($action == 'realdel'){
	$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 = 'hotword_manage.php' </script>";
	die;
} 
 

 
 

?>