implemented JSON file conversion on purge and storage in PHP files for data leak protection

This commit is contained in:
El RIDO
2017-10-08 11:03:17 +02:00
parent 577586c47f
commit 4f06feef81
10 changed files with 127 additions and 136 deletions

View File

@@ -22,6 +22,13 @@ use PrivateBin\Json;
*/
class DataStore extends AbstractPersistence
{
/**
* First line in JSON files, to hide contents
*
* @const string
*/
const PROTECTION_LINE = '<?php http_response_code(403); /*';
/**
* store the data
*
@@ -38,7 +45,7 @@ class DataStore extends AbstractPersistence
$filename = substr($filename, strlen($path));
}
try {
self::_store($filename, Json::encode($data));
self::_store($filename, self::PROTECTION_LINE . PHP_EOL . Json::encode($data));
return true;
} catch (Exception $e) {
return false;