summaryrefslogtreecommitdiff
path: root/inc/functions.php
diff options
context:
space:
mode:
authorMichael <savetheinternet@tinyboard.org>2013-06-18 10:45:13 -0700
committerMichael <savetheinternet@tinyboard.org>2013-06-18 10:45:13 -0700
commit0ac9dd5f25ffd9969786567cf7f3081c39f4e0c7 (patch)
treefd8e8bce38293493b1565147e1bbc3e3fdb7b875 /inc/functions.php
parentcbc3bd0c0a13463dbdbc3d53a03dd9b2080496c4 (diff)
parent399aa463b3d046a49c861a2c60c997f39af22561 (diff)
Merge pull request #115 from Macil/miscfixes
Miscellaneous fixes
Diffstat (limited to 'inc/functions.php')
-rw-r--r--inc/functions.php35
1 files changed, 16 insertions, 19 deletions
diff --git a/inc/functions.php b/inc/functions.php
index cd079141..64a3ca88 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;
}
@@ -725,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);
@@ -1365,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('--', '&ndash;', $body); // en dash
$body = str_replace('---', '&mdash;', $body); // em dash
+ $body = str_replace('--', '&ndash;', $body); // en dash
return $body;
}