2DU 9 ani în urmă
părinte
comite
f594644e6a
2 a modificat fișierele cu 74 adăugiri și 2 ștergeri
  1. 59 1
      app.py
  2. 15 1
      templates/index.html

+ 59 - 1
app.py

@@ -242,8 +242,14 @@ def w(name = None):
     curs.execute("select * from data where title = '" + pymysql.escape_string(name) + "'")
     rows = curs.fetchall()
     if(rows):
+        if(rows[0]['acl'] == 'admin'):
+            acl = '(관리자)'
+        elif(rows[0]['acl'] == 'user'):
+            acl = '(유저)'
+        else:
+            acl = ''
         enddata = namumark(rows[0]['data'])
-        return render_template('index.html', title = name, logo = data['name'], page = parse.quote(name), data = enddata, license = data['license'], tn = 1)
+        return render_template('index.html', title = name, logo = data['name'], page = parse.quote(name), data = enddata, license = data['license'], tn = 1, acl = acl)
     else:
         return render_template('index.html', title = name, logo = data['name'], page = parse.quote(name), data = '<br>문서 없음', license = data['license'], tn = 1)
 
@@ -679,6 +685,58 @@ def ban(name = None):
         else:
             return render_template('index.html', title = '권한 오류', logo = data['name'], data = '비 로그인 상태 입니다.')
 
+@app.route('/acl/<name>', methods=['POST', 'GET'])
+def acl(name = None):
+    if(request.method == 'POST'):
+        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 rows[0]['acl'] == 'admin'):
+                    curs.execute("select * from data where title = '" + pymysql.escape_string(name) + "'")
+                    row = curs.fetchall()
+                    if(row):
+                        if(request.form["select"] == 'admin'):
+                           curs.execute("update data set acl = 'admin' where title = '" + pymysql.escape_string(name) + "'")
+                        elif(request.form["select"] == 'user'):
+                            curs.execute("update data set acl = 'user' where title = '" + pymysql.escape_string(name) + "'")
+                        else:
+                            curs.execute("update data set acl = '' where title = '" + pymysql.escape_string(name) + "'")
+                        conn.commit()
+                    return '<meta http-equiv="refresh" content="0;url=/w/' + parse.quote(name) + '" />' 
+                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)
+            curs.execute("select * from user where id = '" + pymysql.escape_string(ip) + "'")
+            rows = curs.fetchall()
+            if(rows):
+                if(rows[0]['acl'] == 'owner' or rows[0]['acl'] == 'admin'):
+                    curs.execute("select * from data where title = '" + pymysql.escape_string(name) + "'")
+                    row = curs.fetchall()
+                    if(row):
+                        if(row[0]['acl'] == 'admin'):
+                            now = '관리자만'
+                        elif(row[0]['acl'] == 'user'):
+                            now = '유저 이상'
+                        else:
+                            now = '일반'
+                        return render_template('index.html', title = name, page = parse.quote(name), logo = data['name'], tn = 19, now = '현재 ACL 상태는 ' + now)
+                    else:
+                        return '<meta http-equiv="refresh" content="0;url=/w/' + parse.quote(name) + '" />' 
+                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 = '비 로그인 상태 입니다.')
+
 @app.route('/admin/<name>', methods=['POST', 'GET'])
 def admin(name = None):
     if(request.method == 'POST'):

+ 15 - 1
templates/index.html

@@ -57,7 +57,7 @@
 				</nav>
 			</div>
 			<h1 class="titlee">{{title}}</h1>
-			<h2 class="titlee"><span style="margin-left:5px"></span></h2>
+			<h2 class="titlee"><span style="margin-left:5px">{{acl}}</span></h2>
 			{% if redirect %}
 			{% autoescape false %}
 			<li>{{redirect}}</li>
@@ -375,6 +375,20 @@
 				{% endif %}
 				<button class="btn btn-primary" type="submit">{{now}}</button>
 			</form>
+			{% elif tn == 19 %}
+			<h1 class="title">{{title}}</h1>
+			<h2 class="title"><span style="margin-left:5px"></span>(ACL)</h2>
+			<p>{{now}}</p>
+			<form id="usrform" method="POST" action="/acl/{{page}}">
+				<select name="select">
+					<option value="admin" selected="selected">관리자만</option>
+					<option value="user">유저 이상</option>
+					<option value="normal">일반</option>
+				</select>
+				<br>
+				<br>
+				<button class="btn btn-primary" type="submit">ACL 변경</button>
+			</form>
 			{% else %}
 			<h1 class="title">{{title}}</h1>
 			<h2 class="title"><span style="margin-left:5px"></span></h2>