Browse Source

...

pull/40/head
Savetheinternet 13 years ago
parent
commit
67148f2846
  1. 0
      default.css
  2. 13
      inc/display.php
  3. 36
      inc/functions.php
  4. 37
      inc/mod.php
  5. 23
      main.js
  6. 13
      style.css

0
default.css

13
inc/display.php

@ -110,7 +110,9 @@
global $board; global $board;
$built = '<div class="post reply"' . (!$index?' id="reply_' . $this->id . '"':'') . '>' . $built = '<div class="post reply"' . (!$index?' id="reply_' . $this->id . '"':'') . '>' .
'<p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>'; '<p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>' .
// Delete
'<input type="checkbox" class="delete" name="delete_' . $this->id . '" id="delete_' . $this->id . '" /><label for="delete_' . $this->id . '">';
// Subject // Subject
if(!empty($this->subject)) if(!empty($this->subject))
@ -135,6 +137,9 @@
// Date/time // Date/time
$built .= ' ' . date(POST_DATE, $this->time); $built .= ' ' . date(POST_DATE, $this->time);
// End delete
$built .= '</label>';
$built .= ' <a class="post_no"' . $built .= ' <a class="post_no"' .
// JavaScript highlight // JavaScript highlight
($index?'':' onclick="highlightReply(' . $this->id . ');"') . ($index?'':' onclick="highlightReply(' . $this->id . ');"') .
@ -266,6 +271,9 @@
$built .= '<div class="post op"><p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>'; $built .= '<div class="post op"><p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>';
// Delete
$built .= '<input type="checkbox" class="delete" name="delete_' . $this->id . '" id="delete_' . $this->id . '" /><label for="delete_' . $this->id . '">';
// Subject // Subject
if(!empty($this->subject)) if(!empty($this->subject))
$built .= '<span class="subject">' . $this->subject . '</span> '; $built .= '<span class="subject">' . $this->subject . '</span> ';
@ -289,6 +297,9 @@
// Date/time // Date/time
$built .= ' ' . date(POST_DATE, $this->time); $built .= ' ' . date(POST_DATE, $this->time);
// End delete
$built .= '</label>';
$built .= ' <a class="post_no"' . $built .= ' <a class="post_no"' .
// JavaScript highlight // JavaScript highlight
($index?'':' onclick="highlightReply(' . $this->id . ');"') . ($index?'':' onclick="highlightReply(' . $this->id . ');"') .

36
inc/functions.php

@ -262,6 +262,42 @@
$query->execute() or error(db_error($query)); $query->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) // Delete a post (reply or thread)
function deletePost($id) { function deletePost($id) {
global $board; global $board;

37
inc/mod.php

@ -173,40 +173,5 @@
'</form>' . '</form>' .
'</fieldset>'; '</fieldset>';
} }
// 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']);
}
?> ?>

23
main.js

@ -14,9 +14,21 @@ function focusId(id)
document.getElementById(id).focus(); document.getElementById(id).focus();
init(); 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) { function dopost(form) {
localStorage.name = form.name.value; localStorage.name = form.name.value.replace(/ ##.+$/, '');
localStorage.email = form.email.value; if(form.email.value != 'sage')
localStorage.email = form.email.value;
return form.body.value != "" || (typeof form.thread != "undefined" && form.file.value != ""); return form.body.value != "" || (typeof form.thread != "undefined" && form.file.value != "");
} }
@ -65,6 +77,13 @@ function init()
newElement.appendChild(style); newElement.appendChild(style);
} }
if(!localStorage.password)
localStorage.password = generatePassword();
elements = document.getElementsByName('password');
for(x=0;x<elements.length;x++) {
elements[x].value = localStorage.password;
}
document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild) document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild)
if (window.location.hash.indexOf('q') == 1) if (window.location.hash.indexOf('q') == 1)

13
style.css

@ -113,6 +113,10 @@ div.banner a:hover {
color: #EEF2FF; color: #EEF2FF;
text-decoration: none; text-decoration: none;
} }
img.banner {
float: none;
margin: 4px auto 0 auto;
}
img { img {
display: block; display: block;
float: left; float: left;
@ -138,6 +142,10 @@ p.intro {
padding: 0; padding: 0;
padding-bottom: 0.2em; padding-bottom: 0.2em;
} }
input.delete {
float: left;
margin: 1px 6px 0 0;
}
p.intro span.subject { p.intro span.subject {
color: #0F0C5D; color: #0F0C5D;
font-weight: bold; font-weight: bold;
@ -153,6 +161,9 @@ p.intro a.nametag {
p.intro a { p.intro a {
margin-left: 8px; margin-left: 8px;
} }
div.delete {
float: right;
}
div.post.reply p { div.post.reply p {
margin: 0.3em 0 0 0; margin: 0.3em 0 0 0;
} }
@ -243,4 +254,4 @@ div.styles a {
} }
div.styles a.selected { div.styles a.selected {
text-decoration: none; text-decoration: none;
} }

Loading…
Cancel
Save