summaryrefslogtreecommitdiff
path: root/inc/functions.php
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-08-27 02:40:50 +1000
committerMichael Save <savetheinternet@tinyboard.org>2012-08-27 02:40:50 +1000
commita9562075f6c17bc848f7a5b1923177ade75f3611 (patch)
treea7674d9d93580a91184b8a7981c2ab5540aec7b4 /inc/functions.php
parentc7a5635f55c4fc270ba6db0e4624d66605642e1d (diff)
parent82c960cc94eddd1a245a8c1d2f102f9165db1530 (diff)
Merge branch 'master' of git://github.com/Yousha/Tinyboard into yousha
Diffstat (limited to 'inc/functions.php')
-rw-r--r--inc/functions.php55
1 files changed, 26 insertions, 29 deletions
diff --git a/inc/functions.php b/inc/functions.php
index eedbf9b9..cba58e52 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -241,6 +241,7 @@ function create_antibot($board, $thread = null) {
function rebuildThemes($action) {
// List themes
$query = query("SELECT `theme` FROM `theme_settings` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error());
+
while ($theme = $query->fetch()) {
rebuildTheme($theme['theme'], $action);
}
@@ -327,6 +328,7 @@ function setupBoard($array) {
function openBoard($uri) {
global $config;
+
if ($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) {
setupBoard($board);
return true;
@@ -341,7 +343,9 @@ function openBoard($uri) {
cache::set('board_' . $uri, $board);
setupBoard($board);
return true;
- } else return false;
+ }
+
+ return false;
}
function boardTitle($uri) {
@@ -356,7 +360,9 @@ function boardTitle($uri) {
if ($title = $query->fetch()) {
return $title['title'];
- } else return false;
+ }
+
+ return false;
}
function purge($uri) {
@@ -546,9 +552,9 @@ function until($timestamp) {
return ($num = round($difference/(60*60*24))) . ' day' . ($num != 1 ? 's' : '');
} elseif ($difference < 60*60*24*365) {
return ($num = round($difference/(60*60*24*7))) . ' week' . ($num != 1 ? 's' : '');
- } else {
- return ($num = round($difference/(60*60*24*365))) . ' year' . ($num != 1 ? 's' : '');
}
+
+ return ($num = round($difference/(60*60*24*365))) . ' year' . ($num != 1 ? 's' : '');
}
function ago($timestamp) {
@@ -563,9 +569,9 @@ function ago($timestamp) {
return ($num = round($difference/(60*60*24))) . ' day' . ($num != 1 ? 's' : '');
} elseif ($difference < 60*60*24*365) {
return ($num = round($difference/(60*60*24*7))) . ' week' . ($num != 1 ? 's' : '');
- } else {
- return ($num = round($difference/(60*60*24*365))) . ' year' . ($num != 1 ? 's' : '');
}
+
+ return ($num = round($difference/(60*60*24*365))) . ' year' . ($num != 1 ? 's' : '');
}
function displayBan($ban) {
@@ -683,7 +689,9 @@ function threadExists($id) {
if ($query->rowCount()) {
return true;
- } else return false;
+ }
+
+ return false;
}
function post(array $post) {
@@ -841,10 +849,7 @@ function rebuildPost($id) {
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
- if (!$post = $query->fetch())
- return false;
-
- if (!$post['body_nomarkup'])
+ if ((!$post = $query->fetch()) || !$post['body_nomarkup'])
return false;
markup($body = &$post['body_nomarkup']);
@@ -1101,10 +1106,7 @@ function makerobot($body) {
}
function checkRobot($body) {
- if (empty($body))
- return true;
-
- if (event('check-robot', $body))
+ if (empty($body) || event('check-robot', $body))
return true;
$body = makerobot($body);
@@ -1114,14 +1116,13 @@ function checkRobot($body) {
if ($query->fetch()) {
return true;
- } else {
- // Insert new hash
-
- $query = prepare("INSERT INTO `robot` VALUES (:hash)");
- $query->bindValue(':hash', $body);
- $query->execute() or error(db_error($query));
- return false;
}
+
+ // Insert new hash
+ $query = prepare("INSERT INTO `robot` VALUES (:hash)");
+ $query->bindValue(':hash', $body);
+ $query->execute() or error(db_error($query));
+ return false;
}
function numPosts($id) {
@@ -1197,7 +1198,6 @@ function checkMute() {
}
}
-
function buildIndex() {
global $board, $config;
@@ -1536,11 +1536,11 @@ function buildThread($id, $return=false, $mod=false) {
'boardlist' => createBoardlist($mod),
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['uri'] . '/' . $config['file_index'])
));
-
+
if ($return)
return $body;
- else
- file_write($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $id), $body);
+
+ file_write($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $id), $body);
}
function rrmdir($dir) {
@@ -1634,8 +1634,6 @@ function fraction($numerator, $denominator, $sep) {
return "{$numerator}{$sep}{$denominator}";
}
-
-
function getPostByHash($hash) {
global $board;
$query = prepare(sprintf("SELECT `id`,`thread` FROM `posts_%s` WHERE `filehash` = :hash", $board['uri']));
@@ -1706,4 +1704,3 @@ function DNS($host) {
return $ip_addr;
}
-