Procházet zdrojové kódy

Merge pull request #2061 from openNAMU/dev

버그 수정 및 이것저것 수정
잉여개발기 před 2 roky
rodič
revize
655acff767

+ 1 - 1
app.py

@@ -721,7 +721,7 @@ app.route('/search/<int:num>/<everything:name>', methods = ['POST', 'GET'])(main
 app.route('/search_data/<everything:name>', defaults = { 'search_type' : 'data' }, methods = ['POST', 'GET'])(main_search_deep)
 app.route('/search_data/<int:num>/<everything:name>', defaults = { 'search_type' : 'data' }, methods = ['POST', 'GET'])(main_search_deep)
 app.route('/goto', methods=['POST'])(main_search_goto)
-app.route('/goto/<everything:name>', methods=['POST'])(main_search_goto)
+app.route('/goto/<everything:name>', methods=['GET', 'POST'])(main_search_goto)
 
 app.route('/setting')(main_setting)
 app.route('/setting/main', defaults = { 'db_set' : data_db_set['type'] }, methods = ['POST', 'GET'])(main_setting_main)

+ 4 - 13
route/api_user_info.py

@@ -31,19 +31,10 @@ def api_user_info(user_name = ''):
         else:
             data_result['auth_date'] = '0'
 
-        curs.execute(db_change("select data from user_set where id = ? and name = 'level'"), [user_name])
-        db_data = curs.fetchall()
-        if db_data:
-            data_result['level'] = db_data[0][0]
-        else:
-            data_result['level'] = '0'
-
-        curs.execute(db_change("select data from user_set where id = ? and name = 'experience'"), [user_name])
-        db_data = curs.fetchall()
-        if db_data:
-            data_result['exp'] = db_data[0][0]
-        else:
-            data_result['exp'] = '0'
+        level_data = level_check(user_name)
+        data_result['level'] = level_data[0]
+        data_result['exp'] = level_data[1]
+        data_result['max_exp'] = level_data[2]
             
         # ban part
         if ban_check(user_name) == 0:

+ 1 - 1
route/api_w_raw.py

@@ -6,7 +6,7 @@ def api_w_raw(name = 'Test', rev = '', exist_check = ''):
 
         if exist_check != '':
             curs.execute(db_change("select title from data where title = ?"), [name])
-            if data:
+            if curs.fetchall():
                 return flask.jsonify({ 'exist' : '1' })
             else:
                 return flask.jsonify({})

+ 1 - 1
route/edit.py

@@ -179,7 +179,7 @@ def edit(name = 'Test', section = 0, do_type = ''):
 
             curs.execute(db_change("select data from other where name = 'edit_timeout'"))
             db_data_2 = curs.fetchall()
-            db_data_2 = '' if not db_data_2 else number_check(db_data_2[0][0])
+            db_data_2 = number_check(db_data_2[0][0]) if db_data_2 and db_data_2[0][0] != '' else ''
 
             if db_data_2 != '' and platform.system() == 'Linux':
                 timeout = edit_timeout(edit_render_set, (name, content), timeout = int(db_data_2))

+ 6 - 1
route/give_auth.py

@@ -4,6 +4,7 @@ def give_auth(name):
     with get_db_connect() as conn:
         curs = conn.cursor()
 
+        ip = ip_check()
         owner_auth = admin_check()
         admin_auth = admin_check(7)
 
@@ -19,7 +20,7 @@ def give_auth(name):
             if curs.fetchall():
                 return re_error('/error/3')
 
-            if ip_check() == name:
+            if ip == name:
                 return re_error('/error/3')
 
         if flask.request.method == 'POST':
@@ -40,6 +41,10 @@ def give_auth(name):
             time_limit = flask.request.form.get('date', '')
             if re.search(r'^[0-9]{4}-[0-9]{2}-[0-9]{2}$', time_limit):
                 curs.execute(db_change("insert into user_set (id, name, data) values (?, 'auth_date', ?)"), [name, time_limit])
+            else:
+                time_limit = ''
+
+            add_alarm(name, ip, 'Auth change to ' + select_data + (' (' + time_limit + ')' if time_limit != '' else ''))
 
             conn.commit()
 

+ 44 - 57
route/tool/func.py

@@ -1045,7 +1045,7 @@ def wiki_css(data):
     data_css = ''
     data_css_dark = ''
 
-    data_css_ver = '194'
+    data_css_ver = '196'
     data_css_ver = '.cache_v' + data_css_ver
 
     if 'main_css' in global_wiki_set:
@@ -1222,15 +1222,12 @@ def wiki_custom():
 
             if admin_check('all') == 1:
                 user_admin = '1'
-                user_acl_list = []
 
                 curs.execute(db_change("select data from user_set where id = ? and name = 'acl'"), [ip])
                 curs.execute(db_change('select acl from alist where name = ?'), [curs.fetchall()[0][0]])
                 user_acl = curs.fetchall()
-                for i in user_acl:
-                    user_acl_list += [i[0]]
-
-                user_acl_list = user_acl_list if user_acl != [] else '0'
+                user_acl_list = [for_a[0] for for_a in user_acl]
+                user_acl_list = user_acl_list if user_acl_list != [] else '0'
             else:
                 user_admin = '0'
                 user_acl_list = '0'
@@ -1252,10 +1249,7 @@ def wiki_custom():
         user_topic = '1' if curs.fetchall() else '0'
         
         split_path = flask.request.path.split('/')
-        if len(split_path) > 1:
-            split_path = split_path[1:]
-        else:
-            split_path = 0
+        split_path = split_path[1:] if len(split_path) > 1 else 0
 
         return [
             '',
@@ -1270,7 +1264,8 @@ def wiki_custom():
             user_acl_list,
             ip,
             user_topic,
-            split_path
+            split_path,
+            level_check(ip)
         ]
 
 def load_skin(data = '', set_n = 0, default = 0):
@@ -1775,6 +1770,32 @@ def get_admin_list(num = None):
                 
             return admin_list
 
+def level_check(ip = ''):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+    
+        if ip == '':
+            ip = ip_check()
+
+        level = '0'
+        exp = '0'
+        max_exp = '0'
+
+        curs.execute(db_change("select data from user_set where id = ? and name = 'level'"), [ip])
+        db_data = curs.fetchall()
+        if db_data:
+            level = db_data[0][0]
+
+        curs.execute(db_change("select data from user_set where id = ? and name = 'experience'"), [ip])
+        db_data = curs.fetchall()
+        if db_data:
+            exp = db_data[0][0]
+
+        if exp != '0':
+            max_exp = str(500 + (int(level) * 50))
+
+        return [level, exp, max_exp]
+
 def admin_check(num = None, what = None, name = ''):
     with get_db_connect() as conn:
         curs = conn.cursor()
@@ -2171,14 +2192,9 @@ def ip_pas(raw_ip, type_data = 0):
                     curs.execute(db_change("select data from other where name = 'user_name_level'"))
                     db_data = curs.fetchall()
                     if db_data and db_data[0][0] != '':
-                        level = '0'
+                        level_data = level_check(raw_ip)
 
-                        curs.execute(db_change("select data from user_set where id = ? and name = 'level'"), [raw_ip])
-                        db_data = curs.fetchall()
-                        if db_data:
-                            level = db_data[0][0]
-
-                        ip += '<sup>' + level + '</sup>'
+                        ip += '<sup>' + level_data[0] + '</sup>'
 
                     ip = '<a href="/w/' + url_pas('user:' + raw_ip) + '">' + ip + '</a>'
                     
@@ -2379,19 +2395,9 @@ def do_reload_recent_thread(topic_num, date, name = None, sub = None):
 
         curs.execute(db_change("select code from rd where code = ?"), [topic_num])
         if curs.fetchall():
-            curs.execute(db_change("update rd set date = ? where code = ?"), [
-                date, 
-                topic_num
-            ])
+            curs.execute(db_change("update rd set date = ? where code = ?"), [date, topic_num])
         else:
-            curs.execute(db_change(
-                "insert into rd (title, sub, code, date, band, stop, agree, acl) values (?, ?, ?, ?, '', '', '', '')"
-            ), [
-                name, 
-                sub, 
-                topic_num, 
-                date
-            ])
+            curs.execute(db_change("insert into rd (title, sub, code, date, band, stop, agree, acl) values (?, ?, ?, ?, '', '', '', '')"), [name, sub, topic_num, date])
 
 def add_alarm(to_user, from_user, context):
     with get_db_connect() as conn:
@@ -2406,9 +2412,7 @@ def add_alarm(to_user, from_user, context):
             if db_data:
                 count = str(int(db_data[0][0]) + 1)
 
-            curs.execute(db_change(
-                'insert into user_notice (id, name, data, date, readme) values (?, ?, ?, ?, "")'
-            ), [count, to_user, context, get_time()])
+            curs.execute(db_change('insert into user_notice (id, name, data, date, readme) values (?, ?, ?, ?, "")'), [count, to_user, context, get_time()])
     
 def add_user(user_name, user_pw, user_email = '', user_encode = ''):
     with get_db_connect() as conn:
@@ -2430,28 +2434,13 @@ def add_user(user_name, user_pw, user_email = '', user_encode = ''):
         else:
             user_auth = 'user'
 
-        curs.execute(db_change("insert into user_set (id, name, data) values (?, 'pw', ?)"), [
-            user_name,
-            user_pw_hash
-        ])
-        curs.execute(db_change("insert into user_set (id, name, data) values (?, 'acl', ?)"), [
-            user_name,
-            user_auth
-        ])
-        curs.execute(db_change("insert into user_set (id, name, data) values (?, 'date', ?)"), [
-            user_name,
-            get_time()
-        ])
-        curs.execute(db_change("insert into user_set (id, name, data) values (?, 'encode', ?)"), [
-            user_name,
-            data_encode
-        ])
+        curs.execute(db_change("insert into user_set (id, name, data) values (?, 'pw', ?)"), [user_name, user_pw_hash])
+        curs.execute(db_change("insert into user_set (id, name, data) values (?, 'acl', ?)"), [user_name, user_auth])
+        curs.execute(db_change("insert into user_set (id, name, data) values (?, 'date', ?)"), [user_name, get_time()])
+        curs.execute(db_change("insert into user_set (id, name, data) values (?, 'encode', ?)"), [user_name, data_encode])
         
         if user_email != '':
-            curs.execute(db_change("insert into user_set (name, id, data) values ('email', ?, ?)"), [
-                user_name,
-                user_email
-            ])
+            curs.execute(db_change("insert into user_set (name, id, data) values ('email', ?, ?)"), [user_name, user_email])
     
 def ua_plus(u_id, u_ip, u_agent, time):
     with get_db_connect() as conn:
@@ -2462,9 +2451,7 @@ def ua_plus(u_id, u_ip, u_agent, time):
         if rep_data and rep_data[0][0] != '':
             pass
         else:
-            curs.execute(db_change(
-                "insert into ua_d (name, ip, ua, today, sub) values (?, ?, ?, ?, '')"
-            ), [
+            curs.execute(db_change("insert into ua_d (name, ip, ua, today, sub) values (?, ?, ?, ?, '')"), [
                 u_id, 
                 u_ip, 
                 u_agent, 
@@ -2485,7 +2472,7 @@ def ban_insert(name, end, why, login, blocker, type_d = None, release = 0):
                 'release',
                 now_time,
                 blocker,
-                '',
+                why,
                 band
             ])
         else:

+ 2 - 2
route/view_read.py

@@ -275,10 +275,10 @@ def view_read(name = 'Test', do_type = ''):
                 '<div class="opennamu_trace">' + \
                     '<a class="opennamu_trace_button" href="javascript:opennamu_do_trace_spread();"> (+)</a>' + \
                     load_lang('trace') + ' : ' + \
-                    '  '.join(
+                    '  '.join(
                         [
                             '<a href="/w/' + url_pas(for_a) + '">' + html.escape(for_a) + '</a>'
-                            for for_a in flask.session['lastest_document']
+                            for for_a in reversed(flask.session['lastest_document'])
                         ]
                     ) + \
                 '</div>' + \

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.5.0-dev2",
+        "r_ver" : "v3.5.0-dev5",
         "c_ver" : "3500374",
         "s_ver" : "3500113"
     }

+ 8 - 13
views/main_css/js/func/insert_user_info.js

@@ -36,9 +36,9 @@ function do_insert_user_info_sub(name, lang_data_list, lang_data = {}, for_a = 0
                 
                 get_data_ban += lang_data['type'] + ' : ';
                 if(data['data']['ban']['type'] === 'normal') {
-                    get_data_ban += lang_data['normal']; 
+                    get_data_ban += '<a href="/block_log/user/' + opennamu_do_url_encode(name) + '">' + lang_data['normal'] + '</a>'; 
                 } else {
-                    get_data_ban += lang_data['regex'];
+                    get_data_ban += '<a href="/block_log/regex">' + lang_data['regex'] + '</a>';
                 }
                 get_data_ban += '<br>';
                 
@@ -58,16 +58,11 @@ function do_insert_user_info_sub(name, lang_data_list, lang_data = {}, for_a = 0
                 }
                 get_data_ban += '<br>';
                 
-                get_data_ban += lang_data['why'] + ' : ' + data['data']['ban']['reason'];
-            }
-
-            let level = '0';
-            let exp = '0';
-            let max_exp = '0';
-            if(get_data_auth !== lang_data['ip']) {
-                level = data['data']['level'];
-                exp = data['data']['exp'];
-                max_exp = String(500 + (Number(data['data']['level']) * 50));
+                if(data['data']['ban']['reason'] === 'edit filter') {
+                    get_data_ban += lang_data['why'] + ' : <a href="/edit_filter/' + opennamu_do_url_encode(name) + '">' + data['data']['ban']['reason'] + '</a>';
+                } else {
+                    get_data_ban += lang_data['why'] + ' : ' + data['data']['ban']['reason'];
+                }
             }
             
             let end_data = '' +
@@ -86,7 +81,7 @@ function do_insert_user_info_sub(name, lang_data_list, lang_data = {}, for_a = 0
                     '</tr>' +
                     '<tr>' +
                         '<td>' + lang_data['level'] + '</td>' +
-                        '<td>' + level + ' (' + exp + ' / ' + max_exp + ')</td>' +
+                        '<td>' + data['data']['level'] + ' (' + data['data']['exp'] + ' / ' + data['data']['max_exp'] + ')</td>' +
                     '</tr>' +
                 '</table>' +
             '';