| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602 |
- ๏ปฟfrom flask import Flask, request, send_from_directory
- from flask_reggie import Reggie
- from tornado.wsgi import WSGIContainer
- from tornado.httpserver import HTTPServer
- from tornado.ioloop import IOLoop
- import bcrypt
- import difflib
- import shutil
- import threading
- import logging
- import random
- import sys
- logging.basicConfig(level = logging.ERROR)
- app = Flask(__name__)
- Reggie(app)
- r_ver = 'v2.6.5 Beta'
- print('Version : ' + r_ver)
- from func import *
- from set_mark.mid_pas import mid_pas
- from set_mark.macro import savemark
- # set.json ์ค์ ํ์ธ
- try:
- json_data = open('set.json').read()
- set_data = json.loads(json_data)
- except:
- while 1:
- print('DB Name : ', end = '')
- new_json = str(input())
- if new_json != '':
- with open("set.json", "w") as f:
- f.write('{ "db" : "' + new_json + '" }')
-
- json_data = open('set.json').read()
- set_data = json.loads(json_data)
- break
- else:
- print('Insert Values')
-
- pass
- # ๋๋น ์ฐ๊ฒฐ
- conn = sqlite3.connect(set_data['db'] + '.db', check_same_thread = False)
- curs = conn.cursor()
- # ์คํจ ๋ถ๋ฌ์ค๊ธฐ ๋ถ๋ถ
- skin_check(conn)
- # ์
์
๋ถ๋ถ
- curs.execute("create table if not exists data(title text, data text)")
- curs.execute("create table if not exists history(id text, title text, data text, date text, ip text, send text, leng text, hide text)")
- curs.execute("create table if not exists rd(title text, sub text, date text)")
- curs.execute("create table if not exists user(id text, pw text, acl text, date text)")
- curs.execute("create table if not exists ban(block text, end text, why text, band text)")
- curs.execute("create table if not exists topic(id text, title text, sub text, data text, date text, ip text, block text, top text)")
- curs.execute("create table if not exists stop(title text, sub text, close text)")
- curs.execute("create table if not exists rb(block text, end text, today text, blocker text, why text)")
- curs.execute("create table if not exists back(title text, link text, type text)")
- curs.execute("create table if not exists agreedis(title text, sub text)")
- curs.execute("create table if not exists custom(user text, css text)")
- curs.execute("create table if not exists other(name text, data text)")
- curs.execute("create table if not exists alist(name text, acl text)")
- curs.execute("create table if not exists re_admin(who text, what text, time text)")
- curs.execute("create table if not exists alarm(name text, data text, date text)")
- curs.execute("create table if not exists ua_d(name text, ip text, ua text, today text, sub text)")
- curs.execute("create table if not exists filter(name text, regex text, sub text)")
- curs.execute("create table if not exists scan(user text, title text)")
- curs.execute("create table if not exists acl(title text, dec text, dis text, why text)")
- curs.execute("create table if not exists inter(title text, link text)")
- curs.execute("select name from alist where acl = 'owner'")
- if not curs.fetchall():
- curs.execute("delete from alist where name = 'owner'")
- curs.execute("insert into alist (name, acl) values ('owner', 'owner')")
- curs.execute("select data from other where name = 'port'")
- rep_data = curs.fetchall()
- if not rep_data:
- while 1:
- print('Port : ', end = '')
- rep_port = int(input())
- if rep_port:
- curs.execute("insert into other (name, data) values ('port', ?)", [rep_port])
-
- break
- else:
- pass
- else:
- rep_port = rep_data[0][0]
- print('Port : ' + str(rep_port))
- curs.execute("select data from other where name = 'key'")
- rep_data = curs.fetchall()
- if not rep_data:
- while 1:
- print('Secret Key : ', end = '')
- rep_key = str(input())
- if rep_key:
- curs.execute("insert into other (name, data) values ('key', ?)", [rep_key])
-
- break
- else:
- pass
- else:
- rep_key = rep_data[0][0]
- print('Secret Key : ' + rep_key)
- print('')
- # ํธํ์ฑ ์ค์
- curs.execute("drop table if exists move")
- try:
- curs.execute("alter table history add hide text default ''")
-
- curs.execute('select title, re from hidhi')
- for rep in curs.fetchall():
- curs.execute("update history set hide = 'O' where title = ? and id = ?", [rep[0], rep[1]])
- curs.execute("drop table if exists hidhi")
- except:
- pass
- try:
- curs.execute("alter table user add date text default ''")
- except:
- pass
- try:
- curs.execute("alter table rb add band text default ''")
- except:
- pass
- try:
- curs.execute("alter table ban add login text default ''")
- except:
- pass
- try:
- curs.execute("select title, acl from data where acl != ''")
- for rep in curs.fetchall():
- curs.execute("insert into acl (title, dec, dis, why) values (?, ?, '', '')", [rep[0], rep[1]])
- curs.execute("alter table data drop acl")
- except:
- pass
- try:
- curs.execute("select data from other where name = 'robot'")
- robot_test = curs.fetchall()
- if robot_test:
- fw_test = open('./robots.txt', 'w')
- fw_test.write(re.sub('\r\n', '\n', robot_test[0][0]))
- fw_test.close()
- except:
- pass
- try:
- curs.execute("alter table user add email text default ''")
- except:
- pass
- conn.commit()
- # ์ด๋ฏธ์ง ํด๋ ์์ฑ
- if not os.path.exists('image'):
- os.makedirs('image')
-
- # ์คํจ ํด๋ ์์ฑ
- if not os.path.exists('views'):
- os.makedirs('views')
- # ๋ฐฑ์
์ค์
- def back_up():
- try:
- shutil.copyfile(set_data['db'] + '.db', 'back_' + set_data['db'] + '.db')
- print('Back Up Ok')
- except:
- print('Back Up Error')
- threading.Timer(60 * 60 * back_time, back_up).start()
- try:
- curs.execute('select data from other where name = "back_up"')
- back_up_time = curs.fetchall()
- back_time = int(back_up_time[0][0])
- except:
- back_time = 0
-
- # ๋ฐฑ์
์ฌ๋ถ ํ์ธ
- if back_time != 0:
- print(str(back_time) + ' Hours Back Up')
- if __name__ == '__main__':
- back_up()
- else:
- print('No Back Up')
- @app.route('/del_alarm')
- def del_alarm():
- curs.execute("delete from alarm where name = ?", [ip_check()])
- conn.commit()
- return redirect('/alarm')
- @app.route('/alarm')
- def alarm():
- ip = ip_check()
- if custom(conn)[2] == 0:
- return redirect('/login')
- da = '<ul>'
- curs.execute("select data, date from alarm where name = ? order by date desc", [ip])
- dt = curs.fetchall()
- if dt:
- da = '<a href="/del_alarm">(๋ชจ๋ ์ญ์ )</a><hr>' + da
- for do in dt:
- da += '<li>' + do[0] + ' / ' + do[1] + '</li>'
- else:
- da += '<li>์๋ฆผ์ด ์์ต๋๋ค.</li>'
- da += '</ul>'
- return html_minify(template('index',
- imp = ['์๋ฆผ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = da,
- menu = [['user', '์ฌ์ฉ์']]
- ))
- @app.route('/inter_wiki')
- def inter_wiki():
- div = ''
- admin = admin_check(conn, None, None)
- curs.execute('select title, link from inter')
- db_data = curs.fetchall()
- if db_data:
- div = '<ul>'
- for data in db_data:
- div += '<li>' + data[0] + ' : ' + data[1]
- if admin == 1:
- div += ' <a href="/del_inter/' + url_pas(data[0]) + '">(์ญ์ )</a>'
- div += '</li>'
- div += '</ul>'
- if admin == 1:
- div += '<hr><a href="/plus_inter">(์ถ๊ฐ)</a>'
- else:
- if admin == 1:
- div += '<a href="/plus_inter">(์ถ๊ฐ)</a>'
- return html_minify(template('index',
- imp = ['์ธํฐ์ํค ๋ชฉ๋ก', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = div,
- menu = [['other', '๊ธฐํ']]
- ))
- @app.route('/del_inter/<name>')
- def del_inter(name = None):
- if admin_check(conn, None, None) == 1:
- curs.execute("delete from inter where title = ?", [name])
- conn.commit()
- return redirect('/inter_wiki')
- else:
- return re_error(conn, '/error/3')
- @app.route('/plus_inter', methods=['POST', 'GET'])
- def plus_inter():
- if request.method == 'POST':
- curs.execute('insert into inter (title, link) values (?, ?)', [request.form['title'], request.form['link']])
- conn.commit()
- admin_check(conn, None, 'inter_wiki_plus')
-
- return redirect('/inter_wiki')
- else:
- return html_minify(template('index',
- imp = ['์ธํฐ์ํค ๋ชฉ๋ก', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post"> \
- <input placeholder="์ด๋ฆ" type="text" name="title"><hr> \
- <input placeholder="๋งํฌ" type="text" name="link"><hr> \
- <button type="submit">์ถ๊ฐ</button> \
- </form>',
- menu = [['other', '๊ธฐํ']]
- ))
- @app.route('/edit_set')
- @app.route('/edit_set/<int:num>', methods=['POST', 'GET'])
- def edit_set(num = 0):
- if num != 0 and admin_check(conn, None, None) != 1:
- return re_error(conn, '/ban')
- if num == 0:
- li_list = ['๊ธฐ๋ณธ ์ค์ ', '๋ฌธ๊ตฌ ๊ด๋ จ', '์ ์ญ HEAD', 'robots.txt', '๊ตฌ๊ธ ๊ด๋ จ']
- x = 0
- li_data = ''
- for li in li_list:
- x += 1
- li_data += ' * [[wiki:edit_set/' + str(x) + '|' + li + ']]\r\n'
- return html_minify(template('index',
- imp = ['์ค์ ํธ์ง', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = namumark(conn, '', '[๋ชฉ์ฐจ(์์)]\r\n' + \
- '== ๋ฉ๋ด ==\r\n' + \
- li_data, 0, 0, 0),
- menu = [['manager', '๊ด๋ฆฌ์']]
- ))
- elif num == 1:
- i_list = ['name', 'logo', 'frontpage', 'license', 'upload', 'skin', 'edit', 'reg', 'ip_view', 'back_up', 'all_title']
- n_list = ['๋ฌด๋ช
์ํค', '', '์ํค:๋๋ฌธ', 'CC 0', '2', '', 'normal', '', '', '0', '']
- if request.method == 'POST':
- i = 0
- for data in i_list:
- curs.execute("update other set data = ? where name = ?", [request.form.get(data, n_list[i]), data])
- i += 1
- conn.commit()
- admin_check(conn, None, 'edit_set')
- return redirect('/edit_set/1')
- else:
- d_list = []
-
- x = 0
- for i in i_list:
- curs.execute('select data from other where name = ?', [i])
- sql_d = curs.fetchall()
- if sql_d:
- d_list += [sql_d[0][0]]
- else:
- curs.execute('insert into other (name, data) values (?, ?)', [i, n_list[x]])
- d_list += [n_list[x]]
- x += 1
- conn.commit()
- div = ''
- if d_list[6] == 'login':
- div += '<option value="login">๊ฐ์
์</option>'
- div += '<option value="normal">์ผ๋ฐ</option>'
- div += '<option value="admin">๊ด๋ฆฌ์</option>'
- elif d_list[6] == 'admin':
- div += '<option value="admin">๊ด๋ฆฌ์</option>'
- div += '<option value="login">๊ฐ์
์</option>'
- div += '<option value="normal">์ผ๋ฐ</option>'
- else:
- div += '<option value="normal">์ผ๋ฐ</option>'
- div += '<option value="admin">๊ด๋ฆฌ์</option>'
- div += '<option value="login">๊ฐ์
์</option>'
- ch_1 = ''
- ch_2 = ''
- ch_3 = ''
- if d_list[7]:
- ch_1 = 'checked="checked"'
-
- if d_list[8]:
- ch_2 = 'checked="checked"'
- if d_list[10]:
- ch_3 = 'checked="checked"'
- return html_minify(template('index',
- imp = ['๊ธฐ๋ณธ ์ค์ ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post"> \
- <span>์ด๋ฆ</span><br><br> \
- <input placeholder="์ด๋ฆ" type="text" name="name" value="' + html.escape(d_list[0]) + '"><hr> \
- <span>๋ก๊ณ (HTML)</span><br><br> \
- <input placeholder="๋ก๊ณ " type="text" name="logo" value="' + html.escape(d_list[1]) + '"><hr> \
- <span>๋๋ฌธ</span><br><br> \
- <input placeholder="๋๋ฌธ" type="text" name="frontpage" value="' + html.escape(d_list[2]) + '"><hr> \
- <span>๋ผ์ด์ ์ค (HTML)</span><br><br> \
- <input placeholder="๋ผ์ด์ ์ค" type="text" name="license" value="' + html.escape(d_list[3]) + '"><hr> \
- <span>ํ์ผ ํฌ๊ธฐ [๋ฉ๊ฐ]</span><br><br> \
- <input placeholder="ํ์ผ ํฌ๊ธฐ" type="text" name="upload" value="' + html.escape(d_list[4]) + '"><hr> \
- <span>์คํจ {์ฌ์์ ํ์}</span><br><br> \
- <input placeholder="์คํจ" type="text" name="skin" value="' + html.escape(d_list[5]) + '"><hr> \
- <span>์ ์ญ ACL</span><br><br> \
- <select name="edit">' + div + '</select><hr> \
- <input type="checkbox" name="reg" ' + ch_1 + '> ๊ฐ์
๋ถ๊ฐ<hr> \
- <input type="checkbox" name="ip_view" ' + ch_2 + '> ์์ดํผ ๋น๊ณต๊ฐ<hr> \
- <input type="checkbox" name="all_title" ' + ch_3 + '> ๋ชจ๋ ๋ฌธ์ ๋ณด๊ธฐ ๋นํ์ฑํ<hr> \
- <span>๋ฐฑ์
๊ฐ๊ฒฉ [์๊ฐ] (๋๊ธฐ : 0) {์ฌ์์ ํ์}</span><hr> \
- <input placeholder="๋ฐฑ์
๊ฐ๊ฒฉ" type="text" name="back_up" value="' + html.escape(d_list[9]) + '"><hr> \
- <button id="save" type="submit">์ ์ฅ</button> \
- </form>',
- menu = [['edit_set', '์ค์ ']]
- ))
- elif num == 2:
- if request.method == 'POST':
- curs.execute("update other set data = ? where name = ?", [request.form['contract'], 'contract'])
- curs.execute("update other set data = ? where name = ?", [request.form['no_login_warring'], 'no_login_warring'])
- conn.commit()
- admin_check(conn, None, 'edit_set')
- return redirect('/edit_set/2')
- else:
- i_list = ['contract', 'no_login_warring']
- n_list = ['', '']
- d_list = []
-
- x = 0
- for i in i_list:
- curs.execute('select data from other where name = ?', [i])
- sql_d = curs.fetchall()
- if sql_d:
- d_list += [sql_d[0][0]]
- else:
- curs.execute('insert into other (name, data) values (?, ?)', [i, n_list[x]])
- d_list += [n_list[x]]
- x += 1
- conn.commit()
- return html_minify(template('index',
- imp = ['๋ฌธ๊ตฌ ๊ด๋ จ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post"> \
- <span>๊ฐ์
์ฝ๊ด</span><br><br> \
- <input placeholder="๊ฐ์
์ฝ๊ด" type="text" name="contract" value="' + html.escape(d_list[0]) + '"><hr> \
- <span>๋น ๋ก๊ทธ์ธ ๊ฒฝ๊ณ </span><br><br> \
- <input placeholder="๋น ๋ก๊ทธ์ธ ๊ฒฝ๊ณ " type="text" name="no_login_warring" value="' + html.escape(d_list[1]) + '"><hr> \
- <button id="save" type="submit">์ ์ฅ</button> \
- </form>',
- menu = [['edit_set', '์ค์ ']]
- ))
- elif num == 3:
- if request.method == 'POST':
- curs.execute("select name from other where name = 'head'")
- if curs.fetchall():
- curs.execute("update other set data = ? where name = 'head'", [request.form['content']])
- else:
- curs.execute("insert into other (name, data) values ('head', ?)", [request.form['content']])
- conn.commit()
- admin_check(conn, None, 'edit_set')
- return redirect('/edit_set/3')
- else:
- curs.execute("select data from other where name = 'head'")
- head = curs.fetchall()
- if head:
- data = head[0][0]
- else:
- data = ''
- return html_minify(template('index',
- imp = ['์ ์ญ HEAD', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<span><style>CSS</style><br><script>JS</script></span><hr> \
- <form method="post"> \
- <textarea rows="25" name="content">' + html.escape(data) + '</textarea><hr> \
- <button id="save" type="submit">์ ์ฅ</button> \
- </form>',
- menu = [['edit_set', '์ค์ ']]
- ))
- elif num == 4:
- if request.method == 'POST':
- curs.execute("select name from other where name = 'robot'")
-
- if curs.fetchall():
- curs.execute("update other set data = ? where name = 'robot'", [request.form['content']])
- else:
- curs.execute("insert into other (name, data) values ('robot', ?)", [request.form['content']])
-
- conn.commit()
- fw = open('./robots.txt', 'w')
- fw.write(re.sub('\r\n', '\n', request.form['content']))
- fw.close()
-
- admin_check(conn, None, 'edit_set')
- return redirect('/edit_set/4')
- else:
- curs.execute("select data from other where name = 'robot'")
- robot = curs.fetchall()
- if robot:
- data = robot[0][0]
- else:
- data = ''
- f = open('./robots.txt', 'r')
- lines = f.readlines()
- f.close()
- if not data or data == '':
- data = ''.join(lines)
- return html_minify(template('index',
- imp = ['robots.txt', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<a href="/robots.txt">(๋ณด๊ธฐ)</a><hr> \
- <form method="post"> \
- <textarea rows="25" name="content">' + html.escape(data) + '</textarea><hr> \
- <button id="save" type="submit">์ ์ฅ</button> \
- </form>',
- menu = [['edit_set', '์ค์ ']]
- ))
- elif num == 5:
- if request.method == 'POST':
- curs.execute("update other set data = ? where name = 'recaptcha'", [request.form['recaptcha']])
- curs.execute("update other set data = ? where name = 'sec_re'", [request.form['sec_re']])
- conn.commit()
- admin_check(conn, None, 'edit_set')
- return redirect('/edit_set/5')
- else:
- i_list = ['recaptcha', 'sec_re']
- n_list = ['', '']
- d_list = []
-
- x = 0
- for i in i_list:
- curs.execute('select data from other where name = ?', [i])
- sql_d = curs.fetchall()
- if sql_d:
- d_list += [sql_d[0][0]]
- else:
- curs.execute('insert into other (name, data) values (?, ?)', [i, n_list[x]])
- d_list += [n_list[x]]
- x += 1
- conn.commit()
- return html_minify(template('index',
- imp = ['๊ตฌ๊ธ ๊ด๋ จ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post"> \
- <span>๋ฆฌ์บก์ฐจ (HTML)</span><br><br> \
- <input placeholder="๋ฆฌ์บก์ฐจ (HTML)" type="text" name="recaptcha" value="' + html.escape(d_list[0]) + '"><hr> \
- <span>๋ฆฌ์บก์ฐจ (๋น๋ฐํค)</span><br><br> \
- <input placeholder="๋ฆฌ์บก์ฐจ (๋น๋ฐํค)" type="text" name="sec_re" value="' + html.escape(d_list[1]) + '"><hr> \
- <button id="save" type="submit">์ ์ฅ</button> \
- </form>',
- menu = [['edit_set', '์ค์ ']]
- ))
- else:
- return redirect('/')
- @app.route('/not_close_topic')
- def not_close_topic():
- div = '<ul>'
- 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><a href="/topic/' + url_pas(data[0]) + '/sub/' + url_pas(data[1]) + '">' + data[0] + ' (' + data[1] + ')</a></li>'
-
- div += '</ul>'
- return html_minify(template('index',
- imp = ['์ด๋ฆฐ ํ ๋ก ๋ชฉ๋ก', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = div,
- menu = [['manager', '๊ด๋ฆฌ์']]
- ))
- @app.route('/image/<name>')
- def image_view(name = None):
- if os.path.exists(os.path.join('image', name)):
- return send_from_directory('./image', name)
- else:
- return redirect('/')
- @app.route('/acl_list')
- def acl_list():
- div = '<ul>'
- curs.execute("select title, dec from acl where dec = 'admin' or dec = 'user' order by title desc")
- list_data = curs.fetchall()
- for data in list_data:
- if not re.search('^์ฌ์ฉ์:', data[0]) and not re.search('^ํ์ผ:', data[0]):
- if data[1] == 'admin':
- acl = '๊ด๋ฆฌ์'
- else:
- acl = '๊ฐ์
์'
- div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a> (' + acl + ')</li>'
-
- div += '</ul>'
-
- return html_minify(template('index',
- imp = ['ACL ๋ฌธ์ ๋ชฉ๋ก', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = div,
- menu = [['other', '๊ธฐํ']]
- ))
- @app.route('/admin_plus/<name>', methods=['POST', 'GET'])
- def admin_plus(name = None):
- if request.method == 'POST':
- if admin_check(conn, None, 'admin_plus (' + name + ')') != 1:
- return re_error(conn, '/error/3')
- curs.execute("delete from alist where name = ?", [name])
-
- if request.form.get('ban', 0) != 0:
- curs.execute("insert into alist (name, acl) values (?, 'ban')", [name])
- if request.form.get('mdel', 0) != 0:
- curs.execute("insert into alist (name, acl) values (?, 'mdel')", [name])
- if request.form.get('toron', 0) != 0:
- curs.execute("insert into alist (name, acl) values (?, 'toron')", [name])
-
- if request.form.get('check', 0) != 0:
- curs.execute("insert into alist (name, acl) values (?, 'check')", [name])
- if request.form.get('acl', 0) != 0:
- curs.execute("insert into alist (name, acl) values (?, 'acl')", [name])
- if request.form.get('hidel', 0) != 0:
- curs.execute("insert into alist (name, acl) values (?, 'hidel')", [name])
- if request.form.get('give', 0) != 0:
- curs.execute("insert into alist (name, acl) values (?, 'give')", [name])
- if request.form.get('owner', 0) != 0:
- curs.execute("insert into alist (name, acl) values (?, 'owner')", [name])
-
- conn.commit()
-
- return redirect('/admin_plus/' + url_pas(name))
- else:
- curs.execute('select acl from alist where name = ?', [name])
- acl_list = curs.fetchall()
-
- data = '<ul>'
- exist_list = ['', '', '', '', '', '', '', '']
- for go in acl_list:
- 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] == 'give':
- exist_list[6] = 'checked="checked"'
- elif go[0] == 'owner':
- exist_list[7] = 'checked="checked"'
- if admin_check(conn, None, None) != 1:
- state = 'disabled'
- else:
- state = ''
- data += '<li><input type="checkbox" ' + state + ' name="ban" ' + exist_list[0] + '> ์ฐจ๋จ</li>'
- data += '<li><input type="checkbox" ' + state + ' name="mdel" ' + exist_list[1] + '> ๋ง์ ๋ฌธ์ ์ญ์ </li>'
- data += '<li><input type="checkbox" ' + state + ' name="toron" ' + exist_list[2] + '> ํ ๋ก ๊ด๋ฆฌ</li>'
- data += '<li><input type="checkbox" ' + state + ' name="check" ' + exist_list[3] + '> ์ฌ์ฉ์ ๊ฒ์ฌ</li>'
- data += '<li><input type="checkbox" ' + state + ' name="acl" ' + exist_list[4] + '> ๋ฌธ์ ACL</li>'
- data += '<li><input type="checkbox" ' + state + ' name="hidel" ' + exist_list[5] + '> ์ญ์ฌ ์จ๊น</li>'
- data += '<li><input type="checkbox" ' + state + ' name="give" ' + exist_list[6] + '> ๊ถํ ๋ถ์ฌ</li>'
- data += '<li><input type="checkbox" ' + state + ' name="owner" ' + exist_list[7] + '> ์์ ์</li></ul>'
- return html_minify(template('index',
- imp = ['๊ด๋ฆฌ ๊ทธ๋ฃน ์ถ๊ฐ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post">' + data + '<hr><button id="save" ' + state + ' type="submit">์ ์ฅ</button></form>',
- menu = [['manager', '๊ด๋ฆฌ์']]
- ))
-
- @app.route('/admin_list')
- def admin_list():
- div = '<ul>'
-
- curs.execute("select id, acl, date from user where not acl = 'user' order by date desc")
- user_data = curs.fetchall()
- for data in user_data:
- name = ip_pas(conn, data[0]) + ' <a href="/admin_plus/' + url_pas(data[1]) + '">(' + data[1] + ')</a>'
- if data[2] != '':
- name += '(๊ฐ์
: ' + data[2] + ')'
- div += '<li>' + name + '</li>'
-
- div += '</ul>'
-
- return html_minify(template('index',
- imp = ['๊ด๋ฆฌ์ ๋ชฉ๋ก', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = div,
- menu = [['other', '๊ธฐํ']]
- ))
-
- @app.route('/hidden/<path:name>')
- def history_hidden(name = None):
- num = int(request.args.get('num', 0))
- if admin_check(conn, 6, 'history_hidden (' + name + '#' + str(num) + ')') == 1:
- curs.execute("select title from history where title = ? and id = ? and hide = 'O'", [name, str(num)])
- if curs.fetchall():
- curs.execute("update history set hide = '' where title = ? and id = ?", [name, str(num)])
- else:
- curs.execute("update history set hide = 'O' where title = ? and id = ?", [name, str(num)])
-
- conn.commit()
-
- return redirect('/history/' + url_pas(name))
-
- @app.route('/user_log')
- def user_log():
- num = int(request.args.get('num', 1))
- if num * 50 > 0:
- sql_num = num * 50 - 50
- else:
- sql_num = 0
-
- list_data = '<ul>'
- admin_one = admin_check(conn, 1, None)
-
- curs.execute("select id, date from user order by date desc limit ?, '50'", [str(sql_num)])
- user_list = curs.fetchall()
- for data in user_list:
- if admin_one == 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(conn, data[0])
- list_data += '<li>' + ip + ban_button
- if data[1] != '':
- list_data += ' (๊ฐ์
: ' + data[1] + ')'
- list_data += '</li>'
- if num == 1:
- curs.execute("select count(id) from user")
- user_count = curs.fetchall()
- if user_count:
- count = user_count[0][0]
- else:
- count = 0
- list_data += '</ul><hr><ul><li>์ด ์ํค์๋ ' + str(count) + '๋ช
์ ์ฌ๋์ด ์์ต๋๋ค.</li></ul>'
- list_data += next_fix('/user_log?num=', num, user_list)
- return html_minify(template('index',
- imp = ['์ฌ์ฉ์ ๊ฐ์
๊ธฐ๋ก', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = list_data,
- menu = [['other', '๊ธฐํ']]
- ))
- @app.route('/admin_log')
- def admin_log():
- num = int(request.args.get('num', 1))
- if num * 50 > 0:
- sql_num = num * 50 - 50
- else:
- sql_num = 0
- list_data = '<ul>'
-
- curs.execute("select who, what, time from re_admin order by time desc limit ?, '50'", [str(sql_num)])
- get_list = curs.fetchall()
- for data in get_list:
- ip = ip_pas(conn, data[0])
- list_data += '<li>' + ip + ' / ' + data[1] + ' / ' + data[2] + '</li>'
- list_data += '</ul><hr><ul><li>์ฃผ์ : ๊ถํ ์ฌ์ฉ ์ํ๊ณ ์ด๋๋ง ํด๋ ๊ธฐ๋ก๋๋ ๊ฒฝ์ฐ๋ ์์ต๋๋ค.</li></ul>'
- list_data += next_fix('/admin_log?num=', num, get_list)
- return html_minify(template('index',
- imp = ['๊ถํ ์ฌ์ฉ ๊ธฐ๋ก', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = list_data,
- menu = [['other', '๊ธฐํ']]
- ))
- @app.route('/give_log')
- def give_log():
- list_data = '<ul>'
- back = ''
- curs.execute("select distinct name from alist order by name asc")
- get_list = curs.fetchall()
- for data in get_list:
- if back != data[0]:
- back = data[0]
- list_data += '<li><a href="/admin_plus/' + url_pas(data[0]) + '">' + data[0] + '</a></li>'
-
- list_data += '</ul><hr><a href="/manager/8">(์์ฑ)</a>'
- return html_minify(template('index',
- imp = ['๊ด๋ฆฌ ๊ทธ๋ฃน ๋ชฉ๋ก', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = list_data,
- menu = [['other', '๊ธฐํ']]
- ))
- @app.route('/indexing')
- def indexing():
- if admin_check(conn, None, 'indexing') != 1:
- return re_error(conn, '/error/3')
- print('')
- curs.execute("select name from sqlite_master where type = 'index'")
- index_data = curs.fetchall()
- if index_data:
- for delete_index in index_data:
- print('Delete : ' + delete_index[0])
-
- sql = 'drop index if exists ' + delete_index[0]
- try:
- curs.execute(sql)
- except:
- pass
- else:
- curs.execute("select name from sqlite_master where type in ('table', 'view') and name not like " + \
- "'sqlite_%' union all select name from sqlite_temp_master where type in ('table', 'view') order by 1;")
- data = curs.fetchall()
-
- for table in data:
- curs.execute('select sql from sqlite_master where name = ?', [table[0]])
- cul = curs.fetchall()
-
- r_cul = re.findall('(?:([^ (]*) text)', str(cul[0]))
-
- for n_cul in r_cul:
- print('Create : index_' + table[0] + '_' + n_cul)
-
- sql = 'create index index_' + table[0] + '_' + n_cul + ' on ' + table[0] + '(' + n_cul + ')'
-
- try:
- curs.execute(sql)
- except:
- pass
- conn.commit()
- print('')
- return redirect('/')
- @app.route('/re_start')
- def re_start():
- if admin_check(conn, None, 're_start') != 1:
- return re_error(conn, '/error/3')
- print('')
- print('Re Start')
- print('')
- os.execl(sys.executable, sys.executable, *sys.argv)
-
- @app.route('/xref/<path:name>')
- def xref(name = None):
- num = int(request.args.get('num', 1))
- if num * 50 > 0:
- sql_num = num * 50 - 50
- else:
- sql_num = 0
-
- div = '<ul>'
-
- curs.execute("select link, type from back where title = ? and not type = 'cat' and not type = 'no' order by link asc limit ?, '50'", \
- [name, str(sql_num)])
- data_list = curs.fetchall()
- for data in data_list:
- div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a>'
-
- if data[1]:
- if data[1] == 'include':
- side = 'ํฌํจ'
- elif data[1] == 'file':
- side = 'ํ์ผ'
- else:
- side = '๋๊ฒจ์ฃผ๊ธฐ'
-
- div += ' (' + side + ')'
-
- div += '</li>'
-
- if re.search('^ํ:', data[0]):
- div += '<li><a id="inside" href="/xref/' + url_pas(data[0]) + '">' + data[0] + '</a> (์ญ๋งํฌ)</li>'
-
- div += '</ul>' + next_fix('/xref/' + url_pas(name) + '?num=', num, data_list)
-
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (์ญ๋งํฌ)', 0])],
- data = div,
- menu = [['w/' + url_pas(name), '๋ฌธ์']]
- ))
- @app.route('/please')
- def please():
- num = int(request.args.get('num', 1))
- if num * 50 > 0:
- sql_num = num * 50 - 50
- else:
- sql_num = 0
-
- div = '<ul>'
- var = ''
-
- curs.execute("select distinct title from back where type = 'no' order by title asc limit ?, '50'", [str(sql_num)])
- data_list = curs.fetchall()
- for data in data_list:
- if var != data[0]:
- div += '<li><a class="not_thing" href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a></li>'
- var = data[0]
-
- div += '</ul>' + next_fix('/please?num=', num, data_list)
-
- return html_minify(template('index',
- imp = ['ํ์ํ ๋ฌธ์', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = div,
- menu = [['other', '๊ธฐํ']]
- ))
-
- @app.route('/recent_discuss')
- @app.route('/recent_discuss/<regex("close"):tools>')
- def recent_discuss(tools = 'normal'):
- if tools == 'normal' or tools == 'close':
- div = ''
-
- if tools == 'normal':
- div += '<a href="/recent_discuss/close">(๋ซํ)</a>'
- m_sub = 0
- else:
- div += '<a href="/recent_discuss">(์ด๋ฆผ)</a>'
- m_sub = ' (๋ซํ)'
- div += '<hr><table style="width: 100%; text-align: center;"><tbody><tr> \
- <td style="width: 50%;">ํ ๋ก ๋ช
</td><td style="width: 50%;">์๊ฐ</td></tr>'
- else:
- return redirect('/')
-
- curs.execute("select title, sub, date from rd order by date desc limit 50")
- for data in curs.fetchall():
- title = html.escape(data[0])
- sub = html.escape(data[1])
- close = 0
- if tools == 'normal':
- curs.execute("select title from stop where title = ? and sub = ? and close = 'O'", [data[0], data[1]])
- if curs.fetchall():
- close = 1
- else:
- curs.execute("select title from stop where title = ? and sub = ? and close = 'O'", [data[0], data[1]])
- if not curs.fetchall():
- close = 1
- if close == 0:
- 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 html_minify(template('index',
- imp = ['์ต๊ทผ ํ ๋ก ๋ด์ญ', wiki_set(conn, 1), custom(conn), other2([m_sub, 0])],
- data = div,
- menu = 0
- ))
- @app.route('/block_log')
- @app.route('/block_log/<regex("ip|user|never_end|can_end|end|now"):tool2>')
- @app.route('/<regex("block_user|block_admin"):tool>/<name>')
- def block_log(name = None, tool = None, tool2 = None):
- num = int(request.args.get('num', 1))
- if num * 50 > 0:
- sql_num = num * 50 - 50
- else:
- sql_num = 0
-
- 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>'
- data_list = ''
-
- if not name:
- if not tool2:
- div = '<a href="/manager/11">(์ฐจ๋จ์)</a> <a href="/manager/12">(๊ด๋ฆฌ์)</a><hr><a href="/block_log/ip">(์์ดํผ)</a>' + \
- ' <a href="/block_log/user">(๊ฐ์
์)</a> <a href="/block_log/never_end">(์๊ตฌ)</a> <a href="/block_log/can_end">(๊ธฐ๊ฐ)</a>' + \
- ' <a href="/block_log/end">(ํด์ )</a> <a href="/block_log/now">(ํ์ฌ)</a><hr>' + div
- sub = 0
- menu = [['other', '๊ธฐํ']]
- curs.execute("select why, block, blocker, end, today from rb order by today desc limit ?, '50'", [str(sql_num)])
- else:
- menu = [['block_log', '์ผ๋ฐ']]
- if tool2 == 'ip':
- sub = ' (์์ดํผ)'
- curs.execute("select why, block, blocker, end, today from rb where (block like ? or block like ?) order by today desc limit ?, '50'", \
- ['%.%', '%:%', str(sql_num)])
- elif tool2 == 'user':
- sub = ' (๊ฐ์
์)'
- curs.execute("select why, block, blocker, end, today from rb where not (block like ? or block like ?) order by today desc limit ?, '50'", \
- ['%.%', '%:%', str(sql_num)])
- elif tool2 == 'never_end':
- sub = '(์๊ตฌ)'
- curs.execute("select why, block, blocker, end, today from rb where not end like ? and not end like ? order by today desc limit ?, '50'", \
- ['%:%', '%ํด์ %', str(sql_num)])
- elif tool2 == 'end':
- sub = '(ํด์ )'
- curs.execute("select why, block, blocker, end, today from rb where end = ? order by today desc limit ?, '50'", ['ํด์ ', str(sql_num)])
- elif tool2 == 'now':
- sub = '(ํ์ฌ)'
- data_list = []
- curs.execute("select block from ban limit ?, '50'", [str(sql_num)])
- for in_data in curs.fetchall():
- curs.execute("select why, block, blocker, end, today from rb where block = ? order by today desc limit 1", [in_data[0]])
- data_list = [curs.fetchall()[0]] + data_list
- else:
- sub = '(๊ธฐ๊ฐ)'
- curs.execute("select why, block, blocker, end, today from rb where end like ? order by today desc limit ?, '50'", ['%\-%', str(sql_num)])
- else:
- menu = [['block_log', '์ผ๋ฐ']]
- if tool == 'block_user':
- sub = ' (์ฐจ๋จ์)'
- curs.execute("select why, block, blocker, end, today from rb where block = ? order by today desc limit ?, '50'", [name, str(sql_num)])
- else:
- sub = ' (๊ด๋ฆฌ์)'
- curs.execute("select why, block, blocker, end, today from rb where blocker = ? order by today desc limit ?, '50'", [name, str(sql_num)])
- if data_list == '':
- data_list = curs.fetchall()
- for data in data_list:
- why = html.escape(data[0])
- if why == '':
- why = '<br>'
-
- b = re.search("^([0-9]{1,3}\.[0-9]{1,3})$", data[1])
- if b:
- ip = data[1] + ' (๋์ญ)'
- else:
- ip = ip_pas(conn, data[1])
- if data[3] != '':
- end = data[3]
- else:
- end = '๋ฌด๊ธฐํ'
-
- div += '<tr><td>' + ip + '</td><td>' + ip_pas(conn, data[2]) + '</td><td>์์ : ' + data[4] + '<br>๋ : ' + end + '</td></tr>'
- div += '<tr><td colspan="3">' + why + '</td></tr>'
- div += '</tbody></table>'
- if not name:
- if not tool2:
- div += next_fix('/block_log?num=', num, data_list)
- else:
- div += next_fix('/block_log/' + url_pas(tool2) + '?num=', num, data_list)
- else:
- div += next_fix('/' + url_pas(tool) + '/' + url_pas(name) + '?num=', num, data_list)
-
- return html_minify(template('index',
- imp = ['์ฐจ๋จ ๊ธฐ๋ก', wiki_set(conn, 1), custom(conn), other2([sub, 0])],
- data = div,
- menu = menu
- ))
-
- @app.route('/search', methods=['POST'])
- def search():
- return redirect('/search/' + url_pas(request.form['search']))
- @app.route('/goto', methods=['POST'])
- def goto():
- curs.execute("select title from data where title = ?", [request.form['search']])
- data = curs.fetchall()
- if data:
- return redirect('/w/' + url_pas(request.form['search']))
- else:
- return redirect('/search/' + url_pas(request.form['search']))
- @app.route('/search/<path:name>')
- def deep_search(name = None):
- num = int(request.args.get('num', 1))
- if num * 50 > 0:
- sql_num = num * 50 - 50
- else:
- sql_num = 0
- div = '<ul>'
- div_plus = ''
- no = 0
- start = 2
- test = ''
- curs.execute("select title from data where title = ?", [name])
- if curs.fetchall():
- div = '<ul><li>๋ฌธ์๋ก <a href="/w/' + url_pas(name) + '">๋ฐ๋ก๊ฐ๊ธฐ</a></li></ul><hr><ul>'
- else:
- div = '<ul><li>๋ฌธ์๊ฐ ์์ต๋๋ค. <a class="not_thing" href="/w/' + url_pas(name) + '">๋ฐ๋ก๊ฐ๊ธฐ</a></li></ul><hr><ul>'
- curs.execute("select distinct title, case when title like ? then '์ ๋ชฉ' else '๋ด์ฉ' " + \
- "end from data where title like ? or data like ? order by case when title like ? " + \
- "then 1 else 2 end limit ?, '50'", ['%' + name + '%', '%' + name + '%', '%' + name + '%', '%' + name + '%', str(sql_num)])
- all_list = curs.fetchall()
- if all_list:
- test = all_list[0][1]
- for data in all_list:
- if data[1] != test:
- div_plus += '</ul><hr><ul>'
- test = data[1]
- div_plus += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a> (' + data[1] + ')</li>'
- else:
- div += '<li>๊ฒ์ ๊ฒฐ๊ณผ ์์</li>'
- div += div_plus + '</ul>'
- div += next_fix('/search/' + url_pas(name) + '?num=', num, all_list)
-
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (๊ฒ์)', 0])],
- data = div,
- menu = 0
- ))
-
- @app.route('/raw/<path:name>')
- @app.route('/topic/<path:name>/sub/<sub_t>/raw/<int:num>')
- def raw_view(name = None, sub_t = None, num = None):
- v_name = name
- sub = ' (์๋ณธ)'
- if not num:
- num = request.args.get('num', None)
- if num:
- num = int(num)
-
- if not sub_t and num:
- curs.execute("select title from history where title = ? and id = ? and hide = 'O'", [name, str(num)])
- hid = curs.fetchall()
- if hid and admin_check(conn, 6, None) != 1:
- return re_error(conn, '/error/3')
-
- curs.execute("select data from history where title = ? and id = ?", [name, str(num)])
- sub += ' (' + str(num) + 'ํ)'
- menu = [['history/' + url_pas(name), '์ญ์ฌ']]
- elif sub_t:
- curs.execute("select data from topic where id = ? and title = ? and sub = ? and block = ''", [str(num), name, sub_t])
- v_name = 'ํ ๋ก ์๋ณธ'
- sub = ' (' + str(num) + '๋ฒ)'
- menu = [['topic/' + url_pas(name) + '/sub/' + url_pas(sub_t) + '#' + str(num), 'ํ ๋ก ']]
- else:
- curs.execute("select data from data where title = ?", [name])
-
- menu = [['w/' + url_pas(name), '๋ฌธ์']]
- data = curs.fetchall()
- if data:
- p_data = html.escape(data[0][0])
-
- p_data = '<textarea readonly rows="25">' + p_data + '</textarea>'
-
- return html_minify(template('index',
- imp = [v_name, wiki_set(conn, 1), custom(conn), other2([sub, 0])],
- data = p_data,
- menu = menu
- ))
- else:
- return redirect('/w/' + url_pas(name))
-
- @app.route('/revert/<path:name>', methods=['POST', 'GET'])
- def revert(name = None):
- ip = ip_check()
- can = acl_check(conn, name)
- today = get_time()
- num = int(request.args.get('num', 0))
-
- if request.method == 'POST':
- if captcha_post(request.form.get('g-recaptcha-response', None), conn) == 1:
- return re_error(conn, '/error/13')
- else:
- captcha_post('', conn, 0)
- curs.execute("select title from history where title = ? and id = ? and hide = 'O'", [name, str(num)])
- if curs.fetchall() and admin_check(conn, 6, None) != 1:
- return re_error(conn, '/error/3')
- if can == 1:
- return re_error(conn, '/ban')
- curs.execute("delete from back where link = ?", [name])
- conn.commit()
- curs.execute("select data from history where title = ? and id = ?", [name, str(num)])
- data = curs.fetchall()
- if(data):
- curs.execute("select data from data where title = ?", [name])
- d = curs.fetchall()
- if d:
- leng = leng_check(len(d[0][0]), len(data[0][0]))
- curs.execute("update data set data = ? where title = ?", [data[0][0], name])
- else:
- leng = '+' + str(len(data[0][0]))
- curs.execute("insert into data (title, data) values (?, ?)", [name, data[0][0]])
-
- history_plus(conn, name, data[0][0], today, ip, request.form['send'] + ' (' + str(num) + 'ํ)', leng)
-
- namumark(conn, name, data[0][0], 1, 0, 0)
- conn.commit()
-
- return redirect('/w/' + url_pas(name))
- else:
- curs.execute("select title from history where title = ? and id = ? and hide = 'O'", [name, str(num)])
- hid = curs.fetchall()
- if hid and admin_check(conn, 6, None) != 1:
- return re_error(conn, '/error/3')
-
- if can == 1:
- return re_error(conn, '/ban')
- curs.execute("select title from history where title = ? and id = ?", [name, str(num)])
- if not curs.fetchall():
- return redirect('/w/' + url_pas(name))
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (๋๋๋ฆฌ๊ธฐ)', 0])],
- data = '<form method="post"> \
- <span>' + request.args.get('num', '0') + 'ํ์ผ๋ก ๋๋๋ฆฌ๊ฒ ์ต๋๊น?</span><hr> \
- ' + ip_warring(conn) + ' \
- <input placeholder="์ฌ์ " name="send" type="text"><hr> \
- ' + captcha_get(conn) + ' \
- <button type="submit">๋๋๋ฆฌ๊ธฐ</button> \
- </form>',
- menu = [['history/' + url_pas(name), '์ญ์ฌ'], ['recent_changes', '์ต๊ทผ ๋ณ๊ฒฝ']]
- ))
-
- @app.route('/big_delete', methods=['POST', 'GET'])
- def big_delete():
- if admin_check(conn, 2, 'big_delete') != 1:
- return re_error(conn, '/error/3')
- if request.method == 'POST':
- today = get_time()
- ip = ip_check()
- data = request.form['content'] + '\r\n'
- m = re.findall('(.*)\r\n', data)
- for g in m:
- curs.execute("select data from data where title = ?", [g])
- d = curs.fetchall()
- if d:
- curs.execute("delete from back where title = ?", [g])
- leng = '-' + str(len(d[0][0]))
- curs.execute("delete from data where title = ?", [g])
- history_plus(conn, g, '', today, ip, request.form['send'] + ' (๋๋ ์ญ์ )', leng)
- data = re.sub('(.*)\r\n', '', data, 1)
- conn.commit()
- return redirect('/')
- else:
- return html_minify(template('index',
- imp = ['๋ง์ ๋ฌธ์ ์ญ์ ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<span>๋ฌธ์๋ช
A<br>๋ฌธ์๋ช
B<br>๋ฌธ์๋ช
C<hr>์ด๋ฐ ์์ผ๋ก ์ ์ผ์ธ์.</span><hr> \
- <form method="post"> \
- <textarea rows="25" name="content"></textarea><hr> \
- <input placeholder="์ฌ์ " name="send" type="text"><hr> \
- <button type="submit">์ญ์ </button> \
- </form>',
- menu = [['manager', '๊ด๋ฆฌ์']]
- ))
- @app.route('/edit_filter')
- def edit_filter():
- div = '<ul>'
-
- curs.execute("select name from filter")
- data = curs.fetchall()
- for data_list in data:
- div += '<li><a href="/edit_filter/' + url_pas(data_list[0]) + '">' + data_list[0] + '</a></li>'
- div += '</ul>'
- div += '<hr><a href="/manager/9">(์ถ๊ฐ)</a>'
- return html_minify(template('index',
- imp = ['ํธ์ง ํํฐ ๋ชฉ๋ก', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = div,
- menu = [['manager', '๊ด๋ฆฌ์']]
- ))
- @app.route('/edit_filter/<name>/delete', methods=['POST', 'GET'])
- def delete_edit_filter(name = None):
- if admin_check(conn, 1, 'edit_filter delete') != 1:
- return re_error('/error/3')
- curs.execute("delete from filter where name = ?", [name])
- conn.commit()
- return redirect('/edit_filter')
- @app.route('/edit_filter/<name>', methods=['POST', 'GET'])
- def set_edit_filter(name = None):
- if request.method == 'POST':
- if admin_check(conn, 1, 'edit_filter edit') != 1:
- return re_error('/error/3')
- if request.form['day'] == '00':
- end = ''
- elif request.form['day'] == '09':
- end = 'X'
- else:
- end = request.form['day'] + ' ' + request.form['hour'] + ':' + request.form['minu']
- curs.execute("select name from filter where name = ?", [name])
- if curs.fetchall():
- curs.execute("update filter set regex = ?, sub = ? where name = ?", [request.form['content'], end, name])
- else:
- curs.execute("insert into filter (name, regex, sub) values (?, ?, ?)", [name, request.form['content'], end])
- conn.commit()
-
- return redirect('/edit_filter/' + url_pas(name))
- else:
- curs.execute("select regex, sub from filter where name = ?", [name])
- exist = curs.fetchall()
- if exist:
- textarea = exist[0][0]
- match = re.search("^([^ ]+) ([^:]+):([^:]+)$", exist[0][1])
- if match:
- end_data = match.groups()
- else:
- end_data = ['', '', '']
- else:
- textarea = ''
- end_data = ['', '', '']
- if admin_check(conn, 1, None) != 1:
- stat = 'disabled'
- else:
- stat = ''
- day = '<option value="00">์ฐจ๋จ X</option>'
- if exist[0][1] == 'X':
- day += '<option value="09" selected>์๊ตฌ</option>'
- else:
- day += '<option value="09">์๊ตฌ</option>'
- for i in range(0, 32):
- if str(i) == end_data[0]:
- day += '<option value="' + str(i) + '" selected>' + str(i) + '</option>'
- else:
- day += '<option value="' + str(i) + '">' + str(i) + '</option>'
- hour = ''
- for i in range(0, 24):
- if str(i) == end_data[1]:
- hour += '<option value="' + str(i) + '" selected>' + str(i) + '</option>'
- else:
- hour += '<option value="' + str(i) + '">' + str(i) + '</option>'
- minu = ''
- for i in range(0, 61):
- if str(i) == end_data[2]:
- minu += '<option value="' + str(i) + '" selected>' + str(i) + '</option>'
- else:
- minu += '<option value="' + str(i) + '">' + str(i) + '</option>'
- data = '<select ' + stat + ' name="day">' + day + '</select> ์ผ '
- data += '<select ' + stat + ' name="hour">' + hour + '</select> ์ '
- data += '<select ' + stat + ' name="minu">' + minu + '</select> ๋ถ ๋์<hr>'
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (ํธ์ง ํํฐ)', 0])],
- data = '<form method="post"> \
- ' + data + ' \
- <input ' + stat + ' placeholder="์ ๊ท์" name="content" value="' + html.escape(textarea) + '" type="text"><hr> \
- <button ' + stat + ' id="save" type="submit">์ ์ฅ</button> \
- </form>',
- menu = [['edit_filter', '๋ชฉ๋ก'], ['edit_filter/' + url_pas(name) + '/delete', '์ญ์ ']]
- ))
- @app.route('/edit/<path:name>', methods=['POST', 'GET'])
- def edit(name = None):
- ip = ip_check()
- can = acl_check(conn, name)
- if can == 1:
- return re_error(conn, '/ban')
-
- if request.method == 'POST':
- if admin_check(conn, 1, 'edit_filter pass') != 1:
- curs.execute("select regex, sub from filter")
- data = curs.fetchall()
- for data_list in data:
- match = re.compile(data_list[0])
- if match.search(request.form['content']):
- if data_list[1] == 'X':
- curs.execute("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, '')", \
- [ip, '', get_time(), '๋๊ตฌ:ํธ์ง ํํฐ', 'ํธ์ง ํํฐ์ ์ํ ์ฐจ๋จ'])
- curs.execute("insert into ban (block, end, why, band, login) values (?, '', ?, '', '')", [ip, 'ํธ์ง ํํฐ์ ์ํ ์ฐจ๋จ'])
- elif data_list[1] != '':
- match = re.search("^([^ ]+) ([^:]+):([^:]+)$", data_list[1])
- end_data = match.groups()
- match = re.search("^([^-]+)-([^-]+)-([^ ]+) ([^:]+):([^:]+):(.+)$", get_time())
- time_data = match.groups()
- if int(time_data[2]) + int(end_data[0]) > 29:
- month = int(time_data[1]) + 1
- day = int(time_data[2]) + int(end_data[0]) - 30
- if month > 12:
- year = int(time_data[0]) + 1
- month -= 12
- else:
- year = int(time_data[0])
- else:
- month = int(time_data[1])
- day = int(time_data[2]) + int(end_data[0])
- year = int(time_data[0])
- if int(time_data[3]) + int(end_data[1]) > 23:
- day += 1
- hour = int(time_data[3]) + int(end_data[1]) - 24
- else:
- hour = int(time_data[3]) + int(end_data[1])
- if int(time_data[4]) + int(end_data[2]) > 59:
- hour += 1
- minu = int(time_data[4]) + int(end_data[2]) - 60
- else:
- minu = int(time_data[4]) + int(end_data[2])
- time_list = [month, day, hour, minu]
- num = 0
- for time_fix in time_list:
- if not re.search("[0-9]{2}", str(time_fix)):
- time_list[num] = '0' + str(time_fix)
- else:
- time_list[num] = str(time_fix)
-
- num += 1
- end = str(year) + '-' + time_list[0] + '-' + time_list[1] + ' ' + time_list[2] + ':' + time_list[3] + ':' + time_data[5]
- curs.execute("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, '')", \
- [ip, end, get_time(), '๋๊ตฌ:ํธ์ง ํํฐ', 'ํธ์ง ํํฐ์ ์ํ ์ฐจ๋จ'])
- curs.execute("insert into ban (block, end, why, band, login) values (?, ?, ?, '', '')", [ip, end, 'ํธ์ง ํํฐ์ ์ํ ์ฐจ๋จ'])
-
- conn.commit()
- return re_error(conn, '/error/21')
- if captcha_post(request.form.get('g-recaptcha-response', None), conn) == 1:
- return re_error(conn, '/error/13')
- else:
- captcha_post('', conn, 0)
- if len(request.form['send']) > 500:
- return re_error(conn, '/error/15')
- if request.form['otent'] == request.form['content']:
- return re_error(conn, '/error/18')
- today = get_time()
- content = savemark(request.form['content'])
- curs.execute("select data from data where title = ?", [name])
- old = curs.fetchall()
- if old:
- if not request.args.get('section', None) and request.form['otent'] != old[0][0]:
- return re_error(conn, '/error/12')
- leng = leng_check(len(request.form['otent']), len(content))
- if request.args.get('section', None):
- content = old[0][0].replace(request.form['otent'], content)
-
- curs.execute("update data set data = ? where title = ?", [content, name])
- else:
- leng = '+' + str(len(content))
- curs.execute("insert into data (title, data) values (?, ?)", [name, content])
- curs.execute("select user from scan where title = ?", [name])
- for user_data in curs.fetchall():
- curs.execute("insert into alarm (name, data, date) values (?, ?, ?)", \
- [ip, ip + '๋์ด <a href="/w/' + url_pas(name) + '">' + name + '</a> ๋ฌธ์๋ฅผ ํธ์ง ํ์ต๋๋ค.', today])
- history_plus(conn, name, content, today, ip, send_p(request.form['send']), leng)
- curs.execute("delete from back where link = ?", [name])
- curs.execute("delete from back where title = ? and type = 'no'", [name])
- namumark(conn, name, content, 1, 0, 0)
- conn.commit()
-
- return redirect('/w/' + url_pas(name))
- else:
- curs.execute("select data from data where title = ?", [name])
- new = curs.fetchall()
- if new:
- if request.args.get('section', None):
- i = 0
- j = 0
-
- data = new[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)?)+)", data)
- if m:
- if i == int(request.args.get('section', 0)) - 1:
- g = m.groups()
- data = re.sub("\r\n$", "", g[0])
-
- break
- else:
- data = re.sub("((?:={1,6})\s?(?:[^=]*)\s?(?:={1,6})(?:\s+)?\n(?:(?:(?:(?!(?:={1,6})" + \
- "\s?(?:[^=]*)\s?(?:={1,6})(?:\s+)?\n).)*)(?:\n)?)+)", "", data, 1)
-
- i += 1
- else:
- j = 1
-
- break
-
- if j == 0:
- data = re.sub("\r\n$", "", data)
- else:
- data = new[0][0]
- else:
- data = ''
-
- data2 = data
- if not request.args.get('section', None):
- get_name = '<form method="post" id="get_edit" action="/edit_get/' + url_pas(name) + '"> \
- <input placeholder="๋ถ๋ฌ ์ฌ ๋ฌธ์" name="name" style="width: 50%;" type="text"> \
- <button id="come" type="submit">๋ถ๋ฌ์ค๊ธฐ</button> \
- </form><hr>'
- action = ''
- else:
- get_name = ''
- action = '?section=' + request.args.get('section', None)
-
- if request.args.get('froms', None):
- curs.execute("select data from data where title = ?", [request.args.get('froms', None)])
- get_data = curs.fetchall()
- if get_data:
- data = get_data[0][0]
- get_name = ''
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (์์ )', 0])],
- data = get_name + ' \
- <form method="post" action="/edit/' + url_pas(name) + action + '"> \
- <textarea rows="25" name="content">' + html.escape(data) + '</textarea> \
- <textarea style="display: none;" name="otent">' + html.escape(data2) + '</textarea><hr> \
- <input placeholder="์ฌ์ " name="send" type="text"><hr> \
- ' + captcha_get(conn) + ' \
- ' + ip_warring(conn) + ' \
- <button id="save" type="submit">์ ์ฅ</button> \
- <button id="preview" type="submit" formaction="/preview/' + url_pas(name) + action + '">๋ฏธ๋ฆฌ๋ณด๊ธฐ</button> \
- </form>',
- menu = [['w/' + url_pas(name), '๋ฌธ์']]
- ))
-
- @app.route('/edit_get/<path:name>', methods=['POST'])
- def edit_get(name = None):
- return redirect('/edit/' + url_pas(name) + '?froms=' + url_pas(request.form['name']))
- @app.route('/preview/<path:name>', methods=['POST'])
- def preview(name = None):
- ip = ip_check()
- can = acl_check(conn, name)
-
- if can == 1:
- return re_error(conn, '/ban')
-
- newdata = request.form['content']
- newdata = re.sub('^#(?:redirect|๋๊ฒจ์ฃผ๊ธฐ) (?P<in>[^\n]*)', ' * [[\g<in>]] ๋ฌธ์๋ก ๋๊ฒจ์ฃผ๊ธฐ', newdata)
- enddata = namumark(conn, name, newdata, 0, 0, 1)
- if request.args.get('section', None):
- action = '?section=' + request.args.get('section', None)
- else:
- action = ''
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (๋ฏธ๋ฆฌ๋ณด๊ธฐ)', 0])],
- data = '<form method="post" action="/edit/' + url_pas(name) + action + '"> \
- <textarea rows="25" name="content">' + html.escape(request.form['content']) + '</textarea> \
- <textarea style="display: none;" name="otent">' + html.escape(request.form['otent']) + '</textarea><hr> \
- <input placeholder="์ฌ์ " name="send" type="text"><hr> \
- ' + captcha_get(conn) + ' \
- <button id="save" type="submit">์ ์ฅ</button> \
- <button id="preview" type="submit" formaction="/preview/' + url_pas(name) + action + '">๋ฏธ๋ฆฌ๋ณด๊ธฐ</button> \
- </form><hr>' + enddata,
- menu = [['w/' + url_pas(name), '๋ฌธ์']]
- ))
-
- @app.route('/delete/<path:name>', methods=['POST', 'GET'])
- def delete(name = None):
- ip = ip_check()
- can = acl_check(conn, name)
- if can == 1:
- return re_error(conn, '/ban')
-
- if request.method == 'POST':
- if captcha_post(request.form.get('g-recaptcha-response', None), conn) == 1:
- return re_error(conn, '/error/13')
- else:
- captcha_post('', conn, 0)
- curs.execute("select data from data where title = ?", [name])
- data = curs.fetchall()
- if data:
- today = get_time()
-
- leng = '-' + str(len(data[0][0]))
- history_plus(conn, name, '', today, ip, request.form['send'] + ' (์ญ์ )', leng)
- curs.execute("select title, link from back where title = ? and not type = 'cat' and not type = 'no'", [name])
- for data in curs.fetchall():
- curs.execute("insert into back (title, link, type) values (?, ?, 'no')", [data[0], data[1]])
-
- curs.execute("delete from back where link = ?", [name])
- 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])
- if not curs.fetchall():
- return redirect('/w/' + url_pas(name))
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (์ญ์ )', 0])],
- data = '<form method="post"> \
- ' + ip_warring(conn) + ' \
- <input placeholder="์ฌ์ " name="send" type="text"><hr> \
- ' + captcha_get(conn) + ' \
- <button type="submit">์ญ์ </button> \
- </form>',
- menu = [['w/' + url_pas(name), '๋ฌธ์']]
- ))
-
- @app.route('/move_data/<path:name>')
- def move_data(name = None):
- data = '<ul>'
- curs.execute("select send, date, ip from history where send like ? or send like ? order by date desc", \
- ['%<a href="/w/' + url_pas(name) + '">' + name + '</a> ์ด๋)%', '%(<a href="/w/' + url_pas(name) + '">' + name + '</a>%'])
- for for_data in curs.fetchall():
- match = re.findall('<a href="\/w\/(?:(?:(?!">).)+)">((?:(?!<\/a>).)+)<\/a>', for_data[0])
- send = re.sub('\([^\)]+\)$', '', for_data[0])
-
- data += '<li><a href="/move_data/' + url_pas(match[0]) + '">' + match[0] + '</a> - <a href="/move_data/' + url_pas(match[1]) + '">' + match[1] + '</a>'
- if re.search('^( *)+$', send):
- data += ' / ' + for_data[2] + ' / ' + for_data[1] + '</li>'
- else:
- data += ' / ' + for_data[2] + ' / ' + for_data[1] + ' / ' + send + '</li>'
-
- data += '</ul>'
-
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (์ด๋ ๊ธฐ๋ก)', 0])],
- data = data,
- menu = [['history/' + url_pas(name), '์ญ์ฌ']]
- ))
-
- @app.route('/move/<path:name>', methods=['POST', 'GET'])
- def move(name = None):
- ip = ip_check()
- can = acl_check(conn, name)
- today = get_time()
- if can == 1:
- return re_error(conn, '/ban')
-
- if request.method == 'POST':
- if captcha_post(request.form.get('g-recaptcha-response', None), conn) == 1:
- return re_error(conn, '/error/13')
- else:
- captcha_post('', conn, 0)
- curs.execute("select title from history where title = ?", [request.form['title']])
- if curs.fetchall():
- return re_error(conn, '/error/19')
-
- curs.execute("select data from data where title = ?", [name])
- data = curs.fetchall()
- leng = '0'
- if(data):
- curs.execute("update data set title = ? where title = ?", [request.form['title'], name])
- curs.execute("update back set link = ? where link = ?", [request.form['title'], name])
-
- d = data[0][0]
- else:
- d = ''
-
- history_plus(conn, name, d, today, ip, request.form['send'] + ' (<a href="/w/' + url_pas(name) + '">' + name + \
- '</a> - <a href="/w/' + url_pas(request.form['title']) + '">' + request.form['title'] + '</a> ์ด๋)', leng)
- curs.execute("select title, link from back where title = ? and not type = 'cat' and not type = 'no'", [name])
- for data in curs.fetchall():
- curs.execute("insert into back (title, link, type) values (?, ?, 'no')", [data[0], data[1]])
-
- curs.execute("update history set title = ? where title = ?", [request.form['title'], name])
- conn.commit()
-
- return redirect('/w/' + url_pas(request.form['title']))
- else:
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (์ด๋)', 0])],
- data = '<form method="post"> \
- ' + ip_warring(conn) + ' \
- <input placeholder="๋ฌธ์๋ช
" value="' + name + '" name="title" type="text"><hr> \
- <input placeholder="์ฌ์ " name="send" type="text"><hr> \
- ' + captcha_get(conn) + ' \
- <button type="submit">์ด๋</button> \
- </form>',
- menu = [['w/' + url_pas(name), '๋ฌธ์']]
- ))
-
- @app.route('/other')
- def other():
- return html_minify(template('index',
- imp = ['๊ธฐํ ๋ฉ๋ด', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = namumark(conn, '', '[๋ชฉ์ฐจ(์์)]\r\n' + \
- '== ๊ธฐ๋ก ==\r\n' + \
- ' * [[wiki:block_log|์ฐจ๋จ ๊ธฐ๋ก]]\r\n' + \
- ' * [[wiki:user_log|๊ฐ์
๊ธฐ๋ก]]\r\n' + \
- ' * [[wiki:admin_log|๊ถํ ์ฌ์ฉ ๊ธฐ๋ก]]\r\n' + \
- ' * [[wiki:manager/6|ํธ์ง ๊ธฐ๋ก]]\r\n' + \
- ' * [[wiki:manager/7|ํ ๋ก ๊ธฐ๋ก]]\r\n' + \
- '== ๋ชฉ๋ก ==\r\n' + \
- ' * [[wiki:admin_list|๊ด๋ฆฌ์ ๋ชฉ๋ก]]\r\n' + \
- ' * [[wiki:give_log|๊ด๋ฆฌ ๊ทธ๋ฃน ๋ชฉ๋ก]]\r\n' +
- ' * [[wiki:not_close_topic|์ด๋ฆฐ ํ ๋ก ๋ชฉ๋ก]]\r\n' + \
- '== ๊ธฐํ ==\r\n' + \
- ' * [[wiki:title_index|๋ชจ๋ ๋ฌธ์]]\r\n' + \
- ' * [[wiki:acl_list|ACL ๋ฌธ์]]\r\n' + \
- ' * [[wiki:please|ํ์ํ ๋ฌธ์]]\r\n' + \
- ' * [[wiki:upload|ํ์ผ ์ฌ๋ฆฌ๊ธฐ]]\r\n' + \
- ' * [[wiki:manager/10|๋ฌธ์ ๊ฒ์]]\r\n' + \
- '== ๊ด๋ฆฌ์ ==\r\n' + \
- ' * [[wiki:manager/1|๊ด๋ฆฌ์ ๋ฉ๋ด]]\r\n' + \
- '== ๋ฒ์ ==\r\n' + \
- ' * ์ด ์คํ๋๋ฌด๋ [[https://github.com/2DU/openNAMU/blob/master/version.md|' + r_ver + ']] ์
๋๋ค.', 0, 0, 0),
- menu = 0
- ))
-
- @app.route('/manager', methods=['POST', 'GET'])
- @app.route('/manager/<int:num>', methods=['POST', 'GET'])
- def manager(num = 1):
- title_list = [['๋ฌธ์ ACL', '๋ฌธ์๋ช
', 'acl'], ['์ฌ์ฉ์ ๊ฒ์ฌ', 0, 'check'], ['์ฌ์ฉ์ ์ฐจ๋จ', 0, 'ban'], ['๊ถํ ์ฃผ๊ธฐ', 0, 'admin'], ['ํธ์ง ๊ธฐ๋ก', 0, 'record'], ['ํ ๋ก ๊ธฐ๋ก', 0, 'topic_record'], ['๊ทธ๋ฃน ์์ฑ', '๊ทธ๋ฃน๋ช
', 'admin_plus'], ['ํธ์ง ํํฐ ์์ฑ', 'ํํฐ๋ช
', 'edit_filter'], ['๋ฌธ์ ๊ฒ์', '๋ฌธ์๋ช
', 'search'], ['์ฐจ๋จ์ ๊ฒ์', 0, 'block_user'], ['๊ด๋ฆฌ์ ๊ฒ์', 0, 'block_admin'], ['์ฃผ์ ๋ฌธ์ ์ถ๊ฐ', '๋ฌธ์๋ช
', 'watch_list']]
- if num == 1:
- return html_minify(template('index',
- imp = ['๊ด๋ฆฌ์ ๋ฉ๋ด', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = namumark(conn, '', '[๋ชฉ์ฐจ(์์)]\r\n' + \
- '== ๋ชฉ๋ก ==\r\n' + \
- ' * [[wiki:manager/2|๋ฌธ์ ACL]]\r\n' + \
- ' * [[wiki:manager/3|์ฌ์ฉ์ ๊ฒ์ฌ]]\r\n' + \
- ' * [[wiki:manager/4|์ฌ์ฉ์ ์ฐจ๋จ]]\r\n' + \
- ' * [[wiki:manager/5|๊ถํ ์ฃผ๊ธฐ]]\r\n' + \
- ' * [[wiki:big_delete|์ฌ๋ฌ ๋ฌธ์ ์ญ์ ]]\r\n' + \
- ' * [[wiki:edit_filter|ํธ์ง ํํฐ]]\r\n' + \
- '== ์์ ์ ==\r\n' + \
- ' * [[wiki:indexing|์ธ๋ฑ์ฑ (์์ฑ or ์ญ์ )]]\r\n' + \
- ' * [[wiki:manager/8|๊ด๋ฆฌ ๊ทธ๋ฃน ์์ฑ]]\r\n' + \
- ' * [[wiki:edit_set|์ค์ ํธ์ง]]\r\n' + \
- ' * [[wiki:re_start|์๋ฒ ์ฌ ์์]]\r\n' + \
- ' * [[wiki:inter_wiki|์ธํฐ์ํค]]\r\n' + \
- '== ๊ธฐํ ==\r\n' + \
- ' * ์ด ๋ฉ๋ด์ ์๋ ๊ธฐ๋ฅ์ ํด๋น ๋ฌธ์์ ์ญ์ฌ๋ ํ ๋ก ์์ ๋ฐ๋ก ์ฌ์ฉ ๊ฐ๋ฅํจ', 0, 0, 0),
- menu = [['other', '๊ธฐํ']]
- ))
- elif num in range(2, 14):
- if request.method == 'POST':
- return redirect('/' + title_list[(num - 2)][2] + '/' + url_pas(request.form['name']))
- else:
- if title_list[(num - 2)][1] == 0:
- placeholder = '์ฌ์ฉ์๋ช
'
- else:
- placeholder = title_list[(num - 2)][1]
- return html_minify(template('index',
- imp = [title_list[(num - 2)][0], wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post"> \
- <input placeholder="' + placeholder + '" name="name" type="text"><hr> \
- <button type="submit">์ด๋</button> \
- </form>',
- menu = [['manager', '๊ด๋ฆฌ์']]
- ))
- else:
- return redirect('/')
-
- @app.route('/title_index')
- def title_index():
- page = int(request.args.get('page', 1))
- num = int(request.args.get('num', 100))
- if page * num > 0:
- sql_num = page * num - num
- else:
- sql_num = 0
- if num != 0:
- all_list = sql_num + 1
- else:
- all_list = 1
- if num > 1000:
- return re_error(conn, '/error/3')
- data = '<ul><a href="/title_index?num=0">(์ ์ฒด)</a> <a href="/title_index?num=250">(250)</a> <a href="/title_index?num=500">(500)</a> <a href="/title_index?num=1000">(1000)</a>'
- if num == 0:
- curs.execute("select data from other where name = 'all_title'")
- all_title_can = curs.fetchall()
- if all_title_can and all_title_can[0][0] != '':
- return re_error(conn, '/error/3')
- curs.execute("select title from data order by title asc")
- else:
- curs.execute("select title from data order by title asc limit ?, ?", [str(sql_num), str(num)])
- title_list = curs.fetchall()
- if title_list:
- data += '<hr>'
- for list_data in title_list:
- data += '<li>' + str(all_list) + '. <a href="/w/' + url_pas(list_data[0]) + '">' + list_data[0] + '</a></li>'
- all_list += 1
- if page == 1:
- count_end = []
- curs.execute("select count(title) from data")
- count = curs.fetchall()
- if count:
- count_end += [count[0][0]]
- else:
- count_end += [0]
- sql_list = ['ํ:', '๋ถ๋ฅ:', '์ฌ์ฉ์:', 'ํ์ผ:']
- for sql in sql_list:
- curs.execute("select count(title) from data where title like ?", [sql + '%'])
- count = curs.fetchall()
- if count:
- count_end += [count[0][0]]
- else:
- count_end += [0]
- count_end += [count_end[0] - count_end[1] - count_end[2] - count_end[3] - count_end[4]]
- data += '</ul><hr><ul><li>์ด ์ํค์๋ ์ด ' + str(count_end[0]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li></ul><hr><ul>'
- data += '<li>ํ ๋ฌธ์๋ ์ด ' + str(count_end[1]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li>'
- data += '<li>๋ถ๋ฅ ๋ฌธ์๋ ์ด ' + str(count_end[2]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li>'
- data += '<li>์ฌ์ฉ์ ๋ฌธ์๋ ์ด ' + str(count_end[3]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li>'
- data += '<li>ํ์ผ ๋ฌธ์๋ ์ด ' + str(count_end[4]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li>'
- data += '<li>๋๋จธ์ง ๋ฌธ์๋ ์ด ' + str(count_end[5]) + '๊ฐ์ ๋ฌธ์๊ฐ ์์ต๋๋ค.</li>'
- if num != 0:
- data += '</ul>' + next_fix('/title_index?num=' + str(num) + '&page=', page, title_list, num)
-
- if ' (' + str(num) + '๊ฐ)' == ' (0๊ฐ)':
- sub = 0
- else:
- sub = ' (' + str(num) + '๊ฐ)'
-
- return html_minify(template('index',
- imp = ['๋ชจ๋ ๋ฌธ์', wiki_set(conn, 1), custom(conn), other2([sub, 0])],
- data = data,
- menu = [['other', '๊ธฐํ']]
- ))
-
- @app.route('/topic/<path:name>/sub/<sub>/b/<int:num>')
- def topic_block(name = None, sub = None, num = None):
- if admin_check(conn, 3, 'blind (' + name + ' - ' + sub + '#' + str(num) + ')') != 1:
- return re_error(conn, '/error/3')
- 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)])
-
- rd_plus(conn, name, sub, get_time())
- conn.commit()
-
- return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '#' + str(num))
-
- @app.route('/topic/<path:name>/sub/<sub>/notice/<int:num>')
- def topic_top(name = None, sub = None, num = None):
- if admin_check(conn, 3, 'notice (' + name + ' - ' + sub + '#' + str(num) + ')') != 1:
- return re_error(conn, '/error/3')
- 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)])
-
- rd_plus(conn, name, sub, get_time())
- conn.commit()
- return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '#' + str(num))
-
- @app.route('/topic/<path:name>/sub/<sub>/tool/<regex("close|stop|agree"):tool>')
- def topic_stop(name = None, sub = None, tool = None):
- if tool == 'close':
- set_list = ['O', '', 'ํ ๋ก ๋ซ๊ธฐ', 'ํ ๋ก ์ด๋ฆผ']
- elif tool == 'stop':
- set_list = ['', 'O', 'ํ ๋ก ์ ์ง', 'ํ ๋ก ์ฌ๊ฐ']
- elif tool == 'agree':
- pass
- else:
- return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
- if admin_check(conn, 3, 'topic ' + tool + ' (' + name + ' - ' + sub + ')') != 1:
- return re_error(conn, '/error/3')
- ip = ip_check()
- time = get_time()
-
- 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:
- if tool == 'agree':
- curs.execute("select title from agreedis where title = ? and sub = ?", [name, sub])
- if curs.fetchall():
- 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])
- else:
- curs.execute("select title from stop where title = ? and sub = ? and close = ?", [name, sub, set_list[0]])
- if curs.fetchall():
- curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '1')", \
- [str(int(topic_check[0][0]) + 1), name, sub, set_list[3], time, ip])
- curs.execute("delete from stop where title = ? and sub = ? and close = ?", [name, sub, set_list[0]])
- 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, set_list[2], time, ip])
- curs.execute("insert into stop (title, sub, close) values (?, ?, ?)", [name, sub, set_list[0]])
- curs.execute("delete from stop where title = ? and sub = ? and close = ?", [name, sub, set_list[1]])
-
- rd_plus(conn, name, sub, time)
- conn.commit()
-
- return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
- @app.route('/topic/<path:name>/sub/<sub>/admin/<int:num>')
- def topic_admin(name = None, sub = None, num = None):
- curs.execute("select block, ip, date from topic where title = ? and sub = ? and id = ?", [name, sub, str(num)])
- data = curs.fetchall()
- if not data:
- return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
- ban = ''
- if admin_check(conn, 3, None) == 1:
- ban += '== ๊ด๋ฆฌ ๋๊ตฌ ==\r\n'
- is_ban = ' * [[wiki:topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/b/' + str(num) + '|'
- if data[0][0] == 'O':
- is_ban += '๊ฐ๋ฆผ ํด์ '
- else:
- is_ban += '๊ฐ๋ฆผ'
- is_ban += ']]\r\n'
- curs.execute("select id from topic where title = ? and sub = ? and id = ? and top = 'O'", [name, sub, str(num)])
- is_ban += ' * [[wiki:topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/notice/' + str(num) + '|'
- if curs.fetchall():
- is_ban += '๊ณต์ง ํด์ '
- else:
- is_ban += '๊ณต์ง'
- is_ban += ']]\r\n'
- curs.execute("select end from ban where block = ?", [data[0][1]])
- ban += ' * [[wiki:ban/' + url_pas(data[0][1]) + '|'
- if curs.fetchall():
- ban += '์ฐจ๋จ ํด์ '
- else:
- ban += '์ฐจ๋จ'
- ban += ']]\r\n' + is_ban
- ban += '== ๊ธฐํ ๋๊ตฌ ==\r\n'
- ban += ' * [[wiki:topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/raw/' + str(num) + '|์๋ณธ]]\r\n'
- ban = ' * ์์ฑ ์๊ฐ : ' + data[0][2] + '\r\n' + ban
- if re.search('(\.|:)', data[0][1]):
- ban = ' * ์์ฑ์ธ : ' + data[0][1] + ' [[wiki:record/' + url_pas(data[0][1]) + '|(๊ธฐ๋ก)]]\r\n' + ban
- else:
- ban = ' * ์์ฑ์ธ : [[์ฌ์ฉ์:' + data[0][1] + '|' + data[0][1] + ']] [[wiki:record/' + url_pas(data[0][1]) + '|(๊ธฐ๋ก)]]\r\n' + ban
- ban = '== ์ ๋ณด ==\r\n' + ban
- ban = '[๋ชฉ์ฐจ(์์)]\r\n' + ban
- return html_minify(template('index',
- imp = ['ํ ๋ก ๋๊ตฌ', wiki_set(conn, 1), custom(conn), other2([' (' + str(num) + '๋ฒ)', 0])],
- data = namumark(conn, '', ban, 0, 0, 0),
- menu = [['topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '#' + str(num), 'ํ ๋ก ']]
- ))
- @app.route('/topic/<path:name>/sub/<sub>', methods=['POST', 'GET'])
- def topic(name = None, sub = None):
- ban = topic_check(conn, name, sub)
- admin = admin_check(conn, 3, None)
-
- if request.method == 'POST':
- if captcha_post(request.form.get('g-recaptcha-response', None), conn) == 1:
- return re_error(conn, '/error/13')
- else:
- captcha_post('', conn, 0)
- ip = ip_check()
- today = get_time()
- if ban == 1 and admin != 1:
- return re_error(conn, '/ban')
-
- curs.execute("select id from topic where title = ? and sub = ? order by id + 0 desc limit 1", [name, sub])
- old_num = curs.fetchall()
- if old_num:
- num = int(old_num[0][0]) + 1
- else:
- num = 1
- match = re.search('^์ฌ์ฉ์:([^/]+)', name)
- if match:
- curs.execute('insert into alarm (name, data, date) values (?, ?, ?)', [match.groups()[0], ip + '๋์ด <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '">์ฌ์ฉ์ ํ ๋ก </a>์ ์์ํ์ต๋๋ค.', today])
-
- data = re.sub("\[\[(๋ถ๋ฅ:(?:(?:(?!\]\]).)*))\]\]", "[br]", request.form['content'])
- match = re.findall("(?:#([0-9]+))", data)
- for rd_data in match:
- curs.execute("select ip from topic where title = ? and sub = ? and id = ?", [name, sub, rd_data])
- ip_data = curs.fetchall()
- if ip_data and not re.search('(\.|:)', ip_data[0][0]):
- curs.execute('insert into alarm (name, data, date) values (?, ?, ?)', [ip_data[0][0], ip + '๋์ด <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '#' + str(num) + '">ํ ๋ก </a>์์ ์ธ๊ธ ํ์ต๋๋ค.', today])
- data = re.sub("(?P<in>#(?:[0-9]+))", '[[\g<in>]]', data)
- data = savemark(data)
- rd_plus(conn, name, sub, today)
- curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '')", [str(num), name, sub, data, today, ip])
- conn.commit()
-
- return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
- else:
- curs.execute("select title from stop where title = ? and sub = ? and close = 'O'", [name, sub])
- close_data = curs.fetchall()
- curs.execute("select title from stop where title = ? and sub = ? and close = ''", [name, sub])
- stop_data = curs.fetchall()
- curs.execute("select id from topic where title = ? and sub = ? limit 1", [name, sub])
- topic_exist = curs.fetchall()
-
- display = ''
- all_data = ''
- data = ''
- number = 1
- if admin == 1 and topic_exist:
- if close_data:
- all_data += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/close">(์ด๊ธฐ)</a> '
- else:
- all_data += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/close">(๋ซ๊ธฐ)</a> '
-
- if stop_data:
- all_data += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/stop">(์ฌ๊ฐ)</a> '
- else:
- all_data += '<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])
- if curs.fetchall():
- all_data += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/agree">(์ทจ์)</a>'
- else:
- all_data += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/agree">(ํฉ์)</a>'
-
- all_data += '<hr>'
-
- if (close_data or stop_data) and admin != 1:
- display = 'display: none;'
-
- curs.execute("select data, id, date, ip, block, top from topic where title = ? and sub = ? order by id + 0 asc", [name, sub])
- topic_1 = 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])
- topic_2 = curs.fetchall()
- for topic_data in topic_2:
- who_plus = ''
- curs.execute("select who from re_admin where what = ? order by time desc limit 1", ['notice (' + name + ' - ' + sub + '#' + topic_data[1] + ')'])
- topic_data_top = curs.fetchall()
- if topic_data_top:
- who_plus += ' <span style="margin-right: 5px;">@' + topic_data_top[0][0] + ' </span>'
-
- all_data += '<table id="toron"><tbody><tr><td id="toron_color_red">'
- all_data += '<a href="#' + topic_data[1] + '">#' + topic_data[1] + '</a> ' + ip_pas(conn, topic_data[3]) + who_plus + ' <span style="float: right;">' + topic_data[2] + '</span>'
- all_data += '</td></tr><tr><td>' + namumark(conn, '', topic_data[0], 0, 0, 0) + '</td></tr></tbody></table><br>'
- for topic_data in topic_1:
- if number == 1:
- start = topic_data[3]
- if topic_data[4] == 'O':
- blind_data = 'style="background: gainsboro;"'
- if admin != 1:
- curs.execute("select who from re_admin where what = ? order by time desc limit 1", ['blind (' + name + ' - ' + sub + '#' + str(number) + ')'])
- who_blind = curs.fetchall()
- if who_blind:
- user_write = '[[์ฌ์ฉ์:' + who_blind[0][0] + ']]๋์ด ๊ฐ๋ฆผ'
- else:
- user_write = '๊ด๋ฆฌ์๊ฐ ๊ฐ๋ฆผ'
- else:
- blind_data = ''
- user_write = namumark(conn, '', topic_data[0], 0, 0, 0)
- ip = ip_pas(conn, topic_data[3])
- curs.execute('select acl from user where id = ?', [topic_data[3]])
- user_acl = curs.fetchall()
- if user_acl and user_acl[0][0] != 'user':
- ip += ' <a href="javascript:void(0);" title="๊ด๋ฆฌ์">โ
</a>'
- if admin == 1 or blind_data == '':
- ip += ' <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/admin/' + str(number) + '">(๋๊ตฌ)</a>'
- curs.execute("select end from ban where block = ?", [topic_data[3]])
- if curs.fetchall():
- ip += ' <a href="javascript:void(0);" title="์ฐจ๋จ์">โ </a>'
-
- if topic_data[5] == '1':
- color = '_blue'
- elif topic_data[3] == start:
- color = '_green'
- else:
- color = ''
-
- if user_write == '':
- user_write = '<br>'
-
- all_data += '<table id="toron"><tbody><tr><td id="toron_color' + color + '">'
- all_data += '<a href="javascript:void(0);" id="' + str(number) + '">#' + str(number) + '</a> ' + ip + '</span>'
- all_data += '</td></tr><tr ' + blind_data + '><td>' + user_write + '</td></tr></tbody></table><br>'
- number += 1
- if ban != 1 or admin == 1:
- data += '<a id="reload" href="javascript:void(0);" onclick="location.href.endsWith(\'#reload\') ? ' + \
- 'location.reload(true) : location.href = \'#reload\'"><i aria-hidden="true" class="fa fa-refresh"></i></a>' + \
- '<form style="' + display + '" method="post"><br><textarea style="height: 100px;" name="content"></textarea><hr>' + captcha_get(conn)
-
- if display == '':
- data += ip_warring(conn)
- data += '<button type="submit">์ ์ก</button></form>'
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (ํ ๋ก )', 0])],
- data = '<h2 id="topic_top_title">' + sub + '</h2><hr id="under_bar" style="margin-top: -5px;">' + all_data + data,
- menu = [['topic/' + url_pas(name), '๋ชฉ๋ก']]
- ))
-
- @app.route('/topic/<path:name>', methods=['POST', 'GET'])
- @app.route('/topic/<path:name>/<regex("close|agree"):tool>', methods=['GET'])
- def close_topic_list(name = None, tool = None):
- div = ''
- 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.form['topic'] + t_num])
- if curs.fetchall():
- 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.form['topic'] + t_num))
- else:
- plus = ''
- menu = [['topic/' + url_pas(name), '๋ชฉ๋ก']]
- 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:
- curs.execute("select sub from rd where title = ? order by date desc", [name])
- sub = 'ํ ๋ก ๋ชฉ๋ก'
- menu = [['w/' + url_pas(name), '๋ฌธ์']]
- plus = '<a href="/topic/' + url_pas(name) + '/close">(๋ซํ)</a> <a href="/topic/' + url_pas(name) + '/agree">(ํฉ์)</a><hr> \
- <input placeholder="ํ ๋ก ๋ช
" class="form-control" name="topic" type="text"><hr> \
- <button type="submit">๋ง๋ค๊ธฐ</button>'
- for data in curs.fetchall():
- curs.execute("select data, date, ip, block from topic where title = ? and sub = ? and id = '1'", [name, data[0]])
- if(curs.fetchall()):
- it_p = 0
- if sub == 'ํ ๋ก ๋ชฉ๋ก':
- curs.execute("select title from stop where title = ? and sub = ? and close = 'O' order by sub asc", [name, data[0]])
- close = curs.fetchall()
- if close:
- it_p = 1
-
- if it_p != 1:
- div += '<h2><a href="/topic/' + url_pas(name) + '/sub/' + url_pas(data[0]) + '">' + data[0] + \
- '</a></h2><hr id="under_bar" style="margin-top: -5px;">'
- if div == '':
- plus = re.sub('^<br>', '', plus)
-
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (' + sub + ')', 0])],
- data = '<form method="post">' + div + plus + '</form>',
- menu = menu
- ))
-
- @app.route('/login', methods=['POST', 'GET'])
- def login():
- if 'Now' in session and session['Now'] == 1:
- return re_error(conn, '/error/11')
- ip = ip_check()
- agent = request.headers.get('User-Agent')
-
- curs.execute("select block from ban where block = ? and login = 'O'", [ip])
- if not curs.fetchall():
- ban = ban_check(conn)
- else:
- ban = 0
- if ban == 1:
- return re_error(conn, '/ban')
-
- if request.method == 'POST':
- if captcha_post(request.form.get('g-recaptcha-response', None), conn) == 1:
- return re_error(conn, '/error/13')
- else:
- captcha_post('', conn, 0)
- curs.execute("select pw from user where id = ?", [request.form['id']])
- user = curs.fetchall()
- if not user:
- return re_error(conn, '/error/5')
- if not bcrypt.checkpw(bytes(request.form['pw'], 'utf-8'), bytes(user[0][0], 'utf-8')):
- return re_error(conn, '/error/10')
- session['Now'] = 1
- session['DREAMER'] = request.form['id']
- curs.execute("select css from custom where user = ?", [request.form['id']])
- css_data = curs.fetchall()
- if css_data:
- session['Daydream'] = css_data[0][0]
- else:
- session['Daydream'] = ''
-
- curs.execute("insert into ua_d (name, ip, ua, today, sub) values (?, ?, ?, ?, '')", [request.form['id'], ip, agent, get_time()])
- conn.commit()
-
- return redirect('/user')
- else:
- return html_minify(template('index',
- imp = ['๋ก๊ทธ์ธ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post"> \
- <input placeholder="์์ด๋" name="id" type="text"><hr> \
- <input placeholder="๋น๋ฐ๋ฒํธ" name="pw" type="password"><hr> \
- ' + captcha_get(conn) + ' \
- <button type="submit">๋ก๊ทธ์ธ</button><hr> \
- <span>์ฃผ์ : ๋ง์ฝ HTTPS ์ฐ๊ฒฐ์ด ์๋ ๊ฒฝ์ฐ ๋ฐ์ดํฐ๊ฐ ์ ์ถ๋ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค. ์ด์ ๋ํด ์ฑ
์์ง์ง ์์ต๋๋ค.</span> \
- </form>',
- menu = [['user', '์ฌ์ฉ์']]
- ))
-
- @app.route('/change', methods=['POST', 'GET'])
- def change_password():
- ban = ban_check(conn)
-
- if request.method == 'POST':
- if request.form['pw2'] != request.form['pw3']:
- return re_error(conn, '/error/20')
- if ban == 1:
- return re_error(conn, '/ban')
- curs.execute("select pw from user where id = ?", [session['DREAMER']])
- user = curs.fetchall()
- if not user:
- return re_error(conn, '/error/10')
- if custom(conn)[2] == 0:
- return redirect('/login')
- if not bcrypt.checkpw(bytes(request.form['pw'], 'utf-8'), bytes(user[0][0], 'utf-8')):
- return re_error(conn, '/error/5')
- hashed = bcrypt.hashpw(bytes(request.form['pw2'], 'utf-8'), bcrypt.gensalt())
-
- curs.execute("update user set pw = ? where id = ?", [hashed.decode(), session['DREAMER']])
- conn.commit()
-
- return redirect('/user')
- else:
- if ban == 1:
- return re_error(conn, '/ban')
- if custom(conn)[2] == 0:
- return redirect('/login')
- return html_minify(template('index',
- imp = ['๋น๋ฐ๋ฒํธ ๋ณ๊ฒฝ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post"> \
- <input placeholder="ํ์ฌ ๋น๋ฐ๋ฒํธ" name="pw" type="password"><hr> \
- <input placeholder="๋ณ๊ฒฝํ ๋น๋ฐ๋ฒํธ" name="pw2" type="password"><hr> \
- <input placeholder="์ฌ ํ์ธ" name="pw3" type="password"><hr> \
- <button type="submit">๋ณ๊ฒฝ</button><hr> \
- <span>์ฃผ์ : ๋ง์ฝ HTTPS ์ฐ๊ฒฐ์ด ์๋ ๊ฒฝ์ฐ ๋ฐ์ดํฐ๊ฐ ์ ์ถ๋ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค. ์ด์ ๋ํด ์ฑ
์์ง์ง ์์ต๋๋ค.</span> \
- </form>',
- menu = [['user', '์ฌ์ฉ์']]
- ))
-
- @app.route('/check/<name>')
- def user_check(name = None):
- if admin_check(conn, 4, 'check (' + name + ')') != 1:
- return re_error(conn, '/error/3')
- curs.execute("select acl from user where id = ? or id = ?", [name, request.args.get('plus', 'None-Data')])
- user = curs.fetchall()
- if user and user[0][0] != 'user':
- if admin_check(conn, None, None) != 1:
- return re_error(conn, '/error/4')
-
- if request.args.get('plus', None):
- if re.search('(?:\.|:)', name):
- if re.search('(?:\.|:)', request.args.get('plus', None)):
- curs.execute("select name, ip, ua, today from ua_d where ip = ? or ip = ? order by today desc", [name, request.args.get('plus', None)])
- else:
- curs.execute("select name, ip, ua, today from ua_d where ip = ? or name = ? order by today desc", [name, request.args.get('plus', None)])
- else:
- if re.search('(?:\.|:)', request.args.get('plus', None)):
- curs.execute("select name, ip, ua, today from ua_d where name = ? or ip = ? order by today desc", [name, request.args.get('plus', None)])
- else:
- curs.execute("select name, ip, ua, today from ua_d where name = ? or name = ? order by today desc", [name, request.args.get('plus', None)])
- elif re.search('(?:\.|:)', name):
- curs.execute("select name, ip, ua, today from ua_d where ip = ? order by today desc", [name])
- else:
- curs.execute("select name, ip, ua, today from ua_d where name = ? order by today desc", [name])
-
- record = curs.fetchall()
- if record:
- if not request.args.get('plus', None):
- div = '<a href="/plus_check/' + url_pas(name) + '">(๋น๊ต)</a><hr>'
- else:
- div = '<a href="/check/' + url_pas(name) + '">(์ฃผ์ ๋์)</a> <a href="/check/' + url_pas(request.args.get('plus', None)) + '">(๋น๊ต ๋์)</a><hr>'
- div += '<table style="width: 100%; text-align: center;"><tbody><tr>'
- div += '<td style="width: 33.3%;">์ด๋ฆ</td><td style="width: 33.3%;">์์ดํผ</td><td style="width: 33.3%;">์ธ์ </td></tr>'
- for data in record:
- if data[2]:
- ua = data[2]
- else:
- ua = '<br>'
- div += '<tr><td>' + ip_pas(conn, data[0]) + '</td><td>' + ip_pas(conn, data[1]) + '</td><td>' + data[3] + '</td></tr>'
- div += '<tr><td colspan="3">' + ua + '</td></tr>'
-
- div += '</tbody></table>'
- else:
- return re_error(conn, '/error/5')
-
- return html_minify(template('index',
- imp = ['๋ค์ค ๊ฒ์ฌ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = div,
- menu = [['manager', '๊ด๋ฆฌ์']]
- ))
- @app.route('/plus_check/<name>', methods=['POST', 'GET'])
- def plus_check(name):
- if request.method == 'POST':
- return redirect('/check/' + url_pas(name) + '?plus=' + url_pas(request.form['name2']))
- else:
- return html_minify(template('index',
- imp = ['๋์ ์ถ๊ฐ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post"> \
- <input placeholder="๋น๊ต ๋์" name="name2" type="text"><hr> \
- <button type="submit">์ด๋</button> \
- </form>',
- menu = [['manager', '๊ด๋ฆฌ์']]
- ))
-
- @app.route('/register', methods=['POST', 'GET'])
- def register():
- ban = ban_check(conn)
- if ban == 1:
- return re_error(conn, '/ban')
- if not admin_check(conn, None, None) == 1:
- curs.execute('select data from other where name = "reg"')
- set_d = curs.fetchall()
- if set_d and set_d[0][0] == 'on':
- return re_error(conn, '/ban')
-
- if request.method == 'POST':
- if captcha_post(request.form.get('g-recaptcha-response', None), conn) == 1:
- return re_error(conn, '/error/13')
- else:
- captcha_post('', conn, 0)
- if request.form['pw'] != request.form['pw2']:
- return re_error(conn, '/error/20')
- if re.search('(?:[^A-Za-zใฑ-ํฃ0-9 ])', request.form['id']):
- return re_error(conn, '/error/8')
- if len(request.form['id']) > 32:
- return re_error(conn, '/error/7')
- curs.execute("select id from user where id = ?", [request.form['id']])
- if curs.fetchall():
- return re_error(conn, '/error/6')
- hashed = bcrypt.hashpw(bytes(request.form['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, date, email) values (?, ?, 'owner', ?, ?)", \
- [request.form['id'], hashed.decode(), get_time(), request.form.get('email', '')])
- else:
- curs.execute("insert into user (id, pw, acl, date, email) values (?, ?, 'user', ?, ?)", \
- [request.form['id'], hashed.decode(), get_time(), request.form.get('email', '')])
- conn.commit()
-
- return redirect('/login')
- else:
- contract = ''
- curs.execute('select data from other where name = "contract"')
- data = curs.fetchall()
- if data and data[0][0] != '':
- contract = data[0][0] + '<hr>'
- return html_minify(template('index',
- imp = ['ํ์๊ฐ์
', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post"> \
- ' + contract + ' \
- <input placeholder="์์ด๋" name="id" type="text"><hr> \
- <input placeholder="๋น๋ฐ๋ฒํธ" name="pw" type="password"><hr> \
- <input placeholder="๋ค์" name="pw2" type="password"><hr> \
- <input placeholder="์ด๋ฉ์ผ (์ ํ)" name="email" type="text"><hr> \
- ' + captcha_get(conn) + ' \
- <button type="submit">๊ฐ์
</button><hr> \
- <span>์ฃผ์ : ๋ง์ฝ HTTPS ์ฐ๊ฒฐ์ด ์๋ ๊ฒฝ์ฐ ๋ฐ์ดํฐ๊ฐ ์ ์ถ๋ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค. ์ด์ ๋ํด ์ฑ
์์ง์ง ์์ต๋๋ค.</span> \
- </form>',
- menu = [['user', '์ฌ์ฉ์']]
- ))
-
- @app.route('/logout')
- def logout():
- session['Now'] = 0
- session.pop('DREAMER', None)
- return redirect('/user')
-
- @app.route('/ban/<name>', methods=['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':
- if admin_check(conn, None, None) != 1:
- return re_error(conn, '/error/4')
- if request.method == 'POST':
- if admin_check(conn, 1, 'ban (' + name + ')') != 1:
- return re_error(conn, '/error/3')
- ip = ip_check()
- time = get_time()
- time_list = [request.form['month'], request.form['day'], request.form['hour'], request.form['minu']]
- num = 0
- for time_fix in time_list:
- if not re.search("[0-9]{2}", time_fix):
- time_list[num] = '0' + time_fix
-
- num += 1
-
- if request.form['year'] == '09':
- end = ''
- else:
- end = request.form['year'] + '-' + time_list[0] + '-' + time_list[1] + ' ' + time_list[2] + ':' + time_list[3] + ':00'
- curs.execute("select block from ban where block = ?", [name])
- if curs.fetchall():
- curs.execute("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, '')", [name, 'ํด์ ', time, ip, ''])
- curs.execute("delete from ban where block = ?", [name])
- else:
- if re.search("^([0-9]{1,3}\.[0-9]{1,3})$", name):
- band_d = 'O'
- else:
- band_d = ''
- if request.form['login_ok'] != '':
- login = 'O'
- else:
- login = ''
- curs.execute("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, ?)", \
- [name, end, time, ip, request.form['why'], band_d])
- curs.execute("insert into ban (block, end, why, band, login) values (?, ?, ?, ?, ?)", \
- [name, end, request.form['why'], band_d, login])
- conn.commit()
- return redirect('/ban/' + url_pas(name))
- else:
- if admin_check(conn, 1, None) != 1:
- return re_error(conn, '/error/3')
- curs.execute("select end from ban where block = ?", [name])
- end = curs.fetchall()
- if end:
- now = '์ฐจ๋จ ํด์ '
- if end[0][0] == '':
- data = '์๊ตฌ ์ฐจ๋จ<hr>'
- else:
- data = end[0][0] + ' ๊น์ง ์ฐจ๋จ<hr>'
- else:
- if re.search("^([0-9]{1,3}\.[0-9]{1,3})$", name):
- now = '๋์ญ ์ฐจ๋จ'
- else:
- now = '์ฐจ๋จ'
- now_time = get_time()
- m = re.search('^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):[0-9]{2}', now_time)
- g = m.groups()
- year = '<option value="09">์๊ตฌ</option>'
- for i in range(int(g[0]), int(g[0]) + 11):
- if i == int(g[0]):
- year += '<option value="' + str(i) + '" selected>' + str(i) + '</option>'
- else:
- year += '<option value="' + str(i) + '">' + str(i) + '</option>'
- month = ''
- for i in range(1, 13):
- if i == int(g[1]):
- month += '<option value="' + str(i) + '" selected>' + str(i) + '</option>'
- else:
- month += '<option value="' + str(i) + '">' + str(i) + '</option>'
-
- day = ''
- for i in range(1, 32):
- if i == int(g[2]):
- day += '<option value="' + str(i) + '" selected>' + str(i) + '</option>'
- else:
- day += '<option value="' + str(i) + '">' + str(i) + '</option>'
- hour = ''
- for i in range(0, 24):
- if i == int(g[3]):
- hour += '<option value="' + str(i) + '" selected>' + str(i) + '</option>'
- else:
- hour += '<option value="' + str(i) + '">' + str(i) + '</option>'
- minu = ''
- for i in range(0, 61):
- if i == int(g[4]):
- minu += '<option value="' + str(i) + '" selected>' + str(i) + '</option>'
- else:
- minu += '<option value="' + str(i) + '">' + str(i) + '</option>'
- is_it = ''
- if re.search('(\.|:)', name):
- plus = '<input type="checkbox" name="login_ok"> ๋ก๊ทธ์ธ ๊ฐ๋ฅ<hr>'
- else:
- plus = ''
-
- data = '<select name="year">' + year + '</select> ๋
'
- data += '<select name="month">' + month + '</select> ์ '
- data += '<select name="day">' + day + '</select> ์ผ <hr>'
- data += '<select name="hour">' + hour + '</select> ์ '
- data += '<select name="minu">' + minu + '</select> ๋ถ ๊น์ง<hr>'
- data += '<input placeholder="์ฌ์ " class="form-control" name="why" type="text"><br>' + plus
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (' + now + ')', 0])],
- data = '<form method="post">' + data + '<button type="submit">' + now + '</button></form>',
- menu = [['manager', '๊ด๋ฆฌ์']]
- ))
-
- @app.route('/acl/<path:name>', methods=['POST', 'GET'])
- def acl(name = None):
- test = re.search('^์ฌ์ฉ์:(.+)$', name)
- if request.method == 'POST':
- if test:
- test = test.groups()
- ip = ip_check()
- if custom(conn)[2] == 0:
- return redirect('/login')
- elif test[0] != ip:
- if admin_check(conn, 5, 'acl (' + name + ')') != 1:
- return re_error(conn, '/error/3')
- else:
- if admin_check(conn, 5, 'acl (' + name + ')') != 1:
- return re_error(conn, '/error/3')
- if request.form['select'] == 'admin':
- sql = 'admin'
- elif request.form['select'] == 'all':
- sql = 'all'
- elif request.form['select'] == 'user':
- sql = 'user'
- else:
- sql = ''
-
- if sql == '':
- curs.execute("delete from acl where title = ?", [name])
- else:
- curs.execute("select title from acl where title = ?", [name])
- if curs.fetchall():
- curs.execute("update acl set dec = ? where title = ?", [sql, name])
- else:
- curs.execute("insert into acl (title, dec, dis, why) values (?, ?, '', '')", [name, sql])
- conn.commit()
-
- return redirect('/w/' + url_pas(name))
- else:
- if test:
- test = test.groups()
- ip = ip_check()
- if custom(conn)[2] == 0:
- return redirect('/login')
- elif test[0] != ip:
- if admin_check(conn, 5, 'acl (' + name + ')') != 1:
- return re_error(conn, '/error/3')
- else:
- if admin_check(conn, 5, 'acl (' + name + ')') != 1:
- return re_error(conn, '/error/3')
- acl_list = ['', '', '']
- curs.execute("select dec from acl where title = ?", [name])
- acl_d = curs.fetchall()
- if acl_d:
- if test and acl_d[0][0] == 'all':
- now = '๋ชจ๋'
- acl_list[0] = 'selected="selected"'
- elif not test and acl_d[0][0] == 'admin':
- now = '๊ด๋ฆฌ์'
- acl_list[0] = 'selected="selected"'
- elif acl_d[0][0] == 'user':
- now = '๊ฐ์
์'
- acl_list[1] = 'selected="selected"'
- else:
- now = '์ผ๋ฐ'
- acl_list[2] = 'selected="selected"'
- else:
- now = '์ผ๋ฐ'
- acl_list[2] = 'selected="selected"'
- if test:
- plus = '<option value="all" ' + acl_list[0] + '>๋ชจ๋</option>'
- else:
- plus = '<option value="admin" ' + acl_list[0] + '>๊ด๋ฆฌ์</option>'
-
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (ACL)', 0])],
- data = '<form method="post"> \
- <span>ํ์ฌ ACL : ' + now + '</span><hr> \
- <select name="select"> \
- ' + plus + ' \
- <option value="user" ' + acl_list[1] + '>๊ฐ์
์</option> \
- <option value="normal" ' + acl_list[2] + '>์ผ๋ฐ</option> \
- </select><hr> \
- <button type="submit">ACL ๋ณ๊ฒฝ</button> \
- </form>',
- menu = [['w/' + url_pas(name), '๋ฌธ์'], ['manager', '๊ด๋ฆฌ์']]
- ))
-
- @app.route('/admin/<name>', methods=['POST', 'GET'])
- def user_admin(name = None):
- owner = admin_check(conn, None, None)
- curs.execute("select acl from user where id = ?", [name])
- user = curs.fetchall()
- if not user:
- return re_error(conn, '/error/5')
- else:
- if owner != 1:
- curs.execute('select name from alist where name = ? and acl = "owner"', [user[0][0]])
- if curs.fetchall():
- return re_error(conn, '/error/3')
- if ip_check() == name:
- return re_error(conn, '/error/3')
- if request.method == 'POST':
- if admin_check(conn, 7, 'admin (' + name + ')') != 1:
- return re_error(conn, '/error/3')
- curs.execute('select name from alist where name = ? and acl = "owner"', [request.form['select']])
- if curs.fetchall():
- return re_error(conn, '/error/3')
- if request.form['select'] == 'X':
- curs.execute("update user set acl = 'user' where id = ?", [name])
- else:
- curs.execute("update user set acl = ? where id = ?", [request.form['select'], name])
- conn.commit()
-
- return redirect('/admin/' + url_pas(name))
- else:
- if admin_check(conn, 7, None) != 1:
- return re_error(conn, '/error/3')
- div = '<option value="X">X</option>'
-
- curs.execute('select distinct name from alist order by name asc')
- get_alist = curs.fetchall()
- if get_alist:
- i = 0
- name_rem = ''
- for data in get_alist:
- if user[0][0] == data[0]:
- div += '<option value="' + data[0] + '" selected="selected">' + data[0] + '</option>'
- else:
- if owner != 1:
- curs.execute('select name from alist where name = ? and acl = "owner"', [data[0]])
- if not curs.fetchall():
- div += '<option value="' + data[0] + '">' + data[0] + '</option>'
- else:
- div += '<option value="' + data[0] + '">' + data[0] + '</option>'
-
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (๊ถํ ๋ถ์ฌ)', 0])],
- data = '<form method="post"> \
- <select name="select">' + div + '</select><hr> \
- <button type="submit">๋ณ๊ฒฝ</button> \
- </form>',
- menu = [['manager', '๊ด๋ฆฌ์']]
- ))
-
- @app.route('/diff/<path:name>')
- def diff_data(name = None):
- first = request.args.get('first', '1')
- second = request.args.get('second', '1')
- curs.execute("select data from history where id = ? and title = ?", [first, name])
- first_raw_data = curs.fetchall()
- if first_raw_data:
- curs.execute("select data from history where id = ? and title = ?", [second, name])
- second_raw_data = curs.fetchall()
- if second_raw_data:
- first_data = html.escape(first_raw_data[0][0])
- second_data = html.escape(second_raw_data[0][0])
- if first == second:
- result = '๋ด์ฉ์ด ๊ฐ์ต๋๋ค.'
- else:
- diff_data = difflib.SequenceMatcher(None, first_data, second_data)
- result = diff(diff_data)
-
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (๋น๊ต)', 0])],
- data = '<pre>' + result + '</pre>',
- menu = [['history/' + url_pas(name), '์ญ์ฌ']]
- ))
- return redirect('/history/' + url_pas(name))
-
- @app.route('/down/<path:name>')
- def down(name = None):
- curs.execute("select title from data where title like ?", ['%' + name + '/%'])
- under = curs.fetchall()
-
- div = '<ul>'
- for data in under:
- div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a></li>'
-
- div += '</ul>'
-
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([' (ํ์)', 0])],
- data = div,
- menu = [['w/' + url_pas(name), '๋ฌธ์']]
- ))
- @app.route('/w/<path:name>')
- def read_view(name = None):
- data_none = 0
- sub = ''
- acl = ''
- div = ''
- topic = 0
- num = request.args.get('num', None)
- if num:
- num = int(num)
-
- if not num:
- if 'View_list' in session:
- m = re.findall('([^\n]+)\n', session['View_List'])
- if m[-1] != name:
- d = re.sub(name + '\n', '', session['View_List'])
- d += name + '\n'
- if len(m) > 50:
- d = re.sub('([^\n]+)\n', '', d, 1)
- session['View_List'] = d
- else:
- session['View_List'] = name + '\n'
- curs.execute("select sub from rd where title = ? order by date desc", [name])
- rd = curs.fetchall()
- for data in rd:
- curs.execute("select title from stop where title = ? and sub = ? and close = 'O'", [name, data[0]])
- if not curs.fetchall():
- topic = 1
- break
-
- curs.execute("select title from data where title like ?", ['%' + name + '/%'])
- if curs.fetchall():
- down = 1
- else:
- down = 0
-
- m = re.search("^(.*)\/(.*)$", name)
- if m:
- uppage = m.groups()[0]
- else:
- uppage = 0
-
- if admin_check(conn, 5, None) == 1:
- admin_memu = 1
- else:
- admin_memu = 0
-
- if(re.search("^๋ถ๋ฅ:", name)):
- curs.execute("select link from back where title = ? and type='cat' order by link asc", [name])
- back = curs.fetchall()
- if back:
- div = '[๋ชฉ์ฐจ(์์)]\r\n== ๋ถ๋ฅ ==\r\n'
- u_div = ''
- i = 0
-
- for data in back:
- if re.search('^๋ถ๋ฅ:', data[0]):
- if u_div == '':
- u_div = '=== ํ์ ๋ถ๋ฅ ===\r\n'
- u_div += ' * [[:' + data[0] + ']]\r\n'
- elif re.search('^ํ:', data[0]):
- curs.execute("select data from data where title = ?", [data[0]])
- db_data = curs.fetchall()
- if db_data:
- cat_data = re.sub("\[\[(๋ถ๋ฅ:(?:(?:(?!\]\]|#include).)+))\]\]", "", mid_pas(db_data[0][0], 0, 1, 0, 0)[0])
- if re.search('\[\[' + name + '|include]]', cat_data):
- div += ' * [[' + data[0] + ']]\r\n * [[wiki:xref/' + url_pas(data[0]) + '|' + data[0] + ']] (์ญ๋งํฌ)\r\n'
- else:
- div += ' * [[' + data[0] + ']]\r\n'
- else:
- div += ' * [[' + data[0] + ']]\r\n'
- div += u_div
- if num:
- curs.execute("select title from history where title = ? and id = ? and hide = 'O'", [name, str(num)])
- hid = curs.fetchall()
- if hid and admin_check(conn, 6, None) != 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 title, data from data where title = ?", [name])
- data = curs.fetchall()
- if data:
- elsedata = data[0][1]
- else:
- data_none = 1
- response.status = 404
- elsedata = ''
- if not num:
- curs.execute("select dec from acl where title = ?", [name])
- acl_d = curs.fetchall()
- if acl_d:
- if acl_d[0][0] == 'admin':
- acl = ' (๊ด๋ฆฌ์)'
- elif acl_d[0][0] == 'user':
- acl = ' (๊ฐ์
์)'
- else:
- curs.execute('select data from other where name = "edit"')
- set_data = curs.fetchall()
- if set_data:
- if set_data[0][0] == 'admin':
- acl = ' (๊ด๋ฆฌ์)'
- elif set_data[0][0] == 'user':
- acl = ' (๊ฐ์
์)'
- 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 = ' (๊ด๋ฆฌ์)'
- else:
- curs.execute("select block from ban where block = ?", [g[0]])
- if curs.fetchall():
- sub = ' (์ฐจ๋จ)'
- else:
- acl = ''
- curs.execute("select dec from acl where title = ?", [name])
- data = curs.fetchall()
- if data:
- if data[0][0] == 'all':
- acl += ' (๋ชจ๋)'
- elif data[0][0] == 'user':
- acl += ' (๊ฐ์
์)'
-
- if request.args.get('froms', None):
- elsedata = re.sub("^#(?:redirect|๋๊ฒจ์ฃผ๊ธฐ) (?P<in>[^\n]*)", " * [[\g<in>]] ๋ฌธ์๋ก ๋๊ฒจ์ฃผ๊ธฐ", elsedata)
-
- enddata = namumark(conn, name, elsedata, 0, 0, 1)
- if data_none == 1:
- menu = [['edit/' + url_pas(name), '์์ฑ'], ['topic/' + url_pas(name), topic], \
- ['history/' + url_pas(name), '์ญ์ฌ'], ['move/' + url_pas(name), '์ด๋'], ['xref/' + url_pas(name), '์ญ๋งํฌ']]
- else:
- menu = [['edit/' + url_pas(name), '์์ '], ['topic/' + url_pas(name), topic], \
- ['history/' + url_pas(name), '์ญ์ฌ'], ['delete/' + url_pas(name), '์ญ์ '], \
- ['move/' + url_pas(name), '์ด๋'], ['raw/' + url_pas(name), '์๋ณธ'], ['xref/' + url_pas(name), '์ญ๋งํฌ']]
-
- if admin_memu == 1:
- menu += [['acl/' + url_pas(name), 'ACL']]
- if request.args.get('froms', None):
- menu += [['w/' + url_pas(name), '๋๊ธฐ๊ธฐ']]
- enddata = '<ul id="redirect"><li><a href="/w/' + url_pas(request.args.get('froms', None)) + \
- '?froms=' + url_pas(name) + '">' + request.args.get('froms', None) + '</a>์์ ๋์ด ์์ต๋๋ค.</li></ul><br>' + enddata
- if uppage != 0:
- menu += [['w/' + url_pas(uppage), '์์']]
- if down:
- menu += [['down/' + url_pas(name), 'ํ์']]
- if num:
- menu = [['history/' + url_pas(name), '์ญ์ฌ']]
- sub = ' (' + str(num) + 'ํ)'
- acl = ''
- r_date = 0
- else:
- curs.execute("select date from history where title = ? order by date desc limit 1", [name])
- date = curs.fetchall()
- if date:
- r_date = date[0][0]
- else:
- r_date = 0
- if div != '' and enddata != '':
- div = enddata + '<br>' + namumark(conn, name, div, 0, 0, 0)
- else:
- div = enddata + namumark(conn, name, div, 0, 0, 0)
- return html_minify(template('index',
- imp = [name, wiki_set(conn, 1), custom(conn), other2([sub + acl, r_date])],
- data = div,
- menu = menu
- ))
- @app.route('/topic_record/<name>')
- def user_topic_list(name = None):
- num = int(request.args.get('num', 1))
- if num * 50 > 0:
- sql_num = num * 50 - 50
- else:
- sql_num = 0
-
- one_admin = admin_check(conn, 1, None)
- div = '<table style="width: 100%; text-align: center;"><tbody><tr>'
- div += '<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 ?, '50'", [name, str(sql_num)])
- data_list = curs.fetchall()
- for data in data_list:
- title = html.escape(data[0])
- sub = html.escape(data[2])
-
- if one_admin == 1:
- curs.execute("select * from ban where block = ?", [data[3]])
- if curs.fetchall():
- ban = ' <a href="/ban/' + url_pas(data[3]) + '">(ํด์ )</a>'
- else:
- ban = ' <a href="/ban/' + url_pas(data[3]) + '">(์ฐจ๋จ)</a>'
- else:
- ban = ''
-
- ip = ip_pas(conn, data[3])
-
- div += '<tr><td><a href="/topic/' + url_pas(data[0]) + '/sub/' + url_pas(data[2]) + '#' + data[1] + '">' + \
- title + '#' + data[1] + '</a> (' + sub + ')</td>'
- div += '<td>' + ip + ban + '</td><td>' + data[4] + '</td></tr>'
- div += '</tbody></table>'
- div += next_fix('/topic_record/' + url_pas(name) + '?num=', num, data_list)
-
- curs.execute("select end, why from ban where block = ?", [name])
- ban_it = curs.fetchall()
- if ban_it:
- sub = ' (์ฐจ๋จ)'
- else:
- sub = 0
-
- return html_minify(template('index',
- imp = ['ํ ๋ก ๊ธฐ๋ก', wiki_set(conn, 1), custom(conn), other2([sub, 0])],
- data = div,
- menu = [['other', '๊ธฐํ'], ['user', '์ฌ์ฉ์'], ['count/' + url_pas(name), 'ํ์'], ['record/' + url_pas(name), 'ํธ์ง']]
- ))
- @app.route('/recent_changes')
- @app.route('/<regex("record"):tool>/<name>')
- @app.route('/<regex("history"):tool>/<path:name>', methods=['POST', 'GET'])
- def recent_changes(name = None, tool = 'record'):
- if request.method == 'POST':
- return redirect('/diff/' + url_pas(name) + '?first=' + request.form['b'] + '&second=' + request.form['a'])
- else:
- one_admin = admin_check(conn, 1, None)
- six_admin = admin_check(conn, 6, None)
- ban = ''
- select = ''
- what = request.args.get('what', 'all')
- div = '<table style="width: 100%; text-align: center;"><tbody><tr>'
-
- if name:
- num = int(request.args.get('num', 1))
- if num * 50 > 0:
- sql_num = num * 50 - 50
- else:
- sql_num = 0
- if tool == 'history':
- div += '<td style="width: 33.3%;">ํ</td><td style="width: 33.3%;">ํธ์ง์</td><td style="width: 33.3%;">์๊ฐ</td></tr>'
- curs.execute("select id, title, date, ip, send, leng from history where title = ? order by id + 0 desc limit ?, '50'", \
- [name, str(sql_num)])
- else:
- div += '<td style="width: 33.3%;">๋ฌธ์๋ช
</td><td style="width: 33.3%;">ํธ์ง์</td><td style="width: 33.3%;">์๊ฐ</td></tr>'
- if what == 'all':
- div = '<a href="/record/' + url_pas(name) + '?what=revert">(๋๋๋ฆฌ๊ธฐ)</a><hr>' + div
- div = '<a href="/record/' + url_pas(name) + '?what=move">(์ด๋)</a> ' + div
- div = '<a href="/record/' + url_pas(name) + '?what=delete">(์ญ์ )</a> ' + div
-
- curs.execute("select id, title, date, ip, send, leng from history where ip = ? order by date desc limit ?, '50'", \
- [name, str(sql_num)])
- else:
- if what == 'delete':
- sql = '%(์ญ์ )'
- elif what == 'move':
- sql = '%์ด๋)'
- elif what == 'revert':
- sql = '%ํ)'
- else:
- return redirect('/')
- curs.execute("select id, title, date, ip, send, leng from history where ip = ? and send like ? order by date desc limit ?, '50'", \
- [name, sql, str(sql_num)])
- else:
- div += '<td style="width: 33.3%;">๋ฌธ์๋ช
</td><td style="width: 33.3%;">ํธ์ง์</td><td style="width: 33.3%;">์๊ฐ</td></tr>'
- if what == 'all':
- div = '<a href="/recent_changes?what=revert">(๋๋๋ฆฌ๊ธฐ)</a><hr>' + div
- div = '<a href="/recent_changes?what=move">(์ด๋)</a> ' + div
- div = '<a href="/recent_changes?what=delete">(์ญ์ )</a> ' + div
- curs.execute("select id, title, date, ip, send, leng from history order by date desc limit 50")
- else:
- if what == 'delete':
- sql = '%(์ญ์ )'
- elif what == 'move':
- sql = '%์ด๋)'
- elif what == 'revert':
- sql = '%ํ)'
- else:
- return redirect('/')
- curs.execute("select id, title, date, ip, send, leng from history where send like ? order by date desc limit 50", [sql])
- data_list = curs.fetchall()
- for data in data_list:
- select += '<option value="' + data[0] + '">' + data[0] + '</option>'
- send = '<br>'
- if data[4]:
- if not re.search("^(?: *)$", data[4]):
- send = data[4]
-
- 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 one_admin == 1:
- curs.execute("select * from ban where block = ?", [data[3]])
- if curs.fetchall():
- ban = ' <a href="/ban/' + url_pas(data[3]) + '">(ํด์ )</a>'
- else:
- ban = ' <a href="/ban/' + url_pas(data[3]) + '">(์ฐจ๋จ)</a>'
-
- ip = ip_pas(conn, data[3])
-
- if (int(data[0]) - 1) == 0:
- revert = ''
- else:
- revert = '<a href="/diff/' + url_pas(data[1]) + '?first=' + str(int(data[0]) - 1) + '&second=' + data[0] + \
- '">(๋น๊ต)</a> <a href="/revert/' + url_pas(data[1]) + '?num=' + str(int(data[0]) - 1) + '">(๋๋๋ฆฌ๊ธฐ)</a>'
-
- style = ['', '']
- date = data[2]
- curs.execute("select title from history where title = ? and id = ? and hide = 'O'", [data[1], data[0]])
- hide = curs.fetchall()
- if six_admin == 1:
- if(hide):
- hidden = ' <a href="/hidden/' + url_pas(data[1]) + '?num=' + data[0] + '">(๊ณต๊ฐ)'
-
- style[0] = 'background: gainsboro;'
- style[1] = 'background: gainsboro;'
- if send == '<br>':
- send = '(์จ๊น)'
- else:
- send += ' (์จ๊น)'
- else:
- hidden = ' <a href="/hidden/' + url_pas(data[1]) + '?num=' + data[0] + '">(์จ๊น)'
- elif not hide:
- hidden = ''
- else:
- ip = ''
- hidden = ''
- ban = ''
- date = ''
- send = '(์จ๊น)'
- style[0] = 'display: none;'
- style[1] = 'background: gainsboro;'
- if tool == 'history':
- title = '<a href="/w/' + url_pas(name) + '?num=' + data[0] + '">' + data[0] + 'ํ</a> <a href="/raw/' + \
- url_pas(name) + '?num=' + data[0] + '">(์๋ณธ)</a> '
- else:
- title = '<a href="/w/' + url_pas(data[1]) + '">' + html.escape(data[1]) + '</a> <a href="/history/' + \
- url_pas(data[1]) + '">(' + data[0] + 'ํ)</a> '
-
- div += '<tr style="' + style[0] + '"><td>' + title + revert + ' ' + leng + '</td>'
- div += '<td>' + ip + ban + hidden + '</td><td>' + date + '</td></tr><tr style="' + style[1] + '"><td colspan="3">' + send + '</td></tr>'
- div += '</tbody></table>'
- sub = ''
- if name:
- if tool == 'history':
- div = '<form method="post"><select name="a">' + select + '</select> <select name="b">' + select + \
- '</select> <button type="submit">๋น๊ต</button></form><hr>' + div
- title = name
- sub += ' (์ญ์ฌ)'
- menu = [['w/' + url_pas(name), '๋ฌธ์'], ['move_data/' + url_pas(name), '์ด๋ ๊ธฐ๋ก']]
-
- div += next_fix('/history/' + url_pas(name) + '?num=', num, data_list)
- else:
- curs.execute("select end, why from ban where block = ?", [name])
- ban_it = curs.fetchall()
- if ban_it:
- sub += ' (์ฐจ๋จ)'
- title = 'ํธ์ง ๊ธฐ๋ก'
- menu = [['other', '๊ธฐํ'], ['user', '์ฌ์ฉ์'], ['count/' + url_pas(name), 'ํ์'], ['topic_record/' + url_pas(name), 'ํ ๋ก ']]
- div += next_fix('/record/' + url_pas(name) + '/' + url_pas(what) + '?num=', num, data_list)
- if what != 'all':
- menu += [['record/' + url_pas(name), '์ผ๋ฐ']]
- else:
- menu = 0
- title = '์ต๊ทผ ๋ณ๊ฒฝ๋ด์ญ'
- if what != 'all':
- menu = [['recent_changes', '์ผ๋ฐ']]
-
- if what == 'delete':
- sub += ' (์ญ์ )'
- elif what == 'move':
- sub += ' (์ด๋)'
- elif what == 'revert':
- sub += ' (๋๋๋ฆฌ๊ธฐ)'
-
- if sub == '':
- sub = 0
-
- return html_minify(template('index',
- imp = [title, wiki_set(conn, 1), custom(conn), other2([sub, 0])],
- data = div,
- menu = menu
- ))
-
- @app.route('/upload', methods=['GET', 'POST'])
- def upload():
- if ban_check(conn) == 1:
- return re_error(conn, '/ban')
-
- if request.method == 'POST':
- if captcha_post(request.form.get('g-recaptcha-response', None), conn) == 1:
- return re_error(conn, '/error/13')
- else:
- captcha_post('', conn, 0)
- data = request.files['f_data']
- if not data:
- return re_error(conn, '/error/9')
- if int(wiki_set(conn, 3)) * 1024 * 1024 < request.content_length:
- return re_error(conn, '/error/17')
-
- value = os.path.splitext(data.filename)[1]
- if not value in ['.jpeg', '.jpg', '.gif', '.png', '.webp', '.JPEG', '.JPG', '.GIF', '.PNG', '.WEBP']:
- return re_error(conn, '/error/14')
-
- if request.form['f_name']:
- name = request.form['f_name'] + value
- else:
- name = data.filename
-
- piece = os.path.splitext(name)
- if re.search('[^ใฑ-ํฃ0-9a-zA-Z_\- ]', piece[0]):
- return re_error(conn, '/error/22')
- e_data = sha224(piece[0]) + piece[1]
- curs.execute("select title from data where title = ?", ['ํ์ผ:' + name])
- if curs.fetchall():
- return re_error(conn, '/error/16')
-
- ip = ip_check()
- if request.form['f_lice']:
- lice = request.form['f_lice']
- else:
- if custom(conn)[2] == 0:
- lice = ip + ' ์ฌ๋ฆผ'
- else:
- lice = '[[์ฌ์ฉ์:' + ip + ']] ์ฌ๋ฆผ'
-
- if os.path.exists(os.path.join('image', e_data)):
- os.remove(os.path.join('image', e_data))
- data.save(os.path.join('image', e_data))
- else:
- data.save(os.path.join('image', e_data))
-
- curs.execute("select title from data where title = ?", ['ํ์ผ:' + name])
- exist = curs.fetchall()
- if(exist):
- curs.execute("delete from data where title = ?", ['ํ์ผ:' + name])
-
- curs.execute("insert into data (title, data) values (?, ?)", \
- ['ํ์ผ:' + name, '[[ํ์ผ:' + name + ']][br][br]{{{[[ํ์ผ:' + name + ']]}}}[br][br]' + lice])
- curs.execute("insert into acl (title, dec, dis, why) values (?, 'admin', '', '')", ['ํ์ผ:' + name])
- history_plus(conn, 'ํ์ผ:' + name, '[[ํ์ผ:' + name + ']][br][br]{{{[[ํ์ผ:' + name + ']]}}}[br][br]' + lice, \
- get_time(), ip, '(ํ์ผ ์ฌ๋ฆผ)', '0')
- conn.commit()
-
- return redirect('/w/ํ์ผ:' + name)
- else:
- return html_minify(template('index',
- imp = ['ํ์ผ ์ฌ๋ฆฌ๊ธฐ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post" enctype="multipart/form-data" accept-charset="utf8"> \
- <input type="file" name="f_data"><hr> \
- <input placeholder="ํ์ผ ์ด๋ฆ" name="f_name" type="text"><hr> \
- <input placeholder="๋ผ์ด์ ์ค" name="f_lice" type="text"><hr> \
- ' + captcha_get(conn) + ' \
- <button id="save" type="submit">์ ์ฅ</button> \
- </form>',
- menu = [['other', '๊ธฐํ']]
- ))
-
- @app.route('/user')
- def user_info():
- ip = ip_check()
-
- curs.execute("select acl from user where id = ?", [ip])
- data = curs.fetchall()
- if ban_check(conn) == 0:
- if data:
- if data[0][0] != 'user':
- acl = data[0][0]
- else:
- acl = '๊ฐ์
์'
- else:
- acl = '์ผ๋ฐ'
- else:
- acl = '์ฐจ๋จ'
-
- curs.execute("select block from ban where block = ? and login = 'O'", [ip])
- if curs.fetchall():
- acl += ' (๋ก๊ทธ์ธ ๊ฐ๋ฅ)'
-
- if custom(conn)[2] != 0:
- ip_user = '[[์ฌ์ฉ์:' + ip + '|' + ip + ']]'
- plus = ' * [[wiki:logout|๋ก๊ทธ์์]]\r\n * [[wiki:change|๋น๋ฐ๋ฒํธ ๋ณ๊ฒฝ]]\r\n * [[wiki:email|์ด๋ฉ์ผ ์์ ]]'
- else:
- ip_user = ip
- plus = ' * [[wiki:login|๋ก๊ทธ์ธ]]'
- return html_minify(template('index',
- imp = ['์ฌ์ฉ์ ๋ฉ๋ด', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = namumark(conn, '', '[๋ชฉ์ฐจ(์์)]\r\n' + \
- '== ์ํ ==\r\n' + \
- ' * ' + ip_user + ' [[wiki:record/' + url_pas(ip) + '|(๊ธฐ๋ก)]]\r\n' + \
- ' * ๊ถํ ์ํ : ' + acl + '\r\n' + \
- '== ๋ก๊ทธ์ธ ==\r\n' + \
- plus + '\r\n' + \
- ' * [[wiki:register|ํ์๊ฐ์
]]\r\n' + \
- '== ์ฌ์ฉ์ ๊ธฐ๋ฅ ==\r\n' + \
- ' * [[wiki:acl/์ฌ์ฉ์:' + url_pas(ip) + '|์ฌ์ฉ์ ๋ฌธ์ ACL]]\r\n' + \
- ' * [[wiki:custom_head|์ฌ์ฉ์ HEAD]]\r\n' + \
- '== ๊ธฐํ ==\r\n' + \
- ' * [[wiki:alarm|์๋ฆผ]]\r\n' + \
- ' * [[wiki:view_log|์ง๋์จ ๋ฌธ์]]\r\n' + \
- ' * [[wiki:watch_list|์ฃผ์ ๋ฌธ์]]\r\n' + \
- ' * [[wiki:count|ํ๋ ํ์]]\r\n', 0, 0, 0),
- menu = 0
- ))
- @app.route('/email', methods=['GET', 'POST'])
- def email():
- if custom(conn)[2] == 0:
- return re_error(conn, '/error/1')
- if request.method == 'POST':
- curs.execute("update user set email = ? where id = ?", [request.form.get('email', ''), ip_check()])
- conn.commit()
- return redirect('/user')
- else:
- curs.execute('select email from user where id = ?', [ip_check()])
- data = curs.fetchall()
- if data:
- email = data[0][0]
- else:
- email = ''
- return html_minify(template('index',
- imp = ['์ด๋ฉ์ผ ์์ ', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = '<form method="post"> \
- <input placeholder="์ด๋ฉ์ผ" name="email" type="text" value="' + email + '"><hr> \
- <button type="submit">๋ณ๊ฒฝ</button><hr> \
- </form>',
- menu = [['user', '์ฌ์ฉ์']]
- ))
- @app.route('/watch_list')
- def watch_list():
- div = 'ํ๋ : 10๊ฐ<hr>'
- ip = ip_check()
-
- if custom(conn)[2] == 0:
- return redirect('/login')
- curs.execute("select title from scan where user = ?", [ip])
- data = curs.fetchall()
- for data_list in data:
- div += '<li><a href="/w/' + url_pas(data_list[0]) + '">' + data_list[0] + '</a> <a href="/watch_list/' + \
- url_pas(data_list[0]) + '">(์ญ์ )</a></li>'
- if data:
- div = '<ul>' + div + '</ul><hr>'
- div += '<a href="/manager/13">(์ถ๊ฐ)</a>'
- return html_minify(template('index',
- imp = ['ํธ์ง ํํฐ ๋ชฉ๋ก', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = div,
- menu = [['manager', '๊ด๋ฆฌ์']]
- ))
- @app.route('/watch_list/<name>')
- def watch_list_name(name = None):
- ip = ip_check()
- if custom(conn)[2] == 0:
- return redirect('/login')
- curs.execute("select count(title) from scan where user = ?", [ip])
- count = curs.fetchall()
- if count:
- if count[0][0] > 9:
- return redirect('/watch_list')
- curs.execute("select title from scan where user = ? and title = ?", [ip, name])
- if curs.fetchall():
- curs.execute("delete from scan where user = ? and title = ?", [ip, name])
- else:
- curs.execute("insert into scan (user, title) values (?, ?)", [ip, name])
- conn.commit()
- return redirect('/watch_list')
- @app.route('/view_log')
- def view_log():
- data = '<ul>'
- if session['View_List']:
- data += '<li>์ต๊ทผ 50๊ฐ</li><hr>'
- m = re.findall('([^\n]+)\n', session['View_List'])
- for d in m:
- data += '<li><a href="/w/' + url_pas(d) + '">' + d + '</a></li>'
- else:
- data += '<li>๊ธฐ๋ก ์์</li>'
- data += '</ul>'
- return html_minify(template('index',
- imp = ['์ง๋์จ ๋ฌธ์', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = data,
- menu = [['user', '์ฌ์ฉ์']]
- ))
- @app.route('/custom_head', methods=['GET', 'POST'])
- def custom_head_view():
- ip = ip_check()
- if request.method == 'POST':
- if custom(conn)[2] != 0:
- curs.execute("select user from custom where user = ?", [ip + ' (head)'])
- if curs.fetchall():
- curs.execute("update custom set css = ? where user = ?", [request.form['content'], ip + ' (head)'])
- else:
- curs.execute("insert into custom (user, css) values (?, ?)", [ip + ' (head)', request.form['content']])
- conn.commit()
- session['MyMaiToNight'] = request.form['content']
- return redirect('/user')
- else:
- if custom(conn)[2] != 0:
- start = ''
- curs.execute("select css from custom where user = ?", [ip + ' (head)'])
- head_data = curs.fetchall()
- if head_data:
- data = head_data[0][0]
- else:
- data = ''
- else:
- start = '<span>๋น ๋ก๊ทธ์ธ์ ๊ฒฝ์ฐ์๋ ๋ก๊ทธ์ธํ๊ฑฐ๋ ๋ธ๋ผ์ฐ์ ๋ซ์ผ๋ฉด ๋ ์๊ฐ๋๋ค.</span><hr>'
- try:
- data = session['MyMaiToNight']
- except:
- data = ''
- start += '<span><style>CSS</style><br><script>JS</script></span><hr>'
- return html_minify(template('index',
- imp = ['์ฌ์ฉ์ HEAD', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = start + ' \
- <form method="post"> \
- <textarea rows="25" cols="100" name="content">' + data + '</textarea><hr> \
- <button id="save" type="submit">์ ์ฅ</button> \
- </form>',
- menu = [['user', '์ฌ์ฉ์']]
- ))
- @app.route('/count')
- @app.route('/count/<name>')
- 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 html_minify(template('index',
- imp = ['ํ๋ ํ์', wiki_set(conn, 1), custom(conn), other2([0, 0])],
- data = namumark(conn, "", "[๋ชฉ์ฐจ(์์)]\r\n== " + that + " ==\r\n||<:> ํธ์ง ํ์ ||<:> " + str(data) + \
- "||\r\n||<:> ํ ๋ก ํ์ ||<:> " + str(t_data) + "||", 0, 0, 0),
- menu = [['user', '์ฌ์ฉ์'], ['record/' + url_pas(that), 'ํธ์ง ๊ธฐ๋ก'], ['topic_record/' + url_pas(that), 'ํ ๋ก ๊ธฐ๋ก']]
- ))
-
- @app.route('/random')
- def random():
- curs.execute("select title from data order by random() limit 1")
- d = curs.fetchall()
- if d:
- return redirect('/w/' + url_pas(d[0][0]))
- else:
- return redirect('/')
-
- @app.route('/views/<path:name>')
- 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
- m = re.search('\.(.+)$', name)
- if m:
- g = m.groups()
- else:
- g = ['']
- if g == 'css':
- return css_minify(send_from_directory('./views' + plus, rename))
- elif g == 'js':
- return js_minify(send_from_directory('./views' + plus, rename))
- elif g == 'html':
- return html_minify(send_from_directory('./views' + plus, rename))
- else:
- return send_from_directory('./views' + plus, rename)
- @app.route('/<test>')
- def main_file(test = None):
- if re.search('\.(txt|html)$', test):
- return send_from_directory('./', test)
- else:
- return ''
- @app.errorhandler(404)
- def error_404(e):
- return '<!-- ๋๋์นด๊ฐ ํ์ง๋ง๋ฃปํ
์ฝํ ์ ์ค์๋ฆฌ๋ ์ธ ๋๊ฐ๋ฃจ๋ค๋ํ
์บ๊ฐ์ํ
๋ชจ ๋ฏธ๋์บํ. ์ด์ผ, ์บ์นด์ํ์ฟ ๋์บํ๋ค... \
- ์๋ง์คํ ๋ง๋์ค ํํ์ฟ ์๋ผ์นด๋ผ ์ํ์๋
ธ ์-๋ ์นด๋์๋ฏธ ํํ
๋ฃจ ํ ๋ฉ๋๋์ฟ ์ด๋ง์ค ๋๋ผ์ํ
\
- ์ค๋ชจ์ด๋ฐ ๋ํ
์ด๋ผ๋์ด๋
ธ ์ฝ์ฝ๋ก๊ฐ ์ฟ ๋ฃจ์์ฟ ๋๋ฃจ ๋ค์ผ๋คํ No more! September Rain No more! September Rain \
- ์ด์ธ ๋ทํ
์๋ํ์ ๋ฏธ์ง์นด๋ทํ ์์์์ ํค๋ชจ์น์ค ํ์์นด๋ฉ๋ฃปํ
์ฝํ ๋ชจ ํ์ธ ์-์๋์ฟ ํ
\
- ์์ ๋ ๋์นด๋ผ์์ฟ ๋๋ ํ์นด๋ผ ์์ ์ํ
ํ๋
ธ ์นด๋ชจ์๋ ๋์ด๋ค ๋-์ํ
? ๋๋ฏธ๋ ํ ์ด์นด์ผ๋ฃจ์ผ๋ \
- ๋์ธ ๋
ธ ํ์ง๋ง๋ฆฌ๊ฐ ์ธ ๋ ํ
ํคํ ์ค๋ชจ์ด ๋์ธ ๊ฐ ์ค์๋ฃจํ ํค ํค์์ฑ ์ฐ๋ชจ๋
ธ๋ทํ ๋ํ
์๋ผ๋์ฟ ํ
\
- ํ ํค๋ฉ์ดํ
ํ ์์ธ ์ด ํค์ธ์ธ \
- ์ฐ๋ฏธ๋ฒ ๋
ธ ์๋ผ๊ฐ ํ์บํ
ํ ์ธ ์ ์ฟ ๋ชจ๊ฐ ๋๊ฐ๋ ์ค์ธ ๋ถ๋
ธ ์๋ฉ ์ํ์๋
ธ ๋์นด๋
ธ ๋๋ฏธ๋ค๋ฏธํ์ด \
- ์ฝ๋๋ ํ๋
ธ์์ด ๋์ธ ๊ฐ ์ฆํ ์ธ ์ฆ์ดํ
์ฟณํ
์ ์งํ
ํ์ But now... September Rain But now... September Rain -->' + \
- redirect('/w/' + url_pas(wiki_set(conn, 2)))
- if __name__=="__main__":
- app.secret_key = rep_key
- http_server = HTTPServer(WSGIContainer(app))
- http_server.listen(rep_port)
- IOLoop.instance().start()
|