Constants

PROTECTION_LINE

PROTECTION_LINE

first line in paste or comment files, to protect their contents from browsing exposed data directories

HTACCESS_LINE

HTACCESS_LINE

line in generated .htaccess files, to protect exposed directories from being browsable on apache web servers

Properties

$_last_cache

$_last_cache :array

cache for the traffic limiter

Type

array

$_path

$_path :string

path in which to persist something

Type

string

Methods

getInstance()

getInstance(array  $options): \PrivateBin\Data\Filesystem

get instance of singleton

Parameters

array $options

Returns

\PrivateBin\Data\Filesystem

create()

create(string  $pasteid,array  $paste): boolean

Create a paste.

Parameters

string $pasteid
array $paste

Returns

boolean

read()

read(string  $pasteid): array|false

Read a paste.

Parameters

string $pasteid

Returns

array|false

delete()

delete(string  $pasteid)

Delete a paste and its discussion.

Parameters

string $pasteid

exists()

exists(string  $pasteid): boolean

Test if a paste exists.

Parameters

string $pasteid

Returns

boolean

createComment()

createComment(string  $pasteid,string  $parentid,string  $commentid,array  $comment): boolean

Create a comment in a paste.

Parameters

string $pasteid
string $parentid
string $commentid
array $comment

Returns

boolean

readComments()

readComments(string  $pasteid): array

Read all comments of paste.

Parameters

string $pasteid

Returns

array

existsComment()

existsComment(string  $pasteid,string  $parentid,string  $commentid): boolean

Test if a comment exists.

Parameters

string $pasteid
string $parentid
string $commentid

Returns

boolean

purgeValues()

purgeValues(string  $namespace,integer  $time): void

Purge outdated entries.

Parameters

string $namespace
integer $time

setValue()

setValue(string  $value,string  $namespace,string  $key = ''): boolean

Save a value.

Parameters

string $value
string $namespace
string $key

Returns

boolean

getValue()

getValue(string  $namespace,string  $key = ''): string

Load a value.

Parameters

string $namespace
string $key

Returns

string

purge()

purge(integer  $batchsize)

Perform a purge of old pastes, at most the given batchsize is deleted.

Parameters

integer $batchsize

__construct()

__construct()

Enforce singleton, disable constructor

Instantiate using \getInstance(), this object implements the singleton pattern.

_getExpiredPastes()

_getExpiredPastes(integer  $batchsize): array

Returns up to batch size number of paste ids that have expired

Parameters

integer $batchsize

Returns

array

getOpenSlot()

getOpenSlot(array  $comments,integer|string  $postdate): integer|string

Get next free slot for comment from postdate.

Parameters

array $comments
integer|string $postdate

Returns

integer|string

upgradePreV1Format()

upgradePreV1Format(array  $paste): array

Upgrade pre-version 1 pastes with attachment to version 1 format.

Parameters

array $paste

Returns

array

__clone()

__clone()

Enforce singleton, disable cloning

Instantiate using \getInstance(), this object implements the singleton pattern.

_get()

_get(string  $filename): array|false

get the data

Parameters

string $filename

Returns

array|false —

$data

_dataid2path()

_dataid2path(string  $dataid): string

Convert paste id to storage path.

The idea is to creates subdirectories in order to limit the number of files per directory. (A high number of files in a single directory can slow things down.) eg. "f468483c313401e8" will be stored in "data/f4/68/f468483c313401e8" High-trafic websites may want to deepen the directory structure (like Squid does).

eg. input 'e3570978f9e4aa90' --> output 'data/e3/57/'

Parameters

string $dataid

Returns

string

_dataid2discussionpath()

_dataid2discussionpath(string  $dataid): string

Convert paste id to discussion storage path.

eg. input 'e3570978f9e4aa90' --> output 'data/e3/57/e3570978f9e4aa90.discussion/'

Parameters

string $dataid

Returns

string

_isFirstLevelDir()

_isFirstLevelDir(string  $element): boolean

Check that the given element is a valid first level directory.

Parameters

string $element

Returns

boolean

_isSecondLevelDir()

_isSecondLevelDir(string  $element): boolean

Check that the given element is a valid second level directory.

Parameters

string $element

Returns

boolean

_store()

_store(string  $filename,array  $data): boolean

store the data

Parameters

string $filename
array $data

Returns

boolean

_storeString()

_storeString(string  $filename,string  $data): boolean

store a string

Parameters

string $filename
string $data

Returns

boolean

_prependRename()

_prependRename(string  $srcFile,string  $destFile): void

rename a file, prepending the protection line at the beginning

Parameters

string $srcFile
string $destFile