ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
WhitelistFileHeaderPreProcessor.php
Go to the documentation of this file.
1 <?php
2 
4 
10 
21 {
23 
27  private $fileHeader;
32 
33 
39  public function __construct($fileHeader)
40  {
41  $this->stringTypeCheck($fileHeader, 'fileHeader');
42 
43  $this->fileHeaderLength = strlen($fileHeader);
44  $this->fileHeader = $fileHeader;
45  }
46 
47 
51  public function process(FileStream $stream, Metadata $metadata)
52  {
53  $header = $stream->read($this->fileHeaderLength);
54  if (strcmp($this->fileHeader, $header) === 0) {
55  return new ProcessingStatus(ProcessingStatus::OK, 'File header complies with whitelist.');
56  }
57 
58  return new ProcessingStatus(ProcessingStatus::REJECTED, 'File header don\'t complies with whitelist.');
59  }
60 }
const REJECTED
Upload got rejected by a processor.
__construct($fileHeader)
WhitelistFileHeaderPreProcessor constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface FileStream The base interface for all filesystem streams.
Definition: FileStream.php:17