func.py 48 KB

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