<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: update_profile.php 10954 2009-01-12 05:26:27Z liguode $
*/

include_once('../common.php');

//是否关闭站点
checkclose();

//是否公开
if(empty($_SCONFIG['networkpublic'])) {
	checklogin();
}
$list = array();
$def_domain = array('blog');
if ( !empty($_SGLOBAL['supe_uid']) )
{
	$domain = strtolower($_POST['domain']);
	if ( !ereg("^[a-z0-9]*$",$domain) ) 
	{  
		echo   "无效的个性域名：只能包含英文字母和数字"; 
		exit;
	}
	if ( strlen($domain) < 4 )
	{
		echo   "个性域名太短：至少4位字符"; 
		exit;
	}
	if ( in_array( $domain, $def_domain ) )
	{
		echo   "此域名不可用"; 
		exit;
	}

	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site_domain')." WHERE domain='".$domain."'");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$list[] = $value;
	}
	if ( $list )
	{
		echo "该个性域名已经注册过了";
		exit;
	}
	else
	{
		$setarr = array(
			'domain' => $domain,
			'uid' => $_SGLOBAL['supe_uid'],
			'active' => 1
		);
		$aid = inserttable('site_domain', $setarr, 1);
		echo "success";
		exit;
	}
}
else
{
	echo "请您登陆后设置";
	exit;
}
?>