aboutsummaryrefslogtreecommitdiff
path: root/cgi/weabot.py
diff options
context:
space:
mode:
Diffstat (limited to 'cgi/weabot.py')
-rwxr-xr-xcgi/weabot.py78
1 files changed, 7 insertions, 71 deletions
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: