|
@@ -82,9 +82,7 @@ if sys.version_info < (3, 6):
|
|
|
global_lang = {}
|
|
global_lang = {}
|
|
|
global_wiki_set = {}
|
|
global_wiki_set = {}
|
|
|
|
|
|
|
|
-global_db_set = ''
|
|
|
|
|
-
|
|
|
|
|
-data_css_ver = '114'
|
|
|
|
|
|
|
+data_css_ver = '106'
|
|
|
data_css = ''
|
|
data_css = ''
|
|
|
|
|
|
|
|
conn = ''
|
|
conn = ''
|
|
@@ -102,13 +100,75 @@ def load_conn(data):
|
|
|
load_conn2(data)
|
|
load_conn2(data)
|
|
|
|
|
|
|
|
# Func-init
|
|
# Func-init
|
|
|
-def get_conn(db_set = ''):
|
|
|
|
|
- global global_db_set
|
|
|
|
|
- if db_set != '':
|
|
|
|
|
- global_db_set = db_set
|
|
|
|
|
- else:
|
|
|
|
|
- db_set = global_db_set
|
|
|
|
|
|
|
+class server_init:
|
|
|
|
|
+ def __init__(self):
|
|
|
|
|
+ self.env_dict = {
|
|
|
|
|
+ 'host' : os.getenv('NAMU_HOST'),
|
|
|
|
|
+ 'port' : os.getenv('NAMU_PORT'),
|
|
|
|
|
+ 'language' : os.getenv('NAMU_LANG'),
|
|
|
|
|
+ 'markup' : os.getenv('NAMU_MARKUP'),
|
|
|
|
|
+ 'encode' : os.getenv('NAMU_ENCRYPT')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ self.server_set_var = {
|
|
|
|
|
+ 'host' : {
|
|
|
|
|
+ 'display' : 'Host',
|
|
|
|
|
+ 'require' : 'conv',
|
|
|
|
|
+ 'default' : '0.0.0.0'
|
|
|
|
|
+ }, 'port' : {
|
|
|
|
|
+ 'display' : 'Port',
|
|
|
|
|
+ 'require' : 'conv',
|
|
|
|
|
+ 'default' : '3000'
|
|
|
|
|
+ }, 'language' : {
|
|
|
|
|
+ 'display' : 'Language',
|
|
|
|
|
+ 'require' : 'select',
|
|
|
|
|
+ 'default' : 'ko-KR',
|
|
|
|
|
+ 'list' : ['ko-KR', 'en-US']
|
|
|
|
|
+ }, 'markup' : {
|
|
|
|
|
+ 'display' : 'Markup',
|
|
|
|
|
+ 'require' : 'select',
|
|
|
|
|
+ 'default' : 'namumark',
|
|
|
|
|
+ 'list' : ['namumark', 'custom', 'raw']
|
|
|
|
|
+ }, 'encode' : {
|
|
|
|
|
+ 'display' : 'Encryption method',
|
|
|
|
|
+ 'require' : 'select',
|
|
|
|
|
+ 'default' : 'sha3',
|
|
|
|
|
+ 'list' : ['sha3', 'sha256']
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ def server_init(self):
|
|
|
|
|
+ return self.server_set_var
|
|
|
|
|
|
|
|
|
|
+ def init(self, key):
|
|
|
|
|
+ if self.env_dict[key] != None:
|
|
|
|
|
+ return self.env_dict[key]
|
|
|
|
|
+ else:
|
|
|
|
|
+ while 1:
|
|
|
|
|
+ if self.server_set_var[key]['require'] == 'select':
|
|
|
|
|
+ list_ = '[' + ', '.join(self.server_set_var[key]['list']) + ']'
|
|
|
|
|
+ else:
|
|
|
|
|
+ list_ = ''
|
|
|
|
|
+
|
|
|
|
|
+ print('{} ({}) {} : '.format(
|
|
|
|
|
+ self.server_set_var[key]['display'],
|
|
|
|
|
+ self.server_set_var[key]['default'],
|
|
|
|
|
+ list_
|
|
|
|
|
+ ), end = '')
|
|
|
|
|
+
|
|
|
|
|
+ server_set_val = input()
|
|
|
|
|
+ if server_set_val:
|
|
|
|
|
+ if self.server_set_var[key]['require'] == 'select':
|
|
|
|
|
+ if server_set_val not in self.server_set_var[key]['list']:
|
|
|
|
|
+ pass
|
|
|
|
|
+ else:
|
|
|
|
|
+ return server_set_val
|
|
|
|
|
+ else:
|
|
|
|
|
+ return server_set_val
|
|
|
|
|
+ else:
|
|
|
|
|
+ return self.server_set_var[key]['default']
|
|
|
|
|
+
|
|
|
|
|
+def get_conn(db_set):
|
|
|
if db_set['type'] == 'sqlite':
|
|
if db_set['type'] == 'sqlite':
|
|
|
conn = sqlite3.connect(db_set['name'] + '.db')
|
|
conn = sqlite3.connect(db_set['name'] + '.db')
|
|
|
curs = conn.cursor()
|
|
curs = conn.cursor()
|
|
@@ -132,8 +192,6 @@ def get_conn(db_set = ''):
|
|
|
|
|
|
|
|
conn.select_db(db_set['name'])
|
|
conn.select_db(db_set['name'])
|
|
|
|
|
|
|
|
- load_conn(conn)
|
|
|
|
|
-
|
|
|
|
|
return conn
|
|
return conn
|
|
|
|
|
|
|
|
def update(ver_num, set_data):
|
|
def update(ver_num, set_data):
|
|
@@ -369,14 +427,14 @@ def set_init():
|
|
|
if not curs.fetchall():
|
|
if not curs.fetchall():
|
|
|
for i in ['naver.com', 'gmail.com', 'daum.net', 'kakao.com']:
|
|
for i in ['naver.com', 'gmail.com', 'daum.net', 'kakao.com']:
|
|
|
curs.execute(db_change(
|
|
curs.execute(db_change(
|
|
|
- "insert into html_filter (html, kind, plus, plus_t) values (?, 'email', '', '')"
|
|
|
|
|
|
|
+ "insert into html_filter (html, kind) values (?, 'email')"
|
|
|
), [i])
|
|
), [i])
|
|
|
|
|
|
|
|
curs.execute(db_change("select html from html_filter where kind = 'extension'"))
|
|
curs.execute(db_change("select html from html_filter where kind = 'extension'"))
|
|
|
if not curs.fetchall():
|
|
if not curs.fetchall():
|
|
|
for i in ['jpg', 'jpeg', 'png', 'gif', 'webp']:
|
|
for i in ['jpg', 'jpeg', 'png', 'gif', 'webp']:
|
|
|
curs.execute(db_change(
|
|
curs.execute(db_change(
|
|
|
- "insert into html_filter (html, kind, plus, plus_t) values (?, 'extension', '', '')"
|
|
|
|
|
|
|
+ "insert into html_filter (html, kind) values (?, 'extension')"
|
|
|
), [i])
|
|
), [i])
|
|
|
|
|
|
|
|
curs.execute(db_change(
|
|
curs.execute(db_change(
|
|
@@ -396,7 +454,8 @@ def set_init():
|
|
|
curs.execute(db_change('select data from other where name = "key"'))
|
|
curs.execute(db_change('select data from other where name = "key"'))
|
|
|
rep_data = curs.fetchall()
|
|
rep_data = curs.fetchall()
|
|
|
if not rep_data:
|
|
if not rep_data:
|
|
|
- curs.execute(db_change('insert into other (name, data) values ("key", ?)'), [load_random_key()])
|
|
|
|
|
|
|
+ rep_key = ''.join(random.choice("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") for i in range(64))
|
|
|
|
|
+ curs.execute(db_change('insert into other (name, data) values ("key", ?)'), [rep_key])
|
|
|
|
|
|
|
|
curs.execute(db_change('select data from other where name = "count_all_title"'))
|
|
curs.execute(db_change('select data from other where name = "count_all_title"'))
|
|
|
if not curs.fetchall():
|
|
if not curs.fetchall():
|
|
@@ -442,7 +501,7 @@ def load_random_key(long = 64):
|
|
|
) for i in range(long)
|
|
) for i in range(long)
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-def edit_button(editor_display = '0'):
|
|
|
|
|
|
|
+def edit_button():
|
|
|
insert_list = []
|
|
insert_list = []
|
|
|
|
|
|
|
|
curs.execute(db_change("select html, plus from html_filter where kind = 'edit_top'"))
|
|
curs.execute(db_change("select html, plus from html_filter where kind = 'edit_top'"))
|
|
@@ -454,7 +513,7 @@ def edit_button(editor_display = '0'):
|
|
|
for insert_data in insert_list:
|
|
for insert_data in insert_list:
|
|
|
data += '' + \
|
|
data += '' + \
|
|
|
'<a href="' + \
|
|
'<a href="' + \
|
|
|
- 'javascript:do_insert_data(\'textarea_edit_view\', \'' + insert_data[0] + '\', ' + editor_display + ')' + \
|
|
|
|
|
|
|
+ 'javascript:do_insert_data(\'content\', \'' + insert_data[0] + '\')' + \
|
|
|
'">(' + insert_data[1] + ')</a> ' + \
|
|
'">(' + insert_data[1] + ')</a> ' + \
|
|
|
''
|
|
''
|
|
|
|
|
|
|
@@ -504,10 +563,15 @@ def next_fix(link, num, page, end = 50):
|
|
|
|
|
|
|
|
return list_data
|
|
return list_data
|
|
|
|
|
|
|
|
-def leng_check(A, B):
|
|
|
|
|
- # B -> new
|
|
|
|
|
- # A -> old
|
|
|
|
|
- return '0' if A == B else (('-' + str(A - B)) if A > B else ('+' + str(B - A)))
|
|
|
|
|
|
|
+def leng_check(first, second):
|
|
|
|
|
+ if first < second:
|
|
|
|
|
+ all_plus = '+' + str(second - first)
|
|
|
|
|
+ elif second < first:
|
|
|
|
|
+ all_plus = '-' + str(first - second)
|
|
|
|
|
+ else:
|
|
|
|
|
+ all_plus = '0'
|
|
|
|
|
+
|
|
|
|
|
+ return all_plus
|
|
|
|
|
|
|
|
def number_check(data):
|
|
def number_check(data):
|
|
|
try:
|
|
try:
|
|
@@ -674,13 +738,18 @@ def wiki_css(data):
|
|
|
return data
|
|
return data
|
|
|
|
|
|
|
|
def cut_100(data):
|
|
def cut_100(data):
|
|
|
- data = re.search(r'<pre style="display: none;" id="render_content_load">([^<>]+)<\/pre>', data)
|
|
|
|
|
- if data:
|
|
|
|
|
- data = data.group(1)
|
|
|
|
|
- if len(data) > 100:
|
|
|
|
|
- return data[0:100] + '...'
|
|
|
|
|
- else:
|
|
|
|
|
- return data[0:len(data)]
|
|
|
|
|
|
|
+ if re.search(r'^\/w\/', flask.request.path):
|
|
|
|
|
+ data = re.sub(r'<script>((\n*(((?!<\/script>).)+)\n*)+)<\/script>', '', data)
|
|
|
|
|
+ data = re.sub(r'<hr class="main_hr">((\n*((.+)\n*))+)$', '', data)
|
|
|
|
|
+ data = re.sub(r'<div id="cate_all">((\n*((.+)\n*))+)$', '', data)
|
|
|
|
|
+
|
|
|
|
|
+ data = re.sub(r'<(((?!>).)*)>', ' ', data)
|
|
|
|
|
+ data = re.sub(r'\n', ' ', data)
|
|
|
|
|
+ data = re.sub(r'^ +', '', data)
|
|
|
|
|
+ data = re.sub(r' +$', '', data)
|
|
|
|
|
+ data = re.sub(r' {2,}', ' ', data)
|
|
|
|
|
+
|
|
|
|
|
+ return data[0:100] + '...'
|
|
|
else:
|
|
else:
|
|
|
return ''
|
|
return ''
|
|
|
|
|
|
|
@@ -732,7 +801,7 @@ def wiki_set(num = 1):
|
|
|
|
|
|
|
|
return data_list
|
|
return data_list
|
|
|
|
|
|
|
|
-def wiki_custom():
|
|
|
|
|
|
|
+def wiki_custom():
|
|
|
ip = ip_check()
|
|
ip = ip_check()
|
|
|
if ip_or_user(ip) == 0:
|
|
if ip_or_user(ip) == 0:
|
|
|
user_icon = 1
|
|
user_icon = 1
|
|
@@ -775,12 +844,6 @@ def wiki_custom():
|
|
|
|
|
|
|
|
curs.execute(db_change("select title from rd where title = ? and stop = ''"), ['user:' + ip])
|
|
curs.execute(db_change("select title from rd where title = ? and stop = ''"), ['user:' + ip])
|
|
|
user_topic = '1' if curs.fetchall() else '0'
|
|
user_topic = '1' if curs.fetchall() else '0'
|
|
|
-
|
|
|
|
|
- split_path = flask.request.path.split('/')
|
|
|
|
|
- if len(split_path) > 1:
|
|
|
|
|
- split_path = split_path[1]
|
|
|
|
|
- else:
|
|
|
|
|
- split_path = 0
|
|
|
|
|
|
|
|
|
|
return [
|
|
return [
|
|
|
'',
|
|
'',
|
|
@@ -794,8 +857,7 @@ def wiki_custom():
|
|
|
user_notice,
|
|
user_notice,
|
|
|
user_acl_list,
|
|
user_acl_list,
|
|
|
ip,
|
|
ip,
|
|
|
- user_topic,
|
|
|
|
|
- split_path
|
|
|
|
|
|
|
+ user_topic
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
def load_skin(data = '', set_n = 0, default = 0):
|
|
def load_skin(data = '', set_n = 0, default = 0):
|
|
@@ -812,7 +874,7 @@ def load_skin(data = '', set_n = 0, default = 0):
|
|
|
|
|
|
|
|
skin_list_get = os.listdir('views')
|
|
skin_list_get = os.listdir('views')
|
|
|
if default == 1:
|
|
if default == 1:
|
|
|
- skin_list_get = ['default'] + skin_list_get
|
|
|
|
|
|
|
+ skin_list_get += ['default']
|
|
|
|
|
|
|
|
for skin_data in skin_list_get:
|
|
for skin_data in skin_list_get:
|
|
|
if skin_data != 'default':
|
|
if skin_data != 'default':
|
|
@@ -1313,7 +1375,7 @@ def ip_pas(raw_ip, type_d = 0):
|
|
|
ip = '<a href="/w/' + url_pas('user:' + raw_ip) + '">' + raw_ip + '</a>'
|
|
ip = '<a href="/w/' + url_pas('user:' + raw_ip) + '">' + raw_ip + '</a>'
|
|
|
|
|
|
|
|
if change_ip == 0:
|
|
if change_ip == 0:
|
|
|
- ip += ' <a href="/user/' + url_pas(raw_ip) + '">(' + load_lang('tool') + ')</a>'
|
|
|
|
|
|
|
+ ip += ' <a href="/tool/' + url_pas(raw_ip) + '">(' + load_lang('tool') + ')</a>'
|
|
|
|
|
|
|
|
end_ip[raw_ip] = ip
|
|
end_ip[raw_ip] = ip
|
|
|
|
|
|