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
b0e30300
Commit
b0e30300
authored
Jul 14, 2023
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加录像上传的功能
- 录像自动上传 - 可以在历史优胜中下载录像 - 现在录像是默认打开的 - 回放界面屏蔽跳转和开场剧情
parent
ea84cc46
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
122 additions
and
9 deletions
+122
-9
.gitignore
.gitignore
+3
-0
include/game20130526.js
include/game20130526.js
+52
-6
include/system.func.php
include/system.func.php
+13
-0
record_backend.php
record_backend.php
+42
-0
templates/default/header.htm
templates/default/header.htm
+1
-1
templates/default/profile.htm
templates/default/profile.htm
+1
-1
templates/default/winnerlist.htm
templates/default/winnerlist.htm
+1
-0
winner.php
winner.php
+9
-1
No files found.
.gitignore
View file @
b0e30300
...
...
@@ -80,3 +80,6 @@ vendor
# env file
.env
# 录像文件
records
include/game20130526.js
View file @
b0e30300
...
...
@@ -573,7 +573,7 @@ function skill_unacquired_mouseout(e)
//录制处理
var
recordedData
=
[];
var
isRecording
=
fals
e
;
var
isRecording
=
tru
e
;
function
startRecording
()
{
isRecording
=
true
;
console
.
log
(
'
startRecording
'
);
...
...
@@ -587,7 +587,9 @@ function startRecording() {
linkElement
.
setAttribute
(
'
onclick
'
,
'
stopRecording()
'
);
}
}
document
.
addEventListener
(
'
click
'
,
recordButtonClick
);
function
stopRecording
()
{
isRecording
=
false
;
...
...
@@ -599,7 +601,7 @@ function stopRecording() {
// 停止监听
document
.
removeEventListener
(
'
click
'
,
recordButtonClick
);
downloadRecordedData
();
//
downloadRecordedData();
}
function
downloadRecordedData
()
{
...
...
@@ -620,6 +622,7 @@ function recordButtonClick(event) {
// 如果录制状态为 true,则将当前前端的全部静态网页数据保存到数组中
if
(
isRecording
)
{
recordedData
.
push
(
document
.
documentElement
.
outerHTML
.
concat
(
"
\n
"
));
sendLastRecordedData
(
recordedData
);
}
}
...
...
@@ -664,6 +667,20 @@ function showPage(pageContent, currentPageIndex) {
recordedDataDiv
.
innerHTML
=
'
已经到达最后一页
'
;
}
};
// 阻止链接跳转
var
links
=
recordedDataDiv
.
getElementsByTagName
(
'
a
'
);
for
(
var
i
=
0
;
i
<
links
.
length
;
i
++
)
{
links
[
i
].
addEventListener
(
'
click
'
,
function
(
event
)
{
event
.
preventDefault
();
});
}
// 删除具有 id="hidden-model" 的元素
var
hiddenModelElement
=
document
.
getElementById
(
'
hidden-model
'
);
if
(
hiddenModelElement
)
{
hiddenModelElement
.
remove
();
}
recordedDataDiv
.
insertBefore
(
nextPageButton
,
recordedDataDiv
.
firstChild
);
...
...
@@ -706,12 +723,41 @@ function displayRecordedData(file) {
}
}
window
.
onbeforeunload
=
function
()
{
/*
window.onbeforeunload = function () {
if (isRecording) {
window.alert('你正在录制游戏,之后将会自动下载录制数据。');
downloadRecordedData();
}
};
};*/
function
sendLastRecordedData
(
recordedData
)
{
const
nickinfoElement
=
document
.
getElementById
(
'
nickinfo
'
);
if
(
!
nickinfoElement
)
{
return
;
}
const
nickinfo
=
nickinfoElement
.
innerText
;
const
lastRecord
=
recordedData
[
recordedData
.
length
-
1
];
fetch
(
'
record_backend.php
'
,
{
method
:
'
POST
'
,
body
:
JSON
.
stringify
({
lastRecord
,
nickinfo
}),
headers
:
{
'
Content-Type
'
:
'
application/json
'
}
})
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
// 处理从后端返回的响应
//console.log(data);
})
.
catch
(
error
=>
{
// 处理错误
console
.
error
(
error
);
});
}
include/system.func.php
View file @
b0e30300
...
...
@@ -440,6 +440,19 @@ function duel($time = 0,$keyitm = ''){
function
gameover
(
$time
=
0
,
$mode
=
''
,
$winname
=
''
)
{
global
$gamestate
,
$winmode
,
$alivenum
,
$winner
,
$now
,
$gamenum
,
$db
,
$gtablepre
,
$tablepre
,
$gamenum
,
$starttime
,
$validnum
,
$hdamage
,
$hplayer
;
global
$groomid
;
//遍历./records/$gamenum/下的所有txt文件
$filelist
=
glob
(
"./records/
$gamenum
/**/*.txt"
);
//然后gzip压缩
foreach
(
$filelist
as
$file
){
$input
=
fopen
(
$file
,
'rb'
);
$output
=
gzopen
(
$file
.
'.gz'
,
'wb'
);
while
(
!
feof
(
$input
))
{
gzwrite
(
$output
,
fread
(
$input
,
1024
));
}
fclose
(
$input
);
//删除原文件
unlink
(
$file
);
}
if
(
$gamestate
<
10
){
return
;}
if
((
!
$mode
)
||
((
$mode
==
2
)
&&
(
!
$winname
)))
{
//在没提供游戏结束模式的情况下,自行判断模式
if
(
$validnum
<=
0
)
{
//无激活者情况下,全部死亡
...
...
record_backend.php
0 → 100644
View file @
b0e30300
<?php
define
(
'CURSCRIPT'
,
'record_backend'
);
require
'./include/common.inc.php'
;
try
{
$jsonData
=
file_get_contents
(
'php://input'
);
$requestData
=
json_decode
(
$jsonData
,
true
);
if
(
$requestData
===
null
)
{
http_response_code
(
400
);
$response
=
[
"message"
=>
"Invalid JSON data"
];
echo
json_encode
(
$response
);
return
;
}
global
$gamenum
;
$lastRecord
=
$requestData
[
'lastRecord'
];
$nickinfo
=
$requestData
[
'nickinfo'
];
$directoryPath
=
"./records/
$gamenum
/
$nickinfo
"
;
$filePath
=
"
$directoryPath
/record.txt"
;
// 创建目录
if
(
!
is_dir
(
$directoryPath
)
&&
!
mkdir
(
$directoryPath
,
0777
,
true
))
{
throw
new
Exception
(
'Failed to create directory'
);
}
// 写入数据到文件
if
(
!
file_put_contents
(
$filePath
,
$lastRecord
.
"
\n
"
,
FILE_APPEND
))
{
throw
new
Exception
(
'Failed to write data to file'
);
}
// 返回信息
echo
json_encode
([
"message"
=>
"Success"
,
]);
}
catch
(
Exception
$e
)
{
http_response_code
(
500
);
$response
=
[
"message"
=>
$e
->
getMessage
()];
echo
json_encode
(
$response
);
}
templates/default/header.htm
View file @
b0e30300
...
...
@@ -206,7 +206,7 @@
</div>
</a>
</span>
<a
href=
"javascript:void(0)"
onclick=
"st
artRecording()"
>
>>开始
录像
</a>
<a
href=
"javascript:void(0)"
onclick=
"st
opRecording()"
>
>>停止
录像
</a>
<a
href=
"record.php"
>
>>回放录像
</a>
<a
href=
"admin.php"
>
>>{lang admin}
</a>
<a
href=
"https://bbs.brdts.online/"
target=
"_blank"
>
>>{lang report}
</a>
...
...
templates/default/profile.htm
View file @
b0e30300
...
...
@@ -12,7 +12,7 @@
<table
border=
"0"
width=
"720"
cellspacing=
"0"
cellpadding=
"0"
valign=
"middle"
>
<tr>
<!--{eval $nickinfo = titles_get_desc($nick,1);}-->
<td
width=
"210"
colspan=
"3"
class=
"b1
"
><span>
{$nickinfo} {$name}
</span></td>
<td
width=
"210"
colspan=
"3"
class=
"b1"
id=
"nickinfo
"
><span>
{$nickinfo} {$name}
</span></td>
<td
width=
"100"
colspan=
"1"
class=
"b1"
><span>
{$sexinfo[$gd]}{$sNo}号
</span></td>
<td
width=
"95"
colspan=
"2"
class=
"b1"
><span>
{lang weather}:$wthinfo[$weather]
</span></td>
<td
width=
"215"
colspan=
"1"
class=
"b1"
><span>
{lang gamedate}
<!--{if $gamestate == 40 }-->
<span
class=
"yellow"
>
{lang combo}
</span>
<!--{/if}--><!--{if $gamestate == 50 }-->
<span
class=
"red"
>
{lang duel}
</span>
<!--{/if}-->
</span></td>
...
...
templates/default/winnerlist.htm
View file @
b0e30300
...
...
@@ -55,6 +55,7 @@
<input
type=
"button"
value=
"角色信息"
<!
--
{
if
$
info
['
wmode
']
&&
$
info
['
wmode
']
!=
1
&&
$
info
['
wmode
']
!=
4
&&
$
info
['
wmode
']
!=
6
}
--
>
onclick="$('command').value='info';$('gnum').value='$gid';document.info.submit();"
<!--{else}-->
disabled
<!--{/if}-->
>
<!--{if $info['wmode'] && $info['wmode'] !=4}-->
<span
class=
"white"
><a
href=
"winner.php?command=news&gnum=$info[gid]"
>
📼
</a></span>
<!--{else}-->
<!--{/if}-->
<input
type=
"button"
value=
"该局状况"
<!
--
{
if
$
info
['
wmode
']
&&
$
info
['
wmode
']
!=
4
}
--
>
onclick="$('command').value='news';$('gnum').value='$gid';document.info.submit();"
<!--{else}-->
disabled
<!--{/if}-->
>
$download_buttons[$gid]
</span>
</TD>
</TR>
...
...
winner.php
View file @
b0e30300
...
...
@@ -23,6 +23,7 @@ if($command == 'info') {
$hnewsinfo
=
readover
(
$hnewsfile
);
}
}
else
{
$download_button
=
[];
if
(
!
isset
(
$start
)
||
!
$start
){
$result
=
$db
->
query
(
"SELECT gid,name,nick,icon,gd,wep,wmode,teamID,teamMate,teamIcon,getime,motto,hdp,hdmg,hkp,hkill FROM
{
$gtablepre
}
winners ORDER BY gid desc LIMIT
$winlimit
"
);
}
else
{
...
...
@@ -50,7 +51,14 @@ if($command == 'info') {
$wdata
[
'nickinfo'
]
=
(
!
empty
(
$wdata
[
'nick'
])
||
$wdata
[
'nick'
]
===
'0'
)
?
titles_get_desc
(
$wdata
[
'nick'
])
:
''
;
}
}
$winfo
[
$wdata
[
'gid'
]]
=
$wdata
;
$winfo
[
$wdata
[
'gid'
]]
=
$wdata
;
//遍历./records/$wdata['gid']/下的所有gz文件
$filelist
=
glob
(
"./records/
{
$wdata
[
'gid'
]
}
/**/*.gz"
);
foreach
(
$filelist
as
$file
)
{
//下载按钮,html
$dirname
=
basename
(
dirname
(
$file
));
$download_buttons
[
$wdata
[
'gid'
]]
.=
"<br><a href=
\"
$file
\"
download=
\"
$dirname
\"
>下载
$dirname
</a>"
;
}
}
$listnum
=
floor
(
$gamenum
/
$winlimit
);
...
...
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