Esempio n. 1
0
def admin_check(conn, num, what):
    ip = ip_check()
    curs = conn.cursor()
    curs.execute("select acl from user where id = ?", [ip])
    user = curs.fetchall()
    if (user):
        reset = 0
        while (1):
            if (num == 1 and reset == 0):
                check = 'ban'
            elif (num == 2 and reset == 0):
                check = 'mdel'
            elif (num == 3 and reset == 0):
                check = 'toron'
            elif (num == 4 and reset == 0):
                check = 'check'
            elif (num == 5 and reset == 0):
                check = 'acl'
            elif (num == 6 and reset == 0):
                check = 'hidel'
            elif (num == 7 and reset == 0):
                check = 'give'
            else:
                check = 'owner'

            curs.execute('select name from alist where name = ? and acl = ?',
                         [user[0][0], check])
            acl_data = curs.fetchall()
            if (acl_data):
                if (what):
                    curs.execute(
                        "insert into re_admin (who, what, time) values (?, ?, ?)",
                        [ip, what, get_time()])
                    conn.commit()

                return (1)
            else:
                if (reset == 0):
                    reset = 1
                else:
                    break
Esempio n. 2
0
def api_error(conn, data):
    curs = conn.cursor()
    if (data == '/ban'):
        ip = ip_check()
        end = '|| 사유 || 권한이 맞지 않는 상태 입니다. ||'
        if (ban_check(conn) == 1):
            curs.execute("select end, why from ban where block = ?", [ip])
            d = curs.fetchall()
            if (not d):
                m = re.search("^([0-9]{1,3}\.[0-9]{1,3})", ip)
                if (m):
                    curs.execute(
                        "select end, why from ban where block = ? and band = 'O'",
                        [m.groups()[0]])
                    d = curs.fetchall()

            if (d):
                end = '|| 상태 ||'
                if (d[0][0]):
                    now = int(re.sub('(:|-| )', '', get_time()))
                    day = re.sub('\-', '', d[0][0])

                    if (re.search(':', day)):
                        day = re.sub('( |:)', '', day)
                    else:
                        day += '000000'

                    if (now >= int(day)):
                        curs.execute("delete from ban where block = ?", [ip])
                        conn.commit()

                        end += '차단이 풀렸습니다. 다시 시도 해 보세요.'
                    else:
                        end += d[0][0] + ' 까지 차단 상태 입니다.'
                else:
                    end += '영구 차단 상태 입니다.'

                end += '||'

                if (d[0][1] != ''):
                    end += '\r\n|| 사유 || ' + d[0][1] + ' ||'

        return json.dumps({'code': 403, 'message': end, 'result': ""})

    d = re.search('\/error\/([0-9]+)', data)
    if (d):
        num = int(d.groups()[0])
        if (num == 1):
            title = '권한 오류'
            data = '비 로그인 상태 입니다.'
        elif (num == 2):
            title = '권한 오류'
            data = '이 계정이 없습니다.'
        elif (num == 3):
            title = '권한 오류'
            data = '권한이 모자랍니다.'
        elif (num == 4):
            title = '권한 오류'
            data = '관리자는 차단, 검사 할 수 없습니다.'
        elif (num == 5):
            title = '사용자 오류'
            data = '그런 계정이 없습니다.'
        elif (num == 6):
            title = '가입 오류'
            data = '동일한 아이디의 사용자가 있습니다.'
        elif (num == 7):
            title = '가입 오류'
            data = '아이디는 20글자보다 짧아야 합니다.'
        elif (num == 8):
            title = '가입 오류'
            data = '아이디에는 한글과 알파벳과 공백만 허용 됩니다.'
        elif (num == 9):
            title = '파일 올리기 오류'
            data = '파일이 없습니다.'
        elif (num == 10):
            title = '변경 오류'
            data = '비밀번호가 다릅니다.'
        elif (num == 11):
            title = '로그인 오류'
            data = '이미 로그인 되어 있습니다.'
        elif (num == 12):
            title = '편집 오류'
            data = '누군가 먼저 편집 했습니다.'
        elif (num == 13):
            title = '리캡차 오류'
            data = '리캡차를 통과하세요.'
        elif (num == 14):
            title = '파일 올리기 오류'
            data = 'jpg, gif, jpeg, png, webp만 가능 합니다.'
        elif (num == 15):
            title = '편집 오류'
            data = '편집 기록은 500자를 넘을 수 없습니다.'
        elif (num == 16):
            title = '파일 올리기 오류'
            data = '동일한 이름의 파일이 있습니다.'
        elif (num == 17):
            title = '파일 올리기 오류'
            data = '파일 용량은 ' + wiki_set(conn, 3) + 'MB를 넘길 수 없습니다.'
        elif (num == 18):
            title = '편집 오류'
            data = '내용이 원래 문서와 동일 합니다.'
        elif (num == 19):
            title = '이동 오류'
            data = '이동 하려는 곳에 문서가 이미 있습니다.'
        elif (num == 20):
            title = '비밀번호 오류'
            data = '재 확인이랑 비밀번호가 다릅니다.'
        elif (num == 21):
            title = '편집 오류'
            data = '편집 필터에 의해 검열 되었습니다.'
        else:
            title = '정체 불명의 오류'
            data = '???'
        # 귀찮은 관계로 그냥 다 500 에러 처리한다.
        return json.dumps({'code': 500, 'message': title, 'result': data})
    else:
        return json.dumps({
            'code': 500,
            'message': 'internal server error',
            'result': ""
        })
Esempio n. 3
0
def re_error(conn, data):
    curs = conn.cursor()
    if (data == '/ban'):
        ip = ip_check()
        end = '|| 사유 || 권한이 맞지 않는 상태 입니다. ||'
        if (ban_check(conn) == 1):
            curs.execute("select end, why from ban where block = ?", [ip])
            d = curs.fetchall()
            if (not d):
                m = re.search("^([0-9]{1,3}\.[0-9]{1,3})", ip)
                if (m):
                    curs.execute(
                        "select end, why from ban where block = ? and band = 'O'",
                        [m.groups()[0]])
                    d = curs.fetchall()

            if (d):
                end = '|| 상태 ||'
                if (d[0][0]):
                    now = int(re.sub('(:|-| )', '', get_time()))
                    day = re.sub('\-', '', d[0][0])

                    if (re.search(':', day)):
                        day = re.sub('( |:)', '', day)
                    else:
                        day += '000000'

                    if (now >= int(day)):
                        curs.execute("delete from ban where block = ?", [ip])
                        conn.commit()

                        end += '차단이 풀렸습니다. 다시 시도 해 보세요.'
                    else:
                        end += d[0][0] + ' 까지 차단 상태 입니다.'
                else:
                    end += '영구 차단 상태 입니다.'

                end += '||'

                if (d[0][1] != ''):
                    end += '\r\n|| 사유 || ' + d[0][1] + ' ||'

        return (html_minify(
            template(
                'index',
                imp=['권한 오류',
                     wiki_set(conn, 1),
                     custom(conn),
                     other2([0, 0])],
                data=namumark(conn, "", "[목차(없음)]\r\n== 권한 상태 ==\r\n" + end, 0,
                              0, 0),
                menu=0)))

    d = re.search('\/error\/([0-9]+)', data)
    if (d):
        num = int(d.groups()[0])
        if (num == 1):
            title = '권한 오류'
            data = '비 로그인 상태 입니다.'
        elif (num == 2):
            title = '권한 오류'
            data = '이 계정이 없습니다.'
        elif (num == 3):
            title = '권한 오류'
            data = '권한이 모자랍니다.'
        elif (num == 4):
            title = '권한 오류'
            data = '관리자는 차단, 검사 할 수 없습니다.'
        elif (num == 5):
            title = '사용자 오류'
            data = '그런 계정이 없습니다.'
        elif (num == 6):
            title = '가입 오류'
            data = '동일한 아이디의 사용자가 있습니다.'
        elif (num == 7):
            title = '가입 오류'
            data = '아이디는 20글자보다 짧아야 합니다.'
        elif (num == 8):
            title = '가입 오류'
            data = '아이디에는 한글과 알파벳과 공백만 허용 됩니다.'
        elif (num == 9):
            title = '파일 올리기 오류'
            data = '파일이 없습니다.'
        elif (num == 10):
            title = '변경 오류'
            data = '비밀번호가 다릅니다.'
        elif (num == 11):
            title = '로그인 오류'
            data = '이미 로그인 되어 있습니다.'
        elif (num == 12):
            title = '편집 오류'
            data = '누군가 먼저 편집 했습니다.'
        elif (num == 13):
            title = '리캡차 오류'
            data = '리캡차를 통과하세요.'
        elif (num == 14):
            title = '파일 올리기 오류'
            data = 'jpg, gif, jpeg, png, webp만 가능 합니다.'
        elif (num == 15):
            title = '편집 오류'
            data = '편집 기록은 500자를 넘을 수 없습니다.'
        elif (num == 16):
            title = '파일 올리기 오류'
            data = '동일한 이름의 파일이 있습니다.'
        elif (num == 17):
            title = '파일 올리기 오류'
            data = '파일 용량은 ' + wiki_set(conn, 3) + 'MB를 넘길 수 없습니다.'
        elif (num == 18):
            title = '편집 오류'
            data = '내용이 원래 문서와 동일 합니다.'
        elif (num == 19):
            title = '이동 오류'
            data = '이동 하려는 곳에 문서가 이미 있습니다.'
        elif (num == 20):
            title = '비밀번호 오류'
            data = '재 확인이랑 비밀번호가 다릅니다.'
        elif (num == 21):
            title = '편집 오류'
            data = '편집 필터에 의해 검열 되었습니다.'
        else:
            title = '정체 불명의 오류'
            data = '???'

        if (title):
            return (html_minify(
                template('index',
                         imp=[
                             title,
                             wiki_set(conn, 1),
                             custom(conn),
                             other2([0, 0])
                         ],
                         data=namumark(conn, "",
                                       "[목차(없음)]\r\n== 오류 발생 ==\r\n" + data, 0,
                                       0, 0),
                         menu=0)))
        else:
            return (redirect('/'))
    else:
        return (redirect('/'))