*/}}

index.php 356 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095
  1. <?php
  2. include 'Parsedown.php';
  3. include 'ParsedownExtra.php';
  4. ini_set('max_execution_time', 300);
  5. if($_SERVER['HTTP_HOST']=='localhost'){
  6. ini_set('display_errors', '0');
  7. ini_set('display_startup_errors', '1');
  8. error_reporting(E_ALL);
  9. }
  10. global $LA_GLOBAL_LANG;
  11. global $INDEXPHP;
  12. $INDEXPHP='index.php';
  13. if($LA_GLOBAL_LANG=='en'){
  14. $INDEXPHP='en.php';
  15. }
  16. class LA{
  17. protected $PDE;
  18. protected $style;
  19. public $PAGE;
  20. public $AFTER;
  21. public $PSTACK;
  22. protected $PNUMBER;
  23. /* config */
  24. protected $Title;
  25. protected $ShortTitle;
  26. protected $Admin;
  27. protected $Password;
  28. protected $DisplayName;
  29. protected $EMail;
  30. protected $SpecialNavigation;
  31. protected $SpecialSidebar;
  32. protected $SpecialFooter;
  33. protected $SpecialFooter2;
  34. protected $SpecialPinned;
  35. protected $SpecialPinnedNotes;
  36. protected $DefaultGallery;
  37. protected $SelfAuthPath;
  38. protected $HereHost;
  39. protected $HereTitle;
  40. protected $HereShortTitle;
  41. protected $HereAlbum;
  42. protected $HereNavigation;
  43. protected $HereFooter;
  44. protected $ExpHost;
  45. protected $ExpAlbum;
  46. protected $ExpTitle;
  47. protected $ExpShortTitle;
  48. protected $ExpCaution;
  49. protected $ExpNavigation;
  50. protected $ExpFooter;
  51. protected $CommentEnabled;
  52. protected $MastodonToken;
  53. protected $MastodonURL;
  54. protected $MastodonPreferredLang;
  55. protected $HostURL;
  56. protected $GalleryStep;
  57. protected $AllowLanguageChoices;
  58. protected $Redirect;
  59. protected $Translations;
  60. protected $CustomTranslationContent;
  61. protected $CommentsPerPage;
  62. protected $UsePosts;
  63. protected $CurrentOffset;
  64. protected $PostsPerPage;
  65. protected $HotPostCount;
  66. protected $LoggedIn;
  67. protected $LoginTokens;
  68. protected $InHereMode;
  69. protected $InExperimentalMode;
  70. protected $LanguageAppendix;
  71. protected $UseRemoteFont;
  72. protected $NotesView;
  73. protected $Posts;
  74. protected $Threads; // [ keys: first last displayed count]
  75. protected $WaybackThreads;
  76. public $Images;
  77. protected $Galleries;
  78. protected $Anchors;
  79. protected $ArchiveHandles;
  80. protected $Archive;
  81. public $WayBack;
  82. protected $YearBegin;
  83. protected $YearEnd;
  84. protected $Markers;
  85. protected $ExtraScripts;
  86. protected $APubID;
  87. protected $APubActor;
  88. protected $APubPublicKey;
  89. protected $APubPrivateKey;
  90. protected $TIME_STRING;
  91. public $NULL_POST;
  92. public $NULL_IMAGE;
  93. public $NULL_IMAGE_DUMMY;
  94. public $NULL_Gallery;
  95. protected $DoneReadPosts;
  96. protected $DoneReadImages;
  97. protected $DoneReadArchive;
  98. protected $NeedWritePosts;
  99. protected $NeedWriteImages;
  100. protected $NeedWriteArchive;
  101. protected $HereDisplayTitle;
  102. protected $VisitedHere;
  103. protected $HereNumber;
  104. protected $HereMainImage;
  105. public $PageType;
  106. public $CurrentPostID;
  107. public $HereID;
  108. public $ActualPostID;
  109. public $TagID;
  110. function &_TRow(){ if(!isset($this->PAGE)){$this->PAGE=[];} if(!isset($this->PAGE[0])){$this->PAGE[]=[];} return $this->PAGE[array_key_last($this->PAGE)]; }
  111. function &TRow(){ $last=array_key_last($this->PAGE); if($this->PAGE[$last]==[]) return $this->PAGE[$last]; $this->PAGE[]=[]; return $this->PAGE[$last]; }
  112. function TFill($k,&$content,$span=null){ $a=&$this->_TRow();if(!isset($a[$k]))$a[$k]="";$a[$k].=$content; $content=''; if($span!=null && $span>1){ $a['span'.$k]=$span; } }
  113. function TExtra($rowextra){ $a=&$this->_TRow(); $a['extra']=$rowextra; }
  114. function TAfter(&$content){ $this->AFTER.=$content; $content=''; }
  115. function TBackup(){ if(!isset($this->PSTACK)){$this->PSTACK=[];}; $this->PSTACK[]=$this->PAGE; $this->PAGE=[]; }
  116. function TRestore($extra=""){ if(!isset($this->PSTACK) || $this->PSTACK==[]) return "";
  117. $S=$this->GeneratePage(0,$extra); $this->PAGE=end($this->PSTACK); unset($this->PSTACK[array_key_last($this->PSTACK)]); return $S;
  118. }
  119. function ReadableTime($id){
  120. $dt = DateTime::createFromFormat('YmdHis', $id);
  121. return $dt->format('Y/m/d H:i:s');
  122. }
  123. function StandardTime($id){
  124. $dt = DateTime::createFromFormat('YmdHis', $id);
  125. return $dt->format('Y-m-d\TH:i:sP');
  126. }
  127. function FullURL(){
  128. return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?
  129. "https" : "http") . "://" . $_SERVER['HTTP_HOST'] .
  130. $_SERVER['REQUEST_URI'];
  131. }
  132. function T($str){
  133. if(!$this->LanguageAppendix) return $str;
  134. foreach($this->Translations as $entry){
  135. if($entry['zh']==$str)
  136. return $entry[$this->LanguageAppendix];
  137. }
  138. return $str;
  139. }
  140. function SwitchLanguageAndFont(){ global $LA_GLOBAL_LANG;
  141. $this->LanguageAppendix = 'zh';
  142. if(isset($_COOKIE['la_language'])){
  143. $this->LanguageAppendix = $_COOKIE['la_language'];
  144. }else{
  145. if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
  146. $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  147. $lang = substr($lang,0,5);
  148. if(preg_match("/zh/i",$lang))$this->LanguageAppendix = 'zh';
  149. else $this->LanguageAppendix = 'en';
  150. }else{
  151. $this->LanguageAppendix = 'en';
  152. }
  153. }
  154. if(isset($LA_GLOBAL_LANG)){
  155. if($LA_GLOBAL_LANG=='en'){ $this->LanguageAppendix = 'en'; setcookie('la_language','en',time()+3600*24*7,'/'); }
  156. else if($LA_GLOBAL_LANG=='zh'){ $this->LanguageAppendix = 'zh'; setcookie('la_language','zh',time()+3600*24*7,'/'); }
  157. }
  158. if(isset($_COOKIE['la_font'])){
  159. $this->UseRemoteFont = ($_COOKIE['la_font']!='local');
  160. }
  161. if($this->LoggedIn && isset($_COOKIE['la_notes_view'])){ $this->NotesView=$_COOKIE['la_notes_view']; }
  162. }
  163. function SwitchWayBackMode(){
  164. if(isset($_COOKIE['la_wayback'])){
  165. $this->WayBack = $_COOKIE['la_wayback'];
  166. }else $this->WayBack = NULL;
  167. }
  168. function DisplayRedirectConfig(){
  169. $s = "";
  170. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  171. if($r['for']=='P'){
  172. $s.=("P ".$r['format'].":".$r['target'].";".PHP_EOL);
  173. }else if($r['for']=='S'){
  174. $s.=("S ".$r['format'].":".$r['domain'].":".$r['target'].";".PHP_EOL);
  175. }
  176. }
  177. return $s;
  178. }
  179. function DoSiteRedirect(){ global $INDEXPHP;
  180. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  181. if($r['for']=='S'){
  182. if(preg_match('/'.$r['format'].'/ui', $_SERVER['HTTP_HOST'])){
  183. if($_SERVER['REQUEST_URI']=='/'||$_SERVER['REQUEST_URI']==''){
  184. header('Location:https://'.$r['domain'].'/'.$INDEXPHP.'?post='.$r['target']); exit;
  185. }else{
  186. header('Location:https://'.$r['domain'].$_SERVER['REQUEST_URI']); exit;
  187. }
  188. }
  189. }
  190. }
  191. }
  192. function WriteHTACCESS(){
  193. $conf = fopen('.htaccess','w');
  194. fwrite($conf,"RewriteEngine on".PHP_EOL.PHP_EOL);
  195. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  196. if($r['for']=='P'){
  197. if(!preg_match('/[0-9]{14}/',$r['target'])){
  198. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?'.$r['target'].' [R=302,L,NC]'.PHP_EOL.PHP_EOL);
  199. }
  200. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?post='.$r['target'].' [R=302,L,NC]'.PHP_EOL.PHP_EOL);
  201. }// do site redirect in php.
  202. }
  203. fwrite($conf, 'RewriteCond %{HTTPS} !=on'.PHP_EOL.
  204. 'RewriteCond %{HTTP_HOST} !=localhost'.PHP_EOL.
  205. 'RewriteCond %{REQUEST_URI} !^.*(jpg|png|gif)$'.PHP_EOL.
  206. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]'.PHP_EOL.PHP_EOL);
  207. fwrite($conf,'<Files ~ "\.md$">'.PHP_EOL.'deny from all'.PHP_EOL.'</Files>'.PHP_EOL);
  208. fflush($conf);fclose($conf);
  209. }
  210. function BuildRedirectConfig($conf){
  211. $this->Redirect=[];
  212. if(preg_match_all('/P\s+(.*)\:\s*([0-9]{14}|.+)\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  213. foreach($ma as $m){
  214. $redirect=[]; $redirect['for'] = 'P'; $redirect['format'] = $m[1]; $redirect['target'] = $m[2];
  215. $this->Redirect[]=$redirect;
  216. }
  217. }
  218. if(preg_match_all('/S\s+(\S+)\s*\:\s*(\S+)\s*\:\s*([0-9]{14})\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  219. foreach($ma as $m){
  220. $redirect=[]; $redirect['for'] = 'S'; $redirect['format'] = $m[1]; $redirect['domain'] = $m[2]; $redirect['target'] = $m[3];
  221. $this->Redirect[]=$redirect;
  222. }
  223. }
  224. }
  225. function WriteTokens(){
  226. $tf = fopen('la_tokens.php','w');
  227. fwrite($tf,'<?php header("Location:index.php"); exit; ?>'.PHP_EOL.PHP_EOL);
  228. if(isset($this->LoginTokens) && sizeof($this->LoginTokens)) {
  229. foreach($this->LoginTokens as $t){
  230. fwrite($tf,'- '.$t.PHP_EOL);
  231. }
  232. }
  233. fflush($tf);fclose($tf);
  234. }
  235. function WriteConfig(){
  236. if(!isset($this->Title)) $this->Title = $this->T('那么的维基');
  237. if(!isset($this->ShortTitle)) $this->ShortTitle = $this->T('基');
  238. if(!isset($this->Admin)) $this->Admin = 'admin';
  239. if(!isset($this->DisplayName)) $this->DisplayName = $this->T('管理员');
  240. if(!isset($this->Password)) $this->Password = password_hash('Admin', PASSWORD_DEFAULT).PHP_EOL;
  241. $conf = fopen('la_config.php','w');
  242. fwrite($conf,'<?php header("Location:index.php"); exit; ?> '.PHP_EOL.PHP_EOL);
  243. fwrite($conf,'- Title = '.$this->Title.PHP_EOL);
  244. fwrite($conf,'- ShortTitle = '.$this->ShortTitle.PHP_EOL);
  245. fwrite($conf,'- Admin = '.$this->Admin.PHP_EOL);
  246. fwrite($conf,'- DisplayName = '.$this->DisplayName.PHP_EOL);
  247. fwrite($conf,'- Password = '.$this->Password.PHP_EOL);
  248. fwrite($conf,'- EMail = '.$this->EMail.PHP_EOL);
  249. fwrite($conf,'- SpecialNavigation = '.$this->SpecialNavigation.PHP_EOL);
  250. fwrite($conf,'- SpecialSidebar = '.$this->SpecialSidebar.PHP_EOL);
  251. fwrite($conf,'- SpecialFooter = '.$this->SpecialFooter.PHP_EOL);
  252. fwrite($conf,'- SpecialFooter2 = '.$this->SpecialFooter2.PHP_EOL);
  253. fwrite($conf,'- SpecialPinned = '.$this->SpecialPinned.PHP_EOL);
  254. fwrite($conf,'- SpecialPinnedNotes = '.$this->SpecialPinnedNotes.PHP_EOL);
  255. fwrite($conf,'- DefaultGallery = '.$this->DefaultGallery.PHP_EOL);
  256. fwrite($conf,'- SelfAuthPath = '.$this->SelfAuthPath.PHP_EOL);
  257. fwrite($conf,'- CommentEnabled = '.($this->CommentEnabled?"True":"False").PHP_EOL);
  258. fwrite($conf,'- NewsletterEnabled = '.($this->NewsletterEnabled?"True":"False").PHP_EOL);
  259. fwrite($conf,'- HereHost = '.$this->HereHost.PHP_EOL);
  260. fwrite($conf,'- HereTitle = '.$this->HereTitle.PHP_EOL);
  261. fwrite($conf,'- HereShortTitle = '.$this->HereShortTitle.PHP_EOL);
  262. fwrite($conf,'- HereAlbum = '.$this->HereAlbum.PHP_EOL);
  263. fwrite($conf,'- HereNavigation = '.$this->HereNavigation.PHP_EOL);
  264. fwrite($conf,'- HereFooter = '.$this->HereFooter.PHP_EOL);
  265. fwrite($conf,'- ExpHost = '.$this->ExpHost.PHP_EOL);
  266. fwrite($conf,'- ExpTitle = '.$this->ExpTitle.PHP_EOL);
  267. fwrite($conf,'- ExpShortTitle = '.$this->ExpShortTitle.PHP_EOL);
  268. fwrite($conf,'- ExpCaution = '.$this->ExpCaution.PHP_EOL);
  269. fwrite($conf,'- ExpAlbum = '.$this->ExpAlbum.PHP_EOL);
  270. fwrite($conf,'- ExpNavigation = '.$this->ExpNavigation.PHP_EOL);
  271. fwrite($conf,'- ExpFooter = '.$this->ExpFooter.PHP_EOL);
  272. fwrite($conf,'- MastodonToken = '.$this->MastodonToken.PHP_EOL);
  273. fwrite($conf,'- MastodonURL = '.$this->MastodonURL.PHP_EOL);
  274. fwrite($conf,'- MastodonPreferredLang = '.$this->MastodonPreferredLang.PHP_EOL);
  275. fwrite($conf,'- HostURL = '.$this->HostURL.PHP_EOL);
  276. fwrite($conf,'- APubID = '.$this->APubID.PHP_EOL);
  277. fwrite($conf,'- GalleryStep = '.$this->GalleryStep.PHP_EOL);
  278. fwrite($conf,'- AllowLanguageChoices = '.$this->AllowLanguageChoices.PHP_EOL);
  279. fflush($conf);fclose($conf);
  280. $conf = fopen('la_redirect.md','w');
  281. fwrite($conf,$this->DisplayRedirectConfig());fflush($conf);fclose($conf);
  282. $this->WriteHTACCESS();
  283. $this->WriteTokens();
  284. }
  285. function Install(){
  286. if(!file_exists('la_config.php')){
  287. $this->WriteConfig();
  288. }
  289. if(!is_dir('posts')) mkdir('posts');
  290. if(!is_dir('images')) mkdir('images');
  291. if(!is_dir('images/thumb')) mkdir('images/thumb');
  292. if(!is_dir('styles')) mkdir('styles');
  293. if(!is_dir('archive')) mkdir('archive');
  294. $this->WriteStyles();
  295. $this->WriteHTACCESS();
  296. }
  297. function ReadFromExistingConfig(){
  298. $f=null;
  299. if(file_exists('la_config.php')) $f='la_config.php';
  300. else if(file_exists('la_config.md')) $f='la_config.md';
  301. if(!isset($f)) return;
  302. $c = file_get_contents($f);
  303. if(preg_match_all('/-\s*(\S+)\s*=\s*(\S+)\s*$/um', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  304. $str = $m[1];
  305. $this->$str = $m[2];
  306. }
  307. $this->CommentEnabled = $this->CommentEnabled=="True";
  308. if(!isset($this->GalleryStep)) $this->GalleryStep=20;
  309. }
  310. function ReadConfig(){
  311. $this->ReadFromExistingConfig();
  312. if(file_exists('la_redirect.md')){
  313. $c = file_get_contents('la_redirect.md');
  314. $this->BuildRedirectConfig($c);
  315. }
  316. if(!file_exists('la_config.php')){
  317. $this->Install();
  318. }
  319. $this->Translations=[];
  320. if(file_exists("translations.md")){
  321. $c = file_get_contents('translations.md');
  322. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  323. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  324. $this->Translations[] = $entry;
  325. }
  326. }
  327. if(file_exists("custom_translations.md")){
  328. $this->CustomTranslationContent = file_get_contents('custom_translations.md');
  329. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$this->CustomTranslationContent, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  330. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  331. $this->Translations[] = $entry;
  332. }
  333. }
  334. $this->LoginTokens=[];
  335. if(file_exists('la_tokens.php')){
  336. $c = file_get_contents('la_tokens.php');
  337. if(preg_match_all('/-\s+(\S.*)\s*$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  338. $this->LoginTokens[] = $m[1];
  339. }
  340. }
  341. }
  342. function MastodonPostStatus($status){ return $this->MastodonCall('/api/v1/statuses', 'POST', $status); }
  343. function MastodonPostMedia($media){ return $this->MastodonCall('/api/v1/media', 'POST', $media); }
  344. function MastodonCall($endpoint, $method, $data){
  345. $headers = [
  346. 'Authorization: Bearer '.$this->MastodonToken,
  347. 'Content-Type: multipart/form-data',
  348. ];
  349. $ch = curl_init();
  350. curl_setopt($ch, CURLOPT_URL, $this->MastodonURL.$endpoint);
  351. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  352. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  353. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  354. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  355. $reply = curl_exec($ch);
  356. if (!$reply) {
  357. return json_encode(['ok'=>false, 'curl_error_code' => curl_errno($ch_status), 'curl_error' => curl_error(ch_status)]);
  358. }
  359. curl_close($ch);
  360. return json_decode($reply, true);
  361. }
  362. function MastodonSendPost(&$post, &$errmsg=NULL){
  363. if(isset($post['mark_value']) && $post['mark_value']==7){ return NULL; }
  364. $this->LanguageAppendix = 'zh';
  365. if(in_array($this->MastodonPreferredLang,['en','zh'])){ $this->LanguageAppendix = $this->MastodonPreferredLang; }
  366. $this->ConvertPost($post);
  367. $media_ids = NULL;
  368. $mastodon_post_url = NULL;
  369. $imcount = 0;
  370. if(isset($post['original_images']) && isset($post['original_images'][0])) foreach($post['original_images'] as $im){
  371. $curl_file = curl_file_create($im, mime_content_type($im), basename($im));
  372. $body = ['file' => $curl_file,]; $response = $this->MastodonPostMedia($body);
  373. if(isset($response['id'])){ if(!isset($media_ids)){$media_ids=[];} $media_ids[]=$response['id']; }
  374. else{ if(isset($response['error'])) $errmsg.=$response['error']."<br /><br />"; }
  375. $imcount++; if($imcount>=4){ break; }
  376. }
  377. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$post['html']));
  378. if(isset($this->HostURL) && $this->HostURL!=""){
  379. $text.=("\n\n".$this->T('来自').' '.$this->HostURL.'?post='.$post['id']);
  380. }
  381. $vis = (isset($post['mark_value']) && $post['mark_value']==6)?"private":"public";
  382. $status_data = [ 'status' => $text, 'visibility' => $vis, 'language' => $this->LanguageAppendix, ];
  383. if(isset($post['prev']) && ($pp=&$this->GetPost($post['prev']))!=$this->NULL_POST){
  384. if(isset($pp['mastodon_url'])){ $status_data['in_reply_to_id'] = basename($pp['mastodon_url']);
  385. }
  386. }
  387. if(isset($media_ids[0])){ $status_data['media_ids']=$media_ids; }
  388. $status_data = preg_replace('/(media_ids%5B)[0-9]+(%5D)/','$1$2', http_build_query($status_data));
  389. $status_response = $this->MastodonPostStatus($status_data);
  390. if(isset($status_response['url']) && $status_response['url']){
  391. $mastodon_post_url = $status_response['url'];
  392. $post['mastodon_url'] = $mastodon_post_url;
  393. $this->NeedWritePosts = 1;
  394. }
  395. if(isset($status_response['error'])) { $errmsg .= $status_response['error']; }
  396. return $mastodon_post_url;
  397. }
  398. function __construct() {
  399. $this->ReadConfig();
  400. $this->PDE = new ParsedownExtra();
  401. $this->PDE->SetInterlinkPath('/');
  402. $this->Posts = [];
  403. $this->Threads = [];
  404. $this->VisitedHere = [];
  405. $this->NULL_IMAGE_DUMMY = [];
  406. $this->NULL_IMAGE_DUMMY['name']=$this->NULL_IMAGE_DUMMY['file']=$this->NULL_IMAGE_DUMMY['thumb']="";
  407. $this->Markers=['●', '○', '✓', '×', '!', 'P', 'E', 'S', 'N'];
  408. $this->PostsPerPage = 40;
  409. $this->CommentsPerPage = 100;
  410. $this->HotPostCount = 15;
  411. $this->TIME_STRING = date('YmdHis');
  412. $this->WayBack = NULL;
  413. $this->YearBegin = $this->YearEnd = 2000;
  414. $this->DoneReadPosts = $this->DoneReadImages = $this->DoneReadArchive = false;
  415. $this->NeedWritePosts= $this->NeedWriteImages= $this->NeedWriteArchive= false;
  416. $this->UsePosts = &$this->Posts;
  417. $this->PNUMBER=0;
  418. }
  419. function DoLogout(){
  420. $this->LoggedIn = false;
  421. unset($_SESSION['user_id']);
  422. $this->RecordToken(true);
  423. }
  424. function RecordToken($unset_current=false){
  425. if(isset($unset_current) && isset($_COOKIE['la_token'])){
  426. $t = $_COOKIE['la_token'];
  427. setcookie('la_token', null, -1,'/'); unset($_COOKIE['la_token']);
  428. if (($key = array_search($t,$this->LoginTokens)) !== false) { unset($this->LoginTokens[$key]); }
  429. $this->WriteTokens();
  430. return null;
  431. }else{
  432. $t = uniqid('la_',true);
  433. setcookie('la_token',$t,time()+3600*24*7,'/'); $_COOKIE['la_token'] = $t;
  434. $this->LoginTokens[] = $t;
  435. $this->WriteTokens();
  436. return $t;
  437. }
  438. }
  439. function LoginThroughToken(){
  440. if(!isset($_COOKIE['la_token'])) return false;
  441. $t = $_COOKIE['la_token'];
  442. if (($key = array_search($t,$this->LoginTokens)) !== false) {
  443. $_SESSION['user_id']=$this->Admin;
  444. $this->LoggedIn = true;
  445. setcookie('la_token',$t,time()+3600*24*7,'/');
  446. return true;
  447. }
  448. return false;
  449. }
  450. function DoLogin(){
  451. session_start();
  452. $redirect=false;
  453. if(isset($_GET['logout'])){ $this->DoLogout(); header('Location:index.php'); }
  454. else if(!isset($_SESSION['user_id'])){
  455. if(isset($_POST['login_button'])){
  456. $id = trim($_POST['login_id']);
  457. $pwd = trim($_POST['login_password']);
  458. if(strtolower($this->Admin)==strtolower($id)&&password_verify($pwd, $this->Password)){
  459. $_SESSION['user_id']=$id;
  460. $this->RecordToken(false);
  461. }
  462. $redirect = true;
  463. }else if($this->LoginThroughToken()){
  464. // nothing;
  465. }
  466. }else{
  467. if(strtolower($_SESSION['user_id']) == strtolower($this->Admin)){ $this->LoggedIn = true; }
  468. else{ $this->DoLogout();}
  469. }
  470. if($redirect){
  471. header('Location:index.php'.(isset($_GET['post'])?("?post=".$_GET['post']):"")
  472. .(isset($_GET['settings'])?"?settings=true":""));
  473. }
  474. }
  475. function SetHereMainImage($im_this){
  476. if(isset($im_this) && isset($im_this['parent'])){ $this->HereMainImage = &$this->FindImage($im_this['parent'],true);}
  477. }
  478. function RecordVisitedHere($image_or_post_name, $image_title){
  479. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  480. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  481. if(!(isset($_SESSION[$visited_here][0]) && in_array($image_or_post_name,$_SESSION[$visited_here]))){
  482. $_SESSION[$visited_here][] = $image_or_post_name;
  483. }
  484. if(isset($image_title)){ $this->HereDisplayTitle=$image_title; }
  485. $this->HereNumber = array_search($image_or_post_name,$_SESSION[$visited_here])+1;
  486. $_SESSION['here_number'] = $this->HereNumber;
  487. $this->VisitedHere = $_SESSION[$visited_here];
  488. }
  489. function HereLinkFromNumber($number){
  490. $number -= 1; if($number<0){ $number=0; }
  491. if($number>=sizeof($this->VisitedHere)){ $number = sizeof($this->VisitedHere)-1; }
  492. if(preg_match('/(jpg|jpeg|png|gif)/u',$this->VisitedHere[$number])){ return "?here=images/".$this->VisitedHere[$number]; }
  493. else{ return "?post=".$this->VisitedHere[$number]; }
  494. }
  495. function WriteStyles(){
  496. $this->style="
  497. html{font-size:18px;font-family:'Noto Serif CJK SC','Times New Roman','SimSun', Georgia, serif;}
  498. .page{overflow:none;}
  499. body{background-color:%white%;color:%black%;}
  500. sup,sub{line-height:0;} .lpctrl{display:none;}
  501. blockquote{border-left:2px solid %black%;padding-left:0.3em;}
  502. *{box-sizing:border-box;padding:0;margin:0;font-weight:normal;}
  503. b,strong,th{font-weight:bold;}
  504. select{font-size:inherit;}
  505. .page,.page_gallery{padding:1em;padding-top:0;padding-bottom:0;}
  506. .hidden_on_desktop,.hidden_on_wide{display:none;}
  507. .hidden_on_desktop_force{display:none !important;}
  508. ::file-selector-button{background:none;border:none;}
  509. a,button,::file-selector-button{text-decoration:underline;color:%black%;text-decoration-thickness:2px;text-underline-offset:0.15em;}
  510. a:hover,.button:hover,::file-selector-button:hover{text-decoration:none;color:%gray%;}
  511. .button:disabled{background-color:%gray%;pointer-events:none;}
  512. header{position:fixed;top:0;width:calc(100% - 2em);background-color:%white%;z-index:10;padding-top:0.5em;box-shadow: 0.5em 0px %white%;}
  513. header::before{content:'';position:absolute;left:0;right:0;top:0;height:1.95em;box-shadow:-2em 0em 1em -1em inset %white%;pointer-events:none;}
  514. header>div{overflow:auto;white-space:nowrap;}
  515. .header_nav{display:inline;}
  516. header a,.left a,.footer a,.clean_a,.clean_a a{text-decoration:none;}
  517. header a:hover,.button:hover{color:%gray% !important;text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:0.15em;}
  518. .exp_h_f{padding-top:0.3em !important;padding-bottom:0.3em !important;line-height:1.5em !important;height:2.1em !important;}
  519. .exp_f{text-align:center;}
  520. .toc_button{position:absolute;top:0.5em;right:0;text-shadow: 0px 0px 10px %white%;background-color:%white%88;}
  521. .footer{background-color:%white%;z-index:10;position:relative;}
  522. .invert_a,.invert_a a{color:%gray%;text-decoration:none;}
  523. .invert_a:hover,.invert_a a:hover{color:%black% !important;}
  524. .gray,.gray a{color:%gray%;}
  525. hr{border:1px solid %gray%;}
  526. header ul,.small_footer ul,.small_footer span,header li,.small_footer li{display:inline-block;vertical-align:text-top;}
  527. header li::before,.small_footer li::before{content:' - '}
  528. header li ul{display:none;}
  529. header:hover li ul{display:inline;}
  530. header li ul li{display:block !important;margin-left:1em;}
  531. header li ul li a{font-size:0.9em;}
  532. //h1,h2,h3,h4,h5{font-size:1em;}
  533. //h1{text-decoration:underline;}
  534. header h1,header h2,header h3,header h4,header h5,header p{display:inline;font-size:1rem;}
  535. .main{position:relative;word-spacing:-1em;top:2em;margin-bottom:2em;}
  536. .main *{word-spacing:initial;}
  537. pre{overflow:auto;display:block;line-break:anywhere;white-space:pre-wrap;}code{font-size:0.83em;}
  538. ul{display:block;}
  539. li{display:block;}
  540. .clean_table{border:none;font-size:1em !important;}.clean_table thead{box-shadow:none;}.clean_table td{vertical-align:top;}
  541. table{width:100%;border-collapse:collapse;border-bottom:2px solid %black%;border-top:3px solid %black%;}
  542. .settings input,.post inpiut{border:none!important;}
  543. .post table img{max-width:min(100%, 20rem) !important;}
  544. td{padding-left:0.1em;padding-right:0.1em;}
  545. td:first-child{padding-left:0;}
  546. td:last-child{padding-right:0;}
  547. tbody tr:hover{box-shadow:inset 0 -2px 0 0px %black%;}
  548. thead{box-shadow:inset 0 -1px 0 0px %black%;}
  549. .post table{font-size:0.85em;}
  550. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 20em);}
  551. .interesting_tbody td{display:contents;}
  552. .interesting_tbody tr{position:relative;scroll-margin:4.5em}
  553. .interesting_tbody td>*{display:table-cell;}
  554. .interesting_tbody td>.wscroll{display:none !important;}
  555. .interesting_tbody .post_access{padding-top:0;}
  556. .interesting_tbody .post_menu_button{top:0;opacity:0;}
  557. .interesting_tbody td>img,.interesting_tbody td>.imd{position:absolute;left:1.4em;z-index:-1;height:1em;width:20em;
  558. display:flex;top:0.2em;object-fit:cover;max-width:calc(100% - 1.4em) !important;overflow:hidden;}
  559. .interesting_tbody td>.imd>a{display:flex;}
  560. .interesting_tbody img{object-fit:cover;width:100%;}
  561. .interesting_tbody .p_row{display:flex;position:absolute;left:1.4em;top:0.25em;z-index:-1;flex-wrap:nowrap;max-width:calc(100% - 1.4em);}
  562. .interesting_tbody .p_thumb{height:1em;}
  563. .interesting_tbody .p_thumb img,.interesting_tbody .p_thumb video{max-height:10rem !important;max-width:20rem !important;}
  564. tr:hover .post_menu_button{opacity:1;}
  565. .post_current_row{background-color:%graybkg%;mix-blend-mode:screen;text-shadow:0px 0px 0.1em %white%;}
  566. .align_right{text-align:right;}
  567. .left{display:inline-block;vertical-align:top;width:25%;padding-right:1.5em;padding-bottom:4rem;position:sticky;top:2em;
  568. overflow:auto;max-height:calc(100vh - 2.6em);}
  569. .center{display:inline-block;vertical-align:top;width:50%;overflow:visible;padding-bottom:4rem;}
  570. .center_slides{display:block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;font-size:5vmin;user-select:none;}
  571. .center_slides .print_column{display:table;position:fixed;top:0;right:0;left:0;bottom:0;width:100%;height:100%;z-index:90;}
  572. .center_slides .print_column .post{display:table-cell;vertical-align:middle;padding:5vmin !important;max-height:100vh;width:100vw;overflow:auto;}
  573. .center_slides .active_post{background-color:%white%;}.center_slides .post{background-color:%white%;}
  574. .center_slides .post_access{display:none;}
  575. .center_slides .post_menu_button{display:none !important;}
  576. .center_slides .post_width{display:block;vertical-align:middle;max-height:100vh;overflow-y:auto;overflow-x:hidden;width:100%;}
  577. .center_slides .linked_posts{display:none;}.center_slides .ref_compact{position:relative!important;display:block!important;}
  578. .slides_buttons{position:fixed;z-index:200;right:0.5rem;bottom:0.5rem;user-select:none;background-color:%white%aa;padding:0.5rem;font-family:monospace;}
  579. .slides_buttons a{text-decoration: none;}
  580. .center_slides .imd{text-align:center;pointer-events:none;}
  581. .imd_float{float:right;width:50% !important;clear:both;margin-left:0.5em !important;}
  582. .center_wide{display:inline-block;vertical-align:top;width:75%;padding-left:0.3em;overflow:visible;padding-bottom:4rem;}
  583. .center_full{display:inline-block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;}
  584. .center_wide .p_thumb{height:12rem;width:12rem;margin:0;margin-right:0.5rem;margin-bottom:0.5rem;box-shadow:5px 5px 15px 2px black;}
  585. .linked_posts{padding:0.5em;background-color:#0004;box-shadow:0px 0.2em 0.2em -0.2em inset %shadow%;}
  586. .active_post .linked_posts{background-color:%highlight_slice%;}
  587. input:checked~.linked_posts,input:checked~a{display:none;}
  588. .bkg_recent>.post,.bkg_section{background:%post_white%;box-shadow:0em 0em 0.5em %shadow%;margin-bottom:0.5em;}
  589. .bkg_recent>.post>.post_width :last-child{margin-bottom:0;}
  590. .sticky_title{position:sticky;top:calc(1.6rem + 2px);z-index:1;background-color:%white%;pointer-events:none;}
  591. .center_exp{display:block;width:80%;margin:0 auto;overflow:visible;padding-bottom:1em;}
  592. .table_top{position:relative;left:calc(-50% - 0.45em);width:calc(200% + 0.6em);background:%white%;z-index:1;
  593. box-shadow:0px 0px 2em 1em %white%;margin-top:2em;margin-bottom:2em;}
  594. textarea,input[type=text],input[type=password]{font-family:monospace;width:100%;display:block;font-family:inherit;max-height:60vh;font-size:inherit;}
  595. select,textarea,input[type=text],input[type=password]{font-family:monospace;background:none;border:none;border-bottom:1px solid %black%;color:%black%;}
  596. .text_highlight input{border-bottom:1px solid %white%;color:%white%;}
  597. .button{background:none;border:none;font-family:inherit;color:%black%;font-size:inherit;font-weight:bold;}
  598. .post{position:relative;scroll-margin:3.5em;}
  599. .active_post{background-color:%highlight_white%;}.active_post .post_access{background-color:%highlight_slice%;}
  600. .center_exp .post{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;}
  601. .post li,.footer_additional li,.footer_additional li,.post_dummy li
  602. {display:list-item;margin-left:1em;list-style:disc;}
  603. .post li li,.footer_additional li li,.footer_additional li li,.post_dummy li li
  604. {list-style:circle;}
  605. ol li{list-style:unset !important;}
  606. .post_width > *,.post_dummy > *,.post_ref > *{margin:0;margin-bottom:0.5rem}
  607. .post > td:nth-child(3) > *{margin:0;margin-bottom:0.5rem}
  608. .post_dummy > *{width:60%;margin:0 auto;margin-bottom:0.5rem}
  609. .post_dummy > p img{display:block;width:100%;margin:0 auto;}
  610. .gallery_left li{display:list-item;margin-left:1em;list-style:none;}
  611. .gallery_left .selected{list-style:'→';}
  612. .bkg_section .post_width{padding-top:0;padding-bottom:0;}
  613. .bkg_section .restart+.post .post_width{padding-top:0.5em;}
  614. .post_width{display:inline-block;margin-left:0.5em;vertical-align:top;}
  615. .opt_compact .post_width,.ref_compact .post_width{padding-top:0;padding-bottom:0;}
  616. .p_thumb .post_menu_button{right:0.3rem;top:0.3em;}
  617. .post_menu_button{position:absolute;display:none;right:0rem;width:1.5rem;box-shadow:0px 0px 3px %shadow%;
  618. text-align:center;border-radius:0.3em;user-select:none;cursor:pointer;z-index:10;background-color:%post_white%aa;}
  619. .pointer{cursor:pointer;}
  620. .post:hover .post_menu_button{display:block;}
  621. .pop_menu{position:absolute;top:0.3rem;z-index:95;background-color:%grayslice%;
  622. padding:0.3em;right:0.3rem;text-align:right;border-radius:0.3em;font-size:1rem;
  623. box-shadow:0px 0px 10px %shadow%;}
  624. .pop_menu li{list-style:none;margin-left:0;}
  625. .pop_menu hr{border:2px solid rgba(0,0,0,0.1);}
  626. .toc{left:60%;width:40%;top:0;position:absolute;}
  627. .paa{width:1.4rem;min-width:1.4rem;}
  628. .opt_compact .post_access,.ref_compact .post_access{border-right:2px solid %gray%;background-color:%post_white%;right:unset;left:-2em;}
  629. .active_post .opt_compact .post_access,.active_post .ref_compact .post_access{background-color:%highlight_white%;}
  630. .post_preview{overflow:hidden;margin-bottom:0.4em;background-color:%white%aa;box-shadow: 0px 0px 0.2em %shadow%;}
  631. .post_preview:hover{filter:contrast(90%);}
  632. .active_post .post_preview:hover{filter:contrast(90%);}
  633. .hide_long{max-height:12em;overflow:hidden !important;}
  634. .post .post_ref{margin:0;padding-left:1.5rem;}
  635. .post_ref_main{display:inline-block;vertical-align:top;max-height:6em;overflow:hidden;margin:0.4em;}
  636. .post_ref_images{overflow:hidden;margin:0.4em;margin-top:0;}
  637. .post_ref_hint{text-align:right;}
  638. .page_selector{padding-top:2rem;text-align:center;}
  639. .smaller{font-size:0.85em;} .bigger{font-size:1.3em;} .block{display:block;}
  640. .restart{text-align:left;padding-top:1rem;padding-bottom:0.5rem;}
  641. .opt_compact{margin-left:2rem;}
  642. .post_box_top{padding-bottom:0.3em;padding-top:0.3em;}
  643. .post_box_fixed_bottom{position:sticky;bottom:0em;background-color:%white%;z-index:5;}
  644. .spacer{height:0.5em;}
  645. .pop_right,.pop_right_big{position:fixed;top:0;right:0;bottom:0;width:30%;z-index:100;background-color:%graybkg%;display:none;
  646. transition-timing-function:ease-out;padding:1rem;overflow:auto;}
  647. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  648. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  649. @keyframes pop_slide_in_big{0%{right:-30%;}100%{right:0%;}}
  650. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-30%;}}
  651. .backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background-color:rgba(0,0,0,0.5);transition-timing-function:ease-out;z-index:90;}
  652. @keyframes backdrop_fade_in{0%{opacity:0%;}100%{opacity:100%;}}
  653. @keyframes backdrop_fade_out{0%{opacity:100%;}100%{opacity:0%;}}
  654. .toc_entry_1{font-size:1.1em;}
  655. .toc_entry_2{font-size:1.0em;padding-left:0.5rem;}
  656. .toc_entry_3{font-size:0.9em;padding-left:1rem;}
  657. .toc_entry_4{font-size:0.85em;padding-left:1.5rem;}
  658. .toc_entry_5{font-size:0.8em;padding-left:2rem;}
  659. h1,h2,h3,h4,h5{scroll-margin:2.5em;}
  660. .post h1,.post h2,.post h3,.post h4,.post h5{margin-top:1rem;}
  661. .left ul h1,.left ul h2,.left ul h3,.left ul h4,.left ul h5,.left ul p{font-size:1em;}
  662. .deleted_post{color:%gray%;text-decoration:line-through;}
  663. #file_list{margin-top:0.5em;}
  664. .file_thumb img,.file_thumb video{max-height:100%;max-width:100%;object-fit:cover;min-width:100%;min-height:100%;}
  665. .file_thumb video{border:2px dashed %black%;}f
  666. #file_list li{margin-bottom:0.3em;}
  667. .ref_thumb{white-space:nowrap;overflow:hidden;}
  668. .ref_thumb .file_thumb{width:2em;height:2em;margin:0;margin-right:0.3em}
  669. .side_thumb li{margin:0.4em;display:inline-block;}
  670. .file_thumb{width:4em;height:4em;display:inline-block;line-height:0;vertical-align:middle;overflow:hidden;}
  671. .p_row{display:flex;flex-wrap:wrap;width:100%;}
  672. .p_thumb{display:flex;flex-grow:100;height:6rem;overflow:hidden;position:relative;margin-right:0.5em;margin-bottom:0.5em;}
  673. .p_thumb_narrow{width:1rem !important;flex-grow:1;opacity:0.2;}
  674. .p_thumb img,.p_thumb video{object-fit:cover;max-height:100%;min-width:100%;}.p_thumb a{display:contents;}
  675. .p_thumb:hover .post_menu_button{display:block;}
  676. .p_thumb_selected{color:%black% !important;}
  677. .p_thumb_selected{display:block;}
  678. .post .p_thumb img,.post .p_thumb video{max-height:6rem;}
  679. .p_thumb video{border-bottom:0.4em dashed %black%;border-top:0.4em dashed %black%;}
  680. .p_thumb_end{flex-grow:10000 !important;box-shadow:none;align-items:center;padding:2em !important;}
  681. .p_thumb_end:hover, .p_thumb_end a:hover{background-color:%gray%;cursor:pointer;}
  682. .big_image_box{position:fixed;top:0;bottom:0;left:0;width:75%;z-index:95;text-align:center;pointer-events:none;}
  683. .big_image_box *{pointer-events:auto;}
  684. .big_image_box img,.big_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  685. .here_image_box{position:relative;width:100%;text-align:center;height:calc(100vh - 4.5em);}
  686. .here_image_box img,.here_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  687. .big_side_box{position:fixed;top:0;bottom:0;right:0;width:25%;overflow:auto;z-index:98;color:%black%;padding:1rem;pointer-events:none;}
  688. .big_side_box a,.big_side_box hr,#dropping_background{color:%black%;}
  689. .big_side_box a:hover{color:%gray%;}
  690. .big_side_box *{pointer-events:auto;}
  691. .big_side_box .post_preview{border-bottom:1px dotted %black%;background-color:unset;}
  692. .image_nav{pointer-events:none;}
  693. #dropping_background{background-color:rgba(255,255,255,0.4);position:fixed;top:0;right:0;bottom:0;left:0;z-index:100;text-align:center;
  694. box-shadow:0px 0px 500px black inset;display:flex;align-items:center;}
  695. img,video{cursor:pointer;max-height:100%;max-width:100%;vertical-align:middle;}
  696. .post img,.post video{max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  697. .post > a > img,.post > a > video{display:block;margin:0.3em auto;}
  698. .post .original_img{max-width:100%;display:inline-block;vertical-align:middle;
  699. margin-left:auto;margin-right:auto;max-width:100%;max-height:90vh;}
  700. .center_exp .post .original_img{display:block;}
  701. .original_img img,.original_img video{max-height:90vh;max-width:100%;}
  702. .p_row .original_img{margin-bottom:0;}
  703. .post_ref .original_img{margin:unset;max-width:unset;max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  704. .imbtn{color:rgba(0,0,0,0);display:block;contain:content;padding:0.25em;margin-bottom:0.5em;text-decoration:none;}
  705. .imbtn img{display:block;object-fit:cover;position:absolute;top:0;left:0;bottom:0;right:0;margin:auto;z-index:-1;
  706. min-width:100% !important;min-height:100% !important;filter:opacity(70%);transition:0.1s;}
  707. .imbtn:hover img{filter:opacity(20%) blur(0.2em);} .imbtn:hover{color:%black% !important;}
  708. .imbtn:hover {color:%black%;text-shadow:0px 0px 5px %white%;}
  709. header .imbtn{display:inherit;border:none;padding:0em;height:unset;height:unset;margin:0em;contain:unset;}
  710. header .imbtn:hover{border:none;color:%gray% !important;} header .imbtn img{display:none;}
  711. .b ul{font-size:1.4em;}
  712. no_pop{cursor:unset;}
  713. p{min-height:0.8em;}
  714. .bold,.bold *{font-weight:bold;}
  715. .footer_additional{display:inline-block;width:50%;vertical-align:text-top;white-space:normal;}
  716. .small_footer{background-color:%white%;padding-bottom:0.5em;position:sticky;bottom:0px;z-index:10;box-shadow: 0.5em 0px %white%;}
  717. .small_footer>div{overflow:auto;white-space:nowrap;}
  718. .small_footer::before{content:'';position:absolute;left:0;right:0;bottom:0;height:1.95em;box-shadow:-2em 0em 1em -1em inset %white%;pointer-events:none;}
  719. .top_post_hint{margin-left:0.5em;font-weight:bold;}
  720. .white{color:%white%;}
  721. .full_box{border:1px solid %black% !important;padding:0.3rem;overflow:auto;}
  722. .image_nav_prev,.image_nav_next{z-index:100;position:absolute;line-height:0;height:50%;width:20%;top:25%;display:flex;align-items:center;
  723. transition:background-size .2s ease;padding:0.5em;text-shadow:0px 0px 5px black;user-select:none;pointer-events:auto;}
  724. .image_nav_prev{left:0;justify-content:left;background:linear-gradient(to left, rgba(0,0,0,0), rgba(0,0,0,0.4));
  725. background-repeat:no-repeat;background-size:0% 100%;}
  726. .image_nav_prev:hover,.image_nav_next:hover{background-size:100% 100%;}
  727. .image_nav_next{right:0;justify-content:right;background:linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.2));
  728. background-repeat:no-repeat;background-size:0% 100%;transition:background-size .2s ease;background-position-x:100%;}
  729. .inquiry_buttons{position:fixed;left:0;right:25%;text-align:center;bottom:1em;margin:0 auto;width:max-content;
  730. background-color:rgba(0,0,0,0.5);z-index:110;padding:0.2em;padding-left:1em;padding-right:1em;
  731. border-radius:1em;box-shadow:0px 0px 5px;text-shadow:0px 0px 5px black;opacity:1;user-select:none;}
  732. .lr_buttons{background-color:rgba(0,0,0,0.5);padding:0.5em;padding-top:1em;padding-bottom:1em;
  733. border-radius:1em;box-shadow:0px 0px 5px;font-size:1.2rem;text-shadow:0px 0px 5px black;}
  734. .img_btn_hidden{opacity:0;transition:opacity 0.2s;}
  735. .special_alipay{background-color:#027aff;color:white;white-space:nowrap;
  736. font-family:sans-serif;font-weight:bold;border-radius:0.7em;font-size:0.75em;padding:0.25em;}
  737. .special_paypal{background-color:white;color:#253b80;white-space:nowrap;
  738. font-family:sans-serif;font-weight:bold;border-radius:2em;font-size:0.75em;
  739. padding:0.25em;padding-left:0.5em;padding-right:0.65em;font-style: italic;}
  740. .special_paypal_inner{color:#169bd7;}
  741. #waiting_bar{position:fixed;z-index:200;top:0;left:0;right:0;height:0.2em;background-color:%black%;transform:translate(-100%,0);
  742. animation:anim_loading 1s linear infinite;}
  743. @keyframes anim_loading{0%{transform:translate(-100%,0);} 100%{transform:translate(100%,0);}}
  744. .product_ref{width:32%;padding:0.2em!important;display:inline-block;text-align:center;vertical-align:top;margin-bottom:0.8em;}
  745. .product_thumb{max-height:11em;max-width:11em;display:inline-flex;margin-bottom:0.2em;background-color:%graybkg%;}
  746. .product_thumb img,{box-shadow:none;object-fit:contain;max-height:unset;max-width:unset;width:100%;margin:0 auto !important;}
  747. .product_ref p{margin-bottom:0.2em;text-align:left;}
  748. .post_preview .product_thumb{max-height:4em;max-width:6em;}
  749. .purchase_button{background-color:%black%;color:%white%;padding-left:0.5em;padding-right:0.5em;text-decoration:none;font-weight:bold;}
  750. .page_break{page-break-after:always;}
  751. .text_highlight,.text_highlight a,.text_highlight select{background-color:%black%;color:%white%;border:none;}
  752. .gray.text_highlight,.gray.text_highlight a,.gray.text_highlight select{background-color:%gray%;color:%white%;}
  753. .show_on_print{display:none;}.inline_print{display:none;}
  754. .comment{font-size:0.9em;font-family:sans-serif;overflow:auto !important;width:100%;}
  755. .comment tbody tr:hover{box-shadow:none;}
  756. .comment table{border:none;}
  757. .comment li{display:list-item;list-style:'→';padding-left:0.3em;}
  758. .comment ul{padding-left:1em;}
  759. .comment ul li *{margin-bottom:0.5em;}
  760. .history li{display:list-item;list-style:disc;padding-left:0.3em;}
  761. .history li li{list-style:circle;}
  762. .history ul{padding-left:1em;}
  763. .history a{text-decoration:underline;}
  764. .history .list{overflow:auto;white-space:nowrap;}
  765. .diff_table{table-layout:fixed;}
  766. .diff_table thead{font-size:0.9em;text-align:center;}
  767. .diff_table tbody pre{font-size:0.9rem;white-space:pre-line;}
  768. .diff_table td{vertical-align:top;}
  769. .omittable_title{display:block;width:100%;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
  770. .wayback_close{float:right;}
  771. .wayback_expand{display:inline;}
  772. .post_selecting .post>*>*{pointer-events:none;}
  773. .post_selected{background-color:%graybkg%;}
  774. .small_pad{padding:0.2em;padding-top:0.1em;padding-bottom:0.1em;}
  775. .wscroll{scroll-margin:3.5em;padding-left:0.3em;display:none;font-weight:bold;font-size:0.75em;box-shadow: 13em 0em 4em -8em inset %gray%;color:%white%;}
  776. .wscroll:target{display:block;} .post_ref .wscroll{display:none !important;}
  777. .wayback_link{display:inline;}
  778. .imd{object-fit:cover;width:100%;}
  779. .center_exp .post>.imd,.center_exp .p_row{width:60%;}
  780. .center_exp .p_thumb img,.center_exp .p_thumb video{max-height:3rem;}
  781. .center_exp .p_thumb{max-height:3rem;filter:opacity(40%);}
  782. .center_exp .p_thumb:hover{filter:unset;}
  783. #here_buttons{display:contents;}
  784. .here_buttons_inner{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;max-height:100%;max-width:100%;}
  785. .here_btn{position:absolute;z-index:110;transform:translate(-50%,-50%);
  786. width:2em;height:2em;display:block;border:1px solid %black%;background-color:rgba(0,0,0,0.5);}
  787. .round_btn{box-shadow: 0px 0px 0px 1px inset %black%;display:inline-block;padding-left:0.4em;padding-right:0.4em;border-radius:0.5em;}
  788. .center .center{width:100%;padding-bottom:unset;}
  789. .center{border:none;}
  790. .center{overflow:auto;}
  791. .center>tbody>tr:hover{box-shadow:none;}
  792. .center>tbody>tr>td{white-space:normal;vertical-align:top;min-width:1em;}
  793. .center>tbody>tr>td:first-child{text-align:center;color:%gray%;padding-left:0.1em;}
  794. .center>tbody>tr>td:nth-child(1)>*{}
  795. .center>tbody>tr>td:nth-child(2){text-align:center;color:%gray%;box-shadow:0.3em 0px 0px -0.15em %black%44;}
  796. .center>tbody>.no_line>td:nth-child(2){box-shadow:none;}
  797. .center>tbody>tr>td:nth-child(2) a{color:%gray%;}
  798. .center>tbody>tr>td:nth-child(2) .marked{color:%black% !important;}
  799. .center>tbody>tr>td:nth-child(3){width:100%;text-align:left;padding-left:0.5em;}
  800. .center>tbody>tr>td:nth-child(3)>div{overflow:auto;}
  801. .center>tbody>tr>td:last-child{padding-right:0.5em;}
  802. .main>.center>tbody>tr{border-bottom:1px dotted %black%;}
  803. .ref_count{cursor:pointer;} td .ref_count{text-align:left;display:block;}
  804. .big_side_box .center{width:100%;}
  805. #big_image_upload{max-width:100%;}
  806. label{text-align:left;display:inline-block;}
  807. @media screen and (max-width:1000px) and (min-width:666px){
  808. .left{width:35%;}
  809. .center,.center_wide{width:65%;}
  810. .center_wide .p_thumb{height:8rem;width:8rem;margin-right:0.4rem;margin-bottom:0.4rem;box-shadow:3px 3px 12px 2px black;}
  811. .post_width{width:calc(100% - 1.5rem);padding-left:0.2em;}
  812. .hidden_on_wide{display:unset;}
  813. .pop_right{width:30%;}
  814. .pop_right_big{width:40%;}
  815. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  816. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  817. @keyframes pop_slide_in_big{0%{right:-40%;}100%{right:0%;}}
  818. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-40%;}}
  819. .big_side_box{width:35%;}
  820. .big_image_box{width:65%;}
  821. .inquiry_buttons{right:35%;}
  822. .table_top{left:calc(-50% - 1.7em);width:calc(154% + 0.5em);}
  823. .post_dummy > *{width:80%;max-width:55rem;}
  824. .center_exp .post>.imd,.center_exp .p_row{width:80%;max-width:55rem;}
  825. .here_btn{width:1.5em;height:1.5em;}
  826. }
  827. @media screen and (max-width:666px){
  828. .main{margin-bottom:unset;}
  829. html{font-size:16px;}
  830. pre{max-width:85vw;}
  831. #titlectrl:checked ~ header .mobile_fold{display:block !important;}
  832. #titlectrl:checked ~ .main .mobile_fold{display:block !important;}
  833. #titlectrl:checked ~ header li ul{display:inline;}
  834. .mobile_fold{display:none !important;}
  835. .hidden_m{display:none !important;}
  836. .block_m{display:block !important;}
  837. .hidden_on_desktop{display:inherit;}
  838. .hidden_on_wide{display:inherit;}
  839. header{position:inherit;}
  840. header ul{display:block;}
  841. header li{display:block;}
  842. header li::before{content:''}
  843. header::before{box-shadow:none;display:none;}
  844. .small_footer::before{box-shadow:none;display:none;}
  845. .left{position:relative;width:100%;top:unset;height:unset;max-height:unset;padding-right:0;display:block;}
  846. .center,.center_wide,.center_full{display:block;position:relative;line-break:anywhere;left:0;top:0;width:100%;padding-left:0;}
  847. .center_wide .p_thumb{height:6rem;width:6rem;margin-right:0.3rem;margin-bottom:0.3rem;box-shadow:2px 2px 10px 1px black;}
  848. .pop_right,.pop_right_big{top:unset;right:0;bottom:0;left:0;width:100%;}
  849. .pop_right{height:30%;}
  850. .pop_right_big{height:70%;}
  851. @keyframes pop_slide_in{0%{bottom:-30%;}100%{bottom:0%;}}
  852. @keyframes pop_slide_out{0%{bottom:0%;}100%{bottom:-30%;}}
  853. @keyframes pop_slide_in_big{0%{bottom:-70%;}100%{bottom:0%;}}
  854. @keyframes pop_slide_out_big{0%{bottom:0%;}100%{bottom:-70%;}}
  855. .big_image_box{position:fixed;top:0;bottom:8.5rem;left:0;right:0;width:100%;}
  856. .side_box_mobile_inner{background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(1,1,1,0.9) 20%);
  857. transition:none;background-size:100% 100%;padding:0.5rem;padding-bottom: 5em;}
  858. .side_box_mobile_inner:hover{background-size:100% 100%;}
  859. .big_side_box{position:fixed;top:0;bottom:0;right:0;left:0;width:100%;
  860. height:unset;padding:0;padding-top:calc(100vh - 8.5rem);background:none;}
  861. .p_thumb{height:3rem;}
  862. .center .post{padding-right:0rem;padding-left:0rem;}
  863. .post .p_thumb img,.post .p_thumb video{max-height:3rem;}
  864. .page,.page_gallery{padding:0.2em;padding-top:0;}
  865. header{padding-top:0.3em;}
  866. .toc_button{top:0.3em;}
  867. .small_footer{padding-bottom:0.3em;}
  868. .footer_additional{display:block;width:100%;}
  869. .album_hint{display:block;font-size:1rem;}
  870. .image_nav{position:absolute !important;}
  871. .image_nav_prev,.image_nav_next{width:25%;}
  872. .image_nav_prev:hover,.image_nav_next:hover{background-size:0% 100%;color:%black% !important;}
  873. .inquiry_buttons{position:relative;left:unset;right:unset;text-align:left;bottom:unset;margin:unset;width:unset;
  874. background-color:unset;z-index:unset;padding:unset;padding-left:unset;padding-right:unset;
  875. border-radius:unset;box-shadow:unset;text-shadow:unset;}.img_btn_hidden{opacity:1;}
  876. .lr_buttons{background-color:unset;padding:unset;padding-top:unset;padding-bottom:unset;
  877. border-radius:unset;box-shadow:unset;font-size:1.3rem;text-shadow:unset;}
  878. .opt_compact,.ref_compact{line-break:anywhere;}
  879. .table_top{left:unset;width:100%;overflow:auto;}
  880. .post table img{min(100%, 30vw) !important;}
  881. .product_ref{width:100%;display:block;}
  882. .post_dummy > *{width:100%;max-width:25rem;}
  883. .center_exp .post>.imd,.center_exp .p_row{width:100%;max-width:25rem;}
  884. .center_exp .post .p_thumb img,.center_exp .post .p_thumb video{max-height:2rem;}
  885. .center_exp .p_thumb{height:2rem;filter:opacity(40%);}
  886. .center_exp .p_thumb:hover{filter:unset;}
  887. .sticky_title{top:0;}
  888. .small_footer{position:relative;}
  889. #upload_selector{width:100%;}
  890. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 10em);}
  891. .wayback_expand{display:block;text-align:center;}
  892. .wayback_link{display:block;}
  893. .center_exp{display:block;width:100%;margin:0 auto;padding-bottom:1em;}
  894. .center_exp .post{overflow:auto;}
  895. .center_exp .imd{width:100%;}
  896. .here_btn{width:1.2em;height:1.2em;}
  897. .exp_h_f{height:unset !important;}
  898. .exp_f{margin-bottom:1em;}
  899. .linked_posts{padding-left:1em;}
  900. .center>tbody>tr>td{min-width:unset;}
  901. .center>tbody>tr>td:last-child{padding-right:0.1em;}
  902. }
  903. @media print{
  904. .small_footer .hidden_on_print{display:none}
  905. header b,.small_footer b{font-weight:normal;}
  906. header{display:table-header-group;box-shadow:none;} .main{display:table-row-group;top:unset;margin-bottom:unset;} .small_footer{text-align:right;}
  907. header::before{box-shadow:none;display:none;} header::after{display:block;height:1em;content:' ';}
  908. .small_footer::before{box-shadow:none;display:block;height:1em;position:relative;}
  909. body,footer,header,.small_footer,a,.clean_a,.invert_a,.clean_a a,.invert_a a{background:none;color:black;}
  910. .bkg_section,.bkg_recent>.post,.active_post{background:none !important;box-shadow:none;}
  911. .post *,.post_dummy *{margin-bottom:0em;}
  912. .p_row,.post table,.post img,.post_ref img,.post_ref .original_img,
  913. .post_width>.original_img,.post pre{margin-top:0.5rem;margin-bottom:0.5rem;text-indent:0;}
  914. pre{white-space:pre-wrap;line-break:anywhere;}
  915. .post p{line-height:1.3;text-indent:2em;} .product_ref p {text-indent:0;}
  916. .post table img{margin:0 !important;}
  917. .post h1+p,.post h2+p,.post img+p,.post video+p,.post .imd+p,.post table+p,.last_wide p:first-of-type{text-indent:0;}
  918. .post ul,.post ol{margin:0.5rem !important;margin-left:1.4rem !important;margin-right: 0rem !important;}
  919. table{border-bottom:2px solid black;border-top:2px solid black;}
  920. .post table img{max-width:5em;max-width:8em !important;max-height:8em !important;}
  921. thead{box-shadow:inset 0 -1px 0 0px black;background:none;}
  922. .linked_posts{display:none;}
  923. .post_width{overflow:clip;left:0;width:100%;padding-left:0em;padding-right:0em;}
  924. .section .post h2{font-size:1.8em;margin:1.5em auto 0 !important;}.list h2,.compact h2{margin:0 !important;}
  925. .section .post h3{font-size:1.5em;margin:1.0em auto 0 !important;}.list h3,.compact h3{margin:0 !important;}
  926. .section .post h4{font-size:1.1em;margin:0.5em auto 0 !important;}.list h4,.compact h4{margin:0 !important;}
  927. .post .post{margin-bottom:0.5rem;margin-top:0.5rem;}
  928. .gray,.gray a,.deleted_post{color:rgba(0,0,0,0.5);}
  929. .left{display:none;}
  930. .center, .center_wide, .center_full{width:100%;padding:0;font-size:16px;line-height:1.3}
  931. hr{border:1px solid black;}
  932. .post_box_top{display:none;}
  933. .post_access{display:none;}
  934. .opt_compact .post_access,.ref_compact .post_access{border-right:none;display:inline;background:unset;}
  935. .text_highlight,.text_highlight a,.gray.text_highlight,.gray.text_highlight a,.purchase_button{background-color:lightgray;color:black;}
  936. .hidden_on_print{display:none !important;}
  937. .print_column{column-count:2;margin-top:0.5rem;margin-bottom:0.5rem;}
  938. .print_column .print_column{column-count:1;margin:unset;}
  939. .opt_compact{margin-left:0;left:1.5em;}
  940. .post .post_ref{padding-left:2rem;}
  941. .section .post h1:first-of-type{column-span:all;display:block;margin-top:1rem !important;margin-bottom:0.5rem !important;}
  942. .bkg_section .restart+.post .post_width{padding-top:0;}
  943. .restart{background-color:unset;padding:unset;}
  944. .opt_compact h1:first-of-type,.ref_compact h1:first-of-type{display:unset;}
  945. .table_top{position:relative;left:0;width:100%;background:none;z-index:1;box-shadow:none;}
  946. .header_nav{display:none;}
  947. .show_on_print{display:block;}.inline_print{display:inline;}
  948. blockquote{border-left:2px solid black;}
  949. .footer_additional{display:none;}
  950. .small_footer{margin-top:1rem;box-shadow:none;}
  951. .page{display:table;width:100%;}
  952. .page_selector{display:none;}
  953. .p_thumb{height:4rem;margin-bottom:0.25rem;}
  954. .post .p_thumb img,.post .p_thumb video{max-height:4rem;}
  955. .sticky_title{box-shadow:none;}
  956. .center_wide .p_thumb{display:inline-flex;height:5.8rem;width:5.8rem;margin-right:0;}
  957. .center_wide .p_row{display:block;}
  958. .interesting_tbody{background:none;}
  959. .interesting_tbody img{display:none !important;}
  960. .imd{margin-top:0.5em;margin-bottom:0.5em;line-height:0px;}
  961. .p_row .imd{margin-top:0em;margin-bottom:0em;}
  962. .center,.center>tbody,.center>tbody>tr,.center>tbody>tr>td{display:block;}
  963. .main>.center>tbody>tr{border:none;}
  964. .center>tbody>tr>td:first-child{display:none;color:rgba(0,0,0,0.5);}
  965. .center>tbody>tr>td:nth-child(2){display:none;color:rgba(0,0,0,0.5);}
  966. .center>tbody>tr>td:nth-child(2) a{display:none;color:rgba(0,0,0,0.5);}
  967. .center>tbody>tr>td:nth-child(3){margin:unset;padding:unset;}
  968. .post > td:nth-child(3) > *{margin:unset;padding:unset;}
  969. .wide_post_print{column-span:all;margin-top:1em;margin-bottom:1em;}
  970. }
  971. ";
  972. //$this->style=preg_replace('/%highlight_white%/','#5b3607',$this->style);
  973. //$this->style=preg_replace('/%highlight_slice%/','#734307',$this->style);
  974. //$this->style=preg_replace('/%grayslice%/','#442c0b',$this->style);
  975. //$this->style=preg_replace('/%post_white%/','#2d2110',$this->style);
  976. //$this->style=preg_replace('/%white%/','#231a0d',$this->style);
  977. //$this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
  978. //$this->style=preg_replace('/%gray%/','#ac7843',$this->style);
  979. //$this->style=preg_replace('/%graybkg%/','#39270e',$this->style);
  980. //$this->style=preg_replace('/%shadow%/','#000000cc',$this->style);
  981. $this->style=preg_replace('/%highlight_white%/','#804a06',$this->style);
  982. $this->style=preg_replace('/%highlight_slice%/','#ae6407',$this->style);
  983. $this->style=preg_replace('/%grayslice%/','#6a491c',$this->style);
  984. $this->style=preg_replace('/%post_white%/','#4a3413',$this->style);
  985. $this->style=preg_replace('/%white%/','#2d2214',$this->style);
  986. $this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
  987. $this->style=preg_replace('/%gray%/','#f8ca9b88',$this->style);
  988. $this->style=preg_replace('/%graybkg%/','#a9270e',$this->style);
  989. $this->style=preg_replace('/%shadow%/','#000000ee',$this->style);
  990. $f = fopen('styles/main.css','w');
  991. fwrite($f,$this->style);
  992. fclose($f);
  993. }
  994. function GiveSafeEMail(){
  995. return preg_replace('/\./u','[dot]',preg_replace('/\@/u','[at]',$this->EMail));
  996. }
  997. function &FindImage($name, $loose=false){ if(!isset($name) || !$name){ return $this->NULL_IMAGE; }
  998. if(isset($this->Images[0])) foreach($this->Images as &$im){
  999. if($loose) { if(preg_match('/'.preg_quote($name).'/u',$im['name'])) return $im; }
  1000. else { if($im['name']==$name) return $im; }
  1001. }
  1002. return $this->NULL_IMAGE;
  1003. }
  1004. function &GiveImageInHere($rand=false){
  1005. $this->ReadImages(); $this->DetectPageType();
  1006. $album = $this->PageType=='here'?$this->HereAlbum:$this->ExpAlbum;
  1007. if(!isset($album) || !$album){
  1008. if(isset($this->Images[0])) return $this->Images[0]; else return $this->NULL_IMAGE; }
  1009. $imlist=[]; $imlist_fallback=[];
  1010. if(isset($this->Images[0])){
  1011. foreach($this->Images as &$im){
  1012. if(isset($im['galleries'][0]) && in_array($album,$im['galleries']) && $this->CanShowImage($im)){
  1013. if(!$rand) return $im; else {
  1014. $imlist_fallback[] = $im;
  1015. if(!in_array($im['name'],$this->VisitedHere)) $imlist[] = $im;
  1016. }
  1017. }
  1018. }
  1019. }
  1020. if(!$rand || !isset($imlist_fallback[0])) return $this->NULL_IMAGE;
  1021. if(sizeof($imlist)){
  1022. $r = random_int(0, sizeof($imlist)-1);
  1023. return $imlist[$r];
  1024. }else{
  1025. $r = random_int(0, sizeof($imlist_fallback)-1);
  1026. return $imlist_fallback[$r];
  1027. }
  1028. }
  1029. function ImageTitle($im){
  1030. $imtitle = (isset($im)&&isset($im['title']))?$im['title']:NULL;
  1031. if(isset($im['parent'])&&($imp = &$this->FindImage($im['parent'],true))&&isset($imp['title'])){ $imtitle=$imp['title']; }
  1032. return $imtitle;
  1033. }
  1034. function ImageHasHere(&$im, $here_name){
  1035. if(!isset($im['here'])||!isset($im['here'][0])) return false;
  1036. foreach($im['here'] as $h) { if($h[0] == $here_name) return true; } return false;
  1037. }
  1038. function ReadImages($clear_non_exist = false){
  1039. $path = 'images/list.md';
  1040. if($this->DoneReadImages){ return; }
  1041. if(!file_exists($path)){ $f = fopen($path,'w'); fflush($f); fclose($f); }
  1042. $c = file_get_contents($path);
  1043. if(preg_match_all('/GALLERY\s+(\S+)(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  1044. $g=[]; $g['name']=$m[1];//$g['count']=0;
  1045. if(preg_match('/FEATURED([^;]*?);/u', $m[2], $arg)){ $g['featured']=true; }
  1046. if(preg_match('/EXPERIMENTAL([^;]*?);/u', $m[2], $arg)){ $g['experimental']=true; }
  1047. if(preg_match('/DESCRIPTION\s+([^;]+);/u', $m[2], $arg)){ $g['description']=$arg[1]; }
  1048. $this->Galleries[] = $g;
  1049. }
  1050. if(preg_match_all('/^-\s*([^;]+)\s*?;\s*?(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  1051. $name = trim($m[1]);
  1052. $item = []; $item['file'] = 'images/'.$name; $item['name'] = $name;
  1053. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  1054. if(preg_match('/REFS\s+([^;]*);/u',$m[2],$refs) && preg_match_all('/[0-9]{14}/u',$refs[1],$rs, PREG_SET_ORDER)){
  1055. $item['refs']=[];
  1056. foreach($rs as $r){ if(!in_array($r[0], $item['refs'])) $item['refs'][] = $r[0]; }
  1057. }
  1058. if(preg_match('/GAL\s+([^;]*);/u',$m[2],$gals) && preg_match_all('/(\S+)/u',$gals[1],$ga, PREG_SET_ORDER)){
  1059. $item['galleries']=[];
  1060. foreach($ga as $g){ if(!in_array($g[0], $item['galleries'])) $item['galleries'][] = $g[0]; }
  1061. }
  1062. if(preg_match('/PRODUCT\s+([^;]*);/u',$m[2],$product)){ $item['product']=$product[1]; }
  1063. if(preg_match('/PARENT\s+([^;]*);/u',$m[2],$parent)){ $item['parent']=$parent[1]; }
  1064. if(preg_match('/TITLE\s+([^;]*);/u',$m[2],$title)){ $item['title']=$title[1]; }
  1065. if(preg_match('/ALIGN\s+([^;]*);/u',$m[2],$align)){ $item['align']=$align[1]; }
  1066. if(preg_match('/HERE\s+([^;]*);/u',$m[2],$heres) && preg_match_all('/(\S+)-(\S+)-(\S+)/u',$heres[1],$here, PREG_SET_ORDER)){
  1067. $item['here']=[];
  1068. foreach($here as $h){ if(!$this->ImageHasHere($item, $h[1])) $item['here'][] = [$h[1],$h[2],$h[3]]; }
  1069. }
  1070. if(preg_match('/\.mp4/u',$item['name'])){
  1071. $item['video']='video/mp4';
  1072. }
  1073. $this->Images[] = $item;
  1074. }
  1075. $files = array_merge([],glob('images/*.jpg'));
  1076. $files = array_merge($files,glob('images/*.jpeg'));
  1077. $files = array_merge($files,glob('images/*.png'));
  1078. $files = array_merge($files,glob('images/*.gif'));
  1079. $files = array_merge($files,glob('images/*.mp4'));
  1080. if(isset($files[0]))foreach($files as $file) {
  1081. if(preg_match('/[0-9]{14,}\.(jpg|jpeg|gif|png|mp4)/u', $file, $m)) {
  1082. $name = trim($m[0]);
  1083. if(!$this->FindImage($name)){
  1084. $item = []; $item['name']=$name; $item['file'] = 'images/'.$name;
  1085. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  1086. $this->Images[] = $item;
  1087. }
  1088. }
  1089. }
  1090. if($clear_non_exist){
  1091. if(isset($this->Images[0]) && isset($files[0])){
  1092. foreach($this->Images as &$im){
  1093. if(!in_array($im['file'],$files)){
  1094. $im['deleted'] = 1;
  1095. }
  1096. }
  1097. }
  1098. }
  1099. function cmpf($a, $b){
  1100. if ($a['name'] == $b['name']) return 0;
  1101. return (($a['name'] > $b['name']) ? 1 : -1);
  1102. }
  1103. function cmpaf($a, $b){
  1104. if ($a['name'] == $b['name']) return 0;
  1105. return ($a['name'] > $b['name']) ? -1 : 1;
  1106. }
  1107. if(isset($this->Galleries[0]))usort($this->Galleries,"cmpf");
  1108. if(isset($this->Images[0]))usort($this->Images,"cmpaf");
  1109. $this->DoneReadImages = 1;
  1110. }
  1111. function WriteImages(){
  1112. if(isset($this->WayBack)) return;
  1113. $path = 'images/list.md';
  1114. $f = fopen($path,'w');
  1115. if(isset($this->Galleries[0]))foreach($this->Galleries as &$g){
  1116. if(isset($g['deleted'])) continue;
  1117. fwrite($f,'GALLERY '.$g['name']);
  1118. if(isset($g['featured']) && $g['featured']!=false) { fwrite($f,' FEATURED;'); }
  1119. if(isset($g['experimental']) && $g['experimental']!=false) { fwrite($f,' EXPERIMENTAL;'); }
  1120. if(isset($g['description']) && $g['description']!="") { fwrite($f,' DESCRIPTION '.$g['description'].';'); }
  1121. fwrite($f, PHP_EOL);
  1122. }
  1123. if(isset($this->Images[0]))foreach($this->Images as &$im){
  1124. if(isset($im['deleted'])) continue;
  1125. fwrite($f, "- ".$im['name'].'; ');
  1126. if(isset($im['refs']) && isset($im['refs'][0])){ fwrite($f, 'REFS '.implode(" ",$im['refs'])."; "); }
  1127. if(isset($im['galleries']) && isset($im['galleries'][0])){ fwrite($f, 'GAL '.implode(" ",$im['galleries'])."; "); }
  1128. if(isset($im['product']) && $im['product']!=''){ fwrite($f, 'PRODUCT '.$im['product']."; "); }
  1129. if(isset($im['parent']) && $im['parent']!=''){ fwrite($f, 'PARENT '.$im['parent']."; "); }
  1130. if(isset($im['title']) && $im['title']!=''){ fwrite($f, 'TITLE '.$im['title']."; "); }
  1131. if(isset($im['align']) && $im['align']!='' && $im['align']!='middle'){ fwrite($f, 'ALIGN '.$im['align']."; "); }
  1132. if(isset($im['here']) && $im['here']!=''){ fwrite($f, 'HERE ');
  1133. foreach($im['here'] as $here){ fwrite($f, implode('-',$here).' '); } fwrite($f, '; ');
  1134. }
  1135. fwrite($f, PHP_EOL);
  1136. }
  1137. fflush($f);
  1138. fclose($f);
  1139. }
  1140. function EditImage($name, $link_gallery, $do_remove = false, $product_link=NULL, $rename=NULL, $parent=NULL, $align=NULL){
  1141. if(!($im = &$this->FindImage($name))) return;
  1142. if(isset($link_gallery)){
  1143. if($do_remove){
  1144. if(!isset($im['galleries']) || !isset($im['galleries'][0])) return;
  1145. foreach($im['galleries'] as $key => $g){ if ($g==$link_gallery) unset($im['galleries'][$key]); }
  1146. $im['galleries'] = array_merge($im['galleries']);
  1147. }else{
  1148. if(!isset($im['galleries'])) $im['galleries']=[];
  1149. foreach($im['galleries'] as &$g){ if ($g==$link_gallery) return; }
  1150. $im['galleries'][]=$link_gallery;
  1151. }
  1152. }
  1153. if(isset($product_link)){
  1154. if($product_link!=''){$im['product']=$product_link;}
  1155. else{unset($im['product']);}
  1156. }
  1157. if(isset($rename) && $rename!=$im['name']){
  1158. $ext=pathinfo($im['file'],PATHINFO_EXTENSION);
  1159. rename($im['file'], 'images/'.$rename.'.'.$ext);
  1160. if(isset($im['thumb'])) rename($im['thumb'], 'images/thumb/'.$rename.'.'.$ext);
  1161. $im['name'] = $rename.'.'.$ext;
  1162. }
  1163. if(isset($parent) && $parent!=$im['parent']){
  1164. if($parent==''){ unset($im['parent']); }
  1165. else{ $im['parent'] = $parent; }
  1166. }
  1167. if(isset($align) && in_array($align,['top','middle','bottom'])){
  1168. if($align=='middle'){ unset($im['align']); }
  1169. else{ $im['align']=$align; }
  1170. }
  1171. $this->NeedWriteImages = 1;
  1172. }
  1173. function RegenerateThumbnails(){
  1174. $glob = glob('images/*.jpg');
  1175. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1176. foreach($glob as $file) {
  1177. $thumb_destination = 'images/thumb/'.basename($file);
  1178. $img = new Imagick($file); $geo=$img->getImageGeometry();
  1179. $width=$geo['width']; $height=$geo['height'];
  1180. $lim=400;
  1181. $scale = $lim / min($width,$height);
  1182. if($scale<1){
  1183. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1184. }
  1185. $img->setImageFormat('jpeg');
  1186. $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1187. $img->setImageCompressionQuality(90);
  1188. $img->writeImage($thumb_destination);
  1189. }
  1190. }
  1191. function CleanupImageCompression($run=false){
  1192. $glob = glob('images/*.jpg');
  1193. if(!$run){
  1194. echo $this->T("将重新压缩下列文件:")."<style>img{max-width:10em;max-height:10em;}</style><ul>";
  1195. }
  1196. foreach($glob as $file) {
  1197. $destination = 'images/'.basename($file);
  1198. $img = new Imagick($file); $geo=$img->getImageGeometry();
  1199. $width=$geo['width']; $height=$geo['height'];
  1200. $interlace=$img->getImageInterlaceScheme();
  1201. $progressive=($interlace==imagick::INTERLACE_NO || $interlace==imagick::INTERLACE_LINE || $interlace==imagick::INTERLACE_UNDEFINED);
  1202. $sizelim=1920;$abs_max=2560;
  1203. $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
  1204. $sz=filesize($destination);
  1205. if($scale<0.98 && $sz>2097152 && $progressive){ /* need scale, greater than 2mb, and not interlaced */
  1206. if(!$run){
  1207. echo "<li><a href='index.php?pic=$destination'><img src='images/thumb/".basename($file)."'><br />$destination, $width x $height, $interlace</a></li>";
  1208. }else{
  1209. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1210. $img->setImageFormat('jpeg');
  1211. $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1212. $img->setImageCompressionQuality(90);
  1213. $img->writeImage($destination);
  1214. }
  1215. }
  1216. $img->clear();
  1217. }
  1218. if(!$run){
  1219. echo "</ul><a href='index.php?cleanup_image_compression=true&run=true'>".$this->T("立即执行")."</a>"; exit;
  1220. }
  1221. }
  1222. function CompressImage($source, $destination, $thumb_destination, $quality, $sizelim, $abs_max, $ext) {
  1223. $img = new Imagick($source); $geo=$img->getImageGeometry(); $img2 = clone $img;
  1224. $width=$geo['width']; $height=$geo['height'];
  1225. $lim=400;
  1226. $scale = $lim / min($width,$height);
  1227. if($scale<1){
  1228. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1229. }
  1230. $img->setImageFormat('jpeg');
  1231. $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1232. $img->setImageCompressionQuality($quality);
  1233. $img->writeImage($thumb_destination);
  1234. $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
  1235. if($scale<0.98 || ($ext!='jpg'&&$ext!='jpeg')){
  1236. $img2->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.5);
  1237. $img2->setImageFormat('jpeg');
  1238. $img2->setImageCompressionQuality($quality);
  1239. $img2->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1240. $img2->writeImage($destination);
  1241. }else{
  1242. rename($source,$destination);
  1243. }
  1244. }
  1245. function DoUpload(){
  1246. if(!isset($_FILES['upload_file_name'])) return 0;
  1247. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1248. if($_FILES['upload_file_name']['error']>0){
  1249. echo"file upload err code ".$_FILES['upload_file_name']['error']; exit;
  1250. return -1;
  1251. }else{
  1252. $ext=strtolower(pathinfo($_FILES['upload_file_name']['name'],PATHINFO_EXTENSION));
  1253. if(!in_array($ext,['jpg','jpeg','png','gif','mp4'])) return 0;
  1254. $fp = fopen('.la_lock',"w");
  1255. while (!flock($fp, LOCK_EX| LOCK_NB)){
  1256. usleep(10000);
  1257. }
  1258. $num=date('YmdHis'); $replace=0;
  1259. if(isset($_POST['image_replace_button']) && isset($_GET['pic']) && preg_match('/([0-9]{14,})/u',$_GET['pic'],$mim)){
  1260. $num = $mim[1]; $replace=1;
  1261. }
  1262. $base = 'images/'.$num;
  1263. $thumb = 'images/thumb/'.$num;
  1264. $use_ext=($ext=='gif' || $ext=='mp4')?('.'.$ext):('.jpg');
  1265. $final_path = $base.$use_ext; $final_thumb = $thumb.$use_ext; $i=0;
  1266. if(!$replace) while(file_exists($final_path)){
  1267. $final_path = $base.strval($i).$use_ext; $final_thumb = $thumb.strval($i).$use_ext; $i++;
  1268. }
  1269. if($ext!='gif' && $ext!='mp4'){
  1270. $compress = (isset($_GET['compress'])&&$_GET['compress']);
  1271. $this->CompressImage($_FILES['upload_file_name']['tmp_name'], $final_path, $final_thumb, 90,
  1272. $compress?800:1920, $compress?1920:2560, $ext);
  1273. }else{
  1274. move_uploaded_file($_FILES['upload_file_name']['tmp_name'], $final_path);
  1275. }
  1276. flock($fp, LOCK_UN);
  1277. fclose($fp);
  1278. $this->ReadImages(true);
  1279. $this->WriteImages();
  1280. echo '<uploaded>'.pathinfo($final_path,PATHINFO_BASENAME)."</uploaded>";
  1281. if(isset($_POST['image_replace_button'])){
  1282. header('Location: '.$_SERVER['REQUEST_URI']);exit;
  1283. }
  1284. exit;
  1285. return 1;
  1286. }
  1287. return 0;
  1288. }
  1289. function &GetGallery($name){
  1290. if(isset($this->Galleries[0])) foreach($this->Galleries as &$g){
  1291. if($g['name'] == $name) return $g;
  1292. }
  1293. return $this->NULL_GALLERY;
  1294. }
  1295. function EditGallery($name, $new_name=null, $delete=false, $do_rw=true, $set_featured=null, $set_experimental=null,$desc=null){
  1296. $this->ReadImages();
  1297. $gallery = &$this->GetGallery($name);
  1298. if(!isset($gallery)){
  1299. if(!isset($new_name) || preg_match('/main|trash|\s/u',$new_name))return;
  1300. $g = []; $g['name']=$new_name;
  1301. $this->Galleries[]=$g;
  1302. }else{
  1303. if(isset($new_name)) {
  1304. if(preg_match('/main|trash|\s/u',$new_name))return;
  1305. $gallery['name'] = $new_name;
  1306. foreach ($this->Images as &$im){
  1307. if(isset($im['galleries'])&&isset($im['galleries'][0]))foreach($im['galleries'] as &$g){
  1308. if($g == $name){ $g = $new_name; }
  1309. }
  1310. }
  1311. }
  1312. //if(isset($count)) $gallery['count'] = $count;
  1313. if(isset($delete) && $delete) $gallery['deleted'] = true;
  1314. if(isset($set_featured)) $gallery['featured'] = $set_featured;
  1315. if(isset($set_experimental)) $gallery['experimental'] = $set_experimental;
  1316. if(isset($desc)) $gallery['description'] = $desc;
  1317. }
  1318. if($do_rw) { $this->NeedWriteImages = 1; }
  1319. }
  1320. function ClearData(){
  1321. $this->Posts = [];
  1322. $this->Threads = [];
  1323. $this->Images = [];
  1324. $this->Archive = [];
  1325. $this->ArchiveHandles = [];
  1326. }
  1327. function InsertArchivePost(&$post){
  1328. $a = NULL;
  1329. if(($a = &$this->GetArchiveHandle($post['id']))==$this->NULL_POST){
  1330. $ah = []; $ah['id'] = $post['id']; $ah['list'] = [];
  1331. $this->ArchiveHandles[] = &$ah; $a = &$ah;
  1332. }
  1333. $a['list'][] = $post;
  1334. $this->Archive[] = $post;
  1335. }
  1336. function ReadArchiveFromFile($path){
  1337. if(!file_exists($path)){
  1338. return;
  1339. }
  1340. $c = file_get_contents($path);
  1341. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1342. foreach($matches as $m){
  1343. $post = [];
  1344. $post['id'] = $m[1];
  1345. $post['content'] = trim($m[3]);
  1346. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1347. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1348. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1349. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1350. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1351. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1352. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1353. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1354. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1355. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1356. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1357. if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
  1358. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1359. foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
  1360. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1361. $post['merged_into'] = [trim($n[1]),trim($n[2])];
  1362. }
  1363. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1364. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1365. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1366. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1367. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1368. }
  1369. $this->InsertArchivePost($post);
  1370. }
  1371. }
  1372. }
  1373. function SortArchive(){
  1374. $cmpac = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1375. $cmpap = function($a, $b){ if ($a['id'] == $b['id']) return ((($a['version'] > $b['version']) ? 1 : -1));
  1376. return (($a['id'] > $b['id']) ? 1 : -1);
  1377. };
  1378. if(isset($this->Archive[0])){
  1379. usort($this->Archive,$cmpap);
  1380. $year_begin = substr($this->Archive[0]['id'],0,4);
  1381. $this->YearBegin = ($year_begin<$this->YearBegin)?$year_begin:$this->YearBegin;
  1382. }
  1383. if(isset($this->ArchiveHandles[0])){
  1384. usort($this->ArchiveHandles,$cmpac);
  1385. foreach($this->ArchiveHandles as &$a){
  1386. if(isset($a['list'])){ usort($a['list'],$cmpap);
  1387. $last_valid=NULL;
  1388. foreach($a['list'] as &$ver){ $ver['archive']= &$a;
  1389. if(isset($ver['merged_thread'])){ $ver['content']=$last_valid; }
  1390. else{ $last_valid = $ver['content']; } }
  1391. if(isset($a['list'][0]['version'])&&$a['list'][0]['version']>$a['list'][0]['id']){ /* if early versions missing. */
  1392. $origin=$a['list'][0]; $origin['version']=$origin['id']; array_unshift($a['list'], $origin);
  1393. }
  1394. }
  1395. if(($p = &$this->GetPost($a['id'],true))!=NULL){
  1396. $p['archive'] = &$a;
  1397. }
  1398. }
  1399. }
  1400. }
  1401. function ReadPostsFromFile($path){
  1402. if(!file_exists($path)){
  1403. $f = fopen($path,'w');
  1404. fclose($f);
  1405. }
  1406. $c = file_get_contents($path);
  1407. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1408. foreach($matches as $m){
  1409. $post = [];
  1410. $post['id'] = $m[1];
  1411. $post['real_content'] = trim($m[3]);
  1412. $post['content'] = &$post['real_content'];
  1413. if(preg_match('/COMMENT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['comment_to'] = $n[1];
  1414. if(preg_match('/EMAIL\s+([^;]+)\s*;/u', $m[2], $n)) $post['email'] = $n[1];
  1415. if(preg_match('/NAME\s+([^;]+)\s*;/u', $m[2], $n)) $post['name'] = $n[1];
  1416. if(preg_match('/LINK\s+([^;]+)\s*;/u', $m[2], $n)) $post['link'] = $n[1];
  1417. if(preg_match('/IP\s+([^;]+)\s*;/u', $m[2], $n)) $post['ip'] = $n[1];
  1418. if(preg_match('/NEXT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['next'] = $n[1];
  1419. if(preg_match('/PREV\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['prev'] = $n[1];
  1420. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1421. if(preg_match('/MDEL\s*;/u', $m[2])) $post['mark_delete'] = True;
  1422. if(preg_match('/MVAL\s*([^;]+);/u', $m[2], $n)) $post['mark_value'] = trim($n[1]);
  1423. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1424. if(preg_match('/REFS\s*([^;]+);/u', $m[2], $ma)){
  1425. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1426. foreach($links as $l){ $entries[] = $l[1]; } $post['refs'] = $entries; } }
  1427. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1428. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1429. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1430. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1431. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1432. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1433. if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
  1434. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1435. foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
  1436. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1437. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1438. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1439. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1440. $post['merged_into'] = [trim($n[1]),trim($n[2])]; }
  1441. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1442. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1443. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1444. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1445. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1446. }
  1447. if(preg_match('/NUM\s+([0-9]{1,})\s*;/u', $m[2], $n)){ $post['number']=$n[1]; $this->PNUMBER=max($post['number'],$this->PNUMBER); }
  1448. else{ $this->PNUMBER++; $post['number']=$this->PNUMBER; }
  1449. //$this->PNUMBER++; $post['number']=$this->PNUMBER;
  1450. if(isset($post['mark_value']) && $post['mark_value']==5){
  1451. $post['product']=[];
  1452. }
  1453. /* marks add here */
  1454. $this->Posts[] = $post;
  1455. if(isset($post['comment_to']) && ($target_post = &$this->GetPost($post['comment_to'],true))){
  1456. if(!isset($target_post['comments']) || !isset($target_post['comments'][0])) $target_post['comments']=[];
  1457. $target_post['comments'][]=&$this->Posts[count($this->Posts) - 1];
  1458. }
  1459. }
  1460. }
  1461. }
  1462. function SortPosts($wayback=false){
  1463. $cmpp = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1464. $sortlist = &$this->Posts;
  1465. if($wayback) $sortlist = &$this->WaybackPosts;
  1466. if(isset($sortlist[0])){
  1467. usort($sortlist,$cmpp);
  1468. $this->YearEnd = substr($this->TIME_STRING,0,4);
  1469. $this->YearBegin = substr($sortlist[0]['id'],0,4);
  1470. }
  1471. }
  1472. function ReadPosts(){
  1473. if ((!file_exists('la_config.md') || is_readable('la_config.md') == false) ||
  1474. (!file_exists('la_config.php') || is_readable('la_config.php') == false) ||
  1475. (!is_dir('posts') || is_readable('posts') == false) ||
  1476. (!is_dir('archive') || is_readable('archive') == false) ||
  1477. (!is_dir('images') || is_readable('images') == false) ||
  1478. (!is_dir('styles') || is_readable('styles') == false)){
  1479. $this->Install();
  1480. }
  1481. if($this->DoneReadPosts){ return; }
  1482. $file_list = [];
  1483. $glob = glob('posts/*');
  1484. foreach($glob as $file) {
  1485. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1486. $file_list[] = $file;
  1487. }
  1488. }
  1489. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1490. foreach($file_list as $f) {
  1491. $this->ReadPostsFromFile($f);
  1492. }
  1493. $this->SortPosts();
  1494. $this->DetectThreads();
  1495. $this->DoneReadPosts=1;
  1496. }
  1497. function UpdatePostRefsForWayback(){
  1498. if(!isset($this->WayBack)) return;
  1499. if(isset($this->Images[0])) foreach($this->Images as &$i){ unset($i['refs']); }
  1500. if(!isset($this->WaybackPosts[0])) return;
  1501. foreach($this->WaybackPosts as &$p){ unset($p['refs']); }
  1502. foreach($this->WaybackPosts as &$p){
  1503. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $r){
  1504. $pr = &$this->GetPost($r); if(isset($pr)){
  1505. if(!isset($pr['refs'])) $pr['refs']=[];
  1506. if(!in_array($p['id'],$pr['refs'])){ $pr['refs'][] = $p['id']; }
  1507. }
  1508. }
  1509. if(isset($p['hasi']) && isset($p['hasi'][0])) foreach($p['hasi'] as $r){
  1510. $ir = &$this->FindImage($r); if(isset($ir)){
  1511. if(!isset($ir['refs'])) $ir['refs']=[];
  1512. if(!in_array($p['id'],$ir['refs'])){ $ir['refs'][] = $p['id'];}
  1513. }
  1514. }
  1515. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1516. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1517. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$p['id']; }
  1518. }
  1519. }
  1520. }
  1521. function ReadArchive(){
  1522. if (!is_dir('archive') || is_readable('archive') == false){ $this->Install(); }
  1523. if ($this->DoneReadArchive) return;
  1524. $file_list = []; $glob = glob('archive/*');
  1525. foreach($glob as $file) {
  1526. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1527. $file_list[] = $file;
  1528. }
  1529. }
  1530. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1531. foreach($file_list as $f) {
  1532. $this->ReadArchiveFromFile($f);
  1533. }
  1534. $this->SortArchive();
  1535. $this->DoneReadArchive=1;
  1536. $this->UpdateThreadForWayback();
  1537. $this->UpdatePostRefsForWayback();
  1538. }
  1539. function GetThreadForPost(&$post){
  1540. if(isset($post['tid'])) return;
  1541. $th = []; $iterp = NULL;
  1542. $post['tid'] = &$th; $th['first'] = &$post; $th['last'] = &$post;
  1543. if(!(isset($post['prev']) || isset($post['next']))) { $this->Threads[] = &$th; return; }
  1544. if(isset($post['prev']))for($p = $post['prev']; $p!=NULL; $p = $iterp){
  1545. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1546. $np['tid'] = &$th;
  1547. $th['first'] = &$np;
  1548. $iterp = isset($np['prev'])?$np['prev']:NULL;
  1549. }
  1550. if(isset($post['next']))for($p = $post['next']; $p!=NULL; $p = $iterp){
  1551. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1552. $np['tid'] = &$th;
  1553. $th['last'] = &$np;
  1554. $iterp = isset($np['next'])?$np['next']:NULL;
  1555. }
  1556. if(isset($th['first']['mark_value'])){
  1557. if($th['first']['mark_value']==6) $th['exp'] = true;
  1558. else if($th['first']['mark_value']>=7) $th['slf'] = true;
  1559. if($th['first']['mark_value']==8) $th['sln'] = true;
  1560. }
  1561. if($th['first'] == $th['last']){ unset($post['tid']); return; }
  1562. $this->Threads[] = &$th;
  1563. }
  1564. function IdentifyThreadCategory(&$th,&$first_post){
  1565. unset($th['categories']);unset($th['interesting']);unset($th['reversed']);
  1566. if(preg_match('/^\s*\@(.*?)$/mu',$first_post['content'],$m)){
  1567. $first_post['categories']=[]; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1568. foreach($matches as $ma){ $first_post['categories'][] = $ma[1]; }
  1569. }
  1570. if(isset($th) && $th){ $th['categories'] = &$first_post['categories']; }
  1571. }
  1572. if(preg_match('/\{\s*WIDE\s*\}/imu',$first_post['content'],$m)){ $first_post['wide'] = true; }
  1573. if(preg_match('/\{\s*NO_TIME\s*\}/imu',$first_post['content'],$m)){ $first_post['no_time'] = true; }
  1574. if(preg_match('/\{\s*NO_TITLE\s*\}/imu',$first_post['content'],$m)){ $first_post['no_title'] = true; }
  1575. if(preg_match('/\{\s*SLIDES\s*\}/imu',$first_post['content'],$m)){ $first_post['slides'] = true; }
  1576. if(preg_match('/\{\s*HEADER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['header'] = trim($m[1]); }
  1577. if(preg_match('/\{\s*FOOTER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['footer'] = trim($m[1]); }
  1578. if(!isset($th)) return;
  1579. if(isset($first_post['wide'])) $th['wide']=$first_post['wide'];
  1580. if(isset($first_post['header'])) $th['header']=$first_post['header'];
  1581. if(isset($first_post['footer'])) $th['footer']=$first_post['footer'];
  1582. if(isset($first_post['no_time'])) $th['no_time']=$first_post['no_time'];
  1583. if(isset($first_post['slides'])) $th['slides']=$first_post['slides'];
  1584. if(isset($first_post['no_title'])) $th['no_title']=$first_post['no_title'];
  1585. if(preg_match('/\{\s*INTERESTING\s+(.*?)\}/imu',$first_post['content'],$m)){
  1586. $th['interesting'] = []; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1587. foreach($matches as $ma){ $th['interesting'][] = $ma[1]; }
  1588. }
  1589. }
  1590. if(preg_match('/\{\s*REVERSED(\s+.*?)?\}/imu',$first_post['content'],$m)){ $th['reversed'] = 'm';
  1591. if(isset($m[1])&&preg_match('/^\s*(y|m|d|p)/iu',$m[1],$ma)){ $th['reversed']=$ma[1]; }
  1592. }
  1593. }
  1594. function IsInterestingPost(&$p){
  1595. if(isset($p['tid']) && isset($p['tid']['interesting']) && isset($p['tid']['interesting'][0])) return true;
  1596. return false;
  1597. }
  1598. function IsReversedThread(&$th){
  1599. if(isset($th['reversed']) && $th['reversed']!=false) return true;
  1600. return false;
  1601. }
  1602. function GiveAllMergedPosts(&$po,&$arr){
  1603. if(isset($po['merged_from'])&&isset($po['merged_from'][0])) foreach($po['merged_from'] as $pm){
  1604. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr);}
  1605. }
  1606. if(isset($po['archive']) && isset($po['archive']['list'])){
  1607. foreach($po['archive']['list'] as &$ver){
  1608. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $pm){
  1609. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr); } }
  1610. }
  1611. }
  1612. }
  1613. function ThreadMakeWayback(&$th){
  1614. if(!isset($th['arr'][0])) return;
  1615. if(isset($this->WayBack)){
  1616. $remlist = [];
  1617. foreach($th['arr'] as &$pi){
  1618. $po = &$this->GetPost($pi['id'],true); if(!isset($po)){continue;/*merged*/}
  1619. if(isset($po['merged_thread']) && isset($po['version']) && $po['version']>$this->WayBack){
  1620. $remlist = array_unique(array_merge($remlist,$po['merged_thread'][0]));
  1621. }
  1622. $ah = &$this->GetArchiveHandle($po['id']);
  1623. if(isset($ah)) foreach(array_reverse($ah['list']) as &$ver){
  1624. if(!isset($ver['merged_thread'])) continue;
  1625. if((isset($ver['version']) && $ver['version'] > $this->WayBack) ||
  1626. (!isset($ver['version']) && $ver['id'] > $this->WayBack)){
  1627. $remlist = array_unique(array_merge($remlist,$ver['merged_thread'][0]));
  1628. }
  1629. }
  1630. }
  1631. if(isset($remlist[0]) && isset($th['arr'][0])){
  1632. foreach($remlist as $rem){ $this->GiveAllMergedPosts($this->GetPost($rem,true),$remlist); }
  1633. foreach($th['arr'] as $key => $pr){
  1634. foreach($remlist as $rem){ if($pr['id'] == $rem) { unset($th['arr'][$key]); break; } } }
  1635. $new_th = []; $new_arr = [];
  1636. foreach($remlist as $rem){ $np=&$this->GetPost($rem); if(isset($np)){$new_arr[]=&$np;} }
  1637. $new_th['arr'] = &$new_arr;
  1638. $this->WaybackThreads[] = &$new_th;
  1639. $this->ThreadMakeWayback($new_th);
  1640. }
  1641. }
  1642. }
  1643. function AddMergedPosts(&$p, &$array){
  1644. if(isset($p['archive']) && isset($p['archive']['list'])){
  1645. foreach($p['archive']['list'] as &$ver){
  1646. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $po){
  1647. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1648. }
  1649. }
  1650. if(isset($p['merged_from'])&&isset($p['merged_from'][0])) foreach($p['merged_from'] as $po){
  1651. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1652. }
  1653. function &array_shift_ref(&$array){if(count($array)>0){$key=key($array);$first=&$array[$key];}else{$first=null;}array_shift($array);return $first;}
  1654. function FinalizeThread(&$th, $relink_posts=false, $now=0){
  1655. $nextp=NULL; $arr=[]; $lasttime=NULL;
  1656. if(!isset($th['arr'])){
  1657. for($p = &$th['first']; $p!=$this->NULL_POST; $p = &$this->GetPost(isset($p['next'])?$p['next']:NULL,true)){
  1658. $arr[]=&$p;
  1659. } $th['arr'] = &$arr;
  1660. if(isset($this->WayBack) && $this->DoneReadArchive){ $new_arr=[];
  1661. foreach($arr as &$p){ $pa = &$this->GetPost($p['id']); if(isset($pa)) {$new_arr[]=&$pa;$this->WaybackPosts[]=&$pa;} }
  1662. foreach($arr as &$p){ $this->AddMergedPosts($p,$new_arr); }
  1663. $arr=&$new_arr; $th['arr']=&$new_arr;
  1664. $this->ThreadMakeWayback($th); }
  1665. }
  1666. $cmppt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1667. if(isset($th['arr'][0])){ usort($th['arr'],$cmppt); } $th['count'] = sizeof($th['arr']);
  1668. if($relink_posts){ $count = $th['count'];
  1669. $arr = &$th['arr'];
  1670. for($i=0; $i<$count; $i++){ if($i>0) $arr[$i]['prev'] = $arr[$i-1]['id']; if($i<$count-1) $arr[$i]['next'] = $arr[$i+1]['id'];
  1671. $arr[$i]['tid']=&$th;}
  1672. $th['first'] = &$arr[0]; $th['last'] = &$arr[$count-1]; unset($arr[0]['prev']); unset($arr[$count-1]['next']);
  1673. }
  1674. $th['score'] = 0; if(!isset($th['first'])){ return; }
  1675. $this->IdentifyThreadCategory($th, $th['first']);
  1676. if(isset($this->WayBack)) $lasttime=$this->WayBack;
  1677. if(!isset($last_time)) $lasttime = DateTime::createFromFormat('YmdHis', $th['last']['id']);
  1678. $diff_days = ($now - date_timestamp_get($lasttime))/3600/24;
  1679. $th['score'] = (float)$th['count']*0.2 - min($diff_days,200);
  1680. if(isset($th['reversed'])){ $chunks=[]; $last_id=$last_y=$last_m=$last_d=0; $mo=$th['reversed']; $final=[];
  1681. $first_post=&$this->array_shift_ref($th['arr']); $ch=[];
  1682. while($n=&$this->array_shift_ref($th['arr'])){
  1683. $this_id=$n['id']; $this_y=substr($this_id,0,4); $this_m=substr($this_id,4,2); $this_d=substr($this_id,6,2);
  1684. if($mo=='y'&&$this_y!=$last_y){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y; }
  1685. if($mo=='m'&&$this_m!=$last_m){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y.'/'.$this_m; }
  1686. if($mo=='d'&&$this_d!=$last_d){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y.'/'.$this_m.'/'.$this_d; }
  1687. if($mo=='p'){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} }
  1688. $ch[]=&$n; $last_id=$this_id; $last_y=$this_y; $last_m=$this_m; $last_d=$this_d;
  1689. }if(isset($ch[0])){$chunks[]=$ch;} if(isset($chunks[0])){$use_chunks=array_reverse($chunks);}
  1690. $final[]=&$first_post;
  1691. foreach($use_chunks as &$ch){ foreach($ch as &$p){ $final[]=&$p;} }
  1692. $th['arr']=$final; }
  1693. }
  1694. function SortThreads(){
  1695. if (!function_exists('cmpt')) {
  1696. function cmpt($a, $b){
  1697. if ($a['score'] == $b['score']) return 0;
  1698. return ($a['score'] > $b['score']) ? -1 : 1;
  1699. }
  1700. }
  1701. usort($this->Threads,"cmpt");
  1702. }
  1703. function DetectThreads(){
  1704. foreach($this->Posts as &$p){
  1705. if(isset($p['tid'])) { continue; }
  1706. $this->GetThreadForPost($p);
  1707. if(!isset($p['tid'])) { $this->IdentifyThreadCategory($this->NULL_POST, $p); }
  1708. }
  1709. if(!isset($this->Threads) || !isset($this->Threads[0])) return;
  1710. $now = date_timestamp_get(date_create());
  1711. foreach($this->Threads as &$t){
  1712. $this->FinalizeThread($t,false,$now);
  1713. }
  1714. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1715. $this->FinalizeThread($th,false,$now);
  1716. $this->Threads[] = &$th;
  1717. }
  1718. $this->SortThreads();
  1719. }
  1720. function UpdateThreadForWayback(){$now = date_timestamp_get(date_create());
  1721. if(!isset($this->WayBack) || !$this->DoneReadArchive){ return; }
  1722. foreach($this->Threads as &$t){
  1723. unset($t['arr']); $this->FinalizeThread($t,true,$now);
  1724. }
  1725. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1726. $this->FinalizeThread($th,true,$now);
  1727. $this->Threads[] = &$th;
  1728. }
  1729. $this->SortThreads();
  1730. $this->SortPosts(true);
  1731. $this->UsePosts = &$this->WaybackPosts;
  1732. }
  1733. function &GetMergedPost($id){
  1734. $this->ReadArchive();
  1735. $ah = &$this->GetArchiveHandle($id);
  1736. if(!isset($ah) || !isset($ah['list']) || !isset($ah['list'][0])){ return $this->NULL_POST; }
  1737. $ver = &$ah['list'][sizeof($ah['list'])-1];
  1738. if(!isset($ver['merged_into'])) return $this->GetPost($id);
  1739. [$tp, $tver] = $ver['merged_into'];
  1740. if(isset($this->WayBack)){
  1741. if($tver <= $this->WayBack) return $this->GetMergedPost($tp);
  1742. else return $this->GetPost($id); /* should not happen directly. */
  1743. }
  1744. return $this->GetMergedPost($tp);
  1745. }
  1746. function &GetPost($id, $latest_only=false, $find_merged=false){
  1747. if(!isset($id)) return $this->NULL_POST;
  1748. $found=&$this->NULL_POST;
  1749. if(isset($this->Posts[0])) foreach($this->Posts as &$p){
  1750. if($p&& $p['id'] == $id) { $found = &$p; break; }
  1751. if($find_merged && isset($p['hastag'][0]) && in_array($id, $p['hastag'])){ $found = &$p; break; }
  1752. }
  1753. if($latest_only || !isset($this->WayBack)){ return $found; }
  1754. else{
  1755. if(isset($found)){
  1756. if(!isset($found['archive'])&&!isset($found['archive']['list']))
  1757. { if($found['id'] > $this->WayBack) return $this->NULL_POST; else return $found; }
  1758. $last_ver = &$this->NULL_POST;
  1759. if(isset($found['archive']['list'][0])) foreach($found['archive']['list'] as &$ver){
  1760. if($ver['version'] > $this->WayBack) return $last_ver;
  1761. $last_ver = &$ver;
  1762. }
  1763. if(isset($found['version']) && $found['version'] <= $this->WayBack) return $found;
  1764. else return $last_ver;
  1765. }else{
  1766. $ah = &$this->GetArchiveHandle($id); $last_ver = &$this->NULL_POST;
  1767. if(isset($ah) && isset($ah['list']) && isset($ah['list'][0])) foreach($ah['list'] as &$ver){
  1768. if($ver['version'] > $this->WayBack) return $last_ver;
  1769. $last_ver = &$ver;
  1770. } if(!isset($last_ver['merged_into'])) return $last_ver; else{
  1771. [$tp, $tver] = $last_ver['merged_into'];
  1772. if($tver <= $this->WayBack) {
  1773. if($find_merged && $tp!=$id) return $this->GetPost($tp); return $this->NULL_POST; }
  1774. return $last_ver;
  1775. }
  1776. }
  1777. }
  1778. return $this->NULL_POST;
  1779. }
  1780. function &GetArchiveHandle($id){
  1781. if(!isset($id)) return $this->NULL_POST;
  1782. if(isset($this->ArchiveHandles[0])) foreach($this->ArchiveHandles as &$p){
  1783. if($p && $p['id'] == $id) { return $p; }
  1784. }
  1785. return $this->NULL_POST;
  1786. }
  1787. function &GetArchive($id){
  1788. if(!isset($id)) return $this->NULL_POST;
  1789. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1790. if($p && $p['id'] == $id) { return $p; }
  1791. }
  1792. return $this->NULL_POST;
  1793. }
  1794. function &GetArchiveVersion(&$ah, $version, &$next_ver, &$last_ver){
  1795. if(!isset($ah)) return $this->NULL_POST;
  1796. $found = NULL; $last_verp=NULL;
  1797. if(isset($ah['list'][0])) foreach($ah['list'] as &$p){
  1798. if(isset($found)){ $next_ver = $p; $last_ver = $last_verp; return $found; }
  1799. if($p && $p['version'] == $version) { $found = &$p; continue; }
  1800. $last_verp = &$p;
  1801. }
  1802. if(isset($found)) { $next_ver=NULL; $last_ver = $last_verp; return $found; }
  1803. return $this->NULL_POST;
  1804. }
  1805. function CacheArchiveOwnLinks(){
  1806. if(isset($this->WayBack)) return;
  1807. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1808. $this->ConvertPost($p); unset($p['hasp']); unset($p['hasi']); unset($p['hastag']);
  1809. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$p['html'],$matches,PREG_SET_ORDER)){
  1810. foreach($matches as $m){
  1811. if(!isset($p['hasp']))$p['hasp']=[]; if(!in_array($m[1],$p['hasp'])){ $p['hasp'][]=$m[1]; }
  1812. }
  1813. }
  1814. if(preg_match_all('/\/\/([0-9]{14})/u', $p['content'],$matches,PREG_SET_ORDER)){
  1815. foreach($matches as $m){
  1816. if(!isset($p['hastag']))$p['hastag']=[]; if(!in_array($m[1],$p['hastag'])){ $p['hastag'][]=$m[1]; }
  1817. }
  1818. }
  1819. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\)/u', $p['content'],$matches,PREG_SET_ORDER)){
  1820. foreach($matches as $m){
  1821. if(!isset($p['hasi']))$p['hasi']=[]; if(!in_array($m[2],$p['hasi'])){ $p['hasi'][]=$m[2]; }
  1822. }
  1823. }
  1824. }
  1825. }
  1826. function WriteArchive(){
  1827. if(isset($this->WayBack)) return;
  1828. $cf = NULL;$opened =NULL;
  1829. $this->SortArchive();
  1830. $this->CacheArchiveOwnLinks();
  1831. if(isset($this->Archive[0])) foreach($this->Archive as $p){
  1832. $nid = substr($p['id'], 0,6);
  1833. if($cf != $nid){
  1834. if($opened){
  1835. fflush($opened);
  1836. fclose($opened);
  1837. }
  1838. $cf = $nid;
  1839. $opened = fopen("archive/$cf.md", 'w');
  1840. }
  1841. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1842. "VER {$p['version']}; ".
  1843. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1844. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1]).";"):"").
  1845. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1846. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1847. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1848. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1849. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1850. ']';
  1851. if(isset($p['merged_thread'])){ $p['content']=""; }
  1852. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['content'].PHP_EOL.PHP_EOL);
  1853. }
  1854. }
  1855. function WritePosts(){
  1856. if(isset($this->WayBack)) return;
  1857. $cf = NULL;$opened =NULL;
  1858. $this->SortPosts();
  1859. if(isset($this->Posts[0])) foreach($this->Posts as $p){
  1860. $nid = substr($p['id'], 0,6);
  1861. if($cf != $nid){
  1862. if($opened){
  1863. fflush($opened);
  1864. fclose($opened);
  1865. }
  1866. $cf = $nid;
  1867. $opened = fopen("posts/$cf.md", 'w');
  1868. }
  1869. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1870. ((isset($p['number']) && $p['number'])?"NUM {$p['number']}; ":"").
  1871. ((isset($p['version']) && $p['version'])?"VER {$p['version']}; ":"").
  1872. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1873. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1874. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1875. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1])."; "):"").
  1876. ((isset($p['comment_to']) && $p['comment_to'])?"COMMENT {$p['comment_to']}; ":"").
  1877. ((isset($p['email']) && $p['email'])?"EMAIL {$p['email']}; ":"").
  1878. ((isset($p['name']) && $p['name'])?"NAME {$p['name']}; ":"").
  1879. ((isset($p['link']) && $p['link'])?"LINK {$p['link']}; ":"").
  1880. ((isset($p['ip']) && $p['ip'])?"IP {$p['ip']}; ":"").
  1881. ((isset($p['mark_delete']) && $p['mark_delete'])?"MDEL; ":"").
  1882. ((isset($p['mark_value']) && $p['mark_value']>=0)?"MVAL {$p['mark_value']}; ":"").
  1883. ((isset($p['next']) && $p['next'])?"NEXT {$p['next']}; ":"").
  1884. ((isset($p['prev']) && $p['prev'])?"PREV {$p['prev']}; ":"").
  1885. ((isset($p['refs']) && isset($p['refs'][0]))?("REFS ".implode(" ",$p['refs'])."; "):"").
  1886. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1887. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1888. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1889. ((isset($p['mastodon_url']) && isset($p['mastodon_url']))?("MSTDN ".$p['mastodon_url']."; "):"").
  1890. ']';
  1891. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['real_content'].PHP_EOL.PHP_EOL);
  1892. }
  1893. }
  1894. function CachePostLinks(){
  1895. if(isset($this->WayBack)) return;
  1896. if(isset($this->Posts) && isset($this->Posts[0]))foreach ($this->Posts as &$post){
  1897. $this->ConvertPost($post);
  1898. unset($post['refs']);unset($post['hasp']);unset($post['hasi']);unset($post['hastag']);
  1899. //discard lost old version
  1900. //if(!isset($post['archive']) && $this->DoneReadArchive && isset($post['version'])){ unset($post['version']); }
  1901. }else return;
  1902. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1903. unset($im['refs']); unset($im['here']); unset($im['title']);
  1904. }
  1905. foreach ($this->Posts as &$post){
  1906. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$post['html'],$matches,PREG_SET_ORDER)){
  1907. foreach($matches as $m){
  1908. $ref = &$this->GetPost($m[1],true);
  1909. if($ref!=NULL){
  1910. if(!isset($ref['refs']))$ref['refs']=[]; if(!in_array($post['id'],$ref['refs']))$ref['refs'][]=$post['id'];
  1911. }
  1912. if(!isset($post['hasp']))$post['hasp']=[]; if(!in_array($m[1],$post['hasp']))$post['hasp'][]=$m[1];
  1913. }
  1914. }
  1915. if(preg_match_all('/\/\/([0-9]{14})/u', $post['content'],$matches,PREG_SET_ORDER)){
  1916. foreach($matches as $m){
  1917. if(!isset($post['hastag']))$post['hastag']=[]; if(!in_array($m[1],$post['hastag']))$post['hastag'][]=$m[1];
  1918. }
  1919. }
  1920. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\)/u', $post['content'],$matches,PREG_SET_ORDER)){
  1921. foreach($matches as $m){
  1922. if(($im = &$this->FindImage($m[2]))!=NULL){
  1923. if(!isset($im['refs']))$im['refs']=[]; if(!in_array($post['id'], $im['refs']))$im['refs'][] = $post['id'];
  1924. }
  1925. if(!isset($post['hasi']))$post['hasi']=[]; if(!in_array($m[2],$post['hasi']))$post['hasi'][]=$m[2];
  1926. }
  1927. }
  1928. if(preg_match("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\))(\R*(\R(-|\*).+){1,})/u",
  1929. $post['content'],$matches)){
  1930. $use_img_name = $matches[2];
  1931. if(($im = &$this->FindImage($use_img_name))!=NULL){
  1932. if(preg_match_all("/(-|\*)\s+here\s*:\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s+images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))/u",
  1933. $matches[4],$mah,PREG_SET_ORDER)){
  1934. foreach($mah as $ma){
  1935. if(!isset($im['here']))$im['here']=[]; if(!$this->ImageHasHere($item, $ma[4])){
  1936. $here = [$ma[4], $ma[2], $ma[3]]; $im['here'][] = $here; }
  1937. }
  1938. }
  1939. }
  1940. }
  1941. }foreach($this->Posts as &$post){
  1942. if(isset($post['hasp']) && isset($post['hasp'][0])) foreach($post['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1943. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1944. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$post['id']; }
  1945. }
  1946. }
  1947. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1948. $min_id = '99999999999999';
  1949. if(isset($im['refs']) && isset($im['refs'][0])) foreach ($im['refs'] as &$ref){
  1950. $r = &$this->GetPost($ref,true); if(isset($r)) $title = $this->GetPostTitle($r,true,false);
  1951. if($title && $ref<$min_id) { $im['title'] = preg_replace('/;/u',' ',trim($title)); $min_id=$r['id']; }
  1952. }
  1953. }
  1954. }
  1955. function CreatePostAnchor(&$post){
  1956. $that=&$this;
  1957. $post['html'] = preg_replace_callback('/<h([0-9])>(.+?)(?=<\/h[0-9]>)/u', function ($ma) use ($that){
  1958. $id = '_heading_'.sizeof($this->Anchors);
  1959. $entry=[(int)$ma[1], $id, $ma[2]];
  1960. $that->Anchors[] = $entry;
  1961. return "<h{$ma[1]} id='{$id}'>{$ma[2]}";
  1962. }, $post['html']);
  1963. }
  1964. function RenamePost(&$post, $rename){
  1965. foreach($this->Posts as &$p){
  1966. if($p['id']==$rename && $p!==$post) { return; /* don't overwrite */ }
  1967. }
  1968. foreach($this->Posts as &$p){
  1969. if(isset($p['prev']) && $p['prev']==$post['id']) { $p['prev']=$rename; }
  1970. if(isset($p['next']) && $p['next']==$post['id']) { $p['next']=$rename; }
  1971. }
  1972. $post['id'] = $rename;
  1973. }
  1974. function DetachPost(&$th,&$post){
  1975. $p0=$p1=NULL;foreach($th['arr'] as $a) echo $a['id']." "; echo '&nbsp;&nbsp;&nbsp;-'.$post['id']."<br />";
  1976. if(isset($post['prev'])){$p0=&$this->GetPost($post['prev'],true);} if(isset($post['next'])){$p1=&$this->GetPost($post['next'],true);}
  1977. if(isset($p0)){ $p0['next']=$p1['id']; }else{ $th['first']=$p1['id']; }
  1978. if(isset($p1)){ $p1['prev'] =$p0['id']; }else{ $th['last']=$p0['id']; }
  1979. foreach($this->Posts as $key => $p){ if ($p==$post) unset($this->Posts[$key]); }
  1980. unset($th['arr']); $now = date_timestamp_get(date_create());
  1981. $this->FinalizeThread($th, true, $now);
  1982. }
  1983. function PushPostVersion(&$post, $optime_id, $mode=1, $info=NULL){
  1984. $a = &$this->GetArchiveHandle($post['id']);
  1985. $ap = []; $ap['id'] = $post['id']; $ap['content'] = $post['real_content'];
  1986. $ap['version'] = isset($post['version'])?$post['version']:$ap['id'];
  1987. if(isset($post['merged_from'])) { $ap['merged_from'] = $post['merged_from']; unset($post['merged_from']); }
  1988. if(isset($post['merged_into'])) { $ap['merged_into'] = $post['merged_into']; unset($post['merged_into']); }
  1989. if(isset($post['merged_thread'])) { $ap['merged_thread'] = $post['merged_thread']; unset($post['merged_thread']); }
  1990. $post['version'] = $optime_id;
  1991. if($mode==1){
  1992. $this->InsertArchivePost($ap);
  1993. }else if($mode==2){
  1994. $post['merged_from'] = $info;
  1995. $this->InsertArchivePost($ap);
  1996. }else if($mode==3){
  1997. $ap['merged_into'] = $info;
  1998. $this->InsertArchivePost($ap);
  1999. if(isset($post['tid']) && $post['tid']['first']!=$post['tid']['last'] && $post!=$post['tid']['first']){
  2000. $this->DetachPost($post['tid'], $post);
  2001. }
  2002. }else if($mode==4){
  2003. $post['merged_thread'] = $info;
  2004. $this->InsertArchivePost($ap);
  2005. }
  2006. }
  2007. function &MergeThreads($post_id, $post_into_id){
  2008. $this->ReadPosts();
  2009. $po = &$this->GetPost($post_id, true); $pt = &$this->GetPost($post_into_id, true);
  2010. if (!isset($po) || !isset($pt) || !isset($po['tid']) || !isset($pt['tid']) ||
  2011. !isset($po['tid']['arr'][0]) || !isset($pt['tid']['arr'][0])){ return $this->NULL_POST; }
  2012. $po = &$po['tid']['arr'][0]; $pt = &$pt['tid']['arr'][0];
  2013. $th = &$po['tid']; $tt = &$pt['tid']; $info=[[],[]];
  2014. if($po['id'] < $pt['id']){ $temp = &$th; $th=&$tt; $tt=&$temp; $temp = &$po; $po=&$pt; $pt=&$temp; }
  2015. foreach($th['arr'] as &$p){ $info[0][]=$p['id']; }
  2016. foreach($tt['arr'] as &$p){ $info[1][]=$p['id']; }
  2017. $this->EditPost($pt['id'], NULL, NULL, NULL, false, NULL, NULL, 4, $info,NULL);
  2018. $arr_combined = array_merge($tt['arr'],$th['arr']);
  2019. $cmppmt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  2020. if(isset($arr_combined[0])){ usort($arr_combined,$cmppmt); } $tt['arr']=&$arr_combined;
  2021. $tt['count'] = sizeof($tt['arr']);
  2022. $this->FinalizeThread($tt, true, $this->TIME_STRING);
  2023. $first_post = &$this->NULL_POST;
  2024. if(isset($tt['arr'][0])) $first_post= &$tt['arr'][0];
  2025. $this->NeedWritePosts=1;
  2026. $this->NeedWriteArchive=1;
  2027. return $first_post;
  2028. }
  2029. function &MergePosts($ids_string){
  2030. $ids = explode(" ", $ids_string);
  2031. $combined_content = ""; $first_id=NULL;
  2032. $this->ReadPosts(); $child_list=[];
  2033. foreach($ids as $id){
  2034. if(!preg_match('/[0-9]{14}/u',$id) || $this->GetPost($id,true)==$this->NULL_POST) continue;
  2035. if(!isset($first_id)) { $first_id = $id; } else { $combined_content.=PHP_EOL.PHP_EOL."//".$id.PHP_EOL; $child_list[]=$id; }
  2036. $combined_content.=$this->EditPost($id, NULL, NULL, NULL, true, NULL, NULL, false, NULL,NULL);
  2037. }
  2038. if(!isset($child_list[0])) return $this->NULL_POST;
  2039. $first_post = &$this->EditPost($first_id, $combined_content, NULL, NULL, false, NULL, NULL, 2, $child_list,NULL);
  2040. foreach($child_list as $id){
  2041. $this->EditPost($id, NULL, NULL, NULL, false, NULL, NULL, 3, [$first_id,$this->TIME_STRING],NULL);
  2042. }
  2043. $this->NeedWritePosts=1;
  2044. $this->NeedWriteArchive=1;
  2045. return $first_post;
  2046. }
  2047. /* push_version: 1 edit 2 post merged from ids list 3 post end into id-ver */
  2048. function &EditPost($id_if_edit, $content, $mark_delete, $reply_to,
  2049. $get_original_only=false, $mark_value=NULL, $rename=NULL,
  2050. $push_version=false, $version_info=NULL, $mastodon_url=NULL){
  2051. $this->ReadImages();
  2052. $this->ReadPosts();
  2053. if(isset($push_version) && $push_version){
  2054. $this->ReadArchive();
  2055. }
  2056. $p_success = NULL;
  2057. if(isset($id_if_edit)){
  2058. $post = &$this->GetPost($id_if_edit,true);
  2059. if($post===$this->NULL_POST) return $this->NULL_POST;
  2060. if($get_original_only){
  2061. return $post['real_content'];
  2062. }
  2063. if(isset($push_version) && $push_version){
  2064. $this->PushPostVersion($post,$this->TIME_STRING,$push_version,$version_info);
  2065. }
  2066. if(isset($content)) {$post['real_content'] = $content; $post['content'] = &$post['real_content'];}
  2067. if(isset($mark_delete)) $post['mark_delete'] = $mark_delete;
  2068. if(isset($mark_value)) $post['mark_value'] = $mark_value;
  2069. if(isset($rename) && preg_match('/^[0-9]{14}$/u',$rename)) $this->RenamePost($post,$rename);
  2070. if(isset($mastodon_url)) { if($mastodon_url!='') $post['mastodon_url']=$mastodon_url; else unset($post['mastodon_url']); }
  2071. $p_success = &$post;
  2072. }else{
  2073. if(!isset($content)) return $this->NULL_POST;
  2074. $id = date('YmdHis');
  2075. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  2076. $post = []; $post['id'] = $id;
  2077. $post['real_content'] = $content; $post['content'] = &$post['real_content'];
  2078. if(isset($mark_value) && $mark_value!==NULL) $post['mark_value'] = $mark_value;
  2079. if(isset($reply_to) && ($rep = &$this->GetPost($reply_to,true))!== $this->NULL_POST){
  2080. while($rep !== $this->NULL_POST && isset($rep['next']) && $rep['next']){ $rep = &$this->GetPost($rep['next'],true); }
  2081. if($rep !== $this->NULL_POST){ $rep['next'] = $id; $post['prev'] = $rep['id']; }
  2082. }
  2083. $this->Posts[] = $post;
  2084. $p_success = &$this->Posts[count($this->Posts) - 1];
  2085. }
  2086. $this->NeedWritePosts=1;
  2087. $this->NeedWriteImages=1;
  2088. if(isset($push_version) && $push_version){
  2089. $this->NeedWriteArchive=1;
  2090. }
  2091. return $p_success;
  2092. }
  2093. function &EditComment($id_if_edit, $comment_to_id, $content, $email, $name, $link=NULL, $ip=NULL){
  2094. $this->ReadPosts();
  2095. $p_success = NULL;
  2096. if(isset($id_if_edit)){
  2097. $post = &$this->GetPost($id_if_edit,true);
  2098. if($post===$this->NULL_POST || !isset($post['comment_to'])) return $this->NULL_POST;
  2099. if(isset($content)) $post['content'] = $content;
  2100. if(isset($comment_to_id)) $post['comment_to'] = $comment_to_id;
  2101. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  2102. if(isset($ip)) $post['ip'] = $ip;
  2103. $p_success = &$post;
  2104. }else{
  2105. if(!isset($content) || !isset($comment_to_id)) return $this->NULL_POST;
  2106. $id = date('YmdHis');
  2107. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  2108. if(!($to_post=$this->GetPost($comment_to_id,true))) return $this->NULL_POST;
  2109. $post = []; $post['id'] = $id; $post['content'] = $content; $post['comment_to'] = $comment_to_id;
  2110. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  2111. if(isset($ip)) $post['ip'] = $ip;
  2112. $this->Posts[] = $post;
  2113. $p_success = &$this->Posts[count($this->Posts) - 1];
  2114. }
  2115. $this->NeedWritePosts=1;
  2116. return $p_success;
  2117. }
  2118. function InsertReplacementSymbols($MarkdownContent, &$post_for_it_is_here){
  2119. $replacement = preg_replace('/<!--[\s\S]*-->/U',"",$MarkdownContent);
  2120. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  2121. function($matches){
  2122. $rep = preg_replace('/->/','-@>',$matches[0]);
  2123. $rep = preg_replace('/=>/','=@>',$rep);
  2124. $rep = preg_replace('/<=/','<@=',$rep);
  2125. $rep = preg_replace('/<-/','<@-',$rep);
  2126. $rep = preg_replace('/\R([+]{3,})\R/',PHP_EOL.'@$1'.PHP_EOL,$rep);
  2127. $rep = preg_replace('/\[-/','[@-',$rep);
  2128. $rep = preg_replace('/\{/','{@',$rep);
  2129. $rep = preg_replace('/(en|zh|any)\|(en|zh|any)/','$1@|$2',$rep);
  2130. return $rep;
  2131. },
  2132. $replacement);
  2133. $replacement = preg_replace("/<[-]+>/","↔",$replacement);
  2134. $replacement = preg_replace("/([^-])->/","$1→",$replacement);
  2135. $replacement = preg_replace("/<-([^-])/","←$1",$replacement);
  2136. $replacement = preg_replace("/([^-])[-]+->/","$1⟶",$replacement);
  2137. $replacement = preg_replace("/<-[-]+([^-])/","⟵$1",$replacement);
  2138. $replacement = preg_replace("/<[=]+>/","⇔",$replacement);
  2139. $replacement = preg_replace("/[=]+>/","⇒",$replacement);
  2140. $replacement = preg_replace("/<[=]+/","⇐",$replacement);
  2141. $replacement = preg_replace("/\R([+]{3,})\R/","<div class='page_break'></div>",$replacement);
  2142. $replacement = preg_replace("/\[-(.*)-\]/U","<span class='text_highlight'>$1</span>",$replacement);
  2143. $replacement = preg_replace("/{支付宝(\s+[^}]*?)?}/u","<span class='special_alipay'>支付宝$1</span>",$replacement);
  2144. $replacement = preg_replace("/{PayPal(\s+[^}]*?)?}/ui",
  2145. "<span class='special_paypal'>Pay<span class='special_paypal_inner'>Pal</span>$1</span>",$replacement);
  2146. $replacement = preg_replace("/\/\/([0-9]{14})/imu","<p class='wscroll' id='$1'>".$this->T("链接位置")."</p>",$replacement);
  2147. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  2148. function($matches){
  2149. $rep = preg_replace('/-@>/','->',$matches[0]);
  2150. $rep = preg_replace('/<@-/','<-',$rep);
  2151. $rep = preg_replace('/=@>/','=>',$rep);
  2152. $rep = preg_replace('/<@=/','<=',$rep);
  2153. $rep = preg_replace('/\R@([+]{3,})\R/',PHP_EOL.'$1'.PHP_EOL,$rep);
  2154. $rep = preg_replace('/\[@-/','[-',$rep);
  2155. $rep = preg_replace('/\{@/','{',$rep);
  2156. $rep = preg_replace('/(en|zh|any)@\|(en|zh|any)/','$1|$2',$rep);
  2157. return $rep;
  2158. }, $replacement);
  2159. $replacement = preg_replace_callback("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\))(\R*(\R.+){1,})/u",
  2160. function($matches) use (&$post_for_it_is_here){
  2161. $rep = preg_replace("/(-|\*)\s+here\s*:\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s+images\/([0-9]{14,}\.(jpg|jpeg|png|gif))/u","", $matches[4]);
  2162. return $matches[1].$rep;
  2163. }, $replacement);
  2164. return $replacement;
  2165. }
  2166. function CanShowPost(&$p,$in_recent=false){
  2167. if(!isset($p) || isset($p['comment_to'])) return false;
  2168. $is_mark_exp = (isset($p['tid'])&&isset($p['tid']['exp'])&&$p['tid']['exp']) || (isset($p['mark_value'])&&$p['mark_value']==6);
  2169. $is_mark_slf = (isset($p['tid'])&&isset($p['tid']['slf'])&&$p['tid']['slf']) || (isset($p['mark_value'])&&$p['mark_value']>=7);
  2170. $is_mark_sln = (isset($p['tid'])&&isset($p['tid']['sln'])&&$p['tid']['sln']) || (isset($p['mark_value'])&&$p['mark_value']==8);
  2171. if($is_mark_slf && !$this->LoggedIn){ return false; }
  2172. if(isset($this->WayBack)){
  2173. if(isset($p['version'])) { if ($p['version']>$this->WayBack) return false; }
  2174. else if ($p['id']>$this->WayBack) return false;
  2175. }
  2176. if(!$this->InExperimentalMode){
  2177. if(!$this->LoggedIn){
  2178. if($is_mark_exp) return false;
  2179. return true;
  2180. }
  2181. if($this->NotesView && !$is_mark_sln && $in_recent){ return false; }
  2182. return true;
  2183. }else{
  2184. if($is_mark_exp) return true;
  2185. return false;
  2186. }
  2187. }
  2188. function SkipProduct(&$p){
  2189. if($this->LoggedIn) return false;
  2190. return (isset($p['mark_value']) && $p['mark_value']==5);
  2191. }
  2192. function GetRedirect($args=NULL, $force_index=NULL){ global $INDEXPHP;
  2193. $str = (isset($force_index)?$force_index:$INDEXPHP).'?';
  2194. if(isset($args['post'])) $str.='&post='.$args['post'];
  2195. else if(isset($_GET['post'])) $str.='&post='.$_GET['post'];
  2196. if(isset($args['gallery'])) $str.='&gallery='.$args['gallery'];
  2197. else if(isset($_GET['gallery'])) $str.='&gallery='.$_GET['gallery'];
  2198. if(isset($args['pic'])) $str.='&pic='.$args['pic'];
  2199. else if(isset($_GET['pic'])) $str.='&pic='.$_GET['pic'];
  2200. if(isset($args['settings'])) $str.='&settings='.$args['settings'];
  2201. else if(isset($_GET['settings'])) $str.='&settings='.$_GET['settings'];
  2202. if(isset($args['statistics'])) $str.='&statistics='.$args['statistics'];
  2203. else if(isset($_GET['statistics'])) $str.='&statistics='.$_GET['statistics'];
  2204. if(isset($args['extras'])) $str.='&extras='.$args['extras'];
  2205. else if(isset($_GET['extras'])) $str.='&extras='.$_GET['extras'];
  2206. if(isset($args['category'])) $str.='&category='.$args['category'];
  2207. else if(isset($_GET['category'])) $str.='&category='.$_GET['category'];
  2208. if(isset($args['history'])) $str.='&history='.$args['history'];
  2209. else if(isset($_GET['history'])) $str.='&history='.$_GET['history'];
  2210. if(isset($args['version'])) $str.='&version='.$args['version'];
  2211. else if(isset($_GET['version'])) $str.='&version='.$_GET['version'];
  2212. if(isset($args['search'])) $str.='&search='.$args['search'];
  2213. else if(isset($_GET['search'])) $str.='&search='.$_GET['search'];
  2214. if(isset($args['here'])) $str.='&here='.$args['here'];
  2215. else if(isset($_GET['here'])) $str.='&here='.$_GET['here'];
  2216. return $str;
  2217. }
  2218. function WriteAsNecessary(){
  2219. if(!$this->LoggedIn || isset($this->WayBack)){return;}
  2220. if($this->NeedWritePosts){ $this->CachePostLinks(); $this->WritePosts(); }
  2221. if($this->NeedWriteImages){ $this->WriteImages(); }
  2222. if($this->NeedWriteArchive){ $this->WriteArchive(); }
  2223. }
  2224. function APubEnsureWebfinger($name, $host){
  2225. if(!is_dir('.well-known')) mkdir('.well-known');
  2226. if(!is_dir('.well-known/webfinger')) mkdir('.well-known/webfinger');
  2227. $f = fopen('.well-known/webfinger/index.php',"w");
  2228. $without_protocol = parse_url($host, PHP_URL_HOST);
  2229. $finger = ["subject"=>"acct:".$name.'@'.$without_protocol,
  2230. "links"=>[["rel"=>"self", "type"=>"application/activity+json", "href"=>$host."?apub_actor=1"]]];
  2231. fwrite($f, "<?php header('Content-Type: application/json'); echo '".json_encode($finger, JSON_UNESCAPED_SLASHES)."'; ?>"); fclose($f);
  2232. if(!file_exists('.well-known/apub_public_key.pem') || !file_exists('.well-known/apub_private_key.php')){
  2233. $res = openssl_pkey_new();
  2234. $this->APubPublicKey = openssl_pkey_get_details($res)['key'];
  2235. openssl_pkey_export($res, $this->APubPrivateKey);
  2236. $f = fopen('.well-known/apub_public_key.pem',"w");
  2237. fwrite($f, $this->APubPublicKey); fclose($f);
  2238. $f = fopen('.well-known/apub_private_key.php',"w");
  2239. fwrite($f, "<?php exit; ?>".PHP_EOL.PHP_EOL.$this->APubPrivateKey); fclose($f);
  2240. }
  2241. }
  2242. function APubInit(){
  2243. $kf = file_get_contents('.well-known/apub_private_key.php'); if($kf===false) return;
  2244. preg_match("/(-----BEGIN PRIVATE KEY-----[\s\S]*)/",$kf,$ma); $this->APubPrivateKey=$ma[1];
  2245. }
  2246. function APubEnsureInfo(){
  2247. if(!isset($this->APubID) || !isset($this->HostURL)) return;
  2248. if(!file_exists('.well-known/apub_public_key.pem')){$this->APubEnsureWebfinger($this->APubID, $this->HostURL);}
  2249. $pk = file_get_contents('.well-known/apub_public_key.pem'); //$pk = preg_replace('/\n/u','\\n',$pk);
  2250. $actor = ["@context"=>["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1"],
  2251. "id"=> $this->HostURL."?apub_actor=1",
  2252. "type"=> "Person",
  2253. "name"=> $this->DisplayName,
  2254. "url"=> $this->HostURL,
  2255. "summary"=> "Lazy... No summary",
  2256. "preferredUsername"=> $this->APubID,
  2257. "inbox"=> $this->HostURL."?apub_inbox=1",
  2258. "outbox"=> $this->HostURL."?apub_outbox=1",
  2259. "publicKey"=> ["id"=> $this->HostURL."?apub_actor=1#main-key",
  2260. "owner"=> $this->HostURL."?apub_actor=1",
  2261. "publicKeyPem"=>$pk]];
  2262. $this->APubActor = json_encode($actor, JSON_UNESCAPED_SLASHES);
  2263. }
  2264. function APubMakeOutbox(){
  2265. $this->ReadPosts();$this->ReadImages();
  2266. $obj = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2267. "id"=>$this->HostURL."?apub_outbox=1",
  2268. "type"=>"OrderedCollection"];
  2269. $items=[]; $i=0;
  2270. foreach(array_reverse($this->Posts) as &$p){
  2271. $this->ConvertPost($p);
  2272. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$p['html']));
  2273. $time = DateTime::createFromFormat('YmdHis', $p['id'], new DateTimeZone('+0800'));
  2274. $ob = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2275. "type"=> "Create",
  2276. "id"=> $this->HostURL."?post=".$p['id']."?apub_object=1",
  2277. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2278. //"to"=> ["https://chatty.example/ben/"],
  2279. "actor"=> $this->HostURL."?apub_actor=1",
  2280. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2281. "object"=> ["type"=> "Note",
  2282. "id"=> $this->HostURL."?post=".$p['id'],
  2283. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2284. "attributedTo"=> $this->HostURL."?apub_actor=1",
  2285. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2286. "content"=> $text]];
  2287. $items[] = $ob;
  2288. $i++; if($i>20) break;
  2289. }
  2290. $obj['orderedItems'] = $items; $obj["totalItems"] = sizeof($items);
  2291. return json_encode($obj, JSON_UNESCAPED_SLASHES);
  2292. }
  2293. function APubDeliver($body,$target){
  2294. $head_digest = base64_encode(hash("sha256",$body,true));
  2295. $body_digest = "SHA-256=".$head_digest;
  2296. // rfc standards require the timezone be declared as GMT and PHP's built-in formats all say UTC
  2297. // so we gotta do it manually
  2298. $d = new DateTimeImmutable("now", new DateTimeZone('Asia/Shanghai'));
  2299. $d=$d->setTimezone(new DateTimeZone('UTC'));
  2300. $date=$d->format("D, d M Y H:i:s")." GMT";
  2301. $data = "(request-target): post ".parse_url($target,PHP_URL_PATH)
  2302. ."\nhost: ".parse_url($target,PHP_URL_HOST)
  2303. ."\ndate: $date"
  2304. ."\ndigest: $body_digest";
  2305. if (openssl_sign($data, $signature, $this->APubPrivateKey, OPENSSL_ALGO_SHA256) === FALSE) {
  2306. http_response_code(500); die('unable to sign');
  2307. }
  2308. $signature = base64_encode($signature);
  2309. $keyid = 'keyId="'.$this->HostURL.'?apub_actor=1#main-key"';
  2310. $algo = 'algorithm="rsa-sha256"';
  2311. $headers = 'headers="(request-target) host date digest"';
  2312. $signature = "signature=\"$signature\"";
  2313. $h = array(
  2314. 'Content-Type: application/activity+json',
  2315. 'Accept: application/activity+json',
  2316. //"Content-Length: ".strlen($body),
  2317. "Host: ". parse_url($target,PHP_URL_HOST),
  2318. "Date: $date",
  2319. "Digest: $body_digest",
  2320. "Signature: $keyid,$algo,$headers,$signature"
  2321. );
  2322. $ch = curl_init($target);
  2323. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  2324. curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
  2325. curl_setopt($ch, CURLOPT_HTTPHEADER, $h);
  2326. curl_setopt($ch, CURLOPT_USERAGENT, "laMDWiki APub");
  2327. $result = curl_exec($ch);
  2328. curl_close($ch); echo "<pre>";
  2329. print_r($body); echo "\n\n".$target."\n\n";
  2330. print_r($result); echo "\n\n"; print_r($h);
  2331. echo "\n\n"; print_r(curl_getinfo($ch)); echo "</pre>"; exit;
  2332. return $result;
  2333. }
  2334. function APubTestDeliver(){
  2335. $this->APubInit();
  2336. $obj=[];
  2337. $obj['published']=gmdate("Y-m-d\TH:i:s\Z");
  2338. $obj['id']=""; //<-------------------
  2339. $obj['url']=$this->HostURL.""; //<-------------------
  2340. $obj['type']='Note';
  2341. $obj['attributedTo']=$this->HostURL."?apub_actor=1";
  2342. $tag=[]; $tag['type']='Mention'; $tag['name']="@chengdulittlea"; $tag['href']="https://mastodon.art/users/chengdulittlea";
  2343. $obj['tag']=[$tag];
  2344. // must have cc to have notification in mastodon.
  2345. $obj['cc']=["https://mastodon.art/users/chengdulittlea"];
  2346. $obj['content']="<p>@chengdulittlea Hello activitypub from laMDWiki!</p>";
  2347. $obj['to']="https://www.w3.org/ns/activitystreams#Public";
  2348. $obj['inReplyTo']=""; //<-------------------
  2349. $arr=[];
  2350. $arr['@context']="https://www.w3.org/ns/activitystreams";
  2351. $arr['id']=""; //<-------------------
  2352. $arr['actor']=$this->HostURL."?apub_actor=1";
  2353. $arr['type']="Create";
  2354. $arr['to']="https://www.w3.org/ns/activitystreams#Public";
  2355. $arr['object']=$obj;
  2356. $this->APubDeliver(json_encode($arr),"https://mastodon.example/inbox"); //<-------------------
  2357. }
  2358. function APubProcessInbox(){
  2359. $r = file_get_contents('php://input');
  2360. file_put_contents('postdump.txt',$r);
  2361. }
  2362. function MakeRSS(){
  2363. $this->ReadPosts();$this->ReadImages();
  2364. $posts = []; if(isset($this->UsePosts[0])){
  2365. $posts = array_reverse($this->UsePosts);
  2366. $last_updated = $this->StandardTime($posts[0]['id']);
  2367. }else{ $last_updated= $this->StandardTime("20000101000000"); }
  2368. $author = "<author><name>".$this->DisplayName."</name><email>".$this->EMail."</email><uri>".$this->HostURL."</uri></author>";
  2369. $all_content="<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom'>".
  2370. "<id>".$this->HostURL."/?rss</id>".
  2371. "<updated>".$last_updated."</updated>".
  2372. "<title>".$this->T($this->Title)."</title>".
  2373. "<link href='".$this->HostURL."/index.php?rss=".($this->LanguageAppendix=='zh'?'zh':'en')."' rel='self'/>".
  2374. "<link href='".$this->HostURL."' />".$author;
  2375. $i=0;
  2376. if(isset($posts[0])) foreach($posts as &$p){
  2377. if($i>100) break;
  2378. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  2379. if(isset($p['tid'])){ /* Should always be set. */
  2380. $th = &$p['tid']; if($p['tid']['count']==0) continue; }
  2381. if(in_array($p['id'],
  2382. [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
  2383. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  2384. $is_thread = isset($p['tid']['count'])&&($p['tid']['count']>1);
  2385. $is_reversed=false;
  2386. $content="<entry>"; $title = NULL;
  2387. if($is_thread){
  2388. $use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false; if($is_reversed){
  2389. $use_arr=array_reverse($th['arr']); $fp=array_pop($use_arr); array_unshift($use_arr,$fp); }
  2390. foreach($use_arr as &$po){
  2391. $this->ConvertPost($po);
  2392. if(!isset($title)){$title = htmlspecialchars($this->GetPostTitle($po, false, false)); if(!$title){$title='untitled';}
  2393. $content.="<id>".$this->HostURL."/?post=".$po['id']."</id>";
  2394. $content.="<title type='html'>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$po['id']."' />";
  2395. $content.="<published>".$this->StandardTime($po['id'])."</published>";
  2396. $content.="<updated>".$this->StandardTime(isset($po['tid']['last']['version'])?
  2397. $po['tid']['last']['version']:$po['tid']['last']['id'])."</updated>".$author;
  2398. $content.="<content type='html'>"; }
  2399. $content.= htmlspecialchars($po['html']);
  2400. //if(isset($po['images'])&&isset($po['images'][0])) foreach($po['images'] as $im){ $content.=htmlspecialchars($im); }
  2401. }
  2402. $content.=$this->ReadableTime($p['tid']['first']['id'])." - ".
  2403. $this->ReadableTime(isset($p['tid']['last']['version'])?
  2404. $p['tid']['last']['version']:$p['tid']['last']['id']);
  2405. $content.="</content>";
  2406. }else{
  2407. $this->ConvertPost($p);
  2408. if(!isset($title)){$title = htmlspecialchars($this->GetPostTitle($p, false, false)); if(!$title){$title='untitled';}
  2409. $content.="<id>".$this->HostURL."/?post=".$p['id']."</id>";
  2410. $content.="<title type='html'>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$p['id']."' />";
  2411. $content.="<published>".$this->StandardTime($p['id'])."</published>";
  2412. $content.="<updated>".$this->StandardTime(isset($p['tid']['last']['version'])?
  2413. $p['tid']['last']['version']:$p['tid']['last']['id'])."</updated>".$author;}
  2414. $content.= "<content type='html'>".htmlspecialchars($p['html']);
  2415. //if(isset($p['images'])&&isset($p['images'][0])) foreach($p['images'] as $im){ $content.=htmlspecialchars($im); }
  2416. $content.=$this->ReadableTime($p['id'])." - ".
  2417. $this->ReadableTime(isset($p['version'])?$p['version']:$p['id']);
  2418. $content.="</content>";
  2419. }
  2420. $i++;
  2421. $content.="</entry>";
  2422. $all_content.=$content;
  2423. }
  2424. $all_content.="</feed>";
  2425. header( "Content-type: text/xml");
  2426. echo $all_content;
  2427. }
  2428. function MakeHereButtons($im, $insert_here){
  2429. if(isset($im['here'])&&isset($im['here'][0])){
  2430. $size=getimagesize($im['file']); $aspect=$size[0]/$size[1];
  2431. echo ($insert_here?"<here>":"")."<div class='here_buttons_inner' style='aspect-ratio:".$aspect.";'>";
  2432. foreach($im['here'] as $here){
  2433. if($insert_here){
  2434. echo "<a href='?show_image=".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'".
  2435. "onclick='event.preventDefault();event.stopPropagation();ShowBigImage(\"".$here[0]."\",1);'></a>";
  2436. }else{
  2437. echo "<a href='?here=images/".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'></a>";
  2438. }
  2439. }
  2440. echo "</div>".($insert_here?"</here>":"");
  2441. }
  2442. }
  2443. function ProcessRequest(&$message=NULL, &$redirect=NULL){ global $INDEXPHP;
  2444. if(isset($_GET['gallery_continue']) && $_GET['gallery']){
  2445. $this->ReadImages();
  2446. $this->GetImageBatch($_GET['gallery_continue'],0);
  2447. exit;
  2448. }
  2449. if(isset($_GET['gallery']) && $_GET['gallery']=='default'){
  2450. $redirect = "$INDEXPHP?gallery=".(isset($this->DefaultGallery)&&$this->DefaultGallery!=''?$this->DefaultGallery:"main");
  2451. return 0;
  2452. }
  2453. if(isset($_GET['set_language'])){
  2454. setcookie('la_language',$_GET['set_language'],time()+3600*24*7,'/'); $_COOKIE['la_language'] = $_GET['set_language'];
  2455. $redirect=$this->GetRedirect(); return 0;
  2456. }
  2457. if(isset($_GET['rss'])){
  2458. if(in_array($_GET['rss'],['en','zh'])){$this->LanguageAppendix=$_GET['rss'];}
  2459. $this->MakeRSS(); exit;
  2460. }
  2461. if(isset($_GET['toggle_font'])){ $use_font='local';
  2462. if(!isset($_COOKIE['la_font']) || $_COOKIE['la_font']!='remote') $use_font='remote';
  2463. setcookie('la_font',$use_font,time()+3600*24*7,'/'); $_COOKIE['la_font'] = $use_font;
  2464. $redirect=$this->GetRedirect(); return 0;
  2465. }
  2466. if(isset($_GET['set_wayback'])){
  2467. if($_GET['set_wayback']!='false'){
  2468. $wayback= date('YmdHis');
  2469. if($_GET['set_wayback']=='post'){
  2470. if(isset($_POST['wayback_year'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_year'],4,"0",STR_PAD_LEFT),0,4);
  2471. if(isset($_POST['wayback_month'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_month'],2,"0",STR_PAD_LEFT),4,2);
  2472. if(isset($_POST['wayback_day'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_day'],2,"0",STR_PAD_LEFT),6,2);
  2473. if(isset($_POST['wayback_hour'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_hour'],2,"0",STR_PAD_LEFT),8,2);
  2474. if(isset($_POST['wayback_minute'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_minute'],2,"0",STR_PAD_LEFT),10,2);
  2475. }else{ if(preg_match('/[0-9]{14}/u', $_GET['set_wayback'])) $wayback = $_GET['set_wayback']; }
  2476. setcookie('la_wayback',$wayback,time()+3600*24*7,'/'); $_COOKIE['la_wayback'] = $wayback;
  2477. }else{
  2478. setcookie('la_wayback', null, -1,'/'); unset($_COOKIE['la_wayback']);
  2479. }
  2480. $redirect=$this->GetRedirect(); return 0;
  2481. }
  2482. if(isset($_GET['post'])){ $this->CurrentPostID = $_GET['post']; $this->TagID = $this->CurrentPostID; }
  2483. if(isset($_GET['here'])){ $this->HereID = $_GET['here']; }
  2484. if(isset($_GET['offset'])){ $this->CurrentOffset = $_GET['offset']; }
  2485. if(isset($_GET['post'])){
  2486. $this->ExtraScripts.="window.addEventListener('load', (event) => {ScrollToPost('".$_GET['post']."');});";
  2487. }
  2488. if(isset($_GET['random_here'])){
  2489. $this->DoIdentifyExperimental(); $this->DetectPageType();
  2490. $im = &$this->GiveImageInHere(true); if(isset($im)){ $redirect='?here=images/'.$im['name']; return 0; }
  2491. }
  2492. if(isset($_POST['search_content'])){ $redirect=$INDEXPHP.'?search='.$_POST['search_content'];return 0; }
  2493. if(isset($_GET['image_info']) || isset($_GET['show_image'])){
  2494. $m=isset($_GET['image_info'])?$_GET['image_info']:$_GET['show_image'];
  2495. $direct_return = !isset($_GET['show_image']);
  2496. $this->ReadImages(); $this->ReadPosts();
  2497. $this->SwitchWayBackMode(); if(isset($this->WayBack)){$this->ReadArchive();}
  2498. $im = &$this->FindImage($m);
  2499. if($im==NULL || !isset($im['refs']) || !isset($im['refs'][0])){ echo "not_found"; exit; }
  2500. if($direct_return){
  2501. echo "<ref>".sizeof($im['refs'])."</ref>";
  2502. echo "<insert>";
  2503. }else{ ob_start(); }
  2504. $STR="";
  2505. $this->TBackup();
  2506. foreach(array_reverse($im['refs']) as $ref){
  2507. $p = $this->GetPost($ref);
  2508. if(!$p || !$this->CanShowPost($p)) continue;
  2509. $this->MakeSinglePostV2($p, false, true, "post_preview", true, false, false, false, true);
  2510. }
  2511. $STR=$this->TRestore(" compact");
  2512. if($direct_return){
  2513. echo $STR;
  2514. echo "</insert>";
  2515. $this->MakeHereButtons($im, true);
  2516. }else{
  2517. $str = $STR;
  2518. $this->MakePageBegin($this->NULL_POST);
  2519. $side = "";
  2520. if(isset($im['refs'])&&isset($im['refs'][0])){
  2521. $side.="<span class='small'>".$this->T('该图片出现在')." ".sizeof($im['refs'])." ".$this->T('个帖子中')."</span>";
  2522. }else{$side.="<span class='smaller gray'>".$this->T('该图片未被引用')."</span>";}
  2523. $static_image = isset($im['video'])?NULL:$im['file'];
  2524. $static_video = isset($im['video'])?$im['file']:NULL;
  2525. $this->MakeImageOverlay($side."<ul>".$str."</ul>",$static_image,$static_video);
  2526. $this->MakePageEnd();
  2527. }
  2528. exit;
  2529. }
  2530. if(isset($_GET['confirm_enter']) && $_GET['confirm_enter']!=false){
  2531. setcookie('la_experimental','confirmed',time()+3600*24*7,'/'); $_COOKIE['la_experimental'] = $_GET['confirmed'];
  2532. $redirect=$INDEXPHP.(isset($_GET['post'])?'?post='.$_GET['post']:"");return 0;
  2533. }
  2534. if(isset($_GET['apub_actor'])){
  2535. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2536. echo $this->APubActor; exit;
  2537. }
  2538. if(isset($_GET['apub_outbox'])){
  2539. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2540. echo $this->APubMakeOutbox(); exit;
  2541. }
  2542. if(isset($_GET['apub_inbox'])){
  2543. $this->APubProcessInbox();
  2544. http_response_code(202); exit;
  2545. }
  2546. if($this->LoggedIn){
  2547. if(isset($_GET['TestAPubDeliver'])){
  2548. $this->APubTestDeliver();
  2549. }
  2550. if(isset($_GET['set_notes_view'])){
  2551. setcookie('la_notes_view',$_GET['set_notes_view'],time()+3600*24*7,'/'); $_COOKIE['la_notes_view'] = $_GET['set_notes_view'];
  2552. $redirect=$this->GetRedirect(); return 0;
  2553. }
  2554. $this->DoUpload();
  2555. if(isset($_POST['settings_button'])){
  2556. if(isset($_POST['settings_title'])) $this->Title=$_POST['settings_title'];
  2557. if(isset($_POST['settings_short_title'])) $this->ShortTitle=$_POST['settings_short_title'];
  2558. if(isset($_POST['settings_display_name'])) $this->DisplayName=$_POST['settings_display_name'];
  2559. if(isset($_POST['settings_email'])) $this->EMail=$_POST['settings_email'];
  2560. if(isset($_POST['settings_special_navigation'])) $this->SpecialNavigation=$_POST['settings_special_navigation'];
  2561. if(isset($_POST['settings_special_sidebar'])) $this->SpecialSidebar=$_POST['settings_special_sidebar'];
  2562. if(isset($_POST['settings_special_footer'])) $this->SpecialFooter=$_POST['settings_special_footer'];
  2563. if(isset($_POST['settings_special_footer2'])) $this->SpecialFooter2=$_POST['settings_special_footer2'];
  2564. if(isset($_POST['settings_special_pinned'])) $this->SpecialPinned=$_POST['settings_special_pinned'];
  2565. if(isset($_POST['settings_special_pinned_notes'])) $this->SpecialPinnedNotes=$_POST['settings_special_pinned_notes'];
  2566. if(isset($_POST['settings_default_gallery'])) $this->DefaultGallery=$_POST['settings_default_gallery'];
  2567. if(isset($_POST['settings_selfauth_path'])) $this->SelfAuthPath=$_POST['settings_selfauth_path'];
  2568. if(isset($_POST['settings_enable_comments'])) $this->CommentEnabled=True; else $this->CommentEnabled=False;
  2569. if(isset($_POST['settings_enable_newsletter'])) $this->NewsletterEnabled=True; else $this->NewsletterEnabled=False;
  2570. if(isset($_POST['settings_gallery_step'])) $this->GalleryStep=$_POST['settings_gallery_step'];
  2571. if(isset($_POST['settings_here_host'])) $this->HereHost=$_POST['settings_here_host'];
  2572. if(isset($_POST['settings_here_title'])) $this->HereTitle=$_POST['settings_here_title'];
  2573. if(isset($_POST['settings_here_short_title'])) $this->HereShortTitle=$_POST['settings_here_short_title'];
  2574. if(isset($_POST['settings_here_album'])) $this->HereAlbum=$_POST['settings_here_album'];
  2575. if(isset($_POST['settings_here_navigation'])) $this->HereNavigation=$_POST['settings_here_navigation'];
  2576. if(isset($_POST['settings_here_footer'])) $this->HereFooter=$_POST['settings_here_footer'];
  2577. if(isset($_POST['settings_exp_host'])) $this->ExpHost=$_POST['settings_exp_host'];
  2578. if(isset($_POST['settings_exp_title'])) $this->ExpTitle=$_POST['settings_exp_title'];
  2579. if(isset($_POST['settings_exp_short_title'])) $this->ExpShortTitle=$_POST['settings_exp_short_title'];
  2580. if(isset($_POST['settings_exp_caution'])) $this->ExpCaution=$_POST['settings_exp_caution'];
  2581. if(isset($_POST['settings_exp_album'])) $this->ExpAlbum=$_POST['settings_exp_album'];
  2582. if(isset($_POST['settings_exp_navigation'])) $this->ExpNavigation=$_POST['settings_exp_navigation'];
  2583. if(isset($_POST['settings_exp_footer'])) $this->ExpFooter=$_POST['settings_exp_footer'];
  2584. if(isset($_POST['settings_allow_language'])) $this->AllowLanguageChoices=True; else $this->AllowLanguageChoices=False;
  2585. if(isset($_POST['settings_mastodon_token'])) $this->MastodonToken=$_POST['settings_mastodon_token'];
  2586. if(isset($_POST['settings_mastodon_url'])) $this->MastodonURL=$_POST['settings_mastodon_url'];
  2587. if(isset($_POST['settings_mastodon_lang'])) $this->MastodonPreferredLang=$_POST['settings_mastodon_lang'];
  2588. if(isset($_POST['settings_host_url'])) $this->HostURL=$_POST['settings_host_url'];
  2589. if(isset($_POST['settings_apub_id']) && isset($this->HostURL)) {
  2590. $this->APubID=$_POST['settings_apub_id'];
  2591. $this->APubEnsureWebfinger($this->APubID,$this->HostURL);
  2592. }
  2593. if(isset($_POST['settings_old_password'])&&password_verify($_POST['settings_old_password'], $this->Password)){
  2594. if(isset($_POST['settings_id'])) $this->Admin=$_POST['settings_id'];
  2595. if(isset($_POST['settings_new_password']) && isset($_POST['settings_new_password_redo']) &&
  2596. $_POST['settings_new_password'] = $_POST['settings_new_password_redo'])
  2597. {$this->Password=password_hash($_POST['settings_new_password'], PASSWORD_DEFAULT);}
  2598. $redirect=$_SERVER['REQUEST_URI'];
  2599. $this->DoLogout();
  2600. }
  2601. $this->WriteConfig();
  2602. return 0;
  2603. }
  2604. if(isset($_POST['settings_save_redirect'])){
  2605. if(isset($_POST['settings_redirect'])){
  2606. $this->BuildRedirectConfig($_POST['settings_redirect']);
  2607. }
  2608. $this->WriteConfig();
  2609. $redirect = $INDEXPHP.'?extras=true'; return 0;
  2610. }
  2611. if(isset($_POST['settings_save_translation'])){
  2612. if(isset($_POST['settings_translation'])){
  2613. $f = fopen("custom_translations.md", "w"); fwrite($f,$_POST['settings_translation']); fflush($f); fclose($f);
  2614. }
  2615. $redirect = $INDEXPHP.'?extras=true'; return 0;
  2616. }
  2617. if(isset($_GET['post'])){
  2618. if(isset($_GET['post_original'])){
  2619. echo $this->EditPost($_GET['post'],NULL,false,NULL,true,NULL,NULL,false,NULL,NULL);
  2620. exit;
  2621. }
  2622. }
  2623. if(isset($_GET['mark_delete']) && isset($_GET['target'])){
  2624. $this->EditPost($_GET['target'],NULL,$_GET['mark_delete']=='true',NULL,false,NULL,NULL,false,NULL,NULL);
  2625. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2626. return 0;
  2627. }
  2628. if(isset($_GET['set_mark']) && isset($_GET['target'])){
  2629. $this->EditPost($_GET['target'],NULL,NULL,NULL,NULL,$_GET['set_mark'],NULL,false,NULL,NULL);
  2630. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2631. return 0;
  2632. }
  2633. if((isset($_POST['post_button'])||isset($_POST['post_button_note'])) && isset($_POST['post_content'])){
  2634. $c = $_POST['post_content'];
  2635. if('有什么想说的' == $c){ return 0;}
  2636. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2637. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2638. $reply_to = (isset($_POST['post_reply_to'])&&$_POST['post_reply_to']!="")?$_POST['post_reply_to']:NULL;
  2639. $edit_id = (isset($_POST['post_edit_target'])&&$_POST['post_edit_target']!="")?$_POST['post_edit_target']:NULL;
  2640. $push_history = (isset($edit_id) && isset($_POST['post_record_edit']));
  2641. $postmark=NULL;
  2642. if(isset($_POST['post_button_note'])){ $postmark=8; }
  2643. if(($edited = $this->EditPost($edit_id, $c, NULL, $reply_to,NULL,$postmark,NULL,$push_history,NULL,NULL))!=NULL){
  2644. $redirect='?post='.$edited['id']; return 0;
  2645. };
  2646. }
  2647. if(isset($_POST['post_rename_confirm']) && isset($_POST['post_rename_name']) && isset($_GET['rename_post'])){
  2648. if(($edited =$this->EditPost($_GET['rename_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,NULL))!=NULL){
  2649. $redirect='?post='.$edited['id']; return 0;
  2650. };
  2651. }
  2652. if(isset($_POST['post_mastodon_confirm']) && isset($_POST['post_mastodon_url']) && isset($_GET['mastodon_post'])){
  2653. if(($edited =$this->EditPost(
  2654. $_GET['mastodon_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,$_POST['post_mastodon_url']))!=NULL){
  2655. $redirect='?post='.$edited['id']; return 0;
  2656. };
  2657. }
  2658. if(isset($_GET['mastodon_send_post']) && preg_match('/([0-9]{14})/u',$_GET['mastodon_send_post'],$m)){
  2659. $this->ReadImages(); $this->ReadPosts(); $post = &$this->GetPost($m[1]); $err=$this->T("未知错误");
  2660. if(isset($post)){
  2661. if($mastodon_url = $this->MastodonSendPost($post, $err)){
  2662. $this->NeedWritePosts = 1; $this->WritePosts(); // for mastodon url
  2663. echo "SUCCESS ".$mastodon_url;
  2664. }else{ echo $err; }
  2665. } exit;
  2666. }
  2667. if(isset($_GET['merge_threads'])&&$_GET['merge_threads']!=""){
  2668. if(preg_match('/([0-9]{14})\s+([0-9]{14})/u',$_GET['merge_threads'],$m)){
  2669. if(($pe = &$this->MergeThreads($m[1],$m[2]))!=$this->NULL_POST){ $redirect='?post='.$pe['id']; return 0; }
  2670. }
  2671. }
  2672. if(isset($_GET['merge_posts'])&&$_GET['merge_posts']!=""){
  2673. if(($pe = &$this->MergePosts($_GET['merge_posts']))!=$this->NULL_POST){
  2674. $redirect='?post='.$pe['id']; return 0;
  2675. }
  2676. }
  2677. if ($this->CommentEnabled && isset($_POST['comment_confirm']) && (isset($_GET['comment_to']))
  2678. && isset($_POST['comment_box']) && isset($_POST['comment_email']) && isset($_POST['comment_name'])){
  2679. $c = $_POST['comment_box'];
  2680. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2681. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2682. $comment_to = ($_GET['comment_to']!="")?$_GET['comment_to']:NULL;
  2683. if(($edited = $this->EditComment(NULL,
  2684. $_GET['comment_to'], $c, $_POST['comment_email'], $_POST['comment_name'],
  2685. isset($_POST['comment_link'])?$_POST['comment_link']:NULL,
  2686. $_SERVER['REMOTE_ADDR']))!=NULL){
  2687. $redirect='?post='.$_GET['post'];
  2688. return 0;
  2689. };
  2690. }
  2691. if(isset($_GET['send']) && isset($_GET['addr']) && isset($_GET['post']) && $_GET['post']!=''){
  2692. require_once("mailsub.php"); $this->ReadPosts(); $this->ReadImages();
  2693. $post = &$this->GetPost($_GET['post'],true); if($post==$this->NULL_POST){ echo $this->T("问题"); exit; }
  2694. $content = $this->GenerateSinglePost($post, 0, 0, 0, 0, 0);
  2695. //$content = preg_replace("/(=[\'\"](.*\.php)?)(\?)/","$1{$GLOBALS['MY_HOST']}/$3",$content);
  2696. //$content = preg_replace("/(src=[\'\"])(images)/","$1{$GLOBALS['MY_HOST']}/$2",$content);
  2697. //$content = preg_replace("/(=[\'\"])(Files)/","$1{$GLOBALS['MY_HOST']}/$2",$content);
  2698. $content = $content."<br />.<hr />".mailsub_regular_text($_GET['send'],$_GET['addr']);
  2699. $title=$this->GetPostTitle($post);
  2700. if(send_email($_GET['addr'],$title,$content)<0){ echo $this->T("问题"); exit; }
  2701. echo $content; exit;
  2702. }
  2703. if(isset($_POST['gallery_edit_confirm']) && isset($_POST['gallery_edit_new_name']) && $_POST['gallery_edit_new_name']!=''){
  2704. $old_name = isset($_POST['gallery_edit_old_name'])?$_POST['gallery_edit_old_name']:"";
  2705. $new_name = $_POST['gallery_edit_new_name'];
  2706. if($old_name!=''){
  2707. $desc=isset($_POST['gallery_edit_description'])?$_POST['gallery_edit_description']:null;
  2708. if(!preg_match('/[0-9]{14}/',$desc))$desc="";
  2709. $this->EditGallery($old_name, $new_name, false, true, null, null,$desc);
  2710. $redirect='?gallery='.$new_name;
  2711. }else{
  2712. $this->EditGallery(null, $new_name, false, true, null,null);
  2713. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2714. }
  2715. return 0;
  2716. }
  2717. if(isset($_GET['gallery_edit_delete'])&&$_GET['gallery_edit_delete']!=null){
  2718. $this->EditGallery($_GET['gallery_edit_delete'], null, true, true, null, null,null);
  2719. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery=main'; else $redirect=$INDEXPHP;
  2720. return 0;
  2721. }
  2722. if(isset($_POST['gallery_move_ops'])&&isset($_POST['gallery_move_ops'])){
  2723. if(preg_match('/^(REM|ADD)\s+(\S+)\s+(.*)$/u', $_POST['gallery_move_ops'], $ma)){
  2724. $this->ReadImages();
  2725. if(preg_match_all('/(\S+)/u', $ma[3], $files, PREG_SET_ORDER)) foreach($files as $name){
  2726. $this->EditImage($name[1], $ma[2], ($ma[1]=='REM'), NULL, NULL, NULL, NULL);
  2727. }
  2728. }
  2729. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2730. return 0;
  2731. }
  2732. if(isset($_GET['gallery_set_featured'])&&isset($_GET['value'])){
  2733. $this->EditGallery($_GET['gallery_set_featured'], null, false, true, $_GET['value']!='false', null);
  2734. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2735. return 0;
  2736. }
  2737. if(isset($_GET['gallery_set_experimental'])&&isset($_GET['value'])){
  2738. $this->EditGallery($_GET['gallery_set_experimental'], null, false, true, null, $_GET['value']!='false');
  2739. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2740. return 0;
  2741. }
  2742. if(isset($_GET['image_list'])&&$_GET['image_list']!=""){
  2743. $this->ReadImages();
  2744. $gallery = $_GET['image_list']; $count=0;
  2745. foreach($this->Images as $im){ if($count>25){ break; }
  2746. if($gallery=='main'){ echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; $count++; continue; }
  2747. if(isset($im['galleries']) && isset($im['galleries'][0]) && in_array($gallery,$im['galleries'])) {
  2748. echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; $count++; }
  2749. }
  2750. exit;
  2751. }
  2752. $do_image_redirect = 0;
  2753. if (isset($_POST['image_button']) && isset($_GET['pic']) &&
  2754. preg_match('/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4))/u',$_GET['pic'],$ma)){
  2755. $this->ReadImages(); $pic = $ma[1]; $picext=$ma[2];
  2756. if(isset($_POST['image_ops_product_link'])){
  2757. $this->EditImage($pic, NULL, false, $_POST['image_ops_product_link'], NULL, NULL, NULL);
  2758. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2759. }
  2760. if(isset($_POST['image_edit_new_name']) && preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_edit_new_name'],$man)){
  2761. $this->EditImage($pic, NULL, false, NULL, $man[1], NULL, NULL);
  2762. $redirect=$this->GetRedirect(['pic'=>'images/'.$man[1].'.'.$picext]);
  2763. $do_image_redirect = 1;
  2764. }
  2765. if(isset($_POST['image_parent'])){ $parent="";
  2766. if(preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_parent'],$man)){ $parent = $man[1]; }
  2767. $this->EditImage($pic, NULL, false, NULL, NULL, $parent, NULL);
  2768. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2769. }
  2770. if(isset($_POST['image_align'])){$val=$_POST['image_align'];
  2771. $this->EditImage($pic, NULL, false, NULL, NULL, NULL, $val);
  2772. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2773. }
  2774. $this->NeedWriteImages = 1;
  2775. if($do_image_redirect) return 0;
  2776. }
  2777. if(isset($_GET['rewrite_styles'])){
  2778. $this->WriteStyles(); $redirect='?extras=true'; return 0;
  2779. }
  2780. if(isset($_GET['regenerate_thumbnails'])){
  2781. $this->RegenerateThumbnails(); $redirect='?extras=true'; return 0;
  2782. }
  2783. if(isset($_GET['cleanup_image_compression'])){ $run=false;
  2784. if(isset($_GET['run'])){ $run=true; }
  2785. $this->CleanupImageCompression($run); $redirect='?extras=true'; return 0;
  2786. }
  2787. if(isset($_GET['clear_all_logins'])){
  2788. $this->LoginTokens=[]; $this->WriteTokens();
  2789. }
  2790. if($_SERVER['HTTP_HOST']=='localhost'){$this->WriteStyles();}
  2791. }
  2792. return 0;
  2793. }
  2794. function PostProcessHTML($html,&$added_images=null,$do_product_info=false, &$product_info=null, &$orig_src_list=null, &$end_wide=null, &$print_wide=null){
  2795. if(!$this->LoggedIn){
  2796. $html = preg_replace("/(<a[^>]*href=[\'\"])(.*?)([\'\"][^>]*)>(\#.*?<\/a>)/u","",$html);
  2797. }
  2798. $html = preg_replace("/(<a[^>]*href=[\'\"])([0-9]{14})([\'\"][^>]*)>(.*?<\/a>)/u","$1?post=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2799. $html = preg_replace("/(<a[^>]*href=[\'\"])\@(.*?)([\'\"][^>]*)>(.*?<\/a>)/u","$1?category=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2800. $html = preg_replace("/(<a[^>]*href=[\'\"])((.*?:\/\/).*?)([\'\"][^>]*)(>)(.*?)(<\/a>)/u",
  2801. "$1$2$4 target='_blank'$5$6<sup>↗</sup>$7",$html);
  2802. $html = preg_replace("/<p>\s*\@.*?<\/p>/mu","",$html);
  2803. $html = preg_replace("/\{\s*(REVERSED|INTERESTING|HEADER|FOOTER)\s+(.*?)\}/imu","",$html);
  2804. $html = preg_replace("/\{\s*(REVERSED|NO_TIME|NO_TITLE|SLIDES)\s*\}/imu","",$html);
  2805. $html = preg_replace("/\{\s*WIDE\s*\}/imu","",$html,-1,$rep_count); if($rep_count){$print_wide=true;}
  2806. $images = []; $images_noclick = []; $images_orig_src_list = [];
  2807. $html = preg_replace_callback(
  2808. "/(<p>\s*|<a\s.*?>\s*)?(<img([^>]*)src=[\'\"])(images\/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4)))([\'\"][^>]*)\/>(\s*<\/p>)?/u",
  2809. function($m) use (&$images,&$images_noclick,&$images_orig_src_list) {
  2810. if(isset($m[1])&&$m[1]&&$m[1][1]=='a'){ $height="";
  2811. if(preg_match("/([0-9]{1,2})em/u",$m[0],$hm)){$height=' style="height:'.$hm[1].'em;"';}
  2812. return "<a class='imbtn'".$height.substr($m[0],2); }
  2813. $orig_src = $src = $m[5]; $keep = false; $original = false; $float=false;
  2814. if (preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[3]) ||
  2815. preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[7])) { $keep=true; }
  2816. if ($keep && preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[3]) ||
  2817. preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[7])) { $original=true; }
  2818. if (preg_match('/alt=[\'\"].*float.*[\'\"]/u',$m[3]) ||
  2819. preg_match('/alt=[\'\"].*float.*[\'\"]/u',$m[7])) { $keep=true;$original=true;$float=true; }
  2820. if(($im = &$this->FindImage($m[5]))!=NULL && isset($im['thumb'])){
  2821. $src = $im['thumb']; $orig_src=$im['file'];
  2822. }if($im == NULL){ $im = &$this->NULL_IMAGE_DUMMY; }
  2823. $media_start = $m[2];
  2824. $media_end = $m[7];
  2825. $dataset = " data-imgsrc='".$m[5]."'".
  2826. (isset($im['product'])?" data-product='".$im['product']."'":"").
  2827. (isset($im['parent'])?" data-parent='".$im['parent']."'":"").
  2828. (isset($im['align'])?' data-align="'.$im["align"].'" style="object-position:'.$im['align'].';"':"").
  2829. ($original?" class='original_img'":"");
  2830. if(isset($im['video']) && isset($im['video'])!=''){
  2831. $media_start = "<video controls".$dataset."><source src='"; $media_end="' type='".$im['video']."'></video";
  2832. $src = $orig_src; $dataset="";
  2833. }
  2834. $float_add=""; if($float){ $float_add=" imd_float"; }
  2835. if($this->InHereMode){
  2836. $click = "<div class='imd$float_add'>"."<a href='?here=".$im['file']."' class='original_img'>".
  2837. $media_start.($original?$orig_src:$src).$media_end."></a></div>";
  2838. $ret=""; if($keep) { $ret = $click; }
  2839. else { $images[] = $click; }
  2840. return $ret;
  2841. }else{
  2842. $click ="<div class='imd$float_add'><a href='?show_image={$im['name']}' target='_blank' onclick='event.preventDefault();'>".
  2843. $media_start.($original?$orig_src:$src).$media_end.$dataset."></a></div>";
  2844. $images_noclick[]=$media_start.$src.$media_end.">"; $images_orig_src_list[]=$orig_src;
  2845. $ret = "";
  2846. if($keep) { $ret = $click; }
  2847. else { $images[] = $click; }
  2848. if(isset($m[1])&&isset($m[8])&&$m[1]&&$m[8]) return $ret;
  2849. else return ((isset($m[1])&&$m[1]?$m[1]:"").$ret.(isset($m[8])&&$m[8]?$m[8]:""));
  2850. }
  2851. },$html,-1,$count);
  2852. $html = preg_replace('/<p>\s*<\/p>/u',"", $html); if($html==""){$html="<p>&nbsp;</p>";}
  2853. if(sizeof($images)){
  2854. if((!$this->InHereMode) && sizeof($images)==1){$html.= $images[0]; }
  2855. else{
  2856. $html.="<div class='p_row'>";
  2857. foreach($images as $img){
  2858. $html.="<div class='p_thumb'>".$img."</div>";
  2859. }
  2860. $html.="<div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div>";
  2861. }
  2862. }
  2863. if(sizeof($images_noclick)){ $added_images = $images_noclick; }
  2864. if(sizeof($images_orig_src_list)) { $orig_src_list = $images_orig_src_list; }
  2865. if($do_product_info){
  2866. $html = preg_replace_callback("/\{PRICE\s+([^]]+?)\}/u",
  2867. function($m) use (&$product_info) { $product_info['price']=$m[1];return ""; },$html);
  2868. $html = preg_replace_callback("/\{SHORT\s+([^]]+?)\}/u",
  2869. function($m) use (&$product_info) { $product_info['short']=$m[1];return ""; },$html);
  2870. $html = preg_replace('/<p>\s*<\/p>/u',"", $html);
  2871. if (preg_match('/<h[1-5]>(.+?)<\/h/u',$html,$title)){ $product_info['title']=$title[1]; }
  2872. else { $product_info['title'] = $this->T('商品'); }
  2873. if(!isset($product_info['price'])) $product_info['price']=$this->T('未设置价格');
  2874. $html = preg_replace_callback("/\{PURCHASE\s+([^]]+?)\}/u",function($m) use (&$product_info) {
  2875. return "<a class='purchase_button' href=\"mailto:".$this->T($this->DisplayName)."<".$this->EMail.">?subject=".
  2876. $this->T('购买').' '.$product_info['title'].
  2877. "&body=".$this->T('你好!我想购买').$product_info['title'].urlencode(PHP_EOL.PHP_EOL).
  2878. $this->FullURL().urlencode(PHP_EOL.PHP_EOL)."\">".$m[1]."</a>"; },$html);
  2879. }
  2880. if(preg_match("/(<\/div>|<\/table>|<\/video>)\s*$/u",$html)){$end_wide=true;}
  2881. return $html;
  2882. }
  2883. function ConvertPost(&$post){
  2884. if(!isset($post['html'])){
  2885. $info=[];
  2886. $post['html'] = $this->TranslatePostParts($this->PostProcessHTML($this->ChoosePartsByLanguage($this->PDE->text($this->InsertReplacementSymbols($post['content'], $post)),true),
  2887. $post['images'],
  2888. isset($post['product']), $info,
  2889. $post['original_images'],
  2890. $post['end_wide'],
  2891. $post['wide']));
  2892. if(isset($post['product'])) $post['product']=$info;
  2893. }
  2894. }
  2895. function GetPostTitle(&$post, $h1_only=false, $add_unamed=true){
  2896. if($h1_only){
  2897. if(preg_match('/^#\s+(.*?)$/mu',$post['content'],$m)) return strip_tags($this->TranslatePostParts($m[1]));
  2898. else return NULL;
  2899. }
  2900. if(!isset($post['title'])){
  2901. if(preg_match('/^#{1,6}\s+(.*?)$/mu',$post['content'],$m)){$post['title']=$m[0];}
  2902. else{ $post['title'] = $add_unamed?$this->T('未命名'):"";
  2903. if(preg_match('/(.*)$/mu',$post['content'],$m)){
  2904. $post['title'].=($add_unamed?' (':'').$this->PDE->text($m[1]).($add_unamed?')':''); }
  2905. }
  2906. }
  2907. return strip_tags($this->TranslatePostParts($this->PDE->text($post['title'])));
  2908. }
  2909. function DetectPageType(){
  2910. if ($this->InExperimentalMode) $this->PageType='experimental';
  2911. else if($this->InHereMode) $this->PageType='here';
  2912. else if(isset($_GET['history'])) $this->PageType='history';
  2913. else if(isset($_GET['extras'])) $this->PageType='extras';
  2914. else if(isset($_GET['settings'])) $this->PageType='settings';
  2915. else if(isset($_GET['gallery'])) $this->PageType='gallery';
  2916. else if(isset($_GET['search'])) $this->PageType='search';
  2917. else if(isset($_GET['category'])) $this->PageType='category';
  2918. else if(isset($this->CurrentPostID)) $this->PageType = "post";
  2919. else if(isset($_GET['comments'])) $this->PageType='comments';
  2920. else if(isset($_GET['statistics'])) $this->PageType='statistics';
  2921. else $this->PageType = "main";
  2922. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  2923. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  2924. $this->VisitedHere = $_SESSION[$visited_here];
  2925. }
  2926. function MakePageBegin(&$p){ $title=$this->InExperimentalMode?$this->T($this->ExpTitle):
  2927. ($this->InHereMode?$this->T($this->HereTitle):$this->T($this->Title)) ?>
  2928. <!DOCTYPE html><html lang='zh-Hans-CN'>
  2929. <head>
  2930. <meta charset='utf-8'>
  2931. <meta content="width=device-width, initial-scale=1" name="viewport">
  2932. <title><?=$title?></title>
  2933. <meta property="og:title" content="<?=$title.(isset($p)?(" | ".$this->GetPostTitle($p)):"")?>">
  2934. <?php if(isset($p)&&isset($p['hasi'])&&isset($p['hasi'][0])){?> <meta property="twitter:card" content="summary_large_image" />
  2935. <meta property="og:image" content="<?=(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']==='on'?"https":"http").'://'.$_SERVER['HTTP_HOST'].'/images/thumb/'.$p['hasi'][0]?>"><?php } ?>
  2936. <?php if($this->UseRemoteFont){ ?><style>
  2937. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Regular.otf") format("opentype");font-weight:normal;}
  2938. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Bold.otf") format("opentype");font-weight:bold;}
  2939. </style><?php } ?>
  2940. <link href='styles/main.css' rel='stylesheet' type="text/css">
  2941. <link rel="alternate" type="application/rss+xml" title="<?=$this->T($this->Title);?>" href="?rss=<?=$this->LanguageAppendix;?>" />
  2942. <link rel="alternate" hreflang="zh" href="index.php?<?=$_SERVER['QUERY_STRING']?>" />
  2943. <link rel="alternate" hreflang="en" href="en.php?<?=$_SERVER['QUERY_STRING']?>" />
  2944. <link rel="alternate" hreflang="x-default" href="en.php?<?=$_SERVER['QUERY_STRING']?>" />
  2945. <?php if(isset($this->SelfAuthPath)&&$this->SelfAuthPath!=""){ ?>
  2946. <link rel="authorization_endpoint" href="<?=$this->SelfAuthPath?>" /><?php } ?>
  2947. <noscript><style>.lb.post_access{top:unset;bottom:0;height:2em;} .active_post .lb.post_access{height:100%;}.post label{pointer-events:all;}</style></noscript>
  2948. </head>
  2949. <div class='page'>
  2950. <?php }
  2951. function MakeHeader(&$p){
  2952. $this->MakePageBegin($p) ?>
  2953. <script type='text/javascript'>
  2954. function toggle_mobile_show(a){a.classList.toggle('hidden_m')}
  2955. function ShowWaitingBar(){wait = document.querySelector("#waiting_bar");wait.style.display='';}
  2956. function HideWaitingBar(){wait = document.querySelector("#waiting_bar");wait.style.display='none';}
  2957. <?php if(!$this->InHereMode){ ?>
  2958. function la_auto_grow(element){
  2959. s=window.scrollY;element.style.height="30px";element.style.height=(element.scrollHeight)+"px";window.scroll(0, s);
  2960. }
  2961. function ShowBackdrop(alpha=0.5){
  2962. b = document.getElementById('backdrop');
  2963. b.style="background-color:rgba(0,0,0,"+alpha+");";
  2964. b.style.animation='backdrop_fade_in 0.3s forwards';
  2965. b.style.display = 'block';
  2966. }
  2967. function HideBackdrop(){
  2968. b = document.getElementById('backdrop');
  2969. b.style.animation='backdrop_fade_out 0.3s forwards';
  2970. setTimeout(function(e1){e1.style.display='none';}, 300, b);
  2971. }
  2972. function ShowRightSide(big,elem_to_clone){
  2973. p = document.getElementById('pop_right');
  2974. if(elem_to_clone){
  2975. c = elem_to_clone.cloneNode(true);
  2976. c.id='side_bar_cloned';c.className="";c.style="";
  2977. p.querySelector('._content').appendChild(c);
  2978. }
  2979. p.classList.remove('pop_right','pop_right_big');
  2980. if(big) {p.classList.add('pop_right_big');p.style.animation='pop_slide_in_big 0.3s forwards';}
  2981. else {p.classList.add('pop_right');p.style.animation='pop_slide_in 0.3s forwards';}
  2982. p.style.display='block';
  2983. ShowBackdrop(0.5);
  2984. }
  2985. function HideRightSide(){
  2986. p = document.getElementById('pop_right');
  2987. if(side=p.querySelector('#side_bar_cloned')){
  2988. side.remove();
  2989. }
  2990. put = document.querySelector("#_uploader");
  2991. if(p.classList.contains('pop_right')){p.style.animation='pop_slide_out 0.3s forwards';}
  2992. else{p.style.animation='pop_slide_out_big 0.3s forwards';}
  2993. setTimeout(function(e1, e2){e1.style.display='none';if(e2)e2.style.display='none';}, 300, p, put);
  2994. HideBackdrop();
  2995. }
  2996. function CssNumberID(id){ return "#\\3"+id.substr(0,1)+" "+id.substr(1); }
  2997. function ScrollToPost(id){
  2998. post=null;
  2999. if(!(post = document.querySelector("[data-post-id='"+id+"']"))){
  3000. if(!(post = document.querySelector(CssNumberID(id)))) return; }
  3001. post.scrollIntoView({ behavior: 'smooth', block: 'start'});
  3002. }
  3003. <?php } ?>
  3004. </script><input type='checkbox' class='lpctrl' id='titlectrl'>
  3005. <header<?=$this->InHereMode?' class="exp_h_f"':''?>><div>
  3006. <?php if($this->InHereMode){
  3007. $this->MakeExpNavButtons($p);
  3008. }else{
  3009. $this->MakeNavButtons($p);
  3010. if(isset($p['tid']['header'])){ ?><div style='float:right' class='show_on_print'><?=$this->ChoosePartsByLanguage($p['tid']['header']);?></div><?php }
  3011. echo "<hr class='hidden_m'>";
  3012. } ?>
  3013. <?php if(isset($this->WayBack)){
  3014. $time=(isset($_COOKIE['la_wayback']) && preg_match('/[0-9]{14}/u',$_COOKIE['la_wayback']))?$_COOKIE['la_wayback']:date('YmdHis');
  3015. $year=substr($time,0,4);$month=substr($time,4,2);$day=substr($time,6,2);
  3016. $hour=substr($time,8,2);$minute=substr($time,10,2);?> <div class='text_highlight'>
  3017. &nbsp;<b><span onclick='document.getElementById("wayback_config").classList.toggle("hidden_m")'>
  3018. <div class='wayback_close' onclick='event.stopPropagation()'><a href='<?=$this->GetRedirect()?>&set_wayback=false'>
  3019. <span class='hidden_m'><?=$this->T('退出')?></span>×&nbsp;</a></div>
  3020. + <?=$this->T('正以过去的日期浏览')?></b><div id='wayback_config' class='wayback_expand hidden_m'>
  3021. <select id="wayback_year" name="wayback_year" form="wayback_form"><?php for($y=$this->YearBegin;$y<=$this->YearEnd;$y++){ ?>
  3022. <option value="<?=$y?>"<?=$y==$year?" selected":""?>><?=$y?></option><?php } ?></select>
  3023. <br class='hidden_on_desktop' />
  3024. <select id="wayback_month" name="wayback_month" form="wayback_form"><?php for($y=1;$y<=12;$y++){ ?>
  3025. <option value="<?=$y?>"<?=$y==$month?" selected":""?>><?=$y?></option><?php } ?></select>
  3026. <select id="wayback_day" name="wayback_day" form="wayback_form"><?php for($y=1;$y<=31;$y++){ ?>
  3027. <option value="<?=$y?>"<?=$y==$day?" selected":""?>><?=$y?></option><?php } ?></select>
  3028. <br class='hidden_on_desktop' />
  3029. <select id="wayback_hour" name="wayback_hour" form="wayback_form"><?php for($y=0;$y<=23;$y++){ ?>
  3030. <option value="<?=$y?>"<?=$y==$hour?" selected":""?>><?=$y?></option><?php } ?></select>:
  3031. <select id="wayback_minute" name="wayback_minute" form="wayback_form"><?php for($y=0;$y<=59;$y++){ ?>
  3032. <option value="<?=$y?>"<?=$y==$minute?" selected":""?>><?=$y?></option><?php } ?></select>
  3033. <br class='hidden_on_desktop' />
  3034. <form action="<?=$this->GetRedirect()?>&set_wayback=post" method="post" style='display:none;' id='wayback_form'></form>
  3035. <input type='submit' style='font-weight:normal;border-bottom:none;' class='button clean_a' form='wayback_form'
  3036. id='wayback_see' name='wayback_see' value="<?=$this->T('查看')?> →">
  3037. </div></div><?php } ?>
  3038. </div></header>
  3039. <div id='waiting_bar' style='display:none;'></div>
  3040. <script>ShowWaitingBar();window.addEventListener('load',(event) =>{HideWaitingBar();}); </script>
  3041. <?php if(!$this->InHereMode){ ?>
  3042. <div id='post_menu' style='display:none;' class='pop_menu clean_a'>
  3043. <ul>
  3044. <li><span id='_time_hook' class='smaller'>时间</span>&nbsp;&nbsp;<a href='javascript:HidePopMenu();'>×</a></li>
  3045. <li><a id='share_copy'>⎘<?=$this->T('复制链接')?></a></li>
  3046. <hr />
  3047. <?php if($this->LoggedIn){ ?>
  3048. <li><a id='menu_history'><?=$this->T('历史')?></a>
  3049. <?php if(!isset($this->WayBack) && $this->PageType!='search'){ ?>
  3050. | <a id='menu_edit'><?=$this->T('修改')?></a><?php } ?></li>
  3051. <?php if(!isset($this->WayBack)){ ?><li>
  3052. <a id='menu_refer_copy'><?=$this->T('复制编号')?></a><?php if($this->PageType!='search'){ ?>
  3053. | <a id='menu_refer'><?=$this->T('引用')?></a><?php } ?><br class='hidden_on_desktop' />
  3054. </li>
  3055. <li><a id='menu_rename' href='javascript:ToggleRenameDetails()'><?=$this->T('改名')?></a> |
  3056. <a id='menu_mark' href='javascript:ToggleMarkDetails()'><?=$this->T('标记')?></a></li>
  3057. <li id='mark_details' style='display:none;'><b>
  3058. <a id='mark_set_clear' href='javascript:SetMark(-1);'>_</a>
  3059. <a id='mark_set_0' href='javascript:SetMark(0);'><?=$this->Markers[0]?></a>
  3060. <a id='mark_set_1' href='javascript:SetMark(1);'><?=$this->Markers[1]?></a>
  3061. <a id='mark_set_2' href='javascript:SetMark(2);'><?=$this->Markers[2]?></a>
  3062. <a id='mark_set_3' href='javascript:SetMark(3);'><?=$this->Markers[3]?></a>
  3063. <a id='mark_set_4' href='javascript:SetMark(4);'><?=$this->Markers[4]?></a>
  3064. <a id='mark_set_5' href='javascript:SetMark(5);'><?=$this->Markers[5]?></a>
  3065. <a id='mark_set_6' href='javascript:SetMark(6);'><?=$this->Markers[6]?></a>
  3066. <a id='mark_set_7' href='javascript:SetMark(7);'><?=$this->Markers[7]?></a>
  3067. <a id='mark_set_8' href='javascript:SetMark(8);'><?=$this->Markers[8]?></a>
  3068. </b></li>
  3069. <li id='rename_details' style='display:none;text-align:left;' class='smaller'>
  3070. <form action="" method="post" style='display:none;' id='post_rename_form'></form>
  3071. <input type='text' id='post_rename_name' name='post_rename_name' form="post_rename_form" style='width:9em;'>
  3072. <input class='button' type='submit' form='post_rename_form'
  3073. name='post_rename_confirm' id='post_rename_confirm' value='<?=$this->T('确认')?>'>
  3074. </li><hr /> <?php if(isset($this->MastodonToken)){ ?>
  3075. <li><a id='menu_mastodon_view' class='button' style='display:none;' target='_blank'><?=$this->T('转到')?></a>
  3076. <a id='menu_mastodon' href='javascript:ToggleMastodonDetails()'><?=$this->T('长毛象')?></a></li>
  3077. <li id='mastodon_details' style='display:none;text-align:left;' class='smaller'>
  3078. <a id='menu_mastodon_send' class='button' target='_blank'><?=$this->T('发送')?></a>
  3079. <form action="" method="post" style='display:none;' id='post_mastodon_form'></form>
  3080. <input type='text' id='post_mastodon_url' name='post_mastodon_url' form="post_mastodon_form" style='width:9em;'>
  3081. <input class='button' type='submit' form='post_mastodon_form'
  3082. name='post_mastodon_confirm' id='post_mastodon_confirm' value='<?=$this->T('修改')?>'></li> <?php } ?>
  3083. <hr /><li><a id='menu_delete' class='smaller'><?=$this->T('删除')?></a></li><?php } ?>
  3084. <?php }else{ ?>
  3085. <li><a id='menu_history'><?=$this->T('历史')?></a></li>
  3086. <?php } ?>
  3087. </ul>
  3088. </div>
  3089. <div id='backdrop' style='display:none;' class='backdrop' onclick='HideRightSide();HideBigImage(1);'
  3090. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"></div>
  3091. <div id='pop_right' class='pop_right' onclick='event.stopPropagation()'>
  3092. <div style='text-align:right;position:sticky;top:0;'><a class='clean_a' href='javascript:HideRightSide();'>
  3093. <?=$this->T('关闭')?>→</a></div>
  3094. <?php if($this->LoggedIn && in_array($this->PageType,['main','post'])){ ?>
  3095. <div id='_uploader' style='display:none;'>
  3096. <?php $this->MakeUploader(true); ?>
  3097. <p>&nbsp;</p>
  3098. <?php $this->MakeSideGalleryCode(); ?>
  3099. </div>
  3100. <?php } ?>
  3101. <div class='_content'></div>
  3102. </div>
  3103. <?php } ?>
  3104. <?php
  3105. }
  3106. function ChoosePartsByLanguage($content,$use_p=false){ if(!isset($content)) return $content;
  3107. $split = preg_split('/'.($use_p?'<p>\s*':'').'((en|zh|any)\|(en|zh|any))'.($use_p?'<\/p>\s*':'').'/u',$content, -1,
  3108. PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
  3109. $lang = $this->LanguageAppendix; $last_lang='0'; $reduced="";
  3110. if($split) for($i=0;$i<sizeof($split);$i+=4){
  3111. $this_lang = '0'; if($i+2>=sizeof($split)){ $this_lang = $last_lang; }else{ $this_lang = $split[$i+2]; }
  3112. if($this_lang==$lang || $this_lang=='any'){ $reduced.=$split[$i]; }
  3113. if($i+3<sizeof($split)){ $last_lang = $split[$i+3]; }
  3114. }
  3115. if(!$reduced)$reduced = $content;
  3116. return $reduced;
  3117. }
  3118. function TranslatePostParts($html){
  3119. $html = preg_replace_callback('/>(\s*)([^><]+?)(\s*)</u', function($ma){
  3120. $reduced = $this->ChoosePartsByLanguage($ma[2], false);
  3121. return ">".$ma[1].$this->T($reduced).$ma[3]."<";
  3122. }, $html);
  3123. return $html;
  3124. }
  3125. function MakeNavButtons(&$p){ global $INDEXPHP; $interesting=$this->IsInterestingPost($p); $no_title=isset($p['tid']['first']['no_title']);?>
  3126. <a href='<?=$INDEXPHP?>' class='clean_a hidden_m<?=$no_title?" hidden_on_print":""?>' onclick='ShowWaitingBar()'><b><?=$this->T($this->Title);?></b></a>
  3127. <?=$no_title?"<a class='inline_print'>&nbsp;</a>":""?>
  3128. <label for='titlectrl' id='mtitle'><b><a class='hidden_on_desktop'><?=$this->T($this->ShortTitle)?>...</a></b></label>
  3129. <div class='header_nav'>
  3130. <ul class='mobile_fold hidden_on_print' id='mobile_nav'>
  3131. <li class='hidden_m'><a href='?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  3132. <li class='hidden_on_desktop_force block_m smaller'>&nbsp;</li>
  3133. <li class='hidden_on_desktop_force block_m bigger'>
  3134. <a href='<?=$INDEXPHP?>?part=recent' onclick='ShowWaitingBar()'><?=$this->NotesView?$this->T('备忘录'):$this->T('最近')?></a>
  3135. <?php if($this->LoggedIn){ ?> | <span class='gray invert_a'>
  3136. <a href='<?=$INDEXPHP?>?set_notes_view=<?=$this->NotesView?'0':'1'?>'>N</a>
  3137. <a href='<?=$INDEXPHP?>?comments=all'>@</a> <a href='<?=$INDEXPHP?>?statistics=all'>%</a>
  3138. </span><?php } ?></li>
  3139. <li class='hidden_on_desktop_force block_m bigger'>
  3140. <a href='<?=$INDEXPHP?>?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  3141. <?php $this->SpecialNavigation;if(isset($this->SpecialNavigation) && ($p = &$this->GetPost($this->SpecialNavigation))!=NULL){
  3142. echo $this->GenerateSinglePost($p, false, false, false, false);
  3143. } ?>
  3144. <?php if($this->LanguageAppendix=='zh'){ ?>
  3145. <li class='smaller gray'>
  3146. <a href='<?=$this->GetRedirect(null,'en.php').'&set_language=en'?>' onclick='ShowWaitingBar()'><b>汉语</b>/English</a></li>
  3147. <?php }else { ?>
  3148. <li class='smaller gray'>
  3149. <a href='<?=$this->GetRedirect(null,'index.php').'&set_language=zh'?>' onclick='ShowWaitingBar()'>
  3150. 汉语/<b>English</b></a>
  3151. <br class='hidden_on_desktop' />
  3152. <a id='translate_button' target='_blank'>&nbsp;[Google Translate]&nbsp;</a></li>
  3153. <?php } ?>
  3154. </ul></div>
  3155. <?php
  3156. }
  3157. function MakeExpNavButtons(&$p){ global $INDEXPHP; ?>
  3158. <a href='<?=$INDEXPHP?>' class='hidden_m'>
  3159. <b><?=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle)?></b></a>
  3160. <a class='hidden_on_desktop'
  3161. href='javascript:toggle_mobile_show(document.getElementById("mobile_nav"))'><b class='round_btn'>
  3162. <?=$this->InExperimentalMode?$this->T($this->ExpShortTitle):$this->T($this->HereShortTitle)?></b></a>
  3163. <?php if(!$this->InExperimentalMode){ ?>
  3164. <a <?=$this->HereNumber==1?"class='gray'":("href=".$this->HereLinkFromNumber($this->HereNumber-1))?>>←</a>
  3165. <span><?=$this->HereNumber.'/'.sizeof($this->VisitedHere);?></span>
  3166. <span class='round_btn'>
  3167. <a href='<?=$this->HereNumber==sizeof($this->VisitedHere)?"?random_here=1":$this->HereLinkFromNumber($this->HereNumber+1);?>'>→</a>
  3168. <a href='?random_here=1'><?=$this->T("随机")?></a></span><span class='hidden_m'></span>
  3169. <?php } ?>
  3170. <ul class='hidden_m' id='mobile_nav' style='text-align:center;'>
  3171. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  3172. <li class='hidden_on_desktop block_m'><a href='<?=$INDEXPHP?>'><?=$this->T('主页')?></a></li>
  3173. <?php if($this->InExperimentalMode && isset($this->ExpNavigation) && ($p = &$this->GetPost($this->ExpNavigation))!=NULL){
  3174. echo $this->GenerateSinglePost($p, false, false, false, false);
  3175. }else if($this->InHereMode && isset($this->HereNavigation) && ($p = &$this->GetPost($this->HereNavigation))!=NULL){
  3176. echo $this->GenerateSinglePost($p, false, false, false, false);
  3177. } ?>
  3178. <?php if($this->AllowLanguageChoices){ ?>
  3179. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  3180. <?php if($this->LanguageAppendix=='zh'){ ?>
  3181. <li class='smaller invert_a gray'><a href='<?=$this->GetRedirect().'&set_language=en'?>'><b>汉语</b>/English</a></li>
  3182. <?php }else { ?>
  3183. <li class='smaller invert_a gray'><a href='<?=$this->GetRedirect().'&set_language=zh'?>'>汉语/<b>English</b></a></li>
  3184. <li class='smaller invert_a gray'><a id='translate_button' target='_blank'>&nbsp;Google Translate&nbsp;</a></li>
  3185. <?php } ?>
  3186. <?php } ?>
  3187. </ul>
  3188. <?php
  3189. }
  3190. function MakePostingFieldsV2($reply_to=NULL, $show_hint=false){ $STR="";
  3191. if(isset($this->WayBack)){
  3192. $STR.="<span class='gray'><i>{$this->T('以过去日期浏览时不能发帖。')}</i></span>";
  3193. $this->TFill(2,$STR); $this->TExtra("class='hidden_on_print no_line'"); $this->TRow(); return;
  3194. }
  3195. $STR.="<form action='{$_SERVER['REQUEST_URI']}' method='post' style='display:none;' id='post_form'></form>
  3196. <div class='smaller'><div style='display:".($show_hint?"block":"none")."'>
  3197. <span id='post_hint_text'>{$this->T('继续补充该话题:')}</span></div>
  3198. <div id='post_hint_modify' style='display:none;'>
  3199. <input type='checkbox' name='post_record_edit' value='1' form='post_form' checked> {$this->T('新增历史记录')}</div></div>
  3200. <textarea id='post_content' name='post_content' rows='4' form='post_form'
  3201. onfocus=\"if (value =='{$this->T('有什么想说的')}'){value ='';}la_auto_grow(this);\"
  3202. onblur=\"if (value ==''){value='{$this->T('有什么想说的')}';la_auto_grow(this);}\"
  3203. oninput=\"la_auto_grow(this);\" onload=\"la_auto_grow(this);\">{$this->T('有什么想说的')}</textarea>
  3204. <input class='button' form=\"post_form\" type=\"submit\" name='post_button' value='{$this->T('发送')}'
  3205. onclick='ShowWaitingBar();' />
  3206. <input class='button' form=\"post_form\" type=\"submit\" name='post_button_note' value='{$this->T('备忘')}'
  3207. onclick='ShowWaitingBar();' />
  3208. | <a class='gray smaller pointer' onclick='ShowSideUploader();'>{$this->T('图片')}</a>
  3209. <div style='float:right;'>
  3210. <a class='gray smaller pointer' onclick=\"t=document.querySelector('#post_content');t.value='';la_auto_grow(t);\">
  3211. {$this->T('清空')}</a>
  3212. <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
  3213. </div>
  3214. <input style='display:none;' type=input form='post_form' id='post_edit_target' name='post_edit_target' />
  3215. <script> la_auto_grow(document.getElementById('post_content'));</script>";
  3216. if($reply_to){
  3217. $STR.="<input style='display:none;' type=input form='post_form' id='post_reply_to' name='post_reply_to' value='{$reply_to}' />";
  3218. }
  3219. $this->TFill(2,$STR);$this->TExtra("class='hidden_on_print no_line'"); $this->TRow();
  3220. }
  3221. function MakeLinkedPostsV2(&$p){ $STR="";
  3222. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); if(!$has_ref)return; $count=0;
  3223. $STR.="<input type='checkbox' class='lpctrl' id='fake{$p["id"]}' checked='checked'>";
  3224. $count_product=0;
  3225. $STR.="<div class='linked_posts smaller'>";
  3226. $refs=sizeof($p["refs"]);
  3227. $STR.="<label class='lb ref_count' for='fake{$p["id"]}'>× $refs".$this->T("个引用").":</label><hr />";
  3228. foreach(array_reverse($p['refs']) as &$pr){
  3229. $po = $this->GetPost($pr);
  3230. if(!$this->CanShowPost($po)){ continue; } $count++;
  3231. $this->TBackup();
  3232. $this->MakeSinglePostV2($po, false, true, 0, true, true, false, false, true, false, false);
  3233. $STR.=$this->TRestore(" compact");
  3234. }
  3235. $STR.="</div>";
  3236. $this->TFill(0,$S0);
  3237. $this->TFill(1,$STR,2);$this->TExtra("style='border-bottom:none;'"); $this->TRow();
  3238. }
  3239. function MakeSinglePostV2(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
  3240. $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
  3241. $generate_thumb = false, $is_top = false, $force_hide_long=false){
  3242. $STR=""; $EXTRA="";$S0=""; $S1="";
  3243. $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
  3244. $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
  3245. $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
  3246. $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
  3247. $number = isset($post['number'])?$post['number']:0;
  3248. $title = $generate_anchor?$this->ChoosePartsByLanguage($this->GetPostTitle($post, true)):NULL;
  3249. $this->ConvertPost($post);// NEEDED FOR WIDE;
  3250. $is_wide = (isset($post['wide'])&&$post['wide']) || (isset($post['tid']) && isset($post['tid']['wide']) && $post['tid']['wide']);
  3251. if($show_link && (!$side)){ $this->MakeLinkedPostsV2($post); }
  3252. $EXTRA.="class='post $extra_class_string".($is_deleted?" deleted_post":"").($is_wide?" wide_post_print":"")."'";
  3253. if(!$side) $EXTRA.=(" data-post-id='".$post['id']."'");
  3254. if($is_deleted) $EXTRA.=" data-mark-delete='true'";
  3255. if(!$side&&isset($post['mastodon_url'])) $EXTRA.=(" data-mastodon_url='".$post['mastodon_url']."'");
  3256. //if($is_wide) $EXTRA.=" class=''";
  3257. if(!$side && !$strip_tags && $show_link){ $STR.="<div class='post_menu_button _menu_hook' >+</div>"; }
  3258. $this->TFill(2,$STR);
  3259. $symbol=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:"#";
  3260. $S1.="<a".($symbol!='#'?' class="marked"':'').
  3261. " href='?post={$post['id']}' onclick=\"".(($show_thread_link||$side)?'ShowWaitingBar()':'ClickPost(this.parentNode.parentNode,event,true)')."\">".
  3262. $symbol."<span class='mobile_fold'>".$number."</span>";
  3263. if($ref_count && !$side){
  3264. $S0.="<label class='lb' ".($show_link?"for='fake{$post["id"]}":"")."'><div class='ref_count'>+<span class='hidden_m'>{$ref_count}</span></div></label>";
  3265. }
  3266. if($is_product&&!$generate_anchor){ $STR.="<p class='smaller gray'>".$this->T('商品')."</p>";}
  3267. $STR.=$this->GenerateSinglePost($post, $strip_tags, $generate_anchor, $show_link,
  3268. $generate_thumb,($show_thread_link||$side||$force_hide_long));
  3269. if($show_thread_link && (!$side) && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) && $post['tid']['first']['id']!=$post['id']){
  3270. $STR.="<div class='gray block'>";
  3271. $STR.="<div class='smaller'>{$this->T('回复给主题帖:')}</div>";
  3272. $this->TBackup();
  3273. $this->MakeSinglePostV2($post['tid']['first'], false, false, false, false, false, false,false, true, false, false);
  3274. $STR.=$this->TRestore(" compact");
  3275. $STR.="</div>";
  3276. }
  3277. if($show_reply_count && isset($post['tid'])){
  3278. $STR.="<a class='smaller block invert_a' href='?post={$post['tid']['last']['id']}'>{$post['tid']['count']} {$this->T('个回复')}</a>";
  3279. }
  3280. $this->TFill(2,$STR); $this->TFill(1,$S1); $this->TFill(0,$S0); $this->TExtra($EXTRA); $this->TRow();
  3281. }
  3282. function MakePostSectionV2(&$post){ $STR=""; $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1;
  3283. $this->Anchors = []; if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))) $centerclass='center_slides'; else $centerclass='center';
  3284. if(isset($this->TagID)){ $STR.=<<<EOT
  3285. <style>{$this->CssNumberID($this->TagID)}{display:block;}</style>
  3286. EOT; } $th=NULL; $STR.="<br /><h2>";
  3287. $is_wide = (isset($post['wide'])&&$post['wide']) || ($is_thread && isset($post['tid']['wide']) && $post['tid']['wide']);
  3288. if($is_thread){ $th = $post['tid']; $STR.=$this->T('话题'); }else{ $STR.=$this->T('话题');$this->T('详细'); } $STR.="</h2>";
  3289. $this->TFill(2,$STR); $this->TExtra("class='hidden_on_print no_line'"); $this->TRow();
  3290. $cat = NULL;
  3291. if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
  3292. else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
  3293. $this->MakePostTools();
  3294. if($cat){ $STR=<<<EOT
  3295. <p class='hidden_on_print'><b>{$this->T('分类')}</b> |
  3296. EOT; foreach($cat as $c){ $STR.=("<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "); }
  3297. $STR.="</p>";
  3298. }
  3299. $STR.="<br class='hidden_on_print' />"; $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();$is_reversed=false;
  3300. if($is_thread){ $use_arr = $th['arr']; $hinted=false;
  3301. $last_end_wide = true; $is_reversed=$this->IsReversedThread($th);
  3302. foreach($use_arr as &$p){$use_class="";if($p==$post){$use_class.=" active_post";}
  3303. if($last_end_wide){$use_class.=" last_wide";}
  3304. $make_title = ($p == $post);
  3305. if(isset($p['restart'])){ $STR="<li class='restart'><h3>{$p['restart']} …</h3></li>"; $this->TFill(0,$STR,3); $this->TExtra("class='no_line'"); $this->TRow(); }
  3306. $this->MakeSinglePostV2($p,true,false,$use_class,false, false, false, true, false, false);
  3307. if($make_title){ $STR.='<script>
  3308. document.title+=" | '.addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100))).'"</script>';
  3309. $this->TFill(2,$STR); $this->TExtra("class='no_line'");
  3310. }
  3311. if($is_reversed && !$hinted){ $hinted = true;
  3312. if($this->LoggedIn && (!$this->InHereMode)){
  3313. $STR.="<div class='hidden_on_print'>";
  3314. $STR.=$this->MakePostingFieldsV2($is_thread?$th['last']['id']:$post['id'], true);
  3315. $STR.="</div><br />";
  3316. }
  3317. }
  3318. $last_end_wide = isset($p['end_wide']) && $p['end_wide'];
  3319. }
  3320. }else{
  3321. $this->MakeSinglePostV2($post,true, false,"active_post",false, false, false, true, false, false);
  3322. $STR.='<script>
  3323. document.title+=" | '.addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($post),0,100))).'"</script>';
  3324. $this->TFill(2,$STR); $this->TRow();
  3325. }
  3326. $STR="";
  3327. $class_add=""; if(isset($post['tid']['first']['no_time'])){ $class_add=' hidden_on_print'; }
  3328. $STR.="<div class='smaller align_right$class_add'>
  3329. <span class='gray'>".$this->ReadableTime($post['tid']['first']['id'])."</span>
  3330. <br class='hidden_on_desktop' />".
  3331. $this->ReadableTime(isset($post['tid']['last']['version'])?$post['tid']['last']['version']:$post['tid']['last']['id'])."
  3332. </div>";
  3333. $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow(); $STR="";
  3334. if(!$is_reversed && ($this->LoggedIn && (!$this->InHereMode))){
  3335. $STR.="<div class='hidden_on_print'><br />{$this->MakePostingFieldsV2($is_thread?$th['last']['id']:$post['id'], true)}</div>";
  3336. $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
  3337. }
  3338. if($this->NewsletterEnabled){ $STR=$this->MakeSubscription(); $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow(); }
  3339. //$this->MakeCommentSection($post);
  3340. $STR="";
  3341. if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))){
  3342. $STR.=<<<EOL
  3343. <div class='slides_buttons code' onclick="event.stopPropagation();">
  3344. <a onclick="SlidesFontCheck(-1)">T-</a> <a onclick="SlidesFontCheck(1)">T+</a>&nbsp;
  3345. <a onclick="SlidesStart(null)"><<</a> <a onclick="SlidesCheck(-1);"><</a>
  3346. <a onclick="SlidesStart(1)"><span id="slides_now">1</span>/<span id="slides_total">1</span></a>
  3347. <a onclick="SlidesCheck(1);">></a> <a onclick="SlidesEnd();">X</a>
  3348. </div>
  3349. <script>
  3350. function SlidesStart(from_here){
  3351. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  3352. sdone=0; fp=0; if(from_here){
  3353. urlParams = new URLSearchParams(window.location.search);
  3354. fp = urlParams.get('post');
  3355. }
  3356. document.querySelector("#slides_total").innerText=slides.length; cur=document.querySelector("#slides_now");
  3357. for(i=0;i<slides.length;i++){ slides[i].style.display="none";
  3358. if(from_here && slides[i].dataset.postId==fp){ slides[i].style.display="table-cell";sdone=1; ClickPost(slides[i],0,true); cur.innerText=i+1; }
  3359. } if(!sdone){ slides[0].style.display="table-cell"; ClickPost(slides[0],0,true); cur.innerText=1; }
  3360. c=document.querySelector('.center'); if(!c) return;
  3361. c.classList.remove('center'); c.classList.add('center_slides'); if(c.dataset.fontSize){ c.style.fontSize=c.dataset.fontSize; }
  3362. c=document.querySelector('.left'); if(!c) return; c.style.display="none";
  3363. }
  3364. function SlidesCheck(offset){
  3365. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return; cur=document.querySelector("#slides_now");
  3366. for(i=0;i<slides.length;i++){ if(slides[i].style.display=="table-cell" && slides[i+offset] && (i+offset)>=0){
  3367. slides[i+offset].style.display="table-cell"; slides[i].style.display="none"; ClickPost(slides[i+offset],0,true); cur.innerText=i+offset+1; break;
  3368. }
  3369. }
  3370. }
  3371. function SlidesFontCheck(offset){
  3372. c=document.querySelector('.center_slides'); if(!c) return;
  3373. f=5; if(c.style.fontSize){ f=parseInt(c.style.fontSize); }
  3374. f+=offset; if(f<=0) f=1; if(f>12) f=12; c.style.fontSize=""+f+"vmin"; c.dataset.fontSize=c.style.fontSize;
  3375. }
  3376. function SlidesEnd(){
  3377. c=document.querySelector('.center_slides'); if(!c) return;
  3378. c.classList.remove('center_slides'); c.classList.add('center'); c.style.fontSize="";
  3379. c=document.querySelector('.left'); if(!c) return; c.style.display="inline-block";
  3380. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  3381. for(i=0;i<slides.length;i++){ slides[i].style.display=""; }
  3382. }
  3383. //document.addEventListener("wheel", function(event){ if(event.deltaY>0) SlidesCheck(1); else SlidesCheck(-1); }, { passive: false });
  3384. document.addEventListener("click", function(event){ SlidesCheck(1); });
  3385. document.addEventListener('keydown', function(event) {
  3386. const key = event.key; // "ArrowRight", "ArrowLeft", "ArrowUp", or "ArrowDown"
  3387. switch(key){
  3388. case "ArrowUp": case "ArrowLeft": SlidesCheck(-1); break; case "ArrowDown": case "ArrowRight": SlidesCheck(1); break;
  3389. case "Escape": SlidesEnd(); break;
  3390. }
  3391. });
  3392. </script>
  3393. EOL; $this->TAfter($STR);
  3394. }
  3395. }
  3396. function MakeSubscription($smaller=false){
  3397. $STR="";$STR.="<div class='hidden_on_print".($smaller?" smaller'":"")."'>
  3398. <form action='mailsub.php?subscribe=1' method='post' id='subscribe_form' style='display:none;'></form>
  3399. <br />
  3400. <h".($smaller?"3":"2").">{$this->T("订阅我的新闻")}</h".($smaller?"3":"2").">
  3401. <span class='gray'>{$this->T("输入您的邮件:")}</span>
  3402. <input type='text' id='email_subscribe_name' name='email_subscribe_name' form='subscribe_form' ".
  3403. ($smaller?"style='border-color:#f8ca9b88;background:rgba(0,0,0,0.2);max-width:16em;'":"").">
  3404. <input class='button' form='subscribe_form' type='submit' value={$this->T("订阅")}>
  3405. <br /></div>";
  3406. return $STR;
  3407. }
  3408. function MakeRecentPostsV2($search_term=NULL, $category=NULL){ global $INDEXPHP;
  3409. $STR=""; $tmppinned=$this->SpecialPinned;
  3410. if($this->LoggedIn && $this->NotesView){ $this->SpecialPinned=$this->SpecialPinnedNotes; }
  3411. if(!isset($search_term) && !isset($category) &&
  3412. (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
  3413. $this->CanShowPost($p,true)){
  3414. $this->MakeSinglePostV2($p, true, false, "active_post", false, true, false, false, false, true, false);
  3415. }
  3416. $this->SpecialPinned=$tmppinned;
  3417. if($this->NewsletterEnabled && !isset($category) && !isset($search_term) && !$this->NotesView){
  3418. $STR=$this->MakeSubscription(); $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow(); $STR='';
  3419. }
  3420. $STR.="<br /><h2>".(isset($search_term)?$this->T('搜索'):
  3421. (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
  3422. ($category=='none'?$this->T('未分类'):$this->T($category))):($this->NotesView?$this->T('备忘录'):$this->T('最近')).
  3423. "<span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
  3424. ($this->LoggedIn?" <a href='".$INDEXPHP."?set_notes_view=".($this->NotesView?'0':'1')."'>N</a> ".
  3425. "<a href='".$INDEXPHP."?comments=all'>@</a> <a href='".$INDEXPHP."?statistics=all'>%</a>":"")."</span>")).
  3426. "</h2><br />";
  3427. $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
  3428. if(isset($search_term)){
  3429. $STR.="<form action='".$INDEXPHP."' method='post' style='display:none;' id='search_form'></form>".
  3430. "<input id='search_content' name='search_content' rows='4' form='search_form' type='text' value='$search_term'>".
  3431. "<input class='button' form='search_form' type='submit' name='search_button' value='{$this->T('搜索')}'>";
  3432. $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
  3433. }else if(isset($category)){
  3434. $STR.="<div></div>";
  3435. $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
  3436. }else if($this->LoggedIn){
  3437. $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
  3438. $this->MakePostingFieldsV2(NULL,false);
  3439. }
  3440. $this->PostsPerPage=20;
  3441. $i = 0; $last_end_wide = true;
  3442. if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
  3443. if(!$this->CanShowPost($p,true) || $this->SkipProduct($p)) continue;
  3444. if(isset($p['tid'])){ /* Should always be set. */
  3445. $th = &$p['tid']; if($p['tid']['count']==0) continue;
  3446. if(!isset($search_term)) { $p = &$th['last']; }
  3447. }
  3448. if(isset($search_term)){
  3449. if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
  3450. }else if(isset($category)){
  3451. $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
  3452. (isset($p['categories'])?($p['categories']):[]);
  3453. if ($category=='none') { if($cat!=[]) continue; }
  3454. else{ if ($category=='' || !in_array($category, $cat)) continue; }
  3455. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3456. }else{
  3457. if(in_array($p['id'],
  3458. [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
  3459. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3460. }
  3461. if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
  3462. if($last_end_wide){$use_class="last_wide";}else{$use_class="";}
  3463. $this->MakeSinglePostV2($p, true, false, $use_class, false, !isset($search_term), false, false, false, false, isset($search_term));
  3464. $i++;
  3465. if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
  3466. $last_end_wide = sizeof($p['tid']['arr'])==1 && isset($p['end_wide']) && $p['end_wide'];
  3467. }
  3468. $STR=""; $EXTRA="class='clean_a'"; $STR.="<br /><br />".
  3469. "<a ".($this->CurrentOffset>0?("href='".$INDEXPHP."?offset=".($this->CurrentOffset-1).
  3470. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):"").
  3471. ($this->CurrentOffset==0?" class='gray'":"").">{$this->T('上一页')} ← </a>";
  3472. $STR.=" [ ".($this->CurrentOffset+1)." ] ";
  3473. $STR.="<a href='".$INDEXPHP."?offset=".($this->CurrentOffset+1).
  3474. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'>".
  3475. " → {$this->T('下一页')}</a>";
  3476. $this->TFill(0,$STR,3); $this->TExtra($EXTRA); $this->TExtra("class='no_line'"); $this->TRow();
  3477. }
  3478. function GeneratePage($is_section=false,$extra_classes=""){ $S="";
  3479. $S.="<table class='center print_column".($is_section?" clickable_section":"").($extra_classes)."'><tbody>";
  3480. foreach($this->PAGE as $r){ $S.="<tr ".(isset($r['extra'])?$r['extra']:"").">"; $spantotal=0; $sp="";
  3481. if(isset($r['span0'])){$sp=" colspan='".$r['span0']."'"; $spantotal+=$r['span0']; }else{ $spantotal++; };
  3482. if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[0])){ $S.=$r[0]; } $S.="</td>"; }
  3483. if(isset($r['span1'])){$sp=" colspan='".$r['span1']."'"; $spantotal+=$r['span1']; }else{ $spantotal++; };
  3484. if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[1])){ $S.=$r[1]; } $S.="</td>"; }
  3485. if(isset($r['span2'])){$sp=" colspan='".$r['span2']."'"; $spantotal+=$r['span2']; }else{ $spantotal++; };
  3486. if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[2])){ $S.=$r[2]; } $S.="</td>"; }
  3487. $S.="</tr>";
  3488. }
  3489. $S.="</tbody></table>";
  3490. return $S;
  3491. }
  3492. function GenerateLinkedPosts($ht){
  3493. $ht = preg_replace_callback('/<p>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>(.*)<\/a>[\s]*<\/p>/u',
  3494. function($m){
  3495. if(preg_match('/^\s*<img/u',$m[2])){ return $m[0]; }
  3496. $rp = &$this->GetPost($m[1], false, true);
  3497. $STR=$this->T("未找到该引用。");
  3498. if($rp!==NULL && $this->CanShowPost($rp)){
  3499. $this->TBackup();
  3500. $this->MakeSinglePostV2($rp, false, false, false, false, false, false,false, true, false, false);
  3501. $STR=$this->TRestore(" compact");
  3502. }
  3503. $s="<a class='smaller block' href='?post=".$m[1]."'>".$m[2]."</a><div class='block post gray'>".$STR."</div>";
  3504. return $s;
  3505. },
  3506. $ht
  3507. );
  3508. $ht = preg_replace_callback('/<li>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>PRODUCT\s+(.*)<\/a>[\s]*<\/li>/u',
  3509. function($m){
  3510. $rp = &$this->GetPost($m[1], false, true);
  3511. $s="<div class='product_ref block post ref_compact'><a href='?post=".$m[1]."' class='clean_a' onclick='ShowWaitingBar()'>".
  3512. (($rp!==NULL && $this->CanShowPost($rp))?
  3513. $this->GenerateSinglePost($rp,true,false,false,true,true):$this->T("未找到该引用。")).
  3514. "</a></div>";
  3515. return $s;
  3516. },
  3517. $ht
  3518. );
  3519. return $ht;
  3520. }
  3521. function GenerateSinglePost(&$post, $strip_tags, $generate_anchor=false, $generate_refs=false,
  3522. $generate_thumbs=false, $hide_long = false){
  3523. $this->ConvertPost($post);
  3524. if($generate_anchor){ $this->CreatePostAnchor($post); }
  3525. $ht = $post['html'];
  3526. if(isset($post['mark_value']) && $post['mark_value']==5 && ($generate_thumbs || !$generate_anchor)){
  3527. $ht="<div class='product_thumb'>".$post['images'][0]."</div>".
  3528. "<p class='bold'>".$post['product']['title']."</p>".
  3529. (isset($post['product']['short'])?("<p class='smaller gray'>".$post['product']['short']."</p>"):"").
  3530. "<p class='smaller bold'>".$post['product']['price']."</p>";
  3531. return $ht;
  3532. }
  3533. if($hide_long){
  3534. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>[\s\S]*/u',"<p class='smaller bold'>[".$this->T("阅读更多")."]</p>", $ht);
  3535. }else{
  3536. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>/u',"", $ht);
  3537. }
  3538. if ($strip_tags){
  3539. $ht = strip_tags($ht,'<b><i><h1><h2><h3><h4><p><blockquote><span>');
  3540. $ht = preg_replace('/<p>\s*<\/p>/u',"", $ht);
  3541. $ht = $ht;
  3542. }
  3543. else{
  3544. if($generate_refs) $ht = $this->GenerateLinkedPosts($ht);
  3545. }
  3546. if ($strip_tags && $generate_thumbs){
  3547. $ht="<div class='hide_long'>".$ht."</div>";
  3548. if(isset($post['images']) && isset($post['images'][0])){
  3549. $ht.="<div class='post_ref_images'><ul class='side_thumb ref_thumb'>";
  3550. foreach($post['images'] as $im){
  3551. $ht.="<li class='file_thumb'>".$im."</li>";
  3552. }
  3553. $ht.="</ul></div>";
  3554. }
  3555. }
  3556. return $ht;
  3557. }
  3558. function MakeSinglePostExp(&$post){ ?>
  3559. <li class='post post_dummy'>
  3560. <?=$this->GenerateSinglePost($post, false, false, true, false, false); ?>
  3561. </li>
  3562. <?php
  3563. }
  3564. function MakeSinglePost(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
  3565. $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
  3566. $generate_thumb = false, $is_top = false, $force_hide_long=false){
  3567. $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
  3568. $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
  3569. $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
  3570. $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
  3571. $title = $generate_anchor?$this->ChoosePartsByLanguage($this->GetPostTitle($post, true)):NULL;
  3572. $this->ConvertPost($post);// NEEDED FOR WIDE;
  3573. $is_wide = (isset($post['wide'])&&$post['wide']) || (isset($post['tid']) && isset($post['tid']['wide']) && $post['tid']['wide']);
  3574. ?>
  3575. <?=$title?"<div class='print_title'><h1>".$title."</h1></div>":""?>
  3576. <div class='post<?=isset($extra_class_string)?' '.$extra_class_string:''?>'
  3577. <?=(!$side)?"data-post-id='".$post['id']."'":""?> <?=$is_deleted?"data-mark-delete='true'":""?>
  3578. <?=(!$side&&isset($post['mastodon_url']))?"data-mastodon_url='".$post['mastodon_url']."'":""?>
  3579. <?=$is_wide?" style='column-span:all;'":"";?>>
  3580. <?php if($mark_value>=0 && !$show_link && $mark_value!='P'){?>
  3581. <div class='smaller <?=$is_deleted?"gray":""?>'><?=$mark_value?> <?=$this->T('标记')?></div>
  3582. <?php }
  3583. if(!$side && !$strip_tags && $show_link){?><div class='post_menu_button _menu_hook' >+</div><?php } ?>
  3584. <?php if(!$side && $show_link){ $ref_count=100; ?>
  3585. <a href='?post=<?=$post['id']?>' onclick="<?=$show_thread_link||isset($_GET['search'])?'ShowWaitingBar()':'ClickPost(this.parentNode,event,true)'?>">
  3586. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  3587. <?=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:($ref_count?"":"")?>
  3588. </div>
  3589. </a><?php if($ref_count){ ?>
  3590. <label class='lb post_access' for='fake<?=$post["id"]?>'><div class='ref_count'><?=$ref_count?></div></label><?php }
  3591. } ?>
  3592. <?=$side?"<a href='?post={$post['id']}' onclick='ShowWaitingBar()'>":""?>
  3593. <?php if(!$strip_tags){ $this->MakeLinkedPosts($post); } ?>
  3594. <div class='<?=$side?"":'post_width'?><?=$is_deleted?" deleted_post":""?>'>
  3595. <?php if($is_product&&!$generate_anchor){
  3596. echo "<p class='smaller gray'>".$this->T('商品')."</p>";
  3597. echo "<div class='product_ref clean_a'><a href='?post={$post['id']}'>";} ?>
  3598. <?=$this->GenerateSinglePost($post, $strip_tags, $generate_anchor, true,
  3599. $generate_thumb,($show_thread_link||$side||$force_hide_long)); ?>
  3600. <?php if($is_product&&!$generate_anchor){echo "</a></div>";} ?>
  3601. </div>
  3602. <?=$side?"</a>":""?> <?php
  3603. if($show_thread_link && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) &&
  3604. $post['tid']['first']['id']!=$post['id']){ ?>
  3605. <div class='gray smaller block opt_compact post'>
  3606. <a href='?post=<?=$post['tid']['first']['id']?>' onclick='ShowWaitingBar()'>#423
  3607. <div class='post_access invert_a hover_dark smaller'><?=isset($post['tid']['first']['mark_value'])?
  3608. $this->Markers[$post['tid']['first']['mark_value']]:"→"?></div></a>
  3609. <div class='post_width'><div class='smaller'><?=$this->T('回复给主题帖:')?></div>
  3610. <?=$this->GenerateSinglePost($post['tid']['first'], false, false, false, true, true);?>
  3611. </div>
  3612. </div>
  3613. <?php }
  3614. if($show_reply_count && isset($post['tid'])){ ?>
  3615. <a class='smaller block invert_a' href='?post=<?=$post['tid']['last']['id']?>'><?=$post['tid']['count']?>
  3616. <?=$this->T('个回复')?></a>
  3617. <?php } ?>
  3618. </div>
  3619. <?php
  3620. }
  3621. function MakePostingFields($reply_to=NULL, $show_hint=false){
  3622. if(isset($this->WayBack)){ ?>
  3623. <span class='gray'><i><?=$this->T('以过去日期浏览时不能发帖。')?></i></span>
  3624. <?php return; } ?>
  3625. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='post_form'></form>
  3626. <div class='smaller'><div style='display:<?=$show_hint?"block":"none"?>;'>
  3627. <span id='post_hint_text'><?=$this->T('继续补充该话题:')?></span></div>
  3628. <div id='post_hint_modify' style='display:none;'>
  3629. <input type="checkbox" name="post_record_edit" value="1" form='post_form' checked> <?=$this->T('新增历史记录');?></div></div>
  3630. <textarea id="post_content" name="post_content" rows="4" form='post_form'
  3631. onfocus="if (value =='<?=$this->T('有什么想说的')?>'){value ='';}la_auto_grow(this);"
  3632. onblur="if (value ==''){value='<?=$this->T('有什么想说的')?>';la_auto_grow(this);}"
  3633. oninput="la_auto_grow(this);" onload="la_auto_grow(this);"><?=$this->T('有什么想说的')?></textarea>
  3634. <input class='button' form="post_form" type="submit" name='post_button' value=<?=$this->T('发送')?>
  3635. onclick='ShowWaitingBar();' />
  3636. | <a class='gray smaller pointer' onclick='ShowSideUploader();'><?=$this->T('图片')?></a>
  3637. <div style='float:right;'>
  3638. <a class='gray smaller pointer' onclick='t=document.querySelector("#post_content");t.value="";la_auto_grow(t);'>
  3639. <?=$this->T('清空')?></a>
  3640. <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
  3641. </div>
  3642. <input style='display:none;' type=input form="post_form" id='post_edit_target' name='post_edit_target' />
  3643. <script> la_auto_grow(document.getElementById("post_content"));</script>
  3644. <?php if($reply_to){ ?>
  3645. <input style='display:none;' type=input form="post_form" id='post_reply_to' name='post_reply_to' value='<?=$reply_to?>' />
  3646. <?php } ?>
  3647. <?php
  3648. }
  3649. function MakeCommentPosts(){ global $INDEXPHP;
  3650. if(!$this->LoggedIn) return; ?>
  3651. <h2><?=$this->T('评论')?></h2><div class='spacer'></div>
  3652. <?php if(!$this->CommentEnabled){
  3653. echo "<p><span class='text_highlight'>&nbsp;".$this->T("已关闭评论")."&nbsp;</span></p><br />"; } ?>
  3654. <div class='comment'><ul>
  3655. <?php $i=0;
  3656. foreach(array_reverse($this->Posts) as $p){
  3657. if(!isset($p['comment_to'])) continue;
  3658. if($i < $this->CommentsPerPage * $this->CurrentOffset) {$i++; continue;}
  3659. $ht = $this->GenerateSinglePost($p, false, false, false, false, false);
  3660. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3661. $post_to = $this->GetPost($p['comment_to']); $post_title = $this->GetPostTitle($post_to);
  3662. if(!$post_to) $post_title = "?";
  3663. $mail = "<span class='gray hidden_on_print'>&nbsp;".
  3664. "<a href='mailto:".$p['email']."'>@</a>&nbsp;".
  3665. (isset($p['ip'])?$p['ip']:"?")."&nbsp;<br class='hidden_on_desktop'/>".
  3666. "<a href='$INDEXPHP?post=".$p['comment_to']."'>(".$post_title.")</a></span>";
  3667. echo "<li><p><b>".$name.":</b>".$mail."<br /></p>".$ht."</li>";
  3668. $i++;
  3669. }
  3670. ?>
  3671. </ul><br /></div>
  3672. <?php
  3673. }
  3674. function MakeRecentPosts($search_term=NULL, $category=NULL){ global $INDEXPHP; ?>
  3675. <div class='center' id='div_center'><br class='hidden_on_print' />
  3676. <?php if(!isset($search_term) && !isset($category) &&
  3677. (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
  3678. $this->CanShowPost($p)){
  3679. ?><ul class='print_column list bkg_section'><?php
  3680. $this->MakeSinglePost($p, true, false, "active_post", false, true, false, false, false, true, false);
  3681. ?></ul><br /><?php
  3682. }?>
  3683. <h2><?=isset($search_term)?$this->T('搜索'):
  3684. (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
  3685. ($category=='none'?$this->T('未分类'):$this->T($category))):($this->NotesView?$this->T('备忘录'):$this->T('最近')).
  3686. " <span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
  3687. ($this->LoggedIn?"<a href='$INDEXPHP?comments=all'>@</a> <a href='$INDEXPHP?statistics=all'>%</a>":"")."</span>")?></h2><br />
  3688. <?php if(isset($search_term)){ ?>
  3689. <form action="<?=$INDEXPHP?>" method="post" style='display:none;' id='search_form'></form>
  3690. <input id="search_content" name="search_content" rows="4" form='search_form' type='text' value='<?=$search_term?>'>
  3691. <input class='button' form="search_form" type="submit" name='search_button' value=<?=$this->T('搜索')?>
  3692. <?php }else if(isset($category)){ ?>
  3693. <div></div>
  3694. <?php }else if($this->LoggedIn){ ?>
  3695. <div class='post_box_top _input_bundle'>
  3696. <?php $this->MakePostingFields(NULL,false); ?>
  3697. </div>
  3698. <?php } ?>
  3699. <ul class='print_column list bkg_recent'>
  3700. <?php
  3701. $i = 0; $last_end_wide = true;
  3702. if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
  3703. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  3704. if(isset($p['tid'])){ /* Should always be set. */
  3705. $th = &$p['tid']; if($p['tid']['count']==0) continue;
  3706. if(!isset($search_term)) { $p = &$th['last']; }
  3707. }
  3708. if(isset($search_term)){
  3709. if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
  3710. }else if(isset($category)){
  3711. $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
  3712. (isset($p['categories'])?($p['categories']):[]);
  3713. if ($category=='none') { if($cat!=[]) continue; }
  3714. else{ if ($category=='' || !in_array($category, $cat)) continue; }
  3715. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3716. }else{
  3717. if(in_array($p['id'],
  3718. [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
  3719. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3720. }
  3721. if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
  3722. if($last_end_wide){$use_class="last_wide";}else{$use_class="";}
  3723. $this->MakeSinglePost($p, true, false, $use_class, false, !isset($search_term), false, false, false, false, isset($search_term));
  3724. $i++;
  3725. if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
  3726. $last_end_wide = sizeof($p['tid']['arr'])==1 && isset($p['end_wide']) && $p['end_wide'];
  3727. }?>
  3728. </ul>
  3729. <div class='page_selector clean_a'>
  3730. <hr />
  3731. <a <?=$this->CurrentOffset>0?("href='".$INDEXPHP."?offset=".($this->CurrentOffset-1).
  3732. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):""?>
  3733. <?=$this->CurrentOffset==0?"class='gray'":""?>><?=$this->T('上一页')?> ←</a>
  3734. <?=$this->CurrentOffset+1?>
  3735. <a href='<?=$INDEXPHP?>?offset=<?=($this->CurrentOffset+1).
  3736. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))?>'>
  3737. → <?=$this->T('下一页')?></a>
  3738. </div>
  3739. </div>
  3740. <?php
  3741. }
  3742. function MakeLinkedPosts(&$p){
  3743. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); if(!$has_ref)return; $count=0;?>
  3744. <input type='checkbox' class='lpctrl' id='fake<?=$p["id"]?>' checked='checked'>
  3745. <div class='linked_posts smaller'>
  3746. <ul><?php $count_product=0;
  3747. foreach(array_reverse($p['refs']) as &$pr){
  3748. $po = $this->GetPost($pr);
  3749. if(!$this->CanShowPost($po)){ continue; } $count++;
  3750. $this->MakeSinglePost($po, false, true, "post_preview invert_a", true, false, false, false, true, false, false);
  3751. }
  3752. ?></ul>
  3753. </div>
  3754. <?php
  3755. }
  3756. function MakeLinkedPostsExp(&$p){
  3757. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); ?>
  3758. <div class='center_exp post_dummy smaller'>
  3759. <hr />
  3760. <?php if(!$this->InExperimentalMode){ ?>
  3761. <h3<?=$has_ref?"":" class='gray'"?>><?=$this->T('链接')?></h3>
  3762. <?php if($has_ref){ ?>
  3763. <div class='smaller'><?=sizeof($p['refs'])?> <?=$this->T('个引用:')?></div>
  3764. <ul><?php $count_product=0;
  3765. foreach(array_reverse($p['refs']) as &$pr){
  3766. echo "<li class='post_dummy'><a href='?post=".$pr."'>".$this->T($this->GetPostTitle($this->GetPost($pr),false)).
  3767. "</a></li>";
  3768. }
  3769. ?></ul>
  3770. <?php if($count_product){ ?> <span class='smaller'><?=$this->T('和').' '.$count_product.' '.$this->T('个商品')?></span> <?php }
  3771. }else{ ?>
  3772. <div class='gray smaller'><?=$this->T('没有帖子链接到这里。')?></div>
  3773. <?php } }?>
  3774. <div style='margin-bottom:4rem;'>&nbsp;</div>
  3775. </div>
  3776. <?php
  3777. }
  3778. function MakePostHistoryList(&$ah, &$post,$version=NULL, $show_latest=true){
  3779. $latest_ver=isset($post['version'])?$post['version']:$post['id'];
  3780. $can_show=1; if(isset($this->WayBack) && $latest_ver>$this->WayBack) $can_show=0;
  3781. $title = NULL; if(!isset($ah) || ($show_latest && $can_show)) { $title=$this->T($this->GetPostTitle($post, false)); }
  3782. else{ $ver = &$ah['list'][sizeof($ah['list'])-1]; $title= $this->GetPostTitle($ver); }
  3783. if(!isset($title)) $title=$this->T('未命名');
  3784. if(!isset($ah)){ ?>
  3785. <h2><?=$this->T('没有历史记录')?></h2>
  3786. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$post['id']?>'><?=$title?></a></span><br />
  3787. <?php }else{ ?>
  3788. <h2><?=$this->T('历史记录')?></h2>
  3789. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$ah['id']?>'><?=$title?></a></span><br />
  3790. <div class='list'><ul>
  3791. <?php if($show_latest && $can_show){ $post['history_displayed']=1; ?>
  3792. <li class='<?=isset($version)&&$version==$latest_ver?" post_current_row bold":""?>' style='list-style:"";'>
  3793. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$latest_ver?>'><?=$this->ReadableTime($latest_ver)?></a>
  3794. <span class='smaller gray'><?=$this->T('长度').' '.strlen($post['content'])?></span>
  3795. <?php if(isset($post['merged_from'][0])){ ?><ul><?php foreach($post['merged_from'] as $from){
  3796. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3797. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3798. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3799. <?=$this->GetPostTitle($ver);?></a>
  3800. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3801. <?php } ?></ul><?php } ?>
  3802. <?php if(isset($post['merged_thread'][0][0])){ $pm=$post['merged_thread'][0][0];
  3803. $mah = &$this->GetArchiveHandle($pm);
  3804. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3805. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  3806. <span class='smaller gray'><?=sizeof($post['merged_thread'][0]);?> <?=$this->T('个帖子')?></span></li></ul>
  3807. <?php } ?>
  3808. </li><?php } ?>
  3809. <?php if(isset($ah['list'][0])) foreach(array_reverse($ah['list']) as &$ver){
  3810. if(isset($this->WayBack) && $ver['version']>$this->WayBack) continue;
  3811. if(isset($ver['history_displayed']) && $ver['history_displayed']) continue; ?>
  3812. <li<?=isset($version)&&$version==$ver['version']?" class='post_current_row bold'":""?>>
  3813. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$ver['version']?>'><?=$this->ReadableTime($ver['version'])?></a>
  3814. <span class='smaller gray'> <?=$this->T('长度').' '.strlen($ver['content'])?></span>
  3815. <?php if(isset($ver['merged_thread'][0][0])){ $pm=$ver['merged_thread'][0][0];
  3816. $mah = &$this->GetArchiveHandle($pm); $mver = &$this->GetPost($pm);
  3817. if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3818. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  3819. <span class='smaller gray'> <?=sizeof($ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></li></ul>
  3820. <?php } if(isset($ver['merged_from'][0])){ ?><ul><?php foreach($ver['merged_from'] as $from){
  3821. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3822. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3823. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3824. <?=$this->GetPostTitle($ver);?></a>
  3825. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3826. <?php } ?></ul></li><?php } ?>
  3827. <?php } ?></ul></div>
  3828. <?php } ?>
  3829. <?php
  3830. }
  3831. function MakePostDiff(&$this_ver, &$last_ver){
  3832. if(!isset($this_ver)){ ?>
  3833. <h2 class='gray'><?=$this->T('版本不存在')?></h2>
  3834. <?php }else{ ?>
  3835. <h2><?=$this->T('差异')?></h2>
  3836. <?php if(isset($this_ver['merged_thread']) && isset($this_ver['merged_thread'][0][0])){
  3837. $pm=$this_ver['merged_thread'][0][0]; $mah = &$this->GetArchiveHandle($pm);
  3838. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3839. <p><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver)?></a> <?=$this->T('并入这里')?>
  3840. <br /><span class='smaller gray'> <?=sizeof($this_ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></p>
  3841. <?php }else{ ?>
  3842. <table class='diff_table'><thead>
  3843. <tr><td><?php if(!isset($last_ver)){ ?><?=$this->T('没有更旧的版本')?><?php }else{ ?>
  3844. <?=$this->T('上一个版本')?><br /><?=$this->ReadableTime($last_ver['version'])?><?php } ?></td>
  3845. <td class='text_highlight bold'><?=$this->T('选择的版本')?><br /><?=$this->ReadableTime($this_ver['version'])?></td></tr>
  3846. </thead><tbody>
  3847. <tr><td><pre><?=isset($last_ver)?$last_ver['content']:""?></pre></td><td><pre><?=$this_ver['content']?></pre></td></tr>
  3848. </tbody>
  3849. </table>
  3850. <?php } ?>
  3851. <br /><a class='smaller' href='?post=<?=$this_ver['id']?>&set_wayback=<?=isset($this_ver['version'])?$this_ver['version']:$this_ver['id']?>'><?=$this->T('前往该版本时间')?> ←</a>
  3852. <?php } ?>
  3853. <?php
  3854. }
  3855. function MakePostHistory(&$post, $version=NULL){
  3856. $ah = &$this->GetArchiveHandle($this->CurrentPostID);
  3857. $p = &$post; if(!isset($post)){ $p=&$ah['list'][0]; }
  3858. $show_latest = isset($ah)?(!isset($ah['list'][sizeof($ah['list'])-1]['merged_into'])):true;
  3859. ?>
  3860. <div class='left mobile_fold history' id='div_left'>
  3861. <?php if (isset($version)){
  3862. $this->MakePostHistoryList($ah, $p, $version, $show_latest);
  3863. }else{ echo "&nbsp;"; } ?>
  3864. </div>
  3865. <div class='center history' id='div_center'>
  3866. <?php if (!isset($version)){
  3867. $this->MakePostHistoryList($ah, $p, NULL, $show_latest);
  3868. }else{
  3869. $this_ver = NULL; $next_ver = NULL; $last_ver=NULL;
  3870. $this_ver = &$this->GetArchiveVersion($ah, $version, $next_ver, $last_ver);
  3871. if(!isset($this_ver)){$this_ver = $p; $last_ver=$ah['list'][sizeof($ah['list'])-1];}
  3872. $this->MakePostDiff($this_ver, $last_ver, $p);
  3873. } ?>
  3874. </div>
  3875. <?php
  3876. }
  3877. function MakeCommentSection(&$post){ global $INDEXPHP;
  3878. if(!$this->CommentEnabled){ return; }
  3879. $to_post = isset($post['tid'])?$post['tid']['first']:$post;
  3880. $comment_count = (isset($to_post['comments']) && isset($to_post['comments'][0]))?count($to_post['comments']):0;
  3881. ?><div class='comment'>
  3882. <br /><h2><?=$this->T('评论')?> (<?=$comment_count;?>)</h2><div class='spacer'></div>
  3883. <?php if($comment_count) { echo "<ul>";
  3884. foreach($to_post['comments'] as $p){
  3885. $ht = $this->GenerateSinglePost($p, false, false, false, false, false);
  3886. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3887. $mail = $this->LoggedIn?("<span class='gray clean_a hidden_on_print'>&nbsp;".
  3888. "<a href='mailto:".$p['email']."'>@</a>&nbsp;</span>"):"";
  3889. echo "<li><p><b>".$name.":</b>".$mail."</p>".$ht."</li>";
  3890. }
  3891. echo "</ul>";
  3892. } else {
  3893. echo $this->T('还没有评论');
  3894. } ?>
  3895. <div class='hidden_on_print'>
  3896. <div class='spacer'></div>
  3897. <form action="<?=$INDEXPHP?>?post=<?=$this->CurrentPostID?>&comment_to=<?=$to_post['id']?>"
  3898. method="post" style="display:none;" id="comment_form"></form>
  3899. <p><a class='text_highlight bold clean_a'
  3900. onclick='document.getElementById("comment_box").style.display="block";this.parentNode.style.display="none"'>
  3901. &nbsp;<?=$this->T('写评论');?>&nbsp;</a></p>
  3902. <div id='comment_box' style='display:none;'>
  3903. <p class='gray' style='margin-bottom:0.5em;'><?=$this->T('您的邮箱不会公开展示。');?></p>
  3904. <table style='white-space:nowrap;'>
  3905. <tr><td colspan='2'>
  3906. <textarea id="comment_box" name="comment_box" rows="4" class='full_box' form='comment_form'
  3907. oninput="CommentUpdated();" ></textarea>
  3908. </td></tr>
  3909. <tr><td><?=$this->T('电子邮件')?>*</td><td><?=$this->T('称呼')?>*</td></tr>
  3910. <tr><td><input type="text" form="comment_form" id='comment_email' name='comment_email'
  3911. class='full_box' oninput="CommentUpdated();" /></td>
  3912. <td><input type="text" form="comment_form" id='comment_name' name='comment_name'
  3913. class='full_box' oninput="CommentUpdated();" /></td></tr>
  3914. <tr><td colspan='2'><?=$this->T('个人网站')?></td></tr>
  3915. <tr><td colspan='2'>
  3916. <input type="text" form="comment_form" id='comment_link' name='comment_link'
  3917. class='full_box' oninput="CommentUpdated();" />
  3918. </td></tr>
  3919. <tr><td colspan='2'>
  3920. <div class='spacer'></div>
  3921. <input class='button text_highlight bigger' type='submit' form='comment_form'
  3922. name='comment_confirm' id='comment_confirm' value='&nbsp;<?=$this->T('发送')?>&nbsp;'>
  3923. </td></tr>
  3924. </table></div>
  3925. <script>
  3926. const IsValidEmail = (email) => {
  3927. return String(email).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
  3928. };
  3929. function IsValidHttpUrl(string) {
  3930. let url; try{ url = new URL(string); } catch (_) { return false; }
  3931. return url.protocol === "http:" || url.protocol === "https:";
  3932. }
  3933. var cbox = document.getElementById('comment_box');
  3934. var cemail = document.getElementById('comment_email');
  3935. var cname = document.getElementById('comment_name');
  3936. var clink = document.getElementById('comment_link');
  3937. var cconfirm = document.getElementById('comment_confirm');
  3938. function CommentUpdated(){
  3939. cconfirm.disabled=true;
  3940. if (cemail.value!="" && IsValidEmail(cemail.value) &&
  3941. cbox.innerText.length>2 && cname.value.length>2 &&
  3942. clink.value=="" || IsValidHttpUrl(clink.value)){
  3943. cconfirm.removeAttribute("disabled");
  3944. }
  3945. }
  3946. CommentUpdated();
  3947. </script>
  3948. </div>
  3949. </div>
  3950. <?php
  3951. }
  3952. function MakeInterestingSection(&$th){
  3953. $this->Anchors = [];
  3954. $c = &$th['first']['content'];
  3955. $this->ConvertPost($th['first']);
  3956. $ht = $th['first']['html'];
  3957. ?>
  3958. <script>function ClickImage(post_access){im=post_access.querySelector('img');if(im){im.click();}}</script>
  3959. <div class='center_full' id='div_center'>
  3960. <?php $this->MakePostTools(); ?>
  3961. <?php $cat = NULL;
  3962. if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; }
  3963. if($cat){ ?>
  3964. <p><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  3965. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  3966. <?php } ?>
  3967. <h2 class='hidden_on_print'><?=$this->T('有趣')?>
  3968. <a class='gray clean_a' href='?post=<?=$th['first']['id']?>'>→</a></h2>
  3969. <ul><li class='post' data-post-id='<?=$th['first']['id']?>'>
  3970. <div class='post_menu_button _menu_hook' onclick='ShowPostMenu(this.parentNode);'>+</div><?=$ht?>
  3971. <?php if(isset($th['first']['refs'][0])){ ?><p class='smaller'><?=$this->T('引用')?>: </p><ul class='smaller'>
  3972. <?php foreach($th['first']['refs'] as $ref){
  3973. $po = $this->GetPost($ref);
  3974. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  3975. if(!$this->CanShowPost($po)){ continue; }
  3976. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  3977. } ?>
  3978. </ul><?php } ?>
  3979. <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  3980. <div class='hidden_on_print'><br />
  3981. <?php $this->MakePostingFields($th['last']['id'], true);?><br />
  3982. </div>
  3983. <?php } ?>
  3984. <table><thead><tr><?php foreach($th['interesting'] as $header){ ?>
  3985. <td><?=$this->T($header);?></td>
  3986. <?php } ?><td></td></tr></thead><tbody class='interesting_tbody'>
  3987. <?php $plist = array_reverse(array_slice($th['arr'],1));
  3988. foreach($plist as &$p){
  3989. $this->ConvertPost($p);
  3990. $mark_value = isset($p['mark_value'])?$this->Markers[$p['mark_value']]:-1;
  3991. $ref_count = isset($p['refs'])?sizeof($p['refs']):0;
  3992. $is_current = $p['id']==$this->CurrentPostID;
  3993. $is_deleted = (isset($p['mark_delete'])&&$p['mark_delete']); ?>
  3994. <tr class='<?=$is_current?"post_current_row":""?><?=$is_deleted?" deleted_post":""?>'
  3995. data-post-id='<?=$p['id']?>' <?=$is_deleted?"data-mark-delete='true'":""?>
  3996. onDblClick='ClickImage(this)'><td>
  3997. <?php if($ref_count){ ?>
  3998. <div class='post_access ref_count'><?=$ref_count?></div>
  3999. <?php } ?></a>
  4000. <?=$p['html'];?>
  4001. <a class='_menu_hook clean_a post_menu_button' onclick='ShowPostMenu(this.parentNode.parentNode);'>+</a>
  4002. <a <?=$is_current?"":("href='?post=".$p['id']."' onclick='ShowWaitingBar()'");?> class='clean_a paa'>
  4003. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  4004. <?=isset($p['mark_value'])?$this->Markers[$p['mark_value']]:($ref_count?"":"→")?>
  4005. </div></td></tr>
  4006. <?php if($is_current && $ref_count>0){ ?><tr class='post_current_row'><td><p>&nbsp;</p><ul class='smaller'>
  4007. <?php foreach($p['refs'] as $ref){
  4008. $po = $this->GetPost($ref);
  4009. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  4010. if(!$this->CanShowPost($po)){ continue; }
  4011. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  4012. } ?>
  4013. </ul></td></tr><?php } ?>
  4014. <?php } ?>
  4015. </tbody></table>
  4016. </li></ul>
  4017. <br />
  4018. <?php $this->MakeCommentSection($th['first']); ?>
  4019. </div>
  4020. <?php return true;
  4021. }
  4022. function CssNumberID($id){
  4023. return "#\\3".substr($id,0,1)." ".substr($id,1);
  4024. }
  4025. function MakePostTools(){
  4026. if($this->LoggedIn && !isset($this->WayBack)){ $STR=<<<EOT
  4027. <div class='smaller gray hidden_on_print clean_a'>
  4028. <a id='merge_cancel' href='javascript:{TogglePostSelectMode(false,true);ToggleThreadMerge(false,true);}'>
  4029. {$this->T('工具')}</a>:<div class='hidden_m' style='display:inline'>
  4030. <span id='merge_post_btn'><a href='javascript:TogglePostSelectMode()'>{$this->T('合并帖子')}</a></span>
  4031. | <span id='merge_thread_btn'><a href='javascript:ToggleThreadMerge()'>{$this->T('合并话题')}</a></span>
  4032. </div>
  4033. <select class='hidden_on_desktop' id='merge_select'
  4034. onchange="if(this.selectedIndex==1){TogglePostSelectMode(true);}else if(this.selectedIndex==2){ToggleThreadMerge(true);}">
  4035. <option value='-1' selected>--</option>
  4036. <option value='1'>{$this->T('合并帖子')}</option>
  4037. <option value='2'>{$this->T('合并话题')}</option></select>
  4038. <div style='display:none;' id='merge_post_dialog' class='text_highlight small_pad align_right'>
  4039. <div style='display:inline;'>{$this->T('将合并')} <span id='merge_post_count'></span> {$this->T('个帖子')}</div>
  4040. <span class='clean_a bold align_right'><a id='merge_post'>&nbsp;{$this->T('执行')}</a></span></div>
  4041. <div style='display:none;overflow:auto' id='merge_thread_dialog' class='text_highlight small_pad align_right'>
  4042. <div style='display:inline;'>{$this->T('合并到话题')}</div>
  4043. <input id="merge_thread_target" type="text" style="width:9em;display:inline" onChange='ThreadMergeInput(this);' onInput='ThreadMergeInput(this);'>
  4044. <span class='clean_a bold align_right'><a id='merge_thread'>&nbsp;{$this->T('执行')}</a></span></div>
  4045. </div><div class='spacer hidden_on_print'></div>
  4046. EOT;
  4047. }
  4048. $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
  4049. }
  4050. function MakeSidebar(){ ?>
  4051. <div class='left mobile_fold'><?php if(isset($this->SpecialSidebar) && ($p = &$this->GetPost($this->SpecialSidebar))!=NULL){
  4052. ?><span class='gray smaller'><br /></span><?php
  4053. //echo $this->GenerateSinglePost($p, false, false, false, false);
  4054. }?>
  4055. <div class='wayback_link clean_a smaller'><span class='gray'><br /><?=$this->T('工具')?></span><ul>
  4056. <li><a href='?search=' onclick='ShowWaitingBar()' class='bigger'><?=$this->T('搜索')?></a></li>
  4057. <li><?php if(!isset($this->WayBack)){ ?>
  4058. <a href='<?=$this->GetRedirect()?>&set_wayback=true'><?=$this->T('以过去的日期浏览')?></a>
  4059. <?php }else{ ?><a href='<?=$this->GetRedirect()?>&set_wayback=false'><?=$this->T('回到当前日期')?></a><?php } ?></li>
  4060. <li><a href='<?=$this->GetRedirect()?>&toggle_font=true'>
  4061. <?=$this->T('切换字体')?>: <?=$this->T($this->UseRemoteFont?"远程":"本地");?></a></li>
  4062. <li><a rel="alternate" type="application/rss+xml" href="?rss=<?=$this->LanguageAppendix;?>" />RSS/Atom<sup><?=$this->LanguageAppendix;?></sup></a></li>
  4063. </ul>
  4064. </div>
  4065. <?php if($this->NewsletterEnabled){ $STR=$this->MakeSubscription(1); echo $STR; }?>
  4066. <br />
  4067. <hr class="hidden_on_desktop" />
  4068. </div>
  4069. <?php }
  4070. function MakePostSection(&$post){ $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1;
  4071. $this->Anchors = []; if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))) $centerclass='center_slides'; else $centerclass='center';
  4072. if(isset($this->TagID)){ ?><style><?=$this->CssNumberID($this->TagID);?>{display:block;}</style><?php } ?>
  4073. <div class='<?=$centerclass;?>' id='div_center'><br class='hidden_on_print' />
  4074. <h2 class='hidden_on_print'>
  4075. <?php $th=NULL;
  4076. $is_wide = (isset($post['wide'])&&$post['wide']) || ($is_thread && isset($post['tid']['wide']) && $post['tid']['wide']);
  4077. if($is_thread){ $th = $post['tid'];?> <?=$this->T('话题')?> <?php }else{ ?> <?=$this->T('详细')?>
  4078. <?php } ?></h2>
  4079. <?php $cat = NULL;
  4080. if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
  4081. else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
  4082. $this->MakePostTools();
  4083. if($cat){ ?>
  4084. <p class='hidden_on_print'><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  4085. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  4086. <?php } ?><br class='hidden_on_print' />
  4087. <ul class='print_column bkg_section'>
  4088. <?php $is_reversed=false;
  4089. if($is_thread){
  4090. $use_arr = $th['arr']; $hinted=false;
  4091. $last_end_wide = true; $is_reversed=$this->IsReversedThread($th);
  4092. foreach($use_arr as &$p){$use_class="";if($p==$post){$use_class.=" active_post";}
  4093. if($last_end_wide){$use_class.=" last_wide";}
  4094. $make_title = ($p == $post);
  4095. if(isset($p['restart'])){ ?>
  4096. <li class='restart'><h3><?=$p['restart']?></h3></li><?php }
  4097. $this->MakeSinglePost($p,true,false,$use_class,false, false, false, true, false, false);
  4098. if($make_title){?>
  4099. <script>
  4100. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  4101. </script>
  4102. <?php } if($is_reversed && !$hinted){ ?><?php $hinted = true;
  4103. if($this->LoggedIn && (!$this->InHereMode)){ ?>
  4104. <div class='hidden_on_print'>
  4105. <?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?></div><br />
  4106. <?php } }
  4107. $last_end_wide = isset($p['end_wide']) && $p['end_wide'];
  4108. }
  4109. }else{
  4110. $this->MakeSinglePost($post,true, false,"active_post",false, false, false, true, false, false);
  4111. ?><script>
  4112. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($post),0,100)))?>";
  4113. </script><?php
  4114. } $class_add=""; if(isset($post['tid']['first']['no_time'])){ $class_add=' hidden_on_print'; } ?>
  4115. </ul>
  4116. <div class='smaller align_right<?=$class_add;?>'>
  4117. <span class='gray'><?=$this->ReadableTime($post['tid']['first']['id']);?></span>
  4118. <br class='hidden_on_desktop' /><?=$this->ReadableTime(isset($post['tid']['last']['version'])?
  4119. $post['tid']['last']['version']:$post['tid']['last']['id']);?>
  4120. </div>
  4121. <?php if(!$is_reversed && ($this->LoggedIn && (!$this->InHereMode))){ ?>
  4122. <div class='hidden_on_print'>
  4123. <br /><?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?>
  4124. </div>
  4125. <?php }
  4126. $this->MakeCommentSection($post);
  4127. ?>
  4128. </div>
  4129. <?php if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))){ ?>
  4130. <div class='slides_buttons code' onclick="event.stopPropagation();">
  4131. <a onclick="SlidesFontCheck(-1)">T-</a> <a onclick="SlidesFontCheck(1)">T+</a>&nbsp;
  4132. <a onclick="SlidesStart(null)"><<</a> <a onclick="SlidesCheck(-1);"><</a>
  4133. <a onclick="SlidesStart(1)"><span id="slides_now">1</span>/<span id="slides_total">1</span></a>
  4134. <a onclick="SlidesCheck(1);">></a> <a onclick="SlidesEnd();">X</a>
  4135. </div>
  4136. <script>
  4137. function SlidesStart(from_here){
  4138. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  4139. sdone=0; fp=0; if(from_here){
  4140. urlParams = new URLSearchParams(window.location.search);
  4141. fp = urlParams.get('post');
  4142. }
  4143. document.querySelector("#slides_total").innerText=slides.length; cur=document.querySelector("#slides_now");
  4144. for(i=0;i<slides.length;i++){ slides[i].style.display="none";
  4145. if(from_here && slides[i].dataset.postId==fp){ slides[i].style.display="table-cell";sdone=1; ClickPost(slides[i],0,true); cur.innerText=i+1; }
  4146. } if(!sdone){ slides[0].style.display="table-cell"; ClickPost(slides[0],0,true); cur.innerText=1; }
  4147. c=document.querySelector('.center'); if(!c) return;
  4148. c.classList.remove('center'); c.classList.add('center_slides'); if(c.dataset.fontSize){ c.style.fontSize=c.dataset.fontSize; }
  4149. c=document.querySelector('.left'); if(!c) return; c.style.display="none";
  4150. }
  4151. function SlidesCheck(offset){
  4152. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return; cur=document.querySelector("#slides_now");
  4153. for(i=0;i<slides.length;i++){ if(slides[i].style.display=="table-cell" && slides[i+offset] && (i+offset)>=0){
  4154. slides[i+offset].style.display="table-cell"; slides[i].style.display="none"; ClickPost(slides[i+offset],0,true); cur.innerText=i+offset+1; break;
  4155. }
  4156. }
  4157. }
  4158. function SlidesFontCheck(offset){
  4159. c=document.querySelector('.center_slides'); if(!c) return;
  4160. f=5; if(c.style.fontSize){ f=parseInt(c.style.fontSize); }
  4161. f+=offset; if(f<=0) f=1; if(f>12) f=12; c.style.fontSize=""+f+"vmin"; c.dataset.fontSize=c.style.fontSize;
  4162. }
  4163. function SlidesEnd(){
  4164. c=document.querySelector('.center_slides'); if(!c) return;
  4165. c.classList.remove('center_slides'); c.classList.add('center'); c.style.fontSize="";
  4166. c=document.querySelector('.left'); if(!c) return; c.style.display="inline-block";
  4167. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  4168. for(i=0;i<slides.length;i++){ slides[i].style.display=""; }
  4169. }
  4170. //document.addEventListener("wheel", function(event){ if(event.deltaY>0) SlidesCheck(1); else SlidesCheck(-1); }, { passive: false });
  4171. document.addEventListener("click", function(event){ SlidesCheck(1); });
  4172. document.addEventListener('keydown', function(event) {
  4173. const key = event.key; // "ArrowRight", "ArrowLeft", "ArrowUp", or "ArrowDown"
  4174. switch(key){
  4175. case "ArrowUp": case "ArrowLeft": SlidesCheck(-1); break; case "ArrowDown": case "ArrowRight": SlidesCheck(1); break;
  4176. case "Escape": SlidesEnd(); break;
  4177. }
  4178. });
  4179. </script>
  4180. <?php }
  4181. }
  4182. function MakePostSectionExp(&$post){
  4183. $this->Anchors = []; $is_thread = isset($post['tid']);
  4184. ?>
  4185. <div class='center_exp' id='div_center'><br class='hidden_on_print' />
  4186. <ul>
  4187. <?php $is_reversed=false;
  4188. if($is_thread){ $th = &$post['tid'];$use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false;
  4189. foreach($use_arr as &$p){
  4190. $this->MakeSinglePostExp($p);
  4191. if($p == $th['first']){?>
  4192. <script>
  4193. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  4194. </script>
  4195. <?php } if($is_reversed && !$hinted){ ?>
  4196. <li class='gray smaller bold' style='text-align:center;'>
  4197. <p>&nbsp;</p><hr><?=$this->T('该话题最新帖子在前')?><hr><p>&nbsp;</p></li>
  4198. <?php $hinted = true; }
  4199. }
  4200. }else{
  4201. $this->MakeSinglePostExp($post);
  4202. ?><!--<script>
  4203. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  4204. </script>--><?php
  4205. } ?>
  4206. </ul>
  4207. </div>
  4208. <?php
  4209. }
  4210. function MakeHereSection(&$im){ $image_okay = (isset($im) && $im!=$this->NULL_IMAGE); ?>
  4211. <div class='here_image_box clean_a'>
  4212. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'>
  4213. <?=$image_okay?$this->T('请稍候'):$this->T('未找到图像')?></div>
  4214. <?php if($image_okay){ ?>
  4215. <?php if(isset($im['video']) && isset($im['video'])!=""){ ?>
  4216. <video controls><source src='<?=$im['file'];?>' type='<?=$im['video']?>'></video>
  4217. <?php }else{ ?>
  4218. <img id='big_image' onload="HideWaitingBar();" src="<?=$im['file'];?>" />
  4219. <?php } ?>
  4220. <?php } $this->MakeHereButtons($im, false); ?>
  4221. </div>
  4222. <?php }
  4223. function MakeSideGalleryCode(){?>
  4224. <div>
  4225. <h3><?=$this->T('点击图片以插入:')?></h3>
  4226. <select id="side_gallery_select" onchange="RefreshSideGallery()">
  4227. <option value="main"><?=$this->T('全部')?></option>
  4228. <?php if($this->LoggedIn){ ?>
  4229. <option value="trash"><?=$this->T('垃圾桶')?></option>
  4230. <?php }?>
  4231. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  4232. <option value="<?=$g['name']?>"><?=$g['name']?></option>
  4233. <?php } ?>
  4234. </select>
  4235. <div id='side_gallery'>
  4236. </div>
  4237. </div>
  4238. <script>
  4239. function InsertImage(imgname){
  4240. t = document.querySelector("#post_content");
  4241. v = t.value;
  4242. t.value = v.slice(0, t.selectionStart) + "![<?=$this->T('图片')?>](images/"+imgname+")"+ v.slice(t.selectionEnd);
  4243. la_auto_grow(t);
  4244. }
  4245. function RefreshSideGallery(){
  4246. let xhr = new XMLHttpRequest();
  4247. xhr.onreadystatechange = (function(){
  4248. if (this.readyState === this.DONE) {
  4249. if (this.status === 200) {
  4250. ind = document.querySelector("#side_gallery");
  4251. if(res = xhr.responseText.matchAll(/\[(.*?),(.*?)\]/gu)){
  4252. str = "<ul class='side_thumb'>"
  4253. for (const m of res) {
  4254. imgstr = "<img src='"+m[2]+"' />";
  4255. if(m[2].match('\.mp4')){
  4256. imgstr = "<video><source src='"+m[2]+"'></video>";
  4257. }
  4258. str+="<li><div class='file_thumb' onclick='InsertImage(\""+m[1]+"\")'>"+imgstr+"</div>"
  4259. }
  4260. str += "</ul>"
  4261. ind.innerHTML = str;
  4262. }
  4263. }
  4264. }
  4265. });
  4266. xhr.open("GET", "?image_list="+document.querySelector("#side_gallery_select").value, true);
  4267. xhr.send();
  4268. }
  4269. </script>
  4270. <?php
  4271. }
  4272. function MakeUploader($is_side=false){ ?>
  4273. <div id='upload_operation_area' class='hidden_on_print'>
  4274. <p><?=$this->T('选择、粘贴或者拖动到页面以上传图片。')?></p>
  4275. <input type="file" id='upload_selector' accept="image/x-png,image/png,image/gif,image/jpeg" multiple/>
  4276. <ul id='file_list'>
  4277. </ul>
  4278. <div class='smaller gray' id='upload_hint'><?=$this->T('就绪')?></div>
  4279. </div>
  4280. <a id='upload_click' class='hidden_on_print pointer' onclick='this.removeAttribute("onclick");UploadList();'
  4281. <?=$is_side?" data-is-side='true'":""?>><?=$this->T('上传列表中的文件')?></a>
  4282. <script>
  4283. function pastehandler(event){
  4284. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  4285. for (index in items) {
  4286. var item = items[index];
  4287. if (item.kind === 'file') {
  4288. put = document.querySelector("#_uploader");
  4289. if(put) ShowSideUploader();
  4290. var blob = item.getAsFile();
  4291. AddImageFile(blob);
  4292. return;
  4293. }
  4294. }
  4295. }
  4296. let _fd_list = []; var uploading=0;
  4297. let hint=document.querySelector('#upload_hint');
  4298. function ToggleCompress(button){
  4299. li = button.parentNode;
  4300. num=li.dataset.number;
  4301. for(i=0;i<_fd_list.length;i++){
  4302. if (_fd_list[i][0] == num){
  4303. state = _fd_list[i][2];
  4304. if(state){_fd_list[i][2] = 0; button.innerHTML='1920';break;}
  4305. else{_fd_list[i][2] = 1; button.innerHTML='800';break;}
  4306. }
  4307. }
  4308. }
  4309. function RemoveFromUpload(button){
  4310. li = button.parentNode;
  4311. num=li.dataset.number;
  4312. for(i=0;i<_fd_list.length;i++){
  4313. if (_fd_list[i][0] == num){
  4314. _fd_list.splice(i, 1);break;
  4315. }
  4316. }
  4317. li.parentNode.removeChild(li);
  4318. }
  4319. function EndThisUpload(){
  4320. unfinished = 0;
  4321. for(i=0;i<_fd_list.length;i++){
  4322. if (_fd_list[i][3]==0){
  4323. unfinished=1;
  4324. }
  4325. }
  4326. if(!unfinished){
  4327. uploading=0;
  4328. hint.innerHTML="<?=$this->T('上传完成。')?>";
  4329. cl=document.querySelector('#upload_click');
  4330. if(!cl.dataset.isSide){
  4331. cl.innerHTML="<?=$this->T('刷新页面')?>";
  4332. cl.href=window.location.href;
  4333. }else{
  4334. _fd_list.splice(0,_fd_list.length);
  4335. fl = document.querySelector("#file_list");
  4336. fl.innerHTML = "";
  4337. list=document.querySelector('#upload_operation_area');
  4338. list.style.pointerEvents='';
  4339. list.style.opacity='';
  4340. cl.onclick=function(){this.removeAttribute("onclick");UploadList();};
  4341. document.onpaste=pastehandler;
  4342. RefreshSideGallery();
  4343. }
  4344. }
  4345. }
  4346. function UploadList(){
  4347. if(!_fd_list.length || uploading) return;
  4348. uploading=1;
  4349. hint.innerHTML="<?=$this->T('正在上传...')?>";
  4350. list=document.querySelector('#upload_operation_area');
  4351. list.style.pointerEvents='none';
  4352. list.style.opacity='0.5';
  4353. document.onpaste="";
  4354. for(i=0;i<_fd_list.length;i++){
  4355. let xhr = new XMLHttpRequest();
  4356. var li = list.querySelector('[data-number="'+_fd_list[i][0].toString()+'"]')
  4357. xhr.open("POST", "?compress="+_fd_list[i][2].toString(), true);
  4358. function wrap(li, i){
  4359. var ind = li.querySelector('._compress_toggle')
  4360. return function(){
  4361. if (this.readyState === this.DONE) {
  4362. if (this.status === 200) {
  4363. var response = xhr.responseText;
  4364. if(res = response.match(/<uploaded>(.*)<\/uploaded>/)){
  4365. ind.innerHTML = "<?=$this->T('已上传为')?> "+res[1];
  4366. _fd_list[i][3] = 1;
  4367. }else{
  4368. ind.innerHTML = "<?=$this->T('出现错误。')?>";
  4369. _fd_list[i][3] = 1;
  4370. }
  4371. EndThisUpload();
  4372. }
  4373. }
  4374. }
  4375. }
  4376. xhr.onreadystatechange = wrap(li, i);
  4377. xhr.send(_fd_list[i][1]);
  4378. }
  4379. }
  4380. function AddImageFile(blob){
  4381. var ext="";
  4382. if(blob.name.match(/png$/i))ext = 'png';
  4383. else if(blob.name.match(/jpg$/i))ext = 'jpg';
  4384. else if(blob.name.match(/jpeg$/i))ext = 'jpeg';
  4385. else if(blob.name.match(/gif$/i))ext = 'gif';
  4386. else if(blob.name.match(/mp4$/i))ext = 'mp4';
  4387. else return;
  4388. var fd = new FormData();
  4389. blob.name = blob.name=generateUID().toString();
  4390. fd.append("upload_file_name", blob, "_upload_"+blob.name+"."+ext);
  4391. _fd_list.push([blob.name, fd, 1, 0]);/* number original is_compress uploaded */
  4392. var reader = new FileReader();
  4393. reader.onload = function(event){
  4394. fl = document.querySelector("#file_list");
  4395. ht = "<li id='_upload_"+blob.name+"' data-number='"+blob.name+"'>"+
  4396. "<a class='_remove_file pointer invert_a' onclick='RemoveFromUpload(this)'>×</a> "+"<div class='file_thumb'>"+
  4397. "<img class='no_pop' src='"+event.target.result+"'>"+"</div>"+
  4398. " →<a class='_compress_toggle pointer' onclick='ToggleCompress(this)'>800</a></li>";
  4399. fl.innerHTML+=ht;
  4400. };
  4401. reader.readAsDataURL(blob);
  4402. }
  4403. sel = document.querySelector('#upload_selector');
  4404. sel.addEventListener("change", function(){
  4405. var input = this;
  4406. function ff(file){
  4407. return function(e){
  4408. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  4409. blob.name = file.name;
  4410. AddImageFile(blob);
  4411. }
  4412. }
  4413. for(i=0;i<input.files.length;i++){
  4414. if(input.files[i].size){
  4415. let reader = new FileReader();
  4416. reader.onload = ff(input.files[i]);
  4417. reader.readAsArrayBuffer(input.files[i]);
  4418. }
  4419. }
  4420. });
  4421. function generateUID() {
  4422. var firstPart = (Math.random() * 46656) | 0;
  4423. var secondPart = (Math.random() * 46656) | 0;
  4424. firstPart = ("000" + firstPart.toString(36)).slice(-3);
  4425. secondPart = ("000" + secondPart.toString(36)).slice(-3);
  4426. return firstPart + secondPart;
  4427. }
  4428. document.onpaste = pastehandler;
  4429. function dropHandler(ev) {
  4430. put = document.querySelector("#_uploader");
  4431. if(put) ShowSideUploader();
  4432. bkg=document.querySelector('#dropping_background');
  4433. bkg.style.display="none";
  4434. console.log('File(s) dropped');
  4435. ev.preventDefault();ev.stopPropagation();
  4436. if (ev.dataTransfer && ev.dataTransfer.items) {
  4437. for (var i = 0; i < ev.dataTransfer.items.length; i++) {
  4438. if (ev.dataTransfer.items[i].kind === 'file') {
  4439. var file = ev.dataTransfer.items[i].getAsFile();
  4440. function ff(file){
  4441. return function(e){
  4442. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  4443. blob.name = file.name;
  4444. AddImageFile(blob);
  4445. }
  4446. }
  4447. if(file){
  4448. let reader = new FileReader();
  4449. reader.onload = ff(file);
  4450. reader.readAsArrayBuffer(file);
  4451. }
  4452. }
  4453. }
  4454. } else {
  4455. for (var i = 0; i < ev.dataTransfer.files.length; i++) {
  4456. function ff(file){
  4457. return function(e){
  4458. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  4459. blob.name = file.name;
  4460. AddImageFile(blob);
  4461. }
  4462. }
  4463. if(ev.dataTransfer.files[i].size){
  4464. let reader = new FileReader();
  4465. reader.onload = ff(ev.dataTransfer.files[i]);
  4466. reader.readAsArrayBuffer(ev.dataTransfer.files[i]);
  4467. }
  4468. }
  4469. }
  4470. }
  4471. function dragOverHandler(ev) {
  4472. bkg=document.querySelector('#dropping_background');
  4473. bkg.style.display="";
  4474. console.log('File(s) in drop zone');
  4475. ev.preventDefault();
  4476. }
  4477. </script>
  4478. <?php
  4479. }
  4480. function CanShowGallery(&$g){
  4481. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($g['experimental']) && $g['experimental']) return false;
  4482. return true;
  4483. }
  4484. function CanShowImage(&$im){
  4485. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($im['galleries']) && isset($im['galleries'][0])) foreach($im['galleries'] as $ga){
  4486. if(($g=$this->GetGallery($ga)) && isset($g['experimental']) && $g['experimental']) return false;
  4487. }
  4488. if(isset($this->WayBack) && substr($im['name'],0,14)>$this->WayBack) return false;
  4489. return true;
  4490. }
  4491. function GetImageBatch($from,$show_all){
  4492. if(!isset($_GET['gallery'])) return;
  4493. $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){$name=$_GET['gallery'];}
  4494. $reached=0; $count=0;
  4495. if(isset($this->Images[0])) foreach($this->Images as $im){
  4496. if(isset($from)&&!$reached){ if($from==$im['name']){ $reached=1; } continue; }
  4497. if(!$this->CanShowImage($im)){ continue; }
  4498. if($_GET['gallery']=='trash') $name='trash';
  4499. if($_GET['gallery']!='main'){ if(!isset($im['galleries']) || !in_array($name, $im['galleries'])) continue;} ?>
  4500. <div class='p_thumb<?=isset($im['parent'])?" p_thumb_narrow":""?>'>
  4501. <?php if($this->LoggedIn){ ?>
  4502. <div class="post_menu_button _select_hook white" onclick='ToggleSelectImage(this, "<?=$im["name"]?>")'>●</div>
  4503. <?php } ?>
  4504. <a href='?show_image=<?=$im['name']?>' target='_blank' onclick='event.preventDefault();'>
  4505. <?php if(isset($im['video']) && $im['video']!=""){ ?>
  4506. <video data-imgsrc='<?=$im["name"]?>'><source src='<?=$im['file']?>' type='<?=$im['video']?>'></video>
  4507. <?php }else{ ?>
  4508. <img src='<?=$im['thumb']?>' data-imgsrc='<?=$im["name"]?>'
  4509. <?=isset($im['product'])?'data-product="'.$im["product"].'"':""?>
  4510. <?=isset($im['parent'])?'data-parent="'.$im["parent"].'"':""?>
  4511. <?=isset($im['align'])?'data-align="'.$im["align"].'" style="object-position:'.$im['align'].';"':""?>/>
  4512. <?php } ?>
  4513. </a>
  4514. </div>
  4515. <?php $count+=isset($im['parent'])?0:1; if((!$show_all)&&($count>=$this->GalleryStep)){ break; }
  4516. }
  4517. if($count<$this->GalleryStep){ ?><div style='display:none'>END_GALLERY</div><?php return 0; }
  4518. return 1;
  4519. }
  4520. function MakeGallerySection(){ global $INDEXPHP;
  4521. if(!isset($_GET['gallery'])) return;
  4522. $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){ $name=$_GET['gallery'];}
  4523. $show_all=0; if(isset($_GET['show_all']) && $_GET['show_all']!='0'){ $show_all=1; } ?>
  4524. <script>
  4525. document.title+=" | <?=$this->T('画廊')?>";
  4526. </script>
  4527. <div class='center_wide' id='div_center' style='position:relative;'><br class='hidden_on_print' />
  4528. <h2><?=(isset($name) && ($gal=$this->GetGallery($name))!=NULL)?
  4529. ("<span class='gray album_hint'>".$this->T('相册').":</span>".$this->T($name)):
  4530. ($_GET['gallery']=='trash'?$this->T('垃圾桶'):$this->T('画廊'))?></h2>
  4531. <?php $description=(isset($gal) && isset($gal['description']))?$gal['description']:null; ?>
  4532. <div class='hidden_on_desktop'>
  4533. <?=$this->T('前往')?>
  4534. <select id="gallery_go_to" onchange="window.location.href='?gallery='+this.value;">
  4535. <optgroup label="<?=$this->T('精选')?>">
  4536. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4537. if(!isset($g['featured']) || !$g['featured'] ||
  4538. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  4539. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  4540. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  4541. <?php } ?></optgroup><optgroup label="<?=$this->T('其他相册')?>">
  4542. <option value="main" <?=$_GET['gallery']=='main'?"selected":""?>>[<?=$this->T('全部')?>]</option>
  4543. <?php if($this->LoggedIn){ ?>
  4544. <option value="trash" <?=$_GET['gallery']=='trash'?"selected":""?>>[<?=$this->T('垃圾桶')?>]</option>
  4545. <?php } ?>
  4546. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4547. if((isset($g['featured']) && $g['featured']) ||
  4548. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  4549. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  4550. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  4551. <?php } ?></optgroup>
  4552. </select>
  4553. </div>
  4554. <?php if($this->LoggedIn){?>
  4555. <div>
  4556. <?php if(isset($name)){ ?>
  4557. <div style='text-align:right;position:absolute;right:0;top:0;width:100%;' class='invert_a smaller hidden_on_print'>
  4558. <a href='javascript:ShowDeleteMenu();'><?=$this->T('删除相册')?></a><br />
  4559. <?php if(isset($gal['featured']) && $gal['featured']!=false){ ?>
  4560. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=false'>
  4561. <?=$this->T('取消精选')?></a>
  4562. <?php }else{ ?>
  4563. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=true'>
  4564. <?=$this->T('设为精选')?></a>
  4565. <?php } ?><br />
  4566. <?php if(isset($gal['experimental']) && $gal['experimental']!=false){ ?>
  4567. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=false'>
  4568. <?=$this->T('取消实验')?></a>
  4569. <?php }else{ ?>
  4570. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=true'>
  4571. <?=$this->T('设为实验')?></a>
  4572. <?php } ?>
  4573. <div class='pop_menu invert_a' id='gallery_delete_menu' style='display:none;'>
  4574. <div style='float:left;' class='gray'><?=$this->T('该操作不删除图片。')?></div>
  4575. <a href='javascript:HidePopMenu();'>×</a>
  4576. <hr />
  4577. <a href='?gallery=main&gallery_edit_delete=<?=$_GET['gallery']?>'><b><?=$this->T('删除相册')?></b></a>
  4578. </div>
  4579. </div>
  4580. <?php } ?>
  4581. <?php $this->MakeUploader(false); ?>
  4582. <div style='text-align:right;position:relative;' class='invert_a smaller hidden_on_print'>
  4583. <div style='position:relative'>
  4584. <?php if(isset($name)){ ?>
  4585. <a href='javascript:ShowGalleryEditMenu("<?=$name?>",null)'><?=$this->T('改名')?></a>
  4586. <a href='javascript:ShowGalleryEditMenu("<?=$name?>","<?=$description?>")'><?=$this->T('描述')?></a>
  4587. <?php } ?>
  4588. <a href='javascript:ShowGalleryEditMenu(null,null)'><?=$this->T('添加')?></a>
  4589. <div class='pop_menu invert_a' id='gallery_edit_menu' style='display:none;max-width:90%;'>
  4590. <form action="<?=$_SERVER['REQUEST_URI']?>&edit_gallery=true"
  4591. method="post" style='display:none;' id='gallery_edit_form'></form>
  4592. <a style='float:left;'><?=$this->T('设置为:')?></a>
  4593. <a href='javascript:HidePopMenu();'>×</a>
  4594. <input type='text' form='gallery_edit_form' name='gallery_edit_new_name' id='gallery_edit_new_name' style='width:10em;'>
  4595. <input type='text' form='gallery_edit_form' name='gallery_edit_old_name' id='gallery_edit_old_name' style='display:none'>
  4596. <input type='text' form='gallery_edit_form' name='gallery_edit_description' id='gallery_edit_description' style='width:10em;display:none'>
  4597. <input class='button' type='submit' form='gallery_edit_form'
  4598. name='gallery_edit_confirm' id='gallery_edit_confirm' value='<?=$this->T('确认')?>'>
  4599. </div>
  4600. </div>
  4601. </div>
  4602. <div class='smaller hidden_on_print'>
  4603. <form action="<?=$_SERVER['REQUEST_URI']?>"
  4604. method="post" style='display:none;' id='gallery_move_form'></form>
  4605. <input type='text' form='gallery_move_form' name='gallery_move_ops'
  4606. id='gallery_move_ops' style='display:none'>
  4607. <p><?=$this->T('选择了')?> <span id='gallery_selected_count'>0</span> <?=$this->T('个图片。')?>
  4608. <a href='javascript:ClearSelectedImages()'><?=$this->T('清除')?></a></p>
  4609. <p><?=$this->T('添加到')?>
  4610. <select id="gallery_move_to">
  4611. <option value="trash"><?=$this->T('垃圾桶')?></option>
  4612. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  4613. <option value="<?=$g['name']?>"><?=$this->T($g['name'])?></option>
  4614. <?php } ?>
  4615. </select>
  4616. <a href='javascript:AddToGallery()'><?=$this->T('执行')?></a>
  4617. </p>
  4618. <p>
  4619. <?=$this->T('或者')?><a href='javascript:RemoveFromGallery()'><?=$this->T('从相册移除')?></a>
  4620. </p>
  4621. </div>
  4622. </div>
  4623. <?php } $desc=isset($description)?$this->GetPost($description):null;
  4624. if(isset($desc)){ ?><ul class='print_column list'><br /><?php
  4625. $this->MakeSinglePost($desc, false, false, false, false, false, false, false, false, true, false);
  4626. ?></ul><?php } ?>
  4627. <br />
  4628. <div><div class='p_row'><?php $has_more=$this->GetImageBatch(NULL, $show_all);?>
  4629. <div class='p_thumb p_thumb_end' <?=$has_more?"onclick='ThisGetMore(this);'":""?>>
  4630. <a onclick='event.preventDefault();' href='<?=$INDEXPHP?>?gallery=<?=$_GET['gallery']?>&show_all=1'>
  4631. <h2 id="btn_more_images"><?=$has_more?$this->T("查看更多"):$this->T("没有更多的了");?></a></h2></div></div>
  4632. </div>
  4633. </div>
  4634. <script type='text/javascript'>
  4635. function ThisGetMore(end_ui){
  4636. var xhr = new XMLHttpRequest();
  4637. xhr.onreadystatechange = function() {
  4638. if (this.readyState == 4 && this.status == 200) {
  4639. doc = document.createElement("div"); doc.innerHTML=xhr.responseText.trim(); next_child=null;
  4640. for(child=doc.firstChild; child!==null; child=next_child) { next_child=child.nextSibling; end_ui.parentNode.insertBefore(child,end_ui); }
  4641. doc.remove();
  4642. if(xhr.responseText.search('END_GALLERY')>=0){ end_ui.onclick=null; end_ui.innerHTML="<h2><?=$this->T("没有更多的了");?></h2>"; }
  4643. UpdateImageClickables();
  4644. btn=document.getElementById("btn_more_images"); if(btn) btn.innerText="<?=$this->T("查看更多");?>";
  4645. }
  4646. };
  4647. btn=document.getElementById("btn_more_images"); if(btn) btn.innerText="<?=$this->T("稍等");?>";
  4648. im=end_ui.previousElementSibling.querySelector('img,video');
  4649. from=im?im.dataset.imgsrc:null; if(!from) return;
  4650. const urlParams = new URLSearchParams(window.location.search); const gallery = urlParams.get('gallery')
  4651. xhr.open("GET", "<?=$INDEXPHP?>?gallery_continue="+from+'&gallery='+gallery, true);
  4652. xhr.send();
  4653. }
  4654. <?php if($this->LoggedIn){ ?>
  4655. var selected_image = new Array();
  4656. function RemoveFromGallery(){
  4657. form = document.querySelector('#gallery_move_form');
  4658. ops = document.querySelector('#gallery_move_ops');
  4659. sel = document.querySelector('#gallery_move_to');
  4660. ops.value = "REM <?=$_GET['gallery']?>"+" "+selected_image.join(' ');
  4661. form.submit();
  4662. }
  4663. function AddToGallery(){
  4664. form = document.querySelector('#gallery_move_form');
  4665. ops = document.querySelector('#gallery_move_ops');
  4666. sel = document.querySelector('#gallery_move_to');
  4667. ops.value = "ADD "+sel.value+" "+selected_image.join(' ');
  4668. form.submit();
  4669. }
  4670. function ClearSelectedImages(){
  4671. selected_image.splice(0, selected_image.length);
  4672. checks = document.querySelectorAll('._select_hook');
  4673. [].forEach.call(checks, function(c){
  4674. c.classList.remove('p_thumb_selected');
  4675. });
  4676. count = document.querySelector('#gallery_selected_count');
  4677. count.innerHTML="0";
  4678. }
  4679. function ToggleSelectImage(elem, name){
  4680. count = document.querySelector('#gallery_selected_count');
  4681. if(selected_image.indexOf(name) == -1){ selected_image.push(name); elem.classList.add('p_thumb_selected'); }
  4682. else{ selected_image.splice(selected_image.indexOf(name), 1); elem.classList.remove('p_thumb_selected'); }
  4683. count.innerHTML=selected_image.length.toString()
  4684. }
  4685. function ShowGalleryEditMenu(old_name,desc){
  4686. m = document.querySelector('#gallery_edit_menu');
  4687. old = document.querySelector('#gallery_edit_old_name');
  4688. newname = document.querySelector('#gallery_edit_new_name');
  4689. description = document.querySelector('#gallery_edit_description');
  4690. m.style.display='block';
  4691. if(desc!==null){ description.style.display='block';newname.style.display='none';description.value=desc;}
  4692. else{ description.style.display='none';newname.style.display='';}
  4693. if(old_name!=''){ old.value=old_name; newname.value=old.value; }else{ old.value=''; }
  4694. }
  4695. function ShowDeleteMenu(){
  4696. m=document.querySelector('#gallery_delete_menu');
  4697. m.style.display='block';
  4698. }
  4699. <?php } ?>
  4700. </script>
  4701. <?php
  4702. }
  4703. function MakeGalleryLeft(){?>
  4704. <div class='left hidden_m gallery_left' id='div_left'><div><br /></div>
  4705. <h2><?=$this->T('相册')?></h2>
  4706. <div>
  4707. <span class='gray smaller bold'><?=$this->T('精选')?><hr> </span>
  4708. <ul>
  4709. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4710. if(!isset($g['featured']) || !$g['featured'] || !$this->CanShowGallery($g)){ continue; } ?>
  4711. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4712. <li class='<?=$_GET['gallery']==$g['name']?'selected':""?>'>
  4713. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4714. <?php } ?>
  4715. </ul>
  4716. <div class='smaller'><span class='gray'><?=$this->T('其他相册')?><hr></span><ul>
  4717. <a href='?gallery=main' onclick='ShowWaitingBar()'>
  4718. <li class='<?=$_GET['gallery']=='main'?' selected':""?>'>[<?=$this->T('全部图片')?>]</li></a>
  4719. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4720. if((isset($g['featured']) && $g['featured']) || !$this->CanShowGallery($g)){ continue; } ?>
  4721. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4722. <li class='<?=$_GET['gallery']==$g['name']?' selected':""?>'>
  4723. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4724. <?php } ?>
  4725. <?php if($this->LoggedIn){ ?>
  4726. <a href='?gallery=trash' onclick='ShowWaitingBar()'>
  4727. <li class='<?=$_GET['gallery']=='trash'?' selected':""?>'>[<?=$this->T('垃圾桶')?>]</li></a>
  4728. <?php } ?>
  4729. </ul></div>
  4730. <p>&nbsp;</p>
  4731. <script>
  4732. </script>
  4733. </div>
  4734. </div>
  4735. <?php
  4736. }
  4737. function MakeStatistics(){
  4738. $this->ReadPosts(); $this->ReadImages(); $this->ReadArchive();
  4739. $list=[]; $last_date=null; $info=[]; $info['count']=0; $info['edits']=0; $info['length']=0;
  4740. $imlist=[]; $imlast_date=null; $iminfo=[]; $iminfo['count']=0;
  4741. $maxposts=0; $maxlength=0; $maximages=0;
  4742. foreach($this->Posts as &$p){ $is_ref=0;
  4743. $this_date=substr($p['id'],0,8);
  4744. if($last_date!=null && $last_date!=$this_date){
  4745. if($maxposts<$info['count']+$info['edits'])$maxposts=$info['count']+$info['edits'];
  4746. if($maxlength<$info['length'])$maxlength=$info['length'];
  4747. $list[]=$info; $info=[]; $info['count']=0; $info['edits']=0; $info['length']=0;
  4748. }
  4749. $ah = &$this->GetArchiveHandle($p['id']); if(isset($ah)&&isset($ah['list'][0])) $info['edits']+=count($ah['list']);
  4750. $info['count']++; $info['id']=$this_date; if(isset($p['content']))$info['length']+=strlen($p['content']); $last_date=$this_date;
  4751. }
  4752. $last_date=null;
  4753. foreach($this->Images as &$im){ $is_ref=0;
  4754. $this_date=substr($im['name'],0,8);
  4755. if($last_date!=null && $last_date!=$this_date){
  4756. if($maximages<$iminfo['count'])$maximages=$iminfo['count'];
  4757. $imlist[]=$iminfo; $iminfo=[]; $iminfo['count']=0;
  4758. }
  4759. $iminfo['count']++; $iminfo['id']=$this_date; $last_date=$this_date;
  4760. }
  4761. if($info!=[]) $list[]=$info;
  4762. if($iminfo!=[]) $imlist[]=$iminfo;
  4763. if(!isset($list[0])) return;
  4764. $earliest=DateTimeImmutable::createFromFormat('!Ymd',$list[0]['id']); $ey=substr($list[0]['id'],0,4);
  4765. $latest=DateTimeImmutable::createFromFormat('!Ymd',end($list)['id']); $ly=substr(end($list)['id'],0,4);
  4766. $days=$earliest->diff($latest)->days; $lw=2.0; $dw=$days*$lw; $spw=20;
  4767. ?>
  4768. <style>.stastics_posts{direction:ltr;} .stastics_posts line,.stastics_posts circle{stroke:#f8ca9b; stroke-width:2px;}
  4769. .stastics_posts .line_edits{stroke:#f8ca9b40;}
  4770. .stastics_posts .line_year{stroke:#f8ca9b30; stroke-width:2px;} .stastics_posts text{fill:#f8ca9ba0; font: 0.9em serif;}
  4771. </style>
  4772. <div class='settings'><h2><?=$this->T('统计')?></h2><br />
  4773. <div style="overflow:auto;direction:rtl;width:100%;">
  4774. <svg class='stastics_posts' viewBox="-<?=$spw?> -<?=$spw?> <?=$days*$lw+$spw*6?> <?=200+4*$spw?>" height="<?=200+4*$spw?>" width="<?=$days*$lw+$spw*6?>">
  4775. <?php foreach($list as $info){ $itv=DateTimeImmutable::createFromFormat('!Ymd',$info['id'])->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);
  4776. $p1=100.0*(1-$info['count']/$maxposts); $p2=$p1-100.0*$info['edits']/$maxposts;
  4777. $p3=100.0*$info['length']/$maxlength+$spw+100; ?>
  4778. <line x1="<?=$ds?>" x2="<?=$ds?>" y1="100.0" y2="<?=$p1?>"/>
  4779. <?php if($info['edits']>0){ ?><line class='line_edits' x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=$p1?>" y2="<?=$p2?>"/><?php } ?>
  4780. <?php if($info['length']>0){ ?><line class='line_edits' x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=$spw+100?>" y2="<?=$p3?>"/><?php } ?>
  4781. <?php } ?>
  4782. <?php foreach($imlist as $im){ $itv=DateTimeImmutable::createFromFormat('!Ymd',$im['id'])->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);
  4783. $p1=100+$spw+100.0*($im['count']/$maximages); ?>
  4784. <circle cx="<?=$ds?>" cy="<?=$p1?>" r='3'/>
  4785. <?php } ?>
  4786. <?php for($y=$ey;$y<=$ly;$y++){ $itv=DateTimeImmutable::createFromFormat('!Y',$y)->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);?>
  4787. <line x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=220+$spw?>" y2="-<?=$spw?>" class='line_year'/>
  4788. <text x="<?=$ds+4?>" y="-4"><?=$y?></text>
  4789. <text x="<?=$ds+4?>" y="<?=$spw*2+200-4?>"><?=$y?></text>
  4790. <?php for($ym=1;$ym<=12;$ym++){ $st=str_pad($ym,2,'0',STR_PAD_LEFT); $itv2=DateTimeImmutable::createFromFormat('!Ym',$y.$st)->diff($earliest);
  4791. $dds=$lw/2+$lw*$itv2->days*($itv2->invert?1:-1); if($dds<0||$dds>$lw/2+$dw) continue; ?>
  4792. <line x1="<?=$dds?>" x2="<?=$dds?>" y1="<?=100+$spw?>" y2="100" class='line_year'/>
  4793. <text x="<?=$dds+4?>" y="<?=100+$spw-3?>"><?=$ym?></text>
  4794. <?php } } ?>
  4795. <line x1="<?=$lw/2+$dw?>" x2="<?=$days*$lw?>" y1="<?=220+$spw?>" y2="-<?=$spw?>" class='line_year'/>
  4796. <line x1="0" x2="<?=$dw?>" y1="0" y2="0" class='line_year'/>
  4797. <line x1="0" x2="<?=$dw?>" y1="100" y2="100" class='line_year'/>
  4798. <line x1="0" x2="<?=$dw?>" y1="<?=100+$spw?>" y2="<?=100+$spw?>" class='line_year'/>
  4799. <line x1="0" x2="<?=$dw?>" y1="<?=200+$spw?>" y2="<?=200+$spw?>" class='line_year'/>
  4800. <text x="<?=$dw+10?>" y="8"><?=$maxposts?></text>
  4801. <text x="<?=$dw+10?>" y="<?=$spw+8?>"><tspan style='fill:#f8ca9b;'>▪ <?=$this->T('新增')?></tspan></text>
  4802. <text x="<?=$dw+10?>" y="<?=$spw*2+8?>"><tspan style='fill:#f8ca9ba0;'>▪ <?=$this->T('改动')?></tspan></text>
  4803. <text x="<?=$dw+10?>" y="<?=$spw*2+200-4?>"><?=$maxlength?></text>
  4804. <text x="<?=$dw+10?>" y="<?=$spw+200-4?>"><tspan style='fill:#f8ca9b;'><?=$maximages?></tspan></text>
  4805. <text x="<?=$dw+10?>" y="<?=200-4?>"><tspan style='fill:#f8ca9b;'>▪ <?=$this->T('媒体')?></text>
  4806. <text x="<?=$dw+10?>" y="<?=200-4-$spw?>">▪ <?=$this->T('长度')?></tspan></text>
  4807. </svg></div>
  4808. <br /><br />
  4809. </div>
  4810. <?php
  4811. }
  4812. function MakeSettings(){ global $INDEXPHP; ?>
  4813. <div class='settings'>
  4814. <h2><?=$this->T('设置')?></h2>
  4815. <table style='white-space:nowrap;'>
  4816. <?php if($this->LoggedIn){ ?>
  4817. <form action="<?=$INDEXPHP?>?settings=true" method="post" style='display:none;' id='settings_form'></form>
  4818. <colgroup><col style='min-width:5em;'><col style='width:100%;min-width:5em;'></colgroup>
  4819. <thead><tr><td><?=$this->T('选项')?></td><td><?=$this->T('值')?></td></tr></thead>
  4820. <tr><td><?=$this->T('网站标题')?></td>
  4821. <td><input type="text" form="settings_form" id='settings_title' name='settings_title'
  4822. value='<?=$this->Title?>'/></td></tr>
  4823. <tr><td><?=$this->T('短标题')?></td>
  4824. <td><input type="text" form="settings_form" id='settings_short_title' name='settings_short_title'
  4825. value='<?=$this->ShortTitle?>'/></td></tr>
  4826. <tr><td><?=$this->T('显示名称')?></td>
  4827. <td><input type="text" form="settings_form" id='settings_display_name' name='settings_display_name'
  4828. value='<?=$this->DisplayName?>'/></td></tr>
  4829. <tr><td><?=$this->T('电子邮件')?></td>
  4830. <td><input type="text" form="settings_form" id='settings_email' name='settings_email'
  4831. value='<?=$this->EMail?>'/></td></tr>
  4832. <tr><td><?=$this->T('导航栏')?>
  4833. <?=isset($this->SpecialNavigation)?"<a href='?post=".$this->SpecialNavigation."'>→</a>":""?></td>
  4834. <td><input type="text" form="settings_form" id='settings_special_navigation' name='settings_special_navigation'
  4835. value='<?=$this->SpecialNavigation?>'/></td></tr>
  4836. <tr><td><?=$this->T('侧边栏')?>
  4837. <?=isset($this->SpecialSidebar)?"<a href='?post=".$this->SpecialSidebar."'>→</a>":""?></td>
  4838. <td><input type="text" form="settings_form" id='settings_special_sidebar' name='settings_special_sidebar'
  4839. value='<?=$this->SpecialSidebar?>'/></td></tr>
  4840. <tr><td><?=$this->T('脚注')?> 1<?=isset($this->SpecialFooter)?"<a href='?post=".$this->SpecialFooter."'>→</a>":""?></td>
  4841. <td><input type="text" form="settings_form" id='settings_special_footer' name='settings_special_footer'
  4842. value='<?=$this->SpecialFooter?>'/></td></tr>
  4843. <tr><td><?=$this->T('脚注')?> 2<?=isset($this->SpecialFooter2)?"<a href='?post=".$this->SpecialFooter2."'>→</a>":""?></td>
  4844. <td><input type="text" form="settings_form" id='settings_special_footer2' name='settings_special_footer2'
  4845. value='<?=$this->SpecialFooter2?>'/></td></tr>
  4846. <tr><td><?=$this->T('置顶文')?><?=isset($this->SpecialPinned)?"<a href='?post=".$this->SpecialPinned."'>→</a>":""?></td>
  4847. <td><input type="text" form="settings_form" id='settings_special_pinned' name='settings_special_pinned'
  4848. value='<?=$this->SpecialPinned?>'/></td></tr>
  4849. <tr><td><?=$this->T('置顶备忘')?><?=isset($this->SpecialPinnedNotes)?"<a href='?post=".$this->SpecialPinnedNotes."'>→</a>":""?></td>
  4850. <td><input type="text" form="settings_form" id='settings_special_pinned_notes' name='settings_special_pinned_notes'
  4851. value='<?=$this->SpecialPinnedNotes?>'/></td></tr>
  4852. <tr><td><?=$this->T('默认相册')?></td>
  4853. <td><input type="text" form="settings_form" id='settings_default_gallery' name='settings_default_gallery'
  4854. value='<?=$this->DefaultGallery?>'/></td></tr>
  4855. <tr><td><?=$this->T('相册单步')?></td>
  4856. <td><input type="text" form="settings_form" id='settings_gallery_step' name='settings_gallery_step'
  4857. value='<?=$this->GalleryStep?>'/></td></tr>
  4858. <tr><td><?=$this->T('SelfAuth 路径')?></td>
  4859. <td><input type="text" form="settings_form" id='settings_selfauth_path' name='settings_selfauth_path'
  4860. value='<?=$this->SelfAuthPath?>'/></td></tr>
  4861. <tr><td><?=$this->T('启用评论')?></td>
  4862. <td><input type="checkbox" id="settings_enable_comments" name="settings_enable_comments"
  4863. form="settings_form" <?=$this->CommentEnabled?"checked":""?>/></td></tr>
  4864. <tr><td><?=$this->T('启用新闻')?></td>
  4865. <td><input type="checkbox" id="settings_enable_newsletter" name="settings_enable_newsletter"
  4866. form="settings_form" <?=$this->NewsletterEnabled?"checked":""?>/></td></tr>
  4867. <tr><td><?=$this->T('附加操作')?></td><td><a class='gray' href='<?=$INDEXPHP?>?extras=true'><?=$this->T('进入')?></a></td></tr>
  4868. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4869. <tr><td class='smaller gray'><?=$this->T('长毛象')?></td></tr>
  4870. <tr><td><?=$this->T('长毛象实例')?></td>
  4871. <td><input type="text" form="settings_form" id='settings_mastodon_url' name='settings_mastodon_url'
  4872. value='<?=$this->MastodonURL?>'/></td></tr>
  4873. <tr><td><?=$this->T('长毛象令牌')?></td>
  4874. <td><input type="text" form="settings_form" id='settings_mastodon_token' name='settings_mastodon_token'
  4875. value='<?=$this->MastodonToken?>'/></td></tr>
  4876. <tr><td><?=$this->T('偏好语言')?></td>
  4877. <td><input type="text" form="settings_form" id='settings_mastodon_lang' name='settings_mastodon_lang'
  4878. value='<?=$this->MastodonPreferredLang?>'/></td></tr>
  4879. <tr><td><?=$this->T('本站地址')?></td>
  4880. <td><input type="text" form="settings_form" id='settings_host_url' name='settings_host_url'
  4881. value='<?=$this->HostURL?>'/></td></tr>
  4882. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4883. <tr><td class='smaller gray'><?=$this->T('Activity Pub')?></td></tr>
  4884. <tr><td><?=$this->T('用户名')?></td>
  4885. <td><input type="text" form="settings_form" id='settings_apub_id' name='settings_apub_id'
  4886. value='<?=$this->APubID?>'/></td></tr>
  4887. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4888. <tr><td class='smaller gray'><?=$this->T('这里访问')?></td></tr>
  4889. <tr><td><?=$this->T('主机')?></td>
  4890. <td><input type="text" form="settings_form" id='settings_here_host' name='settings_here_host'
  4891. value='<?=$this->HereHost?>'/></td></tr>
  4892. <tr><td><?=$this->T('网站标题')?></td>
  4893. <td><input type="text" form="settings_form" id='settings_here_title' name='settings_here_title'
  4894. value='<?=$this->HereTitle?>'/></td></tr>
  4895. <tr><td><?=$this->T('短标题')?></td>
  4896. <td><input type="text" form="settings_form" id='settings_here_short_title' name='settings_here_short_title'
  4897. value='<?=$this->HereShortTitle?>'/></td></tr>
  4898. <tr><td><?=$this->T('相册')?></td>
  4899. <td><input type="text" form="settings_form" id='settings_here_album' name='settings_here_album'
  4900. value='<?=$this->HereAlbum?>'/></td></tr>
  4901. <tr><td><?=$this->T('导航栏')?>
  4902. <?=isset($this->HereNavigation)?"<a href='?post=".$this->HereNavigation."'>→</a>":""?></td>
  4903. <td><input type="text" form="settings_form" id='settings_here_navigation' name='settings_here_navigation'
  4904. value='<?=$this->HereNavigation?>'/></td></tr>
  4905. <tr><td><?=$this->T('脚注')?><?=isset($this->HereFooter)?"<a href='?post=".$this->HereFooter."'>→</a>":""?></td>
  4906. <td><input type="text" form="settings_form" id='settings_here_footer' name='settings_here_footer'
  4907. value='<?=$this->HereFooter?>'/></td></tr>
  4908. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4909. <tr><td class='smaller gray'><?=$this->T('实验访问')?></td></tr>
  4910. <tr><td><?=$this->T('主机')?></td>
  4911. <td><input type="text" form="settings_form" id='settings_exp_host' name='settings_exp_host'
  4912. value='<?=$this->ExpHost?>'/></td></tr>
  4913. <tr><td><?=$this->T('网站标题')?></td>
  4914. <td><input type="text" form="settings_form" id='settings_exp_title' name='settings_exp_title'
  4915. value='<?=$this->ExpTitle?>'/></td></tr>
  4916. <tr><td><?=$this->T('短标题')?></td>
  4917. <td><input type="text" form="settings_form" id='settings_exp_short_title' name='settings_exp_short_title'
  4918. value='<?=$this->ExpShortTitle?>'/></td></tr>
  4919. <tr><td><?=$this->T('首次提示')?><?=isset($this->ExpCaution)?"<a href='?post=".$this->ExpCaution."'>→</a>":""?></td>
  4920. <td><input type="text" form="settings_form" id='settings_exp_caution' name='settings_exp_caution'
  4921. value='<?=$this->ExpCaution?>'/></td></tr>
  4922. <tr><td><?=$this->T('相册')?></td>
  4923. <td><input type="text" form="settings_form" id='settings_exp_album' name='settings_exp_album'
  4924. value='<?=$this->ExpAlbum?>'/></td></tr>
  4925. <tr><td><?=$this->T('导航栏')?>
  4926. <?=isset($this->ExpNavigation)?"<a href='?post=".$this->ExpNavigation."'>→</a>":""?></td>
  4927. <td><input type="text" form="settings_form" id='settings_exp_navigation' name='settings_exp_navigation'
  4928. value='<?=$this->ExpNavigation?>'/></td></tr>
  4929. <tr><td><?=$this->T('脚注')?><?=isset($this->ExpFooter)?"<a href='?post=".$this->ExpFooter."'>→</a>":""?></td>
  4930. <td><input type="text" form="settings_form" id='settings_exp_footer' name='settings_exp_footer'
  4931. value='<?=$this->ExpFooter?>'/></td></tr>
  4932. <tr><td><?=$this->T('允许选择语言')?>
  4933. <td><input type="checkbox" id="settings_allow_language" name="settings_allow_language"
  4934. form="settings_form" <?=$this->AllowLanguageChoices?"checked":""?>/></td></tr>
  4935. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4936. <tr><td class='smaller gray'><?=$this->T('管理员')?></td><td class='smaller'>
  4937. <a href='<?=$INDEXPHP?>?logout=true'><?=$this->T('登出')?></a></td></tr>
  4938. <tr><td><?=$this->T('帐号')?></td>
  4939. <td><input type="text" form="settings_form" id='settings_id' name='settings_id'
  4940. value='<?=$this->Admin?>'/></td></tr>
  4941. <tr><td><?=$this->T('新密码')?></td>
  4942. <td><input type="password" form="settings_form"
  4943. id='settings_new_password' name='settings_new_password' /></td></tr>
  4944. <tr><td><?=$this->T('再次输入')?></td>
  4945. <td><input type="password" form="settings_form"
  4946. id='settings_new_password_redo' name='settings_new_password_redo' /></td></tr>
  4947. <tr><td><?=$this->T('旧密码')?></td>
  4948. <td><input type="password" form="settings_form" id='settings_old_password' name='settings_old_password' /></td></tr>
  4949. <?php }else{ ?>
  4950. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='login_form'></form>
  4951. <colgroup><col style='min-width:3em;'><col style='width:100%;min-width:5em;'></colgroup>
  4952. <tr><td class='smaller gray'><?=$this->T('请登录')?></td></tr>
  4953. <tr><td><?=$this->T('帐号')?></td>
  4954. <td><input type="text" form="login_form" id='login_id' name='login_id' /></td></tr>
  4955. <tr><td><?=$this->T('密码')?></td>
  4956. <td><input type="password" form="login_form" id='login_password' name='login_password' /></td></tr>
  4957. <?php } ?>
  4958. </table>
  4959. <?php if($this->LoggedIn){ ?>
  4960. <input class='button' form="settings_form" type="submit" name='settings_button' value='<?=$this->T('保存设置')?>' />
  4961. <?php }else{ ?>
  4962. <input class='button' form="login_form" type="submit" name='login_button' value='<?=$this->T('登录')?>' />
  4963. <?php } ?>
  4964. </div>
  4965. <?php
  4966. }
  4967. function MakeSubscribers(){ ?>
  4968. <table><tbody><tr><td><?=$this->T("帖子")?></td><td><input type='text' id='mail_news_id' name='mail_news_id'></td></tr>
  4969. <?php
  4970. $subs=file_get_contents("all_subscribers.php");
  4971. if(preg_match_all("/(.+)\s+\[\[\[(.*)\]\]\]/u",$subs,$ma,PREG_SET_ORDER)){
  4972. foreach($ma as $m){ ?>
  4973. <tr><td><a id="send<?=$m[1]?>" ondblclick="SendNews(this,'<?=$m[1]?>','<?=$m[2]?>')"><?=$this->T("发送");?></a></td>
  4974. <td id="content<?=$m[1]?>"><?=$m[2];?></td><?php
  4975. }
  4976. } ?>
  4977. </tbody></table><script>
  4978. function copyElementToClipboard(element) {
  4979. window.getSelection().removeAllRanges();
  4980. let range = document.createRange();
  4981. range.selectNode(element);
  4982. window.getSelection().addRange(range);
  4983. document.execCommand('copy');
  4984. window.getSelection().removeAllRanges();
  4985. }
  4986. function SendNews(but,id,email){
  4987. txt=document.querySelector("#mail_news_id"); if(!txt)return;
  4988. post=txt.value; if(post=='') return;
  4989. but.innerHTML = "<?=$this->T('稍等')?>"; but.ondblclick=null;
  4990. var xhr = new XMLHttpRequest();
  4991. function wrapidxhr(_id){ return function() {
  4992. if (this.readyState == 4) {
  4993. btn = document.querySelector('#send'+_id);
  4994. if(this.status == 200){ btn.innerHTML="<?=$this->T('好')?>"
  4995. //ctn = document.querySelector('#content'+_id);
  4996. //ctn.innerHTML=this.responseText.trim();
  4997. //copyElementToClipboard(ctn);
  4998. //ctn.innerHTML="<?=$this->T('复制到剪贴板')?>";
  4999. }else{ btn.innerHTML="<?=$this->T('问题')?>" }
  5000. }
  5001. }; };
  5002. xhr.onreadystatechange = wrapidxhr(id)
  5003. xhr.open("GET", "<?=$INDEXPHP?>?post="+post.toString()+'&send='+id.toString()+'&addr='+email.toString(), true);
  5004. xhr.send();
  5005. }
  5006. </script><?php
  5007. }
  5008. function MakeExtraOperations(){ global $INDEXPHP; ?>
  5009. <div class='settings' style='overflow:auto;'>
  5010. <h2><?=$this->T('附加操作')?></h2>
  5011. <a href='<?=$INDEXPHP?>?&settings=true'><?=$this->T('返回一般设置')?></a>
  5012. <p>&nbsp;</p>
  5013. <h3><?=$this->T('自动重定向')?></h3>
  5014. <span class='smaller gray'>
  5015. <?=$this->T('P为帖子跳转,匹配REQUEST_URI跳到目标文章;S为站点跳转,可以重定向来源域名,例子:')?>
  5016. <br /><pre>P discount:20001001010101;<br />S old_domain:www.new_domain.com:20001001010101;</pre></span>
  5017. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form2'></form>
  5018. <textarea id="settings_redirect" name="settings_redirect" rows="4" class='full_box' wrap="off"
  5019. form='settings_form2'><?=$this->DisplayRedirectConfig()?></textarea>
  5020. <input class='button' form="settings_form2" type="submit" name='settings_save_redirect'
  5021. value='<?=$this->T('保存重定向设置')?>' />
  5022. <p>&nbsp;</p>
  5023. <h3><?=$this->T('自定义翻译')?></h3>
  5024. <span class='smaller gray'>
  5025. <?=$this->T('填写格式:')?>
  5026. <br /><pre>- 语言 | Language</pre></span>
  5027. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form3'></form>
  5028. <textarea id="settings_translation" name="settings_translation" rows="4" class='full_box' wrap="off"
  5029. form='settings_form3'><?=$this->CustomTranslationContent?></textarea>
  5030. <input class='button' form="settings_form3" type="submit" name='settings_save_translation'
  5031. value='<?=$this->T('保存翻译')?>' />
  5032. <?php if($this->NewsletterEnabled){
  5033. $subs=file_get_contents("all_subscribers.php"); ?>
  5034. <br /><br /><h3><?=$this->T('邮件订阅者')?></h3>
  5035. <?php $this->MakeSubscribers(); ?>
  5036. <?php } ?>
  5037. <br />
  5038. <p class='smaller gray'><?=$this->T('ActivityPub 测试:')?></p>
  5039. <ul>
  5040. <li><a href='?TestAPubDeliver=1'><?=$this->T('测试发送')?></a></li></ui>
  5041. </ui>
  5042. <br />
  5043. <p class='smaller gray'><?=$this->T('当心!下列操作将立即执行:')?></p>
  5044. <ul>
  5045. <li><label for='opbtn0' class='ref_count'><?=$this->T('重新写入默认CSS')?></label><input type="checkbox" class='lpctrl' id='opbtn0' checked='checked'/>
  5046. <a href='?rewrite_styles=true'>→</a></li>
  5047. <li><label for='opbtn1' class='ref_count'><?=$this->T('重新生成图片缩略图')?></label><input type="checkbox" class='lpctrl' id='opbtn1' checked='checked'/>
  5048. <a href='?regenerate_thumbnails=true'>→</a></li>
  5049. <li><label for='opbtn2' class='ref_count'><?=$this->T('清理未压缩的图像')?></label><input type="checkbox" class='lpctrl' id='opbtn2' checked='checked'/>
  5050. <a href='?cleanup_image_compression=true'>→</a></li>
  5051. <li><label for='opbtn3' class='ref_count'><?=$this->T('删除所有登录')?></label><input type="checkbox" class='lpctrl' id='opbtn3' checked='checked'/>
  5052. <a href='?clear_all_logins=true'>→</a></li>
  5053. </ui>
  5054. <br /><br /><br /><a href='?&settings=true'><?=$this->T('返回一般设置')?></a><br />&nbsp;
  5055. </div>
  5056. <?php
  5057. }
  5058. function MakeMainBegin(){?>
  5059. <div class='main' <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  5060. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"<?php } ?>>
  5061. <?php
  5062. }
  5063. function MakeMainEnd(){?>
  5064. </div>
  5065. <?php
  5066. }
  5067. function MakeExpFooter(){
  5068. $exptitle = isset($this->HereDisplayTitle)?('"'.trim($this->T($this->ChoosePartsByLanguage($this->HereDisplayTitle))).'"'):NULL;
  5069. if(!isset($exptitle)) $exptitle=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle);?>
  5070. <div class='small_footer exp_h_f exp_f'><div>
  5071. <?php if($this->InExperimentalMode){ ?>
  5072. <b><?=$exptitle?></b>
  5073. <?php }else{ ?>
  5074. <b><?=$exptitle?></b> ©<?=$this->T($this->DisplayName)?>
  5075. <?php }?>
  5076. <?=isset($this->HereMainImage)?("<a class='invert_a' href='?here=images/".$this->HereMainImage['name']."'>".$this->T("看全图")."</a>"):""; ?>
  5077. <div class='wayback_link gray clean_a invert_a hidden_on_print'><br class="hidden_on_desktop" />
  5078. <?php if($this->InExperimentalMode && isset($this->ExpFooter) && ($p = &$this->GetPost($this->ExpFooter,true))!=NULL){
  5079. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  5080. }else if($this->InHereMode && isset($this->HereFooter) && ($p = &$this->GetPost($this->HereFooter,true))!=NULL){
  5081. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  5082. }?></div>
  5083. </div>
  5084. </div>
  5085. </div><!-- page -->
  5086. </body>
  5087. </html>
  5088. <script>
  5089. if(trans = document.getElementById('translate_button')){
  5090. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  5091. }
  5092. </script>
  5093. <?php
  5094. }
  5095. function MakeImageOverlay($side_info=null,$static_image=null,$static_video=null){
  5096. $static=isset($side_info); ?>
  5097. <div id='big_image_overlay' <?=$static?"":"style='display:none'";?>>
  5098. <div class='big_image_box clean_a' onclick='HideBigImage(1)'>
  5099. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'><?=$this->T('请稍候')?></div>
  5100. <?php if(!$static_video){ ?>
  5101. <img id='big_image' onload="HideWaitingBar();" <?=isset($static_image)?("src='".$static_image."'"):""?>/><?php } ?>
  5102. <?php if(!$static_image){ ?>
  5103. <video id='big_video' onloadstart="HideWaitingBar();" controls><source id='big_video_src' type='video/mp4'
  5104. <?=isset($static_video)?("src='".$static_video."'"):""?>></video><?php } ?>
  5105. </div>
  5106. <div class='big_side_box' onclick='HideBigImage(1);'>
  5107. <?php if(!$static){ ?>
  5108. <div class='big_image_box clean_a image_nav' onclick='HideBigImage(1)'>
  5109. <div ><a id='prev_image' class='image_nav_prev img_btn_hidden' onclick="event.stopPropagation();">
  5110. <div class='lr_buttons'>←</div></a></div>
  5111. <div ><a id='next_image' class='image_nav_next img_btn_hidden' onclick="event.stopPropagation();">
  5112. <div class='lr_buttons'>→</div></a></div>
  5113. <div id='here_buttons'></div>
  5114. </div><?php } ?>
  5115. <div class='side_box_mobile_inner'>
  5116. <?php if(!$static){ ?>
  5117. <div class='inquiry_buttons img_btn_hidden' id='inquiry_buttons' onclick="event.stopPropagation();">
  5118. <span style='display:none;' id='image_purchase' class='clean_a'>
  5119. <b><a id='image_purchase_button' target="_blank">¥<?=$this->T('购买印刷品')?></a></b>
  5120. <br class='hidden_on_desktop block_m' /></span>
  5121. <b><a class='clean_a' id='image_download'><span id='download_processing'>↓</span><?=$this->T('下载')?></a></b>
  5122. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  5123. &nbsp;<a class='clean_a' id='image_inquiry'>
  5124. <b>@</b><?=$this->T('咨询')?></a>
  5125. <?php } ?><hr class='hidden_on_desktop block_m' />
  5126. </div>
  5127. <div id='big_image_share' class='clean_a' onclick="event.stopPropagation();">
  5128. <li class='wayback_close'><a onclick='HideBigImage(1);'><?=$this->T('关闭')?> ×</a></li>
  5129. <li><a id='big_share_copy'>⎘ <?=$this->T('复制链接')?></a></li>
  5130. <hr />
  5131. </div><?php } //static ?>
  5132. <div id='big_image_info' onclick="event.stopPropagation();"><?=$static?$side_info:""?></div>
  5133. <?php if($this->LoggedIn && !$static){ ?><div id='big_image_ops' onclick="event.stopPropagation();">
  5134. <br /><?=$this->T('印刷品链接')?>
  5135. <form action="" method="post" style='display:none;' id='image_ops_form'></form>
  5136. <input type='text' id='image_ops_product_link' name='image_ops_product_link' form="image_ops_form" >
  5137. <?=$this->T('重命名')?>
  5138. <input type='text' id='image_edit_new_name' name='image_edit_new_name' form="image_ops_form" >
  5139. <?=$this->T('主图')?>
  5140. <input type='text' id='image_parent' name='image_parent' form="image_ops_form" >
  5141. <?=$this->T('对齐')?> <select id='image_align' name='image_align' form="image_ops_form">
  5142. <option value='top'><?=$this->T('顶部')?></option>
  5143. <option value='middle'><?=$this->T('中间')?></option>
  5144. <option value='bottom'><?=$this->T('底部')?></option></select><br />
  5145. <input class='button' form="image_ops_form" type="submit" name='image_button' value=<?=$this->T('保存')?> />
  5146. <br /><br /><?=$this->T('替换图像')?>
  5147. <form action="" method="post" style='display:none;' id='image_edit_form' enctype="multipart/form-data"></form>
  5148. <input type="file" form='image_edit_form'
  5149. id='big_image_upload' name='upload_file_name' accept="image/x-png,image/png,image/gif,image/jpeg"/><br />
  5150. <input class='button' form="image_edit_form" type="submit" name='image_replace_button'
  5151. value=<?=$this->T('执行')?> />
  5152. </div><?php } ?>
  5153. </div>
  5154. </div>
  5155. </div>
  5156. <?php }
  5157. function MakePageEnd(){?>
  5158. </div><!-- page -->
  5159. </body>
  5160. </html>
  5161. <?php }
  5162. function MakeFooter(&$p){ global $INDEXPHP;
  5163. $is_slides=(isset($p['slides']) || (isset($p['tid'])&&isset($p['tid']['slides']))); $no_title=isset($p['tid']['first']['no_title']);?>
  5164. <div class='small_footer'><div>
  5165. <hr />
  5166. <?php if(isset($p['tid']['footer'])){ ?><div class='show_on_print'><?=$p['tid']['footer'];?></div><?php } ?>
  5167. <b<?=$no_title?" class='hidden_on_print'":"";?>><?=$this->T($this->Title)?></b>
  5168. <span onclick='event.stopPropagation()'<?=$no_title?" class='hidden_on_print'":"";?>
  5169. ondblclick='javascript:window.location.href="<?=$INDEXPHP?>?settings=true"'>©</span><?=$this->T($this->DisplayName)?>
  5170. <div class='smaller show_on_print'><?=$_SERVER['SERVER_NAME']?><br /><?=$this->EMail?></div>
  5171. </div></div>
  5172. <div class='footer'>
  5173. <div style='white-space:nowrap;'>
  5174. <div class='footer_additional'>
  5175. <?php if(isset($this->SpecialFooter) && ($p = &$this->GetPost($this->SpecialFooter))!=NULL){
  5176. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  5177. } ?>
  5178. </div>
  5179. <div class='footer_additional'>
  5180. <?php if(isset($this->SpecialFooter2) && ($p = &$this->GetPost($this->SpecialFooter2))!=NULL){
  5181. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  5182. } ?>
  5183. </div>
  5184. </div>
  5185. </div>
  5186. <p>&nbsp;<p>
  5187. <div id='dropping_background' style='display:none;' onclick='this.style.display="none";'
  5188. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);">
  5189. <h2 style='width:100%;'><?=$this->T('上传到这里')?></h2>
  5190. </div>
  5191. <?php $this->MakeImageOverlay(); $this->MakePageEnd(); ?>
  5192. <script>
  5193. <?php if($is_slides){ ?>SlidesStart(null);<?php } ?>
  5194. <?=$this->ExtraScripts?>
  5195. if(back = document.getElementById('button_back')){
  5196. if(document.referrer.indexOf(location.protocol + "//" + location.host) == 0){
  5197. back.href='javascript:history.back()';
  5198. }else{
  5199. back.href='<?=$INDEXPHP?>';
  5200. }
  5201. }
  5202. function copy_text(t) {
  5203. ta = document.createElement('textarea'); document.body.appendChild(ta); ta.value = t; ta.select();
  5204. document.execCommand("copy"); document.body.removeChild(ta);
  5205. }
  5206. if(trans = document.getElementById('translate_button')){
  5207. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  5208. }
  5209. function ClickPost(p,e,pushstate){if(e)e.preventDefault();
  5210. id=p.dataset.postId; if(!id)return; list=p.parentNode;active=list.getElementsByClassName('active_post');
  5211. if(active&&active[0]&&active[0]!=p){
  5212. if(pushstate){window.history.pushState('?post='+id,null,'?post='+id);}
  5213. active[0].classList.remove('active_post'); p.classList.add('active_post');
  5214. }
  5215. if(!active[0]){ window.location.href="?post="+id; }
  5216. }function InitLabel(){
  5217. lb=document.querySelector('#mtitle'); lb.removeAttribute('for'); lb.onclick=function()
  5218. {c=document.querySelector('#titlectrl');if(c.checked)c.checked=false;else c.checked=true;}
  5219. lb=document.querySelectorAll('.bkg_section label');if(!lb||!lb[0])return;
  5220. for(i=0;i<lb.length;i++){ lb[i].removeAttribute('for');lb[i].onclick=function()
  5221. {c=this.parentNode.querySelector('.lpctrl');if(!c)return;if(c.checked)c.checked=false;else c.checked=true;} }
  5222. }InitLabel();
  5223. <?php if($this->LoggedIn){ ?>
  5224. var Scenter = document.querySelector('.center');
  5225. var Sposts = Scenter?Scenter.querySelectorAll('.post'):null;
  5226. <?php if(isset($this->MastodonToken)){ ?>
  5227. function MarkPostDoneMastodon(id,mastodon_url){
  5228. for(var i=0;i<Sposts.length;i++){
  5229. if(Sposts[i].dataset.postId==id){ Sposts[i].dataset.mastodon_url= mastodon_url; break;} }
  5230. }
  5231. <?php } ?>
  5232. <?php if($this->PageType=='post' && !isset($this->WayBack)) { ?>
  5233. var Smerge_post_dialog = Scenter.querySelector('#merge_post_dialog');
  5234. var Smerge_post = Scenter.querySelector('#merge_post');
  5235. var Smerge_post_count = Smerge_post_dialog.querySelector('#merge_post_count');
  5236. var Smerge_post_btn = Scenter.querySelector('#merge_post_btn');
  5237. var Smerge_cancel = Scenter.querySelector('#merge_cancel');
  5238. var Smerge_select = Scenter.querySelector('#merge_select');
  5239. var Smerge_thread_dialog = Scenter.querySelector('#merge_thread_dialog');
  5240. var Smerge_thread = Scenter.querySelector('#merge_thread');
  5241. var Smerge_thread_target = Scenter.querySelector('#merge_thread_target');
  5242. var Smerge_thread_btn = Scenter.querySelector('#merge_thread_btn');
  5243. var select_mode = false; var merge_mode = false; var selected_posts = null;
  5244. function TogglePostSelectMode(force_on=false,force_off=false){
  5245. Scenter.classList.add('post_selecting');
  5246. if((!select_mode || force_on) && !force_off){ ToggleThreadMerge(false,true); Scenter.classList.add('post_selecting');
  5247. Smerge_post_dialog.style.display="block";Smerge_post_btn.classList.add('text_highlight');
  5248. Smerge_cancel.innerText='<?=$this->T("取消")?>'; select_mode = 1;}
  5249. else{ select_mode = 0; Scenter.classList.remove('post_selecting');
  5250. Smerge_post_dialog.style.display="none";Smerge_post_btn.classList.remove('text_highlight');
  5251. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  5252. for(var i=0;i<Sposts.length;i++){ Sposts[i].classList.remove('post_selected');
  5253. Sposts[i].onclick=select_mode?function(){TogglePostSelect(this);}:null; }
  5254. Smerge_post_count.innerText="0";
  5255. Smerge_post.href="#";
  5256. }
  5257. function TogglePostSelect(elem){
  5258. if(elem.classList.contains('post_selected')){ elem.classList.remove('post_selected'); }
  5259. else{ elem.classList.add('post_selected'); }
  5260. selected_posts = new Array();
  5261. for(var i=0;i<Sposts.length;i++){ if(Sposts[i].classList.contains('post_selected')){
  5262. selected_posts.push(Sposts[i].dataset.postId); } }
  5263. Smerge_post.href="?merge_posts="+selected_posts.join(" ");
  5264. Smerge_post_count.innerText=selected_posts.length;
  5265. }
  5266. function ThreadMergeInput(elem){
  5267. if(elem.value.match(/[0-9]{14}/)) { Smerge_thread.href="?merge_threads=<?=$this->ActualPostID?> "+elem.value; }
  5268. else{ Smerge_thread.href="#"; }
  5269. }
  5270. function ToggleThreadMerge(force_on=false,force_off=false){
  5271. if((!merge_mode || force_on) && !force_off){ TogglePostSelectMode(false,true);
  5272. Smerge_thread_dialog.style.display="block";Smerge_thread_btn.classList.add('text_highlight');
  5273. Smerge_cancel.innerText='<?=$this->T("取消")?>'; merge_mode = 1;}
  5274. else{ merge_mode = 0;
  5275. Smerge_thread_dialog.style.display="none";Smerge_thread_btn.classList.remove('text_highlight');
  5276. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  5277. Smerge_thread.href="#";
  5278. Smerge_thread_target.value='';
  5279. }
  5280. <?php } ?>
  5281. function ShowSideUploader(){
  5282. ShowRightSide(true,null);
  5283. put = document.querySelector("#_uploader");
  5284. put.style.display='block';
  5285. RefreshSideGallery();
  5286. }
  5287. dmark = document.querySelector("#mark_details");
  5288. drename = document.querySelector("#rename_details");
  5289. dmastodon = document.querySelector("#mastodon_details");
  5290. drename_form = document.querySelector("#post_rename_form");
  5291. drename_input = document.querySelector("#post_rename_name");
  5292. var rp = document.querySelector('#post_reply_to');
  5293. var _reply_to = rp?rp.defaultValue:"";
  5294. function RestoreReply(){
  5295. if(rp){
  5296. rp.defaultValue = _reply_to;
  5297. }
  5298. document.querySelector('#post_reply_restore').style.display='none';
  5299. ht = document.querySelector('#post_hint_text');
  5300. if (_reply_to!=""){
  5301. ht.style.display='block';
  5302. ht.innerHTML="<?=$this->T('继续补充该话题:')?>";
  5303. }else{
  5304. ht.style.display='none';
  5305. }
  5306. document.querySelector('#post_edit_target').value="";
  5307. ch = document.querySelector('#post_hint_modify');
  5308. ch.style.display='none';
  5309. }
  5310. function MakeRefer(id){
  5311. t = document.querySelector('#post_content')
  5312. t.focus();
  5313. v = t.value;
  5314. t.value = v.slice(0, t.selectionStart) + "[<?=$this->T('引用文章')?>]("+id.toString()+")" + v.slice(t.selectionEnd);
  5315. la_auto_grow(t);
  5316. if(rp){
  5317. rp.defaultValue = "";
  5318. ht = document.querySelector('#post_hint_text');
  5319. ht.innerHTML = "<?=$this->T('引用并发送新话题:')?>"; ht.style.display='block';
  5320. document.querySelector('#post_reply_restore').style.display='inline';
  5321. rs = document.querySelector('#post_reply_restore');
  5322. rs.style.display='inline'; rs.innerHTML="<?=$this->T('切换为回复')?>";
  5323. document.getElementById('post_menu').style.display='none';
  5324. ch = document.querySelector('#post_hint_modify');
  5325. ch.style.display='none';
  5326. }
  5327. }
  5328. function CopyRefer(id){
  5329. copy_text(id.toString());
  5330. menu.querySelector('#menu_refer_copy').innerHTML="<?=$this->T('已复制')?>";
  5331. }
  5332. function MakeEdit(id){
  5333. ed = document.getElementById('menu_edit');
  5334. ed.innerHTML="<?=$this->T('稍等')?>";
  5335. ed.href="#";
  5336. var xhr = new XMLHttpRequest();
  5337. xhr.onreadystatechange = function() {
  5338. if (this.readyState == 4 && this.status == 200) {
  5339. ed.innerHTML='——';
  5340. ch = document.querySelector('#post_hint_modify');
  5341. ch.style.display='block';
  5342. ht = document.querySelector('#post_hint_text');
  5343. ht.innerHTML = "<?=$this->T('修改帖子:')?>";
  5344. rs = document.querySelector('#post_reply_restore');
  5345. rs.style.display='inline'; rs.innerHTML="<?=$this->T('取消')?>";
  5346. t = document.querySelector('#post_content');
  5347. t.value=xhr.responseText.trim();
  5348. t.focus();
  5349. la_auto_grow(t);
  5350. document.querySelector('#post_edit_target').value=id;
  5351. document.getElementById('post_menu').style.display='none';
  5352. }
  5353. };
  5354. xhr.open("GET", "<?=$INDEXPHP?>?post="+id.toString()+'&post_original=true', true);
  5355. xhr.send();
  5356. }
  5357. function MarkDelete(id){
  5358. p = document.querySelector('[data-post-id="'+id+'"]');
  5359. op = p.dataset.markDelete?"false":"true";
  5360. window.location.href=
  5361. "<?=$INDEXPHP?>?<?=$this->GetRedirect()?>&mark_delete="+op+'&target='+id.toString();
  5362. }
  5363. function SetMark(mark){
  5364. menu = document.getElementById('post_menu');
  5365. window.location.href=
  5366. "<?=$INDEXPHP?>?<?=$this->GetRedirect()?>&target="+
  5367. menu.parentNode.dataset.postId+"&set_mark="+mark;
  5368. }
  5369. function ToggleMarkDetails(){
  5370. dmark.style.display=(dmark.style.display=='block')?'none':'block';
  5371. drename.style.display=dmastodon.style.display='none';
  5372. }
  5373. function ToggleRenameDetails(){
  5374. drename.style.display=(drename.style.display=='block')?'none':'block';
  5375. dmark.style.display=dmastodon.style.display='none';
  5376. }
  5377. function ToggleMastodonDetails(){
  5378. dmastodon.style.display=(dmastodon.style.display=='block')?'none':'block';
  5379. dmark.style.display=drename.style.display='none';
  5380. }
  5381. <?php } if(isset($_GET['post'])){ ?> ScrollToPost("<?=$_GET['post']?>"); <?php } ?>
  5382. function ShowPostMenu(post){
  5383. menu = document.getElementById('post_menu');
  5384. menu.style.display='block';
  5385. menu.parentNode.removeChild(menu);
  5386. post.appendChild(menu);
  5387. menu.style.display='block';
  5388. id = post.dataset.postId
  5389. menu.querySelector('#_time_hook').innerHTML = ''+id.substring(2,4)+'/'+id.substring(4,6)+'/'+id.substring(6,8)+
  5390. ' '+id.substring(8,10)+':'+id.substring(10,12);
  5391. window.onClick="HidePopMenu()";
  5392. menu.onClick=(function(event){
  5393. event.stopPropagation();
  5394. });
  5395. hs = menu.querySelector('#menu_history');
  5396. hs.href='?post='+id+'&history=1';
  5397. <?php if($this->LoggedIn && !isset($this->WayBack)){ ?>
  5398. <?php if($this->PageType!='search'){?>
  5399. menu.querySelector('#menu_refer').href='javascript:MakeRefer(id)';
  5400. ed = menu.querySelector('#menu_edit');ed.href='javascript:MakeEdit(id)'; ed.innerHTML="<?=$this->T('修改')?>";
  5401. <?php } ?>
  5402. ref = menu.querySelector('#menu_refer_copy')
  5403. ref.innerHTML='<?=$this->T("复制编号")?>';
  5404. ref.href='javascript:CopyRefer(id)';
  5405. d = menu.querySelector('#menu_delete');
  5406. d.href='javascript:MarkDelete(\"'+id+'\")';
  5407. p = document.querySelector('[data-post-id="'+id+'"]');
  5408. d.innerHTML = p.dataset.markDelete?"<?=$this->T('恢复')?>":"<?=$this->T('删除')?>";
  5409. menu.querySelector('#mark_details').dataset.id=id;
  5410. drename_input.value=id;
  5411. drename_form.action="<?=$this->GetRedirect()?>"+"&rename_post="+id;
  5412. <?php if(isset($this->MastodonToken)){ ?>
  5413. dmastodon_form = document.querySelector("#post_mastodon_form");
  5414. dmastodon_form.action='?mastodon_post='+id;
  5415. function MastodonSend(id){
  5416. mastodon_send.innerHTML="<?=$this->T('稍等')?>";
  5417. var xhr = new XMLHttpRequest();
  5418. function wrapidxhr(_id) { return function() {
  5419. if (this.readyState == 4 && this.status == 200) {
  5420. var response = xhr.responseText;
  5421. let content="";
  5422. if(res = response.match(/SUCCESS (\S+)/u)){
  5423. content="<?=$this->T('成功发送到长毛象')?>";
  5424. }else{content="<b><?=$this->T('出现问题')?></b><br /><span class='smaller'>"+response+"</span>";}
  5425. mastodon_send.innerHTML=content; mastodon_send.href=res[1];
  5426. MarkPostDoneMastodon(_id, res[1]);
  5427. } }
  5428. };
  5429. xhr.onreadystatechange = wrapidxhr(id);
  5430. xhr.open("GET", "<?=$INDEXPHP?>?mastodon_send_post="+id, true); xhr.send();
  5431. }
  5432. menu_mastodon = menu.querySelector("#menu_mastodon");
  5433. mastodon_send = menu.querySelector("#menu_mastodon_send");
  5434. mastodon_view = menu.querySelector("#menu_mastodon_view");
  5435. mastodon_url = menu.querySelector("#post_mastodon_url");
  5436. if(p.dataset.mastodon_url){mastodon_view.style.display='inline';mastodon_view.href=p.dataset.mastodon_url;
  5437. mastodon_send.innerHTML='<?=$this->T("重新发送")?>'; mastodon_url.value=p.dataset.mastodon_url; }
  5438. else{mastodon_view.style.display='none';mastodon_view.href=""; mastodon_send.innerHTML="<?=$this->T('发送')?>";
  5439. mastodon_url.value="";}
  5440. mastodon_send.onclick=function(){
  5441. this.onclick=function(){};
  5442. MastodonSend(id); };
  5443. <?php } } ?>
  5444. title = document.title;
  5445. copy = document.getElementById('share_copy');
  5446. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  5447. copy.addEventListener("click", function(){
  5448. url = window.location
  5449. path = location.pathname
  5450. copy_text(url.protocol+"//"+url.host+path+"?post="+id);
  5451. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  5452. });
  5453. }
  5454. function HidePopMenu(){
  5455. var menus = document.querySelectorAll('.pop_menu');
  5456. [].forEach.call(menus, function(m){m.style.display='none';});
  5457. }
  5458. var posts = document.querySelectorAll('.main>.center>tbody>.post'); if(!posts || !posts[0]) posts = document.querySelectorAll('.center_slides .post');
  5459. [].forEach.call(posts, function(p){
  5460. if(s=p.querySelector('._menu_hook')) s.addEventListener("click", function() {
  5461. ShowPostMenu(this.parentNode.parentNode);
  5462. if(document.querySelector('.clickable_section')!=null) ClickPost(this.parentNode.parentNode,null,true)
  5463. });
  5464. p.addEventListener("dblclick", function(){ ClickPost(this,null,true); lp=this.querySelector('.lpctrl'); if(lp){ if(lp.checked)lp.checked=false;else lp.checked=true; }});
  5465. });
  5466. //var post_clickables = document.querySelectorAll('.center .post a');
  5467. //[].forEach.call(post_clickables, function(p){
  5468. // p.addEventListener("click", function(event){
  5469. // event.stopPropagation();
  5470. // });
  5471. //});
  5472. function FindImage(imgsrc){
  5473. for(var i=0;i<document.images_filtered.length;i++){
  5474. if (document.images_filtered[i].dataset.imgsrc==imgsrc) return document.images_filtered[i]
  5475. }
  5476. return null
  5477. }
  5478. var dottime1;
  5479. var dottime2;
  5480. function ToDataURL(url) {
  5481. return fetch(url).then((response) => {return response.blob();}).then(blob => {
  5482. clearTimeout(dottime1);clearTimeout(dottime2);
  5483. ps = document.querySelector('#download_processing');
  5484. ps.innerHTML='↓';ps.style.opacity='';
  5485. return URL.createObjectURL(blob);});
  5486. }
  5487. async function DownloadAsImage(url,name) {
  5488. const a = document.createElement("a"); a.href = await ToDataURL(url); a.download = name;
  5489. document.body.appendChild(a); a.click(); document.body.removeChild(a);
  5490. }
  5491. function basename(url){return url.split(/[\\/]/).pop();}
  5492. pushed=0;
  5493. function ShowBigImage(imgsrc,do_push){
  5494. ShowWaitingBar();
  5495. share = document.querySelector('#big_image_share');
  5496. img = document.querySelector('#big_image');
  5497. vid = document.querySelector('#big_video');
  5498. vidsrc = document.querySelector('#big_video_src');
  5499. down = document.querySelector('#image_download');
  5500. img.src = ""; vidsrc.src="";
  5501. if(imgsrc.match(/\.mp4$/)){
  5502. vidsrc.src = src = "images/"+imgsrc; img.style.display='none'; vid.load();vid.style.display='block';
  5503. }else{
  5504. img.src = src = "images/"+imgsrc; vid.style.display='none';img.style.display='block';
  5505. }
  5506. down.href="images/"+imgsrc;
  5507. var downname='<?=$this->T($this->Title);?>_<?=$this->T($this->DisplayName);?>_<?=$this->GiveSafeEMail()?>_'+
  5508. basename(down.href);
  5509. img.alt = downname; down.download=downname;
  5510. var use_href = "images/"+imgsrc;
  5511. down.onclick=function(event){event.stopPropagation();event.preventDefault();
  5512. ps = this.querySelector('#download_processing');ps.innerText='…';
  5513. var dotwait = function(ps){ var self = this;
  5514. dottime1 = setTimeout(function(ps){
  5515. ps.style.opacity='0'; dottime2 = setTimeout(function(ps){ps.style.opacity='1'; dotwait(ps);},300,ps); },300,ps) }
  5516. dotwait(this.querySelector('#download_processing'));
  5517. DownloadAsImage(use_href,downname);};
  5518. if(do_push){PushGalleryHistory(src)}
  5519. page_url = encodeURIComponent(window.location.href);
  5520. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  5521. inqb = document.querySelector('#image_inquiry');
  5522. inqb.href="mailto:<?=$this->T($this->DisplayName);?>\<<?=$this->EMail?>\>?subject=<?=$this->T('网站图片咨询');?>&body="+
  5523. encodeURIComponent("<?=$this->T('你好!我对你网站上的这张图片感兴趣:')?>"+'\n\n')+
  5524. (page_url)+encodeURIComponent('\n\n');
  5525. <?php } ?>
  5526. this_image = FindImage(imgsrc);
  5527. if(this_image&&this_image.dataset.prevsrc){
  5528. new_image = FindImage(this_image.dataset.prevsrc);
  5529. new_prev = new_image?new_image.dataset.prevsrc:null;
  5530. im = document.querySelector('#prev_image');
  5531. if(new_prev) {im.href='javascript:ShowBigImage("'+this_image.dataset.prevsrc+'",'+do_push+')';im.style.opacity='';}
  5532. else {im.style.opacity='0';im.removeAttribute("href");}
  5533. }
  5534. if(this_image&&this_image.dataset.nextsrc){
  5535. new_image = FindImage(this_image.dataset.nextsrc);
  5536. new_next = new_image?new_image.dataset.nextsrc:null;
  5537. im = document.querySelector('#next_image');
  5538. if(new_next) {im.href='javascript:ShowBigImage("'+this_image.dataset.nextsrc+'",'+do_push+')';im.style.opacity='';}
  5539. else {im.style.opacity='0';im.removeAttribute("href");}
  5540. }
  5541. purchase = document.querySelector('#image_purchase');
  5542. purchase_btn = document.querySelector('#image_purchase_button');
  5543. <?php if($this->LoggedIn){ ?>
  5544. product_link = document.querySelector('#image_ops_product_link');
  5545. product_form = document.querySelector('#image_ops_form');
  5546. edit_form = document.querySelector('#image_edit_form');
  5547. edit_new_name = document.querySelector('#image_edit_new_name');
  5548. edit_parent = document.querySelector('#image_parent');
  5549. edit_align = document.querySelector('#image_align');
  5550. product_form.action = window.location.href;
  5551. edit_form.action = window.location.href;
  5552. edit_new_name.value = imgsrc.split('.')[0];
  5553. if(this_image){
  5554. if(this_image.dataset.product){ product_link.value = this_image.dataset.product; }else{ product_link.value = ""; }
  5555. if(this_image.dataset.parent){ edit_parent.value = this_image.dataset.parent; }else{ edit_parent.value = ""; }
  5556. if(this_image.dataset.align){ edit_align.value = this_image.dataset.align; }else{ edit_align.value = "middle"; }
  5557. }
  5558. <?php } ?>
  5559. if(this_image&&this_image.dataset.product){
  5560. purchase.style.display='';
  5561. href = this_image.dataset.product;
  5562. if(this_image.dataset.product.match('^[0-9]{14}$')){
  5563. href = '?post='+href;
  5564. }
  5565. purchase_btn.href = href;
  5566. }else{
  5567. purchase.style.display='none';
  5568. purchase_btn.removeAttribute("href");
  5569. }
  5570. DelayHideImgBtn(null);
  5571. title = encodeURIComponent(document.title);
  5572. copy = document.getElementById('big_share_copy');
  5573. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  5574. copy.addEventListener("click", function(){
  5575. copy_text(window.location.href);
  5576. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  5577. });
  5578. o = document.querySelector('#big_image_overlay');
  5579. info = document.querySelector('#big_image_info');info.innerHTML="<?=$this->T('正在查询……')?>";
  5580. here = document.querySelector('#here_buttons');here.innerHTML='';
  5581. o.style.display="block";
  5582. ShowBackdrop(0.8);
  5583. var xhr = new XMLHttpRequest();
  5584. xhr.onreadystatechange = function() {
  5585. if (this.readyState == 4 && this.status == 200) {
  5586. info = document.querySelector('#big_image_info');
  5587. var response = xhr.responseText;
  5588. let content=""
  5589. if(res = response.match(/<ref>(.*)<\/ref>/u)){
  5590. content="<span class='small'><?=$this->T('该图片出现在')?> "+res[1]+" <?=$this->T('个帖子中')?></span>"+content;
  5591. }else{content="<span class='smaller gray'><?=$this->T('该图片未被引用')?></span>"+content;}
  5592. if(res = response.match(/<insert>([\s\S]*)<\/insert>/u)){ content+=res[1]; }
  5593. info.innerHTML=content;
  5594. if(res = response.match(/<here>([\s\S]*)<\/here>/u)){
  5595. here.innerHTML=res[1]; window.here_b=document.getElementsByClassName('here_btn');
  5596. if(window.here_b)for(b=0;b<window.here_b.length;b++) {
  5597. window.here_b[b].addEventListener('mousemove',DontHideImgBtn);
  5598. window.here_b[b].addEventListener('mouseover',DontHideImgBtn);}
  5599. }
  5600. }
  5601. };
  5602. xhr.open("GET", "<?=$INDEXPHP?>?image_info="+imgsrc+"", true);
  5603. xhr.send();
  5604. }
  5605. function HideBigImage(do_push){
  5606. o = document.querySelector('#big_image_overlay');
  5607. img = document.querySelector('#big_image');
  5608. vid = document.querySelector('#big_video');
  5609. vidsrc = document.querySelector('#big_video_src');
  5610. img.src = ""; vidsrc.src="";
  5611. if(o.style.display!='none'){
  5612. o.style.display="none";
  5613. HideBackdrop();
  5614. if(do_push){PushGalleryHistory("");}
  5615. HideWaitingBar();
  5616. }
  5617. }
  5618. var lbtn=document.querySelector('#prev_image'),rbtn=document.querySelector('#next_image');
  5619. var inq=document.querySelector('#inquiry_buttons');
  5620. var overlay=document.querySelector('#big_image_overlay');
  5621. var hide_timeout;
  5622. function DontHideImgBtn(e){ clearTimeout(hide_timeout); e.stopPropagation(); }
  5623. function DelayHideImgBtn(e){
  5624. lbtn.classList.remove('img_btn_hidden'); rbtn.classList.remove('img_btn_hidden');
  5625. inq.classList.remove('img_btn_hidden');
  5626. if(window.here_b)for(b=0;b<window.here_b.length;b++){window.here_b[b].classList.remove('img_btn_hidden');}
  5627. clearTimeout(hide_timeout);
  5628. hide_timeout = setTimeout(function(e1,e2,e3,e4){e1.classList.add('img_btn_hidden');
  5629. e2.classList.add('img_btn_hidden');e3.classList.add('img_btn_hidden');
  5630. if(window.here_b)for(b=0;b<window.here_b.length;b++){
  5631. window.here_b[b].classList.add('img_btn_hidden');}}, 1000, lbtn, rbtn, inq);
  5632. }
  5633. lbtn.addEventListener('mousemove',DontHideImgBtn);lbtn.addEventListener('mouseover',DontHideImgBtn);
  5634. rbtn.addEventListener('mousemove',DontHideImgBtn);rbtn.addEventListener('mouseover',DontHideImgBtn);
  5635. inq.addEventListener('mousemove',DontHideImgBtn);inq.addEventListener('mouseover',DontHideImgBtn);
  5636. overlay.addEventListener('mousemove',DelayHideImgBtn);
  5637. function UpdateImageClickables(){
  5638. var images = document.querySelectorAll('.center img, .center video, .center_wide img, .center_wide video');
  5639. var images_filtered=new Array(); var imgadded = new Array();
  5640. var images_remaining=new Array();
  5641. [].forEach.call(images, function(img){
  5642. if(img.classList.contains("no_pop") || (!(imgsrc = img.dataset.imgsrc))) return;
  5643. if(imgadded.indexOf(imgsrc)>=0) {images_remaining.push(img); return;}
  5644. images_filtered.push(img);imgadded.push(imgsrc);
  5645. });
  5646. for(var i=0; i<images_filtered.length; i++){
  5647. previmg = nextimg = null; img = images_filtered[i];
  5648. if(i>0) previmg=images_filtered[i-1];
  5649. if(i<images_filtered.length-1) nextimg=images_filtered[i+1];
  5650. prevsrc=previmg?previmg.dataset.imgsrc:null; nextsrc=nextimg?nextimg.dataset.imgsrc:null;
  5651. img.dataset.prevsrc = prevsrc; img.dataset.nextsrc = nextsrc;
  5652. function wrap(imgsrc){return function(event){ShowBigImage(imgsrc, 1);}}
  5653. var clone = img.cloneNode(true); img.replaceWith(clone);
  5654. clone.addEventListener("click", wrap(img.dataset.imgsrc));
  5655. }
  5656. for(var i=0; i<images_remaining.length; i++){
  5657. img = images_remaining[i];
  5658. function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
  5659. var clone = img.cloneNode(true); img.replaceWith(clone);
  5660. clone.addEventListener("click", wrap(img.dataset.imgsrc));
  5661. }
  5662. document.images_filtered = images_filtered;
  5663. }
  5664. UpdateImageClickables();
  5665. function PopGalleryHistory(){
  5666. if(pushed){
  5667. pushed = 0;
  5668. try{
  5669. history.back();
  5670. }catch{
  5671. console.log("can't do it.");
  5672. }
  5673. }
  5674. }
  5675. function PushGalleryHistory(src){
  5676. abs_img = window.location.protocol+"//"+window.location.host+'/'+src
  5677. title = "照片"
  5678. extra = "?";
  5679. sp = new URLSearchParams(window.location.search)
  5680. if(sp.has('post')){extra+="post="+sp.get('post')}
  5681. if(sp.has('gallery')){extra+="&gallery="+sp.get('gallery')}
  5682. try{
  5683. window.history.pushState('&pic='+src, 'Title', extra+'&pic='+src);
  5684. }catch{
  5685. console.log("can't do it.");
  5686. }
  5687. pushed = 1;
  5688. }
  5689. document.addEventListener('keydown', function(e){
  5690. large = document.getElementById('big_image_overlay')
  5691. if (large.style.display!='block') return;
  5692. if(e.key=='Escape'||e.key=='Esc'||e.keyCode==27){
  5693. HideBigImage(1);
  5694. }
  5695. }, true);
  5696. window.addEventListener('popstate', (event) => {
  5697. href=window.location.href;
  5698. let sp = new URLSearchParams(href.substring(href.indexOf('?')))
  5699. if(sp.has('pic')){
  5700. src = sp.get('pic')
  5701. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)) ShowBigImage(onlyimg[0], 0);
  5702. else{HideBigImage(0);}
  5703. }else{HideBigImage(0);}
  5704. if(sp.has('post')){
  5705. id=sp.get('post');post=document.querySelector('.post[data-post-id="'+id+'"]');
  5706. if(post){ClickPost(post,null,false);}
  5707. }
  5708. });
  5709. let searchParams = new URLSearchParams(window.location.search)
  5710. if(searchParams.has('pic')){
  5711. src = searchParams.get('pic')
  5712. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)){
  5713. ShowBigImage(onlyimg[0], 1);
  5714. }
  5715. }
  5716. function _dropHandler(event){ if (typeof dropHandler === "function") dropHandler(event); }
  5717. function _dragOverHandler(event){ if (typeof dragOverHandler === "function") dragOverHandler(event); }
  5718. </script>
  5719. </body>
  5720. <?php
  5721. }
  5722. function DoIdentifyExperimental(){
  5723. if(isset($this->ExpHost) && $this->ExpHost && preg_match('/'.preg_quote($this->ExpHost).'/u', $_SERVER['HTTP_HOST'])){
  5724. $this->InExperimentalMode=True; $this->InHereMode=True;
  5725. if(!$this->AllowLanguageChoices){ $this->LanguageAppendix='en'; }
  5726. }
  5727. if(isset($this->HereHost) && $this->HereHost && preg_match('/'.preg_quote($this->HereHost).'/u', $_SERVER['HTTP_HOST'])){
  5728. $this->InHereMode=True;
  5729. }
  5730. //$this->InHereMode=True;
  5731. }
  5732. function DoExperimentalTopLink($p){
  5733. if($this->InHereMode && $p){
  5734. if(isset($p['tid']) && $p['tid']['first']!=$p){
  5735. header('Location: ?post='.$p['tid']['first']['id']); exit();
  5736. }
  5737. }
  5738. }
  5739. function MakeExperimentalConfirm(){ global $INDEXPHP;
  5740. if(isset($_COOKIE['la_experimental']) && $_COOKIE['la_experimental'] == 'confirmed'){
  5741. return false;
  5742. }
  5743. $caution_html =
  5744. $confirm = "<a class='text_highlight clean_a bold' href='".$INDEXPHP."?confirm_enter=1".
  5745. (isset($this->CurrentPostID)?("&post=".$this->CurrentPostID):"").
  5746. "'>&nbsp;&nbsp;".$this->T('继续')."&nbsp;&nbsp;</a>";
  5747. ?>
  5748. <div class='center_exp'><?php
  5749. if(isset($this->ExpCaution) && ($p=$this->GetPost($this->ExpCaution,true)))$this->MakeSinglePostExp($p);
  5750. else echo "<li class='post post_dummy'>".$this->TranslatePostParts("<h1>注意</h1><p>您将进入实验站。</p>")."</li>";
  5751. ?></div>
  5752. <div class='center_exp'><li class='post post_dummy'><p><?=$confirm?></p></li></div>
  5753. <?php return true;
  5754. }
  5755. }
  5756. $la = new LA;
  5757. $la->DoSiteRedirect();
  5758. $la->DoLogin();
  5759. $la->SwitchLanguageAndFont();
  5760. $err = $la->ProcessRequest($message, $redirect);
  5761. $la->WriteAsNecessary();
  5762. $la->DoIdentifyExperimental();
  5763. $la->SwitchWayBackMode();
  5764. if($err){
  5765. echo $message;
  5766. exit();
  5767. }
  5768. if(isset($redirect)){
  5769. header('Location: '.$redirect);
  5770. exit();
  5771. }
  5772. $la->DetectPageType();
  5773. $la->ReadImages(false);
  5774. $la->ReadPosts();
  5775. if(isset($la->WayBack)){
  5776. $la->ReadArchive();
  5777. }
  5778. $im = NULL;
  5779. if(isset($la->HereID) && preg_match('/images\/(.*)/u',$la->HereID,$imname) && ($im = &$la->FindImage($imname[1]))){
  5780. if(!$la->CanShowImage($im)) { $im=&$la->NULL_IMAGE; }
  5781. }
  5782. $p = &$la->GetPost($la->CurrentPostID);
  5783. if(!isset($p)){
  5784. $p = &$la->GetMergedPost($la->CurrentPostID);
  5785. }
  5786. if(isset($p) && !$la->CanShowPost($p)) $p=NULL;
  5787. else{ $la->DoExperimentalTopLink($p); }
  5788. if(isset($p)){ $la->ActualPostID = $p['id']; }
  5789. if($la->PageType=='here' ||$la->PageType=='experimental'){
  5790. if($im){
  5791. $la->SetHereMainImage($im);
  5792. $la->RecordVisitedHere($im['name'],$im?$la->ImageTitle($im):NULL);
  5793. }else if($p){
  5794. $la->RecordVisitedHere($p['id'],NULL);
  5795. }else {
  5796. $im = &$la->GiveImageInHere(false);
  5797. if($im){
  5798. $la->SetHereMainImage($im);
  5799. $la->RecordVisitedHere($im['name'],$la->ImageTitle($im));
  5800. }
  5801. }
  5802. }
  5803. $la->MakeHeader($p);
  5804. $la->MakeMainBegin();
  5805. if($la->PageType=='here' ||$la->PageType=='experimental'){
  5806. if(($la->PageType=='experimental' && (!$la->MakeExperimentalConfirm())) || $la->PageType=='here'){
  5807. if($im){
  5808. $la->MakeHereSection($im);
  5809. }else if($p){
  5810. $la->MakePostSectionExp($p);
  5811. $la->MakeLinkedPostsExp($p);
  5812. }else {
  5813. if($im){
  5814. $la->MakeHereSection($im);
  5815. }else{
  5816. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5817. "</p><p><a href='".$INDEXPHP."'>".$la->T('返回首页')."</a></p><br />";
  5818. }
  5819. }
  5820. }
  5821. $la->MakeMainEnd();
  5822. $la->MakeExpFooter();
  5823. }else{
  5824. if($la->PageType=='extras'){
  5825. $la->MakeExtraOperations();
  5826. }else if($la->PageType=='settings'){
  5827. $la->MakeSettings();
  5828. }else if($la->PageType=='gallery'){
  5829. $la->MakeGalleryLeft();
  5830. $la->MakeGallerySection();
  5831. }else if($la->PageType=='post'){
  5832. if($p){
  5833. $made_interesting = false;
  5834. if($la->IsInterestingPost($p)){
  5835. $la->MakeInterestingSection($p['tid']);
  5836. }
  5837. else{
  5838. $la->MakeSidebar();
  5839. $la->MakePostSectionV2($p);
  5840. echo $la->GeneratePage(1," section");
  5841. //$la->MakePostSection($p);
  5842. }
  5843. }else{
  5844. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5845. "</p><p><a href='".$INDEXPHP."'>".$la->T('返回首页')."</a></p><br />";
  5846. }
  5847. }else if($la->PageType=='history'){
  5848. $la->ReadArchive();
  5849. $la->MakePostHistory($p, $_GET['version']??NULL);
  5850. }else if($la->PageType=='search'){
  5851. $la->MakeSidebar();
  5852. $la->MakeRecentPostsV2($_GET['search']);
  5853. echo $la->GeneratePage();
  5854. }else if($la->PageType=='category'){
  5855. $la->MakeSidebar();
  5856. $la->MakeRecentPostsV2(NULL,$_GET['category']);
  5857. echo $la->GeneratePage();
  5858. }else if($la->PageType=='comments'){
  5859. $la->MakeCommentPosts();
  5860. }else if($la->PageType=='statistics'){
  5861. $la->MakeStatistics();
  5862. }else{
  5863. $la->MakeSidebar();
  5864. $la->MakeRecentPostsV2();
  5865. echo $la->GeneratePage();
  5866. }
  5867. $la->MakeMainEnd();
  5868. $la->MakeFooter($p);
  5869. }
  5870. ?>