Added more configuration options, based on patch by Uli Köhler

This commit is contained in:
Simon Rupf
2013-10-30 23:54:42 +01:00
parent b19e4d4689
commit 630e16c4a0
5 changed files with 80 additions and 38 deletions

View File

@@ -69,6 +69,9 @@ class trafficlimiter
*/
public static function canPass($ip)
{
// disable limits if set to less then 1
if (self::$_limit < 1) return true;
// Create storage directory if it does not exist.
if (!is_dir(self::$_path)) mkdir(self::$_path, 0705);
// Create .htaccess file if it does not exist.

View File

@@ -180,32 +180,14 @@ class zerobin
// Read expiration date
if (!empty($_POST['expire']))
{
switch ($_POST['expire'])
{
case 'burn':
$meta['burnafterreading'] = true;
break;
case '5min':
$meta['expire_date'] = time()+5*60;
break;
case '10min':
$meta['expire_date'] = time()+10*60;
break;
case '1hour':
$meta['expire_date'] = time()+60*60;
break;
case '1day':
$meta['expire_date'] = time()+24*60*60;
break;
case '1week':
$meta['expire_date'] = time()+7*24*60*60;
break;
case '1month':
$meta['expire_date'] = strtotime('+1 month');
break;
case '1year':
$meta['expire_date'] = strtotime('+1 year');
if ($_POST['expire'] == 'burn') {
$meta['burnafterreading'] = true;
} elseif (array_key_exists($_POST['expire'], $this->_conf['expire_options'])) {
$expire = $this->_conf['expire_options'][$_POST['expire']];
} else {
$expire = $this->_conf['expire_options'][$this->_conf['expire']['default']];
}
if ($expire > 0) $meta['expire_date'] = time() + $expire;
}
// Read open discussion flag.
@@ -405,12 +387,24 @@ class zerobin
header('Last-Modified: ' . $time);
header('Vary: Accept');
// label all the expiration options
$expire = array();
foreach ($this->_conf['expire_options'] as $key => $value) {
$expire[$key] = array_key_exists($key, $this->_conf['expire_labels']) ?
$this->_conf['expire_labels'][$key] :
$key;
}
$page = new RainTPL;
// We escape it here because ENT_NOQUOTES can't be used in RainTPL templates.
// we escape it here because ENT_NOQUOTES can't be used in RainTPL templates
$page->assign('CIPHERDATA', htmlspecialchars($this->_data, ENT_NOQUOTES));
$page->assign('ERRORMESSAGE', $this->_error);
$page->assign('OPENDISCUSSION', $this->_conf['main']['opendiscussion']);
$page->assign('VERSION', self::VERSION);
$page->assign('BURNAFTERREADINGSELECTED', $this->_conf['main']['burnafterreadingselected']);
$page->assign('OPENDISCUSSION', $this->_conf['main']['opendiscussion']);
$page->assign('SYNTAXHIGHLIGHTING', $this->_conf['main']['syntaxhighlighting']);
$page->assign('EXPIRE', $expire);
$page->assign('EXPIREDEFAULT', $this->_conf['expire']['default']);
$page->draw('page');
}