| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254 |
- ๏ปฟfrom bottle import *
- from bottle.ext import beaker
- import bcrypt
- import os
- import difflib
- import hashlib
- import json
- import sqlite3
- import html
- try:
- json_data = open('set.json').read()
- set_data = json.loads(json_data)
- except:
- new_json = []
- print('DB ์ด๋ฆ : ', end = '')
- new_json += [input()]
- print('์ํค ํฌํธ : ', end = '')
- new_json += [input()]
- with open("set.json", "w") as f:
- f.write('{ \
- "db" : "' + new_json[0] + '", \
- "port" : "' + new_json[1] + '" \
- }')
-
- json_data = open('set.json').read()
- set_data = json.loads(json_data)
- conn = sqlite3.connect(set_data['db'] + '.db')
- curs = conn.cursor()
- session_opts = {
- 'session.type': 'file',
- 'session.data_dir': './app_session/',
- 'session.auto': 1
- }
- app = beaker.middleware.SessionMiddleware(app(), session_opts)
- BaseRequest.MEMFILE_MAX = 1024 * 1024
- def redirect(data):
- return('<meta http-equiv="refresh" content="0;url=' + data + '" />')
-
- from func import *
- r_ver = '2.2.2'
- p_ver = 'b'
- try:
- curs.execute('select data from other where name = "version"')
- version = curs.fetchall()
- if(version):
- t_ver = re.sub('\.', '', version[0][0])
- r_t_ver = re.sub('\.', '', r_ver)
- if(int(t_ver) < int(r_t_ver)):
- curs.execute("update other set data = ? where name = 'version'", [r_ver])
-
- conn.commit()
- except:
- pass
- @route('/setup', method=['GET', 'POST'])
- def setup():
- curs.execute("create table data(title text, data text, acl text)")
- curs.execute("create table history(id text, title text, data text, date text, ip text, send text, leng text)")
- curs.execute("create table rd(title text, sub text, date text)")
- curs.execute("create table user(id text, pw text, acl text)")
- curs.execute("create table ban(block text, end text, why text, band text)")
- curs.execute("create table topic(id text, title text, sub text, data text, date text, ip text, block text, top text)")
- curs.execute("create table stop(title text, sub text, close text)")
- curs.execute("create table rb(block text, end text, today text, blocker text, why text)")
- curs.execute("create table login(user text, ip text, today text)")
- curs.execute("create table back(title text, link text, type text)")
- curs.execute("create table cat(title text, cat text)")
- curs.execute("create table hidhi(title text, re text)")
- curs.execute("create table agreedis(title text, sub text)")
- curs.execute("create table custom(user text, css text)")
- curs.execute("create table other(name text, data text)")
- curs.execute("create table alist(name text, acl text)")
- curs.execute("insert into alist (name, acl) values ('owner', 'owner')")
- curs.execute("insert into other (name, data) values ('version', ?)", [r_ver])
- curs.execute('insert into other (name, data) values ("name", "wiki")')
- curs.execute('insert into other (name, data) values ("frontpage", "์ํค:๋๋ฌธ")')
- curs.execute('insert into other (name, data) values ("license", "CC 0")')
- curs.execute('insert into other (name, data) values ("upload", "2")')
- conn.commit()
- return(redirect('/'))
- @route('/edit_set', method=['POST', 'GET'])
- def edit_set():
- if(admin_check(None) == 1):
- if(request.method == 'POST'):
- curs.execute("update other set data = ? where name = ?", [request.forms.name, 'name'])
- curs.execute("update other set data = ? where name = 'frontpage'", [request.forms.frontpage])
- curs.execute("update other set data = ? where name = 'license'", [request.forms.license])
- curs.execute("update other set data = ? where name = 'upload'", [request.forms.upload])
- conn.commit()
- return(redirect('/'))
- else:
- curs.execute('select data from other where name = ?', ['name'])
- name_d = curs.fetchall()
- curs.execute('select data from other where name = "frontpage"')
- frontpage_d = curs.fetchall()
- curs.execute('select data from other where name = "license"')
- license_d = curs.fetchall()
- curs.execute('select data from other where name = "upload"')
- upload_d = curs.fetchall()
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = '<form method="post"> \
- <input type="text" name="name" value="' + name_d[0][0] + '"> \
- <br> \
- <br> \
- <input type="text" name="frontpage" value="' + frontpage_d[0][0] + '"> \
- <br> \
- <br> \
- <input type="text" name="license" value="' + license_d[0][0] + '"> \
- <br> \
- <br> \
- <input type="text" name="upload" value="' + upload_d[0][0] + '"> \
- <br> \
- <br> \
- <span>์ฐจ๋ก๋๋ก ์ํค ์ด๋ฆ, ์์ ํ์ด์ง, ๋ผ์ด์ ์ค, ์
๋ก๋ ์ต๋ ํฌ๊ธฐ ์
๋๋ค.</span> \
- <br> \
- <br> \
- <button class="btn btn-primary" type="submit">์ ์ฅ</button> \
- </form>',
- title = '์ค์ ํธ์ง'
- )
- )
- else:
- return(redirect('/ban'))
- @route('/update')
- @route('/update/<num:int>')
- def update(num = 1):
- if(admin_check(None) == 1):
- if(num == 1):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = '<li><a href="/update/2">2.2.1</a></li>',
- title = '์
๋ฐ์ดํธ ๋ชฉ๋ก'
- )
- )
- elif(num == 2):
- curs.execute('insert into other (name, data) values ("name", ?)', [set_data['name']])
- curs.execute('insert into other (name, data) values ("frontpage", ?)', [set_data['frontpage']])
- curs.execute('insert into other (name, data) values ("license", ?)', [set_data['license']])
- curs.execute('insert into other (name, data) values ("upload", ?)', [set_data['upload']])
- conn.commit()
- return(redirect('/'))
- else:
- return(redirect('/ban'))
- @route('/not_close_topic')
- def not_close_topic():
- div = ''
- i = 1
- curs.execute('select title, sub from rd order by date desc')
- n_list = curs.fetchall()
- for data in n_list:
- curs.execute('select * from stop where title = ? and sub = ? and close = "O"', [data[0], data[1]])
- is_close = curs.fetchall()
- if(not is_close):
- div += '<li>' + str(i) + '. <a href="/topic/' + url_pas(data[0]) + '/sub/' + url_pas(data[1]) + '">' + data[0] + ' (' + data[1] + ')</a></li>'
- i += 1
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = div,
- title = '์ ๋ซํ ํ ๋ก ๋ชฉ๋ก'
- )
- )
- @route('/image/<name:path>')
- def static(name = None):
- if(os.path.exists(os.path.join('image', name))):
- return(static_file(name, root = 'image'))
- else:
- return(redirect('/'))
- @route('/acl_list')
- def acl_list():
- div = ''
- i = 0
- curs.execute("select title, acl from data where acl = 'admin' or acl = 'user' order by acl desc")
- list_data = curs.fetchall()
- for data in list_data:
- if(data[1] == 'admin'):
- acl = '๊ด๋ฆฌ์'
- else:
- acl = '๋ก๊ทธ์ธ'
- div += '<li>' + str(i + 1) + '. <a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a> (' + acl + ')</li>'
-
- i += 1
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = div,
- title = 'ACL ๋ฌธ์ ๋ชฉ๋ก'
- )
- )
-
- @route('/list_acl')
- def list_acl():
- div = ''
- i = 1
- curs.execute("select name, acl from alist order by name desc")
- list_data = curs.fetchall()
- for data in list_data:
- if(data[1] == 'ban'):
- acl = '์ฐจ๋จ'
- elif(data[1] == 'mdel'):
- acl = '๋ง์ ๋ฌธ์ ์ญ์ '
- elif(data[1] == 'toron'):
- acl = 'ํ ๋ก ๊ด๋ฆฌ'
- elif(data[1] == 'check'):
- acl = '์ฌ์ฉ์ ๊ฒ์ฌ'
- elif(data[1] == 'acl'):
- acl = '๋ฌธ์ ACL'
- elif(data[1] == 'hidel'):
- acl = '์ญ์ฌ ์จ๊น'
- elif(data[1] == 'owner'):
- acl = '์์ ์'
-
- div += '<li>' + str(i + 1) + '. <a href="/admin_plus/' + url_pas(data[0]) + '">' + data[0] + '</a> (' + acl + ')</li>'
-
- i += 1
- else:
- div += '<br> \
- <a href="/manager/8">(์์ฑ)</a>'
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = re.sub('^<br>', '', div),
- title = 'ACL ๋ชฉ๋ก'
- )
- )
- @route('/admin_plus/<name:path>', method=['POST', 'GET'])
- def admin_plus(name = None):
- if(admin_check(None) == 1):
- if(request.method == 'POST'):
- curs.execute("delete from alist where name = ?", [name])
-
- if(request.forms.ban):
- curs.execute("insert into alist (name, acl) values (?, 'ban')", [name])
- if(request.forms.mdel):
- curs.execute("insert into alist (name, acl) values (?, 'mdel')", [name])
- if(request.forms.toron):
- curs.execute("insert into alist (name, acl) values (?, 'toron')", [name])
-
- if(request.forms.check):
- curs.execute("insert into alist (name, acl) values (?, 'check')", [name])
- if(request.forms.acl):
- curs.execute("insert into alist (name, acl) values (?, 'acl')", [name])
- if(request.forms.hidel):
- curs.execute("insert into alist (name, acl) values (?, 'hidel')", [name])
- if(request.forms.owner):
- curs.execute("insert into alist (name, acl) values (?, 'owner')", [name])
-
- conn.commit()
-
- return(redirect('/admin_plus/admin'))
- else:
- curs.execute('select acl from alist where name = ?', [name])
- test = curs.fetchall()
-
- data = ''
- exist_list = ['', '', '', '', '', '', '', '', '']
- for go in test:
- if(go[0] == 'ban'):
- exist_list[0] = 'checked="checked"'
- elif(go[0] == 'mdel'):
- exist_list[1] = 'checked="checked"'
- elif(go[0] == 'toron'):
- exist_list[2] = 'checked="checked"'
- elif(go[0] == 'check'):
- exist_list[3] = 'checked="checked"'
- elif(go[0] == 'acl'):
- exist_list[4] = 'checked="checked"'
- elif(go[0] == 'hidel'):
- exist_list[5] = 'checked="checked"'
- elif(go[0] == 'owner'):
- exist_list[7] = 'checked="checked"'
- data += '<li><input type="checkbox" name="ban" ' + exist_list[0] + '> ์ฐจ๋จ</li>'
- data += '<li><input type="checkbox" name="mdel" ' + exist_list[1] + '> ๋ง์ ๋ฌธ์ ์ญ์ </li>'
- data += '<li><input type="checkbox" name="toron" ' + exist_list[2] + '> ํ ๋ก ๊ด๋ฆฌ</li>'
- data += '<li><input type="checkbox" name="check" ' + exist_list[3] + '> ์ฌ์ฉ์ ๊ฒ์ฌ</li>'
- data += '<li><input type="checkbox" name="acl" ' + exist_list[4] + '> ๋ฌธ์ ACL</li>'
- data += '<li><input type="checkbox" name="hidel" ' + exist_list[5] + '> ์ญ์ฌ ์จ๊น</li>'
- data += '<li><input type="checkbox" name="owner" ' + exist_list[7] + '> ์์ ์</li>'
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ด๋ฆฌ ๊ทธ๋ฃน ์ถ๊ฐ',
- logo = wiki_set(1),
- data = '<form method="post">' \
- + data + \
- '<div class="form-actions"> \
- <button class="btn btn-primary" type="submit">์ ์ฅ</button> \
- </div> \
- </form>'
- )
- )
- else:
- return(redirect('/error/3'))
-
- @route('/admin_list')
- def admin_list():
- i = 1
- div = ''
-
- curs.execute("select id, acl from user where not acl = 'user'")
- user_data = curs.fetchall()
- for data in user_data:
- name = ip_pas(data[0], 2) + ' (' + data[1] + ')'
- div += '<li>' + str(i) + '. ' + name + '</li>'
-
- i += 1
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = div,
- title = '๊ด๋ฆฌ์ ๋ชฉ๋ก'
- )
- )
-
- @route('/record/<name:path>')
- @route('/record/<name:path>/n/<num:int>')
- @route('/recent_changes')
- def recent_changes(name = None, num = 1):
- ydmin = admin_check(1)
- zdmin = admin_check(6)
- ban = ''
- send = '<br>'
- div = '<table style="width: 100%; text-align: center;"> \
- <tbody> \
- <tr> \
- <td style="width: 33.3%;">๋ฌธ์๋ช
</td> \
- <td style="width: 33.3%;">๊ธฐ์ฌ์</td> \
- <td style="width: 33.3%;">์๊ฐ</td> \
- </tr>'
-
- if(name):
- if(num * 50 <= 0):
- v = 50
- else:
- v = num * 50
-
- i = v - 50
- curs.execute("select id, title, date, ip, send, leng from history where ip = ? order by date desc limit ?, ?", [name, str(i), str(v)])
- else:
- curs.execute("select id, title, date, ip, send, leng from history order by date desc limit 50")
- rows = curs.fetchall()
- for data in rows:
- send = '<br>'
- if(data[4]):
- if(not re.search("^(?: *)$", data[4])):
- send = data[4]
-
- title = html.escape(data[1])
-
- if(re.search("\+", data[5])):
- leng = '<span style="color:green;">' + data[5] + '</span>'
- elif(re.search("\-", data[5])):
- leng = '<span style="color:red;">' + data[5] + '</span>'
- else:
- leng = '<span style="color:gray;">' + data[5] + '</span>'
-
- if(ydmin == 1):
- curs.execute("select * from ban where block = ?", [data[3]])
- row = curs.fetchall()
- if(row):
- ban = ' <a href="/ban/' + url_pas(data[3]) + '">(ํด์ )</a>'
- else:
- ban = ' <a href="/ban/' + url_pas(data[3]) + '">(์ฐจ๋จ)</a>'
-
- ip = ip_pas(data[3], None)
-
- if((int(data[0]) - 1) == 0):
- revert = ''
- else:
- 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>'
-
- style = ''
- curs.execute("select * from hidhi where title = ? and re = ?", [data[1], data[0]])
- row = curs.fetchall()
- if(zdmin == 1):
- if(row):
- ip += ' (์จ๊น)'
- hidden = ' <a href="/history/' + url_pas(data[1]) + '/r/' + data[0] + '/hidden">(๊ณต๊ฐ)'
- else:
- hidden = ' <a href="/history/' + url_pas(data[1]) + '/r/' + data[0] + '/hidden">(์จ๊น)'
- else:
- if(row):
- ip = '์จ๊น'
- hidden = ''
- send = '์จ๊น'
- ban = ''
- style = 'display:none;'
- else:
- hidden = ''
-
- div += '<tr style="' + style + '"> \
- <td> \
- <a href="/w/' + url_pas(data[1]) + '">' + title + '</a> (<a href="/history/' + url_pas(data[1]) + '">' + data[0] + 'ํ</a>) ' + revert + ' (' + leng + ') \
- </td> \
- <td>' + ip + ban + hidden + '</td> \
- <td>' + data[2] + '</td> \
- </tr> \
- <tr> \
- <td colspan="3">' + send + '</td> \
- </tr>'
- else:
- div += '</tbody> \
- </table>'
- if(name):
- curs.execute("select end, why from ban where block = ?", [name])
- ban_it = curs.fetchall()
- if(ban_it):
- sub = '์ฐจ๋จ'
- else:
- sub = None
- title = '์ฌ์ฉ์ ๊ธฐ๋ก'
- div += '<br> \
- <a href="/record/' + url_pas(name) + '/n/' + str(num + 1) + '">(์ด์ )</a> <a href="/record/' + url_pas(name) + '/n/' + str(num - 1) + '">(์ด์ )</a>'
- else:
- sub = None
- title = '์ต๊ทผ ๋ณ๊ฒฝ๋ด์ญ'
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = div,
- sub = sub,
- title = title
- )
- )
-
- @route('/history/<name:path>/r/<num:int>/hidden')
- def history_hidden(name = None, num = None):
- if(admin_check(6) == 1):
- curs.execute("select * from hidhi where title = ? and re = ?", [name, str(num)])
- exist = curs.fetchall()
- if(exist):
- curs.execute("delete from hidhi where title = ? and re = ?", [name, str(num)])
- else:
- curs.execute("insert into hidhi (title, re) values (?, ?)", [name, str(num)])
-
- conn.commit()
-
- return(redirect('/history/' + url_pas(name)))
-
- @route('/userlog')
- @route('/userlog/n/<num:int>')
- def user_log(num = 1):
- if(num * 50 <= 0):
- i = 50
- else:
- i = num * 50
-
- j = i - 50
- list_data = ''
- ydmin = admin_check(1)
-
- curs.execute("select id from user limit ?, ?", [str(j), str(i)])
- user_list = curs.fetchall()
- for data in user_list:
- if(ydmin == 1):
- curs.execute("select block from ban where block = ?", [data[0]])
- ban_exist = curs.fetchall()
- if(ban_exist):
- ban_button = ' <a href="/ban/' + url_pas(data[0]) + '">(ํด์ )</a>'
- else:
- ban_button = ' <a href="/ban/' + url_pas(data[0]) + '">(์ฐจ๋จ)</a>'
- else:
- ban_button = ''
-
- ip = ip_pas(data[0], None)
-
- list_data += '<li>' + str(j + 1) + '. ' + ip + ban_button + '</li>'
-
- j += 1
- else:
- list_data += '<br> \
- <a href="/userlog/n/' + str(num - 1) + '">(์ด์ )</a> <a href="/userlog/n/' + str(num + 1) + '">(์ดํ)</a>'
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = list_data,
- title = '์ฌ์ฉ์ ๊ฐ์
๊ธฐ๋ก'
- )
- )
-
- @route('/back_reset')
- def back_reset():
- if(admin_check(None) == 1):
- curs.execute("delete from back")
- curs.execute("delete from cat")
- conn.commit()
-
- curs.execute("select title, data from data")
- data = curs.fetchall()
- for end in data:
- print(end[0])
-
- namumark(end[0], end[1], 1, 0)
-
- return(redirect('/'))
- else:
-
- return(redirect('/error/3'))
-
- @route('/xref/<name:path>')
- @route('/xref/<name:path>/n/<num:int>')
- def xref(name = None, num = 1):
- if(num * 50 <= 0):
- v = 50
- else:
- v = num * 50
-
- i = v - 50
- div = ''
-
- curs.execute("delete from back where title = ? and link = ''", [name])
- conn.commit()
-
- curs.execute("select link, type from back where title = ? order by link asc limit ?, ?", [name, str(i), str(v)])
- rows = curs.fetchall()
- for data in rows:
- div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a>'
-
- if(data[1]):
- div += ' (' + data[1] + ')'
-
- div += '</li>'
- else:
- div += '<br> \
- <a href="/xref/' + url_pas(name) + '/n/' + str(num - 1) + '">(์ด์ )</a> <a href="/xref/' + url_pas(name) + '/n/' + str(num + 1) + '">(์ดํ)</a>'
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = div,
- title = name,
- page = url_pas(name),
- sub = '์ญ๋งํฌ'
- )
- )
-
- @route('/recent_discuss')
- def recent_discuss():
- div = '<table style="width: 100%; text-align: center;"> \
- <tbody> \
- <tr> \
- <td style="width: 50%;">ํ ๋ก ๋ช
</td> \
- <td style="width: 50%;">์๊ฐ</td> \
- </tr>'
-
- curs.execute("select title, sub, date from rd order by date desc limit 50")
- rows = curs.fetchall()
- for data in rows:
- title = html.escape(data[0])
- sub = html.escape(data[1])
-
- div += '<tr> \
- <td> \
- <a href="/topic/' + url_pas(data[0]) + '/sub/' + url_pas(data[1]) + '">' + title + '</a> (' + sub + ') \
- </td> \
- <td>' + data[2] + '</td> \
- </tr>'
- else:
- div += '</tbody> \
- </table>'
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = div,
- title = '์ต๊ทผ ํ ๋ก ๋ด์ญ'
- )
- )
- @route('/blocklog')
- @route('/blocklog/n/<number:int>')
- def blocklog(num = 1):
- if(num * 50 <= 0):
- v = 50
- else:
- v = num * 50
-
- i = v - 50
- div = '<table style="width: 100%; text-align: center;"> \
- <tbody> \
- <tr> \
- <td style="width: 20%;">์ฐจ๋จ์</td> \
- <td style="width: 20%;">๊ด๋ฆฌ์</td> \
- <td style="width: 20%;">๊ธฐ๊ฐ</td> \
- <td style="width: 20%;">์ด์ </td> \
- <td style="width: 20%;">์๊ฐ</td> \
- </tr>'
-
- curs.execute("select why, block, blocker, end, today from rb order by today desc limit ?, ?", [str(i), str(v)])
- rows = curs.fetchall()
- for data in rows:
- why = html.escape(data[0])
-
- b = re.search("^([0-9]{1,3}\.[0-9]{1,3})$", data[1])
- if(b):
- ip = data[1] + ' (๋์ญ)'
- else:
- ip = data[1]
-
- div += '<tr> \
- <td>' + ip + '</td> \
- <td>' + data[2] + '</td> \
- <td>' + data[3] + '</td> \
- <td>' + why + '</td> \
- <td>' + data[4] + '</td> \
- </tr>'
- else:
- div += '</tbody> \
- </table> \
- <br> \
- <a href="/xref/' + url_pas(name) + '/n/' + str(num - 1) + '">(์ด์ )</a> <a href="/xref/' + url_pas(name) + '/n/' + str(num + 1) + '">(์ดํ)</a>'
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = div,
- title = '์ฌ์ฉ์ ์ฐจ๋จ ๊ธฐ๋ก'
- )
- )
- @route('/history/<name:path>', method=['POST', 'GET'])
- @route('/history/<name:path>/n/<num:int>', method=['POST', 'GET'])
- def history_view(name = None, num = 1):
- if(request.method == 'POST'):
- return(redirect('/w/' + url_pas(name) + '/r/' + request.forms.b + '/diff/' + request.forms.a))
- else:
- select = ''
- if(num * 50 <= 0):
- i = 50
- else:
- i = num * 50
-
- j = i - 50
-
- admin1 = admin_check(1)
- admin2 = admin_check(6)
-
- div = '<table style="width: 100%; text-align: center;"> \
- <tbody> \
- <tr> \
- <td style="width: 33.3%;">ํ</td> \
- <td style="width: 33.3%;">๊ธฐ์ฌ์</td> \
- <td style="width: 33.3%;">์๊ฐ</td> \
- </tr>'
-
- curs.execute("select send, leng, ip, date, title, id from history where title = ? order by id + 0 desc limit ?, ?", [name, str(j), str(i)])
- all_data = curs.fetchall()
- for data in all_data:
- select += '<option value="' + data[5] + '">' + data[5] + '</option>'
-
- if(data[0]):
- send = data[0]
- else:
- send = '<br>'
-
- if(re.search("^\+", data[1])):
- leng = '<span style="color:green;">' + data[1] + '</span>'
- elif(re.search("^\-", data[1])):
- leng = '<span style="color:red;">' + data[1] + '</span>'
- else:
- leng = '<span style="color:gray;">' + data[1] + '</span>'
-
- ip = ip_pas(data[2], None)
-
- curs.execute("select block from ban where block = ?", [data[2]])
- ban_it = curs.fetchall()
- if(ban_it):
- if(admin1 == 1):
- ban = ' <a href="/ban/' + url_pas(data[2]) + '">(ํด์ )</a>'
- else:
- ban = ' (X)'
- else:
- if(admin1 == 1):
- ban = ' <a href="/ban/' + url_pas(data[2]) + '">(์ฐจ๋จ)</a>'
- else:
- ban = ''
-
- curs.execute("select * from hidhi where title = ? and re = ?", [name, data[5]])
- hid_it = curs.fetchall()
- if(hid_it):
- if(admin2):
- hidden = ' <a href="/history/' + url_pas(name) + '/r/' + url_pas(data[5]) + '/hidden">(๊ณต๊ฐ)'
- hid = 0
- else:
- hid = 1
- else:
- if(admin2):
- hidden = ' <a href="/history/' + url_pas(name) + '/r/' + url_pas(data[5]) + '/hidden">(์จ๊น)'
- hid = 0
- else:
- hidden = ''
- hid = 0
-
- if(hid == 1):
- div += '<tr> \
- <td colspan="3">์จ๊น</td> \
- </tr>'
- else:
- div += '<tr> \
- <td> \
- ' + data[5] + 'ํ</a> <a href="/w/' + url_pas(name) + '/r/' + url_pas(data[5]) + '">(๋ณด๊ธฐ)</a> \
- <a href="/raw/' + url_pas(name) + '/r/' + url_pas(data[5]) + '">(์๋ณธ)</a> \
- <a href="/revert/' + url_pas(name) + '/r/' + url_pas(data[5]) + '">(๋๋๋ฆฌ๊ธฐ)</a> (' + leng + ') \
- </td> \
- <td>' + ip + ban + hidden + '</td> \
- <td>' + data[3] + '</td> \
- </tr> \
- <tr> \
- <td colspan="3">' + send + '</td> \
- </tr>'
- else:
- div += '</tbody> \
- </table> \
- <br> \
- <a href="/history/' + url_pas(name) + '/n/' + str(num - 1) + '">(์ด์ )</a> <a href="/history/' + url_pas(name) + '/n/' + str(num + 1) + '">(์ดํ)</a>'
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = div,
- title = name,
- page = url_pas(name),
- select = select,
- sub = '์ญ์ฌ'
- )
- )
-
- @route('/search', method=['POST'])
- def search():
- return(redirect('/search/' + url_pas(request.forms.search)))
- @route('/goto', method=['POST'])
- def goto():
- curs.execute("select title from data where title = ?", [request.forms.search])
- data = curs.fetchall()
- if(data):
- return(redirect('/w/' + url_pas(request.forms.search)))
- else:
- return(redirect('/search/' + url_pas(request.forms.search)))
- @route('/search/<name:path>')
- @route('/search/<name:path>/n/<num:int>')
- def deep_search(name = None, num = 1):
- if(num * 50 <= 0):
- v = num * 50
- else:
- v = 50
- i = v - 50
- div = ''
- div_plus = ''
- end = ''
- curs.execute("select title from data where title like ?", ['%' + name + '%'])
- title_list = curs.fetchall()
- curs.execute("select title from data where data like ?", ['%' + name + '%'])
- data_list = curs.fetchall()
- curs.execute("select title from data where title = ?", [name])
- exist = curs.fetchall()
- if(exist):
- div = '<li>๋ฌธ์๋ก <a href="/w/' + url_pas(name) + '">๋ฐ๋ก๊ฐ๊ธฐ</a></li> \
- <br>'
- else:
- div = '<li>๋ฌธ์๊ฐ ์์ต๋๋ค. <a class="not_thing" href="/w/' + url_pas(name) + '">๋ฐ๋ก๊ฐ๊ธฐ</a></li> \
- <br>'
- if(title_list):
- no = 0
- if(data_list):
- all_list = title_list + data_list
- else:
- all_list = title_list
- else:
- if(data_list):
- no = 1
- all_list = data_list
- else:
- all_list = ''
-
- if(all_list != ''):
- for data in all_list:
- re_title = re.compile(name, re.I)
- if(re.search(re_title, data[0])):
- if(no == 0):
- div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a> (๋ฌธ์๋ช
)</li>'
- else:
- div_plus += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a> (๋ด์ฉ)</li>'
- else:
- no = 1
- div_plus += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a> (๋ด์ฉ)</li>'
- else:
- div += '<li>๊ฒ์ ๊ฒฐ๊ณผ ์์</li>'
- div += div_plus + end
- div += '<br> \
- <a href="/search/' + url_pas(name) + '/n/' + str(num - 1) + '">(์ด์ )</a> <a href="/search/' + url_pas(name) + '/n/' + str(num + 1) + '">(์ดํ)</a>'
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = div,
- title = name,
- sub = '๊ฒ์'
- )
- )
-
- @route('/raw/<name:path>')
- @route('/raw/<name:path>/r/<num:int>')
- def raw_view(name = None, num = None):
- if(num):
- curs.execute("select title from hidhi where title = ? and re = ?", [name, str(num)])
- hid = curs.fetchall()
- if(hid and admin_check(6) != 1):
- return(redirect('/error/3'))
-
- curs.execute("select data from history where title = ? and id = ?", [name, str(num)])
- else:
- curs.execute("select data from data where title = ?", [name])
- rows = curs.fetchall()
- if(rows):
- enddata = html.escape(rows[0][0])
-
- enddata = '<textarea readonly="" style="height: 80%;">' + enddata + '</textarea>'
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- logo = wiki_set(1),
- page = url_pas(name),
- data = enddata,
- sub = '์๋ณธ'
- )
- )
- else:
- return(redirect('/w/' + url_pas(name)))
-
- @route('/revert/<name:path>/r/<num:int>', method=['POST', 'GET'])
- def revert(name = None, num = None):
- ip = ip_check()
- can = acl_check(ip, name)
- today = get_time()
-
- if(request.method == 'POST'):
- curs.execute("select title from hidhi where title = ? and re = ?", [name, str(num)])
- hid = curs.fetchall()
- if(hid and admin_check(6) != 1):
- return(redirect('/error/3'))
- if(can == 1):
- return(redirect('/ban'))
- else:
- curs.execute("delete from back where link = ?", [name])
- curs.execute("delete from cat where cat = ?", [name])
- conn.commit()
- curs.execute("select data from history where title = ? and id = ?", [name, str(num)])
- rows = curs.fetchall()
- if(rows):
- curs.execute("select data from data where title = ?", [name])
- row = curs.fetchall()
- if(row):
- leng = leng_check(len(row[0][0]), len(rows[0][0]))
-
- curs.execute("update data set data = ? where title = ?", [rows[0][0], name])
- conn.commit()
- else:
- leng = '+' + str(len(rows[0][0]))
-
- curs.execute("insert into data (title, data, acl) values (?, ?, '')", [name, rows[0][0]])
- conn.commit()
-
- history_plus(
- name,
- rows[0][0],
- today,
- ip,
- '๋ฌธ์๋ฅผ ' + str(num) + 'ํ์ผ๋ก ๋๋๋ ธ์ต๋๋ค.',
- leng
- )
-
- return(redirect('/w/' + url_pas(name)))
- else:
- curs.execute("select title from hidhi where title = ? and re = ?", [name, str(num)])
- hid = curs.fetchall()
- if(hid and admin_check(6) != 1):
- return(redirect('/error/3'))
-
- if(can == 1):
- return(redirect('/ban'))
- else:
- curs.execute("select title from history where title = ? and id = ?", [name, str(num)])
- rows = curs.fetchall()
- if(rows):
- return(
- template('revert',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- logo = wiki_set(1),
- page = url_pas(name),
- r = url_pas(str(num)),
- plus = '์ ๋ง ๋๋๋ฆฌ์๊ฒ ์ต๋๊น?',
- sub = '๋๋๋ฆฌ๊ธฐ'
- )
- )
- else:
- return(redirect('/w/' + url_pas(name)))
-
- @route('/m_del', method=['POST', 'GET'])
- def m_del():
- today = get_time()
- ip = ip_check()
- if(admin_check(2) == 1):
- if(request.method == 'POST'):
- data = request.forms.content + '\r\n'
- m = re.findall('(.*)\r\n', data)
- for g in m:
- curs.execute("select data from data where title = ?", [g])
- rows = curs.fetchall()
- if(rows):
- curs.execute("delete from back where title = ?", [g])
- curs.execute("delete from cat where title = ?", [g])
- leng = '-' + str(len(rows[0][0]))
- curs.execute("delete from data where title = ?", [g])
- history_plus(
- g,
- '',
- today,
- ip,
- request.forms.send + ' (๋๋ ์ญ์ )',
- leng
- )
- data = re.sub('(.*)\r\n', '', data, 1)
- conn.commit()
- return(redirect('/'))
- else:
- return(
- template('mdel',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๋ง์ ๋ฌธ์ ์ญ์ ',
- logo = wiki_set(1)
- )
- )
- else:
- return(redirect('/error/3'))
-
- @route('/edit/<name:path>/section/<num:int>', method=['POST', 'GET'])
- def section_edit(name = None, num = None):
- ip = ip_check()
- can = acl_check(ip, name)
-
- if(request.method == 'POST'):
- if(len(request.forms.send) > 500):
- return(redirect('/error/15'))
- else:
- today = get_time()
- content = savemark(request.forms.content)
- curs.execute("delete from back where link = ?", [name])
- curs.execute("delete from cat where cat = ?", [name])
- curs.execute("select data from data where title = ?", [name])
- rows = curs.fetchall()
- if(rows):
- if(request.forms.otent == content):
- return(redirect('/error/18'))
- else:
- if(can == 1):
- return(redirect('/ban'))
- else:
- leng = leng_check(len(request.forms.otent), len(content))
- content = rows[0][0].replace(request.forms.otent, content)
-
- history_plus(
- name,
- content,
- today,
- ip,
- send_p(request.forms.send),
- leng
- )
-
- curs.execute("update data set data = ? where title = ?", [content, name])
- include_check(name, content)
-
- conn.commit()
- return(redirect('/w/' + url_pas(name)))
- else:
- if(can == 1):
- return(redirect('/ban'))
- else:
- curs.execute("select data from data where title = ?", [name])
- rows = curs.fetchall()
- if(rows):
- i = 0
- j = 0
-
- gdata = rows[0][0] + '\r\n'
- while(1):
- m = re.search("((?:={1,6})\s?(?:[^=]*)\s?(?:={1,6})(?:\s+)?\n(?:(?:(?:(?!(?:={1,6})\s?(?:[^=]*)\s?(?:={1,6})(?:\s+)?\n).)*)(?:\n)?)+)", gdata)
- if(m):
- if(i == num - 1):
- g = m.groups()
- gdata = re.sub("\r\n$", "", g[0])
-
- break
- else:
- gdata = re.sub("((?:={1,6})\s?(?:[^=]*)\s?(?:={1,6})(?:\s+)?\n(?:(?:(?:(?!(?:={1,6})\s?(?:[^=]*)\s?(?:={1,6})(?:\s+)?\n).)*)(?:\n)?)+)", "", gdata, 1)
-
- i += 1
- else:
- j = 1
-
- break
-
- if(j == 0):
- gdata = re.sub("\r\n$", "", gdata)
- return(
- template('edit',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- logo = wiki_set(1),
- page = url_pas(name),
- data = gdata,
- section = 1,
- number = num,
- sub = 'ํธ์ง'
- )
- )
- else:
- return(redirect('/w/' + url_pas(name)))
- else:
- return(redirect('/w/' + url_pas(name)))
- @route('/edit/<name:path>', method=['POST', 'GET'])
- def edit(name = None):
- ip = ip_check()
- can = acl_check(ip, name)
-
- if(request.method == 'POST'):
- if(len(request.forms.send) > 500):
- return(redirect('/error/15'))
- else:
- today = get_time()
- content = savemark(request.forms.content)
- if(can == 1):
- return(redirect('/ban'))
- curs.execute("select data from data where title = ?", [name])
- rows = curs.fetchall()
- if(rows):
- if(rows[0][0] == content):
- return(redirect('/error/18'))
- leng = leng_check(len(rows[0][0]), len(content))
- curs.execute("update data set data = ? where title = ?", [content, name])
- else:
- leng = '+' + str(len(content))
- curs.execute("insert into data (title, data, acl) values (?, ?, '')", [name, content])
- curs.execute("delete from back where link = ?", [name])
- curs.execute("delete from cat where cat = ?", [name])
-
- history_plus(
- name,
- content,
- today,
- ip,
- send_p(request.forms.send),
- leng
- )
-
- include_check(name, content)
-
- conn.commit()
- return(redirect('/w/' + url_pas(name)))
- else:
- if(can == 1):
- return(redirect('/ban'))
- else:
- curs.execute("select data from data where title = ?", [name])
- rows = curs.fetchall()
- if(rows):
- data = rows[0][0]
- else:
- data = ''
-
- return(
- template('edit',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- logo = wiki_set(1),
- page = url_pas(name),
- data = data,
- sub = 'ํธ์ง'
- )
- )
- @route('/preview/<name:path>/section/<num:int>', method=['POST'])
- def section_preview(name = None, num = None):
- ip = ip_check()
- can = acl_check(ip, name)
-
- if(can == 1):
- return(redirect('/ban'))
- else:
- newdata = request.forms.content
- newdata = re.sub('^#(?:redirect|๋๊ฒจ์ฃผ๊ธฐ)\s(?P<in>[^\n]*)', ' * [[\g<in>]] ๋ฌธ์๋ก ๋๊ฒจ์ฃผ๊ธฐ', newdata)
- enddata = namumark(name, newdata, 0, 0)
-
- return(
- template('edit',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- logo = wiki_set(1),
- page = url_pas(name),
- data = request.forms.content,
- preview = 1,
- enddata = enddata,
- section = 1,
- number = num,
- odata = request.forms.otent,
- sub = '๋ฏธ๋ฆฌ๋ณด๊ธฐ'
- )
- )
-
- @route('/preview/<name:path>', method=['POST'])
- def preview(name = None):
- ip = ip_check()
- can = acl_check(ip, name)
-
- if(can == 1):
- return(redirect('/ban'))
- else:
- newdata = request.forms.content
- newdata = re.sub('^#(?:redirect|๋๊ฒจ์ฃผ๊ธฐ)\s(?P<in>[^\n]*)', ' * [[\g<in>]] ๋ฌธ์๋ก ๋๊ฒจ์ฃผ๊ธฐ', newdata)
- enddata = namumark(name, newdata, 0, 0)
-
- return(
- template('edit',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- logo = wiki_set(1),
- page = url_pas(name),
- data = request.forms.content,
- preview = 1,
- enddata = enddata,
- sub = '๋ฏธ๋ฆฌ๋ณด๊ธฐ'
- )
- )
-
- @route('/delete/<name:path>', method=['POST', 'GET'])
- def delete(name = None):
- ip = ip_check()
- can = acl_check(ip, name)
-
- if(request.method == 'POST'):
- curs.execute("select data from data where title = ?", [name])
- rows = curs.fetchall()
- if(rows):
- if(can == 1):
- return(redirect('/ban'))
- today = get_time()
- curs.execute("delete from back where link = ?", [name])
- curs.execute("delete from cat where cat = ?", [name])
-
- leng = '-' + str(len(rows[0][0]))
- history_plus(
- name,
- '',
- today,
- ip,
- request.forms.send + ' (์ญ์ )',
- leng
- )
-
- curs.execute("delete from data where title = ?", [name])
- conn.commit()
-
- return(redirect('/w/' + url_pas(name)))
- else:
- curs.execute("select title from data where title = ?", [name])
- rows = curs.fetchall()
- if(rows):
- if(can == 1):
- return(redirect('/ban'))
- return(
- template('del',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- logo = wiki_set(1),
- page = url_pas(name),
- plus = '์ ๋ง ์ญ์ ํ์๊ฒ ์ต๋๊น?',
- sub = '์ญ์ '
- )
- )
- else:
- return(redirect('/w/' + url_pas(name)))
-
- @route('/move/<name:path>', method=['POST', 'GET'])
- def move(name = None):
- ip = ip_check()
- can = acl_check(ip, name)
- today = get_time()
- if(can == 1):
- return(redirect('/ban'))
-
- if(request.method == 'POST'):
- curs.execute("select data from data where title = ?", [name])
- rows = curs.fetchall()
- leng = '0'
- curs.execute("select title from history where title = ?", [request.forms.title])
- row = curs.fetchall()
- if(row):
- return(redirect('/error/19'))
- history_plus(
- name,
- rows[0][0],
- today,
- ip,
- request.forms.send + ' (<a href="/w/' + url_pas(name) + '">' + name + '</a> - <a href="/w/' + url_pas(request.forms.title) + '">' + request.forms.title + '</a> ์ด๋)',
- leng
- )
-
- if(rows):
- curs.execute("update data set title = ? where title = ?", [request.forms.title, name])
- curs.execute("delete from back where link = ?", [name])
- curs.execute("delete from cat where cat = ?", [name])
- curs.execute("update history set title = ? where title = ?", [request.forms.title, name])
- conn.commit()
-
- return(redirect('/w/' + url_pas(request.forms.title)))
- else:
- return(
- template('move',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- logo = wiki_set(1),
- page = url_pas(name),
- plus = '์ ๋ง ์ด๋ ํ์๊ฒ ์ต๋๊น?',
- sub = '์ด๋'
- )
- )
-
- @route('/other')
- def other():
- return(
- template(
- 'other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ธฐํ ๋ฉ๋ด',
- logo = wiki_set(1),
- data = '<h2 style="margin-top: 0px;">๊ธฐ๋ก</h2> \
- <li><a href="/blocklog">์ฌ์ฉ์ ์ฐจ๋จ ๊ธฐ๋ก</a></li> \
- <li><a href="/userlog">์ฌ์ฉ์ ๊ฐ์
๊ธฐ๋ก</a></li> \
- <li><a href="/manager/6">์ฌ์ฉ์ ๊ธฐ๋ก</a></li> \
- <li><a href="/manager/7">์ฌ์ฉ์ ํ ๋ก ๊ธฐ๋ก</a></li> \
- <h2>๊ธฐํ</h2> \
- <li><a href="/title_index">๋ชจ๋ ๋ฌธ์</a></li> \
- <li><a href="/acl_list">ACL ๋ฌธ์ ๋ชฉ๋ก</a></li> \
- <li><a href="/admin_list">๊ด๋ฆฌ์ ๋ชฉ๋ก</a></li> \
- <li><a href="/manager/1">๊ด๋ฆฌ์ ๋ฉ๋ด</a></li> \
- <br> \
- ์ด ์คํ๋๋ฌด์ ๋ฒ์ ์ <a href="https://github.com/2DU/openNAMU/blob/SQLite/version.md">v' + r_ver + p_ver + '</a> ์
๋๋ค.'
- )
- )
-
- @route('/manager', method=['POST', 'GET'])
- @route('/manager/<num:int>', method=['POST', 'GET'])
- def manager(num = 1):
- if(num == 1):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ด๋ฆฌ์ ๋ฉ๋ด',
- logo = wiki_set(1),
- data = '<h2 style="margin-top: 0px;">๋ชฉ๋ก</h2> \
- <li><a href="/manager/2">๋ฌธ์ ACL</a></li> \
- <li><a href="/manager/3">์ฌ์ฉ์ ์ฒดํฌ</a></li> \
- <li><a href="/manager/4">์ฌ์ฉ์ ์ฐจ๋จ</a></li> \
- <li><a href="/manager/5">๊ด๋ฆฌ์ ๊ถํ ์ฃผ๊ธฐ</a></li> \
- <li><a href="/m_del">๋ง์ ๋ฌธ์ ์ญ์ </a></li> \
- <li><a href="/not_close_topic">์ ๋ซํ ํ ๋ก ๋ชฉ๋ก</a></li> \
- <h2>์์ ์</h2> \
- <li><a href="/back_reset">์ญ๋งํฌ, ๋ถ๋ฅ ๋ค์ ์์ฑ</a></li> \
- <li><a href="/manager/8">๊ด๋ฆฌ ๊ทธ๋ฃน ์์ฑ</a></li> \
- <li><a href="/update">์
๋ฐ์ดํธ ๋ฉ๋ด</a></li> \
- <li><a href="/edit_set">์ค์ ํธ์ง</a></li> \
- <li><a href="/manager/9">๋ฌธ์ JSON ์ถ๋ ฅ</a></li> \
- <li><a href="/json_in">๋ฌธ์ JSON ์
๋ ฅ</a></li> \
- <h2>๊ธฐํ</h2> \
- <li>์ด ๋ฉ๋ด์ ์๋ ๊ธฐ๋ฅ์ ํด๋น ๋ฌธ์์ ์ญ์ฌ๋ ํ ๋ก ์์ ๋ฐ๋ก ์ฌ์ฉ ๊ฐ๋ฅํจ</li>'
- )
- )
- elif(num == 2):
- if(request.method == 'POST'):
- return(redirect('/acl/' + url_pas(request.forms.name)))
- else:
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = 'ACL ์ด๋',
- logo = wiki_set(1),
- data = '<form method="post"> \
- <input name="name" type="text"> \
- <br> \
- <br> \
- <button class="btn btn-primary" type="submit">์ด๋</button> \
- </form>'
- )
- )
- elif(num == 3):
- if(request.method == 'POST'):
- return(redirect('/check/' + url_pas(request.forms.name)))
- else:
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '์ฒดํฌ ์ด๋',
- logo = wiki_set(1),
- data = '<form method="post"> \
- <input name="name" type="text"> \
- <br> \
- <br> \
- <button class="btn btn-primary" type="submit">์ด๋</button> \
- </form>'
- )
- )
- elif(num == 4):
- if(request.method == 'POST'):
- return(redirect('/ban/' + url_pas(request.forms.name)))
- else:
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '์ฐจ๋จ ์ด๋',
- logo = wiki_set(1),
- data = '<form method="post"> \
- <input name="name" type="text"> \
- <br> \
- <br> \
- <button class="btn btn-primary" type="submit">์ด๋</button> \
- <br> \
- <br> \
- <span>์์ดํผ ์ ๋์๋ฆฌ (XXX.XXX) ์
๋ ฅํ๋ฉด ๋์ญ ์ฐจ๋จ</span> \
- </form>'
- )
- )
- elif(num == 5):
- if(request.method == 'POST'):
- return(redirect('/admin/' + url_pas(request.forms.name)))
- else:
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ถํ ์ด๋',
- logo = wiki_set(1),
- data = '<form method="post"> \
- <input name="name" type="text"> \
- <br> \
- <br> \
- <button class="btn btn-primary" type="submit">์ด๋</button> \
- </form>'
- )
- )
- elif(num == 6):
- if(request.method == 'POST'):
- return(redirect('/record/' + url_pas(request.forms.name)))
- else:
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ธฐ๋ก ์ด๋',
- logo = wiki_set(1),
- data = '<form method="post"> \
- <input name="name" type="text"> \
- <br> \
- <br> \
- <button class="btn btn-primary" type="submit">์ด๋</button> \
- </form>'
- )
- )
- elif(num == 7):
- if(request.method == 'POST'):
- return(redirect('/user/' + url_pas(request.forms.name) + '/topic'))
- else:
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = 'ํ ๋ก ๊ธฐ๋ก ์ด๋',
- logo = wiki_set(1),
- data = '<form method="post"> \
- <input name="name" type="text"> \
- <br> \
- <br> \
- <button class="btn btn-primary" type="submit">์ด๋</button> \
- </form>'
- )
- )
- elif(num == 8):
- if(request.method == 'POST'):
- return(redirect('/admin_plus/' + url_pas(request.forms.name)))
- else:
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ทธ๋ฃน ์์ฑ ์ด๋',
- logo = wiki_set(1),
- data = '<form method="post"> \
- <input name="name" type="text"> \
- <br> \
- <br> \
- <button class="btn btn-primary" type="submit">์ด๋</button> \
- </form>'
- )
- )
- elif(num == 9):
- if(request.method == 'POST'):
- return(redirect('/json_out/' + url_pas(request.forms.name)))
- else:
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๋ฌธ์ ์ถ๋ ฅ ์ด๋',
- logo = wiki_set(1),
- data = '<form method="post"> \
- <input name="name" type="text"> \
- <br> \
- <br> \
- <button class="btn btn-primary" type="submit">์ด๋</button> \
- </form>'
- )
- )
- else:
- return(redirect('/'))
- @route('/json_out/<name:path>')
- def json_out(name = None):
- if(admin_check(None) == 1):
- curs.execute('select data from data where title = ?', [name])
- get_d = curs.fetchall()
- if(get_d):
- da = get_d[0][0]
- else:
- da = ''
- curs.execute('select ip from history where title = ? order by ip asc', [name])
- get_h = curs.fetchall()
- var_n = ''
- hi_d = ''
- for hi in get_h:
- if(hi[0] != var_n):
- var_n = hi[0]
- hi_d += json.dumps(hi[0]) + ', '
- else:
- hi_d = re.sub(', $', '', hi_d)
- if(hi_d == ''):
- return(redirect('/w/' + url_pas(name)))
-
- json_f = '{ "title" : ' + json.dumps(name) + ', "data" : ' + json.dumps(da) + ', "history" : [' + hi_d + '] }'
- return(json_f)
- else:
- return(redirect('/error/3'))
- @route('/json_in', method=['POST', 'GET'])
- def json_in():
- if(admin_check(None) == 1):
- if(request.method == 'POST'):
- data = json.loads(request.forms.data)
- title = data["title"]
- curs.execute('select title from history where title = ?', [title])
- get_d = curs.fetchall()
- if(get_d):
- return(redirect('/w/' + url_pas(title)))
- curs.execute('insert into data (title, data, acl) values (?, ?, "")', [title, data["data"]])
- i = 0
- date = get_time()
- for hi in data["history"]:
- i += 1
- curs.execute('insert into history (id, title, data, date, ip, send, leng) values (?, ?, "", ?, ?, "", "0")', [i, title, date, hi])
- conn.commit()
- return(redirect('/w/' + url_pas(title)))
- else:
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๋ฌธ์ JSON ์
๋ ฅ',
- logo = wiki_set(1),
- data = '<form method="post"> \
- <textarea style="height: 80%;" name="data"></textarea> \
- <br> \
- <br> \
- <button class="btn btn-primary" type="submit">์
๋ ฅ</button> \
- </form>'
- )
- )
- else:
- return(redirect('/error/3'))
-
- @route('/title_index')
- def title_index():
- i = [0, 0, 0, 0, 0, 0]
- data = ''
- curs.execute("select title from data order by title asc")
- title_list = curs.fetchall()
- for list_data in title_list:
- data += '<li>' + str(i[0] + 1) + '. <a href="/w/' + url_pas(list_data[0]) + '">' + list_data[0] + '</a></li>'
- if(re.search('^๋ถ๋ฅ:', list_data[0])):
- i[1] += 1
- elif(re.search('^์ฌ์ฉ์:', list_data[0])):
- i[2] += 1
- elif(re.search('^ํ:', list_data[0])):
- i[3] += 1
- elif(re.search('^ํ์ผ:', list_data[0])):
- i[4] += 1
- else:
- i[5] += 1
-
- i[0] += 1
- if(title_list):
- data += '<br> \
- <li>์ด ์ํค์๋ ์ด ' + str(i[0]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li> \
- <br> \
- <li>ํ ๋ฌธ์๋ ์ด ' + str(i[3]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li> \
- <li>๋ถ๋ฅ ๋ฌธ์๋ ์ด ' + str(i[1]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li> \
- <li>์ฌ์ฉ์ ๋ฌธ์๋ ์ด ' + str(i[2]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li> \
- <li>ํ์ผ ๋ฌธ์๋ ์ด ' + str(i[4]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li> \
- <li>๋๋จธ์ง ๋ฌธ์๋ ์ด ' + str(i[5]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li>'
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = data,
- title = '๋ชจ๋ ๋ฌธ์'
- )
- )
-
- @route('/topic/<name:path>/sub/<sub:path>/b/<num:int>')
- def topic_block(name = None, sub = None, num = None):
- if(admin_check(3) == 1):
- curs.execute("select block from topic where title = ? and sub = ? and id = ?", [name, sub, str(num)])
- block = curs.fetchall()
- if(block):
- if(block[0][0] == 'O'):
- curs.execute("update topic set block = '' where title = ? and sub = ? and id = ?", [name, sub, str(num)])
- else:
- curs.execute("update topic set block = 'O' where title = ? and sub = ? and id = ?", [name, sub, str(num)])
- conn.commit()
-
- rd_plus(
- name,
- sub,
- get_time()
- )
-
- return(redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub)))
- else:
- return(redirect('/error/3'))
-
- @route('/topic/<name:path>/sub/<sub:path>/notice/<num:int>')
- def topic_top(name = None, sub = None, num = None):
- if(admin_check(3) == 1):
- curs.execute("select * from topic where title = ? and sub = ? and id = ?", [name, sub, str(num)])
- topic_data = curs.fetchall()
- if(topic_data):
- curs.execute("select top from topic where id = ? and title = ? and sub = ?", [str(num), name, sub])
- top_data = curs.fetchall()
- if(top_data):
- if(top_data[0][0] == 'O'):
- curs.execute("update topic set top = '' where title = ? and sub = ? and id = ?", [name, sub, str(num)])
- else:
- curs.execute("update topic set top = 'O' where title = ? and sub = ? and id = ?", [name, sub, str(num)])
- conn.commit()
-
- rd_plus(
- name,
- sub,
- get_time()
- )
- return(redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub)))
- else:
- return(redirect('/error/3'))
- @route('/topic/<name:path>/sub/<sub:path>/tool/agree')
- def topic_agree(name = None, sub = None):
- if(admin_check(3) == 1):
- ip = ip_check()
-
- curs.execute("select id from topic where title = ? and sub = ? order by id + 0 desc limit 1", [name, sub])
- topic_check = curs.fetchall()
- if(topic_check):
- time = get_time()
-
- curs.execute("select title from agreedis where title = ? and sub = ?", [name, sub])
- agree = curs.fetchall()
- if(agree):
- 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])
- curs.execute("delete from agreedis where title = ? and sub = ?", [name, sub])
- else:
- 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])
- curs.execute("insert into agreedis (title, sub) values (?, ?)", [name, sub])
- conn.commit()
-
- rd_plus(
- name,
- sub,
- time
- )
-
- return(redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub)))
- else:
-
- return(redirect('/error/3'))
-
- @route('/topic/<name:path>/sub/<sub:path>/tool/<tool:path>')
- def topic_stop(name = None, sub = None, tool = None):
- if(tool == 'close'):
- close = 'O'
- n_close = ''
- data = 'ํ ๋ก ๋ซ์'
- n_data = 'ํ ๋ก ๋ค์ ์ด๊ธฐ'
- elif(tool == 'stop'):
- close = ''
- n_close = 'O'
- data = 'ํ ๋ก ์ ์ง'
- n_data = 'ํ ๋ก ์ฌ ์์'
- else:
- return(redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub)))
- if(admin_check(3) == 1):
- ip = ip_check()
-
- curs.execute("select id from topic where title = ? and sub = ? order by id + 0 desc limit 1", [name, sub])
- topic_check = curs.fetchall()
- if(topic_check):
- time = get_time()
-
- curs.execute("select title from stop where title = ? and sub = ? and close = ?", [name, sub, close])
- stop = curs.fetchall()
- if(stop):
- 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])
- curs.execute("delete from stop where title = ? and sub = ? and close = ?", [name, sub, close])
- else:
- 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])
- curs.execute("insert into stop (title, sub, close) values (?, ?, ?)", [name, sub, close])
- curs.execute("delete from stop where title = ? and sub = ? and close = ?", [name, sub, n_close])
-
- conn.commit()
-
- rd_plus(
- name,
- sub,
- time
- )
-
- return(redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub)))
- else:
-
- return(redirect('/error/3'))
- @route('/topic/<name:path>/sub/<sub:path>', method=['POST', 'GET'])
- def topic(name = None, sub = None):
- ip = ip_check()
- ban = topic_check(ip, name, sub)
- admin = admin_check(3)
-
- if(request.method == 'POST'):
- curs.execute("select id from topic where title = ? and sub = ? order by id + 0 desc limit 1", [name, sub])
- rows = curs.fetchall()
- if(rows):
- num = int(rows[0][0]) + 1
- else:
- num = 1
-
- if(ban == 1 and admin != 1):
- return(redirect('/ban'))
- else:
- today = get_time()
- rd_plus(
- name,
- sub,
- today
- )
-
- aa = re.sub("\[\[(๋ถ๋ฅ:(?:(?:(?!\]\]).)*))\]\]", "[br]", request.forms.content)
- aa = savemark(aa)
-
- curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '')", [str(num), name, sub, aa, today, ip])
- conn.commit()
-
- return(redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub)))
- else:
- style = ''
- div = ''
- curs.execute("select title from stop where title = ? and sub = ? and close = 'O'", [name, sub])
- close = curs.fetchall()
- curs.execute("select title from stop where title = ? and sub = ? and close = ''", [name, sub])
- stop = curs.fetchall()
-
- if(admin == 1):
- if(close):
- div += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/close">(ํ ๋ก ์ด๊ธฐ)</a> '
- else:
- div += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/close">(ํ ๋ก ๋ซ๊ธฐ)</a> '
-
- if(stop):
- div += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/stop">(ํ ๋ก ์ฌ๊ฐ)</a> '
- else:
- div += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/stop">(ํ ๋ก ์ ์ง)</a> '
- curs.execute("select title from agreedis where title = ? and sub = ?", [name, sub])
- agree = curs.fetchall()
- if(agree):
- div += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/agree">(ํฉ์ ์ทจ์)</a>'
- else:
- div += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/agree">(ํฉ์ ์๋ฃ)</a>'
-
- div += '<br><br>'
-
- if((stop or close) and admin != 1):
- style = 'display:none;'
-
- curs.execute("select data, id, date, ip, block, top from topic where title = ? and sub = ? order by id + 0 asc", [name, sub])
- toda = curs.fetchall()
- curs.execute("select data, id, date, ip from topic where title = ? and sub = ? and top = 'O' order by id + 0 asc", [name, sub])
- top = curs.fetchall()
- for dain in top:
- top_data = namumark('', dain[0], 0, 0)
- top_data = re.sub("(?P<in>#(?:[0-9]*))", '<a href="\g<in>">\g<in></a>', top_data)
-
- ip = ip_pas(dain[3], 1)
-
- div += '<table id="toron"> \
- <tbody> \
- <tr> \
- <td id="toron_color_red"> \
- <a href="#' + dain[1] + '">#' + dain[1] + '</a> ' + ip + ' <span style="float:right;">' + dain[2] + '</span> \
- </td> \
- </tr> \
- <tr> \
- <td>' + top_data + '</td> \
- </tr> \
- </tbody> \
- </table> \
- <br>'
-
- i = 0
- for dain in toda:
- if(i == 0):
- start = dain[3]
-
- indata = namumark('', dain[0], 0, 0)
- indata = re.sub("(?P<in>#(?:[0-9]*))", '<a href="\g<in>">\g<in></a>', indata)
-
- if(dain[4] == 'O'):
- indata = '<br>'
- block = 'style="display: none;"'
- else:
- block = ''
- if(admin == 1):
- if(dain[4] == 'O'):
- isblock = ' <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/b/' + str(i + 1) + '">(ํด์ )</a>'
- else:
- isblock = ' <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/b/' + str(i + 1) + '">(๊ฐ๋ฆผ)</a>'
- curs.execute("select id from topic where title = ? and sub = ? and id = ? and top = 'O'", [name, sub, str(i + 1)])
- row = curs.fetchall()
- if(row):
- isblock = isblock + ' <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/notice/' + str(i + 1) + '">(ํด์ )</a>'
- else:
- isblock = isblock + ' <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/notice/' + str(i + 1) + '">(๊ณต์ง)</a>'
-
- curs.execute("select end from ban where block = ?", [dain[3]])
- ban_it = curs.fetchall()
- if(ban_it):
- ban = ' <a href="/ban/' + url_pas(dain[3]) + '">(ํด์ )</a>' + isblock
- else:
- ban = ' <a href="/ban/' + url_pas(dain[3]) + '">(์ฐจ๋จ)</a>' + isblock
- else:
- curs.execute("select end from ban where block = ?", [dain[3]])
- ban_it = curs.fetchall()
- if(ban_it):
- ban = ' <a href="javascript:void(0);" title="์ฐจ๋จ์">โ </a>'
- else:
- ban = ''
-
- chad = ''
- curs.execute('select acl from user where id = ?', [dain[3]])
- adch = curs.fetchall()
- if(adch and adch[0][0] != 'user'):
- chad = ' <a href="javascript:void(0);" title="๊ด๋ฆฌ์">โ
</a>'
- ip = ip_pas(dain[3], 1)
-
- if(dain[5] == '1'):
- color = '_blue'
- elif(dain[3] == start):
- color = '_green'
- else:
- color = ''
-
- div += '<table id="toron"> \
- <tbody> \
- <tr> \
- <td id="toron_color' + color + '"> \
- <a href="javascript:void(0);" id="' + str(i + 1) + '">#' + str(i + 1) + '</a> ' + ip + chad + ban + ' <span style="float:right;">' + dain[2] + '</span> \
- </td> \
- </tr> \
- <tr ' + block + '> \
- <td>' + indata + '</td> \
- </tr> \
- </tbody> \
- </table> \
- <br>'
-
- i += 1
-
- return(
- template('vstopic',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- page = url_pas(name),
- suburl = url_pas(sub),
- toron = sub,
- logo = wiki_set(1),
- rows = div,
- ban = ban,
- style = style,
- sub = 'ํ ๋ก '
- )
- )
-
- @route('/topic/<name:path>', method=['POST', 'GET'])
- @route('/topic/<name:path>/<tool:path>', method=['GET'])
- def close_topic_list(name = None, tool = None):
- div = ''
- i = 0
- list_d = 0
- if(request.method == 'POST'):
- t_num = ''
- while(1):
- curs.execute("select title from topic where title = ? and sub = ? limit 1", [name, request.forms.topic + t_num])
- t_data = curs.fetchall()
- if(t_data):
- if(t_num == ''):
- t_num = ' 2'
- else:
- t_num = ' ' + str(int(t_num.replace(' ', '')) + 1)
- else:
- break
- return(redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(request.forms.topic + t_num)))
- else:
- if(tool == 'close'):
- curs.execute("select sub from stop where title = ? and close = 'O' order by sub asc", [name])
- sub = '๋ซํ'
- elif(tool == 'agree'):
- curs.execute("select sub from agreedis where title = ? order by sub asc", [name])
- sub = 'ํฉ์'
- else:
- list_d = 1
- curs.execute("select sub from rd where title = ? order by date desc", [name])
- sub = 'ํ ๋ก ๋ชฉ๋ก'
- rows = curs.fetchall()
- for data in rows:
- curs.execute("select data, date, ip, block from topic where title = ? and sub = ? and id = '1'", [name, data[0]])
- row = curs.fetchall()
- if(row):
- indata = namumark(name, row[0][0], 0, 0)
-
- if(row[0][3] == 'O'):
- indata = '<br>'
- block = 'id="block"'
- else:
- block = ''
- ip = ip_pas(row[0][2], 1)
-
- div += '<h2> \
- <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(data[0]) + '">' + str((i + 1)) + '. ' + data[0] + '</a> \
- </h2> \
- <table id="toron"> \
- <tbody> \
- <tr> \
- <td id="toron_color_green"> \
- <a href="javascript:void(0);" id="1">#1</a> ' + ip + ' <span style="float:right;">' + row[0][1] + '</span> \
- </td> \
- </tr> \
- <tr> \
- <td ' + block + '>' + indata + '</td> \
- </tr> \
- </tbody> \
- </table> \
- <br>'
-
- i += 1
-
- return(
- template('topic',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- page = url_pas(name),
- logo = wiki_set(1),
- plus = div,
- sub = sub,
- list = list_d
- )
- )
-
- @route('/login', method=['POST', 'GET'])
- def login():
- session = request.environ.get('beaker.session')
- ip = ip_check()
- ban = ban_check(ip)
-
- if(request.method == 'POST'):
- if(ban == 1):
- return(redirect('/ban'))
- curs.execute("select pw from user where id = ?", [request.forms.id])
- user = curs.fetchall()
- if(user):
- if(session.get('Now') == 1):
- return(redirect('/error/11'))
- if(bcrypt.checkpw(bytes(request.forms.pw, 'utf-8'), bytes(user[0][0], 'utf-8'))):
- session['Now'] = 1
- session['DREAMER'] = request.forms.id
- curs.execute("select css from custom where user = ?", [request.forms.id])
- css_data = curs.fetchall()
- if(css_data):
- session['Daydream'] = css_data[0][0]
- else:
- session['Daydream'] = ''
-
- curs.execute("insert into login (user, ip, today) values (?, ?, ?)", [request.forms.id, ip, get_time()])
- conn.commit()
-
- return(redirect('/user'))
- else:
- return(redirect('/error/10'))
- else:
- return(redirect('/error/5'))
- else:
- if(ban == 1):
- return(redirect('/ban'))
- if(session.get('Now') == 1):
- return(redirect('/error/11'))
- return(
- template('login',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๋ก๊ทธ์ธ',
- enter = '๋ก๊ทธ์ธ',
- logo = wiki_set(1)
- )
- )
-
- @route('/change', method=['POST', 'GET'])
- def change_password():
- ip = ip_check()
- ban = ban_check(ip)
-
- if(request.method == 'POST'):
- if(request.forms.pw2 == request.forms.pw3):
- if(ban == 1):
- return(redirect('/ban'))
- curs.execute("select id from user where id = ?", [request.forms.id])
- user = curs.fetchall()
- if(user):
- if(not re.search('(\.|:)', ip)):
- return(redirect('/logout'))
- if(bcrypt.checkpw(bytes(request.forms.pw, 'utf-8'), bytes(user[0]['pw'], 'utf-8'))):
- hashed = bcrypt.hashpw(bytes(request.forms.pw2, 'utf-8'), bcrypt.gensalt())
-
- curs.execute("update user set pw = ? where id = ?", [hashed.decode(), request.forms.id])
- conn.commit()
-
- return(redirect('/login'))
- else:
- return(redirect('/error/10'))
- else:
- return(redirect('/error/5'))
- else:
- return(redirect('/error/20'))
- else:
- if(ban == 1):
- return(redirect('/ban'))
- if(not re.search('(\.|:)', ip)):
- return(redirect('/logout'))
-
- return(
- template('login',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๋น๋ฐ๋ฒํธ ๋ณ๊ฒฝ',
- enter = '๋ณ๊ฒฝ',
- logo = wiki_set(1)
- )
- )
-
- @route('/check/<name:path>')
- def user_check(name = None):
- curs.execute("select acl from user where id = ?", [name])
- user = curs.fetchall()
- if(user and user[0][0] != 'user'):
- return(redirect('/error/4'))
- if(admin_check(4) == 1):
- m = re.search('^(?:[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}?)$', name)
- if(m):
- sql = 'ip'
- else:
- sql = 'user'
- curs.execute("select user, ip, today from login where ? = ? order by today desc", [sql, name])
- row = curs.fetchall()
- if(row):
- c = '<div> \
- <table style="width: 100%; text-align: center;"> \
- <tbody> \
- <tr> \
- <td style="width: 33.3%;">์ด๋ฆ</td> \
- <td style="width: 33.3%;">์์ดํผ</td> \
- <td style="width: 33.3%;">์ธ์ </td> \
- </tr>'
- for data in row:
- c += '<tr> \
- <td>' + data[0] + '</td> \
- <td>' + data[1] + '</td> \
- <td>' + data[2] + '</td> \
- </tr>'
- else:
- c += '</tbody> \
- </table> \
- </div>'
- else:
- c = ''
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๋ค์ค ๊ฒ์ฌ',
- logo = wiki_set(1),
- data = c
- )
- )
- else:
- return(redirect('/error/3'))
-
- @route('/register', method=['POST', 'GET'])
- def register():
- ip = ip_check()
- ban = ban_check(ip)
- if(ban == 1):
- return(redirect('/ban'))
-
- if(request.method == 'POST'):
- if(request.forms.pw == request.forms.pw2):
- m = re.search('(?:[^A-Za-zใฑ-ํฃ0-9 ])', request.forms.id)
- if(m):
- return(redirect('/error/8'))
- if(len(request.forms.id) > 20):
- return(redirect('/error/7'))
- curs.execute("select id from user where id = ?", [request.forms.id])
- rows = curs.fetchall()
- if(rows):
- return(redirect('/error/6'))
- hashed = bcrypt.hashpw(bytes(request.forms.pw, 'utf-8'), bcrypt.gensalt())
-
- curs.execute("select id from user limit 1")
- user_ex = curs.fetchall()
- if(not user_ex):
- curs.execute("insert into user (id, pw, acl) values (?, ?, 'owner')", [request.forms.id, hashed.decode()])
- else:
- curs.execute("insert into user (id, pw, acl) values (?, ?, 'user')", [request.forms.id, hashed.decode()])
- conn.commit()
-
- return(redirect('/login'))
- else:
- return(redirect('/error/20'))
- else:
- return(
- template('login',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = 'ํ์๊ฐ์
',
- enter = 'ํ์๊ฐ์
',
- logo = wiki_set(1)
- )
- )
-
- @route('/logout')
- def logout():
- session = request.environ.get('beaker.session')
- session['Now'] = 0
- session.pop('DREAMER', None)
- return(redirect('/user'))
-
- @route('/ban/<name:path>', method=['POST', 'GET'])
- def user_ban(name = None):
- curs.execute("select acl from user where id = ?", [name])
- user = curs.fetchall()
- if(user and user[0][0] != 'user'):
- return(redirect('/error/4'))
- if(request.method == 'POST'):
- if(admin_check(1) == 1):
- ip = ip_check()
-
- if(not re.search("[0-9]{4}-[0-9]{2}-[0-9]{2}", request.forms.end)):
- end = ''
- else:
- end = request.forms.end
- curs.execute("select block from ban where block = ?", [name])
- row = curs.fetchall()
- if(row):
- rb_plus(name, 'ํด์ ', get_time(), ip, '')
-
- curs.execute("delete from ban where block = ?", [name])
- else:
- b = re.search("^([0-9]{1,3}\.[0-9]{1,3})$", name)
- if(b):
- band_d = 'O'
- else:
- band_d = ''
- rb_plus(name, end, get_time(), ip, request.forms.why)
- curs.execute("insert into ban (block, end, why, band) values (?, ?, ?, ?)", [name, end, request.forms.why, band_d])
- conn.commit()
- return(redirect('/ban/' + url_pas(name)))
- else:
- return(redirect('/error/3'))
- else:
- if(admin_check(1) == 1):
- curs.execute("select * from ban where block = ?", [name])
- row = curs.fetchall()
- if(row):
- now = '์ฐจ๋จ ํด์ '
- else:
- b = re.search("^([0-9]{1,3}\.[0-9]{1,3})$", name)
- if(b):
- now = '๋์ญ ์ฐจ๋จ'
- else:
- now = '์ฐจ๋จ'
- return(
- template('ban',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- page = url_pas(name),
- logo = wiki_set(1),
- now = now,
- today = get_time(),
- sub = '์ฐจ๋จ'
- )
- )
- else:
- return(redirect('/error/3'))
-
- @route('/acl/<name:path>', method=['POST', 'GET'])
- def acl(name = None):
- if(request.method == 'POST'):
- if(admin_check(5) == 1):
- curs.execute("select acl from data where title = ?", [name])
- row = curs.fetchall()
- if(row):
- if(request.forms.select == 'admin'):
- curs.execute("update data set acl = 'admin' where title = ?", [name])
- elif(request.forms.select == 'user'):
- curs.execute("update data set acl = 'user' where title = ?", [name])
- else:
- curs.execute("update data set acl = '' where title = ?", [name])
-
- conn.commit()
-
- return(redirect('/w/' + url_pas(name)))
- else:
- return(redirect('/error/3'))
- else:
- if(admin_check(5) == 1):
- curs.execute("select acl from data where title = ?", [name])
- row = curs.fetchall()
- if(row):
- if(row[0][0] == 'admin'):
- now = '๊ด๋ฆฌ์๋ง'
- elif(row[0][0] == 'user'):
- now = '๋ก๊ทธ์ธ ์ด์'
- else:
- now = '์ผ๋ฐ'
-
- return(
- template('acl',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- page = url_pas(name),
- logo = wiki_set(1),
- now = 'ํ์ฌ ACL ์ํ๋ ' + now,
- sub = 'ACL'
- )
- )
- else:
- return(redirect('/w/' + url_pas(name)) )
- else:
- return(redirect('/error/3'))
-
- @route('/admin/<name:path>', method=['POST', 'GET'])
- def user_admin(name = None):
- if(request.method == 'POST'):
- if(admin_check(None) == 1):
- curs.execute("select acl from user where id = ?", [name])
- user = curs.fetchall()
- if(user):
- if(user[0][0] != 'user'):
- curs.execute("update user set acl = 'user' where id = ?", [name])
- else:
- curs.execute("update user set acl = ? where id = ?", [request.forms.select, name])
- conn.commit()
-
- return(redirect('/'))
- else:
- return(redirect('/error/5'))
- else:
- return(redirect('/error/3'))
- else:
- if(admin_check(None) == 1):
- curs.execute("select acl from user where id = ?", [name])
- user = curs.fetchall()
- if(user):
- if(user[0][0] != 'user'):
- now = '๊ถํ ํด์ '
- else:
- now = '๊ถํ ๋ถ์ฌ'
-
- div = ''
-
- curs.execute('select name from alist order by name asc')
- get_alist = curs.fetchall()
- if(get_alist):
- i = 0
- name_rem = ''
- for data in get_alist:
- if(name_rem != data[0]):
- name_rem = data[0]
- div += '<option value="' + data[0] + '" selected="selected">' + data[0] + '</option>'
-
- return(
- template('admin',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- page = url_pas(name),
- datalist = div,
- logo = wiki_set(1),
- now = now,
- sub = '๊ถํ ๋ถ์ฌ'
- )
- )
- else:
- return(redirect('/error/5'))
- else:
- return(redirect('/error/3'))
-
- @route('/ban')
- def are_you_ban():
- ip = ip_check()
-
- if(ban_check(ip) == 1):
- curs.execute("select end, why from ban where block = ?", [ip])
- rows = curs.fetchall()
- if(not rows):
- data = re.search("^([0-9](?:[0-9]?[0-9]?)\.[0-9](?:[0-9]?[0-9]?))", ip)
- if(data):
- results = data.groups()
- curs.execute("select end, why from ban where block = ? and band = 'O'", [results[0]])
- rows = curs.fetchall()
- if(rows):
- if(rows[0][0]):
- end = rows[0][0] + ' ๊น์ง ์ฐจ๋จ ์ํ ์
๋๋ค. / ์ฌ์ : ' + rows[0][1]
- now = re.sub(':', '', get_time())
- now = re.sub('\-', '', now)
- now = int(re.sub(' ', '', now))
-
- day = re.sub('\-', '', rows[0][0])
-
- if(now >= int(day + '000000')):
- curs.execute("delete from ban where block = ?", [ip])
- conn.commit()
-
- end = '์ฐจ๋จ์ด ํ๋ ธ์ต๋๋ค. ๋ค์ ์๋ ํด ๋ณด์ธ์.'
- else:
- end = '์๊ตฌ ์ฐจ๋จ ์ํ ์
๋๋ค. / ์ฌ์ : ' + rows[0][1]
- else:
- end = '๊ถํ์ด ๋ง์ง ์๋ ์ํ ์
๋๋ค.'
- else:
- end = '๊ถํ์ด ๋ง์ง ์๋ ์ํ ์
๋๋ค.'
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ถํ ์ค๋ฅ',
- logo = wiki_set(1),
- data = end
- )
- )
-
- @route('/w/<name:path>/r/<a:int>/diff/<b:int>')
- def diff_data(name = None, a = None, b = None):
- curs.execute("select data from history where id = ? and title = ?", [str(a), name])
- a_raw_data = curs.fetchall()
- if(a_raw_data):
- curs.execute("select data from history where id = ? and title = ?", [str(b), name])
- b_raw_data = curs.fetchall()
- if(b_raw_data):
- a_data = html.escape(a_raw_data[0][0])
- b_data = html.escape(b_raw_data[0][0])
-
- diff_data = difflib.SequenceMatcher(None, a_data, b_data)
- result = diff(diff_data)
-
- result = '<pre>' + result + '</pre>'
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- logo = wiki_set(1),
- data = result,
- sub = '๋น๊ต',
- page = url_pas(name)
- )
- )
- return(redirect('/history/' + url_pas(name)))
-
- @route('/down/<name:path>')
- def down(name = None):
- curs.execute("select title from data where title like ?", ['%' + name + '/%'])
- under = curs.fetchall()
-
- div = ''
- i = 0
- for data in under:
- div += '<li>' + str(i + 1) + '. <a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a></li>'
- i += 1
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- logo = wiki_set(1),
- data = div,
- sub = 'ํ์',
- page = url_pas(name)
- )
- )
- @route('/w/<name:path>')
- @route('/w/<name:path>/r/<num:int>')
- @route('/w/<name:path>/from/<redirect:path>')
- def read_view(name = None, num = None, redirect = None):
- data_none = 0
- sub = 0
- acl = ''
- div = ''
- topic = ''
-
- curs.execute("select sub from rd where title = ? order by date desc", [name])
- rows = curs.fetchall()
- for data in rows:
- curs.execute("select title from stop where title = ? and sub = ? and close = 'O'", [name, data[0]])
- row = curs.fetchall()
- if(not row):
- topic = "open"
-
- break
-
- curs.execute("select title from data where title like ?", ['%' + name + '/%'])
- under = curs.fetchall()
- if(under):
- down = 1
- else:
- down = 0
-
- m = re.search("^(.*)\/(.*)$", name)
- if(m):
- uppage = m.groups()[0]
- else:
- uppage = 0
-
- if(admin_check(5) == 1):
- admin_memu = 'ACL'
- else:
- admin_memu = ''
-
- if(re.search("^๋ถ๋ฅ:", name)):
- curs.execute("delete from cat where title = ? and cat = ''", [name])
- conn.commit()
-
- curs.execute("select cat from cat where title = ? order by cat asc", [name])
- rows = curs.fetchall()
- if(rows):
- div = '<h2>๋ถ๋ฅ</h2>'
- u_div = ''
- i = 0
-
- for data in rows:
- if(re.search('^๋ถ๋ฅ:', data[0])):
- if(u_div == ''):
- u_div = '<h3>ํ์ ๋ถ๋ฅ</h3>'
- u_div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a></li>'
- else:
- div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a></li>'
- div += u_div
- if(num):
- curs.execute("select title from hidhi where title = ? and re = ?", [name, str(num)])
- hid = curs.fetchall()
- if(hid and admin_check(6) != 1):
- return(redirect('/history/' + url_pas(name)))
- curs.execute("select title, data from history where title = ? and id = ?", [name, str(num)])
- else:
- curs.execute("select acl, data from data where title = ?", [name])
- rows = curs.fetchall()
- if(rows):
- if(not num):
- if(rows[0][0] == 'admin'):
- acl = '(๊ด๋ฆฌ์)'
- elif(rows[0][0] == 'user'):
- acl = '(๋ก๊ทธ์ธ)'
-
- elsedata = rows[0][1]
- else:
- data_none = 1
- elsedata = ''
- m = re.search("^์ฌ์ฉ์:([^/]*)", name)
- if(m):
- g = m.groups()
-
- curs.execute("select acl from user where id = ?", [g[0]])
- test = curs.fetchall()
- if(test and test[0][0] != 'user'):
- acl = '(๊ด๋ฆฌ์)'
- curs.execute("select block from ban where block = ?", [g[0]])
- user = curs.fetchall()
- if(user):
- sub = '์ฐจ๋จ'
-
- if(redirect):
- elsedata = re.sub("^#(?:redirect|๋๊ฒจ์ฃผ๊ธฐ)\s(?P<in>[^\n]*)", " * [[\g<in>]] ๋ฌธ์๋ก ๋๊ฒจ์ฃผ๊ธฐ", elsedata)
-
- enddata = namumark(name, elsedata, 1, 0)
-
- return(
- template('read',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = name,
- logo = wiki_set(1),
- page = url_pas(name),
- data = enddata + div,
- uppage = uppage,
- acl = acl,
- topic = topic,
- redirect = redirect,
- admin = admin_memu,
- data_none = data_none,
- sub = sub,
- down = down
- )
- )
- @route('/user/<name:path>/topic')
- @route('/user/<name:path>/topic/<num:int>')
- def user_topic_list(name = None, num = 1):
- if(num * 50 <= 0):
- v = 50
- else:
- v = num * 50
-
- i = v - 50
- ydmin = admin_check(1)
- div = '<table style="width: 100%; text-align: center;"> \
- <tbody> \
- <tr> \
- <td style="width: 33.3%;">ํ ๋ก ๋ช
</td> \
- <td style="width: 33.3%;">์์ฑ์</td> \
- <td style="width: 33.3%;">์๊ฐ</td> \
- </tr>'
-
- curs.execute("select title, id, sub, ip, date from topic where ip = ? order by date desc limit ?, ?", [name, str(i), str(v)])
- rows = curs.fetchall()
- if(rows):
- for data in rows:
- title = html.escape(data[0])
- sub = html.escape(data[2])
-
- if(ydmin == 1):
- curs.execute("select * from ban where block = ?", [data[3]])
- row = curs.fetchall()
- if(row):
- ban = ' <a href="/ban/' + url_pas(data[3]) + '">(ํด์ )</a>'
- else:
- ban = ' <a href="/ban/' + url_pas(data[3]) + '">(์ฐจ๋จ)</a>'
- else:
- ban = ''
-
- ip = ip_pas(data[3], 1)
-
- div += '<tr> \
- <td> \
- <a href="/topic/' + url_pas(data[0]) + '/sub/' + url_pas(data[2]) + '#' + data[1] + '">' + title + '#' + data[1] + '</a> (' + sub + ') \
- </td> \
- <td>' + ip + ban + '</td> \
- <td>' + data[4] + '</td> \
- </tr>'
- else:
- div += '</tbody> \
- </table>'
- else:
- div = ''
-
- div += '<br> \
- <a href="/user/' + url_pas(name) + '/topic/' + str(num - 1) + '">(์ด์ )</a> <a href="/user/' + url_pas(name) + '/topic/' + str(num + 1) + '">(์ดํ)</a>'
-
- curs.execute("select end, why from ban where block = ?", [name])
- ban_it = curs.fetchall()
- if(ban_it):
- sub = '์ฐจ๋จ'
- else:
- sub = None
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- logo = wiki_set(1),
- data = div,
- title = '์ฌ์ฉ์ ํ ๋ก ๊ธฐ๋ก',
- sub = sub
- )
- )
-
- @route('/user')
- def user_info():
- ip = ip_check()
- raw_ip = ip
-
- curs.execute("select acl from user where id = ?", [ip])
- rows = curs.fetchall()
- if(ban_check(ip) == 0):
- if(rows):
- if(rows[0][0] != 'user'):
- acl = rows[0][0]
- else:
- acl = '๋ก๊ทธ์ธ'
- else:
- acl = '์ผ๋ฐ'
- else:
- acl = '์ฐจ๋จ'
-
- ip = ip_pas(ip, 2)
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '์ฌ์ฉ์ ๋ฉ๋ด',
- logo = wiki_set(1),
- data = ip + \
- '<br> \
- <br> \
- <span>๊ถํ ์ํ : ' + acl + '</span> \
- <h2>๋ก๊ทธ์ธ ๊ด๋ จ</h2> \
- <li><a href="/login">๋ก๊ทธ์ธ</a></li> \
- <li><a href="/logout">๋ก๊ทธ์์</a></li> \
- <li><a href="/register">ํ์๊ฐ์
</a></li> \
- <h2>๊ธฐํ</h2> \
- <li><a href="/change">๋น๋ฐ๋ฒํธ ๋ณ๊ฒฝ</a></li> \
- <li><a href="/count">๊ธฐ์ฌ ํ์</a></li> \
- <li><a href="/custom_css">์ปค์คํ
CSS</a></li> \
- <li><a href="/custom_js">์ปค์คํ
JS</a></li>'
- )
- )
- @route('/custom_css', method=['GET', 'POST'])
- def custom_css_view():
- session = request.environ.get('beaker.session')
- ip = ip_check()
- if(request.method == 'POST'):
- if(not re.search('(\.|:)', ip)):
- curs.execute("select * from custom where user = ?", [ip])
- css_data = curs.fetchall()
- if(css_data):
- curs.execute("update custom set css = ? where user = ?", [request.forms.content, ip])
- else:
- curs.execute("insert into custom (user, css) values (?, ?)", [ip, request.forms.content])
- conn.commit()
- session['Daydream'] = request.forms.content
- return(redirect('/user'))
- else:
- if(not re.search('(\.|:)', ip)):
- start = ''
- curs.execute("select css from custom where user = ?", [ip])
- css_data = curs.fetchall()
- if(css_data):
- data = css_data[0][0]
- else:
- data = ''
- else:
- start = '<span>๋น ๋ก๊ทธ์ธ์ ๊ฒฝ์ฐ์๋ ๋ก๊ทธ์ธํ๋ฉด ๋ ์๊ฐ๋๋ค.</span><br><br>'
- try:
- data = session['Daydream']
- except:
- data = ''
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '์ปค์คํ
CSS',
- logo = wiki_set(1),
- data = start + \
- '<form method="post"> \
- <textarea rows="30" cols="100" name="content">'\
- + data + \
- '</textarea> \
- <br> \
- <br> \
- <div class="form-actions"> \
- <button class="btn btn-primary" type="submit">์ ์ฅ</button> \
- </div> \
- </form>'
- )
- )
- @route('/custom_js', method=['GET', 'POST'])
- def custom_js_view():
- session = request.environ.get('beaker.session')
- ip = ip_check()
- if(request.method == 'POST'):
- if(not re.search('(\.|:)', ip)):
- curs.execute("select * from custom where user = ?", [ip + ' (js)'])
- js_data = curs.fetchall()
- if(js_data):
- curs.execute("update custom set css = ? where user = ?", [request.forms.content, ip + ' (js)'])
- else:
- curs.execute("insert into custom (user, css) values (?, ?)", [ip + ' (js)', request.forms.content])
- conn.commit()
- session['AQUARIUM'] = request.forms.content
- return(redirect('/user'))
- else:
- if(not re.search('(\.|:)', ip)):
- start = ''
- curs.execute("select css from custom where user = ?", [ip + ' (js)'])
- js_data = curs.fetchall()
- if(js_data):
- data = js_data[0][0]
- else:
- data = ''
- else:
- start = '<span>๋น ๋ก๊ทธ์ธ์ ๊ฒฝ์ฐ์๋ ๋ก๊ทธ์ธํ๋ฉด ๋ ์๊ฐ๋๋ค.</span><br><br>'
- try:
- data = session['AQUARIUM']
- except:
- data = ''
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '์ปค์คํ
JS',
- logo = wiki_set(1),
- data = start + \
- '<form method="post"> \
- <textarea rows="30" cols="100" name="content">'\
- + data + \
- '</textarea> \
- <br> \
- <br> \
- <div class="form-actions"> \
- <button class="btn btn-primary" type="submit">์ ์ฅ</button> \
- </div> \
- </form>'
- )
- )
- @route('/count')
- @route('/count/<name:path>')
- def count_edit(name = None):
- if(name == None):
- that = ip_check()
- else:
- that = name
- curs.execute("select count(title) from history where ip = ?", [that])
- count = curs.fetchall()
- if(count):
- data = count[0][0]
- else:
- data = 0
- curs.execute("select count(title) from topic where ip = ?", [that])
- count = curs.fetchall()
- if(count):
- t_data = count[0][0]
- else:
- t_data = 0
-
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ธฐ์ฌ ํ์',
- logo = wiki_set(1),
- data = namumark("", "||<-2><:> " + that + " ||\r\n||<:> ๊ธฐ์ฌ ํ์ ||<:> " + str(data) + "||\r\n||<:> ํ ๋ก ํ์ ||<:> " + str(t_data) + "||", 0, 1)
- )
- )
-
- @route('/random')
- def random():
- curs.execute("select title from data order by random() limit 1")
- rows = curs.fetchall()
- if(rows):
- return(redirect('/w/' + url_pas(rows[0][0])))
- else:
- return(redirect('/'))
-
- @route('/views/<name:path>')
- def views(name = None):
- if(re.search('\/', name)):
- m = re.search('^(.*)\/(.*)$', name)
- if(m):
- n = m.groups()
- plus = '/' + n[0]
- rename = n[1]
- else:
- plus = ''
- rename = name
- else:
- plus = ''
- rename = name
-
- return(
- static_file(rename,
- root = './views' + plus
- )
- )
-
- @route('/error/<num:int>')
- def error_test(num = None):
- if(num == 1):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ถํ ์ค๋ฅ',
- logo = wiki_set(1),
- data = '๋น ๋ก๊ทธ์ธ ์ํ ์
๋๋ค.'
- )
- )
- elif(num == 2):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ถํ ์ค๋ฅ',
- logo = wiki_set(1),
- data = '์ด ๊ณ์ ์ด ์์ต๋๋ค.'
- )
- )
- elif(num == 3):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ถํ ์ค๋ฅ',
- logo = wiki_set(1),
- data = '๊ถํ์ด ๋ชจ์๋๋๋ค.'
- )
- )
- elif(num == 4):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ถํ ์ค๋ฅ',
- logo = wiki_set(1),
- data = '๊ด๋ฆฌ์๋ ์ฐจ๋จ, ๊ฒ์ฌ ํ ์ ์์ต๋๋ค.'
- )
- )
- elif(num == 5):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '์ฌ์ฉ์ ์ค๋ฅ',
- logo = wiki_set(1),
- data = '๊ทธ๋ฐ ๊ณ์ ์ด ์์ต๋๋ค.'
- )
- )
- elif(num == 6):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ฐ์
์ค๋ฅ',
- logo = wiki_set(1),
- data = '๋์ผํ ์์ด๋์ ์ฌ์ฉ์๊ฐ ์์ต๋๋ค.'
- )
- )
- elif(num == 7):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ฐ์
์ค๋ฅ',
- logo = wiki_set(1),
- data = '์์ด๋๋ 20๊ธ์๋ณด๋ค ์งง์์ผ ํฉ๋๋ค.'
- )
- )
- elif(num == 8):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๊ฐ์
์ค๋ฅ',
- logo = wiki_set(1),
- data = '์์ด๋์๋ ํ๊ธ๊ณผ ์ํ๋ฒณ๊ณผ ๊ณต๋ฐฑ๋ง ํ์ฉ ๋ฉ๋๋ค.'
- )
- )
- elif(num == 10):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๋ณ๊ฒฝ ์ค๋ฅ',
- logo = wiki_set(1),
- data = '๋น๋ฐ๋ฒํธ๊ฐ ๋ค๋ฆ
๋๋ค.'
- )
- )
- elif(num == 11):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๋ก๊ทธ์ธ ์ค๋ฅ',
- logo = wiki_set(1),
- data = '์ด๋ฏธ ๋ก๊ทธ์ธ ๋์ด ์์ต๋๋ค.'
- )
- )
- elif(num == 14):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '์
๋ก๋ ์ค๋ฅ',
- logo = wiki_set(1),
- data = 'jpg, gif, jpeg, png๋ง ๊ฐ๋ฅ ํฉ๋๋ค.'
- )
- )
- elif(num == 15):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = 'ํธ์ง ์ค๋ฅ',
- logo = wiki_set(1),
- data = 'ํธ์ง ๊ธฐ๋ก์ 500์๋ฅผ ๋์ ์ ์์ต๋๋ค.'
- )
- )
- elif(num == 16):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '์
๋ก๋ ์ค๋ฅ',
- logo = wiki_set(1),
- data = '๋์ผํ ์ด๋ฆ์ ํ์ผ์ด ์์ต๋๋ค.'
- )
- )
- elif(num == 17):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '์
๋ก๋ ์ค๋ฅ',
- logo = wiki_set(1),
- data = 'ํ์ผ ์ฉ๋์ ' + wiki_set(4) + 'MB๋ฅผ ๋๊ธธ ์ ์์ต๋๋ค.'
- )
- )
- elif(num == 18):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = 'ํธ์ง ์ค๋ฅ',
- logo = wiki_set(1),
- data = '๋ด์ฉ์ด ์๋ ๋ฌธ์์ ๋์ผ ํฉ๋๋ค.'
- )
- )
- elif(num == 19):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '์ด๋ ์ค๋ฅ',
- logo = wiki_set(1),
- data = '์ด๋ ํ๋ ค๋ ๊ณณ์ ๋ฌธ์๊ฐ ์ด๋ฏธ ์์ต๋๋ค.'
- )
- )
- elif(num == 20):
- return(
- template('other',
- custom_css = custom_css(),
- custom_js = custom_js(),
- license = wiki_set(3),
- login = login_check(),
- title = '๋น๋ฐ๋ฒํธ ์ค๋ฅ',
- logo = wiki_set(1),
- data = '์ฌ ํ์ธ์ด๋ ๋น๋ฐ๋ฒํธ๊ฐ ๋ค๋ฆ
๋๋ค.'
- )
- )
- else:
- return(redirect('/'))
- @error(404)
- def error_404(error):
- return(redirect('/w/' + url_pas(wiki_set(2))))
-
- run(
- app = app,
- server = 'tornado',
- host = '0.0.0.0',
- port = int(set_data['port'])
- )
|