summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-04-11 17:36:34 +1000
committerMichael Save <savetheinternet@tinyboard.org>2012-04-11 17:36:34 +1000
commit88092e4f9e50e94f094e55c54a6150df104043b1 (patch)
treeaea80f6a46763d2af918e789fd76613f242c863b
parentc0968639c44a28478a466bcb3084cb66a13a3128 (diff)
Bugfix: some tracked post citations were not being purged upon thread deletion
-rw-r--r--inc/functions.php8
-rw-r--r--templates/main.js32
2 files changed, 22 insertions, 18 deletions
diff --git a/inc/functions.php b/inc/functions.php
index 5f00cfdb..3592512e 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -829,6 +829,8 @@
else return false;
}
+ $ids = array();
+
// Delete posts and maybe replies
while($post = $query->fetch()) {
if(!$post['thread']) {
@@ -846,15 +848,17 @@
// Delete file
file_unlink($board['dir'] . $config['dir']['img'] . $post['file']);
}
+
+ $ids[] = (int)$post['id'];
+
}
$query = prepare(sprintf("DELETE FROM `posts_%s` WHERE `id` = :id OR `thread` = :id", $board['uri']));
$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` = :id");
+ $query = prepare("SELECT `board`, `post` FROM `cites` WHERE `target_board` = :board AND (`target` = " . implode(' OR `target` = ', $ids) . ")");
$query->bindValue(':board', $board['uri']);
- $query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
while($cite = $query->fetch()) {
if($board['uri'] != $cite['board']) {
diff --git a/templates/main.js b/templates/main.js
index 3903ff6e..de62bd8b 100644
--- a/templates/main.js
+++ b/templates/main.js
@@ -9,7 +9,7 @@ var saved = {};
function get_cookie(cookie_name) {
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
- if(results)
+ if (results)
return (unescape(results[2]));
else
return null;
@@ -29,7 +29,7 @@ function highlightReply(id) {
}
if (id) {
var post = document.getElementById('reply_'+id);
- if(post)
+ if (post)
post.className += ' highlighted';
}
}
@@ -37,7 +37,7 @@ function highlightReply(id) {
function generatePassword() {
var pass = '';
var chars = '{% endraw %}{{ config.genpassword_chars }}{% raw %}';
- for(var i = 0; i < 8; i++) {
+ for (var i = 0; i < 8; i++) {
var rnd = Math.floor(Math.random() * chars.length);
pass += chars.substring(rnd, rnd + 1);
}
@@ -45,10 +45,10 @@ function generatePassword() {
}
function dopost(form) {
- if(form.elements['name']) {
+ if (form.elements['name']) {
localStorage.name = form.elements['name'].value.replace(/ ##.+$/, '');
}
- if(form.elements['email'] && form.elements['email'].value != 'sage') {
+ if (form.elements['email'] && form.elements['email'].value != 'sage') {
localStorage.email = form.elements['email'].value;
}
@@ -92,39 +92,39 @@ if(localStorage.stylesheet) {
}
function rememberStuff() {
- if(document.forms.post) {
- if(document.forms.post.password) {
- if(!localStorage.password)
+ if (document.forms.post) {
+ if (document.forms.post.password) {
+ if (!localStorage.password)
localStorage.password = generatePassword();
document.forms.post.password.value = localStorage.password;
}
- if(localStorage.name && document.forms.post.elements['name'])
+ if (localStorage.name && document.forms.post.elements['name'])
document.forms.post.elements['name'].value = localStorage.name;
- if(localStorage.email && document.forms.post.elements['email'])
+ if (localStorage.email && document.forms.post.elements['email'])
document.forms.post.elements['email'].value = localStorage.email;
if (window.location.hash.indexOf('q') == 1)
citeReply(window.location.hash.substring(2));
- if(sessionStorage.body) {
+ if (sessionStorage.body) {
var saved = JSON.parse(sessionStorage.body);
- if(get_cookie('{% endraw %}{{ config.cookies.js }}{% raw %}')) {
+ if (get_cookie('{% endraw %}{{ config.cookies.js }}{% raw %}')) {
// Remove successful posts
var successful = JSON.parse(get_cookie('{% endraw %}{{ config.cookies.js }}{% raw %}'));
- for (var url in successful) {
+ for(var url in successful) {
saved[url] = null;
}
sessionStorage.body = JSON.stringify(saved);
document.cookie = '{% endraw %}{{ config.cookies.js }}{% raw %}={};expires=0;path=/;';
}
- if(saved[document.location]) {
+ if (saved[document.location]) {
document.forms.post.body.value = saved[document.location];
}
}
- if(localStorage.body) {
+ if (localStorage.body) {
document.forms.post.body.value = localStorage.body;
localStorage.body = '';
}
@@ -135,7 +135,7 @@ function init() {
var newElement = document.createElement('div');
newElement.className = 'styles';
- for(x=0;x<styles.length;x++) {
+ for(x = 0; x < styles.length; x++) {
var style = document.createElement('a');
style.innerHTML = '[' + styles[x][0] + ']';
style.href = 'javascript:changeStyle(' + x + ');';