| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033 |
- from func import *
- json_data = open('set.json').read()
- set_data = json.loads(json_data)
- conn = pymysql.connect(host = set_data['host'], user = set_data['user'], password = set_data['pw'], charset = 'utf8mb4')
- curs = conn.cursor(pymysql.cursors.DictCursor)
-
- def db_get():
- return curs.fetchall()
-
- db_ex = curs.execute
- db_pas = pymysql.escape_string
- db_ex("use " + set_data['db'])
- def savemark(data):
- data = re.sub("\[date\(now\)\]", get_time(), data)
-
- if(not re.search("\.", ip_check())):
- name = '[[사용자:' + ip_check() + '|' + ip_check() + ']]'
- else:
- name = ip_check()
-
- data = re.sub("\[name\]", name, data)
- return data
- def html_pas(data):
- while(True):
- y = re.search("<((div|span|embed|iframe)(?:[^>]*))>", data)
-
- if(y):
- b = y.groups()
- if(re.search("<(\/" + b[1] + ")>", data)):
- XSS = re.search('src=(?:"|\')http(?:s)?:\/\/([^\/]*)\/(?:[^"\']*)(?:"|\')', b[0])
-
- if(XSS):
- check = XSS.groups()
-
- if(check[0] == "www.youtube.com" or check[0] == "serviceapi.nmv.naver.com" or check[0] == "tv.kakao.com" or check[0] == "tvple.com"):
- a = b[0]
- else:
- a = re.sub('src=(?:"|\')([^"\']*)(?:"|\')', '', b[0])
- else:
- a = b[0]
-
- a = re.sub('(?:"|\')', '#.#', a)
- data = re.sub("<((?:\/)?" + b[1] + "(?:[^>]*))>", "[" + a + "]", data, 1)
- data = re.sub("<\/" + b[1] + ">", "[/" + b[1] + "]", data, 1)
- else:
- data = re.sub("<((?:\/)?" + b[1] + "(?:[^>]*))>", '<' + b[0] + '>', data, 1)
-
- break
- else:
- break
- data = re.sub('<', '<', data)
- data = re.sub('>', '>', data)
- data = re.sub('"', '"', data)
-
- data = re.sub("\[(?P<in>(?:\/)?(?:div|span|embed|iframe)(?:[^\]]*))\]", "<\g<in>>", data)
- data = re.sub('#.#', '"', data)
-
- return data
-
- def mid_pas(data, fol_num, include):
- while(True):
- com = re.compile("{{{((?:(?!{{{)(?!}}}).)*)}}}", re.DOTALL)
- y = com.search(data)
-
- if(y):
- a = y.groups()
-
- big_a = re.compile("^\+([1-5])\s(.*)$", re.DOTALL)
- big = big_a.search(a[0])
-
- small_a = re.compile("^\-([1-5])\s(.*)$", re.DOTALL)
- small = small_a.search(a[0])
-
- color_a = re.compile("^(#[0-9a-f-A-F]{6})\s(.*)$", re.DOTALL)
- color = color_a.search(a[0])
-
- color_b = re.compile("^(#[0-9a-f-A-F]{3})\s(.*)$", re.DOTALL)
- color_2 = color_b.search(a[0])
-
- color_c = re.compile("^#(\w+)\s(.*)$", re.DOTALL)
- color_3 = color_c.search(a[0])
-
- back_a = re.compile("^@([0-9a-f-A-F]{6})\s(.*)$", re.DOTALL)
- back = back_a.search(a[0])
-
- back_b = re.compile("^@([0-9a-f-A-F]{3})\s(.*)$", re.DOTALL)
- back_2 = back_b.search(a[0])
-
- back_c = re.compile("^@(\w+)\s(.*)$", re.DOTALL)
- back_3 = back_c.search(a[0])
-
- include_out_a = re.compile("^#!noin\s(.*)$", re.DOTALL)
- include_out = include_out_a.search(a[0])
-
- div_a = re.compile("^#!wiki\sstyle="((?:(?!"|\n).)*)"\n?\s\n(.*)$", re.DOTALL)
- div = div_a.search(a[0])
-
- html_a = re.compile("^#!html\s(.*)$", re.DOTALL)
- html = html_a.search(a[0])
-
- fol_a = re.compile("^#!folding\s((?:(?!\n).)*)\n?\s\n(.*)$", re.DOTALL)
- fol = fol_a.search(a[0])
-
- if(big):
- result = big.groups()
- data = com.sub('<span class="font-size-' + result[0] + '">' + result[1] + '</span>', data, 1)
- elif(small):
- result = small.groups()
- data = com.sub('<span class="font-size-small-' + result[0] + '">' + result[1] + '</span>', data, 1)
- elif(color):
- result = color.groups()
- data = com.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', data, 1)
- elif(color_2):
- result = color_2.groups()
- data = com.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', data, 1)
- elif(color_3):
- result = color_3.groups()
- data = com.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', data, 1)
- elif(back):
- result = back.groups()
- data = com.sub('<span style="background:#' + result[0] + '">' + result[1] + '</span>', data, 1)
- elif(back_2):
- result = back_2.groups()
- data = com.sub('<span style="background:#' + result[0] + '">' + result[1] + '</span>', data, 1)
- elif(back_3):
- result = back_3.groups()
- data = com.sub('<span style="background:' + result[0] + '">' + result[1] + '</span>', data, 1)
- elif(div):
- result = div.groups()
- data = com.sub('<div style="' + result[0] + '">' + result[1] + '</div>', data, 1)
- elif(html):
- result = html.groups()
- data = com.sub(result[0], data, 1)
- elif(fol):
- result = fol.groups()
- data = com.sub("<div>" + result[0] + "<span style='float:right;'><div id='folding_" + str(fol_num + 1) + "' style='display:block;'>[<a href='javascript:void(0);' onclick='var f=document.getElementById(\"folding_" + str(fol_num) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";this.className=s?\"\":\"opened\";var f=document.getElementById(\"folding_" + str(fol_num + 1) + "\");var s=f.style.display==\"none\";f.style.display=s?\"block\":\"none\";var f=document.getElementById(\"folding_" + str(fol_num + 2) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";'>펼치기</a>]</div><div id='folding_" + str(fol_num + 2) + "' style='display:none;'>[<a href='javascript:void(0);' onclick='var f=document.getElementById(\"folding_" + str(fol_num) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";this.className=s?\"\":\"opened\";var f=document.getElementById(\"folding_" + str(fol_num + 1) + "\");var s=f.style.display==\"none\";f.style.display=s?\"block\":\"none\";var f=document.getElementById(\"folding_" + str(fol_num + 2) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";'>접기</a>]</div></a></span><div id='folding_" + str(fol_num) + "' style='display:none;'><br>" + result[1] + "</div></div>", data, 1)
-
- fol_num += 3
- elif(html):
- result = html.groups()
- data = com.sub(result[0], data, 1)
- elif(include_out):
- if(include == True):
- data = com.sub("", data, 1)
- else:
- result = include_out.groups()
- data = com.sub(result[0], data, 1)
- else:
- data = com.sub('<code>' + a[0] + '</code>', data, 1)
- else:
- break
-
- while(True):
- com = re.compile("<code>(((?!<\/code>).)*)<\/code>", re.DOTALL)
- y = com.search(data)
- if(y):
- a = y.groups()
-
- mid_data = re.sub("<\/span>", "}}}", a[0])
- mid_data = re.sub("<\/div>", "}}}", mid_data)
- mid_data = re.sub('<span class="font\-size\-(?P<in>[1-6])">', "{{{+\g<in> ", mid_data)
- mid_data = re.sub('<span class="font\-size\-small\-(?P<in>[1-6])">', "{{{-\g<in> ", mid_data)
- mid_data = re.sub('<span style="color:(?:#)?(?P<in>[^"]*)">', "{{{#\g<in> ", mid_data)
- mid_data = re.sub('<span style="background:(?:#)?(?P<in>[^"]*)">', "{{{@\g<in> ", mid_data)
- mid_data = re.sub('<div style="(?P<in>[^"]*)">', "{{{#!wiki style="\g<in>"\n", mid_data)
- mid_data = re.sub("(?P<in>.)", "<span>\g<in></span>", mid_data)
-
- data = com.sub(mid_data, data, 1)
- else:
- break
-
- data = re.sub("<span>&</span><span>l</span><span>t</span><span>;</span>", "<span><</span>", data)
- data = re.sub("<span>&</span><span>g</span><span>t</span><span>;</span>", "<span>></span>", data)
-
- return (data, fol_num)
- def backlink_plus(name, link, backtype):
- db_ex("select title from back where title = '" + db_pas(link) + "' and link = '" + db_pas(name) + "' and type = '" + backtype + "'")
- y = db_get()
- if(not y):
- db_ex("insert into back (title, link, type) value ('" + db_pas(link) + "', '" + db_pas(name) + "', '" + backtype + "')")
- db_com()
- def cat_plus(name, link):
- db_ex("select title from cat where title = '" + db_pas(link) + "' and cat = '" + db_pas(name) + "'")
- y = db_get()
- if(not y):
- db_ex("insert into cat (title, cat) value ('" + db_pas(link) + "', '" + db_pas(name) + "')")
- db_com()
- def namumark(title, data):
- data = html_pas(data)
- b = 0
- a = mid_pas(data, b, False)
-
- data = a[0]
- b = a[1]
-
- data = re.sub("\[anchor\((?P<in>[^\[\]]*)\)\]", '<span id="\g<in>"></span>', data)
- data = savemark(data)
- i = 1
- while(True):
- m = re.search("\n((?:(?:#\s?(?:[^\n]*))\n?)+)", data)
- if(m):
- result = m.groups()
- test = result[0]
- while(True):
- if(re.search("(?:#\s?(?:[^\n]*))", test)):
- test = re.sub("(?:#\s?(?P<in>[^\n]*))", str(i) + ". \g<in>", test, 1)
- else:
- break
- i += 1
- data = re.sub("\n((?:(?:#\s?(?:[^\n]*))\n?)+)", '\n' + test, data, 1)
- i = 1
- else:
- break
-
- while(True):
- m = re.search("\[include\(((?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\]", data)
- if(m):
- results = m.groups()
- if(results[0] == title):
- data = re.sub("\[include\(((?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\]", "<b>" + results[0] + "</b>", data, 1)
- else:
- db_ex("select * from data where title = '" + db_pas(results[0]) + "'")
- in_con = db_get()
-
- backlink_plus(title, results[0], 'include')
- if(in_con):
- in_data = in_con[0]['data']
- in_data = re.sub("\[include\(((?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\]", "", in_data)
-
- in_data = html_pas(in_data)
- in_data = mid_pas(in_data, b, True)[0]
-
- if(results[1]):
- a = results[1]
- while(True):
- g = re.search("([^= ,]*)\=([^,]*)", a)
- if(g):
- result = g.groups()
- in_data = re.sub("@" + result[0] + "@", result[1], in_data)
- a = re.sub("([^= ,]*)\=([^,]*)", "", a, 1)
- else:
- break
- data = re.sub("\[include\(((?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\]", '\n#nobr#<div>' + in_data + '</div>\n#nobr#', data, 1)
- else:
- data = re.sub("\[include\(((?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\]", "<a class=\"not_thing\" href=\"" + url_pas(results[0]) + "\">" + results[0] + "</a>", data, 1)
- else:
- break
-
- while(True):
- m = re.search('^#(?:redirect|넘겨주기)\s([^\n]*)', data)
- if(m):
- results = m.groups()
- aa = re.search("^(.*)(#(?:.*))$", results[0])
- if(aa):
- results = aa.groups()
- data = re.sub('^#(?:redirect|넘겨주기)\s([^\n]*)', '<meta http-equiv="refresh" content="0;url=/w/' + url_pas(results[0]) + '/from/' + url_pas(title) + results[1] + '" />', data, 1)
- else:
- data = re.sub('^#(?:redirect|넘겨주기)\s([^\n]*)', '<meta http-equiv="refresh" content="0;url=/w/' + url_pas(results[0]) + '/from/' + url_pas(title) + '" />', data, 1)
-
- backlink_plus(title, results[0], 'redirect')
- else:
- break
- data = '\n' + data + '\n'
-
- while(True):
- m = re.search("\n>\s?((?:[^\n]*)(?:(?:(?:(?:\n>\s?)(?:[^\n]*))+)?))", data)
- if(m):
- result = m.groups()
- blockquote = result[0]
- blockquote = re.sub("\n>\s?", "\n", blockquote)
- data = re.sub("\n>\s?((?:[^\n]*)(?:(?:(?:(?:\n>\s?)(?:[^\n]*))+)?))", "\n<blockquote>" + blockquote + "</blockquote>", data, 1)
- else:
- break
-
- m = re.search('\[목차\]', data)
- if(not m):
- data = re.sub("(?P<in>(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n)", "[목차]\n\g<in>", data, 1)
-
- data = re.sub("(\n)(?P<in>\r\n(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n)", "\g<in>", data)
-
- i = 0
- h0c = 0
- h1c = 0
- h2c = 0
- h3c = 0
- h4c = 0
- h5c = 0
- last = 0
- rtoc = '<div id="toc"><span id="toc-name">목차</span><br><br>'
- while(True):
- i = i + 1
- m = re.search('(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n', data)
- if(m):
- result = m.groups()
- wiki = len(result[0])
- if(last < wiki):
- last = wiki
- else:
- last = wiki
- if(wiki == 1):
- h1c = 0
- h2c = 0
- h3c = 0
- h4c = 0
- h5c = 0
- elif(wiki == 2):
- h2c = 0
- h3c = 0
- h4c = 0
- h5c = 0
- elif(wiki == 3):
- h3c = 0
- h4c = 0
- h5c = 0
- elif(wiki == 4):
- h4c = 0
- h5c = 0
- elif(wiki == 5):
- h5c = 0
- if(wiki == 1):
- h0c = h0c + 1
- elif(wiki == 2):
- h1c = h1c + 1
- elif(wiki == 3):
- h2c = h2c + 1
- elif(wiki == 4):
- h3c = h3c + 1
- elif(wiki == 5):
- h4c = h4c + 1
- else:
- h5c = h5c + 1
- toc = str(h0c) + '.' + str(h1c) + '.' + str(h2c) + '.' + str(h3c) + '.' + str(h4c) + '.' + str(h5c) + '.'
- toc = re.sub("(?P<in>[0-9]0(?:[0]*)?)\.", '\g<in>#.', toc)
- toc = re.sub("0\.", '', toc)
- toc = re.sub("#\.", '.', toc)
- toc = re.sub("\.$", '', toc)
- rtoc = rtoc + '<a href="#s-' + toc + '">' + toc + '</a>. ' + result[1] + '<br>'
- c = re.sub(" $", "", result[1])
- d = c
- c = re.sub("\[\[(([^|]*)\|)?(?P<in>[^\]]*)\]\]", "\g<in>", c)
- data = re.sub('(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n', '<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) + '">편집</a>]</span></h' + str(wiki) + '>', data, 1);
- else:
- rtoc = rtoc + '</div>'
- break
-
- data = re.sub("\[목차\]", rtoc, data)
-
- category = ''
- while(True):
- m = re.search("\[\[(분류:(?:(?:(?!\]\]).)*))\]\]", data)
- if(m):
- g = m.groups()
-
- if(not title == g[0]):
- cat_plus(title, g[0])
-
- if(category == ''):
- db_ex("select title from data where title = '" + db_pas(g[0]) + "'")
- exists = db_get()
- if(exists):
- red = ""
- else:
- red = 'class="not_thing"'
-
- category = category + '<a ' + red + ' href="/w/' + url_pas(g[0]) + '">' + re.sub("분류:", "", g[0]) + '</a>'
- else:
- db_ex("select title from data where title = '" + db_pas(g[0]) + "'")
- exists = db_get()
- if(exists):
- red = ""
- else:
- red = 'class="not_thing"'
-
- category = category + ' / ' + '<a ' + red + ' href="/w/' + url_pas(g[0]) + '">' + re.sub("분류:", "", g[0]) + '</a>'
-
- data = re.sub("\[\[(분류:(?:(?:(?!\]\]).)*))\]\]", '', data, 1)
- else:
- break
- data = re.sub("'''(?P<in>.+?)'''(?!')", '<b>\g<in></b>', data)
- data = re.sub("''(?P<in>.+?)''(?!')", '<i>\g<in></i>', data)
- data = re.sub('~~(?P<in>.+?)~~(?!~)', '<s>\g<in></s>', data)
- data = re.sub('--(?P<in>.+?)--(?!-)', '<s>\g<in></s>', data)
- data = re.sub('__(?P<in>.+?)__(?!_)', '<u>\g<in></u>', data)
- data = re.sub('\^\^(?P<in>.+?)\^\^(?!\^)', '<sup>\g<in></sup>', data)
- data = re.sub(',,(?P<in>.+?),,(?!,)', '<sub>\g<in></sub>', data)
-
- data = re.sub('<math>(?P<in>((?!<math>).)*)<\/math>', '$\g<in>$', data)
-
- data = re.sub('{{\|(?P<in>(?:(?:(?:(?!\|}}).)*)(?:\n?))+)\|}}', '<table><tbody><tr><td>\g<in></td></tr></tbody></table>', data)
-
- data = re.sub('\[ruby\((?P<in>[^\|]*)\|(?P<out>[^\)]*)\)\]', '<ruby>\g<in><rp>(</rp><rt>\g<out></rt><rp>)</rp></ruby>', data)
-
- data = re.sub("##\s?(?P<in>[^\n]*)\n", "<div style='display:none;'>\g<in></div>", data)
-
- while(True):
- m = re.search("\[\[파일:((?:(?!\]\]|\|).)*)(?:\|((?:(?!\]\]).)*))?\]\]", data)
- if(m):
- c = m.groups()
- if(c):
- if(not re.search("^파일:([^\n]*)", title)):
- backlink_plus(title, '파일:' + c[0], 'file')
- if(c[1]):
- n = re.search("width=([^ \n&]*)", c[1])
- e = re.search("height=([^ \n&]*)", c[1])
- if(n):
- a = n.groups()
- width = a[0]
- else:
- width = ''
- if(e):
- b = e.groups()
- height = b[0]
- else:
- height = ''
- extension = re.search("(.+)(\.[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])$", c[0]).groups()
- img = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", extension[1])
- data = re.sub("\[\[파일:((?:(?!\]\]|\?).)*)(?:\?((?:(?!\]\]).)*))?\]\]", '<a href="/w/파일:' + extension[0] + img + '"><img src="/image/' + sha224(extension[0]) + img + '" width="' + width + '" height="' + height + '"></a>', data, 1)
- else:
- extension = re.search("(.+)(\.[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])$", c[0]).groups()
-
- img = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", extension[1])
- data = re.sub("\[\[파일:((?:(?!\]\]|\?).)*)(?:\?((?:(?!\]\]).)*))?\]\]", "<a href='/w/파일:" + extension[0] + img + "'><img src='/image/" + sha224(extension[0]) + img + "'></a>", data, 1)
- else:
- break
- else:
- break
-
- data = re.sub("\[br\]",'<br>', data)
-
- while(True):
- com = re.compile("\[youtube\(((?:(?!,|\)\]).)*)(?:,(?:\s)?)?(?:width=((?:(?!,|\)\]).)*))?(?:,(?:\s)?)?(?:height=((?:(?!,|\)\]).)*))?\)\]")
- m = com.search(data)
- if(m):
- result = m.groups()
- if(result[1]):
- if(result[2]):
- width = result[1]
- height = result[2]
- else:
- width = result[1]
- height = '315'
- elif(result[2]):
- height = result[2]
- width = '560'
- else:
- width = '560'
- height = '315'
- data = com.sub('<iframe width="' + width + '" height="' + height + '" src="https://www.youtube.com/embed/' + result[0] + '" frameborder="0" allowfullscreen></iframe><br>', data, 1)
- else:
- break
-
- data = re.sub("\[\[(?::(?P<in>(?:분류|파일):(?:(?:(?!\]\]).)*)))\]\]", "[[\g<in>]]", data)
-
- while(True):
- m = re.search("\[\[(((?!\]\]).)*)\]\]", data)
- if(m):
- result = m.groups()
- a = re.search("((?:(?!\|).)*)\|(.*)", result[0])
- if(a):
- results = a.groups()
- aa = re.search("^(.*)(#(?:.*))$", results[0])
- if(aa):
- g = results[1]
- results = aa.groups()
- b = re.search("^http(?:s)?:\/\/", results[0])
- if(b):
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + results[0] + results[1] + '">' + g + '</a>', data, 1)
- else:
- if(results[0] == title):
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<b>' + g + '</b>', data, 1)
- else:
- db_ex("select title from data where title = '" + db_pas(results[0]) + "'")
- y = db_get()
- if(y):
- clas = ''
- else:
- clas = 'not_thing'
-
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a title="' + results[0] + results[1] + '" class="' + clas + '" href="/w/' + url_pas(results[0]) + results[1] + '">' + g + '</a>', data, 1)
-
- backlink_plus(title, results[0], '')
- else:
- b = re.search("^http(?:s)?:\/\/", results[0])
- if(b):
- c = re.search("(?:\.[Jj][Pp][Gg]|\.[Pp][Nn][Gg]|\.[Gg][Ii][Ff]|\.[Jj][Pp][Ee][Gg])", results[0])
- if(c):
- img = results[0]
- img = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", img)
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + img + '">' + results[1] + '</a>', data, 1)
- else:
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + results[0] + '">' + results[1] + '</a>', data, 1)
- else:
- if(results[0] == title):
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<b>' + results[1] + '</b>', data, 1)
- else:
- db_ex("select title from data where title = '" + db_pas(results[0]) + "'")
- y = db_get()
- if(y):
- clas = ''
- else:
- clas = 'not_thing'
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a title="' + results[0] + '" class="' + clas + '" href="/w/' + url_pas(results[0]) + '">' + results[1] + '</a>', data, 1)
- backlink_plus(title, results[0], '')
- else:
- aa = re.search("^(.*)(#(?:.*))$", result[0])
- if(aa):
- result = aa.groups()
- b = re.search("^http(?:s)?:\/\/", result[0])
- if(b):
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + result[0] + result[1] + '">' + result[0] + result[1] + '</a>', data, 1)
- else:
- if(result[0] == title):
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<b>' + result[0] + result[1] + '</b>', data, 1)
- else:
- db_ex("select title from data where title = '" + db_pas(result[0]) + "'")
- y = db_get()
- if(y):
- clas = ''
- else:
- clas = 'not_thing'
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a href="/w/' + url_pas(result[0]) + result[1] + '" class="' + clas + '">' + result[0] + result[1] + '</a>', data, 1)
-
- backlink_plus(title, result[0], '')
- else:
- b = re.search("^http(?:s)?:\/\/", result[0])
- if(b):
- c = re.search("(?:\.[Jj][Pp][Gg]|\.[Pp][Nn][Gg]|\.[Gg][Ii][Ff]|\.[Jj][Pp][Ee][Gg])", result[0])
- if(c):
- img = result[0]
- img = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", img)
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + img + '">' + img + '</a>', data, 1)
- else:
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + result[0] + '">' + result[0] + '</a>', data, 1)
- else:
- if(result[0] == title):
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<b>' + result[0] + '</b>', data, 1)
- else:
- db_ex("select title from data where title = '" + db_pas(result[0]) + "'")
- y = db_get()
- if(y):
- clas = ''
- else:
- clas = 'not_thing'
- data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a href="/w/' + url_pas(result[0]) + '" class="' + clas + '">' + result[0] + '</a>', data, 1)
-
- backlink_plus(title, result[0], '')
- else:
- break
-
- while(True):
- com = re.compile("(http(?:s)?:\/\/(?:(?:(?:(?!\.[Jj][Pp][Gg]|\.[Pp][Nn][Gg]|\.[Gg][Ii][Ff]|\.[Jj][Pp][Ee][Gg]|#[Jj][Pp][Gg]#|#[Pp][Nn][Gg]#|#[Gg][Ii][Ff]#|#[Jj][Pp][Ee][Gg]#|<\/(?:[^>]*)>).)*)(?:\.[Jj][Pp][Gg]|\.[Pp][Nn][Gg]|\.[Gg][Ii][Ff]|\.[Jj][Pp][Ee][Gg])))(?:(?:(?:\?)width=((?:[0-9]*)(?:px|%)?))?(?:(?:\?|&)height=((?:[0-9]*)(?:px|%)?))?)")
- m = com.search(data)
- if(m):
- result = m.groups()
- if(result[1]):
- if(result[2]):
- width = result[1]
- height = result[2]
- else:
- width = result[1]
- height = ''
- elif(result[2]):
- height = result[2]
- width = ''
- else:
- width = ''
- height = ''
- c = result[0]
- c = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", c)
- data = com.sub("<img width='" + width + "' height='" + height + "' src='" + c + "'>", data, 1)
- else:
- break
-
- while(True):
- m = re.search("((?:(?:( +)\*\s(?:[^\n]*))\n?)+)", data)
- if(m):
- result = m.groups()
- end = str(result[0])
- while(True):
- isspace = re.search("( +)\*\s([^\n]*)", end)
- if(isspace):
- spacebar = isspace.groups()
- up = len(spacebar[0]) * 20
- end = re.sub("( +)\*\s([^\n]*)", "<li style='margin-left:" + str(up) + "px'>" + spacebar[1] + "</li>", end, 1)
- else:
- break
- end = re.sub("\n", '', end)
- data = re.sub("(?:(?:(?:( +)\*\s([^\n]*))\n?)+)", '<ul id="list">' + end + '</ul>', data, 1)
- else:
- break
-
- data = re.sub('\[date\]', get_time(), data)
- data = re.sub("#(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])#", ".\g<in>", data)
- data = re.sub("-{4,11}", "<hr>", data)
-
- while(True):
- b = re.search("\n( +)", data)
- if(b):
- result = b.groups()
- up = re.sub(' ', '<span id="in"></span>', result[0])
- data = re.sub("\n( +)", '<br>' + up, data, 1)
- else:
- break
-
- a = 1
- tou = "<hr id='footnote'><div class='wiki-macro-footnote'><br>"
- while(True):
- b = re.search("\[\*([^\s]*)\s(((?!\]).)*)\]", data)
- if(b):
- results = b.groups()
- if(results[0]):
- c = results[1]
- c = re.sub("<(?:[^>]*)>", '', c)
- tou = tou + "<span class='footnote-list'><a href=\"#rfn-" + str(a) + "\" id=\"fn-" + str(a) + "\">[" + results[0] + "]</a> " + results[1] + "</span><br>"
- data = re.sub("\[\*([^\s]*)\s(((?!\]).)*)\]", "<sup><a class=\"footnotes\" title=\"" + c + "\" id=\"rfn-" + str(a) + "\" href=\"#fn-" + str(a) + "\">[" + results[0] + "]</a></sup>", data, 1)
- else:
- c = results[1]
- c = re.sub("<(?:[^>]*)>", '', c)
- tou = tou + "<span class='footnote-list'><a href=\"#rfn-" + str(a) + "\" id=\"fn-" + str(a) + "\">[" + str(a) + "]</a> " + results[1] + "</span><br>"
- data = re.sub("\[\*([^\s]*)\s(((?!\]).)*)\]", '<sup><a class="footnotes" title="' + c + '" id="rfn-' + str(a) + '" href="#fn-' + str(a) + '">[' + str(a) + ']</a></sup>', data, 1)
- a = a + 1
- else:
- tou = tou + '</div>'
- if(tou == "<hr id='footnote'><div class='wiki-macro-footnote'><br></div>"):
- tou = ""
- break
-
- data = re.sub("\[각주\](?:(?:<br>| |\r|\n)+)?$", "", data)
- data = re.sub("(?:(?:<br>| |\r|\n)+)$", "", data)
- data = re.sub("\[각주\]", "<br>" + tou, data)
- data = data + tou
-
- if(category):
- data = data + '<div style="width:100%;border: 1px solid #777;padding: 5px;margin-top: 1em;">분류: ' + category + '</div>'
-
- data = re.sub("(?:\|\|\r\n)", "#table#<nobr>", data)
-
- while(True):
- y = re.search("(\|\|(?:(?:(?:(?:(?!\|\|).)*)(?:\n?))+))", data)
- if(y):
- a = y.groups()
-
- mid_data = re.sub("\|\|", "#table#", a[0])
- mid_data = re.sub("\r\n", "<br>", mid_data)
-
- data = re.sub("(\|\|((?:(?:(?:(?!\|\|).)*)(?:\n?))+))", mid_data, data, 1)
- else:
- break
-
- data = re.sub("#table#", "||", data)
- data = re.sub("<nobr>", "\r\n", data)
-
- while(True):
- m = re.search("(\|\|(?:(?:(?:.*)\n?)\|\|)+)", data)
- if(m):
- results = m.groups()
- table = results[0]
- while(True):
- a = re.search("^(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", table)
- if(a):
- row = ''
- cel = ''
- celstyle = ''
- rowstyle = ''
- alltable = ''
- result = a.groups()
- if(result[1]):
- alltable = 'style="'
- celstyle = 'style="'
- rowstyle = 'style="'
- q = re.search("<table\s?width=((?:(?!>).)*)>", result[1])
- w = re.search("<table\s?height=((?:(?!>).)*)>", result[1])
- e = re.search("<table\s?align=((?:(?!>).)*)>", result[1])
- if(q):
- resultss = q.groups()
- alltable = alltable + 'width:' + resultss[0] + ';'
- if(w):
- resultss = w.groups()
- alltable = alltable + 'height:' + resultss[0] + ';'
- if(e):
- resultss = e.groups()
- if(resultss[0] == 'right'):
- alltable = alltable + 'margin-left:auto;'
- elif(resultss[0] == 'center'):
- alltable = alltable + 'margin:auto;'
- else:
- alltable = alltable + 'margin-right:auto;'
-
- ee = re.search("<table\s?textalign=((?:(?!>).)*)>", result[1])
- if(ee):
- resultss = ee.groups()
- if(resultss[0] == 'right'):
- alltable = alltable + 'text-align:right;'
- elif(resultss[0] == 'center'):
- alltable = alltable + 'text-align:center;'
- else:
- alltable = alltable + 'text-align:left;'
-
- r = re.search("<-((?:(?!>).)*)>", result[1])
- if(r):
- resultss = r.groups()
- cel = 'colspan="' + resultss[0] + '"'
- else:
- cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
- t = re.search("<\|((?:(?!>).)*)>", result[1])
- if(t):
- resultss = t.groups()
- row = 'rowspan="' + resultss[0] + '"'
- ba = re.search("<rowbgcolor=(#[0-9a-f-A-F]{6})>", result[1])
- bb = re.search("<rowbgcolor=(#[0-9a-f-A-F]{3})>", result[1])
- bc = re.search("<rowbgcolor=(\w+)>", result[1])
- if(ba):
- resultss = ba.groups()
- rowstyle = rowstyle + 'background:' + resultss[0] + ';'
- elif(bb):
- resultss = bb.groups()
- rowstyle = rowstyle + 'background:' + resultss[0] + ';'
- elif(bc):
- resultss = bc.groups()
- rowstyle = rowstyle + 'background:' + resultss[0] + ';'
-
- z = re.search("<table\s?bordercolor=(#[0-9a-f-A-F]{6})>", result[1])
- x = re.search("<table\s?bordercolor=(#[0-9a-f-A-F]{3})>", result[1])
- c = re.search("<table\s?bordercolor=(\w+)>", result[1])
- if(z):
- resultss = z.groups()
- alltable = alltable + 'border:' + resultss[0] + ' 2px solid;'
- elif(x):
- resultss = x.groups()
- alltable = alltable + 'border:' + resultss[0] + ' 2px solid;'
- elif(c):
- resultss = c.groups()
- alltable = alltable + 'border:' + resultss[0] + ' 2px solid;'
-
- aq = re.search("<table\s?bgcolor=(#[0-9a-f-A-F]{6})>", result[1])
- aw = re.search("<table\s?bgcolor=(#[0-9a-f-A-F]{3})>", result[1])
- ae = re.search("<table\s?bgcolor=(\w+)>", result[1])
- if(aq):
- resultss = aq.groups()
- alltable = alltable + 'background:' + resultss[0] + ';'
- elif(aw):
- resultss = aw.groups()
- alltable = alltable + 'background:' + resultss[0] + ';'
- elif(ae):
- resultss = ae.groups()
- alltable = alltable + 'background:' + resultss[0] + ';'
-
- j = re.search("<bgcolor=(#[0-9a-f-A-F]{6})>", result[1])
- k = re.search("<bgcolor=(#[0-9a-f-A-F]{3})>", result[1])
- l = re.search("<bgcolor=(\w+)>", result[1])
- if(j):
- resultss = j.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(k):
- resultss = k.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(l):
- resultss = l.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
-
- aa = re.search("<(#[0-9a-f-A-F]{6})>", result[1])
- ab = re.search("<(#[0-9a-f-A-F]{3})>", result[1])
- ac = re.search("<(\w+)>", result[1])
- if(aa):
- resultss = aa.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(ab):
- resultss = ab.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(ac):
- resultss = ac.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
-
- qa = re.search("<width=((?:(?!>).)*)>", result[1])
- qb = re.search("<height=((?:(?!>).)*)>", result[1])
- if(qa):
- resultss = qa.groups()
- celstyle = celstyle + 'width:' + resultss[0] + ';'
- if(qb):
- resultss = qb.groups()
- celstyle = celstyle + 'height:' + resultss[0] + ';'
-
- i = re.search("<\)>", result[1])
- o = re.search("<:>", result[1])
- p = re.search("<\(>", result[1])
- if(i):
- celstyle = celstyle + 'text-align:right;'
- elif(o):
- celstyle = celstyle + 'text-align:center;'
- elif(p):
- celstyle = celstyle + 'text-align:left;'
-
- alltable = alltable + '"'
- celstyle = celstyle + '"'
- rowstyle = rowstyle + '"'
-
- table = re.sub("^(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "<table " + alltable + "><tbody><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
- else:
- cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
- table = re.sub("^(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "<table><tbody><tr><td " + cel + ">", table, 1)
- else:
- break
-
- table = re.sub("\|\|$", "</td></tr></tbody></table>", table)
-
- while(True):
- b = re.search("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", table)
- if(b):
- row = ''
- cel = ''
- celstyle = ''
- rowstyle = ''
- result = b.groups()
- if(result[1]):
- celstyle = 'style="'
- rowstyle = 'style="'
-
- r = re.search("<-((?:(?!>).)*)>", result[1])
- if(r):
- resultss = r.groups()
- cel = 'colspan="' + resultss[0] + '"'
- else:
- cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
- t = re.search("<\|((?:(?!>).)*)>", result[1])
- if(t):
- resultss = t.groups()
- row = 'rowspan="' + resultss[0] + '"'
-
- ba = re.search("<rowbgcolor=(#[0-9a-f-A-F]{6})>", result[1])
- bb = re.search("<rowbgcolor=(#[0-9a-f-A-F]{3})>", result[1])
- bc = re.search("<rowbgcolor=(\w+)>", result[1])
- if(ba):
- resultss = ba.groups()
- rowstyle = rowstyle + 'background:' + resultss[0] + ';'
- elif(bb):
- resultss = bb.groups()
- rowstyle = rowstyle + 'background:' + resultss[0] + ';'
- elif(bc):
- resultss = bc.groups()
- rowstyle = rowstyle + 'background:' + resultss[0] + ';'
-
- j = re.search("<bgcolor=(#[0-9a-f-A-F]{6})>", result[1])
- k = re.search("<bgcolor=(#[0-9a-f-A-F]{3})>", result[1])
- l = re.search("<bgcolor=(\w+)>", result[1])
- if(j):
- resultss = j.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(k):
- resultss = k.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(l):
- resultss = l.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- aa = re.search("<(#[0-9a-f-A-F]{6})>", result[1])
- ab = re.search("<(#[0-9a-f-A-F]{3})>", result[1])
- ac = re.search("<(\w+)>", result[1])
- if(aa):
- resultss = aa.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(ab):
- resultss = ab.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(ac):
- resultss = ac.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- qa = re.search("<width=((?:(?!>).)*)>", result[1])
- qb = re.search("<height=((?:(?!>).)*)>", result[1])
- if(qa):
- resultss = qa.groups()
- celstyle = celstyle + 'width:' + resultss[0] + ';'
- if(qb):
- resultss = qb.groups()
- celstyle = celstyle + 'height:' + resultss[0] + ';'
-
- i = re.search("<\)>", result[1])
- o = re.search("<:>", result[1])
- p = re.search("<\(>", result[1])
- if(i):
- celstyle = celstyle + 'text-align:right;'
- elif(o):
- celstyle = celstyle + 'text-align:center;'
- elif(p):
- celstyle = celstyle + 'text-align:left;'
- celstyle = celstyle + '"'
- rowstyle = rowstyle + '"'
-
- table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "</td></tr><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
- else:
- cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
- table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "</td></tr><tr><td " + cel + ">", table, 1)
- else:
- break
- while(True):
- c = re.search("(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", table)
- if(c):
- row = ''
- cel = ''
- celstyle = ''
- result = c.groups()
- if(result[1]):
- celstyle = 'style="'
-
- r = re.search("<-((?:(?!>).)*)>", result[1])
- if(r):
- resultss = r.groups()
- cel = 'colspan="' + resultss[0] + '"';
- else:
- cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
- t = re.search("<\|((?:(?!>).)*)>", result[1])
- if(t):
- resultss = t.groups()
- row = 'rowspan="' + resultss[0] + '"';
-
- j = re.search("<bgcolor=(#[0-9a-f-A-F]{6})>", result[1])
- k = re.search("<bgcolor=(#[0-9a-f-A-F]{3})>", result[1])
- l = re.search("<bgcolor=(\w+)>", result[1])
- if(j):
- resultss = j.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(k):
- resultss = k.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(l):
- resultss = l.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
-
- aa = re.search("<(#[0-9a-f-A-F]{6})>", result[1])
- ab = re.search("<(#[0-9a-f-A-F]{3})>", result[1])
- ac = re.search("<(\w+)>", result[1])
- if(aa):
- resultss = aa.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(ab):
- resultss = ab.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
- elif(ac):
- resultss = ac.groups()
- celstyle = celstyle + 'background:' + resultss[0] + ';'
-
- qa = re.search("<width=((?:(?!>).)*)>", result[1])
- qb = re.search("<height=((?:(?!>).)*)>", result[1])
- if(qa):
- resultss = qa.groups()
- celstyle = celstyle + 'width:' + resultss[0] + ';'
- if(qb):
- resultss = qb.groups()
- celstyle = celstyle + 'height:' + resultss[0] + ';'
-
- i = re.search("<\)>", result[1])
- o = re.search("<:>", result[1])
- p = re.search("<\(>", result[1])
- if(i):
- celstyle = celstyle + 'text-align:right;'
- elif(o):
- celstyle = celstyle + 'text-align:center;'
- elif(p):
- celstyle = celstyle + 'text-align:left;'
- celstyle = celstyle + '"'
-
- table = re.sub("(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "</td><td " + cel + " " + row + " " + celstyle + ">", table, 1)
- else:
- cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
- table = re.sub("(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "</td><td " + cel + ">", table, 1)
- else:
- break
-
- data = re.sub("(\|\|(?:(?:(?:.*)\n?)\|\|)+)", table, data, 1)
- else:
- break
-
- data = re.sub("(\n#nobr#|#nobr#\n|#nobr#)", "", data)
- data = re.sub('<\/blockquote>((\r)?\n){2}<blockquote>', '</blockquote><br><blockquote>', data)
- data = re.sub('\n', '<br>', data)
- data = re.sub('^<br>', '', data)
-
- return data
|