mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2026-04-19 21:58:08 -04:00
deduplicate logic
This commit is contained in:
+13
-19
@@ -267,31 +267,25 @@ class Filesystem extends AbstractData
|
|||||||
*/
|
*/
|
||||||
public function setValue($value, $namespace, $key = '')
|
public function setValue($value, $namespace, $key = '')
|
||||||
{
|
{
|
||||||
|
$file = $this->_path . DIRECTORY_SEPARATOR . $namespace . '.php';
|
||||||
|
if (function_exists('opcache_invalidate')) {
|
||||||
|
opcache_invalidate($file);
|
||||||
|
}
|
||||||
switch ($namespace) {
|
switch ($namespace) {
|
||||||
case 'purge_limiter':
|
case 'purge_limiter':
|
||||||
if (function_exists('opcache_invalidate')) {
|
$content = '<?php' . PHP_EOL . '$GLOBALS[\'purge_limiter\'] = ' . var_export($value, true) . ';';
|
||||||
opcache_invalidate($this->_path . DIRECTORY_SEPARATOR . 'purge_limiter.php');
|
break;
|
||||||
}
|
|
||||||
return $this->_storeString(
|
|
||||||
$this->_path . DIRECTORY_SEPARATOR . 'purge_limiter.php',
|
|
||||||
'<?php' . PHP_EOL . '$GLOBALS[\'purge_limiter\'] = ' . var_export($value, true) . ';'
|
|
||||||
);
|
|
||||||
case 'salt':
|
case 'salt':
|
||||||
return $this->_storeString(
|
$content = '<?php # |' . $value . '|';
|
||||||
$this->_path . DIRECTORY_SEPARATOR . 'salt.php',
|
break;
|
||||||
'<?php # |' . $value . '|'
|
|
||||||
);
|
|
||||||
case 'traffic_limiter':
|
case 'traffic_limiter':
|
||||||
$this->_last_cache[$key] = $value;
|
$this->_last_cache[$key] = $value;
|
||||||
if (function_exists('opcache_invalidate')) {
|
$content = '<?php' . PHP_EOL . '$GLOBALS[\'traffic_limiter\'] = ' . var_export($this->_last_cache, true) . ';';
|
||||||
opcache_invalidate($this->_path . DIRECTORY_SEPARATOR . 'traffic_limiter.php');
|
break;
|
||||||
}
|
default:
|
||||||
return $this->_storeString(
|
return false;
|
||||||
$this->_path . DIRECTORY_SEPARATOR . 'traffic_limiter.php',
|
|
||||||
'<?php' . PHP_EOL . '$GLOBALS[\'traffic_limiter\'] = ' . var_export($this->_last_cache, true) . ';'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return false;
|
return $this->_storeString($file, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user