updated doc blocks, comments, fixed indentations, moved some constant strings
This commit is contained in:
parent
b72994f2e0
commit
3327645fd4
5 changed files with 24 additions and 15 deletions
|
@ -15,7 +15,7 @@ namespace PrivateBin\Data;
|
|||
/**
|
||||
* AbstractData
|
||||
*
|
||||
* Abstract model for PrivateBin data access, implemented as a singleton.
|
||||
* Abstract model for data access, implemented as a singleton.
|
||||
*/
|
||||
abstract class AbstractData
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ abstract class AbstractData
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -51,7 +51,7 @@ abstract class AbstractData
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
|
|
|
@ -234,7 +234,7 @@ class Database extends AbstractData
|
|||
|
||||
self::$_cache[$pasteid] = false;
|
||||
try {
|
||||
$paste = self::_select(
|
||||
$paste = self::_select(
|
||||
'SELECT * FROM ' . self::_sanitizeIdentifier('paste') .
|
||||
' WHERE dataid = ?', array($pasteid), true
|
||||
);
|
||||
|
|
|
@ -23,12 +23,19 @@ use PrivateBin\Json;
|
|||
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 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
|
||||
*
|
||||
|
@ -327,8 +334,8 @@ class Filesystem extends AbstractData
|
|||
substr(
|
||||
file_get_contents($filename),
|
||||
strlen(self::PROTECTION_LINE . PHP_EOL)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -453,7 +460,7 @@ class Filesystem extends AbstractData
|
|||
private static function _isFirstLevelDir($element)
|
||||
{
|
||||
return self::_isSecondLevelDir($element) &&
|
||||
is_dir(self::$_path . DIRECTORY_SEPARATOR . $element);
|
||||
is_dir(self::$_path . DIRECTORY_SEPARATOR . $element);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -513,11 +520,15 @@ class Filesystem extends AbstractData
|
|||
if ($fileCreated = @touch($file)) {
|
||||
$writtenBytes = @file_put_contents(
|
||||
$file,
|
||||
'Require all denied' . PHP_EOL,
|
||||
self::HTACCESS_LINE . PHP_EOL,
|
||||
LOCK_EX
|
||||
);
|
||||
);
|
||||
}
|
||||
if ($fileCreated === false || $writtenBytes === false || $writtenBytes < 19) {
|
||||
if (
|
||||
$fileCreated === false ||
|
||||
$writtenBytes === false ||
|
||||
$writtenBytes < strlen(self::HTACCESS_LINE . PHP_EOL)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -533,7 +544,7 @@ class Filesystem extends AbstractData
|
|||
if ($fileCreated === false || $writtenBytes === false || $writtenBytes < strlen($data)) {
|
||||
return false;
|
||||
}
|
||||
@chmod($filename, 0640); // protect file access
|
||||
@chmod($filename, 0640); // protect file from access by other users on the host
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,6 @@ use PrivateBin\Json;
|
|||
|
||||
class GoogleCloudStorage extends AbstractData
|
||||
{
|
||||
const DATETIME_FORMAT = 'Y-m-d\TH:i:s.u\Z';
|
||||
|
||||
/**
|
||||
* returns a Google Cloud Storage data backend.
|
||||
*
|
||||
|
|
|
@ -306,7 +306,7 @@ class StorageObjectStub extends StorageObject
|
|||
$this->_info = $info;
|
||||
$this->_connection = $connection;
|
||||
$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()
|
||||
|
|
Loading…
Reference in a new issue