잉여개발기 1 سال پیش
والد
کامیت
98e26a34ce

+ 7 - 1
app.py

@@ -148,7 +148,13 @@ with get_db_connect(init_mode = True) as conn:
             pass
 
         if setup_tool == 'update':
-            update(conn, int(ver_set_data[0][0]), data_db_set)
+            try:
+                loop = asyncio.get_running_loop()
+                loop.create_task(update(conn, int(ver_set_data[0][0]), data_db_set))
+            except RuntimeError:
+                loop = asyncio.new_event_loop()
+                asyncio.set_event_loop(loop)
+                loop.run_until_complete(update(conn, int(ver_set_data[0][0]), data_db_set))
         else:
             set_init(conn)
 

+ 2 - 2
route/api_user_info.py

@@ -7,7 +7,7 @@ async def api_user_info(user_name = ''):
         data_result = {}
         
         # name part
-        data_result['render'] = ip_pas(user_name)
+        data_result['render'] = await ip_pas(user_name)
         
         # auth part
         curs.execute(db_change("select data from user_set where id = ? and name = 'acl'"), [user_name])
@@ -32,7 +32,7 @@ async def api_user_info(user_name = ''):
         data_result['max_exp'] = level_data[2]
             
         # ban part
-        ban = ban_check(user_name)
+        ban = await ban_check(user_name)
         if ban[0] == 0:
             data_result['ban'] = '0'
         else:

+ 2 - 2
route/bbs_w.py

@@ -151,7 +151,7 @@ async def bbs_w(bbs_num = '', tool = 'bbs', page = 1, name = ''):
                     
                 data += '''
                     <tr>
-                        <td>''' + ip_pas(temp_dict['comment_user_id']) + '''</td>
+                        <td>''' + await ip_pas(temp_dict['comment_user_id']) + '''</td>
                         <td>''' + temp_dict['comment_date'] + '''</td>
                         <td>''' + ('#' + comment_link) + '''</td>
                     </tr>
@@ -173,7 +173,7 @@ async def bbs_w(bbs_num = '', tool = 'bbs', page = 1, name = ''):
             
                 data += '''
                     <tr class="''' + ('opennamu_comment_color_red' if notice == 1 else '') + '''">
-                        <td>''' + ip_pas(temp_dict['user_id']) + '''</td>
+                        <td>''' + await ip_pas(temp_dict['user_id']) + '''</td>
                         <td>''' + temp_dict['date'] + '''</td>
                         <td>''' + last_comment_date + '''</td>
                     </tr>

+ 6 - 6
route/bbs_w_post.py

@@ -37,7 +37,7 @@ async def bbs_w_post_comment(conn, user_id, sub_code, comment_num, bbs_num_str,
 
             comment_data += '<span style="padding-left: 20px;"></span>' * margin_count
             comment_data += api_topic_thread_make(
-                ip_pas(temp_dict['comment_user_id']),
+                await ip_pas(temp_dict['comment_user_id']),
                 date,
                 render_set(conn, doc_data = temp_dict['comment']),
                 sub_code_check,
@@ -98,7 +98,7 @@ async def bbs_w_post(bbs_num = '', post_num = ''):
                         return redirect(conn, '/bbs/w/' + bbs_num_str + '/' + post_num_str)
                     
                     data = data.replace('\r', '')
-                    data = api_topic_thread_pre_render(conn, data, id_data, ip, set_id, bbs_name, temp_dict['title'], 'post')
+                    data = await api_topic_thread_pre_render(conn, data, id_data, ip, set_id, bbs_name, temp_dict['title'], 'post')
                     
                     date = get_time()
 
@@ -106,7 +106,7 @@ async def bbs_w_post(bbs_num = '', post_num = ''):
                     curs.execute(db_change("insert into bbs_data (set_name, set_code, set_id, set_data) values ('comment_date', ?, ?, ?)"), [id_data, set_id, date])
                     curs.execute(db_change("insert into bbs_data (set_name, set_code, set_id, set_data) values ('comment_user_id', ?, ?, ?)"), [id_data, set_id, ip])
 
-                    add_alarm(temp_dict['user_id'], ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + id_data + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + id_data + '</a>')
+                    await add_alarm(temp_dict['user_id'], ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + id_data + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + id_data + '</a>')
 
                     return redirect(conn, '/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + id_data)
                 else:
@@ -165,9 +165,9 @@ async def bbs_w_post(bbs_num = '', post_num = ''):
                         set_id += '-' if set_id != '' else ''
                         end_id = set_id + id_data
 
-                    add_alarm(temp_dict['user_id'], ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + end_id + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + end_id + '</a>')
+                    await add_alarm(temp_dict['user_id'], ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + end_id + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + end_id + '</a>')
                     if comment_user_name != '':
-                        add_alarm(comment_user_name, ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + end_id + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + end_id + '</a>')
+                        await add_alarm(comment_user_name, ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + end_id + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + end_id + '</a>')
 
                     return redirect(conn, '/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + end_id)
             else:
@@ -181,7 +181,7 @@ async def bbs_w_post(bbs_num = '', post_num = ''):
                 data = ''
                 data += '<h2>' + html.escape(temp_dict['title']) + '</h2>'
                 data += api_topic_thread_make(
-                    ip_pas(temp_dict['user_id']),
+                    await ip_pas(temp_dict['user_id']),
                     date,
                     render_set(conn, doc_data = temp_dict['data']),
                     '0',

+ 2 - 2
route/edit.py

@@ -228,7 +228,7 @@ async def edit(name = 'Test', section = 0, do_type = ''):
         
                 curs.execute(db_change("select id from user_set where name = 'watchlist' and data = ?"), [name])
                 for scan_user in curs.fetchall():
-                    add_alarm(scan_user[0], ip, '<a href="/w/' + url_pas(name) + '">' + html.escape(name) + '</a>')
+                    await add_alarm(scan_user[0], ip, '<a href="/w/' + url_pas(name) + '">' + html.escape(name) + '</a>')
                         
                 history_plus(conn, 
                     name,
@@ -257,7 +257,7 @@ async def edit(name = 'Test', section = 0, do_type = ''):
 
                 curs.execute(db_change("select id from user_set where name = 'watchlist' and data = ?"), [name])
                 for scan_user in curs.fetchall():
-                    add_alarm(scan_user[0], ip, '<a href="/edit_request/' + url_pas(name) + '">' + html.escape(name) + '</a> edit_request')
+                    await add_alarm(scan_user[0], ip, '<a href="/edit_request/' + url_pas(name) + '">' + html.escape(name) + '</a> edit_request')
             
                 return redirect(conn, '/edit_request_from/' + url_pas(name))
         else:

+ 1 - 1
route/edit_request.py

@@ -47,7 +47,7 @@ async def edit_request(name = 'Test', do_type = ''):
             
             curs.execute(db_change("select id from user_set where name = 'watchlist' and data = ?"), [name])
             for scan_user in curs.fetchall():
-                add_alarm(scan_user[0], edit_request_user, '<a href="/w/' + url_pas(name) + '">' + html.escape(name) + '</a>')
+                await add_alarm(scan_user[0], edit_request_user, '<a href="/w/' + url_pas(name) + '">' + html.escape(name) + '</a>')
 
             if flask.request.form.get('check', '') == 'Y':
                 curs.execute(db_change("delete from data where title = ?"), [name])

+ 1 - 1
route/give_user_ban.py

@@ -6,7 +6,7 @@ async def give_user_ban(name = None, ban_type = ''):
 
         ip = ip_check()
         
-        if ban_check(ip = ip, tool = 'login')[0] == 1:
+        if (await ban_check(ip = ip, tool = 'login'))[0] == 1:
             if ip_or_user(ip) == 1 or await acl_check(tool = 'all_admin_auth', ip = ip) != 0:
                 return await re_error(conn, 0)
         else:

+ 5 - 5
route/go_api_topic.py

@@ -38,7 +38,7 @@ def api_topic_thread_make(user_id, date, data, code, color = '', blind = '', add
         </span>
     '''
 
-def api_topic_thread_pre_render(conn, data, num, ip, topic_num = '', name = '', sub = '', do_type = 'thread'):
+async def api_topic_thread_pre_render(conn, data, num, ip, topic_num = '', name = '', sub = '', do_type = 'thread'):
     curs = conn.cursor()
 
     # 이거 좀 엉성해서 언젠간 손 보고 싶음
@@ -79,12 +79,12 @@ def api_topic_thread_pre_render(conn, data, num, ip, topic_num = '', name = '',
             ip_data = curs.fetchall()
             if ip_data and ip_or_user(ip_data[0][0]) == 0:
                 if do_type == 'thread':
-                    add_alarm(ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                    await add_alarm(ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
                 else:
                     set_id = topic_num.split('-')
                     set_id = ['', ''] if len(set_id) < 2 else set_id
 
-                    add_alarm(ip_data[0][0], ip, 'BBS <a href="/bbs/w/' + set_id[0] + '/' + set_id[1] + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                    await add_alarm(ip_data[0][0], ip, 'BBS <a href="/bbs/w/' + set_id[0] + '/' + set_id[1] + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
 
             data = re.sub(call_thread_regex, rd_data[0] + '<topic_a_' + do_type + '>#' + view_data + '</topic_a_' + do_type + '>' + rd_data[3], data, 1)
 
@@ -109,10 +109,10 @@ def api_topic_thread_pre_render(conn, data, num, ip, topic_num = '', name = '',
 
             if ip_data and ip_or_user(ip_data[0][0]) == 0:
                 if do_type == 'thread':
-                    add_alarm(ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                    await add_alarm(ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
                 else:
                     set_id = topic_num.split('-')
-                    add_alarm(ip_data[0][0], ip, 'BBS <a href="/bbs/w/' + set_id[0] + '/' + set_id[1] + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                    await add_alarm(ip_data[0][0], ip, 'BBS <a href="/bbs/w/' + set_id[0] + '/' + set_id[1] + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
 
             data = re.sub(call_user_regex, rd_data[0] + '<topic_call>@' + rd_data[1] + '</topic_call>' + rd_data[2], data, 1)
 

+ 1 - 1
route/go_main_func_easter_egg.py

@@ -1,6 +1,6 @@
 from .tool.func import *
 
-def main_func_easter_egg():
+async def main_func_easter_egg():
     with get_db_connect() as conn:
         curs = conn.cursor()
 

+ 1 - 1
route/list_admin.py

@@ -11,7 +11,7 @@ async def list_admin():
         ))
         for data in curs.fetchall():
             name = '' + \
-                ip_pas(data[0]) + ' ' + \
+                await ip_pas(data[0]) + ' ' + \
                 '<a href="/auth/list/add/' + url_pas(data[1]) + '">(' + data[1] + ')</a>' + \
             ''
 

+ 1 - 1
route/list_admin_auth_use.py

@@ -32,7 +32,7 @@ async def list_admin_auth_use(arg_num = 1, arg_search = 'normal'):
                         do_data = do_data.split(' ')
                         do_data = do_data[0] if do_data[0] in ('ban') else data[1]
 
-                list_data += '<li>' + ip_pas(data[0]) + ' | ' + html.escape(do_data) + ' | ' + data[2] + '</li>'
+                list_data += '<li>' + await ip_pas(data[0]) + ' | ' + html.escape(do_data) + ' | ' + data[2] + '</li>'
 
             list_data += '</ul>'
             list_data += get_next_page_bottom(conn, '/list/admin/auth_use_page/{}/' + url_pas(arg_search), arg_num, get_list)

+ 1 - 1
route/list_user.py

@@ -12,7 +12,7 @@ async def list_user(arg_num = 1):
         user_list = curs.fetchall()
         for data in user_list:
             list_data += '<li>'
-            list_data += ip_pas(data[0])
+            list_data += await ip_pas(data[0])
             list_data += ' | ' + data[1] if data[1] != '' else ''
             list_data += '</li>'
 

+ 1 - 1
route/login_login.py

@@ -8,7 +8,7 @@ async def login_login_2():
         if ip_or_user(ip) == 0:
             return redirect(conn, '/user')
 
-        if ban_check(None, 'login')[0] == 1:
+        if (await ban_check(None, 'login'))[0] == 1:
             return await re_error(conn, 0)
 
         if flask.request.method == 'POST':

+ 1 - 1
route/login_login_2fa.py

@@ -14,7 +14,7 @@ async def login_login_2fa_2():
         if ip_or_user(ip) == 0:
             return redirect(conn, '/user')
 
-        if ban_check(None, 'login')[0] == 1:
+        if (await ban_check(None, 'login'))[0] == 1:
             return await re_error(conn, 0)
 
         if flask.request.method == 'POST':

+ 1 - 1
route/login_login_2fa_email.py

@@ -14,7 +14,7 @@ async def login_login_2fa_email_2():
         if ip_or_user(ip) == 0:
             return redirect(conn, '/user')
 
-        if ban_check(None, 'login')[0] == 1:
+        if (await ban_check(None, 'login'))[0] == 1:
             return await re_error(conn, 0)
 
         if flask.request.method == 'POST':

+ 1 - 1
route/login_register.py

@@ -4,7 +4,7 @@ async def login_register_2():
     with get_db_connect() as conn:
         curs = conn.cursor()
 
-        if ban_check(None, 'register')[0] == 1:
+        if (await ban_check(None, 'register'))[0] == 1:
             return await re_error(conn, 0)
 
         ip = ip_check()

+ 1 - 1
route/recent_change.py

@@ -120,7 +120,7 @@ async def recent_change(name = '', tool = '', num = 1, set_type = 'normal'):
 
             div += '</tr>'
 
-            all_ip = ip_pas([i[3] for i in data_list])
+            all_ip = await ip_pas([i[3] for i in data_list])
             for data in data_list:
                 select += '<option value="' + data[0] + '">' + data[0] + '</option>'
                 send = data[4]

+ 1 - 1
route/recent_record_topic.py

@@ -16,7 +16,7 @@ async def recent_record_topic(name = 'Test'):
                 </tr>
         '''
         sub = '(' + html.escape(name) + ')'
-        pas_name = ip_pas(name)
+        pas_name = await ip_pas(name)
 
         curs.execute(db_change("select code, id, date from topic where ip = ? order by date desc limit ?, 50"), [name, sql_num])
         data_list = curs.fetchall()

+ 5 - 5
route/tool/func.py

@@ -429,7 +429,7 @@ def get_db_table_list():
     
     return create_data
 
-def update(conn, ver_num, set_data):
+async def update(conn, ver_num, set_data):
     curs = conn.cursor()
 
     # 업데이트 하위 호환 유지 함수
@@ -724,9 +724,9 @@ def update(conn, ver_num, set_data):
             for for_b in curs.fetchall():
                 lang_name = get_lang_name(conn, tool = 'inter')
                 if lang_name == 'ko-KR':
-                    add_alarm(for_b[0], 'tool:system', '메인 ACL이 권한으로 개편되면서 기존 설정 값이 날라갔으니 권한으로 재설정 해주세요.')
+                    await add_alarm(for_b[0], 'tool:system', '메인 ACL이 권한으로 개편되면서 기존 설정 값이 날라갔으니 권한으로 재설정 해주세요.')
                 else:
-                    add_alarm(for_b[0], 'tool:system', 'As the main ACL has been reorganized into the auth, the existing setting values have been lost, so please reset it to the auth.')
+                    await add_alarm(for_b[0], 'tool:system', 'As the main ACL has been reorganized into the auth, the existing setting values have been lost, so please reset it to the auth.')
 
     print('Update completed')
 
@@ -1451,7 +1451,7 @@ async def wiki_custom(conn):
         email,
         user_name,
         user_admin,
-        str(ban_check()[0]),
+        str((await ban_check())[0]),
         user_notice,
         user_acl_list,
         ip,
@@ -2321,7 +2321,7 @@ async def re_error(conn, data):
     curs = conn.cursor()
 
     if data == 0:
-        if ban_check()[0] == 1:
+        if (await ban_check())[0] == 1:
             end = '<div id="opennamu_get_user_info">' + html.escape(ip_check()) + '</div>'
         else:
             end = '<ul><li>' + get_lang(conn, 'authority_error') + '</li></ul>'

+ 3 - 3
route/topic.py

@@ -98,14 +98,14 @@ async def topic(topic_num = 0, do_type = '', doc_name = 'Test'):
                         y_check = 1
 
                 if y_check == 1:
-                    add_alarm(match, ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                    await add_alarm(match, ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
             
             curs.execute(db_change("select ip from topic where code = ? and id = '1'"), [topic_num])
             ip_data = curs.fetchall()
             if ip_data and ip_or_user(ip_data[0][0]) == 0:
-                add_alarm(ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                await add_alarm(ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
 
-            data = api_topic_thread_pre_render(conn, data, num, ip, topic_num, name, sub)
+            data = await api_topic_thread_pre_render(conn, data, num, ip, topic_num, name, sub)
 
             do_add_thread(conn, 
                 topic_num,

+ 1 - 1
route/topic_comment_tool.py

@@ -18,7 +18,7 @@ async def topic_comment_tool(topic_num = 1, num = 1):
         ban = '''
             <h2>''' + get_lang(conn, 'state') + '''</h2>
             <ul>
-                <li>''' + get_lang(conn, 'writer') + ' : ''' + ip_pas(data[0][1]) + '''</li>
+                <li>''' + get_lang(conn, 'writer') + ' : ''' + await ip_pas(data[0][1]) + '''</li>
                 <li>''' + get_lang(conn, 'time') + ' : ' + data[0][2] + '''</li>
             </ul>
             <h2>''' + get_lang(conn, 'other_tool') + '''</h2>

+ 1 - 1
route/user_alarm.py

@@ -28,7 +28,7 @@ async def user_alarm():
                 
                 data += '' + \
                     '<li style="' + data_style + '">' + \
-                        ip_pas(data_split[0]) + (' | ' + ' | '.join(data_split[1:]) if len(data_split) > 1 else '') + \
+                        await ip_pas(data_split[0]) + (' | ' + ' | '.join(data_split[1:]) if len(data_split) > 1 else '') + \
                         ' | ' + data_one[1] + \
                         ' <a href="/alarm/delete/' + url_pas(data_one[3]) + '">(' + get_lang(conn, 'delete') + ')</a>' + \
                     '</li>' + \

+ 1 - 1
route/user_setting_pw.py

@@ -4,7 +4,7 @@ async def user_setting_pw():
     with get_db_connect() as conn:
         curs = conn.cursor()
 
-        if ban_check()[0] == 1:
+        if (await ban_check())[0] == 1:
             return await re_error(conn, 0)
 
         ip = ip_check()

+ 1 - 1
route/user_setting_skin_set_main.py

@@ -107,7 +107,7 @@ async def user_setting_skin_set_main():
         curs = conn.cursor()
 
         ip = ip_check()
-        if ban_check(ip)[0] == 1:
+        if (await ban_check(ip))[0] == 1:
             return await re_error(conn, 0)
             
         set_list = user_setting_skin_set_main_set_list(conn)

+ 1 - 1
route/user_setting_top_menu.py

@@ -5,7 +5,7 @@ async def user_setting_top_menu():
         curs = conn.cursor()
 
         ip = ip_check()
-        if ban_check(ip)[0] == 1:
+        if (await ban_check(ip))[0] == 1:
             return await re_error(conn, 0)
 
         if ip_or_user(ip) == 1:

+ 1 - 1
route/user_setting_user_name.py

@@ -1,6 +1,6 @@
 from .tool.func import *
 
-def user_setting_user_name(user_name = ''):
+async def user_setting_user_name(user_name = ''):
     with get_db_connect() as conn:
         curs = conn.cursor()
 

+ 0 - 1
route/view_w.py

@@ -181,7 +181,6 @@ async def view_w(name = 'Test', do_type = ''):
             name_view = name
 
         doc_data = await api_w_raw(name)
-        print(doc_data)
         if doc_data["response"] == "ok":
             render_data = await api_w_render(name, request_method = 'POST', request_data = {
                 'name' : name,

+ 1 - 1
route/vote_end.py

@@ -35,7 +35,7 @@ async def vote_end(num = 1):
             curs.execute(db_change('select user from vote where id = ? and user != "" and data = ?'), [num, str(i)])
             data_list_2 = curs.fetchall()
             if data_list[0][3] == 'open' or data_list[0][3] == 'close':
-                all_ip = ip_pas([j[0] for j in data_list_2])
+                all_ip = await ip_pas([j[0] for j in data_list_2])
                 for j in data_list_2:
                     data += '<li>' + all_ip[j[0]] + '</li>'