mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-03-22 13:10:41 +08:00
Added more configuration options, based on patch by Uli Köhler
This commit is contained in:
parent
b19e4d4689
commit
630e16c4a0
40
cfg/conf.ini
40
cfg/conf.ini
|
@ -11,11 +11,49 @@
|
|||
; enable or disable discussions
|
||||
opendiscussion = true
|
||||
|
||||
; size limit per paste or comment in bytes
|
||||
; enable or disable syntax highlighting
|
||||
syntaxhighlighting = true
|
||||
|
||||
; preselect the burn-after-reading feature by default
|
||||
burnafterreadingselected = false
|
||||
|
||||
; size limit per paste or comment in bytes, default is 2 Mibibytes
|
||||
sizelimit = 2097152
|
||||
|
||||
[expire]
|
||||
; expire value that is selected per default
|
||||
; make sure the value exists in [expire_options]
|
||||
default = "1month"
|
||||
|
||||
[expire_options]
|
||||
; Set each one of these to the number of seconds in the expiration period,
|
||||
; or 0 if it should never expire
|
||||
5min = 300
|
||||
10min = 600
|
||||
1hour = 3600
|
||||
1day = 86400
|
||||
1week = 604800
|
||||
; Well this is not *exactly* one month, it's 30 days:
|
||||
1month = 2592000
|
||||
1year = 31536000
|
||||
never = 0
|
||||
|
||||
[expire_labels]
|
||||
; descriptive labels for the expiration times
|
||||
; must match those in [expire_options]
|
||||
5min = "5 minutes"
|
||||
10min = "10 minutes"
|
||||
1hour = "1 hour"
|
||||
1day = "1 day"
|
||||
1week = "1 week"
|
||||
1month = "1 month"
|
||||
1year = "1 year"
|
||||
never = "Never"
|
||||
|
||||
|
||||
[traffic]
|
||||
; time limit between calls from the same IP address in seconds
|
||||
; Set this to 0 to disable rate limiting.
|
||||
limit = 10
|
||||
dir = PATH "data"
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -51,15 +51,8 @@
|
|||
<button id="clonebutton" onclick="clonePaste();return false;" class="hidden"><img src="img/icon_clone.png#" width="15" height="17" alt="" />Clone</button>
|
||||
<div id="expiration" class="hidden">Expire:
|
||||
<select id="pasteExpiration" name="pasteExpiration">
|
||||
<option value="burn">Burn after reading</option>
|
||||
<option value="5min">5 minutes</option>
|
||||
<option value="10min">10 minutes</option>
|
||||
<option value="1hour">1 hour</option>
|
||||
<option value="1day">1 day</option>
|
||||
<option value="1week">1 week</option>
|
||||
<option value="1month" selected="selected">1 month</option>
|
||||
<option value="1year">1 year</option>
|
||||
<option value="never">Never</option>
|
||||
<option value="burn"{if="$BURNAFTERREADINGSELECTED"} selected="selected"{/if}>Burn after reading</option>{loop="EXPIRE"}
|
||||
<option value="{$key}"{if="!$BURNAFTERREADINGSELECTED && $key == $EXPIREDEFAULT"} selected="selected"{/if}>{$value}</option>{/loop}
|
||||
</select>
|
||||
</div>
|
||||
<div id="remainingtime" class="hidden"></div>
|
||||
|
|
|
@ -5,6 +5,14 @@ class RainTPLTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
private static $error = 'foo bar';
|
||||
|
||||
private static $expire = array(
|
||||
'5min' => '5 minutes',
|
||||
'1hour' => '1 hour',
|
||||
'never' => 'Never',
|
||||
);
|
||||
|
||||
private static $expire_default = '1hour';
|
||||
|
||||
private static $version = 'Version 1.2.3';
|
||||
|
||||
private $_content;
|
||||
|
@ -14,11 +22,17 @@ class RainTPLTest extends PHPUnit_Framework_TestCase
|
|||
/* Setup Routine */
|
||||
$page = new RainTPL;
|
||||
$page::configure(array('cache_dir' => 'tmp/'));
|
||||
|
||||
$page = new RainTPL;
|
||||
// We escape it here because ENT_NOQUOTES can't be used in RainTPL templates.
|
||||
$page->assign('CIPHERDATA', htmlspecialchars(self::$data, ENT_NOQUOTES));
|
||||
$page->assign('ERRORMESSAGE', self::$error);
|
||||
$page->assign('OPENDISCUSSION', false);
|
||||
$page->assign('VERSION', self::$version);
|
||||
$page->assign('BURNAFTERREADINGSELECTED', false);
|
||||
$page->assign('OPENDISCUSSION', false);
|
||||
$page->assign('SYNTAXHIGHLIGHTING', true);
|
||||
$page->assign('EXPIRE', self::$expire);
|
||||
$page->assign('EXPIREDEFAULT', self::$expire_default);
|
||||
ob_start();
|
||||
$page->draw('page');
|
||||
$this->_content = ob_get_contents();
|
||||
|
|
Loading…
Reference in New Issue
Block a user