From 45610ff8b3d8868dec8586f51be4c8b91cdee4bd Mon Sep 17 00:00:00 2001 From: bai Date: Tue, 28 Jul 2020 04:06:01 -0400 Subject: Usando el mas nuevo check_output para crear miniaturas --- cgi/img.py | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'cgi') diff --git a/cgi/img.py b/cgi/img.py index ef64ac0..73bbdc7 100644 --- a/cgi/img.py +++ b/cgi/img.py @@ -95,15 +95,24 @@ def processImage(post, data, t, originalname, spoiler=False): logTime("Generating thumbnail") if used_filetype['mime'][:5] == 'video': - retcode = subprocess.call([ - Settings.FFMPEG_PATH, '-strict', '-2', '-ss', '0', '-i', file_path, - '-v', 'quiet', '-an', '-vframes', '1', '-f', 'mjpeg', '-vf', 'scale=%d:%d' % ( - file_thumb_width, file_thumb_height), - '-threads', '1', file_thumb_path]) - if spoiler: - args = [Settings.CONVERT_PATH, file_thumb_path, "-limit", "thread", "1", "-background", "white", "-flatten", "-resize", "%dx%d" % (file_thumb_width, file_thumb_height), "-blur", "0x12", "-gravity", "center", "-fill", "rgba(0,0,0, .6)", "-draw", "rectangle 0,%d,%d,%d" % ( - (file_thumb_height/2)-10, file_thumb_width, (file_thumb_height/2)+7), "-fill", "white", "-annotate", "0", "Alerta de spoiler", "-quality", str(Settings.THUMB_QUALITY), file_thumb_path] - retcode = subprocess.call(args) + # Create preview for video AND spoiler it if necessary + try: + subprocess.check_output([ + Settings.FFMPEG_PATH, '-strict', '-2', '-ss', '0', '-i', file_path, + '-v', 'quiet', '-an', '-vframes', '1', '-f', 'mjpeg', '-vf', 'scale=%d:%d' % ( + file_thumb_width, file_thumb_height), + '-threads', '1', file_thumb_path]) + if spoiler: + subprocess.check_output([Settings.CONVERT_PATH, file_thumb_path, "-limit", "thread", + "1", "-background", "white", "-flatten", "-resize", + "%dx%d" % (file_thumb_width, file_thumb_height), "-blur", "0x12", + "-gravity", "center", "-fill", "rgba(0,0,0, .6)", + "-draw", "rectangle 0,%d,%d,%d" % ((file_thumb_height/2)-10, file_thumb_width, (file_thumb_height/2)+7), + "-fill", "white", "-annotate", "0", "Alerta de spoiler", + "-quality", str(Settings.THUMB_QUALITY), file_thumb_path]) + except subprocess.CalledProcessError, e: + os.remove(file_path) + raise UserError, _("Thumbnail creation failure.") + ' ('+str(e.returncode)+')' elif used_filetype['mime'][:5] == 'audio': # we do an exception and use png for audio waveform thumbnails since they # 1. are smaller 2. allow for transparency @@ -119,19 +128,14 @@ def processImage(post, data, t, originalname, spoiler=False): file_thumb_width = 150 file_thumb_height = 75 - retcode = subprocess.call([ - Settings.FFMPEG_PATH, '-t', '300', '-i', file_path, + try: + subprocess.check_output([Settings.FFMPEG_PATH, '-t', '300', '-i', file_path, '-filter_complex', 'showwavespic=s=%dx%d:split_channels=1' % ( int(file_thumb_width), int(file_thumb_height)), '-frames:v', '1', '-threads', '1', file_thumb_path]) -# elif used_filetype['mime'] == 'application/x-shockwave-flash' or used_filetype['mime'] == 'mime/x-shockwave-flash': -# retcode = subprocess.call([ -# './ffmpeg', '-i', file_path, '-vcodec', 'mjpeg', '-vframes', '1', '-an', '-f', 'rawvideo', -# '-vf', 'scale=%d:%d' % (file_thumb_width, file_thumb_height), '-threads', '1', file_thumb_path]) - - if retcode != 0: - os.remove(file_path) - raise UserError, _("Thumbnail creation failure.") + ' ('+str(retcode)+')' + except subprocess.CalledProcessError, e: + os.remove(file_path) + raise UserError, _("Thumbnail creation failure.") + ' ('+str(e.returncode)+')' else: # use imagemagick to make thumbnail args = [Settings.CONVERT_PATH, file_path, "-limit", "thread", "1", "-background", @@ -143,10 +147,11 @@ def processImage(post, data, t, originalname, spoiler=False): # generate thumbnails logTime("Generating thumbnail") - retcode = subprocess.call(args) - if retcode != 0: + try: + subprocess.check_output(args) + except subprocess.CalledProcessError, e: os.remove(file_path) - raise UserError, _("Thumbnail creation failure.") + ' ('+str(retcode)+')' + raise UserError, _("Thumbnail creation failure.") + ' ('+str(e.returncode)+')' # check if thumbnail was truly created try: -- cgit v1.2.1-18-gbd029 From e4a14199d57455083e71f7b68b78fc231d32fc77 Mon Sep 17 00:00:00 2001 From: bai Date: Tue, 28 Jul 2020 04:28:12 -0400 Subject: Usando logging correcto de Python --- cgi/framework.py | 43 ++----------------------------------------- cgi/img.py | 8 ++++++-- cgi/post.py | 9 +++++---- cgi/weabot.py | 15 ++++++--------- 4 files changed, 19 insertions(+), 56 deletions(-) (limited to 'cgi') diff --git a/cgi/framework.py b/cgi/framework.py index 5f95303..8c39f81 100644 --- a/cgi/framework.py +++ b/cgi/framework.py @@ -9,6 +9,7 @@ import socket import _mysql import urllib import re +import logging from Cookie import SimpleCookie from settings import Settings @@ -22,7 +23,7 @@ def setBoard(dir): """ if not dir: raise UserError, _("The specified board is invalid.") - logTime("Seteando el board " + dir) + logging.debug("Seteando el board " + dir) board = FetchOne( "SELECT * FROM `boards` WHERE `dir` = '%s' LIMIT 1" % _mysql.escape_string(dir)) if not board: @@ -32,7 +33,6 @@ def setBoard(dir): "SELECT * FROM `boards_filetypes` INNER JOIN `filetypes` ON filetypes.id = boards_filetypes.filetypeid WHERE `boardid` = %s ORDER BY `ext` ASC" % _mysql.escape_string(board['id'])) board["filetypes_ext"] = [filetype['ext'] for filetype in board['filetypes']] - logTime("Board seteado.") Settings._.BOARD = board @@ -474,42 +474,3 @@ def send_mail(subject, srcmsg): s.sendmail(me, [you], msg.as_string()) s.quit() - -class weabotLogger: - def __init__(self): - self.times = [] - - def log(self, message): - self.times.append([time.time(), message]) - - def allTimes(self): - output = "Time Logged action\n--------------------------\n" - start = self.times[0][0] - for time in self.times: - difference = str(time[0] - start) - difference_split = difference.split(".") - if len(difference_split[0]) < 2: - difference_split[0] = "0" + difference_split[0] - - if len(difference_split[1]) < 7: - difference_split[1] = ( - "0" * (7 - len(difference_split[1]))) + difference_split[1] - elif len(difference_split[1]) > 7: - difference_split[1] = difference_split[1][:7] - - output += ".".join(difference_split) + " " + time[1] + "\n" - - return output - - -logger = weabotLogger() - - -def logTime(message): - global logger - logger.log(message) - - -def logTimes(): - global logger - return logger.allTimes() diff --git a/cgi/img.py b/cgi/img.py index 73bbdc7..ff7cd74 100644 --- a/cgi/img.py +++ b/cgi/img.py @@ -4,6 +4,7 @@ import math #import random import os import subprocess +import logging from StringIO import StringIO from settings import Settings @@ -92,7 +93,7 @@ def processImage(post, data, t, originalname, spoiler=False): if used_filetype['ffmpeg_thumb'] == '1': # use ffmpeg to make thumbnail - logTime("Generating thumbnail") + logging.debug("Generating thumbnail") if used_filetype['mime'][:5] == 'video': # Create preview for video AND spoiler it if necessary @@ -112,6 +113,7 @@ def processImage(post, data, t, originalname, spoiler=False): "-quality", str(Settings.THUMB_QUALITY), file_thumb_path]) except subprocess.CalledProcessError, e: os.remove(file_path) + logging.error("Thumbnail creation failure: " + e.output) raise UserError, _("Thumbnail creation failure.") + ' ('+str(e.returncode)+')' elif used_filetype['mime'][:5] == 'audio': # we do an exception and use png for audio waveform thumbnails since they @@ -135,6 +137,7 @@ def processImage(post, data, t, originalname, spoiler=False): '-frames:v', '1', '-threads', '1', file_thumb_path]) except subprocess.CalledProcessError, e: os.remove(file_path) + logging.error("Thumbnail creation failure: " + e.output) raise UserError, _("Thumbnail creation failure.") + ' ('+str(e.returncode)+')' else: # use imagemagick to make thumbnail @@ -146,11 +149,12 @@ def processImage(post, data, t, originalname, spoiler=False): args += ["-quality", str(Settings.THUMB_QUALITY), file_thumb_path] # generate thumbnails - logTime("Generating thumbnail") + logging.debug("Generating thumbnail") try: subprocess.check_output(args) except subprocess.CalledProcessError, e: os.remove(file_path) + logging.error("Thumbnail creation failure: " + repr(e.output)) raise UserError, _("Thumbnail creation failure.") + ' ('+str(e.returncode)+')' # check if thumbnail was truly created diff --git a/cgi/post.py b/cgi/post.py index da2ad47..e27b971 100644 --- a/cgi/post.py +++ b/cgi/post.py @@ -7,6 +7,7 @@ import threading import Queue import _mysql import formatting +import logging from database import * from template import * @@ -49,7 +50,7 @@ class Post(object): return self.post def insert(self): - logTime("Insertando Post") + logging.info("Insertando Post") post_values = [] for key, value in self.post.iteritems(): @@ -715,7 +716,7 @@ def deletePost(postid, password, deltype='0', imageonly=False, quick=False): if int(post["parentid"]) == 0: deleteReplies(post) - logTime("Deleting post " + str(postid)) + logging.info("Deleting post " + str(postid)) if deltype != '0' and post["parentid"] != '0': # Soft delete (recycle bin) UpdateDb("UPDATE `posts` SET `IS_DELETED` = %s WHERE `boardid` = %s AND `id` = %s LIMIT 1" % (deltype, board["id"], post["id"])) @@ -788,7 +789,7 @@ def trimThreads(): """ Delete any threads which have passed the MAX_THREADS setting """ - logTime("Trimming threads") + logging.debug("Trimming threads") board = Settings._.BOARD archived = False @@ -1026,7 +1027,7 @@ def regenerateHome(): """ Update index.html in the boards directory with useful data for users """ - logTime("Updating home") + logging.debug("Updating home") t = datetime.datetime.now() limit = Settings.HOME_LASTPOSTS diff --git a/cgi/weabot.py b/cgi/weabot.py index 3c5d0f5..ff93118 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -8,6 +8,7 @@ import time import datetime import random import cgi +import logging import _mysql from Cookie import SimpleCookie @@ -33,6 +34,9 @@ _LOG = False class weabot(object): def __init__(self, environ, start_response): global _DEBUG + + logging.basicConfig(filename='weabot.log', format='%(asctime)s %(levelname)s %(message)s', level=logging.DEBUG) + self.environ = environ if self.environ["PATH_INFO"].startswith("/weabot.py/"): self.environ["PATH_INFO"] = self.environ["PATH_INFO"][11:] @@ -48,7 +52,6 @@ class weabot(object): 'weabot', './locale', languages=[Settings.LANG]) lang.install() - logTime("**Start**") if _DEBUG: import cProfile @@ -70,12 +73,6 @@ class weabot(object): # close database and finish CloseDb() - logTime("**End**") - - if _LOG: - logfile = open(Settings.ROOT_DIR + "weabot.txt", "w") - logfile.write(logTimes()) - logfile.close() def __iter__(self): self.handleResponse() @@ -812,7 +809,7 @@ class weabot(object): post["message"]), _mysql.escape_string(board["id"]), _mysql.escape_string(str(postid)))) # do operations if replying to a thread (bump, autoclose, update cache) - logTime("Updating thread") + logging.debug("Updating thread") thread_length = None if post["parentid"]: # get length of the thread @@ -1086,7 +1083,7 @@ if __name__ == "__main__": # Psyco is not required, however it will be used if available try: import psyco - logTime("Psyco se ha instalado") + logging.debug("Psyco se ha instalado") psyco.bind(tenjin.helpers.to_str) psyco.bind(weabot.run, 2) psyco.bind(getFormData) -- cgit v1.2.1-18-gbd029 From e8049e9b5a50ad432e87fb28bd93b929e74b8d8a Mon Sep 17 00:00:00 2001 From: bai Date: Tue, 28 Jul 2020 04:29:23 -0400 Subject: Arreglado manejo de países --- cgi/weabot.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'cgi') diff --git a/cgi/weabot.py b/cgi/weabot.py index ff93118..5f659e0 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -729,8 +729,6 @@ class weabot(object): if board["slip"] == '2': if hide_end: host = '★' - elif addressIsTor(ip): - host = 'onion' else: host = getHost(ip) if host: @@ -764,7 +762,7 @@ class weabot(object): if hide_end or addressIsTor(ip): country = '??' else: - country = getCountry(ip) + country = getCountry(ip) or '??' post["name"] += " [%s]" % country # set expiration date if necessary -- cgit v1.2.1-18-gbd029 From 6513d960466a7819fbf2bf3f473c8133621ddaa9 Mon Sep 17 00:00:00 2001 From: bai Date: Tue, 28 Jul 2020 05:09:53 -0400 Subject: Manejando funciones de conversión de miniaturas correctamente --- cgi/img.py | 100 ++++++++++++++++++++++++++++--------------------------------- 1 file changed, 46 insertions(+), 54 deletions(-) (limited to 'cgi') diff --git a/cgi/img.py b/cgi/img.py index ff7cd74..9bc25b7 100644 --- a/cgi/img.py +++ b/cgi/img.py @@ -88,74 +88,62 @@ def processImage(post, data, t, originalname, spoiler=False): # Do we need to thumbnail it? if not used_filetype['image']: # make thumbnail + logging.debug("Generating thumbnail") file_thumb_width, file_thumb_height = getThumbDimensions( width, height, maxsize) - - if used_filetype['ffmpeg_thumb'] == '1': - # use ffmpeg to make thumbnail - logging.debug("Generating thumbnail") - - if used_filetype['mime'][:5] == 'video': - # Create preview for video AND spoiler it if necessary - try: - subprocess.check_output([ + + try: + if used_filetype['ffmpeg_thumb'] == '1': + # use ffmpeg to make thumbnail + if used_filetype['mime'][:5] == 'video': + # Create preview for video AND spoiler it if necessary + call_wrap([ Settings.FFMPEG_PATH, '-strict', '-2', '-ss', '0', '-i', file_path, '-v', 'quiet', '-an', '-vframes', '1', '-f', 'mjpeg', '-vf', 'scale=%d:%d' % ( file_thumb_width, file_thumb_height), '-threads', '1', file_thumb_path]) if spoiler: - subprocess.check_output([Settings.CONVERT_PATH, file_thumb_path, "-limit", "thread", + call_wrap([Settings.CONVERT_PATH, file_thumb_path, "-limit", "thread", "1", "-background", "white", "-flatten", "-resize", "%dx%d" % (file_thumb_width, file_thumb_height), "-blur", "0x12", "-gravity", "center", "-fill", "rgba(0,0,0, .6)", "-draw", "rectangle 0,%d,%d,%d" % ((file_thumb_height/2)-10, file_thumb_width, (file_thumb_height/2)+7), "-fill", "white", "-annotate", "0", "Alerta de spoiler", "-quality", str(Settings.THUMB_QUALITY), file_thumb_path]) - except subprocess.CalledProcessError, e: - os.remove(file_path) - logging.error("Thumbnail creation failure: " + e.output) - raise UserError, _("Thumbnail creation failure.") + ' ('+str(e.returncode)+')' - elif used_filetype['mime'][:5] == 'audio': - # we do an exception and use png for audio waveform thumbnails since they - # 1. are smaller 2. allow for transparency - file_thumb_name = file_thumb_name[:-3] + "png" - file_thumb_path = file_thumb_path[:-3] + "png" - file_mobile_path = file_mobile_path[:-3] + "png" - file_cat_path = file_cat_path[:-3] + "png" - - if int(board['thumb_px']) > 149: - file_thumb_width = board['thumb_px'] - file_thumb_height = float(int(board['thumb_px'])/2) - else: - file_thumb_width = 150 - file_thumb_height = 75 - - try: - subprocess.check_output([Settings.FFMPEG_PATH, '-t', '300', '-i', file_path, - '-filter_complex', 'showwavespic=s=%dx%d:split_channels=1' % ( + elif used_filetype['mime'][:5] == 'audio': + # we do an exception and use png for audio waveform thumbnails since they + # 1. are smaller 2. allow for transparency + file_thumb_name = file_thumb_name[:-3] + "png" + file_thumb_path = file_thumb_path[:-3] + "png" + file_mobile_path = file_mobile_path[:-3] + "png" + file_cat_path = file_cat_path[:-3] + "png" + + if int(board['thumb_px']) > 149: + file_thumb_width = board['thumb_px'] + file_thumb_height = float(int(board['thumb_px'])/2) + else: + file_thumb_width = 150 + file_thumb_height = 75 + + call_wrap([Settings.FFMPEG_PATH, '-t', '300', '-i', file_path, + '-filter_complex', 'showwavespic=s=%dx%d:split_channels=1' % ( int(file_thumb_width), int(file_thumb_height)), - '-frames:v', '1', '-threads', '1', file_thumb_path]) - except subprocess.CalledProcessError, e: - os.remove(file_path) - logging.error("Thumbnail creation failure: " + e.output) - raise UserError, _("Thumbnail creation failure.") + ' ('+str(e.returncode)+')' - else: - # use imagemagick to make thumbnail - args = [Settings.CONVERT_PATH, file_path, "-limit", "thread", "1", "-background", - "white", "-flatten", "-resize", "%dx%d" % (file_thumb_width, file_thumb_height)] - if spoiler: - args += ["-blur", "0x12", "-gravity", "center", "-fill", "rgba(0,0,0, .6)", "-draw", "rectangle 0,%d,%d,%d" % ( - (file_thumb_height/2)-10, file_thumb_width, (file_thumb_height/2)+7), "-fill", "white", "-annotate", "0", "Alerta de spoiler"] - args += ["-quality", str(Settings.THUMB_QUALITY), file_thumb_path] - - # generate thumbnails - logging.debug("Generating thumbnail") - try: - subprocess.check_output(args) - except subprocess.CalledProcessError, e: - os.remove(file_path) - logging.error("Thumbnail creation failure: " + repr(e.output)) - raise UserError, _("Thumbnail creation failure.") + ' ('+str(e.returncode)+')' + '-frames:v', '1', '-threads', '1', file_thumb_path]) + else: + # use imagemagick to make thumbnail + args = [Settings.CONVERT_PATH, file_path, "-limit", "thread", "1", "-background", + "white", "-flatten", "-resize", "%dx%d" % (file_thumb_width, file_thumb_height)] + if spoiler: + args += ["-blur", "0x12", "-gravity", "center", "-fill", "rgba(0,0,0, .6)", "-draw", "rectangle 0,%d,%d,%d" % ( + (file_thumb_height/2)-10, file_thumb_width, (file_thumb_height/2)+7), "-fill", "white", "-annotate", "0", "Alerta de spoiler"] + args += ["-quality", str(Settings.THUMB_QUALITY), file_thumb_path] + + # generate thumbnails + call_wrap(args) + except subprocess.CalledProcessError, e: + os.remove(file_path) + logging.error("Thumbnail creation failure: " + e.output) + raise UserError, _("Thumbnail creation failure.") + ' ('+str(e.returncode)+')' # check if thumbnail was truly created try: @@ -380,6 +368,10 @@ def ffprobe_f(filename): return json.loads(out) +def call_wrap(args): + subprocess.check_output(args, stderr=subprocess.STDOUT) + + def getThumbDimensions(width, height, maxsize): """ Calculate dimensions to use for a thumbnail with maximum width/height of -- cgit v1.2.1-18-gbd029 From 8102e461d107adfb8958bb7a8e28a9ca9ff540ee Mon Sep 17 00:00:00 2001 From: bai Date: Tue, 28 Jul 2020 05:33:19 -0400 Subject: Arreglado error al usar spoilers en miniaturas --- cgi/img.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cgi') diff --git a/cgi/img.py b/cgi/img.py index 9bc25b7..48d4277 100644 --- a/cgi/img.py +++ b/cgi/img.py @@ -108,7 +108,7 @@ def processImage(post, data, t, originalname, spoiler=False): "%dx%d" % (file_thumb_width, file_thumb_height), "-blur", "0x12", "-gravity", "center", "-fill", "rgba(0,0,0, .6)", "-draw", "rectangle 0,%d,%d,%d" % ((file_thumb_height/2)-10, file_thumb_width, (file_thumb_height/2)+7), - "-fill", "white", "-annotate", "0", "Alerta de spoiler", + "-fill", "white", "-font", "Liberation-Sans", "-annotate", "0", "Alerta de spoiler", "-quality", str(Settings.THUMB_QUALITY), file_thumb_path]) elif used_filetype['mime'][:5] == 'audio': # we do an exception and use png for audio waveform thumbnails since they @@ -135,7 +135,8 @@ def processImage(post, data, t, originalname, spoiler=False): "white", "-flatten", "-resize", "%dx%d" % (file_thumb_width, file_thumb_height)] if spoiler: args += ["-blur", "0x12", "-gravity", "center", "-fill", "rgba(0,0,0, .6)", "-draw", "rectangle 0,%d,%d,%d" % ( - (file_thumb_height/2)-10, file_thumb_width, (file_thumb_height/2)+7), "-fill", "white", "-annotate", "0", "Alerta de spoiler"] + (file_thumb_height/2)-10, file_thumb_width, (file_thumb_height/2)+7), "-fill", "white", + "-font", "Liberation-Sans", "-annotate", "0", "Alerta de spoiler"] args += ["-quality", str(Settings.THUMB_QUALITY), file_thumb_path] # generate thumbnails -- cgit v1.2.1-18-gbd029 From 109f8e55385fa37946fa7ad0ac90cc87d738a72c Mon Sep 17 00:00:00 2001 From: bai Date: Tue, 28 Jul 2020 05:33:38 -0400 Subject: Cambiado nivel de logging a WARN --- cgi/weabot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cgi') diff --git a/cgi/weabot.py b/cgi/weabot.py index 5f659e0..b8b9f96 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -35,7 +35,7 @@ class weabot(object): def __init__(self, environ, start_response): global _DEBUG - logging.basicConfig(filename='weabot.log', format='%(asctime)s %(levelname)s %(message)s', level=logging.DEBUG) + logging.basicConfig(filename='weabot.log', format='%(asctime)s %(levelname)s %(message)s', level=logging.WARN) self.environ = environ if self.environ["PATH_INFO"].startswith("/weabot.py/"): -- cgit v1.2.1-18-gbd029 From f71a7d75ddc0725fe15ae78ec44d54f69b32d771 Mon Sep 17 00:00:00 2001 From: bai Date: Tue, 28 Jul 2020 05:42:39 -0400 Subject: Arreglados IPs en manage->recycle bin --- cgi/manage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cgi') diff --git a/cgi/manage.py b/cgi/manage.py index f21e7e8..61cf95e 100644 --- a/cgi/manage.py +++ b/cgi/manage.py @@ -1117,7 +1117,7 @@ def manage(self, path_split): # Table if 'board' in self.formdata.keys() and self.formdata['board'] != 'all': cboard = self.formdata['board'] - posts = FetchAll("SELECT posts.id, posts.timestamp, timestamp_formatted, IS_DELETED, INET6_NTOA(posts.ip) as ip, posts.message, dir, boardid FROM `posts` INNER JOIN `boards` ON boardid = boards.id WHERE `dir` = '%s' AND IS_DELETED %s ORDER BY `timestamp` DESC LIMIT %d, %d" % ( + posts = FetchAll("SELECT posts.id, posts.timestamp, timestamp_formatted, IS_DELETED, INET6_NTOA(posts.ip) AS ip, posts.message, dir, boardid FROM `posts` INNER JOIN `boards` ON boardid = boards.id WHERE `dir` = '%s' AND IS_DELETED %s ORDER BY `timestamp` DESC LIMIT %d, %d" % ( _mysql.escape_string(self.formdata['board']), _mysql.escape_string(type_condition), currentpage*pagesize, pagesize)) try: totals = FetchOne("SELECT COUNT(id) FROM `posts` WHERE IS_DELETED %s AND `boardid` = %s" % ( @@ -1126,7 +1126,7 @@ def manage(self, path_split): skip = True else: cboard = 'all' - posts = FetchAll("SELECT posts.id, posts.timestamp, timestamp_formatted, IS_DELETED, posts.ip, posts.message, dir FROM `posts` INNER JOIN `boards` ON boardid = boards.id WHERE IS_DELETED %s ORDER BY `timestamp` DESC LIMIT %d, %d" % ( + posts = FetchAll("SELECT posts.id, posts.timestamp, timestamp_formatted, IS_DELETED, INET6_NTOA(posts.ip) AS ip, posts.message, dir FROM `posts` INNER JOIN `boards` ON boardid = boards.id WHERE IS_DELETED %s ORDER BY `timestamp` DESC LIMIT %d, %d" % ( _mysql.escape_string(type_condition), currentpage*pagesize, pagesize)) totals = FetchOne("SELECT COUNT(id) FROM `posts` WHERE IS_DELETED %s" % _mysql.escape_string(type_condition), 0) -- cgit v1.2.1-18-gbd029 From c0a967d9c9f3bcb674b7fcbbdab6c8879ae9a6b0 Mon Sep 17 00:00:00 2001 From: bai Date: Tue, 28 Jul 2020 05:52:59 -0400 Subject: IP de failed log-ins logeado a archivo ahora. --- cgi/manage.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'cgi') diff --git a/cgi/manage.py b/cgi/manage.py index 61cf95e..5def5c5 100644 --- a/cgi/manage.py +++ b/cgi/manage.py @@ -3,9 +3,8 @@ import _mysql import os import cgi import shutil -import imaplib -import poplib import datetime +import logging from database import * from settings import Settings @@ -40,8 +39,8 @@ def manage(self, path_split): str(timestamp() - 604800)) # one week else: page += _('Incorrect username/password.') - logAction('', 'Failed log-in. U:'+_mysql.escape_string( - self.formdata['username'])+' IP:'+self.environ["REMOTE_ADDR"]) + logAction('', 'Failed log-in. U:'+_mysql.escape_string(self.formdata['username'])+' IP logged.') + logging.warn("Failed log-in. U:{} IP:{}".format(self.formdata['username'], self.environ["REMOTE_ADDR"])) else: # Validate existing session manage_cookie = getCookie(self, 'weabot_manage') -- cgit v1.2.1-18-gbd029 From 256445343323a7cb4e9015f680af8c7a387d6f1b Mon Sep 17 00:00:00 2001 From: bai Date: Thu, 30 Jul 2020 05:52:28 -0400 Subject: Agregado logeo de excepciones --- cgi/weabot.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cgi') diff --git a/cgi/weabot.py b/cgi/weabot.py index b8b9f96..d809cf0 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -64,6 +64,8 @@ class weabot(object): except UserError, message: self.error(message) except Exception, inst: + logging.exception(inst) + import sys import traceback exc_type, exc_value, exc_traceback = sys.exc_info() -- cgit v1.2.1-18-gbd029 From 27c48ff31e5ecc635f0620711699db996b3e996c Mon Sep 17 00:00:00 2001 From: root Date: Thu, 30 Jul 2020 05:59:43 -0400 Subject: Agregado soporte para WebP --- cgi/img.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cgi') diff --git a/cgi/img.py b/cgi/img.py index 48d4277..1c57e37 100644 --- a/cgi/img.py +++ b/cgi/img.py @@ -31,6 +31,7 @@ def processImage(post, data, t, originalname, spoiler=False): # get image information content_type, width, height, size, extra = getImageInfo(data) + logging.info("{} {} {}".format(content_type, width, height)) # check the size is fine if size > int(board["maxsize"])*1024: @@ -291,6 +292,22 @@ def getImageInfo(data): except ValueError: pass + # handle WebP + if data[:4] == b'RIFF' and data[8:12] == b'WEBP': + chunk = data[12:] + if chunk[:4] == b"VP8 " and chunk[11:14] == b"\x9d\x01\x2a": + # Lossy VP8 + w, h = struct.unpack("HH", chunk[14:18]) + width = w & 0x3fff + height = h & 0x3fff + content_type = "image/webp" + elif chunk[:4] == b"VP8L": + # Lossless VP8 + b0, b1, b2, b3 = struct.unpack("BBBB", chunk[9:13]) + width = 1 + (((b1 & 0x3F) << 8) | b0) + height = 1 + (((b3 & 0xF) << 10) | (b2 << 2) | ((b1 & 0xC0) >> 6)) + content_type = "image/webp" + # handle WebM elif (size >= 4) and data.startswith("\x1A\x45\xDF\xA3"): content_type = "video/webm" -- cgit v1.2.1-18-gbd029 From 89630525f6d84cd58ffa6df79751bf4ff3946fcb Mon Sep 17 00:00:00 2001 From: neptune Date: Thu, 30 Jul 2020 06:01:45 -0400 Subject: Logeando INFO por defecto --- cgi/weabot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cgi') diff --git a/cgi/weabot.py b/cgi/weabot.py index d809cf0..f92e777 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -35,7 +35,7 @@ class weabot(object): def __init__(self, environ, start_response): global _DEBUG - logging.basicConfig(filename='weabot.log', format='%(asctime)s %(levelname)s %(message)s', level=logging.WARN) + logging.basicConfig(filename='weabot.log', format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO) self.environ = environ if self.environ["PATH_INFO"].startswith("/weabot.py/"): -- cgit v1.2.1-18-gbd029