From 6fd6b92fe828824dee408614805b35fe29177cd2 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Fri, 1 Mar 2013 07:12:17 +0800 Subject: Fix openBoard and boardTitle functions using same caching keys. Added getBoardInfo function that's used by both of the above functions, and can get a board's info without loading it. --- inc/functions.php | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 16b16901..872c6c23 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -328,11 +328,19 @@ function setupBoard($array) { } function openBoard($uri) { + $board = getBoardInfo($uri); + if ($board) { + setupBoard($board); + return true; + } + return false; +} + +function getBoardInfo($uri) { global $config; if ($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) { - setupBoard($board); - return true; + return $board; } $query = prepare("SELECT * FROM `boards` WHERE `uri` = :uri LIMIT 1"); @@ -342,27 +350,16 @@ function openBoard($uri) { if ($board = $query->fetch()) { if ($config['cache']['enabled']) cache::set('board_' . $uri, $board); - setupBoard($board); - return true; + return $board; } return false; } function boardTitle($uri) { - global $config; - if ($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) { + $board = getBoardInfo($uri); + if ($board) return $board['title']; - } - - $query = prepare("SELECT `title` FROM `boards` WHERE `uri` = :uri LIMIT 1"); - $query->bindValue(':uri', $uri); - $query->execute() or error(db_error($query)); - - if ($title = $query->fetch()) { - return $title['title']; - } - return false; } -- cgit v1.3 From b078222ede702b8ecf4b28f5ebd6db5c34b65143 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Sat, 8 Jun 2013 05:55:13 -0500 Subject: Fix "Undefined index: sticky" and "locked" errors on new thread creation. --- inc/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 872c6c23..b83d6c86 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -722,13 +722,13 @@ function post(array $post) { $query->bindValue(':password', $post['password']); $query->bindValue(':ip', isset($post['ip']) ? $post['ip'] : $_SERVER['REMOTE_ADDR']); - if ($post['op'] && $post['mod'] && $post['sticky']) { + if ($post['op'] && $post['mod'] && isset($post['sticky']) && $post['sticky']) { $query->bindValue(':sticky', 1, PDO::PARAM_INT); } else { $query->bindValue(':sticky', 0, PDO::PARAM_INT); } - if ($post['op'] && $post['mod'] && $post['locked']) { + if ($post['op'] && $post['mod'] && isset($post['locked']) && $post['locked']) { $query->bindValue(':locked', 1, PDO::PARAM_INT); } else { $query->bindValue(':locked', 0, PDO::PARAM_INT); -- cgit v1.3 From 765e64ee38919c48f840403c4910a37fbce037e9 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Wed, 13 Feb 2013 01:25:56 +0800 Subject: m and n dash fix --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index b83d6c86..a9afb450 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1362,8 +1362,8 @@ function unicodify($body) { // En and em- dashes are rendered exactly the same in // most monospace fonts (they look the same in code // editors). - $body = str_replace('--', '–', $body); // en dash $body = str_replace('---', '—', $body); // em dash + $body = str_replace('--', '–', $body); // en dash return $body; } -- cgit v1.3