Răsfoiți Sursa

버그 수정

Surplus_Up (2DU) 6 ani în urmă
părinte
comite
2b9abf4102
6 a modificat fișierele cu 25 adăugiri și 26 ștergeri
  1. 8 8
      app.py
  2. 2 5
      route/api_recent_change.py
  3. 1 5
      route/recent_changes.py
  4. 10 6
      route/tool/func.py
  5. 3 1
      route/tool/init.py
  6. 1 1
      version.json

+ 8 - 8
app.py

@@ -9,8 +9,8 @@ for i_data in os.listdir("route"):
         exec("from route." + f_src + " import *")
 
 # DB
-version_list = json.loads(open('version.json', encoding='utf8').read())
-app_var = json.loads(open('data/app_var.json', encoding='utf8').read())
+version_list = json.loads(open('version.json', encoding = 'utf8').read())
+app_var = json.loads(open('data/app_var.json', encoding = 'utf8').read())
 
 print('Version : ' + version_list['master']['r_ver'])
 print('DB set version : ' + version_list['master']['c_ver'])
@@ -19,7 +19,7 @@ print('----')
 
 while 1:
     try:
-        set_data = json.loads(open('data/set.json', encoding='utf8').read())
+        set_data = json.loads(open('data/set.json', encoding = 'utf8').read())
         if not 'db_type' in set_data:
             try:
                 os.remove('data/set.json')
@@ -67,10 +67,10 @@ while 1:
             if new_json[1] == '':
                 new_json[1] = 'data'
 
-            with open('data/set.json', 'w', encoding='utf8') as f:
+            with open('data/set.json', 'w', encoding = 'utf8') as f:
                 f.write('{ "db" : "' + new_json[1] + '", "db_type" : "' + new_json[0] + '" }')
 
-            set_data = json.loads(open('data/set.json', encoding='utf8').read())
+            set_data = json.loads(open('data/set.json', encoding = 'utf8').read())
 
             break
 
@@ -78,7 +78,7 @@ db_data_get(set_data['db_type'])
 
 if set_data['db_type'] == 'mysql':
     try:
-        set_data_mysql = json.loads(open('data/mysql.json', encoding='utf8').read())
+        set_data_mysql = json.loads(open('data/mysql.json', encoding = 'utf8').read())
     except:
         new_json = ['', '', '']
 
@@ -99,10 +99,10 @@ if set_data['db_type'] == 'mysql':
         if new_json[2] == '':
             new_json[2] == 'localhost'
 
-        with open('data/mysql.json', 'w', encoding='utf8') as f:
+        with open('data/mysql.json', 'w', encoding = 'utf8') as f:
             f.write('{ "user" : "' + new_json[0] + '", "password" : "' + new_json[1] + '", "host" : "' + new_json[2] + '" }')
 
-        set_data_mysql = json.loads(open('data/mysql.json', encoding='utf8').read())
+        set_data_mysql = json.loads(open('data/mysql.json', encoding = 'utf8').read())
 
     conn = pymysql.connect(
         host = set_data_mysql['host'] if 'host' in set_data_mysql else 'localhost',

+ 2 - 5
route/api_recent_change.py

@@ -9,12 +9,9 @@ def api_recent_change_2(conn):
     data_list = []
     curs.execute(db_change('select id, title from rc order by date desc'))
     for i in curs.fetchall():
-        curs.execute(db_change('' + \
-            'select id, title, date, ip, send, leng, hide from history ' + \
-            'where id = ? and title = ? ' + \
-            'order by date desc' + \
-        ''), i)
+        curs.execute(db_change('select id, title, date, ip, send, leng, hide from history where id = ? and title = ?'), i)
         data_list += curs.fetchall()
+        
     if data_list:
         return flask.jsonify(data_list)
     else:

+ 1 - 5
route/recent_changes.py

@@ -112,11 +112,7 @@ def recent_changes_2(conn, name, tool):
                 data_list = []
                 curs.execute(db_change('select id, title from rc order by date desc'))
                 for i in curs.fetchall():
-                    curs.execute(db_change('' + \
-                        'select id, title, date, ip, send, leng, hide from history ' + \
-                        'where id = ? and title = ? ' + \
-                        'order by date desc' + \
-                    ''), i)
+                    curs.execute(db_change('select id, title, date, ip, send, leng, hide from history where id = ? and title = ?'), i)
                     data_list += curs.fetchall()
 
         div += '</tr>'

+ 10 - 6
route/tool/func.py

@@ -1135,12 +1135,16 @@ def history_plus(title, data, date, ip, send, leng, t_check = '', d_type = ''):
     send = send[:128] if len(send) > 128 else send
     send = send + ' (' + t_check + ')' if t_check != '' else send
 
-    curs.execute(db_change('delete from rc order by date asc limit 1'))
-    curs.execute(db_change("insert into rc (id, title, date, type) values (?, ?, ?, 'normal')"), [
-        id_data,
-        title,
-        date
-    ])
+    if not re.search('^user:', title):
+        curs.execute(db_change("select count(*) from rc where type = 'normal'"))
+        if curs.fetchall()[0][0] > 49:
+            curs.execute(db_change('delete from rc order by date asc limit 1'))
+        
+        curs.execute(db_change("insert into rc (id, title, date, type) values (?, ?, ?, 'normal')"), [
+            id_data,
+            title,
+            date
+        ])
 
     curs.execute(db_change("insert into history (id, title, data, date, ip, send, leng, hide, type) values (?, ?, ?, ?, ?, ?, ?, '', ?)"), [
         id_data,

+ 3 - 1
route/tool/init.py

@@ -65,4 +65,6 @@ def init(key):
                 else:
                     return server_set_val
             else:
-                return server_set_var[key]['default']
+                return server_set_var[key]['default']
+
+        print('----')

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "master" : {
-        "r_ver" : "v3.1.9-master-13",
+        "r_ver" : "v3.1.9-master-14",
         "c_ver" : "3191301",
         "s_ver" : "8"
     }, "stable" : {