Ver Fonte

mod file sys

2du há 4 anos atrás
pai
commit
92c8aa4887

+ 12 - 5
app.py

@@ -603,9 +603,13 @@ def search_deep(name = 'test'):
 
 # Func-view
 @app.route('/xref/<everything:name>')
-def view_xref(name = None):
+def view_xref(name = 'Test'):
     return view_xref_2(conn, name)
 
+@app.route('/xref/this/<everything:name>')
+def view_xref_this(name = 'Test'):
+    return view_xref_2(conn, name, xref_type = '2')
+
 @app.route('/raw/<everything:name>')
 @app.route('/thread/<int:topic_num>/raw/<int:num>')
 def view_raw(name = None, topic_num = None, num = None):
@@ -643,10 +647,13 @@ def edit_backlink_reset(name = 'Test'):
 def edit_delete(name = None):
     return edit_delete_2(conn, name)
 
-# 개편 예정
-@app.route('/many_delete', methods = ['POST', 'GET'])
-def edit_delete_many():
-    return edit_delete_many_2(conn)
+@app.route('/delete/doc_file/<everything:name>', methods = ['POST', 'GET'])
+def edit_delete_file(name = 'test.jpg'):
+    return edit_delete_file_2(conn, name)
+
+@app.route('/delete/doc_mutiple', methods = ['POST', 'GET'])
+def edit_delete_mutiple():
+    return edit_delete_mutiple_2(conn)
 
 @app.route('/move/<everything:name>', methods = ['POST', 'GET'])
 def edit_move(name = None):

+ 4 - 0
route/edit_delete.py

@@ -47,6 +47,7 @@ def edit_delete_2(conn, name):
 
         file_check = re.search(r'^file:(.+)\.(.+)$', name)
         if file_check:
+            '''
             file_check = file_check.groups()
             file_directory = os.path.join(
                 load_image_url(), 
@@ -54,6 +55,9 @@ def edit_delete_2(conn, name):
             )
             if os.path.exists(file_directory):
                 os.remove(file_directory)
+            '''
+            
+            pass
         else:
             curs.execute(db_change('select data from other where name = "count_all_title"'))
             curs.execute(db_change("update other set data = ? where name = 'count_all_title'"), [str(int(curs.fetchall()[0][0]) - 1)])

+ 43 - 0
route/edit_delete_file.py

@@ -0,0 +1,43 @@
+from .tool.func import *
+
+def edit_delete_file_2(conn, name):
+    curs = conn.cursor()
+
+    ip = ip_check()
+    if admin_check() == 0:
+        return re_error('/ban')
+
+    mime_type = re.search(r'([^.]+)$', name)
+    if mime_type:
+        mime_type = mime_type.group(1).lower()
+    else:
+        mime_type = 'jpg'
+
+    file_name = re.sub(r'\.([^.]+)$', '', name)
+    file_name = re.sub(r'^file:', '', file_name)
+    
+    file_all_name = sha224_replace(file_name) + '.' + mime_type
+    file_directory = os.path.join(load_image_url(), file_all_name)
+    
+    if not os.path.exists(file_directory):
+        return redirect('/w/' + url_pas(name))
+
+    if flask.request.method == 'POST':
+        admin_check(None, 'file del (' + name + ')')
+        os.remove(file_directory)
+
+        return redirect('/w/' + url_pas(name))
+    else:
+        return easy_minify(flask.render_template(skin_check(),
+            imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('file_delete') + ')', 0])],
+            data = '''
+                <form method="post">
+                    <img src="/image/''' + url_pas(file_all_name) + '''">
+                    <hr class="main_hr">
+                    <a href="/image/''' + url_pas(file_all_name) + '''">/image/''' + url_pas(file_all_name) + '''</a>
+                    <hr class="main_hr">
+                    <button type="submit">''' + load_lang('file_delete') + '''</button>
+                </form>
+            ''',
+            menu = [['w/' + url_pas(name), load_lang('return')]]
+        ))

+ 1 - 1
route/edit_delete_many.py → route/edit_delete_mutiple.py

@@ -1,7 +1,7 @@
 from .tool.func import *
 from . import edit_delete
 
-def edit_delete_many_2(conn):
+def edit_delete_mutiple_2(conn):
     curs = conn.cursor()
 
     ip = ip_check()

+ 1 - 1
route/main_manager.py

@@ -38,7 +38,7 @@ def main_manager_2(conn, num):
                     <h2>2. ''' + load_lang('owner') + '''</h2>
                     <ul class="inside_ul">
                         <li><a href="/admin_group">''' + load_lang('admin_group_list') + '''</a></li>
-                        <li><a href="/many_delete">''' + load_lang('many_delete') + '''</a></li>
+                        <li><a href="/delete/doc_mutiple">''' + load_lang('many_delete') + '''</a></li>
                         <li><a href="/app_submit">''' + load_lang('application_list') + '''</a></li>
                         <li><a href="/api/sitemap.xml">''' + load_lang('get_sitemap') + '''</a></li>
                         <li><a href="/register">''' + load_lang('add_user') + '''</a></li>

+ 1 - 2
route/main_upload.py

@@ -61,8 +61,7 @@ def main_upload_2(conn):
 
             data_url_image = load_image_url()
             if os.path.exists(os.path.join(data_url_image, e_data)):
-                os.remove(os.path.join(data_url_image, e_data))
-                data.save(os.path.join(data_url_image, e_data))
+                return re_error('/error/16')
             else:
                 data.save(os.path.join(data_url_image, e_data))
 

+ 17 - 10
route/view_read.py

@@ -59,16 +59,23 @@ def view_read_2(conn, name, doc_rev, doc_from):
         file_name = re.sub(r'\.([^.]+)$', '', name)
         file_name = re.sub(r'^file:', '', file_name)
         
-        file_size = str(round(os.path.getsize(os.path.join(load_image_url(), sha224_replace(file_name) + '.' + mime_type)) / 1000, 1))
-        file_data = '''
-            <img src="/image/''' + sha224_replace(file_name) + '''.''' + mime_type + '''">
-            <h2>DATA</h2>
-            <table>
-                <tr><td>URL</td><td><a href="/image/''' + url_pas(sha224_replace(name) + '.' + mime_type) + '''">LINK</a></td></tr>
-                <tr><td>VOLUME</td><td>''' + file_size + '''KB</td></tr>
-            </table>
-            <h2>CONTENT</h2>
-        '''
+        file_all_name = sha224_replace(file_name) + '.' + mime_type
+        file_path_name = os.path.join(load_image_url(), file_all_name)
+        if os.path.exists(file_path_name):
+            file_size = str(round(os.path.getsize(file_path_name) / 1000, 1))
+            file_data = '''
+                <img src="/image/''' + url_pas(file_all_name) + '''">
+                <h2>DATA</h2>
+                <table>
+                    <tr><td>URL</td><td><a href="/image/''' + url_pas(file_all_name) + '''">LINK</a></td></tr>
+                    <tr><td>VOLUME</td><td>''' + file_size + '''KB</td></tr>
+                </table>
+                <h2>CONTENT</h2>
+            '''
+
+            menu += [['delete/doc_file/' + url_pas(name), load_lang('file_delete')]]
+        else:
+            file_data = ''
             
     if num != '0':
         curs.execute(db_change("select title from history where title = ? and id = ? and hide = 'O'"), [name, num])

+ 9 - 6
route/view_xref.py

@@ -1,6 +1,6 @@
 from .tool.func import *
 
-def view_xref_2(conn, name):
+def view_xref_2(conn, name, xref_type = '1'):
     curs = conn.cursor()
 
     if acl_check(name, 'render') == 1:
@@ -9,18 +9,21 @@ def view_xref_2(conn, name):
     num = int(number_check(flask.request.args.get('num', '1')))
     sql_num = (num * 50 - 50) if num * 50 > 0 else 0
     
-    xref_type = flask.request.args.get('change', '1')
     if xref_type == '1':
-        div = '<a href="?change=2">(' + load_lang('link_in_this') + ')</a><hr class="main_hr">'
+        div = '<a href="/xref/this/' + url_pas(name) + '">(' + load_lang('link_in_this') + ')</a><hr class="main_hr">'
+        
+        data_sub = '(' + load_lang('backlink') + ')'
     else:
-        div = '<a href="?change=1">(' + load_lang('normal') + ')</a><hr class="main_hr">'
+        div = '<a href="/xref/' + url_pas(name) + '">(' + load_lang('normal') + ')</a><hr class="main_hr">'
+        
+        data_sub = '(' + load_lang('link_in_this') + ')'
 
     div += '<ul class="inside_ul">'
 
     sql_insert = ['link', 'title'] if xref_type == '1' else ['title', 'link']
     curs.execute(db_change("" + \
         "select distinct " + sql_insert[0] + ", type from back " + \
-        "where " + sql_insert[1] + " = ? and not type = 'cat' and not type = 'no' and not type = 'nothing'" + \
+        "where " + sql_insert[1] + " = ? and not type = 'no' and not type = 'nothing'" + \
         "order by type asc, title asc limit ?, 50" + \
     ""), [
         name,
@@ -44,7 +47,7 @@ def view_xref_2(conn, name):
     div += '</ul>' + next_fix('/xref/' + url_pas(name) + '?change=' + xref_type + '&num=', num, data_list)
 
     return easy_minify(flask.render_template(skin_check(),
-        imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('backlink') + ')', 0])],
+        imp = [name, wiki_set(), wiki_custom(), wiki_css([data_sub, 0])],
         data = div,
         menu = [['w/' + url_pas(name), load_lang('return')], ['backlink_reset/' + url_pas(name), load_lang('reset_backlink')]]
     ))

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.5.0-dev (stable1) (beta10) (dev10)",
+        "r_ver" : "v3.5.0-dev (stable1) (beta10) (dev11)",
         "c_ver" : "3500101",
         "s_ver" : "3500110"
     }