diff options
Diffstat (limited to 'cgi/post.py')
-rw-r--r-- | cgi/post.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/cgi/post.py b/cgi/post.py index 8937054..5e17df1 100644 --- a/cgi/post.py +++ b/cgi/post.py @@ -50,11 +50,19 @@ class Post(object): def insert(self): logTime("Insertando Post") - post_values = [_mysql.escape_string(str(value)) for key, value in self.post.iteritems()] + post_values = [] + + for key, value in self.post.iteritems(): + if key == 'ip': + template = "INET6_ATON('%s')" + else: + template = "'%s'" + + post_values.append(template % _mysql.escape_string(str(value))) - return InsertDb("INSERT INTO `posts` (`%s`) VALUES ('%s')" % ( + return InsertDb("INSERT INTO `posts` (`%s`) VALUES (%s)" % ( "`, `".join(self.post.keys()), - "', '".join(post_values) + ", ".join(post_values) )) class RegenerateThread(threading.Thread): @@ -101,7 +109,7 @@ def getThread(postid=0, mobile=False, timestamp=0): else: cond = "`id` = %s" % str(postid) - op_post = FetchOne("SELECT IS_DELETED, email, file, file_size, id, image_height, image_width, ip, message, name, subject, thumb, thumb_height, thumb_width, timestamp_formatted, tripcode, parentid, locked, expires, expires_alert, expires_formatted, timestamp FROM `posts` WHERE %s AND `boardid` = %s AND parentid = 0 LIMIT 1" % (cond, board["id"])) + op_post = FetchOne("SELECT IS_DELETED, email, file, file_size, id, image_height, image_width, message, name, subject, thumb, thumb_height, thumb_width, timestamp_formatted, tripcode, parentid, locked, expires, expires_alert, expires_formatted, timestamp FROM `posts` WHERE %s AND `boardid` = %s AND parentid = 0 LIMIT 1" % (cond, board["id"])) if op_post: op_post['num'] = 1 if mobile: @@ -110,7 +118,7 @@ def getThread(postid=0, mobile=False, timestamp=0): #thread = {"id": op_post["id"], "posts": [op_post], "omitted": 0, "omitted_img": 0} total_bytes += len(op_post["message"])+80 - replies = FetchAll("SELECT IS_DELETED, email, file, file_size, id, image_height, image_width, ip, message, name, subject, thumb, thumb_height, thumb_width, timestamp_formatted, tripcode, parentid, locked, expires, expires_alert, expires_formatted, timestamp FROM `posts` WHERE `parentid` = %s AND `boardid` = %s ORDER BY `id` ASC" % (op_post["id"], board["id"])) + replies = FetchAll("SELECT IS_DELETED, email, file, file_size, id, image_height, image_width, message, name, subject, thumb, thumb_height, thumb_width, timestamp_formatted, tripcode, parentid, locked, expires, expires_alert, expires_formatted, timestamp FROM `posts` WHERE `parentid` = %s AND `boardid` = %s ORDER BY `id` ASC" % (op_post["id"], board["id"])) thread["length"] = 1 if replies: for reply in replies: |