Kaynağa Gözat

Merge pull request #2 from 2du/master

import
hoparkgo9ma 7 yıl önce
ebeveyn
işleme
18c7f1df8e
5 değiştirilmiş dosya ile 382 ekleme ve 109 silme
  1. 285 97
      app.py
  2. 23 10
      func.py
  3. 3 1
      requirements.txt
  4. 1 1
      set_mark/namu.py
  5. 70 0
      views/neo_yousoro/js/main.js

+ 285 - 97
app.py

@@ -15,7 +15,7 @@ import random
 
 from func import *
 
-r_ver = 'v3.0.8-master-08'
+r_ver = 'v3.0.8-stable-99'
 c_ver = ''.join(re.findall('[0-9]', r_ver))
 
 print('version : ' + r_ver)
@@ -330,7 +330,7 @@ def alarm():
 @app.route('/<regex("inter_wiki|(?:edit|email|name)_filter"):tools>')
 def inter_wiki(tools = None):
     div = ''
-    admin = admin_check(None, None)
+    admin = admin_check()
 
     if tools == 'inter_wiki':
         del_link = 'del_inter_wiki'
@@ -353,6 +353,13 @@ def inter_wiki(tools = None):
                 '''
 
         curs.execute("select html from html_filter where kind = 'email'")
+    elif tools == 'name_filter':
+        del_link = 'del_name_filter'
+        plus_link = 'plus_name_filter'
+        title = load_lang('id') + ' ' + load_lang('filter') + ' ' + load_lang('list')
+        div = ''
+
+        curs.execute("select html from html_filter where kind = 'name'")
     else:
         del_link = 'del_edit_filter'
         plus_link = 'manager/9'
@@ -399,6 +406,8 @@ def del_inter(tools = None, name = None):
             curs.execute("delete from inter where title = ?", [name])
         elif tools == 'del_edit_filter':
             curs.execute("delete from filter where name = ?", [name])
+        elif tools == 'del_name_filter':
+            curs.execute("delete from html_filter where html = ? and kind = 'name'", [name])
         else:
             curs.execute("delete from html_filter where html = ? and kind = 'email'", [name])
         
@@ -430,14 +439,20 @@ def plus_inter(tools = None, name = None):
             else:
                 curs.execute("insert into filter (name, regex, sub) values (?, ?, ?)", [name, flask.request.form.get('content', 'test'), end])
         else:
-            curs.execute('insert into html_filter (html, kind) values (?, "email")', [flask.request.form.get('title', None)])
-            admin_check(None, 'email_filter edit')
+            if tools == 'plus_name_filter':
+                admin_check(None, 'name_filter edit')
+                type_d = 'name'
+            else:
+                admin_check(None, 'email_filter edit')
+                type_d = 'email'
+            
+            curs.execute('insert into html_filter (html, kind) values (?, ?)', [flask.request.form.get('title', 'test'), type_d])
         
         conn.commit()
     
         return redirect('/' + re.sub('^plus_', '', tools))
     else:
-        if admin_check(1, None) != 1:
+        if admin_check(1) != 1:
             stat = 'disabled'
         else:
             stat = ''
@@ -474,6 +489,9 @@ def plus_inter(tools = None, name = None):
                         <hr>
                         <input ''' + stat + ''' placeholder="''' + load_lang('regex') + '''" name="content" value="''' + html.escape(textarea) + '''" type="text">
                         '''
+        elif tools == 'plus_name_filter':
+            title = load_lang('id') + ' ' + load_lang('filter') + ' ' + load_lang('plus')
+            form_data = '<input placeholder="' + load_lang('id') + ' ' + load_lang('regex') + '" type="text" name="title">'
         else:
             title = 'email ' + load_lang('filter') + ' ' + load_lang('plus')
             form_data = '<input placeholder="email" type="text" name="title">'
@@ -493,11 +511,11 @@ def plus_inter(tools = None, name = None):
 @app.route('/setting')
 @app.route('/setting/<int:num>', methods=['POST', 'GET'])
 def setting(num = 0):
-    if num != 0 and admin_check(None, None) != 1:
+    if num != 0 and admin_check() != 1:
         return re_error('/ban')
 
     if num == 0:
-        li_list = [load_lang('main'), load_lang('text') + ' ' + load_lang('setting'), load_lang('main') + ' head', 'robots.txt', 'google']
+        li_list = [load_lang('main'), load_lang('text') + ' ' + load_lang('setting'), load_lang('main') + ' head', load_lang('main') + ' body', 'robots.txt', 'google']
         
         x = 0
         
@@ -721,21 +739,34 @@ def setting(num = 0):
                         ''',
                 menu = [['setting', load_lang('setting')]]
             ))
-    elif num == 3:
+    elif num == 3 or num == 4:
         if flask.request.method == 'POST':
-            curs.execute("select name from other where name = 'head'")
+            if num == 4:
+                info_d = 'body'
+                end_r = '4'
+            else:
+                info_d = 'head'
+                end_r = '3'
+            
+            curs.execute("select name from other where name = ?", [info_d])
             if curs.fetchall():
-                curs.execute("update other set data = ? where name = 'head'", [flask.request.form.get('content', None)])
+                curs.execute("update other set data = ? where name = ?", [flask.request.form.get('content', ''), info_d])
             else:
-                curs.execute("insert into other (name, data) values ('head', ?)", [flask.request.form.get('content', None)])
+                curs.execute("insert into other (name, data) values (?, ?)", [info_d, flask.request.form.get('content', '')])
             
             conn.commit()
 
             admin_check(None, 'edit_set')
 
-            return redirect('/setting/3')
+            return redirect('/setting/' + end_r)
         else:
-            curs.execute("select data from other where name = 'head'")
+            if num == 4:
+                curs.execute("select data from other where name = 'body'")
+                title = 'body'
+            else:
+                curs.execute("select data from other where name = 'head'")
+                title = 'head'
+                
             head = curs.fetchall()
             if head:
                 data = head[0][0]
@@ -743,7 +774,7 @@ def setting(num = 0):
                 data = ''
 
             return easy_minify(flask.render_template(skin_check(), 
-                imp = [load_lang('main') + ' head', wiki_set(), custom(), other2([0, 0])],
+                imp = [load_lang('main') + ' ' + title, wiki_set(), custom(), other2([0, 0])],
                 data =  '''
                         <form method="post">
                             <textarea rows="25" name="content">''' + html.escape(data) + '''</textarea>
@@ -753,7 +784,7 @@ def setting(num = 0):
                         ''',
                 menu = [['setting', load_lang('setting')]]
             ))
-    elif num == 4:
+    elif num == 5:
         if flask.request.method == 'POST':
             curs.execute("select name from other where name = 'robot'")
             if curs.fetchall():
@@ -798,7 +829,7 @@ def setting(num = 0):
                         ''',
                 menu = [['setting', load_lang('setting')]]
             ))
-    elif num == 5:
+    elif num == 6:
         i_list = ['recaptcha', 'sec_re', 'g_email', 'g_pass']
 
         if flask.request.method == 'POST':
@@ -914,9 +945,21 @@ def acl_list():
                 else:
                     acl += [load_lang('subscriber')]
 
-            div += '<tr><td><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a></td><td>' + acl[0] + '</td><td>' + acl[1] + '</td><td>' + acl[2] + '</td></tr>'
+            div +=  '''
+                    <tr>
+                        <td>
+                            <a href="/w/''' + url_pas(data[0]) + '">' + data[0] + '''</a>
+                        </td>
+                        <td>''' + acl[0] + '''</td>
+                        <td>''' + acl[1] + '''</td>
+                        <td>''' + acl[2] + '''</td>
+                    </tr>
+                    '''
         
-    div += '</tbody></table>'
+    div +=  '''
+                </tbody>
+            </table>
+            '''
     
     return easy_minify(flask.render_template(skin_check(), 
         imp = ['acl ' + load_lang('document') + ' ' + load_lang('list'), wiki_set(), custom(), other2([0, 0])],
@@ -979,18 +1022,21 @@ def admin_plus(name = None):
             elif go[0] == 'owner':
                 exist_list[7] = 'checked="checked"'
 
-        if admin_check(None, None) != 1:
+        if admin_check() != 1:
             state = 'disabled'
         else:
             state = ''
 
-        data += '<li><input type="checkbox" ' + state +  ' name="ban" ' + exist_list[0] + '> ' + load_lang('ban') + '</li>'
-        data += '<li><input type="checkbox" ' + state +  ' name="toron" ' + exist_list[2] + '> ' + load_lang('discussion') + '</li>'
-        data += '<li><input type="checkbox" ' + state +  ' name="check" ' + exist_list[3] + '> ' + load_lang('user') + ' ' + load_lang('check') + '</li>'
-        data += '<li><input type="checkbox" ' + state +  ' name="acl" ' + exist_list[4] + '> ' + load_lang('document') + ' acl</li>'
-        data += '<li><input type="checkbox" ' + state +  ' name="hidel" ' + exist_list[5] + '> ' + load_lang('history') + ' ' + load_lang('hide') + '</li>'
-        data += '<li><input type="checkbox" ' + state +  ' name="give" ' + exist_list[6] + '> ' + load_lang('authority') + '</li>'
-        data += '<li><input type="checkbox" ' + state +  ' name="owner" ' + exist_list[7] + '> ' + load_lang('owner') + '</li></ul>'
+        data += '''
+                    <li><input type="checkbox" ''' + state +  ' name="ban" ' + exist_list[0] + '> ' + load_lang('ban') + '''</li>
+                    <li><input type="checkbox" ''' + state +  ' name="toron" ' + exist_list[2] + '> ' + load_lang('discussion') + '''</li>
+                    <li><input type="checkbox" ''' + state +  ' name="check" ' + exist_list[3] + '> ' + load_lang('user') + ' ' + load_lang('check') + '''</li>
+                    <li><input type="checkbox" ''' + state +  ' name="acl" ' + exist_list[4] + '> ' + load_lang('document') + ''' acl</li>
+                    <li><input type="checkbox" ''' + state +  ' name="hidel" ' + exist_list[5] + '> ' + load_lang('history') + ' ' + load_lang('hide') + '''</li>
+                    <li><input type="checkbox" ''' + state +  ' name="give" ' + exist_list[6] + '> ' + load_lang('authority') + '''</li>
+                    <li><input type="checkbox" ''' + state +  ' name="owner" ' + exist_list[7] + '> ' + load_lang('owner') + '''</li>
+                </ul>
+                '''
 
         return easy_minify(flask.render_template(skin_check(), 
             imp = [load_lang('admin_group') + ' ' + load_lang('plus'), wiki_set(), custom(), other2([0, 0])],
@@ -1050,7 +1096,7 @@ def user_log():
         
     list_data = '<ul>'
 
-    admin_one = admin_check(1, None)
+    admin_one = admin_check(1)
     
     curs.execute("select id, date from user order by date desc limit ?, '50'", [str(sql_num)])
     user_list = curs.fetchall()
@@ -1079,7 +1125,13 @@ def user_log():
         else:
             count = 0
 
-        list_data += '</ul><hr><ul><li>all : ' + str(count) + '</li></ul>'
+        list_data +=    '''
+                        </ul>
+                        <hr>
+                        <ul>
+                            <li>all : ''' + str(count) + '''</li>
+                        </ul>
+                        '''
 
     list_data += next_fix('/user_log?num=', num, user_list)
 
@@ -1500,9 +1552,19 @@ def deep_search(name = None):
     
     curs.execute("select title from data where title = ?", [name])
     if curs.fetchall():
-        div = '<ul><li><a href="/w/' + url_pas(name) + '">' + name + '</a></li></ul><hr><ul>'
+        link_id = ''
     else:
-        div = '<ul><li><a id="not_thing" href="/w/' + url_pas(name) + '">' + name + '</a></li></ul><hr><ul>'
+        link_id = 'id="not_thing"'
+    
+    div =   '''
+            <ul>
+                <li>
+                    <a ''' + link_id + ' href="/w/' + url_pas(name) + '">' + name + '''</a>
+                </li>
+            </ul>
+            <hr>
+            <ul>
+            '''
 
     curs.execute("select distinct title, case when title like ? then '제목' else '내용' end from data where title like ? or data like ? order by case when title like ? then 1 else 2 end limit ?, '50'", ['%' + name + '%', '%' + name + '%', '%' + name + '%', '%' + name + '%', str(sql_num)])
     all_list = curs.fetchall()
@@ -1541,7 +1603,7 @@ def raw_view(name = None, sub_title = None, num = None):
     
     if not sub_title and num:
         curs.execute("select title from history where title = ? and id = ? and hide = 'O'", [name, str(num)])
-        if curs.fetchall() and admin_check(6, None) != 1:
+        if curs.fetchall() and admin_check(6) != 1:
             return re_error('/error/3')
         
         curs.execute("select data from history where title = ? and id = ?", [name, str(num)])
@@ -1579,7 +1641,7 @@ def revert(name = None):
     num = int(flask.request.args.get('num', 0))
 
     curs.execute("select title from history where title = ? and id = ? and hide = 'O'", [name, str(num)])
-    if curs.fetchall() and admin_check(6, None) != 1:
+    if curs.fetchall() and admin_check(6) != 1:
         return re_error('/error/3')
 
     if acl_check(name) == 1:
@@ -2060,9 +2122,13 @@ def manager(num = 1):
                     <ul>
                         <li><a href="/manager/8">''' + load_lang('admin_group') + ' ' + load_lang('create') + '''</a></li>
                         <li><a href="/setting">''' + load_lang('setting') + ' ' + load_lang('edit') + '''</a></li>
+                    </ul>
+                    <h3>''' + load_lang('filter') + '''</h3>
+                    <ul>
                         <li><a href="/inter_wiki">''' + load_lang('interwiki') + '''</a></li>
                         <li><a href="/html_filter">html ''' + load_lang('filter') + '''</a></li>
                         <li><a href="/email_filter">email ''' + load_lang('filter') + '''</a></li>
+                        <li><a href="/name_filter">''' + load_lang('id') + ' ' + load_lang('filter') + '''</a></li>
                     </ul>
                     <br>
                     <h2>''' + load_lang('server') + '''</h2>
@@ -2146,12 +2212,20 @@ def title_index():
 
         count_end += [count_end[0] - count_end[1]  - count_end[2]  - count_end[3]  - count_end[4]]
         
-        data += '</ul><hr><ul><li>all : ' + str(count_end[0]) + '</li></ul><hr><ul>'
-        data += '<li>' + load_lang('template') + ' : ' + str(count_end[1]) + '</li>'
-        data += '<li>' + load_lang('category') + ' : ' + str(count_end[2]) + '</li>'
-        data += '<li>' + load_lang('user') + ' : ' + str(count_end[3]) + '</li>'
-        data += '<li>' + load_lang('file') + ' : ' + str(count_end[4]) + '</li>'
-        data += '<li>other : ' + str(count_end[5]) + '</li>'
+        data += '''
+                </ul>
+                <hr>
+                <ul>
+                    <li>all : ''' + str(count_end[0]) + '''</li>
+                </ul>
+                <hr>
+                <ul>
+                    <li>''' + load_lang('template') + ' : ' + str(count_end[1]) + '''</li>
+                    <li>''' + load_lang('category') + ' : ' + str(count_end[2]) + '''</li>
+                    <li>''' + load_lang('user') + ' : ' + str(count_end[3]) + '''</li>
+                    <li>''' + load_lang('file') + ' : ' + str(count_end[4]) + '''</li>
+                    <li>other : ''' + str(count_end[5]) + '''</li>
+                '''
 
     data += '</ul>' + next_fix('/title_index?num=' + str(num) + '&page=', page, title_list, num)
     sub = ' (' + str(num) + ')'
@@ -2264,8 +2338,13 @@ def topic_admin(name = None, sub = None, num = None):
 
     ban = ''
 
-    if admin_check(3, None) == 1:
-        ban += '</ul><br><h2>' + load_lang('admin') + ' ' + load_lang('tool') + '</h2><ul>'
+    if admin_check(3) == 1:
+        ban +=  '''
+                </ul>
+                <br>
+                <h2>''' + load_lang('admin') + ' ' + load_lang('tool') + '''</h2>
+                <ul>
+                '''
         is_ban = '<li><a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/b/' + str(num) + '">'
 
         if data[0][0] == 'O':
@@ -2273,8 +2352,12 @@ def topic_admin(name = None, sub = None, num = None):
         else:
             is_ban += load_lang('hide')
         
-        is_ban += '</a></li>'
-        is_ban += '<li><a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/notice/' + str(num) + '">'
+        is_ban +=   '''
+                        </a>
+                    </li>
+                    <li>
+                        <a href="/topic/''' + url_pas(name) + '/sub/' + url_pas(sub) + '/notice/' + str(num) + '''">
+                    '''
 
         curs.execute("select id from topic where title = ? and sub = ? and id = ? and top = 'O'", [name, sub, str(num)])
         if curs.fetchall():
@@ -2293,14 +2376,25 @@ def topic_admin(name = None, sub = None, num = None):
         
         ban += '</a></li>' + is_ban
 
-    ban += '</ul><br><h2>' + load_lang('other') + ' ' + load_lang('tool') + '</h2><ul>'
-    ban += '<li><a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/raw/' + str(num) + '">raw</a></li>'
+    ban +=  '''
+            </ul>
+            <br>
+            <h2>''' + load_lang('other') + ' ' + load_lang('tool') + '''</h2>
+            <ul>
+                <li>
+                    <a href="/topic/''' + url_pas(name) + '/sub/' + url_pas(sub) + '/raw/' + str(num) + '''">raw</a>
+                </li>
+            '''
     ban = '<li>' + load_lang('time') + ' : ' + data[0][2] + '</li>' + ban
     
     if ip_or_user(data[0][1]) == 1:
         ban = '<li>' + load_lang('writer') + ' : ' + data[0][1] + ' <a href="/record/' + url_pas(data[0][1]) + '">(' + load_lang('record') + ')</a></li>' + ban
     else:
-        ban = '<li>' + load_lang('writer') + ' : <a href="/w/user:' + data[0][1] + '">' + data[0][1] + '</a> <a href="/record/' + url_pas(data[0][1]) + '">(' + load_lang('record') + ')</a></li>' + ban
+        ban =   '''
+                <li>
+                    ''' + load_lang('writer') + ' : <a href="/w/user:' + data[0][1] + '">' + data[0][1] + '</a> <a href="/record/' + url_pas(data[0][1]) + '">(' + load_lang('record') + ''')</a>
+                </li>
+                ''' + ban
 
     ban = '<h2>' + load_lang('state') + '</h2><ul>' + ban
 
@@ -2313,7 +2407,7 @@ def topic_admin(name = None, sub = None, num = None):
 @app.route('/topic/<everything:name>/sub/<sub>', methods=['POST', 'GET'])
 def topic(name = None, sub = None):
     ban = topic_check(name, sub)
-    admin = admin_check(3, None)
+    admin = admin_check(3)
     
     if flask.request.method == 'POST':
         if captcha_post(flask.request.form.get('g-recaptcha-response', '')) == 1:
@@ -2404,9 +2498,23 @@ def topic(name = None, sub = None):
             if topic_data_top:
                 who_plus += ' <span style="margin-right: 5px;">@' + topic_data_top[0][0] + ' </span>'
                                 
-            all_data += '<table id="toron"><tbody><tr><td id="toron_color_red">'
-            all_data += '<a href="#' + topic_data[1] + '">#' + topic_data[1] + '</a> ' + ip_pas(topic_data[3]) + who_plus + ' <span style="float: right;">' + topic_data[2] + '</span>'
-            all_data += '</td></tr><tr><td>' + render_set(data = topic_data[0]) + '</td></tr></tbody></table><br>'    
+            all_data += '''
+                        <table id="toron">
+                            <tbody>
+                                <tr>
+                                    <td id="toron_color_red">
+                                        <a href="#''' + topic_data[1] + '''">
+                                            #''' + topic_data[1] + '''
+                                        </a> ''' + ip_pas(topic_data[3]) + who_plus + ''' <span style="float: right;">''' + topic_data[2] + '''</span>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td>''' + render_set(data = topic_data[0]) + '''</td>
+                                </tr>
+                            </tbody>
+                        </table>
+                        <br>
+                        '''    
 
         for topic_data in topic:
             user_write = topic_data[0]
@@ -2436,7 +2544,7 @@ def topic(name = None, sub = None):
                 ip += ' <a href="javascript:void(0);" title="' + load_lang('admin') + '">★</a>'
 
             if admin == 1 or blind_data == '':
-                ip += ' <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/admin/' + str(number) + '">(' + load_lang('tool') + ')</a>'
+                ip += ' <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/admin/' + str(number) + '">(' + load_lang('discussion') + ' ' + load_lang('tool') + ')</a>'
 
             curs.execute("select end from ban where block = ?", [topic_data[3]])
             if curs.fetchall():
@@ -2484,7 +2592,10 @@ def topic(name = None, sub = None):
             if display == '':
                 data += ip_warring()
 
-            data += '<button type="submit">' + load_lang('send') + '</button></form>'
+            data += '''
+                        <button type="submit">''' + load_lang('send') + '''</button>
+                    </form>
+                    '''
 
         return easy_minify(flask.render_template(skin_check(), 
             imp = [name, wiki_set(), custom(), other2([' (' + load_lang('discussion') + ')', 0])],
@@ -2497,9 +2608,24 @@ def user_tool(name = None):
     data =  '''
             <h2>''' + load_lang('tool') + '''</h2>
             <ul>
-                <li><a href="/record/''' + url_pas(name) + '''">''' + load_lang('record') + '''</li>
+                <li><a href="/record/''' + url_pas(name) + '''">''' + load_lang('record') + '''</a></li>
             </ul>
             '''
+            
+    if admin_check(1) == 1:
+        curs.execute("select block from ban where block = ?", [name])
+        if curs.fetchall():
+            ban_name = load_lang('release')
+        else:
+            ban_name = load_lang('ban')
+    
+        data += '''
+                <h2>''' + load_lang('admin') + '''</h2>
+                <ul>
+                    <li><a href="/ban/''' + url_pas(name) + '''">''' + ban_name + '''</a></li>
+                    <li><a href="/check/''' + url_pas(name) + '''">''' + load_lang('check') + '''</a></li>
+                </ul>
+                '''
 
     return easy_minify(flask.render_template(skin_check(), 
         imp = [name, wiki_set(), custom(), other2([' (' + load_lang('tool') + ')', 0])],
@@ -2751,7 +2877,7 @@ def user_check(name = None):
     curs.execute("select acl from user where id = ? or id = ?", [name, flask.request.args.get('plus', '-')])
     user = curs.fetchall()
     if user and user[0][0] != 'user':
-        if admin_check(None, None) != 1:
+        if admin_check() != 1:
             return re_error('/error/4')
 
     if admin_check(4, 'check (' + name + ')') != 1:
@@ -2787,12 +2913,19 @@ def user_check(name = None):
     record = curs.fetchall()
     if record:
         if not flask.request.args.get('plus', None):
-            div = '<a href="/manager/14?plus=' + url_pas(name) + '">(' + load_lang('compare') + ')</a> <a href="/easy_check/' + url_pas(name) + '">(' + load_lang('easy') + ')</a><hr>'
+            div = '<a href="/manager/14?plus=' + url_pas(name) + '">(' + load_lang('compare') + ')</a><hr>'
         else:
             div = '<a href="/check/' + url_pas(name) + '">(' + name + ')</a> <a href="/check/' + url_pas(flask.request.args.get('plus', None)) + '">(' + flask.request.args.get('plus', None) + ')</a><hr>'
 
-        div += '<table id="main_table_set"><tbody><tr>'
-        div += '<td id="main_table_width">' + load_lang('name') + '</td><td id="main_table_width">ip</td><td id="main_table_width">' + load_lang('time') + '</td></tr>'
+        div +=  '''
+                <table id="main_table_set">
+                    <tbody>
+                        <tr>
+                            <td id="main_table_width">''' + load_lang('name') + '''</td>
+                            <td id="main_table_width">ip</td>
+                            <td id="main_table_width">''' + load_lang('time') + '''</td>
+                        </tr>
+                '''
         
         for data in record:
             if data[2]:
@@ -2800,10 +2933,21 @@ def user_check(name = None):
             else:
                 ua = '<br>'
 
-            div += '<tr><td>' + ip_pas(data[0]) + '</td><td>' + ip_pas(data[1]) + '</td><td>' + data[3] + '</td></tr>'
-            div += '<tr><td colspan="3">' + ua + '</td></tr>'
+            div +=  '''
+                    <tr>
+                        <td>''' + ip_pas(data[0]) + '''</td>
+                        <td>''' + ip_pas(data[1]) + '''</td>
+                        <td>''' + data[3] + '''</td>
+                    </tr>
+                    <tr>
+                        <td colspan="3">''' + ua + '''</td>
+                    </tr>
+                    '''
         
-        div += '</tbody></table>'
+        div +=  '''
+                    </tbody>
+                </table>
+                '''
     else:
         return re_error('/error/2')
         
@@ -2826,7 +2970,7 @@ def register():
     if custom()[2] != 0:
         return redirect('/user')
 
-    if not admin_check(None, None) == 1:
+    if not admin_check() == 1:
         curs.execute('select data from other where name = "reg"')
         set_d = curs.fetchall()
         if set_d and set_d[0][0] == 'on':
@@ -2843,6 +2987,13 @@ def register():
 
         if re.search('(?:[^A-Za-zㄱ-힣0-9 ])', flask.request.form.get('id', None)):
             return re_error('/error/8')
+            
+        curs.execute('select html from html_filter where kind = "name"')
+        set_d = curs.fetchall()
+        for i in set_d:
+            check_r = re.compile(i[0], re.I)
+            if check_r.search(flask.request.form.get('id', None)):
+                return re_error('/error/8')
 
         if len(flask.request.form.get('id', None)) > 32:
             return re_error('/error/7')
@@ -3074,7 +3225,7 @@ def user_ban(name = None):
             return re_error('/error/2')
 
         if user and user[0][0] != 'user':
-            if admin_check(None, None) != 1:
+            if admin_check() != 1:
                 return re_error('/error/4')
 
     if ban_check(ip = ip_check(), tool = 'login') == 1:
@@ -3093,7 +3244,7 @@ def user_ban(name = None):
 
         return redirect('/ban/' + url_pas(name))     
     else:
-        if admin_check(1, None) != 1:
+        if admin_check(1) != 1:
             return re_error('/error/3')
 
         curs.execute("select end, why from ban where block = ?", [name])
@@ -3125,12 +3276,23 @@ def user_ban(name = None):
             else:
                 plus = ''
 
-            data = '<input placeholder="' + load_lang('second') + '" name="second" type="text"><hr><input type="checkbox" name="limitless"> ' + load_lang('limitless') + '<hr>'
-            data += '<input placeholder="' + load_lang('why') + '" name="why" type="text"><hr>' + plus
+            data =  '''
+                    <input placeholder="''' + load_lang('second') + '''" name="second" type="text">
+                    <hr>
+                    <input type="checkbox" name="limitless"> ''' + load_lang('limitless') + '''
+                    <hr>
+                    <input placeholder="''' + load_lang('why') + '''" name="why" type="text">
+                    <hr>
+                    ''' + plus
 
         return easy_minify(flask.render_template(skin_check(), 
             imp = [name, wiki_set(), custom(), other2([' (' + now + ')', 0])],
-            data = '<form method="post">' + data + '<button type="submit">' + now + '</button></form>',
+            data =  '''
+                    <form method="post">
+                        ''' + data + '''
+                        <button type="submit">''' + now + '''</button>
+                    </form>
+                    ''',
             menu = [['manager', load_lang('admin')]]
         ))            
                 
@@ -3244,7 +3406,7 @@ def acl(name = None):
             
 @app.route('/admin/<name>', methods=['POST', 'GET'])
 def user_admin(name = None):
-    owner = admin_check(None, None)
+    owner = admin_check()
     
     curs.execute("select acl from user where id = ?", [name])
     user = curs.fetchall()
@@ -3277,7 +3439,7 @@ def user_admin(name = None):
         
         return redirect('/admin/' + url_pas(name))            
     else:
-        if admin_check(7, None) != 1:
+        if admin_check(7) != 1:
             return re_error('/error/3')            
 
         div = '<option value="X">X</option>'
@@ -3414,7 +3576,7 @@ def read_view(name = None):
 
     if num:
         curs.execute("select title from history where title = ? and id = ? and hide = 'O'", [name, str(num)])
-        if curs.fetchall() and admin_check(6, None) != 1:
+        if curs.fetchall() and admin_check(6) != 1:
             return redirect('/history/' + url_pas(name))
 
         curs.execute("select title, data from history where title = ? and id = ?", [name, str(num)])
@@ -3449,7 +3611,7 @@ def read_view(name = None):
     if data:
         acl += ' (acl)'
             
-    if flask.request.args.get('from', None):
+    if flask.request.args.get('from', None) and else_data:
         else_data = re.sub('^\r\n', '', else_data)
         else_data = re.sub('\r\n$', '', else_data)
             
@@ -3496,6 +3658,11 @@ def read_view(name = None):
             r_date = 0
 
     div = end_data + div
+            
+    curs.execute("select data from other where name = 'body'")
+    body = curs.fetchall()
+    if body:
+        div = body[0][0] + '<hr>' + div
 
     return easy_minify(flask.render_template(skin_check(), 
         imp = [flask.request.args.get('show', name), wiki_set(), custom(), other2([sub + acl, r_date])],
@@ -3511,7 +3678,7 @@ def user_topic_list(name = None):
     else:
         sql_num = 0
     
-    one_admin = admin_check(1, None)
+    one_admin = admin_check(1)
 
     div =   '''
             <table id="main_table_set">
@@ -3563,15 +3730,19 @@ def recent_changes(name = None, tool = 'record'):
     if flask.request.method == 'POST':
         return redirect('/diff/' + url_pas(name) + '?first=' + flask.request.form.get('b', None) + '&second=' + flask.request.form.get('a', None))
     else:
-        one_admin = admin_check(1, None)
-        six_admin = admin_check(6, None)
+        one_admin = admin_check(1)
+        six_admin = admin_check(6)
         
         ban = ''
         select = ''
 
         what = flask.request.args.get('what', 'all')
 
-        div = '<table id="main_table_set"><tbody><tr>'
+        div =   '''
+                <table id="main_table_set">
+                    <tbody>
+                        <tr>
+                '''
         
         if name:
             num = int(flask.request.args.get('num', 1))
@@ -3589,13 +3760,15 @@ def recent_changes(name = None, tool = 'record'):
                 
                 curs.execute("select id, title, date, ip, send, leng from history where title = ? order by id + 0 desc limit ?, '50'", [name, str(sql_num)])
             else:
-                div += '<td id="main_table_width">' + load_lang('document') + ' ' + load_lang('name') + '</td><td id="main_table_width">' + load_lang('editor') + '</td><td id="main_table_width">' + load_lang('time') + '</td></tr>'
+                div +=  '''
+                            <td id="main_table_width">''' + load_lang('document') + ' ' + load_lang('name') + '''</td>
+                            <td id="main_table_width">''' + load_lang('editor') + '''</td>
+                            <td id="main_table_width">''' + load_lang('time') + '''</td>
+                        </tr>
+                        '''
 
                 if what == 'all':
-                    div = '<a href="/record/' + url_pas(name) + '?what=revert">(' + load_lang('revert') + ')</a><hr>' + div
-                    div = '<a href="/record/' + url_pas(name) + '?what=move">(' + load_lang('move') + ')</a> ' + div
-                    div = '<a href="/record/' + url_pas(name) + '?what=delete">(' + load_lang('delete') + ')</a> ' + div
-                    div = '<a href="/topic_record/' + url_pas(name) + '">(' + load_lang('discussion') + ')</a> ' + div
+                    div = '<a href="/topic_record/' + url_pas(name) + '">(' + load_lang('discussion') + ')</a> <a href="/record/' + url_pas(name) + '?what=delete">(' + load_lang('delete') + ')</a> <a href="/record/' + url_pas(name) + '?what=move">(' + load_lang('move') + ')</a> <a href="/record/' + url_pas(name) + '?what=revert">(' + load_lang('revert') + ')</a><hr>' + div
                     
                     curs.execute("select id, title, date, ip, send, leng from history where ip = ? order by date desc limit ?, '50'", [name, str(sql_num)])
                 else:
@@ -3616,12 +3789,15 @@ def recent_changes(name = None, tool = 'record'):
             else:
                 sql_num = 0            
             
-            div += '<td id="main_table_width">' + load_lang('document') + ' ' + load_lang('name') + '</td><td id="main_table_width">' + load_lang('editor') + '</td><td id="main_table_width">' + load_lang('time') + '</td></tr>'
+            div +=  '''
+                        <td id="main_table_width">''' + load_lang('document') + ' ' + load_lang('name') + '''</td>
+                        <td id="main_table_width">''' + load_lang('editor') + '''</td>
+                        <td id="main_table_width">''' + load_lang('time') + '''</td>
+                    </tr>
+                    '''
             
             if what == 'all':
-                div = '<a href="/recent_changes?what=revert">(' + load_lang('revert') + ')</a><hr>' + div
-                div = '<a href="/recent_changes?what=move">(' + load_lang('move') + ')</a> ' + div
-                div = '<a href="/recent_changes?what=delete">(' + load_lang('delete') + ')</a> ' + div
+                div = '<a href="/recent_changes?what=delete">(' + load_lang('delete') + ')</a> <a href="/recent_changes?what=move">(' + load_lang('move') + ')</a> <a href="/recent_changes?what=revert">(' + load_lang('revert') + ')</a><hr>' + div
 
                 div = '<a href="/recent_discuss">(' + load_lang('discussion') + ')</a> <a href="/block_log">(' + load_lang('ban') + ')</a> <a href="/user_log">(' + load_lang('subscriber') + ')</a> <a href="/admin_log">(' + load_lang('authority') + ')</a><hr>' + div
                 
@@ -3654,13 +3830,6 @@ def recent_changes(name = None, tool = 'record'):
             else:
                 leng = '<span style="color:gray;">(' + data[5] + ')</span>'
                 
-            if one_admin == 1:
-                curs.execute("select block from ban where block = ?", [data[3]])
-                if curs.fetchall():
-                    ban = ' <a href="/ban/' + url_pas(data[3]) + '">(' + load_lang('release') + ')</a>'
-                else:
-                    ban = ' <a href="/ban/' + url_pas(data[3]) + '">(' + load_lang('ban') + ')</a>'            
-                
             ip = ip_pas(data[3])
             if int(data[0]) - 1 == 0:
                 revert = ''
@@ -3704,20 +3873,39 @@ def recent_changes(name = None, tool = 'record'):
             else:
                 title = '<a href="/w/' + url_pas(data[1]) + '">' + html.escape(data[1]) + '</a> <a href="/history/' + url_pas(data[1]) + '">(' + data[0] + load_lang('version') + ')</a> '
                     
-            div += '<tr ' + style[0] + '><td>' + title + revert + ' ' + leng + '</td>'
-            div += '<td>' + ip + ban + hidden + '</td><td>' + date + '</td></tr><tr ' + style[1] + '><td colspan="3">' + send_parser(send) + '</td></tr>'
+            div +=  '''
+                    <tr ''' + style[0] + '''>
+                        <td>''' + title + revert + ' ' + leng + '''</td>
+                        <td>''' + ip + ban + hidden + '''</td>
+                        <td>''' + date + '''</td>
+                    </tr>
+                    <tr ''' + style[1] + '''>
+                        <td colspan="3">''' + send_parser(send) + '''</td>
+                    </tr>
+                    '''
 
-        div += '</tbody></table>'
+        div +=  '''
+                    </tbody>
+                </table>
+                '''
         sub = ''
 
         if name:
             if tool == 'history':
-                div = '<form method="post"><select name="a">' + select + '</select> <select name="b">' + select + '</select> <button type="submit">' + load_lang('compare') + '</button></form><hr>' + div
+                div =   '''
+                        <form method="post">
+                            <select name="a">''' + select + '''</select> <select name="b">''' + select + '''</select>
+                            <button type="submit">''' + load_lang('compare') + '''</button>
+                        </form>
+                        <hr>
+                        <a href="/move_data/''' + url_pas(name) + '''">(''' + load_lang('move') + ''')</a>
+                        <hr>
+                        ''' + div
                 title = name
                 
                 sub += ' (' + load_lang('history') + ')'
                 
-                menu = [['w/' + url_pas(name), load_lang('document')], ['raw/' + url_pas(name), 'raw'], ['move_data/' + url_pas(name), load_lang('move') + ' ' + load_lang('history')]]
+                menu = [['w/' + url_pas(name), load_lang('document')], ['raw/' + url_pas(name), 'raw']]
                 
                 div += next_fix('/history/' + url_pas(name) + '?num=', num, data_list)
             else:
@@ -4148,9 +4336,9 @@ def views(name = None):
         g = ['']
 
     if g == 'css':
-        return easy_minify(flask.send_from_directory('./views' + plus, rename))   
+        return easy_minify(flask.send_from_directory('./views' + plus, rename), 'css')   
     elif g == 'js':
-        return easy_minify(flask.send_from_directory('./views' + plus, rename))
+        return easy_minify(flask.send_from_directory('./views' + plus, rename), 'js')
     elif g == 'html':
         return easy_minify(flask.send_from_directory('./views' + plus, rename))   
     else:
@@ -4158,7 +4346,7 @@ def views(name = None):
 
 @app.route('/<data>')
 def main_file(data = None):
-    if re.search('\.(txt|html)$', data):
+    if re.search('\.txt$', data):
         return flask.send_from_directory('./', data)
     else:
         return redirect('/w/' + url_pas(wiki_set(2)))

+ 23 - 10
func.py

@@ -10,6 +10,10 @@ import html
 import sys
 import re
 import os
+try:
+    import css_html_js_minify
+except:
+    pass
 
 if sys.version_info < (3, 6):
     import sha3
@@ -51,9 +55,18 @@ def send_email(who, title, data):
     except:
         print('error : email login error')
 
-def easy_minify(data):
-    data = re.sub('\n +<', '\n<', data)
-    data = re.sub('>(\n| )+<', '> <', data)
+def easy_minify(data, tool = None):
+    try:
+        if not tool:
+            data = css_html_js_minify.html_minify(data)
+        else:
+            if tool == 'css':
+                data = css_html_js_minify.css_minify(data)
+            elif tool == 'js':
+                data = css_html_js_minify.js_minify(data)
+    except:
+        data = re.sub('\n +<', '\n<', data)
+        data = re.sub('>(\n| )+<', '> <', data)
     
     return data
 
@@ -426,7 +439,7 @@ def diff(seqm):
             
     return sub
            
-def admin_check(num, what):
+def admin_check(num = None, what = None):
     ip = ip_check() 
 
     curs.execute("select acl from user where id = ?", [ip])
@@ -462,6 +475,8 @@ def admin_check(num, what):
                     reset = 1
                 else:
                     break
+                    
+    return 0
 
 def ip_pas(raw_ip):
     hide = 0
@@ -750,10 +765,8 @@ def rd_plus(title, sub, date):
 def history_plus(title, data, date, ip, send, leng):
     curs.execute("select id from history where title = ? order by id + 0 desc limit 1", [title])
     id_data = curs.fetchall()
-    if id_data:
-        curs.execute("insert into history (id, title, data, date, ip, send, leng, hide) values (?, ?, ?, ?, ?, ?, ?, '')", [str(int(id_data[0][0]) + 1), title, data, date, ip, send, leng])
-    else:
-        curs.execute("insert into history (id, title, data, date, ip, send, leng, hide) values ('1', ?, ?, ?, ?, ?, ?, '')", [title, data, date, ip, send + ' (' + load_lang('new', 1) + ' ' + load_lang('document', 1) + ')', leng])
+    
+    curs.execute("insert into history (id, title, data, date, ip, send, leng, hide) values (?, ?, ?, ?, ?, ?, ?, '')", [str(int(id_data[0][0]) + 1) if id_data else '1', title, data, date, ip, send, leng])
 
 def leng_check(first, second):
     if first < second:
@@ -769,7 +782,7 @@ def edit_filter_do(data):
     if admin_check(1, 'edit_filter pass') != 1:
         curs.execute("select regex, sub from filter")
         for data_list in curs.fetchall():
-            match = re.compile(data_list[0])
+            match = re.compile(data_list[0], re.I)
             if match.search(data):
                 ban_insert(
                     ip_check(), 
@@ -849,7 +862,7 @@ def re_error(data):
             elif num == 7:
                 data = load_lang('long_id_error')
             elif num == 8:
-                data = load_lang('id_char_error')
+                data = load_lang('id_char_error') + ' <a href="/name_filter">(' + load_lang('id') + ' ' + load_lang('filter') + ')</a>'
             elif num == 9:
                 data = load_lang('file_exist_error')
             elif num == 10:

+ 3 - 1
requirements.txt

@@ -3,4 +3,6 @@ bcrypt
 flask
 flask-Reggie
 flask-compress
-pysha3; python_version < "3.6"
+pysha3; python_version < "3.6"
+css-html-js-minify==2.2.2; python_version < "3.6"
+css-html-js-minify; python_version >= "3.6"

+ 1 - 1
set_mark/namu.py

@@ -169,7 +169,7 @@ def middle_parser(data, fol_num, syntax_num, folding_num):
     middle_list = []
     middle_number = 0
 
-    middle_re = re.compile('(?:{{{((?:(?! |{{{|}}}|&lt;).)*) ?|(}}}))')
+    middle_re = re.compile('(?:{{{((?:(?:(?! |{{{|}}}|&lt;).)*) ?)|(}}}))')
     while 1:
         middle_data = middle_re.search(data)
         if middle_data:

+ 70 - 0
views/neo_yousoro/js/main.js

@@ -1,3 +1,37 @@
+// 쿠키 생성
+function setCookie(name, value, expiredays) {
+    var cookie = name + "=" + escape(value) + "; path=/;"
+    if (typeof expiredays != 'undefined') {
+        var todayDate = new Date();
+        todayDate.setDate(todayDate.getDate() + expiredays);
+        cookie += "expires=" + todayDate.toGMTString() + ";"
+    }
+    document.cookie = cookie;
+}
+ 
+// 쿠키 획득
+function getCookie(name) {
+    name += "=";
+    var cookie = document.cookie;
+    var startIdx = cookie.indexOf(name);
+    if (startIdx != -1) {
+        startIdx += name.length;
+        var endIdx = cookie.indexOf(";", startIdx);
+        if (endIdx == -1) {
+            endIdx = cookie.length;
+            return unescape(cookie.substring(startIdx, endIdx));
+        }
+    }
+    return null;
+}
+ 
+// 쿠키 삭제
+function deleteCookie(name) {
+    setCookie(name, "", -1);
+}
+
+// http://vip00112.tistory.com/33
+
 function opening(data) {
     var element = document.getElementById(data);
     if(element.style.display == 'none') {
@@ -5,4 +39,40 @@ function opening(data) {
     } else {
         element.style.display = 'none';
     }
+}
+
+function get_post() {
+    check = document.getElementById('strike');
+    if(check.checked == true) {
+        setCookie("set_strike", "1");
+    } else {
+        deleteCookie("set_strike");
+    }
+    
+    window.location.reload(true);
+}
+
+head_data = document.querySelector('head');
+if(getCookie("set_strike") == "1") {
+    head_data.innerHTML += '<style>s { display: none; }';
+}
+
+window.onload = function () {
+    if(window.location.pathname == '/skin_set') {
+        document.getElementById("main_top").innerHTML = '<h1>skin setting</h1>';
+        data = document.getElementById("main_data")
+        
+        set_data = {};
+        if(getCookie("set_strike") == "1") {
+            set_data["strike"] = "checked";
+        } 
+        
+        data.innerHTML =    `
+                            <input ` + set_data["strike"] + ` type="checkbox" id="strike" name="strike" value="strike"> remove strikethrough
+                            <hr>
+                            <button onclick="get_post();">Save</button>
+                            `;
+                            
+        document.title = document.title.replace(/.*(\- .*)$/, "skin setting $1");
+    }
 }