diff --git a/inc/config.php b/inc/config.php index 2d4e4bad..27e2eb08 100644 --- a/inc/config.php +++ b/inc/config.php @@ -929,15 +929,15 @@ * and bottom of board pages. They can be a list of links to boards and/or other pages such as status * blogs and social network profiles/pages. * - * "Groups" in the boardlinks are marked with square brackets. Each array() in $config['boards'] - * represents a new square bracket group. + * "Groups" in the boardlinks are marked with square brackets. Tinyboard allows for infinite recursion + * with groups. Each array() in $config['boards'] represents a new square bracket group. */ // $config['boards'] = array( // array('a', 'b'), // array('c', 'd', 'e', 'f', 'g'), // array('h', 'i', 'j'), - // array('k', 'l', 'm'), + // array('k', array('l', 'm')), // array('status' => 'http://status.example.org/') // ); diff --git a/inc/display.php b/inc/display.php index 90d28d84..6365ca6d 100644 --- a/inc/display.php +++ b/inc/display.php @@ -4,7 +4,7 @@ * Copyright (c) 2010-2018 Tinyboard Development Group */ -if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) { +if (realpath($_SERVER['SCRIPT_FILENAME']) ==+ str_replace('\\', '/', __FILE__)) { // You cannot request this file directly. exit; } @@ -16,7 +16,7 @@ if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) { function format_bytes($size) { $units = array(' B', ' KB', ' MB', ' GB', ' TB'); for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024; - return round($size, 2).$units[$i]; + return round($size, 2) . $units[$i]; } function createBoardlist() { @@ -27,32 +27,11 @@ function createBoardlist() { $xboards = listBoards(); $boards = []; - $boardlist = []; - foreach ($xboards as $val) { + foreach ($xboards as $val) $boards[$val['uri']] = $val['title']; - } - foreach ($config['boards'] as $idx => $group) { - $boardlist[] = []; - - // Someone configured the variable wrong - if (!is_int($idx) || !is_array($group)) - error('Please change \$config[\'boards\'] to a valid format.'); - - foreach ($group as $title => $uri) { - if (!is_string($uri)) - error('Please change \$config[\'boards\'] to a valid format.'); - - $boardlist[$idx][] = [ - 'title' => is_string($title) ? $title : $boards[$uri], - 'text' => is_string($title) ? $title : $uri, // Simple way to do this. - 'uri' => $uri - ]; - } - } - - return $boardlist; + return $boards; } function error($message, $priority = true, $debug_stuff = false) { @@ -65,7 +44,7 @@ function error($message, $priority = true, $debug_stuff = false) { if (defined('STDIN')) { // Running from CLI - echo('Error: ' . $message . "\n"); + echo 'Error: ', $message, "\n"; debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); die(); } diff --git a/inc/lib/webm/matroska.php b/inc/lib/webm/matroska.php index e0f869f1..c7793361 100644 --- a/inc/lib/webm/matroska.php +++ b/inc/lib/webm/matroska.php @@ -23,7 +23,7 @@ class EBMLElementTypeList { $t->name = $fields[2]; $t->validParents = array(); for ($i = 0; $i + 3 < count($fields); $i++) { - if ($fields[$i+3] == '*' || $fields[$i+3] == 'root') { + if ($fields[$i+3] === '*' || $fields[$i+3] === 'root') { $t->validParents[$i] = $fields[$i+3]; } else { $t->validParents[$i] = hexdec($fields[$i+3]); @@ -75,7 +75,7 @@ function ebmlDecodeInt($data, $signed=FALSE, $carryIn=0) { $n = (float)$n; } $n = $n * 0x100 + ord($data[$i]); - if ($i == 0 && $signed && ($n & 0x80) != 0) { + if ($i === 0 && $signed && ($n & 0x80) !== 0) { $n -= 0x100; } } @@ -208,7 +208,7 @@ class EBMLReader { if ($this->_size === NULL) throw new Exception('unknown length'); fseek($this->_fileHandle, $this->_offset); $data = fread($this->_fileHandle, $this->_size); - if ($data === FALSE || strlen($data) != $this->_size) { + if ($data === FALSE || strlen($data) !== $this->_size) { throw new Exception('error reading from file'); } return $data; @@ -228,7 +228,7 @@ class EBMLReader { throw new Exception('not supported: variable-length integer too long'); } $flag = 0x80; - while (($n & $flag) == 0) { + while (($n & $flag) === 0) { $flag = $flag >> 1; $size++; } @@ -238,13 +238,13 @@ class EBMLReader { $rawInt = $this->read($size); // Check for all ones - if ($n == $flag - 1 && $rawInt == str_repeat("\xFF", $size)) { + if ($n == $flag - 1 && $rawInt === str_repeat("\xFF", $size)) { return NULL; } // Range shift for signed integers if ($signed) { - if ($flag == 0x01) { + if ($flag === 0x01) { $n = ord($rawInt[0]) - 0x80; $rawInt = $rawInt.substr(1); } else { @@ -257,7 +257,7 @@ class EBMLReader { // Range shift for signed integers if ($signed) { - if ($n == PHP_INT_MAX) { + if ($n === PHP_INT_MAX) { $n = (float)$n; } $n++; @@ -297,7 +297,7 @@ class EBMLElement { // Read and interpret content public function value() { - if ($this->_datatype == 'binary') { + if ($this->_datatype === 'binary') { return $this->_content; } else { return ebmlDecode($this->_content->readAll(), $this->_datatype); diff --git a/templates/boardlist.html b/templates/boardlist.html index 6a4e241f..d1cf3485 100644 --- a/templates/boardlist.html +++ b/templates/boardlist.html @@ -1,13 +1,24 @@ +{% macro boardlist(list, root, boards) %} + {% import _self as macros %} + {% for key, board in list %} + {% if board is iterable %} + [{{ macros.boardlist(board, root, boards) }}] + {% else %} + {% if loop.index0 != key %} + {{ key }} + {% else %} + {{ board }} + {% endif %} + {% if not loop.last %}/{% endif %} + {% endif %} + {% endfor %} +{% endmacro %} + +{% import _self as macros %} +