Procházet zdrojové kódy

밴 만 구현 및 버그 수정

2DU před 9 roky
rodič
revize
212f079616
2 změnil soubory, kde provedl 22 přidání a 3 odebrání
  1. 21 2
      app.py
  2. 1 1
      templates/index.html

+ 21 - 2
app.py

@@ -505,10 +505,29 @@ def logout():
     session.pop('DREAMER', None)
     return '<meta http-equiv="refresh" content="0;url=/w/' + parse.quote(data['frontpage']) + '" />'
 
-@app.route('/ban/<name>')
+@app.route('/ban/<name>', methods=['POST', 'GET'])
 def ban(name = None):
     if(request.method == 'POST'):
-        return render_template('index.html', title = '권한 오류', logo = data['name'], data = '비 로그인 상태 입니다.')
+        if(session.get('Now') == True):
+            ip = getip(request)
+            curs.execute("select * from user where id = '" + pymysql.escape_string(ip) + "'")
+            rows = curs.fetchall()
+            if(rows):
+                if(rows[0]['acl'] == 'owner' or 'admin'):
+                    curs.execute("select * from ban where block = '" + pymysql.escape_string(name) + "'")
+                    row = curs.fetchall()
+                    if(row):
+                        curs.execute("delete from ban where block = '" + pymysql.escape_string(name) + "'")
+                    else:
+                        curs.execute("insert into ban (block, end, why, band) value ('" + pymysql.escape_string(name) + "', '" + pymysql.escape_string(request.form["end"]) + "', '" + pymysql.escape_string(request.form["why"]) + "', '')")
+                    conn.commit()
+                    return '<meta http-equiv="refresh" content="0;url=/w/' + parse.quote(data['frontpage']) + '" />'
+                else:
+                    return render_template('index.html', title = '권한 오류', logo = data['name'], data = '권한이 모자랍니다.')
+            else:
+                return render_template('index.html', title = '권한 오류', logo = data['name'], data = '계정이 없습니다.')
+        else:
+            return render_template('index.html', title = '권한 오류', logo = data['name'], data = '비 로그인 상태 입니다.')
     else:
         if(session.get('Now') == True):
             ip = getip(request)

+ 1 - 1
templates/index.html

@@ -283,8 +283,8 @@
 			<h1 class="title">{{title}}</h1>
 			<h2 class="title"><span style="margin-left:5px"></span>(차단)</h2>
 			<form id="usrform" method="POST" action="/ban/{{page}}">
-				<input class="form-control" name="end" style="width: 100%">
 				{% if now == '차단' %}
+				<input class="form-control" name="end" style="width: 100%">
 				<br>
 				<br>
 				<span>아무것도 안 적으면 무기한 차단 입니다.</span>