mark.py 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. from bottle import request, app
  2. from bottle.ext import beaker
  3. from urllib import parse
  4. import json
  5. import sqlite3
  6. import time
  7. import re
  8. import hashlib
  9. import html
  10. json_data = open('set.json').read()
  11. set_data = json.loads(json_data)
  12. conn = sqlite3.connect(set_data['db'] + '.db')
  13. curs = conn.cursor()
  14. session_opts = {
  15. 'session.type': 'file',
  16. 'session.data_dir': './app_session/',
  17. 'session.auto': 1
  18. }
  19. app = beaker.middleware.SessionMiddleware(app(), session_opts)
  20. def get_time():
  21. now = time.localtime()
  22. date = "%04d-%02d-%02d %02d:%02d:%02d" % (now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec)
  23. return(date)
  24. def ip_check():
  25. session = request.environ.get('beaker.session')
  26. if(session.get('Now') == 1):
  27. ip = format(session['DREAMER'])
  28. else:
  29. if(request.environ.get('HTTP_X_FORWARDED_FOR')):
  30. ip = request.environ.get('HTTP_X_FORWARDED_FOR')
  31. else:
  32. ip = request.environ.get('REMOTE_ADDR')
  33. return(ip)
  34. def url_pas(data):
  35. return(parse.quote(data).replace('/','%2F'))
  36. def sha224(data):
  37. return(hashlib.sha224(bytes(data, 'utf-8')).hexdigest())
  38. def savemark(data):
  39. data = re.sub("\[date\(now\)\]", get_time(), data)
  40. if(not re.search("\.", ip_check())):
  41. name = '[[사용자:' + ip_check() + '|' + ip_check() + ']]'
  42. else:
  43. name = ip_check()
  44. data = re.sub("\[name\]", name, data)
  45. return(data)
  46. def send_p(d):
  47. d = html.escape(d)
  48. js_p = re.compile('javascript:', re.I)
  49. d = js_p.sub('', d)
  50. d = re.sub('&lt;a href="(?:[^"]*)"&gt;(?P<in>(?:(?!&lt;).)*)&lt;\/a&gt;', '<a href="' + url_pas('\g<in>') + '">\g<in></a>', d)
  51. return(d)
  52. def table_p(d, d2):
  53. alltable = 'style="'
  54. celstyle = 'style="'
  55. rowstyle = 'style="'
  56. row = ''
  57. cel = ''
  58. table_w = re.search("&lt;table\s?width=((?:(?!&gt;).)*)&gt;", d)
  59. table_h = re.search("&lt;table\s?height=((?:(?!&gt;).)*)&gt;", d)
  60. table_a = re.search("&lt;table\s?align=((?:(?!&gt;).)*)&gt;", d)
  61. if(table_w):
  62. alltable += 'width: ' + table_w.groups()[0] + ';'
  63. if(table_h):
  64. alltable += 'height: ' + table_h.groups()[0] + ';'
  65. if(table_a):
  66. if(table_a.groups()[0] == 'right'):
  67. alltable += 'float: right;'
  68. elif(table_a.groups()[0] == 'center'):
  69. alltable += 'margin: auto;'
  70. table_t_a = re.search("&lt;table\s?textalign=((?:(?!&gt;).)*)&gt;", d)
  71. if(table_t_a):
  72. if(table_t_a.groups()[0] == 'right'):
  73. alltable += 'text-align: right;'
  74. elif(table_t_a.groups()[0] == 'center'):
  75. alltable += 'text-align: center;'
  76. row_t_a = re.search("&lt;row\s?textalign=((?:(?!&gt;).)*)&gt;", d)
  77. if(row_t_a):
  78. if(row_t_a.groups()[0] == 'right'):
  79. rowstyle += 'text-align: right;'
  80. elif(row_t_a.groups()[0] == 'center'):
  81. rowstyle += 'text-align: center;'
  82. else:
  83. rowstyle += 'text-align: left;'
  84. table_cel = re.search("&lt;-((?:(?!&gt;).)*)&gt;", d)
  85. if(table_cel):
  86. cel = 'colspan="' + table_cel.groups()[0] + '"'
  87. else:
  88. cel = 'colspan="' + str(round(len(d2) / 2)) + '"'
  89. table_row = re.search("&lt;\|((?:(?!&gt;).)*)&gt;", d)
  90. if(table_row):
  91. row = 'rowspan="' + table_row.groups()[0] + '"'
  92. row_bgcolor_1 = re.search("&lt;rowbgcolor=(#[0-9a-f-A-F]{6})&gt;", d)
  93. row_bgcolor_2 = re.search("&lt;rowbgcolor=(#[0-9a-f-A-F]{3})&gt;", d)
  94. row_bgcolor_3 = re.search("&lt;rowbgcolor=(\w+)&gt;", d)
  95. if(row_bgcolor_1):
  96. rowstyle += 'background: ' + row_bgcolor_1.groups()[0] + ';'
  97. elif(row_bgcolor_2):
  98. rowstyle += 'background: ' + row_bgcolor_2.groups()[0] + ';'
  99. elif(row_bgcolor_3):
  100. rowstyle += 'background: ' + row_bgcolor_3.groups()[0] + ';'
  101. table_border_1 = re.search("&lt;table\s?bordercolor=(#[0-9a-f-A-F]{6})&gt;", d)
  102. table_border_2 = re.search("&lt;table\s?bordercolor=(#[0-9a-f-A-F]{3})&gt;", d)
  103. table_border_3 = re.search("&lt;table\s?bordercolor=(\w+)&gt;", d)
  104. if(table_border_1):
  105. alltable += 'border: ' + table_border_1.groups()[0] + ' 2px solid;'
  106. elif(table_border_2):
  107. alltable += 'border: ' + table_border_2.groups()[0] + ' 2px solid;'
  108. elif(table_border_3):
  109. alltable += 'border: ' + table_border_3.groups()[0] + ' 2px solid;'
  110. table_bgcolor_1 = re.search("&lt;table\s?bgcolor=(#[0-9a-f-A-F]{6})&gt;", d)
  111. table_bgcolor_2 = re.search("&lt;table\s?bgcolor=(#[0-9a-f-A-F]{3})&gt;", d)
  112. table_bgcolor_3 = re.search("&lt;table\s?bgcolor=(\w+)&gt;", d)
  113. if(table_bgcolor_1)
  114. alltable += 'background: ' + table_bgcolor_1.groups()[0] + ';'
  115. elif(table_bgcolor_2):
  116. alltable += 'background: ' + table_bgcolor_2.groups()[0] + ';'
  117. elif(table_bgcolor_3):
  118. alltable += 'background: ' + table_bgcolor_3.groups()[0] + ';'
  119. bgcolor_1 = re.search("&lt;bgcolor=(#[0-9a-f-A-F]{6})&gt;", d)
  120. bgcolor_2 = re.search("&lt;bgcolor=(#[0-9a-f-A-F]{3})&gt;", d)
  121. bgcolor_3 = re.search("&lt;bgcolor=(\w+)&gt;", d)
  122. if(bgcolor_1):
  123. celstyle += 'background: ' + bgcolor_1.groups()[0] + ';'
  124. elif(bgcolor_2):
  125. celstyle += 'background: ' + bgcolor_2.groups()[0] + ';'
  126. elif(bgcolor_3):
  127. celstyle += 'background: ' + bgcolor_3.groups()[0] + ';'
  128. st_bgcolor_1 = re.search("&lt;(#[0-9a-f-A-F]{6})&gt;", d)
  129. st_bgcolor_2 = re.search("&lt;(#[0-9a-f-A-F]{3})&gt;", d)
  130. st_bgcolor_3 = re.search("&lt;(\w+)&gt;", d)
  131. if(st_bgcolor_1):
  132. celstyle += 'background: ' + st_bgcolor_1.groups()[0] + ';'
  133. elif(st_bgcolor_2):
  134. celstyle += 'background: ' + st_bgcolor_2.groups()[0] + ';'
  135. elif(st_bgcolor_3):
  136. celstyle += 'background: ' + st_bgcolor_3.groups()[0] + ';'
  137. n_width = re.search("&lt;width=((?:(?!&gt;).)*)&gt;", d)
  138. n_height = re.search("&lt;height=((?:(?!&gt;).)*)&gt;", d)
  139. if(n_width):
  140. celstyle += 'width: ' + n_width.groups()[0] + ';'
  141. if(n_height):
  142. celstyle += 'height: ' + n_height.groups()[0] + ';'
  143. text_right = re.search("&lt;\)&gt;", d)
  144. text_center = re.search("&lt;:&gt;", d)
  145. text_left = re.search("&lt;\(&gt;", d)
  146. if(text_right):
  147. celstyle += 'text-align: right;'
  148. elif(text_center):
  149. celstyle += 'text-align: center;'
  150. elif(text_left):
  151. celstyle += 'text-align: left;'
  152. alltable += '"'
  153. celstyle += '"'
  154. rowstyle += '"'
  155. return([alltable, rowstyle, celstyle, row, cel])
  156. def html_pas(data):
  157. data = re.sub("%phtml%(?P<in>(?:\/)?(?:a|div|span|embed|iframe)(?:\s[^%]*)?)%phtml%", "<\g<in>>", data)
  158. while(1):
  159. y = re.search("<((div|span|embed|iframe)(?:\s[^>]*))>", data)
  160. if(y):
  161. b = y.groups()
  162. if(re.search("<(\/" + b[1] + ")>", data)):
  163. xss_test = re.search('src=(?:"|\')?(http(s)?:\/\/([^\/]*)\/(?:[^"\' ]*))(?:"|\')?', b[0])
  164. if(xss_test):
  165. check = xss_test.groups()
  166. if(check[2] == "www.youtube.com" or check[2] == "serviceapi.nmv.naver.com" or check[2] == "tv.kakao.com" or check[2] == "tvple.com"):
  167. a = b[0]
  168. else:
  169. a = re.sub('src=(?:"|\')([^"\']*)(?:"|\')', '', b[0])
  170. else:
  171. a = b[0]
  172. try:
  173. if(check[1] != None):
  174. data = re.sub("<((?:\/)?" + b[1] + "(?:\s[^>]*))>", "%phtml%" + a + "%phtml%", data, 1)
  175. data = re.sub("<\/" + b[1] + ">", "%phtml%/" + b[1] + "%phtml%", data, 1)
  176. else:
  177. data = re.sub("<((?:\/)?" + b[1] + "(?:\s[^>]*))>", "[[" + check[0] + "]]", data, 1)
  178. data = re.sub("<\/" + b[1] + ">", "", data, 1)
  179. except:
  180. data = re.sub("<((?:\/)?" + b[1] + "(?:\s[^>]*))>", "%phtml%" + a + "%phtml%", data, 1)
  181. data = re.sub("<\/" + b[1] + ">", "%phtml%/" + b[1] + "%phtml%", data, 1)
  182. else:
  183. data = re.sub("<((?:\/)?" + b[1] + "(?:\s[^>]*))>", '&lt;' + b[0] + '&gt;', data, 1)
  184. break
  185. else:
  186. break
  187. data = html.escape(data)
  188. js_p = re.compile('javascript:', re.I)
  189. data = js_p.sub('', data)
  190. data = re.sub("%phtml%(?P<in>(?:\/)?(?:a|div|span|embed|iframe)(?:\s[^%]*)?)%phtml%", "<\g<in>>", data)
  191. return(data)
  192. def mid_pas(data, fol_num, include, in_c):
  193. while(1):
  194. com = re.compile("{{{((?:(?!{{{)(?!}}}).)*)}}}", re.DOTALL)
  195. y = com.search(data)
  196. if(y):
  197. a = y.groups()
  198. big_a = re.compile("^\+([1-5])\s(.*)$", re.DOTALL)
  199. big = big_a.search(a[0])
  200. small_a = re.compile("^\-([1-5])\s(.*)$", re.DOTALL)
  201. small = small_a.search(a[0])
  202. color_a = re.compile("^(#[0-9a-f-A-F]{6})\s(.*)$", re.DOTALL)
  203. color = color_a.search(a[0])
  204. color_b = re.compile("^(#[0-9a-f-A-F]{3})\s(.*)$", re.DOTALL)
  205. color_2 = color_b.search(a[0])
  206. color_c = re.compile("^#(\w+)\s(.*)$", re.DOTALL)
  207. color_3 = color_c.search(a[0])
  208. back_a = re.compile("^@([0-9a-f-A-F]{6})\s(.*)$", re.DOTALL)
  209. back = back_a.search(a[0])
  210. back_b = re.compile("^@([0-9a-f-A-F]{3})\s(.*)$", re.DOTALL)
  211. back_2 = back_b.search(a[0])
  212. back_c = re.compile("^@(\w+)\s(.*)$", re.DOTALL)
  213. back_3 = back_c.search(a[0])
  214. include_out_a = re.compile("^#!noin\s(.*)$", re.DOTALL)
  215. include_out = include_out_a.search(a[0])
  216. div_a = re.compile("^#!wiki\sstyle=(?:&quot;|&apos;)((?:(?!&quot;|&apos;).)*)(?:&quot;|&apos;)\r\n(.*)$", re.DOTALL)
  217. div = div_a.search(a[0])
  218. html_a = re.compile("^#!html\s(.*)$", re.DOTALL)
  219. html = html_a.search(a[0])
  220. fol_a = re.compile("^#!folding\s((?:(?!\n).)*)\n?\s\n(.*)$", re.DOTALL)
  221. fol = fol_a.search(a[0])
  222. syn_a = re.compile("^#!syntax\s([^\n]*)\r\n(.*)$", re.DOTALL)
  223. syn = syn_a.search(a[0])
  224. if(big):
  225. result = big.groups()
  226. data = com.sub('<span class="font-size-' + result[0] + '">' + result[1] + '</span>', data, 1)
  227. elif(small):
  228. result = small.groups()
  229. data = com.sub('<span class="font-size-small-' + result[0] + '">' + result[1] + '</span>', data, 1)
  230. elif(color):
  231. result = color.groups()
  232. data = com.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', data, 1)
  233. elif(color_2):
  234. result = color_2.groups()
  235. data = com.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', data, 1)
  236. elif(color_3):
  237. result = color_3.groups()
  238. data = com.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', data, 1)
  239. elif(back):
  240. result = back.groups()
  241. data = com.sub('<span style="background:#' + result[0] + '">' + result[1] + '</span>', data, 1)
  242. elif(back_2):
  243. result = back_2.groups()
  244. data = com.sub('<span style="background:#' + result[0] + '">' + result[1] + '</span>', data, 1)
  245. elif(back_3):
  246. result = back_3.groups()
  247. data = com.sub('<span style="background:' + result[0] + '">' + result[1] + '</span>', data, 1)
  248. elif(div):
  249. result = div.groups()
  250. data = com.sub('<div style="' + result[0] + '">' + result[1] + '</div>', data, 1)
  251. elif(html):
  252. result = html.groups()
  253. data = com.sub(result[0], data, 1)
  254. elif(fol):
  255. result = fol.groups()
  256. data = com.sub( "<div> \
  257. " + result[0] + " \
  258. <div id='folding_" + str(fol_num + 1) + "' style='display: inline-block;'> \
  259. [<a href='javascript:void(0);' onclick='folding(" + str(fol_num + 1) + "); folding(" + str(fol_num + 2) + "); folding(" + str(fol_num) + ");'>펼치기</a>] \
  260. </div> \
  261. <div id='folding_" + str(fol_num + 2) + "' style='display: none;'> \
  262. [<a href='javascript:void(0);' onclick='folding(" + str(fol_num + 1) + "); folding(" + str(fol_num + 2) + "); folding(" + str(fol_num) + ");'>접기</a>] \
  263. </div> \
  264. <div id='folding_" + str(fol_num) + "' style='display: none;'> \
  265. <br> \
  266. " + result[1] + " \
  267. </div> \
  268. </div>", data, 1)
  269. fol_num += 3
  270. elif(syn):
  271. result = syn.groups()
  272. data = com.sub('<pre id="syntax"><code class="' + result[0] + '">' + re.sub('\r\n', '<isbr>', re.sub(' ', '<space>', result[1])) + '</code></pre>', data, 1)
  273. elif(html):
  274. result = html.groups()
  275. data = com.sub(result[0], data, 1)
  276. elif(include_out):
  277. if((include or in_c) == 1):
  278. data = com.sub("", data, 1)
  279. else:
  280. result = include_out.groups()
  281. data = com.sub(result[0], data, 1)
  282. else:
  283. data = com.sub('<code>' + a[0] + '</code>', data, 1)
  284. else:
  285. break
  286. while(1):
  287. com = re.compile("<code>(((?!<\/code>).)*)<\/code>", re.DOTALL)
  288. y = com.search(data)
  289. if(y):
  290. a = y.groups()
  291. mid_data = re.sub("<\/span>", "}}}", a[0])
  292. mid_data = re.sub("<\/div>", "}}}", mid_data)
  293. mid_data = re.sub('<span class="font\-size\-(?P<in>[1-6])">', "{{{+\g<in> ", mid_data)
  294. mid_data = re.sub('<span class="font\-size\-small\-(?P<in>[1-6])">', "{{{-\g<in> ", mid_data)
  295. mid_data = re.sub('<span style="color:(?:#)?(?P<in>[^"]*)">', "{{{#\g<in> ", mid_data)
  296. mid_data = re.sub('<span style="background:(?:#)?(?P<in>[^"]*)">', "{{{@\g<in> ", mid_data)
  297. mid_data = re.sub('<div style="(?P<in>[^"]*)">', "{{{#!wiki style=\"\g<in>\"\n", mid_data)
  298. mid_data = re.sub("(?P<in>.)", "<nowiki>\g<in></nowiki>", mid_data)
  299. data = com.sub(mid_data, data, 1)
  300. else:
  301. break
  302. return([data, fol_num])
  303. def toc_pas(data, title):
  304. i = [0, 0, 0, 0, 0, 0, 0]
  305. last = 0
  306. span = ''
  307. rtoc = '<div id="toc"><span id="toc-name">목차</span><br><br>'
  308. while(1):
  309. i[0] += 1
  310. m = re.search('(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n', data)
  311. if(m):
  312. result = m.groups()
  313. wiki = len(result[0])
  314. if(last < wiki):
  315. last = wiki
  316. else:
  317. last = wiki
  318. if(wiki == 1):
  319. i[2] = 0
  320. i[3] = 0
  321. i[4] = 0
  322. i[5] = 0
  323. i[6] = 0
  324. elif(wiki == 2):
  325. i[3] = 0
  326. i[4] = 0
  327. i[5] = 0
  328. i[6] = 0
  329. elif(wiki == 3):
  330. i[4] = 0
  331. i[5] = 0
  332. i[6] = 0
  333. elif(wiki == 4):
  334. i[5] = 0
  335. i[6] = 0
  336. elif(wiki == 5):
  337. i[6] = 0
  338. if(wiki == 1):
  339. i[1] += 1
  340. elif(wiki == 2):
  341. i[2] += 1
  342. elif(wiki == 3):
  343. i[3] += 1
  344. elif(wiki == 4):
  345. i[4] += 1
  346. elif(wiki == 5):
  347. i[5] += 1
  348. else:
  349. i[6] += 1
  350. toc = str(i[1]) + '.' + str(i[2]) + '.' + str(i[3]) + '.' + str(i[4]) + '.' + str(i[5]) + '.' + str(i[6]) + '.'
  351. toc = re.sub("(?P<in>[0-9]0(?:[0]*)?)\.", '\g<in>#.', toc)
  352. toc = re.sub("0\.", '', toc)
  353. toc = re.sub("#\.", '.', toc)
  354. toc = re.sub("\.$", '', toc)
  355. test = re.search('([0-9]*)(\.([0-9]*))?(\.([0-9]*))?(\.([0-9]*))?(\.([0-9]*))?', toc)
  356. if(test):
  357. g = test.groups()
  358. if(g[4]):
  359. span = '<span id="out"></span>' * 4
  360. elif(g[3]):
  361. span = '<span id="out"></span>' * 3
  362. elif(g[2]):
  363. span = '<span id="out"></span>' * 2
  364. elif(g[1]):
  365. span = '<span id="out"></span>'
  366. else:
  367. span = ''
  368. rtoc += span + '<a href="#s-' + toc + '">' + toc + '</a>. ' + result[1] + '<br>'
  369. c = re.sub(" $", "", result[1])
  370. d = c
  371. c = re.sub("\[\[(([^|]*)\|)?(?P<in>[^\]]*)\]\]", "\g<in>", c)
  372. data = re.sub('(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n', '<tablenobr><h' + str(wiki) + ' id="' + c + '"><a href="#toc" id="s-' + toc + '">' + toc + '.</a> ' + d + ' <span style="font-size:11px;">[<a href="/edit/' + url_pas(title) + '/section/' + str(i[0]) + '">편집</a>]</span></h' + str(wiki) + '>', data, 1)
  373. else:
  374. rtoc += '</div>'
  375. break
  376. data = re.sub("\[목차\]", rtoc, data)
  377. return(data)
  378. def backlink_plus(name, link, backtype, num):
  379. if(num == 1):
  380. curs.execute("select title from back where title = ? and link = ? and type = ?", [link, name, backtype])
  381. y = curs.fetchall()
  382. if(not y):
  383. curs.execute("insert into back (title, link, type) values (?, ?, ?)", [link, name, backtype])
  384. def cat_plus(name, link, num):
  385. if(num == 1):
  386. curs.execute("select title from cat where title = ? and cat = ?", [link, name])
  387. y = curs.fetchall()
  388. if(not y):
  389. curs.execute("insert into cat (title, cat) values (?, ?)", [link, name])
  390. def namumark(title, data, num, in_c):
  391. data = html_pas(data)
  392. b = 0
  393. a = mid_pas(data, b, 0, in_c)
  394. data = a[0]
  395. b = a[1]
  396. data = re.sub("\[anchor\((?P<in>[^\[\]]*)\)\]", '<span id="\g<in>"></span>', data)
  397. data = savemark(data)
  398. include = re.compile("\[include\(((?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\]")
  399. while(1):
  400. m = include.search(data)
  401. if(m):
  402. results = m.groups()
  403. if(results[0] == title):
  404. data = include.sub("<b>" + results[0] + "</b>", data, 1)
  405. else:
  406. curs.execute("select data from data where title = ?", [results[0]])
  407. in_con = curs.fetchall()
  408. backlink_plus(title, results[0], 'include', num)
  409. if(in_con):
  410. in_data = in_con[0][0]
  411. in_data = include.sub("", in_data)
  412. in_data = html_pas(in_data)
  413. in_data = mid_pas(in_data, b, 1, in_c)[0]
  414. if(results[1]):
  415. a = results[1]
  416. while(1):
  417. g = re.search("([^= ,]*)\=([^,]*)", a)
  418. if(g):
  419. result = g.groups()
  420. in_data = re.sub("@" + result[0] + "@", result[1], in_data)
  421. a = re.sub("([^= ,]*)\=([^,]*)", "", a, 1)
  422. else:
  423. break
  424. in_data = toc_pas(in_data, results[0])
  425. data = include.sub('\n<nobr><a href="/w/' + url_pas(results[0]) + '">[' + results[0] + ' 이동]</a><div>' + in_data + '</div><nobr>\n', data, 1)
  426. else:
  427. data = include.sub("<a class=\"not_thing\" href=\"" + url_pas(results[0]) + "\">" + results[0] + "</a>", data, 1)
  428. else:
  429. break
  430. while(1):
  431. m = re.search('^#(?:redirect|넘겨주기) ([^\n]*)$', data)
  432. if(m):
  433. results = m.groups()
  434. g = re.sub("\\\#", "<sharp>", results[0])
  435. aa = re.search("^([^\n]*)(#(?:[^\n]*))$", g)
  436. if(aa):
  437. results = aa.groups()
  438. nosharp = re.sub("<sharp>", "#", results[0])
  439. data = re.sub('^#(?:redirect|넘겨주기) ([^\n]*)$', '<meta http-equiv="refresh" content="0;url=/w/' + url_pas(nosharp) + '/from/' + url_pas(title) + results[1] + '" />', data, 1)
  440. else:
  441. nosharp = re.sub("<sharp>", "#", g)
  442. data = re.sub('^#(?:redirect|넘겨주기) ([^\n]*)$', '<meta http-equiv="refresh" content="0;url=/w/' + url_pas(nosharp) + '/from/' + url_pas(title) + '" />', data, 1)
  443. backlink_plus(title, results[0], 'redirect', num)
  444. else:
  445. break
  446. data = '\n' + data + '\n'
  447. data = re.sub("\[nicovideo\((?P<in>[^,)]*)(?:(?:,(?:[^,)]*))+)?\)\]", "[[http://embed.nicovideo.jp/watch/\g<in>]]", data)
  448. while(1):
  449. m = re.search("\n&gt;\s?((?:[^\n]*)(?:(?:(?:(?:\n&gt;\s?)(?:[^\n]*))+)?))", data)
  450. if(m):
  451. result = m.groups()
  452. blockquote = result[0]
  453. blockquote = re.sub("\n&gt;\s?", "\n", blockquote)
  454. data = re.sub("\n&gt;\s?((?:[^\n]*)(?:(?:(?:(?:\n&gt;\s?)(?:[^\n]*))+)?))", "\n<blockquote>" + blockquote + "</blockquote>", data, 1)
  455. else:
  456. break
  457. if(not re.search('\[목차\]', data)):
  458. if(not re.search('\[목차\(없음\)\]', data)):
  459. data = re.sub("(?P<in>(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n)", "[목차]\n\g<in>", data, 1)
  460. else:
  461. data = re.sub("\[목차\(없음\)\]", "", data)
  462. data = re.sub("(\n)(?P<in>\r\n(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n)", "\g<in>", data)
  463. data = toc_pas(data, title)
  464. category = ''
  465. while(1):
  466. m = re.search("\[\[(분류:(?:(?:(?!\]\]).)*))\]\]", data)
  467. if(m):
  468. g = m.groups()
  469. if(title != g[0]):
  470. cat_plus(title, g[0], num)
  471. if(category == ''):
  472. curs.execute("select title from data where title = ?", [g[0]])
  473. exists = curs.fetchall()
  474. if(exists):
  475. red = ""
  476. else:
  477. red = 'class="not_thing"'
  478. category += '<a ' + red + ' href="/w/' + url_pas(g[0]) + '">' + re.sub("분류:", "", g[0]) + '</a>'
  479. else:
  480. curs.execute("select title from data where title = ?", [g[0]])
  481. exists = curs.fetchall()
  482. if(exists):
  483. red = ""
  484. else:
  485. red = 'class="not_thing"'
  486. category += ' / ' + '<a ' + red + ' href="/w/' + url_pas(g[0]) + '">' + re.sub("분류:", "", g[0]) + '</a>'
  487. data = re.sub("\[\[(분류:(?:(?:(?!\]\]).)*))\]\]", '', data, 1)
  488. else:
  489. break
  490. data = re.sub("&#x27;&#x27;&#x27;(?P<in>(?:(?!&#x27;).)*)&#x27;&#x27;&#x27;", '<b>\g<in></b>', data)
  491. data = re.sub("&#x27;&#x27;(?P<in>(?:(?!&#x27;).)*)&#x27;&#x27;", '<i>\g<in></i>', data)
  492. data = re.sub('(?:~~|--)(?P<in>(?:(?!~~|--).)*)(?:~~|--)', '<s>\g<in></s>', data)
  493. data = re.sub('__(?P<in>.+?)__(?!_)', '<u>\g<in></u>', data)
  494. data = re.sub('\^\^(?P<in>.+?)\^\^(?!\^)', '<sup>\g<in></sup>', data)
  495. data = re.sub(',,(?P<in>.+?),,(?!,)', '<sub>\g<in></sub>', data)
  496. data = re.sub('&lt;math&gt;(?P<in>((?!&lt;math&gt;).)*)&lt;\/math&gt;', '$\g<in>$', data)
  497. data = re.sub('{{\|(?P<in>(?:(?:(?:(?!\|}}).)*)(?:\n?))+)\|}}', '<table> \
  498. <tbody> \
  499. <tr> \
  500. <td> \
  501. \g<in> \
  502. </td> \
  503. </tr> \
  504. </tbody> \
  505. </table>', data)
  506. data = re.sub('\[ruby\((?P<in>[^\,]*)\,\s?(?P<out>[^\)]*)\)\]', '<ruby> \
  507. \g<in> \
  508. <rp>(</rp> \
  509. <rt>\g<out></rt> \
  510. <rp>)</rp> \
  511. </ruby>', data)
  512. data = re.sub("##\s?(?P<in>[^\n]*)\n", "<div style='display:none;'>\g<in></div>", data)
  513. test = re.findall('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', data)
  514. if(test):
  515. for wiki in test:
  516. if(wiki[1]):
  517. data = re.sub('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', '<a id="inside" href="/' + wiki[0] + '">' + wiki[1] + '</a>', data, 1)
  518. else:
  519. data = re.sub('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', '<a id="inside" href="/' + wiki[0] + '">' + wiki[0] + '</a>', data, 1)
  520. while(1):
  521. m = re.search("\[\[(파일|외부):((?:(?!\]\]|\|).)*)(?:\|((?:(?!\]\]).)*))?\]\]", data)
  522. if(m):
  523. img_d = m.groups()
  524. if(img_d):
  525. if(img_d[0] == '파일' and not re.search("^파일:([^\n]*)", title)):
  526. backlink_plus(title, '파일:' + img_d[1], 'file', num)
  527. width = ''
  528. height = ''
  529. if(img_d[2]):
  530. width_r = re.search("width=([^ \n&]*)", img_d[2])
  531. height_r = re.search("height=([^ \n&]*)", img_d[2])
  532. if(width_r):
  533. width_d = width_r.groups()
  534. width = width_d[0]
  535. if(height_r):
  536. height_d = height_r.groups()
  537. height = height_d[0]
  538. if(img_d[0] == '파일'):
  539. img_e = re.search('^(.+)(\.(?:.+))$', img_d[1]).groups()
  540. data = re.sub("\[\[(파일|외부):((?:(?!\]\]|\|).)*)(?:\|((?:(?!\]\]).)*))?\]\]", '<a href="/w/파일:' + img_d[1] + '"><img src="/image/' + sha224(img_e[0]) + img_e[1] + '" width="' + width + '" height="' + height + '"></a>', data, 1)
  541. else:
  542. data = re.sub("\[\[(파일|외부):((?:(?!\]\]|\|).)*)(?:\|((?:(?!\]\]).)*))?\]\]", '<img src="' + img_d[1] + '" width="' + width + '" height="' + height + '">', data, 1)
  543. else:
  544. break
  545. else:
  546. break
  547. data = re.sub("\[br\]",'<br>', data)
  548. while(1):
  549. com = re.compile("\[youtube\(([^, )]*)(,[^)]*)?\)\]")
  550. m = com.search(data)
  551. if(m):
  552. src = ''
  553. width = '560'
  554. height = '315'
  555. time = '0'
  556. result = m.groups()
  557. if(result[0]):
  558. yudt = re.search('(?:\?v=(.*)|\/([^/?]*)|^([a-zA-Z0-9\-]*))$', result[0])
  559. if(yudt):
  560. if(yudt.groups()[0]):
  561. src = yudt.groups()[0]
  562. elif(yudt.groups()[1]):
  563. src = yudt.groups()[1]
  564. elif(yudt.groups()[2]):
  565. src = yudt.groups()[2]
  566. else:
  567. src = ''
  568. if(result[1]):
  569. mdata = re.search('width=([0-9]*)', result[1])
  570. if(mdata):
  571. width = mdata.groups()[0]
  572. mdata = re.search('height=([0-9]*)', result[1])
  573. if(mdata):
  574. height = mdata.groups()[0]
  575. mdata = re.search('time=([0-9]*)', result[1])
  576. if(mdata):
  577. time = mdata.groups()[0]
  578. data = com.sub('<iframe width="' + width + '" height="' + height + '" src="https://www.youtube.com/embed/' + src + '?start=' + time + '" frameborder="0" allowfullscreen></iframe><br>', data, 1)
  579. else:
  580. break
  581. data = re.sub("\[\[(?::(?P<in>(?:분류|파일):(?:(?:(?!\]\]).)*)))\]\]", "[[\g<in>]]", data)
  582. a = re.findall('\[\[\.\.\/(\|(?:[^\]]*))?\]\]', data)
  583. for i in a:
  584. b = re.search('(.*)\/', title)
  585. if(b):
  586. m = b.groups()
  587. if(i):
  588. data = re.sub('\[\[\.\.\/(\|(?:[^\]]*))?\]\]', '[[' + m[0] + i + ']]', data, 1)
  589. else:
  590. data = re.sub('\[\[\.\.\/(\|(?:[^\]]*))?\]\]', '[[' + m[0] + ']]', data, 1)
  591. else:
  592. if(i):
  593. data = re.sub('\[\[\.\.\/(\|(?:[^\]]*))?\]\]', '[[' + title + i + ']]', data, 1)
  594. else:
  595. data = re.sub('\[\[\.\.\/(\|(?:[^\]]*))?\]\]', '[[' + title + ']]', data, 1)
  596. data = re.sub('\[\[(?P<in>\/[^\]|]*)(?P<out>\|(?:[^\]]*))?\]\]', '[[' + title + '\g<in>\g<out>]]', data)
  597. while(1):
  598. m = re.search("\[\[(((?!\]\]).)*)\]\]", data)
  599. if(m):
  600. result = m.groups()
  601. rep = result[0]
  602. rep = re.sub("\\\#", "<sharp>", rep)
  603. a = re.search("^((?:(?!\|).)*)(?:\|(.*))?$", rep)
  604. results = a.groups()
  605. aa = re.search("^([^#]*)(#(?:.*))?$", results[0])
  606. if(results[1]):
  607. g = re.sub("<sharp>", "#", results[1])
  608. else:
  609. g = re.sub("<sharp>", "#", results[0])
  610. results = aa.groups()
  611. if(not results[1]):
  612. sharp = ''
  613. else:
  614. sharp = results[1]
  615. b = re.search("^http(?:s)?:\/\/", results[0])
  616. if(b):
  617. comp = re.compile("(?:\.(?:jpg|png|gif|jpeg))", re.I)
  618. c = comp.search(results[0])
  619. if(c):
  620. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" rel="nofollow" target="_blank" href="' + results[0] + sharp + '">' + g + '</a>', data, 1)
  621. else:
  622. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" rel="nofollow" target="_blank" href="' + results[0] + sharp + '">' + g + '</a>', data, 1)
  623. else:
  624. if(results[0] == title):
  625. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<b>' + g + '</b>', data, 1)
  626. else:
  627. nosharp = re.sub("<sharp>", "#", results[0])
  628. curs.execute("select title from data where title = ?", [nosharp])
  629. y = curs.fetchall()
  630. if(y):
  631. clas = ''
  632. else:
  633. clas = 'not_thing'
  634. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a title="' + re.sub('#', '\#', nosharp) + sharp + '" class="' + clas + '" href="/w/' + url_pas(nosharp) + sharp + '">' + g + '</a>', data, 1)
  635. backlink_plus(title, results[0], '', num)
  636. else:
  637. break
  638. while(1):
  639. m = re.search("((?:(?:( +)\*\s(?:[^\n]*))\n?)+)", data)
  640. if(m):
  641. result = m.groups()
  642. end = str(result[0])
  643. while(1):
  644. isspace = re.search("( +)\*\s([^\n]*)", end)
  645. if(isspace):
  646. spacebar = isspace.groups()
  647. up = len(spacebar[0]) * 20
  648. end = re.sub("( +)\*\s([^\n]*)", "<li style='margin-left:" + str(up) + "px'>" + spacebar[1] + "</li>", end, 1)
  649. else:
  650. break
  651. end = re.sub("\n", '', end)
  652. data = re.sub("(?:(?:(?:( +)\*\s([^\n]*))\n?)+)", '<ul id="list">' + end + '</ul>', data, 1)
  653. else:
  654. break
  655. now_time = get_time()
  656. data = re.sub('\[date\]', now_time, data)
  657. time_data = re.search('^([0-9]{4})-([0-9]{2})-([0-9]{2})', now_time)
  658. time = time_data.groups()
  659. age_data = re.findall('\[age\(([0-9]{4})-([0-9]{2})-([0-9]{2})\)\]', data)
  660. for age in age_data:
  661. year = int(time[0]) - int(age[0])
  662. if(age[1] > time[1]):
  663. year -= 1
  664. elif(age[1] == time[1]):
  665. if(age[2] > time[2]):
  666. year -= 1
  667. data = re.sub('\[age\(([0-9]{4})-([0-9]{2})-([0-9]{2})\)\]', str(year), data, 1)
  668. data = re.sub("-{4,11}", "<hr>", data)
  669. while(1):
  670. b = re.search("(<\/h[0-9]>|\n)( +)", data)
  671. if(b):
  672. result = b.groups()
  673. up = re.sub(' ', '<span id="in"></span>', result[1])
  674. if(re.search('<\/h[0-9]>', result[0])):
  675. data = re.sub("(?P<in>\/h[0-9]>)( +)", '\g<in>' + up, data, 1)
  676. else:
  677. data = re.sub("(?:\n)( +)", '<br>' + up, data, 1)
  678. else:
  679. break
  680. a = 1
  681. tou = "<hr id='footnote'><div><br>"
  682. namu = []
  683. while(1):
  684. b = re.search("\[\*([^\s]*)(?:\s(((?!\[|\]).)*))?\]", data)
  685. if(b):
  686. results = b.groups()
  687. if(not results[1] and results[0]):
  688. i = 0
  689. while(1):
  690. try:
  691. if(namu[i] == results[0]):
  692. none_this = 0
  693. break
  694. else:
  695. i += 2
  696. except:
  697. none_this = 1
  698. break
  699. if(none_this == 0):
  700. data = re.sub("\[\*([^\s]*)(?:\s(((?!\[|\]).)*))?\]", "<sup><a title=\"" + namu[i + 1] + "\" id=\"rfn-" + str(a) + "\" href=\"#fn-" + str(a) + "\">[" + results[0] + "]</a></sup>", data, 1)
  701. else:
  702. data = re.sub("\[\*([^\s]*)(?:\s(((?!\[|\]).)*))?\]", "<sup><a id=\"rfn-" + str(a) + "\" href=\"#fn-" + str(a) + "\">[" + results[0] + "]</a></sup>", data, 1)
  703. elif(results[0]):
  704. namu += [results[0]]
  705. namu += [results[1]]
  706. c = results[1]
  707. c = re.sub("<(?:[^>]*)>", '', c)
  708. tou += "<span id='footnote-list'><a href=\"#rfn-" + str(a) + "\" id=\"fn-" + str(a) + "\">[" + results[0] + "]</a> " + results[1] + "</span><br>"
  709. data = re.sub("\[\*([^\s]*)(?:\s(((?!\[|\]).)*))?\]", "<sup><a title=\"" + c + "\" id=\"rfn-" + str(a) + "\" href=\"#fn-" + str(a) + "\">[" + results[0] + "]</a></sup>", data, 1)
  710. a += 1
  711. else:
  712. c = results[1]
  713. c = re.sub("<(?:[^>]*)>", '', c)
  714. tou += "<span id='footnote-list'><a href=\"#rfn-" + str(a) + "\" id=\"fn-" + str(a) + "\">[" + str(a) + "]</a> " + results[1] + "</span><br>"
  715. data = re.sub("\[\*([^\s]*)(?:\s(((?!\[|\]).)*))?\]", '<sup><a title="' + c + '" id="rfn-' + str(a) + '" href="#fn-' + str(a) + '">[' + str(a) + ']</a></sup>', data, 1)
  716. a += 1
  717. else:
  718. tou += '</div>'
  719. if(tou == "<hr id='footnote'><div><br></div>"):
  720. tou = ""
  721. break
  722. data = re.sub("\[각주\](?:(?:<br>| |\r|\n)+)?$", "", data)
  723. data = re.sub("(?:(?:<br>| |\r|\n)+)$", "", data)
  724. data = re.sub("\[각주\]", "<br>" + tou, data)
  725. data += tou
  726. if(category):
  727. data += '<div id="cate">분류: ' + category + '</div>'
  728. data = re.sub("(?:\|\|\r\n)", "#table#<tablenobr>", data)
  729. while(1):
  730. y = re.search("(\|\|(?:(?:(?:(?:(?!\|\|).)*)(?:\n?))+))", data)
  731. if(y):
  732. a = y.groups()
  733. mid_data = re.sub("\|\|", "#table#", a[0])
  734. mid_data = re.sub("\r\n", "<br>", mid_data)
  735. data = re.sub("(\|\|((?:(?:(?:(?!\|\|).)*)(?:\n?))+))", mid_data, data, 1)
  736. else:
  737. break
  738. data = re.sub("#table#", "||", data)
  739. data = re.sub("<tablenobr>", "\r\n", data)
  740. while(1):
  741. m = re.search("(\|\|(?:(?:(?:.*)\n?)\|\|)+)", data)
  742. if(m):
  743. results = m.groups()
  744. table = results[0]
  745. while(1):
  746. a = re.search("^(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", table)
  747. if(a):
  748. row = ''
  749. cel = ''
  750. celstyle = ''
  751. rowstyle = ''
  752. alltable = ''
  753. table_d = ''
  754. result = a.groups()
  755. if(result[1]):
  756. table_d = table_p(result[1], result[0])
  757. alltable = table_d[0]
  758. rowstyle = table_d[1]
  759. celstyle = table_d[2]
  760. row = table_d[3]
  761. cel = table_d[4]
  762. table = re.sub("^(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "<table " + alltable + "> \
  763. <tbody> \
  764. <tr " + rowstyle + "> \
  765. <td " + cel + " " + row + " " + celstyle + ">", table, 1)
  766. else:
  767. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  768. table = re.sub("^(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "<table> \
  769. <tbody> \
  770. <tr> \
  771. <td " + cel + ">", table, 1)
  772. else:
  773. break
  774. table = re.sub("\|\|$", "</td> \
  775. </tr> \
  776. </tbody> \
  777. </table>", table)
  778. while(1):
  779. b = re.search("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", table)
  780. if(b):
  781. row = ''
  782. cel = ''
  783. celstyle = ''
  784. rowstyle = ''
  785. table_d = ''
  786. result = b.groups()
  787. if(result[1]):
  788. table_d = table_p(result[1], result[0])
  789. rowstyle = table_d[1]
  790. celstyle = table_d[2]
  791. row = table_d[3]
  792. cel = table_d[4]
  793. table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td> \
  794. </tr> \
  795. <tr " + rowstyle + "> \
  796. <td " + cel + " " + row + " " + celstyle + ">", table, 1)
  797. else:
  798. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  799. table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td> \
  800. </tr> \
  801. <tr> \
  802. <td " + cel + ">", table, 1)
  803. else:
  804. break
  805. while(1):
  806. c = re.search("(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", table)
  807. if(c):
  808. row = ''
  809. cel = ''
  810. celstyle = ''
  811. table_d = ''
  812. result = c.groups()
  813. if(result[1]):
  814. table_d = table_p(result[1], result[0])
  815. celstyle = table_d[2]
  816. row = table_d[3]
  817. cel = table_d[4]
  818. table = re.sub("(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td> \
  819. <td " + cel + " " + row + " " + celstyle + ">", table, 1)
  820. else:
  821. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  822. table = re.sub("(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td> \
  823. <td " + cel + ">", table, 1)
  824. else:
  825. break
  826. data = re.sub("(\|\|(?:(?:(?:.*)\n?)\|\|)+)", table, data, 1)
  827. else:
  828. break
  829. data = re.sub("\r\n(?P<in><h[0-6])", "\g<in>", data)
  830. data = re.sub("(\n<nobr>|<nobr>\n|<nobr>)", "", data)
  831. data = re.sub("<nowiki>(?P<in>.)<\/nowiki>", "\g<in>", data)
  832. data = re.sub("<space>", " ", data)
  833. data = re.sub('<\/blockquote>(?:(?:\r)?\n){2}<blockquote>', '</blockquote><blockquote>', data)
  834. data = re.sub('<\/blockquote>(?:(?:\r)?\n)<br><blockquote>', '</blockquote><blockquote>', data)
  835. data = re.sub('\n', '<br>', data)
  836. data = re.sub('<isbr>', '\r\n', data)
  837. data = re.sub('^<br>', '', data)
  838. data += "<script> \
  839. function folding(num) { \
  840. var fol = document.getElementById('folding_' + num); \
  841. if(fol.style.display == 'inline-block' || fol.style.display == 'block') { \
  842. fol.style.display = 'none'; \
  843. } else { \
  844. if(num % 3 == 0) { \
  845. fol.style.display = 'block'; \
  846. } else { \
  847. fol.style.display = 'inline-block'; \
  848. } \
  849. } \
  850. } \
  851. </script>"
  852. conn.commit()
  853. return(data)