Browse Source

More track_cites work

pull/40/head
Michael Foster 11 years ago
parent
commit
46d41cd2a7
  1. 32
      inc/functions.php
  2. 17
      inc/mod/pages.php

32
inc/functions.php

@ -168,21 +168,21 @@ function loadConfig() {
if (preg_match('/^\:\:(ffff\:)?(\d+\.\d+\.\d+\.\d+)$/', $__ip, $m)) if (preg_match('/^\:\:(ffff\:)?(\d+\.\d+\.\d+\.\d+)$/', $__ip, $m))
$_SERVER['REMOTE_ADDR'] = $m[2]; $_SERVER['REMOTE_ADDR'] = $m[2];
if (_setlocale(LC_ALL, $config['locale']) === false) { if ($config['locale'] != 'en') {
$error('The specified locale (' . $config['locale'] . ') does not exist on your platform!'); if (_setlocale(LC_ALL, $config['locale']) === false) {
} $error('The specified locale (' . $config['locale'] . ') does not exist on your platform!');
}
if (extension_loaded('gettext')) { if (extension_loaded('gettext')) {
bindtextdomain('tinyboard', './inc/locale'); bindtextdomain('tinyboard', './inc/locale');
bind_textdomain_codeset('tinyboard', 'UTF-8'); bind_textdomain_codeset('tinyboard', 'UTF-8');
textdomain('tinyboard'); textdomain('tinyboard');
} else { } else {
_bindtextdomain('tinyboard', './inc/locale'); _bindtextdomain('tinyboard', './inc/locale');
_bind_textdomain_codeset('tinyboard', 'UTF-8'); _bind_textdomain_codeset('tinyboard', 'UTF-8');
_textdomain('tinyboard'); _textdomain('tinyboard');
}
} }
if ($config['syslog']) if ($config['syslog'])
openlog('tinyboard', LOG_ODELAY, LOG_SYSLOG); // open a connection to sysem logger 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->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query)); $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->bindValue(':board', $board['uri']);
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
while ($cite = $query->fetch(PDO::FETCH_ASSOC)) { 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)) if (isset($tmp_board))
openBoard($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->bindValue(':board', $board['uri']);
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
if (isset($rebuild) && $rebuild_after) { if (isset($rebuild) && $rebuild_after) {
buildThread($rebuild); buildThread($rebuild);
} }

17
inc/mod/pages.php

@ -1001,7 +1001,7 @@ function mod_bumplock($board, $unbumplock, $post) {
} }
function mod_move($originBoard, $postID) { function mod_move($originBoard, $postID) {
global $board, $config, $mod; global $board, $config, $mod, $pdo;
if (!openBoard($originBoard)) if (!openBoard($originBoard))
error($config['error']['noboard']); 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']); $clone($post['file_thumb'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $post['thumb']);
} }
foreach ($post['tracked_cites'] as $cite) { if (!empty($post['tracked_cites'])) {
$query = prepare('INSERT INTO ``cites`` VALUES (:board, :post, :target_board, :target)'); $insert_rows = array();
$query->bindValue(':board', $board['uri']); foreach ($post['tracked_cites'] as $cite) {
$query->bindValue(':post', $newPostID, PDO::PARAM_INT); $insert_rows[] = '(' .
$query->bindValue(':target_board',$cite[0]); $pdo->quote($board['uri']) . ', ' . $newPostID . ', ' .
$query->bindValue(':target', $cite[1], PDO::PARAM_INT); $pdo->quote($cite[0]) . ', ' . (int)$cite[1] . ')';
$query->execute() or error(db_error($query)); }
query('INSERT INTO ``cites`` VALUES ' . implode(', ', $insert_rows)) or error(db_error());;
} }
} }

Loading…
Cancel
Save