func.py 45 KB

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