app.py 182 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616
  1. from flask import Flask, request, session, render_template, send_file
  2. app = Flask(__name__)
  3. from urllib import parse
  4. import json
  5. import pymysql
  6. import time
  7. import re
  8. import bcrypt
  9. import os
  10. import difflib
  11. import hashlib
  12. json_data = open('set.json').read()
  13. data = json.loads(json_data)
  14. print('오픈나무 시작 포트 : ' + data['port'])
  15. import logging
  16. log = logging.getLogger('werkzeug')
  17. log.setLevel(logging.ERROR)
  18. def 시작():
  19. try:
  20. DB_실행("select * from data limit 1")
  21. except:
  22. DB_실행("create table data(title text, data longtext, acl text)")
  23. try:
  24. DB_실행("select * from history limit 1")
  25. except:
  26. DB_실행("create table history(id text, title text, data longtext, date text, ip text, send text, leng text)")
  27. try:
  28. DB_실행("select * from rd limit 1")
  29. except:
  30. DB_실행("create table rd(title text, sub text, date text)")
  31. try:
  32. DB_실행("select * from user limit 1")
  33. except:
  34. DB_실행("create table user(id text, pw text, acl text)")
  35. try:
  36. DB_실행("select * from ban limit 1")
  37. except:
  38. DB_실행("create table ban(block text, end text, why text, band text)")
  39. try:
  40. DB_실행("select * from topic limit 1")
  41. except:
  42. DB_실행("create table topic(id text, title text, sub text, data longtext, date text, ip text, block text)")
  43. try:
  44. DB_실행("select * from stop limit 1")
  45. except:
  46. DB_실행("create table stop(title text, sub text, close text)")
  47. try:
  48. DB_실행("select * from rb limit 1")
  49. except:
  50. DB_실행("create table rb(block text, end text, today text, blocker text, why text)")
  51. try:
  52. DB_실행("select * from login limit 1")
  53. except:
  54. DB_실행("create table login(user text, ip text, today text)")
  55. try:
  56. DB_실행("select * from back limit 1")
  57. except:
  58. DB_실행("create table back(title text, link text, type text)")
  59. try:
  60. DB_실행("select * from cat limit 1")
  61. except:
  62. DB_실행("create table cat(title text, cat text)")
  63. try:
  64. DB_실행("select * from hidhi limit 1")
  65. except:
  66. DB_실행("create table hidhi(title text, re text)")
  67. try:
  68. DB_실행("select * from distop limit 1")
  69. except:
  70. DB_실행("create table distop(id text, title text, sub text)")
  71. try:
  72. DB_실행("select * from agreedis limit 1")
  73. except:
  74. DB_실행("create table agreedis(title text, sub text)")
  75. conn = pymysql.connect(host = data['host'], user = data['user'], password = data['pw'], charset = 'utf8mb4')
  76. curs = conn.cursor(pymysql.cursors.DictCursor)
  77. def DB_실행(데이터):
  78. curs.execute(데이터)
  79. def DB_갱신():
  80. conn.commit()
  81. def URL_인코딩(데이터):
  82. return parse.quote(데이터).replace('/','%2F')
  83. def DB_인코딩(데이터):
  84. return pymysql.escape_string(데이터)
  85. try:
  86. DB_실행("use " + data['db'])
  87. except:
  88. DB_실행("create database " + data['db'])
  89. DB_실행("use " + data['db'])
  90. DB_실행("alter database " + data['db'] + " character set = utf8mb4 collate = utf8mb4_unicode_ci")
  91. 시작()
  92. app.secret_key = hashlib.sha512(bytes(data['key'], 'ascii')).hexdigest()
  93. def show_diff(seqm):
  94. output= []
  95. for opcode, a0, a1, b0, b1 in seqm.get_opcodes():
  96. if(opcode == 'equal'):
  97. output.append(seqm.a[a0:a1])
  98. elif(opcode == 'insert'):
  99. output.append("<span style='background:#CFC;'>" + seqm.b[b0:b1] + "</span>")
  100. elif(opcode == 'delete'):
  101. output.append("<span style='background:#FDD;'>" + seqm.a[a0:a1] + "</span>")
  102. elif(opcode == 'replace'):
  103. output.append("<span style='background:#CFC;'>" + seqm.b[b0:b1] + "</span><span style='background:#FDD;'>" + seqm.a[a0:a1] + "</span>")
  104. else:
  105. output.append(seqm.a[a0:a1])
  106. return ''.join(output)
  107. def 관리자_확인():
  108. if(session.get('Now') == True):
  109. ip = getip(request)
  110. DB_실행("select * from user where id = '" + DB_인코딩(ip) + "'")
  111. rows = curs.fetchall()
  112. if(rows):
  113. if(rows[0]['acl'] == 'owner' or rows[0]['acl'] == 'admin'):
  114. return 1
  115. def 소유자_확인():
  116. if(session.get('Now') == True):
  117. ip = getip(request)
  118. DB_실행("select * from user where id = '" + DB_인코딩(ip) + "'")
  119. rows = curs.fetchall()
  120. if(rows):
  121. if(rows[0]['acl'] == 'owner'):
  122. return 1
  123. def isin(name, data):
  124. if(re.search('^틀:', name)):
  125. DB_실행("select * from back where title = '" + DB_인코딩(name) + "' and type = 'include'")
  126. include = curs.fetchall()
  127. if(include):
  128. i = 0
  129. while(True):
  130. try:
  131. namumark(include[i]['link'], data)
  132. except:
  133. break
  134. i = i + 1
  135. def savemark(data):
  136. data = re.sub("\[date\(now\)\]", 시간(), data)
  137. if(not re.search("\.", getip(request))):
  138. name = '[[사용자:' + getip(request) + '|' + getip(request) + ']]'
  139. else:
  140. name = getip(request)
  141. data = re.sub("\[name\]", name, data)
  142. return data
  143. def nowlogin():
  144. if(session.get('Now') == True):
  145. return 1
  146. else:
  147. return 0
  148. def 아이디_파싱(원래_아이디):
  149. 있나 = re.search("([^-]*)\s\-\s(Close|Reopen|Stop|Restart|Admin|Agreement|Settlement)$", 원래_아이디)
  150. if(있나):
  151. 분리 = 있나.groups()
  152. DB_실행("select * from data where title = '사용자:" + DB_인코딩(분리[0]) + "'")
  153. row = curs.fetchall()
  154. if(row):
  155. ip = '<a href="/w/' + URL_인코딩('사용자:' + 분리[0]) + '">' + 분리[0] + '</a> - ' + 분리[1]
  156. else:
  157. ip = '<a class="not_thing" href="/w/' + URL_인코딩('사용자:' + 분리[0]) + '">' + 분리[0] + '</a> - ' + 분리[1]
  158. elif(re.search("\.", 원래_아이디)):
  159. ip = 원래_아이디
  160. else:
  161. DB_실행("select * from data where title = '사용자:" + DB_인코딩(원래_아이디) + "'")
  162. row = curs.fetchall()
  163. if(row):
  164. ip = '<a href="/w/' + URL_인코딩('사용자:' + 원래_아이디) + '">' + 원래_아이디 + '</a>'
  165. else:
  166. ip = '<a class="not_thing" href="/w/' + URL_인코딩('사용자:' + 원래_아이디) + '">' + 원래_아이디 + '</a>'
  167. return ip
  168. def namumark(title, data):
  169. while(True):
  170. m = re.search("<((div|span|embed|iframe)(?:[^>]*))>", data)
  171. if(m):
  172. g = m.groups()
  173. if(re.search("<(\/" + g[1] + ")>", data) and not re.search("'", g[0])):
  174. n = re.search('src="http(?:s)?:\/\/([^\/]*)\/(?:[^"]*)"', g[0])
  175. if(n):
  176. gm = n.groups()
  177. if(gm[0] == "www.youtube.com" or gm[0] == "serviceapi.nmv.naver.com" or gm[0] == "tv.kakao.com" or gm[0] == "tvple.com" or gm[0] == "tvpot.daum.net"):
  178. r = g[0]
  179. else:
  180. r = re.sub('src="([^"]*)"', '', g[0])
  181. else:
  182. r = g[0]
  183. r = re.sub('"', '#.#', r)
  184. data = re.sub("<((?:\/)?" + g[1] + "(?:[^>]*))>", "[" + r + "]", data, 1)
  185. data = re.sub("<\/" + g[1] + ">", "[/" + g[1] + "]", data, 1)
  186. else:
  187. data = re.sub("<((?:\/)?" + g[1] + "(?:[^>]*))>", '&lt;' + g[0] + '&gt;', data, 1)
  188. break
  189. else:
  190. break
  191. data = re.sub('<', '&lt;', data)
  192. data = re.sub('>', '&gt;', data)
  193. data = re.sub('"', '&quot;', data)
  194. data = re.sub("\[(?P<in>(?:\/)?(?:div|span|embed|iframe)(?:[^\]]*))\]", "<\g<in>>", data)
  195. data = re.sub('#.#', '"', data)
  196. jjjj = 0
  197. while(True):
  198. p = re.compile("{{{((?:(?!{{{)(?!}}}).)*)}}}", re.DOTALL)
  199. m = p.search(data)
  200. if(m):
  201. results = m.groups()
  202. q = re.compile("^\+([1-5])\s(.*)$", re.DOTALL)
  203. n = q.search(results[0])
  204. w = re.compile("^\-([1-5])\s(.*)$", re.DOTALL)
  205. a = w.search(results[0])
  206. e = re.compile("^(#[0-9a-f-A-F]{6})\s(.*)$", re.DOTALL)
  207. b = e.search(results[0])
  208. r = re.compile("^(#[0-9a-f-A-F]{3})\s(.*)$", re.DOTALL)
  209. c = r.search(results[0])
  210. t = re.compile("^#(\w+)\s(.*)$", re.DOTALL)
  211. d = t.search(results[0])
  212. qqq = re.compile("^@([0-9a-f-A-F]{6})\s(.*)$", re.DOTALL)
  213. qqe = qqq.search(results[0])
  214. qqw = re.compile("^@([0-9a-f-A-F]{3})\s(.*)$", re.DOTALL)
  215. qqa = qqw.search(results[0])
  216. qwe = re.compile("^@(\w+)\s(.*)$", re.DOTALL)
  217. qsd = qwe.search(results[0])
  218. qawe = re.compile("^#!noin\s(.*)$", re.DOTALL)
  219. qasd = qawe.search(results[0])
  220. y = re.compile("^#!wiki\sstyle=&quot;((?:(?!&quot;|\n).)*)&quot;\n?\s\n(.*)$", re.DOTALL)
  221. l = y.search(results[0])
  222. html = re.compile("^#!html\s(.*)$", re.DOTALL)
  223. htmlr = html.search(results[0])
  224. ppp = re.compile("^#!folding\s((?:(?!\n).)*)\n?\s\n(.*)$", re.DOTALL)
  225. ooo = ppp.search(results[0])
  226. if(n):
  227. result = n.groups()
  228. data = p.sub('<span class="font-size-' + result[0] + '">' + result[1] + '</span>', data, 1)
  229. elif(a):
  230. result = a.groups()
  231. data = p.sub('<span class="font-size-small-' + result[0] + '">' + result[1] + '</span>', data, 1)
  232. elif(b):
  233. result = b.groups()
  234. data = p.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', data, 1)
  235. elif(c):
  236. result = c.groups()
  237. data = p.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', data, 1)
  238. elif(d):
  239. result = d.groups()
  240. data = p.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', data, 1)
  241. elif(qqe):
  242. result = qqe.groups()
  243. data = p.sub('<span style="background:#' + result[0] + '">' + result[1] + '</span>', data, 1)
  244. elif(qqa):
  245. result = qqa.groups()
  246. data = p.sub('<span style="background:#' + result[0] + '">' + result[1] + '</span>', data, 1)
  247. elif(qsd):
  248. result = qsd.groups()
  249. data = p.sub('<span style="background:' + result[0] + '">' + result[1] + '</span>', data, 1)
  250. elif(l):
  251. result = l.groups()
  252. data = p.sub('<div style="' + result[0] + '">' + result[1] + '</div>', data, 1)
  253. elif(htmlr):
  254. result = htmlr.groups()
  255. data = p.sub(result[0], data, 1)
  256. elif(ooo):
  257. result = ooo.groups()
  258. data = p.sub("<div>" + result[0] + "<span style='float:right;'><div id='folding_" + str(jjjj + 1) + "' style='display:block;'>[<a href='javascript:void(0);' onclick='var f=document.getElementById(\"folding_" + str(jjjj) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";this.className=s?\"\":\"opened\";var f=document.getElementById(\"folding_" + str(jjjj + 1) + "\");var s=f.style.display==\"none\";f.style.display=s?\"block\":\"none\";var f=document.getElementById(\"folding_" + str(jjjj + 2) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";'>펼치기</a>]</div><div id='folding_" + str(jjjj + 2) + "' style='display:none;'>[<a href='javascript:void(0);' onclick='var f=document.getElementById(\"folding_" + str(jjjj) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";this.className=s?\"\":\"opened\";var f=document.getElementById(\"folding_" + str(jjjj + 1) + "\");var s=f.style.display==\"none\";f.style.display=s?\"block\":\"none\";var f=document.getElementById(\"folding_" + str(jjjj + 2) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";'>접기</a>]</div></a></span><div id='folding_" + str(jjjj) + "' style='display:none;'><br>" + result[1] + "</div></div>", data, 1)
  259. jjjj = jjjj + 3
  260. elif(qasd):
  261. result = qasd.groups()
  262. data = p.sub(result[0], data, 1)
  263. else:
  264. data = p.sub('<code>' + results[0] + '</code>', data, 1)
  265. else:
  266. break
  267. while(True):
  268. a = re.compile("<code>(((?!<\/code>).)*)<\/code>", re.DOTALL)
  269. m = a.search(data)
  270. if(m):
  271. g = m.groups()
  272. j = re.sub("<\/span>", "}}}", g[0])
  273. j = re.sub("<\/div>", "}}}", j)
  274. j = re.sub('<span class="font\-size\-(?P<in>[1-6])">', "{{{+\g<in> ", j)
  275. j = re.sub('<span class="font\-size\-small\-(?P<in>[1-6])">', "{{{-\g<in> ", j)
  276. j = re.sub('<span style="color:(?:#)?(?P<in>[^"]*)">', "{{{#\g<in> ", j)
  277. j = re.sub('<span style="background:(?:#)?(?P<in>[^"]*)">', "{{{@\g<in> ", j)
  278. j = re.sub('<div style="(?P<in>[^"]*)">', "{{{#!wiki style=&quot;\g<in>&quot;\n", j)
  279. j = re.sub("(?P<in>.)", "<span>\g<in></span>", j)
  280. data = a.sub(j, data, 1)
  281. else:
  282. break
  283. data = re.sub("<span>&</span><span>l</span><span>t</span><span>;</span>", "<span>&lt;</span>", data)
  284. data = re.sub("<span>&</span><span>g</span><span>t</span><span>;</span>", "<span>&gt;</span>", data)
  285. data = re.sub("\[anchor\((?P<in>[^\[\]]*)\)\]", '<span id="\g<in>"></span>', data)
  286. data = re.sub('\[date\(now\)\]', 시간(), data)
  287. if(not re.search("\.", getip(request))):
  288. name = '[[사용자:' + getip(request) + '|' + getip(request) + ']]'
  289. else:
  290. name = getip(request)
  291. data = re.sub("\[name\]", name, data)
  292. while(True):
  293. m = re.search("\[include\(((?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\]", data)
  294. if(m):
  295. results = m.groups()
  296. if(results[0] == title):
  297. data = re.sub("\[include\(((?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\]", "<b>" + results[0] + "</b>", data, 1)
  298. else:
  299. DB_실행("select * from data where title = '" + DB_인코딩(results[0]) + "'")
  300. rows = curs.fetchall()
  301. if(rows):
  302. DB_실행("select * from back where title = '" + DB_인코딩(results[0]) + "' and link = '" + DB_인코딩(title) + "' and type = 'include'")
  303. abb = curs.fetchall()
  304. if(not abb):
  305. DB_실행("insert into back (title, link, type) value ('" + DB_인코딩(results[0]) + "', '" + DB_인코딩(title) + "', 'include')")
  306. DB_갱신()
  307. enddata = rows[0]['data']
  308. enddata = re.sub("\[include\(((?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\]", "", enddata)
  309. while(True):
  310. m = re.search("<((?:\/)?(?:div|span|embed|iframe)(?:[^>]*))>", enddata)
  311. if(m):
  312. g = m.groups()
  313. n = re.search('src="http(?:s)?:\/\/([^\/]*)\/(?:[^"]*)"', g[0])
  314. if(n):
  315. gm = n.groups()
  316. if(gm[0] == "www.youtube.com" or gm[0] == "serviceapi.nmv.naver.com" or gm[0] == "tv.kakao.com" or gm[0] == "tvple.com" or gm[0] == "tvpot.daum.net"):
  317. r = g[0]
  318. else:
  319. r = re.sub('src="([^"]*)"', '', g[0])
  320. else:
  321. r = g[0]
  322. r = re.sub('"', '#.#', r)
  323. enddata = re.sub("<((?:\/)?(?:div|span|embed|iframe)(?:[^>]*))>", "[" + r + "]", enddata, 1)
  324. else:
  325. break
  326. enddata = re.sub('<', '&lt;', enddata)
  327. enddata = re.sub('>', '&gt;', enddata)
  328. enddata = re.sub('"', '&quot;', enddata)
  329. enddata = re.sub("\[(?P<in>(?:\/)?(?:div|span|embed|iframe)(?:[^\]]*))\]", "<\g<in>>", enddata)
  330. enddata = re.sub('#.#', '"', enddata)
  331. while(True):
  332. p = re.compile("{{{((?:(?!{)(?!}).)*)}}}", re.DOTALL)
  333. m = p.search(enddata)
  334. if(m):
  335. nnn = m.groups()
  336. q = re.compile("^\+([1-5])\s(.*)$", re.DOTALL)
  337. n = q.search(nnn[0])
  338. w = re.compile("^\-([1-5])\s(.*)$", re.DOTALL)
  339. a = w.search(nnn[0])
  340. e = re.compile("^(#[0-9a-f-A-F]{6})\s(.*)$", re.DOTALL)
  341. b = e.search(nnn[0])
  342. r = re.compile("^(#[0-9a-f-A-F]{3})\s(.*)$", re.DOTALL)
  343. c = r.search(nnn[0])
  344. t = re.compile("^#(\w+)\s(.*)$", re.DOTALL)
  345. d = t.search(nnn[0])
  346. qqq = re.compile("^@([0-9a-f-A-F]{6})\s(.*)$", re.DOTALL)
  347. qqe = qqq.search(nnn[0])
  348. qqw = re.compile("^@([0-9a-f-A-F]{3})\s(.*)$", re.DOTALL)
  349. qqa = qqw.search(nnn[0])
  350. qwe = re.compile("^@(\w+)\s(.*)$", re.DOTALL)
  351. qsd = qwe.search(nnn[0])
  352. qawe = re.compile("^#!noin\s(.*)$", re.DOTALL)
  353. qasd = qawe.search(nnn[0])
  354. y = re.compile("^#!wiki\sstyle=&quot;((?:(?!&quot;|\n).)*)&quot;\n?\s\n(.*)$", re.DOTALL)
  355. l = y.search(nnn[0])
  356. html = re.compile("^#!html\s(.*)$", re.DOTALL)
  357. htmlr = html.search(nnn[0])
  358. ppp = re.compile("^#!folding\s((?:(?!\n).)*)\n?\s\n(.*)$", re.DOTALL)
  359. ooo = ppp.search(nnn[0])
  360. if(n):
  361. result = n.groups()
  362. enddata = p.sub('<span class="font-size-' + result[0] + '">' + result[1] + '</span>', enddata, 1)
  363. elif(a):
  364. result = a.groups()
  365. enddata = p.sub('<span class="font-size-small-' + result[0] + '">' + result[1] + '</span>', enddata, 1)
  366. elif(b):
  367. result = b.groups()
  368. enddata = p.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', enddata, 1)
  369. elif(c):
  370. result = c.groups()
  371. enddata = p.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', enddata, 1)
  372. elif(d):
  373. result = d.groups()
  374. enddata = p.sub('<span style="color:' + result[0] + '">' + result[1] + '</span>', enddata, 1)
  375. elif(qqe):
  376. result = qqe.groups()
  377. enddata = p.sub('<span style="background:#' + result[0] + '">' + result[1] + '</span>', enddata, 1)
  378. elif(qqa):
  379. result = qqa.groups()
  380. enddata = p.sub('<span style="background:#' + result[0] + '">' + result[1] + '</span>', enddata, 1)
  381. elif(qsd):
  382. result = qsd.groups()
  383. enddata = p.sub('<span style="background:' + result[0] + '">' + result[1] + '</span>', enddata, 1)
  384. elif(l):
  385. result = l.groups()
  386. enddata = p.sub('<div style="' + result[0] + '">' + result[1] + '</div>', enddata, 1)
  387. elif(htmlr):
  388. result = htmlr.groups()
  389. data = p.sub(result[0], enddata, 1)
  390. elif(ooo):
  391. result = ooo.groups()
  392. enddata = p.sub("<div>" + result[0] + "<span style='float:right;'><div id='folding_" + str(jjjj + 1) + "' style='display:block;'>[<a href='javascript:void(0);' onclick='var f=document.getElementById(\"folding_" + str(jjjj) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";this.className=s?\"\":\"opened\";var f=document.getElementById(\"folding_" + str(jjjj + 1) + "\");var s=f.style.display==\"none\";f.style.display=s?\"block\":\"none\";var f=document.getElementById(\"folding_" + str(jjjj + 2) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";'>펼치기</a>]</div><div id='folding_" + str(jjjj + 2) + "' style='display:none;'>[<a href='javascript:void(0);' onclick='var f=document.getElementById(\"folding_" + str(jjjj) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";this.className=s?\"\":\"opened\";var f=document.getElementById(\"folding_" + str(jjjj + 1) + "\");var s=f.style.display==\"none\";f.style.display=s?\"block\":\"none\";var f=document.getElementById(\"folding_" + str(jjjj + 2) + "\");var s=f.style.display==\"block\";f.style.display=s?\"none\":\"block\";'>접기</a>]</div></a></span><div id='folding_" + str(jjjj) + "' style='display:none;'><br>" + result[1] + "</div></div>", enddata, 1)
  393. jjjj = jjjj + 3
  394. elif(qasd):
  395. enddata = p.sub("", enddata, 1)
  396. else:
  397. enddata = p.sub('<code>' + nnn[0] + '</code>', enddata, 1)
  398. else:
  399. break
  400. while(True):
  401. a = re.compile("<code>(((?!<\/code>).)*)<\/code>", re.DOTALL)
  402. m = a.search(enddata)
  403. if(m):
  404. g = m.groups()
  405. j = re.sub("<\/span>", "}}}", g[0])
  406. j = re.sub("<\/div>", "}}}", j)
  407. j = re.sub('<span class="font\-size\-(?P<in>[1-6])">', "{{{+\g<in> ", j)
  408. j = re.sub('<span class="font\-size\-small\-(?P<in>[1-6])">', "{{{-\g<in> ", j)
  409. j = re.sub('<span style="color:(?:#)?(?P<in>[^"]*)">', "{{{#\g<in> ", j)
  410. j = re.sub('<span style="background:(?:#)?(?P<in>[^"]*)">', "{{{@\g<in> ", j)
  411. j = re.sub('<div style="(?P<in>[^"]*)">', "{{{#!wiki style=&quot;\g<in>&quot;\n", j)
  412. j = re.sub("(?P<in>.)", "<span>\g<in></span>", j)
  413. enddata = a.sub(j, enddata, 1)
  414. else:
  415. break
  416. enddata = re.sub("<span>&</span><span>l</span><span>t</span><span>;</span>", "<span>&lt;</span>", enddata)
  417. enddata = re.sub("<span>&</span><span>g</span><span>t</span><span>;</span>", "<span>&gt;</span>", enddata)
  418. if(results[1]):
  419. a = results[1]
  420. while(True):
  421. g = re.search("([^= ,]*)\=([^,]*)", a)
  422. if(g):
  423. result = g.groups()
  424. enddata = re.sub("@" + result[0] + "@", result[1], enddata)
  425. a = re.sub("([^= ,]*)\=([^,]*)", "", a, 1)
  426. else:
  427. break
  428. data = re.sub("\[include\(((?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\]", '\n<div>' + enddata + '</div>\n', data, 1)
  429. else:
  430. DB_실행("select * from back where title = '" + DB_인코딩(results[0]) + "' and link = '" + DB_인코딩(title) + "' and type = 'include'")
  431. abb = curs.fetchall()
  432. if(not abb):
  433. DB_실행("insert into back (title, link, type) value ('" + DB_인코딩(results[0]) + "', '" + DB_인코딩(title) + "', 'include')")
  434. DB_갱신()
  435. data = re.sub("\[include\(((?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\]", "<a class=\"not_thing\" href=\"" + URL_인코딩(results[0]) + "\">" + results[0] + "</a>", data, 1)
  436. else:
  437. break
  438. while(True):
  439. m = re.search('^#(?:redirect|넘겨주기)\s([^\n]*)', data)
  440. if(m):
  441. results = m.groups()
  442. aa = re.search("^(.*)(#(?:.*))$", results[0])
  443. if(aa):
  444. results = aa.groups()
  445. data = re.sub('^#(?:redirect|넘겨주기)\s([^\n]*)', '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(results[0]) + '/from/' + URL_인코딩(title) + results[1] + '" />', data, 1)
  446. else:
  447. data = re.sub('^#(?:redirect|넘겨주기)\s([^\n]*)', '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(results[0]) + '/from/' + URL_인코딩(title) + '" />', data, 1)
  448. DB_실행("select * from back where title = '" + DB_인코딩(results[0]) + "' and link = '" + DB_인코딩(title) + "' and type = 'redirect'")
  449. abb = curs.fetchall()
  450. if(not abb):
  451. DB_실행("insert into back (title, link, type) value ('" + DB_인코딩(results[0]) + "', '" + DB_인코딩(title) + "', 'redirect')")
  452. DB_갱신()
  453. else:
  454. break
  455. data = '\n' + data + '\n'
  456. while(True):
  457. m = re.search("\n&gt;\s?((?:[^\n]*)(?:(?:(?:(?:\n&gt;\s?)(?:[^\n]*))+)?))", data)
  458. if(m):
  459. result = m.groups()
  460. blockquote = result[0]
  461. blockquote = re.sub("\n&gt;\s?", "\n", blockquote)
  462. data = re.sub("\n&gt;\s?((?:[^\n]*)(?:(?:(?:(?:\n&gt;\s?)(?:[^\n]*))+)?))", "\n<blockquote>" + blockquote + "</blockquote>", data, 1)
  463. else:
  464. break
  465. m = re.search('\[목차\]', data)
  466. if(not m):
  467. data = re.sub("(?P<in>(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n)", "[목차]\n\g<in>", data, 1)
  468. i = 0
  469. h0c = 0
  470. h1c = 0
  471. h2c = 0
  472. h3c = 0
  473. h4c = 0
  474. h5c = 0
  475. last = 0
  476. rtoc = '<div id="toc"><span id="toc-name">목차</span><br><br>'
  477. while(True):
  478. i = i + 1
  479. m = re.search('(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n', data)
  480. if(m):
  481. result = m.groups()
  482. wiki = len(result[0])
  483. if(last < wiki):
  484. last = wiki
  485. else:
  486. last = wiki
  487. if(wiki == 1):
  488. h1c = 0
  489. h2c = 0
  490. h3c = 0
  491. h4c = 0
  492. h5c = 0
  493. elif(wiki == 2):
  494. h2c = 0
  495. h3c = 0
  496. h4c = 0
  497. h5c = 0
  498. elif(wiki == 3):
  499. h3c = 0
  500. h4c = 0
  501. h5c = 0
  502. elif(wiki == 4):
  503. h4c = 0
  504. h5c = 0
  505. elif(wiki == 5):
  506. h5c = 0
  507. if(wiki == 1):
  508. h0c = h0c + 1
  509. elif(wiki == 2):
  510. h1c = h1c + 1
  511. elif(wiki == 3):
  512. h2c = h2c + 1
  513. elif(wiki == 4):
  514. h3c = h3c + 1
  515. elif(wiki == 5):
  516. h4c = h4c + 1
  517. else:
  518. h5c = h5c + 1
  519. toc = str(h0c) + '.' + str(h1c) + '.' + str(h2c) + '.' + str(h3c) + '.' + str(h4c) + '.' + str(h5c) + '.'
  520. toc = re.sub("(?P<in>[0-9]0(?:[0]*)?)\.", '\g<in>#.', toc)
  521. toc = re.sub("0\.", '', toc)
  522. toc = re.sub("#\.", '.', toc)
  523. toc = re.sub("\.$", '', toc)
  524. rtoc = rtoc + '<a href="#s-' + toc + '">' + toc + '</a>. ' + result[1] + '<br>'
  525. c = re.sub(" $", "", result[1])
  526. data = re.sub('(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n', '<h' + str(wiki) + ' id="' + c + '"><a href="#toc" id="s-' + toc + '">' + toc + '.</a> ' + c + ' <span style="font-size:11px;">[<a href="/edit/' + URL_인코딩(title) + '/section/' + str(i) + '">편집</a>]</span></h' + str(wiki) + '>', data, 1);
  527. else:
  528. rtoc = rtoc + '</div>'
  529. break
  530. data = re.sub("\[목차\]", rtoc, data)
  531. category = ''
  532. while(True):
  533. m = re.search("\[\[(분류:(?:(?:(?!\]\]).)*))\]\]", data)
  534. if(m):
  535. g = m.groups()
  536. if(not title == g[0]):
  537. DB_실행("select * from cat where title = '" + DB_인코딩(g[0]) + "' and cat = '" + DB_인코딩(title) + "'")
  538. abb = curs.fetchall()
  539. if(not abb):
  540. DB_실행("insert into cat (title, cat) value ('" + DB_인코딩(g[0]) + "', '" + DB_인코딩(title) + "')")
  541. DB_갱신()
  542. if(category == ''):
  543. DB_실행("select * from data where title = '" + DB_인코딩(g[0]) + "'")
  544. exists = curs.fetchall()
  545. if(exists):
  546. red = ""
  547. else:
  548. red = 'class="not_thing"'
  549. category = category + '<a ' + red + ' href="/w/' + URL_인코딩(g[0]) + '">' + re.sub("분류:", "", g[0]) + '</a>'
  550. else:
  551. DB_실행("select * from data where title = '" + DB_인코딩(g[0]) + "'")
  552. exists = curs.fetchall()
  553. if(exists):
  554. red = ""
  555. else:
  556. red = 'class="not_thing"'
  557. category = category + ' / ' + '<a ' + red + ' href="/w/' + URL_인코딩(g[0]) + '">' + re.sub("분류:", "", g[0]) + '</a>'
  558. data = re.sub("\[\[(분류:(?:(?:(?!\]\]).)*))\]\]", '', data, 1)
  559. else:
  560. break
  561. data = re.sub("'''(?P<in>.+?)'''(?!')", '<b>\g<in></b>', data)
  562. data = re.sub("''(?P<in>.+?)''(?!')", '<i>\g<in></i>', data)
  563. data = re.sub('~~(?P<in>.+?)~~(?!~)', '<s>\g<in></s>', data)
  564. data = re.sub('--(?P<in>.+?)--(?!-)', '<s>\g<in></s>', data)
  565. data = re.sub('__(?P<in>.+?)__(?!_)', '<u>\g<in></u>', data)
  566. data = re.sub('\^\^(?P<in>.+?)\^\^(?!\^)', '<sup>\g<in></sup>', data)
  567. data = re.sub(',,(?P<in>.+?),,(?!,)', '<sub>\g<in></sub>', data)
  568. data = re.sub('&lt;math&gt;(?P<in>((?!&lt;math&gt;).)*)&lt;\/math&gt;', '$\g<in>$', data)
  569. data = re.sub('{{\|(?P<in>(?:(?:(?:(?!\|}}).)*)(?:\n?))+)\|}}', '<table><tbody><tr><td>\g<in></td></tr></tbody></table>', data)
  570. data = re.sub('\[ruby\((?P<in>[^\|]*)\|(?P<out>[^\)]*)\)\]', '<ruby>\g<in><rp>(</rp><rt>\g<out></rt><rp>)</rp></ruby>', data)
  571. data = re.sub("##\s?(?P<in>[^\n]*)\n", "<div style='display:none;'>\g<in></div>", data);
  572. while(True):
  573. m = re.search("\[\[파일:((?:(?!\]\]|\|).)*)(?:\|((?:(?!\]\]).)*))?\]\]", data)
  574. if(m):
  575. c = m.groups()
  576. if(c[1]):
  577. n = re.search("width=([^ \n&]*)", c[1])
  578. e = re.search("height=([^ \n&]*)", c[1])
  579. if(n):
  580. a = n.groups()
  581. width = a[0]
  582. else:
  583. width = ''
  584. if(e):
  585. b = e.groups()
  586. height = b[0]
  587. else:
  588. height = ''
  589. img = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", c[0])
  590. data = re.sub("\[\[파일:((?:(?!\]\]|\?).)*)(?:\?((?:(?!\]\]).)*))?\]\]", '<a href="/w/파일:' + img + '"><img src="/image/' + img + '" width="' + width + '" height="' + height + '"></a>', data, 1)
  591. else:
  592. img = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", c[0])
  593. data = re.sub("\[\[파일:((?:(?!\]\]|\?).)*)(?:\?((?:(?!\]\]).)*))?\]\]", "<a href='/w/파일:" + img + "'><img src='/image/" + img + "'></a>", data, 1)
  594. if(not re.search("^파일:([^\n]*)", title)):
  595. DB_실행("select * from back where title = '" + DB_인코딩(c[0]) + "' and link = '" + DB_인코딩(title) + "' and type = 'redirect'")
  596. abb = curs.fetchall()
  597. if(not abb):
  598. DB_실행("insert into back (title, link, type) value ('파일:" + DB_인코딩(c[0]) + "', '" + DB_인코딩(title) + "', 'file')")
  599. DB_갱신()
  600. else:
  601. break
  602. data = re.sub("\[br\]",'<br>', data);
  603. while(True):
  604. m = re.search("\[youtube\(((?:(?!,|\)\]).)*)(?:,\s)?(?:width=((?:(?!,|\)\]).)*))?(?:,\s)?(?:height=((?:(?!,|\)\]).)*))?(?:,\s)?(?:width=((?:(?!,|\)\]).)*))?\)\]", data)
  605. if(m):
  606. result = m.groups()
  607. if(result[1]):
  608. if(result[2]):
  609. width = result[1]
  610. height = result[2]
  611. else:
  612. width = result[1]
  613. height = '315'
  614. elif(result[2]):
  615. if(result[3]):
  616. height = result[2]
  617. width = result[3]
  618. else:
  619. height = result[2]
  620. width = '560'
  621. else:
  622. width = '560'
  623. height = '315'
  624. data = re.sub("\[youtube\(((?:(?!,|\)\]).)*)(?:,\s)?(?:width=((?:(?!,|\)\]).)*))?(?:,\s)?(?:height=((?:(?!,|\)\]).)*))?(?:,\s)?(?:width=((?:(?!,|\)\]).)*))?\)\]", '<iframe width="' + width + '" height="' + height + '" src="https://www.youtube.com/embed/' + result[0] + '" frameborder="0" allowfullscreen></iframe>', data, 1)
  625. else:
  626. break
  627. data = re.sub("\[\[(?::(?P<in>(?:분류|파일):(?:(?:(?!\]\]).)*)))\]\]", "[[\g<in>]]", data)
  628. while(True):
  629. m = re.search("\[\[(((?!\]\]).)*)\]\]", data)
  630. if(m):
  631. result = m.groups()
  632. a = re.search("((?:(?!\|).)*)\|(.*)", result[0])
  633. if(a):
  634. results = a.groups()
  635. aa = re.search("^(.*)(#(?:.*))$", results[0])
  636. if(aa):
  637. g = results[1]
  638. results = aa.groups()
  639. b = re.search("^http(?:s)?:\/\/", results[0])
  640. if(b):
  641. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + results[0] + results[1] + '">' + g + '</a>', data, 1)
  642. else:
  643. if(results[0] == title):
  644. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<b>' + g + '</b>', data, 1)
  645. else:
  646. DB_실행("select * from data where title = '" + DB_인코딩(results[0]) + "'")
  647. rows = curs.fetchall()
  648. if(rows):
  649. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a title="' + results[0] + results[1] + '" href="/w/' + URL_인코딩(results[0]) + results[1] + '">' + g + '</a>', data, 1)
  650. else:
  651. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a title="' + results[0] + results[1] + '" class="not_thing" href="/w/' + URL_인코딩(results[0]) + results[1] + '">' + g + '</a>', data, 1)
  652. DB_실행("select * from back where title = '" + DB_인코딩(results[0]) + "' and link = '" + DB_인코딩(title) + "'")
  653. rows = curs.fetchall()
  654. if(not rows):
  655. DB_실행("insert into back (title, link, type) value ('" + DB_인코딩(results[0]) + "', '" + DB_인코딩(title) + "', '')")
  656. DB_갱신()
  657. else:
  658. b = re.search("^http(?:s)?:\/\/", results[0])
  659. if(b):
  660. c = re.search("(?:\.[Jj][Pp][Gg]|\.[Pp][Nn][Gg]|\.[Gg][Ii][Ff]|\.[Jj][Pp][Ee][Gg])", results[0])
  661. if(c):
  662. img = results[0]
  663. img = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", img)
  664. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + img + '">' + results[1] + '</a>', data, 1)
  665. else:
  666. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + results[0] + '">' + results[1] + '</a>', data, 1)
  667. else:
  668. if(results[0] == title):
  669. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<b>' + results[1] + '</b>', data, 1)
  670. else:
  671. DB_실행("select * from data where title = '" + DB_인코딩(results[0]) + "'")
  672. rows = curs.fetchall()
  673. if(rows):
  674. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a title="' + results[0] + '" href="/w/' + URL_인코딩(results[0]) + '">' + results[1] + '</a>', data, 1)
  675. else:
  676. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a title="' + results[0] + '" class="not_thing" href="/w/' + URL_인코딩(results[0]) + '">' + results[1] + '</a>', data, 1)
  677. DB_실행("select * from back where title = '" + DB_인코딩(results[0]) + "' and link = '" + DB_인코딩(title) + "'")
  678. rows = curs.fetchall()
  679. if(not rows):
  680. DB_실행("insert into back (title, link, type) value ('" + DB_인코딩(results[0]) + "', '" + DB_인코딩(title) + "', '')")
  681. DB_갱신()
  682. else:
  683. aa = re.search("^(.*)(#(?:.*))$", result[0])
  684. if(aa):
  685. result = aa.groups()
  686. b = re.search("^http(?:s)?:\/\/", result[0])
  687. if(b):
  688. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + result[0] + result[1] + '">' + result[0] + result[1] + '</a>', data, 1)
  689. else:
  690. if(result[0] == title):
  691. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<b>' + result[0] + result[1] + '</b>', data, 1)
  692. else:
  693. DB_실행("select * from data where title = '" + DB_인코딩(result[0]) + "'")
  694. rows = curs.fetchall()
  695. if(rows):
  696. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a href="/w/' + URL_인코딩(result[0]) + result[1] + '">' + result[0] + result[1] + '</a>', data, 1)
  697. else:
  698. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="not_thing" href="/w/' + URL_인코딩(result[0]) + result[1] + '">' + result[0] + result[1] + '</a>', data, 1)
  699. DB_실행("select * from back where title = '" + DB_인코딩(result[0]) + "' and link = '" + DB_인코딩(title) + "'")
  700. rows = curs.fetchall()
  701. if(not rows):
  702. DB_실행("insert into back (title, link, type) value ('" + DB_인코딩(result[0]) + "', '" + DB_인코딩(title) + "', '')")
  703. DB_갱신()
  704. else:
  705. b = re.search("^http(?:s)?:\/\/", result[0])
  706. if(b):
  707. c = re.search("(?:\.[Jj][Pp][Gg]|\.[Pp][Nn][Gg]|\.[Gg][Ii][Ff]|\.[Jj][Pp][Ee][Gg])", result[0])
  708. if(c):
  709. img = result[0]
  710. img = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", img)
  711. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + img + '">' + img + '</a>', data, 1)
  712. else:
  713. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + result[0] + '">' + result[0] + '</a>', data, 1)
  714. else:
  715. if(result[0] == title):
  716. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<b>' + result[0] + '</b>', data, 1)
  717. else:
  718. DB_실행("select * from data where title = '" + DB_인코딩(result[0]) + "'")
  719. rows = curs.fetchall()
  720. if(rows):
  721. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a href="/w/' + URL_인코딩(result[0]) + '">' + result[0] + '</a>', data, 1)
  722. else:
  723. data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="not_thing" href="/w/' + URL_인코딩(result[0]) + '">' + result[0] + '</a>', data, 1)
  724. DB_실행("select * from back where title = '" + DB_인코딩(result[0]) + "' and link = '" + DB_인코딩(title) + "'")
  725. rows = curs.fetchall()
  726. if(not rows):
  727. DB_실행("insert into back (title, link, type) value ('" + DB_인코딩(result[0]) + "', '" + DB_인코딩(title) + "', '')")
  728. DB_갱신()
  729. else:
  730. break
  731. while(True):
  732. m = re.search("(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|%)?))?(?:(?:&)width=((?:[0-9]*)(?:px|%)?))?)?", data)
  733. if(m):
  734. result = m.groups()
  735. if(result[1]):
  736. if(result[2]):
  737. width = result[1]
  738. height = result[2]
  739. else:
  740. width = result[1]
  741. height = ''
  742. elif(result[2]):
  743. if(result[3]):
  744. height = result[2]
  745. width = result[3]
  746. else:
  747. height = result[2]
  748. width = ''
  749. else:
  750. width = ''
  751. height = ''
  752. c = result[0]
  753. c = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", c)
  754. data = re.sub("(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)?))?(?:(?:&)width=((?:[0-9]*)(?:px)?))?)?", "<img width='" + width + "' height='" + height + "' src='" + c + "'>", data, 1)
  755. else:
  756. break
  757. while(True):
  758. m = re.search("((?:(?:( +)\*\s(?:[^\n]*))\n?)+)", data)
  759. if(m):
  760. result = m.groups()
  761. end = str(result[0])
  762. while(True):
  763. isspace = re.search("( +)\*\s([^\n]*)", end)
  764. if(isspace):
  765. spacebar = isspace.groups()
  766. up = len(spacebar[0]) * 20
  767. end = re.sub("( +)\*\s([^\n]*)", "<li style='margin-left:" + str(up) + "px'>" + spacebar[1] + "</li>", end, 1)
  768. else:
  769. break
  770. end = re.sub("\n", '', end)
  771. data = re.sub("(?:(?:(?:( +)\*\s([^\n]*))\n?)+)", '<ul id="list">' + end + '</ul>', data, 1)
  772. else:
  773. break
  774. data = re.sub('\[date\]', 시간(), data)
  775. data = re.sub("#(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])#", ".\g<in>", data)
  776. data = re.sub("-{4,11}", "<hr>", data)
  777. while(True):
  778. b = re.search("\n( +)", data)
  779. if(b):
  780. result = b.groups()
  781. up = re.sub(' ', '<span id="in"></span>', result[0])
  782. data = re.sub("\n( +)", '<br>' + up, data, 1)
  783. else:
  784. break
  785. a = 1
  786. tou = "<hr id='footnote'><div class='wiki-macro-footnote'><br>"
  787. while(True):
  788. b = re.search("\[\*([^\s]*)\s(((?!\]).)*)\]", data)
  789. if(b):
  790. results = b.groups()
  791. if(results[0]):
  792. c = results[1]
  793. c = re.sub("<(?:[^>]*)>", '', c)
  794. tou = tou + "<span class='footnote-list'><a href=\"#rfn-" + str(a) + "\" id=\"fn-" + str(a) + "\">[" + results[0] + "]</a> " + results[1] + "</span><br>"
  795. 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)
  796. else:
  797. c = results[1]
  798. c = re.sub("<(?:[^>]*)>", '', c)
  799. tou = tou + "<span class='footnote-list'><a href=\"#rfn-" + str(a) + "\" id=\"fn-" + str(a) + "\">[" + str(a) + "]</a> " + results[1] + "</span><br>"
  800. 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)
  801. a = a + 1
  802. else:
  803. tou = tou + '</div>'
  804. if(tou == "<hr id='footnote'><div class='wiki-macro-footnote'><br></div>"):
  805. tou = ""
  806. break
  807. data = re.sub("\[각주\](?:(?:<br>| |\r|\n)+)?$", "", data)
  808. data = re.sub("(?:(?:<br>| |\r|\n)+)$", "", data)
  809. data = re.sub("\[각주\]", "<br>" + tou, data)
  810. data = data + tou
  811. if(category):
  812. data = data + '<div style="width:100%;border: 1px solid #777;padding: 5px;margin-top: 1em;">분류: ' + category + '</div>'
  813. while(True):
  814. m = re.search("(\|\|(?:(?:(?:.*)\n?)\|\|)+)", data)
  815. if(m):
  816. results = m.groups()
  817. table = results[0]
  818. while(True):
  819. a = re.search("^(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", table)
  820. if(a):
  821. row = ''
  822. cel = ''
  823. celstyle = ''
  824. rowstyle = ''
  825. alltable = ''
  826. result = a.groups()
  827. if(result[1]):
  828. q = re.search("&lt;table\s?width=((?:(?!&gt;).)*)&gt;", result[1])
  829. w = re.search("&lt;table\s?height=((?:(?!&gt;).)*)&gt;", result[1])
  830. e = re.search("&lt;table\s?align=((?:(?!&gt;).)*)&gt;", result[1])
  831. alltable = 'style="'
  832. celstyle = 'style="'
  833. rowstyle = 'style="'
  834. if(q):
  835. resultss = q.groups()
  836. alltable = alltable + 'width:' + resultss[0] + ';'
  837. if(w):
  838. resultss = w.groups()
  839. alltable = alltable + 'height:' + resultss[0] + ';'
  840. if(e):
  841. resultss = e.groups()
  842. if(resultss[0] == 'right'):
  843. alltable = alltable + 'margin-left:auto;'
  844. elif(resultss[0] == 'center'):
  845. alltable = alltable + 'margin:auto;'
  846. else:
  847. alltable = alltable + 'margin-right:auto;'
  848. ee = re.search("&lt;table\s?textalign=((?:(?!&gt;).)*)&gt;", result[1])
  849. if(ee):
  850. resultss = ee.groups()
  851. if(resultss[0] == 'right'):
  852. alltable = alltable + 'text-align:right;'
  853. elif(resultss[0] == 'center'):
  854. alltable = alltable + 'text-align:center;'
  855. else:
  856. alltable = alltable + 'text-align:left;'
  857. r = re.search("&lt;-((?:(?!&gt;).)*)&gt;", result[1])
  858. if(r):
  859. resultss = r.groups()
  860. cel = 'colspan="' + resultss[0] + '"'
  861. else:
  862. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  863. t = re.search("&lt;\|((?:(?!&gt;).)*)&gt;", result[1])
  864. if(t):
  865. resultss = t.groups()
  866. row = 'rowspan="' + resultss[0] + '"'
  867. ba = re.search("&lt;rowbgcolor=(#[0-9a-f-A-F]{6})&gt;", result[1])
  868. bb = re.search("&lt;rowbgcolor=(#[0-9a-f-A-F]{3})&gt;", result[1])
  869. bc = re.search("&lt;rowbgcolor=(\w+)&gt;", result[1])
  870. if(ba):
  871. resultss = ba.groups()
  872. rowstyle = rowstyle + 'background:' + resultss[0] + ';'
  873. elif(bb):
  874. resultss = bb.groups()
  875. rowstyle = rowstyle + 'background:' + resultss[0] + ';'
  876. elif(bc):
  877. resultss = bc.groups()
  878. rowstyle = rowstyle + 'background:' + resultss[0] + ';'
  879. z = re.search("&lt;table\s?bordercolor=(#[0-9a-f-A-F]{6})&gt;", result[1])
  880. x = re.search("&lt;table\s?bordercolor=(#[0-9a-f-A-F]{3})&gt;", result[1])
  881. c = re.search("&lt;table\s?bordercolor=(\w+)&gt;", result[1])
  882. if(z):
  883. resultss = z.groups()
  884. alltable = alltable + 'border:' + resultss[0] + ' 2px solid;'
  885. elif(x):
  886. resultss = x.groups()
  887. alltable = alltable + 'border:' + resultss[0] + ' 2px solid;'
  888. elif(c):
  889. resultss = c.groups()
  890. alltable = alltable + 'border:' + resultss[0] + ' 2px solid;'
  891. aq = re.search("&lt;table\s?bgcolor=(#[0-9a-f-A-F]{6})&gt;", result[1])
  892. aw = re.search("&lt;table\s?bgcolor=(#[0-9a-f-A-F]{3})&gt;", result[1])
  893. ae = re.search("&lt;table\s?bgcolor=(\w+)&gt;", result[1])
  894. if(aq):
  895. resultss = aq.groups()
  896. alltable = alltable + 'background:' + resultss[0] + ';'
  897. elif(aw):
  898. resultss = aw.groups()
  899. alltable = alltable + 'background:' + resultss[0] + ';'
  900. elif(ae):
  901. resultss = ae.groups()
  902. alltable = alltable + 'background:' + resultss[0] + ';'
  903. j = re.search("&lt;bgcolor=(#[0-9a-f-A-F]{6})&gt;", result[1])
  904. k = re.search("&lt;bgcolor=(#[0-9a-f-A-F]{3})&gt;", result[1])
  905. l = re.search("&lt;bgcolor=(\w+)&gt;", result[1])
  906. if(j):
  907. resultss = j.groups()
  908. celstyle = celstyle + 'background:' + resultss[0] + ';'
  909. elif(k):
  910. resultss = k.groups()
  911. celstyle = celstyle + 'background:' + resultss[0] + ';'
  912. elif(l):
  913. resultss = l.groups()
  914. celstyle = celstyle + 'background:' + resultss[0] + ';'
  915. aa = re.search("&lt;(#[0-9a-f-A-F]{6})&gt;", result[1])
  916. ab = re.search("&lt;(#[0-9a-f-A-F]{3})&gt;", result[1])
  917. ac = re.search("&lt;(\w+)&gt;", result[1])
  918. if(aa):
  919. resultss = aa.groups()
  920. celstyle = celstyle + 'background:' + resultss[0] + ';'
  921. elif(ab):
  922. resultss = ab.groups()
  923. celstyle = celstyle + 'background:' + resultss[0] + ';'
  924. elif(ac):
  925. resultss = ac.groups()
  926. celstyle = celstyle + 'background:' + resultss[0] + ';'
  927. qa = re.search("&lt;width=((?:(?!&gt;).)*)&gt;", result[1])
  928. qb = re.search("&lt;height=((?:(?!&gt;).)*)&gt;", result[1])
  929. if(qa):
  930. resultss = qa.groups()
  931. celstyle = celstyle + 'width:' + resultss[0] + ';'
  932. if(qb):
  933. resultss = qb.groups()
  934. celstyle = celstyle + 'height:' + resultss[0] + ';'
  935. i = re.search("&lt;\)&gt;", result[1])
  936. o = re.search("&lt;:&gt;", result[1])
  937. p = re.search("&lt;\(&gt;", result[1])
  938. if(i):
  939. celstyle = celstyle + 'text-align:right;'
  940. elif(o):
  941. celstyle = celstyle + 'text-align:center;'
  942. elif(p):
  943. celstyle = celstyle + 'text-align:left;'
  944. alltable = alltable + '"'
  945. celstyle = celstyle + '"'
  946. rowstyle = rowstyle + '"'
  947. table = re.sub("^(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "<table " + alltable + "><tbody><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
  948. else:
  949. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  950. table = re.sub("^(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "<table><tbody><tr><td " + cel + ">", table, 1)
  951. else:
  952. break
  953. table = re.sub("\|\|$", "</td></tr></tbody></table>", table)
  954. while(True):
  955. b = re.search("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", table)
  956. if(b):
  957. row = ''
  958. cel = ''
  959. celstyle = ''
  960. rowstyle = ''
  961. result = b.groups()
  962. if(result[1]):
  963. celstyle = 'style="'
  964. rowstyle = 'style="'
  965. r = re.search("&lt;-((?:(?!&gt;).)*)&gt;", result[1])
  966. if(r):
  967. resultss = r.groups()
  968. cel = 'colspan="' + resultss[0] + '"'
  969. else:
  970. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  971. t = re.search("&lt;\|((?:(?!&gt;).)*)&gt;", result[1])
  972. if(t):
  973. resultss = t.groups()
  974. row = 'rowspan="' + resultss[0] + '"'
  975. ba = re.search("&lt;rowbgcolor=(#[0-9a-f-A-F]{6})&gt;", result[1])
  976. bb = re.search("&lt;rowbgcolor=(#[0-9a-f-A-F]{3})&gt;", result[1])
  977. bc = re.search("&lt;rowbgcolor=(\w+)&gt;", result[1])
  978. if(ba):
  979. resultss = ba.groups()
  980. rowstyle = rowstyle + 'background:' + resultss[0] + ';'
  981. elif(bb):
  982. resultss = bb.groups()
  983. rowstyle = rowstyle + 'background:' + resultss[0] + ';'
  984. elif(bc):
  985. resultss = bc.groups()
  986. rowstyle = rowstyle + 'background:' + resultss[0] + ';'
  987. j = re.search("&lt;bgcolor=(#[0-9a-f-A-F]{6})&gt;", result[1])
  988. k = re.search("&lt;bgcolor=(#[0-9a-f-A-F]{3})&gt;", result[1])
  989. l = re.search("&lt;bgcolor=(\w+)&gt;", result[1])
  990. if(j):
  991. resultss = j.groups()
  992. celstyle = celstyle + 'background:' + resultss[0] + ';'
  993. elif(k):
  994. resultss = k.groups()
  995. celstyle = celstyle + 'background:' + resultss[0] + ';'
  996. elif(l):
  997. resultss = l.groups()
  998. celstyle = celstyle + 'background:' + resultss[0] + ';'
  999. aa = re.search("&lt;(#[0-9a-f-A-F]{6})&gt;", result[1])
  1000. ab = re.search("&lt;(#[0-9a-f-A-F]{3})&gt;", result[1])
  1001. ac = re.search("&lt;(\w+)&gt;", result[1])
  1002. if(aa):
  1003. resultss = aa.groups()
  1004. celstyle = celstyle + 'background:' + resultss[0] + ';'
  1005. elif(ab):
  1006. resultss = ab.groups()
  1007. celstyle = celstyle + 'background:' + resultss[0] + ';'
  1008. elif(ac):
  1009. resultss = ac.groups()
  1010. celstyle = celstyle + 'background:' + resultss[0] + ';'
  1011. qa = re.search("&lt;width=((?:(?!&gt;).)*)&gt;", result[1])
  1012. qb = re.search("&lt;height=((?:(?!&gt;).)*)&gt;", result[1])
  1013. if(qa):
  1014. resultss = qa.groups()
  1015. celstyle = celstyle + 'width:' + resultss[0] + ';'
  1016. if(qb):
  1017. resultss = qb.groups()
  1018. celstyle = celstyle + 'height:' + resultss[0] + ';'
  1019. i = re.search("&lt;\)&gt;", result[1])
  1020. o = re.search("&lt;:&gt;", result[1])
  1021. p = re.search("&lt;\(&gt;", result[1])
  1022. if(i):
  1023. celstyle = celstyle + 'text-align:right;'
  1024. elif(o):
  1025. celstyle = celstyle + 'text-align:center;'
  1026. elif(p):
  1027. celstyle = celstyle + 'text-align:left;'
  1028. celstyle = celstyle + '"'
  1029. rowstyle = rowstyle + '"'
  1030. table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td></tr><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
  1031. else:
  1032. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  1033. table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td></tr><tr><td " + cel + ">", table, 1)
  1034. else:
  1035. break
  1036. while(True):
  1037. c = re.search("(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", table)
  1038. if(c):
  1039. row = ''
  1040. cel = ''
  1041. celstyle = ''
  1042. result = c.groups()
  1043. if(result[1]):
  1044. celstyle = 'style="'
  1045. r = re.search("&lt;-((?:(?!&gt;).)*)&gt;", result[1])
  1046. if(r):
  1047. resultss = r.groups()
  1048. cel = 'colspan="' + resultss[0] + '"';
  1049. else:
  1050. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  1051. t = re.search("&lt;\|((?:(?!&gt;).)*)&gt;", result[1])
  1052. if(t):
  1053. resultss = t.groups()
  1054. row = 'rowspan="' + resultss[0] + '"';
  1055. j = re.search("&lt;bgcolor=(#[0-9a-f-A-F]{6})&gt;", result[1])
  1056. k = re.search("&lt;bgcolor=(#[0-9a-f-A-F]{3})&gt;", result[1])
  1057. l = re.search("&lt;bgcolor=(\w+)&gt;", result[1])
  1058. if(j):
  1059. resultss = j.groups()
  1060. celstyle = celstyle + 'background:' + resultss[0] + ';'
  1061. elif(k):
  1062. resultss = k.groups()
  1063. celstyle = celstyle + 'background:' + resultss[0] + ';'
  1064. elif(l):
  1065. resultss = l.groups()
  1066. celstyle = celstyle + 'background:' + resultss[0] + ';'
  1067. aa = re.search("&lt;(#[0-9a-f-A-F]{6})&gt;", result[1])
  1068. ab = re.search("&lt;(#[0-9a-f-A-F]{3})&gt;", result[1])
  1069. ac = re.search("&lt;(\w+)&gt;", result[1])
  1070. if(aa):
  1071. resultss = aa.groups()
  1072. celstyle = celstyle + 'background:' + resultss[0] + ';'
  1073. elif(ab):
  1074. resultss = ab.groups()
  1075. celstyle = celstyle + 'background:' + resultss[0] + ';'
  1076. elif(ac):
  1077. resultss = ac.groups()
  1078. celstyle = celstyle + 'background:' + resultss[0] + ';'
  1079. qa = re.search("&lt;width=((?:(?!&gt;).)*)&gt;", result[1])
  1080. qb = re.search("&lt;height=((?:(?!&gt;).)*)&gt;", result[1])
  1081. if(qa):
  1082. resultss = qa.groups()
  1083. celstyle = celstyle + 'width:' + resultss[0] + ';'
  1084. if(qb):
  1085. resultss = qb.groups()
  1086. celstyle = celstyle + 'height:' + resultss[0] + ';'
  1087. i = re.search("&lt;\)&gt;", result[1])
  1088. o = re.search("&lt;:&gt;", result[1])
  1089. p = re.search("&lt;\(&gt;", result[1])
  1090. if(i):
  1091. celstyle = celstyle + 'text-align:right;'
  1092. elif(o):
  1093. celstyle = celstyle + 'text-align:center;'
  1094. elif(p):
  1095. celstyle = celstyle + 'text-align:left;'
  1096. celstyle = celstyle + '"'
  1097. table = re.sub("(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td><td " + cel + " " + row + " " + celstyle + ">", table, 1)
  1098. else:
  1099. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  1100. table = re.sub("(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td><td " + cel + ">", table, 1)
  1101. else:
  1102. break
  1103. data = re.sub("(\|\|(?:(?:(?:.*)\n?)\|\|)+)", table, data, 1)
  1104. else:
  1105. break
  1106. data = re.sub('<\/blockquote>((\r)?\n){2}<blockquote>', '</blockquote><br><blockquote>', data)
  1107. data = re.sub('\n', '<br>', data)
  1108. data = re.sub('^<br>', '', data)
  1109. return str(data)
  1110. def getip(request):
  1111. if(session.get('Now') == True):
  1112. ip = format(session['DREAMER'])
  1113. else:
  1114. if(request.headers.getlist("X-Forwarded-For")):
  1115. ip = request.headers.getlist("X-Forwarded-For")[0]
  1116. else:
  1117. ip = request.remote_addr
  1118. return ip
  1119. def getcan(ip, name):
  1120. m = re.search("^사용자:(.*)", name)
  1121. n = re.search("^파일:(.*)", name)
  1122. if(m):
  1123. g = m.groups()
  1124. if(ip == g[0]):
  1125. if(re.search("\.", g[0])):
  1126. return 1
  1127. else:
  1128. DB_실행("select * from ban where block = '" + DB_인코딩(ip) + "'")
  1129. rows = curs.fetchall()
  1130. if(rows):
  1131. return 1
  1132. else:
  1133. return 0
  1134. else:
  1135. return 1
  1136. elif(n):
  1137. if(not 소유자_확인() == 1):
  1138. return 1
  1139. else:
  1140. b = re.search("^([0-9](?:[0-9]?[0-9]?)\.[0-9](?:[0-9]?[0-9]?))", ip)
  1141. if(b):
  1142. results = b.groups()
  1143. DB_실행("select * from ban where block = '" + DB_인코딩(results[0]) + "' and band = 'O'")
  1144. rowss = curs.fetchall()
  1145. if(rowss):
  1146. return 1
  1147. else:
  1148. DB_실행("select * from ban where block = '" + DB_인코딩(ip) + "'")
  1149. rows = curs.fetchall()
  1150. if(rows):
  1151. return 1
  1152. else:
  1153. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  1154. row = curs.fetchall()
  1155. if(row):
  1156. DB_실행("select * from user where id = '" + DB_인코딩(ip) + "'")
  1157. rows = curs.fetchall()
  1158. if(row[0]['acl'] == 'user'):
  1159. if(rows):
  1160. return 0
  1161. else:
  1162. return 1
  1163. elif(row[0]['acl'] == 'admin'):
  1164. if(rows):
  1165. if(rows[0]['acl'] == 'admin' or rows[0]['acl'] == 'owner'):
  1166. return 0
  1167. else:
  1168. return 1
  1169. else:
  1170. return 1
  1171. else:
  1172. return 0
  1173. else:
  1174. return 0
  1175. else:
  1176. DB_실행("select * from ban where block = '" + DB_인코딩(ip) + "'")
  1177. rows = curs.fetchall()
  1178. if(rows):
  1179. return 1
  1180. else:
  1181. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  1182. row = curs.fetchall()
  1183. if(row):
  1184. DB_실행("select * from user where id = '" + DB_인코딩(ip) + "'")
  1185. rows = curs.fetchall()
  1186. if(row[0]['acl'] == 'user'):
  1187. if(rows):
  1188. return 0
  1189. else:
  1190. return 1
  1191. elif(row[0]['acl'] == 'admin'):
  1192. if(rows):
  1193. if(rows[0]['acl'] == 'admin' or rows[0]['acl'] == 'owner'):
  1194. return 0
  1195. else:
  1196. return 1
  1197. else:
  1198. return 1
  1199. else:
  1200. return 0
  1201. else:
  1202. return 0
  1203. def getban(ip):
  1204. b = re.search("^([0-9](?:[0-9]?[0-9]?)\.[0-9](?:[0-9]?[0-9]?))", ip)
  1205. if(b):
  1206. results = b.groups()
  1207. DB_실행("select * from ban where block = '" + DB_인코딩(results[0]) + "' and band = 'O'")
  1208. rowss = curs.fetchall()
  1209. if(rowss):
  1210. return 1
  1211. else:
  1212. DB_실행("select * from ban where block = '" + DB_인코딩(ip) + "'")
  1213. rows = curs.fetchall()
  1214. if(rows):
  1215. return 1
  1216. else:
  1217. return 0
  1218. else:
  1219. DB_실행("select * from ban where block = '" + DB_인코딩(ip) + "'")
  1220. rows = curs.fetchall()
  1221. if(rows):
  1222. return 1
  1223. else:
  1224. return 0
  1225. def getdiscuss(ip, name, sub):
  1226. b = re.search("^([0-9](?:[0-9]?[0-9]?)\.[0-9](?:[0-9]?[0-9]?))", ip)
  1227. if(b):
  1228. results = b.groups()
  1229. DB_실행("select * from ban where block = '" + DB_인코딩(results[0]) + "' and band = 'O'")
  1230. rowss = curs.fetchall()
  1231. if(rowss):
  1232. return 1
  1233. else:
  1234. DB_실행("select * from ban where block = '" + DB_인코딩(ip) + "'")
  1235. rows = curs.fetchall()
  1236. if(rows):
  1237. return 1
  1238. else:
  1239. DB_실행("select * from stop where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "'")
  1240. rows = curs.fetchall()
  1241. if(rows):
  1242. return 1
  1243. else:
  1244. return 0
  1245. else:
  1246. DB_실행("select * from ban where block = '" + DB_인코딩(ip) + "'")
  1247. rows = curs.fetchall()
  1248. if(rows):
  1249. return 1
  1250. else:
  1251. DB_실행("select * from stop where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "'")
  1252. rows = curs.fetchall()
  1253. if(rows):
  1254. return 1
  1255. else:
  1256. return 0
  1257. def 시간():
  1258. now = time.localtime()
  1259. s = "%04d-%02d-%02d %02d:%02d:%02d" % (now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec)
  1260. return s
  1261. def discuss(title, sub, date):
  1262. DB_실행("select * from rd where title = '" + DB_인코딩(title) + "' and sub = '" + DB_인코딩(sub) + "'")
  1263. rows = curs.fetchall()
  1264. if(rows):
  1265. DB_실행("update rd set date = '" + DB_인코딩(date) + "' where title = '" + DB_인코딩(title) + "' and sub = '" + DB_인코딩(sub) + "'")
  1266. else:
  1267. DB_실행("insert into rd (title, sub, date) value ('" + DB_인코딩(title) + "', '" + DB_인코딩(sub) + "', '" + DB_인코딩(date) + "')")
  1268. DB_갱신()
  1269. def block(block, end, today, blocker, why):
  1270. DB_실행("insert into rb (block, end, today, blocker, why) value ('" + DB_인코딩(block) + "', '" + DB_인코딩(end) + "', '" + today + "', '" + DB_인코딩(blocker) + "', '" + DB_인코딩(why) + "')")
  1271. DB_갱신()
  1272. def history(title, data, date, ip, send, leng):
  1273. DB_실행("select * from history where title = '" + DB_인코딩(title) + "' order by id+0 desc limit 1")
  1274. rows = curs.fetchall()
  1275. if(rows):
  1276. number = int(rows[0]['id']) + 1
  1277. DB_실행("insert into history (id, title, data, date, ip, send, leng) value ('" + str(number) + "', '" + DB_인코딩(title) + "', '" + DB_인코딩(data) + "', '" + date + "', '" + DB_인코딩(ip) + "', '" + DB_인코딩(send) + "', '" + leng + "')")
  1278. DB_갱신()
  1279. else:
  1280. DB_실행("insert into history (id, title, data, date, ip, send, leng) value ('1', '" + DB_인코딩(title) + "', '" + DB_인코딩(data) + "', '" + date + "', '" + DB_인코딩(ip) + "', '" + DB_인코딩(send + ' (새 문서)') + "', '" + leng + "')")
  1281. DB_갱신()
  1282. def getleng(existing, change):
  1283. if(existing < change):
  1284. leng = change - existing
  1285. leng = '+' + str(leng)
  1286. elif(change < existing):
  1287. leng = existing - change
  1288. leng = '-' + str(leng)
  1289. else:
  1290. leng = '0'
  1291. return leng
  1292. @app.route('/upload', methods=['GET', 'POST'])
  1293. def upload():
  1294. app.config['MAX_CONTENT_LENGTH'] = int(data['upload']) * 1024 * 1024
  1295. if(request.method == 'POST'):
  1296. ip = getip(request)
  1297. ban = getban(ip)
  1298. if(ban == 1):
  1299. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  1300. else:
  1301. file = request.files['file']
  1302. if(file):
  1303. if(re.search('^([^./\\*<>|:?"]+)\.([Jj][Pp][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg]|[Pp][Nn][Gg])$', file.filename)):
  1304. filename = file.filename
  1305. if(os.path.exists(os.path.join('image', filename))):
  1306. return '<meta http-equiv="refresh" content="0;url=/error/16" />'
  1307. else:
  1308. file.save(os.path.join('image', filename))
  1309. DB_실행("insert into data (title, data, acl) value ('" + DB_인코딩('파일:' + filename) + "', '" + DB_인코딩('[[파일:' + filename + ']][br][br]{{{[[파일:' + filename + ']]}}}') + "', '')")
  1310. DB_갱신()
  1311. history('파일:' + filename, '[[파일:' + filename + ']][br][br]{{{[[파일:' + filename + ']]}}}', 시간(), ip, '파일:' + filename + ' 업로드', '0')
  1312. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩('파일:' + filename) + '" />'
  1313. else:
  1314. return '<meta http-equiv="refresh" content="0;url=/error/15" />'
  1315. else:
  1316. return '<meta http-equiv="refresh" content="0;url=/error/14" />'
  1317. else:
  1318. ip = getip(request)
  1319. ban = getban(ip)
  1320. if(ban == 1):
  1321. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  1322. else:
  1323. return render_template('index.html', logo = data['name'], title = '업로드', tn = 21, number = data['upload'])
  1324. @app.route('/image/<path:name>')
  1325. def image(name = None):
  1326. if(os.path.exists(os.path.join('image', name))):
  1327. return send_file(os.path.join('image', name), mimetype='image')
  1328. else:
  1329. return render_template('index.html', logo = data['name'], data = '이미지 없음.', title = '이미지 보기'), 404
  1330. @app.route('/adminlist')
  1331. def adminlist():
  1332. i = 0
  1333. div = '<div>'
  1334. DB_실행("select * from user where acl = 'admin' or acl = 'owner'")
  1335. rows = curs.fetchall()
  1336. if(rows):
  1337. while(True):
  1338. try:
  1339. a = rows[i]
  1340. except:
  1341. div = div + '</div>'
  1342. break
  1343. if(rows[i]['acl'] == 'owner'):
  1344. acl = '소유자'
  1345. else:
  1346. acl = '관리자'
  1347. DB_실행("select * from data where title = '사용자:" + rows[i]['id'] + "'")
  1348. user = curs.fetchall()
  1349. if(user):
  1350. name = '<a href="/w/' + URL_인코딩('사용자:' + rows[i]['id']) + '">' + rows[i]['id'] + '</a> (' + acl + ')'
  1351. else:
  1352. name = '<a class="not_thing" href="/w/' + URL_인코딩('사용자:' + rows[i]['id']) + '">' + rows[i]['id'] + '</a> (' + acl + ')'
  1353. div = div + '<li>' + str(i + 1) + '. ' + name + '</li>'
  1354. i = i + 1
  1355. return render_template('index.html', logo = data['name'], data = div, title = '관리자 목록')
  1356. else:
  1357. return render_template('index.html', logo = data['name'], title = '관리자 목록')
  1358. @app.route('/recentchanges')
  1359. def recentchanges():
  1360. i = 0
  1361. div = '<div>'
  1362. DB_실행("select * from history order by date desc limit 50")
  1363. rows = curs.fetchall()
  1364. if(rows):
  1365. admin = 관리자_확인()
  1366. while(True):
  1367. try:
  1368. a = rows[i]
  1369. except:
  1370. div = div + '</div>'
  1371. break
  1372. if(rows[i]['send']):
  1373. send = rows[i]['send']
  1374. send = re.sub('<a href="\/w\/(?P<in>[^"]*)">(?P<out>[^&]*)<\/a>', '<a href="/w/\g<in>">\g<out></a>', send)
  1375. else:
  1376. send = '<br>'
  1377. title = rows[i]['title']
  1378. title = re.sub('<', '&lt;', title)
  1379. title = re.sub('>', '&gt;', title)
  1380. m = re.search("\+", rows[i]['leng'])
  1381. n = re.search("\-", rows[i]['leng'])
  1382. if(m):
  1383. leng = '<span style="color:green;">' + rows[i]['leng'] + '</span>'
  1384. elif(n):
  1385. leng = '<span style="color:red;">' + rows[i]['leng'] + '</span>'
  1386. else:
  1387. leng = '<span style="color:gray;">' + rows[i]['leng'] + '</span>'
  1388. if(admin == 1):
  1389. DB_실행("select * from ban where block = '" + DB_인코딩(rows[i]['ip']) + "'")
  1390. row = curs.fetchall()
  1391. if(row):
  1392. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['ip']) + '">(해제)</a>'
  1393. else:
  1394. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['ip']) + '">(차단)</a>'
  1395. else:
  1396. ban = ''
  1397. if(re.search('\.', rows[i]['ip'])):
  1398. ip = rows[i]['ip']
  1399. else:
  1400. DB_실행("select * from data where title = '사용자:" + DB_인코딩(rows[i]['ip']) + "'")
  1401. row = curs.fetchall()
  1402. if(row):
  1403. ip = '<a href="/w/' + URL_인코딩('사용자:' + rows[i]['ip']) + '">' + rows[i]['ip'] + '</a>'
  1404. else:
  1405. ip = '<a class="not_thing" href="/w/' + URL_인코딩('사용자:' + rows[i]['ip']) + '">' + rows[i]['ip'] + '</a>'
  1406. if((int(rows[i]['id']) - 1) == 0):
  1407. revert = ''
  1408. else:
  1409. revert = '<a href="/revert/' + URL_인코딩(rows[i]['title']) + '/r/' + str(int(rows[i]['id']) - 1) + '">(되돌리기)</a>'
  1410. div = div + '<table style="width: 100%;"><tbody><tr><td style="text-align: center;width:33.33%;"><a href="/w/' + URL_인코딩(rows[i]['title']) + '">' + title + '</a> <a href="/history/' + URL_인코딩(rows[i]['title']) + '/n/1">(역사)</a> ' + revert + ' (' + leng + ')</td><td style="text-align: center;width:33.33%;">' + ip + ban + '</td><td style="text-align: center;width:33.33%;">' + rows[i]['date'] + '</td></tr><tr><td colspan="3" style="text-align: center;width:100%;">' + send + '</td></tr></tbody></table>'
  1411. i = i + 1
  1412. return render_template('index.html', logo = data['name'], rows = div, tn = 3, title = '최근 변경내역')
  1413. else:
  1414. return render_template('index.html', logo = data['name'], rows = '', tn = 3, title = '최근 변경내역')
  1415. @app.route('/history/<path:name>/r/<int:num>/hidden')
  1416. def hidden(name = None, num = None):
  1417. if(소유자_확인() == 1):
  1418. DB_실행("select * from hidhi where title = '" + DB_인코딩(name) + "' and re = '" + DB_인코딩(str(num)) + "'")
  1419. rows = curs.fetchall()
  1420. if(rows):
  1421. DB_실행("delete from hidhi where title = '" + DB_인코딩(name) + "' and re = '" + DB_인코딩(str(num)) + "'")
  1422. else:
  1423. DB_실행("insert into hidhi (title, re) value ('" + DB_인코딩(name) + "', '" + DB_인코딩(str(num)) + "')")
  1424. DB_갱신()
  1425. return '<meta http-equiv="refresh" content="0;url=/history/' + URL_인코딩(name) + '/n/1" />'
  1426. else:
  1427. return '<meta http-equiv="refresh" content="0;url=/history/' + URL_인코딩(name) + '/n/1" />'
  1428. @app.route('/record/<path:name>/n/<int:number>')
  1429. def record(name = None, number = None):
  1430. v = number * 50
  1431. i = v - 50
  1432. div = '<div>'
  1433. DB_실행("select * from history where ip = '" + DB_인코딩(name) + "' order by date desc")
  1434. rows = curs.fetchall()
  1435. if(rows):
  1436. admin = 관리자_확인()
  1437. while(True):
  1438. try:
  1439. a = rows[i]
  1440. except:
  1441. div = div + '</div>'
  1442. if(number != 1):
  1443. div = div + '<br><a href="/record/' + URL_인코딩(name) + '/n/' + str(number - 1) + '">(이전)'
  1444. break
  1445. if(rows[i]['send']):
  1446. send = rows[i]['send']
  1447. send = re.sub('<a href="\/w\/(?P<in>[^"]*)">(?P<out>[^&]*)<\/a>', '<a href="/w/\g<in>">\g<out></a>', send)
  1448. else:
  1449. send = '<br>'
  1450. title = rows[i]['title']
  1451. title = re.sub('<', '&lt;', title)
  1452. title = re.sub('>', '&gt;', title)
  1453. m = re.search("\+", rows[i]['leng'])
  1454. n = re.search("\-", rows[i]['leng'])
  1455. if(m):
  1456. leng = '<span style="color:green;">' + rows[i]['leng'] + '</span>'
  1457. elif(n):
  1458. leng = '<span style="color:red;">' + rows[i]['leng'] + '</span>'
  1459. else:
  1460. leng = '<span style="color:gray;">' + rows[i]['leng'] + '</span>'
  1461. if(admin == 1):
  1462. DB_실행("select * from ban where block = '" + DB_인코딩(rows[i]['ip']) + "'")
  1463. row = curs.fetchall()
  1464. if(row):
  1465. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['ip']) + '">(해제)</a>'
  1466. else:
  1467. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['ip']) + '">(차단)</a>'
  1468. else:
  1469. ban = ''
  1470. if(re.search('\.', rows[i]['ip'])):
  1471. ip = rows[i]['ip']
  1472. else:
  1473. DB_실행("select * from data where title = '사용자:" + DB_인코딩(rows[i]['ip']) + "'")
  1474. row = curs.fetchall()
  1475. if(row):
  1476. ip = '<a href="/w/' + URL_인코딩('사용자:' + rows[i]['ip']) + '">' + rows[i]['ip'] + '</a>'
  1477. else:
  1478. ip = '<a class="not_thing" href="/w/' + URL_인코딩('사용자:' + rows[i]['ip']) + '">' + rows[i]['ip'] + '</a>'
  1479. if((int(rows[i]['id']) - 1) == 0):
  1480. revert = ''
  1481. else:
  1482. revert = '<a href="/revert/' + URL_인코딩(rows[i]['title']) + '/r/' + str(int(rows[i]['id']) - 1) + '">(되돌리기)</a>'
  1483. div = div + '<table style="width: 100%;"><tbody><tr><td style="text-align: center;width:33.33%;"><a href="/w/' + URL_인코딩(rows[i]['title']) + '">' + title + '</a> r' + rows[i]['id'] + ' <a href="/history/' + URL_인코딩(rows[i]['title']) + '/n/1">(역사)</a> ' + revert + ' (' + leng + ')</td><td style="text-align: center;width:33.33%;">' + ip + ban + '</td><td style="text-align: center;width:33.33%;">' + rows[i]['date'] + '</td></tr><tr><td colspan="3" style="text-align: center;width:100%;">' + send + '</td></tr></tbody></table>'
  1484. if(i == v):
  1485. div = div + '</div>'
  1486. if(number == 1):
  1487. div = div + '<br><a href="/record/' + URL_인코딩(name) + '/n/' + str(number + 1) + '">(다음)'
  1488. else:
  1489. div = div + '<br><a href="/record/' + URL_인코딩(name) + '/n/' + str(number - 1) + '">(이전) <a href="/record/' + URL_인코딩(name) + '/n/' + str(number + 1) + '">(다음)'
  1490. break
  1491. else:
  1492. i = i + 1
  1493. return render_template('index.html', logo = data['name'], rows = div, tn = 3, title = '유저 기록')
  1494. else:
  1495. return render_template('index.html', logo = data['name'], rows = '', tn = 3, title = '유저 기록')
  1496. @app.route('/userlog/n/<int:number>')
  1497. def userlog(number = None):
  1498. v = number * 50
  1499. i = v - 50
  1500. div = ''
  1501. DB_실행("select * from user")
  1502. rows = curs.fetchall()
  1503. if(rows):
  1504. admin = 관리자_확인()
  1505. while(True):
  1506. try:
  1507. a = rows[i]
  1508. except:
  1509. if(number != 1):
  1510. div = div + '<br><a href="/userlog/n/' + str(number - 1) + '">(이전)'
  1511. break
  1512. if(admin == 1):
  1513. DB_실행("select * from ban where block = '" + DB_인코딩(rows[i]['id']) + "'")
  1514. row = curs.fetchall()
  1515. if(row):
  1516. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['id']) + '">(해제)</a>'
  1517. else:
  1518. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['id']) + '">(차단)</a>'
  1519. else:
  1520. ban = ''
  1521. if(re.search('\.', rows[i]['id'])):
  1522. ip = rows[i]['id']
  1523. else:
  1524. DB_실행("select * from data where title = '사용자:" + DB_인코딩(rows[i]['id']) + "'")
  1525. row = curs.fetchall()
  1526. if(row):
  1527. ip = '<a href="/w/' + URL_인코딩('사용자:' + rows[i]['id']) + '">' + rows[i]['id'] + '</a>'
  1528. else:
  1529. ip = '<a class="not_thing" href="/w/' + URL_인코딩('사용자:' + rows[i]['id']) + '">' + rows[i]['id'] + '</a>'
  1530. div = div + '<li>' + str(i + 1) + '. ' + ip + ban + '</li>'
  1531. if(i == v):
  1532. if(number == 1):
  1533. div = div + '<br><a href="/userlog/n/' + str(number + 1) + '">(다음)'
  1534. else:
  1535. div = div + '<br><a href="/userlog/n/' + str(number - 1) + '">(이전) <a href="/userlog/n/' + str(number + 1) + '">(다음)'
  1536. break
  1537. else:
  1538. i = i + 1
  1539. return render_template('index.html', logo = data['name'], data = div, title = '유저 가입 기록')
  1540. else:
  1541. return render_template('index.html', logo = data['name'], data = '', title = '유저 가입 기록')
  1542. @app.route('/backlink/<path:name>/n/<int:number>')
  1543. def backlink(name = None, number = None):
  1544. v = number * 50
  1545. i = v - 50
  1546. div = ''
  1547. restart = 0
  1548. DB_실행("select * from back where title = '" + DB_인코딩(name) + "' order by link asc")
  1549. rows = curs.fetchall()
  1550. if(rows):
  1551. while(True):
  1552. try:
  1553. a = rows[i]
  1554. except:
  1555. if(number != 1):
  1556. div = div + '<br><a href="/backlink/n/' + str(number - 1) + '">(이전)'
  1557. break
  1558. if(rows[i]['type'] == 'include'):
  1559. DB_실행("select * from back where title = '" + DB_인코딩(name) + "' and link = '" + DB_인코딩(rows[i]['link']) + "' and type = ''")
  1560. test = curs.fetchall()
  1561. if(test):
  1562. restart = 1
  1563. DB_실행("delete from back where title = '" + DB_인코딩(name) + "' and link = '" + DB_인코딩(rows[i]['link']) + "' and type = ''")
  1564. DB_갱신()
  1565. if(not re.search('^사용자:', rows[i]['link'])):
  1566. DB_실행("select * from data where title = '" + DB_인코딩(rows[i]['link']) + "'")
  1567. row = curs.fetchall()
  1568. if(row):
  1569. aa = row[0]['data']
  1570. aa = re.sub("(?P<in>\[include\((?P<out>(?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\])", "\g<in>\n\n[[\g<out>]]\n\n", aa)
  1571. aa = re.sub('^#(?:redirect|넘겨주기)\s(?P<in>[^\n]*)', '[[\g<in>]]', aa)
  1572. aa = namumark('', aa)
  1573. if(re.search("<a(?:(?:(?!href=).)*)?href=\"\/w\/" + URL_인코딩(name) + "(?:\#[^\"]*)?\">([^<]*)<\/a>", aa)):
  1574. div = div + '<li><a href="/w/' + URL_인코딩(rows[i]['link']) + '">' + rows[i]['link'] + '</a>'
  1575. if(rows[i]['type']):
  1576. div = div + ' (' + rows[i]['type'] + ')</li>'
  1577. else:
  1578. div = div + '</li>'
  1579. if(i == v):
  1580. if(number == 1):
  1581. div = div + '<br><a href="/backlink/' + URL_인코딩(name) + '/n/' + str(number + 1) + '">(다음)'
  1582. else:
  1583. div = div + '<br><a href="/backlink/' + URL_인코딩(name) + '/n/' + str(number - 1) + '">(이전) <a href="/backlink/' + URL_인코딩(name) + '/n/' + str(number + 1) + '">(다음)'
  1584. break
  1585. else:
  1586. i = i + 1
  1587. else:
  1588. DB_실행("delete from back where title = '" + DB_인코딩(name) + "' and link = '" + DB_인코딩(rows[i]['link']) + "'")
  1589. DB_갱신()
  1590. i = i + 1
  1591. v = v + 1
  1592. else:
  1593. DB_실행("delete from back where title = '" + DB_인코딩(name) + "' and link = '" + DB_인코딩(rows[i]['link']) + "'")
  1594. DB_갱신()
  1595. i = i + 1
  1596. v = v + 1
  1597. else:
  1598. DB_실행("delete from back where title = '" + DB_인코딩(name) + "' and link = '" + DB_인코딩(rows[i]['link']) + "'")
  1599. DB_갱신()
  1600. i = i + 1
  1601. v = v + 1
  1602. if(restart == 1):
  1603. return '<meta http-equiv="refresh" content="0;url=/backlink/' + URL_인코딩(name) + '/n/' + str(number) + '" />'
  1604. else:
  1605. return render_template('index.html', logo = data['name'], data = div, title = name, sub = '역링크')
  1606. else:
  1607. return render_template('index.html', logo = data['name'], data = '', title = name, sub = '역링크')
  1608. @app.route('/recentdiscuss')
  1609. def recentdiscuss():
  1610. i = 0
  1611. div = '<div>'
  1612. DB_실행("select * from rd order by date desc limit 50")
  1613. rows = curs.fetchall()
  1614. if(rows):
  1615. while(True):
  1616. try:
  1617. a = rows[i]
  1618. except:
  1619. div = div + '</div>'
  1620. break
  1621. title = rows[i]['title']
  1622. title = re.sub('<', '&lt;', title)
  1623. title = re.sub('>', '&gt;', title)
  1624. sub = rows[i]['sub']
  1625. sub = re.sub('<', '&lt;', sub)
  1626. sub = re.sub('>', '&gt;', sub)
  1627. div = div + '<table style="width: 100%;"><tbody><tr><td style="text-align: center;width:50%;"><a href="/topic/' + URL_인코딩(rows[i]['title']) + '/sub/' + URL_인코딩(rows[i]['sub']) + '">' + title + '</a> (' + sub + ')</td><td style="text-align: center;width:50%;">' + rows[i]['date'] + '</td></tr></tbody></table>'
  1628. i = i + 1
  1629. return render_template('index.html', logo = data['name'], rows = div, tn = 12, title = '최근 토론내역')
  1630. else:
  1631. return render_template('index.html', logo = data['name'], rows = '', tn = 12, title = '최근 토론내역')
  1632. @app.route('/blocklog/n/<int:number>')
  1633. def blocklog(number = None):
  1634. v = number * 50
  1635. i = v - 50
  1636. div = '<div>'
  1637. DB_실행("select * from rb order by today desc")
  1638. rows = curs.fetchall()
  1639. if(rows):
  1640. while(True):
  1641. try:
  1642. a = rows[i]
  1643. except:
  1644. div = div + '</div>'
  1645. if(number != 1):
  1646. div = div + '<br><a href="/blocklog/n/' + str(number - 1) + '">(이전)'
  1647. break
  1648. why = rows[i]['why']
  1649. why = re.sub('<', '&lt;', why)
  1650. why = re.sub('>', '&gt;', why)
  1651. b = re.search("^([0-9](?:[0-9]?[0-9]?)\.[0-9](?:[0-9]?[0-9]?))$", rows[i]['block'])
  1652. if(b):
  1653. ip = rows[i]['block'] + ' (대역)'
  1654. else:
  1655. ip = rows[i]['block']
  1656. div = div + '<table style="width: 100%;"><tbody><tr><td style="text-align: center;width:20%;">' + ip + '</a></td><td style="text-align: center;width:20%;">' + rows[i]['blocker'] + '</td><td style="text-align: center;width:20%;">' + rows[i]['end'] + '</td><td style="text-align: center;width:20%;">' + rows[i]['why'] + '</td><td style="text-align: center;width:20%;">' + rows[i]['today'] + '</td></tr></tbody></table>'
  1657. if(i == v):
  1658. div = div + '</div>'
  1659. if(number == 1):
  1660. div = div + '<br><a href="/blocklog/n/' + str(number + 1) + '">(다음)'
  1661. else:
  1662. div = div + '<br><a href="/blocklog/n/' + str(number - 1) + '">(이전) <a href="/blocklog/n/' + str(number + 1) + '">(다음)'
  1663. break
  1664. else:
  1665. i = i + 1
  1666. return render_template('index.html', logo = data['name'], rows = div, tn = 20, title = '유저 차단 기록')
  1667. else:
  1668. return render_template('index.html', logo = data['name'], rows = '', tn = 20, title = '유저 차단 기록')
  1669. @app.route('/history/<path:name>/n/<int:number>', methods=['POST', 'GET'])
  1670. def gethistory(name = None, number = None):
  1671. if(request.method == 'POST'):
  1672. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '/r/' + request.form["b"] + '/diff/' + request.form["a"] + '" />'
  1673. else:
  1674. select = ''
  1675. v = number * 50
  1676. i = v - 50
  1677. div = '<div>'
  1678. DB_실행("select * from history where title = '" + DB_인코딩(name) + "' order by id+0 desc")
  1679. rows = curs.fetchall()
  1680. if(rows):
  1681. admin = 관리자_확인()
  1682. while(True):
  1683. style = ''
  1684. try:
  1685. a = rows[i]
  1686. except:
  1687. div = div + '</div>'
  1688. if(number != 1):
  1689. div = div + '<br><a href="/history/' + URL_인코딩(name) + '/n/' + str(number - 1) + '">(이전)'
  1690. break
  1691. select = '<option value="' + str(i + 1) + '">' + str(i + 1) + '</option>' + select
  1692. if(rows[i]['send']):
  1693. send = rows[i]['send']
  1694. send = re.sub('<a href="\/w\/(?P<in>[^"]*)">(?P<out>[^&]*)<\/a>', '<a href="/w/\g<in>">\g<out></a>', send)
  1695. else:
  1696. send = '<br>'
  1697. m = re.search("\+", rows[i]['leng'])
  1698. n = re.search("\-", rows[i]['leng'])
  1699. if(m):
  1700. leng = '<span style="color:green;">' + rows[i]['leng'] + '</span>'
  1701. elif(n):
  1702. leng = '<span style="color:red;">' + rows[i]['leng'] + '</span>'
  1703. else:
  1704. leng = '<span style="color:gray;">' + rows[i]['leng'] + '</span>'
  1705. if(re.search("\.", rows[i]["ip"])):
  1706. ip = rows[i]["ip"]
  1707. else:
  1708. DB_실행("select * from data where title = '사용자:" + DB_인코딩(rows[i]['ip']) + "'")
  1709. row = curs.fetchall()
  1710. if(row):
  1711. ip = '<a href="/w/' + URL_인코딩('사용자:' + rows[i]['ip']) + '">' + rows[i]['ip'] + '</a>'
  1712. else:
  1713. ip = '<a class="not_thing" href="/w/' + URL_인코딩('사용자:' + rows[i]['ip']) + '">' + rows[i]['ip'] + '</a>'
  1714. if(admin == 1):
  1715. DB_실행("select * from user where id = '" + DB_인코딩(rows[i]['ip']) + "'")
  1716. row = curs.fetchall()
  1717. if(row):
  1718. if(row[0]['acl'] == 'owner' or row[0]['acl'] == 'admin'):
  1719. ban = ''
  1720. else:
  1721. DB_실행("select * from ban where block = '" + DB_인코딩(rows[i]['ip']) + "'")
  1722. row = curs.fetchall()
  1723. if(row):
  1724. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['ip']) + '">(해제)</a>'
  1725. else:
  1726. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['ip']) + '">(차단)</a>'
  1727. else:
  1728. DB_실행("select * from ban where block = '" + DB_인코딩(rows[i]['ip']) + "'")
  1729. row = curs.fetchall()
  1730. if(row):
  1731. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['ip']) + '">(해제)</a>'
  1732. else:
  1733. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['ip']) + '">(차단)</a>'
  1734. if(소유자_확인() == 1):
  1735. DB_실행("select * from hidhi where title = '" + DB_인코딩(name) + "' and re = '" + DB_인코딩(rows[i]['id']) + "'")
  1736. row = curs.fetchall()
  1737. if(row):
  1738. ip = ip + ' (숨김)'
  1739. hidden = ' <a href="/history/' + URL_인코딩(name) + '/r/' + rows[i]['id'] + '/hidden">(공개)'
  1740. else:
  1741. hidden = ' <a href="/history/' + URL_인코딩(name) + '/r/' + rows[i]['id'] + '/hidden">(숨김)'
  1742. else:
  1743. DB_실행("select * from hidhi where title = '" + DB_인코딩(name) + "' and re = '" + DB_인코딩(rows[i]['id']) + "'")
  1744. row = curs.fetchall()
  1745. if(row):
  1746. ip = '숨김'
  1747. hidden = ''
  1748. send = '숨김'
  1749. ban = ''
  1750. style = 'display:none;'
  1751. v = v + 1
  1752. else:
  1753. hidden = ''
  1754. else:
  1755. ban = ''
  1756. DB_실행("select * from hidhi where title = '" + DB_인코딩(name) + "' and re = '" + DB_인코딩(rows[i]['id']) + "'")
  1757. row = curs.fetchall()
  1758. if(row):
  1759. ip = '숨김'
  1760. hidden = ''
  1761. send = '숨김'
  1762. ban = ''
  1763. style = 'display:none;'
  1764. v = v + 1
  1765. else:
  1766. hidden = ''
  1767. div = div + '<table style="width: 100%;' + style + '"><tbody><tr><td style="text-align: center;width:33.33%;">r' + rows[i]['id'] + '</a> <a href="/w/' + URL_인코딩(rows[i]['title']) + '/r/' + rows[i]['id'] + '">(w)</a> <a href="/w/' + URL_인코딩(rows[i]['title']) + '/raw/' + rows[i]['id'] + '">(Raw)</a> <a href="/revert/' + URL_인코딩(rows[i]['title']) + '/r/' + rows[i]['id'] + '">(되돌리기)</a> (' + leng + ')</td><td style="text-align: center;width:33.33%;">' + ip + ban + hidden + '</td><td style="text-align: center;width:33.33%;">' + rows[i]['date'] + '</td></tr><tr><td colspan="3" style="text-align: center;width:100%;">' + send + '</td></tr></tbody></table>'
  1768. if(i == v):
  1769. div = div + '</div>'
  1770. if(number == 1):
  1771. div = div + '<br><a href="/history/' + URL_인코딩(name) + '/n/' + str(number + 1) + '">(다음)'
  1772. else:
  1773. div = div + '<br><a href="/history/' + URL_인코딩(name) + '/n/' + str(number - 1) + '">(이전) <a href="/history/' + URL_인코딩(name) + '/n/' + str(number + 1) + '">(다음)'
  1774. break
  1775. else:
  1776. i = i + 1
  1777. return render_template('index.html', logo = data['name'], rows = div, tn = 5, title = name, page = URL_인코딩(name), select = select, sub = '역사')
  1778. else:
  1779. return render_template('index.html', logo = data['name'], rows = '', tn = 5, title = name, page = URL_인코딩(name), select = select, sub = '역사')
  1780. @app.route('/search', methods=['POST'])
  1781. def search():
  1782. DB_실행("select * from data where title = '" + DB_인코딩(request.form["search"]) + "'")
  1783. rows = curs.fetchall()
  1784. if(rows):
  1785. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(request.form["search"]) + '" />'
  1786. else:
  1787. DB_실행("select * from data where title like '%" + DB_인코딩(request.form["search"]) + "%'")
  1788. rows = curs.fetchall()
  1789. if(rows):
  1790. i = 0
  1791. div = '<li>문서가 없습니다. <a href="/w/' + URL_인코딩(request.form["search"]) + '">바로가기</a></li><br>'
  1792. while(True):
  1793. try:
  1794. div = div + '<li><a href="/w/' + URL_인코딩(rows[i]['title']) + '">' + rows[i]['title'] + '</a></li>'
  1795. except:
  1796. break
  1797. i = i + 1
  1798. else:
  1799. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(request.form["search"]) + '" />'
  1800. return render_template('index.html', logo = data['name'], data = div, title = '검색')
  1801. @app.route('/w/<path:name>')
  1802. @app.route('/w/<path:name>/from/<path:redirect>')
  1803. def w(name = None, redirect = None):
  1804. i = 0
  1805. DB_실행("select * from rd where title = '" + DB_인코딩(name) + "' order by date asc")
  1806. rows = curs.fetchall()
  1807. while(True):
  1808. try:
  1809. a = rows[i]
  1810. except:
  1811. topic = ""
  1812. break
  1813. DB_실행("select * from stop where title = '" + DB_인코딩(rows[i]['title']) + "' and sub = '" + DB_인코딩(rows[i]['sub']) + "' and close = 'O'")
  1814. row = curs.fetchall()
  1815. if(not row):
  1816. topic = "open"
  1817. break
  1818. else:
  1819. i = i + 1
  1820. acl = ''
  1821. m = re.search("^(.*)\/(.*)$", name)
  1822. if(m):
  1823. g = m.groups()
  1824. uppage = g[0]
  1825. style = ""
  1826. else:
  1827. uppage = ""
  1828. style = "display:none;"
  1829. if(re.search("^분류:", name)):
  1830. DB_실행("select * from cat where title = '" + DB_인코딩(name) + "' order by cat asc")
  1831. rows = curs.fetchall()
  1832. if(rows):
  1833. div = ''
  1834. i = 0
  1835. while(True):
  1836. try:
  1837. a = rows[i]
  1838. except:
  1839. break
  1840. DB_실행("select * from data where title = '" + DB_인코딩(rows[i]['cat']) + "'")
  1841. row = curs.fetchall()
  1842. if(row):
  1843. aa = row[0]['data']
  1844. aa = namumark('', aa)
  1845. bb = re.search('<div style="width:100%;border: 1px solid #777;padding: 5px;margin-top: 1em;">분류:((?:(?!<\/div>).)*)<\/div>', aa)
  1846. if(bb):
  1847. cc = bb.groups()
  1848. mm = re.search("^분류:(.*)", name)
  1849. if(mm):
  1850. ee = mm.groups()
  1851. if(re.search("<a (class=\"not_thing\")? href=\"\/w\/" + URL_인코딩(name) + "\">" + ee[0] + "<\/a>", cc[0])):
  1852. div = div + '<li><a href="/w/' + URL_인코딩(rows[i]['cat']) + '">' + rows[i]['cat'] + '</a></li>'
  1853. i = i + 1
  1854. else:
  1855. DB_실행("delete from cat where title = '" + DB_인코딩(name) + "' and cat = '" + DB_인코딩(rows[i]['cat']) + "'")
  1856. DB_갱신()
  1857. i = i + 1
  1858. else:
  1859. DB_실행("delete from cat where title = '" + DB_인코딩(name) + "' and cat = '" + DB_인코딩(rows[i]['cat']) + "'")
  1860. DB_갱신()
  1861. i = i + 1
  1862. else:
  1863. DB_실행("delete from cat where title = '" + DB_인코딩(name) + "' and cat = '" + DB_인코딩(rows[i]['cat']) + "'")
  1864. DB_갱신()
  1865. i = i + 1
  1866. else:
  1867. DB_실행("delete from cat where title = '" + DB_인코딩(name) + "' and cat = '" + DB_인코딩(rows[i]['cat']) + "'")
  1868. DB_갱신()
  1869. i = i + 1
  1870. div = '<h2>분류</h2>' + div
  1871. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  1872. bb = curs.fetchall()
  1873. if(bb):
  1874. if(bb[0]['acl'] == 'admin'):
  1875. acl = '(관리자)'
  1876. elif(bb[0]['acl'] == 'user'):
  1877. acl = '(유저)'
  1878. else:
  1879. if(not acl):
  1880. acl = ''
  1881. enddata = namumark(name, bb[0]['data'])
  1882. m = re.search('<div id="toc">((?:(?!\/div>).)*)<\/div>', enddata)
  1883. if(m):
  1884. result = m.groups()
  1885. left = result[0]
  1886. else:
  1887. left = ''
  1888. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = enddata + '<br>' + div, license = data['license'], tn = 1, uppage = uppage, style = style, acl = acl, topic = topic, redirect = redirect, login = nowlogin())
  1889. else:
  1890. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = div, license = data['license'], tn = 1, uppage = uppage, style = style, acl = acl, topic = topic, redirect = redirect, login = nowlogin())
  1891. else:
  1892. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = '분류 문서 없음', license = data['license'], tn = 1, uppage = uppage, style = style, acl = acl, topic = topic, redirect = redirect, login = nowlogin()), 404
  1893. else:
  1894. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  1895. rows = curs.fetchall()
  1896. if(rows):
  1897. if(rows[0]['acl'] == 'admin'):
  1898. acl = '(관리자)'
  1899. elif(rows[0]['acl'] == 'user'):
  1900. acl = '(유저)'
  1901. else:
  1902. if(not acl):
  1903. acl = ''
  1904. m = re.search("^사용자:(.*)", name)
  1905. if(m):
  1906. g = m.groups()
  1907. DB_실행("select * from user where id = '" + DB_인코딩(g[0]) + "'")
  1908. test = curs.fetchall()
  1909. if(test):
  1910. if(test[0]['acl'] == 'owner'):
  1911. acl = '(소유자)'
  1912. elif(test[0]['acl'] == 'admin'):
  1913. acl = '(관리자)'
  1914. DB_실행("select * from ban where block = '" + DB_인코딩(g[0]) + "'")
  1915. user = curs.fetchall()
  1916. if(user):
  1917. elsedata = '{{{#!wiki style="border:2px solid red;padding:10px;"\r\n{{{+2 {{{#red 이 사용자는 차단 당했습니다.}}}}}}\r\n\r\n차단 해제 일 : ' + user[0]['end'] + '[br]사유 : ' + user[0]['why'] + '}}}[br]' + rows[0]['data']
  1918. else:
  1919. elsedata = rows[0]['data']
  1920. else:
  1921. elsedata = rows[0]['data']
  1922. enddata = namumark(name, elsedata)
  1923. m = re.search('<div id="toc">((?:(?!\/div>).)*)<\/div>', enddata)
  1924. if(m):
  1925. result = m.groups()
  1926. left = result[0]
  1927. else:
  1928. left = ''
  1929. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = enddata, license = data['license'], tn = 1, acl = acl, left = left, uppage = uppage, style = style, topic = topic, redirect = redirect, login = nowlogin())
  1930. else:
  1931. m = re.search("^사용자:(.*)", name)
  1932. if(m):
  1933. g = m.groups()
  1934. DB_실행("select * from ban where block = '" + DB_인코딩(g[0]) + "'")
  1935. user = curs.fetchall()
  1936. if(user):
  1937. elsedata = '{{{#!wiki style="border:2px solid red;padding:10px;"\r\n{{{+2 {{{#red 이 사용자는 차단 당했습니다.}}}}}}\r\n\r\n차단 해제 일 : ' + user[0]['end'] + '[br]사유 : ' + user[0]['why'] + '}}}[br]' + '문서 없음'
  1938. else:
  1939. elsedata = '문서 없음'
  1940. else:
  1941. elsedata = '문서 없음'
  1942. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = namumark(name, elsedata), license = data['license'], tn = 1, uppage = uppage, style = style, acl = acl, topic = topic, redirect = redirect, login = nowlogin()), 404
  1943. @app.route('/w/<path:name>/r/<int:number>')
  1944. def rew(name = None, number = None):
  1945. DB_실행("select * from hidhi where title = '" + DB_인코딩(name) + "' and re = '" + DB_인코딩(str(number)) + "'")
  1946. row = curs.fetchall()
  1947. if(row):
  1948. if(소유자_확인() == 1):
  1949. DB_실행("select * from history where title = '" + DB_인코딩(name) + "' and id = '" + str(number) + "'")
  1950. rows = curs.fetchall()
  1951. if(rows):
  1952. enddata = namumark(name, rows[0]['data'])
  1953. m = re.search('<div id="toc">((?:(?!\/div>).)*)<\/div>', enddata)
  1954. if(m):
  1955. result = m.groups()
  1956. left = result[0]
  1957. else:
  1958. left = ''
  1959. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = enddata, license = data['license'], tn = 6, left = left, sub = '옛 문서')
  1960. else:
  1961. return '<meta http-equiv="refresh" content="0;url=/history/' + URL_인코딩(name) + '" />'
  1962. else:
  1963. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  1964. else:
  1965. DB_실행("select * from history where title = '" + DB_인코딩(name) + "' and id = '" + str(number) + "'")
  1966. rows = curs.fetchall()
  1967. if(rows):
  1968. enddata = namumark(name, rows[0]['data'])
  1969. m = re.search('<div id="toc">((?:(?!\/div>).)*)<\/div>', enddata)
  1970. if(m):
  1971. result = m.groups()
  1972. left = result[0]
  1973. else:
  1974. left = ''
  1975. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = enddata, license = data['license'], tn = 6, left = left, sub = '옛 문서')
  1976. else:
  1977. return '<meta http-equiv="refresh" content="0;url=/history/' + URL_인코딩(name) + '" />'
  1978. @app.route('/w/<path:name>/raw/<int:number>')
  1979. def reraw(name = None, number = None):
  1980. DB_실행("select * from hidhi where title = '" + DB_인코딩(name) + "' and re = '" + DB_인코딩(str(number)) + "'")
  1981. row = curs.fetchall()
  1982. if(row):
  1983. if(소유자_확인() == 1):
  1984. DB_실행("select * from history where title = '" + DB_인코딩(name) + "' and id = '" + str(number) + "'")
  1985. rows = curs.fetchall()
  1986. if(rows):
  1987. enddata = re.sub('<', '&lt;', rows[0]['data'])
  1988. enddata = re.sub('>', '&gt;', enddata)
  1989. enddata = re.sub('"', '&quot;', enddata)
  1990. enddata = '<pre>' + enddata + '</pre>'
  1991. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = enddata, license = data['license'])
  1992. else:
  1993. return '<meta http-equiv="refresh" content="0;url=/history/' + URL_인코딩(name) + '" />'
  1994. else:
  1995. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  1996. else:
  1997. DB_실행("select * from history where title = '" + DB_인코딩(name) + "' and id = '" + str(number) + "'")
  1998. rows = curs.fetchall()
  1999. if(rows):
  2000. enddata = re.sub('<', '&lt;', rows[0]['data'])
  2001. enddata = re.sub('>', '&gt;', enddata)
  2002. enddata = re.sub('"', '&quot;', enddata)
  2003. enddata = '<pre>' + enddata + '</pre>'
  2004. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = enddata, license = data['license'])
  2005. else:
  2006. return '<meta http-equiv="refresh" content="0;url=/history/' + URL_인코딩(name) + '" />'
  2007. @app.route('/raw/<path:name>')
  2008. def raw(name = None):
  2009. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2010. rows = curs.fetchall()
  2011. if(rows):
  2012. enddata = re.sub('<', '&lt;', rows[0]['data'])
  2013. enddata = re.sub('>', '&gt;', enddata)
  2014. enddata = re.sub('"', '&quot;', enddata)
  2015. enddata = '<pre>' + enddata + '</pre>'
  2016. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = enddata, license = data['license'], tn = 7, sub = 'Raw')
  2017. else:
  2018. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2019. @app.route('/revert/<path:name>/r/<int:number>', methods=['POST', 'GET'])
  2020. def revert(name = None, number = None):
  2021. if(request.method == 'POST'):
  2022. DB_실행("select * from hidhi where title = '" + DB_인코딩(name) + "' and re = '" + DB_인코딩(str(number)) + "'")
  2023. row = curs.fetchall()
  2024. if(row):
  2025. if(소유자_확인() == 1):
  2026. DB_실행("select * from history where title = '" + DB_인코딩(name) + "' and id = '" + str(number) + "'")
  2027. rows = curs.fetchall()
  2028. if(rows):
  2029. ip = getip(request)
  2030. can = getcan(ip, name)
  2031. if(can == 1):
  2032. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2033. else:
  2034. today = 시간()
  2035. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2036. row = curs.fetchall()
  2037. if(row):
  2038. leng = getleng(len(row[0]['data']), len(rows[0]['data']))
  2039. DB_실행("update data set data = '" + DB_인코딩(rows[0]['data']) + "' where title = '" + DB_인코딩(name) + "'")
  2040. DB_갱신()
  2041. else:
  2042. leng = '+' + str(len(rows[0]['data']))
  2043. DB_실행("insert into data (title, data, acl) value ('" + DB_인코딩(name) + "', '" + DB_인코딩(rows[0]['data']) + "', '')")
  2044. DB_갱신()
  2045. history(name, rows[0]['data'], today, ip, '문서를 ' + str(number) + '판으로 되돌렸습니다.', leng)
  2046. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2047. else:
  2048. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2049. else:
  2050. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2051. else:
  2052. DB_실행("select * from history where title = '" + DB_인코딩(name) + "' and id = '" + str(number) + "'")
  2053. rows = curs.fetchall()
  2054. if(rows):
  2055. ip = getip(request)
  2056. can = getcan(ip, name)
  2057. if(can == 1):
  2058. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2059. else:
  2060. today = 시간()
  2061. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2062. row = curs.fetchall()
  2063. if(row):
  2064. leng = getleng(len(row[0]['data']), len(rows[0]['data']))
  2065. DB_실행("update data set data = '" + DB_인코딩(rows[0]['data']) + "' where title = '" + DB_인코딩(name) + "'")
  2066. DB_갱신()
  2067. else:
  2068. leng = '+' + str(len(rows[0]['data']))
  2069. DB_실행("insert into data (title, data, acl) value ('" + DB_인코딩(name) + "', '" + DB_인코딩(rows[0]['data']) + "', '')")
  2070. DB_갱신()
  2071. history(name, rows[0]['data'], today, ip, '문서를 ' + str(number) + '판으로 되돌렸습니다.', leng)
  2072. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2073. else:
  2074. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2075. else:
  2076. DB_실행("select * from hidhi where title = '" + DB_인코딩(name) + "' and re = '" + DB_인코딩(str(number)) + "'")
  2077. row = curs.fetchall()
  2078. if(row):
  2079. if(소유자_확인() == 1):
  2080. ip = getip(request)
  2081. can = getcan(ip, name)
  2082. if(can == 1):
  2083. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2084. else:
  2085. DB_실행("select * from history where title = '" + DB_인코딩(name) + "' and id = '" + str(number) + "'")
  2086. rows = curs.fetchall()
  2087. if(rows):
  2088. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), r = URL_인코딩(str(number)), tn = 13, plus = '정말 되돌리시겠습니까?', sub = '되돌리기', login = nowlogin())
  2089. else:
  2090. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2091. else:
  2092. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2093. else:
  2094. ip = getip(request)
  2095. can = getcan(ip, name)
  2096. if(can == 1):
  2097. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2098. else:
  2099. DB_실행("select * from history where title = '" + DB_인코딩(name) + "' and id = '" + str(number) + "'")
  2100. rows = curs.fetchall()
  2101. if(rows):
  2102. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), r = URL_인코딩(str(number)), tn = 13, plus = '정말 되돌리시겠습니까?', sub = '되돌리기', login = nowlogin())
  2103. else:
  2104. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2105. @app.route('/edit/<path:name>', methods=['POST', 'GET'])
  2106. def edit(name = None):
  2107. if(request.method == 'POST'):
  2108. m = re.search('(?:[^A-Za-zㄱ-힣0-9 ])', request.form["send"])
  2109. if(m):
  2110. return '<meta http-equiv="refresh" content="0;url=/error/17" />'
  2111. else:
  2112. today = 시간()
  2113. content = savemark(request.form["content"])
  2114. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2115. rows = curs.fetchall()
  2116. if(rows):
  2117. if(rows[0]['data'] == content):
  2118. return '<meta http-equiv="refresh" content="0;url=/error/18" />'
  2119. else:
  2120. ip = getip(request)
  2121. can = getcan(ip, name)
  2122. if(can == 1):
  2123. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2124. else:
  2125. leng = getleng(len(rows[0]['data']), len(content))
  2126. history(name, content, today, ip, request.form["send"], leng)
  2127. DB_실행("update data set data = '" + DB_인코딩(content) + "' where title = '" + DB_인코딩(name) + "'")
  2128. DB_갱신()
  2129. else:
  2130. ip = getip(request)
  2131. can = getcan(ip, name)
  2132. if(can == 1):
  2133. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2134. else:
  2135. leng = '+' + str(len(content))
  2136. history(name, content, today, ip, request.form["send"], leng)
  2137. DB_실행("insert into data (title, data, acl) value ('" + DB_인코딩(name) + "', '" + DB_인코딩(content) + "', '')")
  2138. DB_갱신()
  2139. isin(name, content)
  2140. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2141. else:
  2142. ip = getip(request)
  2143. can = getcan(ip, name)
  2144. if(can == 1):
  2145. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2146. else:
  2147. DB_실행("select * from data where title = '" + DB_인코딩(data["help"]) + "'")
  2148. rows = curs.fetchall()
  2149. if(rows):
  2150. newdata = re.sub('^#(?:redirect|넘겨주기)\s(?P<in>[^\n]*)', ' * \g<in> 문서로 넘겨주기', rows[0]["data"])
  2151. left = namumark(name, newdata)
  2152. else:
  2153. left = ''
  2154. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2155. rows = curs.fetchall()
  2156. if(rows):
  2157. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = rows[0]['data'], tn = 2, left = left, sub = '편집', login = nowlogin())
  2158. else:
  2159. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = '', tn = 2, left = left, sub = '편집', login = nowlogin())
  2160. @app.route('/edit/<path:name>/section/<int:number>', methods=['POST', 'GET'])
  2161. def secedit(name = None, number = None):
  2162. if(request.method == 'POST'):
  2163. m = re.search('(?:[^A-Za-zㄱ-힣0-9 ])', request.form["send"])
  2164. if(m):
  2165. return '<meta http-equiv="refresh" content="0;url=/error/17" />'
  2166. else:
  2167. today = 시간()
  2168. content = savemark(request.form["content"])
  2169. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2170. rows = curs.fetchall()
  2171. if(rows):
  2172. if(request.form["otent"] == content):
  2173. return '<meta http-equiv="refresh" content="0;url=/error/18" />'
  2174. else:
  2175. ip = getip(request)
  2176. can = getcan(ip, name)
  2177. if(can == 1):
  2178. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2179. else:
  2180. leng = getleng(len(request.form['otent']), len(content))
  2181. content = rows[0]['data'].replace(request.form['otent'], content)
  2182. history(name, content, today, ip, request.form["send"], leng)
  2183. DB_실행("update data set data = '" + DB_인코딩(content) + "' where title = '" + DB_인코딩(name) + "'")
  2184. DB_갱신()
  2185. isin(name, content)
  2186. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2187. else:
  2188. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2189. else:
  2190. ip = getip(request)
  2191. can = getcan(ip, name)
  2192. if(can == 1):
  2193. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2194. else:
  2195. DB_실행("select * from data where title = '" + DB_인코딩(data["help"]) + "'")
  2196. rows = curs.fetchall()
  2197. if(rows):
  2198. newdata = re.sub('^#(?:redirect|넘겨주기)\s(?P<in>[^\n]*)', ' * \g<in> 문서로 넘겨주기', rows[0]["data"])
  2199. left = namumark(name, newdata)
  2200. else:
  2201. left = ''
  2202. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2203. rows = curs.fetchall()
  2204. if(rows):
  2205. i = 0
  2206. j = 0
  2207. gdata = rows[0]['data'] + '\r\n'
  2208. while(True):
  2209. m = re.search("((?:={1,6})\s?(?:[^=]*)\s?(?:={1,6})(?:\s+)?\n(?:(?:(?:(?!(?:={1,6})\s?(?:[^=]*)\s?(?:={1,6})(?:\s+)?\n).)*)(?:\n)?)+)", gdata)
  2210. if(m):
  2211. if(i == number - 1):
  2212. g = m.groups()
  2213. gdata = re.sub("\r\n$", "", g[0])
  2214. break
  2215. else:
  2216. gdata = re.sub("((?:={1,6})\s?(?:[^=]*)\s?(?:={1,6})(?:\s+)?\n(?:(?:(?:(?!(?:={1,6})\s?(?:[^=]*)\s?(?:={1,6})(?:\s+)?\n).)*)(?:\n)?)+)", "", gdata, 1)
  2217. i = i + 1
  2218. else:
  2219. j = 1
  2220. break
  2221. if(j == 0):
  2222. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = gdata, tn = 2, left = left, section = 1, number = number, sub = '편집', login = nowlogin())
  2223. else:
  2224. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2225. else:
  2226. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2227. @app.route('/preview/<path:name>', methods=['POST'])
  2228. def preview(name = None):
  2229. ip = getip(request)
  2230. can = getcan(ip, name)
  2231. if(can == 1):
  2232. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2233. else:
  2234. newdata = request.form["content"]
  2235. newdata = re.sub('^#(?:redirect|넘겨주기)\s(?P<in>[^\n]*)', ' * \g<in> 문서로 넘겨주기', newdata)
  2236. enddata = namumark(name, newdata)
  2237. DB_실행("select * from data where title = '" + DB_인코딩(data["help"]) + "'")
  2238. rows = curs.fetchall()
  2239. if(rows):
  2240. newdata = re.sub('^#(?:redirect|넘겨주기)\s(?P<in>[^\n]*)', ' * \g<in> 문서로 넘겨주기', rows[0]["data"])
  2241. left = namumark(name, newdata)
  2242. else:
  2243. left = ''
  2244. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = request.form["content"], tn = 2, preview = 1, enddata = enddata, left = left, sub = '미리보기', login = nowlogin())
  2245. @app.route('/preview/<path:name>/section/<int:number>', methods=['POST'])
  2246. def secpreview(name = None, number = None):
  2247. ip = getip(request)
  2248. can = getcan(ip, name)
  2249. if(can == 1):
  2250. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2251. else:
  2252. if(re.search('\.', ip)):
  2253. notice = '비 로그인 상태 입니다. 비 로그인으로 편집시 아이피가 역사에 기록 됩니다. 편집 시 동의 함으로 간주 됩니다.'
  2254. else:
  2255. notice = ''
  2256. newdata = request.form["content"]
  2257. newdata = re.sub('^#(?:redirect|넘겨주기)\s(?P<in>[^\n]*)', ' * \g<in> 문서로 넘겨주기', newdata)
  2258. enddata = namumark(name, newdata)
  2259. DB_실행("select * from data where title = '" + DB_인코딩(data["help"]) + "'")
  2260. rows = curs.fetchall()
  2261. if(rows):
  2262. newdata = re.sub('^#(?:redirect|넘겨주기)\s(?P<in>[^\n]*)', ' * \g<in> 문서로 넘겨주기', rows[0]["data"])
  2263. left = namumark(name, newdata)
  2264. else:
  2265. left = ''
  2266. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), data = request.form["content"], tn = 2, preview = 1, enddata = enddata, left = left, notice = notice, section = 1, number = number, odata = request.form["otent"], sub = '미리보기')
  2267. @app.route('/delete/<path:name>', methods=['POST', 'GET'])
  2268. def delete(name = None):
  2269. if(request.method == 'POST'):
  2270. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2271. rows = curs.fetchall()
  2272. if(rows):
  2273. ip = getip(request)
  2274. can = getcan(ip, name)
  2275. if(can == 1):
  2276. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2277. else:
  2278. today = 시간()
  2279. leng = '-' + str(len(rows[0]['data']))
  2280. history(name, '', today, ip, '문서를 삭제 했습니다.', leng)
  2281. DB_실행("delete from data where title = '" + DB_인코딩(name) + "'")
  2282. DB_갱신()
  2283. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2284. else:
  2285. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2286. else:
  2287. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2288. rows = curs.fetchall()
  2289. if(rows):
  2290. ip = getip(request)
  2291. can = getcan(ip, name)
  2292. if(can == 1):
  2293. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2294. else:
  2295. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), tn = 8, plus = '정말 삭제 하시겠습니까?', sub = '삭제', login = nowlogin())
  2296. else:
  2297. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2298. @app.route('/move/<path:name>', methods=['POST', 'GET'])
  2299. def move(name = None):
  2300. if(request.method == 'POST'):
  2301. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2302. rows = curs.fetchall()
  2303. if(rows):
  2304. ip = getip(request)
  2305. can = getcan(ip, name)
  2306. if(can == 1):
  2307. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2308. else:
  2309. today = 시간()
  2310. leng = '0'
  2311. DB_실행("select * from history where title = '" + DB_인코딩(request.form["title"]) + "'")
  2312. row = curs.fetchall()
  2313. if(row):
  2314. return '<meta http-equiv="refresh" content="0;url=/error/19" />'
  2315. else:
  2316. history(name, rows[0]['data'], today, ip, '<a href="/w/' + URL_인코딩(name) + '">' + name + '</a> 문서를 <a href="/w/' + URL_인코딩(request.form["title"]) + '">' + request.form["title"] + '</a> 문서로 이동 했습니다.', leng)
  2317. DB_실행("update data set title = '" + DB_인코딩(request.form["title"]) + "' where title = '" + DB_인코딩(name) + "'")
  2318. DB_실행("update history set title = '" + DB_인코딩(request.form["title"]) + "' where title = '" + DB_인코딩(name) + "'")
  2319. DB_갱신()
  2320. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(request.form["title"]) + '" />'
  2321. else:
  2322. ip = getip(request)
  2323. can = getcan(ip, name)
  2324. if(can == 1):
  2325. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2326. else:
  2327. today = 시간()
  2328. leng = '0'
  2329. DB_실행("select * from history where title = '" + DB_인코딩(request.form["title"]) + "'")
  2330. row = curs.fetchall()
  2331. if(row):
  2332. return '<meta http-equiv="refresh" content="0;url=/error/19" />'
  2333. else:
  2334. history(name, '', today, ip, '<a href="/w/' + URL_인코딩(name) + '">' + name + '</a> 문서를 <a href="/w/' + URL_인코딩(request.form["title"]) + '">' + request.form["title"] + '</a> 문서로 이동 했습니다.', leng)
  2335. DB_실행("update history set title = '" + DB_인코딩(request.form["title"]) + "' where title = '" + DB_인코딩(name) + "'")
  2336. DB_갱신()
  2337. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(request.form["title"]) + '" />'
  2338. else:
  2339. ip = getip(request)
  2340. can = getcan(ip, name)
  2341. if(can == 1):
  2342. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2343. else:
  2344. return render_template('index.html', title = name, logo = data['name'], page = URL_인코딩(name), tn = 9, plus = '정말 이동 하시겠습니까?', sub = '이동', login = nowlogin())
  2345. @app.route('/other')
  2346. def other():
  2347. return render_template('index.html', title = '기타 메뉴', logo = data['name'], data = '<h2 style="margin-top: 0px;">기록</h2><li><a href="/blocklog/n/1">유저 차단 기록</a></li><li><a href="/userlog/n/1">유저 가입 기록</a></li><li><a href="/manager/6">유저 기록</a></li><h2>기타</h2><li><a href="/titleindex">모든 문서</a></li><li><a href="/upload">업로드</a></li><li><a href="/adminlist">관리자 목록</a></li><li><a href="/manager/1">관리자 메뉴</a></li><br>이 오픈나무의 버전은 <a href="https://github.com/2DU/openNAMU/blob/master/version.md">1.8.8</a> 입니다.')
  2348. @app.route('/manager/<int:num>', methods=['POST', 'GET'])
  2349. def manager(num = None):
  2350. if(num == 1):
  2351. return render_template('index.html', title = '관리자 메뉴', logo = data['name'], data = '<h2 style="margin-top: 0px;">관리자 및 소유자</h2><li><a href="/manager/2">문서 ACL</a></li><li><a href="/manager/3">유저 체크</a></li><li><a href="/manager/4">유저 차단</a></li><h2>소유자</h2><li><a href="/manager/5">관리자 권한 주기</a></li><h2>기타</h2><li>이 메뉴에 없는 기능은 해당 문서의 역사나 토론에서 바로 사용 가능함</li>')
  2352. elif(num == 2):
  2353. if(request.method == 'POST'):
  2354. return '<meta http-equiv="refresh" content="0;url=/acl/' + URL_인코딩(request.form["name"]) + '" />'
  2355. else:
  2356. return render_template('index.html', title = 'ACL 이동', logo = data['name'], data = '<form id="usrform" method="POST" action="/manager/2"><input name="name" type="text"><br><br><button class="btn btn-primary" type="submit">이동</button></form>')
  2357. elif(num == 3):
  2358. if(request.method == 'POST'):
  2359. return '<meta http-equiv="refresh" content="0;url=/check/' + URL_인코딩(request.form["name"]) + '" />'
  2360. else:
  2361. return render_template('index.html', title = '체크 이동', logo = data['name'], data = '<form id="usrform" method="POST" action="/manager/3"><input name="name" type="text"><br><br><button class="btn btn-primary" type="submit">이동</button></form>')
  2362. elif(num == 4):
  2363. if(request.method == 'POST'):
  2364. return '<meta http-equiv="refresh" content="0;url=/ban/' + URL_인코딩(request.form["name"]) + '" />'
  2365. else:
  2366. return render_template('index.html', title = '차단 이동', logo = data['name'], data = '<form id="usrform" method="POST" action="/manager/4"><input name="name" type="text"><br><br><button class="btn btn-primary" type="submit">이동</button><br><br><span>아이피 앞 두자리 (XXX.XXX) 입력하면 대역 차단</span></form>')
  2367. elif(num == 5):
  2368. if(request.method == 'POST'):
  2369. return '<meta http-equiv="refresh" content="0;url=/admin/' + URL_인코딩(request.form["name"]) + '" />'
  2370. else:
  2371. return render_template('index.html', title = '권한 이동', logo = data['name'], data = '<form id="usrform" method="POST" action="/manager/5"><input name="name" type="text"><br><br><button class="btn btn-primary" type="submit">이동</button></form>')
  2372. elif(num == 6):
  2373. if(request.method == 'POST'):
  2374. return '<meta http-equiv="refresh" content="0;url=/record/' + URL_인코딩(request.form["name"]) + '/n/1" />'
  2375. else:
  2376. return render_template('index.html', title = '기록 이동', logo = data['name'], data = '<form id="usrform" method="POST" action="/manager/6"><input name="name" type="text"><br><br><button class="btn btn-primary" type="submit">이동</button></form>')
  2377. else:
  2378. return '<meta http-equiv="refresh" content="0;url=/" />'
  2379. @app.route('/titleindex')
  2380. def 모든_문서():
  2381. 숫자 = 0
  2382. 데이터 = '<div>'
  2383. DB_실행("select title from data order by title asc")
  2384. 문서명 = curs.fetchall()
  2385. if(문서명):
  2386. while(True):
  2387. try:
  2388. 덤 = 문서명[숫자]
  2389. except:
  2390. break
  2391. 데이터 = 데이터 + '<li>' + str(숫자 + 1) + '. <a href="/w/' + URL_인코딩(문서명[숫자]['title']) + '">' + 문서명[숫자]['title'] + '</a></li>'
  2392. 숫자 += 1
  2393. 데이터 = 데이터 + '</div>'
  2394. return render_template('index.html', logo = data['name'], rows = 데이터 + '<br><span>이 위키에는 총 ' + str(숫자) + '개의 문서가 있습니다.</span>', tn = 4, title = '모든 문서')
  2395. else:
  2396. return render_template('index.html', logo = data['name'], rows = '', tn = 4, title = '모든 문서')
  2397. @app.route('/topic/<path:name>', methods=['POST', 'GET'])
  2398. def topic(name = None):
  2399. if(request.method == 'POST'):
  2400. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(request.form["topic"]) + '" />'
  2401. else:
  2402. div = '<div>'
  2403. i = 0
  2404. j = 1
  2405. DB_실행("select * from rd where title = '" + DB_인코딩(name) + "' order by date asc")
  2406. rows = curs.fetchall()
  2407. while(True):
  2408. try:
  2409. a = rows[i]
  2410. except:
  2411. div = div + '</div>'
  2412. break
  2413. DB_실행("select * from topic where title = '" + DB_인코딩(rows[i]['title']) + "' and sub = '" + DB_인코딩(rows[i]['sub']) + "' and id = '1' order by sub asc")
  2414. aa = curs.fetchall()
  2415. indata = namumark(name, aa[0]['data'])
  2416. if(aa[0]['block'] == 'O'):
  2417. indata = '블라인드 되었습니다.'
  2418. block = 'style="background: gainsboro;"'
  2419. else:
  2420. block = ''
  2421. ip = 아이디_파싱(aa[0]['ip'])
  2422. DB_실행("select * from stop where title = '" + DB_인코딩(rows[i]['title']) + "' and sub = '" + DB_인코딩(rows[i]['sub']) + "' and close = 'O'")
  2423. row = curs.fetchall()
  2424. if(not row):
  2425. div = div + '<h2><a href="/topic/' + URL_인코딩(rows[i]['title']) + '/sub/' + URL_인코딩(rows[i]['sub']) + '">' + str(j) + '. ' + rows[i]['sub'] + '</a></h2><table id="toron"><tbody><tr><td id="toroncolorgreen"><a href="javascript:void(0);" id="1">#1</a> ' + ip + ' <span style="float:right;">' + aa[0]['date'] + '</span></td></tr><tr><td ' + block + '>' + indata + '</td></tr></tbody></table><br>'
  2426. j = j + 1
  2427. i = i + 1
  2428. return render_template('index.html', title = name, page = URL_인코딩(name), logo = data['name'], plus = div, tn = 10, list = 1, sub = '토론 목록')
  2429. @app.route('/topic/<path:name>/close')
  2430. def 닫힌_토론_목록(name = None):
  2431. div = '<div>'
  2432. i = 0
  2433. DB_실행("select * from stop where title = '" + DB_인코딩(name) + "' and close = 'O' order by sub asc")
  2434. rows = curs.fetchall()
  2435. while(True):
  2436. try:
  2437. a = rows[i]
  2438. except:
  2439. div = div + '</div>'
  2440. break
  2441. DB_실행("select * from topic where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(rows[i]['sub']) + "' and id = '1'")
  2442. row = curs.fetchall()
  2443. if(row):
  2444. indata = namumark(name, row[0]['data'])
  2445. if(row[0]['block'] == 'O'):
  2446. indata = '블라인드 되었습니다.'
  2447. block = 'style="background: gainsboro;"'
  2448. else:
  2449. block = ''
  2450. 아이디 = 아이디_파싱(row[0]['ip'])
  2451. div = div + '<h2><a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(rows[i]['sub']) + '">' + str((i + 1)) + '. ' + rows[i]['sub'] + '</a></h2><table id="toron"><tbody><tr><td id="toroncolorgreen"><a href="javascript:void(0);" id="1">#1</a> ' + 아이디 + ' <span style="float:right;">' + row[0]['date'] + '</span></td></tr><tr><td ' + block + '>' + indata + '</td></tr></tbody></table><br>'
  2452. i += 1
  2453. return render_template('index.html', title = name, page = URL_인코딩(name), logo = data['name'], plus = div, tn = 10, sub = '닫힌 토론')
  2454. @app.route('/topic/<path:name>/agree')
  2455. def 합의된_토론_목록(name = None):
  2456. 보여줄_내용 = '<div>'
  2457. 숫자 = 0
  2458. DB_실행("select * from agreedis where title = '" + DB_인코딩(name) + "' order by sub asc")
  2459. 합의_토론 = curs.fetchall()
  2460. while(True):
  2461. try:
  2462. 덤 = 합의_토론[숫자]
  2463. except:
  2464. 보여줄_내용 = 보여줄_내용 + '</div>'
  2465. break
  2466. DB_실행("select * from topic where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(합의_토론[숫자]['sub']) + "' and id = '1'")
  2467. 내용 = curs.fetchall()
  2468. if(내용):
  2469. 내용_파싱 = namumark(name, 내용[0]['data'])
  2470. if(내용[0]['block'] == 'O'):
  2471. 내용_파싱 = '블라인드 되었습니다.'
  2472. 가리기 = 'style="background: gainsboro;"'
  2473. else:
  2474. 가리기 = ''
  2475. 아이디 = 아이디_파싱(내용[0]['ip'])
  2476. 보여줄_내용 = 보여줄_내용 + '<h2><a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(내용[숫자]['sub']) + '">' + str((숫자 + 1)) + '. ' + 내용[숫자]['sub'] + '</a></h2><table id="toron"><tbody><tr><td id="toroncolorgreen"><a href="javascript:void(0);" id="1">#1</a> ' + 아이디 + ' <span style="float:right;">' + 내용[0]['date'] + '</span></td></tr><tr><td ' + 가리기 + '>' + 내용_파싱 + '</td></tr></tbody></table><br>'
  2477. 숫자 += 1
  2478. return render_template('index.html', title = name, page = URL_인코딩(name), logo = data['name'], plus = 보여줄_내용, tn = 10, sub = '합의된 토론')
  2479. @app.route('/topic/<path:name>/sub/<path:sub>', methods=['POST', 'GET'])
  2480. def sub(name = None, sub = None):
  2481. if(request.method == 'POST'):
  2482. DB_실행("select * from topic where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' order by id+0 desc limit 1")
  2483. rows = curs.fetchall()
  2484. if(rows):
  2485. number = int(rows[0]['id']) + 1
  2486. else:
  2487. number = 1
  2488. ip = getip(request)
  2489. ban = getdiscuss(ip, name, sub)
  2490. admin = 관리자_확인()
  2491. if(ban == 1 and not admin == 1):
  2492. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2493. else:
  2494. DB_실행("select * from user where id = '" + DB_인코딩(ip) + "'")
  2495. rows = curs.fetchall()
  2496. if(rows):
  2497. if(rows[0]['acl'] == 'owner' or rows[0]['acl'] == 'admin'):
  2498. ip = ip + ' - Admin'
  2499. today = 시간()
  2500. discuss(name, sub, today)
  2501. aa = request.form["content"]
  2502. aa = re.sub("\[\[(분류:(?:(?:(?!\]\]).)*))\]\]", "[br]", aa)
  2503. aa = savemark(aa)
  2504. DB_실행("insert into topic (id, title, sub, data, date, ip, block) value ('" + str(number) + "', '" + DB_인코딩(name) + "', '" + DB_인코딩(sub) + "', '" + DB_인코딩(aa) + "', '" + today + "', '" + ip + "', '')")
  2505. DB_갱신()
  2506. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '" />'
  2507. else:
  2508. style = ''
  2509. ip = getip(request)
  2510. ban = getdiscuss(ip, name, sub)
  2511. admin = 관리자_확인()
  2512. DB_실행("select * from stop where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' and close = 'O'")
  2513. 닫음 = curs.fetchall()
  2514. DB_실행("select * from stop where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' and close = ''")
  2515. 정지 = curs.fetchall()
  2516. if(admin == 1):
  2517. div = '<div>'
  2518. if(닫음):
  2519. div = div + '<a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '/close">(토론 열기)</a> '
  2520. else:
  2521. div = div + '<a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '/close">(토론 닫기)</a> '
  2522. if(정지):
  2523. div = div + '<a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '/stop">(토론 재개)</a> '
  2524. else:
  2525. div = div + '<a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '/stop">(토론 정지)</a> '
  2526. DB_실행("select * from agreedis where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "'")
  2527. 합의 = curs.fetchall()
  2528. if(합의):
  2529. div = div + '<a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '/agree">(합의 취소)</a>'
  2530. else:
  2531. div = div + '<a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '/agree">(합의 완료)</a>'
  2532. div = div + '<br><br>'
  2533. else:
  2534. div = '<div>'
  2535. if(닫음 or 정지):
  2536. if(not admin == 1):
  2537. style = 'display:none;'
  2538. DB_실행("select * from topic where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' order by id+0 asc")
  2539. rows = curs.fetchall()
  2540. DB_실행("select * from distop where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' order by id+0 asc")
  2541. distop = curs.fetchall()
  2542. i = 0
  2543. if(distop):
  2544. while(True):
  2545. try:
  2546. a = distop[i]
  2547. except:
  2548. break
  2549. num = int(distop[i]['id']) - 1
  2550. if(i == 0):
  2551. start = rows[num]['ip']
  2552. indata = namumark('', rows[num]['data'])
  2553. indata = re.sub("(?P<in>#(?:[0-9]*))", '<a href="\g<in>">\g<in></a>', indata)
  2554. ip = 아이디_파싱(rows[num]['ip'])
  2555. div = div + '<table id="toron"><tbody><tr><td id="toroncolorred"><a href="#' + distop[i]['id'] + '" id="' + distop[i]['id'] + '-nt">#' + distop[i]['id'] + '</a> ' + ip + ' <span style="float:right;">' + rows[num]['date'] + '</span></td></tr><tr><td>' + indata + '</td></tr></tbody></table><br>'
  2556. i = i + 1
  2557. i = 0
  2558. while(True):
  2559. try:
  2560. a = rows[i]
  2561. except:
  2562. div = div + '</div>'
  2563. break
  2564. if(i == 0):
  2565. start = rows[i]['ip']
  2566. indata = namumark('', rows[i]['data'])
  2567. indata = re.sub("(?P<in>#(?:[0-9]*))", '<a href="\g<in>">\g<in></a>', indata)
  2568. if(rows[i]['block'] == 'O'):
  2569. indata = '블라인드 되었습니다.'
  2570. block = 'style="background: gainsboro;"'
  2571. else:
  2572. block = ''
  2573. m = re.search("^([^-]*)\s\-\s(Close|Reopen|Stop|Restart|Agreement|Settlement)$", rows[i]['ip'])
  2574. if(m):
  2575. ban = ""
  2576. else:
  2577. if(admin == 1):
  2578. if(rows[i]['block'] == 'O'):
  2579. isblock = ' <a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '/b/' + str(i + 1) + '">(해제)</a>'
  2580. else:
  2581. isblock = ' <a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '/b/' + str(i + 1) + '">(블라인드)</a>'
  2582. DB_실행("select * from distop where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' and id = '" + DB_인코딩(str(i + 1)) + "'")
  2583. row = curs.fetchall()
  2584. if(row):
  2585. isblock = isblock + ' <a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '/notice/' + str(i + 1) + '">(해제)</a>'
  2586. else:
  2587. isblock = isblock + ' <a href="/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '/notice/' + str(i + 1) + '">(공지)</a>'
  2588. n = re.search("\- (?:Admin)$", rows[i]['ip'])
  2589. if(n):
  2590. ban = isblock
  2591. else:
  2592. DB_실행("select * from ban where block = '" + DB_인코딩(rows[i]['ip']) + "'")
  2593. row = curs.fetchall()
  2594. if(row):
  2595. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['ip']) + '">(해제)</a>' + isblock
  2596. else:
  2597. ban = ' <a href="/ban/' + URL_인코딩(rows[i]['ip']) + '">(차단)</a>' + isblock
  2598. else:
  2599. ban = ""
  2600. ip = 아이디_파싱(rows[i]['ip'])
  2601. if(rows[i]['ip'] == start):
  2602. j = i + 1
  2603. div = div + '<table id="toron"><tbody><tr><td id="toroncolorgreen"><a href="javascript:void(0);" id="' + str(j) + '">#' + str(j) + '</a> ' + ip + ban + ' <span style="float:right;">' + rows[i]['date'] + '</span></td></tr><tr><td ' + block + '>' + indata + '</td></tr></tbody></table><br>'
  2604. else:
  2605. j = i + 1
  2606. div = div + '<table id="toron"><tbody><tr><td id="toroncolor"><a href="javascript:void(0);" id="' + str(j) + '">#' + str(j) + '</a> ' + ip + ban + ' <span style="float:right;">' + rows[i]['date'] + '</span></td></tr><tr><td ' + block + '>' + indata + '</td></tr></tbody></table><br>'
  2607. i = i + 1
  2608. return render_template('index.html', title = name, page = URL_인코딩(name), suburl = URL_인코딩(sub), toron = sub, logo = data['name'], rows = div, tn = 11, ban = ban, style = style, sub = '토론', login = nowlogin())
  2609. @app.route('/topic/<path:name>/sub/<path:sub>/b/<int:number>')
  2610. def blind(name = None, sub = None, number = None):
  2611. if(관리자_확인() == 1):
  2612. DB_실행("select * from topic where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' and id = '" + str(number) + "'")
  2613. row = curs.fetchall()
  2614. if(row):
  2615. if(row[0]['block'] == 'O'):
  2616. DB_실행("update topic set block = '' where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' and id = '" + str(number) + "'")
  2617. else:
  2618. DB_실행("update topic set block = 'O' where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' and id = '" + str(number) + "'")
  2619. DB_갱신()
  2620. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '" />'
  2621. else:
  2622. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '" />'
  2623. else:
  2624. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2625. @app.route('/topic/<path:name>/sub/<path:sub>/notice/<int:number>')
  2626. def notice(name = None, sub = None, number = None):
  2627. if(관리자_확인() == 1):
  2628. DB_실행("select * from topic where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' and id = '" + str(number) + "'")
  2629. data = curs.fetchall()
  2630. if(data):
  2631. DB_실행("select * from distop where id = '" + str(number) + "' and title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "'")
  2632. isthis = curs.fetchall()
  2633. if(isthis):
  2634. DB_실행("delete from distop where id = '" + str(number) + "' and title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "'")
  2635. else:
  2636. DB_실행("insert into distop (id, title, sub) value ('" + DB_인코딩(str(number)) + "', '" + DB_인코딩(name) + "', '" + DB_인코딩(sub) + "')")
  2637. DB_갱신()
  2638. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '" />'
  2639. else:
  2640. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '" />'
  2641. else:
  2642. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2643. @app.route('/topic/<path:name>/sub/<path:sub>/stop')
  2644. def topicstop(name = None, sub = None):
  2645. if(관리자_확인() == 1):
  2646. ip = getip(request)
  2647. DB_실행("select * from topic where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' order by id+0 desc limit 1")
  2648. row = curs.fetchall()
  2649. if(row):
  2650. today = 시간()
  2651. DB_실행("select * from stop where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' and close = ''")
  2652. rows = curs.fetchall()
  2653. if(rows):
  2654. DB_실행("insert into topic (id, title, sub, data, date, ip, block) value ('" + DB_인코딩(str(int(row[0]['id']) + 1)) + "', '" + DB_인코딩(name) + "', '" + DB_인코딩(sub) + "', 'Restart', '" + DB_인코딩(today) + "', '" + DB_인코딩(ip) + " - Restart', '')")
  2655. DB_실행("delete from stop where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' and close = ''")
  2656. else:
  2657. DB_실행("insert into topic (id, title, sub, data, date, ip, block) value ('" + DB_인코딩(str(int(row[0]['id']) + 1)) + "', '" + DB_인코딩(name) + "', '" + DB_인코딩(sub) + "', 'Stop', '" + DB_인코딩(today) + "', '" + DB_인코딩(ip) + " - Stop', '')")
  2658. DB_실행("insert into stop (title, sub, close) value ('" + DB_인코딩(name) + "', '" + DB_인코딩(sub) + "', '')")
  2659. DB_갱신()
  2660. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '" />'
  2661. else:
  2662. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '" />'
  2663. else:
  2664. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2665. @app.route('/topic/<path:name>/sub/<path:sub>/close')
  2666. def topicclose(name = None, sub = None):
  2667. if(관리자_확인() == 1):
  2668. ip = getip(request)
  2669. DB_실행("select * from topic where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' order by id+0 desc limit 1")
  2670. row = curs.fetchall()
  2671. if(row):
  2672. today = 시간()
  2673. DB_실행("select * from stop where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' and close = 'O'")
  2674. rows = curs.fetchall()
  2675. if(rows):
  2676. DB_실행("insert into topic (id, title, sub, data, date, ip, block) value ('" + DB_인코딩(str(int(row[0]['id']) + 1)) + "', '" + DB_인코딩(name) + "', '" + DB_인코딩(sub) + "', 'Reopen', '" + DB_인코딩(today) + "', '" + DB_인코딩(ip) + " - Reopen', '')")
  2677. DB_실행("delete from stop where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' and close = 'O'")
  2678. else:
  2679. DB_실행("insert into topic (id, title, sub, data, date, ip, block) value ('" + DB_인코딩(str(int(row[0]['id']) + 1)) + "', '" + DB_인코딩(name) + "', '" + DB_인코딩(sub) + "', 'Close', '" + DB_인코딩(today) + "', '" + DB_인코딩(ip) + " - Close', '')")
  2680. DB_실행("insert into stop (title, sub, close) value ('" + DB_인코딩(name) + "', '" + DB_인코딩(sub) + "', 'O')")
  2681. DB_갱신()
  2682. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '" />'
  2683. else:
  2684. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '" />'
  2685. else:
  2686. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2687. @app.route('/topic/<path:name>/sub/<path:sub>/agree')
  2688. def 토론_관리자_기능(name = None, sub = None):
  2689. if(관리자_확인() == 1):
  2690. ip = getip(request)
  2691. DB_실행("select id from topic where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "' order by id+0 desc limit 1")
  2692. 토론 = curs.fetchall()
  2693. if(토론):
  2694. today = 시간()
  2695. DB_실행("select * from agreedis where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "'")
  2696. 합의안 = curs.fetchall()
  2697. if(합의안):
  2698. DB_실행("insert into topic (id, title, sub, data, date, ip, block) value ('" + DB_인코딩(str(int(토론[0]['id']) + 1)) + "', '" + DB_인코딩(name) + "', '" + DB_인코딩(sub) + "', 'Settlement', '" + DB_인코딩(today) + "', '" + DB_인코딩(ip) + " - Settlement', '')")
  2699. DB_실행("delete from agreedis where title = '" + DB_인코딩(name) + "' and sub = '" + DB_인코딩(sub) + "'")
  2700. else:
  2701. DB_실행("insert into topic (id, title, sub, data, date, ip, block) value ('" + DB_인코딩(str(int(토론[0]['id']) + 1)) + "', '" + DB_인코딩(name) + "', '" + DB_인코딩(sub) + "', 'Agreement', '" + DB_인코딩(today) + "', '" + DB_인코딩(ip) + " - Agreement', '')")
  2702. DB_실행("insert into agreedis (title, sub) value ('" + DB_인코딩(name) + "', '" + DB_인코딩(sub) + "')")
  2703. DB_갱신()
  2704. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '" />'
  2705. else:
  2706. return '<meta http-equiv="refresh" content="0;url=/topic/' + URL_인코딩(name) + '/sub/' + URL_인코딩(sub) + '" />'
  2707. else:
  2708. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2709. @app.route('/login', methods=['POST', 'GET'])
  2710. def login():
  2711. if(request.method == 'POST'):
  2712. ip = getip(request)
  2713. ban = getban(ip)
  2714. if(ban == 1):
  2715. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2716. else:
  2717. DB_실행("select * from user where id = '" + DB_인코딩(request.form["id"]) + "'")
  2718. rows = curs.fetchall()
  2719. if(rows):
  2720. if(session.get('Now') == True):
  2721. return '<meta http-equiv="refresh" content="0;url=/error/11" />'
  2722. elif(bcrypt.checkpw(bytes(request.form["pw"], 'utf-8'), bytes(rows[0]['pw'], 'utf-8'))):
  2723. session['Now'] = True
  2724. session['DREAMER'] = request.form["id"]
  2725. DB_실행("insert into login (user, ip, today) value ('" + DB_인코딩(request.form["id"]) + "', '" + DB_인코딩(ip) + "', '" + DB_인코딩(시간()) + "')")
  2726. DB_갱신()
  2727. return '<meta http-equiv="refresh" content="0;url=/user" />'
  2728. else:
  2729. return '<meta http-equiv="refresh" content="0;url=/error/13" />'
  2730. else:
  2731. return '<meta http-equiv="refresh" content="0;url=/error/12" />'
  2732. else:
  2733. ip = getip(request)
  2734. ban = getban(ip)
  2735. if(ban == 1):
  2736. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2737. else:
  2738. if(session.get('Now') == True):
  2739. return '<meta http-equiv="refresh" content="0;url=/error/11" />'
  2740. else:
  2741. return render_template('index.html', title = '로그인', enter = '로그인', logo = data['name'], tn = 15)
  2742. @app.route('/change', methods=['POST', 'GET'])
  2743. def change():
  2744. if(request.method == 'POST'):
  2745. ip = getip(request)
  2746. ban = getban(ip)
  2747. if(request.form["pw2"] == request.form["pw3"]):
  2748. if(ban == 1):
  2749. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2750. else:
  2751. DB_실행("select * from user where id = '" + DB_인코딩(request.form["id"]) + "'")
  2752. rows = curs.fetchall()
  2753. if(rows):
  2754. if(session.get('Now') == True):
  2755. session['Now'] = False
  2756. session.pop('DREAMER', None)
  2757. return '<meta http-equiv="refresh" content="0;url=/change" />'
  2758. elif(bcrypt.checkpw(bytes(request.form["pw"], 'utf-8'), bytes(rows[0]['pw'], 'utf-8'))):
  2759. hashed = bcrypt.hashpw(bytes(request.form["pw2"], 'utf-8'), bcrypt.gensalt())
  2760. DB_실행("update user set pw = '" + DB_인코딩(hashed.decode()) + "' where id = '" + DB_인코딩(request.form["id"]) + "'")
  2761. DB_갱신()
  2762. return '<meta http-equiv="refresh" content="0;url=/login" />'
  2763. else:
  2764. return '<meta http-equiv="refresh" content="0;url=/error/10" />'
  2765. else:
  2766. return '<meta http-equiv="refresh" content="0;url=/error/9" />'
  2767. else:
  2768. return '<meta http-equiv="refresh" content="0;url=/error/20" />'
  2769. else:
  2770. ip = getip(request)
  2771. ban = getban(ip)
  2772. if(ban == 1):
  2773. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2774. else:
  2775. if(session.get('Now') == True):
  2776. session['Now'] = False
  2777. session.pop('DREAMER', None)
  2778. return '<meta http-equiv="refresh" content="0;url=/change" />'
  2779. else:
  2780. return render_template('index.html', title = '비밀번호 변경', enter = '변경', logo = data['name'], tn = 15)
  2781. @app.route('/check/<name>')
  2782. def check(name = None, sub = None, number = None):
  2783. DB_실행("select * from user where id = '" + DB_인코딩(name) + "'")
  2784. rows = curs.fetchall()
  2785. if(rows and rows[0]['acl'] == 'owner' or rows and rows[0]['acl'] == 'admin'):
  2786. return '<meta http-equiv="refresh" content="0;url=/error/4" />'
  2787. else:
  2788. if(관리자_확인() == 1):
  2789. m = re.search('(?:[0-9](?:[0-9][0-9])?\.[0-9](?:[0-9][0-9])?\.[0-9](?:[0-9][0-9])?\.[0-9](?:[0-9][0-9])?)', name)
  2790. if(m):
  2791. DB_실행("select * from login where ip = '" + DB_인코딩(name) + "' order by today desc")
  2792. row = curs.fetchall()
  2793. if(row):
  2794. i = 0
  2795. c = ''
  2796. while(True):
  2797. try:
  2798. c = c + '<table style="width: 100%;"><tbody><tr><td style="text-align: center;width:33.33%;">' + row[i]['user'] + '</td><td style="text-align: center;width:33.33%;">' + row[i]['ip'] + '</td><td style="text-align: center;width:33.33%;">' + row[i]['today'] + '</td></tr></tbody></table>'
  2799. except:
  2800. break
  2801. i = i + 1
  2802. return render_template('index.html', title = '다중 검사', logo = data['name'], tn = 22, rows = c)
  2803. else:
  2804. return render_template('index.html', title = '다중 검사', logo = data['name'], tn = 22, rows = '')
  2805. else:
  2806. DB_실행("select * from login where user = '" + DB_인코딩(name) + "' order by today desc")
  2807. row = curs.fetchall()
  2808. if(row):
  2809. i = 0
  2810. c = ''
  2811. while(True):
  2812. try:
  2813. c = c + '<table style="width: 100%;"><tbody><tr><td style="text-align: center;width:33.33%;">' + row[i]['user'] + '</td><td style="text-align: center;width:33.33%;">' + row[i]['ip'] + '</td><td style="text-align: center;width:33.33%;">' + row[i]['today'] + '</td></tr></tbody></table>'
  2814. except:
  2815. break
  2816. i = i + 1
  2817. return render_template('index.html', title = '다중 검사', logo = data['name'], tn = 22, rows = c)
  2818. else:
  2819. return render_template('index.html', title = '다중 검사', logo = data['name'], tn = 22, rows = '')
  2820. else:
  2821. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2822. @app.route('/register', methods=['POST', 'GET'])
  2823. def register():
  2824. if(request.method == 'POST'):
  2825. ip = getip(request)
  2826. ban = getban(ip)
  2827. if(request.form["pw"] == request.form["pw2"]):
  2828. if(ban == 1):
  2829. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2830. else:
  2831. m = re.search('(?:[^A-Za-zㄱ-힣0-9 ])', request.form["id"])
  2832. if(m):
  2833. return '<meta http-equiv="refresh" content="0;url=/error/8" />'
  2834. else:
  2835. if(len(request.form["id"]) > 20):
  2836. return '<meta http-equiv="refresh" content="0;url=/error/7" />'
  2837. else:
  2838. DB_실행("select * from user where id = '" + DB_인코딩(request.form["id"]) + "'")
  2839. rows = curs.fetchall()
  2840. if(rows):
  2841. return '<meta http-equiv="refresh" content="0;url=/error/6" />'
  2842. else:
  2843. hashed = bcrypt.hashpw(bytes(request.form["pw"], 'utf-8'), bcrypt.gensalt())
  2844. if(request.form["id"] == data['owner']):
  2845. DB_실행("insert into user (id, pw, acl) value ('" + DB_인코딩(request.form["id"]) + "', '" + DB_인코딩(hashed.decode()) + "', 'owner')")
  2846. else:
  2847. DB_실행("insert into user (id, pw, acl) value ('" + DB_인코딩(request.form["id"]) + "', '" + DB_인코딩(hashed.decode()) + "', 'user')")
  2848. DB_갱신()
  2849. return '<meta http-equiv="refresh" content="0;url=/login" />'
  2850. else:
  2851. return '<meta http-equiv="refresh" content="0;url=/error/20" />'
  2852. else:
  2853. ip = getip(request)
  2854. ban = getban(ip)
  2855. if(ban == 1):
  2856. return '<meta http-equiv="refresh" content="0;url=/ban" />'
  2857. else:
  2858. return render_template('index.html', title = '회원가입', enter = '회원가입', logo = data['name'], tn = 15)
  2859. @app.route('/logout')
  2860. def logout():
  2861. session['Now'] = False
  2862. session.pop('DREAMER', None)
  2863. return '<meta http-equiv="refresh" content="0;url=/user" />'
  2864. @app.route('/ban/<name>', methods=['POST', 'GET'])
  2865. def ban(name = None):
  2866. DB_실행("select * from user where id = '" + DB_인코딩(name) + "'")
  2867. rows = curs.fetchall()
  2868. if(rows and rows[0]['acl'] == 'owner' or rows and rows[0]['acl'] == 'admin'):
  2869. return '<meta http-equiv="refresh" content="0;url=/error/4" />'
  2870. else:
  2871. if(request.method == 'POST'):
  2872. if(관리자_확인() == 1):
  2873. ip = getip(request)
  2874. if(not re.search("[0-9]{4}-[0-9]{2}-[0-9]{2}", request.form["end"])):
  2875. end = ''
  2876. else:
  2877. end = request.form["end"]
  2878. DB_실행("select * from ban where block = '" + DB_인코딩(name) + "'")
  2879. row = curs.fetchall()
  2880. if(row):
  2881. block(name, '해제', 시간(), ip, '')
  2882. DB_실행("delete from ban where block = '" + DB_인코딩(name) + "'")
  2883. else:
  2884. b = re.search("^([0-9](?:[0-9]?[0-9]?)\.[0-9](?:[0-9]?[0-9]?))$", name)
  2885. if(b):
  2886. block(name, end, 시간(), ip, request.form["why"])
  2887. DB_실행("insert into ban (block, end, why, band) value ('" + DB_인코딩(name) + "', '" + DB_인코딩(end) + "', '" + DB_인코딩(request.form["why"]) + "', 'O')")
  2888. else:
  2889. block(name, end, 시간(), ip, request.form["why"])
  2890. DB_실행("insert into ban (block, end, why, band) value ('" + DB_인코딩(name) + "', '" + DB_인코딩(end) + "', '" + DB_인코딩(request.form["why"]) + "', '')")
  2891. DB_갱신()
  2892. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(data['frontpage']) + '" />'
  2893. else:
  2894. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2895. else:
  2896. if(관리자_확인() == 1):
  2897. DB_실행("select * from ban where block = '" + DB_인코딩(name) + "'")
  2898. row = curs.fetchall()
  2899. if(row):
  2900. now = '차단 해제'
  2901. else:
  2902. b = re.search("^([0-9](?:[0-9]?[0-9]?)\.[0-9](?:[0-9]?[0-9]?))$", name)
  2903. if(b):
  2904. now = '대역 차단'
  2905. else:
  2906. now = '차단'
  2907. return render_template('index.html', title = name, page = URL_인코딩(name), logo = data['name'], tn = 16, now = now, today = 시간(), sub = '차단')
  2908. else:
  2909. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2910. @app.route('/acl/<path:name>', methods=['POST', 'GET'])
  2911. def acl(name = None):
  2912. if(request.method == 'POST'):
  2913. if(관리자_확인() == 1):
  2914. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2915. row = curs.fetchall()
  2916. if(row):
  2917. if(request.form["select"] == 'admin'):
  2918. DB_실행("update data set acl = 'admin' where title = '" + DB_인코딩(name) + "'")
  2919. elif(request.form["select"] == 'user'):
  2920. DB_실행("update data set acl = 'user' where title = '" + DB_인코딩(name) + "'")
  2921. else:
  2922. DB_실행("update data set acl = '' where title = '" + DB_인코딩(name) + "'")
  2923. DB_갱신()
  2924. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2925. else:
  2926. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2927. else:
  2928. if(관리자_확인() == 1):
  2929. DB_실행("select * from data where title = '" + DB_인코딩(name) + "'")
  2930. row = curs.fetchall()
  2931. if(row):
  2932. if(row[0]['acl'] == 'admin'):
  2933. now = '관리자만'
  2934. elif(row[0]['acl'] == 'user'):
  2935. now = '유저 이상'
  2936. else:
  2937. now = '일반'
  2938. return render_template('index.html', title = name, page = URL_인코딩(name), logo = data['name'], tn = 19, now = '현재 ACL 상태는 ' + now, sub = 'ACL')
  2939. else:
  2940. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(name) + '" />'
  2941. else:
  2942. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2943. @app.route('/admin/<name>', methods=['POST', 'GET'])
  2944. def admin(name = None):
  2945. if(request.method == 'POST'):
  2946. if(소유자_확인() == 1):
  2947. DB_실행("select * from user where id = '" + DB_인코딩(name) + "'")
  2948. row = curs.fetchall()
  2949. if(row):
  2950. if(row[0]['acl'] == 'admin' or row[0]['acl'] == 'owner'):
  2951. DB_실행("update user set acl = 'user' where id = '" + DB_인코딩(name) + "'")
  2952. else:
  2953. DB_실행("update user set acl = '" + DB_인코딩(request.form["select"]) + "' where id = '" + DB_인코딩(name) + "'")
  2954. DB_갱신()
  2955. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(data['frontpage']) + '" />'
  2956. else:
  2957. return '<meta http-equiv="refresh" content="0;url=/error/5" />'
  2958. else:
  2959. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2960. else:
  2961. if(소유자_확인() == 1):
  2962. DB_실행("select * from user where id = '" + DB_인코딩(name) + "'")
  2963. row = curs.fetchall()
  2964. if(row):
  2965. if(row[0]['acl'] == 'admin' or row[0]['acl'] == 'owner'):
  2966. now = '권한 해제'
  2967. else:
  2968. now = '권한 부여'
  2969. return render_template('index.html', title = name, page = URL_인코딩(name), logo = data['name'], tn = 18, now = now, sub = '권한 부여')
  2970. else:
  2971. return '<meta http-equiv="refresh" content="0;url=/error/5" />'
  2972. else:
  2973. return '<meta http-equiv="refresh" content="0;url=/error/3" />'
  2974. @app.route('/ban')
  2975. def aban():
  2976. ip = getip(request)
  2977. if(getban(ip) == 1):
  2978. DB_실행("select * from ban where block = '" + DB_인코딩(ip) + "'")
  2979. rows = curs.fetchall()
  2980. if(rows):
  2981. if(rows[0]['end']):
  2982. end = rows[0]['end'] + ' 까지 차단 상태 입니다. / 사유 : ' + rows[0]['why']
  2983. now = 시간()
  2984. now = re.sub(':', '', now)
  2985. now = re.sub('\-', '', now)
  2986. now = re.sub(' ', '', now)
  2987. now = int(now)
  2988. day = rows[0]['end']
  2989. day = re.sub('\-', '', day)
  2990. if(now >= int(day + '000000')):
  2991. DB_실행("delete from ban where block = '" + DB_인코딩(ip) + "'")
  2992. DB_갱신()
  2993. end = '차단이 풀렸습니다. 다시 시도 해 보세요.'
  2994. else:
  2995. end = '영구 차단 상태 입니다. / 사유 : ' + rows[0]['why']
  2996. else:
  2997. b = re.search("^([0-9](?:[0-9]?[0-9]?)\.[0-9](?:[0-9]?[0-9]?))", ip)
  2998. if(b):
  2999. results = b.groups()
  3000. DB_실행("select * from ban where block = '" + DB_인코딩(results[0]) + "' and band = 'O'")
  3001. row = curs.fetchall()
  3002. if(row):
  3003. if(row[0]['end']):
  3004. end = row[0]['end'] + ' 까지 차단 상태 입니다. / 사유 : ' + rows[0]['why']
  3005. now = 시간()
  3006. now = re.sub(':', '', now)
  3007. now = re.sub('\-', '', now)
  3008. now = re.sub(' ', '', now)
  3009. now = int(now)
  3010. day = row[0]['end']
  3011. day = re.sub('\-', '', day)
  3012. if(now >= int(day + '000000')):
  3013. DB_실행("delete from ban where block = '" + DB_인코딩(results[0]) + "' and band = 'O'")
  3014. DB_갱신()
  3015. end = '차단이 풀렸습니다. 다시 시도 해 보세요.'
  3016. else:
  3017. end = '영구 차단 상태 입니다. / 사유 : ' + row[0]['why']
  3018. else:
  3019. end = '권한이 맞지 않는 상태 입니다.'
  3020. return render_template('index.html', title = '권한 오류', logo = data['name'], data = end), 401
  3021. @app.route('/w/<path:name>/r/<int:a>/diff/<int:b>')
  3022. def diff(name = None, a = None, b = None):
  3023. DB_실행("select * from history where id = '" + DB_인코딩(str(a)) + "' and title = '" + DB_인코딩(name) + "'")
  3024. rows = curs.fetchall()
  3025. if(rows):
  3026. DB_실행("select * from history where id = '" + DB_인코딩(str(b)) + "' and title = '" + DB_인코딩(name) + "'")
  3027. row = curs.fetchall()
  3028. if(row):
  3029. indata = re.sub('<', '&lt;', rows[0]['data'])
  3030. indata = re.sub('>', '&gt;', indata)
  3031. indata = re.sub('"', '&quot;', indata)
  3032. enddata = re.sub('<', '&lt;', row[0]['data'])
  3033. enddata = re.sub('>', '&gt;', enddata)
  3034. enddata = re.sub('"', '&quot;', enddata)
  3035. sm = difflib.SequenceMatcher(None, indata, enddata)
  3036. c = show_diff(sm)
  3037. c = '<pre>' + c + '</pre>'
  3038. return render_template('index.html', title = name, logo = data['name'], data = c, sub = '비교')
  3039. else:
  3040. return '<meta http-equiv="refresh" content="0;url=/history/' + URL_인코딩(name) + '" />'
  3041. else:
  3042. return '<meta http-equiv="refresh" content="0;url=/history/' + URL_인코딩(name) + '" />'
  3043. @app.route('/user')
  3044. def user():
  3045. ip = getip(request)
  3046. DB_실행("select * from user where id = '" + DB_인코딩(ip) + "'")
  3047. rows = curs.fetchall()
  3048. if(getban(ip) == 0):
  3049. if(rows):
  3050. if(rows[0]['acl'] == 'admin' or rows[0]['acl'] == 'owner'):
  3051. if(rows[0]['acl'] == 'admin'):
  3052. acl = '관리자'
  3053. else:
  3054. acl = '소유자'
  3055. else:
  3056. acl = '유저'
  3057. else:
  3058. acl = '일반'
  3059. else:
  3060. acl = '차단'
  3061. if(not re.search('\.', ip)):
  3062. DB_실행("select * from data where title = '사용자:" + DB_인코딩(ip) + "'")
  3063. row = curs.fetchall()
  3064. if(row):
  3065. ip = '<a href="/w/' + URL_인코딩('사용자:' + ip) + '">' + ip + '</a>'
  3066. else:
  3067. ip = '<a class="not_thing" href="/w/' + URL_인코딩('사용자:' + ip) + '">' + ip + '</a>'
  3068. return render_template('index.html', title = '유저 메뉴', logo = data['name'], data = ip + '<br><br><span>권한 상태 : ' + acl + '<br><br><li><a href="/login">로그인</a></li><li><a href="/logout">로그아웃</a></li><li><a href="/register">회원가입</a></li><li><a href="/change">비밀번호 변경</a></li>')
  3069. @app.route('/random')
  3070. def random():
  3071. DB_실행("select * from data order by rand() limit 1")
  3072. rows = curs.fetchall()
  3073. if(rows):
  3074. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(rows[0]['title']) + '" />'
  3075. else:
  3076. return '<meta http-equiv="refresh" content="0;url=/" />'
  3077. @app.route('/error/<int:num>')
  3078. def error(num = None):
  3079. if(num == 1):
  3080. return render_template('index.html', title = '권한 오류', logo = data['name'], data = '비 로그인 상태 입니다.'), 401
  3081. elif(num == 2):
  3082. return render_template('index.html', title = '권한 오류', logo = data['name'], data = '이 계정이 없습니다.'), 401
  3083. elif(num == 3):
  3084. return render_template('index.html', title = '권한 오류', logo = data['name'], data = '권한이 모자랍니다.'), 401
  3085. elif(num == 4):
  3086. return render_template('index.html', title = '권한 오류', logo = data['name'], data = '관리자는 차단, 검사 할 수 없습니다.'), 401
  3087. elif(num == 5):
  3088. return render_template('index.html', title = '유저 오류', logo = data['name'], data = '그런 계정이 없습니다.'), 401
  3089. elif(num == 6):
  3090. return render_template('index.html', title = '가입 오류', logo = data['name'], data = '동일한 아이디의 유저가 있습니다.'), 401
  3091. elif(num == 7):
  3092. return render_template('index.html', title = '가입 오류', logo = data['name'], data = '아이디는 20글자보다 짧아야 합니다.'), 401
  3093. elif(num == 8):
  3094. return render_template('index.html', title = '가입 오류', logo = data['name'], data = '아이디에는 한글과 알파벳과 공백만 허용 됩니다.'), 401
  3095. elif(num == 9):
  3096. return render_template('index.html', title = '변경 오류', logo = data['name'], data = '그런 계정이 없습니다.'), 401
  3097. elif(num == 10):
  3098. return render_template('index.html', title = '변경 오류', logo = data['name'], data = '비밀번호가 다릅니다.'), 401
  3099. elif(num == 11):
  3100. return render_template('index.html', title = '로그인 오류', logo = data['name'], data = '이미 로그인 되어 있습니다.'), 401
  3101. elif(num == 12):
  3102. return render_template('index.html', title = '로그인 오류', logo = data['name'], data = '그런 계정이 없습니다.'), 401
  3103. elif(num == 13):
  3104. return render_template('index.html', title = '로그인 오류', logo = data['name'], data = '비밀번호가 다릅니다.'), 401
  3105. elif(num == 14):
  3106. return render_template('index.html', title = '업로드 오류', logo = data['name'], data = 'jpg, gif, jpeg, png만 가능 합니다.'), 401
  3107. elif(num == 15):
  3108. return render_template('index.html', title = '업로드 오류', logo = data['name'], data = '파일 명에 . / \ * < > | : ? 가 들어 갈 수 없습니다.'), 401
  3109. elif(num == 16):
  3110. return render_template('index.html', title = '업로드 오류', logo = data['name'], data = '동일한 이름의 파일이 있습니다.'), 401
  3111. elif(num == 17):
  3112. return render_template('index.html', title = '편집 오류', logo = data['name'], data = '편집 내용 기록에는 한글과 영어와 숫자, 공백만 허용 됩니다.'), 401
  3113. elif(num == 18):
  3114. return render_template('index.html', title = '편집 오류', logo = data['name'], data = '내용이 원래 문서와 동일 합니다.'), 401
  3115. elif(num == 19):
  3116. return render_template('index.html', title = '이동 오류', logo = data['name'], data = '이동 하려는 곳에 문서가 이미 있습니다.'), 401
  3117. elif(num == 20):
  3118. return render_template('index.html', title = '비밀번호 오류', logo = data['name'], data = '재 확인이랑 비밀번호가 다릅니다.'), 401
  3119. else:
  3120. return '<meta http-equiv="refresh" content="0;url=/" />'
  3121. @app.errorhandler(404)
  3122. def uncaughtError(error):
  3123. return '<meta http-equiv="refresh" content="0;url=/w/' + URL_인코딩(data['frontpage']) + '" />'
  3124. @app.errorhandler(413)
  3125. def uncaughtError(error):
  3126. app.config['MAX_CONTENT_LENGTH'] = (1024**3)
  3127. return error, 401
  3128. if __name__ == '__main__':
  3129. app.run(host = '0.0.0.0', port = int(data['port']))