func.py 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. import sys
  2. import platform
  3. import json
  4. import smtplib
  5. import zipfile
  6. import shutil
  7. import logging
  8. import random
  9. for i in range(0, 2):
  10. try:
  11. from diff_match_patch import diff_match_patch
  12. import werkzeug.routing
  13. import werkzeug.debug
  14. import flask
  15. import flask_reggie
  16. import tornado.ioloop
  17. import tornado.httpserver
  18. import tornado.wsgi
  19. import urllib.request
  20. import email.mime.text
  21. import email.utils
  22. import email.header
  23. import requests
  24. import pymysql
  25. import PIL
  26. if sys.version_info < (3, 6):
  27. import sha3
  28. except ImportError as e:
  29. if i == 0:
  30. print(e)
  31. print('----')
  32. if platform.system() == 'Linux' or platform.system() == 'Windows':
  33. sys_pip_ins = os.system(
  34. 'python' + ('3' if platform.system() != 'Windows' else '') + ' ' + \
  35. '-m pip install --user -r requirements.txt'
  36. )
  37. if sys_pip_ins == 0:
  38. print('----')
  39. try:
  40. os.execl(sys.executable, sys.executable, *sys.argv)
  41. except:
  42. try:
  43. os.execl(sys.executable, '"' + sys.executable + '"', *sys.argv)
  44. except:
  45. print('Error : restart failed')
  46. raise
  47. else:
  48. print('Error : library install failed')
  49. raise
  50. print('----')
  51. print(e)
  52. raise
  53. from .func_mark import *
  54. global_lang = {}
  55. data_css_ver = '80'
  56. data_css = ''
  57. conn = ''
  58. curs = ''
  59. def load_conn(data):
  60. global conn
  61. global curs
  62. conn = data
  63. curs = conn.cursor()
  64. load_conn2(data)
  65. def load_image_url():
  66. curs.execute(db_change('select data from other where name = "image_where"'))
  67. image_where = curs.fetchall()
  68. image_where = image_where[0][0] if image_where else 'data/images'
  69. return image_where
  70. def http_warring():
  71. return '''
  72. <div id="http_warring_text"></div>
  73. <script>
  74. if(window.location.protocol !== 'https:') {
  75. document.getElementById('http_warring_text').innerHTML = "''' + load_lang('http_warring') + '''";
  76. document.getElementById('http_warring_text').style.margin = "10px 0px 0px 0px";
  77. }
  78. </script>
  79. '''
  80. def send_email(who, title, data):
  81. try:
  82. curs.execute(db_change('' + \
  83. 'select name, data from other ' + \
  84. 'where name = "smtp_email" or name = "smtp_pass" or name = "smtp_server" or name = "smtp_port" or name = "smtp_security"' + \
  85. ''))
  86. rep_data = curs.fetchall()
  87. smtp_email = ''
  88. smtp_pass = ''
  89. smtp_server = ''
  90. smtp_security = ''
  91. smtp_port = ''
  92. smtp = ''
  93. for i in rep_data:
  94. if i[0] == 'smtp_email':
  95. smtp_email = i[1]
  96. elif i[0] == 'smtp_pass':
  97. smtp_pass = i[1]
  98. elif i[0] == 'smtp_server':
  99. smtp_server = i[1]
  100. elif i[0] == 'smtp_security':
  101. smtp_security = i[1]
  102. elif i[0] == 'smtp_port':
  103. smtp_port = i[1]
  104. smtp_port = int(smtp_port)
  105. if smtp_security == 'plain':
  106. smtp = smtplib.SMTP(smtp_server, smtp_port)
  107. elif smtp_security == 'starttls':
  108. smtp = smtplib.SMTP(smtp_server, smtp_port)
  109. smtp.starttls()
  110. else:
  111. # if smtp_security == 'tls':
  112. smtp = smtplib.SMTP_SSL(smtp_server, smtp_port)
  113. smtp.login(smtp_email, smtp_pass)
  114. domain = load_domain()
  115. wiki_name = wiki_set()[0]
  116. msg = email.mime.text.MIMEText(data)
  117. msg['Subject'] = title
  118. msg['From'] = 'openNAMU <noreply@' + domain + '>'
  119. msg['To'] = who
  120. smtp.sendmail('openNAMU@' + domain, who, msg.as_string())
  121. smtp.quit()
  122. return 1
  123. except Exception as e:
  124. print('----')
  125. print('Error : email send error')
  126. print(e)
  127. return 0
  128. def load_domain():
  129. curs.execute(db_change("select data from other where name = 'domain'"))
  130. domain = curs.fetchall()
  131. domain = domain[0][0] if domain and domain[0][0] != '' else flask.request.host_url
  132. return domain
  133. def load_random_key(long = 64):
  134. return ''.join(random.choice("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") for i in range(long))
  135. def easy_minify(data, tool = None):
  136. return data
  137. def render_set(doc_name = '', doc_data = '', data_type = 'view', data_in = '', doc_acl = ''):
  138. # data_type in ['view', 'raw', 'api_view', 'backlink']
  139. doc_acl = acl_check(doc_name, 'render') if doc_acl == '' else doc_acl
  140. doc_data = 0 if not doc_data else doc_data
  141. if doc_acl == 1:
  142. return 'HTTP Request 401.3'
  143. else:
  144. if data_type == 'raw':
  145. return doc_data
  146. else:
  147. if doc_data != 0:
  148. return render_do(doc_name, doc_data, data_type, data_in)
  149. else:
  150. return 'HTTP Request 404'
  151. def update(ver_num, set_data):
  152. print('----')
  153. # 업데이트 하위 호환 유지 함수
  154. if ver_num < 3160027:
  155. print('Add init set')
  156. set_init()
  157. if ver_num < 3170002:
  158. curs.execute(db_change("select html from html_filter where kind = 'extension'"))
  159. if not curs.fetchall():
  160. for i in ['jpg', 'jpeg', 'png', 'gif', 'webp']:
  161. curs.execute(db_change("insert into html_filter (html, kind) values (?, 'extension')"), [i])
  162. if ver_num < 3170400:
  163. curs.execute(db_change("select title, sub, code from topic where id = '1'"))
  164. for i in curs.fetchall():
  165. curs.execute(db_change("update topic set code = ? where title = ? and sub = ?"), [i[2], i[0], i[1]])
  166. curs.execute(db_change("update rd set code = ? where title = ? and sub = ?"), [i[2], i[0], i[1]])
  167. if ver_num < 3171800:
  168. curs.execute(db_change("select data from other where name = 'recaptcha'"))
  169. change_rec = curs.fetchall()
  170. if change_rec and change_rec[0][0] != '':
  171. new_rec = re.search(r'data-sitekey="([^"]+)"', change_rec[0][0])
  172. if new_rec:
  173. curs.execute(db_change("update other set data = ? where name = 'recaptcha'"), [new_rec.group(1)])
  174. else:
  175. curs.execute(db_change("update other set data = '' where name = 'recaptcha'"))
  176. curs.execute(db_change("update other set data = '' where name = 'sec_re'"))
  177. if ver_num < 3172800 and set_data['db_type'] == 'mysql':
  178. get_data_mysql = json.loads(open('data/mysql.json').read())
  179. with open('data/mysql.json', 'w') as f:
  180. f.write('{ "user" : "' + get_data_mysql['user'] + '", "password" : "' + get_data_mysql['password'] + '", "host" : "localhost" }')
  181. if ver_num < 3183603:
  182. curs.execute(db_change("select block from ban where band = 'O'"))
  183. for i in curs.fetchall():
  184. curs.execute(db_change("update ban set block = ?, band = 'regex' where block = ? and band = 'O'"), [
  185. '^' + i[0].replace('.', '\\.'),
  186. i[0]
  187. ])
  188. curs.execute(db_change("select block from rb where band = 'O'"))
  189. for i in curs.fetchall():
  190. curs.execute(db_change("update rb set block = ?, band = 'regex' where block = ? and band = 'O'"), [
  191. '^' + i[0].replace('.', '\\.'),
  192. i[0]
  193. ])
  194. if ver_num < 3190201:
  195. today_time = get_time()
  196. curs.execute(db_change("select block, end, why, band, login from ban"))
  197. for i in curs.fetchall():
  198. curs.execute(db_change("insert into rb (block, end, today, why, band, login, ongoing) values (?, ?, ?, ?, ?, ?, ?)"), [
  199. i[0],
  200. i[1],
  201. today_time,
  202. i[2],
  203. i[3],
  204. i[4],
  205. '1'
  206. ])
  207. if ver_num < 3191301:
  208. curs.execute(db_change('' + \
  209. 'select id, title, date from history ' + \
  210. 'where not title like "user:%" ' + \
  211. 'order by date desc ' + \
  212. 'limit 50' + \
  213. ''))
  214. data_list = curs.fetchall()
  215. for get_data in data_list:
  216. curs.execute(db_change("insert into rc (id, title, date, type) values (?, ?, ?, 'normal')"), [
  217. get_data[0],
  218. get_data[1],
  219. get_data[2]
  220. ])
  221. if ver_num < 3202400:
  222. curs.execute(db_change("select data from other where name = 'update'"))
  223. get_data = curs.fetchall()
  224. if get_data and get_data[0][0] == 'master':
  225. curs.execute(db_change("update other set data = 'beta' where name = 'update'"), [])
  226. if ver_num < 3202600:
  227. curs.execute(db_change("select name, regex, sub from filter"))
  228. for i in curs.fetchall():
  229. curs.execute(db_change("insert into html_filter (html, kind, plus, plus_t) values (?, 'regex_filter', ?, ?)"), [
  230. i[0],
  231. i[1],
  232. i[2]
  233. ])
  234. curs.execute(db_change("select title, link, icon from inter"))
  235. for i in curs.fetchall():
  236. curs.execute(db_change("insert into html_filter (html, kind, plus, plus_t) values (?, 'inter_wiki', ?, ?)"), [
  237. i[0],
  238. i[1],
  239. i[2]
  240. ])
  241. if ver_num < 3203400:
  242. curs.execute(db_change("select user, css from custom"))
  243. for i in curs.fetchall():
  244. curs.execute(db_change("insert into user_set (name, id, data) values ('custom_css', ?, ?)"), [
  245. re.sub(r' \(head\)$', '', i[0]),
  246. i[1]
  247. ])
  248. if ver_num < 3205500:
  249. curs.execute(db_change("select title, decu, dis, view, why from acl"))
  250. for i in curs.fetchall():
  251. curs.execute(db_change("insert into acl (title, data, type) values (?, ?, ?)"), [i[0], i[1], 'decu'])
  252. curs.execute(db_change("insert into acl (title, data, type) values (?, ?, ?)"), [i[0], i[2], 'dis'])
  253. curs.execute(db_change("insert into acl (title, data, type) values (?, ?, ?)"), [i[0], i[3], 'view'])
  254. curs.execute(db_change("insert into acl (title, data, type) values (?, ?, ?)"), [i[0], i[4], 'why'])
  255. # 캐시 초기화
  256. if ver_num < 3300101:
  257. curs.execute(db_change('delete from cache_data'))
  258. conn.commit()
  259. print('Update completed')
  260. def set_init():
  261. # 초기값 설정 함수
  262. curs.execute(db_change("select html from html_filter where kind = 'email'"))
  263. if not curs.fetchall():
  264. for i in ['naver.com', 'gmail.com', 'daum.net', 'kakao.com']:
  265. curs.execute(db_change("insert into html_filter (html, kind) values (?, 'email')"), [i])
  266. curs.execute(db_change("select html from html_filter where kind = 'extension'"))
  267. if not curs.fetchall():
  268. for i in ['jpg', 'jpeg', 'png', 'gif', 'webp']:
  269. curs.execute(db_change("insert into html_filter (html, kind) values (?, 'extension')"), [i])
  270. curs.execute(db_change('select data from other where name = "smtp_server" or name = "smtp_port" or name = "smtp_security"'))
  271. if not curs.fetchall():
  272. for i in [['smtp_server', 'smtp.gmail.com'], ['smtp_port', '587'], ['smtp_security', 'starttls']]:
  273. curs.execute(db_change("insert into other (name, data) values (?, ?)"), [i[0], i[1]])
  274. def pw_encode(data, type_d = ''):
  275. if type_d == '':
  276. curs.execute(db_change('select data from other where name = "encode"'))
  277. set_data = curs.fetchall()
  278. type_d = set_data[0][0]
  279. if type_d == 'sha256':
  280. return hashlib.sha256(bytes(data, 'utf-8')).hexdigest()
  281. else:
  282. if sys.version_info < (3, 6):
  283. return sha3.sha3_256(bytes(data, 'utf-8')).hexdigest()
  284. else:
  285. return hashlib.sha3_256(bytes(data, 'utf-8')).hexdigest()
  286. def pw_check(data, data2, type_d = 'no', id_d = ''):
  287. curs.execute(db_change('select data from other where name = "encode"'))
  288. db_data = curs.fetchall()
  289. if type_d != 'no':
  290. if type_d == '':
  291. set_data = 'sha3'
  292. else:
  293. set_data = type_d
  294. else:
  295. set_data = db_data[0][0]
  296. re_data = 1 if pw_encode(data, set_data) == data2 else 0
  297. if db_data[0][0] != set_data and re_data == 1 and id_d != '':
  298. curs.execute(db_change("update user set pw = ?, encode = ? where id = ?"), [pw_encode(data), db_data[0][0], id_d])
  299. return re_data
  300. def add_alarm(who, context):
  301. curs.execute(db_change('insert into alarm (name, data, date) values (?, ?, ?)'), [who, context, get_time()])
  302. def captcha_get():
  303. data = ''
  304. if ip_or_user() != 0:
  305. curs.execute(db_change('select data from other where name = "recaptcha"'))
  306. recaptcha = curs.fetchall()
  307. if recaptcha and recaptcha[0][0] != '':
  308. curs.execute(db_change('select data from other where name = "sec_re"'))
  309. sec_re = curs.fetchall()
  310. if sec_re and sec_re[0][0] != '':
  311. curs.execute(db_change('select data from other where name = "recaptcha_ver"'))
  312. rec_ver = curs.fetchall()
  313. if not rec_ver or rec_ver[0][0] == '':
  314. data += '' + \
  315. '<script src="https://www.google.com/recaptcha/api.js" async defer></script>' + \
  316. '<div class="g-recaptcha" data-sitekey="' + recaptcha[0][0] + '"></div>' + \
  317. '<hr class="main_hr">' + \
  318. ''
  319. else:
  320. data += '' + \
  321. '<script src="https://www.google.com/recaptcha/api.js?render=' + recaptcha[0][0] + '"></script>' + \
  322. '<input type="hidden" id="g-recaptcha" name="g-recaptcha">' + \
  323. '<script type="text/javascript">' + \
  324. 'grecaptcha.ready(function() {' + \
  325. 'grecaptcha.execute(\'' + recaptcha[0][0] + '\', {action: \'homepage\'}).then(function(token) {' + \
  326. 'document.getElementById(\'g-recaptcha\').value = token;' + \
  327. '});' + \
  328. '});' + \
  329. '</script>' + \
  330. ''
  331. return data
  332. def captcha_post(re_data, num = 1):
  333. if num == 1:
  334. curs.execute(db_change('select data from other where name = "sec_re"'))
  335. sec_re = curs.fetchall()
  336. if sec_re and sec_re[0][0] != '' and ip_or_user() != 0 and captcha_get() != '':
  337. try:
  338. data = urllib.request.urlopen('https://www.google.com/recaptcha/api/siteverify?secret=' + sec_re[0][0] + '&response=' + re_data)
  339. except:
  340. data = None
  341. if data and data.getcode() == 200:
  342. json_data = json.loads(data.read().decode(data.headers.get_content_charset()))
  343. if json_data['success'] == True:
  344. return 0
  345. else:
  346. return 1
  347. else:
  348. return 0
  349. else:
  350. return 0
  351. else:
  352. pass
  353. def ua_plus(id, ip, ua, time):
  354. curs.execute(db_change("select data from other where name = 'ua_get'"))
  355. rep_data = curs.fetchall()
  356. if rep_data and rep_data[0][0] != '':
  357. pass
  358. else:
  359. curs.execute(db_change("insert into ua_d (name, ip, ua, today, sub) values (?, ?, ?, ?, '')"), [id, ip, ua, time])
  360. def load_lang(data, num = 2, safe = 0):
  361. global global_lang
  362. for i in range(0, 2):
  363. if i == 0:
  364. ip = ip_check()
  365. if ip_or_user(ip) == 0:
  366. curs.execute(db_change('select data from user_set where name = "lang" and id = ?'), [ip])
  367. rep_data = curs.fetchall()
  368. else:
  369. if 'lang' in flask.session:
  370. rep_data = [[flask.session['lang']]]
  371. else:
  372. continue
  373. else:
  374. curs.execute(db_change("select data from other where name = 'language'"))
  375. rep_data = curs.fetchall()
  376. if rep_data and rep_data[0][0] != '' and rep_data[0][0] != 'default':
  377. try:
  378. if not rep_data[0][0] in global_lang:
  379. lang = json.loads(open(os.path.join('lang', rep_data[0][0] + '.json'), encoding='utf8').read())
  380. global_lang[rep_data[0][0]] = lang
  381. else:
  382. lang = global_lang[rep_data[0][0]]
  383. except:
  384. continue
  385. if data in lang:
  386. return lang[data] if safe == 1 else html.escape(lang[data])
  387. else:
  388. continue
  389. else:
  390. continue
  391. return html.escape(data + ' (' + rep_data[0][0] + ')')
  392. def ip_or_user(data = ''):
  393. if data == '':
  394. data = ip_check()
  395. if re.search(r'(\.|:)', data):
  396. return 1
  397. else:
  398. return 0
  399. def edit_button():
  400. insert_list = []
  401. curs.execute(db_change("select html, plus from html_filter where kind = 'edit_top'"))
  402. db_data = curs.fetchall()
  403. for get_data in db_data:
  404. insert_list += [[get_data[1], get_data[0]]]
  405. data = ''
  406. for insert_data in insert_list:
  407. data += '<a href="javascript:do_insert_data(\'content\', \'' + insert_data[0] + '\')">(' + insert_data[1] + ')</a> '
  408. if admin_check() == 1:
  409. data += (' ' if data != '' else '') + '<a href="/edit_top">(' + load_lang('add') + ')</a>'
  410. return data + '<hr class="main_hr">'
  411. def ip_warring():
  412. if ip_or_user() != 0:
  413. curs.execute(db_change('select data from other where name = "no_login_warring"'))
  414. data = curs.fetchall()
  415. if data and data[0][0] != '':
  416. text_data = '' + \
  417. '<span>' + data[0][0] + '</span>' + \
  418. '<hr class="main_hr">' + \
  419. ''
  420. else:
  421. text_data = '' + \
  422. '<span>' + load_lang('no_login_warring') + '</span>' + \
  423. '<hr class="main_hr">' + \
  424. ''
  425. else:
  426. text_data = ''
  427. return text_data
  428. def skin_check(set_n = 0):
  429. skin_list = load_skin('tenshi', 1)
  430. skin = skin_list[0]
  431. check_list = []
  432. ip = ip_check()
  433. if ip_or_user(ip) == 0:
  434. curs.execute(db_change('select data from user_set where name = "skin" and id = ?'), [ip])
  435. skin_exist = curs.fetchall()
  436. check_list += skin_exist
  437. else:
  438. if 'skin' in flask.session:
  439. check_list += [[flask.session['skin']]]
  440. curs.execute(db_change('select data from other where name = "skin"'))
  441. skin_exist = curs.fetchall()
  442. check_list += skin_exist
  443. for i in check_list:
  444. if i[0] != '' and i[0] in skin_list:
  445. skin = i[0]
  446. break
  447. return './views/' + skin + '/index.html' if set_n == 0 else skin
  448. def next_fix(link, num, page, end = 50):
  449. list_data = ''
  450. if num == 1:
  451. if len(page) == end:
  452. list_data += '' + \
  453. '<hr class="main_hr">' + \
  454. '<a href="' + link + str(num + 1) + '">(' + load_lang('next') + ')</a>' + \
  455. ''
  456. elif len(page) != end:
  457. list_data += '' + \
  458. '<hr class="main_hr">' + \
  459. '<a href="' + link + str(num - 1) + '">(' + load_lang('previous') + ')</a>' + \
  460. ''
  461. else:
  462. list_data += '' + \
  463. '<hr class="main_hr">' + \
  464. '<a href="' + link + str(num - 1) + '">(' + load_lang('previous') + ')</a> <a href="' + link + str(num + 1) + '">(' + load_lang('next') + ')</a>' + \
  465. ''
  466. return list_data
  467. def other2(data):
  468. global data_css
  469. global data_css_ver
  470. data += ['' for _ in range(0, 3 - len(data))]
  471. if data_css == '':
  472. for i_data in os.listdir(os.path.join("views", "main_css", "css")):
  473. if i_data != 'sub':
  474. data_css += '<link rel="stylesheet" href="/views/main_css/css/' + i_data + '?ver=' + data_css_ver + '">'
  475. for i_data in os.listdir(os.path.join("views", "main_css", "js")):
  476. if i_data != 'sub':
  477. data_css += '<script src="/views/main_css/js/' + i_data + '?ver=' + data_css_ver + '"></script>'
  478. data = data[0:2] + ['', '''
  479. <link rel="stylesheet"
  480. href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.1.2/build/styles/default.min.css">
  481. <link rel="stylesheet"
  482. href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css"
  483. integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X"
  484. crossorigin="anonymous">
  485. <script src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js"
  486. integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4"
  487. crossorigin="anonymous"></script>
  488. <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.1.2/build/highlight.min.js"></script>
  489. ''' + data_css + '<script>window.addEventListener(\'DOMContentLoaded\', main_css_skin_load);</script>'] + data[2:]
  490. return data
  491. def cut_100(data):
  492. if re.search(r'^\/w\/', flask.request.path):
  493. data = re.sub(r'<script>((\n*(((?!<\/script>).)+)\n*)+)<\/script>', '', data)
  494. data = re.sub(r'<hr class="main_hr">((\n*((.+)\n*))+)$', '', data)
  495. data = re.sub(r'<div id="cate_all">((\n*((.+)\n*))+)$', '', data)
  496. data = re.sub(r'<(((?!>).)*)>', ' ', data)
  497. data = re.sub(r'\n', ' ', data)
  498. data = re.sub(r'^ +', '', data)
  499. data = re.sub(r' +$', '', data)
  500. data = re.sub(r' {2,}', ' ', data)
  501. return data[0:100] + '...'
  502. else:
  503. return ''
  504. def wiki_set(num = 1):
  505. if num == 1:
  506. skin_name = skin_check(1)
  507. data_list = []
  508. curs.execute(db_change('select data from other where name = ?'), ['name'])
  509. db_data = curs.fetchall()
  510. data_list += [db_data[0][0]] if db_data and db_data[0][0] != '' else ['Wiki']
  511. curs.execute(db_change('select data from other where name = "license"'))
  512. db_data = curs.fetchall()
  513. data_list += [db_data[0][0]] if db_data and db_data[0][0] != '' else ['ARR']
  514. data_list += ['', '']
  515. curs.execute(db_change('select data from other where name = "logo" and coverage = ?'), [skin_name])
  516. db_data = curs.fetchall()
  517. if db_data and db_data[0][0] != '':
  518. data_list += [db_data[0][0]]
  519. else:
  520. curs.execute(db_change('select data from other where name = "logo" and coverage = ""'))
  521. db_data = curs.fetchall()
  522. data_list += [db_data[0][0]] if db_data and db_data[0][0] != '' else [data_list[0]]
  523. head_data = ''
  524. curs.execute(db_change("select data from other where name = 'head' and coverage = ''"))
  525. db_data = curs.fetchall()
  526. head_data += db_data[0][0] if db_data and db_data[0][0] != '' else ''
  527. curs.execute(db_change("select data from other where name = 'head' and coverage = ?"), [skin_name])
  528. db_data = curs.fetchall()
  529. head_data += db_data[0][0] if db_data and db_data[0][0] != '' else ''
  530. data_list += [head_data]
  531. elif num == 2:
  532. curs.execute(db_change('select data from other where name = "frontpage"'))
  533. db_data = curs.fetchall()
  534. data_list = db_data[0][0] if db_data and db_data[0][0] != '' else 'FrontPage'
  535. elif num == 3:
  536. curs.execute(db_change('select data from other where name = "upload"'))
  537. db_data = curs.fetchall()
  538. data_list = db_data[0][0] if db_data and db_data[0][0] != '' else '2'
  539. else:
  540. data_list = ''
  541. return data_list
  542. def admin_check(num = None, what = None, name = ''):
  543. ip = ip_check() if name == '' else name
  544. time_data = get_time()
  545. curs.execute(db_change("select acl from user where id = ?"), [ip])
  546. user = curs.fetchall()
  547. if user:
  548. back_num = num
  549. while 1:
  550. if num == 1:
  551. check = 'ban'
  552. elif num == 2:
  553. check = 'nothing'
  554. elif num == 3:
  555. check = 'toron'
  556. elif num == 4:
  557. check = 'check'
  558. elif num == 5:
  559. check = 'acl'
  560. elif num == 6:
  561. check = 'hidel'
  562. elif num == 7:
  563. check = 'give'
  564. else:
  565. check = 'owner'
  566. curs.execute(db_change('select name from alist where name = ? and acl = ?'), [user[0][0], check])
  567. if curs.fetchall():
  568. if what:
  569. curs.execute(db_change("insert into re_admin (who, what, time) values (?, ?, ?)"), [ip, what, time_data])
  570. conn.commit()
  571. return 1
  572. else:
  573. if back_num == 'all':
  574. if num == 'all':
  575. num = 1
  576. elif num != 8:
  577. num += 1
  578. else:
  579. break
  580. elif num:
  581. num = None
  582. else:
  583. break
  584. return 0
  585. def ip_pas(raw_ip, type_d = 0):
  586. hide = 0
  587. end_ip = {}
  588. if type(raw_ip) != type([]):
  589. get_ip = [raw_ip]
  590. return_ip = 1
  591. else:
  592. get_ip = raw_ip
  593. return_ip = 0
  594. for raw_ip in get_ip:
  595. if not raw_ip in end_ip:
  596. if ip_or_user(raw_ip) != 0:
  597. curs.execute(db_change("select data from other where name = 'ip_view'"))
  598. data = curs.fetchall()
  599. if data and data[0][0] != '':
  600. ip = re.sub(r'\.([^.]*)\.([^.]*)$', '.*.*', raw_ip) if re.search(r'\.', raw_ip) else re.sub(r':([^:]*):([^:]*)$', ':*:*', raw_ip)
  601. hide = 1 if not admin_check(1) else 0
  602. else:
  603. ip = raw_ip
  604. else:
  605. if type_d == 0:
  606. ip = '<a href="/w/' + url_pas('user:' + raw_ip) + '">' + raw_ip + '</a>'
  607. ip = '<b>' + ip + '</b>' if admin_check('all', None, raw_ip) == 1 else ip
  608. else:
  609. ip = raw_ip
  610. if type_d == 0:
  611. if ban_check(raw_ip) == 1:
  612. ip = '<s>' + ip + '</s>'
  613. if ban_check(raw_ip, 'login') == 1:
  614. ip = '<i>' + ip + '</i>'
  615. ip = (ip + ' <a href="/tool/' + url_pas(raw_ip) + '">(' + load_lang('tool') + ')</a>') if hide == 0 else ip
  616. end_ip[raw_ip] = ip
  617. return ip if return_ip == 1 else end_ip
  618. def custom():
  619. ip = ip_check()
  620. if ip_or_user(ip) == 0:
  621. user_icon = 1
  622. user_name = ip
  623. curs.execute(db_change("select data from user_set where id = ? and name = 'custom_css'"), [ip])
  624. user_head = curs.fetchall()
  625. user_head = user_head[0][0] if user_head else ''
  626. curs.execute(db_change('select data from user_set where name = "email" and id = ?'), [ip])
  627. email = curs.fetchall()
  628. email = email[0][0] if email else ''
  629. if admin_check('all') == 1:
  630. user_admin = '1'
  631. user_acl_list = []
  632. curs.execute(db_change("select acl from user where id = ?"), [ip])
  633. curs.execute(db_change('select acl from alist where name = ?'), [curs.fetchall()[0][0]])
  634. user_acl = curs.fetchall()
  635. for i in user_acl:
  636. user_acl_list += [i[0]]
  637. user_acl_list = user_acl_list if user_acl != [] else '0'
  638. else:
  639. user_admin = '0'
  640. user_acl_list = '0'
  641. curs.execute(db_change("select count(*) from alarm where name = ?"), [ip])
  642. count = curs.fetchall()
  643. user_notice = str(count[0][0]) if count else '0'
  644. else:
  645. user_icon = 0
  646. user_name = load_lang('user')
  647. email = ''
  648. user_admin = '0'
  649. user_acl_list = '0'
  650. user_notice = '0'
  651. user_head = flask.session['head'] if 'head' in flask.session else ''
  652. curs.execute(db_change("select title from rd where title = ? and stop = ''"), ['user:' + ip])
  653. user_topic = '1' if curs.fetchall() else '0'
  654. return [
  655. '',
  656. '',
  657. user_icon,
  658. user_head,
  659. email,
  660. user_name,
  661. user_admin,
  662. str(ban_check()),
  663. user_notice,
  664. user_acl_list,
  665. ip,
  666. user_topic
  667. ]
  668. def load_skin(data = '', set_n = 0, default = 0):
  669. # data -> 가장 앞에 있을 스킨 이름
  670. # set_n == 0 -> 스트링으로 반환
  671. # set_n == 1 -> 리스트로 반환
  672. # default == 0 -> 디폴트 미포함
  673. # default == 1 -> 디폴트 포함
  674. skin_return_data = '' if set_n == 0 else []
  675. system_file = ['main_css']
  676. skin_list_get = os.listdir(os.path.abspath('views'))
  677. if default == 1:
  678. skin_list_get += ['default']
  679. if data == '':
  680. curs.execute(db_change('select data from user_set where name = "skin" and id = ?'), [ip_check()])
  681. data = curs.fetchall()
  682. if not data:
  683. curs.execute(db_change('select data from other where name = "skin"'))
  684. data = curs.fetchall()
  685. if not data or data[0][0] == '':
  686. if default == 1:
  687. data = [['default']]
  688. else:
  689. data = [['tenshi']]
  690. else:
  691. data = [[data]]
  692. for skin_data in skin_list_get:
  693. see_data = skin_data if skin_data != 'default' else load_lang('default')
  694. if not skin_data in system_file:
  695. if data[0][0] == skin_data:
  696. if set_n == 0:
  697. skin_return_data = '<option value="' + skin_data + '">' + see_data + '</option>' + skin_return_data
  698. else:
  699. skin_return_data = [skin_data] + skin_return_data
  700. else:
  701. if set_n == 0:
  702. skin_return_data += '<option value="' + skin_data + '">' + see_data + '</option>'
  703. else:
  704. skin_return_data += [skin_data]
  705. return skin_return_data
  706. def slow_edit_check():
  707. curs.execute(db_change("select data from other where name = 'slow_edit'"))
  708. slow_edit = curs.fetchall()
  709. if slow_edit and slow_edit != '0' and admin_check(5) != 1:
  710. slow_edit = slow_edit[0][0]
  711. curs.execute(db_change("select date from history where ip = ? order by date desc limit 1"), [ip_check()])
  712. last_edit_data = curs.fetchall()
  713. if last_edit_data:
  714. last_edit_data = int(re.sub(' |:|-', '', last_edit_data[0][0]))
  715. now_edit_data = int((datetime.datetime.now() - datetime.timedelta(seconds = int(slow_edit))).strftime("%Y%m%d%H%M%S"))
  716. if last_edit_data > now_edit_data:
  717. return 1
  718. return 0
  719. def acl_check(name = 'test', tool = '', topic_num = '1'):
  720. ip = ip_check()
  721. get_ban = ban_check()
  722. acl_c = re.search(r"^user:((?:(?!\/).)*)", name) if name else None
  723. if tool == '' and acl_c:
  724. acl_n = acl_c.groups()
  725. if get_ban == 1:
  726. return 1
  727. if admin_check(5) == 1:
  728. return 0
  729. curs.execute(db_change("select data from acl where title = ? and type = 'decu'"), ['user:' + acl_n[0]])
  730. acl_data = curs.fetchall()
  731. if acl_data:
  732. if acl_data[0][0] == 'all':
  733. return 0
  734. elif acl_data[0][0] == 'user' and not ip_or_user(ip) == 1:
  735. return 0
  736. elif ip == acl_n[0] and not ip_or_user(ip) == 1:
  737. return 0
  738. else:
  739. if ip == acl_n[0] and not ip_or_user(ip) == 1 and not ip_or_user(acl_n[0]) == 1:
  740. return 0
  741. return 1
  742. if tool == 'topic':
  743. if not name:
  744. curs.execute(db_change("select title from rd where code = ?"), [topic_num])
  745. name = curs.fetchall()
  746. name = name[0][0] if name else 'test'
  747. end = 3
  748. elif tool == 'render' or tool == '' or tool == 'vote':
  749. if tool == '' and acl_check(name, 'render') == 1:
  750. return 1
  751. end = 2
  752. else:
  753. end = 1
  754. for i in range(0, end):
  755. if tool == '':
  756. if i == 0:
  757. curs.execute(db_change("select data from acl where title = ? and type = 'decu'"), [name])
  758. else:
  759. curs.execute(db_change('select data from other where name = "edit"'))
  760. num = 5
  761. elif tool == 'topic':
  762. if i == 0 and topic_num:
  763. curs.execute(db_change("select acl from rd where code = ?"), [topic_num])
  764. elif i == 1:
  765. curs.execute(db_change("select data from acl where title = ? and type = 'dis'"), [name])
  766. else:
  767. curs.execute(db_change('select data from other where name = "discussion"'))
  768. num = 3
  769. elif tool == 'upload':
  770. curs.execute(db_change("select data from other where name = 'upload_acl'"))
  771. num = 5
  772. elif tool == 'many_upload':
  773. curs.execute(db_change("select data from other where name = 'many_upload_acl'"))
  774. num = 5
  775. elif tool == 'vote':
  776. if i == 0:
  777. curs.execute(db_change('select acl from vote where id = ? and user = ""'), [topic_num])
  778. else:
  779. curs.execute(db_change('select data from other where name = "vote_acl"'))
  780. num = None
  781. else:
  782. # tool == 'render'
  783. if i == 0:
  784. curs.execute(db_change("select data from acl where title = ? and type = 'view'"), [name])
  785. else:
  786. curs.execute(db_change("select data from other where name = 'all_view_acl'"))
  787. num = 5
  788. acl_data = curs.fetchall()
  789. if (i == (end - 1) and (not acl_data or acl_data[0][0] == '' or acl_data[0][0] == 'normal')) and \
  790. get_ban == 1 and \
  791. tool != 'render':
  792. return 1
  793. elif acl_data and acl_data[0][0] != 'normal' and acl_data[0][0] != '':
  794. if acl_data[0][0] != 'ban' and get_ban == 1 and tool != 'render':
  795. return 1
  796. if acl_data[0][0] == 'all' or acl_data[0][0] == 'ban':
  797. return 0
  798. elif acl_data[0][0] == 'user':
  799. if ip_or_user(ip) != 1:
  800. return 0
  801. elif acl_data[0][0] == 'admin':
  802. if ip_or_user(ip) != 1:
  803. if admin_check(num) == 1:
  804. return 0
  805. elif acl_data[0][0] == '50_edit':
  806. if ip_or_user(ip) != 1:
  807. if admin_check(num) == 1:
  808. return 0
  809. else:
  810. curs.execute(db_change("select count(*) from history where ip = ?"), [ip])
  811. count = curs.fetchall()
  812. count = count[0][0] if count else 0
  813. if count >= 50:
  814. return 0
  815. elif acl_data[0][0] == 'before':
  816. if ip_or_user(ip) != 1:
  817. if admin_check(num) == 1:
  818. return 0
  819. curs.execute(db_change("select ip from history where title = ? and ip = ?"), [name, ip])
  820. if curs.fetchall():
  821. return 0
  822. elif acl_data[0][0] == '30_day':
  823. if ip_or_user(ip) != 1:
  824. if admin_check(num) == 1:
  825. return 0
  826. else:
  827. curs.execute(db_change("select date from user where id = ?"), [ip])
  828. user_date = curs.fetchall()[0][0]
  829. time_1 = datetime.datetime.strptime(user_date, '%Y-%m-%d %H:%M:%S') + datetime.timedelta(days = 30)
  830. time_2 = datetime.datetime.strptime(get_time(), '%Y-%m-%d %H:%M:%S')
  831. if time_2 > time_1:
  832. return 0
  833. elif acl_data[0][0] == 'email':
  834. if ip_or_user(ip) != 1:
  835. if admin_check(num) == 1:
  836. return 0
  837. else:
  838. curs.execute(db_change("select data from user_set where id = ? and name = 'email'"), [ip])
  839. if curs.fetchall():
  840. return 0
  841. elif acl_data[0][0] == 'owner':
  842. if admin_check() == 1:
  843. return 0
  844. elif acl_data[0][0] == 'ban_admin':
  845. if admin_check(1) == 1 or ban_check() == 1:
  846. return 0
  847. return 1
  848. else:
  849. if i == (end - 1):
  850. if tool == 'topic' and topic_num:
  851. curs.execute(db_change("select title from rd where code = ? and stop != ''"), [topic_num])
  852. if curs.fetchall():
  853. if admin_check(3, 'topic (code ' + topic_num + ')') == 1:
  854. return 0
  855. else:
  856. return 0
  857. else:
  858. return 0
  859. return 1
  860. def ban_check(ip = None, tool = None):
  861. ip = ip_check() if not ip else ip
  862. if admin_check(None, None, ip) == 1:
  863. return 0
  864. curs.execute(db_change("update rb set ongoing = '' where end < ? and end != '' and ongoing = '1'"), [get_time()])
  865. conn.commit()
  866. curs.execute(db_change("" + \
  867. "select login, block from rb " + \
  868. "where ((end > ? and end != '') or end = '') and band = 'regex' and ongoing = '1'" + \
  869. ""), [get_time()])
  870. regex_d = curs.fetchall()
  871. for test_r in regex_d:
  872. g_regex = re.compile(test_r[1])
  873. if g_regex.search(ip):
  874. if tool and tool == 'login':
  875. if test_r[0] != 'O':
  876. return 1
  877. else:
  878. return 1
  879. curs.execute(db_change("" + \
  880. "select login from rb " + \
  881. "where ((end > ? and end != '') or end = '') and block = ? and band = '' and ongoing = '1'" + \
  882. ""), [get_time(), ip])
  883. ban_d = curs.fetchall()
  884. if ban_d:
  885. if tool and tool == 'login':
  886. if ban_d[0][0] != 'O':
  887. return 1
  888. else:
  889. return 1
  890. return 0
  891. def ban_insert(name, end, why, login, blocker, type_d = None):
  892. now_time = get_time()
  893. band = type_d if type_d else ''
  894. curs.execute(db_change("update rb set ongoing = '' where end < ? and end != '' and ongoing = '1'"), [now_time])
  895. curs.execute(db_change("" + \
  896. "select block from rb where ((end > ? and end != '') or end = '') and block = ? and band = ? and ongoing = '1'" + \
  897. ""), [now_time, name, band])
  898. if curs.fetchall():
  899. curs.execute(db_change("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, ?)"), [
  900. name,
  901. 'release',
  902. now_time,
  903. blocker,
  904. '',
  905. band
  906. ])
  907. curs.execute(db_change("update rb set ongoing = '' where block = ? and band = ? and ongoing = '1'"), [name, band])
  908. else:
  909. login = 'O' if login != '' else ''
  910. if end != '0':
  911. end = int(number_check(end))
  912. time = datetime.datetime.now()
  913. plus = datetime.timedelta(seconds = end)
  914. r_time = (time + plus).strftime("%Y-%m-%d %H:%M:%S")
  915. else:
  916. r_time = ''
  917. curs.execute(db_change("insert into rb (block, end, today, blocker, why, band, ongoing, login) values (?, ?, ?, ?, ?, ?, '1', ?)"), [
  918. name,
  919. r_time,
  920. now_time,
  921. blocker,
  922. why,
  923. band,
  924. login
  925. ])
  926. conn.commit()
  927. def rd_plus(topic_num, date, name = None, sub = None):
  928. curs.execute(db_change("select code from rd where code = ?"), [topic_num])
  929. if curs.fetchall():
  930. curs.execute(db_change("update rd set date = ? where code = ?"), [date, topic_num])
  931. else:
  932. curs.execute(db_change("insert into rd (title, sub, code, date) values (?, ?, ?, ?)"), [name, sub, topic_num, date])
  933. conn.commit()
  934. def history_plus(title, data, date, ip, send, leng, t_check = '', mode = ''):
  935. if mode == 'add':
  936. curs.execute(db_change("select id from history where title = ? order by id + 0 asc limit 1"), [title])
  937. id_data = curs.fetchall()
  938. id_data = str(int(id_data[0][0]) - 1) if id_data else '0'
  939. else:
  940. curs.execute(db_change("select id from history where title = ? order by id + 0 desc limit 1"), [title])
  941. id_data = curs.fetchall()
  942. id_data = str(int(id_data[0][0]) + 1) if id_data else '1'
  943. mode = mode if not re.search('^user:', title) else 'user'
  944. send = re.sub(r'\(|\)|<|>', '', send)
  945. send = send[:128] if len(send) > 128 else send
  946. send = send + ' (' + t_check + ')' if t_check != '' else send
  947. if mode != 'add' and mode != 'user':
  948. curs.execute(db_change("select count(*) from rc where type = 'normal'"))
  949. if curs.fetchall()[0][0] >= 200:
  950. curs.execute(db_change("select id, title from rc where type = 'normal' order by date asc limit 1"))
  951. rc_data = curs.fetchall()
  952. if rc_data:
  953. curs.execute(db_change('delete from rc where id = ? and title = ? and type = "normal"'), [
  954. rc_data[0][0],
  955. rc_data[0][1]
  956. ])
  957. curs.execute(db_change("insert into rc (id, title, date, type) values (?, ?, ?, 'normal')"), [
  958. id_data,
  959. title,
  960. date
  961. ])
  962. if mode != 'add':
  963. curs.execute(db_change("select count(*) from rc where type = ?"), [mode])
  964. if curs.fetchall()[0][0] >= 200:
  965. curs.execute(db_change("select id, title from rc where type = ? order by date asc limit 1"), [mode])
  966. rc_data = curs.fetchall()
  967. if rc_data:
  968. curs.execute(db_change('delete from rc where id = ? and title = ? and type = ?'), [
  969. rc_data[0][0],
  970. rc_data[0][1],
  971. mode
  972. ])
  973. curs.execute(db_change("insert into rc (id, title, date, type) values (?, ?, ?, ?)"), [
  974. id_data,
  975. title,
  976. date,
  977. mode
  978. ])
  979. curs.execute(db_change("insert into history (id, title, data, date, ip, send, leng, hide, type) values (?, ?, ?, ?, ?, ?, ?, '', ?)"), [
  980. id_data,
  981. title,
  982. data,
  983. date,
  984. ip,
  985. send,
  986. leng,
  987. mode
  988. ])
  989. def leng_check(first, second):
  990. if first < second:
  991. all_plus = '+' + str(second - first)
  992. elif second < first:
  993. all_plus = '-' + str(first - second)
  994. else:
  995. all_plus = '0'
  996. return all_plus
  997. def number_check(data):
  998. try:
  999. int(data)
  1000. return data
  1001. except:
  1002. return '1'
  1003. def edit_filter_do(data):
  1004. if admin_check(1) != 1:
  1005. curs.execute(db_change("select plus, plus_t from html_filter where kind = 'regex_filter' and plus != ''"))
  1006. for data_list in curs.fetchall():
  1007. match = re.compile(data_list[0], re.I)
  1008. if match.search(data):
  1009. ban_insert(
  1010. ip_check(),
  1011. '0' if data_list[1] == 'X' else data_list[1],
  1012. 'edit filter',
  1013. None,
  1014. 'tool:edit filter'
  1015. )
  1016. return 1
  1017. return 0
  1018. def redirect(data = '/'):
  1019. return flask.redirect(flask.request.host_url[:-1] + data)
  1020. def get_acl_list(type_d = 'normal'):
  1021. if type_d == 'user':
  1022. return ['', 'user', 'all']
  1023. else:
  1024. return ['', 'all', 'user', 'admin', 'owner', '50_edit', 'email', 'ban', 'before', '30_day', 'ban_admin']
  1025. def re_error(data):
  1026. conn.commit()
  1027. if data == '/ban':
  1028. if ban_check() == 1:
  1029. end = '<div id="get_user_info"></div><script>load_user_info("' + ip_check() + '");</script>'
  1030. else:
  1031. end = '<ul class="inside_ul"><li>' + load_lang('authority_error') + '</li></ul>'
  1032. return easy_minify(flask.render_template(skin_check(),
  1033. imp = [load_lang('error'), wiki_set(1), custom(), other2([0, 0])],
  1034. data = '<h2>' + load_lang('error') + '</h2>' + end,
  1035. menu = 0
  1036. )), 401
  1037. else:
  1038. num = int(number_check(data.replace('/error/', '')))
  1039. if num == 1:
  1040. data = load_lang('no_login_error')
  1041. elif num == 2:
  1042. data = load_lang('no_exist_user_error')
  1043. elif num == 3:
  1044. data = load_lang('authority_error')
  1045. elif num == 4:
  1046. data = load_lang('no_admin_block_error')
  1047. elif num == 5:
  1048. data = load_lang('skin_error')
  1049. elif num == 6:
  1050. data = load_lang('same_id_exist_error')
  1051. elif num == 7:
  1052. data = load_lang('long_id_error')
  1053. elif num == 8:
  1054. data = load_lang('id_char_error') + ' <a href="/name_filter">(' + load_lang('id_filter_list') + ')</a>'
  1055. elif num == 9:
  1056. data = load_lang('file_exist_error')
  1057. elif num == 10:
  1058. data = load_lang('password_error')
  1059. elif num == 11:
  1060. data = load_lang('topic_long_error')
  1061. elif num == 12:
  1062. data = load_lang('email_error')
  1063. elif num == 13:
  1064. data = load_lang('recaptcha_error')
  1065. elif num == 14:
  1066. data = load_lang('file_extension_error') + ' <a href="/extension_filter">(' + load_lang('extension_filter_list') + ')</a>'
  1067. elif num == 15:
  1068. data = load_lang('edit_record_error')
  1069. elif num == 16:
  1070. data = load_lang('same_file_error')
  1071. elif num == 17:
  1072. data = load_lang('file_capacity_error') + wiki_set(3)
  1073. elif num == 18:
  1074. data = load_lang('email_send_error')
  1075. elif num == 19:
  1076. data = load_lang('decument_exist_error')
  1077. elif num == 20:
  1078. data = load_lang('password_diffrent_error')
  1079. elif num == 21:
  1080. data = load_lang('edit_filter_error')
  1081. elif num == 22:
  1082. data = load_lang('file_name_error')
  1083. elif num == 23:
  1084. data = load_lang('regex_error')
  1085. elif num == 24:
  1086. curs.execute(db_change("select data from other where name = 'slow_edit'"))
  1087. data = load_lang('fast_edit_error') + curs.fetchall()[0][0]
  1088. elif num == 25:
  1089. data = load_lang('too_many_dec_error')
  1090. elif num == 26:
  1091. data = load_lang('application_not_found')
  1092. elif num == 27:
  1093. data = load_lang("invalid_password_error")
  1094. elif num == 28:
  1095. data = load_lang('watchlist_overflow_error')
  1096. elif num == 29:
  1097. data = load_lang('copyright_disagreed')
  1098. elif num == 30:
  1099. data = load_lang('ie_wrong_callback')
  1100. elif num == 33:
  1101. data = load_lang('restart_fail_error')
  1102. elif num == 34:
  1103. data = load_lang("update_error") + ' <a href="https://github.com/2DU/opennamu">(Github)</a>'
  1104. elif num == 35:
  1105. data = load_lang('same_email_error')
  1106. elif num == 36:
  1107. data = load_lang('input_email_error')
  1108. else:
  1109. data = '???'
  1110. if num == 5:
  1111. get_url = flask.request.path
  1112. return easy_minify(flask.render_template(skin_check(),
  1113. imp = [(load_lang('skin_set') if get_url != '/main_skin_set' else load_lang('main_skin_set')), wiki_set(1), custom(), other2([0, 0])],
  1114. data = '' + \
  1115. '<div id="main_skin_set">' + \
  1116. '<h2>' + load_lang('error') + '</h2>' + \
  1117. '<ul class="inside_ul">' + \
  1118. '<li>' + data + ' <a href="/main_skin_set">(' + load_lang('main_skin_set') + ')</a></li>' + \
  1119. '</ul>' + \
  1120. '</div>' + \
  1121. ('<script>main_css_skin_set();</script>' if get_url == '/main_skin_set' else ''),
  1122. menu = ([['main_skin_set', load_lang('main_skin_set')]] if get_url != '/main_skin_set' else [['skin_set', load_lang('skin_set')]])
  1123. ))
  1124. else:
  1125. return easy_minify(flask.render_template(skin_check(),
  1126. imp = [load_lang('error'), wiki_set(1), custom(), other2([0, 0])],
  1127. data = '<h2>' + load_lang('error') + '</h2><ul class="inside_ul"><li>' + data + '</li></ul>',
  1128. menu = 0
  1129. )), 400