Commit 5b22917e authored by Richard Mansfield's avatar Richard Mansfield
Browse files

work on virus repeat activity

parent e14fcaeb
...@@ -411,9 +411,10 @@ $string['clamdeletedfilefailed'] = 'The file could not be deleted'; ...@@ -411,9 +411,10 @@ $string['clamdeletedfilefailed'] = 'The file could not be deleted';
$string['clambroken'] = 'Your administrator has enabled virus checking for file uploads but has misconfigured something. Your file upload was NOT successful. Your administrator has been emailed to notify them so they can fix it. Maybe try uploading this file later.'; $string['clambroken'] = 'Your administrator has enabled virus checking for file uploads but has misconfigured something. Your file upload was NOT successful. Your administrator has been emailed to notify them so they can fix it. Maybe try uploading this file later.';
$string['clamemailsubject'] = '%s :: Clam AV notification'; $string['clamemailsubject'] = '%s :: Clam AV notification';
$string['clamlost'] = 'Clam AV is configured to run on file upload, but the path supplied to Clam AV, %s, is invalid.'; $string['clamlost'] = 'Clam AV is configured to run on file upload, but the path supplied to Clam AV, %s, is invalid.';
$string['virusfounduser'] = 'The file you have uploaded, %s, has been scanned by a virus checker and found to be infected! Your file upload was NOT successful.';
$string['clamfailed'] = 'Clam AV has failed to run. The return error message was %s. Here is the output from Clam:'; $string['clamfailed'] = 'Clam AV has failed to run. The return error message was %s. Here is the output from Clam:';
$string['clamunknownerror'] = 'There was an unknown error with clam.'; $string['clamunknownerror'] = 'There was an unknown error with clam.';
$string['virusfounduser'] = 'The file you have uploaded, %s, has been scanned by a virus checker and found to be infected! Your file upload was NOT successful.';
$string['virusrepeatsubject'] = 'Warning: %s is a repeat virus uploader.';
$string['virusrepeatmessage'] = 'The user %s has uploaded multiple files which have been scanned by a virus checker and found to be infected.';
?> ?>
...@@ -132,6 +132,9 @@ function handle_activity($activitytype, $data) { ...@@ -132,6 +132,9 @@ function handle_activity($activitytype, $data) {
} }
break; break;
case 'virusrepeat': case 'virusrepeat':
$userstring = $data->username . ' (' . $data->fullname . ') (userid:' . $data->userid . ')' ;
$data->subject = get_string('virusrepeatsubject', 'mahara', $userstring);
$data->message = get_string('virusrepeatmessage');
break; break;
case 'virusrelease': case 'virusrelease':
break; break;
......
...@@ -111,8 +111,9 @@ class upload_manager { ...@@ -111,8 +111,9 @@ class upload_manager {
/** /**
* Wrapper function that calls {@link preprocess_files()} and {@link viruscheck_files()} and then {@link save_files()} * Wrapper function that calls {@link preprocess_files()} and {@link viruscheck_files()} and then {@link save_files()}
* Modules that require the insert id in the filepath should not use this and call these functions seperately in the required order. * Modules that require the insert id in the filepath should not use this and call these functions seperately in the required order.
* @parameter string $destination Where to save the uploaded files to. * @parameter string $destination Where to save the uploaded file to.
* @return boolean * @parameter string $newname What to call the saved file.
* @return false for no errors, or a string describing the error.
*/ */
function process_file_upload($destination, $newname) { function process_file_upload($destination, $newname) {
$error = $this->preprocess_file(); $error = $this->preprocess_file();
...@@ -226,14 +227,15 @@ function clam_scan_file(&$file) { ...@@ -226,14 +227,15 @@ function clam_scan_file(&$file) {
case 1: // bad wicked evil, we have a virus. case 1: // bad wicked evil, we have a virus.
global $USER; global $USER;
$userid = $USER->get('id'); $userid = $USER->get('id');
$username = $USER->get('username') . ' (' . full_name() . ')';
clam_handle_infected_file($fullpath); clam_handle_infected_file($fullpath);
// Notify admins if user has uploaded more than 3 infected // Notify admins if user has uploaded more than 3 infected
// files in the last month // files in the last month
if (count_records_sql('SELECT COUNT(*) FROM ' . get_config('dbprefix') . 'usr_infectedupload if (count_records_sql('SELECT COUNT(*) FROM ' . get_config('dbprefix') . 'usr_infectedupload
WHERE usr = ? AND time > CURRENT_TIMESTAMP - ?::INTERVAL;', array($userid, '1 month')) >= 2) { WHERE usr = ? AND time > CURRENT_TIMESTAMP - ?::INTERVAL;', array($userid, '1 month')) >= 2) {
log_debug('sending virusrepeat notification'); log_debug('sending virusrepeat notification');
$data = (object) array('name' => $username, 'id' => $userid); $data = (object) array('username' => $USER->get('username'),
'userid' => $userid,
'fullname' => full_name());
require_once('activity.php'); require_once('activity.php');
activity_occurred('virusrepeat', $data); activity_occurred('virusrepeat', $data);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment