12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116 |
- <?php
- include 'Parsedown.php';
- include 'ParsedownExtra.php';
- ini_set('max_execution_time', 300);
- if($_SERVER['HTTP_HOST']=='localhost'){
- ini_set('display_errors', '0');
- ini_set('display_startup_errors', '1');
- error_reporting(E_ALL);
- }
- global $LA_GLOBAL_LANG;
- global $INDEXPHP;
- $INDEXPHP='index.php';
- if($LA_GLOBAL_LANG=='en'){
- $INDEXPHP='en.php';
- }
- class LA{
- protected $PDE;
- protected $style;
-
- public $PAGE;
- public $AFTER;
- public $PSTACK;
- protected $PNUMBER;
- /* config */
- protected $Title;
- protected $ShortTitle;
- protected $Admin;
- protected $Password;
- protected $DisplayName;
- protected $EMail;
- protected $SpecialNavigation;
- protected $SpecialSidebar;
- protected $SpecialFooter;
- protected $SpecialFooter2;
- protected $SpecialPinned;
- protected $SpecialPinnedNotes;
- protected $DefaultGallery;
- protected $SelfAuthPath;
- protected $HereHost;
- protected $HereTitle;
- protected $HereShortTitle;
- protected $HereAlbum;
- protected $HereNavigation;
- protected $HereFooter;
- protected $ExpHost;
- protected $ExpAlbum;
- protected $ExpTitle;
- protected $ExpShortTitle;
- protected $ExpCaution;
- protected $ExpNavigation;
- protected $ExpFooter;
- protected $CommentEnabled;
- protected $MastodonToken;
- protected $MastodonURL;
- protected $MastodonPreferredLang;
- protected $HostURL;
- protected $GalleryStep;
- protected $AllowLanguageChoices;
-
- protected $Redirect;
- protected $Translations;
- protected $CustomTranslationContent;
- protected $CommentsPerPage;
- protected $UsePosts;
-
- protected $CurrentOffset;
- protected $PostsPerPage;
- protected $HotPostCount;
-
- protected $LoggedIn;
- protected $LoginTokens;
- protected $InHereMode;
- protected $InExperimentalMode;
- protected $LanguageAppendix;
- protected $UseRemoteFont;
- protected $NotesView;
-
- protected $Posts;
- protected $Threads; // [ keys: first last displayed count]
- protected $WaybackThreads;
- public $Images;
- protected $Galleries;
- protected $Anchors;
-
- protected $ArchiveHandles;
- protected $Archive;
- public $WayBack;
- protected $YearBegin;
- protected $YearEnd;
-
- protected $Markers;
-
- protected $ExtraScripts;
-
- protected $APubID;
- protected $APubActor;
- protected $APubPublicKey;
- protected $APubPrivateKey;
-
- protected $TIME_STRING;
-
- public $NULL_POST;
- public $NULL_IMAGE;
- public $NULL_IMAGE_DUMMY;
- public $NULL_Gallery;
-
- protected $DoneReadPosts;
- protected $DoneReadImages;
- protected $DoneReadArchive;
- protected $NeedWritePosts;
- protected $NeedWriteImages;
- protected $NeedWriteArchive;
-
- protected $HereDisplayTitle;
- protected $VisitedHere;
- protected $HereNumber;
- protected $HereMainImage;
-
- public $PageType;
- public $CurrentPostID;
- public $HereID;
- public $ActualPostID;
- public $TagID;
-
- function &_TRow(){ if(!isset($this->PAGE)){$this->PAGE=[];} if(!isset($this->PAGE[0])){$this->PAGE[]=[];} return $this->PAGE[array_key_last($this->PAGE)]; }
- function &TRow(){ $last=array_key_last($this->PAGE); if($this->PAGE[$last]==[]) return $this->PAGE[$last]; $this->PAGE[]=[]; return $this->PAGE[$last]; }
- 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; } }
- function TExtra($rowextra){ $a=&$this->_TRow(); $a['extra']=$rowextra; }
- function TAfter(&$content){ $this->AFTER.=$content; $content=''; }
- function TBackup(){ if(!isset($this->PSTACK)){$this->PSTACK=[];}; $this->PSTACK[]=$this->PAGE; $this->PAGE=[]; }
- function TRestore($extra=""){ if(!isset($this->PSTACK) || $this->PSTACK==[]) return "";
- $S=$this->GeneratePage(0,$extra); $this->PAGE=end($this->PSTACK); unset($this->PSTACK[array_key_last($this->PSTACK)]); return $S;
- }
-
- function ReadableTime($id){
- $dt = DateTime::createFromFormat('YmdHis', $id);
- return $dt->format('Y/m/d H:i:s');
- }
- function StandardTime($id){
- $dt = DateTime::createFromFormat('YmdHis', $id);
- return $dt->format('Y-m-d\TH:i:sP');
- }
- function FullURL(){
- return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?
- "https" : "http") . "://" . $_SERVER['HTTP_HOST'] .
- $_SERVER['REQUEST_URI'];
- }
- function T($str){
- if(!$this->LanguageAppendix) return $str;
- foreach($this->Translations as $entry){
- if($entry['zh']==$str)
- return $entry[$this->LanguageAppendix];
- }
- return $str;
- }
- function SwitchLanguageAndFont(){ global $LA_GLOBAL_LANG;
- $this->LanguageAppendix = 'zh';
- if(isset($_COOKIE['la_language'])){
- $this->LanguageAppendix = $_COOKIE['la_language'];
- }else{
- if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
- $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
- $lang = substr($lang,0,5);
- if(preg_match("/zh/i",$lang))$this->LanguageAppendix = 'zh';
- else $this->LanguageAppendix = 'en';
- }else{
- $this->LanguageAppendix = 'en';
- }
- }
- if(isset($LA_GLOBAL_LANG)){
- if($LA_GLOBAL_LANG=='en'){ $this->LanguageAppendix = 'en'; setcookie('la_language','en',time()+3600*24*7,'/'); }
- else if($LA_GLOBAL_LANG=='zh'){ $this->LanguageAppendix = 'zh'; setcookie('la_language','zh',time()+3600*24*7,'/'); }
- }
- if(isset($_COOKIE['la_font'])){
- $this->UseRemoteFont = ($_COOKIE['la_font']!='local');
- }
- if($this->LoggedIn && isset($_COOKIE['la_notes_view'])){ $this->NotesView=$_COOKIE['la_notes_view']; }
- }
- function SwitchWayBackMode(){
- if(isset($_COOKIE['la_wayback'])){
- $this->WayBack = $_COOKIE['la_wayback'];
- }else $this->WayBack = NULL;
- }
-
- function DisplayRedirectConfig(){
- $s = "";
- if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
- if($r['for']=='P'){
- $s.=("P ".$r['format'].":".$r['target'].";".PHP_EOL);
- }else if($r['for']=='S'){
- $s.=("S ".$r['format'].":".$r['domain'].":".$r['target'].";".PHP_EOL);
- }
- }
- return $s;
- }
-
- function DoSiteRedirect(){ global $INDEXPHP;
- if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
- if($r['for']=='S'){
- if(preg_match('/'.$r['format'].'/ui', $_SERVER['HTTP_HOST'])){
- if($_SERVER['REQUEST_URI']=='/'||$_SERVER['REQUEST_URI']==''){
- header('Location:https://'.$r['domain'].'/'.$INDEXPHP.'?post='.$r['target']); exit;
- }else{
- header('Location:https://'.$r['domain'].$_SERVER['REQUEST_URI']); exit;
- }
- }
- }
- }
- }
-
- function WriteHTACCESS(){
- $conf = fopen('.htaccess','w');
- fwrite($conf,"RewriteEngine on".PHP_EOL.PHP_EOL);
- if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
- if($r['for']=='P'){
- if(!preg_match('/[0-9]{14}/',$r['target'])){
- fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?'.$r['target'].' [R=302,L,NC]'.PHP_EOL.PHP_EOL);
- }
- fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?post='.$r['target'].' [R=302,L,NC]'.PHP_EOL.PHP_EOL);
- }// do site redirect in php.
- }
- fwrite($conf, 'RewriteCond %{HTTPS} !=on'.PHP_EOL.
- 'RewriteCond %{HTTP_HOST} !=localhost'.PHP_EOL.
- 'RewriteCond %{REQUEST_URI} !^.*(jpg|jpeg|png|gif)$'.PHP_EOL.
- 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]'.PHP_EOL.PHP_EOL);
- fwrite($conf,'<Files ~ "\.md$">'.PHP_EOL.'deny from all'.PHP_EOL.'</Files>'.PHP_EOL);
- fflush($conf);fclose($conf);
- }
-
- function BuildRedirectConfig($conf){
- $this->Redirect=[];
- if(preg_match_all('/P\s+(.*)\:\s*([0-9]{14}|.+)\s*;/u',$conf,$ma,PREG_SET_ORDER)){
- foreach($ma as $m){
- $redirect=[]; $redirect['for'] = 'P'; $redirect['format'] = $m[1]; $redirect['target'] = $m[2];
- $this->Redirect[]=$redirect;
- }
- }
- if(preg_match_all('/S\s+(\S+)\s*\:\s*(\S+)\s*\:\s*([0-9]{14})\s*;/u',$conf,$ma,PREG_SET_ORDER)){
- foreach($ma as $m){
- $redirect=[]; $redirect['for'] = 'S'; $redirect['format'] = $m[1]; $redirect['domain'] = $m[2]; $redirect['target'] = $m[3];
- $this->Redirect[]=$redirect;
- }
- }
- }
-
- function WriteTokens(){
- $tf = fopen('la_tokens.php','w');
- fwrite($tf,'<?php header("Location:index.php"); exit; ?>'.PHP_EOL.PHP_EOL);
- if(isset($this->LoginTokens) && sizeof($this->LoginTokens)) {
- foreach($this->LoginTokens as $t){
- fwrite($tf,'- '.$t.PHP_EOL);
- }
- }
- fflush($tf);fclose($tf);
- }
-
- function WriteConfig(){
- if(!isset($this->Title)) $this->Title = $this->T('那么的维基');
- if(!isset($this->ShortTitle)) $this->ShortTitle = $this->T('基');
- if(!isset($this->Admin)) $this->Admin = 'admin';
- if(!isset($this->DisplayName)) $this->DisplayName = $this->T('管理员');
- if(!isset($this->Password)) $this->Password = password_hash('Admin', PASSWORD_DEFAULT).PHP_EOL;
- $conf = fopen('la_config.php','w');
- fwrite($conf,'<?php header("Location:index.php"); exit; ?> '.PHP_EOL.PHP_EOL);
- fwrite($conf,'- Title = '.$this->Title.PHP_EOL);
- fwrite($conf,'- ShortTitle = '.$this->ShortTitle.PHP_EOL);
- fwrite($conf,'- Admin = '.$this->Admin.PHP_EOL);
- fwrite($conf,'- DisplayName = '.$this->DisplayName.PHP_EOL);
- fwrite($conf,'- Password = '.$this->Password.PHP_EOL);
- fwrite($conf,'- EMail = '.$this->EMail.PHP_EOL);
- fwrite($conf,'- SpecialNavigation = '.$this->SpecialNavigation.PHP_EOL);
- fwrite($conf,'- SpecialSidebar = '.$this->SpecialSidebar.PHP_EOL);
- fwrite($conf,'- SpecialFooter = '.$this->SpecialFooter.PHP_EOL);
- fwrite($conf,'- SpecialFooter2 = '.$this->SpecialFooter2.PHP_EOL);
- fwrite($conf,'- SpecialPinned = '.$this->SpecialPinned.PHP_EOL);
- fwrite($conf,'- SpecialPinnedNotes = '.$this->SpecialPinnedNotes.PHP_EOL);
- fwrite($conf,'- DefaultGallery = '.$this->DefaultGallery.PHP_EOL);
- fwrite($conf,'- SelfAuthPath = '.$this->SelfAuthPath.PHP_EOL);
- fwrite($conf,'- CommentEnabled = '.($this->CommentEnabled?"True":"False").PHP_EOL);
- fwrite($conf,'- NewsletterEnabled = '.($this->NewsletterEnabled?"True":"False").PHP_EOL);
- fwrite($conf,'- HereHost = '.$this->HereHost.PHP_EOL);
- fwrite($conf,'- HereTitle = '.$this->HereTitle.PHP_EOL);
- fwrite($conf,'- HereShortTitle = '.$this->HereShortTitle.PHP_EOL);
- fwrite($conf,'- HereAlbum = '.$this->HereAlbum.PHP_EOL);
- fwrite($conf,'- HereNavigation = '.$this->HereNavigation.PHP_EOL);
- fwrite($conf,'- HereFooter = '.$this->HereFooter.PHP_EOL);
- fwrite($conf,'- ExpHost = '.$this->ExpHost.PHP_EOL);
- fwrite($conf,'- ExpTitle = '.$this->ExpTitle.PHP_EOL);
- fwrite($conf,'- ExpShortTitle = '.$this->ExpShortTitle.PHP_EOL);
- fwrite($conf,'- ExpCaution = '.$this->ExpCaution.PHP_EOL);
- fwrite($conf,'- ExpAlbum = '.$this->ExpAlbum.PHP_EOL);
- fwrite($conf,'- ExpNavigation = '.$this->ExpNavigation.PHP_EOL);
- fwrite($conf,'- ExpFooter = '.$this->ExpFooter.PHP_EOL);
- fwrite($conf,'- MastodonToken = '.$this->MastodonToken.PHP_EOL);
- fwrite($conf,'- MastodonURL = '.$this->MastodonURL.PHP_EOL);
- fwrite($conf,'- MastodonPreferredLang = '.$this->MastodonPreferredLang.PHP_EOL);
- fwrite($conf,'- HostURL = '.$this->HostURL.PHP_EOL);
- fwrite($conf,'- APubID = '.$this->APubID.PHP_EOL);
- fwrite($conf,'- GalleryStep = '.$this->GalleryStep.PHP_EOL);
- fwrite($conf,'- AllowLanguageChoices = '.$this->AllowLanguageChoices.PHP_EOL);
- fflush($conf);fclose($conf);
- $conf = fopen('la_redirect.md','w');
- fwrite($conf,$this->DisplayRedirectConfig());fflush($conf);fclose($conf);
- $this->WriteHTACCESS();
- $this->WriteTokens();
- }
-
- function Install(){
- if(!file_exists('la_config.php')){
- $this->WriteConfig();
- }
- if(!is_dir('posts')) mkdir('posts');
- if(!is_dir('images')) mkdir('images');
- if(!is_dir('images/thumb')) mkdir('images/thumb');
- if(!is_dir('styles')) mkdir('styles');
- if(!is_dir('archive')) mkdir('archive');
-
- $this->WriteStyles();
- $this->WriteHTACCESS();
- }
-
- function ReadFromExistingConfig(){
- $f=null;
- if(file_exists('la_config.php')) $f='la_config.php';
- else if(file_exists('la_config.md')) $f='la_config.md';
- if(!isset($f)) return;
- $c = file_get_contents($f);
- if(preg_match_all('/-\s*(\S+)\s*=\s*(\S+)\s*$/um', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
- $str = $m[1];
- $this->$str = $m[2];
- }
- $this->CommentEnabled = $this->CommentEnabled=="True";
- if(!isset($this->GalleryStep)) $this->GalleryStep=20;
- }
-
- function ReadConfig(){
- $this->ReadFromExistingConfig();
- if(file_exists('la_redirect.md')){
- $c = file_get_contents('la_redirect.md');
- $this->BuildRedirectConfig($c);
- }
- if(!file_exists('la_config.php')){
- $this->Install();
- }
- $this->Translations=[];
- if(file_exists("translations.md")){
- $c = file_get_contents('translations.md');
- if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
- $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
- $this->Translations[] = $entry;
- }
- }
- if(file_exists("custom_translations.md")){
- $this->CustomTranslationContent = file_get_contents('custom_translations.md');
- if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$this->CustomTranslationContent, $ma, PREG_SET_ORDER)) foreach($ma as $m){
- $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
- $this->Translations[] = $entry;
- }
- }
- $this->LoginTokens=[];
- if(file_exists('la_tokens.php')){
- $c = file_get_contents('la_tokens.php');
- if(preg_match_all('/-\s+(\S.*)\s*$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
- $this->LoginTokens[] = $m[1];
- }
- }
- }
-
- function MastodonPostStatus($status){ return $this->MastodonCall('/api/v1/statuses', 'POST', $status); }
- function MastodonPostMedia($media){ return $this->MastodonCall('/api/v1/media', 'POST', $media); }
- function MastodonCall($endpoint, $method, $data){
- $headers = [
- 'Authorization: Bearer '.$this->MastodonToken,
- 'Content-Type: multipart/form-data',
- ];
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $this->MastodonURL.$endpoint);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- $reply = curl_exec($ch);
- if (!$reply) {
- return json_encode(['ok'=>false, 'curl_error_code' => curl_errno($ch_status), 'curl_error' => curl_error(ch_status)]);
- }
- curl_close($ch);
- return json_decode($reply, true);
- }
- function MastodonSendPost(&$post, &$errmsg=NULL){
- if(isset($post['mark_value']) && $post['mark_value']==7){ return NULL; }
-
- $this->LanguageAppendix = 'zh';
- if(in_array($this->MastodonPreferredLang,['en','zh'])){ $this->LanguageAppendix = $this->MastodonPreferredLang; }
-
- $this->ConvertPost($post);
- $media_ids = NULL;
- $mastodon_post_url = NULL;
-
- $imcount = 0;
- if(isset($post['original_images']) && isset($post['original_images'][0])) foreach($post['original_images'] as $im){
- $curl_file = curl_file_create($im, mime_content_type($im), basename($im));
- $body = ['file' => $curl_file,]; $response = $this->MastodonPostMedia($body);
- if(isset($response['id'])){ if(!isset($media_ids)){$media_ids=[];} $media_ids[]=$response['id']; }
- else{ if(isset($response['error'])) $errmsg.=$response['error']."<br /><br />"; }
- $imcount++; if($imcount>=4){ break; }
- }
-
- $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$post['html']));
- if(isset($this->HostURL) && $this->HostURL!=""){
- $text.=("\n\n".$this->T('来自').' '.$this->HostURL.'?post='.$post['id']);
- }
-
- $vis = (isset($post['mark_value']) && $post['mark_value']==6)?"private":"public";
- $status_data = [ 'status' => $text, 'visibility' => $vis, 'language' => $this->LanguageAppendix, ];
- if(isset($post['prev']) && ($pp=&$this->GetPost($post['prev']))!=$this->NULL_POST){
- if(isset($pp['mastodon_url'])){ $status_data['in_reply_to_id'] = basename($pp['mastodon_url']);
- }
- }
- if(isset($media_ids[0])){ $status_data['media_ids']=$media_ids; }
- $status_data = preg_replace('/(media_ids%5B)[0-9]+(%5D)/','$1$2', http_build_query($status_data));
-
- $status_response = $this->MastodonPostStatus($status_data);
- if(isset($status_response['url']) && $status_response['url']){
- $mastodon_post_url = $status_response['url'];
- $post['mastodon_url'] = $mastodon_post_url;
- $this->NeedWritePosts = 1;
- }
- if(isset($status_response['error'])) { $errmsg .= $status_response['error']; }
-
- return $mastodon_post_url;
- }
-
- function __construct() {
- $this->ReadConfig();
- $this->PDE = new ParsedownExtra();
- $this->PDE->SetInterlinkPath('/');
- $this->Posts = [];
- $this->Threads = [];
- $this->VisitedHere = [];
-
- $this->NULL_IMAGE_DUMMY = [];
- $this->NULL_IMAGE_DUMMY['name']=$this->NULL_IMAGE_DUMMY['file']=$this->NULL_IMAGE_DUMMY['thumb']="";
-
- $this->Markers=['●', '○', '✓', '×', '!', 'P', 'E', 'S', 'N'];
-
- $this->PostsPerPage = 40;
- $this->CommentsPerPage = 100;
- $this->HotPostCount = 15;
-
- $this->TIME_STRING = date('YmdHis');
- $this->WayBack = NULL;
- $this->YearBegin = $this->YearEnd = 2000;
- $this->DoneReadPosts = $this->DoneReadImages = $this->DoneReadArchive = false;
- $this->NeedWritePosts= $this->NeedWriteImages= $this->NeedWriteArchive= false;
- $this->UsePosts = &$this->Posts;
- $this->PNUMBER=0;
- }
-
- function DoLogout(){
- $this->LoggedIn = false;
- unset($_SESSION['user_id']);
- $this->RecordToken(true);
- }
-
- function RecordToken($unset_current=false){
- if(isset($unset_current) && isset($_COOKIE['la_token'])){
- $t = $_COOKIE['la_token'];
- setcookie('la_token', null, -1,'/'); unset($_COOKIE['la_token']);
- if (($key = array_search($t,$this->LoginTokens)) !== false) { unset($this->LoginTokens[$key]); }
- $this->WriteTokens();
- return null;
- }else{
- $t = uniqid('la_',true);
- setcookie('la_token',$t,time()+3600*24*7,'/'); $_COOKIE['la_token'] = $t;
- $this->LoginTokens[] = $t;
- $this->WriteTokens();
- return $t;
- }
- }
-
- function LoginThroughToken(){
- if(!isset($_COOKIE['la_token'])) return false;
- $t = $_COOKIE['la_token'];
- if (($key = array_search($t,$this->LoginTokens)) !== false) {
- $_SESSION['user_id']=$this->Admin;
- $this->LoggedIn = true;
- setcookie('la_token',$t,time()+3600*24*7,'/');
- return true;
- }
- return false;
- }
-
- function DoLogin(){
- session_start();
- $redirect=false;
- if(isset($_GET['logout'])){ $this->DoLogout(); header('Location:index.php'); }
- else if(!isset($_SESSION['user_id'])){
- if(isset($_POST['login_button'])){
- $id = trim($_POST['login_id']);
- $pwd = trim($_POST['login_password']);
- if(strtolower($this->Admin)==strtolower($id)&&password_verify($pwd, $this->Password)){
- $_SESSION['user_id']=$id;
- $this->RecordToken(false);
- }
- $redirect = true;
- }else if($this->LoginThroughToken()){
- // nothing;
- }
- }else{
- if(strtolower($_SESSION['user_id']) == strtolower($this->Admin)){ $this->LoggedIn = true; }
- else{ $this->DoLogout();}
- }
- if($redirect){
- header('Location:index.php'.(isset($_GET['post'])?("?post=".$_GET['post']):"")
- .(isset($_GET['settings'])?"?settings=true":""));
- }
- }
- function SetHereMainImage($im_this){
- if(isset($im_this) && isset($im_this['parent'])){ $this->HereMainImage = &$this->FindImage($im_this['parent'],true);}
- }
- function RecordVisitedHere($image_or_post_name, $image_title){
- $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
- if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
- if(!(isset($_SESSION[$visited_here][0]) && in_array($image_or_post_name,$_SESSION[$visited_here]))){
- $_SESSION[$visited_here][] = $image_or_post_name;
- }
- if(isset($image_title)){ $this->HereDisplayTitle=$image_title; }
- $this->HereNumber = array_search($image_or_post_name,$_SESSION[$visited_here])+1;
- $_SESSION['here_number'] = $this->HereNumber;
- $this->VisitedHere = $_SESSION[$visited_here];
- }
- function HereLinkFromNumber($number){
- $number -= 1; if($number<0){ $number=0; }
- if($number>=sizeof($this->VisitedHere)){ $number = sizeof($this->VisitedHere)-1; }
- if(preg_match('/(jpg|jpeg|png|gif)/u',$this->VisitedHere[$number])){ return "?here=images/".$this->VisitedHere[$number]; }
- else{ return "?post=".$this->VisitedHere[$number]; }
- }
-
- function WriteStyles(){
- $this->style="
- html{font-size:18px;font-family:'Noto Serif CJK SC','Times New Roman','SimSun', Georgia, serif;}
- .page{overflow:none;}
- body{background-color:%white%;color:%black%;}
- sup,sub{line-height:0;} .lpctrl{display:none;}
- blockquote{border-left:2px solid %black%;padding-left:0.3em;}
- *{box-sizing:border-box;padding:0;margin:0;font-weight:normal;}
- b,strong,th{font-weight:bold;}
- select{font-size:inherit;}
- .page,.page_gallery{padding:1em;padding-top:0;padding-bottom:0;}
- .hidden_on_desktop,.hidden_on_wide{display:none;}
- .hidden_on_desktop_force{display:none !important;}
- ::file-selector-button{background:none;border:none;}
- a,button,::file-selector-button{text-decoration:underline;color:%black%;text-decoration-thickness:2px;text-underline-offset:0.15em;}
- a:hover,.button:hover,::file-selector-button:hover{text-decoration:none;color:%gray%;}
- .button:disabled{background-color:%gray%;pointer-events:none;}
- 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%;}
- 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;}
- header>div{overflow:auto;white-space:nowrap;}
- .header_nav{display:inline;}
- header a,.left a,.footer a,.clean_a,.clean_a a{text-decoration:none;}
- header a:hover,.button:hover{color:%gray% !important;text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:0.15em;}
- .exp_h_f{padding-top:0.3em !important;padding-bottom:0.3em !important;line-height:1.5em !important;height:2.1em !important;}
- .exp_f{text-align:center;}
- .toc_button{position:absolute;top:0.5em;right:0;text-shadow: 0px 0px 10px %white%;background-color:%white%88;}
- .footer{background-color:%white%;z-index:10;position:relative;}
- .invert_a,.invert_a a{color:%gray%;text-decoration:none;}
- .invert_a:hover,.invert_a a:hover{color:%black% !important;}
- .gray,.gray a{color:%gray%;}
- hr{border:1px solid %gray%;}
- header ul,.small_footer ul,.small_footer span,header li,.small_footer li{display:inline-block;vertical-align:text-top;}
- header li::before,.small_footer li::before{content:' - '}
- header li ul{display:none;}
- header:hover li ul{display:inline;}
- header li ul li{display:block !important;margin-left:1em;}
- header li ul li a{font-size:0.9em;}
- //h1,h2,h3,h4,h5{font-size:1em;}
- //h1{text-decoration:underline;}
- header h1,header h2,header h3,header h4,header h5,header p{display:inline;font-size:1rem;}
- .main{position:relative;word-spacing:-1em;top:2em;margin-bottom:2em;}
- .main *{word-spacing:initial;}
- pre{overflow:auto;display:block;line-break:anywhere;white-space:pre-wrap;}code{font-size:0.83em;}
- ul{display:block;}
- li{display:block;}
- .clean_table{border:none;font-size:1em !important;}.clean_table thead{box-shadow:none;}.clean_table td{vertical-align:top;}
- table{width:100%;border-collapse:collapse;border-bottom:2px solid %black%;border-top:3px solid %black%;}
- .settings input,.post inpiut{border:none!important;}
- .post table img{max-width:min(100%, 20rem) !important;}
- td{padding-left:0.1em;padding-right:0.1em;}
- td:first-child{padding-left:0;}
- td:last-child{padding-right:0;}
- tbody tr:hover{box-shadow:inset 0 -2px 0 0px %black%;}
- thead{box-shadow:inset 0 -1px 0 0px %black%;}
- .post table{font-size:0.85em;}
- .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 20em);}
- .interesting_tbody td{display:contents;}
- .interesting_tbody tr{position:relative;scroll-margin:4.5em}
- .interesting_tbody td>*{display:table-cell;}
- .interesting_tbody td>.wscroll{display:none !important;}
- .interesting_tbody .post_access{padding-top:0;}
- .interesting_tbody .post_menu_button{top:0;opacity:0;}
- .interesting_tbody td>img,.interesting_tbody td>.imd{position:absolute;left:1.4em;z-index:-1;height:1em;width:20em;
- display:flex;top:0.2em;object-fit:cover;max-width:calc(100% - 1.4em) !important;overflow:hidden;}
- .interesting_tbody td>.imd>a{display:flex;}
- .interesting_tbody img{object-fit:cover;width:100%;}
- .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);}
- .interesting_tbody .p_thumb{height:1em;}
- .interesting_tbody .p_thumb img,.interesting_tbody .p_thumb video{max-height:10rem !important;max-width:20rem !important;}
- tr:hover .post_menu_button{opacity:1;}
- .post_current_row{background-color:%graybkg%;mix-blend-mode:screen;text-shadow:0px 0px 0.1em %white%;}
- .align_right{text-align:right;}
- .left{display:inline-block;vertical-align:top;width:25%;padding-right:1.5em;padding-bottom:4rem;position:sticky;top:2em;
- overflow:auto;max-height:calc(100vh - 2.6em);}
- .center{display:inline-block;vertical-align:top;width:50%;overflow:visible;padding-bottom:4rem;}
- .center_slides{display:block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;font-size:5vmin;user-select:none;}
- .center_slides .print_column{display:table;position:fixed;top:0;right:0;left:0;bottom:0;width:100%;height:100%;z-index:90;}
- .center_slides .print_column .post{display:table-cell;vertical-align:middle;padding:5vmin !important;max-height:100vh;width:100vw;overflow:auto;}
- .center_slides .active_post{background-color:%white%;}.center_slides .post{background-color:%white%;}
- .center_slides .post_access{display:none;}
- .center_slides .post_menu_button{display:none !important;}
- .center_slides .post_width{display:block;vertical-align:middle;max-height:100vh;overflow-y:auto;overflow-x:hidden;width:100%;}
- .center_slides .linked_posts{display:none;}.center_slides .ref_compact{position:relative!important;display:block!important;}
- .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;}
- .slides_buttons a{text-decoration: none;}
- .center_slides .imd{text-align:center;pointer-events:none;}
- .imd_float{float:right;width:50% !important;clear:both;margin-left:0.5em !important;}
- .center_wide{display:inline-block;vertical-align:top;width:75%;padding-left:0.3em;overflow:visible;padding-bottom:4rem;}
- .center_full{display:inline-block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;}
- .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;}
- .linked_posts{padding:0.5em;background-color:#0004;box-shadow:0px 0.2em 0.2em -0.2em inset %shadow%;}
- .active_post .linked_posts{background-color:%highlight_slice%;}
- input:checked~.linked_posts,input:checked~a{display:none;}
- .bkg_recent>.post,.bkg_section{background:%post_white%;box-shadow:0em 0em 0.5em %shadow%;margin-bottom:0.5em;}
- .bkg_recent>.post>.post_width :last-child{margin-bottom:0;}
- .sticky_title{position:sticky;top:calc(1.6rem + 2px);z-index:1;background-color:%white%;pointer-events:none;}
- .center_exp{display:block;width:80%;margin:0 auto;overflow:visible;padding-bottom:1em;}
- .table_top{position:relative;left:calc(-50% - 0.45em);width:calc(200% + 0.6em);background:%white%;z-index:1;
- box-shadow:0px 0px 2em 1em %white%;margin-top:2em;margin-bottom:2em;}
- textarea,input[type=text],input[type=password]{font-family:monospace;width:100%;display:block;font-family:inherit;max-height:60vh;font-size:inherit;}
- select,textarea,input[type=text],input[type=password]{font-family:monospace;background:none;border:none;border-bottom:1px solid %black%;color:%black%;}
- .text_highlight input{border-bottom:1px solid %white%;color:%white%;}
- .button{background:none;border:none;font-family:inherit;color:%black%;font-size:inherit;font-weight:bold;}
- .post{position:relative;scroll-margin:3.5em;}
- .active_post{background-color:%highlight_white%;}.active_post .post_access{background-color:%highlight_slice%;}
- .center_exp .post{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;}
- .post li,.footer_additional li,.footer_additional li,.post_dummy li
- {display:list-item;margin-left:1em;list-style:disc;}
- .post li li,.footer_additional li li,.footer_additional li li,.post_dummy li li
- {list-style:circle;}
- ol li{list-style:unset !important;}
- .post_width > *,.post_dummy > *,.post_ref > *{margin:0;margin-bottom:0.5rem}
- .post > td:nth-child(3) > *{margin:0;margin-bottom:0.5rem}
- .post_dummy > *{width:60%;margin:0 auto;margin-bottom:0.5rem}
- .post_dummy > p img{display:block;width:100%;margin:0 auto;}
- .gallery_left li{display:list-item;margin-left:1em;list-style:none;}
- .gallery_left .selected{list-style:'→';}
- .bkg_section .post_width{padding-top:0;padding-bottom:0;}
- .bkg_section .restart+.post .post_width{padding-top:0.5em;}
- .post_width{display:inline-block;margin-left:0.5em;vertical-align:top;}
- .opt_compact .post_width,.ref_compact .post_width{padding-top:0;padding-bottom:0;}
- .p_thumb .post_menu_button{right:0.3rem;top:0.3em;}
- .post_menu_button{position:absolute;display:none;right:0rem;width:1.5rem;box-shadow:0px 0px 3px %shadow%;
- text-align:center;border-radius:0.3em;user-select:none;cursor:pointer;z-index:10;background-color:%post_white%aa;}
- .pointer{cursor:pointer;}
- .post:hover .post_menu_button{display:block;}
- .pop_menu{position:absolute;top:0.3rem;z-index:95;background-color:%grayslice%;
- padding:0.3em;right:0.3rem;text-align:right;border-radius:0.3em;font-size:1rem;
- box-shadow:0px 0px 10px %shadow%;}
- .pop_menu li{list-style:none;margin-left:0;}
- .pop_menu hr{border:2px solid rgba(0,0,0,0.1);}
- .toc{left:60%;width:40%;top:0;position:absolute;}
- .paa{width:1.4rem;min-width:1.4rem;}
- .opt_compact .post_access,.ref_compact .post_access{border-right:2px solid %gray%;background-color:%post_white%;right:unset;left:-2em;}
- .active_post .opt_compact .post_access,.active_post .ref_compact .post_access{background-color:%highlight_white%;}
- .post_preview{overflow:hidden;margin-bottom:0.4em;background-color:%white%aa;box-shadow: 0px 0px 0.2em %shadow%;}
- .post_preview:hover{filter:contrast(90%);}
- .active_post .post_preview:hover{filter:contrast(90%);}
- .hide_long{max-height:12em;overflow:hidden !important;}
- .post .post_ref{margin:0;padding-left:1.5rem;}
- .post_ref_main{display:inline-block;vertical-align:top;max-height:6em;overflow:hidden;margin:0.4em;}
- .post_ref_images{overflow:hidden;margin:0.4em;margin-top:0;}
- .post_ref_hint{text-align:right;}
- .page_selector{padding-top:2rem;text-align:center;}
- .smaller{font-size:0.85em;} .bigger{font-size:1.3em;} .block{display:block;}
- .restart{text-align:left;padding-top:1rem;padding-bottom:0.5rem;}
- .opt_compact{margin-left:2rem;}
- .post_box_top{padding-bottom:0.3em;padding-top:0.3em;}
- .post_box_fixed_bottom{position:sticky;bottom:0em;background-color:%white%;z-index:5;}
- .spacer{height:0.5em;}
- .pop_right,.pop_right_big{position:fixed;top:0;right:0;bottom:0;width:30%;z-index:100;background-color:%graybkg%;display:none;
- transition-timing-function:ease-out;padding:1rem;overflow:auto;}
- @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
- @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
- @keyframes pop_slide_in_big{0%{right:-30%;}100%{right:0%;}}
- @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-30%;}}
- .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;}
- @keyframes backdrop_fade_in{0%{opacity:0%;}100%{opacity:100%;}}
- @keyframes backdrop_fade_out{0%{opacity:100%;}100%{opacity:0%;}}
- .toc_entry_1{font-size:1.1em;}
- .toc_entry_2{font-size:1.0em;padding-left:0.5rem;}
- .toc_entry_3{font-size:0.9em;padding-left:1rem;}
- .toc_entry_4{font-size:0.85em;padding-left:1.5rem;}
- .toc_entry_5{font-size:0.8em;padding-left:2rem;}
- h1,h2,h3,h4,h5{scroll-margin:2.5em;}
- .post h1,.post h2,.post h3,.post h4,.post h5{margin-top:1rem;}
- .left ul h1,.left ul h2,.left ul h3,.left ul h4,.left ul h5,.left ul p{font-size:1em;}
- .deleted_post{color:%gray%;text-decoration:line-through;}
- #file_list{margin-top:0.5em;}
- .file_thumb img,.file_thumb video{max-height:100%;max-width:100%;object-fit:cover;min-width:100%;min-height:100%;}
- .file_thumb video{border:2px dashed %black%;}f
- #file_list li{margin-bottom:0.3em;}
- .ref_thumb{white-space:nowrap;overflow:hidden;}
- .ref_thumb .file_thumb{width:2em;height:2em;margin:0;margin-right:0.3em}
- .side_thumb li{margin:0.4em;display:inline-block;}
- .file_thumb{width:4em;height:4em;display:inline-block;line-height:0;vertical-align:middle;overflow:hidden;}
- .p_row{display:flex;flex-wrap:wrap;width:100%;}
- .p_thumb{display:flex;flex-grow:100;height:6rem;overflow:hidden;position:relative;margin-right:0.5em;margin-bottom:0.5em;}
- .p_thumb_narrow{width:1rem !important;flex-grow:1;opacity:0.2;}
- .p_thumb img,.p_thumb video{object-fit:cover;max-height:100%;min-width:100%;}.p_thumb a{display:contents;}
- .p_thumb:hover .post_menu_button{display:block;}
- .p_thumb_selected{color:%black% !important;}
- .p_thumb_selected{display:block;}
- .post .p_thumb img,.post .p_thumb video{max-height:6rem;}
- .p_thumb video{border-bottom:0.4em dashed %black%;border-top:0.4em dashed %black%;}
- .p_thumb_end{flex-grow:10000 !important;box-shadow:none;align-items:center;padding:2em !important;}
- .p_thumb_end:hover, .p_thumb_end a:hover{background-color:%gray%;cursor:pointer;}
- .big_image_box{position:fixed;top:0;bottom:0;left:0;width:75%;z-index:95;text-align:center;pointer-events:none;}
- .big_image_box *{pointer-events:auto;}
- .big_image_box img,.big_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
- .here_image_box{position:relative;width:100%;text-align:center;height:calc(100vh - 4.5em);}
- .here_image_box img,.here_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
- .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;}
- .big_side_box a,.big_side_box hr,#dropping_background{color:%black%;}
- .big_side_box a:hover{color:%gray%;}
- .big_side_box *{pointer-events:auto;}
- .big_side_box .post_preview{border-bottom:1px dotted %black%;background-color:unset;}
- .image_nav{pointer-events:none;}
- #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;
- box-shadow:0px 0px 500px black inset;display:flex;align-items:center;}
- img,video{cursor:pointer;max-height:100%;max-width:100%;vertical-align:middle;}
- .post img,.post video{max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
- .post > a > img,.post > a > video{display:block;margin:0.3em auto;}
- .post .original_img{max-width:100%;display:inline-block;vertical-align:middle;
- margin-left:auto;margin-right:auto;max-width:100%;max-height:90vh;}
- .center_exp .post .original_img{display:block;}
- .original_img img,.original_img video{max-height:90vh;max-width:100%;}
- .p_row .original_img{margin-bottom:0;}
- .post_ref .original_img{margin:unset;max-width:unset;max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
- .imbtn{color:rgba(0,0,0,0);display:block;contain:content;padding:0.25em;margin-bottom:0.5em;text-decoration:none;}
- .imbtn img{display:block;object-fit:cover;position:absolute;top:0;left:0;bottom:0;right:0;margin:auto;z-index:-1;
- min-width:100% !important;min-height:100% !important;filter:opacity(70%);transition:0.1s;}
- .imbtn:hover img{filter:opacity(20%) blur(0.2em);} .imbtn:hover{color:%black% !important;}
- .imbtn:hover {color:%black%;text-shadow:0px 0px 5px %white%;}
- header .imbtn{display:inherit;border:none;padding:0em;height:unset;height:unset;margin:0em;contain:unset;}
- header .imbtn:hover{border:none;color:%gray% !important;} header .imbtn img{display:none;}
- .b ul{font-size:1.4em;}
- no_pop{cursor:unset;}
- p{min-height:0.8em;}
- .bold,.bold *{font-weight:bold;}
- .footer_additional{display:inline-block;width:50%;vertical-align:text-top;white-space:normal;}
- .small_footer{background-color:%white%;padding-bottom:0.5em;position:sticky;bottom:0px;z-index:10;box-shadow: 0.5em 0px %white%;}
- .small_footer>div{overflow:auto;white-space:nowrap;}
- .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;}
- .top_post_hint{margin-left:0.5em;font-weight:bold;}
- .white{color:%white%;}
- .full_box{border:1px solid %black% !important;padding:0.3rem;overflow:auto;}
- .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;
- transition:background-size .2s ease;padding:0.5em;text-shadow:0px 0px 5px black;user-select:none;pointer-events:auto;}
- .image_nav_prev{left:0;justify-content:left;background:linear-gradient(to left, rgba(0,0,0,0), rgba(0,0,0,0.4));
- background-repeat:no-repeat;background-size:0% 100%;}
- .image_nav_prev:hover,.image_nav_next:hover{background-size:100% 100%;}
- .image_nav_next{right:0;justify-content:right;background:linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.2));
- background-repeat:no-repeat;background-size:0% 100%;transition:background-size .2s ease;background-position-x:100%;}
- .inquiry_buttons{position:fixed;left:0;right:25%;text-align:center;bottom:1em;margin:0 auto;width:max-content;
- background-color:rgba(0,0,0,0.5);z-index:110;padding:0.2em;padding-left:1em;padding-right:1em;
- border-radius:1em;box-shadow:0px 0px 5px;text-shadow:0px 0px 5px black;opacity:1;user-select:none;}
- .lr_buttons{background-color:rgba(0,0,0,0.5);padding:0.5em;padding-top:1em;padding-bottom:1em;
- border-radius:1em;box-shadow:0px 0px 5px;font-size:1.2rem;text-shadow:0px 0px 5px black;}
- .img_btn_hidden{opacity:0;transition:opacity 0.2s;}
- .special_alipay{background-color:#027aff;color:white;white-space:nowrap;
- font-family:sans-serif;font-weight:bold;border-radius:0.7em;font-size:0.75em;padding:0.25em;}
- .special_paypal{background-color:white;color:#253b80;white-space:nowrap;
- font-family:sans-serif;font-weight:bold;border-radius:2em;font-size:0.75em;
- padding:0.25em;padding-left:0.5em;padding-right:0.65em;font-style: italic;}
- .special_paypal_inner{color:#169bd7;}
- #waiting_bar{position:fixed;z-index:200;top:0;left:0;right:0;height:0.2em;background-color:%black%;transform:translate(-100%,0);
- animation:anim_loading 1s linear infinite;}
- @keyframes anim_loading{0%{transform:translate(-100%,0);} 100%{transform:translate(100%,0);}}
- .product_ref{width:32%;padding:0.2em!important;display:inline-block;text-align:center;vertical-align:top;margin-bottom:0.8em;}
- .product_thumb{max-height:11em;max-width:11em;display:inline-flex;margin-bottom:0.2em;background-color:%graybkg%;}
- .product_thumb img,{box-shadow:none;object-fit:contain;max-height:unset;max-width:unset;width:100%;margin:0 auto !important;}
- .product_ref p{margin-bottom:0.2em;text-align:left;}
- .post_preview .product_thumb{max-height:4em;max-width:6em;}
- .purchase_button{background-color:%black%;color:%white%;padding-left:0.5em;padding-right:0.5em;text-decoration:none;font-weight:bold;}
- .page_break{page-break-after:always;}
- .text_highlight,.text_highlight a,.text_highlight select{background-color:%black%;color:%white%;border:none;}
- .gray.text_highlight,.gray.text_highlight a,.gray.text_highlight select{background-color:%gray%;color:%white%;}
- .show_on_print{display:none;}.inline_print{display:none;}
- .comment{font-size:0.9em;font-family:sans-serif;overflow:auto !important;width:100%;}
- .comment tbody tr:hover{box-shadow:none;}
- .comment table{border:none;}
- .comment li{display:list-item;list-style:'→';padding-left:0.3em;}
- .comment ul{padding-left:1em;}
- .comment ul li *{margin-bottom:0.5em;}
- .history li{display:list-item;list-style:disc;padding-left:0.3em;}
- .history li li{list-style:circle;}
- .history ul{padding-left:1em;}
- .history a{text-decoration:underline;}
- .history .list{overflow:auto;white-space:nowrap;}
- .diff_table{table-layout:fixed;}
- .diff_table thead{font-size:0.9em;text-align:center;}
- .diff_table tbody pre{font-size:0.9rem;white-space:pre-line;}
- .diff_table td{vertical-align:top;}
- .omittable_title{display:block;width:100%;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
- .wayback_close{float:right;}
- .wayback_expand{display:inline;}
- .post_selecting .post>*>*{pointer-events:none;}
- .post_selected{background-color:%graybkg%;}
- .small_pad{padding:0.2em;padding-top:0.1em;padding-bottom:0.1em;}
- .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%;}
- .wscroll:target{display:block;} .post_ref .wscroll{display:none !important;}
- .wayback_link{display:inline;}
- .imd{object-fit:cover;width:100%;}
- .center_exp .post>.imd,.center_exp .p_row{width:60%;}
- .center_exp .p_thumb img,.center_exp .p_thumb video{max-height:3rem;}
- .center_exp .p_thumb{max-height:3rem;filter:opacity(40%);}
- .center_exp .p_thumb:hover{filter:unset;}
- #here_buttons{display:contents;}
- .here_buttons_inner{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;max-height:100%;max-width:100%;}
- .here_btn{position:absolute;z-index:110;transform:translate(-50%,-50%);
- width:2em;height:2em;display:block;border:1px solid %black%;background-color:rgba(0,0,0,0.5);}
- .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;}
- .center .center{width:100%;padding-bottom:unset;}
- .center{border:none;}
- .center{overflow:auto;}
- .center>tbody>tr:hover{box-shadow:none;}
- .center>tbody>tr>td{white-space:normal;vertical-align:top;min-width:1em;}
- .center>tbody>tr>td:first-child{text-align:center;color:%gray%;padding-left:0.1em;}
- .center>tbody>tr>td:nth-child(1)>*{}
- .center>tbody>tr>td:nth-child(2){text-align:center;color:%gray%;box-shadow:0.3em 0px 0px -0.15em %black%44;}
- .center>tbody>.no_line>td:nth-child(2){box-shadow:none;}
- .center>tbody>tr>td:nth-child(2) a{color:%gray%;}
- .center>tbody>tr>td:nth-child(2) .marked{color:%black% !important;}
- .center>tbody>tr>td:nth-child(3){width:100%;text-align:left;padding-left:0.5em;}
- .center>tbody>tr>td:nth-child(3)>div{overflow:auto;}
- .center>tbody>tr>td:last-child{padding-right:0.5em;}
- .main>.center>tbody>tr{border-bottom:1px dotted %black%;}
- .ref_count{cursor:pointer;} td .ref_count{text-align:left;display:block;}
- .big_side_box .center{width:100%;}
- #big_image_upload{max-width:100%;}
- label{text-align:left;display:inline-block;}
- @media screen and (max-width:1000px) and (min-width:666px){
- .left{width:35%;}
- .center,.center_wide{width:65%;}
- .center_wide .p_thumb{height:8rem;width:8rem;margin-right:0.4rem;margin-bottom:0.4rem;box-shadow:3px 3px 12px 2px black;}
- .post_width{width:calc(100% - 1.5rem);padding-left:0.2em;}
- .hidden_on_wide{display:unset;}
- .pop_right{width:30%;}
- .pop_right_big{width:40%;}
- @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
- @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
- @keyframes pop_slide_in_big{0%{right:-40%;}100%{right:0%;}}
- @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-40%;}}
- .big_side_box{width:35%;}
- .big_image_box{width:65%;}
- .inquiry_buttons{right:35%;}
- .table_top{left:calc(-50% - 1.7em);width:calc(154% + 0.5em);}
- .post_dummy > *{width:80%;max-width:55rem;}
- .center_exp .post>.imd,.center_exp .p_row{width:80%;max-width:55rem;}
- .here_btn{width:1.5em;height:1.5em;}
- }
- @media screen and (max-width:666px){
- .main{margin-bottom:unset;}
- html{font-size:16px;}
- pre{max-width:85vw;}
- #titlectrl:checked ~ header .mobile_fold{display:block !important;}
- #titlectrl:checked ~ .main .mobile_fold{display:block !important;}
- #titlectrl:checked ~ header li ul{display:inline;}
- .mobile_fold{display:none !important;}
- .hidden_m{display:none !important;}
- .block_m{display:block !important;}
- .hidden_on_desktop{display:inherit;}
- .hidden_on_wide{display:inherit;}
- header{position:inherit;}
- header ul{display:block;}
- header li{display:block;}
- header li::before{content:''}
- header::before{box-shadow:none;display:none;}
- .small_footer::before{box-shadow:none;display:none;}
- .left{position:relative;width:100%;top:unset;height:unset;max-height:unset;padding-right:0;display:block;}
- .center,.center_wide,.center_full{display:block;position:relative;line-break:anywhere;left:0;top:0;width:100%;padding-left:0;}
- .center_wide .p_thumb{height:6rem;width:6rem;margin-right:0.3rem;margin-bottom:0.3rem;box-shadow:2px 2px 10px 1px black;}
- .pop_right,.pop_right_big{top:unset;right:0;bottom:0;left:0;width:100%;}
- .pop_right{height:30%;}
- .pop_right_big{height:70%;}
- @keyframes pop_slide_in{0%{bottom:-30%;}100%{bottom:0%;}}
- @keyframes pop_slide_out{0%{bottom:0%;}100%{bottom:-30%;}}
- @keyframes pop_slide_in_big{0%{bottom:-70%;}100%{bottom:0%;}}
- @keyframes pop_slide_out_big{0%{bottom:0%;}100%{bottom:-70%;}}
- .big_image_box{position:fixed;top:0;bottom:8.5rem;left:0;right:0;width:100%;}
- .side_box_mobile_inner{background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(1,1,1,0.9) 20%);
- transition:none;background-size:100% 100%;padding:0.5rem;padding-bottom: 5em;}
- .side_box_mobile_inner:hover{background-size:100% 100%;}
- .big_side_box{position:fixed;top:0;bottom:0;right:0;left:0;width:100%;
- height:unset;padding:0;padding-top:calc(100vh - 8.5rem);background:none;}
- .p_thumb{height:3rem;}
- .center .post{padding-right:0rem;padding-left:0rem;}
- .post .p_thumb img,.post .p_thumb video{max-height:3rem;}
- .page,.page_gallery{padding:0.2em;padding-top:0;}
- header{padding-top:0.3em;}
- .toc_button{top:0.3em;}
- .small_footer{padding-bottom:0.3em;}
- .footer_additional{display:block;width:100%;}
- .album_hint{display:block;font-size:1rem;}
- .image_nav{position:absolute !important;}
- .image_nav_prev,.image_nav_next{width:25%;}
- .image_nav_prev:hover,.image_nav_next:hover{background-size:0% 100%;color:%black% !important;}
- .inquiry_buttons{position:relative;left:unset;right:unset;text-align:left;bottom:unset;margin:unset;width:unset;
- background-color:unset;z-index:unset;padding:unset;padding-left:unset;padding-right:unset;
- border-radius:unset;box-shadow:unset;text-shadow:unset;}.img_btn_hidden{opacity:1;}
- .lr_buttons{background-color:unset;padding:unset;padding-top:unset;padding-bottom:unset;
- border-radius:unset;box-shadow:unset;font-size:1.3rem;text-shadow:unset;}
- .opt_compact,.ref_compact{line-break:anywhere;}
- .table_top{left:unset;width:100%;overflow:auto;}
- .post table img{min(100%, 30vw) !important;}
- .product_ref{width:100%;display:block;}
- .post_dummy > *{width:100%;max-width:25rem;}
- .center_exp .post>.imd,.center_exp .p_row{width:100%;max-width:25rem;}
- .center_exp .post .p_thumb img,.center_exp .post .p_thumb video{max-height:2rem;}
- .center_exp .p_thumb{height:2rem;filter:opacity(40%);}
- .center_exp .p_thumb:hover{filter:unset;}
- .sticky_title{top:0;}
- .small_footer{position:relative;}
- #upload_selector{width:100%;}
- .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 10em);}
- .wayback_expand{display:block;text-align:center;}
- .wayback_link{display:block;}
- .center_exp{display:block;width:100%;margin:0 auto;padding-bottom:1em;}
- .center_exp .post{overflow:auto;}
- .center_exp .imd{width:100%;}
- .here_btn{width:1.2em;height:1.2em;}
- .exp_h_f{height:unset !important;}
- .exp_f{margin-bottom:1em;}
- .linked_posts{padding-left:1em;}
- .center>tbody>tr>td{min-width:unset;}
- .center>tbody>tr>td:last-child{padding-right:0.1em;}
- }
- @media print{
- .small_footer .hidden_on_print{display:none}
- header b,.small_footer b{font-weight:normal;}
- header{display:table-header-group;box-shadow:none;} .main{display:table-row-group;top:unset;margin-bottom:unset;} .small_footer{text-align:right;}
- header::before{box-shadow:none;display:none;} header::after{display:block;height:1em;content:' ';}
- .small_footer::before{box-shadow:none;display:block;height:1em;position:relative;}
- body,footer,header,.small_footer,a,.clean_a,.invert_a,.clean_a a,.invert_a a{background:none;color:black;}
- .bkg_section,.bkg_recent>.post,.active_post{background:none !important;box-shadow:none;}
- .post *,.post_dummy *{margin-bottom:0em;}
- .p_row,.post table,.post img,.post_ref img,.post_ref .original_img,
- .post_width>.original_img,.post pre{margin-top:0.5rem;margin-bottom:0.5rem;text-indent:0;}
- pre{white-space:pre-wrap;line-break:anywhere;}
- .post p{line-height:1.3;text-indent:2em;} .product_ref p {text-indent:0;}
- .post table img{margin:0 !important;}
- .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;}
- .post ul,.post ol{margin:0.5rem !important;margin-left:1.4rem !important;margin-right: 0rem !important;}
- table{border-bottom:2px solid black;border-top:2px solid black;}
- .post table img{max-width:5em;max-width:8em !important;max-height:8em !important;}
- thead{box-shadow:inset 0 -1px 0 0px black;background:none;}
- .linked_posts{display:none;}
- .post_width{overflow:clip;left:0;width:100%;padding-left:0em;padding-right:0em;}
- .section .post h2{font-size:1.8em;margin:1.5em auto 0 !important;}.list h2,.compact h2{margin:0 !important;}
- .section .post h3{font-size:1.5em;margin:1.0em auto 0 !important;}.list h3,.compact h3{margin:0 !important;}
- .section .post h4{font-size:1.1em;margin:0.5em auto 0 !important;}.list h4,.compact h4{margin:0 !important;}
- .post .post{margin-bottom:0.5rem;margin-top:0.5rem;}
- .gray,.gray a,.deleted_post{color:rgba(0,0,0,0.5);}
- .left{display:none;}
- .center, .center_wide, .center_full{width:100%;padding:0;font-size:16px;line-height:1.3}
- hr{border:1px solid black;}
- .post_box_top{display:none;}
- .post_access{display:none;}
- .opt_compact .post_access,.ref_compact .post_access{border-right:none;display:inline;background:unset;}
- .text_highlight,.text_highlight a,.gray.text_highlight,.gray.text_highlight a,.purchase_button{background-color:lightgray;color:black;}
- .hidden_on_print{display:none !important;}
- .print_column{column-count:2;margin-top:0.5rem;margin-bottom:0.5rem;}
- .print_column .print_column{column-count:1;margin:unset;}
- .opt_compact{margin-left:0;left:1.5em;}
- .post .post_ref{padding-left:2rem;}
- .section .post h1:first-of-type{column-span:all;display:block;margin-top:1rem !important;margin-bottom:0.5rem !important;}
- .bkg_section .restart+.post .post_width{padding-top:0;}
- .restart{background-color:unset;padding:unset;}
- .opt_compact h1:first-of-type,.ref_compact h1:first-of-type{display:unset;}
- .table_top{position:relative;left:0;width:100%;background:none;z-index:1;box-shadow:none;}
- .header_nav{display:none;}
- .show_on_print{display:block;}.inline_print{display:inline;}
- blockquote{border-left:2px solid black;}
- .footer_additional{display:none;}
- .small_footer{margin-top:1rem;box-shadow:none;}
- .page{display:table;width:100%;}
- .page_selector{display:none;}
- .p_thumb{height:4rem;margin-bottom:0.25rem;}
- .post .p_thumb img,.post .p_thumb video{max-height:4rem;}
- .sticky_title{box-shadow:none;}
- .center_wide .p_thumb{display:inline-flex;height:5.8rem;width:5.8rem;margin-right:0;}
- .center_wide .p_row{display:block;}
- .interesting_tbody{background:none;}
- .interesting_tbody img{display:none !important;}
- .imd{margin-top:0.5em;margin-bottom:0.5em;line-height:0px;}
- .p_row .imd{margin-top:0em;margin-bottom:0em;}
- .center,.center>tbody,.center>tbody>tr,.center>tbody>tr>td{display:block;}
- .main>.center>tbody>tr{border:none;}
- .center>tbody>tr>td:first-child{display:none;color:rgba(0,0,0,0.5);}
- .center>tbody>tr>td:nth-child(2){display:none;color:rgba(0,0,0,0.5);}
- .center>tbody>tr>td:nth-child(2) a{display:none;color:rgba(0,0,0,0.5);}
- .center>tbody>tr>td:nth-child(3){margin:unset;padding:unset;}
- .post > td:nth-child(3) > *{margin:unset;padding:unset;}
- .wide_post_print{column-span:all;margin-top:1em;margin-bottom:1em;}
- }
- ";
- //$this->style=preg_replace('/%highlight_white%/','#5b3607',$this->style);
- //$this->style=preg_replace('/%highlight_slice%/','#734307',$this->style);
- //$this->style=preg_replace('/%grayslice%/','#442c0b',$this->style);
- //$this->style=preg_replace('/%post_white%/','#2d2110',$this->style);
- //$this->style=preg_replace('/%white%/','#231a0d',$this->style);
- //$this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
- //$this->style=preg_replace('/%gray%/','#ac7843',$this->style);
- //$this->style=preg_replace('/%graybkg%/','#39270e',$this->style);
- //$this->style=preg_replace('/%shadow%/','#000000cc',$this->style);
-
- $this->style=preg_replace('/%highlight_white%/','#804a06',$this->style);
- $this->style=preg_replace('/%highlight_slice%/','#ae6407',$this->style);
- $this->style=preg_replace('/%grayslice%/','#6a491c',$this->style);
- $this->style=preg_replace('/%post_white%/','#4a3413',$this->style);
- $this->style=preg_replace('/%white%/','#2d2214',$this->style);
- $this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
- $this->style=preg_replace('/%gray%/','#f8ca9b88',$this->style);
- $this->style=preg_replace('/%graybkg%/','#a9270e',$this->style);
- $this->style=preg_replace('/%shadow%/','#000000ee',$this->style);
- $f = fopen('styles/main.css','w');
- fwrite($f,$this->style);
- fclose($f);
- }
-
- function GiveSafeEMail(){
- return preg_replace('/\./u','[dot]',preg_replace('/\@/u','[at]',$this->EMail));
- }
-
- function &FindImage($name, $loose=false){ if(!isset($name) || !$name){ return $this->NULL_IMAGE; }
- if(isset($this->Images[0])) foreach($this->Images as &$im){
- if($loose) { if(preg_match('/'.preg_quote($name).'/u',$im['name'])) return $im; }
- else { if($im['name']==$name) return $im; }
- }
- return $this->NULL_IMAGE;
- }
-
- function &GiveImageInHere($rand=false){
- $this->ReadImages(); $this->DetectPageType();
- $album = $this->PageType=='here'?$this->HereAlbum:$this->ExpAlbum;
- if(!isset($album) || !$album){
- if(isset($this->Images[0])) return $this->Images[0]; else return $this->NULL_IMAGE; }
- $imlist=[]; $imlist_fallback=[];
- if(isset($this->Images[0])){
- foreach($this->Images as &$im){
- if(isset($im['galleries'][0]) && in_array($album,$im['galleries']) && $this->CanShowImage($im)){
- if(!$rand) return $im; else {
- $imlist_fallback[] = $im;
- if(!in_array($im['name'],$this->VisitedHere)) $imlist[] = $im;
- }
- }
- }
- }
- if(!$rand || !isset($imlist_fallback[0])) return $this->NULL_IMAGE;
- if(sizeof($imlist)){
- $r = random_int(0, sizeof($imlist)-1);
- return $imlist[$r];
- }else{
- $r = random_int(0, sizeof($imlist_fallback)-1);
- return $imlist_fallback[$r];
- }
- }
-
- function ImageTitle($im){
- $imtitle = (isset($im)&&isset($im['title']))?$im['title']:NULL;
- if(isset($im['parent'])&&($imp = &$this->FindImage($im['parent'],true))&&isset($imp['title'])){ $imtitle=$imp['title']; }
-
- return $imtitle;
- }
-
- function ImageHasHere(&$im, $here_name){
- if(!isset($im['here'])||!isset($im['here'][0])) return false;
- foreach($im['here'] as $h) { if($h[0] == $here_name) return true; } return false;
- }
-
- function ReadImages($clear_non_exist = false){
- $path = 'images/list.md';
- if($this->DoneReadImages){ return; }
- if(!file_exists($path)){ $f = fopen($path,'w'); fflush($f); fclose($f); }
- $c = file_get_contents($path);
- if(preg_match_all('/GALLERY\s+(\S+)(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
- $g=[]; $g['name']=$m[1];//$g['count']=0;
- if(preg_match('/FEATURED([^;]*?);/u', $m[2], $arg)){ $g['featured']=true; }
- if(preg_match('/EXPERIMENTAL([^;]*?);/u', $m[2], $arg)){ $g['experimental']=true; }
- if(preg_match('/DESCRIPTION\s+([^;]+);/u', $m[2], $arg)){ $g['description']=$arg[1]; }
- $this->Galleries[] = $g;
- }
- if(preg_match_all('/^-\s*([^;]+)\s*?;\s*?(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
- $name = trim($m[1]);
- $item = []; $item['file'] = 'images/'.$name; $item['name'] = $name;
- if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
- if(preg_match('/REFS\s+([^;]*);/u',$m[2],$refs) && preg_match_all('/[0-9]{14}/u',$refs[1],$rs, PREG_SET_ORDER)){
- $item['refs']=[];
- foreach($rs as $r){ if(!in_array($r[0], $item['refs'])) $item['refs'][] = $r[0]; }
- }
- if(preg_match('/GAL\s+([^;]*);/u',$m[2],$gals) && preg_match_all('/(\S+)/u',$gals[1],$ga, PREG_SET_ORDER)){
- $item['galleries']=[];
- foreach($ga as $g){ if(!in_array($g[0], $item['galleries'])) $item['galleries'][] = $g[0]; }
- }
- if(preg_match('/PRODUCT\s+([^;]*);/u',$m[2],$product)){ $item['product']=$product[1]; }
- if(preg_match('/PARENT\s+([^;]*);/u',$m[2],$parent)){ $item['parent']=$parent[1]; }
- if(preg_match('/TITLE\s+([^;]*);/u',$m[2],$title)){ $item['title']=$title[1]; }
- if(preg_match('/ALIGN\s+([^;]*);/u',$m[2],$align)){ $item['align']=$align[1]; }
- if(preg_match('/HERE\s+([^;]*);/u',$m[2],$heres) && preg_match_all('/(\S+)-(\S+)-(\S+)/u',$heres[1],$here, PREG_SET_ORDER)){
- $item['here']=[];
- foreach($here as $h){ if(!$this->ImageHasHere($item, $h[1])) $item['here'][] = [$h[1],$h[2],$h[3]]; }
- }
- if(preg_match('/\.mp4/u',$item['name'])){
- $item['video']='video/mp4';
- }
- $this->Images[] = $item;
- }
-
- $files = array_merge([],glob('images/*.jpg'));
- $files = array_merge($files,glob('images/*.jpeg'));
- $files = array_merge($files,glob('images/*.png'));
- $files = array_merge($files,glob('images/*.gif'));
- $files = array_merge($files,glob('images/*.mp4'));
- if(isset($files[0]))foreach($files as $file) {
- if(preg_match('/[0-9]{14,}\.(jpg|jpeg|gif|png|mp4)/u', $file, $m)) {
- $name = trim($m[0]);
- if(!$this->FindImage($name)){
- $item = []; $item['name']=$name; $item['file'] = 'images/'.$name;
- if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
- $this->Images[] = $item;
- }
- }
- }
- if($clear_non_exist){
- if(isset($this->Images[0]) && isset($files[0])){
- foreach($this->Images as &$im){
- if(!in_array($im['file'],$files)){
- $im['deleted'] = 1;
- }
- }
- }
- }
- function cmpf($a, $b){
- if ($a['name'] == $b['name']) return 0;
- return (($a['name'] > $b['name']) ? 1 : -1);
- }
- function cmpaf($a, $b){
- if ($a['name'] == $b['name']) return 0;
- return ($a['name'] > $b['name']) ? -1 : 1;
- }
- if(isset($this->Galleries[0]))usort($this->Galleries,"cmpf");
- if(isset($this->Images[0]))usort($this->Images,"cmpaf");
- $this->DoneReadImages = 1;
- }
-
- function WriteImages(){
- if(isset($this->WayBack)) return;
- $path = 'images/list.md';
- $f = fopen($path,'w');
- if(isset($this->Galleries[0]))foreach($this->Galleries as &$g){
- if(isset($g['deleted'])) continue;
- fwrite($f,'GALLERY '.$g['name']);
- if(isset($g['featured']) && $g['featured']!=false) { fwrite($f,' FEATURED;'); }
- if(isset($g['experimental']) && $g['experimental']!=false) { fwrite($f,' EXPERIMENTAL;'); }
- if(isset($g['description']) && $g['description']!="") { fwrite($f,' DESCRIPTION '.$g['description'].';'); }
- fwrite($f, PHP_EOL);
- }
- if(isset($this->Images[0]))foreach($this->Images as &$im){
- if(isset($im['deleted'])) continue;
- fwrite($f, "- ".$im['name'].'; ');
- if(isset($im['refs']) && isset($im['refs'][0])){ fwrite($f, 'REFS '.implode(" ",$im['refs'])."; "); }
- if(isset($im['galleries']) && isset($im['galleries'][0])){ fwrite($f, 'GAL '.implode(" ",$im['galleries'])."; "); }
- if(isset($im['product']) && $im['product']!=''){ fwrite($f, 'PRODUCT '.$im['product']."; "); }
- if(isset($im['parent']) && $im['parent']!=''){ fwrite($f, 'PARENT '.$im['parent']."; "); }
- if(isset($im['title']) && $im['title']!=''){ fwrite($f, 'TITLE '.$im['title']."; "); }
- if(isset($im['align']) && $im['align']!='' && $im['align']!='middle'){ fwrite($f, 'ALIGN '.$im['align']."; "); }
- if(isset($im['here']) && $im['here']!=''){ fwrite($f, 'HERE ');
- foreach($im['here'] as $here){ fwrite($f, implode('-',$here).' '); } fwrite($f, '; ');
- }
- fwrite($f, PHP_EOL);
- }
- fflush($f);
- fclose($f);
- }
-
- function EditImage($name, $link_gallery, $do_remove = false, $product_link=NULL, $rename=NULL, $parent=NULL, $align=NULL){
- if(!($im = &$this->FindImage($name))) return;
- if(isset($link_gallery)){
- if($do_remove){
- if(!isset($im['galleries']) || !isset($im['galleries'][0])) return;
- foreach($im['galleries'] as $key => $g){ if ($g==$link_gallery) unset($im['galleries'][$key]); }
- $im['galleries'] = array_merge($im['galleries']);
- }else{
- if(!isset($im['galleries'])) $im['galleries']=[];
- foreach($im['galleries'] as &$g){ if ($g==$link_gallery) return; }
- $im['galleries'][]=$link_gallery;
- }
- }
- if(isset($product_link)){
- if($product_link!=''){$im['product']=$product_link;}
- else{unset($im['product']);}
- }
- if(isset($rename) && $rename!=$im['name']){
- $ext=pathinfo($im['file'],PATHINFO_EXTENSION);
- rename($im['file'], 'images/'.$rename.'.'.$ext);
- if(isset($im['thumb'])) rename($im['thumb'], 'images/thumb/'.$rename.'.'.$ext);
- $im['name'] = $rename.'.'.$ext;
- }
- if(isset($parent) && $parent!=$im['parent']){
- if($parent==''){ unset($im['parent']); }
- else{ $im['parent'] = $parent; }
- }
- if(isset($align) && in_array($align,['top','middle','bottom'])){
- if($align=='middle'){ unset($im['align']); }
- else{ $im['align']=$align; }
- }
- $this->NeedWriteImages = 1;
- }
-
- function RegenerateThumbnails(){
- $glob = glob('images/*.jpg');
- if(!is_dir('images/thumb')) mkdir('images/thumb');
- foreach($glob as $file) {
- $thumb_destination = 'images/thumb/'.basename($file);
- $img = new Imagick($file); $geo=$img->getImageGeometry();
- $width=$geo['width']; $height=$geo['height'];
- $lim=400;
- $scale = $lim / min($width,$height);
- if($scale<1){
- $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
- }
- $img->setImageFormat('jpeg');
- $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
- $img->setImageCompressionQuality(90);
- $img->writeImage($thumb_destination);
- }
- }
- function CleanupImageCompression($run=false){
- $glob = glob('images/*.jpg');
- if(!$run){
- echo $this->T("将重新压缩下列文件:")."<style>img{max-width:10em;max-height:10em;}</style><ul>";
- }
- foreach($glob as $file) {
- $destination = 'images/'.basename($file);
- $img = new Imagick($file); $geo=$img->getImageGeometry();
- $width=$geo['width']; $height=$geo['height'];
- $interlace=$img->getImageInterlaceScheme();
- $progressive=($interlace==imagick::INTERLACE_NO || $interlace==imagick::INTERLACE_LINE || $interlace==imagick::INTERLACE_UNDEFINED);
- $sizelim=1920;$abs_max=2560;
- $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
- $sz=filesize($destination);
- if($scale<0.98 && $sz>2097152 && $progressive){ /* need scale, greater than 2mb, and not interlaced */
- if(!$run){
- echo "<li><a href='index.php?pic=$destination'><img src='images/thumb/".basename($file)."'><br />$destination, $width x $height, $interlace</a></li>";
- }else{
- $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
- $img->setImageFormat('jpeg');
- $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
- $img->setImageCompressionQuality(90);
- $img->writeImage($destination);
- }
- }
- $img->clear();
- }
- if(!$run){
- echo "</ul><a href='index.php?cleanup_image_compression=true&run=true'>".$this->T("立即执行")."</a>"; exit;
- }
- }
-
- function CompressImage($source, $destination, $thumb_destination, $quality, $sizelim, $abs_max, $ext, $transparency) {
- $img = new Imagick($source); $geo=$img->getImageGeometry(); $img2 = clone $img;
- $width=$geo['width']; $height=$geo['height'];
- $lim=400;
- $scale = $lim / min($width,$height);
- if($scale<1){
- $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
- }
- if(!$transparency){
- $img->setImageBackgroundColor(new ImagickPixel('gray'));
- $img=$img->flattenImages();
- $img->setImageFormat('jpeg');
- $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
- $img->setImageCompressionQuality($quality);
- }
- $img->writeImage($thumb_destination);
-
- $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
- if($scale<0.98 || ($ext!='jpg'&&$ext!='jpeg')){
- $img2->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.5);
- if(!$transparency){
- $img2->setImageFormat('jpeg');
- $img2->setImageBackgroundColor(new ImagickPixel('gray'));
- $img2=$img2->flattenImages();
- $img2->setImageCompressionQuality($quality);
- $img2->setInterlaceScheme(Imagick::INTERLACE_PLANE);
- }
- $img2->writeImage($destination);
- }else{
- rename($source,$destination);
- }
- }
-
- function DoUpload(){
- if(!isset($_FILES['upload_file_name'])) return 0;
- if(!is_dir('images/thumb')) mkdir('images/thumb');
- if($_FILES['upload_file_name']['error']>0){
- echo"file upload err code ".$_FILES['upload_file_name']['error']; exit;
- return -1;
- }else{
- $ext=strtolower(pathinfo($_FILES['upload_file_name']['name'],PATHINFO_EXTENSION));
- if(!in_array($ext,['jpg','jpeg','png','gif','mp4'])) return 0;
- $fp = fopen('.la_lock',"w");
- while (!flock($fp, LOCK_EX| LOCK_NB)){
- usleep(10000);
- }
- $num=date('YmdHis'); $replace=0;
- if(isset($_POST['image_replace_button']) && isset($_GET['pic']) && preg_match('/([0-9]{14,})/u',$_GET['pic'],$mim)){
- $num = $mim[1]; $replace=1;
- }
- $transparency = (isset($_GET['transparency'])&&$_GET['transparency']);
- $base = 'images/'.$num;
- $thumb = 'images/thumb/'.$num;
- $use_ext=($ext=='gif' || $ext=='mp4' || $transparency)?('.'.$ext):('.jpg');
- $final_path = $base.$use_ext; $final_thumb = $thumb.$use_ext; $i=0;
- if(!$replace) while(file_exists($final_path)){
- $final_path = $base.strval($i).$use_ext; $final_thumb = $thumb.strval($i).$use_ext; $i++;
- }
- if($ext!='gif' && $ext!='mp4'){
- $compress = (isset($_GET['compress'])&&$_GET['compress']);
- $this->CompressImage($_FILES['upload_file_name']['tmp_name'], $final_path, $final_thumb, 90,
- $compress?800:1920, $compress?1920:2560, $ext, $transparency);
- }else{
- move_uploaded_file($_FILES['upload_file_name']['tmp_name'], $final_path);
- }
- flock($fp, LOCK_UN);
- fclose($fp);
- $this->ReadImages(true);
- $this->WriteImages();
- echo '<uploaded>'.pathinfo($final_path,PATHINFO_BASENAME)."</uploaded>";
- if(isset($_POST['image_replace_button'])){
- header('Location: '.$_SERVER['REQUEST_URI']);exit;
- }
- exit;
- return 1;
- }
- return 0;
- }
-
- function &GetGallery($name){
- if(isset($this->Galleries[0])) foreach($this->Galleries as &$g){
- if($g['name'] == $name) return $g;
- }
- return $this->NULL_GALLERY;
- }
- function EditGallery($name, $new_name=null, $delete=false, $do_rw=true, $set_featured=null, $set_experimental=null,$desc=null){
- $this->ReadImages();
- $gallery = &$this->GetGallery($name);
- if(!isset($gallery)){
- if(!isset($new_name) || preg_match('/main|trash|\s/u',$new_name))return;
- $g = []; $g['name']=$new_name;
- $this->Galleries[]=$g;
- }else{
- if(isset($new_name)) {
- if(preg_match('/main|trash|\s/u',$new_name))return;
- $gallery['name'] = $new_name;
- foreach ($this->Images as &$im){
- if(isset($im['galleries'])&&isset($im['galleries'][0]))foreach($im['galleries'] as &$g){
- if($g == $name){ $g = $new_name; }
- }
- }
- }
- //if(isset($count)) $gallery['count'] = $count;
- if(isset($delete) && $delete) $gallery['deleted'] = true;
- if(isset($set_featured)) $gallery['featured'] = $set_featured;
- if(isset($set_experimental)) $gallery['experimental'] = $set_experimental;
- if(isset($desc)) $gallery['description'] = $desc;
- }
- if($do_rw) { $this->NeedWriteImages = 1; }
- }
-
- function ClearData(){
- $this->Posts = [];
- $this->Threads = [];
- $this->Images = [];
- $this->Archive = [];
- $this->ArchiveHandles = [];
- }
-
- function InsertArchivePost(&$post){
- $a = NULL;
- if(($a = &$this->GetArchiveHandle($post['id']))==$this->NULL_POST){
- $ah = []; $ah['id'] = $post['id']; $ah['list'] = [];
- $this->ArchiveHandles[] = &$ah; $a = &$ah;
- }
- $a['list'][] = $post;
- $this->Archive[] = $post;
- }
-
- function ReadArchiveFromFile($path){
- if(!file_exists($path)){
- return;
- }
- $c = file_get_contents($path);
- if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
- foreach($matches as $m){
- $post = [];
- $post['id'] = $m[1];
- $post['content'] = trim($m[3]);
- if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
- if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
- if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
- $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
- if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
- $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
- if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
- $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
- if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
- $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
- if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
- $post['merged_into'] = [trim($n[1]),trim($n[2])];
- }
- if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
- $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
- $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
- }
- $this->InsertArchivePost($post);
- }
- }
- }
-
- function SortArchive(){
- $cmpac = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
- $cmpap = function($a, $b){ if ($a['id'] == $b['id']) return ((($a['version'] > $b['version']) ? 1 : -1));
- return (($a['id'] > $b['id']) ? 1 : -1);
- };
- if(isset($this->Archive[0])){
- usort($this->Archive,$cmpap);
- $year_begin = substr($this->Archive[0]['id'],0,4);
- $this->YearBegin = ($year_begin<$this->YearBegin)?$year_begin:$this->YearBegin;
- }
- if(isset($this->ArchiveHandles[0])){
- usort($this->ArchiveHandles,$cmpac);
- foreach($this->ArchiveHandles as &$a){
- if(isset($a['list'])){ usort($a['list'],$cmpap);
- $last_valid=NULL;
- foreach($a['list'] as &$ver){ $ver['archive']= &$a;
- if(isset($ver['merged_thread'])){ $ver['content']=$last_valid; }
- else{ $last_valid = $ver['content']; } }
- if(isset($a['list'][0]['version'])&&$a['list'][0]['version']>$a['list'][0]['id']){ /* if early versions missing. */
- $origin=$a['list'][0]; $origin['version']=$origin['id']; array_unshift($a['list'], $origin);
- }
- }
- if(($p = &$this->GetPost($a['id'],true))!=NULL){
- $p['archive'] = &$a;
- }
- }
- }
- }
-
- function ReadPostsFromFile($path){
- if(!file_exists($path)){
- $f = fopen($path,'w');
- fclose($f);
- }
- $c = file_get_contents($path);
- if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
- foreach($matches as $m){
- $post = [];
- $post['id'] = $m[1];
- $post['real_content'] = trim($m[3]);
- $post['content'] = &$post['real_content'];
- if(preg_match('/COMMENT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['comment_to'] = $n[1];
- if(preg_match('/EMAIL\s+([^;]+)\s*;/u', $m[2], $n)) $post['email'] = $n[1];
- if(preg_match('/NAME\s+([^;]+)\s*;/u', $m[2], $n)) $post['name'] = $n[1];
- if(preg_match('/LINK\s+([^;]+)\s*;/u', $m[2], $n)) $post['link'] = $n[1];
- if(preg_match('/IP\s+([^;]+)\s*;/u', $m[2], $n)) $post['ip'] = $n[1];
- if(preg_match('/NEXT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['next'] = $n[1];
- if(preg_match('/PREV\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['prev'] = $n[1];
- if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
- if(preg_match('/MDEL\s*;/u', $m[2])) $post['mark_delete'] = True;
- if(preg_match('/MVAL\s*([^;]+);/u', $m[2], $n)) $post['mark_value'] = trim($n[1]);
- if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
- if(preg_match('/REFS\s*([^;]+);/u', $m[2], $ma)){
- $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['refs'] = $entries; } }
- if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
- $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
- if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
- $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
- if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
- $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
- if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
- $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
- if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
- $post['merged_into'] = [trim($n[1]),trim($n[2])]; }
-
- if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
- $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
- $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
- foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
- }
- if(preg_match('/NUM\s+([0-9]{1,})\s*;/u', $m[2], $n)){ $post['number']=$n[1]; $this->PNUMBER=max($post['number'],$this->PNUMBER); }
- else{ $this->PNUMBER++; $post['number']=$this->PNUMBER; }
- //$this->PNUMBER++; $post['number']=$this->PNUMBER;
- if(isset($post['mark_value']) && $post['mark_value']==5){
- $post['product']=[];
- }
- /* marks add here */
- $this->Posts[] = $post;
-
- if(isset($post['comment_to']) && ($target_post = &$this->GetPost($post['comment_to'],true))){
- if(!isset($target_post['comments']) || !isset($target_post['comments'][0])) $target_post['comments']=[];
- $target_post['comments'][]=&$this->Posts[count($this->Posts) - 1];
- }
- }
- }
- }
-
- function SortPosts($wayback=false){
- $cmpp = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
- $sortlist = &$this->Posts;
- if($wayback) $sortlist = &$this->WaybackPosts;
- if(isset($sortlist[0])){
- usort($sortlist,$cmpp);
- $this->YearEnd = substr($this->TIME_STRING,0,4);
- $this->YearBegin = substr($sortlist[0]['id'],0,4);
- }
- }
-
- function ReadPosts(){
- if ((!file_exists('la_config.md') || is_readable('la_config.md') == false) ||
- (!file_exists('la_config.php') || is_readable('la_config.php') == false) ||
- (!is_dir('posts') || is_readable('posts') == false) ||
- (!is_dir('archive') || is_readable('archive') == false) ||
- (!is_dir('images') || is_readable('images') == false) ||
- (!is_dir('styles') || is_readable('styles') == false)){
- $this->Install();
- }
- if($this->DoneReadPosts){ return; }
- $file_list = [];
- $glob = glob('posts/*');
- foreach($glob as $file) {
- if(preg_match('/[0-9]{6}\.md/', $file)) {
- $file_list[] = $file;
- }
- }
- sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
- foreach($file_list as $f) {
- $this->ReadPostsFromFile($f);
- }
- $this->SortPosts();
- $this->DetectThreads();
- $this->DoneReadPosts=1;
- }
-
- function UpdatePostRefsForWayback(){
- if(!isset($this->WayBack)) return;
- if(isset($this->Images[0])) foreach($this->Images as &$i){ unset($i['refs']); }
- if(!isset($this->WaybackPosts[0])) return;
- foreach($this->WaybackPosts as &$p){ unset($p['refs']); }
- foreach($this->WaybackPosts as &$p){
- if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $r){
- $pr = &$this->GetPost($r); if(isset($pr)){
- if(!isset($pr['refs'])) $pr['refs']=[];
- if(!in_array($p['id'],$pr['refs'])){ $pr['refs'][] = $p['id']; }
- }
- }
- if(isset($p['hasi']) && isset($p['hasi'][0])) foreach($p['hasi'] as $r){
- $ir = &$this->FindImage($r); if(isset($ir)){
- if(!isset($ir['refs'])) $ir['refs']=[];
- if(!in_array($p['id'],$ir['refs'])){ $ir['refs'][] = $p['id'];}
- }
- }
- if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
- $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
- if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$p['id']; }
- }
- }
- }
-
- function ReadArchive(){
- if (!is_dir('archive') || is_readable('archive') == false){ $this->Install(); }
- if ($this->DoneReadArchive) return;
- $file_list = []; $glob = glob('archive/*');
- foreach($glob as $file) {
- if(preg_match('/[0-9]{6}\.md/', $file)) {
- $file_list[] = $file;
- }
- }
- sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
- foreach($file_list as $f) {
- $this->ReadArchiveFromFile($f);
- }
- $this->SortArchive();
- $this->DoneReadArchive=1;
- $this->UpdateThreadForWayback();
- $this->UpdatePostRefsForWayback();
- }
-
- function GetThreadForPost(&$post){
- if(isset($post['tid'])) return;
- $th = []; $iterp = NULL;
- $post['tid'] = &$th; $th['first'] = &$post; $th['last'] = &$post;
- if(!(isset($post['prev']) || isset($post['next']))) { $this->Threads[] = &$th; return; }
- if(isset($post['prev']))for($p = $post['prev']; $p!=NULL; $p = $iterp){
- $np = &$this->GetPost($p,true); if(!$np) { break; }//err
- $np['tid'] = &$th;
- $th['first'] = &$np;
- $iterp = isset($np['prev'])?$np['prev']:NULL;
- }
- if(isset($post['next']))for($p = $post['next']; $p!=NULL; $p = $iterp){
- $np = &$this->GetPost($p,true); if(!$np) { break; }//err
- $np['tid'] = &$th;
- $th['last'] = &$np;
- $iterp = isset($np['next'])?$np['next']:NULL;
- }
- if(isset($th['first']['mark_value'])){
- if($th['first']['mark_value']==6) $th['exp'] = true;
- else if($th['first']['mark_value']>=7) $th['slf'] = true;
- if($th['first']['mark_value']==8) $th['sln'] = true;
- }
- if($th['first'] == $th['last']){ unset($post['tid']); return; }
- $this->Threads[] = &$th;
- }
-
- function IdentifyThreadCategory(&$th,&$first_post){
- unset($th['categories']);unset($th['interesting']);unset($th['reversed']);
- if(preg_match('/^\s*\@(.*?)$/mu',$first_post['content'],$m)){
- $first_post['categories']=[]; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
- foreach($matches as $ma){ $first_post['categories'][] = $ma[1]; }
- }
- if(isset($th) && $th){ $th['categories'] = &$first_post['categories']; }
- }
- if(preg_match('/\{\s*WIDE\s*\}/imu',$first_post['content'],$m)){ $first_post['wide'] = true; }
- if(preg_match('/\{\s*NO_TIME\s*\}/imu',$first_post['content'],$m)){ $first_post['no_time'] = true; }
- if(preg_match('/\{\s*NO_TITLE\s*\}/imu',$first_post['content'],$m)){ $first_post['no_title'] = true; }
- if(preg_match('/\{\s*SLIDES\s*\}/imu',$first_post['content'],$m)){ $first_post['slides'] = true; }
- if(preg_match('/\{\s*HEADER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['header'] = trim($m[1]); }
- if(preg_match('/\{\s*FOOTER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['footer'] = trim($m[1]); }
-
- if(!isset($th)) return;
- if(isset($first_post['wide'])) $th['wide']=$first_post['wide'];
- if(isset($first_post['header'])) $th['header']=$first_post['header'];
- if(isset($first_post['footer'])) $th['footer']=$first_post['footer'];
- if(isset($first_post['no_time'])) $th['no_time']=$first_post['no_time'];
- if(isset($first_post['slides'])) $th['slides']=$first_post['slides'];
- if(isset($first_post['no_title'])) $th['no_title']=$first_post['no_title'];
- if(preg_match('/\{\s*INTERESTING\s+(.*?)\}/imu',$first_post['content'],$m)){
- $th['interesting'] = []; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
- foreach($matches as $ma){ $th['interesting'][] = $ma[1]; }
- }
- }
- if(preg_match('/\{\s*REVERSED(\s+.*?)?\}/imu',$first_post['content'],$m)){ $th['reversed'] = 'm';
- if(isset($m[1])&&preg_match('/^\s*(y|m|d|p)/iu',$m[1],$ma)){ $th['reversed']=$ma[1]; }
- }
- }
- function IsInterestingPost(&$p){
- if(isset($p['tid']) && isset($p['tid']['interesting']) && isset($p['tid']['interesting'][0])) return true;
- return false;
- }
- function IsReversedThread(&$th){
- if(isset($th['reversed']) && $th['reversed']!=false) return true;
- return false;
- }
-
- function GiveAllMergedPosts(&$po,&$arr){
- if(isset($po['merged_from'])&&isset($po['merged_from'][0])) foreach($po['merged_from'] as $pm){
- $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr);}
- }
- if(isset($po['archive']) && isset($po['archive']['list'])){
- foreach($po['archive']['list'] as &$ver){
- if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $pm){
- $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr); } }
- }
- }
- }
- function ThreadMakeWayback(&$th){
- if(!isset($th['arr'][0])) return;
- if(isset($this->WayBack)){
- $remlist = [];
- foreach($th['arr'] as &$pi){
- $po = &$this->GetPost($pi['id'],true); if(!isset($po)){continue;/*merged*/}
- if(isset($po['merged_thread']) && isset($po['version']) && $po['version']>$this->WayBack){
- $remlist = array_unique(array_merge($remlist,$po['merged_thread'][0]));
- }
- $ah = &$this->GetArchiveHandle($po['id']);
- if(isset($ah)) foreach(array_reverse($ah['list']) as &$ver){
- if(!isset($ver['merged_thread'])) continue;
- if((isset($ver['version']) && $ver['version'] > $this->WayBack) ||
- (!isset($ver['version']) && $ver['id'] > $this->WayBack)){
- $remlist = array_unique(array_merge($remlist,$ver['merged_thread'][0]));
- }
- }
- }
- if(isset($remlist[0]) && isset($th['arr'][0])){
- foreach($remlist as $rem){ $this->GiveAllMergedPosts($this->GetPost($rem,true),$remlist); }
- foreach($th['arr'] as $key => $pr){
- foreach($remlist as $rem){ if($pr['id'] == $rem) { unset($th['arr'][$key]); break; } } }
- $new_th = []; $new_arr = [];
- foreach($remlist as $rem){ $np=&$this->GetPost($rem); if(isset($np)){$new_arr[]=&$np;} }
- $new_th['arr'] = &$new_arr;
- $this->WaybackThreads[] = &$new_th;
- $this->ThreadMakeWayback($new_th);
- }
- }
- }
- function AddMergedPosts(&$p, &$array){
- if(isset($p['archive']) && isset($p['archive']['list'])){
- foreach($p['archive']['list'] as &$ver){
- if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $po){
- $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
- }
- }
- if(isset($p['merged_from'])&&isset($p['merged_from'][0])) foreach($p['merged_from'] as $po){
- $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
- }
- function &array_shift_ref(&$array){if(count($array)>0){$key=key($array);$first=&$array[$key];}else{$first=null;}array_shift($array);return $first;}
- function FinalizeThread(&$th, $relink_posts=false, $now=0){
- $nextp=NULL; $arr=[]; $lasttime=NULL;
- if(!isset($th['arr'])){
- for($p = &$th['first']; $p!=$this->NULL_POST; $p = &$this->GetPost(isset($p['next'])?$p['next']:NULL,true)){
- $arr[]=&$p;
- } $th['arr'] = &$arr;
- if(isset($this->WayBack) && $this->DoneReadArchive){ $new_arr=[];
- foreach($arr as &$p){ $pa = &$this->GetPost($p['id']); if(isset($pa)) {$new_arr[]=&$pa;$this->WaybackPosts[]=&$pa;} }
- foreach($arr as &$p){ $this->AddMergedPosts($p,$new_arr); }
- $arr=&$new_arr; $th['arr']=&$new_arr;
- $this->ThreadMakeWayback($th); }
- }
- $cmppt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
- if(isset($th['arr'][0])){ usort($th['arr'],$cmppt); } $th['count'] = sizeof($th['arr']);
- if($relink_posts){ $count = $th['count'];
- $arr = &$th['arr'];
- 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'];
- $arr[$i]['tid']=&$th;}
- $th['first'] = &$arr[0]; $th['last'] = &$arr[$count-1]; unset($arr[0]['prev']); unset($arr[$count-1]['next']);
- }
- $th['score'] = 0; if(!isset($th['first'])){ return; }
- $this->IdentifyThreadCategory($th, $th['first']);
- if(isset($this->WayBack)) $lasttime=$this->WayBack;
- if(!isset($last_time)) $lasttime = DateTime::createFromFormat('YmdHis', $th['last']['id']);
- $diff_days = ($now - date_timestamp_get($lasttime))/3600/24;
- $th['score'] = (float)$th['count']*0.2 - min($diff_days,200);
- if(isset($th['reversed'])){ $chunks=[]; $last_id=$last_y=$last_m=$last_d=0; $mo=$th['reversed']; $final=[];
- $first_post=&$this->array_shift_ref($th['arr']); $ch=[];
- while($n=&$this->array_shift_ref($th['arr'])){
- $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);
- if($mo=='y'&&$this_y!=$last_y){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y; }
- if($mo=='m'&&$this_m!=$last_m){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y.'/'.$this_m; }
- if($mo=='d'&&$this_d!=$last_d){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y.'/'.$this_m.'/'.$this_d; }
- if($mo=='p'){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} }
- $ch[]=&$n; $last_id=$this_id; $last_y=$this_y; $last_m=$this_m; $last_d=$this_d;
- }if(isset($ch[0])){$chunks[]=$ch;} if(isset($chunks[0])){$use_chunks=array_reverse($chunks);}
- $final[]=&$first_post;
- foreach($use_chunks as &$ch){ foreach($ch as &$p){ $final[]=&$p;} }
- $th['arr']=$final; }
- }
- function SortThreads(){
- if (!function_exists('cmpt')) {
- function cmpt($a, $b){
- if ($a['score'] == $b['score']) return 0;
- return ($a['score'] > $b['score']) ? -1 : 1;
- }
- }
- usort($this->Threads,"cmpt");
- }
- function DetectThreads(){
- foreach($this->Posts as &$p){
- if(isset($p['tid'])) { continue; }
- $this->GetThreadForPost($p);
- if(!isset($p['tid'])) { $this->IdentifyThreadCategory($this->NULL_POST, $p); }
- }
- if(!isset($this->Threads) || !isset($this->Threads[0])) return;
- $now = date_timestamp_get(date_create());
- foreach($this->Threads as &$t){
- $this->FinalizeThread($t,false,$now);
- }
- if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
- $this->FinalizeThread($th,false,$now);
- $this->Threads[] = &$th;
- }
- $this->SortThreads();
- }
- function UpdateThreadForWayback(){$now = date_timestamp_get(date_create());
- if(!isset($this->WayBack) || !$this->DoneReadArchive){ return; }
- foreach($this->Threads as &$t){
- unset($t['arr']); $this->FinalizeThread($t,true,$now);
- }
- if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
- $this->FinalizeThread($th,true,$now);
- $this->Threads[] = &$th;
- }
- $this->SortThreads();
- $this->SortPosts(true);
- $this->UsePosts = &$this->WaybackPosts;
- }
-
- function &GetMergedPost($id){
- $this->ReadArchive();
- $ah = &$this->GetArchiveHandle($id);
- if(!isset($ah) || !isset($ah['list']) || !isset($ah['list'][0])){ return $this->NULL_POST; }
- $ver = &$ah['list'][sizeof($ah['list'])-1];
- if(!isset($ver['merged_into'])) return $this->GetPost($id);
- [$tp, $tver] = $ver['merged_into'];
- if(isset($this->WayBack)){
- if($tver <= $this->WayBack) return $this->GetMergedPost($tp);
- else return $this->GetPost($id); /* should not happen directly. */
- }
- return $this->GetMergedPost($tp);
- }
-
- function &GetPost($id, $latest_only=false, $find_merged=false){
- if(!isset($id)) return $this->NULL_POST;
- $found=&$this->NULL_POST;
- if(isset($this->Posts[0])) foreach($this->Posts as &$p){
- if($p&& $p['id'] == $id) { $found = &$p; break; }
- if($find_merged && isset($p['hastag'][0]) && in_array($id, $p['hastag'])){ $found = &$p; break; }
- }
- if($latest_only || !isset($this->WayBack)){ return $found; }
- else{
- if(isset($found)){
- if(!isset($found['archive'])&&!isset($found['archive']['list']))
- { if($found['id'] > $this->WayBack) return $this->NULL_POST; else return $found; }
- $last_ver = &$this->NULL_POST;
- if(isset($found['archive']['list'][0])) foreach($found['archive']['list'] as &$ver){
- if($ver['version'] > $this->WayBack) return $last_ver;
- $last_ver = &$ver;
- }
- if(isset($found['version']) && $found['version'] <= $this->WayBack) return $found;
- else return $last_ver;
- }else{
- $ah = &$this->GetArchiveHandle($id); $last_ver = &$this->NULL_POST;
- if(isset($ah) && isset($ah['list']) && isset($ah['list'][0])) foreach($ah['list'] as &$ver){
- if($ver['version'] > $this->WayBack) return $last_ver;
- $last_ver = &$ver;
- } if(!isset($last_ver['merged_into'])) return $last_ver; else{
- [$tp, $tver] = $last_ver['merged_into'];
- if($tver <= $this->WayBack) {
- if($find_merged && $tp!=$id) return $this->GetPost($tp); return $this->NULL_POST; }
- return $last_ver;
- }
- }
- }
- return $this->NULL_POST;
- }
- function &GetArchiveHandle($id){
- if(!isset($id)) return $this->NULL_POST;
- if(isset($this->ArchiveHandles[0])) foreach($this->ArchiveHandles as &$p){
- if($p && $p['id'] == $id) { return $p; }
- }
- return $this->NULL_POST;
- }
- function &GetArchive($id){
- if(!isset($id)) return $this->NULL_POST;
- if(isset($this->Archive[0])) foreach($this->Archive as &$p){
- if($p && $p['id'] == $id) { return $p; }
- }
- return $this->NULL_POST;
- }
- function &GetArchiveVersion(&$ah, $version, &$next_ver, &$last_ver){
- if(!isset($ah)) return $this->NULL_POST;
- $found = NULL; $last_verp=NULL;
-
- if(isset($ah['list'][0])) foreach($ah['list'] as &$p){
- if(isset($found)){ $next_ver = $p; $last_ver = $last_verp; return $found; }
- if($p && $p['version'] == $version) { $found = &$p; continue; }
- $last_verp = &$p;
- }
- if(isset($found)) { $next_ver=NULL; $last_ver = $last_verp; return $found; }
- return $this->NULL_POST;
- }
-
- function CacheArchiveOwnLinks(){
- if(isset($this->WayBack)) return;
- if(isset($this->Archive[0])) foreach($this->Archive as &$p){
- $this->ConvertPost($p); unset($p['hasp']); unset($p['hasi']); unset($p['hastag']);
- if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$p['html'],$matches,PREG_SET_ORDER)){
- foreach($matches as $m){
- if(!isset($p['hasp']))$p['hasp']=[]; if(!in_array($m[1],$p['hasp'])){ $p['hasp'][]=$m[1]; }
- }
- }
- if(preg_match_all('/\/\/([0-9]{14})/u', $p['content'],$matches,PREG_SET_ORDER)){
- foreach($matches as $m){
- if(!isset($p['hastag']))$p['hastag']=[]; if(!in_array($m[1],$p['hastag'])){ $p['hastag'][]=$m[1]; }
- }
- }
- if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\)/u', $p['content'],$matches,PREG_SET_ORDER)){
- foreach($matches as $m){
- if(!isset($p['hasi']))$p['hasi']=[]; if(!in_array($m[2],$p['hasi'])){ $p['hasi'][]=$m[2]; }
- }
- }
- }
- }
- function WriteArchive(){
- if(isset($this->WayBack)) return;
- $cf = NULL;$opened =NULL;
- $this->SortArchive();
- $this->CacheArchiveOwnLinks();
- if(isset($this->Archive[0])) foreach($this->Archive as $p){
- $nid = substr($p['id'], 0,6);
- if($cf != $nid){
- if($opened){
- fflush($opened);
- fclose($opened);
- }
- $cf = $nid;
- $opened = fopen("archive/$cf.md", 'w');
- }
- $info = "[LAMDWIKIPOST {$p['id']}; ".
- "VER {$p['version']}; ".
- ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
- ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1]).";"):"").
- ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
- ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
- ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
- ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
- ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
- ']';
-
- if(isset($p['merged_thread'])){ $p['content']=""; }
-
- fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['content'].PHP_EOL.PHP_EOL);
- }
- }
-
- function WritePosts(){
- if(isset($this->WayBack)) return;
- $cf = NULL;$opened =NULL;
- $this->SortPosts();
- if(isset($this->Posts[0])) foreach($this->Posts as $p){
- $nid = substr($p['id'], 0,6);
- if($cf != $nid){
- if($opened){
- fflush($opened);
- fclose($opened);
- }
- $cf = $nid;
- $opened = fopen("posts/$cf.md", 'w');
- }
- $info = "[LAMDWIKIPOST {$p['id']}; ".
- ((isset($p['number']) && $p['number'])?"NUM {$p['number']}; ":"").
- ((isset($p['version']) && $p['version'])?"VER {$p['version']}; ":"").
- ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
- ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
- ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
- ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1])."; "):"").
- ((isset($p['comment_to']) && $p['comment_to'])?"COMMENT {$p['comment_to']}; ":"").
- ((isset($p['email']) && $p['email'])?"EMAIL {$p['email']}; ":"").
- ((isset($p['name']) && $p['name'])?"NAME {$p['name']}; ":"").
- ((isset($p['link']) && $p['link'])?"LINK {$p['link']}; ":"").
- ((isset($p['ip']) && $p['ip'])?"IP {$p['ip']}; ":"").
- ((isset($p['mark_delete']) && $p['mark_delete'])?"MDEL; ":"").
- ((isset($p['mark_value']) && $p['mark_value']>=0)?"MVAL {$p['mark_value']}; ":"").
- ((isset($p['next']) && $p['next'])?"NEXT {$p['next']}; ":"").
- ((isset($p['prev']) && $p['prev'])?"PREV {$p['prev']}; ":"").
- ((isset($p['refs']) && isset($p['refs'][0]))?("REFS ".implode(" ",$p['refs'])."; "):"").
- ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
- ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
- ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
- ((isset($p['mastodon_url']) && isset($p['mastodon_url']))?("MSTDN ".$p['mastodon_url']."; "):"").
- ']';
-
- fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['real_content'].PHP_EOL.PHP_EOL);
- }
- }
-
- function CachePostLinks(){
- if(isset($this->WayBack)) return;
- if(isset($this->Posts) && isset($this->Posts[0]))foreach ($this->Posts as &$post){
- $this->ConvertPost($post);
- unset($post['refs']);unset($post['hasp']);unset($post['hasi']);unset($post['hastag']);
- //discard lost old version
- //if(!isset($post['archive']) && $this->DoneReadArchive && isset($post['version'])){ unset($post['version']); }
- }else return;
- if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
- unset($im['refs']); unset($im['here']); unset($im['title']);
- }
- foreach ($this->Posts as &$post){
- if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$post['html'],$matches,PREG_SET_ORDER)){
- foreach($matches as $m){
- $ref = &$this->GetPost($m[1],true);
- if($ref!=NULL){
- if(!isset($ref['refs']))$ref['refs']=[]; if(!in_array($post['id'],$ref['refs']))$ref['refs'][]=$post['id'];
- }
- if(!isset($post['hasp']))$post['hasp']=[]; if(!in_array($m[1],$post['hasp']))$post['hasp'][]=$m[1];
- }
- }
- if(preg_match_all('/\/\/([0-9]{14})/u', $post['content'],$matches,PREG_SET_ORDER)){
- foreach($matches as $m){
- if(!isset($post['hastag']))$post['hastag']=[]; if(!in_array($m[1],$post['hastag']))$post['hastag'][]=$m[1];
- }
- }
- if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\)/u', $post['content'],$matches,PREG_SET_ORDER)){
- foreach($matches as $m){
- if(($im = &$this->FindImage($m[2]))!=NULL){
- if(!isset($im['refs']))$im['refs']=[]; if(!in_array($post['id'], $im['refs']))$im['refs'][] = $post['id'];
- }
- if(!isset($post['hasi']))$post['hasi']=[]; if(!in_array($m[2],$post['hasi']))$post['hasi'][]=$m[2];
- }
- }
- if(preg_match("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\))(\R*(\R(-|\*).+){1,})/u",
- $post['content'],$matches)){
- $use_img_name = $matches[2];
- if(($im = &$this->FindImage($use_img_name))!=NULL){
- 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",
- $matches[4],$mah,PREG_SET_ORDER)){
- foreach($mah as $ma){
- if(!isset($im['here']))$im['here']=[]; if(!$this->ImageHasHere($item, $ma[4])){
- $here = [$ma[4], $ma[2], $ma[3]]; $im['here'][] = $here; }
- }
- }
- }
- }
- }foreach($this->Posts as &$post){
- if(isset($post['hasp']) && isset($post['hasp'][0])) foreach($post['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
- $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
- if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$post['id']; }
- }
- }
- if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
- $min_id = '99999999999999';
- if(isset($im['refs']) && isset($im['refs'][0])) foreach ($im['refs'] as &$ref){
- $r = &$this->GetPost($ref,true); if(isset($r)) $title = $this->GetPostTitle($r,true,false);
- if($title && $ref<$min_id) { $im['title'] = preg_replace('/;/u',' ',trim($title)); $min_id=$r['id']; }
- }
- }
- }
-
- function CreatePostAnchor(&$post){
- $that=&$this;
- $post['html'] = preg_replace_callback('/<h([0-9])>(.+?)(?=<\/h[0-9]>)/u', function ($ma) use ($that){
- $id = '_heading_'.sizeof($this->Anchors);
- $entry=[(int)$ma[1], $id, $ma[2]];
- $that->Anchors[] = $entry;
- return "<h{$ma[1]} id='{$id}'>{$ma[2]}";
- }, $post['html']);
- }
-
- function RenamePost(&$post, $rename){
- foreach($this->Posts as &$p){
- if($p['id']==$rename && $p!==$post) { return; /* don't overwrite */ }
- }
- foreach($this->Posts as &$p){
- if(isset($p['prev']) && $p['prev']==$post['id']) { $p['prev']=$rename; }
- if(isset($p['next']) && $p['next']==$post['id']) { $p['next']=$rename; }
- }
- $post['id'] = $rename;
- }
-
- function DetachPost(&$th,&$post){
- $p0=$p1=NULL;foreach($th['arr'] as $a) echo $a['id']." "; echo ' -'.$post['id']."<br />";
- if(isset($post['prev'])){$p0=&$this->GetPost($post['prev'],true);} if(isset($post['next'])){$p1=&$this->GetPost($post['next'],true);}
- if(isset($p0)){ $p0['next']=$p1['id']; }else{ $th['first']=$p1['id']; }
- if(isset($p1)){ $p1['prev'] =$p0['id']; }else{ $th['last']=$p0['id']; }
- foreach($this->Posts as $key => $p){ if ($p==$post) unset($this->Posts[$key]); }
- unset($th['arr']); $now = date_timestamp_get(date_create());
- $this->FinalizeThread($th, true, $now);
- }
-
- function PushPostVersion(&$post, $optime_id, $mode=1, $info=NULL){
- $a = &$this->GetArchiveHandle($post['id']);
- $ap = []; $ap['id'] = $post['id']; $ap['content'] = $post['real_content'];
- $ap['version'] = isset($post['version'])?$post['version']:$ap['id'];
- if(isset($post['merged_from'])) { $ap['merged_from'] = $post['merged_from']; unset($post['merged_from']); }
- if(isset($post['merged_into'])) { $ap['merged_into'] = $post['merged_into']; unset($post['merged_into']); }
- if(isset($post['merged_thread'])) { $ap['merged_thread'] = $post['merged_thread']; unset($post['merged_thread']); }
- $post['version'] = $optime_id;
- if($mode==1){
- $this->InsertArchivePost($ap);
- }else if($mode==2){
- $post['merged_from'] = $info;
- $this->InsertArchivePost($ap);
- }else if($mode==3){
- $ap['merged_into'] = $info;
- $this->InsertArchivePost($ap);
- if(isset($post['tid']) && $post['tid']['first']!=$post['tid']['last'] && $post!=$post['tid']['first']){
- $this->DetachPost($post['tid'], $post);
- }
- }else if($mode==4){
- $post['merged_thread'] = $info;
- $this->InsertArchivePost($ap);
- }
- }
-
- function &MergeThreads($post_id, $post_into_id){
- $this->ReadPosts();
- $po = &$this->GetPost($post_id, true); $pt = &$this->GetPost($post_into_id, true);
- if (!isset($po) || !isset($pt) || !isset($po['tid']) || !isset($pt['tid']) ||
- !isset($po['tid']['arr'][0]) || !isset($pt['tid']['arr'][0])){ return $this->NULL_POST; }
- $po = &$po['tid']['arr'][0]; $pt = &$pt['tid']['arr'][0];
- $th = &$po['tid']; $tt = &$pt['tid']; $info=[[],[]];
- if($po['id'] < $pt['id']){ $temp = &$th; $th=&$tt; $tt=&$temp; $temp = &$po; $po=&$pt; $pt=&$temp; }
-
- foreach($th['arr'] as &$p){ $info[0][]=$p['id']; }
- foreach($tt['arr'] as &$p){ $info[1][]=$p['id']; }
- $this->EditPost($pt['id'], NULL, NULL, NULL, false, NULL, NULL, 4, $info,NULL);
-
- $arr_combined = array_merge($tt['arr'],$th['arr']);
-
- $cmppmt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
- if(isset($arr_combined[0])){ usort($arr_combined,$cmppmt); } $tt['arr']=&$arr_combined;
- $tt['count'] = sizeof($tt['arr']);
- $this->FinalizeThread($tt, true, $this->TIME_STRING);
-
- $first_post = &$this->NULL_POST;
- if(isset($tt['arr'][0])) $first_post= &$tt['arr'][0];
- $this->NeedWritePosts=1;
- $this->NeedWriteArchive=1;
- return $first_post;
- }
-
- function &MergePosts($ids_string){
- $ids = explode(" ", $ids_string);
- $combined_content = ""; $first_id=NULL;
- $this->ReadPosts(); $child_list=[];
- foreach($ids as $id){
- if(!preg_match('/[0-9]{14}/u',$id) || $this->GetPost($id,true)==$this->NULL_POST) continue;
- if(!isset($first_id)) { $first_id = $id; } else { $combined_content.=PHP_EOL.PHP_EOL."//".$id.PHP_EOL; $child_list[]=$id; }
- $combined_content.=$this->EditPost($id, NULL, NULL, NULL, true, NULL, NULL, false, NULL,NULL);
- }
- if(!isset($child_list[0])) return $this->NULL_POST;
- $first_post = &$this->EditPost($first_id, $combined_content, NULL, NULL, false, NULL, NULL, 2, $child_list,NULL);
- foreach($child_list as $id){
- $this->EditPost($id, NULL, NULL, NULL, false, NULL, NULL, 3, [$first_id,$this->TIME_STRING],NULL);
- }
- $this->NeedWritePosts=1;
- $this->NeedWriteArchive=1;
- return $first_post;
- }
-
- /* push_version: 1 edit 2 post merged from ids list 3 post end into id-ver */
- function &EditPost($id_if_edit, $content, $mark_delete, $reply_to,
- $get_original_only=false, $mark_value=NULL, $rename=NULL,
- $push_version=false, $version_info=NULL, $mastodon_url=NULL){
- $this->ReadImages();
- $this->ReadPosts();
- if(isset($push_version) && $push_version){
- $this->ReadArchive();
- }
- $p_success = NULL;
- if(isset($id_if_edit)){
- $post = &$this->GetPost($id_if_edit,true);
- if($post===$this->NULL_POST) return $this->NULL_POST;
- if($get_original_only){
- return $post['real_content'];
- }
- if(isset($push_version) && $push_version){
- $this->PushPostVersion($post,$this->TIME_STRING,$push_version,$version_info);
- }
- if(isset($content)) {$post['real_content'] = $content; $post['content'] = &$post['real_content'];}
- if(isset($mark_delete)) $post['mark_delete'] = $mark_delete;
- if(isset($mark_value)) $post['mark_value'] = $mark_value;
- if(isset($rename) && preg_match('/^[0-9]{14}$/u',$rename)) $this->RenamePost($post,$rename);
- if(isset($mastodon_url)) { if($mastodon_url!='') $post['mastodon_url']=$mastodon_url; else unset($post['mastodon_url']); }
- $p_success = &$post;
- }else{
- if(!isset($content)) return $this->NULL_POST;
- $id = date('YmdHis');
- if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
- $post = []; $post['id'] = $id;
- $post['real_content'] = $content; $post['content'] = &$post['real_content'];
- if(isset($mark_value) && $mark_value!==NULL) $post['mark_value'] = $mark_value;
- if(isset($reply_to) && ($rep = &$this->GetPost($reply_to,true))!== $this->NULL_POST){
- while($rep !== $this->NULL_POST && isset($rep['next']) && $rep['next']){ $rep = &$this->GetPost($rep['next'],true); }
- if($rep !== $this->NULL_POST){ $rep['next'] = $id; $post['prev'] = $rep['id']; }
- }
- $this->Posts[] = $post;
- $p_success = &$this->Posts[count($this->Posts) - 1];
- }
- $this->NeedWritePosts=1;
- $this->NeedWriteImages=1;
- if(isset($push_version) && $push_version){
- $this->NeedWriteArchive=1;
- }
- return $p_success;
- }
-
- function &EditComment($id_if_edit, $comment_to_id, $content, $email, $name, $link=NULL, $ip=NULL){
- $this->ReadPosts();
- $p_success = NULL;
- if(isset($id_if_edit)){
- $post = &$this->GetPost($id_if_edit,true);
- if($post===$this->NULL_POST || !isset($post['comment_to'])) return $this->NULL_POST;
- if(isset($content)) $post['content'] = $content;
- if(isset($comment_to_id)) $post['comment_to'] = $comment_to_id;
- if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
- if(isset($ip)) $post['ip'] = $ip;
- $p_success = &$post;
- }else{
- if(!isset($content) || !isset($comment_to_id)) return $this->NULL_POST;
- $id = date('YmdHis');
- if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
- if(!($to_post=$this->GetPost($comment_to_id,true))) return $this->NULL_POST;
- $post = []; $post['id'] = $id; $post['content'] = $content; $post['comment_to'] = $comment_to_id;
- if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
- if(isset($ip)) $post['ip'] = $ip;
- $this->Posts[] = $post;
- $p_success = &$this->Posts[count($this->Posts) - 1];
- }
- $this->NeedWritePosts=1;
- return $p_success;
- }
-
- function InsertReplacementSymbols($MarkdownContent, &$post_for_it_is_here){
- $replacement = preg_replace('/<!--[\s\S]*-->/U',"",$MarkdownContent);
- $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
- function($matches){
- $rep = preg_replace('/->/','-@>',$matches[0]);
- $rep = preg_replace('/=>/','=@>',$rep);
- $rep = preg_replace('/<=/','<@=',$rep);
- $rep = preg_replace('/<-/','<@-',$rep);
- $rep = preg_replace('/\R([+]{3,})\R/',PHP_EOL.'@$1'.PHP_EOL,$rep);
- $rep = preg_replace('/\[-/','[@-',$rep);
- $rep = preg_replace('/\{/','{@',$rep);
- $rep = preg_replace('/(en|zh|any)\|(en|zh|any)/','$1@|$2',$rep);
- return $rep;
- },
- $replacement);
- $replacement = preg_replace("/<[-]+>/","↔",$replacement);
- $replacement = preg_replace("/([^-])->/","$1→",$replacement);
- $replacement = preg_replace("/<-([^-])/","←$1",$replacement);
- $replacement = preg_replace("/([^-])[-]+->/","$1⟶",$replacement);
- $replacement = preg_replace("/<-[-]+([^-])/","⟵$1",$replacement);
- $replacement = preg_replace("/<[=]+>/","⇔",$replacement);
- $replacement = preg_replace("/[=]+>/","⇒",$replacement);
- $replacement = preg_replace("/<[=]+/","⇐",$replacement);
- $replacement = preg_replace("/\R([+]{3,})\R/","<div class='page_break'></div>",$replacement);
- $replacement = preg_replace("/\[-(.*)-\]/U","<span class='text_highlight'>$1</span>",$replacement);
- $replacement = preg_replace("/{支付宝(\s+[^}]*?)?}/u","<span class='special_alipay'>支付宝$1</span>",$replacement);
- $replacement = preg_replace("/{PayPal(\s+[^}]*?)?}/ui",
- "<span class='special_paypal'>Pay<span class='special_paypal_inner'>Pal</span>$1</span>",$replacement);
- $replacement = preg_replace("/\/\/([0-9]{14})/imu","<p class='wscroll' id='$1'>".$this->T("链接位置")."</p>",$replacement);
- $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
- function($matches){
- $rep = preg_replace('/-@>/','->',$matches[0]);
- $rep = preg_replace('/<@-/','<-',$rep);
- $rep = preg_replace('/=@>/','=>',$rep);
- $rep = preg_replace('/<@=/','<=',$rep);
- $rep = preg_replace('/\R@([+]{3,})\R/',PHP_EOL.'$1'.PHP_EOL,$rep);
- $rep = preg_replace('/\[@-/','[-',$rep);
- $rep = preg_replace('/\{@/','{',$rep);
- $rep = preg_replace('/(en|zh|any)@\|(en|zh|any)/','$1|$2',$rep);
- return $rep;
- }, $replacement);
- $replacement = preg_replace_callback("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\))(\R*(\R.+){1,})/u",
- function($matches) use (&$post_for_it_is_here){
- $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]);
- return $matches[1].$rep;
- }, $replacement);
- return $replacement;
- }
-
- function CanShowPost(&$p,$in_recent=false){
- if(!isset($p) || isset($p['comment_to'])) return false;
- $is_mark_exp = (isset($p['tid'])&&isset($p['tid']['exp'])&&$p['tid']['exp']) || (isset($p['mark_value'])&&$p['mark_value']==6);
- $is_mark_slf = (isset($p['tid'])&&isset($p['tid']['slf'])&&$p['tid']['slf']) || (isset($p['mark_value'])&&$p['mark_value']>=7);
- $is_mark_sln = (isset($p['tid'])&&isset($p['tid']['sln'])&&$p['tid']['sln']) || (isset($p['mark_value'])&&$p['mark_value']==8);
- if($is_mark_slf && !$this->LoggedIn){ return false; }
- if(isset($this->WayBack)){
- if(isset($p['version'])) { if ($p['version']>$this->WayBack) return false; }
- else if ($p['id']>$this->WayBack) return false;
- }
- if(!$this->InExperimentalMode){
- if(!$this->LoggedIn){
- if($is_mark_exp) return false;
- return true;
- }
- if($this->NotesView && !$is_mark_sln && $in_recent){ return false; }
- return true;
- }else{
- if($is_mark_exp) return true;
- return false;
- }
- }
-
- function SkipProduct(&$p){
- if($this->LoggedIn) return false;
- return (isset($p['mark_value']) && $p['mark_value']==5);
- }
-
- function GetRedirect($args=NULL, $force_index=NULL){ global $INDEXPHP;
- $str = (isset($force_index)?$force_index:$INDEXPHP).'?';
- if(isset($args['post'])) $str.='&post='.$args['post'];
- else if(isset($_GET['post'])) $str.='&post='.$_GET['post'];
- if(isset($args['gallery'])) $str.='&gallery='.$args['gallery'];
- else if(isset($_GET['gallery'])) $str.='&gallery='.$_GET['gallery'];
- if(isset($args['pic'])) $str.='&pic='.$args['pic'];
- else if(isset($_GET['pic'])) $str.='&pic='.$_GET['pic'];
- if(isset($args['settings'])) $str.='&settings='.$args['settings'];
- else if(isset($_GET['settings'])) $str.='&settings='.$_GET['settings'];
- if(isset($args['statistics'])) $str.='&statistics='.$args['statistics'];
- else if(isset($_GET['statistics'])) $str.='&statistics='.$_GET['statistics'];
- if(isset($args['extras'])) $str.='&extras='.$args['extras'];
- else if(isset($_GET['extras'])) $str.='&extras='.$_GET['extras'];
- if(isset($args['category'])) $str.='&category='.$args['category'];
- else if(isset($_GET['category'])) $str.='&category='.$_GET['category'];
- if(isset($args['history'])) $str.='&history='.$args['history'];
- else if(isset($_GET['history'])) $str.='&history='.$_GET['history'];
- if(isset($args['version'])) $str.='&version='.$args['version'];
- else if(isset($_GET['version'])) $str.='&version='.$_GET['version'];
- if(isset($args['search'])) $str.='&search='.$args['search'];
- else if(isset($_GET['search'])) $str.='&search='.$_GET['search'];
- if(isset($args['here'])) $str.='&here='.$args['here'];
- else if(isset($_GET['here'])) $str.='&here='.$_GET['here'];
- return $str;
- }
-
- function WriteAsNecessary(){
- if(!$this->LoggedIn || isset($this->WayBack)){return;}
- if($this->NeedWritePosts){ $this->CachePostLinks(); $this->WritePosts(); }
- if($this->NeedWriteImages){ $this->WriteImages(); }
- if($this->NeedWriteArchive){ $this->WriteArchive(); }
- }
-
- function APubEnsureWebfinger($name, $host){
- if(!is_dir('.well-known')) mkdir('.well-known');
- if(!is_dir('.well-known/webfinger')) mkdir('.well-known/webfinger');
- $f = fopen('.well-known/webfinger/index.php',"w");
- $without_protocol = parse_url($host, PHP_URL_HOST);
- $finger = ["subject"=>"acct:".$name.'@'.$without_protocol,
- "links"=>[["rel"=>"self", "type"=>"application/activity+json", "href"=>$host."?apub_actor=1"]]];
- fwrite($f, "<?php header('Content-Type: application/json'); echo '".json_encode($finger, JSON_UNESCAPED_SLASHES)."'; ?>"); fclose($f);
- if(!file_exists('.well-known/apub_public_key.pem') || !file_exists('.well-known/apub_private_key.php')){
- $res = openssl_pkey_new();
- $this->APubPublicKey = openssl_pkey_get_details($res)['key'];
- openssl_pkey_export($res, $this->APubPrivateKey);
- $f = fopen('.well-known/apub_public_key.pem',"w");
- fwrite($f, $this->APubPublicKey); fclose($f);
- $f = fopen('.well-known/apub_private_key.php',"w");
- fwrite($f, "<?php exit; ?>".PHP_EOL.PHP_EOL.$this->APubPrivateKey); fclose($f);
- }
- }
- function APubInit(){
- $kf = file_get_contents('.well-known/apub_private_key.php'); if($kf===false) return;
- preg_match("/(-----BEGIN PRIVATE KEY-----[\s\S]*)/",$kf,$ma); $this->APubPrivateKey=$ma[1];
- }
- function APubEnsureInfo(){
- if(!isset($this->APubID) || !isset($this->HostURL)) return;
- if(!file_exists('.well-known/apub_public_key.pem')){$this->APubEnsureWebfinger($this->APubID, $this->HostURL);}
- $pk = file_get_contents('.well-known/apub_public_key.pem'); //$pk = preg_replace('/\n/u','\\n',$pk);
- $actor = ["@context"=>["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1"],
- "id"=> $this->HostURL."?apub_actor=1",
- "type"=> "Person",
- "name"=> $this->DisplayName,
- "url"=> $this->HostURL,
- "summary"=> "Lazy... No summary",
- "preferredUsername"=> $this->APubID,
- "inbox"=> $this->HostURL."?apub_inbox=1",
- "outbox"=> $this->HostURL."?apub_outbox=1",
- "publicKey"=> ["id"=> $this->HostURL."?apub_actor=1#main-key",
- "owner"=> $this->HostURL."?apub_actor=1",
- "publicKeyPem"=>$pk]];
- $this->APubActor = json_encode($actor, JSON_UNESCAPED_SLASHES);
- }
-
- function APubMakeOutbox(){
- $this->ReadPosts();$this->ReadImages();
- $obj = ["@context"=>"https://www.w3.org/ns/activitystreams",
- "id"=>$this->HostURL."?apub_outbox=1",
- "type"=>"OrderedCollection"];
- $items=[]; $i=0;
- foreach(array_reverse($this->Posts) as &$p){
- $this->ConvertPost($p);
- $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$p['html']));
- $time = DateTime::createFromFormat('YmdHis', $p['id'], new DateTimeZone('+0800'));
- $ob = ["@context"=>"https://www.w3.org/ns/activitystreams",
- "type"=> "Create",
- "id"=> $this->HostURL."?post=".$p['id']."?apub_object=1",
- "published"=> $time->format('Y-m-d\TH:i:s\Z'),
- //"to"=> ["https://chatty.example/ben/"],
- "actor"=> $this->HostURL."?apub_actor=1",
- "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
- "object"=> ["type"=> "Note",
- "id"=> $this->HostURL."?post=".$p['id'],
- "published"=> $time->format('Y-m-d\TH:i:s\Z'),
- "attributedTo"=> $this->HostURL."?apub_actor=1",
- "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
- "content"=> $text]];
- $items[] = $ob;
- $i++; if($i>20) break;
- }
- $obj['orderedItems'] = $items; $obj["totalItems"] = sizeof($items);
- return json_encode($obj, JSON_UNESCAPED_SLASHES);
- }
- function APubDeliver($body,$target){
- $head_digest = base64_encode(hash("sha256",$body,true));
- $body_digest = "SHA-256=".$head_digest;
- // rfc standards require the timezone be declared as GMT and PHP's built-in formats all say UTC
- // so we gotta do it manually
- $d = new DateTimeImmutable("now", new DateTimeZone('Asia/Shanghai'));
- $d=$d->setTimezone(new DateTimeZone('UTC'));
- $date=$d->format("D, d M Y H:i:s")." GMT";
- $data = "(request-target): post ".parse_url($target,PHP_URL_PATH)
- ."\nhost: ".parse_url($target,PHP_URL_HOST)
- ."\ndate: $date"
- ."\ndigest: $body_digest";
- if (openssl_sign($data, $signature, $this->APubPrivateKey, OPENSSL_ALGO_SHA256) === FALSE) {
- http_response_code(500); die('unable to sign');
- }
- $signature = base64_encode($signature);
- $keyid = 'keyId="'.$this->HostURL.'?apub_actor=1#main-key"';
- $algo = 'algorithm="rsa-sha256"';
- $headers = 'headers="(request-target) host date digest"';
- $signature = "signature=\"$signature\"";
- $h = array(
- 'Content-Type: application/activity+json',
- 'Accept: application/activity+json',
- //"Content-Length: ".strlen($body),
- "Host: ". parse_url($target,PHP_URL_HOST),
- "Date: $date",
- "Digest: $body_digest",
- "Signature: $keyid,$algo,$headers,$signature"
- );
- $ch = curl_init($target);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $h);
- curl_setopt($ch, CURLOPT_USERAGENT, "laMDWiki APub");
- $result = curl_exec($ch);
- curl_close($ch); echo "<pre>";
- print_r($body); echo "\n\n".$target."\n\n";
- print_r($result); echo "\n\n"; print_r($h);
- echo "\n\n"; print_r(curl_getinfo($ch)); echo "</pre>"; exit;
- return $result;
- }
- function APubTestDeliver(){
- $this->APubInit();
- $obj=[];
- $obj['published']=gmdate("Y-m-d\TH:i:s\Z");
- $obj['id']=""; //<-------------------
- $obj['url']=$this->HostURL.""; //<-------------------
- $obj['type']='Note';
- $obj['attributedTo']=$this->HostURL."?apub_actor=1";
- $tag=[]; $tag['type']='Mention'; $tag['name']="@chengdulittlea"; $tag['href']="https://mastodon.art/users/chengdulittlea";
- $obj['tag']=[$tag];
- // must have cc to have notification in mastodon.
- $obj['cc']=["https://mastodon.art/users/chengdulittlea"];
- $obj['content']="<p>@chengdulittlea Hello activitypub from laMDWiki!</p>";
- $obj['to']="https://www.w3.org/ns/activitystreams#Public";
- $obj['inReplyTo']=""; //<-------------------
- $arr=[];
- $arr['@context']="https://www.w3.org/ns/activitystreams";
- $arr['id']=""; //<-------------------
- $arr['actor']=$this->HostURL."?apub_actor=1";
- $arr['type']="Create";
- $arr['to']="https://www.w3.org/ns/activitystreams#Public";
- $arr['object']=$obj;
- $this->APubDeliver(json_encode($arr),"https://mastodon.example/inbox"); //<-------------------
- }
- function APubProcessInbox(){
- $r = file_get_contents('php://input');
- file_put_contents('postdump.txt',$r);
- }
-
- function MakeRSS(){
- $this->ReadPosts();$this->ReadImages();
- $posts = []; if(isset($this->UsePosts[0])){
- $posts = array_reverse($this->UsePosts);
- $last_updated = $this->StandardTime($posts[0]['id']);
- }else{ $last_updated= $this->StandardTime("20000101000000"); }
- $author = "<author><name>".$this->DisplayName."</name><email>".$this->EMail."</email><uri>".$this->HostURL."</uri></author>";
- $all_content="<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom'>".
- "<id>".$this->HostURL."/?rss</id>".
- "<updated>".$last_updated."</updated>".
- "<title>".$this->T($this->Title)."</title>".
- "<link href='".$this->HostURL."/index.php?rss=".($this->LanguageAppendix=='zh'?'zh':'en')."' rel='self'/>".
- "<link href='".$this->HostURL."' />".$author;
- $i=0;
- if(isset($posts[0])) foreach($posts as &$p){
- if($i>100) break;
- if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
- if(isset($p['tid'])){ /* Should always be set. */
- $th = &$p['tid']; if($p['tid']['count']==0) continue; }
-
- if(in_array($p['id'],
- [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
- if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
-
-
- $is_thread = isset($p['tid']['count'])&&($p['tid']['count']>1);
- $is_reversed=false;
- $content="<entry>"; $title = NULL;
- if($is_thread){
- $use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false; if($is_reversed){
- $use_arr=array_reverse($th['arr']); $fp=array_pop($use_arr); array_unshift($use_arr,$fp); }
- foreach($use_arr as &$po){
- $this->ConvertPost($po);
- if(!isset($title)){$title = htmlspecialchars($this->GetPostTitle($po, false, false)); if(!$title){$title='untitled';}
- $content.="<id>".$this->HostURL."/?post=".$po['id']."</id>";
- $content.="<title type='html'>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$po['id']."' />";
- $content.="<published>".$this->StandardTime($po['id'])."</published>";
- $content.="<updated>".$this->StandardTime(isset($po['tid']['last']['version'])?
- $po['tid']['last']['version']:$po['tid']['last']['id'])."</updated>".$author;
- $content.="<content type='html'>"; }
- $content.= htmlspecialchars($po['html']);
- //if(isset($po['images'])&&isset($po['images'][0])) foreach($po['images'] as $im){ $content.=htmlspecialchars($im); }
- }
- $content.=$this->ReadableTime($p['tid']['first']['id'])." - ".
- $this->ReadableTime(isset($p['tid']['last']['version'])?
- $p['tid']['last']['version']:$p['tid']['last']['id']);
- $content.="</content>";
- }else{
- $this->ConvertPost($p);
- if(!isset($title)){$title = htmlspecialchars($this->GetPostTitle($p, false, false)); if(!$title){$title='untitled';}
- $content.="<id>".$this->HostURL."/?post=".$p['id']."</id>";
- $content.="<title type='html'>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$p['id']."' />";
- $content.="<published>".$this->StandardTime($p['id'])."</published>";
- $content.="<updated>".$this->StandardTime(isset($p['tid']['last']['version'])?
- $p['tid']['last']['version']:$p['tid']['last']['id'])."</updated>".$author;}
- $content.= "<content type='html'>".htmlspecialchars($p['html']);
- //if(isset($p['images'])&&isset($p['images'][0])) foreach($p['images'] as $im){ $content.=htmlspecialchars($im); }
- $content.=$this->ReadableTime($p['id'])." - ".
- $this->ReadableTime(isset($p['version'])?$p['version']:$p['id']);
- $content.="</content>";
- }
- $i++;
- $content.="</entry>";
- $all_content.=$content;
- }
- $all_content.="</feed>";
- header( "Content-type: text/xml");
- echo $all_content;
- }
-
- function MakeHereButtons($im, $insert_here){
- if(isset($im['here'])&&isset($im['here'][0])){
- $size=getimagesize($im['file']); $aspect=$size[0]/$size[1];
- echo ($insert_here?"<here>":"")."<div class='here_buttons_inner' style='aspect-ratio:".$aspect.";'>";
- foreach($im['here'] as $here){
- if($insert_here){
- echo "<a href='?show_image=".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'".
- "onclick='event.preventDefault();event.stopPropagation();ShowBigImage(\"".$here[0]."\",1);'></a>";
- }else{
- echo "<a href='?here=images/".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'></a>";
- }
- }
- echo "</div>".($insert_here?"</here>":"");
- }
- }
-
- function ProcessRequest(&$message=NULL, &$redirect=NULL){ global $INDEXPHP;
- if(isset($_GET['gallery_continue']) && $_GET['gallery']){
- $this->ReadImages();
- $this->GetImageBatch($_GET['gallery_continue'],0);
- exit;
- }
- if(isset($_GET['gallery']) && $_GET['gallery']=='default'){
- $redirect = "$INDEXPHP?gallery=".(isset($this->DefaultGallery)&&$this->DefaultGallery!=''?$this->DefaultGallery:"main");
- return 0;
- }
- if(isset($_GET['set_language'])){
- setcookie('la_language',$_GET['set_language'],time()+3600*24*7,'/'); $_COOKIE['la_language'] = $_GET['set_language'];
- $redirect=$this->GetRedirect(); return 0;
- }
- if(isset($_GET['rss'])){
- if(in_array($_GET['rss'],['en','zh'])){$this->LanguageAppendix=$_GET['rss'];}
- $this->MakeRSS(); exit;
- }
- if(isset($_GET['toggle_font'])){ $use_font='local';
- if(!isset($_COOKIE['la_font']) || $_COOKIE['la_font']!='remote') $use_font='remote';
- setcookie('la_font',$use_font,time()+3600*24*7,'/'); $_COOKIE['la_font'] = $use_font;
- $redirect=$this->GetRedirect(); return 0;
- }
- if(isset($_GET['set_wayback'])){
- if($_GET['set_wayback']!='false'){
- $wayback= date('YmdHis');
- if($_GET['set_wayback']=='post'){
- if(isset($_POST['wayback_year'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_year'],4,"0",STR_PAD_LEFT),0,4);
- if(isset($_POST['wayback_month'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_month'],2,"0",STR_PAD_LEFT),4,2);
- if(isset($_POST['wayback_day'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_day'],2,"0",STR_PAD_LEFT),6,2);
- if(isset($_POST['wayback_hour'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_hour'],2,"0",STR_PAD_LEFT),8,2);
- if(isset($_POST['wayback_minute'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_minute'],2,"0",STR_PAD_LEFT),10,2);
- }else{ if(preg_match('/[0-9]{14}/u', $_GET['set_wayback'])) $wayback = $_GET['set_wayback']; }
- setcookie('la_wayback',$wayback,time()+3600*24*7,'/'); $_COOKIE['la_wayback'] = $wayback;
- }else{
- setcookie('la_wayback', null, -1,'/'); unset($_COOKIE['la_wayback']);
- }
- $redirect=$this->GetRedirect(); return 0;
- }
- if(isset($_GET['post'])){ $this->CurrentPostID = $_GET['post']; $this->TagID = $this->CurrentPostID; }
- if(isset($_GET['here'])){ $this->HereID = $_GET['here']; }
- if(isset($_GET['offset'])){ $this->CurrentOffset = $_GET['offset']; }
- if(isset($_GET['post'])){
- $this->ExtraScripts.="window.addEventListener('load', (event) => {ScrollToPost('".$_GET['post']."');});";
- }
- if(isset($_GET['random_here'])){
- $this->DoIdentifyExperimental(); $this->DetectPageType();
- $im = &$this->GiveImageInHere(true); if(isset($im)){ $redirect='?here=images/'.$im['name']; return 0; }
- }
- if(isset($_POST['search_content'])){ $redirect=$INDEXPHP.'?search='.$_POST['search_content'];return 0; }
- if(isset($_GET['image_info']) || isset($_GET['show_image'])){
- $m=isset($_GET['image_info'])?$_GET['image_info']:$_GET['show_image'];
- $direct_return = !isset($_GET['show_image']);
- $this->ReadImages(); $this->ReadPosts();
- $this->SwitchWayBackMode(); if(isset($this->WayBack)){$this->ReadArchive();}
- $im = &$this->FindImage($m);
- if($im==NULL || !isset($im['refs']) || !isset($im['refs'][0])){ echo "not_found"; exit; }
- if($direct_return){
- echo "<ref>".sizeof($im['refs'])."</ref>";
- echo "<insert>";
- }else{ ob_start(); }
- $STR="";
- $this->TBackup();
- foreach(array_reverse($im['refs']) as $ref){
- $p = $this->GetPost($ref);
- if(!$p || !$this->CanShowPost($p)) continue;
- $this->MakeSinglePostV2($p, false, true, "post_preview", true, false, false, false, true);
- }
- $STR=$this->TRestore(" compact");
- if($direct_return){
- echo $STR;
- echo "</insert>";
- $this->MakeHereButtons($im, true);
- }else{
- $str = $STR;
- $this->MakePageBegin($this->NULL_POST);
- $side = "";
- if(isset($im['refs'])&&isset($im['refs'][0])){
- $side.="<span class='small'>".$this->T('该图片出现在')." ".sizeof($im['refs'])." ".$this->T('个帖子中')."</span>";
- }else{$side.="<span class='smaller gray'>".$this->T('该图片未被引用')."</span>";}
- $static_image = isset($im['video'])?NULL:$im['file'];
- $static_video = isset($im['video'])?$im['file']:NULL;
- $this->MakeImageOverlay($side."<ul>".$str."</ul>",$static_image,$static_video);
- $this->MakePageEnd();
- }
- exit;
- }
- if(isset($_GET['confirm_enter']) && $_GET['confirm_enter']!=false){
- setcookie('la_experimental','confirmed',time()+3600*24*7,'/'); $_COOKIE['la_experimental'] = $_GET['confirmed'];
- $redirect=$INDEXPHP.(isset($_GET['post'])?'?post='.$_GET['post']:"");return 0;
- }
- if(isset($_GET['apub_actor'])){
- $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
- echo $this->APubActor; exit;
- }
- if(isset($_GET['apub_outbox'])){
- $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
- echo $this->APubMakeOutbox(); exit;
- }
- if(isset($_GET['apub_inbox'])){
- $this->APubProcessInbox();
- http_response_code(202); exit;
- }
- if($this->LoggedIn){
- if(isset($_GET['TestAPubDeliver'])){
- $this->APubTestDeliver();
- }
- if(isset($_GET['set_notes_view'])){
- setcookie('la_notes_view',$_GET['set_notes_view'],time()+3600*24*7,'/'); $_COOKIE['la_notes_view'] = $_GET['set_notes_view'];
- $redirect=$this->GetRedirect(); return 0;
- }
-
- $this->DoUpload();
-
- if(isset($_POST['settings_button'])){
- if(isset($_POST['settings_title'])) $this->Title=$_POST['settings_title'];
- if(isset($_POST['settings_short_title'])) $this->ShortTitle=$_POST['settings_short_title'];
- if(isset($_POST['settings_display_name'])) $this->DisplayName=$_POST['settings_display_name'];
- if(isset($_POST['settings_email'])) $this->EMail=$_POST['settings_email'];
- if(isset($_POST['settings_special_navigation'])) $this->SpecialNavigation=$_POST['settings_special_navigation'];
- if(isset($_POST['settings_special_sidebar'])) $this->SpecialSidebar=$_POST['settings_special_sidebar'];
- if(isset($_POST['settings_special_footer'])) $this->SpecialFooter=$_POST['settings_special_footer'];
- if(isset($_POST['settings_special_footer2'])) $this->SpecialFooter2=$_POST['settings_special_footer2'];
- if(isset($_POST['settings_special_pinned'])) $this->SpecialPinned=$_POST['settings_special_pinned'];
- if(isset($_POST['settings_special_pinned_notes'])) $this->SpecialPinnedNotes=$_POST['settings_special_pinned_notes'];
- if(isset($_POST['settings_default_gallery'])) $this->DefaultGallery=$_POST['settings_default_gallery'];
- if(isset($_POST['settings_selfauth_path'])) $this->SelfAuthPath=$_POST['settings_selfauth_path'];
- if(isset($_POST['settings_enable_comments'])) $this->CommentEnabled=True; else $this->CommentEnabled=False;
- if(isset($_POST['settings_enable_newsletter'])) $this->NewsletterEnabled=True; else $this->NewsletterEnabled=False;
- if(isset($_POST['settings_gallery_step'])) $this->GalleryStep=$_POST['settings_gallery_step'];
- if(isset($_POST['settings_here_host'])) $this->HereHost=$_POST['settings_here_host'];
- if(isset($_POST['settings_here_title'])) $this->HereTitle=$_POST['settings_here_title'];
- if(isset($_POST['settings_here_short_title'])) $this->HereShortTitle=$_POST['settings_here_short_title'];
- if(isset($_POST['settings_here_album'])) $this->HereAlbum=$_POST['settings_here_album'];
- if(isset($_POST['settings_here_navigation'])) $this->HereNavigation=$_POST['settings_here_navigation'];
- if(isset($_POST['settings_here_footer'])) $this->HereFooter=$_POST['settings_here_footer'];
- if(isset($_POST['settings_exp_host'])) $this->ExpHost=$_POST['settings_exp_host'];
- if(isset($_POST['settings_exp_title'])) $this->ExpTitle=$_POST['settings_exp_title'];
- if(isset($_POST['settings_exp_short_title'])) $this->ExpShortTitle=$_POST['settings_exp_short_title'];
- if(isset($_POST['settings_exp_caution'])) $this->ExpCaution=$_POST['settings_exp_caution'];
- if(isset($_POST['settings_exp_album'])) $this->ExpAlbum=$_POST['settings_exp_album'];
- if(isset($_POST['settings_exp_navigation'])) $this->ExpNavigation=$_POST['settings_exp_navigation'];
- if(isset($_POST['settings_exp_footer'])) $this->ExpFooter=$_POST['settings_exp_footer'];
- if(isset($_POST['settings_allow_language'])) $this->AllowLanguageChoices=True; else $this->AllowLanguageChoices=False;
- if(isset($_POST['settings_mastodon_token'])) $this->MastodonToken=$_POST['settings_mastodon_token'];
- if(isset($_POST['settings_mastodon_url'])) $this->MastodonURL=$_POST['settings_mastodon_url'];
- if(isset($_POST['settings_mastodon_lang'])) $this->MastodonPreferredLang=$_POST['settings_mastodon_lang'];
- if(isset($_POST['settings_host_url'])) $this->HostURL=$_POST['settings_host_url'];
- if(isset($_POST['settings_apub_id']) && isset($this->HostURL)) {
- $this->APubID=$_POST['settings_apub_id'];
- $this->APubEnsureWebfinger($this->APubID,$this->HostURL);
- }
- if(isset($_POST['settings_old_password'])&&password_verify($_POST['settings_old_password'], $this->Password)){
- if(isset($_POST['settings_id'])) $this->Admin=$_POST['settings_id'];
- if(isset($_POST['settings_new_password']) && isset($_POST['settings_new_password_redo']) &&
- $_POST['settings_new_password'] = $_POST['settings_new_password_redo'])
- {$this->Password=password_hash($_POST['settings_new_password'], PASSWORD_DEFAULT);}
- $redirect=$_SERVER['REQUEST_URI'];
- $this->DoLogout();
- }
- $this->WriteConfig();
- return 0;
- }
- if(isset($_POST['settings_save_redirect'])){
- if(isset($_POST['settings_redirect'])){
- $this->BuildRedirectConfig($_POST['settings_redirect']);
- }
- $this->WriteConfig();
- $redirect = $INDEXPHP.'?extras=true'; return 0;
- }
- if(isset($_POST['settings_save_translation'])){
- if(isset($_POST['settings_translation'])){
- $f = fopen("custom_translations.md", "w"); fwrite($f,$_POST['settings_translation']); fflush($f); fclose($f);
- }
- $redirect = $INDEXPHP.'?extras=true'; return 0;
- }
- if(isset($_GET['post'])){
- if(isset($_GET['post_original'])){
- echo $this->EditPost($_GET['post'],NULL,false,NULL,true,NULL,NULL,false,NULL,NULL);
- exit;
- }
- }
- if(isset($_GET['mark_delete']) && isset($_GET['target'])){
- $this->EditPost($_GET['target'],NULL,$_GET['mark_delete']=='true',NULL,false,NULL,NULL,false,NULL,NULL);
- if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
- return 0;
- }
- if(isset($_GET['set_mark']) && isset($_GET['target'])){
- $this->EditPost($_GET['target'],NULL,NULL,NULL,NULL,$_GET['set_mark'],NULL,false,NULL,NULL);
- if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
- return 0;
- }
- if((isset($_POST['post_button'])||isset($_POST['post_button_note'])) && isset($_POST['post_content'])){
- $c = $_POST['post_content'];
- if('有什么想说的' == $c){ return 0;}
- if(preg_match('/\[LAMDWIKIPOST/u',$c))
- { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
- $reply_to = (isset($_POST['post_reply_to'])&&$_POST['post_reply_to']!="")?$_POST['post_reply_to']:NULL;
- $edit_id = (isset($_POST['post_edit_target'])&&$_POST['post_edit_target']!="")?$_POST['post_edit_target']:NULL;
- $push_history = (isset($edit_id) && isset($_POST['post_record_edit']));
- $postmark=NULL;
- if(isset($_POST['post_button_note'])){ $postmark=8; }
- if(($edited = $this->EditPost($edit_id, $c, NULL, $reply_to,NULL,$postmark,NULL,$push_history,NULL,NULL))!=NULL){
- $redirect='?post='.$edited['id']; return 0;
- };
- }
- if(isset($_POST['post_rename_confirm']) && isset($_POST['post_rename_name']) && isset($_GET['rename_post'])){
- if(($edited =$this->EditPost($_GET['rename_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,NULL))!=NULL){
- $redirect='?post='.$edited['id']; return 0;
- };
- }
- if(isset($_POST['post_mastodon_confirm']) && isset($_POST['post_mastodon_url']) && isset($_GET['mastodon_post'])){
- if(($edited =$this->EditPost(
- $_GET['mastodon_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,$_POST['post_mastodon_url']))!=NULL){
- $redirect='?post='.$edited['id']; return 0;
- };
- }
- if(isset($_GET['mastodon_send_post']) && preg_match('/([0-9]{14})/u',$_GET['mastodon_send_post'],$m)){
- $this->ReadImages(); $this->ReadPosts(); $post = &$this->GetPost($m[1]); $err=$this->T("未知错误");
- if(isset($post)){
- if($mastodon_url = $this->MastodonSendPost($post, $err)){
- $this->NeedWritePosts = 1; $this->WritePosts(); // for mastodon url
- echo "SUCCESS ".$mastodon_url;
- }else{ echo $err; }
- } exit;
- }
- if(isset($_GET['merge_threads'])&&$_GET['merge_threads']!=""){
- if(preg_match('/([0-9]{14})\s+([0-9]{14})/u',$_GET['merge_threads'],$m)){
- if(($pe = &$this->MergeThreads($m[1],$m[2]))!=$this->NULL_POST){ $redirect='?post='.$pe['id']; return 0; }
- }
- }
- if(isset($_GET['merge_posts'])&&$_GET['merge_posts']!=""){
- if(($pe = &$this->MergePosts($_GET['merge_posts']))!=$this->NULL_POST){
- $redirect='?post='.$pe['id']; return 0;
- }
- }
- if ($this->CommentEnabled && isset($_POST['comment_confirm']) && (isset($_GET['comment_to']))
- && isset($_POST['comment_box']) && isset($_POST['comment_email']) && isset($_POST['comment_name'])){
- $c = $_POST['comment_box'];
- if(preg_match('/\[LAMDWIKIPOST/u',$c))
- { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
- $comment_to = ($_GET['comment_to']!="")?$_GET['comment_to']:NULL;
- if(($edited = $this->EditComment(NULL,
- $_GET['comment_to'], $c, $_POST['comment_email'], $_POST['comment_name'],
- isset($_POST['comment_link'])?$_POST['comment_link']:NULL,
- $_SERVER['REMOTE_ADDR']))!=NULL){
- $redirect='?post='.$_GET['post'];
- return 0;
- };
- }
- if(isset($_GET['send']) && isset($_GET['addr']) && isset($_GET['post']) && $_GET['post']!=''){
- require_once("mailsub.php"); $this->ReadPosts(); $this->ReadImages();
- $post = &$this->GetPost($_GET['post'],true); if($post==$this->NULL_POST){ echo $this->T("问题"); exit; }
- $content = $this->GenerateSinglePost($post, 0, 0, 0, 0, 0);
- //$content = preg_replace("/(=[\'\"](.*\.php)?)(\?)/","$1{$GLOBALS['MY_HOST']}/$3",$content);
- //$content = preg_replace("/(src=[\'\"])(images)/","$1{$GLOBALS['MY_HOST']}/$2",$content);
- //$content = preg_replace("/(=[\'\"])(Files)/","$1{$GLOBALS['MY_HOST']}/$2",$content);
- $content = $content."<br />.<hr />".mailsub_regular_text($_GET['send'],$_GET['addr']);
- $title=$this->GetPostTitle($post);
- if(send_email($_GET['addr'],$title,$content)<0){ echo $this->T("问题"); exit; }
- echo $content; exit;
- }
- if(isset($_POST['gallery_edit_confirm']) && isset($_POST['gallery_edit_new_name']) && $_POST['gallery_edit_new_name']!=''){
- $old_name = isset($_POST['gallery_edit_old_name'])?$_POST['gallery_edit_old_name']:"";
- $new_name = $_POST['gallery_edit_new_name'];
- if($old_name!=''){
- $desc=isset($_POST['gallery_edit_description'])?$_POST['gallery_edit_description']:null;
- if(!preg_match('/[0-9]{14}/',$desc))$desc="";
- $this->EditGallery($old_name, $new_name, false, true, null, null,$desc);
- $redirect='?gallery='.$new_name;
- }else{
- $this->EditGallery(null, $new_name, false, true, null,null);
- if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
- }
- return 0;
- }
- if(isset($_GET['gallery_edit_delete'])&&$_GET['gallery_edit_delete']!=null){
- $this->EditGallery($_GET['gallery_edit_delete'], null, true, true, null, null,null);
- if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery=main'; else $redirect=$INDEXPHP;
- return 0;
- }
- if(isset($_POST['gallery_move_ops'])&&isset($_POST['gallery_move_ops'])){
- if(preg_match('/^(REM|ADD)\s+(\S+)\s+(.*)$/u', $_POST['gallery_move_ops'], $ma)){
- $this->ReadImages();
- if(preg_match_all('/(\S+)/u', $ma[3], $files, PREG_SET_ORDER)) foreach($files as $name){
- $this->EditImage($name[1], $ma[2], ($ma[1]=='REM'), NULL, NULL, NULL, NULL);
- }
- }
- if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
- return 0;
- }
- if(isset($_GET['gallery_set_featured'])&&isset($_GET['value'])){
- $this->EditGallery($_GET['gallery_set_featured'], null, false, true, $_GET['value']!='false', null);
- if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
- return 0;
- }
- if(isset($_GET['gallery_set_experimental'])&&isset($_GET['value'])){
- $this->EditGallery($_GET['gallery_set_experimental'], null, false, true, null, $_GET['value']!='false');
- if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
- return 0;
- }
- if(isset($_GET['image_list'])&&$_GET['image_list']!=""){
- $this->ReadImages();
- $gallery = $_GET['image_list']; $count=0;
- foreach($this->Images as $im){ if($count>25){ break; }
- if($gallery=='main'){ echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; $count++; continue; }
- if(isset($im['galleries']) && isset($im['galleries'][0]) && in_array($gallery,$im['galleries'])) {
- echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; $count++; }
- }
- exit;
- }
- $do_image_redirect = 0;
- if (isset($_POST['image_button']) && isset($_GET['pic']) &&
- preg_match('/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4))/u',$_GET['pic'],$ma)){
- $this->ReadImages(); $pic = $ma[1]; $picext=$ma[2];
- if(isset($_POST['image_ops_product_link'])){
- $this->EditImage($pic, NULL, false, $_POST['image_ops_product_link'], NULL, NULL, NULL);
- $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
- }
- if(isset($_POST['image_edit_new_name']) && preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_edit_new_name'],$man)){
- $this->EditImage($pic, NULL, false, NULL, $man[1], NULL, NULL);
- $redirect=$this->GetRedirect(['pic'=>'images/'.$man[1].'.'.$picext]);
- $do_image_redirect = 1;
- }
- if(isset($_POST['image_parent'])){ $parent="";
- if(preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_parent'],$man)){ $parent = $man[1]; }
- $this->EditImage($pic, NULL, false, NULL, NULL, $parent, NULL);
- $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
- }
- if(isset($_POST['image_align'])){$val=$_POST['image_align'];
- $this->EditImage($pic, NULL, false, NULL, NULL, NULL, $val);
- $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
- }
- $this->NeedWriteImages = 1;
- if($do_image_redirect) return 0;
- }
- if(isset($_GET['rewrite_styles'])){
- $this->WriteStyles(); $redirect='?extras=true'; return 0;
- }
- if(isset($_GET['regenerate_thumbnails'])){
- $this->RegenerateThumbnails(); $redirect='?extras=true'; return 0;
- }
- if(isset($_GET['cleanup_image_compression'])){ $run=false;
- if(isset($_GET['run'])){ $run=true; }
- $this->CleanupImageCompression($run); $redirect='?extras=true'; return 0;
- }
- if(isset($_GET['clear_all_logins'])){
- $this->LoginTokens=[]; $this->WriteTokens();
- }
- if($_SERVER['HTTP_HOST']=='localhost'){$this->WriteStyles();}
- }
- return 0;
- }
-
- function PostProcessHTML($html,&$added_images=null,$do_product_info=false, &$product_info=null, &$orig_src_list=null, &$end_wide=null, &$print_wide=null){
- if(!$this->LoggedIn){
- $html = preg_replace("/(<a[^>]*href=[\'\"])(.*?)([\'\"][^>]*)>(\#.*?<\/a>)/u","",$html);
- }
- $html = preg_replace("/(<a[^>]*href=[\'\"])([0-9]{14})([\'\"][^>]*)>(.*?<\/a>)/u","$1?post=$2$3 onclick='ShowWaitingBar()'>$4",$html);
- $html = preg_replace("/(<a[^>]*href=[\'\"])\@(.*?)([\'\"][^>]*)>(.*?<\/a>)/u","$1?category=$2$3 onclick='ShowWaitingBar()'>$4",$html);
- $html = preg_replace("/(<a[^>]*href=[\'\"])((.*?:\/\/).*?)([\'\"][^>]*)(>)(.*?)(<\/a>)/u",
- "$1$2$4 target='_blank'$5$6<sup>↗</sup>$7",$html);
- $html = preg_replace("/<p>\s*\@.*?<\/p>/mu","",$html);
- $html = preg_replace("/\{\s*(REVERSED|INTERESTING|HEADER|FOOTER)\s+(.*?)\}/imu","",$html);
- $html = preg_replace("/\{\s*(REVERSED|NO_TIME|NO_TITLE|SLIDES)\s*\}/imu","",$html);
- $html = preg_replace("/\{\s*WIDE\s*\}/imu","",$html,-1,$rep_count); if($rep_count){$print_wide=true;}
- $images = []; $images_noclick = []; $images_orig_src_list = [];
- $html = preg_replace_callback(
- "/(<p>\s*|<a\s.*?>\s*)?(<img([^>]*)src=[\'\"])(images\/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4)))([\'\"][^>]*)\/>(\s*<\/p>)?/u",
- function($m) use (&$images,&$images_noclick,&$images_orig_src_list) {
- if(isset($m[1])&&$m[1]&&$m[1][1]=='a'){ $height="";
- if(preg_match("/([0-9]{1,2})em/u",$m[0],$hm)){$height=' style="height:'.$hm[1].'em;"';}
- return "<a class='imbtn'".$height.substr($m[0],2); }
- $orig_src = $src = $m[5]; $keep = false; $original = false; $float=false;
- if (preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[3]) ||
- preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[7])) { $keep=true; }
- if ($keep && preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[3]) ||
- preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[7])) { $original=true; }
- if (preg_match('/alt=[\'\"].*float.*[\'\"]/u',$m[3]) ||
- preg_match('/alt=[\'\"].*float.*[\'\"]/u',$m[7])) { $keep=true;$original=true;$float=true; }
- if(($im = &$this->FindImage($m[5]))!=NULL && isset($im['thumb'])){
- $src = $im['thumb']; $orig_src=$im['file'];
- }if($im == NULL){ $im = &$this->NULL_IMAGE_DUMMY; }
- $media_start = $m[2];
- $media_end = $m[7];
- $dataset = " data-imgsrc='".$m[5]."'".
- (isset($im['product'])?" data-product='".$im['product']."'":"").
- (isset($im['parent'])?" data-parent='".$im['parent']."'":"").
- (isset($im['align'])?' data-align="'.$im["align"].'" style="object-position:'.$im['align'].';"':"").
- ($original?" class='original_img'":"");
- if(isset($im['video']) && isset($im['video'])!=''){
- $media_start = "<video controls".$dataset."><source src='"; $media_end="' type='".$im['video']."'></video";
- $src = $orig_src; $dataset="";
- }
- $float_add=""; if($float){ $float_add=" imd_float"; }
- if($this->InHereMode){
- $click = "<div class='imd$float_add'>"."<a href='?here=".$im['file']."' class='original_img'>".
- $media_start.($original?$orig_src:$src).$media_end."></a></div>";
- $ret=""; if($keep) { $ret = $click; }
- else { $images[] = $click; }
- return $ret;
- }else{
- $click ="<div class='imd$float_add'><a href='?show_image={$im['name']}' target='_blank' onclick='event.preventDefault();'>".
- $media_start.($original?$orig_src:$src).$media_end.$dataset."></a></div>";
- $images_noclick[]=$media_start.$src.$media_end.">"; $images_orig_src_list[]=$orig_src;
- $ret = "";
- if($keep) { $ret = $click; }
- else { $images[] = $click; }
- if(isset($m[1])&&isset($m[8])&&$m[1]&&$m[8]) return $ret;
- else return ((isset($m[1])&&$m[1]?$m[1]:"").$ret.(isset($m[8])&&$m[8]?$m[8]:""));
- }
- },$html,-1,$count);
- $html = preg_replace('/<p>\s*<\/p>/u',"", $html); if($html==""){$html="<p> </p>";}
- if(sizeof($images)){
- if((!$this->InHereMode) && sizeof($images)==1){$html.= $images[0]; }
- else{
- $html.="<div class='p_row'>";
- foreach($images as $img){
- $html.="<div class='p_thumb'>".$img."</div>";
- }
- $html.="<div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div>";
- }
- }
- if(sizeof($images_noclick)){ $added_images = $images_noclick; }
- if(sizeof($images_orig_src_list)) { $orig_src_list = $images_orig_src_list; }
- if($do_product_info){
- $html = preg_replace_callback("/\{PRICE\s+([^]]+?)\}/u",
- function($m) use (&$product_info) { $product_info['price']=$m[1];return ""; },$html);
- $html = preg_replace_callback("/\{SHORT\s+([^]]+?)\}/u",
- function($m) use (&$product_info) { $product_info['short']=$m[1];return ""; },$html);
- $html = preg_replace('/<p>\s*<\/p>/u',"", $html);
- if (preg_match('/<h[1-5]>(.+?)<\/h/u',$html,$title)){ $product_info['title']=$title[1]; }
- else { $product_info['title'] = $this->T('商品'); }
- if(!isset($product_info['price'])) $product_info['price']=$this->T('未设置价格');
- $html = preg_replace_callback("/\{PURCHASE\s+([^]]+?)\}/u",function($m) use (&$product_info) {
- return "<a class='purchase_button' href=\"mailto:".$this->T($this->DisplayName)."<".$this->EMail.">?subject=".
- $this->T('购买').' '.$product_info['title'].
- "&body=".$this->T('你好!我想购买').$product_info['title'].urlencode(PHP_EOL.PHP_EOL).
- $this->FullURL().urlencode(PHP_EOL.PHP_EOL)."\">".$m[1]."</a>"; },$html);
- }
- if(preg_match("/(<\/div>|<\/table>|<\/video>)\s*$/u",$html)){$end_wide=true;}
- return $html;
- }
-
- function ConvertPost(&$post){
- if(!isset($post['html'])){
- $info=[];
- $post['html'] = $this->TranslatePostParts($this->PostProcessHTML($this->ChoosePartsByLanguage($this->PDE->text($this->InsertReplacementSymbols($post['content'], $post)),true),
- $post['images'],
- isset($post['product']), $info,
- $post['original_images'],
- $post['end_wide'],
- $post['wide']));
- if(isset($post['product'])) $post['product']=$info;
- }
- }
- function GetPostTitle(&$post, $h1_only=false, $add_unamed=true){
- if($h1_only){
- if(preg_match('/^#\s+(.*?)$/mu',$post['content'],$m)) return strip_tags($this->TranslatePostParts($m[1]));
- else return NULL;
- }
- if(!isset($post['title'])){
- if(preg_match('/^#{1,6}\s+(.*?)$/mu',$post['content'],$m)){$post['title']=$m[0];}
- else{ $post['title'] = $add_unamed?$this->T('未命名'):"";
- if(preg_match('/(.*)$/mu',$post['content'],$m)){
- $post['title'].=($add_unamed?' (':'').$this->PDE->text($m[1]).($add_unamed?')':''); }
- }
- }
-
- return strip_tags($this->TranslatePostParts($this->PDE->text($post['title'])));
- }
-
- function DetectPageType(){
- if ($this->InExperimentalMode) $this->PageType='experimental';
- else if($this->InHereMode) $this->PageType='here';
- else if(isset($_GET['history'])) $this->PageType='history';
- else if(isset($_GET['extras'])) $this->PageType='extras';
- else if(isset($_GET['settings'])) $this->PageType='settings';
- else if(isset($_GET['gallery'])) $this->PageType='gallery';
- else if(isset($_GET['search'])) $this->PageType='search';
- else if(isset($_GET['category'])) $this->PageType='category';
- else if(isset($this->CurrentPostID)) $this->PageType = "post";
- else if(isset($_GET['comments'])) $this->PageType='comments';
- else if(isset($_GET['statistics'])) $this->PageType='statistics';
- else $this->PageType = "main";
-
- $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
- if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
- $this->VisitedHere = $_SESSION[$visited_here];
- }
-
- function MakePageBegin(&$p){ $title=$this->InExperimentalMode?$this->T($this->ExpTitle):
- ($this->InHereMode?$this->T($this->HereTitle):$this->T($this->Title)) ?>
- <!DOCTYPE html><html lang='zh-Hans-CN'>
- <head>
- <meta charset='utf-8'>
- <meta content="width=device-width, initial-scale=1" name="viewport">
- <title><?=$title?></title>
- <meta property="og:title" content="<?=$title.(isset($p)?(" | ".$this->GetPostTitle($p)):"")?>">
- <?php if(isset($p)&&isset($p['hasi'])&&isset($p['hasi'][0])){?> <meta property="twitter:card" content="summary_large_image" />
- <meta property="og:image" content="<?=(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']==='on'?"https":"http").'://'.$_SERVER['HTTP_HOST'].'/images/thumb/'.$p['hasi'][0]?>"><?php } ?>
- <?php if($this->UseRemoteFont){ ?><style>
- @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Regular.otf") format("opentype");font-weight:normal;}
- @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Bold.otf") format("opentype");font-weight:bold;}
- </style><?php } ?>
- <link href='styles/main.css' rel='stylesheet' type="text/css">
- <link rel="alternate" type="application/rss+xml" title="<?=$this->T($this->Title);?>" href="?rss=<?=$this->LanguageAppendix;?>" />
- <link rel="alternate" hreflang="zh" href="index.php?<?=$_SERVER['QUERY_STRING']?>" />
- <link rel="alternate" hreflang="en" href="en.php?<?=$_SERVER['QUERY_STRING']?>" />
- <link rel="alternate" hreflang="x-default" href="en.php?<?=$_SERVER['QUERY_STRING']?>" />
- <?php if(isset($this->SelfAuthPath)&&$this->SelfAuthPath!=""){ ?>
- <link rel="authorization_endpoint" href="<?=$this->SelfAuthPath?>" /><?php } ?>
- <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>
- </head>
- <div class='page'>
- <?php }
- function MakeHeader(&$p){
- $this->MakePageBegin($p) ?>
- <script type='text/javascript'>
- function toggle_mobile_show(a){a.classList.toggle('hidden_m')}
- function ShowWaitingBar(){wait = document.querySelector("#waiting_bar");wait.style.display='';}
- function HideWaitingBar(){wait = document.querySelector("#waiting_bar");wait.style.display='none';}
- <?php if(!$this->InHereMode){ ?>
- function la_auto_grow(element){
- s=window.scrollY;element.style.height="30px";element.style.height=(element.scrollHeight)+"px";window.scroll(0, s);
- }
- function ShowBackdrop(alpha=0.5){
- b = document.getElementById('backdrop');
- b.style="background-color:rgba(0,0,0,"+alpha+");";
- b.style.animation='backdrop_fade_in 0.3s forwards';
- b.style.display = 'block';
- }
- function HideBackdrop(){
- b = document.getElementById('backdrop');
- b.style.animation='backdrop_fade_out 0.3s forwards';
- setTimeout(function(e1){e1.style.display='none';}, 300, b);
- }
- function ShowRightSide(big,elem_to_clone){
- p = document.getElementById('pop_right');
- if(elem_to_clone){
- c = elem_to_clone.cloneNode(true);
- c.id='side_bar_cloned';c.className="";c.style="";
- p.querySelector('._content').appendChild(c);
- }
- p.classList.remove('pop_right','pop_right_big');
- if(big) {p.classList.add('pop_right_big');p.style.animation='pop_slide_in_big 0.3s forwards';}
- else {p.classList.add('pop_right');p.style.animation='pop_slide_in 0.3s forwards';}
- p.style.display='block';
- ShowBackdrop(0.5);
- }
- function HideRightSide(){
- p = document.getElementById('pop_right');
- if(side=p.querySelector('#side_bar_cloned')){
- side.remove();
- }
- put = document.querySelector("#_uploader");
- if(p.classList.contains('pop_right')){p.style.animation='pop_slide_out 0.3s forwards';}
- else{p.style.animation='pop_slide_out_big 0.3s forwards';}
- setTimeout(function(e1, e2){e1.style.display='none';if(e2)e2.style.display='none';}, 300, p, put);
- HideBackdrop();
- }
- function CssNumberID(id){ return "#\\3"+id.substr(0,1)+" "+id.substr(1); }
- function ScrollToPost(id){
- post=null;
- if(!(post = document.querySelector("[data-post-id='"+id+"']"))){
- if(!(post = document.querySelector(CssNumberID(id)))) return; }
- post.scrollIntoView({ behavior: 'smooth', block: 'start'});
- }
- <?php } ?>
- </script><input type='checkbox' class='lpctrl' id='titlectrl'>
- <header<?=$this->InHereMode?' class="exp_h_f"':''?>><div>
- <?php if($this->InHereMode){
- $this->MakeExpNavButtons($p);
- }else{
- $this->MakeNavButtons($p);
- if(isset($p['tid']['header'])){ ?><div style='float:right' class='show_on_print'><?=$this->ChoosePartsByLanguage($p['tid']['header']);?></div><?php }
- echo "<hr class='hidden_m'>";
- } ?>
- <?php if(isset($this->WayBack)){
- $time=(isset($_COOKIE['la_wayback']) && preg_match('/[0-9]{14}/u',$_COOKIE['la_wayback']))?$_COOKIE['la_wayback']:date('YmdHis');
- $year=substr($time,0,4);$month=substr($time,4,2);$day=substr($time,6,2);
- $hour=substr($time,8,2);$minute=substr($time,10,2);?> <div class='text_highlight'>
- <b><span onclick='document.getElementById("wayback_config").classList.toggle("hidden_m")'>
- <div class='wayback_close' onclick='event.stopPropagation()'><a href='<?=$this->GetRedirect()?>&set_wayback=false'>
- <span class='hidden_m'><?=$this->T('退出')?></span>× </a></div>
- + <?=$this->T('正以过去的日期浏览')?></b><div id='wayback_config' class='wayback_expand hidden_m'>
- <select id="wayback_year" name="wayback_year" form="wayback_form"><?php for($y=$this->YearBegin;$y<=$this->YearEnd;$y++){ ?>
- <option value="<?=$y?>"<?=$y==$year?" selected":""?>><?=$y?></option><?php } ?></select>
- <br class='hidden_on_desktop' />
- <select id="wayback_month" name="wayback_month" form="wayback_form"><?php for($y=1;$y<=12;$y++){ ?>
- <option value="<?=$y?>"<?=$y==$month?" selected":""?>><?=$y?></option><?php } ?></select>
- <select id="wayback_day" name="wayback_day" form="wayback_form"><?php for($y=1;$y<=31;$y++){ ?>
- <option value="<?=$y?>"<?=$y==$day?" selected":""?>><?=$y?></option><?php } ?></select>
- <br class='hidden_on_desktop' />
- <select id="wayback_hour" name="wayback_hour" form="wayback_form"><?php for($y=0;$y<=23;$y++){ ?>
- <option value="<?=$y?>"<?=$y==$hour?" selected":""?>><?=$y?></option><?php } ?></select>:
- <select id="wayback_minute" name="wayback_minute" form="wayback_form"><?php for($y=0;$y<=59;$y++){ ?>
- <option value="<?=$y?>"<?=$y==$minute?" selected":""?>><?=$y?></option><?php } ?></select>
- <br class='hidden_on_desktop' />
- <form action="<?=$this->GetRedirect()?>&set_wayback=post" method="post" style='display:none;' id='wayback_form'></form>
- <input type='submit' style='font-weight:normal;border-bottom:none;' class='button clean_a' form='wayback_form'
- id='wayback_see' name='wayback_see' value="<?=$this->T('查看')?> →">
- </div></div><?php } ?>
- </div></header>
- <div id='waiting_bar' style='display:none;'></div>
- <script>ShowWaitingBar();window.addEventListener('load',(event) =>{HideWaitingBar();}); </script>
- <?php if(!$this->InHereMode){ ?>
- <div id='post_menu' style='display:none;' class='pop_menu clean_a'>
- <ul>
- <li><span id='_time_hook' class='smaller'>时间</span> <a href='javascript:HidePopMenu();'>×</a></li>
- <li><a id='share_copy'>⎘<?=$this->T('复制链接')?></a></li>
- <hr />
- <?php if($this->LoggedIn){ ?>
- <li><a id='menu_history'><?=$this->T('历史')?></a>
- <?php if(!isset($this->WayBack) && $this->PageType!='search'){ ?>
- | <a id='menu_edit'><?=$this->T('修改')?></a><?php } ?></li>
- <?php if(!isset($this->WayBack)){ ?><li>
- <a id='menu_refer_copy'><?=$this->T('复制编号')?></a><?php if($this->PageType!='search'){ ?>
- | <a id='menu_refer'><?=$this->T('引用')?></a><?php } ?><br class='hidden_on_desktop' />
- </li>
- <li><a id='menu_rename' href='javascript:ToggleRenameDetails()'><?=$this->T('改名')?></a> |
- <a id='menu_mark' href='javascript:ToggleMarkDetails()'><?=$this->T('标记')?></a></li>
- <li id='mark_details' style='display:none;'><b>
- <a id='mark_set_clear' href='javascript:SetMark(-1);'>_</a>
- <a id='mark_set_0' href='javascript:SetMark(0);'><?=$this->Markers[0]?></a>
- <a id='mark_set_1' href='javascript:SetMark(1);'><?=$this->Markers[1]?></a>
- <a id='mark_set_2' href='javascript:SetMark(2);'><?=$this->Markers[2]?></a>
- <a id='mark_set_3' href='javascript:SetMark(3);'><?=$this->Markers[3]?></a>
- <a id='mark_set_4' href='javascript:SetMark(4);'><?=$this->Markers[4]?></a>
- <a id='mark_set_5' href='javascript:SetMark(5);'><?=$this->Markers[5]?></a>
- <a id='mark_set_6' href='javascript:SetMark(6);'><?=$this->Markers[6]?></a>
- <a id='mark_set_7' href='javascript:SetMark(7);'><?=$this->Markers[7]?></a>
- <a id='mark_set_8' href='javascript:SetMark(8);'><?=$this->Markers[8]?></a>
- </b></li>
- <li id='rename_details' style='display:none;text-align:left;' class='smaller'>
- <form action="" method="post" style='display:none;' id='post_rename_form'></form>
- <input type='text' id='post_rename_name' name='post_rename_name' form="post_rename_form" style='width:9em;'>
- <input class='button' type='submit' form='post_rename_form'
- name='post_rename_confirm' id='post_rename_confirm' value='<?=$this->T('确认')?>'>
- </li><hr /> <?php if(isset($this->MastodonToken)){ ?>
- <li><a id='menu_mastodon_view' class='button' style='display:none;' target='_blank'><?=$this->T('转到')?></a>
- <a id='menu_mastodon' href='javascript:ToggleMastodonDetails()'><?=$this->T('长毛象')?></a></li>
- <li id='mastodon_details' style='display:none;text-align:left;' class='smaller'>
- <a id='menu_mastodon_send' class='button' target='_blank'><?=$this->T('发送')?></a>
- <form action="" method="post" style='display:none;' id='post_mastodon_form'></form>
- <input type='text' id='post_mastodon_url' name='post_mastodon_url' form="post_mastodon_form" style='width:9em;'>
- <input class='button' type='submit' form='post_mastodon_form'
- name='post_mastodon_confirm' id='post_mastodon_confirm' value='<?=$this->T('修改')?>'></li> <?php } ?>
- <hr /><li><a id='menu_delete' class='smaller'><?=$this->T('删除')?></a></li><?php } ?>
- <?php }else{ ?>
- <li><a id='menu_history'><?=$this->T('历史')?></a></li>
- <?php } ?>
- </ul>
- </div>
- <div id='backdrop' style='display:none;' class='backdrop' onclick='HideRightSide();HideBigImage(1);'
- ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"></div>
- <div id='pop_right' class='pop_right' onclick='event.stopPropagation()'>
- <div style='text-align:right;position:sticky;top:0;'><a class='clean_a' href='javascript:HideRightSide();'>
- <?=$this->T('关闭')?>→</a></div>
- <?php if($this->LoggedIn && in_array($this->PageType,['main','post'])){ ?>
- <div id='_uploader' style='display:none;'>
- <?php $this->MakeUploader(true); ?>
- <p> </p>
- <?php $this->MakeSideGalleryCode(); ?>
- </div>
- <?php } ?>
- <div class='_content'></div>
- </div>
- <?php } ?>
- <?php
- }
-
- function ChoosePartsByLanguage($content,$use_p=false){ if(!isset($content)) return $content;
- $split = preg_split('/'.($use_p?'<p>\s*':'').'((en|zh|any)\|(en|zh|any))'.($use_p?'<\/p>\s*':'').'/u',$content, -1,
- PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
- $lang = $this->LanguageAppendix; $last_lang='0'; $reduced="";
- if($split) for($i=0;$i<sizeof($split);$i+=4){
- $this_lang = '0'; if($i+2>=sizeof($split)){ $this_lang = $last_lang; }else{ $this_lang = $split[$i+2]; }
- if($this_lang==$lang || $this_lang=='any'){ $reduced.=$split[$i]; }
- if($i+3<sizeof($split)){ $last_lang = $split[$i+3]; }
- }
- if(!$reduced)$reduced = $content;
- return $reduced;
- }
- function TranslatePostParts($html){
- $html = preg_replace_callback('/>(\s*)([^><]+?)(\s*)</u', function($ma){
- $reduced = $this->ChoosePartsByLanguage($ma[2], false);
- return ">".$ma[1].$this->T($reduced).$ma[3]."<";
- }, $html);
- return $html;
- }
-
- function MakeNavButtons(&$p){ global $INDEXPHP; $interesting=$this->IsInterestingPost($p); $no_title=isset($p['tid']['first']['no_title']);?>
- <a href='<?=$INDEXPHP?>' class='clean_a hidden_m<?=$no_title?" hidden_on_print":""?>' onclick='ShowWaitingBar()'><b><?=$this->T($this->Title);?></b></a>
- <?=$no_title?"<a class='inline_print'> </a>":""?>
- <label for='titlectrl' id='mtitle'><b><a class='hidden_on_desktop'><?=$this->T($this->ShortTitle)?>...</a></b></label>
- <div class='header_nav'>
- <ul class='mobile_fold hidden_on_print' id='mobile_nav'>
- <li class='hidden_m'><a href='?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
- <li class='hidden_on_desktop_force block_m smaller'> </li>
- <li class='hidden_on_desktop_force block_m bigger'>
- <a href='<?=$INDEXPHP?>?part=recent' onclick='ShowWaitingBar()'><?=$this->NotesView?$this->T('备忘录'):$this->T('最近')?></a>
- <?php if($this->LoggedIn){ ?> | <span class='gray invert_a'>
- <a href='<?=$INDEXPHP?>?set_notes_view=<?=$this->NotesView?'0':'1'?>'>N</a>
- <a href='<?=$INDEXPHP?>?comments=all'>@</a> <a href='<?=$INDEXPHP?>?statistics=all'>%</a>
- </span><?php } ?></li>
- <li class='hidden_on_desktop_force block_m bigger'>
- <a href='<?=$INDEXPHP?>?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
- <?php $this->SpecialNavigation;if(isset($this->SpecialNavigation) && ($p = &$this->GetPost($this->SpecialNavigation))!=NULL){
- echo $this->GenerateSinglePost($p, false, false, false, false);
- } ?>
- <?php if($this->LanguageAppendix=='zh'){ ?>
- <li class='smaller gray'>
- <a href='<?=$this->GetRedirect(null,'en.php').'&set_language=en'?>' onclick='ShowWaitingBar()'><b>汉语</b>/English</a></li>
- <?php }else { ?>
- <li class='smaller gray'>
- <a href='<?=$this->GetRedirect(null,'index.php').'&set_language=zh'?>' onclick='ShowWaitingBar()'>
- 汉语/<b>English</b></a>
- <br class='hidden_on_desktop' />
- <a id='translate_button' target='_blank'> [Google Translate] </a></li>
- <?php } ?>
- </ul></div>
- <?php
- }
- function MakeExpNavButtons(&$p){ global $INDEXPHP; ?>
- <a href='<?=$INDEXPHP?>' class='hidden_m'>
- <b><?=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle)?></b></a>
- <a class='hidden_on_desktop'
- href='javascript:toggle_mobile_show(document.getElementById("mobile_nav"))'><b class='round_btn'>
- <?=$this->InExperimentalMode?$this->T($this->ExpShortTitle):$this->T($this->HereShortTitle)?></b></a>
- <?php if(!$this->InExperimentalMode){ ?>
- <a <?=$this->HereNumber==1?"class='gray'":("href=".$this->HereLinkFromNumber($this->HereNumber-1))?>>←</a>
- <span><?=$this->HereNumber.'/'.sizeof($this->VisitedHere);?></span>
- <span class='round_btn'>
- <a href='<?=$this->HereNumber==sizeof($this->VisitedHere)?"?random_here=1":$this->HereLinkFromNumber($this->HereNumber+1);?>'>→</a>
- <a href='?random_here=1'><?=$this->T("随机")?></a></span><span class='hidden_m'></span>
- <?php } ?>
- <ul class='hidden_m' id='mobile_nav' style='text-align:center;'>
- <li class='smaller hidden_on_desktop'> </li>
- <li class='hidden_on_desktop block_m'><a href='<?=$INDEXPHP?>'><?=$this->T('主页')?></a></li>
- <?php if($this->InExperimentalMode && isset($this->ExpNavigation) && ($p = &$this->GetPost($this->ExpNavigation))!=NULL){
- echo $this->GenerateSinglePost($p, false, false, false, false);
- }else if($this->InHereMode && isset($this->HereNavigation) && ($p = &$this->GetPost($this->HereNavigation))!=NULL){
- echo $this->GenerateSinglePost($p, false, false, false, false);
- } ?>
- <?php if($this->AllowLanguageChoices){ ?>
- <li class='smaller hidden_on_desktop'> </li>
- <?php if($this->LanguageAppendix=='zh'){ ?>
- <li class='smaller invert_a gray'><a href='<?=$this->GetRedirect().'&set_language=en'?>'><b>汉语</b>/English</a></li>
- <?php }else { ?>
- <li class='smaller invert_a gray'><a href='<?=$this->GetRedirect().'&set_language=zh'?>'>汉语/<b>English</b></a></li>
- <li class='smaller invert_a gray'><a id='translate_button' target='_blank'> Google Translate </a></li>
- <?php } ?>
- <?php } ?>
- </ul>
- <?php
- }
- function MakePostingFieldsV2($reply_to=NULL, $show_hint=false){ $STR="";
- if(isset($this->WayBack)){
- $STR.="<span class='gray'><i>{$this->T('以过去日期浏览时不能发帖。')}</i></span>";
- $this->TFill(2,$STR); $this->TExtra("class='hidden_on_print no_line'"); $this->TRow(); return;
- }
- $STR.="<form action='{$_SERVER['REQUEST_URI']}' method='post' style='display:none;' id='post_form'></form>
- <div class='smaller'><div style='display:".($show_hint?"block":"none")."'>
- <span id='post_hint_text'>{$this->T('继续补充该话题:')}</span></div>
- <div id='post_hint_modify' style='display:none;'>
- <input type='checkbox' name='post_record_edit' value='1' form='post_form' checked> {$this->T('新增历史记录')}</div></div>
- <textarea id='post_content' name='post_content' rows='4' form='post_form'
- onfocus=\"if (value =='{$this->T('有什么想说的')}'){value ='';}la_auto_grow(this);\"
- onblur=\"if (value ==''){value='{$this->T('有什么想说的')}';la_auto_grow(this);}\"
- oninput=\"la_auto_grow(this);\" onload=\"la_auto_grow(this);\">{$this->T('有什么想说的')}</textarea>
- <input class='button' form=\"post_form\" type=\"submit\" name='post_button' value='{$this->T('发送')}'
- onclick='ShowWaitingBar();' />
- <input class='button' form=\"post_form\" type=\"submit\" name='post_button_note' value='{$this->T('备忘')}'
- onclick='ShowWaitingBar();' />
- | <a class='gray smaller pointer' onclick='ShowSideUploader();'>{$this->T('图片')}</a>
- <div style='float:right;'>
- <a class='gray smaller pointer' onclick=\"t=document.querySelector('#post_content');t.value='';la_auto_grow(t);\">
- {$this->T('清空')}</a>
- <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
- </div>
- <input style='display:none;' type=input form='post_form' id='post_edit_target' name='post_edit_target' />
- <script> la_auto_grow(document.getElementById('post_content'));</script>";
- if($reply_to){
- $STR.="<input style='display:none;' type=input form='post_form' id='post_reply_to' name='post_reply_to' value='{$reply_to}' />";
- }
- $this->TFill(2,$STR);$this->TExtra("class='hidden_on_print no_line'"); $this->TRow();
- }
- function MakeLinkedPostsV2(&$p){ $STR="";
- $has_ref = isset($p['refs'])&&isset($p['refs'][0]); if(!$has_ref)return; $count=0;
- $STR.="<input type='checkbox' class='lpctrl' id='fake{$p["id"]}' checked='checked'>";
- $count_product=0;
- $STR.="<div class='linked_posts smaller'>";
- $refs=sizeof($p["refs"]);
- $STR.="<label class='lb ref_count' for='fake{$p["id"]}'>× $refs".$this->T("个引用").":</label><hr />";
- foreach(array_reverse($p['refs']) as &$pr){
- $po = $this->GetPost($pr);
- if(!$this->CanShowPost($po)){ continue; } $count++;
- $this->TBackup();
- $this->MakeSinglePostV2($po, false, true, 0, true, true, false, false, true, false, false);
- $STR.=$this->TRestore(" compact");
- }
- $STR.="</div>";
- $this->TFill(0,$S0);
- $this->TFill(1,$STR,2);$this->TExtra("style='border-bottom:none;'"); $this->TRow();
- }
- function MakeSinglePostV2(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
- $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
- $generate_thumb = false, $is_top = false, $force_hide_long=false){
- $STR=""; $EXTRA="";$S0=""; $S1="";
- $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
- $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
- $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
- $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
- $number = isset($post['number'])?$post['number']:0;
- $title = $generate_anchor?$this->ChoosePartsByLanguage($this->GetPostTitle($post, true)):NULL;
- $this->ConvertPost($post);// NEEDED FOR WIDE;
- $is_wide = (isset($post['wide'])&&$post['wide']) || (isset($post['tid']) && isset($post['tid']['wide']) && $post['tid']['wide']);
- if($show_link && (!$side)){ $this->MakeLinkedPostsV2($post); }
- $EXTRA.="class='post $extra_class_string".($is_deleted?" deleted_post":"").($is_wide?" wide_post_print":"")."'";
- if(!$side) $EXTRA.=(" data-post-id='".$post['id']."'");
- if($is_deleted) $EXTRA.=" data-mark-delete='true'";
- if(!$side&&isset($post['mastodon_url'])) $EXTRA.=(" data-mastodon_url='".$post['mastodon_url']."'");
- //if($is_wide) $EXTRA.=" class=''";
- if(!$side && !$strip_tags && $show_link){ $STR.="<div class='post_menu_button _menu_hook' >+</div>"; }
- $this->TFill(2,$STR);
- $symbol=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:"#";
- $S1.="<a".($symbol!='#'?' class="marked"':'').
- " href='?post={$post['id']}' onclick=\"".(($show_thread_link||$side)?'ShowWaitingBar()':'ClickPost(this.parentNode.parentNode,event,true)')."\">".
- $symbol."<span class='mobile_fold'>".$number."</span>";
- if($ref_count && !$side){
- $S0.="<label class='lb' ".($show_link?"for='fake{$post["id"]}":"")."'><div class='ref_count'>+<span class='hidden_m'>{$ref_count}</span></div></label>";
- }
- if($is_product&&!$generate_anchor){ $STR.="<p class='smaller gray'>".$this->T('商品')."</p>";}
- $STR.=$this->GenerateSinglePost($post, $strip_tags, $generate_anchor, $show_link,
- $generate_thumb,($show_thread_link||$side||$force_hide_long));
- if($show_thread_link && (!$side) && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) && $post['tid']['first']['id']!=$post['id']){
- $STR.="<div class='gray block'>";
- $STR.="<div class='smaller'>{$this->T('回复给主题帖:')}</div>";
- $this->TBackup();
- $this->MakeSinglePostV2($post['tid']['first'], false, false, false, false, false, false,false, true, false, false);
- $STR.=$this->TRestore(" compact");
- $STR.="</div>";
- }
- if($show_reply_count && isset($post['tid'])){
- $STR.="<a class='smaller block invert_a' href='?post={$post['tid']['last']['id']}'>{$post['tid']['count']} {$this->T('个回复')}</a>";
- }
- $this->TFill(2,$STR); $this->TFill(1,$S1); $this->TFill(0,$S0); $this->TExtra($EXTRA); $this->TRow();
- }
- function MakePostSectionV2(&$post){ $STR=""; $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1;
- $this->Anchors = []; if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))) $centerclass='center_slides'; else $centerclass='center';
- if(isset($this->TagID)){ $STR.=<<<EOT
- <style>{$this->CssNumberID($this->TagID)}{display:block;}</style>
- EOT; } $th=NULL; $STR.="<br /><h2>";
- $is_wide = (isset($post['wide'])&&$post['wide']) || ($is_thread && isset($post['tid']['wide']) && $post['tid']['wide']);
- if($is_thread){ $th = $post['tid']; $STR.=$this->T('话题'); }else{ $STR.=$this->T('话题');$this->T('详细'); } $STR.="</h2>";
- $this->TFill(2,$STR); $this->TExtra("class='hidden_on_print no_line'"); $this->TRow();
- $cat = NULL;
- if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
- else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
- $this->MakePostTools();
- if($cat){ $STR=<<<EOT
- <p class='hidden_on_print'><b>{$this->T('分类')}</b> |
- EOT; foreach($cat as $c){ $STR.=("<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "); }
- $STR.="</p>";
- }
- $STR.="<br class='hidden_on_print' />"; $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();$is_reversed=false;
- if($is_thread){ $use_arr = $th['arr']; $hinted=false;
- $last_end_wide = true; $is_reversed=$this->IsReversedThread($th);
- foreach($use_arr as &$p){$use_class="";if($p==$post){$use_class.=" active_post";}
- if($last_end_wide){$use_class.=" last_wide";}
- $make_title = ($p == $post);
- 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(); }
- $this->MakeSinglePostV2($p,true,false,$use_class,false, false, false, true, false, false);
- if($make_title){ $STR='<script>
- document.title+=" | '.addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100))).'"</script>';
- $this->TFill(2,$STR); $this->TExtra("class='no_line'");
- }
- if($is_reversed && !$hinted){ $hinted = true;
- if($this->LoggedIn && (!$this->InHereMode)){
- $STR.="<div class='hidden_on_print'>";
- $STR.=$this->MakePostingFieldsV2($is_thread?$th['last']['id']:$post['id'], true);
- $STR.="</div><br />";
- }
- }
- $last_end_wide = isset($p['end_wide']) && $p['end_wide'];
- }
- }else{
- $this->MakeSinglePostV2($post,true, false,"active_post",false, false, false, true, false, false);
- $STR.='<script>
- document.title+=" | '.addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($post),0,100))).'"</script>';
- $this->TFill(2,$STR); $this->TRow();
- }
- $STR="";
- $class_add=""; if(isset($post['tid']['first']['no_time'])){ $class_add=' hidden_on_print'; }
- $STR.="<div class='smaller align_right$class_add'>
- <span class='gray'>".$this->ReadableTime($post['tid']['first']['id'])."</span>
- <br class='hidden_on_desktop' />".
- $this->ReadableTime(isset($post['tid']['last']['version'])?$post['tid']['last']['version']:$post['tid']['last']['id'])."
- </div>";
- $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow(); $STR="";
- if(!$is_reversed && ($this->LoggedIn && (!$this->InHereMode))){
- $STR.="<div class='hidden_on_print'><br />{$this->MakePostingFieldsV2($is_thread?$th['last']['id']:$post['id'], true)}</div>";
- $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
- }
- if($this->NewsletterEnabled){ $STR=$this->MakeSubscription(); $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow(); }
- //$this->MakeCommentSection($post);
- $STR="";
- if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))){
- $STR.=<<<EOL
- <div class='slides_buttons code' onclick="event.stopPropagation();">
- <a onclick="SlidesFontCheck(-1)">T-</a> <a onclick="SlidesFontCheck(1)">T+</a>
- <a onclick="SlidesStart(null)"><<</a> <a onclick="SlidesCheck(-1);"><</a>
- <a onclick="SlidesStart(1)"><span id="slides_now">1</span>/<span id="slides_total">1</span></a>
- <a onclick="SlidesCheck(1);">></a> <a onclick="SlidesEnd();">X</a>
- </div>
- <script>
- function SlidesStart(from_here){
- slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
- sdone=0; fp=0; if(from_here){
- urlParams = new URLSearchParams(window.location.search);
- fp = urlParams.get('post');
- }
- document.querySelector("#slides_total").innerText=slides.length; cur=document.querySelector("#slides_now");
- for(i=0;i<slides.length;i++){ slides[i].style.display="none";
- 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; }
- } if(!sdone){ slides[0].style.display="table-cell"; ClickPost(slides[0],0,true); cur.innerText=1; }
- c=document.querySelector('.center'); if(!c) return;
- c.classList.remove('center'); c.classList.add('center_slides'); if(c.dataset.fontSize){ c.style.fontSize=c.dataset.fontSize; }
- c=document.querySelector('.left'); if(!c) return; c.style.display="none";
- }
- function SlidesCheck(offset){
- slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return; cur=document.querySelector("#slides_now");
- for(i=0;i<slides.length;i++){ if(slides[i].style.display=="table-cell" && slides[i+offset] && (i+offset)>=0){
- slides[i+offset].style.display="table-cell"; slides[i].style.display="none"; ClickPost(slides[i+offset],0,true); cur.innerText=i+offset+1; break;
- }
- }
- }
- function SlidesFontCheck(offset){
- c=document.querySelector('.center_slides'); if(!c) return;
- f=5; if(c.style.fontSize){ f=parseInt(c.style.fontSize); }
- f+=offset; if(f<=0) f=1; if(f>12) f=12; c.style.fontSize=""+f+"vmin"; c.dataset.fontSize=c.style.fontSize;
- }
- function SlidesEnd(){
- c=document.querySelector('.center_slides'); if(!c) return;
- c.classList.remove('center_slides'); c.classList.add('center'); c.style.fontSize="";
- c=document.querySelector('.left'); if(!c) return; c.style.display="inline-block";
- slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
- for(i=0;i<slides.length;i++){ slides[i].style.display=""; }
- }
- //document.addEventListener("wheel", function(event){ if(event.deltaY>0) SlidesCheck(1); else SlidesCheck(-1); }, { passive: false });
- document.addEventListener("click", function(event){ SlidesCheck(1); });
- document.addEventListener('keydown', function(event) {
- const key = event.key; // "ArrowRight", "ArrowLeft", "ArrowUp", or "ArrowDown"
- switch(key){
- case "ArrowUp": case "ArrowLeft": SlidesCheck(-1); break; case "ArrowDown": case "ArrowRight": SlidesCheck(1); break;
- case "Escape": SlidesEnd(); break;
- }
- });
- </script>
- EOL; $this->TAfter($STR);
- }
- }
- function MakeSubscription($smaller=false){
- $STR="";$STR.="<div class='hidden_on_print".($smaller?" smaller'":"")."'>
- <form action='mailsub.php?subscribe=1' method='post' id='subscribe_form' style='display:none;'></form>
- <br />
- <h".($smaller?"3":"2").">{$this->T("订阅我的新闻")}</h".($smaller?"3":"2").">
- <span class='gray'>{$this->T("输入您的邮件:")}</span>
- <input type='text' id='email_subscribe_name' name='email_subscribe_name' form='subscribe_form' ".
- ($smaller?"style='border-color:#f8ca9b88;background:rgba(0,0,0,0.2);max-width:16em;'":"").">
- <input class='button' form='subscribe_form' type='submit' value={$this->T("订阅")}>
- <br /></div>";
- return $STR;
- }
- function MakeRecentPostsV2($search_term=NULL, $category=NULL){ global $INDEXPHP;
- $STR=""; $tmppinned=$this->SpecialPinned;
- if($this->LoggedIn && $this->NotesView){ $this->SpecialPinned=$this->SpecialPinnedNotes; }
- if(!isset($search_term) && !isset($category) &&
- (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
- $this->CanShowPost($p,true)){
- $this->MakeSinglePostV2($p, true, false, "active_post", false, true, false, false, false, true, false);
- }
- $this->SpecialPinned=$tmppinned;
- if($this->NewsletterEnabled && !isset($category) && !isset($search_term) && !$this->NotesView){
- $STR=$this->MakeSubscription(); $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow(); $STR='';
- }
- $STR.="<br /><h2>".(isset($search_term)?$this->T('搜索'):
- (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
- ($category=='none'?$this->T('未分类'):$this->T($category))):($this->NotesView?$this->T('备忘录'):$this->T('最近')).
- "<span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
- ($this->LoggedIn?" <a href='".$INDEXPHP."?set_notes_view=".($this->NotesView?'0':'1')."'>N</a> ".
- "<a href='".$INDEXPHP."?comments=all'>@</a> <a href='".$INDEXPHP."?statistics=all'>%</a>":"")."</span>")).
- "</h2><br />";
- $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
- if(isset($search_term)){
- $STR.="<form action='".$INDEXPHP."' method='post' style='display:none;' id='search_form'></form>".
- "<input id='search_content' name='search_content' rows='4' form='search_form' type='text' value='$search_term'>".
- "<input class='button' form='search_form' type='submit' name='search_button' value='{$this->T('搜索')}'>";
- $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
- }else if(isset($category)){
- $STR.="<div></div>";
- $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
- }else if($this->LoggedIn){
- $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
- $this->MakePostingFieldsV2(NULL,false);
- }
- $this->PostsPerPage=20;
- $i = 0; $last_end_wide = true;
- if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
- if(!$this->CanShowPost($p,true) || $this->SkipProduct($p)) continue;
- if(isset($p['tid'])){ /* Should always be set. */
- $th = &$p['tid']; if($p['tid']['count']==0) continue;
- if(!isset($search_term)) { $p = &$th['last']; }
- }
- if(isset($search_term)){
- if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
- }else if(isset($category)){
- $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
- (isset($p['categories'])?($p['categories']):[]);
- if ($category=='none') { if($cat!=[]) continue; }
- else{ if ($category=='' || !in_array($category, $cat)) continue; }
- if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
- }else{
- if(in_array($p['id'],
- [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
- if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
- }
- if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
- if($last_end_wide){$use_class="last_wide";}else{$use_class="";}
- $this->MakeSinglePostV2($p, true, false, $use_class, false, !isset($search_term), false, false, false, false, isset($search_term));
- $i++;
- if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
- $last_end_wide = sizeof($p['tid']['arr'])==1 && isset($p['end_wide']) && $p['end_wide'];
- }
- $STR=""; $EXTRA="class='clean_a'"; $STR.="<br /><br />".
- "<a ".($this->CurrentOffset>0?("href='".$INDEXPHP."?offset=".($this->CurrentOffset-1).
- (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):"").
- ($this->CurrentOffset==0?" class='gray'":"").">{$this->T('上一页')} ← </a>";
- $STR.=" [ ".($this->CurrentOffset+1)." ] ";
- $STR.="<a href='".$INDEXPHP."?offset=".($this->CurrentOffset+1).
- (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'>".
- " → {$this->T('下一页')}</a>";
- $this->TFill(0,$STR,3); $this->TExtra($EXTRA); $this->TExtra("class='no_line'"); $this->TRow();
- }
- function GeneratePage($is_section=false,$extra_classes=""){ $S="";
- $S.="<table class='center print_column".($is_section?" clickable_section":"").($extra_classes)."'><tbody>";
- foreach($this->PAGE as $r){ $S.="<tr ".(isset($r['extra'])?$r['extra']:"").">"; $spantotal=0; $sp="";
- if(isset($r['span0'])){$sp=" colspan='".$r['span0']."'"; $spantotal+=$r['span0']; }else{ $spantotal++; };
- if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[0])){ $S.=$r[0]; } $S.="</td>"; }
- if(isset($r['span1'])){$sp=" colspan='".$r['span1']."'"; $spantotal+=$r['span1']; }else{ $spantotal++; };
- if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[1])){ $S.=$r[1]; } $S.="</td>"; }
- if(isset($r['span2'])){$sp=" colspan='".$r['span2']."'"; $spantotal+=$r['span2']; }else{ $spantotal++; };
- if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[2])){ $S.=$r[2]; } $S.="</td>"; }
- $S.="</tr>";
- }
- $S.="</tbody></table>";
- return $S;
- }
-
- function GenerateLinkedPosts($ht){
- $ht = preg_replace_callback('/<p>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>(.*)<\/a>[\s]*<\/p>/u',
- function($m){
- if(preg_match('/^\s*<img/u',$m[2])){ return $m[0]; }
- $rp = &$this->GetPost($m[1], false, true);
- $STR=$this->T("未找到该引用。");
- if($rp!==NULL && $this->CanShowPost($rp)){
- $this->TBackup();
- $this->MakeSinglePostV2($rp, false, false, false, false, false, false,false, true, false, false);
- $STR=$this->TRestore(" compact");
- }
-
- $s="<a class='smaller block' href='?post=".$m[1]."'>".$m[2]."</a><div class='block post gray'>".$STR."</div>";
- return $s;
- },
- $ht
- );
- $ht = preg_replace_callback('/<li>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>PRODUCT\s+(.*)<\/a>[\s]*<\/li>/u',
- function($m){
- $rp = &$this->GetPost($m[1], false, true);
- $s="<div class='product_ref block post ref_compact'><a href='?post=".$m[1]."' class='clean_a' onclick='ShowWaitingBar()'>".
- (($rp!==NULL && $this->CanShowPost($rp))?
- $this->GenerateSinglePost($rp,true,false,false,true,true):$this->T("未找到该引用。")).
- "</a></div>";
- return $s;
- },
- $ht
- );
- return $ht;
- }
- function GenerateSinglePost(&$post, $strip_tags, $generate_anchor=false, $generate_refs=false,
- $generate_thumbs=false, $hide_long = false){
- $this->ConvertPost($post);
- if($generate_anchor){ $this->CreatePostAnchor($post); }
- $ht = $post['html'];
- if(isset($post['mark_value']) && $post['mark_value']==5 && ($generate_thumbs || !$generate_anchor)){
- $ht="<div class='product_thumb'>".$post['images'][0]."</div>".
- "<p class='bold'>".$post['product']['title']."</p>".
- (isset($post['product']['short'])?("<p class='smaller gray'>".$post['product']['short']."</p>"):"").
- "<p class='smaller bold'>".$post['product']['price']."</p>";
- return $ht;
- }
- if($hide_long){
- $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>[\s\S]*/u',"<p class='smaller bold'>[".$this->T("阅读更多")."]</p>", $ht);
- }else{
- $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>/u',"", $ht);
- }
- if ($strip_tags){
- $ht = strip_tags($ht,'<b><i><h1><h2><h3><h4><p><blockquote><span>');
- $ht = preg_replace('/<p>\s*<\/p>/u',"", $ht);
- $ht = $ht;
- }
- else{
- if($generate_refs) $ht = $this->GenerateLinkedPosts($ht);
- }
- if ($strip_tags && $generate_thumbs){
- $ht="<div class='hide_long'>".$ht."</div>";
- if(isset($post['images']) && isset($post['images'][0])){
- $ht.="<div class='post_ref_images'><ul class='side_thumb ref_thumb'>";
- foreach($post['images'] as $im){
- $ht.="<li class='file_thumb'>".$im."</li>";
- }
- $ht.="</ul></div>";
- }
- }
- return $ht;
- }
-
- function MakeSinglePostExp(&$post){ ?>
- <li class='post post_dummy'>
- <?=$this->GenerateSinglePost($post, false, false, true, false, false); ?>
- </li>
- <?php
- }
- function MakeSinglePost(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
- $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
- $generate_thumb = false, $is_top = false, $force_hide_long=false){
- $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
- $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
- $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
- $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
- $title = $generate_anchor?$this->ChoosePartsByLanguage($this->GetPostTitle($post, true)):NULL;
- $this->ConvertPost($post);// NEEDED FOR WIDE;
- $is_wide = (isset($post['wide'])&&$post['wide']) || (isset($post['tid']) && isset($post['tid']['wide']) && $post['tid']['wide']);
- ?>
- <?=$title?"<div class='print_title'><h1>".$title."</h1></div>":""?>
- <div class='post<?=isset($extra_class_string)?' '.$extra_class_string:''?>'
- <?=(!$side)?"data-post-id='".$post['id']."'":""?> <?=$is_deleted?"data-mark-delete='true'":""?>
- <?=(!$side&&isset($post['mastodon_url']))?"data-mastodon_url='".$post['mastodon_url']."'":""?>
- <?=$is_wide?" style='column-span:all;'":"";?>>
- <?php if($mark_value>=0 && !$show_link && $mark_value!='P'){?>
- <div class='smaller <?=$is_deleted?"gray":""?>'><?=$mark_value?> <?=$this->T('标记')?></div>
- <?php }
- if(!$side && !$strip_tags && $show_link){?><div class='post_menu_button _menu_hook' >+</div><?php } ?>
- <?php if(!$side && $show_link){ $ref_count=100; ?>
- <a href='?post=<?=$post['id']?>' onclick="<?=$show_thread_link||isset($_GET['search'])?'ShowWaitingBar()':'ClickPost(this.parentNode,event,true)'?>">
- <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
- <?=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:($ref_count?"":"")?>
- </div>
- </a><?php if($ref_count){ ?>
- <label class='lb post_access' for='fake<?=$post["id"]?>'><div class='ref_count'><?=$ref_count?></div></label><?php }
- } ?>
- <?=$side?"<a href='?post={$post['id']}' onclick='ShowWaitingBar()'>":""?>
- <?php if(!$strip_tags){ $this->MakeLinkedPosts($post); } ?>
- <div class='<?=$side?"":'post_width'?><?=$is_deleted?" deleted_post":""?>'>
- <?php if($is_product&&!$generate_anchor){
- echo "<p class='smaller gray'>".$this->T('商品')."</p>";
- echo "<div class='product_ref clean_a'><a href='?post={$post['id']}'>";} ?>
- <?=$this->GenerateSinglePost($post, $strip_tags, $generate_anchor, true,
- $generate_thumb,($show_thread_link||$side||$force_hide_long)); ?>
- <?php if($is_product&&!$generate_anchor){echo "</a></div>";} ?>
- </div>
- <?=$side?"</a>":""?> <?php
- if($show_thread_link && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) &&
- $post['tid']['first']['id']!=$post['id']){ ?>
- <div class='gray smaller block opt_compact post'>
- <a href='?post=<?=$post['tid']['first']['id']?>' onclick='ShowWaitingBar()'>#423
- <div class='post_access invert_a hover_dark smaller'><?=isset($post['tid']['first']['mark_value'])?
- $this->Markers[$post['tid']['first']['mark_value']]:"→"?></div></a>
- <div class='post_width'><div class='smaller'><?=$this->T('回复给主题帖:')?></div>
- <?=$this->GenerateSinglePost($post['tid']['first'], false, false, false, true, true);?>
- </div>
- </div>
- <?php }
- if($show_reply_count && isset($post['tid'])){ ?>
- <a class='smaller block invert_a' href='?post=<?=$post['tid']['last']['id']?>'><?=$post['tid']['count']?>
- <?=$this->T('个回复')?></a>
- <?php } ?>
- </div>
- <?php
- }
-
- function MakePostingFields($reply_to=NULL, $show_hint=false){
- if(isset($this->WayBack)){ ?>
- <span class='gray'><i><?=$this->T('以过去日期浏览时不能发帖。')?></i></span>
- <?php return; } ?>
- <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='post_form'></form>
- <div class='smaller'><div style='display:<?=$show_hint?"block":"none"?>;'>
- <span id='post_hint_text'><?=$this->T('继续补充该话题:')?></span></div>
- <div id='post_hint_modify' style='display:none;'>
- <input type="checkbox" name="post_record_edit" value="1" form='post_form' checked> <?=$this->T('新增历史记录');?></div></div>
- <textarea id="post_content" name="post_content" rows="4" form='post_form'
- onfocus="if (value =='<?=$this->T('有什么想说的')?>'){value ='';}la_auto_grow(this);"
- onblur="if (value ==''){value='<?=$this->T('有什么想说的')?>';la_auto_grow(this);}"
- oninput="la_auto_grow(this);" onload="la_auto_grow(this);"><?=$this->T('有什么想说的')?></textarea>
- <input class='button' form="post_form" type="submit" name='post_button' value=<?=$this->T('发送')?>
- onclick='ShowWaitingBar();' />
- | <a class='gray smaller pointer' onclick='ShowSideUploader();'><?=$this->T('图片')?></a>
- <div style='float:right;'>
- <a class='gray smaller pointer' onclick='t=document.querySelector("#post_content");t.value="";la_auto_grow(t);'>
- <?=$this->T('清空')?></a>
- <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
- </div>
- <input style='display:none;' type=input form="post_form" id='post_edit_target' name='post_edit_target' />
- <script> la_auto_grow(document.getElementById("post_content"));</script>
- <?php if($reply_to){ ?>
- <input style='display:none;' type=input form="post_form" id='post_reply_to' name='post_reply_to' value='<?=$reply_to?>' />
- <?php } ?>
- <?php
- }
-
- function MakeCommentPosts(){ global $INDEXPHP;
- if(!$this->LoggedIn) return; ?>
- <h2><?=$this->T('评论')?></h2><div class='spacer'></div>
- <?php if(!$this->CommentEnabled){
- echo "<p><span class='text_highlight'> ".$this->T("已关闭评论")." </span></p><br />"; } ?>
- <div class='comment'><ul>
- <?php $i=0;
- foreach(array_reverse($this->Posts) as $p){
- if(!isset($p['comment_to'])) continue;
- if($i < $this->CommentsPerPage * $this->CurrentOffset) {$i++; continue;}
-
- $ht = $this->GenerateSinglePost($p, false, false, false, false, false);
- $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
- $post_to = $this->GetPost($p['comment_to']); $post_title = $this->GetPostTitle($post_to);
- if(!$post_to) $post_title = "?";
- $mail = "<span class='gray hidden_on_print'> ".
- "<a href='mailto:".$p['email']."'>@</a> ".
- (isset($p['ip'])?$p['ip']:"?")." <br class='hidden_on_desktop'/>".
- "<a href='$INDEXPHP?post=".$p['comment_to']."'>(".$post_title.")</a></span>";
- echo "<li><p><b>".$name.":</b>".$mail."<br /></p>".$ht."</li>";
-
- $i++;
- }
- ?>
- </ul><br /></div>
- <?php
- }
-
- function MakeRecentPosts($search_term=NULL, $category=NULL){ global $INDEXPHP; ?>
- <div class='center' id='div_center'><br class='hidden_on_print' />
- <?php if(!isset($search_term) && !isset($category) &&
- (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
- $this->CanShowPost($p)){
- ?><ul class='print_column list bkg_section'><?php
- $this->MakeSinglePost($p, true, false, "active_post", false, true, false, false, false, true, false);
- ?></ul><br /><?php
- }?>
- <h2><?=isset($search_term)?$this->T('搜索'):
- (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
- ($category=='none'?$this->T('未分类'):$this->T($category))):($this->NotesView?$this->T('备忘录'):$this->T('最近')).
- " <span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
- ($this->LoggedIn?"<a href='$INDEXPHP?comments=all'>@</a> <a href='$INDEXPHP?statistics=all'>%</a>":"")."</span>")?></h2><br />
- <?php if(isset($search_term)){ ?>
- <form action="<?=$INDEXPHP?>" method="post" style='display:none;' id='search_form'></form>
- <input id="search_content" name="search_content" rows="4" form='search_form' type='text' value='<?=$search_term?>'>
- <input class='button' form="search_form" type="submit" name='search_button' value=<?=$this->T('搜索')?>
- <?php }else if(isset($category)){ ?>
- <div></div>
- <?php }else if($this->LoggedIn){ ?>
- <div class='post_box_top _input_bundle'>
- <?php $this->MakePostingFields(NULL,false); ?>
- </div>
- <?php } ?>
- <ul class='print_column list bkg_recent'>
- <?php
- $i = 0; $last_end_wide = true;
- if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
- if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
- if(isset($p['tid'])){ /* Should always be set. */
- $th = &$p['tid']; if($p['tid']['count']==0) continue;
- if(!isset($search_term)) { $p = &$th['last']; }
- }
- if(isset($search_term)){
- if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
- }else if(isset($category)){
- $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
- (isset($p['categories'])?($p['categories']):[]);
- if ($category=='none') { if($cat!=[]) continue; }
- else{ if ($category=='' || !in_array($category, $cat)) continue; }
- if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
- }else{
- if(in_array($p['id'],
- [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
- if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
- }
- if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
- if($last_end_wide){$use_class="last_wide";}else{$use_class="";}
- $this->MakeSinglePost($p, true, false, $use_class, false, !isset($search_term), false, false, false, false, isset($search_term));
- $i++;
- if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
- $last_end_wide = sizeof($p['tid']['arr'])==1 && isset($p['end_wide']) && $p['end_wide'];
- }?>
- </ul>
- <div class='page_selector clean_a'>
- <hr />
- <a <?=$this->CurrentOffset>0?("href='".$INDEXPHP."?offset=".($this->CurrentOffset-1).
- (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):""?>
- <?=$this->CurrentOffset==0?"class='gray'":""?>><?=$this->T('上一页')?> ←</a>
- <?=$this->CurrentOffset+1?>
- <a href='<?=$INDEXPHP?>?offset=<?=($this->CurrentOffset+1).
- (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))?>'>
- → <?=$this->T('下一页')?></a>
- </div>
- </div>
- <?php
- }
- function MakeLinkedPosts(&$p){
- $has_ref = isset($p['refs'])&&isset($p['refs'][0]); if(!$has_ref)return; $count=0;?>
- <input type='checkbox' class='lpctrl' id='fake<?=$p["id"]?>' checked='checked'>
- <div class='linked_posts smaller'>
- <ul><?php $count_product=0;
- foreach(array_reverse($p['refs']) as &$pr){
- $po = $this->GetPost($pr);
- if(!$this->CanShowPost($po)){ continue; } $count++;
- $this->MakeSinglePost($po, false, true, "post_preview invert_a", true, false, false, false, true, false, false);
- }
- ?></ul>
- </div>
- <?php
- }
- function MakeLinkedPostsExp(&$p){
- $has_ref = isset($p['refs'])&&isset($p['refs'][0]); ?>
- <div class='center_exp post_dummy smaller'>
- <hr />
- <?php if(!$this->InExperimentalMode){ ?>
- <h3<?=$has_ref?"":" class='gray'"?>><?=$this->T('链接')?></h3>
- <?php if($has_ref){ ?>
- <div class='smaller'><?=sizeof($p['refs'])?> <?=$this->T('个引用:')?></div>
- <ul><?php $count_product=0;
- foreach(array_reverse($p['refs']) as &$pr){
- echo "<li class='post_dummy'><a href='?post=".$pr."'>".$this->T($this->GetPostTitle($this->GetPost($pr),false)).
- "</a></li>";
- }
- ?></ul>
- <?php if($count_product){ ?> <span class='smaller'><?=$this->T('和').' '.$count_product.' '.$this->T('个商品')?></span> <?php }
- }else{ ?>
- <div class='gray smaller'><?=$this->T('没有帖子链接到这里。')?></div>
- <?php } }?>
- <div style='margin-bottom:4rem;'> </div>
- </div>
- <?php
- }
-
- function MakePostHistoryList(&$ah, &$post,$version=NULL, $show_latest=true){
- $latest_ver=isset($post['version'])?$post['version']:$post['id'];
- $can_show=1; if(isset($this->WayBack) && $latest_ver>$this->WayBack) $can_show=0;
- $title = NULL; if(!isset($ah) || ($show_latest && $can_show)) { $title=$this->T($this->GetPostTitle($post, false)); }
- else{ $ver = &$ah['list'][sizeof($ah['list'])-1]; $title= $this->GetPostTitle($ver); }
- if(!isset($title)) $title=$this->T('未命名');
- if(!isset($ah)){ ?>
- <h2><?=$this->T('没有历史记录')?></h2>
- <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$post['id']?>'><?=$title?></a></span><br />
- <?php }else{ ?>
- <h2><?=$this->T('历史记录')?></h2>
- <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$ah['id']?>'><?=$title?></a></span><br />
- <div class='list'><ul>
- <?php if($show_latest && $can_show){ $post['history_displayed']=1; ?>
- <li class='<?=isset($version)&&$version==$latest_ver?" post_current_row bold":""?>' style='list-style:"";'>
- <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$latest_ver?>'><?=$this->ReadableTime($latest_ver)?></a>
- <span class='smaller gray'><?=$this->T('长度').' '.strlen($post['content'])?></span>
- <?php if(isset($post['merged_from'][0])){ ?><ul><?php foreach($post['merged_from'] as $from){
- $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
- $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
- <li><a href='?post=<?=$ver['id']?>&history=1'>
- <?=$this->GetPostTitle($ver);?></a>
- <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
- <?php } ?></ul><?php } ?>
- <?php if(isset($post['merged_thread'][0][0])){ $pm=$post['merged_thread'][0][0];
- $mah = &$this->GetArchiveHandle($pm);
- $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
- <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
- <span class='smaller gray'><?=sizeof($post['merged_thread'][0]);?> <?=$this->T('个帖子')?></span></li></ul>
- <?php } ?>
- </li><?php } ?>
- <?php if(isset($ah['list'][0])) foreach(array_reverse($ah['list']) as &$ver){
- if(isset($this->WayBack) && $ver['version']>$this->WayBack) continue;
- if(isset($ver['history_displayed']) && $ver['history_displayed']) continue; ?>
- <li<?=isset($version)&&$version==$ver['version']?" class='post_current_row bold'":""?>>
- <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$ver['version']?>'><?=$this->ReadableTime($ver['version'])?></a>
- <span class='smaller gray'> <?=$this->T('长度').' '.strlen($ver['content'])?></span>
- <?php if(isset($ver['merged_thread'][0][0])){ $pm=$ver['merged_thread'][0][0];
- $mah = &$this->GetArchiveHandle($pm); $mver = &$this->GetPost($pm);
- if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
- <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
- <span class='smaller gray'> <?=sizeof($ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></li></ul>
- <?php } if(isset($ver['merged_from'][0])){ ?><ul><?php foreach($ver['merged_from'] as $from){
- $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
- $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
- <li><a href='?post=<?=$ver['id']?>&history=1'>
- <?=$this->GetPostTitle($ver);?></a>
- <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
- <?php } ?></ul></li><?php } ?>
- <?php } ?></ul></div>
- <?php } ?>
- <?php
- }
-
- function MakePostDiff(&$this_ver, &$last_ver){
- if(!isset($this_ver)){ ?>
- <h2 class='gray'><?=$this->T('版本不存在')?></h2>
- <?php }else{ ?>
- <h2><?=$this->T('差异')?></h2>
- <?php if(isset($this_ver['merged_thread']) && isset($this_ver['merged_thread'][0][0])){
- $pm=$this_ver['merged_thread'][0][0]; $mah = &$this->GetArchiveHandle($pm);
- $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
- <p><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver)?></a> <?=$this->T('并入这里')?>
- <br /><span class='smaller gray'> <?=sizeof($this_ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></p>
- <?php }else{ ?>
- <table class='diff_table'><thead>
- <tr><td><?php if(!isset($last_ver)){ ?><?=$this->T('没有更旧的版本')?><?php }else{ ?>
- <?=$this->T('上一个版本')?><br /><?=$this->ReadableTime($last_ver['version'])?><?php } ?></td>
- <td class='text_highlight bold'><?=$this->T('选择的版本')?><br /><?=$this->ReadableTime($this_ver['version'])?></td></tr>
- </thead><tbody>
- <tr><td><pre><?=isset($last_ver)?$last_ver['content']:""?></pre></td><td><pre><?=$this_ver['content']?></pre></td></tr>
- </tbody>
- </table>
- <?php } ?>
- <br /><a class='smaller' href='?post=<?=$this_ver['id']?>&set_wayback=<?=isset($this_ver['version'])?$this_ver['version']:$this_ver['id']?>'><?=$this->T('前往该版本时间')?> ←</a>
- <?php } ?>
- <?php
- }
- function MakePostHistory(&$post, $version=NULL){
- $ah = &$this->GetArchiveHandle($this->CurrentPostID);
- $p = &$post; if(!isset($post)){ $p=&$ah['list'][0]; }
- $show_latest = isset($ah)?(!isset($ah['list'][sizeof($ah['list'])-1]['merged_into'])):true;
- ?>
- <div class='left mobile_fold history' id='div_left'>
- <?php if (isset($version)){
- $this->MakePostHistoryList($ah, $p, $version, $show_latest);
- }else{ echo " "; } ?>
- </div>
- <div class='center history' id='div_center'>
- <?php if (!isset($version)){
- $this->MakePostHistoryList($ah, $p, NULL, $show_latest);
- }else{
- $this_ver = NULL; $next_ver = NULL; $last_ver=NULL;
- $this_ver = &$this->GetArchiveVersion($ah, $version, $next_ver, $last_ver);
- if(!isset($this_ver)){$this_ver = $p; $last_ver=$ah['list'][sizeof($ah['list'])-1];}
- $this->MakePostDiff($this_ver, $last_ver, $p);
- } ?>
- </div>
- <?php
- }
-
- function MakeCommentSection(&$post){ global $INDEXPHP;
- if(!$this->CommentEnabled){ return; }
- $to_post = isset($post['tid'])?$post['tid']['first']:$post;
- $comment_count = (isset($to_post['comments']) && isset($to_post['comments'][0]))?count($to_post['comments']):0;
- ?><div class='comment'>
- <br /><h2><?=$this->T('评论')?> (<?=$comment_count;?>)</h2><div class='spacer'></div>
- <?php if($comment_count) { echo "<ul>";
- foreach($to_post['comments'] as $p){
- $ht = $this->GenerateSinglePost($p, false, false, false, false, false);
- $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
- $mail = $this->LoggedIn?("<span class='gray clean_a hidden_on_print'> ".
- "<a href='mailto:".$p['email']."'>@</a> </span>"):"";
- echo "<li><p><b>".$name.":</b>".$mail."</p>".$ht."</li>";
- }
- echo "</ul>";
- } else {
- echo $this->T('还没有评论');
- } ?>
- <div class='hidden_on_print'>
- <div class='spacer'></div>
- <form action="<?=$INDEXPHP?>?post=<?=$this->CurrentPostID?>&comment_to=<?=$to_post['id']?>"
- method="post" style="display:none;" id="comment_form"></form>
- <p><a class='text_highlight bold clean_a'
- onclick='document.getElementById("comment_box").style.display="block";this.parentNode.style.display="none"'>
- <?=$this->T('写评论');?> </a></p>
- <div id='comment_box' style='display:none;'>
- <p class='gray' style='margin-bottom:0.5em;'><?=$this->T('您的邮箱不会公开展示。');?></p>
- <table style='white-space:nowrap;'>
- <tr><td colspan='2'>
- <textarea id="comment_box" name="comment_box" rows="4" class='full_box' form='comment_form'
- oninput="CommentUpdated();" ></textarea>
- </td></tr>
- <tr><td><?=$this->T('电子邮件')?>*</td><td><?=$this->T('称呼')?>*</td></tr>
- <tr><td><input type="text" form="comment_form" id='comment_email' name='comment_email'
- class='full_box' oninput="CommentUpdated();" /></td>
- <td><input type="text" form="comment_form" id='comment_name' name='comment_name'
- class='full_box' oninput="CommentUpdated();" /></td></tr>
- <tr><td colspan='2'><?=$this->T('个人网站')?></td></tr>
- <tr><td colspan='2'>
- <input type="text" form="comment_form" id='comment_link' name='comment_link'
- class='full_box' oninput="CommentUpdated();" />
- </td></tr>
- <tr><td colspan='2'>
- <div class='spacer'></div>
- <input class='button text_highlight bigger' type='submit' form='comment_form'
- name='comment_confirm' id='comment_confirm' value=' <?=$this->T('发送')?> '>
- </td></tr>
- </table></div>
- <script>
- const IsValidEmail = (email) => {
- 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,}))$/);
- };
- function IsValidHttpUrl(string) {
- let url; try{ url = new URL(string); } catch (_) { return false; }
- return url.protocol === "http:" || url.protocol === "https:";
- }
- var cbox = document.getElementById('comment_box');
- var cemail = document.getElementById('comment_email');
- var cname = document.getElementById('comment_name');
- var clink = document.getElementById('comment_link');
- var cconfirm = document.getElementById('comment_confirm');
- function CommentUpdated(){
- cconfirm.disabled=true;
- if (cemail.value!="" && IsValidEmail(cemail.value) &&
- cbox.innerText.length>2 && cname.value.length>2 &&
- clink.value=="" || IsValidHttpUrl(clink.value)){
- cconfirm.removeAttribute("disabled");
- }
- }
- CommentUpdated();
- </script>
- </div>
- </div>
- <?php
- }
-
- function MakeInterestingSection(&$th){
- $this->Anchors = [];
- $c = &$th['first']['content'];
- $this->ConvertPost($th['first']);
- $ht = $th['first']['html'];
- ?>
- <script>function ClickImage(post_access){im=post_access.querySelector('img');if(im){im.click();}}</script>
- <div class='center_full' id='div_center'>
- <?php $this->MakePostTools(); ?>
- <?php $cat = NULL;
- if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; }
- if($cat){ ?>
- <p><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
- echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
- <?php } ?>
- <h2 class='hidden_on_print'><?=$this->T('有趣')?>
- <a class='gray clean_a' href='?post=<?=$th['first']['id']?>'>→</a></h2>
- <ul><li class='post' data-post-id='<?=$th['first']['id']?>'>
- <div class='post_menu_button _menu_hook' onclick='ShowPostMenu(this.parentNode);'>+</div><?=$ht?>
- <?php if(isset($th['first']['refs'][0])){ ?><p class='smaller'><?=$this->T('引用')?>: </p><ul class='smaller'>
- <?php foreach($th['first']['refs'] as $ref){
- $po = $this->GetPost($ref);
- if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
- if(!$this->CanShowPost($po)){ continue; }
- echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
- } ?>
- </ul><?php } ?>
- <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
- <div class='hidden_on_print'><br />
- <?php $this->MakePostingFields($th['last']['id'], true);?><br />
- </div>
- <?php } ?>
- <table><thead><tr><?php foreach($th['interesting'] as $header){ ?>
- <td><?=$this->T($header);?></td>
- <?php } ?><td></td></tr></thead><tbody class='interesting_tbody'>
- <?php $plist = array_reverse(array_slice($th['arr'],1));
- foreach($plist as &$p){
- $this->ConvertPost($p);
- $mark_value = isset($p['mark_value'])?$this->Markers[$p['mark_value']]:-1;
- $ref_count = isset($p['refs'])?sizeof($p['refs']):0;
- $is_current = $p['id']==$this->CurrentPostID;
- $is_deleted = (isset($p['mark_delete'])&&$p['mark_delete']); ?>
- <tr class='<?=$is_current?"post_current_row":""?><?=$is_deleted?" deleted_post":""?>'
- data-post-id='<?=$p['id']?>' <?=$is_deleted?"data-mark-delete='true'":""?>
- onDblClick='ClickImage(this)'><td>
- <?php if($ref_count){ ?>
- <div class='post_access ref_count'><?=$ref_count?></div>
- <?php } ?></a>
- <?=$p['html'];?>
- <a class='_menu_hook clean_a post_menu_button' onclick='ShowPostMenu(this.parentNode.parentNode);'>+</a>
- <a <?=$is_current?"":("href='?post=".$p['id']."' onclick='ShowWaitingBar()'");?> class='clean_a paa'>
- <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
- <?=isset($p['mark_value'])?$this->Markers[$p['mark_value']]:($ref_count?"":"→")?>
- </div></td></tr>
- <?php if($is_current && $ref_count>0){ ?><tr class='post_current_row'><td><p> </p><ul class='smaller'>
- <?php foreach($p['refs'] as $ref){
- $po = $this->GetPost($ref);
- if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
- if(!$this->CanShowPost($po)){ continue; }
- echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
- } ?>
- </ul></td></tr><?php } ?>
- <?php } ?>
- </tbody></table>
- </li></ul>
- <br />
- <?php $this->MakeCommentSection($th['first']); ?>
- </div>
- <?php return true;
- }
- function CssNumberID($id){
- return "#\\3".substr($id,0,1)." ".substr($id,1);
- }
- function MakePostTools(){
- if($this->LoggedIn && !isset($this->WayBack)){ $STR=<<<EOT
- <div class='smaller gray hidden_on_print clean_a'>
- <a id='merge_cancel' href='javascript:{TogglePostSelectMode(false,true);ToggleThreadMerge(false,true);}'>
- {$this->T('工具')}</a>:<div class='hidden_m' style='display:inline'>
- <span id='merge_post_btn'><a href='javascript:TogglePostSelectMode()'>{$this->T('合并帖子')}</a></span>
- | <span id='merge_thread_btn'><a href='javascript:ToggleThreadMerge()'>{$this->T('合并话题')}</a></span>
- </div>
- <select class='hidden_on_desktop' id='merge_select'
- onchange="if(this.selectedIndex==1){TogglePostSelectMode(true);}else if(this.selectedIndex==2){ToggleThreadMerge(true);}">
- <option value='-1' selected>--</option>
- <option value='1'>{$this->T('合并帖子')}</option>
- <option value='2'>{$this->T('合并话题')}</option></select>
- <div style='display:none;' id='merge_post_dialog' class='text_highlight small_pad align_right'>
- <div style='display:inline;'>{$this->T('将合并')} <span id='merge_post_count'></span> {$this->T('个帖子')}</div>
- <span class='clean_a bold align_right'><a id='merge_post'> {$this->T('执行')}</a></span></div>
- <div style='display:none;overflow:auto' id='merge_thread_dialog' class='text_highlight small_pad align_right'>
- <div style='display:inline;'>{$this->T('合并到话题')}</div>
- <input id="merge_thread_target" type="text" style="width:9em;display:inline" onChange='ThreadMergeInput(this);' onInput='ThreadMergeInput(this);'>
- <span class='clean_a bold align_right'><a id='merge_thread'> {$this->T('执行')}</a></span></div>
- </div><div class='spacer hidden_on_print'></div>
- EOT;
- }
- $this->TFill(2,$STR); $this->TExtra("class='no_line'"); $this->TRow();
- }
- function MakeSidebar(){ ?>
- <div class='left mobile_fold'><?php if(isset($this->SpecialSidebar) && ($p = &$this->GetPost($this->SpecialSidebar))!=NULL){
- ?><span class='gray smaller'><br /></span><?php
- //echo $this->GenerateSinglePost($p, false, false, false, false);
- }?>
- <div class='wayback_link clean_a smaller'><span class='gray'><br /><?=$this->T('工具')?></span><ul>
- <li><a href='?search=' onclick='ShowWaitingBar()' class='bigger'><?=$this->T('搜索')?></a></li>
- <li><?php if(!isset($this->WayBack)){ ?>
- <a href='<?=$this->GetRedirect()?>&set_wayback=true'><?=$this->T('以过去的日期浏览')?></a>
- <?php }else{ ?><a href='<?=$this->GetRedirect()?>&set_wayback=false'><?=$this->T('回到当前日期')?></a><?php } ?></li>
- <li><a href='<?=$this->GetRedirect()?>&toggle_font=true'>
- <?=$this->T('切换字体')?>: <?=$this->T($this->UseRemoteFont?"远程":"本地");?></a></li>
- <li><a rel="alternate" type="application/rss+xml" href="?rss=<?=$this->LanguageAppendix;?>" />RSS/Atom<sup><?=$this->LanguageAppendix;?></sup></a></li>
- </ul>
- </div>
- <?php if($this->NewsletterEnabled){ $STR=$this->MakeSubscription(1); echo $STR; }?>
- <br />
- <hr class="hidden_on_desktop" />
- </div>
- <?php }
- function MakePostSection(&$post){ $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1;
- $this->Anchors = []; if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))) $centerclass='center_slides'; else $centerclass='center';
- if(isset($this->TagID)){ ?><style><?=$this->CssNumberID($this->TagID);?>{display:block;}</style><?php } ?>
- <div class='<?=$centerclass;?>' id='div_center'><br class='hidden_on_print' />
- <h2 class='hidden_on_print'>
- <?php $th=NULL;
- $is_wide = (isset($post['wide'])&&$post['wide']) || ($is_thread && isset($post['tid']['wide']) && $post['tid']['wide']);
- if($is_thread){ $th = $post['tid'];?> <?=$this->T('话题')?> <?php }else{ ?> <?=$this->T('详细')?>
- <?php } ?></h2>
- <?php $cat = NULL;
- if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
- else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
- $this->MakePostTools();
- if($cat){ ?>
- <p class='hidden_on_print'><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
- echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
- <?php } ?><br class='hidden_on_print' />
- <ul class='print_column bkg_section'>
- <?php $is_reversed=false;
- if($is_thread){
- $use_arr = $th['arr']; $hinted=false;
- $last_end_wide = true; $is_reversed=$this->IsReversedThread($th);
- foreach($use_arr as &$p){$use_class="";if($p==$post){$use_class.=" active_post";}
- if($last_end_wide){$use_class.=" last_wide";}
- $make_title = ($p == $post);
- if(isset($p['restart'])){ ?>
- <li class='restart'><h3><?=$p['restart']?></h3></li><?php }
- $this->MakeSinglePost($p,true,false,$use_class,false, false, false, true, false, false);
- if($make_title){?>
- <script>
- document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
- </script>
- <?php } if($is_reversed && !$hinted){ ?><?php $hinted = true;
- if($this->LoggedIn && (!$this->InHereMode)){ ?>
- <div class='hidden_on_print'>
- <?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?></div><br />
- <?php } }
- $last_end_wide = isset($p['end_wide']) && $p['end_wide'];
- }
- }else{
- $this->MakeSinglePost($post,true, false,"active_post",false, false, false, true, false, false);
- ?><script>
- document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($post),0,100)))?>";
- </script><?php
- } $class_add=""; if(isset($post['tid']['first']['no_time'])){ $class_add=' hidden_on_print'; } ?>
-
- </ul>
- <div class='smaller align_right<?=$class_add;?>'>
- <span class='gray'><?=$this->ReadableTime($post['tid']['first']['id']);?></span>
- <br class='hidden_on_desktop' /><?=$this->ReadableTime(isset($post['tid']['last']['version'])?
- $post['tid']['last']['version']:$post['tid']['last']['id']);?>
- </div>
- <?php if(!$is_reversed && ($this->LoggedIn && (!$this->InHereMode))){ ?>
- <div class='hidden_on_print'>
- <br /><?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?>
- </div>
- <?php }
- $this->MakeCommentSection($post);
- ?>
- </div>
- <?php if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))){ ?>
- <div class='slides_buttons code' onclick="event.stopPropagation();">
- <a onclick="SlidesFontCheck(-1)">T-</a> <a onclick="SlidesFontCheck(1)">T+</a>
- <a onclick="SlidesStart(null)"><<</a> <a onclick="SlidesCheck(-1);"><</a>
- <a onclick="SlidesStart(1)"><span id="slides_now">1</span>/<span id="slides_total">1</span></a>
- <a onclick="SlidesCheck(1);">></a> <a onclick="SlidesEnd();">X</a>
- </div>
- <script>
- function SlidesStart(from_here){
- slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
- sdone=0; fp=0; if(from_here){
- urlParams = new URLSearchParams(window.location.search);
- fp = urlParams.get('post');
- }
- document.querySelector("#slides_total").innerText=slides.length; cur=document.querySelector("#slides_now");
- for(i=0;i<slides.length;i++){ slides[i].style.display="none";
- 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; }
- } if(!sdone){ slides[0].style.display="table-cell"; ClickPost(slides[0],0,true); cur.innerText=1; }
- c=document.querySelector('.center'); if(!c) return;
- c.classList.remove('center'); c.classList.add('center_slides'); if(c.dataset.fontSize){ c.style.fontSize=c.dataset.fontSize; }
- c=document.querySelector('.left'); if(!c) return; c.style.display="none";
- }
- function SlidesCheck(offset){
- slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return; cur=document.querySelector("#slides_now");
- for(i=0;i<slides.length;i++){ if(slides[i].style.display=="table-cell" && slides[i+offset] && (i+offset)>=0){
- slides[i+offset].style.display="table-cell"; slides[i].style.display="none"; ClickPost(slides[i+offset],0,true); cur.innerText=i+offset+1; break;
- }
- }
- }
- function SlidesFontCheck(offset){
- c=document.querySelector('.center_slides'); if(!c) return;
- f=5; if(c.style.fontSize){ f=parseInt(c.style.fontSize); }
- f+=offset; if(f<=0) f=1; if(f>12) f=12; c.style.fontSize=""+f+"vmin"; c.dataset.fontSize=c.style.fontSize;
- }
- function SlidesEnd(){
- c=document.querySelector('.center_slides'); if(!c) return;
- c.classList.remove('center_slides'); c.classList.add('center'); c.style.fontSize="";
- c=document.querySelector('.left'); if(!c) return; c.style.display="inline-block";
- slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
- for(i=0;i<slides.length;i++){ slides[i].style.display=""; }
- }
- //document.addEventListener("wheel", function(event){ if(event.deltaY>0) SlidesCheck(1); else SlidesCheck(-1); }, { passive: false });
- document.addEventListener("click", function(event){ SlidesCheck(1); });
- document.addEventListener('keydown', function(event) {
- const key = event.key; // "ArrowRight", "ArrowLeft", "ArrowUp", or "ArrowDown"
- switch(key){
- case "ArrowUp": case "ArrowLeft": SlidesCheck(-1); break; case "ArrowDown": case "ArrowRight": SlidesCheck(1); break;
- case "Escape": SlidesEnd(); break;
- }
- });
- </script>
- <?php }
- }
- function MakePostSectionExp(&$post){
- $this->Anchors = []; $is_thread = isset($post['tid']);
- ?>
- <div class='center_exp' id='div_center'><br class='hidden_on_print' />
- <ul>
- <?php $is_reversed=false;
- if($is_thread){ $th = &$post['tid'];$use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false;
- foreach($use_arr as &$p){
- $this->MakeSinglePostExp($p);
- if($p == $th['first']){?>
- <script>
- document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
- </script>
- <?php } if($is_reversed && !$hinted){ ?>
- <li class='gray smaller bold' style='text-align:center;'>
- <p> </p><hr><?=$this->T('该话题最新帖子在前')?><hr><p> </p></li>
- <?php $hinted = true; }
- }
- }else{
- $this->MakeSinglePostExp($post);
- ?><!--<script>
- document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
- </script>--><?php
- } ?>
- </ul>
- </div>
- <?php
- }
- function MakeHereSection(&$im){ $image_okay = (isset($im) && $im!=$this->NULL_IMAGE); ?>
- <div class='here_image_box clean_a'>
- <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'>
- <?=$image_okay?$this->T('请稍候'):$this->T('未找到图像')?></div>
- <?php if($image_okay){ ?>
- <?php if(isset($im['video']) && isset($im['video'])!=""){ ?>
- <video controls><source src='<?=$im['file'];?>' type='<?=$im['video']?>'></video>
- <?php }else{ ?>
- <img id='big_image' onload="HideWaitingBar();" src="<?=$im['file'];?>" />
- <?php } ?>
- <?php } $this->MakeHereButtons($im, false); ?>
- </div>
- <?php }
-
- function MakeSideGalleryCode(){?>
- <div>
- <h3><?=$this->T('点击图片以插入:')?></h3>
- <select id="side_gallery_select" onchange="RefreshSideGallery()">
- <option value="main"><?=$this->T('全部')?></option>
- <?php if($this->LoggedIn){ ?>
- <option value="trash"><?=$this->T('垃圾桶')?></option>
- <?php }?>
- <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
- <option value="<?=$g['name']?>"><?=$g['name']?></option>
- <?php } ?>
- </select>
- <div id='side_gallery'>
- </div>
- </div>
- <script>
- function InsertImage(imgname){
- t = document.querySelector("#post_content");
- v = t.value;
- t.value = v.slice(0, t.selectionStart) + ""+ v.slice(t.selectionEnd);
- la_auto_grow(t);
- }
- function RefreshSideGallery(){
- let xhr = new XMLHttpRequest();
- xhr.onreadystatechange = (function(){
- if (this.readyState === this.DONE) {
- if (this.status === 200) {
- ind = document.querySelector("#side_gallery");
- if(res = xhr.responseText.matchAll(/\[(.*?),(.*?)\]/gu)){
- str = "<ul class='side_thumb'>"
- for (const m of res) {
- imgstr = "<img src='"+m[2]+"' />";
- if(m[2].match('\.mp4')){
- imgstr = "<video><source src='"+m[2]+"'></video>";
- }
- str+="<li><div class='file_thumb' onclick='InsertImage(\""+m[1]+"\")'>"+imgstr+"</div>"
- }
- str += "</ul>"
- ind.innerHTML = str;
- }
- }
- }
- });
- xhr.open("GET", "?image_list="+document.querySelector("#side_gallery_select").value, true);
- xhr.send();
- }
- </script>
- <?php
- }
-
- function MakeUploader($is_side=false){ ?>
- <div id='upload_operation_area' class='hidden_on_print'>
- <p><?=$this->T('选择、粘贴或者拖动到页面以上传图片。')?></p>
- <input type="file" id='upload_selector' accept="image/x-png,image/png,image/gif,image/jpeg" multiple/>
- <ul id='file_list'>
- </ul>
- <div class='smaller gray' id='upload_hint'><?=$this->T('就绪')?></div>
- </div>
- <a id='upload_click' class='hidden_on_print pointer' onclick='this.removeAttribute("onclick");UploadList();'
- <?=$is_side?" data-is-side='true'":""?>><?=$this->T('上传列表中的文件')?></a>
- <script>
- function pastehandler(event){
- var items = (event.clipboardData || event.originalEvent.clipboardData).items;
- for (index in items) {
- var item = items[index];
- if (item.kind === 'file') {
- put = document.querySelector("#_uploader");
- if(put) ShowSideUploader();
- var blob = item.getAsFile();
- AddImageFile(blob);
- return;
- }
- }
- }
- let _fd_list = []; var uploading=0;
- let hint=document.querySelector('#upload_hint');
- function ToggleCompress(button){
- li = button.parentNode;
- num=li.dataset.number;
- for(i=0;i<_fd_list.length;i++){
- if (_fd_list[i][0] == num){
- state = _fd_list[i][2];
- if(state){_fd_list[i][2] = 0; button.innerHTML='L';break;}
- else{_fd_list[i][2] = 1; button.innerHTML='S';break;}
- }
- }
- }
- function ToggleTransparency(button){
- li = button.parentNode;
- num=li.dataset.number;
- for(i=0;i<_fd_list.length;i++){
- if (_fd_list[i][0] == num){
- state = _fd_list[i][4];
- if(state){_fd_list[i][4] = 0; button.innerHTML='●';break;}
- else{_fd_list[i][4] = 1; button.innerHTML='○';break;}
- }
- }
- }
- function RemoveFromUpload(button){
- li = button.parentNode;
- num=li.dataset.number;
- for(i=0;i<_fd_list.length;i++){
- if (_fd_list[i][0] == num){
- _fd_list.splice(i, 1);break;
- }
- }
- li.parentNode.removeChild(li);
- }
- function EndThisUpload(){
- unfinished = 0;
- for(i=0;i<_fd_list.length;i++){
- if (_fd_list[i][3]==0){
- unfinished=1;
- }
- }
- if(!unfinished){
- uploading=0;
- hint.innerHTML="<?=$this->T('上传完成。')?>";
- cl=document.querySelector('#upload_click');
- if(!cl.dataset.isSide){
- cl.innerHTML="<?=$this->T('刷新页面')?>";
- cl.href=window.location.href;
- }else{
- _fd_list.splice(0,_fd_list.length);
- fl = document.querySelector("#file_list");
- fl.innerHTML = "";
- list=document.querySelector('#upload_operation_area');
- list.style.pointerEvents='';
- list.style.opacity='';
- cl.onclick=function(){this.removeAttribute("onclick");UploadList();};
- document.onpaste=pastehandler;
- RefreshSideGallery();
- }
- }
- }
- function UploadList(){
- if(!_fd_list.length || uploading) return;
- uploading=1;
- hint.innerHTML="<?=$this->T('正在上传...')?>";
- list=document.querySelector('#upload_operation_area');
- list.style.pointerEvents='none';
- list.style.opacity='0.5';
- document.onpaste="";
- for(i=0;i<_fd_list.length;i++){
- let xhr = new XMLHttpRequest();
- var li = list.querySelector('[data-number="'+_fd_list[i][0].toString()+'"]')
- xhr.open("POST", "?compress="+_fd_list[i][2].toString()+"&transparency="+_fd_list[i][4].toString(), true);
- function wrap(li, i){
- var ind = li.querySelector('._compress_toggle')
- return function(){
- if (this.readyState === this.DONE) {
- if (this.status === 200) {
- var response = xhr.responseText;
- if(res = response.match(/<uploaded>(.*)<\/uploaded>/)){
- ind.innerHTML = "<?=$this->T('已上传为')?> "+res[1];
- _fd_list[i][3] = 1;
- }else{
- ind.innerHTML = "<?=$this->T('出现错误。')?>";
- _fd_list[i][3] = 1;
- }
- EndThisUpload();
- }
- }
- }
- }
- xhr.onreadystatechange = wrap(li, i);
- xhr.send(_fd_list[i][1]);
- }
- }
- function AddImageFile(blob){
- var ext="";
- if(blob.name.match(/png$/i))ext = 'png';
- else if(blob.name.match(/jpg$/i))ext = 'jpg';
- else if(blob.name.match(/jpeg$/i))ext = 'jpeg';
- else if(blob.name.match(/gif$/i))ext = 'gif';
- else if(blob.name.match(/mp4$/i))ext = 'mp4';
- else return;
- var fd = new FormData();
- blob.name = blob.name=generateUID().toString();
- fd.append("upload_file_name", blob, "_upload_"+blob.name+"."+ext);
- _fd_list.push([blob.name, fd, 1, 0, 0]);/* number original is_compress uploaded transparency */
- var reader = new FileReader();
- reader.onload = function(event){
- fl = document.querySelector("#file_list");
- ht = "<li id='_upload_"+blob.name+"' data-number='"+blob.name+"'>"+
- "<a class='_remove_file pointer invert_a' onclick='RemoveFromUpload(this)'>×</a> "+"<div class='file_thumb'>"+
- "<img class='no_pop' src='"+event.target.result+"'>"+"</div>"+
- " →<a class='_compress_toggle pointer' onclick='ToggleCompress(this)'>S</a>"+
- " <a class='_transparency_toggle pointer' onclick='ToggleTransparency(this)'>●</a></li>";
- fl.innerHTML+=ht;
- };
- reader.readAsDataURL(blob);
- }
- sel = document.querySelector('#upload_selector');
- sel.addEventListener("change", function(){
- var input = this;
- function ff(file){
- return function(e){
- let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
- blob.name = file.name;
- AddImageFile(blob);
- }
- }
- for(i=0;i<input.files.length;i++){
- if(input.files[i].size){
- let reader = new FileReader();
- reader.onload = ff(input.files[i]);
- reader.readAsArrayBuffer(input.files[i]);
- }
- }
- });
- function generateUID() {
- var firstPart = (Math.random() * 46656) | 0;
- var secondPart = (Math.random() * 46656) | 0;
- firstPart = ("000" + firstPart.toString(36)).slice(-3);
- secondPart = ("000" + secondPart.toString(36)).slice(-3);
- return firstPart + secondPart;
- }
- document.onpaste = pastehandler;
- function dropHandler(ev) {
- put = document.querySelector("#_uploader");
- if(put) ShowSideUploader();
- bkg=document.querySelector('#dropping_background');
- bkg.style.display="none";
- console.log('File(s) dropped');
- ev.preventDefault();ev.stopPropagation();
- if (ev.dataTransfer && ev.dataTransfer.items) {
- for (var i = 0; i < ev.dataTransfer.items.length; i++) {
- if (ev.dataTransfer.items[i].kind === 'file') {
- var file = ev.dataTransfer.items[i].getAsFile();
- function ff(file){
- return function(e){
- let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
- blob.name = file.name;
- AddImageFile(blob);
- }
- }
- if(file){
- let reader = new FileReader();
- reader.onload = ff(file);
- reader.readAsArrayBuffer(file);
- }
- }
- }
- } else {
- for (var i = 0; i < ev.dataTransfer.files.length; i++) {
- function ff(file){
- return function(e){
- let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
- blob.name = file.name;
- AddImageFile(blob);
- }
- }
- if(ev.dataTransfer.files[i].size){
- let reader = new FileReader();
- reader.onload = ff(ev.dataTransfer.files[i]);
- reader.readAsArrayBuffer(ev.dataTransfer.files[i]);
- }
- }
- }
- }
- function dragOverHandler(ev) {
- bkg=document.querySelector('#dropping_background');
- bkg.style.display="";
- console.log('File(s) in drop zone');
- ev.preventDefault();
- }
- </script>
- <?php
- }
-
- function CanShowGallery(&$g){
- if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($g['experimental']) && $g['experimental']) return false;
- return true;
- }
- function CanShowImage(&$im){
- if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($im['galleries']) && isset($im['galleries'][0])) foreach($im['galleries'] as $ga){
- if(($g=$this->GetGallery($ga)) && isset($g['experimental']) && $g['experimental']) return false;
- }
- if(isset($this->WayBack) && substr($im['name'],0,14)>$this->WayBack) return false;
- return true;
- }
-
- function GetImageBatch($from,$show_all){
- if(!isset($_GET['gallery'])) return;
- $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){$name=$_GET['gallery'];}
- $reached=0; $count=0;
- if(isset($this->Images[0])) foreach($this->Images as $im){
- if(isset($from)&&!$reached){ if($from==$im['name']){ $reached=1; } continue; }
- if(!$this->CanShowImage($im)){ continue; }
- if($_GET['gallery']=='trash') $name='trash';
- if($_GET['gallery']!='main'){ if(!isset($im['galleries']) || !in_array($name, $im['galleries'])) continue;} ?>
- <div class='p_thumb<?=isset($im['parent'])?" p_thumb_narrow":""?>'>
- <?php if($this->LoggedIn){ ?>
- <div class="post_menu_button _select_hook white" onclick='ToggleSelectImage(this, "<?=$im["name"]?>")'>●</div>
- <?php } ?>
- <a href='?show_image=<?=$im['name']?>' target='_blank' onclick='event.preventDefault();'>
- <?php if(isset($im['video']) && $im['video']!=""){ ?>
- <video data-imgsrc='<?=$im["name"]?>'><source src='<?=$im['file']?>' type='<?=$im['video']?>'></video>
- <?php }else{ ?>
- <img src='<?=$im['thumb']?>' data-imgsrc='<?=$im["name"]?>'
- <?=isset($im['product'])?'data-product="'.$im["product"].'"':""?>
- <?=isset($im['parent'])?'data-parent="'.$im["parent"].'"':""?>
- <?=isset($im['align'])?'data-align="'.$im["align"].'" style="object-position:'.$im['align'].';"':""?>/>
- <?php } ?>
- </a>
- </div>
- <?php $count+=isset($im['parent'])?0:1; if((!$show_all)&&($count>=$this->GalleryStep)){ break; }
- }
- if($count<$this->GalleryStep){ ?><div style='display:none'>END_GALLERY</div><?php return 0; }
- return 1;
- }
-
- function MakeGallerySection(){ global $INDEXPHP;
- if(!isset($_GET['gallery'])) return;
- $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){ $name=$_GET['gallery'];}
- $show_all=0; if(isset($_GET['show_all']) && $_GET['show_all']!='0'){ $show_all=1; } ?>
- <script>
- document.title+=" | <?=$this->T('画廊')?>";
- </script>
- <div class='center_wide' id='div_center' style='position:relative;'><br class='hidden_on_print' />
- <h2><?=(isset($name) && ($gal=$this->GetGallery($name))!=NULL)?
- ("<span class='gray album_hint'>".$this->T('相册').":</span>".$this->T($name)):
- ($_GET['gallery']=='trash'?$this->T('垃圾桶'):$this->T('画廊'))?></h2>
- <?php $description=(isset($gal) && isset($gal['description']))?$gal['description']:null; ?>
- <div class='hidden_on_desktop'>
- <?=$this->T('前往')?>
- <select id="gallery_go_to" onchange="window.location.href='?gallery='+this.value;">
- <optgroup label="<?=$this->T('精选')?>">
- <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
- if(!isset($g['featured']) || !$g['featured'] ||
- !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
- <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
- <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
- <?php } ?></optgroup><optgroup label="<?=$this->T('其他相册')?>">
- <option value="main" <?=$_GET['gallery']=='main'?"selected":""?>>[<?=$this->T('全部')?>]</option>
- <?php if($this->LoggedIn){ ?>
- <option value="trash" <?=$_GET['gallery']=='trash'?"selected":""?>>[<?=$this->T('垃圾桶')?>]</option>
- <?php } ?>
- <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
- if((isset($g['featured']) && $g['featured']) ||
- !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
- <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
- <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
- <?php } ?></optgroup>
- </select>
- </div>
- <?php if($this->LoggedIn){?>
- <div>
- <?php if(isset($name)){ ?>
- <div style='text-align:right;position:absolute;right:0;top:0;width:100%;' class='invert_a smaller hidden_on_print'>
- <a href='javascript:ShowDeleteMenu();'><?=$this->T('删除相册')?></a><br />
- <?php if(isset($gal['featured']) && $gal['featured']!=false){ ?>
- <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=false'>
- <?=$this->T('取消精选')?></a>
- <?php }else{ ?>
- <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=true'>
- <?=$this->T('设为精选')?></a>
- <?php } ?><br />
- <?php if(isset($gal['experimental']) && $gal['experimental']!=false){ ?>
- <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=false'>
- <?=$this->T('取消实验')?></a>
- <?php }else{ ?>
- <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=true'>
- <?=$this->T('设为实验')?></a>
- <?php } ?>
- <div class='pop_menu invert_a' id='gallery_delete_menu' style='display:none;'>
- <div style='float:left;' class='gray'><?=$this->T('该操作不删除图片。')?></div>
- <a href='javascript:HidePopMenu();'>×</a>
- <hr />
- <a href='?gallery=main&gallery_edit_delete=<?=$_GET['gallery']?>'><b><?=$this->T('删除相册')?></b></a>
- </div>
- </div>
- <?php } ?>
- <?php $this->MakeUploader(false); ?>
- <div style='text-align:right;position:relative;' class='invert_a smaller hidden_on_print'>
- <div style='position:relative'>
- <?php if(isset($name)){ ?>
- <a href='javascript:ShowGalleryEditMenu("<?=$name?>",null)'><?=$this->T('改名')?></a>
- <a href='javascript:ShowGalleryEditMenu("<?=$name?>","<?=$description?>")'><?=$this->T('描述')?></a>
- <?php } ?>
- <a href='javascript:ShowGalleryEditMenu(null,null)'><?=$this->T('添加')?></a>
- <div class='pop_menu invert_a' id='gallery_edit_menu' style='display:none;max-width:90%;'>
- <form action="<?=$_SERVER['REQUEST_URI']?>&edit_gallery=true"
- method="post" style='display:none;' id='gallery_edit_form'></form>
- <a style='float:left;'><?=$this->T('设置为:')?></a>
- <a href='javascript:HidePopMenu();'>×</a>
- <input type='text' form='gallery_edit_form' name='gallery_edit_new_name' id='gallery_edit_new_name' style='width:10em;'>
- <input type='text' form='gallery_edit_form' name='gallery_edit_old_name' id='gallery_edit_old_name' style='display:none'>
- <input type='text' form='gallery_edit_form' name='gallery_edit_description' id='gallery_edit_description' style='width:10em;display:none'>
- <input class='button' type='submit' form='gallery_edit_form'
- name='gallery_edit_confirm' id='gallery_edit_confirm' value='<?=$this->T('确认')?>'>
- </div>
- </div>
- </div>
- <div class='smaller hidden_on_print'>
- <form action="<?=$_SERVER['REQUEST_URI']?>"
- method="post" style='display:none;' id='gallery_move_form'></form>
- <input type='text' form='gallery_move_form' name='gallery_move_ops'
- id='gallery_move_ops' style='display:none'>
- <p><?=$this->T('选择了')?> <span id='gallery_selected_count'>0</span> <?=$this->T('个图片。')?>
- <a href='javascript:ClearSelectedImages()'><?=$this->T('清除')?></a></p>
- <p><?=$this->T('添加到')?>
- <select id="gallery_move_to">
- <option value="trash"><?=$this->T('垃圾桶')?></option>
- <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
- <option value="<?=$g['name']?>"><?=$this->T($g['name'])?></option>
- <?php } ?>
- </select>
- <a href='javascript:AddToGallery()'><?=$this->T('执行')?></a>
- </p>
- <p>
- <?=$this->T('或者')?><a href='javascript:RemoveFromGallery()'><?=$this->T('从相册移除')?></a>
- </p>
- </div>
- </div>
- <?php } $desc=isset($description)?$this->GetPost($description):null;
- if(isset($desc)){ ?><ul class='print_column list'><br /><?php
- $this->MakeSinglePost($desc, false, false, false, false, false, false, false, false, true, false);
- ?></ul><?php } ?>
- <br />
- <div><div class='p_row'><?php $has_more=$this->GetImageBatch(NULL, $show_all);?>
- <div class='p_thumb p_thumb_end' <?=$has_more?"onclick='ThisGetMore(this);'":""?>>
- <a onclick='event.preventDefault();' href='<?=$INDEXPHP?>?gallery=<?=$_GET['gallery']?>&show_all=1'>
- <h2 id="btn_more_images"><?=$has_more?$this->T("查看更多"):$this->T("没有更多的了");?></a></h2></div></div>
- </div>
- </div>
- <script type='text/javascript'>
- function ThisGetMore(end_ui){
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- doc = document.createElement("div"); doc.innerHTML=xhr.responseText.trim(); next_child=null;
- for(child=doc.firstChild; child!==null; child=next_child) { next_child=child.nextSibling; end_ui.parentNode.insertBefore(child,end_ui); }
- doc.remove();
- if(xhr.responseText.search('END_GALLERY')>=0){ end_ui.onclick=null; end_ui.innerHTML="<h2><?=$this->T("没有更多的了");?></h2>"; }
- UpdateImageClickables();
- btn=document.getElementById("btn_more_images"); if(btn) btn.innerText="<?=$this->T("查看更多");?>";
- }
- };
- btn=document.getElementById("btn_more_images"); if(btn) btn.innerText="<?=$this->T("稍等");?>";
- im=end_ui.previousElementSibling.querySelector('img,video');
- from=im?im.dataset.imgsrc:null; if(!from) return;
- const urlParams = new URLSearchParams(window.location.search); const gallery = urlParams.get('gallery')
- xhr.open("GET", "<?=$INDEXPHP?>?gallery_continue="+from+'&gallery='+gallery, true);
- xhr.send();
- }
- <?php if($this->LoggedIn){ ?>
- var selected_image = new Array();
- function RemoveFromGallery(){
- form = document.querySelector('#gallery_move_form');
- ops = document.querySelector('#gallery_move_ops');
- sel = document.querySelector('#gallery_move_to');
- ops.value = "REM <?=$_GET['gallery']?>"+" "+selected_image.join(' ');
- form.submit();
- }
- function AddToGallery(){
- form = document.querySelector('#gallery_move_form');
- ops = document.querySelector('#gallery_move_ops');
- sel = document.querySelector('#gallery_move_to');
- ops.value = "ADD "+sel.value+" "+selected_image.join(' ');
- form.submit();
- }
- function ClearSelectedImages(){
- selected_image.splice(0, selected_image.length);
- checks = document.querySelectorAll('._select_hook');
- [].forEach.call(checks, function(c){
- c.classList.remove('p_thumb_selected');
- });
- count = document.querySelector('#gallery_selected_count');
- count.innerHTML="0";
- }
- function ToggleSelectImage(elem, name){
- count = document.querySelector('#gallery_selected_count');
- if(selected_image.indexOf(name) == -1){ selected_image.push(name); elem.classList.add('p_thumb_selected'); }
- else{ selected_image.splice(selected_image.indexOf(name), 1); elem.classList.remove('p_thumb_selected'); }
- count.innerHTML=selected_image.length.toString()
- }
- function ShowGalleryEditMenu(old_name,desc){
- m = document.querySelector('#gallery_edit_menu');
- old = document.querySelector('#gallery_edit_old_name');
- newname = document.querySelector('#gallery_edit_new_name');
- description = document.querySelector('#gallery_edit_description');
- m.style.display='block';
- if(desc!==null){ description.style.display='block';newname.style.display='none';description.value=desc;}
- else{ description.style.display='none';newname.style.display='';}
- if(old_name!=''){ old.value=old_name; newname.value=old.value; }else{ old.value=''; }
- }
- function ShowDeleteMenu(){
- m=document.querySelector('#gallery_delete_menu');
- m.style.display='block';
- }
- <?php } ?>
- </script>
- <?php
- }
-
- function MakeGalleryLeft(){?>
- <div class='left hidden_m gallery_left' id='div_left'><div><br /></div>
- <h2><?=$this->T('相册')?></h2>
- <div>
- <span class='gray smaller bold'><?=$this->T('精选')?><hr> </span>
- <ul>
- <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
- if(!isset($g['featured']) || !$g['featured'] || !$this->CanShowGallery($g)){ continue; } ?>
- <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
- <li class='<?=$_GET['gallery']==$g['name']?'selected':""?>'>
- <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
- <?php } ?>
- </ul>
- <div class='smaller'><span class='gray'><?=$this->T('其他相册')?><hr></span><ul>
- <a href='?gallery=main' onclick='ShowWaitingBar()'>
- <li class='<?=$_GET['gallery']=='main'?' selected':""?>'>[<?=$this->T('全部图片')?>]</li></a>
- <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
- if((isset($g['featured']) && $g['featured']) || !$this->CanShowGallery($g)){ continue; } ?>
- <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
- <li class='<?=$_GET['gallery']==$g['name']?' selected':""?>'>
- <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
- <?php } ?>
- <?php if($this->LoggedIn){ ?>
- <a href='?gallery=trash' onclick='ShowWaitingBar()'>
- <li class='<?=$_GET['gallery']=='trash'?' selected':""?>'>[<?=$this->T('垃圾桶')?>]</li></a>
- <?php } ?>
- </ul></div>
- <p> </p>
- <script>
- </script>
- </div>
- </div>
- <?php
- }
-
- function MakeStatistics(){
- $this->ReadPosts(); $this->ReadImages(); $this->ReadArchive();
- $list=[]; $last_date=null; $info=[]; $info['count']=0; $info['edits']=0; $info['length']=0;
- $imlist=[]; $imlast_date=null; $iminfo=[]; $iminfo['count']=0;
- $maxposts=0; $maxlength=0; $maximages=0;
- foreach($this->Posts as &$p){ $is_ref=0;
- $this_date=substr($p['id'],0,8);
- if($last_date!=null && $last_date!=$this_date){
- if($maxposts<$info['count']+$info['edits'])$maxposts=$info['count']+$info['edits'];
- if($maxlength<$info['length'])$maxlength=$info['length'];
- $list[]=$info; $info=[]; $info['count']=0; $info['edits']=0; $info['length']=0;
- }
- $ah = &$this->GetArchiveHandle($p['id']); if(isset($ah)&&isset($ah['list'][0])) $info['edits']+=count($ah['list']);
- $info['count']++; $info['id']=$this_date; if(isset($p['content']))$info['length']+=strlen($p['content']); $last_date=$this_date;
- }
- $last_date=null;
- foreach($this->Images as &$im){ $is_ref=0;
- $this_date=substr($im['name'],0,8);
- if($last_date!=null && $last_date!=$this_date){
- if($maximages<$iminfo['count'])$maximages=$iminfo['count'];
- $imlist[]=$iminfo; $iminfo=[]; $iminfo['count']=0;
- }
- $iminfo['count']++; $iminfo['id']=$this_date; $last_date=$this_date;
- }
- if($info!=[]) $list[]=$info;
- if($iminfo!=[]) $imlist[]=$iminfo;
- if(!isset($list[0])) return;
- $earliest=DateTimeImmutable::createFromFormat('!Ymd',$list[0]['id']); $ey=substr($list[0]['id'],0,4);
- $latest=DateTimeImmutable::createFromFormat('!Ymd',end($list)['id']); $ly=substr(end($list)['id'],0,4);
- $days=$earliest->diff($latest)->days; $lw=2.0; $dw=$days*$lw; $spw=20;
- ?>
- <style>.stastics_posts{direction:ltr;} .stastics_posts line,.stastics_posts circle{stroke:#f8ca9b; stroke-width:2px;}
- .stastics_posts .line_edits{stroke:#f8ca9b40;}
- .stastics_posts .line_year{stroke:#f8ca9b30; stroke-width:2px;} .stastics_posts text{fill:#f8ca9ba0; font: 0.9em serif;}
- </style>
- <div class='settings'><h2><?=$this->T('统计')?></h2><br />
- <div style="overflow:auto;direction:rtl;width:100%;">
- <svg class='stastics_posts' viewBox="-<?=$spw?> -<?=$spw?> <?=$days*$lw+$spw*6?> <?=200+4*$spw?>" height="<?=200+4*$spw?>" width="<?=$days*$lw+$spw*6?>">
- <?php foreach($list as $info){ $itv=DateTimeImmutable::createFromFormat('!Ymd',$info['id'])->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);
- $p1=100.0*(1-$info['count']/$maxposts); $p2=$p1-100.0*$info['edits']/$maxposts;
- $p3=100.0*$info['length']/$maxlength+$spw+100; ?>
- <line x1="<?=$ds?>" x2="<?=$ds?>" y1="100.0" y2="<?=$p1?>"/>
- <?php if($info['edits']>0){ ?><line class='line_edits' x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=$p1?>" y2="<?=$p2?>"/><?php } ?>
- <?php if($info['length']>0){ ?><line class='line_edits' x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=$spw+100?>" y2="<?=$p3?>"/><?php } ?>
- <?php } ?>
- <?php foreach($imlist as $im){ $itv=DateTimeImmutable::createFromFormat('!Ymd',$im['id'])->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);
- $p1=100+$spw+100.0*($im['count']/$maximages); ?>
- <circle cx="<?=$ds?>" cy="<?=$p1?>" r='3'/>
- <?php } ?>
- <?php for($y=$ey;$y<=$ly;$y++){ $itv=DateTimeImmutable::createFromFormat('!Y',$y)->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);?>
- <line x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=220+$spw?>" y2="-<?=$spw?>" class='line_year'/>
- <text x="<?=$ds+4?>" y="-4"><?=$y?></text>
- <text x="<?=$ds+4?>" y="<?=$spw*2+200-4?>"><?=$y?></text>
- <?php for($ym=1;$ym<=12;$ym++){ $st=str_pad($ym,2,'0',STR_PAD_LEFT); $itv2=DateTimeImmutable::createFromFormat('!Ym',$y.$st)->diff($earliest);
- $dds=$lw/2+$lw*$itv2->days*($itv2->invert?1:-1); if($dds<0||$dds>$lw/2+$dw) continue; ?>
- <line x1="<?=$dds?>" x2="<?=$dds?>" y1="<?=100+$spw?>" y2="100" class='line_year'/>
- <text x="<?=$dds+4?>" y="<?=100+$spw-3?>"><?=$ym?></text>
- <?php } } ?>
- <line x1="<?=$lw/2+$dw?>" x2="<?=$days*$lw?>" y1="<?=220+$spw?>" y2="-<?=$spw?>" class='line_year'/>
- <line x1="0" x2="<?=$dw?>" y1="0" y2="0" class='line_year'/>
- <line x1="0" x2="<?=$dw?>" y1="100" y2="100" class='line_year'/>
- <line x1="0" x2="<?=$dw?>" y1="<?=100+$spw?>" y2="<?=100+$spw?>" class='line_year'/>
- <line x1="0" x2="<?=$dw?>" y1="<?=200+$spw?>" y2="<?=200+$spw?>" class='line_year'/>
- <text x="<?=$dw+10?>" y="8"><?=$maxposts?></text>
- <text x="<?=$dw+10?>" y="<?=$spw+8?>"><tspan style='fill:#f8ca9b;'>▪ <?=$this->T('新增')?></tspan></text>
- <text x="<?=$dw+10?>" y="<?=$spw*2+8?>"><tspan style='fill:#f8ca9ba0;'>▪ <?=$this->T('改动')?></tspan></text>
- <text x="<?=$dw+10?>" y="<?=$spw*2+200-4?>"><?=$maxlength?></text>
- <text x="<?=$dw+10?>" y="<?=$spw+200-4?>"><tspan style='fill:#f8ca9b;'><?=$maximages?></tspan></text>
- <text x="<?=$dw+10?>" y="<?=200-4?>"><tspan style='fill:#f8ca9b;'>▪ <?=$this->T('媒体')?></text>
- <text x="<?=$dw+10?>" y="<?=200-4-$spw?>">▪ <?=$this->T('长度')?></tspan></text>
- </svg></div>
- <br /><br />
- </div>
- <?php
- }
- function MakeSettings(){ global $INDEXPHP; ?>
- <div class='settings'>
- <h2><?=$this->T('设置')?></h2>
- <table style='white-space:nowrap;'>
- <?php if($this->LoggedIn){ ?>
- <form action="<?=$INDEXPHP?>?settings=true" method="post" style='display:none;' id='settings_form'></form>
- <colgroup><col style='min-width:5em;'><col style='width:100%;min-width:5em;'></colgroup>
- <thead><tr><td><?=$this->T('选项')?></td><td><?=$this->T('值')?></td></tr></thead>
- <tr><td><?=$this->T('网站标题')?></td>
- <td><input type="text" form="settings_form" id='settings_title' name='settings_title'
- value='<?=$this->Title?>'/></td></tr>
- <tr><td><?=$this->T('短标题')?></td>
- <td><input type="text" form="settings_form" id='settings_short_title' name='settings_short_title'
- value='<?=$this->ShortTitle?>'/></td></tr>
- <tr><td><?=$this->T('显示名称')?></td>
- <td><input type="text" form="settings_form" id='settings_display_name' name='settings_display_name'
- value='<?=$this->DisplayName?>'/></td></tr>
- <tr><td><?=$this->T('电子邮件')?></td>
- <td><input type="text" form="settings_form" id='settings_email' name='settings_email'
- value='<?=$this->EMail?>'/></td></tr>
- <tr><td><?=$this->T('导航栏')?>
- <?=isset($this->SpecialNavigation)?"<a href='?post=".$this->SpecialNavigation."'>→</a>":""?></td>
- <td><input type="text" form="settings_form" id='settings_special_navigation' name='settings_special_navigation'
- value='<?=$this->SpecialNavigation?>'/></td></tr>
- <tr><td><?=$this->T('侧边栏')?>
- <?=isset($this->SpecialSidebar)?"<a href='?post=".$this->SpecialSidebar."'>→</a>":""?></td>
- <td><input type="text" form="settings_form" id='settings_special_sidebar' name='settings_special_sidebar'
- value='<?=$this->SpecialSidebar?>'/></td></tr>
- <tr><td><?=$this->T('脚注')?> 1<?=isset($this->SpecialFooter)?"<a href='?post=".$this->SpecialFooter."'>→</a>":""?></td>
- <td><input type="text" form="settings_form" id='settings_special_footer' name='settings_special_footer'
- value='<?=$this->SpecialFooter?>'/></td></tr>
- <tr><td><?=$this->T('脚注')?> 2<?=isset($this->SpecialFooter2)?"<a href='?post=".$this->SpecialFooter2."'>→</a>":""?></td>
- <td><input type="text" form="settings_form" id='settings_special_footer2' name='settings_special_footer2'
- value='<?=$this->SpecialFooter2?>'/></td></tr>
- <tr><td><?=$this->T('置顶文')?><?=isset($this->SpecialPinned)?"<a href='?post=".$this->SpecialPinned."'>→</a>":""?></td>
- <td><input type="text" form="settings_form" id='settings_special_pinned' name='settings_special_pinned'
- value='<?=$this->SpecialPinned?>'/></td></tr>
- <tr><td><?=$this->T('置顶备忘')?><?=isset($this->SpecialPinnedNotes)?"<a href='?post=".$this->SpecialPinnedNotes."'>→</a>":""?></td>
- <td><input type="text" form="settings_form" id='settings_special_pinned_notes' name='settings_special_pinned_notes'
- value='<?=$this->SpecialPinnedNotes?>'/></td></tr>
- <tr><td><?=$this->T('默认相册')?></td>
- <td><input type="text" form="settings_form" id='settings_default_gallery' name='settings_default_gallery'
- value='<?=$this->DefaultGallery?>'/></td></tr>
- <tr><td><?=$this->T('相册单步')?></td>
- <td><input type="text" form="settings_form" id='settings_gallery_step' name='settings_gallery_step'
- value='<?=$this->GalleryStep?>'/></td></tr>
- <tr><td><?=$this->T('SelfAuth 路径')?></td>
- <td><input type="text" form="settings_form" id='settings_selfauth_path' name='settings_selfauth_path'
- value='<?=$this->SelfAuthPath?>'/></td></tr>
- <tr><td><?=$this->T('启用评论')?></td>
- <td><input type="checkbox" id="settings_enable_comments" name="settings_enable_comments"
- form="settings_form" <?=$this->CommentEnabled?"checked":""?>/></td></tr>
- <tr><td><?=$this->T('启用新闻')?></td>
- <td><input type="checkbox" id="settings_enable_newsletter" name="settings_enable_newsletter"
- form="settings_form" <?=$this->NewsletterEnabled?"checked":""?>/></td></tr>
- <tr><td><?=$this->T('附加操作')?></td><td><a class='gray' href='<?=$INDEXPHP?>?extras=true'><?=$this->T('进入')?></a></td></tr>
-
- <tr><td class='smaller gray'> </td></tr>
- <tr><td class='smaller gray'><?=$this->T('长毛象')?></td></tr>
- <tr><td><?=$this->T('长毛象实例')?></td>
- <td><input type="text" form="settings_form" id='settings_mastodon_url' name='settings_mastodon_url'
- value='<?=$this->MastodonURL?>'/></td></tr>
- <tr><td><?=$this->T('长毛象令牌')?></td>
- <td><input type="text" form="settings_form" id='settings_mastodon_token' name='settings_mastodon_token'
- value='<?=$this->MastodonToken?>'/></td></tr>
- <tr><td><?=$this->T('偏好语言')?></td>
- <td><input type="text" form="settings_form" id='settings_mastodon_lang' name='settings_mastodon_lang'
- value='<?=$this->MastodonPreferredLang?>'/></td></tr>
- <tr><td><?=$this->T('本站地址')?></td>
- <td><input type="text" form="settings_form" id='settings_host_url' name='settings_host_url'
- value='<?=$this->HostURL?>'/></td></tr>
-
- <tr><td class='smaller gray'> </td></tr>
- <tr><td class='smaller gray'><?=$this->T('Activity Pub')?></td></tr>
- <tr><td><?=$this->T('用户名')?></td>
- <td><input type="text" form="settings_form" id='settings_apub_id' name='settings_apub_id'
- value='<?=$this->APubID?>'/></td></tr>
-
- <tr><td class='smaller gray'> </td></tr>
- <tr><td class='smaller gray'><?=$this->T('这里访问')?></td></tr>
- <tr><td><?=$this->T('主机')?></td>
- <td><input type="text" form="settings_form" id='settings_here_host' name='settings_here_host'
- value='<?=$this->HereHost?>'/></td></tr>
- <tr><td><?=$this->T('网站标题')?></td>
- <td><input type="text" form="settings_form" id='settings_here_title' name='settings_here_title'
- value='<?=$this->HereTitle?>'/></td></tr>
- <tr><td><?=$this->T('短标题')?></td>
- <td><input type="text" form="settings_form" id='settings_here_short_title' name='settings_here_short_title'
- value='<?=$this->HereShortTitle?>'/></td></tr>
- <tr><td><?=$this->T('相册')?></td>
- <td><input type="text" form="settings_form" id='settings_here_album' name='settings_here_album'
- value='<?=$this->HereAlbum?>'/></td></tr>
- <tr><td><?=$this->T('导航栏')?>
- <?=isset($this->HereNavigation)?"<a href='?post=".$this->HereNavigation."'>→</a>":""?></td>
- <td><input type="text" form="settings_form" id='settings_here_navigation' name='settings_here_navigation'
- value='<?=$this->HereNavigation?>'/></td></tr>
- <tr><td><?=$this->T('脚注')?><?=isset($this->HereFooter)?"<a href='?post=".$this->HereFooter."'>→</a>":""?></td>
- <td><input type="text" form="settings_form" id='settings_here_footer' name='settings_here_footer'
- value='<?=$this->HereFooter?>'/></td></tr>
-
- <tr><td class='smaller gray'> </td></tr>
- <tr><td class='smaller gray'><?=$this->T('实验访问')?></td></tr>
- <tr><td><?=$this->T('主机')?></td>
- <td><input type="text" form="settings_form" id='settings_exp_host' name='settings_exp_host'
- value='<?=$this->ExpHost?>'/></td></tr>
- <tr><td><?=$this->T('网站标题')?></td>
- <td><input type="text" form="settings_form" id='settings_exp_title' name='settings_exp_title'
- value='<?=$this->ExpTitle?>'/></td></tr>
- <tr><td><?=$this->T('短标题')?></td>
- <td><input type="text" form="settings_form" id='settings_exp_short_title' name='settings_exp_short_title'
- value='<?=$this->ExpShortTitle?>'/></td></tr>
- <tr><td><?=$this->T('首次提示')?><?=isset($this->ExpCaution)?"<a href='?post=".$this->ExpCaution."'>→</a>":""?></td>
- <td><input type="text" form="settings_form" id='settings_exp_caution' name='settings_exp_caution'
- value='<?=$this->ExpCaution?>'/></td></tr>
- <tr><td><?=$this->T('相册')?></td>
- <td><input type="text" form="settings_form" id='settings_exp_album' name='settings_exp_album'
- value='<?=$this->ExpAlbum?>'/></td></tr>
- <tr><td><?=$this->T('导航栏')?>
- <?=isset($this->ExpNavigation)?"<a href='?post=".$this->ExpNavigation."'>→</a>":""?></td>
- <td><input type="text" form="settings_form" id='settings_exp_navigation' name='settings_exp_navigation'
- value='<?=$this->ExpNavigation?>'/></td></tr>
- <tr><td><?=$this->T('脚注')?><?=isset($this->ExpFooter)?"<a href='?post=".$this->ExpFooter."'>→</a>":""?></td>
- <td><input type="text" form="settings_form" id='settings_exp_footer' name='settings_exp_footer'
- value='<?=$this->ExpFooter?>'/></td></tr>
- <tr><td><?=$this->T('允许选择语言')?>
- <td><input type="checkbox" id="settings_allow_language" name="settings_allow_language"
- form="settings_form" <?=$this->AllowLanguageChoices?"checked":""?>/></td></tr>
-
- <tr><td class='smaller gray'> </td></tr>
- <tr><td class='smaller gray'><?=$this->T('管理员')?></td><td class='smaller'>
- <a href='<?=$INDEXPHP?>?logout=true'><?=$this->T('登出')?></a></td></tr>
- <tr><td><?=$this->T('帐号')?></td>
- <td><input type="text" form="settings_form" id='settings_id' name='settings_id'
- value='<?=$this->Admin?>'/></td></tr>
- <tr><td><?=$this->T('新密码')?></td>
- <td><input type="password" form="settings_form"
- id='settings_new_password' name='settings_new_password' /></td></tr>
- <tr><td><?=$this->T('再次输入')?></td>
- <td><input type="password" form="settings_form"
- id='settings_new_password_redo' name='settings_new_password_redo' /></td></tr>
- <tr><td><?=$this->T('旧密码')?></td>
- <td><input type="password" form="settings_form" id='settings_old_password' name='settings_old_password' /></td></tr>
- <?php }else{ ?>
- <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='login_form'></form>
- <colgroup><col style='min-width:3em;'><col style='width:100%;min-width:5em;'></colgroup>
- <tr><td class='smaller gray'><?=$this->T('请登录')?></td></tr>
- <tr><td><?=$this->T('帐号')?></td>
- <td><input type="text" form="login_form" id='login_id' name='login_id' /></td></tr>
- <tr><td><?=$this->T('密码')?></td>
- <td><input type="password" form="login_form" id='login_password' name='login_password' /></td></tr>
- <?php } ?>
- </table>
- <?php if($this->LoggedIn){ ?>
- <input class='button' form="settings_form" type="submit" name='settings_button' value='<?=$this->T('保存设置')?>' />
- <?php }else{ ?>
- <input class='button' form="login_form" type="submit" name='login_button' value='<?=$this->T('登录')?>' />
- <?php } ?>
- </div>
- <?php
- }
- function MakeSubscribers(){ ?>
- <table><tbody><tr><td><?=$this->T("帖子")?></td><td><input type='text' id='mail_news_id' name='mail_news_id'></td></tr>
- <?php
- $subs=file_get_contents("all_subscribers.php");
- if(preg_match_all("/(.+)\s+\[\[\[(.*)\]\]\]/u",$subs,$ma,PREG_SET_ORDER)){
- foreach($ma as $m){ ?>
- <tr><td><a id="send<?=$m[1]?>" ondblclick="SendNews(this,'<?=$m[1]?>','<?=$m[2]?>')"><?=$this->T("发送");?></a></td>
- <td id="content<?=$m[1]?>"><?=$m[2];?></td><?php
- }
- } ?>
- </tbody></table><script>
- function copyElementToClipboard(element) {
- window.getSelection().removeAllRanges();
- let range = document.createRange();
- range.selectNode(element);
- window.getSelection().addRange(range);
- document.execCommand('copy');
- window.getSelection().removeAllRanges();
- }
- function SendNews(but,id,email){
- txt=document.querySelector("#mail_news_id"); if(!txt)return;
- post=txt.value; if(post=='') return;
- but.innerHTML = "<?=$this->T('稍等')?>"; but.ondblclick=null;
- var xhr = new XMLHttpRequest();
- function wrapidxhr(_id){ return function() {
- if (this.readyState == 4) {
- btn = document.querySelector('#send'+_id);
- if(this.status == 200){ btn.innerHTML="<?=$this->T('好')?>"
- //ctn = document.querySelector('#content'+_id);
- //ctn.innerHTML=this.responseText.trim();
- //copyElementToClipboard(ctn);
- //ctn.innerHTML="<?=$this->T('复制到剪贴板')?>";
- }else{ btn.innerHTML="<?=$this->T('问题')?>" }
- }
- }; };
- xhr.onreadystatechange = wrapidxhr(id)
- xhr.open("GET", "<?=$INDEXPHP?>?post="+post.toString()+'&send='+id.toString()+'&addr='+email.toString(), true);
- xhr.send();
- }
- </script><?php
- }
-
- function MakeExtraOperations(){ global $INDEXPHP; ?>
- <div class='settings' style='overflow:auto;'>
- <h2><?=$this->T('附加操作')?></h2>
- <a href='<?=$INDEXPHP?>?&settings=true'><?=$this->T('返回一般设置')?></a>
- <p> </p>
- <h3><?=$this->T('自动重定向')?></h3>
- <span class='smaller gray'>
- <?=$this->T('P为帖子跳转,匹配REQUEST_URI跳到目标文章;S为站点跳转,可以重定向来源域名,例子:')?>
- <br /><pre>P discount:20001001010101;<br />S old_domain:www.new_domain.com:20001001010101;</pre></span>
- <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form2'></form>
- <textarea id="settings_redirect" name="settings_redirect" rows="4" class='full_box' wrap="off"
- form='settings_form2'><?=$this->DisplayRedirectConfig()?></textarea>
- <input class='button' form="settings_form2" type="submit" name='settings_save_redirect'
- value='<?=$this->T('保存重定向设置')?>' />
- <p> </p>
- <h3><?=$this->T('自定义翻译')?></h3>
- <span class='smaller gray'>
- <?=$this->T('填写格式:')?>
- <br /><pre>- 语言 | Language</pre></span>
- <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form3'></form>
- <textarea id="settings_translation" name="settings_translation" rows="4" class='full_box' wrap="off"
- form='settings_form3'><?=$this->CustomTranslationContent?></textarea>
- <input class='button' form="settings_form3" type="submit" name='settings_save_translation'
- value='<?=$this->T('保存翻译')?>' />
- <?php if($this->NewsletterEnabled){
- $subs=file_get_contents("all_subscribers.php"); ?>
- <br /><br /><h3><?=$this->T('邮件订阅者')?></h3>
- <?php $this->MakeSubscribers(); ?>
- <?php } ?>
- <br />
- <p class='smaller gray'><?=$this->T('ActivityPub 测试:')?></p>
- <ul>
- <li><a href='?TestAPubDeliver=1'><?=$this->T('测试发送')?></a></li></ui>
- </ui>
- <br />
- <p class='smaller gray'><?=$this->T('当心!下列操作将立即执行:')?></p>
- <ul>
- <li><label for='opbtn0' class='ref_count'><?=$this->T('重新写入默认CSS')?></label><input type="checkbox" class='lpctrl' id='opbtn0' checked='checked'/>
- <a href='?rewrite_styles=true'>→</a></li>
- <li><label for='opbtn1' class='ref_count'><?=$this->T('重新生成图片缩略图')?></label><input type="checkbox" class='lpctrl' id='opbtn1' checked='checked'/>
- <a href='?regenerate_thumbnails=true'>→</a></li>
- <li><label for='opbtn2' class='ref_count'><?=$this->T('清理未压缩的图像')?></label><input type="checkbox" class='lpctrl' id='opbtn2' checked='checked'/>
- <a href='?cleanup_image_compression=true'>→</a></li>
- <li><label for='opbtn3' class='ref_count'><?=$this->T('删除所有登录')?></label><input type="checkbox" class='lpctrl' id='opbtn3' checked='checked'/>
- <a href='?clear_all_logins=true'>→</a></li>
- </ui>
- <br /><br /><br /><a href='?&settings=true'><?=$this->T('返回一般设置')?></a><br />
- </div>
- <?php
- }
-
- function MakeMainBegin(){?>
- <div class='main' <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
- ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"<?php } ?>>
- <?php
- }
- function MakeMainEnd(){?>
- </div>
- <?php
- }
-
- function MakeExpFooter(){
- $exptitle = isset($this->HereDisplayTitle)?('"'.trim($this->T($this->ChoosePartsByLanguage($this->HereDisplayTitle))).'"'):NULL;
- if(!isset($exptitle)) $exptitle=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle);?>
- <div class='small_footer exp_h_f exp_f'><div>
- <?php if($this->InExperimentalMode){ ?>
- <b><?=$exptitle?></b>
- <?php }else{ ?>
- <b><?=$exptitle?></b> ©<?=$this->T($this->DisplayName)?>
- <?php }?>
- <?=isset($this->HereMainImage)?("<a class='invert_a' href='?here=images/".$this->HereMainImage['name']."'>".$this->T("看全图")."</a>"):""; ?>
- <div class='wayback_link gray clean_a invert_a hidden_on_print'><br class="hidden_on_desktop" />
- <?php if($this->InExperimentalMode && isset($this->ExpFooter) && ($p = &$this->GetPost($this->ExpFooter,true))!=NULL){
- echo $this->GenerateSinglePost($p, false, false, false, false, false);
- }else if($this->InHereMode && isset($this->HereFooter) && ($p = &$this->GetPost($this->HereFooter,true))!=NULL){
- echo $this->GenerateSinglePost($p, false, false, false, false, false);
- }?></div>
- </div>
- </div>
- </div><!-- page -->
- </body>
- </html>
- <script>
- if(trans = document.getElementById('translate_button')){
- trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
- }
- </script>
- <?php
- }
-
- function MakeImageOverlay($side_info=null,$static_image=null,$static_video=null){
- $static=isset($side_info); ?>
- <div id='big_image_overlay' <?=$static?"":"style='display:none'";?>>
- <div class='big_image_box clean_a' onclick='HideBigImage(1)'>
- <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'><?=$this->T('请稍候')?></div>
- <?php if(!$static_video){ ?>
- <img id='big_image' onload="HideWaitingBar();" <?=isset($static_image)?("src='".$static_image."'"):""?>/><?php } ?>
- <?php if(!$static_image){ ?>
- <video id='big_video' onloadstart="HideWaitingBar();" controls><source id='big_video_src' type='video/mp4'
- <?=isset($static_video)?("src='".$static_video."'"):""?>></video><?php } ?>
- </div>
- <div class='big_side_box' onclick='HideBigImage(1);'>
- <?php if(!$static){ ?>
- <div class='big_image_box clean_a image_nav' onclick='HideBigImage(1)'>
- <div ><a id='prev_image' class='image_nav_prev img_btn_hidden' onclick="event.stopPropagation();">
- <div class='lr_buttons'>←</div></a></div>
- <div ><a id='next_image' class='image_nav_next img_btn_hidden' onclick="event.stopPropagation();">
- <div class='lr_buttons'>→</div></a></div>
- <div id='here_buttons'></div>
- </div><?php } ?>
- <div class='side_box_mobile_inner'>
- <?php if(!$static){ ?>
- <div class='inquiry_buttons img_btn_hidden' id='inquiry_buttons' onclick="event.stopPropagation();">
- <span style='display:none;' id='image_purchase' class='clean_a'>
- <b><a id='image_purchase_button' target="_blank">¥<?=$this->T('购买印刷品')?></a></b>
- <br class='hidden_on_desktop block_m' /></span>
- <b><a class='clean_a' id='image_download'><span id='download_processing'>↓</span><?=$this->T('下载')?></a></b>
- <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
- <a class='clean_a' id='image_inquiry'>
- <b>@</b><?=$this->T('咨询')?></a>
- <?php } ?><hr class='hidden_on_desktop block_m' />
- </div>
- <div id='big_image_share' class='clean_a' onclick="event.stopPropagation();">
- <li class='wayback_close'><a onclick='HideBigImage(1);'><?=$this->T('关闭')?> ×</a></li>
- <li><a id='big_share_copy'>⎘ <?=$this->T('复制链接')?></a></li>
- <hr />
- </div><?php } //static ?>
- <div id='big_image_info' onclick="event.stopPropagation();"><?=$static?$side_info:""?></div>
- <?php if($this->LoggedIn && !$static){ ?><div id='big_image_ops' onclick="event.stopPropagation();">
- <br /><?=$this->T('印刷品链接')?>
- <form action="" method="post" style='display:none;' id='image_ops_form'></form>
- <input type='text' id='image_ops_product_link' name='image_ops_product_link' form="image_ops_form" >
- <?=$this->T('重命名')?>
- <input type='text' id='image_edit_new_name' name='image_edit_new_name' form="image_ops_form" >
- <?=$this->T('主图')?>
- <input type='text' id='image_parent' name='image_parent' form="image_ops_form" >
- <?=$this->T('对齐')?> <select id='image_align' name='image_align' form="image_ops_form">
- <option value='top'><?=$this->T('顶部')?></option>
- <option value='middle'><?=$this->T('中间')?></option>
- <option value='bottom'><?=$this->T('底部')?></option></select><br />
- <input class='button' form="image_ops_form" type="submit" name='image_button' value=<?=$this->T('保存')?> />
- <br /><br /><?=$this->T('替换图像')?>
- <form action="" method="post" style='display:none;' id='image_edit_form' enctype="multipart/form-data"></form>
- <input type="file" form='image_edit_form'
- id='big_image_upload' name='upload_file_name' accept="image/x-png,image/png,image/gif,image/jpeg"/><br />
- <input class='button' form="image_edit_form" type="submit" name='image_replace_button'
- value=<?=$this->T('执行')?> />
- </div><?php } ?>
- </div>
- </div>
- </div>
- <?php }
-
- function MakePageEnd(){?>
- </div><!-- page -->
- </body>
- </html>
- <?php }
- function MakeFooter(&$p){ global $INDEXPHP;
- $is_slides=(isset($p['slides']) || (isset($p['tid'])&&isset($p['tid']['slides']))); $no_title=isset($p['tid']['first']['no_title']);?>
- <div class='small_footer'><div>
- <hr />
- <?php if(isset($p['tid']['footer'])){ ?><div class='show_on_print'><?=$p['tid']['footer'];?></div><?php } ?>
- <b<?=$no_title?" class='hidden_on_print'":"";?>><?=$this->T($this->Title)?></b>
- <span onclick='event.stopPropagation()'<?=$no_title?" class='hidden_on_print'":"";?>
- ondblclick='javascript:window.location.href="<?=$INDEXPHP?>?settings=true"'>©</span><?=$this->T($this->DisplayName)?>
- <div class='smaller show_on_print'><?=$_SERVER['SERVER_NAME']?><br /><?=$this->EMail?></div>
- </div></div>
- <div class='footer'>
- <div style='white-space:nowrap;'>
- <div class='footer_additional'>
- <?php if(isset($this->SpecialFooter) && ($p = &$this->GetPost($this->SpecialFooter))!=NULL){
- echo $this->GenerateSinglePost($p, false, false, false, false, false);
- } ?>
- </div>
- <div class='footer_additional'>
- <?php if(isset($this->SpecialFooter2) && ($p = &$this->GetPost($this->SpecialFooter2))!=NULL){
- echo $this->GenerateSinglePost($p, false, false, false, false, false);
- } ?>
- </div>
- </div>
- </div>
- <p> <p>
- <div id='dropping_background' style='display:none;' onclick='this.style.display="none";'
- ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);">
- <h2 style='width:100%;'><?=$this->T('上传到这里')?></h2>
- </div>
- <?php $this->MakeImageOverlay(); $this->MakePageEnd(); ?>
- <script>
- <?php if($is_slides){ ?>SlidesStart(null);<?php } ?>
- <?=$this->ExtraScripts?>
- if(back = document.getElementById('button_back')){
- if(document.referrer.indexOf(location.protocol + "//" + location.host) == 0){
- back.href='javascript:history.back()';
- }else{
- back.href='<?=$INDEXPHP?>';
- }
- }
- function copy_text(t) {
- ta = document.createElement('textarea'); document.body.appendChild(ta); ta.value = t; ta.select();
- document.execCommand("copy"); document.body.removeChild(ta);
- }
- if(trans = document.getElementById('translate_button')){
- trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
- }
- function ClickPost(p,e,pushstate){if(e)e.preventDefault();
- id=p.dataset.postId; if(!id)return; list=p.parentNode;active=list.getElementsByClassName('active_post');
- if(active&&active[0]&&active[0]!=p){
- if(pushstate){window.history.pushState('?post='+id,null,'?post='+id);}
- active[0].classList.remove('active_post'); p.classList.add('active_post');
- }
- if(!active[0]){ window.location.href="?post="+id; }
- }function InitLabel(){
- lb=document.querySelector('#mtitle'); lb.removeAttribute('for'); lb.onclick=function()
- {c=document.querySelector('#titlectrl');if(c.checked)c.checked=false;else c.checked=true;}
- lb=document.querySelectorAll('.bkg_section label');if(!lb||!lb[0])return;
- for(i=0;i<lb.length;i++){ lb[i].removeAttribute('for');lb[i].onclick=function()
- {c=this.parentNode.querySelector('.lpctrl');if(!c)return;if(c.checked)c.checked=false;else c.checked=true;} }
- }InitLabel();
- <?php if($this->LoggedIn){ ?>
- var Scenter = document.querySelector('.center');
- var Sposts = Scenter?Scenter.querySelectorAll('.post'):null;
- <?php if(isset($this->MastodonToken)){ ?>
- function MarkPostDoneMastodon(id,mastodon_url){
- for(var i=0;i<Sposts.length;i++){
- if(Sposts[i].dataset.postId==id){ Sposts[i].dataset.mastodon_url= mastodon_url; break;} }
- }
- <?php } ?>
- <?php if($this->PageType=='post' && !isset($this->WayBack)) { ?>
- var Smerge_post_dialog = Scenter.querySelector('#merge_post_dialog');
- var Smerge_post = Scenter.querySelector('#merge_post');
- var Smerge_post_count = Smerge_post_dialog.querySelector('#merge_post_count');
- var Smerge_post_btn = Scenter.querySelector('#merge_post_btn');
- var Smerge_cancel = Scenter.querySelector('#merge_cancel');
- var Smerge_select = Scenter.querySelector('#merge_select');
- var Smerge_thread_dialog = Scenter.querySelector('#merge_thread_dialog');
- var Smerge_thread = Scenter.querySelector('#merge_thread');
- var Smerge_thread_target = Scenter.querySelector('#merge_thread_target');
- var Smerge_thread_btn = Scenter.querySelector('#merge_thread_btn');
- var select_mode = false; var merge_mode = false; var selected_posts = null;
- function TogglePostSelectMode(force_on=false,force_off=false){
- Scenter.classList.add('post_selecting');
- if((!select_mode || force_on) && !force_off){ ToggleThreadMerge(false,true); Scenter.classList.add('post_selecting');
- Smerge_post_dialog.style.display="block";Smerge_post_btn.classList.add('text_highlight');
- Smerge_cancel.innerText='<?=$this->T("取消")?>'; select_mode = 1;}
- else{ select_mode = 0; Scenter.classList.remove('post_selecting');
- Smerge_post_dialog.style.display="none";Smerge_post_btn.classList.remove('text_highlight');
- Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
- for(var i=0;i<Sposts.length;i++){ Sposts[i].classList.remove('post_selected');
- Sposts[i].onclick=select_mode?function(){TogglePostSelect(this);}:null; }
- Smerge_post_count.innerText="0";
- Smerge_post.href="#";
- }
- function TogglePostSelect(elem){
- if(elem.classList.contains('post_selected')){ elem.classList.remove('post_selected'); }
- else{ elem.classList.add('post_selected'); }
- selected_posts = new Array();
- for(var i=0;i<Sposts.length;i++){ if(Sposts[i].classList.contains('post_selected')){
- selected_posts.push(Sposts[i].dataset.postId); } }
- Smerge_post.href="?merge_posts="+selected_posts.join(" ");
- Smerge_post_count.innerText=selected_posts.length;
- }
- function ThreadMergeInput(elem){
- if(elem.value.match(/[0-9]{14}/)) { Smerge_thread.href="?merge_threads=<?=$this->ActualPostID?> "+elem.value; }
- else{ Smerge_thread.href="#"; }
- }
- function ToggleThreadMerge(force_on=false,force_off=false){
- if((!merge_mode || force_on) && !force_off){ TogglePostSelectMode(false,true);
- Smerge_thread_dialog.style.display="block";Smerge_thread_btn.classList.add('text_highlight');
- Smerge_cancel.innerText='<?=$this->T("取消")?>'; merge_mode = 1;}
- else{ merge_mode = 0;
- Smerge_thread_dialog.style.display="none";Smerge_thread_btn.classList.remove('text_highlight');
- Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
- Smerge_thread.href="#";
- Smerge_thread_target.value='';
- }
- <?php } ?>
- function ShowSideUploader(){
- ShowRightSide(true,null);
- put = document.querySelector("#_uploader");
- put.style.display='block';
- RefreshSideGallery();
- }
- dmark = document.querySelector("#mark_details");
- drename = document.querySelector("#rename_details");
- dmastodon = document.querySelector("#mastodon_details");
- drename_form = document.querySelector("#post_rename_form");
- drename_input = document.querySelector("#post_rename_name");
- var rp = document.querySelector('#post_reply_to');
- var _reply_to = rp?rp.defaultValue:"";
- function RestoreReply(){
- if(rp){
- rp.defaultValue = _reply_to;
- }
- document.querySelector('#post_reply_restore').style.display='none';
- ht = document.querySelector('#post_hint_text');
- if (_reply_to!=""){
- ht.style.display='block';
- ht.innerHTML="<?=$this->T('继续补充该话题:')?>";
- }else{
- ht.style.display='none';
- }
- document.querySelector('#post_edit_target').value="";
- ch = document.querySelector('#post_hint_modify');
- ch.style.display='none';
- }
- function MakeRefer(id){
- t = document.querySelector('#post_content')
- t.focus();
- v = t.value;
- t.value = v.slice(0, t.selectionStart) + "[<?=$this->T('引用文章')?>]("+id.toString()+")" + v.slice(t.selectionEnd);
- la_auto_grow(t);
- if(rp){
- rp.defaultValue = "";
- ht = document.querySelector('#post_hint_text');
- ht.innerHTML = "<?=$this->T('引用并发送新话题:')?>"; ht.style.display='block';
- document.querySelector('#post_reply_restore').style.display='inline';
- rs = document.querySelector('#post_reply_restore');
- rs.style.display='inline'; rs.innerHTML="<?=$this->T('切换为回复')?>";
- document.getElementById('post_menu').style.display='none';
- ch = document.querySelector('#post_hint_modify');
- ch.style.display='none';
- }
- }
- function CopyRefer(id){
- copy_text(id.toString());
- menu.querySelector('#menu_refer_copy').innerHTML="<?=$this->T('已复制')?>";
- }
- function MakeEdit(id){
- ed = document.getElementById('menu_edit');
- ed.innerHTML="<?=$this->T('稍等')?>";
- ed.href="#";
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- ed.innerHTML='——';
- ch = document.querySelector('#post_hint_modify');
- ch.style.display='block';
- ht = document.querySelector('#post_hint_text');
- ht.innerHTML = "<?=$this->T('修改帖子:')?>";
- rs = document.querySelector('#post_reply_restore');
- rs.style.display='inline'; rs.innerHTML="<?=$this->T('取消')?>";
- t = document.querySelector('#post_content');
- t.value=xhr.responseText.trim();
- t.focus();
- la_auto_grow(t);
- document.querySelector('#post_edit_target').value=id;
- document.getElementById('post_menu').style.display='none';
- }
- };
- xhr.open("GET", "<?=$INDEXPHP?>?post="+id.toString()+'&post_original=true', true);
- xhr.send();
- }
- function MarkDelete(id){
- p = document.querySelector('[data-post-id="'+id+'"]');
- op = p.dataset.markDelete?"false":"true";
- window.location.href=
- "<?=$INDEXPHP?>?<?=$this->GetRedirect()?>&mark_delete="+op+'&target='+id.toString();
- }
- function SetMark(mark){
- menu = document.getElementById('post_menu');
- window.location.href=
- "<?=$INDEXPHP?>?<?=$this->GetRedirect()?>&target="+
- menu.parentNode.dataset.postId+"&set_mark="+mark;
- }
- function ToggleMarkDetails(){
- dmark.style.display=(dmark.style.display=='block')?'none':'block';
- drename.style.display=dmastodon.style.display='none';
- }
- function ToggleRenameDetails(){
- drename.style.display=(drename.style.display=='block')?'none':'block';
- dmark.style.display=dmastodon.style.display='none';
- }
- function ToggleMastodonDetails(){
- dmastodon.style.display=(dmastodon.style.display=='block')?'none':'block';
- dmark.style.display=drename.style.display='none';
- }
- <?php } if(isset($_GET['post'])){ ?> ScrollToPost("<?=$_GET['post']?>"); <?php } ?>
- function ShowPostMenu(post){
- menu = document.getElementById('post_menu');
- menu.style.display='block';
- menu.parentNode.removeChild(menu);
- post.appendChild(menu);
- menu.style.display='block';
- id = post.dataset.postId
- menu.querySelector('#_time_hook').innerHTML = ''+id.substring(2,4)+'/'+id.substring(4,6)+'/'+id.substring(6,8)+
- ' '+id.substring(8,10)+':'+id.substring(10,12);
- window.onClick="HidePopMenu()";
- menu.onClick=(function(event){
- event.stopPropagation();
- });
- hs = menu.querySelector('#menu_history');
- hs.href='?post='+id+'&history=1';
- <?php if($this->LoggedIn && !isset($this->WayBack)){ ?>
- <?php if($this->PageType!='search'){?>
- menu.querySelector('#menu_refer').href='javascript:MakeRefer(id)';
- ed = menu.querySelector('#menu_edit');ed.href='javascript:MakeEdit(id)'; ed.innerHTML="<?=$this->T('修改')?>";
- <?php } ?>
- ref = menu.querySelector('#menu_refer_copy')
- ref.innerHTML='<?=$this->T("复制编号")?>';
- ref.href='javascript:CopyRefer(id)';
- d = menu.querySelector('#menu_delete');
- d.href='javascript:MarkDelete(\"'+id+'\")';
- p = document.querySelector('[data-post-id="'+id+'"]');
- d.innerHTML = p.dataset.markDelete?"<?=$this->T('恢复')?>":"<?=$this->T('删除')?>";
- menu.querySelector('#mark_details').dataset.id=id;
- drename_input.value=id;
- drename_form.action="<?=$this->GetRedirect()?>"+"&rename_post="+id;
- <?php if(isset($this->MastodonToken)){ ?>
- dmastodon_form = document.querySelector("#post_mastodon_form");
- dmastodon_form.action='?mastodon_post='+id;
- function MastodonSend(id){
- mastodon_send.innerHTML="<?=$this->T('稍等')?>";
- var xhr = new XMLHttpRequest();
- function wrapidxhr(_id) { return function() {
- if (this.readyState == 4 && this.status == 200) {
- var response = xhr.responseText;
- let content="";
- if(res = response.match(/SUCCESS (\S+)/u)){
- content="<?=$this->T('成功发送到长毛象')?>";
- }else{content="<b><?=$this->T('出现问题')?></b><br /><span class='smaller'>"+response+"</span>";}
- mastodon_send.innerHTML=content; mastodon_send.href=res[1];
- MarkPostDoneMastodon(_id, res[1]);
- } }
- };
- xhr.onreadystatechange = wrapidxhr(id);
- xhr.open("GET", "<?=$INDEXPHP?>?mastodon_send_post="+id, true); xhr.send();
- }
- menu_mastodon = menu.querySelector("#menu_mastodon");
- mastodon_send = menu.querySelector("#menu_mastodon_send");
- mastodon_view = menu.querySelector("#menu_mastodon_view");
- mastodon_url = menu.querySelector("#post_mastodon_url");
- if(p.dataset.mastodon_url){mastodon_view.style.display='inline';mastodon_view.href=p.dataset.mastodon_url;
- mastodon_send.innerHTML='<?=$this->T("重新发送")?>'; mastodon_url.value=p.dataset.mastodon_url; }
- else{mastodon_view.style.display='none';mastodon_view.href=""; mastodon_send.innerHTML="<?=$this->T('发送')?>";
- mastodon_url.value="";}
- mastodon_send.onclick=function(){
- this.onclick=function(){};
- MastodonSend(id); };
- <?php } } ?>
-
- title = document.title;
- copy = document.getElementById('share_copy');
- copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
- copy.addEventListener("click", function(){
- url = window.location
- path = location.pathname
- copy_text(url.protocol+"//"+url.host+path+"?post="+id);
- this.innerHTML='✓︎ <?=$this->T("复制链接")?>';
- });
- }
- function HidePopMenu(){
- var menus = document.querySelectorAll('.pop_menu');
- [].forEach.call(menus, function(m){m.style.display='none';});
- }
- var posts = document.querySelectorAll('.main>.center>tbody>.post'); if(!posts || !posts[0]) posts = document.querySelectorAll('.center_slides .post');
- [].forEach.call(posts, function(p){
- if(s=p.querySelector('._menu_hook')) s.addEventListener("click", function() {
- ShowPostMenu(this.parentNode.parentNode);
- if(document.querySelector('.clickable_section')!=null) ClickPost(this.parentNode.parentNode,null,true)
- });
- p.addEventListener("dblclick", function(){ ClickPost(this,null,true); lp=this.querySelector('.lpctrl'); if(lp){ if(lp.checked)lp.checked=false;else lp.checked=true; }});
- });
- //var post_clickables = document.querySelectorAll('.center .post a');
- //[].forEach.call(post_clickables, function(p){
- // p.addEventListener("click", function(event){
- // event.stopPropagation();
- // });
- //});
-
- function FindImage(imgsrc){
- for(var i=0;i<document.images_filtered.length;i++){
- if (document.images_filtered[i].dataset.imgsrc==imgsrc) return document.images_filtered[i]
- }
- return null
- }
-
- var dottime1;
- var dottime2;
-
- function ToDataURL(url) {
- return fetch(url).then((response) => {return response.blob();}).then(blob => {
- clearTimeout(dottime1);clearTimeout(dottime2);
- ps = document.querySelector('#download_processing');
- ps.innerHTML='↓';ps.style.opacity='';
- return URL.createObjectURL(blob);});
- }
- async function DownloadAsImage(url,name) {
- const a = document.createElement("a"); a.href = await ToDataURL(url); a.download = name;
- document.body.appendChild(a); a.click(); document.body.removeChild(a);
- }
- function basename(url){return url.split(/[\\/]/).pop();}
-
- pushed=0;
- function ShowBigImage(imgsrc,do_push){
- ShowWaitingBar();
- share = document.querySelector('#big_image_share');
- img = document.querySelector('#big_image');
- vid = document.querySelector('#big_video');
- vidsrc = document.querySelector('#big_video_src');
- down = document.querySelector('#image_download');
- img.src = ""; vidsrc.src="";
- if(imgsrc.match(/\.mp4$/)){
- vidsrc.src = src = "images/"+imgsrc; img.style.display='none'; vid.load();vid.style.display='block';
- }else{
- img.src = src = "images/"+imgsrc; vid.style.display='none';img.style.display='block';
- }
- down.href="images/"+imgsrc;
- var downname='<?=$this->T($this->Title);?>_<?=$this->T($this->DisplayName);?>_<?=$this->GiveSafeEMail()?>_'+
- basename(down.href);
- img.alt = downname; down.download=downname;
- var use_href = "images/"+imgsrc;
-
- down.onclick=function(event){event.stopPropagation();event.preventDefault();
- ps = this.querySelector('#download_processing');ps.innerText='…';
- var dotwait = function(ps){ var self = this;
- dottime1 = setTimeout(function(ps){
- ps.style.opacity='0'; dottime2 = setTimeout(function(ps){ps.style.opacity='1'; dotwait(ps);},300,ps); },300,ps) }
- dotwait(this.querySelector('#download_processing'));
- DownloadAsImage(use_href,downname);};
-
- if(do_push){PushGalleryHistory(src)}
-
- page_url = encodeURIComponent(window.location.href);
-
- <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
- inqb = document.querySelector('#image_inquiry');
- inqb.href="mailto:<?=$this->T($this->DisplayName);?>\<<?=$this->EMail?>\>?subject=<?=$this->T('网站图片咨询');?>&body="+
- encodeURIComponent("<?=$this->T('你好!我对你网站上的这张图片感兴趣:')?>"+'\n\n')+
- (page_url)+encodeURIComponent('\n\n');
- <?php } ?>
-
- this_image = FindImage(imgsrc);
- if(this_image&&this_image.dataset.prevsrc){
- new_image = FindImage(this_image.dataset.prevsrc);
- new_prev = new_image?new_image.dataset.prevsrc:null;
- im = document.querySelector('#prev_image');
- if(new_prev) {im.href='javascript:ShowBigImage("'+this_image.dataset.prevsrc+'",'+do_push+')';im.style.opacity='';}
- else {im.style.opacity='0';im.removeAttribute("href");}
- }
- if(this_image&&this_image.dataset.nextsrc){
- new_image = FindImage(this_image.dataset.nextsrc);
- new_next = new_image?new_image.dataset.nextsrc:null;
- im = document.querySelector('#next_image');
- if(new_next) {im.href='javascript:ShowBigImage("'+this_image.dataset.nextsrc+'",'+do_push+')';im.style.opacity='';}
- else {im.style.opacity='0';im.removeAttribute("href");}
- }
- purchase = document.querySelector('#image_purchase');
- purchase_btn = document.querySelector('#image_purchase_button');
- <?php if($this->LoggedIn){ ?>
- product_link = document.querySelector('#image_ops_product_link');
- product_form = document.querySelector('#image_ops_form');
- edit_form = document.querySelector('#image_edit_form');
- edit_new_name = document.querySelector('#image_edit_new_name');
- edit_parent = document.querySelector('#image_parent');
- edit_align = document.querySelector('#image_align');
- product_form.action = window.location.href;
- edit_form.action = window.location.href;
- edit_new_name.value = imgsrc.split('.')[0];
- if(this_image){
- if(this_image.dataset.product){ product_link.value = this_image.dataset.product; }else{ product_link.value = ""; }
- if(this_image.dataset.parent){ edit_parent.value = this_image.dataset.parent; }else{ edit_parent.value = ""; }
- if(this_image.dataset.align){ edit_align.value = this_image.dataset.align; }else{ edit_align.value = "middle"; }
- }
- <?php } ?>
- if(this_image&&this_image.dataset.product){
- purchase.style.display='';
- href = this_image.dataset.product;
- if(this_image.dataset.product.match('^[0-9]{14}$')){
- href = '?post='+href;
- }
- purchase_btn.href = href;
- }else{
- purchase.style.display='none';
- purchase_btn.removeAttribute("href");
- }
-
- DelayHideImgBtn(null);
-
- title = encodeURIComponent(document.title);
- copy = document.getElementById('big_share_copy');
- copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
- copy.addEventListener("click", function(){
- copy_text(window.location.href);
- this.innerHTML='✓︎ <?=$this->T("复制链接")?>';
- });
-
- o = document.querySelector('#big_image_overlay');
- info = document.querySelector('#big_image_info');info.innerHTML="<?=$this->T('正在查询……')?>";
- here = document.querySelector('#here_buttons');here.innerHTML='';
- o.style.display="block";
- ShowBackdrop(0.8);
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- info = document.querySelector('#big_image_info');
- var response = xhr.responseText;
- let content=""
- if(res = response.match(/<ref>(.*)<\/ref>/u)){
- content="<span class='small'><?=$this->T('该图片出现在')?> "+res[1]+" <?=$this->T('个帖子中')?></span>"+content;
- }else{content="<span class='smaller gray'><?=$this->T('该图片未被引用')?></span>"+content;}
- if(res = response.match(/<insert>([\s\S]*)<\/insert>/u)){ content+=res[1]; }
- info.innerHTML=content;
- if(res = response.match(/<here>([\s\S]*)<\/here>/u)){
- here.innerHTML=res[1]; window.here_b=document.getElementsByClassName('here_btn');
- if(window.here_b)for(b=0;b<window.here_b.length;b++) {
- window.here_b[b].addEventListener('mousemove',DontHideImgBtn);
- window.here_b[b].addEventListener('mouseover',DontHideImgBtn);}
- }
- }
- };
- xhr.open("GET", "<?=$INDEXPHP?>?image_info="+imgsrc+"", true);
- xhr.send();
- }
- function HideBigImage(do_push){
- o = document.querySelector('#big_image_overlay');
- img = document.querySelector('#big_image');
- vid = document.querySelector('#big_video');
- vidsrc = document.querySelector('#big_video_src');
- img.src = ""; vidsrc.src="";
- if(o.style.display!='none'){
- o.style.display="none";
- HideBackdrop();
- if(do_push){PushGalleryHistory("");}
- HideWaitingBar();
- }
- }
- var lbtn=document.querySelector('#prev_image'),rbtn=document.querySelector('#next_image');
- var inq=document.querySelector('#inquiry_buttons');
- var overlay=document.querySelector('#big_image_overlay');
- var hide_timeout;
- function DontHideImgBtn(e){ clearTimeout(hide_timeout); e.stopPropagation(); }
- function DelayHideImgBtn(e){
- lbtn.classList.remove('img_btn_hidden'); rbtn.classList.remove('img_btn_hidden');
- inq.classList.remove('img_btn_hidden');
- if(window.here_b)for(b=0;b<window.here_b.length;b++){window.here_b[b].classList.remove('img_btn_hidden');}
- clearTimeout(hide_timeout);
- hide_timeout = setTimeout(function(e1,e2,e3,e4){e1.classList.add('img_btn_hidden');
- e2.classList.add('img_btn_hidden');e3.classList.add('img_btn_hidden');
- if(window.here_b)for(b=0;b<window.here_b.length;b++){
- window.here_b[b].classList.add('img_btn_hidden');}}, 1000, lbtn, rbtn, inq);
- }
- lbtn.addEventListener('mousemove',DontHideImgBtn);lbtn.addEventListener('mouseover',DontHideImgBtn);
- rbtn.addEventListener('mousemove',DontHideImgBtn);rbtn.addEventListener('mouseover',DontHideImgBtn);
- inq.addEventListener('mousemove',DontHideImgBtn);inq.addEventListener('mouseover',DontHideImgBtn);
- overlay.addEventListener('mousemove',DelayHideImgBtn);
- function UpdateImageClickables(){
- var images = document.querySelectorAll('.center img, .center video, .center_wide img, .center_wide video');
- var images_filtered=new Array(); var imgadded = new Array();
- var images_remaining=new Array();
- [].forEach.call(images, function(img){
- if(img.classList.contains("no_pop") || (!(imgsrc = img.dataset.imgsrc))) return;
- if(imgadded.indexOf(imgsrc)>=0) {images_remaining.push(img); return;}
- images_filtered.push(img);imgadded.push(imgsrc);
- });
- for(var i=0; i<images_filtered.length; i++){
- previmg = nextimg = null; img = images_filtered[i];
- if(i>0) previmg=images_filtered[i-1];
- if(i<images_filtered.length-1) nextimg=images_filtered[i+1];
- prevsrc=previmg?previmg.dataset.imgsrc:null; nextsrc=nextimg?nextimg.dataset.imgsrc:null;
- img.dataset.prevsrc = prevsrc; img.dataset.nextsrc = nextsrc;
- function wrap(imgsrc){return function(event){ShowBigImage(imgsrc, 1);}}
- var clone = img.cloneNode(true); img.replaceWith(clone);
- clone.addEventListener("click", wrap(img.dataset.imgsrc));
- }
- for(var i=0; i<images_remaining.length; i++){
- img = images_remaining[i];
- function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
- var clone = img.cloneNode(true); img.replaceWith(clone);
- clone.addEventListener("click", wrap(img.dataset.imgsrc));
- }
- document.images_filtered = images_filtered;
- }
- UpdateImageClickables();
- function PopGalleryHistory(){
- if(pushed){
- pushed = 0;
- try{
- history.back();
- }catch{
- console.log("can't do it.");
- }
- }
- }
- function PushGalleryHistory(src){
- abs_img = window.location.protocol+"//"+window.location.host+'/'+src
- title = "照片"
- extra = "?";
- sp = new URLSearchParams(window.location.search)
- if(sp.has('post')){extra+="post="+sp.get('post')}
- if(sp.has('gallery')){extra+="&gallery="+sp.get('gallery')}
- try{
- window.history.pushState('&pic='+src, 'Title', extra+'&pic='+src);
- }catch{
- console.log("can't do it.");
- }
- pushed = 1;
- }
- document.addEventListener('keydown', function(e){
- large = document.getElementById('big_image_overlay')
- if (large.style.display!='block') return;
- if(e.key=='Escape'||e.key=='Esc'||e.keyCode==27){
- HideBigImage(1);
- }
- }, true);
- window.addEventListener('popstate', (event) => {
- href=window.location.href;
- let sp = new URLSearchParams(href.substring(href.indexOf('?')))
- if(sp.has('pic')){
- src = sp.get('pic')
- if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)) ShowBigImage(onlyimg[0], 0);
- else{HideBigImage(0);}
- }else{HideBigImage(0);}
- if(sp.has('post')){
- id=sp.get('post');post=document.querySelector('.post[data-post-id="'+id+'"]');
- if(post){ClickPost(post,null,false);}
- }
- });
-
- let searchParams = new URLSearchParams(window.location.search)
- if(searchParams.has('pic')){
- src = searchParams.get('pic')
- if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)){
- ShowBigImage(onlyimg[0], 1);
- }
- }
- function _dropHandler(event){ if (typeof dropHandler === "function") dropHandler(event); }
- function _dragOverHandler(event){ if (typeof dragOverHandler === "function") dragOverHandler(event); }
- </script>
- </body>
- <?php
- }
-
- function DoIdentifyExperimental(){
- if(isset($this->ExpHost) && $this->ExpHost && preg_match('/'.preg_quote($this->ExpHost).'/u', $_SERVER['HTTP_HOST'])){
- $this->InExperimentalMode=True; $this->InHereMode=True;
- if(!$this->AllowLanguageChoices){ $this->LanguageAppendix='en'; }
- }
- if(isset($this->HereHost) && $this->HereHost && preg_match('/'.preg_quote($this->HereHost).'/u', $_SERVER['HTTP_HOST'])){
- $this->InHereMode=True;
- }
- //$this->InHereMode=True;
- }
- function DoExperimentalTopLink($p){
- if($this->InHereMode && $p){
- if(isset($p['tid']) && $p['tid']['first']!=$p){
- header('Location: ?post='.$p['tid']['first']['id']); exit();
- }
- }
- }
- function MakeExperimentalConfirm(){ global $INDEXPHP;
- if(isset($_COOKIE['la_experimental']) && $_COOKIE['la_experimental'] == 'confirmed'){
- return false;
- }
- $caution_html =
- $confirm = "<a class='text_highlight clean_a bold' href='".$INDEXPHP."?confirm_enter=1".
- (isset($this->CurrentPostID)?("&post=".$this->CurrentPostID):"").
- "'> ".$this->T('继续')." </a>";
- ?>
- <div class='center_exp'><?php
- if(isset($this->ExpCaution) && ($p=$this->GetPost($this->ExpCaution,true)))$this->MakeSinglePostExp($p);
- else echo "<li class='post post_dummy'>".$this->TranslatePostParts("<h1>注意</h1><p>您将进入实验站。</p>")."</li>";
- ?></div>
- <div class='center_exp'><li class='post post_dummy'><p><?=$confirm?></p></li></div>
- <?php return true;
- }
- }
- $la = new LA;
- $la->DoSiteRedirect();
- $la->DoLogin();
- $la->SwitchLanguageAndFont();
- $err = $la->ProcessRequest($message, $redirect);
- $la->WriteAsNecessary();
- $la->DoIdentifyExperimental();
- $la->SwitchWayBackMode();
- if($err){
- echo $message;
- exit();
- }
- if(isset($redirect)){
- header('Location: '.$redirect);
- exit();
- }
- $la->DetectPageType();
- $la->ReadImages(false);
- $la->ReadPosts();
- if(isset($la->WayBack)){
- $la->ReadArchive();
- }
- $im = NULL;
- if(isset($la->HereID) && preg_match('/images\/(.*)/u',$la->HereID,$imname) && ($im = &$la->FindImage($imname[1]))){
- if(!$la->CanShowImage($im)) { $im=&$la->NULL_IMAGE; }
- }
- $p = &$la->GetPost($la->CurrentPostID);
- if(!isset($p)){
- $p = &$la->GetMergedPost($la->CurrentPostID);
- }
- if(isset($p) && !$la->CanShowPost($p)) $p=NULL;
- else{ $la->DoExperimentalTopLink($p); }
- if(isset($p)){ $la->ActualPostID = $p['id']; }
- if($la->PageType=='here' ||$la->PageType=='experimental'){
- if($im){
- $la->SetHereMainImage($im);
- $la->RecordVisitedHere($im['name'],$im?$la->ImageTitle($im):NULL);
- }else if($p){
- $la->RecordVisitedHere($p['id'],NULL);
- }else {
- $im = &$la->GiveImageInHere(false);
- if($im){
- $la->SetHereMainImage($im);
- $la->RecordVisitedHere($im['name'],$la->ImageTitle($im));
- }
- }
- }
- $la->MakeHeader($p);
- $la->MakeMainBegin();
- if($la->PageType=='here' ||$la->PageType=='experimental'){
- if(($la->PageType=='experimental' && (!$la->MakeExperimentalConfirm())) || $la->PageType=='here'){
- if($im){
- $la->MakeHereSection($im);
- }else if($p){
- $la->MakePostSectionExp($p);
- $la->MakeLinkedPostsExp($p);
- }else {
- if($im){
- $la->MakeHereSection($im);
- }else{
- echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
- "</p><p><a href='".$INDEXPHP."'>".$la->T('返回首页')."</a></p><br />";
- }
- }
- }
- $la->MakeMainEnd();
- $la->MakeExpFooter();
- }else{
- if($la->PageType=='extras'){
- $la->MakeExtraOperations();
- }else if($la->PageType=='settings'){
- $la->MakeSettings();
- }else if($la->PageType=='gallery'){
- $la->MakeGalleryLeft();
- $la->MakeGallerySection();
- }else if($la->PageType=='post'){
- if($p){
- $made_interesting = false;
- if($la->IsInterestingPost($p)){
- $la->MakeInterestingSection($p['tid']);
- }
- else{
- $la->MakeSidebar();
- $la->MakePostSectionV2($p);
- echo $la->GeneratePage(1," section");
- //$la->MakePostSection($p);
- }
- }else{
- echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
- "</p><p><a href='".$INDEXPHP."'>".$la->T('返回首页')."</a></p><br />";
- }
- }else if($la->PageType=='history'){
- $la->ReadArchive();
- $la->MakePostHistory($p, $_GET['version']??NULL);
- }else if($la->PageType=='search'){
- $la->MakeSidebar();
- $la->MakeRecentPostsV2($_GET['search']);
- echo $la->GeneratePage();
- }else if($la->PageType=='category'){
- $la->MakeSidebar();
- $la->MakeRecentPostsV2(NULL,$_GET['category']);
- echo $la->GeneratePage();
- }else if($la->PageType=='comments'){
- $la->MakeCommentPosts();
- }else if($la->PageType=='statistics'){
- $la->MakeStatistics();
- }else{
- $la->MakeSidebar();
- $la->MakeRecentPostsV2();
- echo $la->GeneratePage();
- }
- $la->MakeMainEnd();
- $la->MakeFooter($p);
- }
- ?>
|