فهرست منبع

파일 업로드 수정

2DU 8 سال پیش
والد
کامیت
2e922dc608
2فایلهای تغییر یافته به همراه13 افزوده شده و 3 حذف شده
  1. 10 3
      app.py
  2. 3 0
      func.py

+ 10 - 3
app.py

@@ -394,7 +394,7 @@ def edit_set(num = 0):
 
             return(html_minify(template('index', 
                 imp = ['robots.txt', wiki_set(conn, 1), custom(conn), other2([0, 0])],
-                data =  '<a href="/robots.txt">상태 보기</a><hr> \
+                data =  '<a href="/robots.txt">(보기)</a><hr> \
                         <form method="post"> \
                             <textarea rows="25" name="content">' + html.escape(data) + '</textarea><hr> \
                             <button class="btn btn-primary" type="submit">저장</button> \
@@ -3093,7 +3093,12 @@ def upload():
         return(re_error(conn, '/ban'))
     
     if(request.method == 'POST'):
-        data = request.files.f_data
+        if(captcha_post(request.forms.get('g-recaptcha-response'), conn) == 1):
+            return(re_error(conn, '/error/13'))
+        else:
+            captcha_post('', conn, 0)
+
+        data = request.files.get('f_data')
         if(not data):
             return(re_error(conn, '/error/9'))
 
@@ -3102,7 +3107,7 @@ def upload():
         
         value = os.path.splitext(data.filename)[1]
         if(not value):
-            return(re_error(conn, '/error/16'))
+            return(re_error(conn, '/error/22'))
 
         if(not value in ['.jpeg', '.jpg', '.gif', '.png', '.webp', '.JPEG', '.JPG', '.GIF', '.PNG', '.WEBP']):
             return(re_error(conn, '/error/14'))
@@ -3140,12 +3145,14 @@ def upload():
         
         return(redirect('/w/파일:' + name))            
     else:
+        captcha = captcha_get(conn)
         return(html_minify(template('index', 
             imp = ['파일 올리기', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data =  '<form method="post" enctype="multipart/form-data" accept-charset="utf8"> \
                         <input type="file" name="f_data"><hr> \
                         <input placeholder="파일 이름" name="f_name" type="text"><hr> \
                         <input placeholder="라이선스" name="f_lice" type="text"><hr> \
+                        ' + captcha + ' \
                         <button class="btn btn-primary" type="submit">저장</button> \
                     </form>',
             menu = [['other', '기타']]

+ 3 - 0
func.py

@@ -500,6 +500,9 @@ def re_error(conn, data):
         elif(num == 21):
             title = '편집 오류'
             data = '편집 필터에 의해 검열 되었습니다.'
+        elif(num == 22):
+            title = '파일 올리기 오류'
+            data = '파일을 읽을 수 없습니다. 파일명이 한글이면 영문으로 바꿔서 올려주세요.'
         else:
             title = '정체 불명의 오류'
             data = '???'