// Returns an associative array with 'replies' and 'images' keys
// Returns an associative array with 'replies' and 'images' keys
function numPosts($id) {
function numPosts($id) {
global $board;
global $board;
$query = prepare(sprintf("SELECT COUNT(*) AS `replies`, COUNT(NULLIF(`file`, 0)) AS `images` FROM ``posts_%s`` WHERE `thread` = :thread", $board['uri'], $board['uri']));
$query = prepare(sprintf("SELECT COUNT(*) AS `replies`, SUM(`num_files`) AS `images` FROM ``posts_%s`` WHERE `thread` = :thread", $board['uri'], $board['uri']));
@ -260,7 +260,7 @@ if (file_exists($config['has_installed'])) {
$_query->execute() or error(db_error($_query));
$_query->execute() or error(db_error($_query));
}
}
}
}
case 'v0.9.6-dev-9':
case 'v0.9.6-dev-9':
case 'v0.9.6-dev-9 + <ahref="https://github.com/vichan-devel/Tinyboard/">vichan-devel-4.0.3</a>':
case 'v0.9.6-dev-9 + <ahref="https://github.com/vichan-devel/Tinyboard/">vichan-devel-4.0.3</a>':
case 'v0.9.6-dev-9 + <ahref="https://github.com/vichan-devel/Tinyboard/">vichan-devel-4.0.4-gold</a>':
case 'v0.9.6-dev-9 + <ahref="https://github.com/vichan-devel/Tinyboard/">vichan-devel-4.0.4-gold</a>':
case 'v0.9.6-dev-9 + <ahref="https://github.com/vichan-devel/Tinyboard/">vichan-devel-4.0.5-gold</a>':
case 'v0.9.6-dev-9 + <ahref="https://github.com/vichan-devel/Tinyboard/">vichan-devel-4.0.5-gold</a>':
@ -521,6 +521,14 @@ if (file_exists($config['has_installed'])) {
case '4.4.98-pre':
case '4.4.98-pre':
if (!$twig) load_twig();
if (!$twig) load_twig();
$twig->clearCacheFiles();
$twig->clearCacheFiles();
case '4.4.98':
foreach ($boards as &$board) {
query(sprintf('ALTER TABLE ``posts_%s`` ADD `files` text DEFAULT NULL AFTER `bump`;', $board['uri'])) or error(db_error());
query(sprintf('ALTER TABLE ``posts_%s`` ADD `num_files` int(11) DEFAULT 0 AFTER `files`;', $board['uri'])) or error(db_error());
query(sprintf('UPDATE ``posts_%s`` SET `files` = CONCAT(\'[{"file":"\',`filename`,\'", "size":"\',`filesize`,\'", "width":"\',`filewidth`,\'","height":"\',`fileheight`,\'","thumbwidth":"\',`thumbwidth`,\'","thumbheight":"\',`thumbheight`,\'", "file_path":"%s\/src\/\',`filename`,\'","thumb_path":"%s\/thumb\/\',`filename`,\'"}]\') WHERE `file` IS NOT NULL', $board['uri'], $board['uri'], $board['uri'])) or error(db_error());
query(sprintf('ALTER TABLE ``posts_%s`` DROP COLUMN `thumb`, DROP COLUMN `thumbwidth`, DROP COLUMN `thumbheight`, DROP COLUMN `file`, DROP COLUMN `fileheight`, DROP COLUMN `filesize`, DROP COLUMN `filename`', $board['uri'])) or error(db_error());
query(sprintf('ALTER TABLE ``posts_%s`` REBUILD', $board['uri'])) or error(db_error());
query("CREATE TABLE IF NOT EXISTS ``search_queries`` ( `ip` varchar(39) NOT NULL, `time` int(11) NOT NULL, `query` text NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;") or error(db_error());
query("CREATE TABLE IF NOT EXISTS ``search_queries`` ( `ip` varchar(39) NOT NULL, `time` int(11) NOT NULL, `query` text NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;") or error(db_error());
@ -586,7 +594,7 @@ if ($step == 0) {
'required' => false
'required' => false
)
)
);
);
$tests = array(
$tests = array(
array(
array(
'category' => 'PHP',
'category' => 'PHP',
@ -679,6 +687,13 @@ if ($step == 0) {
'required' => false,
'required' => false,
'message' => '(Optional) `gifsicle` was not found or executable; you may not use `convert+gifsicle` for better animated GIF thumbnailing.',
'message' => '(Optional) `gifsicle` was not found or executable; you may not use `convert+gifsicle` for better animated GIF thumbnailing.',
'message' => '(Optional) `md5sum` was not found or executable; file hashing for multiple images will be slower.',
),
array(
array(
'category' => 'File permissions',
'category' => 'File permissions',
'name' => getcwd(),
'name' => getcwd(),
@ -833,9 +848,9 @@ if ($step == 0) {
}
}
file_write($config['has_installed'], VERSION);
file_write($config['has_installed'], VERSION);
if (!file_unlink(__FILE__)) {
/*if (!file_unlink(__FILE__)) {
$page['body'] .= '<divclass="ban"><h2>Delete install.php!</h2><p>I couldn\'t remove <strong>install.php</strong>. You will have to remove it manually.</p></div>';
$page['body'] .= '<divclass="ban"><h2>Delete install.php!</h2><p>I couldn\'t remove <strong>install.php</strong>. You will have to remove it manually.</p></div>';
$query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `file` IS NOT NULL AND `file` != 'deleted' AND `thumb` != 'spoiler' UNION ALL ", $_board['uri'], $_board['uri']);
$query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `files` IS NOT NULL UNION ALL ", $_board['uri'], $_board['uri']);
}
}
$query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_images'], $query);
$query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_images'], $query);
@ -54,10 +54,14 @@
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
openBoard($post['board']);
openBoard($post['board']);
if (isset($post['files']))
$files = json_decode($post['files']);
if ($files[0]->file == 'deleted') continue;
// board settings won't be available in the template file, so generate links now
// board settings won't be available in the template file, so generate links now
if ($posts->rowCount() == ($post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) {
if ($posts->rowCount() == ($post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) {
$ct = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM ``posts_%s`` WHERE `thread` = :thread UNION ALL SELECT COUNT(`id`) FROM ``posts_%s`` WHERE `file` IS NOT NULL AND `thread` = :thread", $post['board'], $post['board']));
$ct = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM ``posts_%s`` WHERE `thread` = :thread UNION ALL SELECT COUNT(`id`) FROM ``posts_%s`` WHERE `files` IS NOT NULL AND `thread` = :thread", $post['board'], $post['board']));