Skip to content

Commit

Permalink
Antivirus: whitespace cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bartv2 committed Jan 8, 2013
1 parent 73e78b3 commit 3e647ae
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions files_antivirus/lib/clamav.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
define('CLAMAV_SCANRESULT_INFECTED', 1);

class OC_Files_Antivirus {
public static function av_scan($path) {

public static function av_scan($path) {
$path=$path[\OC_Filesystem::signal_param_path];
if ($path != '') {
$files_view = \OCP\Files::getStorage("files");
Expand All @@ -57,17 +57,17 @@ public static function av_scan($path) {
$from = 'security-noreply@' . OCP\Util::getServerHost();
\OC_MAIL::send($email, OC_User::getUser(), 'Malware detected', $msg, $from, 'ownCloud', 1);
}
exit();
exit();
break;

case CLAMAV_SCANRESULT_CLEAN:
//do nothing
break;
}
}
}
}
}

private static function clamav_scan($filepath) {
$av_mode = \OCP\Config::getAppValue('files_antivirus', 'av_mode', 'executable');
switch($av_mode) {
Expand All @@ -77,25 +77,25 @@ private static function clamav_scan($filepath) {
return self::_clamav_scan_via_exec($filepath);
}
}

private static function _clamav_scan_via_daemon($filepath) {
$av_host = \OCP\Config::getAppValue('files_antivirus', 'av_host', '');
$av_port = \OCP\Config::getAppValue('files_antivirus', 'av_port', '');
$av_chunk_size = \OCP\Config::getAppValue('files_antivirus', 'av_chunk_size', '1024');

// try to open a socket to clamav
$shandler = ($av_host && $av_port) ? @fsockopen($av_host, $av_port) : false;
if(!$shandler) {
\OCP\Util::writeLog('files_antivirus', 'The clamav module is not configured for daemon mode.', \OCP\Util::ERROR);
return false;
}

$fhandler = fopen($filepath, "r");
if(!$fhandler) {
\OCP\Util::writeLog('files_antivirus', 'File could not be open.', \OCP\Util::ERROR);
return false;
}

// request scan from the daemon
fwrite($shandler, "nINSTREAM\n");
while (!feof($fhandler)) {
Expand Down Expand Up @@ -130,8 +130,7 @@ private static function _clamav_scan_via_daemon($filepath) {
return CLAMAV_SCANRESULT_UNCHECKED;
}
}



private static function _clamav_scan_via_exec($filepath) {
\OCP\Util::writeLog('files_antivirus', 'Exec scan: '.$filepath, \OCP\Util::DEBUG);
// get the path to the executable
Expand Down Expand Up @@ -163,7 +162,7 @@ private static function _clamav_scan_via_exec($filepath) {
case 1:
$line = 0;
$report = array();
while ( strpos($output[$line], "--- SCAN SUMMARY ---") === FALSE ) {
while ( strpos($output[$line], "--- SCAN SUMMARY ---") === FALSE ) {
if (preg_match('/.*: (.*) FOUND$/', $output[$line], $matches)) {
$report[] = $matches[1];
}
Expand Down

0 comments on commit 3e647ae

Please sign in to comment.