diff --git a/lib/i18n.php b/lib/i18n.php index c788f2eae..0195f9750 100644 --- a/lib/i18n.php +++ b/lib/i18n.php @@ -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); @@ -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; } diff --git a/lib/persistence.php b/lib/persistence.php index 9dcc59dc1..675891a5f 100644 --- a/lib/persistence.php +++ b/lib/persistence.php @@ -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; } } @@ -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) { @@ -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 diff --git a/lib/privatebin/data.php b/lib/privatebin/data.php index 285c538da..905039531 100644 --- a/lib/privatebin/data.php +++ b/lib/privatebin/data.php @@ -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(); } @@ -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) ); @@ -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(); @@ -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 ); } } @@ -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; } /** diff --git a/lib/trafficlimiter.php b/lib/trafficlimiter.php index 55e040f2b..bd6f4fede 100644 --- a/lib/trafficlimiter.php +++ b/lib/trafficlimiter.php @@ -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) {