Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
417cbeb4
Commit
417cbeb4
authored
4 years ago
by
echicken
Browse files
Options
Downloads
Patches
Plain Diff
Use require() for request,FileBase. Use 'request' to get query params.
parent
27d96e0d
No related branches found
No related tags found
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webv4/root/api/files.ssjs
+18
-16
18 additions, 16 deletions
webv4/root/api/files.ssjs
with
18 additions
and
16 deletions
webv4/root/api/files.ssjs
+
18
−
16
View file @
417cbeb4
...
...
@@ -4,41 +4,40 @@ var settings = load('modopts.js', 'web') || { web_directory: '../webv4' };
load
(
settings
.
web_directory
+
'
/lib/init.js
'
);
load
(
settings
.
web_lib
+
'
auth.js
'
);
load
(
settings
.
web_lib
+
'
files.js
'
);
require
(
'
filebase.js
'
,
'
FileBase
'
);
var
request
=
require
({},
settings
.
web_lib
+
'
request.js
'
,
'
request
'
);
var
Filebase
=
require
({},
'
filebase.js
'
,
'
FileBase
'
);
var
CHUNK_SIZE
=
1024
;
var
reply
=
{};
if
((
http_request
.
method
===
'
GET
'
||
http_request
.
method
===
'
POST
'
)
&&
typeof
http_request
.
query
.
call
!==
'
undefined
'
&&
user
.
number
>
0
)
{
if
((
http_request
.
method
===
'
GET
'
||
http_request
.
method
===
'
POST
'
)
&&
request
.
has_param
(
'
call
'
)
&&
user
.
number
>
0
)
{
switch
(
http_
request
.
query
.
call
[
0
]
.
toLowerCase
())
{
switch
(
request
.
get_param
(
'
call
'
)
.
toLowerCase
())
{
case
'
download-file
'
:
if
(
typeof
http_request
.
query
.
dir
!==
'
undefined
'
&&
typeof
file_area
.
dir
[
http_request
.
query
.
dir
[
0
]]
!==
'
undefined
'
&&
file_area
.
dir
[
http_request
.
query
.
dir
[
0
]].
lib_index
>=
0
&&
file_area
.
dir
[
http_request
.
query
.
dir
[
0
]].
index
>=
0
&&
file_area
.
dir
[
http_request
.
query
.
dir
[
0
]].
can_download
&&
typeof
http_request
.
query
.
file
!==
'
undefined
'
&&
user
.
compare_ars
(
file_area
.
dir
[
http_request
.
query
.
dir
[
0
]].
download_ars
)
var
dir
=
request
.
get_param
(
'
dir
'
);
if
(
dir
!==
undefined
&&
file_area
.
dir
[
dir
]
!==
undefined
&&
file_area
.
dir
[
dir
].
lib_index
>=
0
&&
file_area
.
dir
[
dir
].
index
>=
0
&&
file_area
.
dir
[
dir
].
can_download
&&
request
.
has_param
(
'
file
'
)
&&
user
.
compare_ars
(
file_area
.
dir
[
dir
].
download_ars
)
)
{
var
dircode
=
file_area
.
dir
[
http_request
.
query
.
dir
[
0
]].
code
;
var
dircode
=
file_area
.
dir
[
dir
].
code
;
var
fn
=
request
.
get_param
(
'
file
'
).
toLowerCase
();
var
fileBase
=
new
FileBase
(
dircode
);
var
file
=
null
;
fileBase
.
some
(
function
(
e
)
{
if
(
e
.
name
.
toLowerCase
()
!==
http_request
.
query
.
file
[
0
].
toLowerCase
()
)
{
if
(
e
.
name
.
toLowerCase
()
!==
fn
)
{
return
false
;
}
else
if
(
typeof
e
.
path
!==
'
undefined
'
)
{
}
else
if
(
e
.
path
!==
undefined
)
{
file
=
e
;
return
true
;
}
});
fileBase
=
undefined
;
if
(
file
===
null
)
{
reply
.
error
=
'
File not found
'
;
break
;
}
if
(
!
file_area
.
dir
[
dir
code
].
is_exempt
&&
file
.
credits
>
(
user
.
security
.
credits
+
user
.
security
.
free_credits
))
{
if
(
!
file_area
.
dir
[
dir
].
is_exempt
&&
file
.
credits
>
(
user
.
security
.
credits
+
user
.
security
.
free_credits
))
{
reply
.
error
=
'
Not enough credits to download this file
'
;
break
;
}
...
...
@@ -64,6 +63,7 @@ if ((http_request.method === 'GET' || http_request.method === 'POST') &&
yield
(
false
);
}
f
.
close
();
f
=
undefined
;
reply
=
false
;
user
.
downloaded_file
(
dircode
,
file
.
path
);
}
...
...
@@ -80,3 +80,5 @@ reply = JSON.stringify(reply);
http_reply
.
header
[
'
Content-Type
'
]
=
'
application/json
'
;
http_reply
.
header
[
'
Content-Length
'
]
=
reply
.
length
;
write
(
reply
);
reply
=
undefined
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment