|
@@ -1,9 +1,10 @@
|
|
|
from .tool.func import *
|
|
from .tool.func import *
|
|
|
|
|
|
|
|
from .api_bbs_w_post import api_bbs_w_post
|
|
from .api_bbs_w_post import api_bbs_w_post
|
|
|
|
|
+from .api_bbs_w_comment_one import api_bbs_w_comment_one
|
|
|
from .edit import edit_editor
|
|
from .edit import edit_editor
|
|
|
|
|
|
|
|
-def bbs_w_edit(bbs_num = '', post_num = '', do_type = ''):
|
|
|
|
|
|
|
+def bbs_w_edit(bbs_num = '', post_num = '', comment_num = '', do_type = ''):
|
|
|
with get_db_connect() as conn:
|
|
with get_db_connect() as conn:
|
|
|
curs = conn.cursor()
|
|
curs = conn.cursor()
|
|
|
|
|
|
|
@@ -16,14 +17,20 @@ def bbs_w_edit(bbs_num = '', post_num = '', do_type = ''):
|
|
|
if not curs.fetchall():
|
|
if not curs.fetchall():
|
|
|
return redirect('/bbs/main')
|
|
return redirect('/bbs/main')
|
|
|
|
|
|
|
|
- if post_num != '':
|
|
|
|
|
- curs.execute(db_change('select set_data from bbs_data where set_name = "user_id" and set_id = ? and set_code = ?'), [bbs_num, post_num])
|
|
|
|
|
- db_data = curs.fetchall()
|
|
|
|
|
- if not db_data:
|
|
|
|
|
- return redirect('/bbs/main')
|
|
|
|
|
|
|
+ if comment_num != '':
|
|
|
|
|
+ temp_dict = json.loads(api_bbs_w_comment_one(bbs_num_str + '-' + post_num_str + '-' + comment_num).data)
|
|
|
|
|
+ if 'comment_user_id' in temp_dict:
|
|
|
|
|
+ if not temp_dict['comment_user_id'] == ip and admin_check() != 1:
|
|
|
|
|
+ return re_error('/ban')
|
|
|
else:
|
|
else:
|
|
|
- if not db_data[0][0] == ip and admin_check() != 1:
|
|
|
|
|
|
|
+ return redirect('/bbs/main')
|
|
|
|
|
+ elif post_num != '':
|
|
|
|
|
+ temp_dict = json.loads(api_bbs_w_post(bbs_num_str + '-' + post_num_str).data)
|
|
|
|
|
+ if 'user_id' in temp_dict:
|
|
|
|
|
+ if not temp_dict['user_id'] == ip and admin_check() != 1:
|
|
|
return re_error('/ban')
|
|
return re_error('/ban')
|
|
|
|
|
+ else:
|
|
|
|
|
+ return redirect('/bbs/main')
|
|
|
|
|
|
|
|
if acl_check(bbs_num_str, 'bbs_edit') == 1:
|
|
if acl_check(bbs_num_str, 'bbs_edit') == 1:
|
|
|
return redirect('/bbs/set/' + bbs_num_str)
|
|
return redirect('/bbs/set/' + bbs_num_str)
|
|
@@ -52,7 +59,17 @@ def bbs_w_edit(bbs_num = '', post_num = '', do_type = ''):
|
|
|
|
|
|
|
|
date = get_time()
|
|
date = get_time()
|
|
|
|
|
|
|
|
- if post_num == '':
|
|
|
|
|
|
|
+ if comment_num != '':
|
|
|
|
|
+ sub_code = (bbs_num_str + '-' + post_num_str + '-' + comment_num).split('-')
|
|
|
|
|
+ sub_code_last = ''
|
|
|
|
|
+ if len(sub_code) > 2:
|
|
|
|
|
+ sub_code_last = sub_code[len(sub_code) - 1]
|
|
|
|
|
+ del sub_code[len(sub_code) - 1]
|
|
|
|
|
+
|
|
|
|
|
+ sub_code = '-'.join(sub_code)
|
|
|
|
|
+
|
|
|
|
|
+ curs.execute(db_change("update bbs_data set set_data = ? where set_name = 'comment' and set_code = ? and set_id = ?"), [data, sub_code_last, sub_code])
|
|
|
|
|
+ elif post_num == '':
|
|
|
curs.execute(db_change("insert into bbs_data (set_name, set_code, set_id, set_data) values ('title', ?, ?, ?)"), [id_data, bbs_num_str, title])
|
|
curs.execute(db_change("insert into bbs_data (set_name, set_code, set_id, set_data) values ('title', ?, ?, ?)"), [id_data, bbs_num_str, title])
|
|
|
curs.execute(db_change("insert into bbs_data (set_name, set_code, set_id, set_data) values ('data', ?, ?, ?)"), [id_data, bbs_num_str, data])
|
|
curs.execute(db_change("insert into bbs_data (set_name, set_code, set_id, set_data) values ('data', ?, ?, ?)"), [id_data, bbs_num_str, data])
|
|
|
curs.execute(db_change("insert into bbs_data (set_name, set_code, set_id, set_data) values ('date', ?, ?, ?)"), [id_data, bbs_num_str, date])
|
|
curs.execute(db_change("insert into bbs_data (set_name, set_code, set_id, set_data) values ('date', ?, ?, ?)"), [id_data, bbs_num_str, date])
|
|
@@ -62,8 +79,13 @@ def bbs_w_edit(bbs_num = '', post_num = '', do_type = ''):
|
|
|
curs.execute(db_change("update bbs_data set set_data = ? where set_name = 'data' and set_code = ? and set_id = ?"), [data, id_data, bbs_num_str])
|
|
curs.execute(db_change("update bbs_data set set_data = ? where set_name = 'data' and set_code = ? and set_id = ?"), [data, id_data, bbs_num_str])
|
|
|
curs.execute(db_change("update bbs_data set set_data = ? where set_name = 'date' and set_code = ? and set_id = ?"), [date, id_data, bbs_num_str])
|
|
curs.execute(db_change("update bbs_data set set_data = ? where set_name = 'date' and set_code = ? and set_id = ?"), [date, id_data, bbs_num_str])
|
|
|
|
|
|
|
|
- return redirect('/bbs/w/' + bbs_num_str + '/' + id_data)
|
|
|
|
|
|
|
+ if comment_num != '':
|
|
|
|
|
+ return redirect('/bbs/w/' + bbs_num_str + '/' + id_data + '#' + url_pas(comment_num))
|
|
|
|
|
+ else:
|
|
|
|
|
+ return redirect('/bbs/w/' + bbs_num_str + '/' + id_data)
|
|
|
else:
|
|
else:
|
|
|
|
|
+ option_display = ''
|
|
|
|
|
+
|
|
|
d_list = ['' for _ in range(0, len(i_list))]
|
|
d_list = ['' for _ in range(0, len(i_list))]
|
|
|
if do_type == 'preview':
|
|
if do_type == 'preview':
|
|
|
title = flask.request.form.get('title', '')
|
|
title = flask.request.form.get('title', '')
|
|
@@ -77,15 +99,18 @@ def bbs_w_edit(bbs_num = '', post_num = '', do_type = ''):
|
|
|
for for_a in range(0, len(i_list)):
|
|
for for_a in range(0, len(i_list)):
|
|
|
d_list[for_a] = flask.request.form.get(i_list[for_a], 'normal')
|
|
d_list[for_a] = flask.request.form.get(i_list[for_a], 'normal')
|
|
|
else:
|
|
else:
|
|
|
- if post_num == '':
|
|
|
|
|
|
|
+ if comment_num != '':
|
|
|
|
|
+ temp_dict = json.loads(api_bbs_w_comment_one(bbs_num_str + '-' + post_num_str + '-' + comment_num).data)
|
|
|
|
|
+
|
|
|
|
|
+ title = ''
|
|
|
|
|
+ data = temp_dict['comment']
|
|
|
|
|
+ data_preview = ''
|
|
|
|
|
+ option_display = 'display: none;'
|
|
|
|
|
+ elif post_num == '':
|
|
|
title = ''
|
|
title = ''
|
|
|
data = ''
|
|
data = ''
|
|
|
data_preview = ''
|
|
data_preview = ''
|
|
|
else:
|
|
else:
|
|
|
- curs.execute(db_change('select set_name, set_data, set_code from bbs_data where set_id = ? and set_code = ?'), [bbs_num, post_num])
|
|
|
|
|
- db_data = curs.fetchall()
|
|
|
|
|
- db_data = list(db_data) if db_data else []
|
|
|
|
|
-
|
|
|
|
|
temp_dict = json.loads(api_bbs_w_post(bbs_num_str + '-' + post_num_str).data)
|
|
temp_dict = json.loads(api_bbs_w_post(bbs_num_str + '-' + post_num_str).data)
|
|
|
|
|
|
|
|
title = temp_dict['title']
|
|
title = temp_dict['title']
|
|
@@ -103,7 +128,10 @@ def bbs_w_edit(bbs_num = '', post_num = '', do_type = ''):
|
|
|
|
|
|
|
|
acl_div[for_a] += '<option value="' + data_list + '" ' + check + '>' + (data_list if data_list != '' else 'normal') + '</option>'
|
|
acl_div[for_a] += '<option value="' + data_list + '" ' + check + '>' + (data_list if data_list != '' else 'normal') + '</option>'
|
|
|
|
|
|
|
|
- if post_num == '':
|
|
|
|
|
|
|
+ if comment_num != '':
|
|
|
|
|
+ form_action = 'formaction="/bbs/edit/' + bbs_num_str + '/' + post_num_str + '/' + url_pas(comment_num) + '"'
|
|
|
|
|
+ form_action_preview = 'formaction="/bbs/edit/preview/' + bbs_num_str + '/' + post_num_str + '/' + url_pas(comment_num) + '"'
|
|
|
|
|
+ elif post_num == '':
|
|
|
form_action = 'formaction="/bbs/edit/' + bbs_num_str + '"'
|
|
form_action = 'formaction="/bbs/edit/' + bbs_num_str + '"'
|
|
|
form_action_preview = 'formaction="/bbs/edit/preview/' + bbs_num_str + '"'
|
|
form_action_preview = 'formaction="/bbs/edit/preview/' + bbs_num_str + '"'
|
|
|
else:
|
|
else:
|
|
@@ -115,7 +143,9 @@ def bbs_w_edit(bbs_num = '', post_num = '', do_type = ''):
|
|
|
if editor_top_text != '':
|
|
if editor_top_text != '':
|
|
|
editor_top_text += '<hr class="main_hr">'
|
|
editor_top_text += '<hr class="main_hr">'
|
|
|
|
|
|
|
|
- if post_num == '':
|
|
|
|
|
|
|
+ if comment_num != '':
|
|
|
|
|
+ bbs_title = load_lang('bbs_comment_edit')
|
|
|
|
|
+ elif post_num == '':
|
|
|
bbs_title = load_lang('post_add')
|
|
bbs_title = load_lang('post_add')
|
|
|
else:
|
|
else:
|
|
|
bbs_title = load_lang('post_edit')
|
|
bbs_title = load_lang('post_edit')
|
|
@@ -124,8 +154,8 @@ def bbs_w_edit(bbs_num = '', post_num = '', do_type = ''):
|
|
|
imp = [bbs_title, wiki_set(), wiki_custom(), wiki_css([0, 0])],
|
|
imp = [bbs_title, wiki_set(), wiki_custom(), wiki_css([0, 0])],
|
|
|
data = editor_top_text + '''
|
|
data = editor_top_text + '''
|
|
|
<form method="post">
|
|
<form method="post">
|
|
|
- <input placeholder="''' + load_lang('title') + '''" name="title" value="''' + html.escape(title) + '''">
|
|
|
|
|
- <hr class="main_hr">
|
|
|
|
|
|
|
+ <input style="''' + option_display + '''" placeholder="''' + load_lang('title') + '''" name="title" value="''' + html.escape(title) + '''">
|
|
|
|
|
+ <hr style="''' + option_display + '''" class="main_hr">
|
|
|
|
|
|
|
|
''' + edit_editor(curs, ip, data, 'bbs') + '''
|
|
''' + edit_editor(curs, ip, data, 'bbs') + '''
|
|
|
<hr class="main_hr">
|
|
<hr class="main_hr">
|
|
@@ -138,19 +168,21 @@ def bbs_w_edit(bbs_num = '', post_num = '', do_type = ''):
|
|
|
<hr class="main_hr">
|
|
<hr class="main_hr">
|
|
|
<div id="opennamu_preview_area">''' + data_preview + '''</div>
|
|
<div id="opennamu_preview_area">''' + data_preview + '''</div>
|
|
|
|
|
|
|
|
- ''' + render_simple_set('''
|
|
|
|
|
- <hr class="main_hr">
|
|
|
|
|
- <a href="/acl/TEST#exp">(''' + load_lang('reference') + ''')</a>
|
|
|
|
|
- <h2>''' + load_lang('acl') + '''</h2>
|
|
|
|
|
- <h3>''' + load_lang('post_view_acl') + '''</h3>
|
|
|
|
|
- <select name="post_view_acl">''' + acl_div[0] + '''</select>
|
|
|
|
|
-
|
|
|
|
|
- <h4>''' + load_lang('post_comment_acl') + '''</h4>
|
|
|
|
|
- <select name="post_comment_acl">''' + acl_div[1] + '''</select>
|
|
|
|
|
-
|
|
|
|
|
- <h2>''' + load_lang('markup') + '''</h2>
|
|
|
|
|
- ''' + load_lang('not_working') + '''
|
|
|
|
|
- ''') + '''
|
|
|
|
|
|
|
+ <div style="''' + option_display + '''">
|
|
|
|
|
+ ''' + render_simple_set('''
|
|
|
|
|
+ <hr class="main_hr">
|
|
|
|
|
+ <a href="/acl/TEST#exp">(''' + load_lang('reference') + ''')</a>
|
|
|
|
|
+ <h2>''' + load_lang('acl') + '''</h2>
|
|
|
|
|
+ <h3>''' + load_lang('post_view_acl') + '''</h3>
|
|
|
|
|
+ <select name="post_view_acl">''' + acl_div[0] + '''</select>
|
|
|
|
|
+
|
|
|
|
|
+ <h4>''' + load_lang('post_comment_acl') + '''</h4>
|
|
|
|
|
+ <select name="post_comment_acl">''' + acl_div[1] + '''</select>
|
|
|
|
|
+
|
|
|
|
|
+ <h2>''' + load_lang('markup') + '''</h2>
|
|
|
|
|
+ ''' + load_lang('not_working') + '''
|
|
|
|
|
+ ''') + '''
|
|
|
|
|
+ </div>
|
|
|
</form>
|
|
</form>
|
|
|
''',
|
|
''',
|
|
|
menu = [['bbs/w/' + bbs_num_str, load_lang('return')]]
|
|
menu = [['bbs/w/' + bbs_num_str, load_lang('return')]]
|