Commit 1ad57f2c authored by Nemo Ma's avatar Nemo Ma Committed by GitHub

Merge pull request #1 from nahakyuu/docker_support

Docker support &  version compare bug
parents fa038d00 13321579
FROM php:5.4-fpm
RUN docker-php-ext-install mysqli && docker-php-ext-install mbstring
COPY ./ /mnt/dts
RUN chmod -R 777 /mnt/dts
COPY ./nginx /nginx
......@@ -6,7 +6,7 @@ define('IN_GAME', TRUE);
define('GAME_ROOT', dirname(__FILE__));
define('GAMENAME', 'bra');
if(PHP_VERSION < '4.3.0') {
if(version_compare(PHP_VERSION, '4.3.0', '<')) {
exit('PHP version must >= 4.3.0!');
}
require GAME_ROOT.'/include/global.func.php';
......
<?php
//以下内容在游戏安装时初始化,不能通过游戏后台修改
//以下内容在游戏安装时初始化,不能通过游戏后台修改
// [EN] Set below parameters according to your account information provided by your hosting
// [CH] 以下变量请根据空间商提供的账号参数修?如有疑问,请联系服务器提供?
// [CH] 以下变量请根据空间商提供的账号参数修?如有疑问,请联系服务器提供?
$dbhost = '127.0.0.1'; // database server
// 数据库服务器
$dbhost = 'db'; // database server
// 数据库服务器
$dbuser = 'root'; // database username
// 数据库用户名
// 数据库用户名
$dbpw = 'mylittlepony'; // database password
// 数据库密?
// 数据库密?
$dbname = 'acdts3'; // database name
// 数据库名
// 数据库名
$dbreport = 1; // send db error report? 1=yes
// 是否发送数据库错误报告? 0=? 1=?
// 是否发送数据库错误报告? 0=? 1=?
// [EN] If you have problems logging in Discuz!, then modify the following parameters, else please leave default
// [CH] 如您?cookie 作用范围有特殊要?或游戏登录不正常,请修改下面变?否则请保持默?
// [CH] 如您?cookie 作用范围有特殊要?或游戏登录不正常,请修改下面变?否则请保持默?
$cookiedomain = ''; // cookie domain
// cookie 作用?
// cookie 作用?
$cookiepath = '/'; // cookie path
// cookie 作用路径
// cookie 作用路径
// [EN] Special parameters, DO NOT modify these unless you are an expert in Discuz!
// [CH] 以下变量为特别选项,一般情况下没有必要修改
// [CH] 以下变量为特别选项,一般情况下没有必要修改
$headercharset = 0; // force outputing charset header
// 强制设置字符?只乱码时使用
// 强制设置字符?只乱码时使用
$onlinehold = 900; // time span of online recording
// 在线保持时间,单位?
// 在线保持时间,单位?
$pconnect = true; // persistent database connection, 0=off, 1=on
// 数据库持久连?false=关闭, true=打开
// 数据库持久连?false=关闭, true=打开
$gamefounder = 'Amarillo_NMC'; // super administrator's UID
// 游戏创始?UID, 可以支持多个创始人,之间使用 ??分隔?
// 如果不设置游戏创始人,则管理员之间可以相互编辑,具体权力差别请见游戏使用文档
// 游戏创始?UID, 可以支持多个创始人,之间使用 ??分隔?
// 如果不设置游戏创始人,则管理员之间可以相互编辑,具体权力差别请见游戏使用文档
$postinterval = 1; //用户提交命令的间隔时间,单位?
$postinterval = 1; //用户提交命令的间隔时间,单位?
$moveut = 8; //set the difference of server time and client time
//如果本地时间跟服务器时间有时差,在此处更?
//如果本地时间跟服务器时间有时差,在此处更?
$moveutmin = 0; //set the difference of server time and client time, by minutes
//如果本地时间跟服务器时间有时差,在此处更?
//如果本地时间跟服务器时间有时差,在此处更?
// [EN] !ATTENTION! Do NOT modify following after your board was settle down
// [CH] 游戏投入使用后不能修改的变量
// [CH] 游戏投入使用后不能修改的变量
$tablepre = 'acbra3_'; // 表名前缀, 同一数据库安装多个游戏请修改此处
$tablepre = 'acbra3_'; // 表名前缀, 同一数据库安装多个游戏请修改此处
// table prefix, modify this when you are installingmore than 1 Discuz! in the same database.
$authkey = 'bra'; //game encrypt key ,the same of plus key
//游戏加密密钥,要与插件密钥相?
//游戏加密密钥,要与插件密钥相?
// [EN] !ATTENTION! Preservation or debugging for developing
// [CH] 切勿修改以下变量,仅供程序开发调试用!
// [CH] 切勿修改以下变量,仅供程序开发调试用!
$database = 'mysql'; // 'mysql' for MySQL version and 'pgsql' for PostgreSQL version
// MySQL 版本请设?'mysql', PgSQL 版本请设?'pgsql'
$database = 'mysqli'; // 'mysql' for MySQL version and 'pgsql' for PostgreSQL version
// MySQL 版本请设?'mysql', PgSQL 版本请设?'pgsql'
$charset = 'utf-8'; // default character set, 'gbk', 'big5', 'utf-8' are available
// 游戏默认字符? 可?'gbk', 'big5', 'utf-8'
// 游戏默认字符? 可?'gbk', 'big5', 'utf-8'
$dbcharset = 'utf8'; // default database character set, 'gbk', 'big5', 'utf8', 'latin1' and blank are available
// MySQL 字符? 可?'gbk', 'big5', 'utf8', 'latin1', 留空为按照游戏字符集设定
// MySQL 字符? 可?'gbk', 'big5', 'utf8', 'latin1', 留空为按照游戏字符集设定
$attackevasive = 0; // protect against attacks via common request, 0=off, 1=cookie refresh limitation, 2=deny proxy request, 3=both
// 防护大量正常请求造成的拒绝服务攻? 0=关闭, 1=cookie 刷新限制, 2=限制代理访问, 3=cookie+代理限制
// 防护大量正常请求造成的拒绝服务攻? 0=关闭, 1=cookie 刷新限制, 2=限制代理访问, 3=cookie+代理限制
$tplrefresh = 1; // auto check validation of templates, 0=off, 1=on
// 模板自动刷新开?0=关闭, 1=打开, 在不修改页面的情况下可以关闭
// 模板自动刷新开?0=关闭, 1=打开, 在不修改页面的情况下可以关闭
$bbsurl = 'http://76573.org/'; //the bbs url for the game plus
//安装游戏插件的论坛地址
//安装游戏插件的论坛地址
$gameurl = 'http://dts.moe/'; // the url of game program files,for the full-window mode
//游戏程序地址,用于全屏模?
$gameurl = 'http://localhost:8080/'; // the url of game program files,for the full-window mode
//游戏程序地址,用于全屏模?
$homepage = 'http://www.amarilloviridian.com/'; // game homepage
//官方网站地址
//官方网站地址
$title = '大 逃 杀'; //game title
//游戏标题
$title = '大 逃 杀'; //game title
//游戏标题
$errorinfo = 0; //是否开启错误信息提示,1为开启,0为关闭。开启会泄漏游戏安装路径
$errorinfo = 0; //是否开启错误信息提示,1为开启,0为关闭。开启会泄漏游戏安装路径
// ============================================================================
......
......@@ -6,7 +6,7 @@ define('IN_GAME', TRUE);
define('GAME_ROOT', dirname(__FILE__));
define('GAMENAME', 'bra');
if(PHP_VERSION < '4.3.0') {
if(version_compare(PHP_VERSION, '4.3.0', '<')) {
exit('PHP version must >= 4.3.0!');
}
require GAME_ROOT.'./include/global.func.php';
......
version: "3"
services:
dts:
build: ./
volumes:
- dts:/mnt/dts
- nginx_conf:/nginx/conf.d
web:
image: nginx:1.19.2
ports:
- "8080:80"
depends_on:
- dts
volumes:
- dts:/mnt/dts
- nginx_conf:/etc/nginx/conf.d
db:
image: mariadb:10
environment:
MYSQL_ROOT_PASSWORD: "mylittlepony"
MYSQL_DATABASE: "acdts3"
volumes:
- db:/var/lib/mysql
volumes:
db:
dts:
nginx_conf:
<?php
<?php
/*Game resources*/
......
......@@ -13,7 +13,7 @@ CREATE TABLE bra_chat (
msg char(60) NOT NULL default '',
PRIMARY KEY (cid)
) TYPE=MyISAM;
) ENGINE=MyISAM;
......@@ -103,7 +103,7 @@ CREATE TABLE bra_players (
PRIMARY KEY (pid),
INDEX TYPE (type, sNo),
INDEX NAME (name, type)
) TYPE=MyISAM;
) ENGINE=MyISAM;
......@@ -22,7 +22,7 @@ CREATE TABLE bra_users (
PRIMARY KEY (uid),
UNIQUE KEY username (username)
) TYPE=MyISAM;
) ENGINE=MyISAM;
--
-- 插入初始数据 `bra_users`
......@@ -142,7 +142,7 @@ CREATE TABLE bra_winners (
hkp char(15) NOT NULL default '',
UNIQUE KEY (gid)
) TYPE=MyISAM;
) ENGINE=MyISAM;
--
......@@ -250,7 +250,7 @@ CREATE TABLE bra_players (
PRIMARY KEY (pid),
INDEX TYPE (type, sNo),
INDEX NAME (name, type)
) TYPE=MyISAM;
) ENGINE=MyISAM;
......@@ -269,7 +269,7 @@ CREATE TABLE bra_chat (
msg char(60) NOT NULL default '',
PRIMARY KEY (cid)
) TYPE=MyISAM;
) ENGINE=MyISAM;
......@@ -6,7 +6,7 @@ define('IN_GAME', TRUE);
define('GAME_ROOT', substr(dirname(__FILE__), 0, -7));
define('GAMENAME', 'bra');
if(PHP_VERSION < '4.3.0') {
if(version_compare(PHP_VERSION, '4.3.0', '<')) {
exit('PHP version must >= 4.3.0!');
}
require GAME_ROOT.'./include/global.func.php';
......
......@@ -22,7 +22,7 @@ class dbstuff {
}
}
if ($this->version () > '4.1') {
if(version_compare($this->version (), '4.1', '>')) {
global $charset, $dbcharset;
if (! $dbcharset && in_array ( strtolower ( $charset ), array ('gbk', 'big5', 'utf-8' ) )) {
$dbcharset = str_replace ( '-', '', $charset );
......@@ -32,7 +32,7 @@ class dbstuff {
mysql_query ( "SET character_set_connection=$dbcharset, character_set_results=$dbcharset, character_set_client=$dbcharset" );
}
if ($this->version () > '5.0.1') {
if(version_compare($this->version (), '5.0.1', '>')) {
mysql_query ( "SET sql_mode=''" );
}
}
......
<?php
if (! defined ( 'IN_GAME' )) { exit ( 'Access Denied' ); }
class dbstuff {
private $con = NULL;
public $query_log = array();
function connect($dbhost, $dbuser, $dbpw, $dbname = '', $pconnect = 0) {
if(!function_exists('mysqli_connect')) exit('未安装mysqli扩展!');
$this -> con = mysqli_connect ( $dbhost, $dbuser, $dbpw, $dbname );
if (mysqli_connect_errno())
$this->halt ( mysqli_connect_errno().': Can not connect to MySQL server' );
global $charset, $dbcharset;
if (! $dbcharset && in_array ( strtolower ( $charset ), array ('gbk', 'big5', 'utf-8' ) )) {
$dbcharset = str_replace ( '-', '', $charset );
}
if ($dbcharset) {
mysqli_query ( $this->con, "SET character_set_connection=$dbcharset, character_set_results=$dbcharset, character_set_client=$dbcharset" );
}
mysqli_query ( $this->con, "SET sql_mode=''" );
if (mysqli_connect_errno())
$this->halt (mysqli_connect_errno().': Can not connect to MySQL server' );
}
function select_db($dbname) {
return mysqli_select_db ( $this->con, $dbname );
}
function fetch_array($query, $result_type = MYSQLI_ASSOC) {
return mysqli_fetch_array ( $query, $result_type );
}
function query($sql, $type = '') {
//mysqli不存在unbuffered指令,游戏也从来没用到过这个参数
//$func = $type == 'UNBUFFERED' && function_exists ( 'mysqli_unbuffered_query' ) ? 'mysqli_unbuffered_query' : 'mysqli_query';
if(!empty(debug_backtrace()[0]['file'])) $this->query_log[] = $sql . ' from ' .debug_backtrace()[0]['file'].' : '.debug_backtrace()[0]['line'];
else $this->query_log[] = $sql;
$result = mysqli_query ( $this -> con, $sql );
if (! $result && $type != 'SILENT') {
$this->halt ( 'MySQL Query Error', $sql );
}
if(strpos($sql,'UPDATE')===0){
if(strpos($sql, 'users') !==false && strpos($sql, 'room') !==false) {
$bk = debug_backtrace();
global $now;
//writeover('tmp_roomid_log_2.txt', $sql.' from line '.$bk[1]['line']." at file ".$bk[1]['file'].' at '.$now."\r\n",'ab+');
}
}
//if(strpos($sql, 'acbra2_users')!==false && strpos($sql, 'UPDATE')!==false && strpos($sql, 'roomid')!==false) writeover('a.txt', substr($sql,0,30).'...'.substr($sql,strlen($sql)-30).' <--- '.debug_backtrace()[0]['file'].' : '.debug_backtrace()[0]['line']."\r\n",'ab+');
// $this->querynum ++;
// if(strpos($sql,'SELECT')===0){$this->selectnum ++;}
// elseif(strpos($sql,'INSERT')===0){$this->insertnum ++;}
// elseif(strpos($sql,'UPDATE')===0){$this->updatenum ++;}
// elseif(strpos($sql,'DELETE')===0){$this->deletenum ++;}
// if(strpos($sql,'UPDATE')===0){
// ob_start();
// var_dump(debug_backtrace());
// $a = ob_get_contents();
// ob_end_clean();
// file_put_contents('a.txt',$a."\r\n",FILE_APPEND);
// }
return $result;
}
function queries ($queries, $ignore_result = true) {
// foreach (preg_split ("/[;]+/", trim($queries)) as $query_split) {
// $query = '';
// foreach (preg_split ("/[\n]+/", trim($query_split)) as $query_row){
// if (!empty($query_row) && substr($query_row,0,2) != '--' && substr($query_row,0,1) != '#') {
// $query .= $query_row;
// }
// }
// if(substr($query, 0, 12) == 'CREATE TABLE') {
// $this->query($this->create_table($query));
// } elseif (!empty($query)) {
// $this->query($query);
// }
// }
mysqli_multi_query($this->con,$this->parse_create_table($queries));
while ($ignore_result && $this->more_results()) {
if ($this->next_result() === false) {
$this->halt ( 'Some error uccurred in multi_querying.' );
break;
}
}
$result = $this->store_result();
return $result;
}
function parse_create_table($sql) {//修改了替换逻辑,不会有什么区别的
global $dbcharset;
if(!$dbcharset) include GAME_ROOT.'./include/modules/core/sys/config/server.config.php';
$sql = preg_replace("/ENGINE\s*=\s*([a-z]+)/i", "ENGINE=$1 DEFAULT CHARSET=".$dbcharset, $sql);
return $sql;
// $type = strtoupper(preg_replace("/\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*;/isU", "\\2", $sql));
// $type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
// return preg_replace("/\s*(CREATE TABLE\s+.+\s+\(.+?\)).*;$/isU", "\\1", $sql)." ENGINE=$type DEFAULT CHARSET=$dbcharset;";
}
//根据$data的键和键值插入数据。多数据插入是直接按字段先后顺序排的,请保证输入数据字段顺序完全一致!
function array_insert($dbname, $data, $on_duplicate_update = 0, $keycol=''){
$tp = 1;//单记录插入
if(is_array(array_values($data)[0])) $tp = 2;//多记录插入
$query = "INSERT INTO {$dbname} ";
$fieldlist = $valuelist = '';
if(2!=$tp){//单记录插入
if(!$data) return;
foreach ($data as $key => $value) {
$fieldlist .= "{$key},";
$valuelist .= "'{$value}',";
}
if(!empty($fieldlist) && !empty($valuelist)){
$query .= '(' . substr($fieldlist, 0, -1) . ') VALUES (' . substr($valuelist, 0, -1) .')';
}
}else{//多记录插入
foreach (array_keys(array_values($data)[0]) as $key) {
$fieldlist .= "{$key},";
}
foreach ($data as $dv){
if(!$dv) continue;
$valuelist .= "(";
foreach ($dv as $value) {
$valuelist .= "'{$value}',";
}
$valuelist = substr($valuelist, 0, -1).'),';
}
if(!empty($valuelist)) {
$query .= '(' . substr($fieldlist, 0, -1) . ') VALUES '.substr($valuelist, 0, -1);
}
}
if(!empty($query) && $on_duplicate_update && $keycol) {
$query .= ' ON DUPLICATE KEY UPDATE ';
$tmp = 2==$tp ? reset($data) : $data;
foreach($tmp as $key => $value){
if($key !== $keycol){
$query .= '`'.$key.'`=VALUES(`'.$key.'`),';
}
}
$query = substr($query, 0, -1);
}
if(!empty($query)) {
$querystrlen = mb_strlen($query);
if(2==$tp && sizeof($data) > 1 && $querystrlen > 1073000000) {
//如果长度超过1M,从中断成两个数组再尝试
//留一点冗余所以不是1073741824
list($data1, $data2) = $this->arr_query_divide($data);
$this->array_insert($dbname, $data1, $on_duplicate_update, $keycol);
$this->array_insert($dbname, $data2, $on_duplicate_update, $keycol);
}else{
$this->query ($query);
}
}
return $query;
}
function arr_query_divide($data)
{
if(sizeof($data) <= 1) return $data;
$offset = (int)floor(sizeof($data)/2);
return array(array_slice($data, 0, $offset), array_slice($data, $offset));
}
function array_update($dbname, $data, $where, $o_data=NULL){ //根据$data的键和键值更新数据
$query = '';
foreach ($data as $key => $value) {
if(!is_array($o_data) || !isset($o_data[$key]) || $value !== $o_data[$key])
$query .= "{$key} = '{$value}',";
}
if(!empty($query)){
$query = "UPDATE {$dbname} SET ".substr($query, 0, -1) . " WHERE {$where}";
$this->query ($query);
}
return $query;
}
function multi_update($dbname, $data, $confield, $singleqry = ''){
$fields = $range = Array();
foreach($data as $rval){
$con = $rval[$confield];
$range[] = "'$con'";
foreach($rval as $fkey => $fval){
if($fkey != $confield){
if(isset(${$fkey.'qry'})){
${$fkey.'qry'} .= "WHEN '$con' THEN '$fval' ";
}else{
$fields[] = $fkey;
${$fkey.'qry'} = "(CASE $confield WHEN '$con' THEN '$fval' ";
}
}
}
}
$query = '';
foreach($fields as $val){
if(!empty(${$val.'qry'})){
${$val.'qry'} .= "END) ";
$query .= "$val = ${$val.'qry'},";
}
}
if(!empty($query)) {
if($singleqry){$singleqry = ','.$singleqry;}
$query = "UPDATE {$dbname} SET ".substr($query,0,-1)."$singleqry WHERE $confield IN (".implode(',',$range).")";
$querystrlen = mb_strlen($query);
if(sizeof($data) > 1 && $querystrlen > 1073000000) {
//如果长度超过1M,从中断成两个数组再尝试
list($data1, $data2) = $this->arr_query_divide($data);
$this->multi_update($dbname, $data1, $confield, $singleqry);
$this->multi_update($dbname, $data2, $confield, $singleqry);
}else{
$this->query ($query);
}
}
return $query;
}
function affected_rows() {
return mysqli_affected_rows ($this -> con);
}
function error() {
return mysqli_error ($this -> con);
}
function errno() {
return intval ( mysqli_errno ($this -> con) );
}
function result($query, $row) {
mysqli_data_seek($query, $row);
return mysqli_fetch_array ( $query, MYSQLI_NUM )[0];
}
function data_seek($query, $row) {
return mysqli_data_seek ( $query, $row );
}
function num_rows($query) {
$query = mysqli_num_rows ( $query );
return $query;
}
function num_fields($query) {
return mysqli_num_fields ( $query );
}
function next_result(){
return mysqli_next_result ( $this->con );
}
function more_results() {
return mysqli_more_results ( $this->con );
}
function store_result() {
return mysqli_store_result ( $this->con );
}
function free_result($query) {
return mysqli_free_result ( $query );
}
function insert_id() {
$id = mysqli_insert_id ($this -> con);
return $id;
}
function fetch_row($query) {
$query = mysqli_fetch_row ( $query );
return $query;
}
function fetch_fields($query) {
return mysqli_fetch_field ( $query );
}
function version() {
return mysqli_get_server_info ($this->con);
}
function close() {
return mysqli_close ($this->con);
}
function halt($message = '', $sql = '') {
header('Content-Type: text/HTML; charset=utf-8');
echo '数据库错误。请联系管理员。<br><br>';
echo '类错误信息:'.$message.'<br>';
if(!empty($sql)) echo 'SQL语句:'.$sql;
echo '<br><br>';
$dberror = $this->errno().' '.$this->error();
echo '数据库错误提示:'.$dberror.'<br><br>';
//echo '以下是stack dump<br>';
//var_export(debug_backtrace());
die();
require_once GAME_ROOT . './include/db/db_mysqli_error.inc.php';
}
function __destruct() {
$this->close();
//file_put_contents(GAME_ROOT.'/query_log.txt', implode("\r\n",$this->query_log)."\r\n\r\n", FILE_APPEND);
}
}
/* End of file db_mysqli.class.php */
/* Location: /include/db/db_mysqli.class.php */
<?
if(!defined('IN_GAME')) {
exit('Access Denied');
}
$timestamp = time();
$errmsg = '';
$dberror = $this->error();
$dberrno = $this->errno();
if($dberrno == 1114) {
?>
<html>
<head>
<title>Max Onlines Reached</title>
</head>
<body bgcolor="#FFFFFF">
<table cellpadding="0" cellspacing="0" border="0" width="600" align="center" height="85%">
<tr align="center" valign="middle">
<td>
<table cellpadding="10" cellspacing="0" border="0" width="80%" align="center" style="font-family: Verdana, Tahoma; color: #666666; font-size: 9px">
<tr>
<td valign="middle" align="center" bgcolor="#EBEBEB">
<br><b style="font-size: 10px">Forum onlines reached the upper limit</b>
<br><br><br>Sorry, the number of online visitors has reached the upper limit.
<br>Please wait for someone else going offline or visit us in idle hours.
<br><br>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?
function_exists('dexit') ? dexit() : exit();
} else {
if($message) {
$errmsg = "<b>BRA info</b>: $message\n\n";
}
if(isset($GLOBALS['_DSESSION']['bra_user'])) {
$errmsg .= "<b>User</b>: ".htmlspecialchars($GLOBALS['_DSESSION']['bra_user'])."\n";
}
$errmsg .= "<b>Time</b>: ".gmdate("Y-n-j g:ia", $timestamp + ($GLOBALS['timeoffset'] * 3600))."\n";
$errmsg .= "<b>Script</b>: ".$GLOBALS['PHP_SELF']."\n\n";
if($sql) {
$errmsg .= "<b>SQL</b>: ".htmlspecialchars($sql)."\n";
}
$errmsg .= "<b>Error</b>: $dberror\n";
$errmsg .= "<b>Errno.</b>: $dberrno";
echo "</table></table></table></table></table>\n";
echo "<p style=\"font-family: Verdana, Tahoma; font-size: 11px; background: #FFFFFF;\">";
echo nl2br($errmsg);
if($GLOBALS['adminemail']) {
$errlog = array();
if(@$fp = fopen(GAME_ROOT.'./gamedata/dberror.log', 'r')) {
while((!feof($fp)) && count($errlog) < 20) {
$log = explode("\t", fgets($fp, 50));
if($timestamp - $log[0] < 86400) {
$errlog[$log[0]] = $log[1];
}
}
fclose($fp);
}
if(!in_array($dberrno, $errlog)) {
$errlog[$timestamp] = $dberrno;
@$fp = fopen(GAME_ROOT.'./gamedata/dberror.log', 'w');
@flock($fp, 2);
foreach(array_unique($errlog) as $dateline => $errno) {
@fwrite($fp, "$dateline\t$errno");
}
@fclose($fp);
if(function_exists('errorlog')) {
errorlog('MySQL', basename($GLOBALS['_SERVER']['PHP_SELF'])." : $dberror - ".cutstr($sql, 120), 0);
}
if($GLOBALS['dbreport']) {
echo "<br><br>An error report has been dispatched to our administrator.";
@sendmail($GLOBALS['adminemail'], '[bra!] MySQL Error Report',
"There seems to have been a problem with the database of your bra game\n\n".
strip_tags($errmsg)."\n\n".
"Please check-up your MySQL server and forum scripts, similar errors will not be reported again in recent 24 hours\n".
"If you have troubles in solving this problem, please visit loongyou Community http://www.loongyou.com");
}
} else {
echo '<br><br>Similar error report has beed dispatched to administrator before.';
}
}
echo '</p>';
function_exists('gexit') ? gexit() : exit();
}
/* End of file db_mysqli_error.inc.php */
/* Location: /include/db/db_mysqli_error.inc.php */
\ No newline at end of file
......@@ -27,7 +27,7 @@ function getclub($who, &$c1, &$c2, &$c3)
$result = $db->query("SELECT uid FROM {$tablepre}users WHERE username='$who'");
$t=$db->fetch_array($result); $curuid=$t['uid']+2;
$result = $db->query("SELECT pid FROM {$tablepre}players WHERE name='$who' AND type=0");
$t=$db->fetch_array($result); $curpid=$result['pid']+3;
$t=$db->fetch_array($result); $curpid=$t['pid']+3;
$c1=calc(12347,10007,$curgid,$curuid,$curpid,$starttime,$validtime);
$c1%=6; if ($c1==0) $c1=9; //超能称号为9号
......
......@@ -183,7 +183,7 @@ function openfile($filename){
}
function compatible_json_encode($data){ //自动选择使用内置函数或者自定义函数,结合JSON.php可做到兼容低版本PHP
if(PHP_VERSION < '5.2.0'){
if(version_compare(PHP_VERSION, '5.2.0', '<')) {
require_once GAME_ROOT.'./include/JSON.php';
$json = new Services_JSON();
$jdata = $json->encode($data);
......
......@@ -7,7 +7,7 @@ error_reporting(E_ERROR | E_WARNING | E_PARSE);
define('IN_GAME', TRUE);
define('GAME_ROOT', '');
if(PHP_VERSION < '4.3.0') {
if(version_compare(PHP_VERSION, '4.3.0', '<')) {
exit('PHP version must >= 4.3.0!');
}
......@@ -657,7 +657,7 @@ if(!$action) {
$curr_os = PHP_OS;
$curr_php_version = PHP_VERSION;
if($curr_php_version < '4.3.0') {
if(version_compare($curr_php_version, '4.3.0', '<')) {
$msg .= "<font color=\"#FF0000\">$lang[php_version_430]</font>\t";
$quit = TRUE;
}
......@@ -673,7 +673,7 @@ if(!$action) {
$query = $db->query("SELECT VERSION()");
$curr_mysql_version = $db->result($query, 0);
if($curr_mysql_version < '3.23') {
if(version_compare($curr_mysql_version, '3.23', '<')) {
$msg .= "<font color=\"#FF0000\">$lang[mysql_version_323]</font>\t";
$quit = TRUE;
}
......@@ -701,7 +701,7 @@ if(!$action) {
$db->select_db($dbname);
if($db->error()) {
if($db->version() > '4.1') {
if(version_compare($db->version(), '3.23', '<')) {
$db->query("CREATE DATABASE IF NOT EXISTS $dbname DEFAULT CHARACTER SET $dbcharset");
} else {
$db->query("CREATE DATABASE IF NOT EXISTS $dbname");
......@@ -1231,7 +1231,7 @@ function runquery($sql) {
if(substr($query, 0, 12) == 'CREATE TABLE') {
$name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query);
echo $lang['create_table'].' '.$name.' ... <font color="#0000EE">'.$lang['succeed'].'</font><br>';
$db->query(createtable($query, $dbcharset));
$db->query(createtable($db, $query, $dbcharset));
} else {
$db->query($query);
}
......@@ -1299,11 +1299,11 @@ function random($length) {
return $hash;
}
function createtable($sql, $dbcharset) {
function createtable($db, $sql, $dbcharset) {
$type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
$type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql).
(mysql_get_server_info() > '4.1' ? " ENGINE=$type DEFAULT CHARSET=$dbcharset" : " TYPE=$type");
(version_compare($db->version(), '4.1', '>') ? " ENGINE=$type DEFAULT CHARSET=$dbcharset" : " TYPE=$type");
}
function setconfig($string) {
......
......@@ -7,7 +7,7 @@ $now = time();
define('IN_GAME', TRUE);
define('GAME_ROOT', substr(dirname(__FILE__), 0, 0));
define('GAMENAME', 'bra');
if(PHP_VERSION < '4.3.0') {
if(version_compare(PHP_VERSION, '4.3.0', '<')) {
exit('PHP version must >= 4.3.0!');
}
require_once GAME_ROOT.'./include/global.func.php';
......
server {
listen 80;
server_name localhost;
root /mnt/dts;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass dts:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment