<?php 
$conf_basedir	= "../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
//$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
include_once($conf_basedir."base.inc.php");
error_reporting(7);
ini_set("display_errors",true);

include_once($conf_basedir."model/block_base_func.php");

  //获取小区列表
if($_REQUEST['actiontype'] == 'getblocklist' && $_REQUEST['q']){

	$blocklist = array();

    $blockname = trim(strip_tags(urldecode($_REQUEST['q'])));
	$temp_block = getBlockArrByKeyword($blockname,10);
	if($temp_block && !empty($temp_block)){
		$i = 0;
		foreach($temp_block as $key=>$value ){
			$blocklist[$i]['label'] = trim(iconv('GBK', 'UTF-8', $value["blockname"]));
			$blocklist[$i]['id']	= $value["id"];
			$i++;
		}
	}else{
		$blocklist[0]['label']  = trim(iconv('GB2312', 'UTF-8', "无相似小区"));
		$blocklist[0]['id']		= "0";
	}

  print_r(json_encode($blocklist));
  exit;
}

if($actiontype == 'getstreet'){

	$district=mb_convert_encoding(urldecode($district),"gb2312","utf-8");
	$sql = "select id,streetname from street where district='$district'";

	$arr[street]=$dbback->GetAssoc($sql);
	$ss = "<option value=''>请选择</option>";
	if(isset($arr[street]) && !empty($arr[street]))
	{
		foreach($arr[street] as $key=>$value)
		{
			$ss.='<option  value="'.$key.'">'.$value.'</option>';
		}
	}

	echo $ss;
	exit;
}

//设置失效
if($actiontype == 'setfailure'){
	$id = intval($id);
	if($id){
		//$uid = $_SESSION[$web_auth]["uid"];
		$where = " id = ".$id;
		$admin_arr = array("youlian_user_a","youlian_user_b","youlian_user_c","youlian_user_d");
		$username =  $_SESSION[$web_auth]["username"];
		if (in_array($username,$admin_arr))
		{
			$where .= " and addname = '".$username."'";
		}
		$sql = "UPDATE friend_link SET status = 0,failtime=".time()." WHERE ".$where;
		if ($db->Execute($sql)) {
			exit("1");
		}else{
			exit('0');
		}
	}else{
		exit('0');
	}
}

if($actiontype == 'seteffective'){
	$id = intval($id);
	if($id){
		//$uid = $_SESSION[$web_auth]["uid"];
		$where = " id = ".$id;
		$admin_arr = array("youlian_user_a","youlian_user_b","youlian_user_c","youlian_user_d");
		$username =  $_SESSION[$web_auth]["username"];
		if (in_array($username,$admin_arr))
		{
			$where .= " and addname = '".$username."'";
		}
		$sql = "UPDATE friend_link SET status = 1,failtime=0 WHERE ".$where;
		if ($db->Execute($sql)) {
			exit("1");
		}else{
			exit('0');
		}
	}else{
		exit('0');
	}
}

?>