code style
This commit is contained in:
parent
918de8f0c4
commit
afaa111d22
|
@ -306,7 +306,7 @@ class i18n
|
|||
case 'zh':
|
||||
return ($n > 1 ? 1 : 0);
|
||||
case 'pl':
|
||||
return ($n == 1 ? 0 : $n%10 >= 2 && $n %10 <=4 && ($n%100 < 10 || $n%100 >= 20) ? 1 : 2);
|
||||
return ($n == 1 ? 0 : $n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
// en, de
|
||||
default:
|
||||
return ($n != 1 ? 1 : 0);
|
||||
|
@ -386,7 +386,7 @@ class i18n
|
|||
protected static function _matchLanguage($a, $b) {
|
||||
$a = explode('-', $a);
|
||||
$b = explode('-', $b);
|
||||
for ($i=0, $n=min(count($a), count($b)); $i<$n; $i++)
|
||||
for ($i=0, $n = min(count($a), count($b)); $i < $n; ++$i)
|
||||
{
|
||||
if ($a[$i] !== $b[$i]) break;
|
||||
}
|
||||
|
|
|
@ -45,13 +45,16 @@ abstract class persistence
|
|||
* @access public
|
||||
* @static
|
||||
* @param string $filename
|
||||
* @return void
|
||||
* @return string
|
||||
*/
|
||||
public static function getPath($filename = null)
|
||||
{
|
||||
if(strlen($filename)) {
|
||||
if (strlen($filename))
|
||||
{
|
||||
return self::$_path . DIRECTORY_SEPARATOR . $filename;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return self::$_path;
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +95,7 @@ abstract class persistence
|
|||
$writtenBytes = @file_put_contents(
|
||||
$file,
|
||||
'Allow from none' . PHP_EOL .
|
||||
'Deny from all'. PHP_EOL,
|
||||
'Deny from all' . PHP_EOL,
|
||||
LOCK_EX
|
||||
);
|
||||
if ($writtenBytes === false || $writtenBytes < 30) {
|
||||
|
@ -116,7 +119,8 @@ abstract class persistence
|
|||
self::_initialize();
|
||||
$file = self::$_path . DIRECTORY_SEPARATOR . $filename;
|
||||
$writtenBytes = @file_put_contents($file, $data, LOCK_EX);
|
||||
if ($writtenBytes === false || $writtenBytes < strlen($data)) {
|
||||
if ($writtenBytes === false || $writtenBytes < strlen($data))
|
||||
{
|
||||
throw new Exception('unable to write to file ' . $file, 13);
|
||||
}
|
||||
@chmod($file, 0640); // protect file access
|
||||
|
|
|
@ -42,7 +42,7 @@ class privatebin_data extends privatebin_abstract
|
|||
array_key_exists('dir', $options)
|
||||
) self::$_dir = $options['dir'] . DIRECTORY_SEPARATOR;
|
||||
// if needed initialize the singleton
|
||||
if(!(self::$_instance instanceof privatebin_data)) {
|
||||
if (!(self::$_instance instanceof privatebin_data)) {
|
||||
self::$_instance = new self;
|
||||
self::_init();
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class privatebin_data extends privatebin_abstract
|
|||
*/
|
||||
public function read($pasteid)
|
||||
{
|
||||
if(!$this->exists($pasteid)) return false;
|
||||
if (!$this->exists($pasteid)) return false;
|
||||
$paste = json_decode(
|
||||
file_get_contents(self::_dataid2path($pasteid) . $pasteid)
|
||||
);
|
||||
|
@ -111,7 +111,7 @@ class privatebin_data extends privatebin_abstract
|
|||
$dir = dir($discdir);
|
||||
while (false !== ($filename = $dir->read()))
|
||||
{
|
||||
if (is_file($discdir.$filename)) @unlink($discdir.$filename);
|
||||
if (is_file($discdir . $filename)) @unlink($discdir . $filename);
|
||||
}
|
||||
$dir->close();
|
||||
|
||||
|
@ -289,7 +289,7 @@ class privatebin_data extends privatebin_abstract
|
|||
file_put_contents(
|
||||
self::$_dir . '.htaccess',
|
||||
'Allow from none' . PHP_EOL .
|
||||
'Deny from all'. PHP_EOL
|
||||
'Deny from all' . PHP_EOL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -311,8 +311,8 @@ class privatebin_data extends privatebin_abstract
|
|||
*/
|
||||
private static function _dataid2path($dataid)
|
||||
{
|
||||
return self::$_dir . substr($dataid,0,2) . DIRECTORY_SEPARATOR .
|
||||
substr($dataid,2,2) . DIRECTORY_SEPARATOR;
|
||||
return self::$_dir . substr($dataid, 0, 2) . DIRECTORY_SEPARATOR .
|
||||
substr($dataid, 2, 2) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -115,7 +115,7 @@ class trafficlimiter extends persistence
|
|||
$tl = $GLOBALS['traffic_limiter'];
|
||||
|
||||
// purge file of expired IPs to keep it small
|
||||
foreach($tl as $key => $time)
|
||||
foreach ($tl as $key => $time)
|
||||
{
|
||||
if ($time + self::$_limit < $now)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue