2DU преди 8 години
родител
ревизия
f90acb2a74
променени са 2 файла, в които са добавени 24 реда и са изтрити 23 реда
  1. 10 21
      app.py
  2. 14 2
      func.py

+ 10 - 21
app.py

@@ -2765,12 +2765,7 @@ def login():
         
         return(redirect('/user'))                            
     else:        
-        curs.execute('select data from other where name = "recaptcha"')
-        recaptcha = curs.fetchall()
-        if(recaptcha and recaptcha[0][0] != ''):
-            plus = recaptcha[0][0] + '<br>'
-        else:
-            plus = ''
+        captcha = captcha_get()
 
         return(
             html_minify(
@@ -2783,7 +2778,7 @@ def login():
                                 <input placeholder="비밀번호" name="pw" type="password"> \
                                 <br> \
                                 <br> \
-                                ' + plus + ' \
+                                ' + captcha + ' \
                                 <button class="btn btn-primary" type="submit">로그인</button> \
                                 <br> \
                                 <br> \
@@ -2962,25 +2957,20 @@ def register():
         
         return(redirect('/login'))
     else:        
-        p = ''
+        contract = ''
         curs.execute('select data from other where name = "contract"')
-        d = curs.fetchall()
-        if(d and d[0][0] != ''):
-            p = d[0][0] + '<br><br>'
-
-        curs.execute('select data from other where name = "recaptcha"')
-        recaptcha = curs.fetchall()
-        if(recaptcha and recaptcha[0][0] != ''):
-            plus = recaptcha[0][0] + '<br>'
-        else:
-            plus = ''
+        data = curs.fetchall()
+        if(data and data[0][0] != ''):
+            contract = data[0][0] + '<br><br>'
+
+        captcha = captcha_get()
 
         return(
             html_minify(
                 template('index',    
                     imp = ['회원가입', wiki_set(1), custom(), other2([0, 0])],
                     data = '<form method="post"> \
-                                ' + p + ' \
+                                ' + contract + ' \
                                 <input placeholder="아이디" name="id" type="text"> \
                                 <br> \
                                 <br> \
@@ -2990,7 +2980,7 @@ def register():
                                 <input placeholder="재 확인" name="pw2" type="password"> \
                                 <br> \
                                 <br> \
-                                ' + plus + ' \
+                                ' + captcha + ' \
                                 <button class="btn btn-primary" type="submit">가입</button> \
                                 <br> \
                                 <br> \
@@ -3044,7 +3034,6 @@ def user_ban(name = None):
 
             curs.execute("insert into ban (block, end, why, band) values (?, ?, ?, ?)", [name, end, request.forms.why, band_d])
 
-        print(request.forms.login_ok)
         if(request.forms.login_ok != ''):
             curs.execute("insert into ok_login (ip, sub) values (?, '')", [name])
 

+ 14 - 2
func.py

@@ -24,6 +24,18 @@ session_opts = {
 
 app = beaker.middleware.SessionMiddleware(app(), session_opts)
 
+def captcha_get():
+    session = request.environ.get('beaker.session')
+
+    plus = ''
+    if(re.search('\.|:', ip_check() and session.get('DREAMER') != 1):
+        curs.execute('select data from other where name = "recaptcha"')
+        recaptcha = curs.fetchall()
+        if(recaptcha and recaptcha[0][0] != ''):
+            plus += recaptcha[0][0] + '<br>'
+
+    return(plus)
+
 def get_time():
     now = time.localtime()
     date = "%04d-%02d-%02d %02d:%02d:%02d" % (now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec)
@@ -50,7 +62,7 @@ def ip_check():
     session = request.environ.get('beaker.session')
     try:
         if(session.get('Now') == 1):
-            ip = format(session['DREAMER'])
+            ip = session['DREAMER']
         else:
             if(request.environ.get('HTTP_X_FORWARDED_FOR')):
                 ip = request.environ.get('HTTP_X_FORWARDED_FOR')
@@ -210,7 +222,7 @@ def ip_pas(raw_ip):
 def custom():
     session = request.environ.get('beaker.session')
     try:
-        user_head = format(session['MyMaiToNight'])
+        user_head = session['MyMaiToNight']
     except:
         user_head = ''