Quellcode durchsuchen

잠재적 버그 수정

잉여개발기 (SPDV) vor 2 Jahren
Ursprung
Commit
4eda8c22f7
4 geänderte Dateien mit 29 neuen und 31 gelöschten Zeilen
  1. 27 1
      app.py
  2. 1 20
      route/tool/func.py
  3. 1 1
      version.json
  4. 0 9
      views/main_css/js/route/wiki_access_password.js

+ 27 - 1
app.py

@@ -347,7 +347,33 @@ def auto_do_something(data_db_set):
 auto_do_something(data_db_set)
 
 print('Now running... http://localhost:' + server_set['port'])
-    
+
+@app.before_request
+def before_request_func():
+    with class_temp_db() as m_conn:
+        m_curs = m_conn.cursor()
+        
+        m_curs.execute('select data from temp where name = "wiki_access_password"')
+        db_data = m_curs.fetchall()
+        if db_data:
+            access_password = db_data[0][0]
+            input_password = flask.request.cookies.get('opennamu_wiki_access', ' ')
+            if url_pas(access_password) != input_password:
+                with get_db_connect() as conn:
+                    return '''
+                        <script>
+                            "use strict";
+                            function opennamu_do_wiki_access() {
+                                let password = document.getElementById('wiki_access').value;
+                                document.cookie = 'opennamu_wiki_access=' + encodeURIComponent(password) + '; path=/;';
+                                history.go(0);
+                            }
+                        </script>
+                        <h2>''' + get_lang(conn, 'error_password_require_for_wiki_access') + '''</h2>
+                        <input type="password" id="wiki_access">
+                        <input type="submit" onclick="opennamu_do_wiki_access();">
+                    '''
+
 # Init-custom
 if os.path.exists('custom.py'):
     from custom import custom_run

+ 1 - 20
route/tool/func.py

@@ -1095,26 +1095,7 @@ def pw_check(conn, data, data2, type_d = 'no', id_d = ''):
         
 # Func-skin
 def easy_minify(conn, data, tool = None):
-    # without_DB
-    with class_temp_db() as m_conn:
-        m_curs = m_conn.cursor()
-        
-        m_curs.execute('select data from temp where name = "wiki_access_password"')
-        db_data = m_curs.fetchall()
-        if db_data:
-            access_password = db_data[0][0]
-            input_password = flask.request.cookies.get('opennamu_wiki_access', ' ')
-            if url_pas(access_password) == input_password:
-                return data
-                
-            return '''
-                <script defer src="/views/main_css/js/route/wiki_access_password.js''' + cache_v() + '''"></script>
-                <h2>''' + get_lang(conn, 'error_password_require_for_wiki_access') + '''</h2>
-                <input type="password" id="wiki_access">
-                <input type="submit" onclick="opennamu_do_wiki_access();">
-            '''
-        else:
-            return data
+    return data
 
 def get_lang(conn, data, safe = 0):
     with class_temp_db() as m_conn:

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.5.0-v147",
+        "r_ver" : "v3.5.0-v148",
         "c_ver" : "20240513",
         "s_ver" : "20240426"
     }

+ 0 - 9
views/main_css/js/route/wiki_access_password.js

@@ -1,9 +0,0 @@
-"use strict";
-
-function opennamu_do_wiki_access() {
-    let password = document.getElementById('wiki_access').value;
-    
-    document.cookie = 'opennamu_wiki_access=' + encodeURIComponent(password) + '; path=/;';
-    
-    history.go(0);
-}