Location: PHPKode > projects > Uchome and Discuz > install/index.php
<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: index.php 13234 2009-08-24 08:20:04Z liguode $
*/

define('IN_UCHOME', TRUE);

error_reporting(0);
$_SGLOBAL = $_SCONFIG = $_SBLOCK = array();

//³ÌÐòĿ¼
define('S_ROOT', substr(dirname(__FILE__), 0, -7));

//»ñȡʱ¼ä
$_SGLOBAL['timestamp'] = time();

include_once(S_ROOT.'./source/function_common.php');
if(!@include_once(S_ROOT.'./config.php')) {
	@include_once(S_ROOT.'./config.new.php');
	show_msg('ÄúÐèÒªÊ×ÏȽ«³ÌÐò¸ùĿ¼ÏÂÃæµÄ "config.new.php" ÎļþÖØÃüÃûΪ "config.php"', 999);
}

//GPC¹ýÂË
if(!(get_magic_quotes_gpc())) {
	$_GET = saddslashes($_GET);
	$_POST = saddslashes($_POST);
}

//ÆôÓÃGIP
if ($_SC['gzipcompress'] && function_exists('ob_gzhandler')) {
	ob_start('ob_gzhandler');
} else {
	ob_start();
}

$formhash = formhash();

$theurl = 'index.php';
$sqlfile = S_ROOT.'./data/install.sql';
if(!file_exists($sqlfile)) {
	show_msg('ÇëÉÏ´«×îÐ嵀 install.sql Êý¾Ý¿â½á¹¹Îļþµ½³ÌÐòµÄ ./data Ŀ¼ÏÂÃ棬ÔÙÖØÐÂÔËÐб¾³ÌÐò', 999);
}
$configfile = S_ROOT.'./config.php';

//±äÁ¿
$step = empty($_GET['step'])?0:intval($_GET['step']);
$action = empty($_GET['action'])?'':trim($_GET['action']);
$nowarr = array('','','','','','','');

$lockfile = S_ROOT.'./data/install.lock';
if(file_exists($lockfile)) {
	show_msg('¾¯¸æ!ÄúÒѾ­°²×°¹ýUCenter Home<br>
		ΪÁ˱£Ö¤Êý¾Ý°²È«£¬ÇëÁ¢¼´ÊÖ¶¯É¾³ý install/index.php Îļþ<br>
		Èç¹ûÄúÏëÖØа²×°UCenter Home£¬Çëɾ³ý data/install.lock Îļþ£¬²¢µ½UCenterºǫ́ӦÓùÜÀí´¦É¾³ý¸ÃÓ¦Óã¬ÔÙÔËÐа²×°Îļþ');
}

//¼ì²éconfigÊÇ·ñ¿Éд
if(!@$fp = fopen($configfile, 'a')) {
	show_msg("Îļþ $configfile ¶ÁдȨÏÞÉèÖôíÎó£¬ÇëÉèÖÃΪ¿Éд£¬ÔÙÖ´Ðа²×°³ÌÐò");
} else {
	@fclose($fp);
}

//Ìá½»´¦Àí
if (submitcheck('ucsubmit')) {

	//°²×°UCÅäÖÃ
	$step = 1;

	//ÅжÏÓòÃûÊÇ·ñ½âÎö
	$ucapi = preg_replace("/\/$/", '', trim($_POST['ucapi']));
	$ucip = trim($_POST['ucip']);

	if(empty($ucapi) || !preg_match("/^(http:\/\/)/i", $ucapi)) {
		show_msg('UCenterµÄURLµØÖ·²»ÕýÈ·');
	} else {
		//¼ì²é·þÎñÆ÷ dns ½âÎöÊÇ·ñÕý³£, dns ½âÎö²»Õý³£ÔòÒªÇóÓû§ÊäÈëucenterµÄipµØÖ·
		if(!$ucip) {
			$temp = @parse_url($ucapi);
			$ucip = gethostbyname($temp['host']);
			if(ip2long($ucip) == -1 || ip2long($ucip) === FALSE) {
				$ucip = '';
			}
		}
	}

	//ÑéÖ¤UCHomeÊÇ·ñ°²×°
	if(!@include_once S_ROOT.'./uc_client/client.php') {
		show_msg('uc_clientĿ¼²»´æÔÚ£¬ÇëÉÏ´«°²×°°üÖÐµÄ ./upload/uc_client µ½³ÌÐò¸ùĿ¼');
	}
	$ucinfo = uc_fopen2($ucapi.'/index.php?m=app&a=ucinfo&release='.UC_CLIENT_RELEASE, 500, '', '', 1, $ucip);
	list($status, $ucversion, $ucrelease, $uccharset, $ucdbcharset, $apptypes) = explode('|', $ucinfo);
	$dbcharset = strtolower(trim($_SC['dbcharset'] ? str_replace('-', '', $_SC['dbcharset']) : $_SC['dbcharset']));
	$ucdbcharset = strtolower(trim($ucdbcharset ? str_replace('-', '', $ucdbcharset) : $ucdbcharset));
	$apptypes = strtolower(trim($apptypes));
	if($status != 'UC_STATUS_OK') {
		show_header();
		print<<<END
		<form id="theform" method="post" action="$theurl">
		<table class="datatable">
		<tr><td><strong>UCenterÎÞ·¨Õý³£Á¬½Ó£¬·µ»Ø´íÎó ( $status )£¬ÇëÈ·ÈÏUCenterµÄIPµØÖ·ÊÇ·ñÕýÈ·</strong><br><br></td></tr>
		<tr><td>UCenter·þÎñÆ÷µÄIPµØÖ·: <input type="text" name="ucip" value="$ucip"> ÀýÈ磺192.168.0.1</td></tr>
		</table>
		<table class=button>
		<tr><td>
		<input type="hidden" name="ucapi" value="$ucapi">
		<input type="hidden" name="ucfounderpw" value="$_POST[ucfounderpw]">
		<input type="submit" id="ucsubmit" name="ucsubmit" value="È·ÈÏIPµØÖ·"></td></tr>
		</table>
		<input type="hidden" name="formhash" value="$formhash">
		</form>
END;
		show_footer();
		exit();
	} elseif($dbcharset && $ucdbcharset && $ucdbcharset != $dbcharset) {
		show_msg('UCenter ·þÎñ¶Ë×Ö·û¼¯Ó뵱ǰӦÓõÄ×Ö·û¼¯²»Í¬£¬ÇëÏÂÔØ '.$ucdbcharset.' ±àÂëµÄ UCenter Home ½øÐа²×°£¬ÏÂÔصØÖ·£ºhttp://download.comsenz.com/');
	} elseif(strexists($apptypes, 'uchome')) {
		show_msg('ÒѾ­°²×°¹ýÒ»¸öUCenter Home²úÆ·£¬Èç¹ûÏë¼ÌÐø°²×°£¬ÇëÏȵ½ UCenter Ó¦ÓùÜÀíÖÐɾ³ýÒÑÓеÄUCenter Home£¡');
	}
	$tagtemplates = 'apptagtemplates[template]='.urlencode('<a href="{url}" target="_blank">{subject}</a>').'&'.
		'apptagtemplates[fields][subject]='.urlencode('ÈÕÖ¾±êÌâ').'&'.
		'apptagtemplates[fields][uid]='.urlencode('Óû§ ID').'&'.
		'apptagtemplates[fields][username]='.urlencode('̞').'&'.
		'apptagtemplates[fields][dateline]='.urlencode('ÈÕÆÚ').'&'.
		'apptagtemplates[fields][spaceurl]='.urlencode('¿Õ¼äµØÖ·').'&'.
		'apptagtemplates[fields][url]='.urlencode('ÈÕÖ¾µØÖ·');

	$uri = $_SERVER['REQUEST_URI']?$_SERVER['REQUEST_URI']:($_SERVER['PHP_SELF']?$_SERVER['PHP_SELF']:$_SERVER['SCRIPT_NAME']);
	$app_url = strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'))).'://'.$_SERVER['HTTP_HOST'].preg_replace("/\/*install$/i", '', substr($uri, 0, strrpos($uri, '/install')));

	$postdata = "m=app&a=add&ucfounder=&ucfounderpw=".urlencode($_POST['ucfounderpw'])."&apptype=".urlencode('UCHOME')."&appname=".urlencode('¸öÈ˼ÒÔ°')."&appurl=".urlencode($app_url)."&appip=&appcharset=".$_SC['charset'].'&appdbcharset='.$_SC['dbcharset'].'&release='.UC_CLIENT_RELEASE.'&'.$tagtemplates;
	$s = uc_fopen2($ucapi.'/index.php', 500, $postdata, '', 1, $ucip);
	if(empty($s)) {
		show_msg('UCenterÓû§ÖÐÐÄÎÞ·¨Á¬½Ó');
	} elseif($s == '-1') {
		show_msg('UCenter¹ÜÀíÔ±ÕʺÅÃÜÂë²»ÕýÈ·');
	} else {
		$ucs = explode('|', $s);
		if(empty($ucs[0]) || empty($ucs[1])) {
			show_msg('UCenter·µ»ØµÄÊý¾Ý³öÏÖÎÊÌ⣬Çë²Î¿¼:<br />'.shtmlspecialchars($s));
		} else {

			//´¦Àí³É¹¦
			$apphidden = '';
			//ÑéÖ¤ÊÇ·ñ¿ÉÒÔÖ±½ÓÁª½ÓMySQL
			$link = mysql_connect($ucs[2], $ucs[4], $ucs[5], 1);
			$connect = $link && mysql_select_db($ucs[3], $link) ? 'mysql' : '';
			//·µ»Ø
			foreach (array('key', 'appid', 'dbhost', 'dbname', 'dbuser', 'dbpw', 'dbcharset', 'dbtablepre', 'charset') as $key => $value) {
				if($value == 'dbtablepre') {
					$ucs[$key] = '`'.$ucs[3].'`.'.$ucs[$key];
				}
				$apphidden .= "<input type=\"hidden\" name=\"uc[$value]\" value=\"".$ucs[$key]."\" />";
			}
			//ÄÚÖÃ
			$apphidden .= "<input type=\"hidden\" name=\"uc[connect]\" value=\"$connect\" />";
			$apphidden .= "<input type=\"hidden\" name=\"uc[api]\" value=\"$_POST[ucapi]\" />";
			$apphidden .= "<input type=\"hidden\" name=\"uc[ip]\" value=\"$ucip\" />";

			show_header();
			print<<<END
			<form id="theform" method="post" action="$theurl">
			<table>
			<tr><td>UCenter×¢²á³É¹¦£¡µ±Ç°³ÌÐòID±êʶΪ: $ucs[1]</td></tr>
			</table>

			<table class=button>
			<tr><td>$apphidden
			<input type="submit" id="uc2submit" name="uc2submit" value="½øÈëÏÂÒ»²½"></td></tr>
			</table>
			<input type="hidden" name="formhash" value="$formhash">
			</form>
END;
			show_footer();
			exit();
		}
	}

} elseif (submitcheck('uc2submit')) {

	//Ôö¼ÓcongfigÅäÖÃ
	$step = 2;

	//дÈëconfigÎļþ
	$configcontent = sreadfile($configfile);
	$keys = array_keys($_POST['uc']);
	foreach ($keys as $value) {
		$upkey = strtoupper($value);
		$configcontent = preg_replace("/define\('UC_".$upkey."'\s*,\s*'.*?'\)/i", "define('UC_".$upkey."', '".$_POST['uc'][$value]."')", $configcontent);
	}
	if(!$fp = fopen($configfile, 'w')) {
		show_msg("Îļþ $configfile ¶ÁдȨÏÞÉèÖôíÎó£¬ÇëÉèÖÃΪ¿Éдºó£¬ÔÙÖ´Ðа²×°³ÌÐò");
	}
	fwrite($fp, trim($configcontent));
	fclose($fp);

} elseif(!empty($_POST['sqlsubmit'])) {

	$step = 2;

	//ÏÈдÈëconfigÎļþ
	$configcontent = sreadfile($configfile);
	$keys = array_keys($_POST['db']);
	foreach ($keys as $value) {
		$configcontent = preg_replace("/[$]\_SC\[\'".$value."\'\](\s*)\=\s*[\"'].*?[\"']/is", "\$_SC['".$value."']\\1= '".$_POST['db'][$value]."'", $configcontent);
	}
	if(!$fp = fopen($configfile, 'w')) {
		show_msg("Îļþ $configfile ¶ÁдȨÏÞÉèÖôíÎó£¬ÇëÉèÖÃΪ¿Éдºó£¬ÔÙÖ´Ðа²×°³ÌÐò");
	}
	fwrite($fp, trim($configcontent));
	fclose($fp);
	
	if(empty($_POST['db']['tablepre'])) {
		show_msg("ÌîдµÄ±íÃûǰ׺²»ÄÜΪ¿Õ");
	}

	//ÅжÏUCenter HomeÊý¾Ý¿â
	$havedata = false;
	if(!@mysql_connect($_POST['db']['dbhost'], $_POST['db']['dbuser'], $_POST['db']['dbpw'])) {
		show_msg('Êý¾Ý¿âÁ¬½ÓÐÅÏ¢Ìîд´íÎó£¬ÇëÈ·ÈÏ');
	}
	if(mysql_select_db($_POST['db']['dbname'])) {
		if(mysql_query("SELECT COUNT(*) FROM {$_POST['db']['tablepre']}space")) {
			$havedata = true;
		}
	} else {
		if(!mysql_query("CREATE DATABASE `".$_POST['db']['dbname']."`")) {
			show_msg('É趨µÄUCenter HomeÊý¾Ý¿âÎÞȨÏÞ²Ù×÷£¬ÇëÏÈÊÖ¹¤²Ù×÷ºó£¬ÔÙÖ´Ðа²×°³ÌÐò');
		}
	}

	if($havedata) {
		show_msg('ΣÏÕ!Ö¸¶¨µÄUCenter HomeÊý¾Ý¿âÒÑÓÐÊý¾Ý£¬Èç¹û¼ÌÐø½«»áÇå¿ÕÔ­ÓÐÊý¾Ý!', ($step+1));
	} else {
		show_msg('Êý¾Ý¿âÅäÖóɹ¦£¬½øÈëÏÂÒ»²½²Ù×÷', ($step+1), 1);
	}

} elseif (submitcheck('opensubmit')) {

	//¼ì²éÓû§Éí·Ý
	include_once(S_ROOT.'./data/data_config.php');

	$step = 5;

	dbconnect();

	//ͬ²½»ñÈ¡Óû§Ô´
	$_SGLOBAL['timestamp'] = time();

	//UC×¢²áÓû§
	if(!@include_once S_ROOT.'./uc_client/client.php') {
		showmessage('system_error');
	}
	$uid = uc_user_register($_POST['username'], $_POST['password'], 'hide@address.com');
	if($uid == -3) {
		//ÒÑ´æÔÚ£¬µÇ¼
		if(!$passport = getpassport($_POST['username'], $_POST['password'])) {
			show_msg('ÊäÈëµÄÓû§ÃûÃÜÂë²»ÕýÈ·£¬ÇëÈ·ÈÏ');
		}
		$setarr = array(
			'uid' => $passport['uid'],
			'username' => addslashes($passport['username'])
		);
	} elseif($uid > 0) {
		$setarr = array(
			'uid' => $uid,
			'username' => $_POST['username']
		);
	} else {
		show_msg('ÊäÈëµÄÓû§ÃûÎÞ·¨×¢²á£¬ÇëÖØÐÂÈ·ÈÏ');
	}
	$setarr['password'] = md5("$setarr[uid]|$_SGLOBAL[timestamp]");//±¾µØÃÜÂëËæ»úÉú³É

	//¸üб¾µØÓû§¿â
	inserttable('member', $setarr, 0, true);

	//¿ªÍ¨¿Õ¼ä
	include_once(S_ROOT.'./source/function_space.php');
	$space = space_open($setarr['uid'], $_POST['username'], 1);

	//·´À¡Êܱ£»¤
	$result = uc_user_addprotected($_POST['username'], $_POST['username']);
	$_SGLOBAL['db']->query("UPDATE ".tname('space')." SET flag=1 WHERE username='$_POST[username]'");

	//ÇåÀíÔÚÏßsession
	insertsession($setarr);

	//ÉèÖÃcookie
	ssetcookie('auth', authcode("$setarr[password]\t$setarr[uid]", 'ENCODE'), 2592000);

	//дlog
	if(@$fp = fopen($lockfile, 'w')) {
		fwrite($fp, 'UCenter Home');
		fclose($fp);
	}

	show_msg('<font color="red">¹§Ï²! UCenter Home°²×°È«²¿Íê³É!</font>
		<br>ΪÁËÄúµÄÊý¾Ý°²È«£¬ÇëµÇ¼ftp£¬É¾³ýinstallĿ¼<br><br>
		ÄúµÄ¹ÜÀíÔ±Éí·ÝÒѾ­³É¹¦È·ÈÏ£¬²¢ÒѾ­¿ªÍ¨¿Õ¼ä¡£½ÓÏÂÀ´£¬Äú¿ÉÒÔ£º<br>
		<br><a href="../space.php" target="_blank">½øÈëÎҵĿռä</a>
		<br>½øÈëÎÒµÄÖ÷Ò³£¬¿ªÊ¼UCenter HomeÖ®ÂÃ
		<br><a href="../admincp.php" target="_blank">½øÈë¹ÜÀíƽ̨</a>
		<br>ÒÔ¹ÜÀíÔ±Éí·Ý¶ÔÕ¾µã²ÎÊý½øÐÐÉèÖÃ', 999);

}

if(empty($step)) {

	show_header();

	//¼ì²éȨÏÞÉèÖÃ
	$checkok = true;
	$perms = array();
	if(!checkfdperm(S_ROOT.'./config.php', 1)) {
		$perms['config'] = 'ʧ°Ü';
		$checkok = false;
	} else {
		$perms['config'] = 'OK';
	}
	if(!checkfdperm(S_ROOT.'./attachment/')) {
		$perms['attachment'] = 'ʧ°Ü';
		$checkok = false;
	} else {
		$perms['attachment'] = 'OK';
	}
	if(!checkfdperm(S_ROOT.'./data/')) {
		$perms['data'] = 'ʧ°Ü';
		$checkok = false;
	} else {
		$perms['data'] = 'OK';
	}
	if(!checkfdperm(S_ROOT.'./uc_client/data/')) {
		$perms['uc_data'] = 'ʧ°Ü';
		$checkok = false;
	} else {
		$perms['uc_data'] = 'OK';
	}

	//°²×°ÔĶÁ
	print<<<END
	<script type="text/javascript">
	function readme() {
		var tbl_readme = document.getElementById('tbl_readme');
		if(tbl_readme.style.display == '') {
			tbl_readme.style.display = 'none';
		} else {
			tbl_readme.style.display = '';
		}
	}
	</script>
	<table class="showtable">
	<tr><td>
	<strong>»¶Ó­ÄúʹÓÃUCenter Home</strong><br>
	ͨ¹ý UCenter Home£¬×÷Ϊ½¨Õ¾ÕßµÄÄú£¬¿ÉÒÔÇáËɹ¹½¨Ò»¸öÒÔºÃÓѹØϵΪºËÐĵĽ»Á÷ÍøÂ磬ÈÃÕ¾µãÓû§¿ÉÒÔÓÃÒ»¾ä»°¼Ç¼Éú»îÖеĵãµãµÎµÎ£»·½±ã¿ì½ÝµØ·¢²¼ÈÕÖ¾¡¢ÉÏ´«Í¼Æ¬£»¸ü¿ÉÒÔÊ®·Ö·½±ãµÄÓëÆäºÃÓÑÃÇÒ»Æð·ÖÏíÐÅÏ¢¡¢ÌÖÂÛ¸ÐÐËȤµÄ»°Ì⣻ÇáËÉ¿ì½ÝµÄÁ˽âºÃÓÑ×îж¯Ì¬¡£
	<br><a href="javascript:;" onclick="readme()"><strong>ÇëÏÈÈÏÕæÔĶÁÎÒÃǵÄÈí¼þʹÓÃÊÚȨЭÒé</strong></a>
	</td></tr>
	</table>

	<table>
	</td></tr>
	<tr><td>
	<strong>Îļþ/Ŀ¼ȨÏÞÉèÖÃ</strong><br>
	ÔÚÄúÖ´Ðа²×°Îļþ½øÐа²×°Ö®Ç°£¬ÏÈÒªÉèÖÃÏà¹ØµÄĿ¼ÊôÐÔ£¬ÒÔ±ãÊý¾ÝÎļþ¿ÉÒÔ±»³ÌÐòÕýÈ·¶Á/д/ɾ/´´½¨×ÓĿ¼¡£<br>
	ÍƼöÄúÕâÑù×ö£º<br>ʹÓà FTP Èí¼þµÇ¼ÄúµÄ·þÎñÆ÷£¬½«·þÎñÆ÷ÉÏÒÔÏÂĿ¼¡¢ÒÔ¼°¸ÃĿ¼ÏÂÃæµÄËùÓÐÎļþµÄÊôÐÔÉèÖÃΪ777£¬winÖ÷»úÇëÉèÖÃinternetÀ´±öÕÊ»§¿É¶ÁдÊôÐÔ<br>
	<table class="datatable">
	<tr style="font-weight:bold;"><td>Ãû³Æ</td><td>ËùÐèȨÏÞÊôÐÔ</td><td>˵Ã÷</td><td>¼ì²â½á¹û</td></tr>
	<tr><td><strong>./config.php</strong></td><td>¶Á/д</td><td>ϵͳÅäÖÃÎļþ</td><td>$perms[config]</td></tr>
	<tr><td><strong>./attachment/</strong> (°üÀ¨±¾Ä¿Â¼¡¢×ÓĿ¼ºÍÎļþ)</td><td>¶Á/д/ɾ</td><td>¸½¼þĿ¼</td><td>$perms[attachment]</td></tr>
	<tr><td><strong>./data/</strong> (°üÀ¨±¾Ä¿Â¼¡¢×ÓĿ¼ºÍÎļþ)</td><td>¶Á/д/ɾ</td><td>Õ¾µãÊý¾ÝĿ¼</td><td>$perms[data]</td></tr>
	<tr><td><strong>./uc_client/data/</strong> (°üÀ¨±¾Ä¿Â¼¡¢×ÓĿ¼ºÍÎļþ)</td><td>¶Á/д/ɾ</td><td>uc_clientÊý¾ÝĿ¼</td><td>$perms[uc_data]</td></tr>
	</table>
	</td></tr>
	</table>
END;

	if(!$checkok) {
		echo "<table><tr><td><b>³öÏÖÎÊÌâ</b>:<br>ϵͳ¼ì²âµ½ÒÔÉÏĿ¼»òÎļþȨÏÞûÓÐÕýÈ·ÉèÖÃ<br>Ç¿ÁÒ½¨ÒéÕý³£ÉèÖÃȨÏÞºóÔÙˢб¾Ò³ÃæÒÔ±ã¼ÌÐø°²×°<br>·ñÔòϵͳ¿ÉÄÜ»á³öÏÖÎÞ·¨Ô¤ÁϵÄÎÊÌâ [<a href=\"$theurl?step=1\">Ç¿ÖƼÌÐø</a>]</td></tr></table>";
	} else {
		$ucapi = empty($_POST['ucapi'])?'/':$_POST['ucapi'];
		$ucfounderpw = empty($_POST['ucfounderpw'])?'':$_POST['ucfounderpw'];
		print <<<END
		<form id="theform" method="post" action="$theurl?step=1">
			<table class=button>
				<tr>
					<td><input type="submit" id="startsubmit" name="startsubmit" value="½ÓÊÜÊÚȨЭÒ飬¿ªÊ¼°²×°UCenter Home"></td>
				</tr>
			</table>
			<input type="hidden" name="ucapi" value="$ucapi" />
			<input type="hidden" name="ucfounderpw" value="$ucfounderpw" />
			<input type="hidden" name="formhash" value="$formhash">
		</form>
END;
	}

	print<<<END
	<table id="tbl_readme" style="display:none;" class="showtable">
	<tr>
	<td><strong>ÇëÄúÎñ±Ø×ÐϸÔĶÁÏÂÃæµÄÐí¿ÉЭÒé:</strong> </td></tr>
	<tr>
	<td>
	<div>ÖÐÎÄ°æÊÚȨЭÒé ÊÊÓÃÓÚÖÐÎÄÓû§
	<p>°æȨËùÓÐ (C) 2001-2009£¬¿µÊ¢´´Ï루±±¾©£©¿Æ¼¼ÓÐÏÞ¹«Ë¾<br>±£ÁôËùÓÐȨÀû¡£
	</p><p>¸ÐлÄúÑ¡Ôñ UCenter Home¡£Ï£ÍûÎÒÃǵÄŬÁ¦ÄÜΪÄúÌṩһ¸öÇ¿´óµÄÉç»á»¯ÍøÂç(SNS)½â¾ö·½°¸¡£Í¨¹ý UCenter Home£¬½¨Õ¾Õß¿ÉÒÔÇáËɹ¹½¨Ò»¸öÒÔºÃÓѹØϵΪºËÐĵĽ»Á÷ÍøÂ磬ÈÃÕ¾µãÓû§¿ÉÒÔÓÃÒ»¾ä»°¼Ç¼Éú»îÖеĵãµãµÎµÎ£»·½±ã¿ì½ÝµØ·¢²¼ÈÕÖ¾¡¢ÉÏ´«Í¼Æ¬£»¸ü¿ÉÒÔÊ®·Ö·½±ãµÄÓëÆäºÃÓÑÃÇÒ»Æð·ÖÏíÐÅÏ¢¡¢ÌÖÂÛ¸ÐÐËȤµÄ»°Ì⣻ÇáËÉ¿ì½ÝµÄÁ˽âºÃÓÑ×îж¯Ì¬¡£
	</p><p>¿µÊ¢´´Ï루±±¾©£©¿Æ¼¼ÓÐÏÞ¹«Ë¾Îª UCenter Home ²úÆ·µÄ¿ª·¢ÉÌ£¬ÒÀ·¨¶ÀÁ¢ÓµÓÐ UCenter Home ²úÆ·Öø×÷Ȩ£¨Öйú¹ú¼Ò°æȨ¾Ö Öø×÷ȨµÇ¼ÇºÅ 2006SR12091£©¡£¿µÊ¢´´Ï루±±¾©£©¿Æ¼¼ÓÐÏÞ¹«Ë¾ÍøַΪ
	http://www.comsenz.com£¬UCenter Home ¹Ù·½ÍøÕ¾ÍøַΪ http://u.discuz.net¡£
	</p><p>UCenter Home Öø×÷ȨÒÑÔÚÖлªÈËÃñ¹²ºÍ¹ú¹ú¼Ò°æȨ¾Ö×¢²á£¬Öø×÷ȨÊܵ½·¨Âɺ͹ú¼Ê¹«Ô¼±£»¤¡£Ê¹ÓÃÕߣºÎÞÂÛ¸öÈË»ò×éÖ¯¡¢Ó¯ÀûÓë·ñ¡¢ÓÃ;ÈçºÎ
	£¨°üÀ¨ÒÔѧϰºÍÑо¿ÎªÄ¿µÄ£©£¬¾ùÐè×ÐϸÔĶÁ±¾Ð­Ò飬ÔÚÀí½â¡¢Í¬Òâ¡¢²¢×ñÊر¾Ð­ÒéµÄÈ«²¿Ìõ¿îºó£¬·½¿É¿ªÊ¼Ê¹Óà UCenter Home Èí¼þ¡£
	</p><p>¿µÊ¢´´Ï루±±¾©£©¿Æ¼¼ÓÐÏÞ¹«Ë¾ÓµÓжԱ¾ÊÚȨЭÒéµÄ×îÖÕ½âÊÍȨ¡£
	<ul type=i>
	<p>
	<li><b>ЭÒéÐí¿ÉµÄȨÀû</b>
	<ul type=1>
	<li>Äú¿ÉÒÔÔÚÍêÈ«×ñÊر¾×îÖÕÓû§ÊÚȨЭÒéµÄ»ù´¡ÉÏ£¬½«±¾Èí¼þÓ¦ÓÃÓÚ·ÇÉÌÒµÓÃ;£¬¶ø²»±ØÖ§¸¶Èí¼þ°æȨÊÚȨ·ÑÓá£
	<li>Äú¿ÉÒÔÔÚЭÒé¹æ¶¨µÄÔ¼ÊøºÍÏÞÖÆ·¶Î§ÄÚÐÞ¸Ä UCenter Home Ô´´úÂë(Èç¹û±»ÌṩµÄ»°)»ò½çÃæ·ç¸ñÒÔÊÊÓ¦ÄúµÄÍøÕ¾ÒªÇó¡£
	<li>ÄúÓµÓÐʹÓñ¾Èí¼þ¹¹½¨µÄÕ¾µãÖÐÈ«²¿»áÔ±×ÊÁÏ¡¢ÎÄÕ¼°Ïà¹ØÐÅÏ¢µÄËùÓÐȨ£¬²¢¶ÀÁ¢³Ðµ£ÓëÎÄÕÂÄÚÈݵÄÏà¹Ø·¨ÂÉÒåÎñ¡£
	<li>»ñµÃÉÌÒµÊÚȨ֮ºó£¬Äú¿ÉÒÔ½«±¾Èí¼þÓ¦ÓÃÓÚÉÌÒµÓÃ;£¬Í¬Ê±ÒÀ¾ÝËù¹ºÂòµÄÊÚȨÀàÐÍÖÐÈ·¶¨µÄ¼¼ÊõÖ§³ÖÆÚÏÞ¡¢¼¼ÊõÖ§³Ö·½Ê½ºÍ¼¼ÊõÖ§³ÖÄÚÈÝ£¬
	×Ô¹ºÂòʱ¿ÌÆð£¬ÔÚ¼¼ÊõÖ§³ÖÆÚÏÞÄÚÓµÓÐͨ¹ýÖ¸¶¨µÄ·½Ê½»ñµÃÖ¸¶¨·¶Î§Äڵļ¼ÊõÖ§³Ö·þÎñ¡£ÉÌÒµÊÚȨÓû§ÏíÓз´Ó³ºÍÌá³öÒâ¼ûµÄȨÁ¦£¬Ïà¹ØÒâ¼û
	½«±»×÷ΪÊ×Òª¿¼ÂÇ£¬µ«Ã»ÓÐÒ»¶¨±»²ÉÄɵijÐŵ»ò±£Ö¤¡£ </li></ul>
	<p></p>
	<li><b>ЭÒé¹æ¶¨µÄÔ¼ÊøºÍÏÞÖÆ</b>
	<ul type=1>
	<li>δ»ñÉÌÒµÊÚȨ֮ǰ£¬²»µÃ½«±¾Èí¼þÓÃÓÚÉÌÒµÓÃ;£¨°üÀ¨µ«²»ÏÞÓÚÆóÒµÍøÕ¾¡¢¾­ÓªÐÔÍøÕ¾¡¢ÒÔÓªÀûΪĿ»òʵÏÖÓ¯ÀûµÄÍøÕ¾£©¡£¹ºÂòÉÌÒµÊÚȨÇëµÇ½http://www.discuz.com²Î¿¼Ïà¹Ø˵Ã÷£¬Ò²¿ÉÒÔÖµç8610-51657885Á˽âÏêÇé¡£
	<li>²»µÃ¶Ô±¾Èí¼þ»òÓëÖ®¹ØÁªµÄÉÌÒµÊÚȨ½øÐгö×â¡¢³öÊÛ¡¢µÖѺ»ò·¢·Å×ÓÐí¿ÉÖ¤¡£
	<li>ÎÞÂÛÈçºÎ£¬¼´ÎÞÂÛÓÃ;ÈçºÎ¡¢ÊÇ·ñ¾­¹ýÐ޸ĻòÃÀ»¯¡¢Ð޸ij̶ÈÈçºÎ£¬Ö»ÒªÊ¹Óà UCenter Home µÄÕûÌå»òÈκβ¿·Ö£¬Î´¾­ÊéÃæÐí¿É£¬³ÌÐòÒ³ÃæÒ³½Å´¦
	µÄ UCenter Home Ãû³ÆºÍ¿µÊ¢´´Ï루±±¾©£©¿Æ¼¼ÓÐÏÞ¹«Ë¾ÏÂÊôÍøÕ¾£¨http://www.comsenz.com¡¢http://u.discuz.net£© µÄ Á´½Ó¶¼±ØÐë±£Áô£¬¶ø²»ÄÜÇå³ý»òÐ޸ġ£
	<li>½ûÖ¹ÔÚ UCenter Home µÄÕûÌå»òÈκβ¿·Ö»ù´¡ÉÏÒÔ·¢Õ¹ÈκÎÅÉÉú°æ±¾¡¢Ð޸İ汾»òµÚÈý·½°æ±¾ÓÃÓÚÖØзַ¢¡£
	<li>Èç¹ûÄúδÄÜ×ñÊر¾Ð­ÒéµÄÌõ¿î£¬ÄúµÄÊÚȨ½«±»ÖÕÖ¹£¬Ëù±»Ðí¿ÉµÄȨÀû½«±»Êջأ¬²¢³Ðµ£ÏàÓ¦·¨ÂÉÔðÈΡ£ </li></ul>
	<p></p>
	<li><b>ÓÐÏÞµ£±£ºÍÃâÔðÉùÃ÷</b>
	<ul type=1>
	<li>±¾Èí¼þ¼°Ëù¸½´øµÄÎļþÊÇ×÷Ϊ²»ÌṩÈκÎÃ÷È·µÄ»òÒþº¬µÄÅâ³¥»òµ£±£µÄÐÎʽÌṩµÄ¡£
	<li>Óû§³öÓÚ×ÔÔ¸¶øʹÓñ¾Èí¼þ£¬Äú±ØÐëÁ˽âʹÓñ¾Èí¼þµÄ·çÏÕ£¬ÔÚÉÐδ¹ºÂò²úÆ·¼¼Êõ·þÎñ֮ǰ£¬ÎÒÃDz»³ÐŵÌṩÈκÎÐÎʽµÄ¼¼ÊõÖ§³Ö¡¢Ê¹Óõ£±££¬
	Ò²²»³Ðµ£ÈκÎÒòʹÓñ¾Èí¼þ¶ø²úÉúÎÊÌâµÄÏà¹ØÔðÈΡ£
	<li>¿µÊ¢´´Ï루±±¾©£©¿Æ¼¼ÓÐÏÞ¹«Ë¾²»¶ÔʹÓñ¾Èí¼þ¹¹½¨µÄÕ¾µãÖеÄÎÄÕ»òÐÅÏ¢³Ðµ£ÔðÈΡ£ </li></ul></li></ul>
	<p>ÓÐ¹Ø UCenter Home ×îÖÕÓû§ÊÚȨЭÒé¡¢ÉÌÒµÊÚȨÓë¼¼Êõ·þÎñµÄÏêϸÄÚÈÝ£¬¾ùÓÉ UCenter Home ¹Ù·½ÍøÕ¾¶À¼ÒÌṩ¡£¿µÊ¢´´Ï루±±¾©£©¿Æ¼¼ÓÐÏÞ¹«Ë¾ÓµÓÐÔÚ²» ÊÂÏÈ֪ͨµÄÇé¿öÏ£¬ÐÞ¸ÄÊÚȨЭÒéºÍ·þÎñ¼ÛÄ¿±íµÄȨÁ¦£¬Ð޸ĺóµÄЭÒé»ò¼ÛÄ¿±í¶Ô×ԸıäÖ®ÈÕÆðµÄÐÂÊÚȨÓû§ÉúЧ¡£
	<p>µç×ÓÎı¾ÐÎʽµÄÊÚȨЭÒéÈçͬ˫·½ÊéÃæÇ©ÊðµÄЭÒéÒ»Ñù£¬¾ßÓÐÍêÈ«µÄºÍµÈͬµÄ·¨ÂÉЧÁ¦¡£ÄúÒ»µ©¿ªÊ¼°²×° UCenter Home£¬¼´±»ÊÓΪÍêÈ«Àí½â²¢½ÓÊܱ¾Ð­ÒéµÄ¸÷ÏîÌõ¿î£¬ÔÚÏíÓÐÉÏÊöÌõ¿îÊÚÓèµÄȨÁ¦µÄͬʱ£¬Êܵ½Ïà¹ØµÄÔ¼ÊøºÍÏÞÖÆ¡£Ð­ÒéÐí¿É·¶Î§ÒÔÍâµÄÐÐΪ£¬½«Ö±½ÓÎ¥·´±¾ÊÚȨЭÒé²¢¹¹³ÉÇÖȨ£¬ÎÒÃÇÓÐȨËæʱÖÕÖ¹ÊÚȨ£¬ÔðÁîÍ£Ö¹Ë𺦣¬²¢±£Áô×·¾¿Ïà¹ØÔðÈεÄȨÁ¦¡£ </p></div>
	</td></tr>
	</table>
END;

	show_footer();

} elseif($step == 1) {

	show_header();
	$ucapi = "http://";
	$ucfounderpw = '';
	$showdiv = 0;
	if($_POST['ucfounderpw']) {
		$showdiv = 1;
		$ucapi = trim($_POST['ucapi']);
		$ucfounderpw = trim($_POST['ucfounderpw']);
	}

	if($showdiv) {
		print<<<END
		<form id="theform" method="post" action="$theurl">
		<div>
			<table class="showtable">
				<tr><td><strong># UCenter ²ÎÊý×Ô¶¯»ñÈ¡</strong></td></tr>
				<tr><td id="msg2">UCenterµÄÏà¹ØÐÅÏ¢Òѳɹ¦»ñÈ¡£¬ÇëÖ±½Óµã»÷ÏÂÃæµÄ°´Å¥Ìá½»ÅäÖÃ</td></tr>
			</table>
			<br/>
		</div>
		<div>
END;
	} else {
		$plus = '';
		if(!$ucfounderpw) {
			$plus = '<tr><td id="msg2">
					ʹÓÃUCenter Home£¬Ê×ÏÈÐèÒªÄúµÄÕ¾µã°²×°ÓÐͳһ´æ´¢Óû§ÕʺÅÐÅÏ¢µÄUCenterÓû§ÖÐÐÄϵͳ¡£<br>
					Èç¹ûÄúµÄÕ¾µã»¹Ã»Óа²×°¹ýUCenter£¬ÇëÕâÑù²Ù×÷£º<br>
					1. <a href="http://download.comsenz.com/UCenter/" target="_blank"><b>Çëµã»÷ÕâÀïÏÂÔØ×îа汾µÄUCenter</b></a>£¬²¢ÔĶÁ³ÌÐò°üÖеÄ˵Ã÷½øÐÐUCenterµÄ°²×°¡£<br>
					2. °²×°Íê±Ï UCenter ºó£¬ÔÚÏÂÃæÌîÈëUCenterµÄÏà¹ØÐÅÏ¢¼´¿É¼ÌÐø½øÐÐUCenter Home µÄ°²×°¡£<br>
				</td></tr>';
		}
		print<<<END
		<form id="theform" method="post" action="$theurl">
		<div>
			<table class="showtable">
				<tr><td><strong># ÇëÌîд UCenter µÄÏà¹Ø²ÎÊý</strong></td></tr>
				$plus
			</table>
			<br>
			<p style="font-weight:bold;">ÇëÊäÈëÒÑ°²×°UCenterµÄÐÅÏ¢:</p>
END;
	}
	print<<<END
		<table class=datatable>
			<tbody>
				<tr>
					<td>UCenter µÄ URL:</td>
					<td><input type="text" id="ucapi" name="ucapi" size="60" value="$ucapi"><br>ÀýÈ磺http://www.discuz.net/ucenter</td>
				</tr>
				<tr>
					<td>UCenter µÄ´´Ê¼ÈËÃÜÂë:</td>
					<td><input type="password" id="ucfounderpw" name="ucfounderpw" size="20" value="$ucfounderpw"></td>
				</tr>
			</tbody>
		</table>
		<br>
	</div>
	<table class=button>
	<tr><td><input type="submit" id="ucsubmit" name="ucsubmit" value="Ìá½»UCenterÅäÖÃÐÅÏ¢"></td></tr>
	</table>
	<input type="hidden" id="ucfounder" name="ucfounder" size="20" value="">
	<input type="hidden" name="formhash" value="$formhash">
	</form>
END;
	show_footer();

} elseif ($step == 2) {

	//¼ì²âĿ¼ÊôÐÔ
	show_header();
	//ÉèÖÃÊý¾Ý¿âÅäÖÃ
	print<<<END
	<form id="theform" method="post" action="$theurl">

	<table class="showtable">
	<tr><td><strong># ÉèÖÃUCenter HomeÊý¾Ý¿âÐÅÏ¢</strong></td></tr>
	<tr><td id="msg1">ÕâÀïÉèÖÃUCenter HomeµÄÊý¾Ý¿âÐÅÏ¢</td></tr>
	</table>
	<table class=datatable>
	<tr>
	<td width="25%">Êý¾Ý¿â·þÎñÆ÷±¾µØµØÖ·:</td>
	<td><input type="text" name="db[dbhost]" size="20" value="localhost"></td>
	<td width="30%">Ò»°ãΪlocalhost</td>
	</tr>
	<tr>
	<td>Êý¾Ý¿âÓû§Ãû:</td>
	<td><input type="text" name="db[dbuser]" size="20" value=""></td>
	<td>&nbsp;</td>
	</tr>
	<tr>
	<td>Êý¾Ý¿âÃÜÂë:</td>
	<td><input type="password" name="db[dbpw]" size="20" value=""></td>
	<td>&nbsp;</td>
	</tr>
	<tr>
	<td>Êý¾Ý¿â×Ö·û¼¯:</td>
	<td>
	<select name="db[dbcharset]" onchange="addoption(this)">
	<option value="$_SC[dbcharset]">$_SC[dbcharset]</option>
	<option value="addoption" class="addoption">+×Ô¶¨Òå</option>
	</select>
	</td>
	<td>MySQL°æ±¾>4.1ÓÐЧ</td>
	</tr>
	<tr>
	<td>Êý¾Ý¿âÃû:</td>
	<td><input type="text" name="db[dbname]" size="20" value=""></td>
	<td>Èç¹û²»´æÔÚ£¬Ôò»á³¢ÊÔ×Ô¶¯´´½¨</td>
	</tr>
	<tr>
	<td>±íÃûǰ׺:</td>
	<td><input type="text" name="db[tablepre]" size="20" value="uchome_"></td>
	<td>²»ÄÜΪ¿Õ£¬Ä¬ÈÏΪuchome_</td>
	</tr>
	</table>

	<table class=button>
	<tr><td><input type="submit" id="sqlsubmit" name="sqlsubmit" value="ÉèÖÃÍê±Ï,¼ì²âÎÒµÄÊý¾Ý¿âÅäÖÃ"></td></tr>
	</table>
	<input type="hidden" name="formhash" value="$formhash">
	</form>
END;
	show_footer();

} elseif ($step == 3) {

	//Á´½ÓÊý¾Ý¿â
	dbconnect();

	//°²×°Êý¾Ý¿â
	//»ñÈ¡×îеÄsqlÎÄ
	$newsql = sreadfile($sqlfile);

	if($_SC['tablepre'] != 'uchome_') $newsql = str_replace('uchome_', $_SC['tablepre'], $newsql);//Ìæ»»±íÃûǰ׺

	//»ñÈ¡Òª´´½¨µÄ±í
	$tables = $sqls = array();
	if($newsql) {
		preg_match_all("/(CREATE TABLE ([a-z0-9\_\-`]+).+?\s*)(TYPE|ENGINE)+\=/is", $newsql, $mathes);
		$sqls = $mathes[1];
		$tables = $mathes[2];
	}
	if(empty($tables)) {
		show_msg("°²×°SQLÓï¾ä»ñȡʧ°Ü£¬ÇëÈ·ÈÏSQLÎļþ $sqlfile ÊÇ·ñ´æÔÚ");
	}

	$heaptype = $_SGLOBAL['db']->version()>'4.1'?" ENGINE=MEMORY".(empty($_SC['dbcharset'])?'':" DEFAULT CHARSET=$_SC[dbcharset]" ):" TYPE=HEAP";
	$myisamtype = $_SGLOBAL['db']->version()>'4.1'?" ENGINE=MYISAM".(empty($_SC['dbcharset'])?'':" DEFAULT CHARSET=$_SC[dbcharset]" ):" TYPE=MYISAM";
	$installok = true;
	foreach ($tables as $key => $tablename) {
		if(strpos($tablename, 'session')) {
			$sqltype = $heaptype;
		} else {
			$sqltype = $myisamtype;
		}
		$_SGLOBAL['db']->query("DROP TABLE IF EXISTS `$tablename`");
		if(!$query = $_SGLOBAL['db']->query($sqls[$key].$sqltype, 'SILENT')) {
			$installok = false;
			break;
		}
	}
	if(!$installok) {
		show_msg("<font color=\"blue\">Êý¾Ý±í ($tablename) ×Ô¶¯°²×°Ê§°Ü</font><br />·´À¡: ".mysql_error()."<br /><br />Çë²ÎÕÕ $sqlfile ÎļþÖеÄSQLÎÄ£¬×Ô¼ºÊÖ¹¤°²×°Êý¾Ý¿âºó£¬ÔÙ¼ÌÐø½øÐа²×°²Ù×÷<br /><br /><a href=\"?step=$step\">ÖØÊÔ</a>");
	} else {
		show_msg('Êý¾Ý±íÒѾ­È«²¿°²×°Íê³É£¬½øÈëÏÂÒ»²½²Ù×÷', ($step+1), 1);
	}

} elseif ($step == 4) {

	//²åÈëĬÈÏÊý¾Ý
	dbconnect();
	$privacy = array(
		'view' => array(
			'index' => 0,
			'profile' => 0,
			'friend' => 0,
			'wall' => 0,
			'feed' => 0,
			'mtag' => 0,
			'event' => 0,
			'doing' => 0,
			'blog' => 0,
			'album' => 0,
			'share' => 0,
			'poll' => 0
		),
		'feed' => array(
			'doing' => 1,
			'blog' => 1,
			'upload' => 1,
			'share' => 1,
			'poll' => 1,
			'joinpoll' => 1,
			'thread' => 1,
			'post' => 1,
			'mtag' => 1,
			'event' => 1,
			'join' => 1,
			'friend' => 1,
			'comment' => 1,
			'show' => 1,
			'spaceopen' => 1,
			'credit' => 1,
			'invite' => 1,
			'task' => 1,
			'profile' => 1,
			'album' => 1,
			'click' => 1
		)
	);
	//config
	$datas = array(
		"('sitename', 'ÎҵĿռä')",
		"('template', 'default')",
		"('adminemail', 'webmaster@".$_SERVER['HTTP_HOST']."')",
		"('onlinehold', '1800')",
		"('timeoffset', '8')",
		"('maxpage', '100')",
		"('starcredit', '100')",
		"('starlevelnum', '5')",
		"('cachemode', 'database')",
		"('cachegrade', '0')",
		"('allowcache', '1')",
		"('allowdomain', '0')",
		"('allowrewrite', '0')",
		"('allowwatermark', '0')",
		"('allowftp', '0')",
		"('holddomain', 'www|*blog*|*space*|x')",
		"('mtagminnum', '5')",
		"('feedday', '7')",
		"('feedmaxnum', '100')",
		"('feedfilternum', '10')",
		"('importnum', '100')",
		"('maxreward', '10')",
		"('singlesent', '50')",
		"('groupnum', '8')",
		"('closeregister', '0')",
		"('closeinvite', '0')",
		"('close', '0')",
		"('networkpublic', '1')",
		"('networkpage', '1')",
		"('seccode_register', '1')",
		"('uc_tagrelated', '1')",
		"('manualmoderator', '1')",
		"('linkguide', '1')",
		"('showall', '1')",
		"('sendmailday', '0')",
		"('realname', '0')",
		"('namecheck', '0')",
		"('namechange', '0')",
		"('name_allowviewspace', '1')",
		"('name_allowfriend', '1')",
		"('name_allowpoke', '1')",
		"('name_allowdoing', '1')",
		"('name_allowblog', '0')",
		"('name_allowalbum', '0')",
		"('name_allowthread', '0')",
		"('name_allowshare', '0')",
		"('name_allowcomment', '0')",
		"('name_allowpost', '0')",
		"('showallfriendnum', '10')",
		"('feedtargetblank', '1')",
		"('feedread', '1')",
		"('feedhotnum', '3')",
		"('feedhotday', '2')",
		"('feedhotmin', '3')",
		"('feedhiddenicon', 'friend,profile,task,wall')",
		"('uc_tagrelatedtime', '86400')",
		"('privacy', '".serialize($privacy)."')",
		"('cronnextrun', '$_SGLOBAL[timestamp]')",
		"('my_status', '0')",
		"('maxreward', '10')",
		"('uniqueemail', '1')",
		"('updatestat', '1')",
		"('my_showgift', '1')",
		"('topcachetime', '60')",
		"('newspacenum', '3')"
	);
	$_SGLOBAL['db']->query("TRUNCATE TABLE ".tname('config'));
	$_SGLOBAL['db']->query("REPLACE INTO ".tname('config')." (var, datavalue) VALUES ".implode(',', $datas));

	//profield
	$datas = array(
		"('×ÔÓÉÁªÃË', 'text', '100', '0', '1')",
		"('µØÇøÁªÃË', 'text', '100', '0', '1')",
		"('ÐËȤÁªÃË', 'text', '100', '0', '1')"
	);
	$_SGLOBAL['db']->query("TRUNCATE TABLE ".tname('profield'));
	$_SGLOBAL['db']->query("REPLACE INTO ".tname('profield')." (title,formtype,inputnum,manualmoderator,manualmember) VALUES ".implode(',', $datas));

	//Óû§×é
	$datas = array();
	$datas['grouptitle'] = array('Õ¾µã¹ÜÀíÔ±', 'ÐÅÏ¢¹ÜÀíÔ±', '¹ó±öVIP', 'ÊÜÏÞ»áÔ±', 'ÆÕͨ»áÔ±', 'Ö춻áÔ±', '¸ß¼¶»áÔ±', '½ûÖ¹·¢ÑÔ', '½ûÖ¹·ÃÎÊ');

	//ºËÐÄÉèÖÃ
	$datas['gid'] = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
	$datas['system'] = array(-1, -1, 1, 0, 0, 0, 0, -1, -1);
	$datas['explower'] = array(0, 0, 0, -999999999, 0, 100, 1000, 0, 0);
	$datas['banvisit'] = array(0, 0, 0, 0, 0, 0, 0, 0, 1);
	$datas['searchignore'] = array(1, 1, 1, 0, 0, 0, 1, 0, 0);
	$datas['videophotoignore'] = array(1, 1, 0, 0, 0, 0, 0, 0, 0);
	$datas['spamignore'] = array(1, 1, 1, 0, 0, 0, 0, 0, 0);

	$datas['color'] = array('red', 'blue', 'green', '', '', '', '', '', '');
	$datas['icon'] = array('image/group/admin.gif', 'image/group/infor.gif', 'image/group/vip.gif', '', '', '', '', '', '');

	//»ù±¾ÉèÖÃ
	$datas['maxfriendnum'] = array(0, 0, 0, 10, 100, 200, 300, 1, 1);
	$datas['maxattachsize'] = array(0, 0, 0, 10, 20, 50, 100, 1, 1);
	$datas['postinterval'] = array(0, 0, 0, 300, 60, 30, 10, 9999, 9999);
	$datas['searchinterval'] = array(0, 0, 0, 600, 60, 30, 10, 9999, 9999);
	
	$datas['verifyevent'] = array(0, 0, 0, 1, 0, 0, 0, 1, 1);

	$datas['domainlength'] = array(1, 3, 3, 0, 0, 5, 3, 99, 99);
	$datas['closeignore'] = array(1, 1, 0, 0, 0, 0, 0, 0, 0);
	$datas['seccode'] = array(0, 0, 0, 1, 0, 0, 0, 1, 1);

	$datas['allowhtml'] = array(1, 1, 1, 0, 0, 0, 1, 0, 0);
	$datas['allowcss'] = array(1, 1, 1, 0, 0, 0, 1, 0, 0);
	$datas['allowviewvideopic'] = array(1, 1, 1, 0, 0, 0, 0, 0, 0);
	
	$datas['allowtopic'] = array(1, 1, 0, 0, 0, 0, 0, 0, 0);
	$datas['allowstat'] = array(1, 1, 0, 0, 0, 0, 0, 0, 0);
	
	foreach (array('comment','blog','poll','doing','upload','share','mtag','thread','post','poke','friend','click','event','magic', 'pm', 'myop') as $value) {
		$datas['allow'.$value] = array(1, 1, 1, 0, 1, 1, 1, 0, 0);
	}

	//¹ÜÀíȨÏÞ
	//Õ¾µãÉèÖÃ
	foreach (array('config','usergroup','credit','profilefield','profield','censor','ad','cache','block','template','backup','stat','cron','app', 'network','name','task','report', 'eventclass', 'magic','magiclog','topic', 'batch', 'delspace', 'spacegroup', 'spaceinfo', 'spacecredit', 'spacenote', 'ip', 'hotuser', 'defaultuser', 'click', 'videophoto', 'log') as $value) {
		$datas['manage'.$value] = array(1, 0, 0, 0, 0, 0, 0, 0, 0);
	}

	//ÐÅÏ¢¹ÜÀí
	foreach (array('tag','mtag','feed','share','doing', 'blog','album','comment','thread', 'event', 'poll') as $value) {
		$datas['manage'.$value] = array(1, 1, 0, 0, 0, 0, 0, 0, 0);
	}

	$keys = array_keys($datas);
	$newdatas = array();
	$g_count = count($datas['grouptitle']);
	for ($i=0; $i<$g_count; $i++) {
		$thes = array();
		foreach ($keys as $value) {
			$thes[] = $datas[$value][$i];
		}
		$newdatas[$i] = "(".simplode($thes).")";
	}
	$_SGLOBAL['db']->query("TRUNCATE TABLE ".tname('usergroup'));
	$_SGLOBAL['db']->query("REPLACE INTO ".tname('usergroup')." (".implode(',', $keys).") VALUES ".implode(',', $newdatas));

	//»ý·Ö¹æÔò
	$ruls = array();
	//¼Ó»ý·Ö
	$ruls[] = "('¿ªÍ¨¿Õ¼ä', 'register', '0', '0', '1', '1', '10', '0', '0')";
	$ruls[] = "('ʵÃûÈÏÖ¤', 'realname', '0', '0', '1', '1', '20', '0', '20')";
	$ruls[] = "('ÓÊÏäÈÏÖ¤', 'realemail', '0', '0', '1', '1', '40', '0', '40')";
	$ruls[] = "('³É¹¦ÑûÇëºÃÓÑ', 'invitefriend', '4', '0', '20', '1', '10', '0', '10')";
	$ruls[] = "('ÉèÖÃÍ·Ïñ', 'setavatar', '0', '0', '1', '1', '15', '0', '15')";
	$ruls[] = "('ÊÓƵÈÏÖ¤', 'videophoto', '0', '0', '1', '1', '40', '0', '40')";
	$ruls[] = "('³É¹¦¾Ù±¨', 'report', '4', '0', '0', '1', '2', '0', '2')";
	$ruls[] = "('¸üÐÂÐÄÇé', 'updatemood', '1', '0', '3', '1', '3', '0', '3')";
	$ruls[] = "('ÈȵãÐÅÏ¢', 'hotinfo', '4', '0', '0', '1', '10', '0', '10')";
	$ruls[] = "('ÿÌìµÇ½', 'daylogin', '1', '0', '1', '1', '15', '0', '15')";
	$ruls[] = "('·ÃÎʱðÈË¿Õ¼ä', 'visit', '1', '0', '10', '1', '1', '2', '1')";
	$ruls[] = "('´òÕкô', 'poke', '1', '0', '10', '1', '1', '2', '1')";
	$ruls[] = "('ÁôÑÔ', 'guestbook', '1', '0', '20', '1', '2', '2', '2')";
	$ruls[] = "('±»ÁôÑÔ', 'getguestbook', '1', '0', '5', '1', '1', '2', '0')";
	$ruls[] = "('·¢±í¼Ç¼', 'doing', '1', '0', '5', '1', '1', '0', '1')";
	$ruls[] = "('·¢±íÈÕÖ¾', 'publishblog', '1', '0', '3', '1', '5', '0', '5')";
	$ruls[] = "('ÉÏ´«Í¼Æ¬', 'uploadimage', '1', '0', '10', '1', '2', '0', '2')";
	$ruls[] = "('ÅÄ´óÍ·Ìù', 'camera', '1', '0', '5', '1', '3', '0', '3')";
	$ruls[] = "('·¢±í»°Ìâ', 'publishthread', '1', '0', '5', '1', '5', '0', '5')";
	$ruls[] = "('»Ø¸´»°Ìâ', 'replythread', '1', '0', '10', '1', '1', '1', '1')";
	$ruls[] = "('´´½¨Í¶Æ±', 'createpoll', '1', '0', '5', '1', '2', '0', '2')";
	$ruls[] = "('²ÎÓëͶƱ', 'joinpoll', '1', '0', '10', '1', '1', '1', '1')";
	$ruls[] = "('·¢Æð»î¶¯', 'createevent', '1', '0', '1', '1', '3', '0', '3')";
	$ruls[] = "('²ÎÓë»î¶¯', 'joinevent', '1', '0', '1', '1', '1', '1', '1')";
	$ruls[] = "('ÍƼö»î¶¯', 'recommendevent', '4', '0', '0', '1', '10', '0', '10')";
	$ruls[] = "('·¢Æð·ÖÏí', 'createshare', '1', '0', '3', '1', '2', '0', '2')";
	$ruls[] = "('ÆÀÂÛ', 'comment', '1', '0', '40', '1', '1', '1', '1')";
	$ruls[] = "('±»ÆÀÂÛ', 'getcomment', '1', '0', '20', '1', '1', '1', '0')";
	$ruls[] = "('°²×°Ó¦ÓÃ', 'installapp', '4', '0', '0', '1', '5', '3', '5')";
	$ruls[] = "('ʹÓÃÓ¦ÓÃ', 'useapp', '1', '0', '10', '1', '1', '3', '1')";
	$ruls[] = "('ÐÅÏ¢±í̬', 'click', '1', '0', '10', '1', '1', '1', '1')";
	//¿Û»ý·Ö
	$ruls[] = "('ÐÞ¸ÄʵÃû', 'editrealname', '0', '0', '1', '0', '5', '0', '0')";
	$ruls[] = "('¸ü¸ÄÓÊÏäÈÏÖ¤', 'editrealemail', '0', '0', '1', '0', '5', '0', '0')";
	$ruls[] = "('Í·Ïñ±»É¾³ý', 'delavatar', '0', '0', '1', '0', '10', '0', '10')";
	$ruls[] = "('»ñÈ¡ÑûÇëÂë', 'invitecode', '0', '0', '1', '0', '0', '0', '0')";
	$ruls[] = "('ËÑË÷Ò»´Î', 'search', '0', '0', '1', '0', '1', '0', '0')";
	$ruls[] = "('ÈÕÖ¾µ¼Èë', 'blogimport', '0', '0', '1', '0', '10', '0', '0')";
	$ruls[] = "('ÐÞ¸ÄÓòÃû', 'modifydomain', '0', '0', '1', '0', '5', '0', '0')";
	$ruls[] = "('ÈÕÖ¾±»É¾³ý', 'delblog', '0', '0', '1', '0', '10', '0', '10')";
	$ruls[] = "('¼Ç¼±»É¾³ý', 'deldoing', '0', '0', '1', '0', '2', '0', '2')";
	$ruls[] = "('ͼƬ±»É¾³ý', 'delimage', '0', '0', '1', '0', '4', '0', '4')";
	$ruls[] = "('ͶƱ±»É¾³ý', 'delpoll', '0', '0', '1', '0', '4', '0', '4')";
	$ruls[] = "('»°Ìⱻɾ³ý', 'delthread', '0', '0', '1', '0', '4', '0', '4')";
	$ruls[] = "('»î¶¯±»É¾³ý', 'delevent', '0', '0', '1', '0', '6', '0', '6')";
	$ruls[] = "('·ÖÏí±»É¾³ý', 'delshare', '0', '0', '1', '0', '4', '0', '4')";
	$ruls[] = "('ÁôÑÔ±»É¾³ý', 'delguestbook', '0', '0', '1', '0', '4', '0', '4')";
	$ruls[] = "('ÆÀÂÛ±»É¾³ý', 'delcomment', '0', '0', '1', '0', '2', '0', '2')";
	
	$_SGLOBAL['db']->query("INSERT INTO ".tname('creditrule')." (`rulename`, `action`, `cycletype`, `cycletime`, `rewardnum`, `rewardtype`, `credit`, `norepeat`, `experience`) VALUES ".implode(',', $ruls));
			
	$_SGLOBAL['db']->query("TRUNCATE TABLE ".tname('data'));
	//ÓʼþÉèÖÃ
	$mails = array(
		'mailsend' => 1,
		'maildelimiter' => 0,
		'mailusername' => 1
	);
	data_set('mail', $mails);

	//ËõÂÔͼÉèÖÃ
	$settings = array(
		'thumbwidth' => 100,
		'thumbheight' => 100,
		'watermarkpos' => 4,
		'watermarktrans' => 75
	);
	data_set('setting', $settings);
	
	//Ëæ±ã¿´¿´
	$network = array(
		'blog' => array('hot1'=>3, 'cache'=>600),
		'pic' => array('hot1'=>3, 'cache'=>700),
		'thread' => array('hot1'=>3, 'cache'=>800),
		'event' => array('cache'=>900),
		'poll' => array('cache'=>500),
	);
	data_set('network', $network);

	//¼Æ»®ÈÎÎñ
	$datas = array(
		"1, 'system', '¸üÐÂä¯ÀÀÊýͳ¼Æ', 'log.php', $_SGLOBAL[timestamp], $_SGLOBAL[timestamp], -1, -1, -1, '0	5	10	15	20	25	30	35	40	45	50	55'",
		"1, 'system', 'ÇåÀí¹ýÆÚfeed', 'cleanfeed.php', $_SGLOBAL[timestamp], $_SGLOBAL[timestamp], -1, -1, 3, '4'",
		"1, 'system', 'ÇåÀí¸öÈË֪ͨ', 'cleannotification.php', $_SGLOBAL[timestamp], $_SGLOBAL[timestamp], -1, -1, 5, '6'",
		"1, 'system', 'ͬ²½UCµÄfeed', 'getfeed.php', $_SGLOBAL[timestamp], $_SGLOBAL[timestamp], -1, -1, -1, '2	7	12	17	22	27	32	37	42	47	52'",
		"1, 'system', 'ÇåÀí½ÅÓ¡ºÍ×îзÿÍ', 'cleantrace.php', $_SGLOBAL[timestamp], $_SGLOBAL[timestamp], -1, -1, 2, '3'"
	);
	$_SGLOBAL['db']->query("TRUNCATE TABLE ".tname('cron'));
	$_SGLOBAL['db']->query("INSERT INTO ".tname('cron')." (available, type, name, filename, lastrun, nextrun, weekday, day, hour, minute) VALUES (".implode('),(', $datas).")");

	//Óû§ÈÎÎñ
	$datas = array();
	$datas[] = "1, '¸üÐÂÒ»ÏÂ×Ô¼ºµÄÍ·Ïñ', 'Í·Ïñ¾ÍÊÇÄãÔÚÕâÀïµÄ¸öÈËÐÎÏó¡£<br>ÉèÖÃ×Ô¼ºµÄÍ·Ïñºó£¬»áÈøü¶àµÄÅóÓѼÇסÄú¡£', 'avatar.php', 1, '', 0, 20, 'image/task/avatar.gif'";
	$datas[] = "1, '½«¸öÈË×ÊÁϲ¹³äÍêÕû', '°Ñ×Ô¼ºµÄ¸öÈË×ÊÁÏÌîдÍêÕû°É¡£<br>ÕâÑùÄú»á±»¸ü¶àµÄÅóÓÑÕÒµ½µÄ£¬ÏµÍ³Ò²»á°ïÄúÕÒµ½ÅóÓÑ¡£', 'profile.php', '', 2, 0, 20, 'image/task/profile.gif'";
	$datas[] = "1, '·¢±í×Ô¼ºµÄµÚһƪÈÕÖ¾', 'ÏÖÔÚ£¬¾ÍдÏÂ×Ô¼ºµÄµÚһƪÈÕÖ¾°É¡£<br>Óë´ó¼ÒÒ»Æð·ÖÏí×Ô¼ºµÄÉú»î¸ÐÎò¡£', 'blog.php', 3, '', 0, 5, 'image/task/blog.gif'";
	$datas[] = "1, 'Ñ°ÕÒ²¢Ìí¼ÓÎåλºÃÓÑ', 'ÓÐÁ˺ÃÓÑ£¬Äú·¢µÄÈÕÖ¾¡¢Í¼Æ¬µÈ»á±»ºÃÓѼ°Ê±¿´µ½²¢´«²¥³öÈ¥£»<br>ÄúÒ²»áÔÚÊ×Ò³·½±ã¼°Ê±µÄ¿´µ½ºÃÓѵÄ×îж¯Ì¬¡£', 'friend.php', 4, '', 0, 50, 'image/task/friend.gif'";
	$datas[] = "1, 'ÑéÖ¤¼¤»î×Ô¼ºµÄÓÊÏä', 'Ìîд×Ô¼ºÕæʵµÄÓÊÏäµØÖ·²¢Ñé֤ͨ¹ý¡£<br>Äú¿ÉÒÔÔÚÍü¼ÇÃÜÂëµÄʱºòʹÓøÃÓÊÏäÈ¡»Ø×Ô¼ºµÄÃÜÂ룻<br>»¹¿ÉÒÔ¼°Ê±½ÓÊÜÕ¾ÄڵĺÃÓÑ֪ͨµÈµÈ¡£', 'email.php', 5, '', 0, 10, 'image/task/email.gif'";
	$datas[] = "1, 'ÑûÇë10¸öÐÂÅóÓѼÓÈë', 'ÑûÇëÒ»ÏÂ×Ô¼ºµÄQQºÃÓÑ»òÕßÓÊÏäÁªÏµÈË£¬ÈÃÇ×ÅóºÃÓÑÒ»ÆðÀ´¼ÓÈëÎÒÃÇ°É¡£', 'invite.php', 6, '', 0, 100, 'image/task/friend.gif'";
	$datas[] = "1, 'ÁìȡÿÈÕ·ÃÎÊ´óÀñ°ü', 'ÿÌìµÇ¼·ÃÎÊ×Ô¼ºµÄÖ÷Ò³£¬¾Í¿ÉÁìÈ¡´óÀñ°ü¡£', 'gift.php', 99, 'day', 0, 5, 'image/task/gift.gif'";

	$_SGLOBAL['db']->query("TRUNCATE TABLE ".tname('task'));
	$_SGLOBAL['db']->query("INSERT INTO ".tname('task')." (`available`, `name`, `note`, `filename`, `displayorder`, `nexttype`, `nexttime`, `credit`, `image`) VALUES (".implode('),(', $datas).")");

	//»î¶¯·ÖÀà
	$datas = array(
		"1, 'Éú»î/¾Û»á', 0, '·ÑÓÃ˵Ã÷£º\r\n¼¯ºÏµØµã£º\r\n×Å×°ÒªÇó£º\r\nÁªÏµ·½Ê½£º\r\n×¢ÒâÊÂÏ', 1",
		"2, '³öÐÐ/ÂÃÓÎ', 0, '·Ïß˵Ã÷:\r\n·ÑÓÃ˵Ã÷:\r\n×°±¸ÒªÇó:\r\n½»Í¨¹¤¾ß:\r\n¼¯ºÏµØµã:\r\nÁªÏµ·½Ê½:\r\n×¢ÒâÊÂÏî:', 2",
		"3, '±ÈÈü/Ô˶¯', 0, '·ÑÓÃ˵Ã÷£º\r\n¼¯ºÏµØµã£º\r\n×Å×°ÒªÇó£º\r\n³¡µØ½éÉÜ£º\r\nÁªÏµ·½Ê½£º\r\n×¢ÒâÊÂÏ', 4",
		"4, 'µçÓ°/Ñݳö', 0, '¾çÇé½éÉÜ£º\r\n·ÑÓÃ˵Ã÷£º\r\n¼¯ºÏµØµã£º\r\nÁªÏµ·½Ê½£º\r\n×¢ÒâÊÂÏ', 3",
		"5, '½ÌÓý/½²×ù', 0, 'Ö÷°ìµ¥Î»£º\r\n»î¶¯Ö÷Ì⣺\r\n·ÑÓÃ˵Ã÷£º\r\n¼¯ºÏµØµã£º\r\nÁªÏµ·½Ê½£º\r\n×¢ÒâÊÂÏ', 5",
		"6, 'ÆäËü', 0, '', 6"
	);	
	$_SGLOBAL['db']->query("TRUNCATE TABLE ".tname('eventclass'));
	$_SGLOBAL['db']->query("INSERT INTO ".tname('eventclass')." (classid, classname, poster, template, displayorder) VALUES (".implode('),(', $datas).")");
	
	//µÀ¾ß
	$datas = array();
	$datas[] = "'invisible', 'ÒþÉí²Ý', 'ÈÃ×Ô¼ºÒþÉíµÇ¼£¬²»ÏÔʾÔÚÏߣ¬24СʱÄÚÓÐЧ', '5', '50', '86400', '10', '86400', '1'";
	$datas[] = "'friendnum', 'ºÃÓÑÔöÈÝ¿¨', 'ÔÚÔÊÐíÌí¼ÓµÄ×î¶àºÃÓÑÊýÏÞÖÆÍ⣬Ôö¼Ó10¸öºÃÓÑÃû¶î', '3', '30', '86400', '999', '0', '1'";
	$datas[] = "'attachsize', '¸½¼þÔöÈÝ¿¨', 'ʹÓÃÒ»´Î£¬¿ÉÒÔ¸ø×Ô¼ºÔö¼Ó 10M µÄ¸½¼þ¿Õ¼ä', '3', '30', '86400', '999', '0', '1'";
	$datas[] = "'thunder', 'À×ÃùÖ®Éù', '·¢²¼Ò»ÌõÈ«Õ¾ÐÅÏ¢£¬Èôó¼ÒÖªµÀ×Ô¼ºÉÏÏßÁË', '5', '500', '86400', '5', '86400', '1'";
	$datas[] = "'updateline', '¾ÈÉúȦ', '°ÑÖ¸¶¨¶ÔÏóµÄ·¢²¼Ê±¼ä¸üÐÂΪµ±Ç°Ê±¼ä', '5', '200', '86400', '999', '0', '1'";
		
	$datas[] = "'downdateline', 'ʱ¿Õ»ú', '°ÑÖ¸¶¨¶ÔÏóµÄ·¢²¼Ê±¼äÐÞ¸ÄΪ¹ýÈ¥µÄʱ¼ä', '5', '250', '86400', '999', '0', '1'";		
	$datas[] = "'color', '²ÊÉ«µÆ', '°ÑÖ¸¶¨¶ÔÏóµÄ±êÌâ±ä³É²ÊÉ«µÄ', '5', '50', '86400', '999', '0', '1'";
	$datas[] = "'hot', 'ÈȵãµÆ', '°ÑÖ¸¶¨¶ÔÏóµÄÈȶÈÔö¼ÓÕ¾µãÍƼöµÄÈȵãÖµ', '5', '50', '86400', '999', '0', '1'";
	$datas[] = "'visit', '»¥·Ã¿¨', 'Ëæ»úÑ¡Ôñ10¸öºÃÓÑ£¬ÏòÆä´òÕкô¡¢ÁôÑÔ»ò·ÃÎÊ¿Õ¼ä', '2', '20', '86400', '999', '0', '1'";
	$datas[] = "'icon', '²Êºçµ°', '¸øÖ¸¶¨¶ÔÏóµÄ±êÌâÇ°ÃæÔö¼Óͼ±ê£¨×î¶à8¸öͼ±ê£©', '2', '20', '86400', '999', '0', '1'";
		
	$datas[] = "'flicker', '²ÊºçìÅ', 'ÈÃÆÀÂÛ¡¢ÁôÑÔµÄÎÄ×ÖÉÁ˸ÆðÀ´', '3', '30', '86400', '999', '0', '1'";
	$datas[] = "'gift', 'ºì°ü¿¨', 'ÔÚ×Ô¼ºµÄ¿Õ¼äÂñÏ»ý·Öºì°üË͸øÀ´·ÃÕß', '2', '20', '86400', '999', '0', '1'";
	$datas[] = "'superstar', '³¬¼¶Ã÷ÐÇ', 'ÔÚ¸öÈËÖ÷Ò³£¬¸ø×Ô¼ºµÄÍ·ÏñÔö¼Ó³¬¼¶Ã÷ÐDZêʶ', '3', '30', '86400', '999', '0', '1'";
	$datas[] = "'viewmagiclog', '°ËØÔ¾µ', '²é¿´Ö¸¶¨Óû§×î½üʹÓõĵÀ¾ß¼Ç¼', '5', '100', '86400', '999', '0', '1'";
	$datas[] = "'viewmagic', '͸ÊÓ¾µ', '²é¿´Ö¸¶¨Óû§µ±Ç°³ÖÓеĵÀ¾ß', '5', '100', '86400', '999', '0', '1'";
		
	$datas[] = "'viewvisitor', '͵¿ú¾µ', '²é¿´Ö¸¶¨Óû§×î½ü·ÃÎʹýµÄ10¸ö¿Õ¼ä', '5', '100', '86400', '999', '0', '1'";
	$datas[] = "'call', 'µãÃû¿¨', '·¢Í¨Öª¸ø×Ô¼ºµÄºÃÓÑ£¬ÈÃËûÃÇÀ´²é¿´Ö¸¶¨µÄ¶ÔÏó', '5', '50', '86400', '999', '0', '1'";
	$datas[] = "'coupon', '´ú½ðȯ','¹ºÂòµÀ¾ßʱÕÛ»»Ò»¶¨Á¿µÄ»ý·Ö', '0', '0', '0', '0', '0', '1'";
	$datas[] = "'frame', 'Ïà¿ò', '¸ø×Ô¼ºµÄÕÕƬÌíÉÏÏà¿ò', '3', '30', '86400', '999', '0', '1'";
	$datas[] = "'bgimage', 'ÐÅÖ½', '¸øÖ¸¶¨µÄ¶ÔÏóÌí¼ÓÐÅÖ½±³¾°', '3', '30', '86400', '999', '0', '1'";
		
	$datas[] = "'doodle', 'Í¿Ñ»°å', 'ÔÊÐíÔÚÁôÑÔ¡¢ÆÀÂ۵ȲÙ×÷ʱʹÓÃÍ¿Ñ»°å', '3', '30', '86400', '999', '0', '1'";
	$datas[] = "'anonymous', 'ÄäÃû¿¨', 'ÔÚÖ¸¶¨µÄµØ·½£¬ÈÃ×Ô¼ºµÄÃû×ÖÏÔʾΪÄäÃû', '5', '50', '86400', '999', '0', '1'";
	$datas[] = "'reveal', 'ÕÕÑý¾µ', '¿ÉÒԲ鿴һ´ÎÄäÃûÓû§µÄÕæʵÉí·Ý', '5', '100', '86400', '999', '0', '1'";
	$datas[] = "'license', 'µÀ¾ßתÈÃÐí¿ÉÖ¤', 'ʹÓÃÐí¿ÉÖ¤£¬½«µÀ¾ßÔùË͸øÖ¸¶¨ºÃÓÑ', '1', '10', '3600', '999', '0', '1'";
	$datas[] = "'detector', '̽²âÆ÷', '̽²âÂñÁ˺ì°üµÄ¿Õ¼ä', '1', '10', '86400', '999', '0', '1'";
	
	$_SGLOBAL['db']->query("TRUNCATE TABLE ".tname('magic'));
	$_SGLOBAL['db']->query("INSERT INTO ".tname('magic')."(`mid`, `name`, `description`, `experience`, `charge`, `provideperoid`, `providecount`, `useperoid`, `usecount`) VALUES (".implode('),(', $datas).")");		

	//±í̬
	$datas = array(
		"'1', '·¹ý', 'luguo.gif', 'blogid'",
		"'2', 'À×ÈË', 'leiren.gif', 'blogid'",
		"'3', 'ÎÕÊÖ', 'woshou.gif', 'blogid'",
		"'4', 'ÏÊ»¨', 'xianhua.gif', 'blogid'",
		"'5', '¼¦µ°', 'jidan.gif', 'blogid'",
		
		"'6', 'ƯÁÁ', 'piaoliang.gif', 'picid'",
		"'7', '¿á±Ð', 'kubi.gif', 'picid'",
		"'8', 'À×ÈË', 'leiren.gif', 'picid'",
		"'9', 'ÏÊ»¨', 'xianhua.gif', 'picid'",
		"'10', '¼¦µ°', 'jidan.gif', 'picid'",
		
		"'11', '¸ãЦ', 'gaoxiao.gif', 'tid'",
		"'12', 'ÃÔ»ó', 'mihuo.gif', 'tid'",
		"'13', 'À×ÈË', 'leiren.gif', 'tid'",
		"'14', 'ÏÊ»¨', 'xianhua.gif', 'tid'",
		"'15', '¼¦µ°', 'jidan.gif', 'tid'"
	);
	$_SGLOBAL['db']->query("TRUNCATE TABLE ".tname('click'));
	$_SGLOBAL['db']->query("INSERT INTO ".tname('click')." (clickid, `name`, icon, idtype) VALUES (".implode('),(', $datas).")");

	show_msg('ϵͳĬÈÏÊý¾ÝÌí¼ÓÍê±Ï£¬½øÈëÏÂÒ»²½²Ù×÷', ($step+1), 1);

} elseif ($step == 5) {

	//¸üлº´æ
	dbconnect();
	include_once(S_ROOT.'./source/function_cache.php');

	config_cache();
	usergroup_cache();
	profilefield_cache();
	profield_cache();
	censor_cache();
	block_cache();
	eventclass_cache();
	magic_cache();
	click_cache();
	task_cache();
	ad_cache();
	creditrule_cache();
	userapp_cache();
	app_cache();
	network_cache();

	$msg = <<<EOF
	<form method="post" action="$theurl">
	<table>
	<tr><td colspan="2">³ÌÐòÊý¾Ý°²×°Íê³É!<br><br>
	×îºó£¬ÇëÊäÈëÄúÔÚÓû§ÖÐÐÄUCenterµÄÓû§ÃûºÍÃÜÂë<br>ϵͳ½«×Ô¶¯ÎªÄú¿ªÍ¨Õ¾ÄÚµÚÒ»¸ö¿Õ¼ä£¬²¢½«ÄúÉèΪ¹ÜÀíÔ±!
	</td></tr>
	<tr><td>ÄúµÄÓû§Ãû</td><td><input type="text" name="username" value="" size="30"></td></tr>
	<tr><td>ÄúµÄÃÜÂë</td><td><input type="password" name="password" value="" size="30"></td></tr>
	<tr><td></td><td><input type="submit" name="opensubmit" value="¿ªÍ¨¹ÜÀíÔ±¿Õ¼ä"></td></tr>
	</table>
	<input type="hidden" name="formhash" value="$formhash">
	</form>
EOF;

	show_msg($msg, 999);
}

//Ò³ÃæÍ·²¿
function show_header() {
	global $_SGLOBAL, $nowarr, $step, $theurl, $_SC;

	$nowarr[$step] = ' class="current"';
	print<<<END
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=$_SC[charset]" />
	<title> UCenter Home ³ÌÐò°²×° </title>
	<style type="text/css">
	* {font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 1.5em; word-break: break-all; }
	body { text-align:center; margin: 0; padding: 0; background: #F5FBFF; }
	.bodydiv { margin: 40px auto 0; width:720px; text-align:left; border: solid #86B9D6; border-width: 5px 1px 1px; background: #FFF; }
	h1 { font-size: 18px; margin: 1px 0 0; line-height: 50px; height: 50px; background: #E8F7FC; color: #5086A5; padding-left: 10px; }
	#menu {width: 100%; margin: 10px auto; text-align: center; }
	#menu td { height: 30px; line-height: 30px; color: #999; border-bottom: 3px solid #EEE; }
	.current { font-weight: bold; color: #090 !important; border-bottom-color: #F90 !important; }
	.showtable { width:100%; border: solid; border-color:#86B9D6 #B2C9D3 #B2C9D3; border-width: 3px 1px 1px; margin: 10px auto; background: #F5FCFF; }
	.showtable td { padding: 3px; }
	.showtable strong { color: #5086A5; }
	.datatable { width: 100%; margin: 10px auto 25px; }
	.datatable td { padding: 5px 0; border-bottom: 1px solid #EEE; }
	input { border: 1px solid #B2C9D3; padding: 5px; background: #F5FCFF; }
	.button { margin: 10px auto 20px; width: 100%; }
	.button td { text-align: center; }
	.button input, .button button { border: solid; border-color:#F90; border-width: 1px 1px 3px; padding: 5px 10px; color: #090; background: #FFFAF0; cursor: pointer; }
	#footer { font-size: 10px; line-height: 40px; background: #E8F7FC; text-align: center; height: 38px; overflow: hidden; color: #5086A5; margin-top: 20px; }
	</style>
	<script type="text/javascript">
	function $(id) {
		return document.getElementById(id);
	}
	//Ìí¼ÓSelectÑ¡Ïî
	function addoption(obj) {
		if (obj.value=='addoption') {
			var newOption=prompt('ÇëÊäÈë:','');
			if (newOption!=null && newOption!='') {
				var newOptionTag=document.createElement('option');
				newOptionTag.text=newOption;
				newOptionTag.value=newOption;
				try {
					obj.add(newOptionTag, obj.options[0]); // doesn't work in IE
				}
				catch(ex) {
					obj.add(newOptionTag, obj.selecedIndex); // IE only
				}
				obj.value=newOption;
			} else {
				obj.value=obj.options[0].value;
			}
		}
	}
	</script>
	</head>
	<body id="append_parent">
	<div class="bodydiv">
	<h1>UCenter Home³ÌÐò°²×°</h1>
	<div style="width:90%;margin:0 auto;">
	<table id="menu">
	<tr>
	<td{$nowarr[0]}>1.°²×°¿ªÊ¼</td>
	<td{$nowarr[1]}>2.ÉèÖÃUCenterÐÅÏ¢</td>
	<td{$nowarr[2]}>3.ÉèÖÃÊý¾Ý¿âÁ¬½ÓÐÅÏ¢</td>
	<td{$nowarr[3]}>4.´´½¨Êý¾Ý¿â½á¹¹</td>
	<td{$nowarr[4]}>5.Ìí¼ÓĬÈÏÊý¾Ý</td>
	<td{$nowarr[5]}>6.°²×°Íê³É</td>
	</tr>
	</table>
END;
}

//Ò³Ã涥²¿
function show_footer() {
	print<<<END
	</div>
	<iframe id="phpframe" name="phpframe" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank"></iframe>
	<div id="footer">&copy; Comsenz Inc. 2001-2009 u.discuz.net</div>
	</div>
	<br>
	</body>
	</html>
END;
}


//ÏÔʾ
function show_msg($message, $next=0, $jump=0) {
	global $theurl;

	$nextstr = '';
	$backstr = '';

	obclean();
	if(empty($next)) {
		$backstr .= "<a href=\"javascript:history.go(-1);\">·µ»ØÉÏÒ»²½</a>";
	} elseif ($next == 999) {
	} else {
		$url_forward = "$theurl?step=$next";
		if($jump) {
			$nextstr .= "<a href=\"$url_forward\">ÇëÉÔµÈ...</a><script>setTimeout(\"window.location.href ='$url_forward';\", 1000);</script>";
		} else {
			$nextstr .= "<a href=\"$url_forward\">¼ÌÐøÏÂÒ»²½</a>";
			$backstr .= "<a href=\"javascript:history.go(-1);\">·µ»ØÉÏÒ»²½</a>";
		}
	}

	show_header();
	print<<<END
	<table>
	<tr><td>$message</td></tr>
	<tr><td>&nbsp;</td></tr>
	<tr><td>$backstr $nextstr</td></tr>
	</table>
END;
	show_footer();
	exit();
}

//¼ì²éȨÏÞ
function checkfdperm($path, $isfile=0) {
	if($isfile) {
		$file = $path;
		$mod = 'a';
	} else {
		$file = $path.'./install_tmptest.data';
		$mod = 'w';
	}
	if(!@$fp = fopen($file, $mod)) {
		return false;
	}
	if(!$isfile) {
		//ÊÇ·ñ¿ÉÒÔɾ³ý
		fwrite($fp, ' ');
		fclose($fp);
		if(!@unlink($file)) {
			return false;
		}
		//¼ì²âÊÇ·ñ¿ÉÒÔ´´½¨×ÓĿ¼
		if(is_dir($path.'./install_tmpdir')) {
			if(!@rmdir($path.'./install_tmpdir')) {
				return false;
			}
		}
		if(!@mkdir($path.'./install_tmpdir')) {
			return false;
		}
		//ÊÇ·ñ¿ÉÒÔɾ³ý
		if(!@rmdir($path.'./install_tmpdir')) {
			return false;
		}
	} else {
		fclose($fp);
	}
	return true;
}

?>
Return current item: Uchome and Discuz