2
0
Эх сурвалжийг харах

아이피 사용자 토론 추가

Surplus_Up (2DU) 7 жил өмнө
parent
commit
de7bf2d734

+ 0 - 3
route/alarm.py

@@ -2,9 +2,6 @@ from .tool.func import *
 
 def alarm_2(conn):
     curs = conn.cursor()
-    
-    if custom()[2] == 0:
-        return redirect('/login')    
 
     data = '<ul>'    
     

+ 5 - 4
route/tool/func.py

@@ -617,8 +617,9 @@ def custom():
     else:
         user_head = ''
 
-    if 'state' in flask.session and flask.session['state'] == 1:
-        curs.execute('select name from alarm where name = ? limit 1', [ip_check()])
+    ip = ip_check()
+    if ip_or_user(ip) == 0:
+        curs.execute('select name from alarm where name = ? limit 1', [ip])
         if curs.fetchall():
             user_icon = 2
         else:
@@ -627,7 +628,7 @@ def custom():
         user_icon = 0
 
     if user_icon != 0:
-        curs.execute('select data from user_set where name = "email" and id = ?', [ip_check()])
+        curs.execute('select data from user_set where name = "email" and id = ?', [ip])
         data = curs.fetchall()
         if data:
             email = data[0][0]
@@ -637,7 +638,7 @@ def custom():
         email = ''
 
     if user_icon != 0:
-        user_name = ip_check()
+        user_name = ip
     else:
         user_name = load_lang('user')
 

+ 23 - 1
route/topic.py

@@ -32,7 +32,29 @@ def topic_2(conn, name, sub):
 
         match = re.search('^user:([^/]+)', name)
         if match:
-            curs.execute('insert into alarm (name, data, date) values (?, ?, ?)', [match.groups()[0], ip + ' - <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '">' + load_lang('user_discussion', 1) + '</a>', today])
+            y_check = 0
+            if ip_or_user(match.groups()[0]) == 1:
+                curs.execute("select ip from history where ip = ? limit 1", [match.groups()[0]])
+                u_data = curs.fetchall()
+                if u_data:
+                    y_check = 1
+                else:
+                    curs.execute("select ip from topic where ip = ? limit 1", [match.groups()[0]])
+                    u_data = curs.fetchall()
+                    if u_data:
+                        y_check = 1
+            else:
+                curs.execute("select id from user where id = ?", [match.groups()[0]])
+                u_data = curs.fetchall()
+                if u_data:
+                    y_check = 1
+
+            if y_check == 1:
+                curs.execute('insert into alarm (name, data, date) values (?, ?, ?)', [
+                    match.groups()[0], 
+                    ip + ' - <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '">' + load_lang('user_discussion', 1) + '</a>', 
+                    today
+                ])
         
         cate_re = re.compile('\[\[((?:분류|category):(?:(?:(?!\]\]).)*))\]\]', re.I)
         data = cate_re.sub('[br]', flask.request.form.get('content', 'Test'))

+ 41 - 42
route/user_info.py

@@ -37,31 +37,30 @@ def user_info_2(conn):
 
             if block_data[0][2] == 'O':
                 acl += ' (' + load_lang('band_blocked') + ')'
-            
+
+    curs.execute('select name from alarm where name = ? limit 1', [ip_check()])
+    if curs.fetchall():
+        plus2 = '<li><a href="/alarm">' + load_lang('alarm') + ' (O)</a></li>'
+    else:
+        plus2 = '<li><a href="/alarm">' + load_lang('alarm') + '</a></li>'
+
     if custom()[2] != 0:
         ip_user = '<a href="/w/user:' + ip + '">' + ip + '</a>'
         
-        plus =  '''
-                <li><a href="/logout">''' + load_lang('logout') + '''</a></li>
-                <li><a href="/change">''' + load_lang('user_setting') + '''</a></li>
-                '''
-        
-        curs.execute('select name from alarm where name = ? limit 1', [ip_check()])
-        if curs.fetchall():
-            plus2 = '<li><a href="/alarm">' + load_lang('alarm') + ' (O)</a></li>'
-        else:
-            plus2 = '<li><a href="/alarm">' + load_lang('alarm') + '</a></li>'
+        plus = '''
+            <li><a href="/logout">''' + load_lang('logout') + '''</a></li>
+            <li><a href="/change">''' + load_lang('user_setting') + '''</a></li>
+        '''
 
         plus2 += '<li><a href="/watch_list">' + load_lang('watchlist') + '</a></li>'
         plus3 = '<li><a href="/acl/user:' + url_pas(ip) + '">' + load_lang('user_document_acl') + '</a></li>'
     else:
         ip_user = ip
         
-        plus =  '''
-                <li><a href="/login">''' + load_lang('login') + '''</a></li>
-                <li><a href="/register">''' + load_lang('register') + '''</a></li>
-                '''
-        plus2 = ''
+        plus = '''
+            <li><a href="/login">''' + load_lang('login') + '''</a></li>
+            <li><a href="/register">''' + load_lang('register') + '''</a></li>
+        '''
         plus3 = ''
 
         curs.execute("select data from other where name = 'email_have'")
@@ -71,31 +70,31 @@ def user_info_2(conn):
 
     return easy_minify(flask.render_template(skin_check(), 
         imp = [load_lang('user') + ' ' + load_lang('tool'), wiki_set(), custom(), other2([0, 0])],
-        data =  '''
-                <h2>''' + load_lang('state') + '''</h2>
-                <ul>
-                    <li>''' + ip_user + ''' <a href="/record/''' + url_pas(ip) + '''">(''' + load_lang('record') + ''')</a></li>
-                    <li>''' + load_lang('state') + ''' : ''' + acl + '''</li>
-                </ul>
-                <br>
-                <h2>''' + load_lang('login') + '''</h2>
-                <ul>
-                    ''' + plus + '''
-                </ul>
-                <br>
-                <h2>''' + load_lang('tool') + '''</h2>
-                <ul>
-                    ''' + plus3 + '''
-                    <li><a href="/custom_head">''' + load_lang('user_head') + '''</a></li>
-                </ul>
-                <br>
-                <h2>''' + load_lang('other') + '''</h2>
-                <ul>
-                ''' + plus2 + '''
-                <li>
-                    <a href="/count">''' + load_lang('count') + '''</a>
-                </li>
-                </ul>
-                ''',
+        data = '''
+            <h2>''' + load_lang('state') + '''</h2>
+            <ul>
+                <li>''' + ip_user + ''' <a href="/record/''' + url_pas(ip) + '''">(''' + load_lang('record') + ''')</a></li>
+                <li>''' + load_lang('state') + ''' : ''' + acl + '''</li>
+            </ul>
+            <br>
+            <h2>''' + load_lang('login') + '''</h2>
+            <ul>
+                ''' + plus + '''
+            </ul>
+            <br>
+            <h2>''' + load_lang('tool') + '''</h2>
+            <ul>
+                ''' + plus3 + '''
+                <li><a href="/custom_head">''' + load_lang('user_head') + '''</a></li>
+            </ul>
+            <br>
+            <h2>''' + load_lang('other') + '''</h2>
+            <ul>
+            ''' + plus2 + '''
+            <li>
+                <a href="/count">''' + load_lang('count') + '''</a>
+            </li>
+            </ul>
+        ''',
         menu = 0
     ))

+ 1 - 0
route/user_tool.py

@@ -7,6 +7,7 @@ def user_tool_2(conn, name):
         <h2>''' + load_lang('tool') + '''</h2>
         <ul>
             <li><a href="/record/''' + url_pas(name) + '''">''' + load_lang('record') + '''</a></li>
+            <li><a href="/topic/user:''' + url_pas(name) + '''">''' + load_lang('user_discussion') + '''</a></li>
         </ul>
     '''