Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle_mod-hvp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle_mod-hvp
Commits
64e6caaa
Unverified
Commit
64e6caaa
authored
2 years ago
by
Svein-Tore Griff With
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #475 from davidherney/issue-200
Check max upload file size and use antivirus if apply
parents
c0627146
05dc02f9
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
classes/file_storage.php
+22
-0
22 additions, 0 deletions
classes/file_storage.php
with
22 additions
and
0 deletions
classes/file_storage.php
+
22
−
0
View file @
64e6caaa
...
@@ -380,6 +380,8 @@ class file_storage implements \H5PFileStorage {
...
@@ -380,6 +380,8 @@ class file_storage implements \H5PFileStorage {
*/
*/
// @codingStandardsIgnoreLine
// @codingStandardsIgnoreLine
public
function
saveFile
(
$file
,
$contentid
,
$contextid
=
null
)
{
public
function
saveFile
(
$file
,
$contentid
,
$contextid
=
null
)
{
global
$CFG
;
if
(
$contentid
!==
0
)
{
if
(
$contentid
!==
0
)
{
// Grab cm context.
// Grab cm context.
$cm
=
\get_coursemodule_from_instance
(
'hvp'
,
$contentid
);
$cm
=
\get_coursemodule_from_instance
(
'hvp'
,
$contentid
);
...
@@ -388,6 +390,26 @@ class file_storage implements \H5PFileStorage {
...
@@ -388,6 +390,26 @@ class file_storage implements \H5PFileStorage {
}
else
if
(
$contextid
===
null
)
{
}
else
if
(
$contextid
===
null
)
{
// Check for context id in params.
// Check for context id in params.
$contextid
=
optional_param
(
'contextId'
,
null
,
PARAM_INT
);
$contextid
=
optional_param
(
'contextId'
,
null
,
PARAM_INT
);
$context
=
\context
::
instance_by_id
(
$contextid
);
}
if
(
!
$context
)
{
\H5PCore
::
ajaxError
(
get_string
(
'invalidcontext'
,
'error'
));
return
;
}
$maxsize
=
get_max_upload_file_size
(
$CFG
->
maxbytes
);
// Check size of each uploaded file and scan for viruses.
foreach
(
$_FILES
as
$uploadedfile
)
{
$filename
=
clean_param
(
$uploadedfile
[
'name'
],
PARAM_FILE
);
if
(
!
has_capability
(
'moodle/course:ignorefilesizelimits'
,
$context
))
{
if
(
$uploadedfile
[
'size'
]
>
$maxsize
)
{
\H5PCore
::
ajaxError
(
get_string
(
'maxbytesfile'
,
'error'
,
[
'file'
=>
$filename
,
'size'
=>
display_size
(
$maxsize
)]));
return
;
}
}
\core\antivirus\manager
::
scan_file
(
$uploadedfile
[
'tmp_name'
],
$filename
,
true
);
}
}
// Files not yet related to any activities are stored in a course context
// Files not yet related to any activities are stored in a course context
...
...
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