Exemplo n.º 1
0
 def set_date(self, editing, date_style):
     '''Sets the date or lastedit according to the timestamp'''
     if not editing:
         self.date = misc.make_date(self.timestamp, date_style)
     else:
         self.date = editing.date
         if not self.ninja:
             self.lastedit = misc.make_date(self.timestamp, date_style)
Exemplo n.º 2
0
 def set_date(self, editing, date_style):
     '''Sets the date or lastedit according to the timestamp'''
     if not editing:
         self.date = misc.make_date(self.timestamp, date_style)
     else:
         self.date = editing.date
         if not self.ninja:
             self.lastedit = misc.make_date(self.timestamp, date_style)
Exemplo n.º 3
0
    def make_admin_ban_panel(self, ip=""):
        session = model.Session()
        table = model.admin

        sql = select(
            [
                model.activity.c.username,
                table.c.num,
                table.c.type,
                table.c.comment,
                table.c.ival1,
                table.c.ival2,
                table.c.sval1,
                table.c.total,
                table.c.expiration,
            ],
            from_obj=[
                table.outerjoin(
                    model.activity,
                    and_(table.c.num == model.activity.c.admin_id, table.c.type == model.activity.c.action),
                )
            ],
        ).order_by(table.c.type.asc(), table.c.num.asc())

        # TODO: We should be paginating, but the page needs to be
        # adjusted first.
        # res = model.Page(sql, self.page, self.perpage)

        query = session.execute(sql)
        bans = [dict(row.items()) for row in query]

        rowtype = 1
        prevtype = ""
        for row in bans:
            prevtype = row
            if prevtype != row["type"]:
                row["divider"] = 1

            # Alternate between values 1 and 2.
            rowtype ^= 0x3
            row["rowtype"] = rowtype

            if row["expiration"]:
                row["expirehuman"] = misc.make_date(row["expiration"])
            else:
                row["expirehuman"] = "Never"

            if row["total"] == "yes":
                row["browsingban"] = "No"
            else:
                row["browsingban"] = "Yes"

        Template.__init__(self, "ban_panel_template", bans=bans, ip=ip)
Exemplo n.º 4
0
 def __init__(self, cookie, action, **kwargs):
     self.action = action
     self.user = staff.StaffMember.get_from_cookie(cookie)
     self.board = None
     self.kwargs = kwargs
     try:
         self.board = kwargs.pop('board')
     except KeyError:
         pass
     self.timestamp = time.time()
     self.date = misc.make_date(self.timestamp, style=config.DATE_STYLE)
     self.contents = []
     self.action = action
     self.admin_id = None
Exemplo n.º 5
0
 def __init__(self, cookie, action, **kwargs):
     self.action = action
     self.user = staff.StaffMember.get_from_cookie(cookie)
     self.board = None
     self.kwargs = kwargs
     try:
         self.board = kwargs.pop('board')
     except KeyError:
         pass
     self.timestamp = time.time()
     self.date = misc.make_date(self.timestamp, style=config.DATE_STYLE)
     self.contents = []
     self.action = action
     self.admin_id = None
Exemplo n.º 6
0
 def __init__(self, admin, action, **kwargs):
     self.action = action
     self.user = staff.check_password(admin)
     self.board = None
     self.kwargs = kwargs
     try:
         self.board = kwargs.pop('board')
     except KeyError:
         pass
     self.timestamp = time.time()
     self.date = misc.make_date(self.timestamp, style=config.DATE_STYLE)
     self.contents = []
     self.action = action
     self.admin_id = None
Exemplo n.º 7
0
    def make_admin_ban_panel(self, ip=''):
        session = model.Session()
        table = model.admin

        sql = select([model.activity.c.username,
                      table.c.num,
                      table.c.type,
                      table.c.comment,
                      table.c.ival1,
                      table.c.ival2,
                      table.c.sval1,
                      table.c.total,
                      table.c.expiration],
            from_obj=[table.outerjoin(model.activity,
            and_(table.c.num == model.activity.c.admin_id,
            table.c.type == model.activity.c.action))])\
            .order_by(table.c.type.asc(), table.c.num.asc())

        # TODO: We should be paginating, but the page needs to be
        # adjusted first.
        # res = model.Page(sql, self.page, self.perpage)

        query = session.execute(sql)
        bans = [dict(row.items()) for row in query]

        rowtype = 1
        prevtype = ''
        for row in bans:
            prevtype = row
            if prevtype != row['type']:
                row['divider'] = 1

            # Alternate between values 1 and 2.
            rowtype ^= 0x3
            row['rowtype'] = rowtype

            if row['expiration']:
                row['expirehuman'] = misc.make_date(row['expiration'])
            else:
                row['expirehuman'] = 'Never'

            if row['total'] == 'yes':
                row['browsingban'] = 'No'
            else:
                row['browsingban'] = 'Yes'

        Template.__init__(self, 'ban_panel_template', bans=bans, ip=ip)
Exemplo n.º 8
0
    def make_admin_ban_panel(self, ip=''):
        session = model.Session()
        table = model.admin

        sql = select([model.activity.c.username,
                      table.c.num,
                      table.c.type,
                      table.c.comment,
                      table.c.ival1,
                      table.c.ival2,
                      table.c.sval1,
                      table.c.total,
                      table.c.expiration],
            from_obj=[table.outerjoin(model.activity,
            and_(table.c.num == model.activity.c.admin_id,
            table.c.type == model.activity.c.action))])\
            .order_by(table.c.type.asc(), table.c.num.asc())

        # TODO: We should be paginating, but the page needs to be
        # adjusted first.
        # res = model.Page(sql, self.page, self.perpage)

        query = session.execute(sql)
        bans = [dict(row.items()) for row in query]

        rowtype = 1
        prevtype = ''
        for row in bans:
            prevtype = row
            if prevtype != row['type']:
                row['divider'] = 1

            # Alternate between values 1 and 2.
            rowtype ^= 0x3
            row['rowtype'] = rowtype

            if row['expiration']:
                row['expirehuman'] = misc.make_date(row['expiration'])
            else:
                row['expirehuman'] = 'Never'

            if row['total'] == 'yes':
                row['browsingban'] = 'No'
            else:
                row['browsingban'] = 'Yes'

        Template.__init__(self, 'ban_panel_template', bans=bans, ip=ip)
Exemplo n.º 9
0
def add_proxy_entry(task_data, type, ip, timestamp):
    session = model.Session()
    table = model.proxy

    if not misc.validate_ip(ip):
        raise WakaError(strings.BADIP)

    age = config.PROXY_WHITE_AGE if type == 'white' else config.PROXY_BLACK_AGE
    timestamp = int(timestamp or '0') - age + time.time()
    date = misc.make_date(time.time(), style=config.DATE_STYLE)

    query = table.delete().where(table.c.ip == ip)
    session.execute(query)

    query = table.insert().values(type=type,
                                  ip=ip,
                                  timestamp=timestamp,
                                  date=date)
    session.execute(query)

    board = local.environ['waka.board']
    forward_url = misc.make_script_url(task='proxy', board=board.name)

    return util.make_http_forward(forward_url, config.ALTERNATE_REDIRECT)
Exemplo n.º 10
0
 def make_date(self, timestamp, style='futaba'):
     return misc.make_date(timestamp, style)
Exemplo n.º 11
0
 def make_date(self, timestamp, style='futaba'):
     return misc.make_date(timestamp, style)