<?php



require('top.php');
InitGP(array('action','type',));
require(R_P.'require/page.php');

//基本参设置;



if ($action == 'web' && $type == 'm') {
	$_SESSION['admin_groupid']  > 2 && Showmsg('authority');
	$yes_up = false;
	$sql = "SELECT * FROM ".$db_tablepre."config";
	$config_set = sql_return($sql);
	while( $config_set_up = $config_set->FetchRow()) {
		$sql_1 = "config_value='".$_POST[$config_set_up['config_name']]."'";
		$sql = "UPDATE ".$db_tablepre."config  SET ".$sql_1."  WHERE config_name='".$config_set_up['config_name']."'";
		sql_return($sql) && unlink($config_path)  && $yes_up = true;
	}
	$yes_up && Showmsg('post_Success');
}



//数据库参数设置;

elseif ($action == 'db' && $type == 'm'){
	$_SESSION['admin_groupid']  == 1 && Showmsg('authority');
	$yes_up = false;
	$sql = "SELECT * FROM ".$db_tablepre."dbconfig";
	$config_set = sql_return($sql);
	while( $config_set_up = sql_return($config_set,'FetchRow')) {
		$sql_1 = "db_value='".$_POST[$config_set_up['db_name']]."'";
		$sql = "UPDATE ".$db_tablepre."dbconfig  SET ".$sql_1."  WHERE db_name='".$config_set_up['db_name']."'";
		sql_return($sql) && unlink($dbconfig_path)   && $yes_up = true;
	}
	$yes_up && Showmsg('post_Success');
}


//房产参数设置;

elseif ($action == 'house' && $type == 'm'){
	$_SESSION['admin_groupid'] > 2 && Showmsg('authority');
	$yes_up = false;
	$sql = "SELECT * FROM ".$db_tablepre."houseconfig";
	$config_set = sql_return($sql);
	while( $config_set_up = sql_return($config_set,'FetchRow')) {
		$sql_1 = "type_value='".$_POST[$config_set_up['type_name']]."'";
		$sql = "UPDATE ".$db_tablepre."houseconfig  SET ".$sql_1."  WHERE type_name='".$config_set_up['type_name']."'";
		sql_return($sql) && unlink($houseconfig_path) && $yes_up = true;
	}
	$yes_up && Showmsg('post_Success');
}


//小区参数设置;

elseif ($action == 'premises'){
	$_SESSION['admin_groupid'] > 3 &&  Showmsg('authority');
	InitGP(array('p_id',));

	if ($type == 'up') {
		//InitGP(array('p_site_1','p_site_2'));
		$premises = array('p_name','p_regional','p_img','p_content','p_site','p_ownedlots','p_shopping','p_bus','p_signs','p_features','p_landscape','p_oldnewflats','p_green','p_matching','p_dicing','p_developer','p_c_type','p_state','p_period','p_hospital','p_park','p_busstops','p_scale','p_c_number','p_c_distance','p_d_junior','p_property','p_p_type','p_settled','p_p_charges');

		InitGP($premises);


		$sql_1 = '';
		foreach ($premises as $ks){
			$sql_1 .=  $ks.'=\''.$$ks.'\',' ;
		}
		$sql_1 .= "p_uptimes = '".$timestamp."'";
		$sql = "UPDATE ".$db_tablepre."premises  SET ".$sql_1."  WHERE p_id='".$p_id."'";
		sql_return($sql)  && Showmsg('post_Success');

	}
	elseif ($type == 'm'){
		$sql = "SELECT * FROM ".$db_tablepre."premises WHERE  p_id=".$p_id;
		$premises_m = sql_return($sql,2);
		//print_r($premises_m);
		foreach ($premises_m as $ks => $vs){
			$$ks = $vs ;
		}
	}
	elseif ($type == 'del'){
		$sql = "DELETE FROM ".$db_tablepre."premises  WHERE  p_id=".$p_id;
		sql_return($sql) && Showmsg('post_Success');

	}
	else {
		//否则显示列表;
		$num_page = '20';
		$str = 'action=premises';//分页附加字符
		$sql = "SELECT * FROM ".$db_tablepre."premises ";
		$rs = sql_return($sql);

		$num_c_page = $rs->RecordCount();
		$page = page_top($num_page,$num_c_page);

		$sql = "SELECT * FROM ".$db_tablepre."premises order by p_id   desc limit ".($page*$num_page).",$num_page";
		$rs = sql_return($sql) ;

		$page_foot = page_foot($page,$num_page,$num_c_page,$str);
	}

}

//生成html设置;

elseif ($action == 'html'){

}
//黑名单;

elseif ($action == 'bl'){
	if ($type == 'up') {
		$blacklist = array('bl_contact','bl_mobile','bl_id',);

		InitGP($blacklist);
		$sql_1 = '';
		foreach ($blacklist as $ks){
			$sql_1 .=  $ks.'=\''.$$ks.'\',' ;
		}
		$sql_1 .= "bl_uptimes = '".$timestamp."'";
		$sql = "UPDATE ".$db_tablepre."blacklist SET ".$sql_1."  WHERE bl_id='".$bl_id."'";
		sql_return($sql)  && Showmsg('post_Success');

	}
	elseif ($type == 'news_into') {
		$blacklist = array('bl_contact','bl_mobile',);
		InitGP($blacklist);
		$sql_1 = '';
		foreach ($blacklist as $ks){
			$sql_1 .=  $ks."," ;
			$sql_2 .=  "'".$$ks."'," ;
		}
		$sql_1 .= "bl_uptimes";
		$sql_2 .= "'".$timestamp."'";
		$sql = $sql = "INSERT INTO ".$db_tablepre."blacklist (".$sql_1.") VALUES(".$sql_2.")";
		sql_return($sql)  && Showmsg('post_Success');

	}
	elseif ($type == 'm'){
		InitGP('bl_id');
		$sql = "SELECT * FROM ".$db_tablepre."blacklist WHERE  bl_id=".$bl_id;
		$blacklist_m = sql_return($sql,2);
		//print_r($premises_m);
		foreach ($blacklist_m as $ks => $vs){
			$$ks = $vs ;
		}
	}
	elseif ($type == 'del'){
		InitGP('bl_id');
		$sql = "DELETE FROM ".$db_tablepre."blacklist  WHERE  bl_id=".$bl_id;
		sql_return($sql) && Showmsg('post_Success');

	}
	else {
		$num_page = '20';
		$str = 'action=bl';//分页附加字符
		$sql = "SELECT * FROM ".$db_tablepre."blacklist ";
		$rs = sql_return($sql);

		$num_c_page = $rs->RecordCount();
		$page = page_top($num_page,$num_c_page);

		$sql = "SELECT * FROM ".$db_tablepre."blacklist order by bl_id  desc limit ".($page*$num_page).",$num_page";
		$rs = sql_return($sql) ;

		$page_foot = page_foot($page,$num_page,$num_c_page,$str);
	}
}

//添加
elseif ($action == 'addadmin'){






}

require PrintEot($self_template,'A');
echo footer('N');
?>