⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.php

📁 Discuz论坛功能、使用、二次开发的详细介绍说明。
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?

	}

?>
		<table class="tb2">
			<tr>
				<th><span class="red"><?=$lang['step2_dbhost']?>:</span></th>
				<td><input name="ucdbhost" type="text" class="txt" value="<?php echo $ucdbhost ? $ucdbhost : (defined('UC_DBHOST') ? UC_DBHOST : 'localhost');?>" /></td>
			</tr>
			<tr>
				<th><?=$lang['step2_dbname']?></th>
				<td><input name="ucdbname" type="text" class="txt" value="<?php echo $ucdbname ? $ucdbname : (defined('UC_DBNAME') ? UC_DBNAME : 'test');?>" /></td>
			</tr>
			<tr>
				<th><?=$lang['step2_dbuser']?>:</th>
				<td><input name="ucdbuser" type="text" class="txt" value="<?php echo $ucdbuser ? $ucdbuser : (defined('UC_DBUSER') ? UC_DBUSER : 'root');?>" /></td>
			</tr>
			<tr>
				<th><?=$lang['step2_dbpw']?>:</th>
				<td><input name="ucdbpw" type="password" class="txt" value="<?php echo $ucdbpw ? $ucdbpw : (defined('UC_DBPW') ? UC_DBPW : '');?>" /></td>
			</tr>
			<tr>
				<th><span class="red"><?=$lang['step2_tablepre']?>:</span></th>
				<td><input name="uctablepre" type="text" class="txt" value="<?php echo $uctablepre ? $uctablepre : (defined('UC_DBTABLEPRE') ? UC_DBTABLEPRE : 'uc_');?>" /></td>
			</tr>
		</table>
		<input type="hidden" name="ucfounderpw" value="<?php echo $ucfounderpw;?>">
		<div class="btnbox marginbot"><input type="button" value="<?=$lang['old_step']?>" onclick="history.back();" /><input type="submit" name="submit" value="<?=$lang['new_step']?>" /></div>
		</form>
<?

	/*echo '<form action="index.php?step=ucdb" method="post">';
	echo $hidden;
	if($pass) {
		$nextstep = ' <input type="button" onclick="history.back();" value="'.$lang['old_step'].'"><input type="submit" value="'.$lang['new_step'].'">';
	} else {
		$nextstep = ' <input type="button" disabled="disabled" value="'.$lang['step1_unwriteable'].'">';
	}
	echo '<div class="btnbox marginbot"> '.$nextstep.'</div>';
	echo '</form>';*/

	uc_install_footer();

} elseif($step == 'ucadmin') {

	//note 检查 mysql 帐号密码
	$msg = '';
	if(!@mysql_connect($ucdbhost, $ucdbuser, $ucdbpw)) {
		$errormsg = 'database_errno_'.mysql_errno();
		$msg .= '<li>'.($lang[$errormsg] ? $lang[$errormsg] : mysql_error()) .'</li>';
		$quit = TRUE;
	} else {

		$curr_mysql_version = mysql_get_server_info();

		if(!$ucdbname) {
			$msg .= $lang['step3_error_dbname_empty'];
		}
		if($curr_mysql_version > '4.1') {
			mysql_query("CREATE DATABASE IF NOT EXISTS `$ucdbname` DEFAULT CHARACTER SET $ucdbcharset");
		} else {
			mysql_query("CREATE DATABASE IF NOT EXISTS `$ucdbname`");
		}
		if(mysql_errno()) {
			$errormsg = isset($lang['database_errno_'.mysql_errno()]) ? $lang['database_errno_'.mysql_errno()] :  mysql_error();
			$msg .= "<li>".$errormsg.'</li>';
			$quit = TRUE;
		} else {
			mysql_select_db($ucdbname);
			if($curr_mysql_version < '3.23') {
				$msg .= '<li>'.$lang['mysql_version_323'].'</li>';
				$quit = TRUE;
			}
			$sqlarray = array(
				'createtable' => 'CREATE TABLE uc_test (test TINYINT (3) UNSIGNED)',
				'insert' => 'INSERT INTO uc_test (test) VALUES (1)',
				'select' => 'SELECT * FROM uc_test',
				'update' => 'UPDATE uc_test SET test=\'2\' WHERE test=\'1\'',
				'delete' => 'DELETE FROM uc_test WHERE test=\'2\'',
				'droptable' => 'DROP TABLE uc_test'
			);

			foreach($sqlarray as $key => $sql) {
				mysql_select_db($ucdbname);
				mysql_query($sql);
				if(mysql_errno()) {
					$errnolang = 'dbpriv_'.$key;
					$msg .= '<li>'.$lang[$errnolang].'</li>';
					$quit = TRUE;
				}
			}

			$result = mysql_query("SELECT COUNT(*) FROM ".$uctablepre."applications");
			if($result) {
				$msg .= '<li><span class="red">'.$lang['db_not_null'].'</span></li>';
				$alert = " onSubmit=\"return confirm('$lang[db_drop_table_confirm]');\"";
			}
		}
	}

	if($quit && empty($_POST['msg'])) {
		$hidden .= var_to_hidden('msg', htmlspecialchars($msg));
		echo '<form action="index.php?step=ucdb" method="post" id="ucdbform">';
		echo $hidden;
		echo '</form>';
		echo '<script type="text/javascript">document.getElementById(\'ucdbform\').submit();</script>';
		exit;
	}

	uc_install_header();

?>
		<div class="setup step3">
			<h2><?=$lang['step3_title']?></h2>
			<p><?=$lang['step3_desc']?></p>
		</div>
		<div class="stepstat">
			<ul>
				<li>1</li>
				<li>2</li>
				<li class="current">3</li>
				<li class="unactivated last">4</li>
			</ul>
			<div class="stepstatbg stepstat3"></div>
		</div>
	</div>
	<div class="main">
		<div class="desc">
			<ul>
				<?=$lang['step3_comment']?>
				<?php echo getgpc('msg', 'P');?>
			</ul>
		</div>
		<form method="post" action="index.php?step=ucinstall&ucdbcharset=<?=$ucdbcharset?>"<?=$alert?>>
		<?=$hidden?>
		<table class="tb2">
			<tr>
				<th><?=$lang['step3_founder']?>:</th>
				<td><input type="text" class="txt" disabled="disabled" readonly="readonly" value="UCenter Administrator" /></td>
			</tr>
			<tr>
				<th><?=$lang['step3_password']?>:</th>
				<td><input name="ucfounderpw" type="password" class="txt" value="<?=$ucfounderpw?>" /></td>
			</tr>
			<tr>
				<th><?=$lang['step3_repeatpw']?>:</th>
				<td><input name="ucfounderpw2" type="password" class="txt" value="<?=$ucfounderpw?>" /></td>
			</tr>
		</table>
		<div class="btnbox marginbot"><input type="button" value="<?=$lang['old_step']?>" onclick="history.back();" /><input type="submit" name="submit" value="<?=$lang['new_step']?>" /></div>
		</form>
<?

	uc_install_footer();

} elseif($step == 'ucinstall') {

	$ucfounderpw = getgpc('ucfounderpw', 'P');
	$ucfounderpw2 = getgpc('ucfounderpw2', 'P');

	if($ucfounderpw != $ucfounderpw2) {
		uc_install_msg('step4_error_password_invalid');
	}

	if(!is_writable(UC_CONFIG)) {
		uc_install_msg($lang['step4_error_config_unwriteable1'].UC_CONFIG.$lang['step4_error_config_unwriteable2']);
	}

	$ucapi = strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'))).'://'.$_SERVER['HTTP_HOST'].substr(substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')), 0, -11);

	//note 创建常用表
	$db = new db();
	$db->connect($ucdbhost, $ucdbuser, $ucdbpw, $ucdbname, $ucdbcharset, 0);

	$sql = file_get_contents(UC_ROOT.'./uc.sql');
	$sql = str_replace("\r\n", "\n", $sql);
	uc_install_header();

?>
		<div class="setup step4">
			<h2><?=$lang['step4_title']?></h2>
			<p><?=$lang['step4_desc']?></p>
		</div>
		<div class="stepstat">
			<ul>
				<li>1</li>
				<li>2</li>
				<li>3</li>
				<li class="current last">4</li>
			</ul>
			<div class="stepstatbg stepstat4"></div>
		</div>
	</div>
<script type="text/javascript">
function showmessage(message) {
	document.getElementById('notice').value += message + "\r\n";
}
function initinput() {
	/*parent.document.getElementById('ucapi').value='<?=$ucapi?>';
	parent.document.getElementById('ucfounder').value='<?=$ucfounder?>';
	parent.document.getElementById('ucfounderpw').value='<?=$ucfounderpw?>';
	parent.document.getElementById('installuclink').style.display='none';*/
	window.location='<?php echo 'index.php?step=login';?>';
}
</script>
	<div class="main">
		<div class="btnbox"><textarea name="notice" style="width: 80%;"  readonly="readonly" id="notice"></textarea></div>
		<div class="btnbox marginbot">
		<input type="button" name="submit" value=" <?=$lang['install_in_processed']?> " disabled style="height: 25" id="laststep" onclick="initinput()">
		</div>
		<?php runquery($sql);?>
<?

	$ucsalt = substr(uniqid(rand()), 0, 6);
	$ucfounderpw= md5(md5($ucfounderpw).$ucsalt);
	$regdate = time();

	//note 写入 UCenter 配置文件 uc/data/config.inc.php
	$configfile = UC_CONFIG;
	$ucauthkey = generate_key();
	$ucsiteid = generate_key();
	$ucmykey = generate_key();
	$config = "<?php \r\ndefine('UC_DBHOST', '$ucdbhost');\r\n";
	$config .= "define('UC_DBUSER', '$ucdbuser');\r\n";
	$config .= "define('UC_DBPW', '$ucdbpw');\r\n";
	$config .= "define('UC_DBNAME', '$ucdbname');\r\n";
	$config .= "define('UC_DBCHARSET', '$ucdbcharset');\r\n";
	$config .= "define('UC_DBTABLEPRE', '$uctablepre');\r\n";
	$config .= "define('UC_COOKIEPATH', '/');\r\n";
	$config .= "define('UC_COOKIEDOMAIN', '');\r\n";
	$config .= "define('UC_DBCONNECT', 0);\r\n";
	$config .= "define('UC_CHARSET', '".UC_CHARSET."');\r\n";
	$config .= "define('UC_FOUNDERPW', '$ucfounderpw');\r\n";
	$config .= "define('UC_FOUNDERSALT', '$ucsalt');\r\n";
	$config .= "define('UC_KEY', '$ucauthkey');\r\n";
	$config .= "define('UC_SITEID', '$ucsiteid');\r\n";
	$config .= "define('UC_MYKEY', '$ucmykey');\r\n";
	$config .= "define('UC_DEBUG', false);\r\n";
	$config .= "define('UC_PPP', 20);\r\n";
	$fp = fopen(UC_CONFIG, 'w');
	fwrite($fp, $config);
	fclose($fp);
	echo '<script type="text/javascript">document.getElementById("laststep").disabled=false;document.getElementById("laststep").value = \''.$lang['install_succeed'].'\';</script>'."\r\n";
	uc_install_footer();

} elseif($step == 'login') {

	include UC_CONFIG;
	$md5password =  UC_FOUNDERPW;
	setcookie('uc_founderauth', authcode("|$md5password|".md5($_SERVER['HTTP_USER_AGENT'])."|1", 'ENCODE', UC_KEY), time() + 3600, '/');
	header("Location:../admin.php?m=frame&a=index&mainurl=".urlencode('admin.php?m=app&a=add'));
	touch(UC_ROOT.'./../data/install.lock');
	exit;

}

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -