Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
elrido committed Jul 18, 2016
1 parent 918de8f commit afaa111
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/i18n.php
Expand Up @@ -306,7 +306,7 @@ protected static function _getPluralForm($n)
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);
Expand Down Expand Up @@ -386,7 +386,7 @@ protected static function _getMatchingLanguage($acceptedLanguages, $availableLan
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;
}
Expand Down
14 changes: 9 additions & 5 deletions lib/persistence.php
Expand Up @@ -45,13 +45,16 @@ public static function setPath($path)
* @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;
}
}
Expand Down Expand Up @@ -92,7 +95,7 @@ protected static function _initialize()
$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) {
Expand All @@ -116,7 +119,8 @@ protected static function _store($filename, $data)
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
Expand Down
12 changes: 6 additions & 6 deletions lib/privatebin/data.php
Expand Up @@ -42,7 +42,7 @@ public static function getInstance($options = null)
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();
}
Expand Down Expand Up @@ -74,7 +74,7 @@ public function create($pasteid, $paste)
*/
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)
);
Expand Down Expand Up @@ -111,7 +111,7 @@ public function delete($pasteid)
$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();

Expand Down Expand Up @@ -289,7 +289,7 @@ private static function _init()
file_put_contents(
self::$_dir . '.htaccess',
'Allow from none' . PHP_EOL .
'Deny from all'. PHP_EOL
'Deny from all' . PHP_EOL
);
}
}
Expand All @@ -311,8 +311,8 @@ private static function _init()
*/
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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/trafficlimiter.php
Expand Up @@ -115,7 +115,7 @@ public static function canPass()
$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)
{
Expand Down

0 comments on commit afaa111

Please sign in to comment.