Kaynağa Gözat

rc 타입별 분리 저장

잉여개발기 (SPDV) 5 yıl önce
ebeveyn
işleme
a129ca55ce

+ 2 - 1
route/edit_delete.py

@@ -29,7 +29,8 @@ def edit_delete_2(conn, name, app_var):
                 ip,
                 flask.request.form.get('send', ''),
                 leng,
-                'delete'
+                t_check = 'delete',
+                mode = 'delete'
             )
 
             curs.execute(db_change("select title, link from back where title = ? and not type = 'cat' and not type = 'no'"), [name])

+ 6 - 3
route/edit_move.py

@@ -45,7 +45,8 @@ def edit_move_2(conn, name):
                     ip_check(),
                     flask.request.form.get('send', ''),
                     '0',
-                    'merge <a>' + name + '</a> - <a>' + move_title + '</a> move'
+                    t_check = 'merge <a>' + name + '</a> - <a>' + move_title + '</a> move',
+                    mode = 'move'
                 )
 
                 curs.execute(db_change("update back set type = 'no' where title = ? and not type = 'cat' and not type = 'no'"), [name])
@@ -112,7 +113,8 @@ def edit_move_2(conn, name):
                         ip_check(),
                         flask.request.form.get('send', ''),
                         '0',
-                        '<a>' + (title_name[0] if title_name[0] != 'test ' + str(i) else name) + '</a> - <a>' + title_name[1] + '</a> move'
+                        t_check = '<a>' + (title_name[0] if title_name[0] != 'test ' + str(i) else name) + '</a> - <a>' + title_name[1] + '</a> move',
+                        mode = 'move'
                     )
 
                     curs.execute(db_change("update history set title = ? where title = ?"), [title_name[1], title_name[0]])
@@ -140,7 +142,8 @@ def edit_move_2(conn, name):
                 ip_check(),
                 flask.request.form.get('send', ''),
                 '0',
-                '<a>' + name + '</a> - <a>' + move_title + '</a> move'
+                t_check = '<a>' + name + '</a> - <a>' + move_title + '</a> move',
+                mode = 'move'
             )
 
             curs.execute(db_change("update back set type = 'no' where title = ? and not type = 'cat' and not type = 'no'"), [name])

+ 2 - 1
route/edit_revert.py

@@ -47,7 +47,8 @@ def edit_revert_2(conn, name):
                 ip_check(),
                 flask.request.form.get('send', ''),
                 leng,
-                'r' + str(num) + ''
+                t_check = 'r' + str(num),
+                mode = 'revert'
             )
 
             render_set(

+ 2 - 1
route/func_upload.py

@@ -106,7 +106,8 @@ def func_upload_2(conn, app_var):
                 ip,
                 ip,
                 '0',
-                'upload'
+                t_check = 'upload',
+                mode = 'upload'
             )
 
             if file_num:

+ 1 - 0
route/give_history_add.py

@@ -21,6 +21,7 @@ def give_history_add_2(conn, name):
             'Add:' + flask.request.form.get('get_ip', ''),
             flask.request.form.get('send', ''),
             leng,
+            t_check = 'add',
             mode = 'add'
         )
 

+ 36 - 69
route/recent_changes.py

@@ -34,29 +34,24 @@ def recent_changes_2(conn, name, tool):
                     <td id="main_table_width">''' + load_lang('time') + '''</td>
                 '''
 
-                tool_select = flask.request.args.get('tool', 'normal')
-                if tool_select == 'move':
-                    plus_sql = 'where (send like ? or send like ?) and type = "" '
-                    plus_list = ['%(<a>' + name +'</a>%', '%<a>' + name + '</a> move)', sql_num]
-                    sub += ' (' + load_lang('move') + ')'
-                elif tool_select == 'delete':
-                    plus_sql = 'where send like "%(delete)" and title = ? and type = "" '
-                    plus_list = [name, sql_num]
-                    sub += ' (' + load_lang('delete') + ')'
-                elif tool_select == 'revert':
-                    plus_sql = 'where send like ? and title = ? and type = "" '
-                    plus_list = ['%(r%)', name, sql_num]
-                    sub += ' (' + load_lang('revert') + ')'
+                set_type = flask.request.args.get('set', 'normal')
+                set_type = '' if set_type == 'edit' else set_type
+
+                if set_type != 'normal':
+                    curs.execute(db_change('' + \
+                        'select id, title, date, ip, send, leng, hide from history ' + \
+                        'where title = ? and type = ? ' + \
+                        'order by id + 0 desc ' + \
+                        "limit ?, 50" + \
+                    ''), [name, set_type, sql_num])
                 else:
-                    plus_sql = 'where title = ? and type = "" '
-                    plus_list = [name, sql_num]
+                    curs.execute(db_change('' + \
+                        'select id, title, date, ip, send, leng, hide from history ' + \
+                        'where title = ? ' + \
+                        'order by id + 0 desc ' + \
+                        "limit ?, 50" + \
+                    ''), [name, sql_num])
 
-                curs.execute(db_change('' + \
-                    'select id, title, date, ip, send, leng, hide from history ' + \
-                    plus_sql + \
-                    'order by id + 0 desc ' + \
-                    "limit ?, 50" + \
-                ''), plus_list)
                 data_list = curs.fetchall()
             else:
                 div +=  '''
@@ -69,7 +64,7 @@ def recent_changes_2(conn, name, tool):
 
                 curs.execute(db_change('' + \
                     'select id, title, date, ip, send, leng, hide from history ' + \
-                    "where ip = ? and type = '' order by date desc limit ?, 50" + \
+                    "where ip = ? order by date desc limit ?, 50" + \
                 ''), [name, sql_num])
                 data_list = curs.fetchall()
         else:
@@ -80,41 +75,13 @@ def recent_changes_2(conn, name, tool):
             '''
             sub = ''
             set_type = flask.request.args.get('set', 'normal')
+            set_type = '' if set_type == 'edit' else set_type
 
-            if set_type != 'normal':
-                if set_type == 'move':
-                    plus_sql = 'where send like "%</a> move)" and '
-                    sub += ' (' + load_lang('move') + ')'
-                elif set_type == 'delete':
-                    plus_sql = 'where send like "%(delete)" and '
-                    sub += ' (' + load_lang('delete') + ')'
-                elif set_type == 'revert':
-                    plus_sql = 'where send like "%(r%)" and '
-                    sub += ' (' + load_lang('revert') + ')'
-                else:
-                    plus_sql = 'where '
-
-                plus_sql += 'type = "" '
-                
-                if set_type == 'user':
-                    plus_sql = 'where title like "user:%" '
-                    sub += ' (' + load_lang('user') + ')'
-                else:
-                    plus_sql += 'and not title like "user:%" '
-
-                curs.execute(db_change('' + \
-                    'select id, title, date, ip, send, leng, hide from history ' + \
-                    plus_sql + \
-                    'order by date desc ' + \
-                    'limit 50' + \
-                ''))
-                data_list = curs.fetchall()
-            else:
-                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 = ?'), i)
-                    data_list += curs.fetchall()
+            data_list = []
+            curs.execute(db_change('select id, title from rc where type = ? order by date desc'), [set_type])
+            for i in curs.fetchall():
+                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>'
 
@@ -186,14 +153,17 @@ def recent_changes_2(conn, name, tool):
 
         if name:
             if tool == 'history':
-                if tool_select == 'normal':
-                    div = '' + \
-                        '<a href="?tool=move">(' + load_lang('move') + ')</a> ' + \
-                        '<a href="?tool=delete">(' + load_lang('delete') + ')</a> ' + \
-                        '<a href="?tool=revert">(' + load_lang('revert') + ')</a>' + \
-                        '<hr class="main_hr">' + div + \
-                    ''
-
+                div = '' + \
+                    '<a href="?set=normal">(' + load_lang('normal') + ')</a> ' + \
+                    '<a href="?set=edit">(' + load_lang('edit') + ')</a> ' + \
+                    '<a href="?set=move">(' + load_lang('move') + ')</a> ' + \
+                    '<a href="?set=delete">(' + load_lang('delete') + ')</a> ' + \
+                    '<a href="?set=revert">(' + load_lang('revert') + ')</a>' + \
+                    '<hr class="main_hr">' + div + \
+                ''
+                menu = [['w/' + url_pas(name), load_lang('return')]]
+                
+                if set_type == 'normal':
                     div = '''
                         <form method="post">
                             <select name="a">''' + select + '''</select> <select name="b">''' + select + '''</select>
@@ -202,15 +172,11 @@ def recent_changes_2(conn, name, tool):
                         <hr class=\"main_hr\">
                     ''' + div
 
-                    menu = [['w/' + url_pas(name), load_lang('return')]]
-
                     if admin == 1:
                         menu += [['add_history/' + url_pas(name), load_lang('history_add')]]
-                else:
-                    menu = [['history/' + url_pas(name), load_lang('return')]]
 
                 title = name
-                div += next_fix('/history/' + url_pas(name) + '?tool=' + tool_select + '&num=', num, data_list)
+                div += next_fix('/history/' + url_pas(name) + '?tool=' + set_type + '&num=', num, data_list)
             else:
                 title = load_lang('edit_record')
                 menu = [['other', load_lang('other')], ['user', load_lang('user')], ['count/' + url_pas(name), load_lang('count')]]
@@ -218,6 +184,7 @@ def recent_changes_2(conn, name, tool):
         else:
             div = '' + \
                 '<a href="?set=normal">(' + load_lang('normal') + ')</a> ' + \
+                '<a href="?set=edit">(' + load_lang('edit') + ')</a> ' + \
                 '<a href="?set=user">(' + load_lang('user_document') + ')</a> ' + \
                 '<a href="?set=move">(' + load_lang('move') + ')</a> ' + \
                 '<a href="?set=delete">(' + load_lang('delete') + ')</a> ' + \

+ 6 - 6
route/tool/func.py

@@ -1104,7 +1104,7 @@ def rd_plus(topic_num, date, name = None, sub = None):
 
     conn.commit()
 
-def history_plus(title, data, date, ip, send, leng, t_check = '', d_type = '', mode = ''):
+def history_plus(title, data, date, ip, send, leng, t_check = '', mode = ''):
     if mode == 'add':
         curs.execute(db_change("select id from history where title = ? and type = '' order by id + 0 asc limit 1"), [title])
         id_data = curs.fetchall()
@@ -1114,14 +1114,13 @@ def history_plus(title, data, date, ip, send, leng, t_check = '', d_type = '', m
         id_data = curs.fetchall()
         id_data = str(int(id_data[0][0]) + 1) if id_data else '1'
         
-        mode = mode if mode != '' else 'edit'
-        mode = mode if not re.search('^user:', title) else 'user_page'
+        mode = mode if not re.search('^user:', title) else 'user'
 
     send = re.sub(r'\(|\)|<|>', '', send)
     send = send[:128] if len(send) > 128 else send
     send = send + ' (' + t_check + ')' if t_check != '' else send
 
-    if mode != 'add' and mode != 'user_page':
+    if mode != 'add' and mode != 'user':
         curs.execute(db_change("select count(*) from rc where type = 'normal'"))
         if curs.fetchall()[0][0] >= 200:
             curs.execute(db_change("select id, title from rc where type = 'normal' order by date asc limit 1"))
@@ -1144,9 +1143,10 @@ def history_plus(title, data, date, ip, send, leng, t_check = '', d_type = '', m
             curs.execute(db_change("select id, title from rc where type = ? order by date asc limit 1"), [mode])
             rc_data = curs.fetchall()
             if rc_data:
-                curs.execute(db_change('delete from rc where id = ? and title = ? and type = "normal"'), [
+                curs.execute(db_change('delete from rc where id = ? and title = ? and type = ?'), [
                     rc_data[0][0],
-                    rc_data[0][1]
+                    rc_data[0][1],
+                    mode
                 ])
     
         curs.execute(db_change("insert into rc (id, title, date, type) values (?, ?, ?, ?)"), [