📄 install.php
字号:
<?php
function remove_remarks( $sql )
{
$i = 0;
while ( $i < strlen( $sql ) )
{
if ( $sql[$i] == "#" && ( $i == 0 || $sql[$i - 1] == "\n" ) )
{
$j = 1;
while ( $sql[$i + $j] != "\n" )
{
$j++;
if ( strlen( $sql ) < $j + $i )
{
break;
}
}
$sql = substr( $sql, 0, $i ).substr( $sql, $i + $j );
}
$i++;
}
return $sql;
}
function split_sql_file( $sql, $delimiter )
{
$sql = trim( $sql );
$char = "";
$last_char = "";
$ret = array( );
$string_start = "";
$in_string = FALSE;
$escaped_backslash = FALSE;
$i = 0;
for ( ; $i < strlen( $sql ); ++$i )
{
$char = $sql[$i];
if ( $char == $delimiter && !$in_string )
{
$ret[] = substr( $sql, 0, $i );
$sql = substr( $sql, $i + 1 );
$i = 0;
$last_char = "";
}
if ( $in_string )
{
if ( $char == "\\" )
{
if ( $last_char != "\\" )
{
$escaped_backslash = FALSE;
}
else
{
$escaped_backslash = !$escaped_backslash;
}
}
if ( $char == $string_start && ( $char == "`" || !( $last_char == "\\" && !$escaped_backslash ) ) )
{
$in_string = FALSE;
$string_start = "";
}
}
else if ( $char == "\"" || $char == "'" || $char == "`" )
{
$in_string = TRUE;
$string_start = $char;
}
$last_char = $char;
}
if ( !empty( $sql ) )
{
$ret[] = $sql;
}
return $ret;
}
function seld( $t, $v )
{
if ( $t == $v )
{
return " selected ";
}
else
{
return " ";
}
}
require_once( "nusoap/nusoap.php" );
$step = 2;
if ( $_POST['command'] == "gonext" )
{
if ( $_POST['nextstep'] == 0 )
{
$donext = true;
}
if ( $_POST['nextstep'] == 1 )
{
if ( !file_exists( "../license.php" ) )
{
$c_params = array(
"username" => $_POST['username'],
"useremail" => $_POST['useremail'],
"domain" => $_SERVER['HTTP_HOST']
);
$ans = $customer->call( "Check_user", $c_params );
if ( $ans == false )
{
$error_msg = "<font style=\"font-size: 14px; color: red;\">您的网站无法连接到注册服务器,请检查是否已连接网络,或稍侯再试!</font>";
$noinstall = "<script>document.all['subm'].disabled = true;</script>";
$donext = false;
}
else if ( 1 < strlen( $ans ) )
{
$error_msg = "<font color=red style='font-size: 14px; font-weight:normal;'>".$ans."</font>";
$donext = false;
}
else
{
$regtime = time( );
$userbirthday = mktime( 12, 12, 12, $_POST['month'], $_POST['day'], $_POST['year'] );
$r_params = array(
"username" => $_POST['username'],
"password" => $_POST['password'],
"usercompany" => $_POST['usercompany'],
"name" => $_POST['name'],
"domain" => $_SERVER['HTTP_HOST'],
"useremail" => $_POST['useremail'],
"usersex" => $_POST['usersex'],
"userwebsite" => $_POST['userwebsite'],
"userqq" => $_POST['userqq'],
"usermsn" => "mediproeshool",
"regtime" => $regtime,
"userbirthday" => $userbirthday,
"ipaddress" => $_SERVER['REMOTE_ADDR']
);
$lic = $customer->call( "Register_user", $r_params );
$fk = fopen( "../license.php", "w" );
fwrite( $fk, $lic, 2000 );
fclose( $fk );
@chmod( "../license.php", 438 );
$donext = true;
}
}
else
{
$donext = true;
}
}
if ( $_POST['nextstep'] == 2 )
{
$donext = true;
}
if ( $_POST['nextstep'] == 3 )
{
$connect = @mysql_connect( $_POST['dbhost'], $_POST['dbuser'], $_POST['dbpwd'] );
$dbhost = $_POST['dbhost'];
$dbuser = $_POST['dbuser'];
$dbpwd = $_POST['dbpwd'];
$dbname = $_POST['dbname'];
$language = $_POST['language'];
$sLan = substr( $language, 0, 5 );
$dbcharset = substr( $language, 6 );
if ( $dbcharset == "utf8" )
{
$charset = "utf-8";
}
else
{
$charset = $dbcharset;
}
if ( !$connect )
{
$error_msg = "<font color=red style='font-size: 14px; font-weight:normal;'>数据库服务器连接失败。请检查输入信息是否正确!</font>";
$donext = false;
}
else
{
$caninstall = 1;
$mysqlvision = substr( mysql_get_server_info( ), 0, 4 );
if ( $mysqlvision < 3.23 )
{
$error_msg = "<font color=red style='font-size: 14px; font-weight:normal;'>Mysql数据库版本不可低于3.23</font>";
$donext = false;
$caninstall = 0;
}
if ( 4.1 <= $mysqlvision )
{
mysql_query( "SET character_set_connection={$dbcharset}, character_set_results={$dbcharset}, character_set_client={$dbcharset}" );
}
$table_num = 0;
$dbname = $_POST['dbname'];
if ( $mysqlvision < 4.1 )
{
$sql_file = "./db/db_".$language.".mysql3x.sql";
}
else
{
$sql_file = "./db/db_".$language.".sql";
}
$view_bookmark = 0;
if ( file_exists( $sql_file ) )
{
$sql_query = fread( fopen( $sql_file, "r" ), filesize( $sql_file ) );
if ( get_magic_quotes_runtime( ) == 1 )
{
$sql_query = stripslashes( $sql_query );
}
}
else
{
$error_msg = "<font color=red style='font-size: 14px; font-weight:normal;'>数据库导入文件".$sql_file."不存在</font>";
$donext = false;
$caninstall = 0;
}
if ( $caninstall == "1" )
{
$sql_query = trim( $sql_query );
if ( $sql_query != "" )
{
$sql_query = remove_remarks( $sql_query );
$pieces = split_sql_file( $sql_query, ";" );
$pieces_count = count( $pieces );
if ( mysql_select_db( $dbname, $connect ) )
{
$i = 0;
for ( ; $i < $pieces_count; $i++ )
{
$a_sql_query = trim( $pieces[$i] );
if ( !empty( $a_sql_query ) && $a_sql_query[0] != "#" )
{
$result = mysql_query( $a_sql_query );
if ( $result == FALSE )
{
$error_msg = "<font color=red style='font-size: 14px; font-weight:normal;'>数据库导入失败!</font>";
$donext = false;
}
}
}
}
else
{
$error_msg = "<font color=red style='font-size: 14px; font-weight:normal;'>不可使用数据库,请检查数据库是否存在、用户是否有权访问该数据库!</font>";
$donext = false;
$caninstall = 0;
}
}
if ( $caninstall == "1" )
{
$result = mysql_list_tables( $dbname, $connect );
$i = 0;
while ( $i < mysql_num_rows( $result ) )
{
$tb_names[$i] = mysql_tablename( $result, $i );
$table_name .= "导入数据表 ".$tb_names[$i]." .........OK<BR>";
$i++;
}
$table_num = $i;
$ConFile = "../config.inc.php";
$SysConfigFile = "./inc.php";
$siteurl = "http://".$_SERVER['HTTP_HOST']."/";
$filestr = fread( fopen( $SysConfigFile, "r" ), 30000 );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -