Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
phpdts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nemo Ma
phpdts
Commits
ec89e019
Commit
ec89e019
authored
Apr 04, 2023
by
Nemo Ma
Committed by
GitHub
Apr 04, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #111 from hikawiier/waaagh
update roommng
parents
5fec49d0
321b8976
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
64 deletions
+49
-64
gamedata/cache/resources_1.php
gamedata/cache/resources_1.php
+7
-0
include/index.php
include/index.php
+0
-36
include/roommng.func.php
include/roommng.func.php
+18
-17
index.php
index.php
+13
-4
templates/default/index.htm
templates/default/index.htm
+1
-2
templates/default/roomlist.htm
templates/default/roomlist.htm
+10
-5
No files found.
gamedata/cache/resources_1.php
View file @
ec89e019
...
...
@@ -1489,6 +1489,13 @@ $_ERROR = Array(
//'banned_name' => '用户名含有违禁用语,请更改用户名',
//'banned_ip' => '此IP已被封禁,请与管理员联系',
//'long_name' => '用户名过长,请重新输入用户名'
'alreay_in_room'
=>
'你已经在房间里了。要创建/加入房间必须退出当前房间。'
,
'not_in_room'
=>
'你不在任何房间里。'
,
'room_ip_limit'
=>
'相同IP最多只能创建2个房间。请先解散其他房间。'
,
'room_num_limit'
=>
'房间数量已达上限,无法新建房间。'
,
'room_close_limit'
=>
'你没有权限解散该房间,只有房主或管理员可以解散房间。'
,
'room_close_limit2'
=>
'不能解散正在进行游戏,且游戏内尚有幸存者的房间!'
,
);
?>
include/index.php
deleted
100644 → 0
View file @
5fec49d0
<?php
define
(
'CURSCRIPT'
,
'index'
);
require
'./include/common.inc.php'
;
$timing
=
0
;
if
(
$gamestate
>
10
)
{
$timing
=
$now
-
$starttime
;
}
else
{
if
(
$starttime
>
$now
)
{
$timing
=
$starttime
-
$now
;
}
else
{
$timing
=
0
;
}
}
$adminmsg
=
file_get_contents
(
'./gamedata/adminmsg.htm'
)
;
$systemmsg
=
file_get_contents
(
'./gamedata/systemmsg.htm'
)
;
include
template
(
'index'
);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<script
type=
"text/javascript"
>
var
gaJsHost
=
((
"
https:
"
==
document
.
location
.
protocol
)
?
"
https://ssl.
"
:
"
http://www.
"
);
document
.
write
(
unescape
(
"
%3Cscript src='
"
+
gaJsHost
+
"
google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E
"
));
</script>
<script
type=
"text/javascript"
>
try
{
var
pageTracker
=
_gat
.
_getTracker
(
"
UA-9744745-2
"
);
pageTracker
.
_trackPageview
();
}
catch
(
err
)
{}
</script>
</head>
</html>
\ No newline at end of file
include/roommng.func.php
View file @
ec89e019
...
...
@@ -49,11 +49,11 @@ function roommng_verify_db_game_structure()
function
roommng_create_new_room
(
&
$udata
)
{
global
$db
,
$gtablepre
,
$now
;
global
$startmin
,
$max_rooms
,
$ip_max_rooms
;
global
$startmin
,
$max_rooms
,
$ip_max_rooms
,
$rerror
;
if
(
!
empty
(
$udata
[
'roomid'
]))
{
echo
"你已经在房间里了。要创建新房间必须退出当前房间。<br>"
;
$rerror
=
'alreay_in_room'
;
return
;
}
...
...
@@ -61,7 +61,7 @@ function roommng_create_new_room(&$udata)
$ipresult
=
$db
->
query
(
"SELECT roomid FROM
{
$gtablepre
}
users WHERE roomid>0 AND ip='
{
$udata
[
'ip'
]
}
'"
);
if
(
$db
->
num_rows
(
$ipresult
)
>=
$ip_max_rooms
)
{
echo
"相同IP最多只能创建
{
$ip_max_rooms
}
个房间。请先解散其他房间。<br>"
;
$rerror
=
'room_ip_limit'
;
return
;
}
...
...
@@ -70,7 +70,7 @@ function roommng_create_new_room(&$udata)
$now_room_nums
=
$db
->
num_rows
(
$result
);
if
(
$now_room_nums
>=
$max_rooms
)
{
echo
"房间数量已达上限,无法新建房间。<br>"
;
$rerror
=
'room_num_limit'
;
return
;
}
...
...
@@ -88,11 +88,11 @@ function roommng_create_new_room(&$udata)
# 加入一个房间
function
roommng_join_room
(
$rkey
,
&
$udata
)
{
global
$db
,
$gtablepre
;
global
$db
,
$gtablepre
,
$rerror
;
if
(
!
empty
(
$udata
[
'roomid'
]))
{
echo
"你已经在房间里了。要加入房间必须退出当前房间。<br>"
;
$rerror
=
'alreay_in_room'
;
return
;
}
...
...
@@ -117,11 +117,11 @@ function roommng_join_room($rkey,&$udata)
# 离开当前房间
function
roommng_exit_room
(
&
$udata
)
{
global
$db
,
$gtablepre
;
global
$db
,
$gtablepre
,
$rerror
;
if
(
empty
(
$udata
[
'roomid'
]))
{
echo
"你不在任何房间里。<br>"
;
$rerror
=
'not_in_room'
;
return
;
}
...
...
@@ -169,11 +169,11 @@ function roommng_exit_room(&$udata)
# 房主解散自己所在的房间
function
roommng_close_own_room
(
&
$udata
)
{
global
$db
,
$gtablepre
;
global
$db
,
$gtablepre
,
$rerror
;
if
(
empty
(
$udata
[
'roomid'
]))
{
echo
"你不在任何房间里。<br>"
;
$rerror
=
'not_in_room'
;
return
;
}
...
...
@@ -184,13 +184,13 @@ function roommng_close_own_room(&$udata)
# 不能解散没有房主的房间
if
(
empty
(
$gdata
[
'groomownid'
])
||
(
!
empty
(
$gdata
[
'groomownid'
])
&&
$gdata
[
'groomownid'
]
!=
$udata
[
'username'
]))
{
echo
"你没有权限解散房间
{
$udata
[
'roomid'
]
}
<br>"
;
$rerror
=
'room_close_limit'
;
return
;
}
# 不能解散正在游戏中的房间
if
(
$gdata
[
'gamestate'
]
>
10
&&
$gdata
[
'alivenum'
])
{
echo
"不能解散游戏正在进行且尚有幸存者的房间!<br>"
;
$rerror
=
'room_close_limit2'
;
return
;
}
# 解散房间
...
...
@@ -202,13 +202,13 @@ function roommng_close_own_room(&$udata)
}
# 强制解散指定房间
function
roommng_close_room
(
$rkey
)
function
roommng_close_room
(
$rkey
,
$adminlog
=
0
)
{
global
$db
,
$gtablepre
;
global
$db
,
$gtablepre
,
$rerror
,
$cmd_info
;
if
(
!
$rkey
)
{
echo
"不能关闭大房间!<br>"
;
$cmd_info
.=
"不能关闭大房间!<br>"
;
return
;
}
...
...
@@ -220,11 +220,12 @@ function roommng_close_room($rkey)
if
(
$gdata
[
'groomnums'
])
$db
->
query
(
"UPDATE
{
$gtablepre
}
users SET roomid=0 WHERE roomid=
{
$rkey
}
"
);
# 关闭房间
$db
->
query
(
"DELETE FROM
{
$gtablepre
}
game WHERE groomid=
{
$rkey
}
"
);
echo
"已关闭房间
{
$rkey
}
号<br>"
;
$cmd_info
.=
"已关闭房间
{
$rkey
}
号<br>"
;
if
(
$adminlog
)
adminlog
(
'closeroom'
,
$rkey
);
}
else
{
echo
"房间
{
$rkey
}
未开启,或房间不存在!<br>"
;
$cmd_info
.=
"房间
{
$rkey
}
未开启,或房间不存在!<br>"
;
}
return
;
}
...
...
index.php
View file @
ec89e019
...
...
@@ -20,14 +20,16 @@ if($gamestate > 10) {
$adminmsg
=
file_get_contents
(
'./gamedata/adminmsg.htm'
)
;
$systemmsg
=
file_get_contents
(
'./gamedata/systemmsg.htm'
)
;
if
(
!
empty
(
$roomact
))
{
if
(
!
$cuser
||!
$cpass
)
{
gexit
(
$_ERROR
[
'no_login'
],
__file__
,
__line__
);
}
$rindex
=
Array
();
if
(
!
$cuser
||!
$cpass
)
{
$rerror
=
'no_login'
;
goto
roommng_flag
;
}
$result
=
$db
->
query
(
"SELECT * FROM
{
$gtablepre
}
users WHERE username='
$cuser
'"
);
if
(
!
$db
->
num_rows
(
$result
))
{
gexit
(
$_ERROR
[
'login_check'
],
__file__
,
__line__
);
}
if
(
!
$db
->
num_rows
(
$result
))
{
$rerror
=
'login_check'
;
goto
roommng_flag
;
}
$udata
=
$db
->
fetch_array
(
$result
);
if
(
$udata
[
'password'
]
!=
$cpass
)
{
gexit
(
$_ERROR
[
'wrong_pw'
],
__file__
,
__line__
);
}
if
(
$udata
[
'groupid'
]
<=
0
)
{
gexit
(
$_ERROR
[
'user_ban'
],
__file__
,
__line__
);
}
if
(
$udata
[
'password'
]
!=
$cpass
)
{
$rerror
=
'wrong_pw'
;
goto
roommng_flag
;
}
if
(
$udata
[
'groupid'
]
<=
0
)
{
$rerror
=
'user_ban'
;
goto
roommng_flag
;
}
if
(
$roomact
==
'create'
)
{
...
...
@@ -47,6 +49,13 @@ if(!empty($roomact))
roommng_close_own_room
(
$udata
);
}
unset
(
$roomact
);
roommng_flag
:
if
(
!
empty
(
$rerror
)
&&
isset
(
$_ERROR
[
$rerror
]))
$rindex
[
'innerHTML'
][
'roomerror'
]
=
$_ERROR
[
$rerror
];
else
$rindex
[
'url'
]
=
'index.php'
;
ob_clean
();
echo
compatible_json_encode
(
$rindex
);
ob_end_flush
();
exit
();
}
else
{
...
...
templates/default/index.htm
View file @
ec89e019
...
...
@@ -13,8 +13,7 @@
$adminmsg
</span>
<br>
<span
class=
"evergreen"
>
<span
class=
"evergreen"
>
当前房间列表:
<span
class=
"evergreen"
>
当前房间列表:
<input
type=
"button"
value=
"点击查看房间列表"
onclick=
"showModalDialog($('roomlist'));"
>
<div
style=
"height:5px;"
>
</div>
{template roomlist}
...
...
templates/default/roomlist.htm
View file @
ec89e019
<dialog
id=
"roomlist"
style=
"max-width: 90%;max-height: 80%; text-align: left;"
>
<span
class=
"yellow b"
><div
id=
"roomerror"
style=
"padding-bottom: 5px;"
></div></span>
<form
method=
"post"
name=
"roomact"
onsubmit=
"return false;"
>
<input
type=
"hidden"
name=
"roomact"
id=
"roomact"
value=
""
>
<!--{eval $now_rooms = !empty($roomlist) ? count($roomlist) : 0;}-->
<span
class=
"evergreen"
>
当前房间列表({$now_rooms}/{$max_rooms})
<!--{if $now_rooms < $max_rooms && !$groomid}-->
<input
type=
"button"
value=
"点击创建一个新的房间"
onclick=
"$('roomact').value='create';postCmd('roomact','index.php');
setTimeout(function(){window.location.href='index.php';},300);disabled=true;
"
>
<!--{if $now_rooms < $max_rooms && !$groomid
&& (!empty($cuser) && !empty($cpass))
}-->
<input
type=
"button"
value=
"点击创建一个新的房间"
onclick=
"$('roomact').value='create';postCmd('roomact','index.php');"
>
<!--{/if}-->
<br>
<div
style=
"height:5px;"
>
</div>
...
...
@@ -37,22 +38,26 @@
</td>
<!--<td class="b3" width="120px">运行时间</td>-->
<td
class=
"b3"
width=
"80px"
>
<!--{if !empty($cuser) && !empty($cpass)}-->
<!--{if !empty($rid)}-->
<!--{if $rid == $rkey}-->
<span
tooltip2=
"退出房间后,如房间内没有其他玩家,则房间会解散;房主退出房间会将房主权限转移给房间内其他玩家;"
>
<input
type=
"button"
value=
"退出"
onclick=
"$('roomact').value='exit';postCmd('roomact','index.php');
setTimeout(function(){window.location.href='index.php';},300);disabled=true;
"
>
<input
type=
"button"
value=
"退出"
onclick=
"$('roomact').value='exit';postCmd('roomact','index.php');"
>
</span>
<!--{if !empty($rinfo['groomownid']) && $rinfo['groomownid'] == $cuser}-->
<span
tooltip2=
"不能解散正在进行游戏且尚有其他玩家存活的房间"
>
<input
type=
"button"
value=
"解散"
onclick=
"$('roomact').value='close';postCmd('roomact','index.php');
setTimeout(function(){window.location.href='index.php';},300);disabled=true;
"
>
<input
type=
"button"
value=
"解散"
onclick=
"$('roomact').value='close';postCmd('roomact','index.php');"
>
</span>
<!--{/if}-->
<!--{else}-->
<span
class=
"grey"
>
-
</span>
<!--{/if}-->
<!--{else}-->
<input
type=
"button"
value=
"加入"
onclick=
"$('roomact').value='join{$rkey}';postCmd('roomact','index.php');
setTimeout(function(){window.location.href='index.php';},300);disabled=true;
"
>
<input
type=
"button"
value=
"加入"
onclick=
"$('roomact').value='join{$rkey}';postCmd('roomact','index.php');"
>
<!--{/if}-->
<!--{else}-->
<span
class=
"grey"
>
-
</span>
<!--{/if}-->
</td>
</tr>
<!--{/loop}-->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment