introducing automatic purging of expired pastes, triggered by default at least 5 minutes apart, deleting a maximum of 10 pastes - resolves #3
This commit is contained in:
@@ -302,7 +302,7 @@ class privatebin_db extends privatebin_abstract
|
||||
* Test if a paste exists.
|
||||
*
|
||||
* @access public
|
||||
* @param string $dataid
|
||||
* @param string $pasteid
|
||||
* @return void
|
||||
*/
|
||||
public function exists($pasteid)
|
||||
@@ -381,7 +381,7 @@ class privatebin_db extends privatebin_abstract
|
||||
* Test if a comment exists.
|
||||
*
|
||||
* @access public
|
||||
* @param string $dataid
|
||||
* @param string $pasteid
|
||||
* @param string $parentid
|
||||
* @param string $commentid
|
||||
* @return void
|
||||
@@ -395,6 +395,30 @@ class privatebin_db extends privatebin_abstract
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns up to batch size number of paste ids that have expired
|
||||
*
|
||||
* @access private
|
||||
* @param int $batchsize
|
||||
* @return array
|
||||
*/
|
||||
protected function _getExpiredPastes($batchsize)
|
||||
{
|
||||
$pastes = array();
|
||||
$rows = self::_select(
|
||||
'SELECT dataid FROM ' . self::_sanitizeIdentifier('paste') .
|
||||
' WHERE expiredate < ? LIMIT ?', array(time(), $batchsize)
|
||||
);
|
||||
if (count($rows))
|
||||
{
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$pastes[] = $row['dataid'];
|
||||
}
|
||||
}
|
||||
return $pastes;
|
||||
}
|
||||
|
||||
/**
|
||||
* execute a statement
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user