<?php
// +---------------------------------------------+
// | Copyright 2008 - 2018 weenBizz |
// | http://www.weentech.com |
// | This file may not be redistributed. |
// +---------------------------------------------+
error_reporting(E_ALL & ~E_NOTICE);
$rootpath = '../';
// ############################## INCLUDE VERSION ##############################
include($rootpath . 'install/version.php');
$default_server = "http://". $_SERVER['HTTP_HOST'] . str_replace("/install/index.php","",$_SERVER['SCRIPT_NAME']) . "/";
// ############################## HEADER AND FOOTER ############################
echo '<html>
<head>
<title>weenBizz闻名在线客服系统-安装程序</title>
<link rel="stylesheet" href="./styles.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<table width="480" cellpadding="0" cellspacing="1" border="0" align="center" class="box">
<tr>
<td class="title">weenBizz闻名在线客服系统 '.$weenbizzversion.' 安装程序</td>
</tr>
<tr>
<td valign="top" style="padding: 5px;"><br />';
// store the footer in a var since it will be used in different parts of this file
$footer = ' </td>
</tr>
</table>
</body>
</html>';
// ################# CHECK IF WEENBIZZ IS ALREADY INSTALLED ##################
@include($rootpath . 'includes/config.php');
if(defined('WEENBIZZINSTALLED'))
{
echo '<font class=ohred><b>weenBizz闻名在线客服系统已经安装!</b></font><br />
weenBizz闻名在线客服系统已经安装,如果您希望删除原数据并重新安装,请先清除config.php文件的内容。
<BR>(' . $default_server . 'includes/config.php)<BR><BR>';
echo $footer;
exit();
}
// #################### CHECK CONFIG EXISTS AND IS WRITABLE ####################
if(!file_exists($rootpath . 'includes/config.php'))
{
echo '<font class=ohred><b>config.php文件不存在!</b></font><br/>
config.php文件不存在! 请用记事本编辑一个空文件并上传到includes目录。<br /><br />
Unix或Linux服务器系统下,需要先将config.php文件属性设置为766。<br />
为了安全起见,安装完成后需将config.php文件属性设置为644。<br /><br />';
echo $footer;
exit();
}
else if(!is_writable($rootpath . 'includes/config.php'))
{
@chmod($rootpath . "includes/config.php", 0776);
if(!is_writable($rootpath . 'includes/config.php'))
{
echo '<font class=ohred><b>config.php文件不可写!</b></font><br />
config.php文件不可写! Unix或Linux服务器系统下,需要先将config.php文件属性设置为766。<br /><br />
为了安全起见,安装完成后需将config.php文件属性设置为644。<br /><br />';
}
echo $footer;
exit();
}
else
{
// Also try and actually open the file in case we are running on Windows
// as they user may not have access to the file
if(!$fp = @fopen($rootpath . 'includes/config.php', "w"))
{
echo '<font class=ohred><b>config.php文件不可写!</b></font><br />
config.php文件不可写! 需要先将config.php文件属性设置为可写。<br /><br />
为了安全起见,安装完成后需将config.php文件属性设置为不可写。<br /><br />';
echo $footer;
exit();
}
}
// ############################### GET POST VARS ###############################
$servername = isset($_POST['install']) ? $_POST['servername'] : 'localhost';
$dbname = isset($_POST['install']) ? $_POST['dbname'] : '';
$dbusername = isset($_POST['install']) ? $_POST['dbusername'] : '';
$dbpassword = isset($_POST['install']) ? $_POST['dbpassword'] : '';
$tableprefix = isset($_POST['install']) ? $_POST['tableprefix'] : 'bizz_';
$username = isset($_POST['install']) ? $_POST['username'] : '';
$password = isset($_POST['install']) ? $_POST['password'] : '';
$confirmpassword = isset($_POST['install']) ? $_POST['confirmpassword'] : '';
if(substr($tableprefix, -1) <> '_'){$tableprefix .= '_';}
// ############################ INSTALL WEENBIZZ #############################
if(isset($_POST['install']))
{
// check for errors
if(strlen($username) == 0)
$installerrors[] = '请输入系统管理用户名.';
if(strlen($password) == 0)
$installerrors[] = '请输入系统管理密码.';
if($password != $confirmpassword)
$installerrors[] = '管理密码与确认密码不匹配.';
// Determine if MySql is installed
if(function_exists('mysql_connect'))
{
// attempt to connect to the database
if($connection = @MYSQL_CONNECT($servername, $dbusername, $dbpassword))
{
$sqlversion = @mysql_get_server_info();
if(empty($sqlversion)){$sqlversion='5.0';}
if($sqlversion >= '4.1'){
mysql_query("set names 'utf8'");
mysql_query("SET COLLATION_CONNECTION='utf8_general_ci'");
mysql_query("ALTER DATABASE $dbname DEFAULT CHARACTER SET utf8 COLLATE 'utf8_general_ci'");
}
if($sqlversion >= '5.0') {
mysql_query("SET sql_mode=''");
}
// connected, now lets select the database
if(!@MYSQL_SELECT_DB($dbname, $connection))
{
// The database does not exist... try to create it:
if(!@DB_Query("CREATE DATABASE $dbname"))
{
$installerrors[] = '创建数据库 "' . $dbname . '" 失败! 您的用户名可能没有创建数据库的权限.<br />' . mysql_error();
}
else
{
if($sqlversion >= '4.1'){
mysql_query("set names 'utf8'");
mysql_query("SET COLLATION_CONNECTION='utf8_general_ci'");
mysql_query("ALTER DATABASE $dbname DEFAULT CHARACTER SET utf8 COLLATE 'utf8_general_ci'");
}
if($sqlversion >= '5.0') {
mysql_query("SET sql_mode=''");
}
// Success! Database created
MYSQL_SELECT_DB($dbname, $connection);
}
}
}
else
{
// could not connect
$installerrors[] = '无法连接MySql数据库服务器, 信息:<br />' . mysql_error();
}
}
else
{
// mysql extensions not installed
$installerrors[] = '网站服务器环境不支持MySql扩展.';
}
if(!isset($installerrors))
{
define('TABLE_PREFIX', $tableprefix);
// Drop weenBizz tables for fresh install
DB_Query("DROP TABLE IF EXISTS " . TABLE_PREFIX . "lines");
DB_Query("DROP TABLE IF EXISTS " . TABLE_PREFIX . "online");
DB_Query("DROP TABLE IF EXISTS " . TABLE_PREFIX . "mainsettings");
DB_Query("DROP TABLE IF EXISTS " . TABLE_PREFIX . "sessions");
DB_Query("DROP TABLE IF EXISTS " . TABLE_PREFIX . "users");
DB_Query("DROP TABLE IF EXISTS " . TABLE_PREFIX . "usergroups");
DB_Query ("CREATE TABLE " . TABLE_PREFIX . "online (
usr_id integer NOT NULL,
usr_name varchar(64) NOT NULL,
usr_ip varchar(15) NOT NULL,
rtime integer NOT NULL,
isbaned tinyint(1) NOT NULL,
iskickouted tinyint(1) NOT NULL,
isserviceman tinyint(1) NOT NULL,
serviceman_id integer NOT NULL
) TYPE=HEAP MAX_ROWS=15000;" );
DB_Query ("CREATE TABLE " . TABLE_PREFIX . "lines (
line_id integer NOT NULL,
from_id integer NOT NULL,
from_name varchar(64) NOT NULL,
line_stamp integer NOT NULL,
line_txt varchar(255) NOT NULL,
line_biu varchar(3) NOT NULL,
line_clr varchar(32) NOT NULL,
to_id integer UNSIGNED NOT NULL,
to_name varchar(64) NOT NULL
) TYPE=HEAP MA