app.py 115 KB

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