|
@@ -119,103 +119,32 @@ def api_topic_thread_pre_render(curs, data, num, ip, topic_num = '', name = '',
|
|
|
|
|
|
|
|
return data
|
|
return data
|
|
|
|
|
|
|
|
-def api_topic(topic_num = 1, tool = 'normal', num = '', render = ''):
|
|
|
|
|
|
|
+def api_topic(db_set, topic_num = 1, tool = 'normal', s_num = '', e_num = ''):
|
|
|
with get_db_connect() as conn:
|
|
with get_db_connect() as conn:
|
|
|
- curs = conn.cursor()
|
|
|
|
|
-
|
|
|
|
|
topic_num = str(topic_num)
|
|
topic_num = str(topic_num)
|
|
|
|
|
|
|
|
|
|
+ other_set = {}
|
|
|
|
|
+ other_set["topic_num"] = topic_num
|
|
|
|
|
+ other_set["tool"] = tool
|
|
|
|
|
+ other_set["s_num"] = str(s_num)
|
|
|
|
|
+ other_set["e_num"] = str(e_num)
|
|
|
|
|
+ other_set["ip"] = ip_check()
|
|
|
|
|
+ other_set = json.dumps(other_set)
|
|
|
|
|
+
|
|
|
if acl_check('', 'topic_view', topic_num) != 1:
|
|
if acl_check('', 'topic_view', topic_num) != 1:
|
|
|
- if tool == 'normal':
|
|
|
|
|
- if num != '':
|
|
|
|
|
- curs.execute(db_change("select id, data, date, ip, block, top from topic where code = ? and id + 0 = ? + 0 order by id + 0 asc"), [topic_num, num])
|
|
|
|
|
|
|
+ if platform.system() == 'Linux':
|
|
|
|
|
+ if platform.machine() in ["AMD64", "x86_64"]:
|
|
|
|
|
+ data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.amd64.bin"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
|
|
|
else:
|
|
else:
|
|
|
- curs.execute(db_change("select id, data, date, ip, block, top from topic where code = ? order by id + 0 asc"), [topic_num])
|
|
|
|
|
- elif tool == 'top':
|
|
|
|
|
- curs.execute(db_change("select id, data, date, ip, block, top from topic where code = ? and top = 'O' order by id + 0 asc"), [topic_num])
|
|
|
|
|
|
|
+ data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.arm64.bin"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
|
|
|
else:
|
|
else:
|
|
|
- # tool == 'length'
|
|
|
|
|
- curs.execute(db_change("select id from topic where code = ? order by id + 0 desc limit 1"), [topic_num])
|
|
|
|
|
- db_data = curs.fetchall()
|
|
|
|
|
- if db_data:
|
|
|
|
|
- return flask.jsonify({ 'length' : db_data[0][0] })
|
|
|
|
|
- else:
|
|
|
|
|
- return flask.jsonify({})
|
|
|
|
|
-
|
|
|
|
|
- data = curs.fetchall()
|
|
|
|
|
- if data:
|
|
|
|
|
- data_a = {}
|
|
|
|
|
- admin = admin_check(3)
|
|
|
|
|
-
|
|
|
|
|
- curs.execute(db_change("select ip from topic where code = ? order by id + 0 asc limit 1"), [topic_num])
|
|
|
|
|
- data_f = curs.fetchall()
|
|
|
|
|
- data_f = data_f[0][0] if data_f else ''
|
|
|
|
|
- data_a['data_main'] = {
|
|
|
|
|
- "ip_first" : ip_pas(data_f, 1),
|
|
|
|
|
- "admin" : str(admin)
|
|
|
|
|
- }
|
|
|
|
|
- data_a['data'] = []
|
|
|
|
|
-
|
|
|
|
|
- ip_a = ip_pas([i[3] for i in data])
|
|
|
|
|
- ip_a_2 = ip_pas([i[3] for i in data], 1)
|
|
|
|
|
- for i in data:
|
|
|
|
|
- data_v = i[1] if i[4] != 'O' or admin == 1 else ''
|
|
|
|
|
- if data_v != '':
|
|
|
|
|
- data_v = render_set(
|
|
|
|
|
- doc_data = data_v,
|
|
|
|
|
- data_type = 'api_thread',
|
|
|
|
|
- data_in = 'topic_' + topic_num + '_' + i[0]
|
|
|
|
|
- )
|
|
|
|
|
- else:
|
|
|
|
|
- data_v = ['', '']
|
|
|
|
|
-
|
|
|
|
|
- data_a['data'] += [{
|
|
|
|
|
- "id" : i[0],
|
|
|
|
|
-
|
|
|
|
|
- "data" : data_v,
|
|
|
|
|
- "date" : i[2],
|
|
|
|
|
- "ip" : ip_a_2[i[3]],
|
|
|
|
|
- "blind" : i[4],
|
|
|
|
|
-
|
|
|
|
|
- "ip_pas" : ip_a[i[3]],
|
|
|
|
|
- "data_pas" : data_v
|
|
|
|
|
- }]
|
|
|
|
|
-
|
|
|
|
|
- if render == '':
|
|
|
|
|
- return flask.jsonify(data_a)
|
|
|
|
|
|
|
+ if platform.machine() in ["AMD64", "x86_64"]:
|
|
|
|
|
+ data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.amd64.exe"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
|
|
|
else:
|
|
else:
|
|
|
- data_r = ''
|
|
|
|
|
- if 'data' in data_a:
|
|
|
|
|
- for for_a in data_a['data']:
|
|
|
|
|
- if tool == 'top':
|
|
|
|
|
- color = 'red'
|
|
|
|
|
- elif for_a["blind"] == '1':
|
|
|
|
|
- color = 'blue'
|
|
|
|
|
- elif data_a['data_main']["ip_first"] == for_a["ip"]:
|
|
|
|
|
- color = 'green'
|
|
|
|
|
- else:
|
|
|
|
|
- color = 'default'
|
|
|
|
|
-
|
|
|
|
|
- data_r += api_topic_thread_make(
|
|
|
|
|
- for_a["ip_pas"],
|
|
|
|
|
- '<a href="/thread/' + topic_num + '/comment/' + for_a["id"] + '/tool">(' + load_lang('tool') + ')</a> ' + for_a["date"],
|
|
|
|
|
- for_a["data_pas"][0] + '<script>' + for_a["data_pas"][1] + '</script>',
|
|
|
|
|
- for_a["id"],
|
|
|
|
|
- color = color,
|
|
|
|
|
- blind = for_a["blind"],
|
|
|
|
|
- add_style = '',
|
|
|
|
|
- admin_check = admin if tool == 'normal' else 0,
|
|
|
|
|
- topic_num = topic_num
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- if admin == 1 and tool == 'normal':
|
|
|
|
|
- data_r += '''
|
|
|
|
|
- <a href="javascript:opennamu_thread_blind();">(''' + load_lang('hide') + ''' | ''' + load_lang('hide_release') + ''')</a>
|
|
|
|
|
- <hr class="main_hr">
|
|
|
|
|
- '''
|
|
|
|
|
-
|
|
|
|
|
- return flask.jsonify({ "data" : data_r })
|
|
|
|
|
- else:
|
|
|
|
|
- return flask.jsonify({})
|
|
|
|
|
|
|
+ data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.arm64.exe"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
|
|
|
|
|
+
|
|
|
|
|
+ data = data.decode('utf8')
|
|
|
|
|
+
|
|
|
|
|
+ return flask.Response(response = data, status = 200, mimetype = 'application/json')
|
|
|
else:
|
|
else:
|
|
|
return flask.jsonify({})
|
|
return flask.jsonify({})
|