Kaynağa Gözat

Merge pull request #1825 from openNAMU/dev

버그 수정, 일부 수정
잉여개발기 (SPDV) 2 yıl önce
ebeveyn
işleme
76511cae67

+ 3 - 0
app.py

@@ -582,6 +582,9 @@ app.route('/api/w/<everything:name>/doc_tool/<tool>', methods = ['POST', 'GET'])
 app.route('/api/w/<everything:name>', methods = ['GET', 'POST'])(api_w)
 app.route('/api/raw/<everything:name>')(api_raw)
 
+app.route('/api/bbs/w/<sub_code>')(api_bbs_w_post)
+app.route('/api/bbs/w/comment/<sub_code>')(api_bbs_w_comment)
+
 app.route('/api/version', defaults = { 'version_list' : version_list })(api_version)
 app.route('/api/skin_info')(api_skin_info)
 app.route('/api/skin_info/<name>')(api_skin_info)

+ 1 - 1
emergency_tool.py

@@ -25,7 +25,7 @@ if data_db_load == 'Y':
     curs = conn.cursor()
 else:
     print('----')
-    print('You can use [9, 11]')
+    print('You can use [9, 11, 19]')
 
 # Main
 print('----')

+ 1 - 0
lang/en-US.json

@@ -577,6 +577,7 @@
             "error_title_length_too_long" : "Documents title or Discussion topic length is too long. Maximum number of characters : ",
             "error_password_length_too_short" : "Password length is too short. Minimum number of characters : ",
             "error_password_require_for_wiki_access" : "A password is required to access the wiki.",
+            "timeout_error" : "Running is taking too long. Maximum running time (Second(s)) : ",
         "_comment_3.2_" : "Warning",
             "http_warning" : "Warning: If you are not on HTTPS connection, your information can be leaked. The users themselves have responsibility to any problems that happen because of this.",
             "user_head_warning" : "User data will be deleted if you close the browser or when you sign in.",

+ 4 - 3
lang/ko-KR.json

@@ -84,7 +84,7 @@
     "file_name_error": "파일명에는 알파벳, 한글, 공백, 밑줄 및 빼기 기호만 사용할 수 있습니다.",
     "pass": "넘기기",
     "recaptcha_error": "'로봇이 아닙니다'를 통해 reCAPTCHA를 통과하세요.",
-    "file_capacity_error": "최대 파일 크기 (MB): ",
+    "file_capacity_error": "최대 파일 크기 (MB) : ",
     "setting": "설정",
     "end": "끝",
     "error": "오류",
@@ -307,7 +307,7 @@
     "requires_approval": "가입시 승인 필요",
     "approval_question": "회원가입 질문",
     "public_key": "공개 키",
-    "fast_edit_error": "편집 속도가 너무 빠릅니다. 제한 (초): ",
+    "fast_edit_error": "편집 속도가 너무 빠릅니다. 제한 (초) : ",
     "main_acl_setting": "기본 ACL 설정",
     "edit_req_acl": "편집 요청 ACL",
     "application_list": "가입신청 목록",
@@ -547,5 +547,6 @@
     "link_case_insensitive": "링크 대소문자 구분 안함",
     "hide_user_name" : "가입자 이름 숨기기",
     "comment" : "댓글",
-    "reply" : "대댓글"
+    "reply" : "대댓글",
+    "timeout_error" : "실행 시간이 너무 오래 걸립니다. 최대 실행 시간 (초) : "
 }

BIN
main_easter_egg


+ 2 - 0
route/__init__.py

@@ -12,6 +12,8 @@ from route.api_topic import api_topic
 from route.api_user_info import api_user_info
 from route.api_version import api_version
 from route.api_w import api_w
+from route.api_bbs_w_post import api_bbs_w_post
+from route.api_bbs_w_comment import api_bbs_w_comment
 
 from route.bbs_edit import bbs_edit
 from route.bbs_main import bbs_main

+ 31 - 0
route/api_bbs_w_comment.py

@@ -0,0 +1,31 @@
+from .tool.func import *
+
+def api_bbs_w_comment(sub_code : str = '') -> flask.Response:
+    conn : typing.Union[sqlite3.Connection, pymysql.connections.Connection]
+    with get_db_connect() as conn:
+        curs : typing.Union[sqlite3.Cursor, pymysql.cursors.Cursor] = conn.cursor()
+
+        curs.execute(db_change('select set_name, set_data, set_code, set_id from bbs_data where (set_name = "comment" or set_name = "comment_date" or set_name = "comment_user_id") and set_id = ? order by set_code + 0 asc'), [sub_code])
+        db_data : typing.Optional[list[tuple[str, str, str]]] = curs.fetchall()
+        if not db_data:
+            return flask.jsonify({})
+        else:
+            temp_id : str = ''
+            temp_dict : dict[str, str] = {}
+            temp_list : list[dict[str, str]] = []
+
+            for_a : tuple[str, str, str]
+            for for_a in db_data:
+                if temp_id != for_a[2]:
+                    if temp_dict != {}:
+                        temp_list += [dict(temp_dict)]
+
+                    temp_id = for_a[2]
+                    temp_dict['code'] = for_a[2]
+
+                temp_dict[for_a[0]] = for_a[1]
+
+            if temp_dict != {}:
+                temp_list += [dict(temp_dict)]
+
+            return flask.jsonify(temp_list)

+ 28 - 0
route/api_bbs_w_post.py

@@ -0,0 +1,28 @@
+from .tool.func import *
+
+def api_bbs_w_post(sub_code : str = '') -> flask.Response:
+    sub_code_split : list[str] = sub_code.split('-')
+    if len(sub_code_split) < 2:
+        sub_code_split = ['', '']
+
+    conn : typing.Union[sqlite3.Connection, pymysql.connections.Connection]
+    with get_db_connect() as conn:
+        curs : typing.Union[sqlite3.Cursor, pymysql.cursors.Cursor] = conn.cursor()
+
+        curs.execute(db_change('select set_name, set_data, set_code from bbs_data where set_id = ? and set_code = ?'), [sub_code_split[0], sub_code_split[1]])
+        db_data : typing.Optional[list[tuple[str, str, str]]] = curs.fetchall()
+        if not db_data:
+            return flask.jsonify({})
+        else:
+            temp_id : str = ''
+            temp_dict : dict[str, str] = {}
+
+            for_a : tuple[str, str, str]
+            for for_a in db_data:
+                if temp_id != for_a[2]:
+                    temp_id = for_a[2]
+                    temp_dict['code'] = for_a[2]
+
+                temp_dict[for_a[0]] = for_a[1]
+
+            return flask.jsonify(temp_dict)

+ 1 - 0
route/bbs_main.py

@@ -26,6 +26,7 @@ def bbs_main():
                 last_date = ('(' + db_data_2[0][0] + ')') if db_data_2 else ''
 
                 data += '<li><a href="/bbs/w/' + for_a[1] + '">' + for_a[0] + ' (' + bbs_type + ') ' + last_date + '</a></li>'
+                data += '<li></li>'
 
             data += '</ul>'
 

+ 148 - 155
route/bbs_w_post.py

@@ -1,6 +1,9 @@
 from .tool.func import *
 
-def bbs_w_post_make_thread(user_id, date, data, code, color = '', blind = '', add_style = ''):
+from .api_bbs_w_post import api_bbs_w_post
+from .api_bbs_w_comment import api_bbs_w_comment
+
+def bbs_w_post_make_thread(user_id : str, date : str, data : str, code : str, color : str = '', blind : str = '', add_style : str = '') -> str:
     if blind != '':
         if data == '':
             color_b = 'opennamu_comment_blind'
@@ -26,29 +29,92 @@ def bbs_w_post_make_thread(user_id, date, data, code, color = '', blind = '', ad
         </table>
     '''
 
-def bbs_w_post(bbs_num = '', post_num = '', do_type = ''):
+def bbs_w_post_comment(user_id : str, sub_code : str, comment_num : str, bbs_num_str : str, post_num_str : str) -> tuple[str, str, int, int]:
+    comment_data : str = ''
+    comment_select : str = ''
+
+    comment_count : int = 0
+    comment_add_count : int = 0
+
+    thread_data : list[dict[str, str]] = json.loads(api_bbs_w_comment(sub_code).data)
+    
+    comment_count += len(thread_data)
+    comment_add_count += comment_count
+
+    temp_dict : dict[str, str]
+    for temp_dict in thread_data:
+        color : str = 'default'
+        if user_id == temp_dict['comment_user_id']:
+            color = 'green'
+
+        sub_code_check : str = re.sub(r'^[0-9]+-[0-9]+-', '', sub_code + '-' + temp_dict['code'])
+        margin_count : int = sub_code_check.count('-')
+
+        date : str = '<a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '/comment/' + sub_code_check + '/tool">(' + load_lang('tool') + ')</a> ' + temp_dict['comment_date']
+
+        comment_data += '<span style="padding-left: 20px;"></span>' * margin_count
+        comment_data += bbs_w_post_make_thread(
+            ip_pas(temp_dict['comment_user_id']),
+            date,
+            render_set(
+                doc_name = '', 
+                doc_data = temp_dict['comment'],
+                data_in = 'from'
+            ),
+            sub_code_check,
+            color = color,
+            add_style = 'width: calc(100% - ' + str(margin_count * 20) + 'px);'
+        )
+
+        comment_default : str = ''
+        if comment_num == sub_code_check:
+            comment_default = 'selected'
+
+        comment_select += '<option value="' + sub_code_check + '" ' + comment_default + '>' + sub_code_check + '</option>'
+        comment_data += '<hr class="main_hr">'
+
+        temp_data : tuple[str, str, int, int] = bbs_w_post_comment(user_id, sub_code + '-' + temp_dict['code'], comment_num, bbs_num_str, post_num_str)
+
+        comment_data += temp_data[0]
+        comment_select += temp_data[1]
+        comment_add_count += temp_data[3]
+
+    return (comment_data, comment_select, comment_count, comment_add_count)
+
+def bbs_w_post(bbs_num : typing.Union[int, str] = '', post_num : typing.Union[int, str] = '', do_type : str = '') -> flask.Response:
+    conn : typing.Union[sqlite3.Connection, pymysql.connections.Connection]
     with get_db_connect() as conn:
-        curs = conn.cursor()
+        curs : typing.Union[sqlite3.Cursor, pymysql.cursors.Cursor] = conn.cursor()
 
         curs.execute(db_change('select set_data from bbs_set where set_id = ? and set_name = "bbs_name"'), [bbs_num])
-        db_data = curs.fetchall()
-        if not db_data:
+        db_data_3 : typing.Optional[list[tuple[str]]] = curs.fetchall()
+        if not db_data_3:
             return redirect('/bbs/main')
         
-        bbs_name = db_data[0][0]
+        bbs_name : str = db_data_3[0][0]
 
         curs.execute(db_change('select set_name, set_data, set_code from bbs_data where set_id = ? and set_code = ?'), [bbs_num, post_num])
-        db_data = curs.fetchall()
+        db_data : typing.Optional[list[tuple[str, str, str]]] = curs.fetchall()
         if not db_data:
             return redirect('/bbs/main')
 
-        bbs_num_str = str(bbs_num)
-        post_num_str = str(post_num)
-        bbs_comment_acl = acl_check(bbs_num_str, 'bbs_comment')
-        ip = ip_check()
+        bbs_num_str : str = str(bbs_num)
+        post_num_str : str = str(post_num)
+        bbs_comment_acl : int = acl_check(bbs_num_str, 'bbs_comment')
+        ip : str = ip_check()
+
+        set_id : str
+        text : str
+        data_preview : str
+        user_id : str
+        bbs_comment_form : str
+        id_data : str
+        data : str
+        date : str
+        temp_dict : dict[str, str]
         
         curs.execute(db_change('select set_data from bbs_set where set_id = ? and set_name = "bbs_type"'), [bbs_num])
-        db_data_2 = curs.fetchall()
+        db_data_2 : typing.Optional[list[tuple[str]]] = curs.fetchall()
         if not db_data_2:
             return redirect('/bbs/main')
         elif db_data_2[0][0] == 'thread':
@@ -64,8 +130,8 @@ def bbs_w_post(bbs_num = '', post_num = '', do_type = ''):
                 set_id = bbs_num_str + '-' + post_num_str
 
                 curs.execute(db_change('select set_code from bbs_data where set_name = "comment" and set_id = ? order by set_code + 0 desc'), [set_id])
-                db_data = curs.fetchall()
-                id_data = str(int(db_data[0][0]) + 1) if db_data else '1'
+                db_data_4 : typing.Optional[list[tuple[str]]] = curs.fetchall()
+                id_data = str(int(db_data_4[0][0]) + 1) if db_data_4 else '1'
 
                 data = flask.request.form.get('content', '')
                 if data == '':
@@ -80,11 +146,13 @@ def bbs_w_post(bbs_num = '', post_num = '', do_type = ''):
 
                 conn.commit()
 
-                return redirect('/bbs/w/' + bbs_num_str + '/' + post_num_str + '#comment_' + str(int(id_data) + 1))
+                return redirect('/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + str(int(id_data) + 1))
             else:
                 if acl_check(bbs_num_str, 'bbs_view') == 1:
                     return re_error('/ban')
 
+                text = ''
+                data_preview = ''
                 if do_type == 'preview':
                     text = flask.request.form.get('content', '')
                     text = text.replace('\r', '')
@@ -94,28 +162,16 @@ def bbs_w_post(bbs_num = '', post_num = '', do_type = ''):
                         doc_data = text,
                         data_in = 'from'
                     )
-                else:
-                    text = ''
-                    data_preview = ''
                 
-                temp_id = ''
-                temp_dict = {}
-
-                db_data = list(db_data) if db_data else []
-                for for_a in db_data + [['', '', '']]:
-                    if temp_id != for_a[2]:
-                        temp_id = for_a[2]
-                        temp_dict['code'] = for_a[2]
-
-                    temp_dict[for_a[0]] = for_a[1]
+                temp_dict = json.loads(api_bbs_w_post(bbs_num_str + '-' + post_num_str).data)
 
-                count = 1
+                date = '<a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '/tool">(' + load_lang('tool') + ')</a> ' + temp_dict['date']
 
                 data = ''
                 data += '<h2>' + html.escape(temp_dict['title']) + '</h2>'
                 data += bbs_w_post_make_thread(
                     ip_pas(temp_dict['user_id']),
-                    temp_dict['date'],
+                    date,
                     render_set(
                         doc_name = '', 
                         doc_data = temp_dict['data'],
@@ -127,46 +183,34 @@ def bbs_w_post(bbs_num = '', post_num = '', do_type = ''):
                 data += '<hr class="main_hr">'
 
                 user_id = temp_dict['user_id']
+                count : int = 1
 
-                temp_id = ''
-                temp_dict = {}
-
-                curs.execute(db_change('select set_name, set_data, set_code, set_id from bbs_data where (set_name = "comment" or set_name = "comment_date" or set_name = "comment_user_id") and set_id = ? order by set_code + 0 asc'), [bbs_num_str + '-' + post_num_str])
-                db_data = curs.fetchall()
-                db_data = list(db_data) if db_data else []
-
-                for for_a in db_data + [['', '', '']]:
-                    if temp_id == '':
-                        temp_id = for_a[2]
-
-                    if temp_id != for_a[2]:
-                        temp_id = for_a[2]
-                        temp_dict['code'] = for_a[2]
-                        count += 1
-
-                        if user_id == temp_dict['comment_user_id']:
-                            color = 'green'
-                        else:
-                            color = 'default'
-
-                        data += bbs_w_post_make_thread(
-                            ip_pas(temp_dict['comment_user_id']),
-                            temp_dict['comment_date'],
-                            render_set(
-                                doc_name = '', 
-                                doc_data = temp_dict['comment'],
-                                data_in = 'from'
-                            ),
-                            str(count),
-                            color = color
-                        )
-                        data += '<hr class="main_hr">'
-
-                    temp_dict[for_a[0]] = for_a[1]
+                thread_data : list[dict[str, str]] = json.loads(api_bbs_w_comment(bbs_num_str + '-' + post_num_str).data)
+                for temp_dict in thread_data:
+                    count += 1
+                    if user_id == temp_dict['comment_user_id']:
+                        color = 'green'
+                    else:
+                        color = 'default'
+                        
+                    date = '<a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '/comment/' + str(count) + '/tool">(' + load_lang('tool') + ')</a> ' + temp_dict['comment_date']
+
+                    data += bbs_w_post_make_thread(
+                        ip_pas(temp_dict['comment_user_id']),
+                        date,
+                        render_set(
+                            doc_name = '', 
+                            doc_data = temp_dict['comment'],
+                            data_in = 'from'
+                        ),
+                        str(count),
+                        color = color
+                    )
+                    data += '<hr class="main_hr">'
 
                 bbs_comment_form = ''
                 if bbs_comment_acl == 0:
-                    bbs_comment_form = '''                        
+                    bbs_comment_form += '''                        
                         <textarea name="content" id="opennamu_edit_textarea" class="opennamu_textarea_100">''' + html.escape(text) + '''</textarea>
                         <hr class="main_hr">
                         
@@ -185,7 +229,7 @@ def bbs_w_post(bbs_num = '', post_num = '', do_type = ''):
                 '''
 
                 return easy_minify(flask.render_template(skin_check(),
-                    imp = [load_lang('bbs_main'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                    imp = [bbs_name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('bbs') + ')', 0])],
                     data = data,
                     menu = [['bbs/w/' + bbs_num_str, load_lang('return')], ['bbs/edit/' + bbs_num_str + '/' + post_num_str, load_lang('edit')]]
                 ))
@@ -200,28 +244,29 @@ def bbs_w_post(bbs_num = '', post_num = '', do_type = ''):
                 else:
                     captcha_post('', 0)
                 
-                select = flask.request.form.get('comment_select', 'default')
+                select : str = flask.request.form.get('comment_select', 'default')
                 select = '' if select == 'default' else select
                 if select != '':
-                    select = select.split('-')
-                    if len(select) < 2:
-                        curs.execute(db_change('select set_code from bbs_data where set_name = "comment" and set_id = ? and set_code = ? limit 1'), [bbs_num_str + '-' + post_num_str, select[0]])
+                    select_split : list[str] = select.split('-')
+                    if len(select_split) < 2:
+                        curs.execute(db_change('select set_code from bbs_data where set_name = "comment" and set_id = ? and set_code = ? limit 1'), [bbs_num_str + '-' + post_num_str, select_split[0]])
                         if not curs.fetchall():
-                            return ''
+                            # re_error로 변경 예정
+                            return redirect('/bbs/w/' + bbs_num_str + '/' + post_num_str)
                         else:
-                            set_id = bbs_num_str + '-' + post_num_str + '-' + select[0]
+                            set_id = bbs_num_str + '-' + post_num_str + '-' + select_split[0]
                     else:
-                        curs.execute(db_change('select set_code from bbs_data where set_name = "comment" and set_id = ? and set_code = ? limit 1'), [bbs_num_str + '-' + post_num_str + '-' + '-'.join(select[0:len(select) - 1]), select[len(select) - 1]])
+                        curs.execute(db_change('select set_code from bbs_data where set_name = "comment" and set_id = ? and set_code = ? limit 1'), [bbs_num_str + '-' + post_num_str + '-' + '-'.join(select_split[0:len(select) - 1]), select_split[len(select_split) - 1]])
                         if not curs.fetchall():
-                            return ''
+                            return redirect('/bbs/w/' + bbs_num_str + '/' + post_num_str)
                         else:
-                            set_id = bbs_num_str + '-' + post_num_str + '-' + '-'.join(select)
+                            set_id = bbs_num_str + '-' + post_num_str + '-' + '-'.join(select_split)
                 else:
                     set_id = bbs_num_str + '-' + post_num_str
 
                 curs.execute(db_change('select set_code from bbs_data where set_name = "comment" and set_id = ? order by set_code + 0 desc'), [set_id])
-                db_data = curs.fetchall()
-                id_data = str(int(db_data[0][0]) + 1) if db_data else '1'
+                db_data_5 : typing.Optional[list[tuple[str]]] = curs.fetchall()
+                id_data = str(int(db_data_5[0][0]) + 1) if db_data_5 else '1'
 
                 data = flask.request.form.get('content', '')
                 if data == '':
@@ -237,43 +282,38 @@ def bbs_w_post(bbs_num = '', post_num = '', do_type = ''):
                 conn.commit()
             
                 if set_id == '':
-                    return redirect('/bbs/w/' + bbs_num_str + '/' + post_num_str + '#comment_' + id_data)
+                    return redirect('/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + id_data)
                 else:
                     set_id = re.sub(r'^[0-9]+-[0-9]+-?', '', set_id)
-                    return redirect('/bbs/w/' + bbs_num_str + '/' + post_num_str + '#comment_' + set_id + '-' + id_data)
+                    return redirect('/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + set_id + '-' + id_data)
             else:
                 if acl_check(bbs_num_str, 'bbs_view') == 1:
                     return re_error('/ban')
                     
+                text = ''
+                comment_num : str = ''
+                data_preview = ''
                 if do_type == 'preview':
                     text = flask.request.form.get('content', '')
                     text = text.replace('\r', '')
 
+                    comment_num = flask.request.form.get('comment_select', '')
+
                     data_preview = render_set(
                         doc_name = '', 
                         doc_data = text,
                         data_in = 'from'
                     )
-                else:
-                    text = ''
-                    data_preview = ''
 
-                temp_id = ''
-                temp_dict = {}
+                temp_dict = json.loads(api_bbs_w_post(bbs_num_str + '-' + post_num_str).data)
 
-                db_data = list(db_data) if db_data else []
-                for for_a in db_data + [['', '', '']]:
-                    if temp_id != for_a[2]:
-                        temp_id = for_a[2]
-                        temp_dict['code'] = for_a[2]
-
-                    temp_dict[for_a[0]] = for_a[1]
+                date = '<a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '/tool">(' + load_lang('tool') + ')</a> ' + temp_dict['date']
 
                 data = ''
                 data += '<h2>' + html.escape(temp_dict['title']) + '</h2>'
                 data += bbs_w_post_make_thread(
                     ip_pas(temp_dict['user_id']),
-                    temp_dict['date'],
+                    date,
                     render_set(
                         doc_name = '', 
                         doc_data = temp_dict['data'],
@@ -284,71 +324,24 @@ def bbs_w_post(bbs_num = '', post_num = '', do_type = ''):
                 )
 
                 user_id = temp_dict['user_id']
-                temp_id = ''
-                temp_dict = {}
-                comment_data = ''
+                comment_data : str = ''
 
-                comment_select = '<hr class="main_hr"><select name="comment_select">'
+                comment_select : str = '<hr class="main_hr"><select name="comment_select">'
                 comment_select += '<option value="default">' + load_lang('normal') + '</option>'
 
-                curs.execute(db_change('select set_name, set_data, set_code, set_id from bbs_data where (set_name = "comment" or set_name = "comment_date" or set_name = "comment_user_id") and set_id = ? order by set_code + 0 asc'), [bbs_num_str + '-' + post_num_str])
-                db_data = curs.fetchall()
-                if db_data:
+                comment_count : int = 0
+                comment_add_count : int = 0
+
+                temp_data : tuple[str, str, int, int] = bbs_w_post_comment(user_id, bbs_num_str + '-' + post_num_str, comment_num, bbs_num_str, post_num_str)
+
+                comment_data += temp_data[0]
+                comment_select += temp_data[1]
+                comment_count += temp_data[2]
+                comment_add_count += temp_data[3]
+                comment_add_count -= comment_count
+
+                if comment_data != '':
                     data += '<hr class="main_hr"><hr>'
-                else:
-                    db_data = []
-
-                for_a = 0
-                db_data_2 = db_data + [['', '', '', '']]
-                db_data_len = len(db_data_2)
-                comment_count = 0
-                comment_add_count = 0
-                while(for_a < db_data_len):
-                    if temp_id != (db_data_2[for_a][3] + '-' + db_data_2[for_a][2]):
-                        if temp_id != '':
-                            temp_dict['code'] = temp_id
-                            temp_dict['code'] = re.sub(r'^[0-9]+-[0-9]+-', '', temp_dict['code'])
-
-                            if user_id == temp_dict['comment_user_id']:
-                                color = 'green'
-                            else:
-                                color = 'default'
-
-                            margin_count = temp_dict['code'].count('-')
-                            if margin_count == 0:
-                                comment_count += 1
-                            else:
-                                comment_add_count += 1
-
-                            comment_data += '<span style="padding-left: 20px;"></span>' * margin_count
-                            comment_data += bbs_w_post_make_thread(
-                                ip_pas(temp_dict['comment_user_id']),
-                                temp_dict['comment_date'],
-                                render_set(
-                                    doc_name = '', 
-                                    doc_data = temp_dict['comment'],
-                                    data_in = 'from'
-                                ),
-                                temp_dict['code'],
-                                color = color,
-                                add_style = 'width: calc(100% - ' + str(margin_count * 20) + 'px);'
-                            )
-
-                            comment_select += '<option value="' + temp_dict['code'] + '">' + temp_dict['code'] + '</option>'
-
-                            curs.execute(db_change('select set_name, set_data, set_code, set_id from bbs_data where (set_name = "comment" or set_name = "comment_date" or set_name = "comment_user_id") and set_id = ? order by set_code + 0 asc'), [bbs_num_str + '-' + post_num_str + '-' + temp_dict['code']])
-                            db_data = curs.fetchall()
-                            if db_data:
-                                db_data_2 = db_data_2[:for_a] + db_data + db_data_2[for_a:]
-                                db_data_len += len(db_data)
-
-                            if db_data_2[for_a][0] != '':
-                                comment_data += '<hr class="main_hr">'
-
-                        temp_id = db_data_2[for_a][3] + '-' + db_data_2[for_a][2]
-
-                    temp_dict[db_data_2[for_a][0]] = db_data_2[for_a][1]
-                    for_a += 1
 
                 comment_select += '</select>'
                 if comment_data != '':
@@ -358,7 +351,7 @@ def bbs_w_post(bbs_num = '', post_num = '', do_type = ''):
 
                 bbs_comment_form = ''
                 if bbs_comment_acl == 0:
-                    bbs_comment_form = '''
+                    bbs_comment_form += '''
                         ''' + comment_select + '''
                         <hr class="main_hr">
                         

+ 23 - 5
route/edit.py

@@ -1,5 +1,26 @@
 from .tool.func import *
 
+def edit_render_set(name, content):
+    render_set(
+        doc_name = name,
+        doc_data = content,
+        data_in = ''
+    )
+
+# https://stackoverflow.com/questions/13821156/timeout-function-using-threading-in-python-does-not-work
+def edit_timeout(func, args = (), timeout = 3):
+    pool = multiprocessing.Pool(processes = 1)
+    result = pool.apply_async(func, args = args)
+    try:
+        result.get(timeout = timeout)
+    except multiprocessing.TimeoutError:
+        pool.terminate()
+        return 1
+    else:
+        pool.close()
+        pool.join()
+        return 0
+
 def edit(name = 'Test', section = 0, do_type = ''):
     with get_db_connect() as conn:
         curs = conn.cursor()
@@ -74,11 +95,8 @@ def edit(name = 'Test', section = 0, do_type = ''):
             else:
                 leng = '+' + str(len(content))
 
-            render_set(
-                doc_name = name,
-                doc_data = content,
-                data_in = ''
-            )
+            if edit_timeout(edit_render_set, (name, content), timeout = 5) == 1:
+                return re_error('/error/41')
                 
             if db_data:
                 curs.execute(db_change("update data set data = ? where title = ?"), [content, name])

+ 8 - 7
route/edit_delete_file.py

@@ -1,26 +1,27 @@
 from .tool.func import *
+
 from .edit_delete import edit_delete
 
 # 처음으로 차세대 코드 방법론 적용
 # 앞으로 다 이렇게 작성할 예정
-def edit_delete_file(name : str = 'test.jpg') -> str:
+def edit_delete_file(name : str = 'test.jpg') -> flask.Response:
+    conn : typing.Union[sqlite3.Connection, pymysql.connections.Connection]
     with get_db_connect() as conn:
-        curs : typing.Union[sqlite3.dbapi2.Cursor, pymysql.cursors.Cursor, None] = conn.cursor()
+        curs : typing.Union[sqlite3.Cursor, pymysql.cursors.Cursor] = conn.cursor()
 
         ip : str = ip_check()
         if admin_check() == 0:
             return re_error('/ban')
 
-        mime_type : typing.Union[re.Match, None] = re.search(r'([^.]+)$', name)
+        mime_type : typing.Optional[re.Match] = re.search(r'([^.]+)$', name)
+        mime_type_str : str = 'jpg'
         if mime_type:
-            mime_type = mime_type.group(1).lower()
-        else:
-            mime_type = 'jpg'
+            mime_type_str = mime_type.group(1).lower()
 
         file_name : str = re.sub(r'\.([^.]+)$', '', name)
         file_name = re.sub(r'^file:', '', file_name)
 
-        file_all_name : str = sha224_replace(file_name) + '.' + mime_type
+        file_all_name : str = sha224_replace(file_name) + '.' + mime_type_str
         file_directory : str = os.path.join(load_image_url(), file_all_name)
 
         if not os.path.exists(file_directory):

+ 1 - 0
route/edit_delete_multiple.py

@@ -1,4 +1,5 @@
 from .tool.func import *
+
 from .edit_delete import edit_delete
 
 def edit_delete_multiple():

+ 7 - 4
route/tool/func.py

@@ -10,6 +10,7 @@ import logging
 import random
 import typing
 import ipaddress
+import multiprocessing
 
 import email.mime.text
 import email.utils
@@ -194,7 +195,7 @@ class get_db_connect:
     
 
 class class_check_json:
-    def do_check_set_json():
+    def do_check_set_json(self):
         if os.getenv('NAMU_DB') or os.getenv('NAMU_DB_TYPE'):
             set_data = {}
             set_data['db'] = os.getenv('NAMU_DB') if os.getenv('NAMU_DB') else 'data'
@@ -249,7 +250,7 @@ class class_check_json:
 
         return data_db_set
 
-    def do_check_mysql_json(data_db_set):
+    def do_check_mysql_json(self, data_db_set):
         if os.path.exists(os.path.join('data', 'mysql.json')):
             db_set_list = ['user', 'password', 'host', 'port']
             with open(os.path.join('data', 'mysql.json'), encoding = 'utf8') as file_data:
@@ -307,9 +308,9 @@ class class_check_json:
         self.data_db_set = {}
             
     def __new__(self):
-        self.data_db_set = self.do_check_set_json()
+        self.data_db_set = self.do_check_set_json(self)
         if self.data_db_set['type'] == 'mysql':
-            self.data_db_set = self.do_check_mysql_json(self.data_db_set)
+            self.data_db_set = self.do_check_mysql_json(self, self.data_db_set)
         
         return self.data_db_set
 
@@ -2637,6 +2638,8 @@ def re_error(data):
                 password_min_length = ''
                 
             data = load_lang('error_password_length_too_short') + password_min_length
+        elif num == 41:
+            data = load_lang('timeout_error') + '5'
         else:
             data = '???'
 

+ 1 - 0
route/tool/func_render.py

@@ -1,4 +1,5 @@
 from .func_tool import *
+
 from .func_render_namumark import class_do_render_namumark
 
 # 커스텀 마크 언젠간 다시 추가 예정

+ 1 - 1
route/tool/func_render_namumark.py

@@ -2020,10 +2020,10 @@ class class_do_render_namumark:
             self.do_render_list()
             self.do_render_macro()
             self.do_render_link()
-            self.do_redner_footnote()
             self.do_render_text()
             self.do_render_hr()
             self.do_render_heading()
+            self.do_redner_footnote()
             
         self.do_render_last()
 

+ 1 - 0
route/topic.py

@@ -1,4 +1,5 @@
 from .tool.func import *
+
 from .api_topic import api_topic
 
 def topic(topic_num = 0, do_type = '', doc_name = 'Test'):

+ 1 - 1
route_go/bin/main_easter_egg.amd64.bin

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.6-RC3-dev189",
+        "r_ver" : "v3.4.6-RC3-dev192",
         "c_ver" : "3500361",
         "s_ver" : "3500111"
     }