folding Persistance\ServerSalt into Data\Filesystem

This commit is contained in:
El RIDO
2021-06-08 22:01:29 +02:00
parent b5a6ce323e
commit 7901ec74a7
12 changed files with 80 additions and 196 deletions

View File

@@ -13,6 +13,7 @@
namespace PrivateBin\Persistence;
use Exception;
use PrivateBin\Data\AbstractData;
/**
* ServerSalt
@@ -71,20 +72,12 @@ class ServerSalt extends AbstractPersistence
return self::$_salt;
}
if (self::_exists(self::$_file)) {
if (is_readable(self::getPath(self::$_file))) {
$items = explode('|', file_get_contents(self::getPath(self::$_file)));
}
if (!isset($items) || !is_array($items) || count($items) != 3) {
throw new Exception('unable to read file ' . self::getPath(self::$_file), 20);
}
self::$_salt = $items[1];
$salt = self::$_store->getValue('salt');
if ($salt) {
self::$_salt = $salt;
} else {
self::$_salt = self::generate();
self::_store(
self::$_file,
'<?php # |' . self::$_salt . '|'
);
self::$_store->setValue(self::$_salt, 'salt');
}
return self::$_salt;
}
@@ -94,11 +87,11 @@ class ServerSalt extends AbstractPersistence
*
* @access public
* @static
* @param string $path
* @param AbstractData $store
*/
public static function setPath($path)
public static function setStore(AbstractData $store)
{
self::$_salt = '';
parent::setPath($path);
parent::setStore($store);
}
}