安静
PHP技术博客

101029 php 产品安装程序制作代码demo

php制作安装程序 简单demo

1:检查文件写入权限

2:配置文件的一些信息

3:最终执行sql导入

<?php
$file = "dbinfo.php";
$step = $_REQUEST ['step'];
if (! step) {
	$step = 0;
}
if ($step == 0) {
	if (! is_writable ( $file )) {
		echo "<font color=red>不可写!!!</font>";
	} else {
		echo "<font color=green>可写,<a href='1.php?step=1'>下一步</a></font>";
	}
}
if ($_POST ['submit']) {
	$content = "<?php";
	$content .= "\n";
	$content .= "$user=" . "'" . $_POST ['dbusername'] . "';//数据库用户名";
	$content .= "\n";
	$content .= "$password=" . "'" . $_POST ['password'] . "';//数据库用户密码";
	$content .= "\n";
	$content .= "$host=" . "'" . $_POST ['host'] . "';//数据库服务器地址";
	$content .= "\n";
	$content .= "$dbname=" . "'" . $_POST ['dbname'] . "';//数据库名";
	$content .= "\n";
	$content .= "$port=" . "'5432';//数据库端口";
	$content .= "\n";
	$content .= "?>";
	$fcontent = fopen ( $file, 'w+' );
	fwrite ( $fcontent, $content );
	$step = 2;
}
if ($step == 1) {
	?>
<form method="post">
	数据库用户名:
	<input type="text" name="dbusername">
	数据库密码:
	<input type="text" name="password">
	数据库名:
	<input type="text" name="host">
	数据库地址:
	<input type="text" name="dbname">
	<input type="submit" name="submit">
</form>
<?php
}
if ($step == 2) {
	echo "执行sql导入成功";
}
?>
<?php

$file = "dbinfo.php";
$step = $_REQUEST ['step'];
if (! step) {
	$step = 0;
}
if ($step == 0) {
	if (! is_writable ( $file )) {
		echo "<font color=red>不可写!!!</font>";
	} else {
		echo "<font color=green>可写,<a href='1.php?step=1'>下一步</a></font>";
	}
}

if ($_POST ['submit']) {
	$content = "<?php";
	$content .= "\n";
	$content .= "$user=" . "'" . $_POST ['dbusername'] . "';//数据库用户名";
	$content .= "\n";
	$content .= "$password=" . "'" . $_POST ['password'] . "';//数据库用户密码";
	$content .= "\n";
	$content .= "$host=" . "'" . $_POST ['host'] . "';//数据库服务器地址";
	$content .= "\n";
	$content .= "$dbname=" . "'" . $_POST ['dbname'] . "';//数据库名";
	$content .= "\n";
	$content .= "$port=" . "'5432';//数据库端口";
	$content .= "\n";
	$content .= "?>";
	$fcontent = fopen ( $file, 'w+' );
	fwrite ( $fcontent, $content );
	$step = 2;
}
if ($step == 1) {
	?>

<form method="post">
	数据库用户名:
	<input type="text" name="dbusername">
	数据库密码:
	<input type="text" name="password">
	数据库名:
	<input type="text" name="host">
	数据库地址:
	<input type="text" name="dbname">
	<input type="submit" name="submit">
</form><?php
}
if ($step == 2) {
	echo "执行sql导入成功";
}
赞(0) 打赏
未经允许不得转载:AJ's Blog » 101029 php 产品安装程序制作代码demo
分享到: 更多 (0)

评论 1

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #-49

    这个博客主题个性,呵呵

    AB先生11年前 (2010-12-13)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏