aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/5.3.10_viruscheck_for_uploads.php
blob: 8abc6bbfc24eb2fe9f996c17d1a9fa8ffab8a533 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php

class ViruscheckForUploads extends Migration
{
    public function description()
    {
        return 'Provide config options for ClamAV usage on file uploads';
    }

    public function up()
    {
        $query = "INSERT IGNORE INTO `config` (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`,
                    `description`)
                  VALUES (:name, :value, :type, :range, :section, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)";

        $statement = DBManager::get()->prepare($query);
        $statement->execute([
            'name'        => 'VIRUSSCAN_ON_UPLOAD',
            'description' => 'Sollen Dateien beim Upload mit ClamAV auf Viren überprüft werden?',
            'type'        => 'boolean',
            'range'       => 'global',
            'section'     => 'files',
            'value'       => '0'
        ]);
        $statement->execute([
            'name'        => 'VIRUSSCAN_SOCKET',
            'description' => 'Pfad zum Unix Socket (wird statt TCP verwendet, falls etwas eingetragen ist)',
            'type'        => 'string',
            'range'       => 'global',
            'section'     => 'files',
            'value'       => '/var/run/clamav/clamd.ctl'
        ]);
        $statement->execute([
            'name'        => 'VIRUSSCAN_HOST',
            'description' => 'Host des Virenscanners (wird nur verwendet, falls kein Socket eingetragen ist)',
            'type'        => 'string',
            'range'       => 'global',
            'section'     => 'files',
            'value'       => '127.0.0.1'
        ]);
        $statement->execute([
            'name'        => 'VIRUSSCAN_PORT',
            'description' => 'Port des Virenscanners (wird nur verwendet, falls kein Socket eingetragen ist)',
            'type'        => 'integer',
            'range'       => 'global',
            'section'     => 'files',
            'value'       => 3310
        ]);
        $statement->execute([
            'name'        => 'VIRUSSCAN_MAX_STREAMLENGTH',
            'description' => 'Maximale Streamlänge in Bytes, die beim Virenscanner erlaubt ist',
            'type'        => 'integer',
            'range'       => 'global',
            'section'     => 'files',
            'value'       => 26214400
        ]);
    }

    public function down()
    {
        $query = "DELETE `config`, `config_values`
                  FROM `config`
                  LEFT JOIN `config_values` USING (`field`)
                  WHERE `field` IN (
                      'VIRUSSCAN_ON_UPLOAD',
                      'VIRUSSCAN_SOCKET',
                      'VIRUSSCAN_HOST',
                      'VIRUSSCAN_PORT',
                      'VIRUSSCAN_MAX_STREAMLENGTH'
                  )";
        DBManager::get()->exec($query);
    }
}