瀏覽代碼

id 글자수 제한 추가

2DU 9 年之前
父節點
當前提交
8fc084d2b8
共有 2 個文件被更改,包括 22 次插入13 次删除
  1. 16 13
      app.py
  2. 6 0
      templates/index.html

+ 16 - 13
app.py

@@ -568,12 +568,12 @@ def upload():
             if(file and allowed_file(file.filename)):
                 filename = secure_filename(file.filename)
                 if(os.path.exists(os.path.join('image', filename))):
-                    return render_template('index.html', logo = data['name'], title = '업로드', data = '<a href="/upload">동일한 이름 파일 있음</a>')
+                    return render_template('index.html', logo = data['name'], title = '업로드', data = '동일한 이름의 파일이 있습니다.')
                 else:
                     file.save(os.path.join('image', filename))
-                    return render_template('index.html', logo = data['name'], title = '업로드', data = '<a href="/upload">완료 됨</a>')
+                    return render_template('index.html', logo = data['name'], title = '업로드', data = '완료 되었습니다.')
             else:
-                return render_template('index.html', logo = data['name'], title = '업로드', data = '<a href="/upload">jpg gif jpeg png만 가능 합니다.</a>')
+                return render_template('index.html', logo = data['name'], title = '업로드', data = 'jpg gif jpeg png만 가능 합니다.')
     else:
         ip = getip(request)
         ban = getban(ip)
@@ -1313,18 +1313,21 @@ def register():
             if(m):
                 return render_template('index.html', title = '회원가입 오류', logo = data['name'], data = '아이디에는 한글과 알파벳 공백만 허용 됩니다.')
             else:
-                curs.execute("select * from user where id = '" + pymysql.escape_string(request.form["id"]) + "'")
-                rows = curs.fetchall()
-                if(rows):
-                    return render_template('index.html', title = '회원가입 오류', logo = data['name'], data = '동일한 아이디의 유저가 있습니다.')
+                if(len(request.form["id"]) > 20):
+                    return render_template('index.html', title = '회원가입 오류', logo = data['name'], data = '아이디는 20글자보다 짧아야 합니다.')
                 else:
-                    hashed = bcrypt.hashpw(bytes(request.form["pw"], 'utf-8'), bcrypt.gensalt())
-                    if(request.form["id"] == data['owner']):
-                        curs.execute("insert into user (id, pw, acl) value ('" + pymysql.escape_string(request.form["id"]) + "', '" + pymysql.escape_string(hashed.decode()) + "', 'owner')")
+                    curs.execute("select * from user where id = '" + pymysql.escape_string(request.form["id"]) + "'")
+                    rows = curs.fetchall()
+                    if(rows):
+                        return render_template('index.html', title = '회원가입 오류', logo = data['name'], data = '동일한 아이디의 유저가 있습니다.')
                     else:
-                        curs.execute("insert into user (id, pw, acl) value ('" + pymysql.escape_string(request.form["id"]) + "', '" + pymysql.escape_string(hashed.decode()) + "', 'user')")
-                    conn.commit()
-                    return '<meta http-equiv="refresh" content="0;url=/login" />'
+                        hashed = bcrypt.hashpw(bytes(request.form["pw"], 'utf-8'), bcrypt.gensalt())
+                        if(request.form["id"] == data['owner']):
+                            curs.execute("insert into user (id, pw, acl) value ('" + pymysql.escape_string(request.form["id"]) + "', '" + pymysql.escape_string(hashed.decode()) + "', 'owner')")
+                        else:
+                            curs.execute("insert into user (id, pw, acl) value ('" + pymysql.escape_string(request.form["id"]) + "', '" + pymysql.escape_string(hashed.decode()) + "', 'user')")
+                        conn.commit()
+                        return '<meta http-equiv="refresh" content="0;url=/login" />'
     else:
         ip = getip(request)
         ban = getban(ip)

+ 6 - 0
templates/index.html

@@ -487,6 +487,12 @@
 			{{rows}}
 			{% endautoescape %}
             {% else %}
+            <div id="tool">
+				<nav class="menu">
+					<a class="menu-item selected" href="#" onclick="return false">{{title}}</a>
+					<a class="menu-item" href="javascript:history.back(-1);">뒤로가기</a>
+				</nav>
+			</div>
 			<h1 class="title">{{title}}</h1>
 			<div>
 				{% autoescape false %}