app.py 180 KB

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