Beispiel #1
0
 /**
  * Constructor.
  *
  * @param string|bool $key
  *
  * @throws PathNotFoundException
  * @throws WrongPermissionException
  */
 public function __construct($key)
 {
     $this->crypto = new Crypto(new Core());
     if ($key === true) {
         $keyFile = GlobalConfig::getConfigDir() . 'encryption_key';
         if (!file_exists($keyFile) || !is_file($keyFile) || !is_readable($keyFile)) {
             throw new PathNotFoundException($keyFile);
         }
         if (fileperms($keyFile) != 0600) {
             chmod($keyFile, 0600);
         }
         $this->key = file_get_contents($keyFile);
         return;
     }
     if (file_exists($key) && is_file($key) && is_readable($key)) {
         if (fileperms($key) != 0600) {
             throw new WrongPermissionException($key, fileperms($key), '0600');
         }
         $this->key = file_get_contents($key);
         return;
     }
     if (is_string($key)) {
         $this->key = $key;
         return;
     }
     throw new InvalidArgumentException('Invalid encrypt value.');
 }
Beispiel #2
0
 /**
  * SyncSettings constructor.
  *
  * @param array        $excludeInput
  * @param array        $excludeOutput
  * @param bool         $skipInputErrors
  * @param bool         $skipOutputErrors
  * @param bool         $delete
  * @param bool         $versioning
  * @param bool         $encrypt
  * @param string|array $to
  * @param string       $cron
  * @param int          $timeout
  * @param string       $timezone
  * @param null         $cronConfig
  * @param bool         $checkFileSize
  */
 public function __construct($excludeInput = [], $excludeOutput = [], $skipInputErrors = true, $skipOutputErrors = true, $delete = true, $versioning = false, $encrypt = false, $to = null, $cron = null, $timeout = 600, $timezone = 'Europe/Berlin', $cronConfig = null, $checkFileSize = true)
 {
     $this->excludeInput = $excludeInput;
     $this->excludeOutput = $excludeOutput;
     $this->ignoreInput = $skipInputErrors;
     $this->ignoreOutput = $skipOutputErrors;
     $this->delete = $delete;
     $this->versioning = $versioning;
     $this->encrypt = $encrypt;
     $this->to = $to;
     $this->cron = $cron;
     $this->timeout = $timeout;
     $this->timezone = $timezone;
     $this->checkFileSize = $checkFileSize;
     $this->cronConfig = $cronConfig ? $cronConfig : GlobalConfig::getConfigDir();
 }