aboutsummaryrefslogtreecommitdiff
path: root/cgi
diff options
context:
space:
mode:
Diffstat (limited to 'cgi')
-rw-r--r--cgi/api.py3
-rw-r--r--cgi/post.py71
-rw-r--r--cgi/templates/mobile/base_top.html2
-rw-r--r--cgi/templates/txt_board.en.html8
-rw-r--r--cgi/templates/txt_board.html6
-rw-r--r--cgi/templates/txt_thread.html4
-rwxr-xr-xcgi/weabot.py78
7 files changed, 81 insertions, 91 deletions
diff --git a/cgi/api.py b/cgi/api.py
index 7b8b6bd..871e88f 100644
--- a/cgi/api.py
+++ b/cgi/api.py
@@ -6,7 +6,6 @@ from framework import *
from database import *
from post import *
-
def api(self, path_split):
if len(path_split) > 2:
try:
@@ -356,7 +355,7 @@ def api_process(self, path_split):
if data_imageonly and data_imageonly == 1:
imageonly = True
- deletePost(postid, data_password, board['recyclebin'], imageonly)
+ deletePosts(board['dir'], postid, imageonly, data_password)
elif method == 'post':
boarddir = formdata.get('board')
diff --git a/cgi/post.py b/cgi/post.py
index b7efef1..c53e8a1 100644
--- a/cgi/post.py
+++ b/cgi/post.py
@@ -56,7 +56,7 @@ class Post(object):
return self.post
def insert(self):
- logging.info("Insertando Post")
+ logging.info("Insertando post")
post_keys = []
post_templates = []
post_values = []
@@ -694,7 +694,63 @@ def regenerateBoard(everything=False):
for post in op_posts:
regenerateThreadPage(post["id"])
-def deletePost(postid, password, deltype=0, imageonly=False, quick=False):
+def deletePosts(boarddir, postid, imageonly, password):
+ board = setBoard(boarddir)
+
+ # validate posts
+ if not postid:
+ raise UserError("Selecciona uno o más mensajes a eliminar.")
+
+ to_delete = []
+ if isinstance(postid, list):
+ to_delete = [int(n.value) for n in postid]
+ else:
+ to_delete = [int(postid)]
+
+ if not password:
+ raise UserError(_("Please enter a password."))
+
+ # delete posts
+ if board['board_type'] == 1 and len(to_delete) == 1:
+ # only delete a single post on textboards
+ # check if it's the last post and delete permanently if so
+ deltype = 0
+
+ post = FetchOne("SELECT id, timestamp, parentid FROM posts WHERE boardid = %s AND id = %s LIMIT 1", (board["id"], to_delete[0]) )
+ if not post:
+ raise UserError(_("There isn't a post with this ID. It was probably deleted."))
+
+ if post['parentid']:
+ op = get_parent_post(post['parentid'], board['id'])
+ if op['last'] != post['timestamp']:
+ deltype = 1
+
+ deletePost(to_delete[0], password, deltype, imageonly)
+ regenerateHome()
+ else:
+ # delete all checked posts on imageboards
+ deleted = 0
+ errors = 0
+ msgs = []
+
+ for pid in to_delete:
+ try:
+ deletePost(pid, password, board['recyclebin'], imageonly)
+ deleted += 1
+ msgs.append('No.%d: Eliminado' % pid)
+ except UserError as message:
+ errors += 1
+ msgs.append('No.%d: %s' % (pid, message))
+
+ # regenerate home
+ if deleted:
+ regenerateHome()
+
+ # show errors, if any
+ if errors:
+ raise UserError('No se pudieron eliminar todos los posts.<br />' + '<br />'.join(msgs))
+
+def deletePost(postid, password, deltype=0, imageonly=False):
"""
Remove post from database and unlink file (if present), along with all replies
if supplied post is a thread
@@ -705,7 +761,7 @@ def deletePost(postid, password, deltype=0, imageonly=False, quick=False):
postid = int(postid)
# get post
- post = FetchOne("SELECT `id`, `timestamp`, `parentid`, `file`, `thumb`, `password`, `length` FROM `posts` WHERE `boardid` = %s AND `id` = %s LIMIT 1", (board["id"], postid))
+ post = FetchOne("SELECT `id`, `timestamp`, `parentid`, `file`, `thumb`, `password`, `length` FROM `posts` WHERE `boardid` = %s AND `id` = %s LIMIT 1", (board["id"], postid) )
# abort if the post doesn't exist
if not post:
@@ -713,13 +769,12 @@ def deletePost(postid, password, deltype=0, imageonly=False, quick=False):
if password:
if password != post['password']:
- raise UserError("No tienes permiso para eliminar este mensaje.")
+ raise UserError("No tienes permiso para eliminar este post.")
elif not post["parentid"] and post["length"] >= Settings.DELETE_FORBID_LENGTH:
raise UserError("No puedes eliminar un hilo con tantas respuestas.")
elif (int(time.time()) - post["timestamp"]) > 86400:
raise UserError("No puedes eliminar un post tan viejo.")
- # just update the DB if deleting only the image, otherwise delete whole post
if imageonly:
if post["file"]:
deleteFile(post)
@@ -729,14 +784,14 @@ def deletePost(postid, password, deltype=0, imageonly=False, quick=False):
if not post["parentid"]:
deleteReplies(post)
- logging.info("Deleting post %d - parentid: %d" % (post["id"], post["parentid"]))
+ logging.debug("Deleting post %d - parentid: %d" % (post["id"], post["parentid"]))
if deltype != 0 and post["parentid"]:
# Soft delete (recycle bin)
- logging.info("Soft delete")
+ logging.debug("Soft delete")
UpdateDb("UPDATE `posts` SET `IS_DELETED` = %s WHERE `boardid` = %s AND `id` = %s LIMIT 1", (deltype, board["id"], post["id"]))
else:
# Hard delete
- logging.info("Hard delete")
+ logging.debug("Hard delete")
if post["file"]:
deleteFile(post)
diff --git a/cgi/templates/mobile/base_top.html b/cgi/templates/mobile/base_top.html
index aa016a4..bc4e680 100644
--- a/cgi/templates/mobile/base_top.html
+++ b/cgi/templates/mobile/base_top.html
@@ -10,5 +10,5 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="#{static_url}img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="#{static_url}css/mobile.css" />
- <script type="text/javascript" src="#{static_url}js/mobile.js"></script>
+ <script type="text/javascript" src="#{static_url}js/mobile.js?v=2"></script>
</head>
diff --git a/cgi/templates/txt_board.en.html b/cgi/templates/txt_board.en.html
index 9327c77..ff101b5 100644
--- a/cgi/templates/txt_board.en.html
+++ b/cgi/templates/txt_board.en.html
@@ -86,10 +86,10 @@
<form id="postform#{thread['id']}" class="postform" action="#{cgi_url}post" method="post" enctype="multipart/form-data">
<input type="hidden" name="board" value="#{board}" /><input type="hidden" name="parent" value="#{thread['id']}" /><input type="hidden" name="password" value="" />
<div style="display:none"><input type="text" name="name" size="13" /><input type="text" name="email" size="13" /></div>
- <input type="submit" value="Reply" /> <input type="button" name="preview" data-thread="#{thread['id']}" value="Preview"> <span><span>Name: </span><input type="text" name="fielda" size="13" /> <span>E-mail: </span><input type="text" name="fieldb" size="13" /></span>
+ <input type="submit" value="Reply" /> <input type="button" name="preview" value="Preview"> <span><span>Name: </span><input type="text" name="fielda" size="13" /> <span>E-mail: </span><input type="text" name="fieldb" size="13" /></span>
<div class="formpad">
<div id="preview#{thread['id']}" class="msg" style="display:none"></div>
- <textarea name="message" cols="90" rows="5"></textarea>
+ <textarea name="message" cols="70" rows="5"></textarea>
<?py if allow_image_replies: ?><br /><input type="file" name="file" /><?py #endif ?>
<?py else: ?>
<form class="postform"><div class="locked"><b>Thread has been closed. You cannot reply anymore.</b></div><div class="formpad">
@@ -131,7 +131,7 @@
<td><input type="text" name="fielda" /></td>
<td class="pblock">E-mail:</td>
<td><input type="text" name="fieldb" /></td>
- <td><input type="button" name="preview" data-thread="0" value="Previsualizar" /></td>
+ <td><input type="button" name="preview" value="Previsualizar" /></td>
</tr>
<tr id="tr_preview" style="display:none">
<td></td>
@@ -139,7 +139,7 @@
</tr>
<tr>
<td class="pblock">Body:</td>
- <td colspan="4"><textarea name="message" cols="90" rows="12" data-h-limit="512"></textarea></td>
+ <td colspan="4"><textarea name="message" cols="90" rows="12"></textarea></td>
</tr>
<?py if allow_images: ?>
<tr>
diff --git a/cgi/templates/txt_board.html b/cgi/templates/txt_board.html
index a6899bf..817f8d6 100644
--- a/cgi/templates/txt_board.html
+++ b/cgi/templates/txt_board.html
@@ -86,10 +86,10 @@
<form id="postform#{thread['id']}" class="postform" action="#{cgi_url}post" method="post" enctype="multipart/form-data">
<input type="hidden" name="board" value="#{board}" /><input type="hidden" name="parent" value="#{thread['id']}" /><input type="hidden" name="password" value="" />
<div style="display:none">No tocar: <input type="text" name="name" /><input type="text" name="email" /></div>
- <input type="submit" value="Responder" /> <input type="button" name="preview" data-thread="#{thread['id']}" value="Previsualizar" /> <span><span>Nombre:&nbsp;</span><input type="text" name="fielda" size="13" /><span>&nbsp;E-mail:&nbsp;</span><input type="text" name="fieldb" size="13" /></span>
+ <input type="submit" value="Responder" /> <input type="button" name="preview" value="Previsualizar" /> <span><span>Nombre:&nbsp;</span><input type="text" name="fielda" size="13" /><span>&nbsp;E-mail:&nbsp;</span><input type="text" name="fieldb" size="13" /></span>
<div class="formpad">
<div id="preview#{thread['id']}" class="msg" style="display:none"></div>
- <textarea name="message" cols="90" rows="5"></textarea>
+ <textarea name="message" cols="70" rows="5"></textarea>
<?py if allow_image_replies: ?><br /><input type="file" name="file" /><?py #endif ?>
<?py else: ?>
<form class="postform"><div class="locked"><b>El hilo ha sido cerrado. Ya no se puede postear en él.</b></div><div class="formpad">
@@ -139,7 +139,7 @@
</tr>
<tr>
<td class="pblock">Mensaje:</td>
- <td colspan="4"><textarea name="message" cols="90" rows="12" data-h-limit="512"></textarea></td>
+ <td colspan="4"><textarea name="message" cols="90" rows="12"></textarea></td>
</tr>
<?py if allow_images: ?>
<tr>
diff --git a/cgi/templates/txt_thread.html b/cgi/templates/txt_thread.html
index 77237ab..611cf82 100644
--- a/cgi/templates/txt_thread.html
+++ b/cgi/templates/txt_thread.html
@@ -90,10 +90,10 @@
<input type="hidden" name="board" value="#{board}" /><input type="hidden" name="parent" value="#{thread['id']}" /><input type="hidden" name="password" value="" />
<?py if thread['locked'] != 1: ?>
<div style="display:none">No tocar: <input type="text" name="name" /><input type="text" name="email" /></div>
- <input type="submit" value="Responder" /> <input type="button" name="preview" data-thread="#{thread['id']}" value="Previsualizar" /> <span><span>Nombre:&nbsp;</span><input type="text" name="fielda" size="13" /><span>&nbsp;E-mail:&nbsp;</span><input type="text" name="fieldb" size="13" /></span>
+ <input type="submit" value="Responder" /> <input type="button" name="preview" value="Previsualizar" /> <span><span>Nombre:&nbsp;</span><input type="text" name="fielda" size="13" /><span>&nbsp;E-mail:&nbsp;</span><input type="text" name="fieldb" size="13" /></span>
<br />
<div id="preview#{thread['id']}" class="msg" style="display:none"></div>
- <textarea name="message" cols="100" rows="7" data-h-limit="512"></textarea>
+ <textarea name="message" cols="80" rows="7"></textarea>
<?py if allow_image_replies: ?>
<br />
<input type="file" name="file" />
diff --git a/cgi/weabot.py b/cgi/weabot.py
index 4a5cfcd..48f19f5 100755
--- a/cgi/weabot.py
+++ b/cgi/weabot.py
@@ -173,8 +173,8 @@ class weabot(object):
self.output += repr(self.environ)
elif path_split[1] == "delete":
- # Deleting a post
caught = True
+ OpenDb()
boarddir = self.formdata.get('board')
postid = self.formdata.get('delete')
@@ -183,7 +183,12 @@ class weabot(object):
mobile = self.formdata.get('mobile')
# call delete function
- self.delete_post(boarddir, postid, imageonly, password, mobile)
+ deletePosts(boarddir, postid, imageonly, password)
+
+ self.output += '<html xmlns="http://www.w3.org/1999/xhtml"><body><meta http-equiv="refresh" content="0;url=%s/" /><p>%s</p></body></html>' % (
+ ("/cgi/mobile/" if mobile else Settings.BOARDS_URL) + boarddir,
+ ("Archivo" if imageonly else "Post") + " eliminado con éxito."
+ )
elif path_split[1] == "anarkia":
import anarkia
caught = True
@@ -854,75 +859,6 @@ class weabot(object):
return (post_url, ttaken, postid)
- def delete_post(self, boarddir, postid, imageonly, password, mobile=False):
- OpenDb()
-
- # set the board
- board = setBoard(boarddir)
-
- if board["dir"] == '0':
- raise UserError("No se pueden eliminar mensajes en esta sección.")
-
- # check if we have a post id and check it's numeric
- if not postid:
- raise UserError("Selecciona uno o más mensajes a eliminar.")
-
- # make sure we have a password
- if not password:
- raise UserError(_("Please enter a password."))
-
- to_delete = []
- if isinstance(postid, list):
- to_delete = [int(n.value) for n in postid]
- else:
- to_delete = [int(postid)]
-
- # delete posts
- if board['board_type'] == 1 and len(to_delete) == 1:
- # we should be deleting only one (textboard)
- # check if it's the last post and delete permanently if so
- deltype = 0
- post = FetchOne("SELECT `id`, `timestamp`, `parentid` FROM `posts` WHERE `boardid` = %s AND `id` = %s LIMIT 1", (
- board["id"], to_delete[0]))
- if post['parentid']:
- op = get_parent_post(post['parentid'], board['id'])
- if op['last'] != post['timestamp']:
- deltype = 1
-
- deletePost(to_delete[0], password, deltype, imageonly)
- regenerateHome()
- else:
- # delete all checked posts (IB)
- deleted = 0
- errors = 0
- msgs = []
-
- for pid in to_delete:
- try:
- deletePost(pid, password, board['recyclebin'], imageonly)
- deleted += 1
- msgs.append('No.%d: Eliminado' % pid)
- except UserError as message:
- errors += 1
- msgs.append('No.%d: %s' % (pid, message))
-
- # regenerate home
- if deleted:
- regenerateHome()
-
- # show errors, if any
- if errors:
- raise UserError('No todos los mensajes pudieron ser eliminados.<br />' + \
- '<br />'.join(msgs))
-
- # redirect
- if imageonly:
- self.output += '<html xmlns="http://www.w3.org/1999/xhtml"><body><meta http-equiv="refresh" content="0;url=%s/" /><p>%s</p></body></html>' % (
- ("/cgi/mobile/" if mobile else Settings.BOARDS_URL) + board["dir"], _("File deleted successfully."))
- else:
- self.output += '<html xmlns="http://www.w3.org/1999/xhtml"><body><meta http-equiv="refresh" content="0;url=%s/" /><p>%s</p></body></html>' % (
- ("/cgi/mobile/" if mobile else Settings.BOARDS_URL) + board["dir"], _("Post deleted successfully."))
-
def report(self, ip, boarddir, postid, reason, txt, postshow):
# don't allow if the report system is off
if not Settings.REPORTS_ENABLE: