From 8921eb9c1a43e13e096fe72850d75dcf2974483f Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Fri, 30 Aug 2013 08:38:14 +1000 Subject: Bugfix: pm_unreadcount cache not working correctly --- inc/mod/pages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/mod') diff --git a/inc/mod/pages.php b/inc/mod/pages.php index e782b09b..043b9a5c 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -92,7 +92,7 @@ function mod_dashboard() { } } - if (!$config['cache']['enabled'] || ($args['unread_pms'] = cache::get('pm_unreadcount_' . $mod['id'])) == false) { + if (!$config['cache']['enabled'] || ($args['unread_pms'] = cache::get('pm_unreadcount_' . $mod['id'])) === false) { $query = prepare('SELECT COUNT(*) FROM ``pms`` WHERE `to` = :id AND `unread` = 1'); $query->bindValue(':id', $mod['id']); $query->execute() or error(db_error($query)); -- cgit v1.3 From 46d41cd2a7bce8e81b0deec2022a1393e155fe32 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Fri, 30 Aug 2013 15:00:33 +1000 Subject: More track_cites work --- inc/functions.php | 32 ++++++++++++++++---------------- inc/mod/pages.php | 17 +++++++++-------- 2 files changed, 25 insertions(+), 24 deletions(-) (limited to 'inc/mod') diff --git a/inc/functions.php b/inc/functions.php index 6c18ce3e..ccf21c9e 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -168,21 +168,21 @@ function loadConfig() { if (preg_match('/^\:\:(ffff\:)?(\d+\.\d+\.\d+\.\d+)$/', $__ip, $m)) $_SERVER['REMOTE_ADDR'] = $m[2]; - if (_setlocale(LC_ALL, $config['locale']) === false) { - $error('The specified locale (' . $config['locale'] . ') does not exist on your platform!'); - } - - if (extension_loaded('gettext')) { - bindtextdomain('tinyboard', './inc/locale'); - bind_textdomain_codeset('tinyboard', 'UTF-8'); - textdomain('tinyboard'); - } else { - _bindtextdomain('tinyboard', './inc/locale'); - _bind_textdomain_codeset('tinyboard', 'UTF-8'); - _textdomain('tinyboard'); + if ($config['locale'] != 'en') { + if (_setlocale(LC_ALL, $config['locale']) === false) { + $error('The specified locale (' . $config['locale'] . ') does not exist on your platform!'); + } + if (extension_loaded('gettext')) { + bindtextdomain('tinyboard', './inc/locale'); + bind_textdomain_codeset('tinyboard', 'UTF-8'); + textdomain('tinyboard'); + } else { + _bindtextdomain('tinyboard', './inc/locale'); + _bind_textdomain_codeset('tinyboard', 'UTF-8'); + _textdomain('tinyboard'); + } } - if ($config['syslog']) openlog('tinyboard', LOG_ODELAY, LOG_SYSLOG); // open a connection to sysem logger @@ -996,7 +996,7 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) { $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); - $query = prepare("SELECT `board`, `post` FROM ``cites`` WHERE `target_board` = :board AND (`target` = " . implode(' OR `target` = ', $ids) . ")"); + $query = prepare("SELECT `board`, `post` FROM ``cites`` WHERE `target_board` = :board AND (`target` = " . implode(' OR `target` = ', $ids) . ") ORDER BY `board`"); $query->bindValue(':board', $board['uri']); $query->execute() or error(db_error($query)); while ($cite = $query->fetch(PDO::FETCH_ASSOC)) { @@ -1011,10 +1011,10 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) { if (isset($tmp_board)) openBoard($tmp_board); - $query = prepare("DELETE FROM ``cites`` WHERE (`target_board` = :board AND `target` = (" . implode(' OR `target` = ', $ids) . ")) OR (`board` = :board AND (`post` = " . implode(' OR `post` = ', $ids) . "))"); + $query = prepare("DELETE FROM ``cites`` WHERE (`target_board` = :board AND (`target` = " . implode(' OR `target` = ', $ids) . ")) OR (`board` = :board AND (`post` = " . implode(' OR `post` = ', $ids) . "))"); $query->bindValue(':board', $board['uri']); $query->execute() or error(db_error($query)); - + if (isset($rebuild) && $rebuild_after) { buildThread($rebuild); } diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 043b9a5c..afd8daf3 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1001,7 +1001,7 @@ function mod_bumplock($board, $unbumplock, $post) { } function mod_move($originBoard, $postID) { - global $board, $config, $mod; + global $board, $config, $mod, $pdo; if (!openBoard($originBoard)) error($config['error']['noboard']); @@ -1118,13 +1118,14 @@ function mod_move($originBoard, $postID) { $clone($post['file_thumb'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $post['thumb']); } - foreach ($post['tracked_cites'] as $cite) { - $query = prepare('INSERT INTO ``cites`` VALUES (:board, :post, :target_board, :target)'); - $query->bindValue(':board', $board['uri']); - $query->bindValue(':post', $newPostID, PDO::PARAM_INT); - $query->bindValue(':target_board',$cite[0]); - $query->bindValue(':target', $cite[1], PDO::PARAM_INT); - $query->execute() or error(db_error($query)); + if (!empty($post['tracked_cites'])) { + $insert_rows = array(); + foreach ($post['tracked_cites'] as $cite) { + $insert_rows[] = '(' . + $pdo->quote($board['uri']) . ', ' . $newPostID . ', ' . + $pdo->quote($cite[0]) . ', ' . (int)$cite[1] . ')'; + } + query('INSERT INTO ``cites`` VALUES ' . implode(', ', $insert_rows)) or error(db_error());; } } -- cgit v1.3 From d166fc70bd6378c3f72b7f40e71a79fcb63bc1f2 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sat, 31 Aug 2013 13:23:29 +1000 Subject: Fix \t in posts (editing posts, and HTML Tidy) --- inc/functions.php | 8 ++++---- inc/mod/pages.php | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'inc/mod') diff --git a/inc/functions.php b/inc/functions.php index ccf21c9e..b9d135cf 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1580,9 +1580,6 @@ function markup(&$body, $track_cites = false) { } } - // replace tabs with 8 spaces - $body = str_replace("\t", ' ', $body); - $tracked_cites = array(); // Cites @@ -1748,6 +1745,7 @@ function markup(&$body, $track_cites = false) { if ($config['markup_repair_tidy']) { $tidy = new tidy(); + $body = str_replace("\t", ' ', $body); $body = $tidy->repairString($body, array( 'doctype' => 'omit', 'bare' => true, @@ -1759,10 +1757,12 @@ function markup(&$body, $track_cites = false) { 'output-html' => true, 'newline' => 'LF', 'quiet' => true, - ), 'utf8'); $body = str_replace("\n", '', $body); } + + // replace tabs with 8 spaces + $body = str_replace("\t", ' ', $body); return $tracked_cites; } diff --git a/inc/mod/pages.php b/inc/mod/pages.php index afd8daf3..202ea182 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1317,6 +1317,8 @@ function mod_edit_post($board, $edit_raw_html, $postID) { $post['body'] = str_replace("\n", ' ', utf8tohtml($post['body'])); $post['body_nomarkup'] = str_replace("\r", '', $post['body_nomarkup']); $post['body'] = str_replace("\r", '', $post['body']); + $post['body_nomarkup'] = str_replace("\t", ' ', $post['body_nomarkup']); + $post['body'] = str_replace("\t", ' ', $post['body']); } mod_page(_('Edit post'), 'mod/edit_post_form.html', array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post)); -- cgit v1.3 From 8d14ef6bf70179018cb7b6d71f2b4a873640e6e6 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sat, 31 Aug 2013 13:33:26 +1000 Subject: lol --- inc/mod/pages.php | 2 +- post.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/mod') diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 202ea182..2997ba6b 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1125,7 +1125,7 @@ function mod_move($originBoard, $postID) { $pdo->quote($board['uri']) . ', ' . $newPostID . ', ' . $pdo->quote($cite[0]) . ', ' . (int)$cite[1] . ')'; } - query('INSERT INTO ``cites`` VALUES ' . implode(', ', $insert_rows)) or error(db_error());; + query('INSERT INTO ``cites`` VALUES ' . implode(', ', $insert_rows)) or error(db_error()); } } diff --git a/post.php b/post.php index de4bc07d..864438b1 100644 --- a/post.php +++ b/post.php @@ -689,7 +689,7 @@ if (isset($_POST['delete'])) { $pdo->quote($board['uri']) . ', ' . (int)$id . ', ' . $pdo->quote($cite[0]) . ', ' . (int)$cite[1] . ')'; } - query('INSERT INTO ``cites`` VALUES ' . implode(', ', $insert_rows)) or error(db_error());; + query('INSERT INTO ``cites`` VALUES ' . implode(', ', $insert_rows)) or error(db_error()); } if (!$post['op'] && strtolower($post['email']) != 'sage' && !$thread['sage'] && ($config['reply_limit'] == 0 || $numposts['replies']+1 < $config['reply_limit'])) { -- cgit v1.3