2du 4 سال پیش
والد
کامیت
019c4f9b42
7فایلهای تغییر یافته به همراه102 افزوده شده و 57 حذف شده
  1. 1 1
      route/api_sitemap.py
  2. 14 19
      route/edit.py
  3. 2 16
      route/edit_delete.py
  4. 3 3
      route/edit_move.py
  5. 25 11
      route/main_func_setting_main.py
  6. 55 5
      route/tool/func.py
  7. 2 2
      version.json

+ 1 - 1
route/api_sitemap.py

@@ -9,7 +9,7 @@ def api_sitemap():
                 '<?xml version="1.0" encoding="UTF-8"?>\n' + \
                 '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n' + \
             ''
-            domain = load_domain()
+            domain = load_domain('full')
 
             curs.execute(db_change("select title from data"))
             all_data = curs.fetchall()

+ 14 - 19
route/edit.py

@@ -30,14 +30,21 @@ def edit(name = 'Test', name_load = 0, section = 0):
     
             today = get_time()
             content = flask.request.form.get('content', '').replace('\r\n', '\n')
+            send = flask.request.form.get('send', '')
             
             if edit_filter_do(content) == 1:
                 return re_error('/error/21')
-                
+            
+            curs.execute(db_change('select data from other where name = "edit_bottom_compulsion"'))
+            db_data = curs.fetchall()
+            if db_data and db_data[0][0] != '' and send == '':
+                return re_error('/error/37')
+
             curs.execute(db_change('select data from other where name = "copyright_checkbox_text"'))
-            copyright_checkbox_text_d = curs.fetchall()
-            if copyright_checkbox_text_d and copyright_checkbox_text_d[0][0] != '' and flask.request.form.get('copyright_agreement', '') != 'yes':
-                return re_error('/error/29')
+            db_data = curs.fetchall()
+            if db_data and db_data[0][0] != '':
+                if flask.request.form.get('copyright_agreement', '') != 'yes':
+                    return re_error('/error/29')
             
             curs.execute(db_change("select data from data where title = ?"), [name])
             old = curs.fetchall()
@@ -64,7 +71,7 @@ def edit(name = 'Test', name_load = 0, section = 0):
                 content,
                 today,
                 ip,
-                flask.request.form.get('send', ''),
+                send,
                 leng
             )
             
@@ -117,20 +124,8 @@ def edit(name = 'Test', name_load = 0, section = 0):
                 '<hr class="main_hr">' + \
             ''
     
-            curs.execute(db_change('select data from other where name = "edit_bottom_text"'))
-            sql_d = curs.fetchall()
-            b_text = ('<hr class="main_hr">' + sql_d[0][0]) if sql_d and sql_d[0][0] != '' else ''
-            
-            curs.execute(db_change('select data from other where name = "copyright_checkbox_text"'))
-            sql_d = curs.fetchall()
-            if sql_d and sql_d[0][0] != '':
-                cccb_text = '' + \
-                    '<hr class="main_hr">' + \
-                    '<input type="checkbox" name="copyright_agreement" value="yes"> ' + sql_d[0][0] + \
-                    '<hr class="main_hr">' + \
-                ''
-            else:
-                cccb_text = ''
+            b_text = get_edit_text_bottom()
+            cccb_text = get_edit_text_bottom_check()
     
             curs.execute(db_change('select data from other where name = "edit_help"'))
             sql_d = curs.fetchall()

+ 2 - 16
route/edit_delete.py

@@ -46,22 +46,8 @@ def edit_delete(name):
                 curs.execute(db_change("delete from data where title = ?"), [name])
                 conn.commit()
 
-            file_check = re.search(r'^file:(.+)\.(.+)$', name)
-            if file_check:
-                '''
-                file_check = file_check.groups()
-                file_directory = os.path.join(
-                    load_image_url(), 
-                    sha224_replace(file_check[0]) + '.' + file_check[1]
-                )
-                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)])
+            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)])
 
             return redirect('/w/' + url_pas(name))
         else:

+ 3 - 3
route/edit_move.py

@@ -162,15 +162,15 @@ def edit_move(name):
                     <form method="post">
                         ''' + ip_warning() + '''
                         <input placeholder="''' + load_lang('document_name') + '" value="' + name + '''" name="title" type="text">
-                        <hr class=\"main_hr\">
+                        <hr class="main_hr">
                         <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
-                        <hr class=\"main_hr\">
+                        <hr class="main_hr">
                         <select name="move_option">
                             <option value="normal"> ''' + load_lang('normal') + '''</option>
                             <option value="reverse"> ''' + load_lang('replace_move') + '''</option>
                             ''' + ('<option value="merge"> ' + load_lang('merge_move') + '</option>' if admin_check() == 1 else '') + '''
                         </select>
-                        <hr class=\"main_hr\">
+                        <hr class="main_hr">
                         ''' + captcha_get() + '''
                         <button type="submit">''' + load_lang('move') + '''</button>
                     </form>

+ 25 - 11
route/main_func_setting_main.py

@@ -27,7 +27,8 @@ def main_func_setting_main(db_set):
             23 : ['ua_get', ''],
             24 : ['enable_comment', ''],
             25 : ['enable_challenge', ''],
-            26 : ['edit_bottom_compulsion', '']
+            26 : ['edit_bottom_compulsion', ''],
+            27 : ['http_select', 'http']
         }
 
         if flask.request.method == 'POST':
@@ -54,13 +55,21 @@ def main_func_setting_main(db_set):
             else:
                 conn.commit()
 
-            acl_div = ['']
-            encode_data = ['sha256', 'sha3']
-            for acl_data in encode_data:
-                if acl_data == d_list[15]:
-                    acl_div[0] = '<option value="' + acl_data + '">' + acl_data + '</option>' + acl_div[0]
+            encode_select = ''
+            encode_select_data = ['sha256', 'sha3']
+            for encode_select_one in encode_select_data:
+                if encode_select_one == d_list[15]:
+                    encode_select = '<option value="' + encode_select_one + '">' + encode_select_one + '</option>' + encode_select
                 else:
-                    acl_div[0] += '<option value="' + acl_data + '">' + acl_data + '</option>'
+                    encode_select += '<option value="' + encode_select_one + '">' + encode_select_one + '</option>'
+                    
+            tls_select = ''
+            tls_select_data = ['http', 'https']
+            for tls_select_one in tls_select_data:
+                if tls_select_one == d_list[27]:
+                    tls_select = '<option value="' + tls_select_one + '">' + tls_select_one + '</option>' + tls_select
+                else:
+                    tls_select += '<option value="' + tls_select_one + '">' + tls_select_one + '</option>'
 
             check_box_div = ['', '', '', '', '', '', '', '']
             for i in range(0, len(check_box_div)):
@@ -110,9 +119,14 @@ def main_func_setting_main(db_set):
                         <input name="frontpage" value="''' + html.escape(d_list[2]) + '''">
                         <hr class="main_hr">
 
-                        <span>''' + load_lang('domain') + '''</span> (EX : http://2du.pythonanywhere.com/)
+                        <span>''' + load_lang('tls_method') + '''</span>
+                        <hr class="main_hr">
+                        <select name="http_select">''' + tls_select + '''</select>
+                        <hr class="main_hr">
+
+                        <span>''' + load_lang('domain') + '''</span> (EX : 2du.pythonanywhere.com)
                         <hr class="main_hr">
-                        <input name="''' + setting_list[22][0] + '''" value="''' + html.escape(d_list[22]) + '''">
+                        <input name="domain" value="''' + html.escape(d_list[22]) + '''">
                         <hr class="main_hr">
 
                         <span>''' + load_lang('wiki_host') + '''</span>
@@ -132,7 +146,7 @@ def main_func_setting_main(db_set):
 
                         <span>''' + load_lang('encryption_method') + '''</span>
                         <hr class="main_hr">
-                        <select name="encode">''' + acl_div[0] + '''</select>
+                        <select name="encode">''' + encode_select + '''</select>
 
                         <h3>1.1. ''' + load_lang('communication_set') + '''</h3>
                         <input type="checkbox" name="enable_comment" ''' + check_box_div[5] + '''> ''' + load_lang('enable_comment_function') + '''
@@ -192,7 +206,7 @@ def main_func_setting_main(db_set):
 
                         <span>''' + load_lang('slow_edit') + ' (' + load_lang('second') + ') (' + load_lang('off') + ''' : 0)</span>
                         <hr class="main_hr">
-                        <input name="''' + setting_list[19][0] + '''" value="''' + html.escape(d_list[19]) + '''">
+                        <input name="slow_edit" value="''' + html.escape(d_list[19]) + '''">
                         
                         <hr class="main_hr">
                         <input type="checkbox" name="edit_bottom_compulsion" ''' + check_box_div[7] + '''> ''' + load_lang('edit_bottom_compulsion') + '''

+ 55 - 5
route/tool/func.py

@@ -540,6 +540,24 @@ def update(ver_num, set_data):
         curs.execute(db_change(
             'delete from acl where title like "file:%" and data = "admin" and type like "decu%"'
         ))
+        
+    if ver_num < 3500106:
+        curs.execute(db_change("select data from other where name = 'domain'"))
+        db_data = curs.fetchall()
+        if db_data and db_data[0][0] != '':
+            db_data = db_data[0][0]
+            db_data = re.match(r'[^/]+\/\/([^/]+)', db_data)
+            if db_data:
+                db_data = db_data.group(1)
+                curs.execute(db_change(
+                    "update other set data = ? where name = 'domain'"
+                ), [
+                    db_data
+                ])
+            else:
+                curs.execute(db_change(
+                    "update other set data = '' where name = 'domain'"
+                ))
     
     conn.commit()
     
@@ -678,7 +696,7 @@ def check_int(data):
         return ''
     
 def redirect(data = '/'):
-    return flask.redirect(flask.request.host_url[:-1] + data)
+    return flask.redirect(load_domain('full') + data)
     
 def get_acl_list(type_d = 'normal'):
     if type_d == 'user':
@@ -696,12 +714,25 @@ def load_image_url():
     
     return image_where
 
-def load_domain():
+def load_domain(data_type = 'normal'):
     curs = conn.cursor()
+    
+    domain = ''
+    
+    if data_type == 'full':
+        curs.execute(db_change("select data from other where name = 'http_select'"))
+        db_data = curs.fetchall()
+        domain += db_data[0][0] if db_data and db_data[0][0] != '' else 'http'
+        domain += '://'
 
-    curs.execute(db_change("select data from other where name = 'domain'"))
-    domain = curs.fetchall()
-    domain = domain[0][0] if domain and domain[0][0] != '' else flask.request.host_url
+        curs.execute(db_change("select data from other where name = 'domain'"))
+        db_data = curs.fetchall()
+        domain += db_data[0][0] if db_data and db_data[0][0] != '' else flask.request.host
+        domain += '/'
+    else:
+        curs.execute(db_change("select data from other where name = 'domain'"))
+        db_data = curs.fetchall()
+        domain += db_data[0][0] if db_data and db_data[0][0] != '' else flask.request.host
 
     return domain
 
@@ -1627,6 +1658,25 @@ def ip_pas(raw_ip, type_data = 0):
         return end_ip
         
 # Func-edit
+def get_edit_text_bottom():
+    curs.execute(db_change('select data from other where name = "edit_bottom_text"'))
+    sql_d = curs.fetchall()
+    return ('<hr class="main_hr">' + sql_d[0][0]) if sql_d and sql_d[0][0] != '' else ''
+
+def get_edit_text_bottom_check():
+    cccb_text = ''
+
+    curs.execute(db_change('select data from other where name = "copyright_checkbox_text"'))
+    sql_d = curs.fetchall()
+    if sql_d and sql_d[0][0] != '':
+        cccb_text = '' + \
+            '<hr class="main_hr">' + \
+            '<input type="checkbox" name="copyright_agreement" value="yes"> ' + sql_d[0][0] + \
+            '<hr class="main_hr">' + \
+        ''
+        
+    return cccb_text
+
 def slow_edit_check():
     curs = conn.cursor()
 

+ 2 - 2
version.json

@@ -1,7 +1,7 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.5 (stable1) (beta1) (dev3)",
-        "c_ver" : "3500105",
+        "r_ver" : "v3.4.5 (stable1) (beta1) (dev4)",
+        "c_ver" : "3500106",
         "s_ver" : "3500110"
     }
 }