TBA version 0.2 Helium
* Using https://www.jwz.org/base64-shortlinks/ more correctly
* Simple flood protection
+ * Lifetime for each paste.
+ * Deletion of paste older than the lifetime
20191221 version 0.1 Hydrogen
* Documentation
-* lifetime
-* deletion of old ones
* add force download parameter
* HTTPS for selfpaste bash client
* multiple secrets
* extending allowed filetypes
-* creation or even access with basic auth
-* flood protection
\ No newline at end of file
+* creation or even access with basic auth
\ No newline at end of file
--- /dev/null
+The default lifetime of a paste is 7 days. Anything older will be deleted.
+
+The default flood prevention time maximum is 30 sec.
\ No newline at end of file
# needed to respond with the correct link for your paste
# please NO / at the end
define('SELFPASTE_URL','http://your.tld/path/selfpaste/webroot');
+# time in seconds how long a paste will be available. Default 7 days = 604800 sec
+define('SELFPASTE_PASTE_LIFETIME',604800);
+# time in seconds how long the flood protection should take action. Default 30sec
+define('SELFPASTE_FLOOD_LIFETIME',30);
$ret = $this->_checkAllowedFiletype();
$ret = $this->_checkStorage();
$ret = $this->_moveUploadedFile();
+
+ $this->_checkLifetime();
}
catch (Exception $e) {
$ret['message'] = $e->getMessage();
$now = time();
foreach ($iterator as $file) {
if($file->isDot() || $file->isDir() || Summoner::startsWith($file->getFilename(),'.')) continue;
- if ($now - $file->getCTime() >= 30) { // 30 sec
+ if ($now - $file->getCTime() >= SELFPASTE_FLOOD_LIFETIME) {
unlink(SELFPASTE_UPLOAD_DIR.'/'.$file->getFilename());
}
}
}
+
+ /**
+ * delete all pastes older than SELFPASTE_PASTE_LIFETIME
+ */
+ private function _checkLifetime() {
+ $iterator = new RecursiveDirectoryIterator(SELFPASTE_UPLOAD_DIR);
+ $now = time();
+
+ foreach (new RecursiveIteratorIterator($iterator) as $file) {
+ $fname = $file->getFilename();
+ if($file->isDir()
+ || Summoner::startsWith($file->getFilename(),'.')
+ || isset($fname[4])
+ ) continue;
+ if ($now - $file->getCTime() >= SELFPASTE_PASTE_LIFETIME) {
+ unlink(SELFPASTE_UPLOAD_DIR.'/'.$fname);
+ }
+ }
+ }
}
\ No newline at end of file