Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
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
MyCard
srvpro
Commits
9349e59c
Commit
9349e59c
authored
Sep 13, 2015
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
c2a887c0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
142 additions
and
16 deletions
+142
-16
.gitignore
.gitignore
+1
-0
config.sample.json
config.sample.json
+8
-3
room.coffee
room.coffee
+1
-1
room.js
room.js
+1
-1
ygopro-pre.js
ygopro-pre.js
+131
-11
No files found.
.gitignore
View file @
9349e59c
# 23333333
# 23333333
config.json
config.json
/config.json
/config.json
test*
/ygocore/
/ygocore/
/ygocore
/ygocore
...
...
config.sample.json
View file @
9349e59c
...
@@ -4,22 +4,27 @@
...
@@ -4,22 +4,27 @@
"version"
:
4918
,
"version"
:
4918
,
"modules"
:
{
"modules"
:
{
"welcome"
:
"YGOPRO Server"
,
"welcome"
:
"YGOPRO Server"
,
"stop"
:
"停服"
,
"stop"
:
false
,
"tips"
:
"http://mercury233.me/ygosrv233/tips.json"
,
"tips"
:
"http://mercury233.me/ygosrv233/tips.json"
,
"dialogues"
:
"http://mercury233.me/ygosrv233/dialogues.json"
,
"dialogues"
:
"http://mercury233.me/ygosrv233/dialogues.json"
,
"post_start_watching"
:
true
,
"post_start_watching"
:
true
,
"TCG_banlist_id"
:
7
,
"TCG_banlist_id"
:
7
,
"enable_TCG_as_default"
:
false
,
"http"
:
{
"http"
:
{
"port"
:
7922
,
"port"
:
7922
,
"password"
:
"123456"
,
"password"
:
"123456"
,
"match"
:
true
"match"
:
true
},
},
"pre"
:
{
"pre"
:
{
"port"
:
7921
,
"port"
:
7911
,
"password"
:
"123456"
,
"git_html_path"
:
"../mercury233.github.io/"
,
"html_path"
:
"../mercury233.github.io/ygosrv233/"
,
"html_path"
:
"../mercury233.github.io/ygosrv233/"
,
"html_filename"
:
"pre.html"
,
"html_filename"
:
"pre.html"
,
"git_db_path"
:
"../ygopro-cards/"
,
"db_path"
:
"../ygopro-cards/unofficial/"
,
"db_path"
:
"../ygopro-cards/unofficial/"
,
"img_rel_path"
:
"pre/pics/"
"html_img_rel_path"
:
"pre/pics/"
,
"ygopro_path"
:
"../ygopro-pre/"
}
}
}
}
}
}
\ No newline at end of file
room.coffee
View file @
9349e59c
...
@@ -72,7 +72,7 @@ class Room
...
@@ -72,7 +72,7 @@ class Room
@
hostinfo
=
@
hostinfo
=
lflist
:
0
lflist
:
0
rule
:
0
rule
:
if
settings
.
modules
.
enable_TCG_as_default
then
0
else
2
mode
:
0
mode
:
0
enable_priority
:
false
enable_priority
:
false
no_check_deck
:
false
no_check_deck
:
false
...
...
room.js
View file @
9349e59c
...
@@ -90,7 +90,7 @@
...
@@ -90,7 +90,7 @@
Room
.
all
.
push
(
this
);
Room
.
all
.
push
(
this
);
this
.
hostinfo
=
{
this
.
hostinfo
=
{
lflist
:
0
,
lflist
:
0
,
rule
:
0
,
rule
:
settings
.
modules
.
enable_TCG_as_default
?
0
:
2
,
mode
:
0
,
mode
:
0
,
enable_priority
:
false
,
enable_priority
:
false
,
no_check_deck
:
false
,
no_check_deck
:
false
,
...
...
ygopro-pre.js
View file @
9349e59c
...
@@ -11,6 +11,8 @@ var http = require('http');
...
@@ -11,6 +11,8 @@ var http = require('http');
var
sqlite3
=
require
(
'
sqlite3
'
).
verbose
();
var
sqlite3
=
require
(
'
sqlite3
'
).
verbose
();
var
fs
=
require
(
'
fs
'
);
var
fs
=
require
(
'
fs
'
);
var
execSync
=
require
(
'
child_process
'
).
execSync
;
var
execSync
=
require
(
'
child_process
'
).
execSync
;
var
spawn
=
require
(
'
child_process
'
).
spawn
;
var
url
=
require
(
'
url
'
);
var
constants
=
require
(
'
./constants.json
'
);
var
constants
=
require
(
'
./constants.json
'
);
var
config
=
require
(
'
./config.json
'
).
modules
.
pre
;
var
config
=
require
(
'
./config.json
'
).
modules
.
pre
;
...
@@ -22,7 +24,9 @@ var responder;
...
@@ -22,7 +24,9 @@ var responder;
//输出反馈信息,如有http长连接则输出到http,否则输出到控制台
//输出反馈信息,如有http长连接则输出到http,否则输出到控制台
var
sendResponse
=
function
(
text
)
{
var
sendResponse
=
function
(
text
)
{
text
=
""
+
text
;
if
(
responder
)
{
if
(
responder
)
{
text
=
text
.
replace
(
/
\n
/g
,
"
<br>
"
);
responder
.
write
(
"
data:
"
+
text
+
"
\n\n
"
);
responder
.
write
(
"
data:
"
+
text
+
"
\n\n
"
);
}
}
else
{
else
{
...
@@ -164,10 +168,12 @@ var writeToFile = function() {
...
@@ -164,10 +168,12 @@ var writeToFile = function() {
fileContent
=
fileContent
.
replace
(
/<tbody class="auto-generated">
[\w\W]
*<
\/
tbody>/
,
'
<tbody class="auto-generated">
\r\n
'
+
newContent
+
'
\r\n
</tbody>
'
);
fileContent
=
fileContent
.
replace
(
/<tbody class="auto-generated">
[\w\W]
*<
\/
tbody>/
,
'
<tbody class="auto-generated">
\r\n
'
+
newContent
+
'
\r\n
</tbody>
'
);
fs
.
writeFileSync
(
config
.
html_path
+
config
.
html_filename
,
fileContent
);
fs
.
writeFileSync
(
config
.
html_path
+
config
.
html_filename
,
fileContent
);
sendResponse
(
"
列表更新完成。
"
);
sendResponse
(
"
列表更新完成。
"
);
copyImages
();
}
}
//读取指定文件夹里所有数据库,异步
//读取指定文件夹里所有数据库,异步
var
loadAllDbs
=
function
()
{
var
loadAllDbs
=
function
()
{
cardHTMLs
=
[];
var
files
=
fs
.
readdirSync
(
config
.
db_path
+
"
expansions/
"
);
var
files
=
fs
.
readdirSync
(
config
.
db_path
+
"
expansions/
"
);
for
(
var
i
in
files
)
{
for
(
var
i
in
files
)
{
var
filename
=
files
[
i
];
var
filename
=
files
[
i
];
...
@@ -177,17 +183,114 @@ var loadAllDbs = function() {
...
@@ -177,17 +183,114 @@ var loadAllDbs = function() {
}
}
}
}
//将数据库文件夹里卡图复制到列表页对应文件夹里
//从远程更新数据库,异步
var
fetchDatas
=
function
()
{
var
process
=
spawn
(
"
git
"
,
[
"
pull
"
,
"
origin
"
],
{
cwd
:
config
.
git_db_path
});
process
.
stdout
.
setEncoding
(
'
utf8
'
);
process
.
stdout
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
git pull:
"
+
data
);
});
process
.
stderr
.
setEncoding
(
'
utf8
'
);
process
.
stderr
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
git pull error:
"
+
data
);
});
process
.
on
(
'
close
'
,
function
(
code
)
{
sendResponse
(
"
命令执行完成。
"
);
});
}
//更新本地网页到服务器,异步
var
pushDatas
=
function
()
{
var
process
=
spawn
(
"
git
"
,
[
"
pull
"
,
"
origin
"
],
{
cwd
:
config
.
git_html_path
});
process
.
stdout
.
setEncoding
(
'
utf8
'
);
process
.
stdout
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
git pull:
"
+
data
);
});
process
.
stderr
.
setEncoding
(
'
utf8
'
);
process
.
stderr
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
git pull error:
"
+
data
);
});
process
.
on
(
'
close
'
,
function
(
code
)
{
sendResponse
(
"
请稍候。
"
);
try
{
execSync
(
'
git add --all .
'
,
{
cwd
:
config
.
git_html_path
});
execSync
(
'
git commit -m update-auto
'
,
{
cwd
:
config
.
git_html_path
});
}
catch
(
error
)
{
sendResponse
(
"
git error:
"
+
error
.
stdout
);
}
var
process2
=
spawn
(
"
git
"
,
[
"
push
"
],
{
cwd
:
config
.
git_html_path
});
process2
.
stdout
.
setEncoding
(
'
utf8
'
);
process2
.
stdout
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
git push:
"
+
data
);
});
process2
.
stderr
.
setEncoding
(
'
utf8
'
);
process2
.
stderr
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
git push:
"
+
data
);
});
process2
.
on
(
'
close
'
,
function
(
code
)
{
sendResponse
(
"
命令执行完成。
"
);
});
});
}
//将数据库文件夹里卡图复制到列表页对应文件夹里,同步
var
copyImages
=
function
()
{
var
copyImages
=
function
()
{
execSync
(
'
rm -rf "
'
+
config
.
html_path
+
config
.
html_img_rel_path
+
'
"
'
);
execSync
(
'
rm -rf "
'
+
config
.
html_path
+
config
.
html_img_rel_path
+
'
"
'
);
execSync
(
'
cp -r "
'
+
config
.
db_path
+
'
pics
'
+
'
" "
'
+
config
.
html_path
+
config
.
html_img_rel_path
+
'
"
'
);
execSync
(
'
cp -r "
'
+
config
.
db_path
+
'
pics
'
+
'
" "
'
+
config
.
html_path
+
config
.
html_img_rel_path
+
'
"
'
);
sendResponse
(
"
卡图复制完成。
"
);
sendResponse
(
"
卡图复制完成。
"
);
}
}
//将数据库文件夹复制到YGOPRO文件夹里,同步
var
copyToYGOPRO
=
function
()
{
execSync
(
'
rm -rf "
'
+
config
.
ygopro_path
+
'
expansions/*
'
+
'
"
'
);
execSync
(
'
cp -rf "
'
+
config
.
db_path
+
'
expansions
'
+
'
" "
'
+
config
.
ygopro_path
+
'
"
'
);
execSync
(
'
cp -rf "
'
+
config
.
db_path
+
'
script
'
+
'
" "
'
+
config
.
ygopro_path
+
'
expansions"
'
);
sendResponse
(
"
更新完成。
"
);
}
//生成更新包,异步
var
packDatas
=
function
()
{
var
process
=
spawn
(
"
7za
"
,
[
"
a
"
,
"
-x!*.zip
"
,
"
-x!mobile.cdb
"
,
"
ygosrv233-pre.zip
"
,
"
*
"
],
{
cwd
:
config
.
db_path
});
process
.
stdout
.
setEncoding
(
'
utf8
'
);
process
.
stdout
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
7z:
"
+
data
);
});
process
.
stderr
.
setEncoding
(
'
utf8
'
);
process
.
stderr
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
7z error:
"
+
data
);
});
process
.
on
(
'
close
'
,
function
(
code
)
{
execSync
(
'
mv -f "
'
+
config
.
db_path
+
'
ygosrv233-pre.zip" "
'
+
config
.
html_path
+
'
"
'
);
sendResponse
(
"
电脑更新包打包完成。
"
);
});
var
process2
=
spawn
(
"
7za
"
,
[
"
a
"
,
"
-x!*.zip
"
,
"
-x!expansions
"
,
"
ygosrv233-pre-mobile.zip
"
,
"
*
"
],
{
cwd
:
config
.
db_path
});
process2
.
stdout
.
setEncoding
(
'
utf8
'
);
process2
.
stdout
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
7z:
"
+
data
);
});
process2
.
stderr
.
setEncoding
(
'
utf8
'
);
process2
.
stderr
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
7z error:
"
+
data
);
});
process2
.
on
(
'
close
'
,
function
(
code
)
{
execSync
(
'
mv -f "
'
+
config
.
db_path
+
'
ygosrv233-pre-mobile.zip" "
'
+
config
.
html_path
+
'
"
'
);
sendResponse
(
"
手机更新包打包完成。
"
);
});
}
//建立一个http服务器,接收API操作
//建立一个http服务器,接收API操作
http
.
createServer
(
function
(
req
,
res
)
{
http
.
createServer
(
function
(
req
,
res
)
{
if
(
req
.
url
===
'
/api/msg
'
)
{
var
u
=
url
.
parse
(
req
.
url
,
true
);
if
(
u
.
query
.
password
!==
config
.
password
)
{
res
.
writeHead
(
403
);
res
.
end
(
"
Auth Failed.
"
);
return
;
}
if
(
u
.
pathname
===
'
/api/msg
'
)
{
res
.
writeHead
(
200
,
{
res
.
writeHead
(
200
,
{
"
Access-Control-Allow-origin
"
:
"
*
"
,
"
Content-Type
"
:
"
text/event-stream
"
,
"
Content-Type
"
:
"
text/event-stream
"
,
"
Cache-Control
"
:
"
no-cache
"
,
"
Cache-Control
"
:
"
no-cache
"
,
"
Connection
"
:
"
keep-alive
"
"
Connection
"
:
"
keep-alive
"
...
@@ -198,25 +301,42 @@ http.createServer(function (req, res) {
...
@@ -198,25 +301,42 @@ http.createServer(function (req, res) {
});
});
responder
=
res
;
responder
=
res
;
sendResponse
(
"
已连接。
"
);
}
}
else
if
(
req
.
url
===
'
/api/load_db
'
)
{
else
if
(
u
.
pathname
===
'
/api/load_db
'
)
{
res
.
writeHead
(
200
);
res
.
end
(
u
.
query
.
callback
+
'
({"message":"开始加载数据库。"});
'
);
loadAllDbs
();
loadAllDbs
();
}
else
if
(
u
.
pathname
===
'
/api/fetch_datas
'
)
{
res
.
writeHead
(
200
);
res
.
writeHead
(
200
);
res
.
end
(
"
开始加载数据库。
"
);
res
.
end
(
u
.
query
.
callback
+
'
({"message":"开始更新数据库。"});
'
);
fetchDatas
();
}
}
else
if
(
req
.
url
===
'
/api/write_to_file
'
)
{
else
if
(
u
.
pathname
===
'
/api/push_datas
'
)
{
res
.
writeHead
(
200
);
res
.
end
(
u
.
query
.
callback
+
'
({"message":"开始上传到网页。"});
'
);
pushDatas
();
}
else
if
(
u
.
pathname
===
'
/api/write_to_file
'
)
{
res
.
writeHead
(
200
);
res
.
end
(
u
.
query
.
callback
+
'
({"message":"开始写列表页。"});
'
);
writeToFile
();
writeToFile
();
}
else
if
(
u
.
pathname
===
'
/api/copy_to_ygopro
'
)
{
res
.
writeHead
(
200
);
res
.
writeHead
(
200
);
res
.
end
(
"
开始写列表页。
"
);
res
.
end
(
u
.
query
.
callback
+
'
({"message":"开始更新到服务器。"});
'
);
copyToYGOPRO
();
}
}
else
if
(
req
.
url
===
'
/api/copy_images
'
)
{
else
if
(
u
.
pathname
===
'
/api/pack_data
'
)
{
copyImages
();
res
.
writeHead
(
200
);
res
.
writeHead
(
200
);
res
.
end
(
"
开始复制卡图。
"
);
res
.
end
(
u
.
query
.
callback
+
'
({"message":"开始生成更新包。"});
'
);
packDatas
();
}
}
else
{
else
{
res
.
writeHead
(
40
4
);
res
.
writeHead
(
40
0
);
res
.
end
(
"
no
"
);
res
.
end
(
"
400
"
);
}
}
}).
listen
(
config
.
port
);
}).
listen
(
config
.
port
);
...
...
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