From 67148f28463f8d4f2b7b61d38aa5d71df9658e4c Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 21 Jan 2011 13:14:55 +1100 Subject: [PATCH] ... --- default.css | 0 inc/display.php | 13 ++++++++++++- inc/functions.php | 36 ++++++++++++++++++++++++++++++++++++ inc/mod.php | 37 +------------------------------------ main.js | 23 +++++++++++++++++++++-- style.css | 13 ++++++++++++- 6 files changed, 82 insertions(+), 40 deletions(-) create mode 100644 default.css diff --git a/default.css b/default.css new file mode 100644 index 00000000..e69de29b diff --git a/inc/display.php b/inc/display.php index 66637d0d..0678cef7 100644 --- a/inc/display.php +++ b/inc/display.php @@ -110,7 +110,9 @@ global $board; $built = '
' . - '

'; + '

' . + // Delete + ''; + $built .= ' '; + // Delete + $built .= ''; + $built .= ' execute() or error(db_error($query)); } + // Remove file from post + function deleteFile($id, $remove_entirely_if_already=true) { + global $board; + + $query = prepare(sprintf("SELECT `thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id AND `thread` IS NOT NULL LIMIT 1", $board['uri'])); + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + if($query->rowCount() < 1) { + error(ERROR_INVALIDPOST); + } + + $post = $query->fetch(); + + $query = prepare(sprintf("UPDATE `posts_%s` SET `thumb` = NULL, `thumbwidth` = NULL, `thumbheight` = NULL, `filewidth` = NULL, `fileheight` = NULL, `filesize` = NULL, `filename` = NULL, `filehash` = NULL, `file` = :file WHERE `id` = :id OR `thread` = :id", $board['uri'])); + if($post['file'] == 'deleted' && $remove_entirely_if_already) { + // Already deleted; remove file fully + $query->bindValue(':file', null, PDO::PARAM_NULL); + } else { + // Delete thumbnail + @unlink($board['dir'] . DIR_THUMB . $post['thumb']); + + // Delete file + @unlink($board['dir'] . DIR_IMG . $post['file']); + + // Set file to 'deleted' + $query->bindValue(':file', 'deleted', PDO::PARAM_INT); + } + // Update database + + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + buildThread($post['thread']); + } + // Delete a post (reply or thread) function deletePost($id) { global $board; diff --git a/inc/mod.php b/inc/mod.php index 5e3a2c87..5a3e6157 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -173,40 +173,5 @@ '' . ''; } - - // Remove file from post - function deleteFile($id) { - global $board; - - $query = prepare(sprintf("SELECT `thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id AND `thread` IS NOT NULL LIMIT 1", $board['uri'])); - $query->bindValue(':id', $id, PDO::PARAM_INT); - $query->execute() or error(db_error($query)); - - if($query->rowCount() < 1) { - error(ERROR_INVALIDPOST); - } - - $post = $query->fetch(); - - $query = prepare(sprintf("UPDATE `posts_%s` SET `thumb` = NULL, `thumbwidth` = NULL, `thumbheight` = NULL, `filewidth` = NULL, `fileheight` = NULL, `filesize` = NULL, `filename` = NULL, `filehash` = NULL, `file` = :file WHERE `id` = :id OR `thread` = :id", $board['uri'])); - if($post['file'] == 'deleted') { - // Already deleted; remove file fully - $query->bindValue(':file', null, PDO::PARAM_NULL); - } else { - // Delete thumbnail - @unlink($board['dir'] . DIR_THUMB . $post['thumb']); - - // Delete file - @unlink($board['dir'] . DIR_IMG . $post['file']); - - // Set file to 'deleted' - $query->bindValue(':file', 'deleted', PDO::PARAM_INT); - } - // Update database - - $query->bindValue(':id', $id, PDO::PARAM_INT); - $query->execute() or error(db_error($query)); - - buildThread($post['thread']); - } + ?> \ No newline at end of file diff --git a/main.js b/main.js index dd46cd18..d0a82dda 100644 --- a/main.js +++ b/main.js @@ -14,9 +14,21 @@ function focusId(id) document.getElementById(id).focus(); init(); } + +function generatePassword() { + pass = ''; + chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+'; + for(i=0;i<8;i++) { + rnd = Math.floor(Math.random() * chars.length); + pass += chars.substring(rnd,rnd + 1); + } + return pass; +} + function dopost(form) { - localStorage.name = form.name.value; - localStorage.email = form.email.value; + localStorage.name = form.name.value.replace(/ ##.+$/, ''); + if(form.email.value != 'sage') + localStorage.email = form.email.value; return form.body.value != "" || (typeof form.thread != "undefined" && form.file.value != ""); } @@ -65,6 +77,13 @@ function init() newElement.appendChild(style); } + if(!localStorage.password) + localStorage.password = generatePassword(); + elements = document.getElementsByName('password'); + for(x=0;x