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

	if ($actiontype) doaction($actiontype,$actionid);
    $css="<link href='http://esfadmin.house365.com/script/css/autocomplete.css' rel='stylesheet' type='text/css' />";
    $js = "<script type='text/javascript' src='http://esfadmin.house365.com/script/js/showpic.js'></script>
    <script type='text/javascript' src='http://esfadmin.house365.com/script/js/public.js'></script>
    <script type='text/javascript' src='http://esfadmin.house365.com/script/js/formValidator.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.core.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.position.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.widget.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.autocomplete.js'></script>";
    $tbl='friend_link';
	//$title="返回上一页";

   if (($action<>"insert") and ($action<>'add')) exit;

if ($action == 'insert') {

    $data = array();
    $data["type"] = $type;
	if($data["type"] == 1){
		$data["typename"] = $keyword;
		if($data["typename"] == ""){
			echo "<script>alert('小区名称不能为空');history.go(-1);</script>";
			exit;
		}
	}else if($data["type"] == 2){
		$data["typename"] = $district;
		if($data["typename"] == ""){
			echo "<script>alert('请选择区属');history.go(-1);</script>";
			exit;
		}
	}else if($data["type"] == 3){
		$data["typename"] = $streetid;
		if($data["typename"] == ""){
			echo "<script>alert('请选择板块');history.go(-1);</script>";
			exit;
		}
	}else{
		echo "<script>alert('请选择类型');history.go(-1);</script>";
		exit;
	}
	$data["linkname"] = $linkname;
	if($data["linkname"] == ""){
		echo "<script>alert('友情链接标题不能为空');history.go(-1);</script>";
		exit;
	}
	$data["url"] = $url;
	if($data["url"] == ""){
		echo "<script>alert('友情链接URL不能为空');history.go(-1);</script>";
		exit;
	}

	$data["addname"] = $_SESSION[$web_auth]["username"];
	$data["ctime"] = time();

    //写入数据库
    $sql = insert_sql($tbl, $data);
    $db->Execute($sql);
	$id = $db->Insert_ID();

    echo "<script>window.opener.location.reload();alert('添加成功');window.close();</script>";
 }

	$cond_arr_1=array();
	$cond_arr_1["0"]		="全部";
    $cond_arr_1["1"]	    ="小区";
    $cond_arr_1["2"]	    ="区属";
    $cond_arr_1["3"]	    ="板块";

    if($data_info["district"] != ""){
	$condext = " WHERE district ='".$data_info["district"]."'";
    }

    $empty = array (""=>"请选择");
    $streetsql = "SELECT id,streetname FROM street ".$condext;
      
    $house['street']	= $empty+$db->GetAssoc($streetsql);
    

    if($conf_city=='nj')
    {
		$house['cbd']		= $empty+$db->GetAssoc("SELECT id,cbdname FROM cbd");
    }

    //引用模版文件
    include_once(Template("header"));
    include_once(Template("friend_link/friend_modify"));
    include_once(Template("footer"));
?>