updated doc blocks, comments, fixed indentations, moved some constant strings
This commit is contained in:
parent
b72994f2e0
commit
3327645fd4
|
@ -15,7 +15,7 @@ namespace PrivateBin\Data;
|
||||||
/**
|
/**
|
||||||
* AbstractData
|
* AbstractData
|
||||||
*
|
*
|
||||||
* Abstract model for PrivateBin data access, implemented as a singleton.
|
* Abstract model for data access, implemented as a singleton.
|
||||||
*/
|
*/
|
||||||
abstract class AbstractData
|
abstract class AbstractData
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,7 @@ abstract class AbstractData
|
||||||
/**
|
/**
|
||||||
* Enforce singleton, disable constructor
|
* Enforce singleton, disable constructor
|
||||||
*
|
*
|
||||||
* Instantiate using {@link getInstance()}, privatebin is a singleton object.
|
* Instantiate using {@link getInstance()}, this object implements the singleton pattern.
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +51,7 @@ abstract class AbstractData
|
||||||
/**
|
/**
|
||||||
* Enforce singleton, disable cloning
|
* Enforce singleton, disable cloning
|
||||||
*
|
*
|
||||||
* Instantiate using {@link getInstance()}, privatebin is a singleton object.
|
* Instantiate using {@link getInstance()}, this object implements the singleton pattern.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,12 +23,19 @@ use PrivateBin\Json;
|
||||||
class Filesystem extends AbstractData
|
class Filesystem extends AbstractData
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* first line in file, to protect its contents
|
* first line in paste or comment files, to protect their contents from browsing exposed data directories
|
||||||
*
|
*
|
||||||
* @const string
|
* @const string
|
||||||
*/
|
*/
|
||||||
const PROTECTION_LINE = '<?php http_response_code(403); /*';
|
const PROTECTION_LINE = '<?php http_response_code(403); /*';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* line in generated .htaccess files, to protect exposed directories from being browsable on apache web servers
|
||||||
|
*
|
||||||
|
* @const string
|
||||||
|
*/
|
||||||
|
const HTACCESS_LINE = 'Require all denied';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path in which to persist something
|
* path in which to persist something
|
||||||
*
|
*
|
||||||
|
@ -513,11 +520,15 @@ class Filesystem extends AbstractData
|
||||||
if ($fileCreated = @touch($file)) {
|
if ($fileCreated = @touch($file)) {
|
||||||
$writtenBytes = @file_put_contents(
|
$writtenBytes = @file_put_contents(
|
||||||
$file,
|
$file,
|
||||||
'Require all denied' . PHP_EOL,
|
self::HTACCESS_LINE . PHP_EOL,
|
||||||
LOCK_EX
|
LOCK_EX
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($fileCreated === false || $writtenBytes === false || $writtenBytes < 19) {
|
if (
|
||||||
|
$fileCreated === false ||
|
||||||
|
$writtenBytes === false ||
|
||||||
|
$writtenBytes < strlen(self::HTACCESS_LINE . PHP_EOL)
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,7 +544,7 @@ class Filesystem extends AbstractData
|
||||||
if ($fileCreated === false || $writtenBytes === false || $writtenBytes < strlen($data)) {
|
if ($fileCreated === false || $writtenBytes === false || $writtenBytes < strlen($data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@chmod($filename, 0640); // protect file access
|
@chmod($filename, 0640); // protect file from access by other users on the host
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,6 @@ use PrivateBin\Json;
|
||||||
|
|
||||||
class GoogleCloudStorage extends AbstractData
|
class GoogleCloudStorage extends AbstractData
|
||||||
{
|
{
|
||||||
const DATETIME_FORMAT = 'Y-m-d\TH:i:s.u\Z';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a Google Cloud Storage data backend.
|
* returns a Google Cloud Storage data backend.
|
||||||
*
|
*
|
||||||
|
|
|
@ -306,7 +306,7 @@ class StorageObjectStub extends StorageObject
|
||||||
$this->_info = $info;
|
$this->_info = $info;
|
||||||
$this->_connection = $connection;
|
$this->_connection = $connection;
|
||||||
$timeCreated = new Datetime();
|
$timeCreated = new Datetime();
|
||||||
$this->_info['metadata']['timeCreated'] = $timeCreated->format(GoogleCloudStorage::DATETIME_FORMAT);
|
$this->_info['metadata']['timeCreated'] = $timeCreated->format('Y-m-d\TH:i:s.u\Z');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function acl()
|
public function acl()
|
||||||
|
|
Loading…
Reference in New Issue