Просмотр исходного кода

custom 쓰던 부분을 다른 함수로 대체

Surplus_Up (2DU) 6 лет назад
Родитель
Сommit
8aee70ea00

+ 1 - 1
route/func_upload.py

@@ -51,7 +51,7 @@ def func_upload_2(conn):
             if flask.request.form.get('f_lice', None):
                 lice = flask.request.form.get('f_lice', None)
             else:
-                if custom()[2] == 0:
+                if ip_or_user(ip) != 0:
                     lice = ip
                 else:
                     lice = '[[user:' + ip + ']]'

+ 2 - 1
route/give_acl.py

@@ -4,6 +4,7 @@ def give_acl_2(conn, name):
     curs = conn.cursor()
 
     check_ok = ''
+    ip = ip_check()
     
     if flask.request.method == 'POST':
         check_data = 'acl (' + name + ')'
@@ -12,7 +13,7 @@ def give_acl_2(conn, name):
     
     user_data = re.search('^user:(.+)$', name)
     if user_data:
-        if check_data and custom()[2] == 0:
+        if check_data and ip_or_user(ip) != 0:
             return redirect('/login')
         
         if user_data.groups()[0] != ip_check():

+ 2 - 1
route/login.py

@@ -3,7 +3,8 @@ from .tool.func import *
 def login_2(conn):
     curs = conn.cursor()
 
-    if custom()[2] != 0:
+    ip = ip_check()
+    if ip_or_user(ip) == 0:
         return redirect('/user')
     
     if ban_check(tool = 'login') == 1:

+ 2 - 1
route/login_pw_change.py

@@ -6,7 +6,8 @@ def login_pw_change_2(conn):
     if ban_check() == 1:
         return re_error('/ban')
 
-    if custom()[2] == 0:
+    ip = ip_check()
+    if ip_or_user(ip) != 0:
         return redirect('/login')
 
     if flask.request.method == 'POST':

+ 2 - 1
route/login_register.py

@@ -6,7 +6,8 @@ def login_register_2(conn):
     if ban_check() == 1:
         return re_error('/ban')
 
-    if custom()[2] != 0:
+    ip = ip_check()
+    if ip_or_user(ip) == 0:
         return redirect('/user')
 
     if not admin_check() == 1:

+ 3 - 3
route/main_views.py

@@ -13,17 +13,17 @@ def main_views_2(conn, name):
         c_open = open('./views/' + name, encoding='utf-8')
         f_open = c_open.read()
         c_open.close()
-        return flask.Response(easy_minify(f_open, 'css'), mimetype="text/css")
+        return flask.Response(easy_minify(f_open, 'css'), mimetype = "text/css")
     elif g[0] == 'js':
         c_open = open('./views/' + name, encoding='utf-8')
         f_open = c_open.read()
         c_open.close()
-        return flask.Response(easy_minify(f_open, 'js'), mimetype="text/js")
+        return flask.Response(easy_minify(f_open, 'js'), mimetype = "text/js")
     elif g[0] == 'html':
         c_open = open('./views/' + name, encoding='utf-8')
         f_open = c_open.read()
         c_open.close()
-        return flask.Response(easy_minify(f_open), mimetype="text/html")
+        return flask.Response(easy_minify(f_open), mimetype = "text/html")
     else:
         if re.search('\/', name):
             m = re.search('^(.*)\/(.*)$', name)

+ 4 - 4
route/search_deep.py

@@ -33,10 +33,10 @@ def search_deep_2(conn, name):
             <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'",
+    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()

+ 18 - 9
route/tool/func.py

@@ -147,8 +147,9 @@ def render_set(title = '', data = '', num = 0, s_data = 0, include = None):
 
 def captcha_get():
     data = ''
+    ip = ip_check()
 
-    if custom()[2] == 0:
+    if ip_or_user(ip) != 0:
         curs.execute('select data from other where name = "recaptcha"')
         recaptcha = curs.fetchall()
         if recaptcha and recaptcha[0][0] != '':
@@ -234,8 +235,10 @@ def pw_check(data, data2, type_d = 'no', id_d = ''):
     return re_data
 
 def captcha_post(re_data, num = 1):
+    ip = ip_check()
+
     if num == 1:
-        if custom()[2] == 0 and captcha_get() != '':
+        if ip_or_user(ip) != 0 and captcha_get() != '':
             curs.execute('select data from other where name = "sec_re"')
             sec_re = curs.fetchall()
             if sec_re and sec_re[0][0] != '':
@@ -332,7 +335,7 @@ def edit_button():
     return data + '<hr class=\"main_hr\">'
 
 def ip_warring():
-    if custom()[2] == 0:    
+    if ip_or_user(ip) != 0:
         curs.execute('select data from other where name = "no_login_warring"')
         data = curs.fetchall()
         if data and data[0][0] != '':
@@ -610,11 +613,7 @@ def custom():
 
     ip = ip_check()
     if ip_or_user(ip) == 0:
-        curs.execute('select name from alarm where name = ? limit 1', [ip])
-        if curs.fetchall():
-            user_icon = 2
-        else:
-            user_icon = 1
+        user_icon = 1
     else:
         user_icon = 0
 
@@ -643,7 +642,17 @@ def custom():
     else:
         user_ban = '0'
 
-    return ['', '', user_icon, user_head, email, user_name, user_admin, user_ban]
+    if user_icon == 1:
+        curs.execute("select count(name) from alarm where name = ?", [ip])
+        count = curs.fetchall()
+        if count:
+            user_notice = str(count[0][0])
+        else:
+            user_notice = '0'
+    else:
+        user_notice = '0'
+
+    return ['', '', user_icon, user_head, email, user_name, user_admin, user_ban, user_notice]
 
 def load_skin(data = '', set_n = 0):
     div2 = ''

+ 0 - 2
route/topic_tool.py

@@ -24,8 +24,6 @@ def topic_tool_2(conn, name, sub):
                 <li><a href="/topic/''' + url_pas(name) + '/sub/' + url_pas(sub) + '''/setting"> Topic setting</a></li>
             </ul>
         '''
-
-    print(close_data)
     data += '''
         <h2>''' + load_lang('tool') + '''</h2>
         <ul>

+ 2 - 2
route/user_custom_head_view.py

@@ -6,7 +6,7 @@ def user_custom_head_view_2(conn):
     ip = ip_check()
 
     if flask.request.method == 'POST':
-        if custom()[2] != 0:
+        if ip_or_user(ip) == 0:
             curs.execute("select user from custom where user = ?", [ip + ' (head)'])
             if curs.fetchall():
                 curs.execute("update custom set css = ? where user = ?", [flask.request.form.get('content', None), ip + ' (head)'])
@@ -19,7 +19,7 @@ def user_custom_head_view_2(conn):
 
         return redirect('/user')
     else:
-        if custom()[2] != 0:
+        if ip_or_user(ip) == 0:
             start = ''
 
             curs.execute("select css from custom where user = ?", [ip + ' (head)'])

+ 1 - 1
route/user_info.py

@@ -11,7 +11,7 @@ def user_info_2(conn):
     else:
         plus2 = '<li><a href="/alarm">' + load_lang('alarm') + '</a></li>'
 
-    if custom()[2] != 0:        
+    if ip_or_user(ip) == 0:  
         plus = '''
             <li><a href="/logout">''' + load_lang('logout') + '''</a></li>
             <li><a href="/change">''' + load_lang('user_setting') + '''</a></li>

+ 2 - 2
route/user_setting.py

@@ -4,14 +4,14 @@ def user_setting_2(conn, server_init):
     curs = conn.cursor()
 
     support_language = server_init.server_set_var['language']['list']
+    ip = ip_check()
 
     if ban_check() == 1:
         return re_error('/ban')
 
-    if custom()[2] == 0:
+    if ip_or_user(ip) != 0:
         return redirect('/login')
 
-    ip = ip_check()
     user_state = flask.request.args.get('user', 'ip')
     
     if user_state == 'ip':

+ 0 - 1
route/view_read.py

@@ -189,7 +189,6 @@ def view_read_2(conn, name):
     
     div = adsense_code + '<div>' + div + '</div>'
 
-    # 이 부분 개선 필요
     match = re.search("^user:([^/]*)", name)
     if match:
         user_name = match.groups()[0]

+ 3 - 4
route/watch_list.py

@@ -4,11 +4,10 @@ def watch_list_2(conn):
     curs = conn.cursor()
 
     div = 'Limit : 10<hr class=\"main_hr\">'
-    
-    if custom()[2] == 0:
-        return redirect('/login')
+    ip = ip_check()    
 
-    ip = ip_check()
+    if ip_or_user(ip) != 0:
+        return redirect('/login')
 
     curs.execute("delete from scan where user = ? and title = ''", [ip])
     conn.commit()

+ 2 - 3
route/watch_list_name.py

@@ -3,10 +3,9 @@ from .tool.func import *
 def watch_list_name_2(conn, name):
     curs = conn.cursor()
     
-    if custom()[2] == 0:
-        return redirect('/login')
-
     ip = ip_check()
+    if ip_or_user(ip) != 0:
+        return redirect('/login')
 
     curs.execute("select count(title) from scan where user = ?", [ip])
     count = curs.fetchall()