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

📄 index.php

📁 很不错的php聊天室源码,提供给大家学习
💻 PHP
字号:
<html>
<head>
<title>
天龙聊天室 安装程序
</title>
<Style>
body,td{font-size:13px;}
</style>
<head>
<body>
<br>
<h3>【天龙聊天室】安装程序</h3>
<?php
error_reporting (E_ERROR | E_WARNING | E_PARSE);
if(!isset($_GET["step"]))
{
	echo "<script language=javascript>location.href='index.php?step=0'</script>";
	exit;
}
if($_GET["step"]==0)
{
?>
<table width=750 bgcolor="black" cellspacing=1 cellpadding=3 align="center">
<tr>
	<td colspan=2 bgcolor="#6699ff" align="center"><b>使用条款</b></td>
</tr>
<tr>
	<td width=200 align="right" bgcolor="buttonface">内容</td>
	<td width=550 bgcolor="white">
	天龙聊天室安装:
	<br>1.天龙聊天室用PHP,MYSQL,结合XMLHTTP的无刷新聊天室。拥有丰富的管理功能。
	<br>2.天龙聊天室是由<a href="http://aotianlong.yeah.net" target="_blank">傲天龙</a>所写,此为第一个版本。
	<br>3.本程序可以任意拷贝,任意修改(除了版权信息),您可以免费使用,但是请不要用于商业用途。
	<br>4.如果您发现程序有什么BUG,或者您有什么好的建议或者意见,请<a href="mailto:aotianlong@hotmail.com">来信</a>。
	<br>5.本程序虽然经过测试,但是如果导致您计算机的信息丢失,作者不负任何责任。
	<br>6.您只有遵守以上条款才可以继续。
	</td>
</tr>
</table>
<center><input type="button" onclick="location.href='http://aotianlong.yeah.net'" value="不同意"> <input type="button" value="我同意" onclick="location.href='index.php?step=1'"></center>
<?php
}
if($_GET["step"]==1)
{
?>
<form name="fm" action="index.php?step=2" method="post">
<table width=750 bgcolor="black" cellspacing=1 cellpadding=3 align="center">
<tr>
	<td colspan=2 bgcolor="#6699ff" align="center"><b>第一步</b></td>
</tr>
<tr>
	<td width=200 align="right" bgcolor="buttonface">请输入MYSQL用户名</td>
	<td width=550 bgcolor="white"><input type="text" name="mysql_username"> 输入主机提供商给你的MYSQL数据库用户名。</td>
</tr>
<tr>
	<td width=200 align="right" bgcolor="buttonface">请输入MYSQL密码</td>
	<td width=550 bgcolor="white"><input type="password" name="mysql_password"> 输入主机提供商给你的MYSQL数据库密码。</td>
</tr>
<tr>
	<td width=200 align="right" bgcolor="buttonface">请输入MYSQL主机</td>
	<td width=550 bgcolor="white"><input type="text" name="mysql_host" value="localhost"> 输入MYSQL数据库服务器。</td>
</tr>
</table>
<center><input type="submit" value="继续下一步"></center>
</form>
<?
}
if($_GET["step"]==2)
{
//检测MYSQL用户名跟密码是否正确
	if(@mysql_connect($_POST["mysql_host"],$_POST["mysql_username"],$_POST["mysql_password"]))
	{
		//连接成功
?>
<form name="fm" action="index.php?step=3" method="post">
<input type="hidden" name="mysql_username" value="<?=$_POST["mysql_username"]?>">
<input type="hidden" name="mysql_password" value="<?=$_POST["mysql_password"]?>">
<input type="hidden" name="mysql_host" value="<?=$_POST["mysql_host"]?>">
<table width=750 bgcolor="black" cellspacing=1 cellpadding=3 align="center">
<tr>
	<td colspan=2 bgcolor="#6699ff" align="center"><b>第二步</b></td>
</tr>
<tr>
	<td colspan=2 bgcolor="buttonface" align="center"><b>连接数据库成功!</b></td>
</tr>
<tr>
	<td width=200 align="right" bgcolor="buttonface">请输入想创建的数据库名称</td>
	<td width=550 bgcolor="white"><input type="text" name="databasename" value="tlchat">输入聊天室数据库名称。</td>
</tr>
	<td width=200 align="right" bgcolor="buttonface">安装在这个数据库下</td>
	<td width=550 bgcolor="white"><input type="checkbox" name="dontcreate" value="1">不创建数据库而直接在数据库中创建表</td>
</tr>
</table>
<center><input type="submit" value="继续下一步"></center>
</form>
<?php
	}
	else
	{
		//连接不成功
		echo "连接数据库失败,错误信息:<br>".mysql_error();
		echo "<center><button onclick='history.go(-1)'>返回上一步</button>";
	}
}
if($_GET["step"]==3)
{
	$info ="";
	$link = mysql_connect($_POST["mysql_host"],$_POST["mysql_username"],$_POST["mysql_password"]);
	if(!isset($_POST["dontcreate"]))
	{
		mysql_query("create database {$_POST["databasename"]}");
	}
	if(!mysql_error())
	{
		mysql_select_db($_POST["databasename"],$link);
		//成功建立数据库,创建程序需要的表。
		if(file_exists("tables.sql"))
		{
			//SQL文件存在
			$arrSql = file("tables.sql");
			for($i=0;$i<count($arrSql);$i++)
			{
				mysql_query($arrSql[$i],$link);
				if(mysql_error())
				{
					$info .= mysql_error()."<br>";
				}
			}
			//写进connect.php
			$str = "<?php\n";
			$str .= "\$serverName='".$_POST["mysql_host"]."';\n";
			$str .= "\$DbName='".$_POST["databasename"]."';\n";
			$str .= "\$DbUser='".$_POST["mysql_username"]."';\n";
			$str .= "\$DbPassword='".$_POST["mysql_password"]."';\n";
			$str .= "?>";
			if($file = @fopen("../include/connect.php","w"))
			{
				fwrite($file,$str);
			}
			else
			{
				$info .= "创建 connect.php 失败!<br>";
				$info .= "请手工安装 聊天室:<br>";
				$info .= "1.如果你数据库表创建成功了,直接创建在 include 目录下创建一个 connect.php 文件。内容如下:";
				$info .= "<br><font color=blue>";
				$info .= "&lt;?php<br>";
				$info .= "\$serverName='您的MYSQL服务器';<br>";
				$info .= "\$DbName='您的数据库名称';<br>";
				$info .= "\$DbUser='您的数据库用户名';<br>";
				$info .= "\$DbPassword = '您的数据库密码';<br>";
				$info .= "?&gt;";
				$info .= "</font><br>2.如果您的数据库没有安装成功,请将setup目录中tables.sql倒入数据库后再执行上述操作!";
				$info .= "<br>3.后台管理员名称:aotianlong,默认密码:123123。";
			}
			if($info=="")
			{
?>
<script language=javascript>
function checkForm(fm)
{
	if(fm.chatroom_admin.value=="")
	{
		alert("请设置聊天室管理员名称");
		fm.chatroom_admin.focus();
		return false;
	}
	if(fm.chatroom_adminpassword.value=="")
	{
		alert("请填写聊天室管理员密码!");
		fm.chatroom_adminpassword.focus();
		return false;
	}
	if(fm.re_chatroom_adminpassword.value!=fm.chatroom_adminpassword.value)
	{
		alert("两次聊天室管理员密码不一致!");
		fm.re_chatroom_adminpassword.value="";
		fm.chatroom_adminpassword.value="";
		fm.chatroom_adminpassword.focus();
		return false;
	}
	if(fm.chatroom_name.value=="")
	{
		alert("请填写聊天室管理员电子邮件");
		fm.chatroom_name.focus();
		return false;
	}
	if(fm.chatroom_adminemail.value=="")
	{
		alert("请填写聊天室管理员电子邮件");
		fm.chatroom_adminemail.focus();
		return false;
	}
}
</script>
<form name="fm" action="index.php?step=4" method="post" onsubmit="return checkForm(this)">
<table width=750 bgcolor="black" cellspacing=1 cellpadding=3 align="center">
<tr>
	<td colspan=2 bgcolor="#6699ff" align="center"><b>第三步</b></td>
</tr>
<tr>
	<td colspan=2 bgcolor="buttonface" align="center"><b>创建数据库成功,已经创建了程序所需要的所有表。</b></td>
</tr>
<tr>
	<td width=200 align="right" bgcolor="buttonface">设置聊天室管理员帐户</td>
	<td width=550 bgcolor="white"><input type="text" name="chatroom_admin">输入聊天室管理员帐户。</td>
</tr>
<tr>
	<td width=200 align="right" bgcolor="buttonface">设置聊天室管理员密码</td>
	<td width=550 bgcolor="white"><input type="password" name="chatroom_adminpassword">输入聊天室管理员密码。</td>
</tr>
<tr>
	<td width=200 align="right" bgcolor="buttonface">重复聊天室管理员密码</td>
	<td width=550 bgcolor="white"><input type="password" name="re_chatroom_adminpassword">再次输入聊天室管理员帐户。</td>
</tr>
<tr>
	<td width=200 align="right" bgcolor="buttonface">设置聊天室名称</td>
	<td width=550 bgcolor="white"><input type="text" name="chatroom_name">请输入聊天室名称。</td>
</tr>
<tr>
	<td width=200 align="right" bgcolor="buttonface">设置管理员电子邮件</td>
	<td width=550 bgcolor="white"><input type="text" name="chatroom_adminemail">请输入管理员电子邮件。</td>
</tr>
</table>
<center><input type="submit" value="完成安装"></center>
</form>
<?php
			}
			else
			{
				echo "创建表发生错误:";
				echo $info;
				echo "<center><button onclick='history.go(-1)'>返回上一步</button>";
			}
		}
		else
		{
			echo "找不到 tables.sql 请确认该文件在安装目录中。";
			echo "<center><button onclick='history.go(-1)'>返回上一步</button>";
		}
	}
	else
	{
		echo  "创建数据库 {$_POST["databasename"]} 发生错误:<br>";
		echo mysql_error();
		echo "<center><button onclick='history.go(-1)'>返回上一步</button>";
	}
	mysql_close($link);
}
if($_GET["step"]==4)
{
	include "../include/query.php";
	include "../include/functions.php";
	timer();
	$db = new db_query;
	$db->connect();
	$db->query("update `config` set `value` = '{$_POST["chatroom_admin"]}' where `name` = 'chatroom_admin'");
	$db->query("update `config` set `value` = '".md5($_POST["chatroom_adminpassword"])."' where `name` = 'chatroom_adminpassword'");
	$db->query("update `config` set `value` = '{$_POST["chatroom_adminemail"]}' where `name` = 'chatroom_adminemail'");
	$db->query("update `config` set `value` = '{$_POST["chatroom_name"]}' where `name` = 'chatroom_name'");
	$db->close();
?>
<table width=750 bgcolor="black" cellspacing=1 cellpadding=10 align="center">
<tr>
	<td colspan=2 bgcolor="#6699ff" align="center"><b>完成安装</b></td>
</tr>
<tr>
	<td width=200 align="right" bgcolor="buttonface">提示信息</td>
	<td width=550 bgcolor="white">欢迎您使用 天龙聊天室 您的聊天室已经可以运行了<br><a href="../admin/index.php" target='_blank'>转到超级管理员控制面板</a><br><a href="../index.php" target='_blank'>转到聊天室登录页面</a><br>为了您的系统的安全稳定运行,请删除setup目录。</td>
</tr>
</table>
<br>
<?php
include "../include/copyrights.php";
}
?>
</body>
</html>                                                                                              

⌨️ 快捷键说明

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