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

버그 수정 및 좀 더 개편

Surplus_Up (2DU) 7 лет назад
Родитель
Сommit
f13825c8cf
3 измененных файлов с 39 добавлено и 45 удалено
  1. 18 26
      app.py
  2. 19 17
      func.py
  3. 2 2
      set_mark/tool.py

+ 18 - 26
app.py

@@ -2495,23 +2495,7 @@ def login():
     ip = ip_check()
     ip = ip_check()
     agent = flask.request.headers.get('User-Agent')
     agent = flask.request.headers.get('User-Agent')
     
     
-    curs.execute("select block from ban where block = ? and login = 'O'", [ip])
-    if not curs.fetchall():
-        match = re.search("^([0-9]{1,3}\.[0-9]{1,3})", ip)
-        if match:
-            match = match.groups()[0]
-        else:
-            match = 'Not'
-
-        curs.execute("select block from ban where block = ? and login = 'O'", [match])
-        if not curs.fetchall():
-            ban = ban_check()
-        else:
-            ban = 0
-    else:
-        ban = 0
-
-    if ban == 1:
+    if ban_check(tool = 'login') == 1:
         return re_error('/ban')
         return re_error('/ban')
         
         
     if flask.request.method == 'POST':        
     if flask.request.method == 'POST':        
@@ -2855,15 +2839,19 @@ def logout():
     
     
 @app.route('/ban/<name>', methods=['POST', 'GET'])
 @app.route('/ban/<name>', methods=['POST', 'GET'])
 def user_ban(name = None):
 def user_ban(name = None):
-    curs.execute("select acl from user where id = ?", [name])
-    user = curs.fetchall()
-    if not user:
-        return re_error('/error/2')
+    if ip_or_user(name) == 0:
+        curs.execute("select acl from user where id = ?", [name])
+        user = curs.fetchall()
+        if not user:
+            return re_error('/error/2')
 
 
-    if user and user[0][0] != 'user':
-        if admin_check(None, None) != 1:
-            return re_error('/error/4')
+        if user and user[0][0] != 'user':
+            if admin_check(None, None) != 1:
+                return re_error('/error/4')
 
 
+    if ban_check(ip = ip_check(), tool = 'login') == 1:
+        return re_error('/ban')
+                
     if flask.request.method == 'POST':
     if flask.request.method == 'POST':
         if admin_check(1, 'ban (' + name + ')') != 1:
         if admin_check(1, 'ban (' + name + ')') != 1:
             return re_error('/error/3')
             return re_error('/error/3')
@@ -2889,6 +2877,10 @@ def user_ban(name = None):
                 data = '<ul><li>' + load_lang('limitless') + ' ' + load_lang('ban') + '</li>'
                 data = '<ul><li>' + load_lang('limitless') + ' ' + load_lang('ban') + '</li>'
             else:
             else:
                 data = '<ul><li>' + load_lang('ban') + ' : ' + end[0][0] + '</li>'
                 data = '<ul><li>' + load_lang('ban') + ' : ' + end[0][0] + '</li>'
+                
+            curs.execute("select block from ban where block = ? and login = 'O'", [name])
+            if curs.fetchall():
+                data += '<li>' + load_lang('login') + ' ' + load_lang('able') + '</li>'
 
 
             if end[0][1] != '':
             if end[0][1] != '':
                 data += '<li>' + load_lang('why') + ' : ' + end[0][1] + '</li></ul><hr>'
                 data += '<li>' + load_lang('why') + ' : ' + end[0][1] + '</li></ul><hr>'
@@ -3617,7 +3609,7 @@ def user_info():
         if match:
         if match:
             match = match.groups()[0]
             match = match.groups()[0]
         else:
         else:
-            match = 'Error'
+            match = '-'
 
 
         curs.execute("select end, login, band from ban where block = ? or block = ?", [ip, match])
         curs.execute("select end, login, band from ban where block = ? or block = ?", [ip, match])
         block_data = curs.fetchall()
         block_data = curs.fetchall()
@@ -3625,7 +3617,7 @@ def user_info():
             if block_data[0][0] != '':
             if block_data[0][0] != '':
                 acl += ' (End : ' + block_data[0][0] + ')'
                 acl += ' (End : ' + block_data[0][0] + ')'
             else:
             else:
-                acl += ' (End : ' + load_lang('limitless') + ')'        
+                acl += ' (' + load_lang('limitless') + ')'        
 
 
             if block_data[0][1] != '':
             if block_data[0][1] != '':
                 acl += ' (' + load_lang('login') + ' ' + load_lang('able') + ')'
                 acl += ' (' + load_lang('login') + ' ' + load_lang('able') + ')'

+ 19 - 17
func.py

@@ -502,29 +502,31 @@ def acl_check(name):
 
 
     return 0
     return 0
 
 
-def ban_check(ip = ip_check()):
+def ban_check(ip = None, tool = None):
+    if not ip:
+        ip = ip_check()
+
     band = re.search("^([0-9]{1,3}\.[0-9]{1,3})", ip)
     band = re.search("^([0-9]{1,3}\.[0-9]{1,3})", ip)
     if band:
     if band:
         band_it = band.groups()[0]
         band_it = band.groups()[0]
     else:
     else:
         band_it = '-'
         band_it = '-'
-        
-    curs.execute("select end from ban where block = ?", [band_it])
+    
+    curs.execute("select end, login from ban where block = ?", [band_it])
     band_d = curs.fetchall()
     band_d = curs.fetchall()
     
     
-    curs.execute("select end from ban where block = ?", [ip])
+    curs.execute("select end, login from ban where block = ?", [ip])
     ban_d = curs.fetchall()
     ban_d = curs.fetchall()
-    if band_d or ban_d:
-        data = band_d or ban_d
-        if data:
-            if data[0][0] > get_time():
-                return 1
-            else:
+    
+    data = band_d or ban_d
+    if data and (data[0][0] == '' or data[0][0] > get_time()):
+        if tool and tool == 'login':                    
+            if data[0][1] == 'O':
                 return 0
                 return 0
-        else:
-            return 0
-    else:
-        return 0
+                
+        return 1
+
+    return 0
         
         
 def topic_check(name, sub):
 def topic_check(name, sub):
     ip = ip_check()
     ip = ip_check()
@@ -630,7 +632,7 @@ def re_error(data):
                     end_data = curs.fetchall()
                     end_data = curs.fetchall()
             
             
             if end_data:
             if end_data:
-                end = '<li>' + load_lang('state') + ' : '
+                end = '<li>' + load_lang('state') + ' : ' + load_lang('ban') + '</li><li>'
 
 
                 if end_data[0][0]:
                 if end_data[0][0]:
                     now = int(re.sub('(\-| |:)', '', get_time()))
                     now = int(re.sub('(\-| |:)', '', get_time()))
@@ -642,9 +644,9 @@ def re_error(data):
 
 
                         end += '<script>location.reload();</script>'
                         end += '<script>location.reload();</script>'
                     else:
                     else:
-                        end += load_lang('why') + ' : ' + end_data[0][0]
+                        end += 'End : ' + end_data[0][0]
                 else:
                 else:
-                    end += load_lang('why') + ' : ' + load_lang('limitless')
+                    end += load_lang('limitless')
                 
                 
                 end += '</li>'
                 end += '</li>'
 
 

+ 2 - 2
set_mark/tool.py

@@ -17,8 +17,8 @@ def ip_check():
             if ip == ('::1' or '127.0.0.1'):
             if ip == ('::1' or '127.0.0.1'):
                 ip = flask.request.environ.get('HTTP_X_FORWARDED_FOR', flask.request.remote_addr)
                 ip = flask.request.environ.get('HTTP_X_FORWARDED_FOR', flask.request.remote_addr)
         except:
         except:
-            ip = 'Error'
-
+            ip = '-'
+            
     return str(ip)
     return str(ip)
 
 
 def savemark(data):
 def savemark(data):