*/}}

index.php 352 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036
  1. <?php
  2. include 'Parsedown.php';
  3. include 'ParsedownExtra.php';
  4. ini_set('max_execution_time', 300);
  5. if($_SERVER['HTTP_HOST']=='localhost'){
  6. ini_set('display_errors', '0');
  7. ini_set('display_startup_errors', '1');
  8. error_reporting(E_ALL);
  9. }
  10. global $LA_GLOBAL_LANG;
  11. global $INDEXPHP;
  12. $INDEXPHP='index.php';
  13. if($LA_GLOBAL_LANG=='en'){
  14. $INDEXPHP='en.php';
  15. }
  16. class LA{
  17. protected $PDE;
  18. protected $style;
  19. public $PAGE;
  20. public $AFTER;
  21. public $PSTACK;
  22. protected $PNUMBER;
  23. /* config */
  24. protected $Title;
  25. protected $ShortTitle;
  26. protected $Admin;
  27. protected $Password;
  28. protected $DisplayName;
  29. protected $EMail;
  30. protected $SpecialNavigation;
  31. protected $SpecialSidebar;
  32. protected $SpecialFooter;
  33. protected $SpecialFooter2;
  34. protected $SpecialPinned;
  35. protected $SpecialPinnedNotes;
  36. protected $DefaultGallery;
  37. protected $SelfAuthPath;
  38. protected $HereHost;
  39. protected $HereTitle;
  40. protected $HereShortTitle;
  41. protected $HereAlbum;
  42. protected $HereNavigation;
  43. protected $HereFooter;
  44. protected $ExpHost;
  45. protected $ExpAlbum;
  46. protected $ExpTitle;
  47. protected $ExpShortTitle;
  48. protected $ExpCaution;
  49. protected $ExpNavigation;
  50. protected $ExpFooter;
  51. protected $CommentEnabled;
  52. protected $MastodonToken;
  53. protected $MastodonURL;
  54. protected $MastodonPreferredLang;
  55. protected $HostURL;
  56. protected $GalleryStep;
  57. protected $AllowLanguageChoices;
  58. protected $Redirect;
  59. protected $Translations;
  60. protected $CustomTranslationContent;
  61. protected $CommentsPerPage;
  62. protected $UsePosts;
  63. protected $CurrentOffset;
  64. protected $PostsPerPage;
  65. protected $HotPostCount;
  66. protected $LoggedIn;
  67. protected $LoginTokens;
  68. protected $InHereMode;
  69. protected $InExperimentalMode;
  70. protected $LanguageAppendix;
  71. protected $UseRemoteFont;
  72. protected $NotesView;
  73. protected $Posts;
  74. protected $Threads; // [ keys: first last displayed count]
  75. protected $WaybackThreads;
  76. public $Images;
  77. protected $Galleries;
  78. protected $Anchors;
  79. protected $ArchiveHandles;
  80. protected $Archive;
  81. public $WayBack;
  82. protected $YearBegin;
  83. protected $YearEnd;
  84. protected $Markers;
  85. protected $ExtraScripts;
  86. protected $APubID;
  87. protected $APubActor;
  88. protected $APubPublicKey;
  89. protected $APubPrivateKey;
  90. protected $TIME_STRING;
  91. public $NULL_POST;
  92. public $NULL_IMAGE;
  93. public $NULL_IMAGE_DUMMY;
  94. public $NULL_Gallery;
  95. protected $DoneReadPosts;
  96. protected $DoneReadImages;
  97. protected $DoneReadArchive;
  98. protected $NeedWritePosts;
  99. protected $NeedWriteImages;
  100. protected $NeedWriteArchive;
  101. protected $HereDisplayTitle;
  102. protected $VisitedHere;
  103. protected $HereNumber;
  104. protected $HereMainImage;
  105. public $PageType;
  106. public $CurrentPostID;
  107. public $HereID;
  108. public $ActualPostID;
  109. public $TagID;
  110. function &_TRow(){ if(!isset($this->PAGE)){$this->PAGE=[];} if(!isset($this->PAGE[0])){$this->PAGE[]=[];} return $this->PAGE[array_key_last($this->PAGE)]; }
  111. function &TRow(){ $last=array_key_last($this->PAGE); if($this->PAGE[$last]==[]) return $this->PAGE[$last]; $this->PAGE[]=[]; return $this->PAGE[$last]; }
  112. function TFill($k,&$content,$span=null){ $a=&$this->_TRow();if(!isset($a[$k]))$a[$k]="";$a[$k].=$content; $content=''; if($span!=null && $span>1){ $a['span'.$k]=$span; } }
  113. function TExtra($rowextra){ $a=&$this->_TRow(); $a['extra']=$rowextra; }
  114. function TAfter(&$content){ $this->AFTER.=$content; $content=''; }
  115. function TBackup(){ if(!isset($this->PSTACK)){$this->PSTACK=[];}; $this->PSTACK[]=$this->PAGE; $this->PAGE=[]; }
  116. function TRestore($extra=""){ if(!isset($this->PSTACK) || $this->PSTACK==[]) return "";
  117. $S=$this->GeneratePage(0,$extra); $this->PAGE=end($this->PSTACK); unset($this->PSTACK[array_key_last($this->PSTACK)]); return $S;
  118. }
  119. function ReadableTime($id){
  120. $dt = DateTime::createFromFormat('YmdHis', $id);
  121. return $dt->format('Y/m/d H:i:s');
  122. }
  123. function StandardTime($id){
  124. $dt = DateTime::createFromFormat('YmdHis', $id);
  125. return $dt->format('Y-m-d\TH:i:sP');
  126. }
  127. function FullURL(){
  128. return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?
  129. "https" : "http") . "://" . $_SERVER['HTTP_HOST'] .
  130. $_SERVER['REQUEST_URI'];
  131. }
  132. function T($str){
  133. if(!$this->LanguageAppendix) return $str;
  134. foreach($this->Translations as $entry){
  135. if($entry['zh']==$str)
  136. return $entry[$this->LanguageAppendix];
  137. }
  138. return $str;
  139. }
  140. function SwitchLanguageAndFont(){ global $LA_GLOBAL_LANG;
  141. $this->LanguageAppendix = 'zh';
  142. if(isset($_COOKIE['la_language'])){
  143. $this->LanguageAppendix = $_COOKIE['la_language'];
  144. }else{
  145. if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
  146. $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  147. $lang = substr($lang,0,5);
  148. if(preg_match("/zh/i",$lang))$this->LanguageAppendix = 'zh';
  149. else $this->LanguageAppendix = 'en';
  150. }
  151. }
  152. if(isset($LA_GLOBAL_LANG)){
  153. if($LA_GLOBAL_LANG=='en'){ $this->LanguageAppendix = 'en'; setcookie('la_language','en',time()+3600*24*7,'/'); }
  154. else if($LA_GLOBAL_LANG=='zh'){ $this->LanguageAppendix = 'zh'; setcookie('la_language','zh',time()+3600*24*7,'/'); }
  155. }
  156. if(isset($_COOKIE['la_font'])){
  157. $this->UseRemoteFont = ($_COOKIE['la_font']!='local');
  158. }
  159. if($this->LoggedIn && isset($_COOKIE['la_notes_view'])){ $this->NotesView=$_COOKIE['la_notes_view']; }
  160. }
  161. function SwitchWayBackMode(){
  162. if(isset($_COOKIE['la_wayback'])){
  163. $this->WayBack = $_COOKIE['la_wayback'];
  164. }else $this->WayBack = NULL;
  165. }
  166. function DisplayRedirectConfig(){
  167. $s = "";
  168. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  169. if($r['for']=='P'){
  170. $s.=("P ".$r['format'].":".$r['target'].";".PHP_EOL);
  171. }else if($r['for']=='S'){
  172. $s.=("S ".$r['format'].":".$r['domain'].":".$r['target'].";".PHP_EOL);
  173. }
  174. }
  175. return $s;
  176. }
  177. function DoSiteRedirect(){ global $INDEXPHP;
  178. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  179. if($r['for']=='S'){
  180. if(preg_match('/'.$r['format'].'/ui', $_SERVER['HTTP_HOST'])){
  181. if($_SERVER['REQUEST_URI']=='/'||$_SERVER['REQUEST_URI']==''){
  182. header('Location:https://'.$r['domain'].'/'.$INDEXPHP.'?post='.$r['target']); exit;
  183. }else{
  184. header('Location:https://'.$r['domain'].$_SERVER['REQUEST_URI']); exit;
  185. }
  186. }
  187. }
  188. }
  189. }
  190. function WriteHTACCESS(){
  191. $conf = fopen('.htaccess','w');
  192. fwrite($conf,"RewriteEngine on".PHP_EOL.PHP_EOL);
  193. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  194. if($r['for']=='P'){
  195. if(!preg_match('/[0-9]{14}/',$r['target'])){
  196. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?'.$r['target'].' [R=302,L,NC]'.PHP_EOL.PHP_EOL);
  197. }
  198. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?post='.$r['target'].' [R=302,L,NC]'.PHP_EOL.PHP_EOL);
  199. }// do site redirect in php.
  200. }
  201. fwrite($conf, 'RewriteCond %{HTTPS} !=on'.PHP_EOL.
  202. 'RewriteCond %{HTTP_HOST} !=localhost'.PHP_EOL.
  203. 'RewriteCond %{REQUEST_URI} !^.*(jpg|png|gif)$'.PHP_EOL.
  204. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]'.PHP_EOL.PHP_EOL);
  205. fwrite($conf,'<Files ~ "\.md$">'.PHP_EOL.'deny from all'.PHP_EOL.'</Files>'.PHP_EOL);
  206. fflush($conf);fclose($conf);
  207. }
  208. function BuildRedirectConfig($conf){
  209. $this->Redirect=[];
  210. if(preg_match_all('/P\s+(.*)\:\s*([0-9]{14}|.+)\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  211. foreach($ma as $m){
  212. $redirect=[]; $redirect['for'] = 'P'; $redirect['format'] = $m[1]; $redirect['target'] = $m[2];
  213. $this->Redirect[]=$redirect;
  214. }
  215. }
  216. if(preg_match_all('/S\s+(\S+)\s*\:\s*(\S+)\s*\:\s*([0-9]{14})\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  217. foreach($ma as $m){
  218. $redirect=[]; $redirect['for'] = 'S'; $redirect['format'] = $m[1]; $redirect['domain'] = $m[2]; $redirect['target'] = $m[3];
  219. $this->Redirect[]=$redirect;
  220. }
  221. }
  222. }
  223. function WriteTokens(){
  224. $tf = fopen('la_tokens.php','w');
  225. fwrite($tf,'<?php header("Location:index.php"); exit; ?>'.PHP_EOL.PHP_EOL);
  226. if(isset($this->LoginTokens) && sizeof($this->LoginTokens)) {
  227. foreach($this->LoginTokens as $t){
  228. fwrite($tf,'- '.$t.PHP_EOL);
  229. }
  230. }
  231. fflush($tf);fclose($tf);
  232. }
  233. function WriteConfig(){
  234. if(!isset($this->Title)) $this->Title = $this->T('那么的维基');
  235. if(!isset($this->ShortTitle)) $this->ShortTitle = $this->T('基');
  236. if(!isset($this->Admin)) $this->Admin = 'admin';
  237. if(!isset($this->DisplayName)) $this->DisplayName = $this->T('管理员');
  238. if(!isset($this->Password)) $this->Password = password_hash('Admin', PASSWORD_DEFAULT).PHP_EOL;
  239. $conf = fopen('la_config.php','w');
  240. fwrite($conf,'<?php header("Location:index.php"); exit; ?> '.PHP_EOL.PHP_EOL);
  241. fwrite($conf,'- Title = '.$this->Title.PHP_EOL);
  242. fwrite($conf,'- ShortTitle = '.$this->ShortTitle.PHP_EOL);
  243. fwrite($conf,'- Admin = '.$this->Admin.PHP_EOL);
  244. fwrite($conf,'- DisplayName = '.$this->DisplayName.PHP_EOL);
  245. fwrite($conf,'- Password = '.$this->Password.PHP_EOL);
  246. fwrite($conf,'- EMail = '.$this->EMail.PHP_EOL);
  247. fwrite($conf,'- SpecialNavigation = '.$this->SpecialNavigation.PHP_EOL);
  248. fwrite($conf,'- SpecialSidebar = '.$this->SpecialSidebar.PHP_EOL);
  249. fwrite($conf,'- SpecialFooter = '.$this->SpecialFooter.PHP_EOL);
  250. fwrite($conf,'- SpecialFooter2 = '.$this->SpecialFooter2.PHP_EOL);
  251. fwrite($conf,'- SpecialPinned = '.$this->SpecialPinned.PHP_EOL);
  252. fwrite($conf,'- SpecialPinnedNotes = '.$this->SpecialPinnedNotes.PHP_EOL);
  253. fwrite($conf,'- DefaultGallery = '.$this->DefaultGallery.PHP_EOL);
  254. fwrite($conf,'- SelfAuthPath = '.$this->SelfAuthPath.PHP_EOL);
  255. fwrite($conf,'- CommentEnabled = '.($this->CommentEnabled?"True":"False").PHP_EOL);
  256. fwrite($conf,'- NewsletterEnabled = '.($this->NewsletterEnabled?"True":"False").PHP_EOL);
  257. fwrite($conf,'- HereHost = '.$this->HereHost.PHP_EOL);
  258. fwrite($conf,'- HereTitle = '.$this->HereTitle.PHP_EOL);
  259. fwrite($conf,'- HereShortTitle = '.$this->HereShortTitle.PHP_EOL);
  260. fwrite($conf,'- HereAlbum = '.$this->HereAlbum.PHP_EOL);
  261. fwrite($conf,'- HereNavigation = '.$this->HereNavigation.PHP_EOL);
  262. fwrite($conf,'- HereFooter = '.$this->HereFooter.PHP_EOL);
  263. fwrite($conf,'- ExpHost = '.$this->ExpHost.PHP_EOL);
  264. fwrite($conf,'- ExpTitle = '.$this->ExpTitle.PHP_EOL);
  265. fwrite($conf,'- ExpShortTitle = '.$this->ExpShortTitle.PHP_EOL);
  266. fwrite($conf,'- ExpCaution = '.$this->ExpCaution.PHP_EOL);
  267. fwrite($conf,'- ExpAlbum = '.$this->ExpAlbum.PHP_EOL);
  268. fwrite($conf,'- ExpNavigation = '.$this->ExpNavigation.PHP_EOL);
  269. fwrite($conf,'- ExpFooter = '.$this->ExpFooter.PHP_EOL);
  270. fwrite($conf,'- MastodonToken = '.$this->MastodonToken.PHP_EOL);
  271. fwrite($conf,'- MastodonURL = '.$this->MastodonURL.PHP_EOL);
  272. fwrite($conf,'- MastodonPreferredLang = '.$this->MastodonPreferredLang.PHP_EOL);
  273. fwrite($conf,'- HostURL = '.$this->HostURL.PHP_EOL);
  274. fwrite($conf,'- APubID = '.$this->APubID.PHP_EOL);
  275. fwrite($conf,'- GalleryStep = '.$this->GalleryStep.PHP_EOL);
  276. fwrite($conf,'- AllowLanguageChoices = '.$this->AllowLanguageChoices.PHP_EOL);
  277. fflush($conf);fclose($conf);
  278. $conf = fopen('la_redirect.md','w');
  279. fwrite($conf,$this->DisplayRedirectConfig());fflush($conf);fclose($conf);
  280. $this->WriteHTACCESS();
  281. $this->WriteTokens();
  282. }
  283. function Install(){
  284. if(!file_exists('la_config.php')){
  285. $this->WriteConfig();
  286. }
  287. if(!is_dir('posts')) mkdir('posts');
  288. if(!is_dir('images')) mkdir('images');
  289. if(!is_dir('images/thumb')) mkdir('images/thumb');
  290. if(!is_dir('styles')) mkdir('styles');
  291. if(!is_dir('archive')) mkdir('archive');
  292. $this->WriteStyles();
  293. $this->WriteHTACCESS();
  294. }
  295. function ReadFromExistingConfig(){
  296. $f=null;
  297. if(file_exists('la_config.php')) $f='la_config.php';
  298. else if(file_exists('la_config.md')) $f='la_config.md';
  299. if(!isset($f)) return;
  300. $c = file_get_contents($f);
  301. if(preg_match_all('/-\s*(\S+)\s*=\s*(\S+)\s*$/um', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  302. $str = $m[1];
  303. $this->$str = $m[2];
  304. }
  305. $this->CommentEnabled = $this->CommentEnabled=="True";
  306. if(!isset($this->GalleryStep)) $this->GalleryStep=20;
  307. }
  308. function ReadConfig(){
  309. $this->ReadFromExistingConfig();
  310. if(file_exists('la_redirect.md')){
  311. $c = file_get_contents('la_redirect.md');
  312. $this->BuildRedirectConfig($c);
  313. }
  314. if(!file_exists('la_config.php')){
  315. $this->Install();
  316. }
  317. $this->Translations=[];
  318. if(file_exists("translations.md")){
  319. $c = file_get_contents('translations.md');
  320. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  321. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  322. $this->Translations[] = $entry;
  323. }
  324. }
  325. if(file_exists("custom_translations.md")){
  326. $this->CustomTranslationContent = file_get_contents('custom_translations.md');
  327. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$this->CustomTranslationContent, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  328. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  329. $this->Translations[] = $entry;
  330. }
  331. }
  332. $this->LoginTokens=[];
  333. if(file_exists('la_tokens.php')){
  334. $c = file_get_contents('la_tokens.php');
  335. if(preg_match_all('/-\s+(\S.*)\s*$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  336. $this->LoginTokens[] = $m[1];
  337. }
  338. }
  339. }
  340. function MastodonPostStatus($status){ return $this->MastodonCall('/api/v1/statuses', 'POST', $status); }
  341. function MastodonPostMedia($media){ return $this->MastodonCall('/api/v1/media', 'POST', $media); }
  342. function MastodonCall($endpoint, $method, $data){
  343. $headers = [
  344. 'Authorization: Bearer '.$this->MastodonToken,
  345. 'Content-Type: multipart/form-data',
  346. ];
  347. $ch = curl_init();
  348. curl_setopt($ch, CURLOPT_URL, $this->MastodonURL.$endpoint);
  349. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  350. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  351. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  352. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  353. $reply = curl_exec($ch);
  354. if (!$reply) {
  355. return json_encode(['ok'=>false, 'curl_error_code' => curl_errno($ch_status), 'curl_error' => curl_error(ch_status)]);
  356. }
  357. curl_close($ch);
  358. return json_decode($reply, true);
  359. }
  360. function MastodonSendPost(&$post, &$errmsg=NULL){
  361. if(isset($post['mark_value']) && $post['mark_value']==7){ return NULL; }
  362. $this->LanguageAppendix = 'zh';
  363. if(in_array($this->MastodonPreferredLang,['en','zh'])){ $this->LanguageAppendix = $this->MastodonPreferredLang; }
  364. $this->ConvertPost($post);
  365. $media_ids = NULL;
  366. $mastodon_post_url = NULL;
  367. $imcount = 0;
  368. if(isset($post['original_images']) && isset($post['original_images'][0])) foreach($post['original_images'] as $im){
  369. $curl_file = curl_file_create($im, mime_content_type($im), basename($im));
  370. $body = ['file' => $curl_file,]; $response = $this->MastodonPostMedia($body);
  371. if(isset($response['id'])){ if(!isset($media_ids)){$media_ids=[];} $media_ids[]=$response['id']; }
  372. else{ if(isset($response['error'])) $errmsg.=$response['error']."<br /><br />"; }
  373. $imcount++; if($imcount>=4){ break; }
  374. }
  375. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$post['html']));
  376. if(isset($this->HostURL) && $this->HostURL!=""){
  377. $text.=("\n\n".$this->T('来自').' '.$this->HostURL.'?post='.$post['id']);
  378. }
  379. $vis = (isset($post['mark_value']) && $post['mark_value']==6)?"private":"public";
  380. $status_data = [ 'status' => $text, 'visibility' => $vis, 'language' => $this->LanguageAppendix, ];
  381. if(isset($post['prev']) && ($pp=&$this->GetPost($post['prev']))!=$this->NULL_POST){
  382. if(isset($pp['mastodon_url'])){ $status_data['in_reply_to_id'] = basename($pp['mastodon_url']);
  383. }
  384. }
  385. if(isset($media_ids[0])){ $status_data['media_ids']=$media_ids; }
  386. $status_data = preg_replace('/(media_ids%5B)[0-9]+(%5D)/','$1$2', http_build_query($status_data));
  387. $status_response = $this->MastodonPostStatus($status_data);
  388. if(isset($status_response['url']) && $status_response['url']){
  389. $mastodon_post_url = $status_response['url'];
  390. $post['mastodon_url'] = $mastodon_post_url;
  391. $this->NeedWritePosts = 1;
  392. }
  393. if(isset($status_response['error'])) { $errmsg .= $status_response['error']; }
  394. return $mastodon_post_url;
  395. }
  396. function __construct() {
  397. $this->ReadConfig();
  398. $this->PDE = new ParsedownExtra();
  399. $this->PDE->SetInterlinkPath('/');
  400. $this->Posts = [];
  401. $this->Threads = [];
  402. $this->VisitedHere = [];
  403. $this->NULL_IMAGE_DUMMY = [];
  404. $this->NULL_IMAGE_DUMMY['name']=$this->NULL_IMAGE_DUMMY['file']=$this->NULL_IMAGE_DUMMY['thumb']="";
  405. $this->Markers=['●', '○', '✓', '×', '!', 'P', 'E', 'S', 'N'];
  406. $this->PostsPerPage = 40;
  407. $this->CommentsPerPage = 100;
  408. $this->HotPostCount = 15;
  409. $this->TIME_STRING = date('YmdHis');
  410. $this->WayBack = NULL;
  411. $this->YearBegin = $this->YearEnd = 2000;
  412. $this->DoneReadPosts = $this->DoneReadImages = $this->DoneReadArchive = false;
  413. $this->NeedWritePosts= $this->NeedWriteImages= $this->NeedWriteArchive= false;
  414. $this->UsePosts = &$this->Posts;
  415. $this->PNUMBER=0;
  416. }
  417. function DoLogout(){
  418. $this->LoggedIn = false;
  419. unset($_SESSION['user_id']);
  420. $this->RecordToken(true);
  421. }
  422. function RecordToken($unset_current=false){
  423. if(isset($unset_current) && isset($_COOKIE['la_token'])){
  424. $t = $_COOKIE['la_token'];
  425. setcookie('la_token', null, -1,'/'); unset($_COOKIE['la_token']);
  426. if (($key = array_search($t,$this->LoginTokens)) !== false) { unset($this->LoginTokens[$key]); }
  427. $this->WriteTokens();
  428. return null;
  429. }else{
  430. $t = uniqid('la_',true);
  431. setcookie('la_token',$t,time()+3600*24*7,'/'); $_COOKIE['la_token'] = $t;
  432. $this->LoginTokens[] = $t;
  433. $this->WriteTokens();
  434. return $t;
  435. }
  436. }
  437. function LoginThroughToken(){
  438. if(!isset($_COOKIE['la_token'])) return false;
  439. $t = $_COOKIE['la_token'];
  440. if (($key = array_search($t,$this->LoginTokens)) !== false) {
  441. $_SESSION['user_id']=$this->Admin;
  442. $this->LoggedIn = true;
  443. setcookie('la_token',$t,time()+3600*24*7,'/');
  444. return true;
  445. }
  446. return false;
  447. }
  448. function DoLogin(){
  449. session_start();
  450. $redirect=false;
  451. if(isset($_GET['logout'])){ $this->DoLogout(); header('Location:index.php'); }
  452. else if(!isset($_SESSION['user_id'])){
  453. if(isset($_POST['login_button'])){
  454. $id = trim($_POST['login_id']);
  455. $pwd = trim($_POST['login_password']);
  456. if(strtolower($this->Admin)==strtolower($id)&&password_verify($pwd, $this->Password)){
  457. $_SESSION['user_id']=$id;
  458. $this->RecordToken(false);
  459. }
  460. $redirect = true;
  461. }else if($this->LoginThroughToken()){
  462. // nothing;
  463. }
  464. }else{
  465. if(strtolower($_SESSION['user_id']) == strtolower($this->Admin)){ $this->LoggedIn = true; }
  466. else{ $this->DoLogout();}
  467. }
  468. if($redirect){
  469. header('Location:index.php'.(isset($_GET['post'])?("?post=".$_GET['post']):"")
  470. .(isset($_GET['settings'])?"?settings=true":""));
  471. }
  472. }
  473. function SetHereMainImage($im_this){
  474. if(isset($im_this) && isset($im_this['parent'])){ $this->HereMainImage = &$this->FindImage($im_this['parent'],true);}
  475. }
  476. function RecordVisitedHere($image_or_post_name, $image_title){
  477. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  478. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  479. if(!(isset($_SESSION[$visited_here][0]) && in_array($image_or_post_name,$_SESSION[$visited_here]))){
  480. $_SESSION[$visited_here][] = $image_or_post_name;
  481. }
  482. if(isset($image_title)){ $this->HereDisplayTitle=$image_title; }
  483. $this->HereNumber = array_search($image_or_post_name,$_SESSION[$visited_here])+1;
  484. $_SESSION['here_number'] = $this->HereNumber;
  485. $this->VisitedHere = $_SESSION[$visited_here];
  486. }
  487. function HereLinkFromNumber($number){
  488. $number -= 1; if($number<0){ $number=0; }
  489. if($number>=sizeof($this->VisitedHere)){ $number = sizeof($this->VisitedHere)-1; }
  490. if(preg_match('/(jpg|jpeg|png|gif)/u',$this->VisitedHere[$number])){ return "?here=images/".$this->VisitedHere[$number]; }
  491. else{ return "?post=".$this->VisitedHere[$number]; }
  492. }
  493. function WriteStyles(){
  494. $this->style="
  495. html{font-size:18px;font-family:'Noto Serif CJK SC','Times New Roman','SimSun', Georgia, serif;}
  496. .page{overflow:none;}
  497. body{background-color:%white%;color:%black%;}
  498. sup,sub{line-height:0;} .lpctrl{display:none;}
  499. blockquote{border-left:2px solid %black%;padding-left:0.3em;}
  500. *{box-sizing:border-box;padding:0;margin:0;font-weight:normal;}
  501. b,strong,th{font-weight:bold;}
  502. select{font-size:inherit;}
  503. .page,.page_gallery{padding:1em;padding-top:0;padding-bottom:0;}
  504. .hidden_on_desktop,.hidden_on_wide{display:none;}
  505. .hidden_on_desktop_force{display:none !important;}
  506. ::file-selector-button{background:none;border:none;}
  507. a,button,::file-selector-button{text-decoration:underline;color:%black%;text-decoration-thickness:2px;text-underline-offset:0.15em;}
  508. a:hover,.button:hover,::file-selector-button:hover{text-decoration:none;color:%gray%;}
  509. .button:disabled{background-color:%gray%;pointer-events:none;}
  510. 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%;}
  511. 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;}
  512. header>div{overflow:auto;white-space:nowrap;}
  513. .header_nav{display:inline;}
  514. header a,.left a,.footer a,.clean_a,.clean_a a{text-decoration:none;}
  515. header a:hover,.button:hover{color:%gray% !important;text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:0.15em;}
  516. .exp_h_f{padding-top:0.3em !important;padding-bottom:0.3em !important;line-height:1.5em !important;height:2.1em !important;}
  517. .exp_f{text-align:center;}
  518. .toc_button{position:absolute;top:0.5em;right:0;text-shadow: 0px 0px 10px %white%;background-color:%white%88;}
  519. .footer{background-color:%white%;z-index:10;position:relative;}
  520. .invert_a,.invert_a a{color:%gray%;text-decoration:none;}
  521. .invert_a:hover,.invert_a a:hover{color:%black% !important;}
  522. .gray,.gray a{color:%gray%;}
  523. hr{border:1px solid %gray%;}
  524. header ul,.small_footer ul,.small_footer span,header li,.small_footer li{display:inline-block;vertical-align:text-top;}
  525. header li::before,.small_footer li::before{content:' - '}
  526. header li ul{display:none;}
  527. header:hover li ul{display:inline;}
  528. header li ul li{display:block !important;margin-left:1em;}
  529. header li ul li a{font-size:0.9em;}
  530. //h1,h2,h3,h4,h5{font-size:1em;}
  531. //h1{text-decoration:underline;}
  532. header h1,header h2,header h3,header h4,header h5,header p{display:inline;font-size:1rem;}
  533. .main{position:relative;word-spacing:-1em;top:2em;margin-bottom:2em;}
  534. .main *{word-spacing:initial;}
  535. pre{overflow:auto;display:block;line-break:anywhere;white-space:pre-wrap;}code{font-size:0.83em;}
  536. ul{display:block;}
  537. li{display:block;}
  538. .clean_table{border:none;font-size:1em !important;}.clean_table thead{box-shadow:none;}.clean_table td{vertical-align:top;}
  539. table{width:100%;border-collapse:collapse;border-bottom:2px solid %black%;border-top:3px solid %black%;}
  540. .settings input,.post inpiut{border:none!important;}
  541. .post table img{max-width:10rem !important;}
  542. td{padding-left:0.1em;padding-right:0.1em;}
  543. td:first-child{padding-left:0;}
  544. td:last-child{padding-right:0;}
  545. tbody tr:hover{box-shadow:inset 0 -2px 0 0px %black%;}
  546. thead{box-shadow:inset 0 -1px 0 0px %black%;}
  547. .post table{font-size:0.85em;}
  548. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 20em);}
  549. .interesting_tbody td{display:contents;}
  550. .interesting_tbody tr{position:relative;scroll-margin:4.5em}
  551. .interesting_tbody td>*{display:table-cell;}
  552. .interesting_tbody td>.wscroll{display:none !important;}
  553. .interesting_tbody .post_access{padding-top:0;}
  554. .interesting_tbody .post_menu_button{top:0;opacity:0;}
  555. .interesting_tbody td>img,.interesting_tbody td>.imd{position:absolute;left:1.4em;z-index:-1;height:1em;width:20em;
  556. display:flex;top:0.2em;object-fit:cover;max-width:calc(100% - 1.4em) !important;overflow:hidden;}
  557. .interesting_tbody td>.imd>a{display:flex;}
  558. .interesting_tbody img{object-fit:cover;width:100%;}
  559. .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);}
  560. .interesting_tbody .p_thumb{height:1em;}
  561. .interesting_tbody .p_thumb img,.interesting_tbody .p_thumb video{max-height:10rem !important;max-width:20rem !important;}
  562. tr:hover .post_menu_button{opacity:1;}
  563. .post_current_row{background-color:%graybkg%;mix-blend-mode:screen;text-shadow:0px 0px 0.1em %white%;}
  564. .align_right{text-align:right;}
  565. .left{display:inline-block;vertical-align:top;width:25%;padding-right:1.5em;padding-bottom:4rem;position:sticky;top:2em;
  566. overflow:auto;max-height:calc(100vh - 2.6em);}
  567. .center{display:inline-block;vertical-align:top;width:50%;overflow:visible;padding-bottom:4rem;}
  568. .center_slides{display:block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;font-size:5vmin;user-select:none;}
  569. .center_slides .print_column{display:table;position:fixed;top:0;right:0;left:0;bottom:0;width:100%;height:100%;z-index:90;}
  570. .center_slides .print_column .post{display:table-cell;vertical-align:middle;padding:5vmin !important;max-height:100vh;width:100vw;overflow:auto;}
  571. .center_slides .active_post{background-color:%white%;}.center_slides .post{background-color:%white%;}
  572. .center_slides .post_access{display:none;}
  573. .center_slides .post_menu_button{display:none !important;}
  574. .center_slides .post_width{display:block;vertical-align:middle;max-height:100vh;overflow-y:auto;overflow-x:hidden;width:100%;}
  575. .center_slides .linked_posts{display:none;}.center_slides .ref_compact{position:relative!important;display:block!important;}
  576. .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;}
  577. .slides_buttons a{text-decoration: none;}
  578. .center_slides .imd{text-align:center;pointer-events:none;}
  579. .imd_float{float:right;width:50% !important;clear:both;margin-left:0.5em !important;}
  580. .center_wide{display:inline-block;vertical-align:top;width:75%;padding-left:0.3em;overflow:visible;padding-bottom:4rem;}
  581. .center_full{display:inline-block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;}
  582. .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;}
  583. .linked_posts{padding:0.5em;background-color:#0004;box-shadow:0px 0.2em 0.2em -0.2em inset %shadow%;}
  584. .active_post .linked_posts{background-color:%highlight_slice%;}
  585. input:checked~.linked_posts,input:checked~a{display:none;}
  586. .bkg_recent>.post,.bkg_section{background:%post_white%;box-shadow:0em 0em 0.5em %shadow%;margin-bottom:0.5em;}
  587. .bkg_recent>.post>.post_width :last-child{margin-bottom:0;}
  588. .sticky_title{position:sticky;top:calc(1.6rem + 2px);z-index:1;background-color:%white%;pointer-events:none;}
  589. .center_exp{display:block;width:80%;margin:0 auto;overflow:visible;padding-bottom:1em;}
  590. .table_top{position:relative;left:calc(-50% - 0.45em);width:calc(200% + 0.6em);background:%white%;z-index:1;
  591. box-shadow:0px 0px 2em 1em %white%;margin-top:2em;margin-bottom:2em;}
  592. textarea,input[type=text],input[type=password]{font-family:monospace;width:100%;display:block;font-family:inherit;max-height:60vh;font-size:inherit;}
  593. select,textarea,input[type=text],input[type=password]{font-family:monospace;background:none;border:none;border-bottom:1px solid %black%;color:%black%;}
  594. .text_highlight input{border-bottom:1px solid %white%;color:%white%;}
  595. .button{background:none;border:none;font-family:inherit;color:%black%;font-size:inherit;font-weight:bold;}
  596. .post{position:relative;scroll-margin:3.5em;}
  597. .active_post{background-color:%highlight_white%;}.active_post .post_access{background-color:%highlight_slice%;}
  598. .center_exp .post{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;}
  599. .post li,.footer_additional li,.footer_additional li,.post_dummy li
  600. {display:list-item;margin-left:1em;list-style:disc;}
  601. .post li li,.footer_additional li li,.footer_additional li li,.post_dummy li li
  602. {list-style:circle;}
  603. ol li{list-style:unset !important;}
  604. .post_width > *,.post_dummy > *,.post_ref > *{margin:0;margin-bottom:0.5rem}
  605. .post > td:nth-child(3) > *{margin:0;margin-bottom:0.5rem}
  606. .post_dummy > *{width:60%;margin:0 auto;margin-bottom:0.5rem}
  607. .post_dummy > p img{display:block;width:100%;margin:0 auto;}
  608. .gallery_left li{display:list-item;margin-left:1em;list-style:none;}
  609. .gallery_left .selected{list-style:'→';}
  610. .bkg_section .post_width{padding-top:0;padding-bottom:0;}
  611. .bkg_section .restart+.post .post_width{padding-top:0.5em;}
  612. .post_width{display:inline-block;margin-left:0.5em;vertical-align:top;}
  613. .opt_compact .post_width,.ref_compact .post_width{padding-top:0;padding-bottom:0;}
  614. .p_thumb .post_menu_button{right:0.3rem;top:0.3em;}
  615. .post_menu_button{position:absolute;display:none;right:0rem;width:1.5rem;box-shadow:0px 0px 3px %shadow%;
  616. text-align:center;border-radius:0.3em;user-select:none;cursor:pointer;z-index:10;background-color:%post_white%aa;}
  617. .pointer{cursor:pointer;}
  618. .post:hover .post_menu_button{display:block;}
  619. .pop_menu{position:absolute;top:0.3rem;z-index:95;background-color:%grayslice%;
  620. padding:0.3em;right:0.3rem;text-align:right;border-radius:0.3em;font-size:1rem;
  621. box-shadow:0px 0px 10px %shadow%;}
  622. .pop_menu li{list-style:none;margin-left:0;}
  623. .pop_menu hr{border:2px solid rgba(0,0,0,0.1);}
  624. .toc{left:60%;width:40%;top:0;position:absolute;}
  625. .paa{width:1.4rem;min-width:1.4rem;}
  626. .opt_compact .post_access,.ref_compact .post_access{border-right:2px solid %gray%;background-color:%post_white%;right:unset;left:-2em;}
  627. .active_post .opt_compact .post_access,.active_post .ref_compact .post_access{background-color:%highlight_white%;}
  628. .post_preview{overflow:hidden;margin-bottom:0.4em;background-color:%white%aa;box-shadow: 0px 0px 0.2em %shadow%;}
  629. .post_preview:hover{filter:contrast(90%);}
  630. .active_post .post_preview:hover{filter:contrast(90%);}
  631. .hide_long{max-height:12em;overflow:hidden !important;}
  632. .post .post_ref{margin:0;padding-left:1.5rem;}
  633. .post_ref_main{display:inline-block;vertical-align:top;max-height:6em;overflow:hidden;margin:0.4em;}
  634. .post_ref_images{overflow:hidden;margin:0.4em;margin-top:0;}
  635. .post_ref_hint{text-align:right;}
  636. .page_selector{padding-top:2rem;text-align:center;}
  637. .smaller{font-size:0.85em;} .bigger{font-size:1.3em;} .block{display:block;}
  638. .restart{text-align:left;padding-top:1rem;padding-bottom:0.5rem;}
  639. .opt_compact{margin-left:2rem;}
  640. .post_box_top{padding-bottom:0.3em;padding-top:0.3em;}
  641. .post_box_fixed_bottom{position:sticky;bottom:0em;background-color:%white%;z-index:5;}
  642. .spacer{height:0.5em;}
  643. .pop_right,.pop_right_big{position:fixed;top:0;right:0;bottom:0;width:30%;z-index:100;background-color:%graybkg%;display:none;
  644. transition-timing-function:ease-out;padding:1rem;overflow:auto;}
  645. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  646. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  647. @keyframes pop_slide_in_big{0%{right:-30%;}100%{right:0%;}}
  648. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-30%;}}
  649. .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;}
  650. @keyframes backdrop_fade_in{0%{opacity:0%;}100%{opacity:100%;}}
  651. @keyframes backdrop_fade_out{0%{opacity:100%;}100%{opacity:0%;}}
  652. .toc_entry_1{font-size:1.1em;}
  653. .toc_entry_2{font-size:1.0em;padding-left:0.5rem;}
  654. .toc_entry_3{font-size:0.9em;padding-left:1rem;}
  655. .toc_entry_4{font-size:0.85em;padding-left:1.5rem;}
  656. .toc_entry_5{font-size:0.8em;padding-left:2rem;}
  657. h1,h2,h3,h4,h5{scroll-margin:2.5em;}
  658. .post h1,.post h2,.post h3,.post h4,.post h5{margin-top:1rem;}
  659. .left ul h1,.left ul h2,.left ul h3,.left ul h4,.left ul h5,.left ul p{font-size:1em;}
  660. .deleted_post{color:%gray%;text-decoration:line-through;}
  661. #file_list{margin-top:0.5em;}
  662. .file_thumb img,.file_thumb video{max-height:100%;max-width:100%;object-fit:cover;min-width:100%;min-height:100%;}
  663. .file_thumb video{border:2px dashed %black%;}f
  664. #file_list li{margin-bottom:0.3em;}
  665. .ref_thumb{white-space:nowrap;overflow:hidden;}
  666. .ref_thumb .file_thumb{width:2em;height:2em;margin:0;margin-right:0.3em}
  667. .side_thumb li{margin:0.4em;display:inline-block;}
  668. .file_thumb{width:4em;height:4em;display:inline-block;line-height:0;vertical-align:middle;overflow:hidden;}
  669. .p_row{display:flex;flex-wrap:wrap;width:100%;}
  670. .p_thumb{display:flex;flex-grow:100;height:6rem;overflow:hidden;position:relative;margin-right:0.5em;margin-bottom:0.5em;}
  671. .p_thumb_narrow{width:1rem !important;flex-grow:1;opacity:0.2;}
  672. .p_thumb img,.p_thumb video{object-fit:cover;max-height:100%;min-width:100%;}.p_thumb a{display:contents;}
  673. .p_thumb:hover .post_menu_button{display:block;}
  674. .p_thumb_selected{color:%black% !important;}
  675. .p_thumb_selected{display:block;}
  676. .post .p_thumb img,.post .p_thumb video{max-height:6rem;}
  677. .p_thumb video{border-bottom:0.4em dashed %black%;border-top:0.4em dashed %black%;}
  678. .p_thumb_end{flex-grow:10000 !important;box-shadow:none;align-items:center;padding:2em !important;}
  679. .p_thumb_end:hover, .p_thumb_end a:hover{background-color:%gray%;cursor:pointer;}
  680. .big_image_box{position:fixed;top:0;bottom:0;left:0;width:75%;z-index:95;text-align:center;pointer-events:none;}
  681. .big_image_box *{pointer-events:auto;}
  682. .big_image_box img,.big_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  683. .here_image_box{position:relative;width:100%;text-align:center;height:calc(100vh - 4.5em);}
  684. .here_image_box img,.here_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  685. .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;}
  686. .big_side_box a,.big_side_box hr,#dropping_background{color:%black%;}
  687. .big_side_box a:hover{color:%gray%;}
  688. .big_side_box *{pointer-events:auto;}
  689. .big_side_box .post_preview{border-bottom:1px dotted %black%;background-color:unset;}
  690. .image_nav{pointer-events:none;}
  691. #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;
  692. box-shadow:0px 0px 500px black inset;display:flex;align-items:center;}
  693. img,video{cursor:pointer;max-height:100%;max-width:100%;vertical-align:middle;}
  694. .post img,.post video{max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  695. .post > a > img,.post > a > video{display:block;margin:0.3em auto;}
  696. .post .original_img{max-width:100%;display:inline-block;vertical-align:middle;
  697. margin-left:auto;margin-right:auto;max-width:100%;max-height:90vh;}
  698. .center_exp .post .original_img{display:block;}
  699. .original_img img,.original_img video{max-height:90vh;max-width:100%;}
  700. .p_row .original_img{margin-bottom:0;}
  701. .post_ref .original_img{margin:unset;max-width:unset;max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  702. .imbtn{color:rgba(0,0,0,0);display:block;contain:content;padding:0.25em;margin-bottom:0.5em;text-decoration:none;}
  703. .imbtn img{display:block;object-fit:cover;position:absolute;top:0;left:0;bottom:0;right:0;margin:auto;z-index:-1;
  704. min-width:100% !important;min-height:100% !important;filter:opacity(70%);transition:0.1s;}
  705. .imbtn:hover img{filter:opacity(20%) blur(0.2em);} .imbtn:hover{color:%black% !important;}
  706. .imbtn:hover {color:%black%;text-shadow:0px 0px 5px %white%;}
  707. header .imbtn{display:inherit;border:none;padding:0em;height:unset;height:unset;margin:0em;contain:unset;}
  708. header .imbtn:hover{border:none;color:%gray% !important;} header .imbtn img{display:none;}
  709. .b ul{font-size:1.4em;}
  710. no_pop{cursor:unset;}
  711. p{min-height:0.8em;}
  712. .bold,.bold *{font-weight:bold;}
  713. .footer_additional{display:inline-block;width:50%;vertical-align:text-top;white-space:normal;}
  714. .small_footer{background-color:%white%;padding-bottom:0.5em;position:sticky;bottom:0px;z-index:10;box-shadow: 0.5em 0px %white%;}
  715. .small_footer>div{overflow:auto;white-space:nowrap;}
  716. .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;}
  717. .top_post_hint{margin-left:0.5em;font-weight:bold;}
  718. .white{color:%white%;}
  719. .full_box{border:1px solid %black% !important;padding:0.3rem;overflow:auto;}
  720. .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;
  721. transition:background-size .2s ease;padding:0.5em;text-shadow:0px 0px 5px black;user-select:none;pointer-events:auto;}
  722. .image_nav_prev{left:0;justify-content:left;background:linear-gradient(to left, rgba(0,0,0,0), rgba(0,0,0,0.4));
  723. background-repeat:no-repeat;background-size:0% 100%;}
  724. .image_nav_prev:hover,.image_nav_next:hover{background-size:100% 100%;}
  725. .image_nav_next{right:0;justify-content:right;background:linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.2));
  726. background-repeat:no-repeat;background-size:0% 100%;transition:background-size .2s ease;background-position-x:100%;}
  727. .inquiry_buttons{position:fixed;left:0;right:25%;text-align:center;bottom:1em;margin:0 auto;width:max-content;
  728. background-color:rgba(0,0,0,0.5);z-index:110;padding:0.2em;padding-left:1em;padding-right:1em;
  729. border-radius:1em;box-shadow:0px 0px 5px;text-shadow:0px 0px 5px black;opacity:1;user-select:none;}
  730. .lr_buttons{background-color:rgba(0,0,0,0.5);padding:0.5em;padding-top:1em;padding-bottom:1em;
  731. border-radius:1em;box-shadow:0px 0px 5px;font-size:1.2rem;text-shadow:0px 0px 5px black;}
  732. .img_btn_hidden{opacity:0;transition:opacity 0.2s;}
  733. .special_alipay{background-color:#027aff;color:white;white-space:nowrap;
  734. font-family:sans-serif;font-weight:bold;border-radius:0.7em;font-size:0.75em;padding:0.25em;}
  735. .special_paypal{background-color:white;color:#253b80;white-space:nowrap;
  736. font-family:sans-serif;font-weight:bold;border-radius:2em;font-size:0.75em;
  737. padding:0.25em;padding-left:0.5em;padding-right:0.65em;font-style: italic;}
  738. .special_paypal_inner{color:#169bd7;}
  739. #waiting_bar{position:fixed;z-index:200;top:0;left:0;right:0;height:0.2em;background-color:%black%;transform:translate(-100%,0);
  740. animation:anim_loading 1s linear infinite;}
  741. @keyframes anim_loading{0%{transform:translate(-100%,0);} 100%{transform:translate(100%,0);}}
  742. .product_ref{width:32%;padding:0.2em!important;display:inline-block;text-align:center;vertical-align:top;margin-bottom:0.8em;}
  743. .product_thumb{max-height:11em;max-width:11em;display:inline-flex;margin-bottom:0.2em;background-color:%graybkg%;}
  744. .product_thumb img,{box-shadow:none;object-fit:contain;max-height:unset;max-width:unset;width:100%;margin:0 auto !important;}
  745. .product_ref p{margin-bottom:0.2em;text-align:left;}
  746. .post_preview .product_thumb{max-height:4em;max-width:6em;}
  747. .purchase_button{background-color:%black%;color:%white%;padding-left:0.5em;padding-right:0.5em;text-decoration:none;font-weight:bold;}
  748. .page_break{page-break-after:always;}
  749. .text_highlight,.text_highlight a,.text_highlight select{background-color:%black%;color:%white%;border:none;}
  750. .gray.text_highlight,.gray.text_highlight a,.gray.text_highlight select{background-color:%gray%;color:%white%;}
  751. .show_on_print{display:none;}.inline_print{display:none;}
  752. .comment{font-size:0.9em;font-family:sans-serif;overflow:auto !important;width:100%;}
  753. .comment tbody tr:hover{box-shadow:none;}
  754. .comment table{border:none;}
  755. .comment li{display:list-item;list-style:'→';padding-left:0.3em;}
  756. .comment ul{padding-left:1em;}
  757. .comment ul li *{margin-bottom:0.5em;}
  758. .history li{display:list-item;list-style:disc;padding-left:0.3em;}
  759. .history li li{list-style:circle;}
  760. .history ul{padding-left:1em;}
  761. .history a{text-decoration:underline;}
  762. .history .list{overflow:auto;white-space:nowrap;}
  763. .diff_table{table-layout:fixed;}
  764. .diff_table thead{font-size:0.9em;text-align:center;}
  765. .diff_table tbody pre{font-size:0.9rem;white-space:pre-line;}
  766. .diff_table td{vertical-align:top;}
  767. .omittable_title{display:block;width:100%;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
  768. .wayback_close{float:right;}
  769. .wayback_expand{display:inline;}
  770. .post_selecting .post>*>*{pointer-events:none;}
  771. .post_selected{background-color:%graybkg%;}
  772. .small_pad{padding:0.2em;padding-top:0.1em;padding-bottom:0.1em;}
  773. .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%;}
  774. .wscroll:target{display:block;} .post_ref .wscroll{display:none !important;}
  775. .wayback_link{display:inline;}
  776. .imd{object-fit:cover;width:100%;}
  777. .center_exp .post>.imd,.center_exp .p_row{width:60%;}
  778. .center_exp .p_thumb img,.center_exp .p_thumb video{max-height:3rem;}
  779. .center_exp .p_thumb{max-height:3rem;filter:opacity(40%);}
  780. .center_exp .p_thumb:hover{filter:unset;}
  781. #here_buttons{display:contents;}
  782. .here_buttons_inner{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;max-height:100%;max-width:100%;}
  783. .here_btn{position:absolute;z-index:110;transform:translate(-50%,-50%);
  784. width:2em;height:2em;display:block;border:1px solid %black%;background-color:rgba(0,0,0,0.5);}
  785. .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;}
  786. .center .center{width:100%;padding-bottom:unset;}
  787. .center{border:none;}
  788. .center{overflow:auto;}
  789. .center>tbody>tr:hover{box-shadow:none;}
  790. .center>tbody>tr>td{white-space:normal;vertical-align:top;min-width:1em;}
  791. .center>tbody>tr>td:first-child{text-align:center;color:%gray%;padding-left:0.1em;}
  792. .center>tbody>tr>td:nth-child(1)>*{}
  793. .center>tbody>tr>td:nth-child(2){text-align:center;color:%gray%;}
  794. .center>tbody>tr>td:nth-child(2) a{color:%gray%;}
  795. .center>tbody>tr>td:nth-child(2) .marked{color:%black% !important;}
  796. .center>tbody>tr>td:nth-child(3){width:100%;text-align:left;}
  797. .center>tbody>tr>td:nth-child(3)>div{overflow:auto;}
  798. .center>tbody>tr>td:last-child{padding-right:0.5em;}
  799. .main>.center>tbody>tr{border-bottom:1px dotted %black%;}
  800. .ref_count{cursor:pointer;} td .ref_count{text-align:left;display:block;}
  801. .big_side_box .center{width:100%;}
  802. #big_image_upload{max-width:100%;}
  803. label{text-align:left;display:inline-block;}
  804. @media screen and (max-width:1000px) and (min-width:666px){
  805. .left{width:35%;}
  806. .center,.center_wide{width:65%;}
  807. .center_wide .p_thumb{height:8rem;width:8rem;margin-right:0.4rem;margin-bottom:0.4rem;box-shadow:3px 3px 12px 2px black;}
  808. .post_width{width:calc(100% - 1.5rem);padding-left:0.2em;}
  809. .hidden_on_wide{display:unset;}
  810. .pop_right{width:30%;}
  811. .pop_right_big{width:40%;}
  812. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  813. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  814. @keyframes pop_slide_in_big{0%{right:-40%;}100%{right:0%;}}
  815. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-40%;}}
  816. .big_side_box{width:35%;}
  817. .big_image_box{width:65%;}
  818. .inquiry_buttons{right:35%;}
  819. .table_top{left:calc(-50% - 1.7em);width:calc(154% + 0.5em);}
  820. .post_dummy > *{width:80%;max-width:55rem;}
  821. .center_exp .post>.imd,.center_exp .p_row{width:80%;max-width:55rem;}
  822. .here_btn{width:1.5em;height:1.5em;}
  823. }
  824. @media screen and (max-width:666px){
  825. .main{top:unset;margin-bottom:unset;}
  826. html{font-size:16px;}
  827. pre{max-width:85vw;}
  828. #titlectrl:checked ~ header .mobile_fold{display:block !important;}
  829. #titlectrl:checked ~ .main .mobile_fold{display:block !important;}
  830. #titlectrl:checked ~ header li ul{display:inline;}
  831. .mobile_fold{display:none !important;}
  832. .hidden_m{display:none !important;}
  833. .block_m{display:block !important;}
  834. .hidden_on_desktop{display:inherit;}
  835. .hidden_on_wide{display:inherit;}
  836. header{position:inherit;}
  837. header ul{display:block;}
  838. header li{display:block;}
  839. header li::before{content:''}
  840. header::before{box-shadow:none;display:none;}
  841. .small_footer::before{box-shadow:none;display:none;}
  842. .left{position:relative;width:100%;top:unset;height:unset;max-height:unset;padding-right:0;display:block;}
  843. .center,.center_wide,.center_full{display:block;position:relative;line-break:anywhere;left:0;top:0;width:100%;padding-left:0;}
  844. .center_wide .p_thumb{height:6rem;width:6rem;margin-right:0.3rem;margin-bottom:0.3rem;box-shadow:2px 2px 10px 1px black;}
  845. .pop_right,.pop_right_big{top:unset;right:0;bottom:0;left:0;width:100%;}
  846. .pop_right{height:30%;}
  847. .pop_right_big{height:70%;}
  848. @keyframes pop_slide_in{0%{bottom:-30%;}100%{bottom:0%;}}
  849. @keyframes pop_slide_out{0%{bottom:0%;}100%{bottom:-30%;}}
  850. @keyframes pop_slide_in_big{0%{bottom:-70%;}100%{bottom:0%;}}
  851. @keyframes pop_slide_out_big{0%{bottom:0%;}100%{bottom:-70%;}}
  852. .big_image_box{position:fixed;top:0;bottom:8.5rem;left:0;right:0;width:100%;}
  853. .side_box_mobile_inner{background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(1,1,1,0.9) 20%);
  854. transition:none;background-size:100% 100%;padding:0.5rem;padding-bottom: 5em;}
  855. .side_box_mobile_inner:hover{background-size:100% 100%;}
  856. .big_side_box{position:fixed;top:0;bottom:0;right:0;left:0;width:100%;
  857. height:unset;padding:0;padding-top:calc(100vh - 8.5rem);background:none;}
  858. .p_thumb{height:3rem;}
  859. .center .post{padding-right:0rem;padding-left:0rem;}
  860. .post .p_thumb img,.post .p_thumb video{max-height:3rem;}
  861. .page,.page_gallery{padding:0.2em;padding-top:0;}
  862. header{padding-top:0.3em;}
  863. .toc_button{top:0.3em;}
  864. .small_footer{padding-bottom:0.3em;}
  865. .footer_additional{display:block;width:100%;}
  866. .album_hint{display:block;font-size:1rem;}
  867. .image_nav{position:absolute !important;}
  868. .image_nav_prev,.image_nav_next{width:25%;}
  869. .image_nav_prev:hover,.image_nav_next:hover{background-size:0% 100%;color:%black% !important;}
  870. .inquiry_buttons{position:relative;left:unset;right:unset;text-align:left;bottom:unset;margin:unset;width:unset;
  871. background-color:unset;z-index:unset;padding:unset;padding-left:unset;padding-right:unset;
  872. border-radius:unset;box-shadow:unset;text-shadow:unset;}.img_btn_hidden{opacity:1;}
  873. .lr_buttons{background-color:unset;padding:unset;padding-top:unset;padding-bottom:unset;
  874. border-radius:unset;box-shadow:unset;font-size:1.3rem;text-shadow:unset;}
  875. .opt_compact,.ref_compact{line-break:anywhere;}
  876. .table_top{left:unset;width:100%;overflow:auto;}
  877. .post table img{max-width:30vw !important;}
  878. .product_ref{width:100%;display:block;}
  879. .post_dummy > *{width:100%;max-width:25rem;}
  880. .center_exp .post>.imd,.center_exp .p_row{width:100%;max-width:25rem;}
  881. .center_exp .post .p_thumb img,.center_exp .post .p_thumb video{max-height:2rem;}
  882. .center_exp .p_thumb{height:2rem;filter:opacity(40%);}
  883. .center_exp .p_thumb:hover{filter:unset;}
  884. .sticky_title{top:0;}
  885. .small_footer{position:relative;}
  886. #upload_selector{width:100%;}
  887. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 10em);}
  888. .wayback_expand{display:block;text-align:center;}
  889. .wayback_link{display:block;}
  890. .center_exp{display:block;width:100%;margin:0 auto;padding-bottom:1em;}
  891. .center_exp .post{overflow:auto;}
  892. .center_exp .imd{width:100%;}
  893. .here_btn{width:1.2em;height:1.2em;}
  894. .exp_h_f{height:unset !important;}
  895. .exp_f{margin-bottom:1em;}
  896. .linked_posts{padding-left:1em;}
  897. .center>tbody>tr>td{min-width:unset;}
  898. .center>tbody>tr>td:last-child{padding-right:0.1em;}
  899. }
  900. @media print{
  901. .small_footer .hidden_on_print{display:none}
  902. header b,.small_footer b{font-weight:normal;}
  903. header{display:table-header-group;box-shadow:none;} .main{display:table-row-group;top:unset;margin-bottom:unset;} .small_footer{text-align:right;}
  904. header::before{box-shadow:none;display:none;} header::after{display:block;height:1em;content:' ';}
  905. .small_footer::before{box-shadow:none;display:block;height:1em;position:relative;}
  906. body,footer,header,.small_footer,a,.clean_a,.invert_a,.clean_a a,.invert_a a{background:none;color:black;}
  907. .bkg_section,.bkg_recent>.post,.active_post{background:none !important;box-shadow:none;}
  908. .post *,.post_dummy *{margin-bottom:0em;}
  909. .p_row,.post table,.post img,.post_ref img,.post_ref .original_img,
  910. .post_width>.original_img,.post pre{margin-top:0.5rem;margin-bottom:0.5rem;text-indent:0;}
  911. pre{white-space:pre-wrap;line-break:anywhere;}
  912. .post p{line-height:1.3;text-indent:2em;} .product_ref p {text-indent:0;}
  913. .post table img{margin:0 !important;}
  914. .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;}
  915. .post ul,.post ol{margin:0.5rem !important;margin-left:1.4rem !important;margin-right: 0rem !important;}
  916. table{border-bottom:2px solid black;border-top:2px solid black;}
  917. .post table img{max-width:5em;max-width:8em !important;max-height:8em !important;}
  918. thead{box-shadow:inset 0 -1px 0 0px black;background:none;}
  919. .linked_posts{display:none;}
  920. .post_width{overflow:clip;left:0;width:100%;padding-left:0em;padding-right:0em;}
  921. .section .post h2{font-size:1.8em;margin:1.5em auto 0 !important;}.list h2,.compact h2{margin:0 !important;}
  922. .section .post h3{font-size:1.5em;margin:1.0em auto 0 !important;}.list h3,.compact h3{margin:0 !important;}
  923. .section .post h4{font-size:1.1em;margin:0.5em auto 0 !important;}.list h4,.compact h4{margin:0 !important;}
  924. .post .post{margin-bottom:0.5rem;margin-top:0.5rem;}
  925. .gray,.gray a,.deleted_post{color:rgba(0,0,0,0.5);}
  926. .left{display:none;}
  927. .center, .center_wide, .center_full{width:100%;padding:0;font-size:16px;line-height:1.3}
  928. hr{border:1px solid black;}
  929. .post_box_top{display:none;}
  930. .post_access{display:none;}
  931. .opt_compact .post_access,.ref_compact .post_access{border-right:none;display:inline;background:unset;}
  932. .text_highlight,.text_highlight a,.gray.text_highlight,.gray.text_highlight a,.purchase_button{background-color:lightgray;color:black;}
  933. .hidden_on_print{display:none !important;}
  934. .print_column{column-count:2;margin-top:0.5rem;margin-bottom:0.5rem;}
  935. .print_column .print_column{column-count:1;margin:unset;}
  936. .opt_compact{margin-left:0;left:1.5em;}
  937. .post .post_ref{padding-left:2rem;}
  938. .section .post h1:first-of-type{column-span:all;display:block;margin-top:1rem !important;margin-bottom:0.5rem !important;}
  939. .bkg_section .restart+.post .post_width{padding-top:0;}
  940. .restart{background-color:unset;padding:unset;}
  941. .opt_compact h1:first-of-type,.ref_compact h1:first-of-type{display:unset;}
  942. .table_top{position:relative;left:0;width:100%;background:none;z-index:1;box-shadow:none;}
  943. .header_nav{display:none;}
  944. .show_on_print{display:block;}.inline_print{display:inline;}
  945. blockquote{border-left:2px solid black;}
  946. .footer_additional{display:none;}
  947. .small_footer{margin-top:1rem;box-shadow:none;}
  948. .page{display:table;width:100%;}
  949. .page_selector{display:none;}
  950. .p_thumb{height:4rem;margin-bottom:0.25rem;}
  951. .post .p_thumb img,.post .p_thumb video{max-height:4rem;}
  952. .sticky_title{box-shadow:none;}
  953. .center_wide .p_thumb{display:inline-flex;height:5.8rem;width:5.8rem;margin-right:0;}
  954. .center_wide .p_row{display:block;}
  955. .interesting_tbody{background:none;}
  956. .interesting_tbody img{display:none !important;}
  957. .imd{margin-top:0.5em;margin-bottom:0.5em;line-height:0px;}
  958. .p_row .imd{margin-top:0em;margin-bottom:0em;}
  959. .center,.center>tbody,.center>tbody>tr,.center>tbody>tr>td{display:block;}
  960. .main>.center>tbody>tr{border:none;}
  961. .center>tbody>tr>td:first-child{display:none;color:rgba(0,0,0,0.5);}
  962. .center>tbody>tr>td:nth-child(2){display:none;color:rgba(0,0,0,0.5);}
  963. .center>tbody>tr>td:nth-child(2) a{display:none;color:rgba(0,0,0,0.5);}
  964. .center>tbody>tr>td:nth-child(3){margin:unset;padding:unset;}
  965. .post > td:nth-child(3) > *{margin:unset;padding:unset;}
  966. .wide_post_print{column-span:all;margin-top:1em;margin-bottom:1em;}
  967. }
  968. ";
  969. //$this->style=preg_replace('/%highlight_white%/','#5b3607',$this->style);
  970. //$this->style=preg_replace('/%highlight_slice%/','#734307',$this->style);
  971. //$this->style=preg_replace('/%grayslice%/','#442c0b',$this->style);
  972. //$this->style=preg_replace('/%post_white%/','#2d2110',$this->style);
  973. //$this->style=preg_replace('/%white%/','#231a0d',$this->style);
  974. //$this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
  975. //$this->style=preg_replace('/%gray%/','#ac7843',$this->style);
  976. //$this->style=preg_replace('/%graybkg%/','#39270e',$this->style);
  977. //$this->style=preg_replace('/%shadow%/','#000000cc',$this->style);
  978. $this->style=preg_replace('/%highlight_white%/','#804a06',$this->style);
  979. $this->style=preg_replace('/%highlight_slice%/','#ae6407',$this->style);
  980. $this->style=preg_replace('/%grayslice%/','#6a491c',$this->style);
  981. $this->style=preg_replace('/%post_white%/','#4a3413',$this->style);
  982. $this->style=preg_replace('/%white%/','#2d2214',$this->style);
  983. $this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
  984. $this->style=preg_replace('/%gray%/','#f8ca9b88',$this->style);
  985. $this->style=preg_replace('/%graybkg%/','#a9270e',$this->style);
  986. $this->style=preg_replace('/%shadow%/','#000000ee',$this->style);
  987. $f = fopen('styles/main.css','w');
  988. fwrite($f,$this->style);
  989. fclose($f);
  990. }
  991. function GiveSafeEMail(){
  992. return preg_replace('/\./u','[dot]',preg_replace('/\@/u','[at]',$this->EMail));
  993. }
  994. function &FindImage($name, $loose=false){ if(!isset($name) || !$name){ return $this->NULL_IMAGE; }
  995. if(isset($this->Images[0])) foreach($this->Images as &$im){
  996. if($loose) { if(preg_match('/'.preg_quote($name).'/u',$im['name'])) return $im; }
  997. else { if($im['name']==$name) return $im; }
  998. }
  999. return $this->NULL_IMAGE;
  1000. }
  1001. function &GiveImageInHere($rand=false){
  1002. $this->ReadImages(); $this->DetectPageType();
  1003. $album = $this->PageType=='here'?$this->HereAlbum:$this->ExpAlbum;
  1004. if(!isset($album) || !$album){
  1005. if(isset($this->Images[0])) return $this->Images[0]; else return $this->NULL_IMAGE; }
  1006. $imlist=[]; $imlist_fallback=[];
  1007. if(isset($this->Images[0])){
  1008. foreach($this->Images as &$im){
  1009. if(isset($im['galleries'][0]) && in_array($album,$im['galleries']) && $this->CanShowImage($im)){
  1010. if(!$rand) return $im; else {
  1011. $imlist_fallback[] = $im;
  1012. if(!in_array($im['name'],$this->VisitedHere)) $imlist[] = $im;
  1013. }
  1014. }
  1015. }
  1016. }
  1017. if(!$rand || !isset($imlist_fallback[0])) return $this->NULL_IMAGE;
  1018. if(sizeof($imlist)){
  1019. $r = random_int(0, sizeof($imlist)-1);
  1020. return $imlist[$r];
  1021. }else{
  1022. $r = random_int(0, sizeof($imlist_fallback)-1);
  1023. return $imlist_fallback[$r];
  1024. }
  1025. }
  1026. function ImageTitle($im){
  1027. $imtitle = (isset($im)&&isset($im['title']))?$im['title']:NULL;
  1028. if(isset($im['parent'])&&($imp = &$this->FindImage($im['parent'],true))&&isset($imp['title'])){ $imtitle=$imp['title']; }
  1029. return $imtitle;
  1030. }
  1031. function ImageHasHere(&$im, $here_name){
  1032. if(!isset($im['here'])||!isset($im['here'][0])) return false;
  1033. foreach($im['here'] as $h) { if($h[0] == $here_name) return true; } return false;
  1034. }
  1035. function ReadImages($clear_non_exist = false){
  1036. $path = 'images/list.md';
  1037. if($this->DoneReadImages){ return; }
  1038. if(!file_exists($path)){ $f = fopen($path,'w'); fflush($f); fclose($f); }
  1039. $c = file_get_contents($path);
  1040. if(preg_match_all('/GALLERY\s+(\S+)(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  1041. $g=[]; $g['name']=$m[1];//$g['count']=0;
  1042. if(preg_match('/FEATURED([^;]*?);/u', $m[2], $arg)){ $g['featured']=true; }
  1043. if(preg_match('/EXPERIMENTAL([^;]*?);/u', $m[2], $arg)){ $g['experimental']=true; }
  1044. if(preg_match('/DESCRIPTION\s+([^;]+);/u', $m[2], $arg)){ $g['description']=$arg[1]; }
  1045. $this->Galleries[] = $g;
  1046. }
  1047. if(preg_match_all('/^-\s*([^;]+)\s*?;\s*?(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  1048. $name = trim($m[1]);
  1049. $item = []; $item['file'] = 'images/'.$name; $item['name'] = $name;
  1050. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  1051. if(preg_match('/REFS\s+([^;]*);/u',$m[2],$refs) && preg_match_all('/[0-9]{14}/u',$refs[1],$rs, PREG_SET_ORDER)){
  1052. $item['refs']=[];
  1053. foreach($rs as $r){ if(!in_array($r[0], $item['refs'])) $item['refs'][] = $r[0]; }
  1054. }
  1055. if(preg_match('/GAL\s+([^;]*);/u',$m[2],$gals) && preg_match_all('/(\S+)/u',$gals[1],$ga, PREG_SET_ORDER)){
  1056. $item['galleries']=[];
  1057. foreach($ga as $g){ if(!in_array($g[0], $item['galleries'])) $item['galleries'][] = $g[0]; }
  1058. }
  1059. if(preg_match('/PRODUCT\s+([^;]*);/u',$m[2],$product)){ $item['product']=$product[1]; }
  1060. if(preg_match('/PARENT\s+([^;]*);/u',$m[2],$parent)){ $item['parent']=$parent[1]; }
  1061. if(preg_match('/TITLE\s+([^;]*);/u',$m[2],$title)){ $item['title']=$title[1]; }
  1062. if(preg_match('/ALIGN\s+([^;]*);/u',$m[2],$align)){ $item['align']=$align[1]; }
  1063. if(preg_match('/HERE\s+([^;]*);/u',$m[2],$heres) && preg_match_all('/(\S+)-(\S+)-(\S+)/u',$heres[1],$here, PREG_SET_ORDER)){
  1064. $item['here']=[];
  1065. foreach($here as $h){ if(!$this->ImageHasHere($item, $h[1])) $item['here'][] = [$h[1],$h[2],$h[3]]; }
  1066. }
  1067. if(preg_match('/\.mp4/u',$item['name'])){
  1068. $item['video']='video/mp4';
  1069. }
  1070. $this->Images[] = $item;
  1071. }
  1072. $files = array_merge([],glob('images/*.jpg'));
  1073. $files = array_merge($files,glob('images/*.jpeg'));
  1074. $files = array_merge($files,glob('images/*.png'));
  1075. $files = array_merge($files,glob('images/*.gif'));
  1076. $files = array_merge($files,glob('images/*.mp4'));
  1077. if(isset($files[0]))foreach($files as $file) {
  1078. if(preg_match('/[0-9]{14,}\.(jpg|jpeg|gif|png|mp4)/u', $file, $m)) {
  1079. $name = trim($m[0]);
  1080. if(!$this->FindImage($name)){
  1081. $item = []; $item['name']=$name; $item['file'] = 'images/'.$name;
  1082. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  1083. $this->Images[] = $item;
  1084. }
  1085. }
  1086. }
  1087. if($clear_non_exist){
  1088. if(isset($this->Images[0]) && isset($files[0])){
  1089. foreach($this->Images as &$im){
  1090. if(!in_array($im['file'],$files)){
  1091. $im['deleted'] = 1;
  1092. }
  1093. }
  1094. }
  1095. }
  1096. function cmpf($a, $b){
  1097. if ($a['name'] == $b['name']) return 0;
  1098. return (($a['name'] > $b['name']) ? 1 : -1);
  1099. }
  1100. function cmpaf($a, $b){
  1101. if ($a['name'] == $b['name']) return 0;
  1102. return ($a['name'] > $b['name']) ? -1 : 1;
  1103. }
  1104. if(isset($this->Galleries[0]))usort($this->Galleries,"cmpf");
  1105. if(isset($this->Images[0]))usort($this->Images,"cmpaf");
  1106. $this->DoneReadImages = 1;
  1107. }
  1108. function WriteImages(){
  1109. if(isset($this->WayBack)) return;
  1110. $path = 'images/list.md';
  1111. $f = fopen($path,'w');
  1112. if(isset($this->Galleries[0]))foreach($this->Galleries as &$g){
  1113. if(isset($g['deleted'])) continue;
  1114. fwrite($f,'GALLERY '.$g['name']);
  1115. if(isset($g['featured']) && $g['featured']!=false) { fwrite($f,' FEATURED;'); }
  1116. if(isset($g['experimental']) && $g['experimental']!=false) { fwrite($f,' EXPERIMENTAL;'); }
  1117. if(isset($g['description']) && $g['description']!="") { fwrite($f,' DESCRIPTION '.$g['description'].';'); }
  1118. fwrite($f, PHP_EOL);
  1119. }
  1120. if(isset($this->Images[0]))foreach($this->Images as &$im){
  1121. if(isset($im['deleted'])) continue;
  1122. fwrite($f, "- ".$im['name'].'; ');
  1123. if(isset($im['refs']) && isset($im['refs'][0])){ fwrite($f, 'REFS '.implode(" ",$im['refs'])."; "); }
  1124. if(isset($im['galleries']) && isset($im['galleries'][0])){ fwrite($f, 'GAL '.implode(" ",$im['galleries'])."; "); }
  1125. if(isset($im['product']) && $im['product']!=''){ fwrite($f, 'PRODUCT '.$im['product']."; "); }
  1126. if(isset($im['parent']) && $im['parent']!=''){ fwrite($f, 'PARENT '.$im['parent']."; "); }
  1127. if(isset($im['title']) && $im['title']!=''){ fwrite($f, 'TITLE '.$im['title']."; "); }
  1128. if(isset($im['align']) && $im['align']!='' && $im['align']!='middle'){ fwrite($f, 'ALIGN '.$im['align']."; "); }
  1129. if(isset($im['here']) && $im['here']!=''){ fwrite($f, 'HERE ');
  1130. foreach($im['here'] as $here){ fwrite($f, implode('-',$here).' '); } fwrite($f, '; ');
  1131. }
  1132. fwrite($f, PHP_EOL);
  1133. }
  1134. fflush($f);
  1135. fclose($f);
  1136. }
  1137. function EditImage($name, $link_gallery, $do_remove = false, $product_link=NULL, $rename=NULL, $parent=NULL, $align=NULL){
  1138. if(!($im = &$this->FindImage($name))) return;
  1139. if(isset($link_gallery)){
  1140. if($do_remove){
  1141. if(!isset($im['galleries']) || !isset($im['galleries'][0])) return;
  1142. foreach($im['galleries'] as $key => $g){ if ($g==$link_gallery) unset($im['galleries'][$key]); }
  1143. $im['galleries'] = array_merge($im['galleries']);
  1144. }else{
  1145. if(!isset($im['galleries'])) $im['galleries']=[];
  1146. foreach($im['galleries'] as &$g){ if ($g==$link_gallery) return; }
  1147. $im['galleries'][]=$link_gallery;
  1148. }
  1149. }
  1150. if(isset($product_link)){
  1151. if($product_link!=''){$im['product']=$product_link;}
  1152. else{unset($im['product']);}
  1153. }
  1154. if(isset($rename) && $rename!=$im['name']){
  1155. $ext=pathinfo($im['file'],PATHINFO_EXTENSION);
  1156. rename($im['file'], 'images/'.$rename.'.'.$ext);
  1157. if(isset($im['thumb'])) rename($im['thumb'], 'images/thumb/'.$rename.'.'.$ext);
  1158. $im['name'] = $rename.'.'.$ext;
  1159. }
  1160. if(isset($parent) && $parent!=$im['parent']){
  1161. if($parent==''){ unset($im['parent']); }
  1162. else{ $im['parent'] = $parent; }
  1163. }
  1164. if(isset($align) && in_array($align,['top','middle','bottom'])){
  1165. if($align=='middle'){ unset($im['align']); }
  1166. else{ $im['align']=$align; }
  1167. }
  1168. $this->NeedWriteImages = 1;
  1169. }
  1170. function RegenerateThumbnails(){
  1171. $glob = glob('images/*.jpg');
  1172. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1173. foreach($glob as $file) {
  1174. $thumb_destination = 'images/thumb/'.basename($file);
  1175. $img = new Imagick($file); $geo=$img->getImageGeometry();
  1176. $width=$geo['width']; $height=$geo['height'];
  1177. $lim=400;
  1178. $scale = $lim / min($width,$height);
  1179. if($scale<1){
  1180. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1181. }
  1182. $img->setImageFormat('jpeg');
  1183. $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1184. $img->setImageCompressionQuality(90);
  1185. $img->writeImage($thumb_destination);
  1186. }
  1187. }
  1188. function CleanupImageCompression($run=false){
  1189. $glob = glob('images/*.jpg');
  1190. if(!$run){
  1191. echo $this->T("将重新压缩下列文件:")."<style>img{max-width:10em;max-height:10em;}</style><ul>";
  1192. }
  1193. foreach($glob as $file) {
  1194. $destination = 'images/'.basename($file);
  1195. $img = new Imagick($file); $geo=$img->getImageGeometry();
  1196. $width=$geo['width']; $height=$geo['height'];
  1197. $interlace=$img->getImageInterlaceScheme();
  1198. $progressive=($interlace==imagick::INTERLACE_NO || $interlace==imagick::INTERLACE_LINE || $interlace==imagick::INTERLACE_UNDEFINED);
  1199. $sizelim=1920;$abs_max=2560;
  1200. $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
  1201. $sz=filesize($destination);
  1202. if($scale<0.98 && $sz>2097152 && $progressive){ /* need scale, greater than 2mb, and not interlaced */
  1203. if(!$run){
  1204. echo "<li><a href='index.php?pic=$destination'><img src='images/thumb/".basename($file)."'><br />$destination, $width x $height, $interlace</a></li>";
  1205. }else{
  1206. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1207. $img->setImageFormat('jpeg');
  1208. $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1209. $img->setImageCompressionQuality(90);
  1210. $img->writeImage($destination);
  1211. }
  1212. }
  1213. $img->clear();
  1214. }
  1215. if(!$run){
  1216. echo "</ul><a href='index.php?cleanup_image_compression=true&run=true'>".$this->T("立即执行")."</a>"; exit;
  1217. }
  1218. }
  1219. function CompressImage($source, $destination, $thumb_destination, $quality, $sizelim, $abs_max, $ext) {
  1220. $img = new Imagick($source); $geo=$img->getImageGeometry(); $img2 = clone $img;
  1221. $width=$geo['width']; $height=$geo['height'];
  1222. $lim=400;
  1223. $scale = $lim / min($width,$height);
  1224. if($scale<1){
  1225. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1226. }
  1227. $img->setImageFormat('jpeg');
  1228. $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1229. $img->setImageCompressionQuality($quality);
  1230. $img->writeImage($thumb_destination);
  1231. $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
  1232. if($scale<0.98 || ($ext!='jpg'&&$ext!='jpeg')){
  1233. $img2->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.5);
  1234. $img2->setImageFormat('jpeg');
  1235. $img2->setImageCompressionQuality($quality);
  1236. $img2->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1237. $img2->writeImage($destination);
  1238. }else{
  1239. rename($source,$destination);
  1240. }
  1241. }
  1242. function DoUpload(){
  1243. if(!isset($_FILES['upload_file_name'])) return 0;
  1244. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1245. if($_FILES['upload_file_name']['error']>0){
  1246. echo"file upload err code ".$_FILES['upload_file_name']['error']; exit;
  1247. return -1;
  1248. }else{
  1249. $ext=strtolower(pathinfo($_FILES['upload_file_name']['name'],PATHINFO_EXTENSION));
  1250. if(!in_array($ext,['jpg','jpeg','png','gif','mp4'])) return 0;
  1251. $fp = fopen('.la_lock',"w");
  1252. while (!flock($fp, LOCK_EX| LOCK_NB)){
  1253. usleep(10000);
  1254. }
  1255. $num=date('YmdHis'); $replace=0;
  1256. if(isset($_POST['image_replace_button']) && isset($_GET['pic']) && preg_match('/([0-9]{14,})/u',$_GET['pic'],$mim)){
  1257. $num = $mim[1]; $replace=1;
  1258. }
  1259. $base = 'images/'.$num;
  1260. $thumb = 'images/thumb/'.$num;
  1261. $use_ext=($ext=='gif' || $ext=='mp4')?('.'.$ext):('.jpg');
  1262. $final_path = $base.$use_ext; $final_thumb = $thumb.$use_ext; $i=0;
  1263. if(!$replace) while(file_exists($final_path)){
  1264. $final_path = $base.strval($i).$use_ext; $final_thumb = $thumb.strval($i).$use_ext; $i++;
  1265. }
  1266. if($ext!='gif' && $ext!='mp4'){
  1267. $compress = (isset($_GET['compress'])&&$_GET['compress']);
  1268. $this->CompressImage($_FILES['upload_file_name']['tmp_name'], $final_path, $final_thumb, 90,
  1269. $compress?800:1920, $compress?1920:2560, $ext);
  1270. }else{
  1271. move_uploaded_file($_FILES['upload_file_name']['tmp_name'], $final_path);
  1272. }
  1273. flock($fp, LOCK_UN);
  1274. fclose($fp);
  1275. $this->ReadImages(true);
  1276. $this->WriteImages();
  1277. echo '<uploaded>'.pathinfo($final_path,PATHINFO_BASENAME)."</uploaded>";
  1278. if(isset($_POST['image_replace_button'])){
  1279. header('Location: '.$_SERVER['REQUEST_URI']);exit;
  1280. }
  1281. exit;
  1282. return 1;
  1283. }
  1284. return 0;
  1285. }
  1286. function &GetGallery($name){
  1287. if(isset($this->Galleries[0])) foreach($this->Galleries as &$g){
  1288. if($g['name'] == $name) return $g;
  1289. }
  1290. return $this->NULL_GALLERY;
  1291. }
  1292. function EditGallery($name, $new_name=null, $delete=false, $do_rw=true, $set_featured=null, $set_experimental=null,$desc=null){
  1293. $this->ReadImages();
  1294. $gallery = &$this->GetGallery($name);
  1295. if(!isset($gallery)){
  1296. if(!isset($new_name) || preg_match('/main|trash|\s/u',$new_name))return;
  1297. $g = []; $g['name']=$new_name;
  1298. $this->Galleries[]=$g;
  1299. }else{
  1300. if(isset($new_name)) {
  1301. if(preg_match('/main|trash|\s/u',$new_name))return;
  1302. $gallery['name'] = $new_name;
  1303. foreach ($this->Images as &$im){
  1304. if(isset($im['galleries'])&&isset($im['galleries'][0]))foreach($im['galleries'] as &$g){
  1305. if($g == $name){ $g = $new_name; }
  1306. }
  1307. }
  1308. }
  1309. //if(isset($count)) $gallery['count'] = $count;
  1310. if(isset($delete) && $delete) $gallery['deleted'] = true;
  1311. if(isset($set_featured)) $gallery['featured'] = $set_featured;
  1312. if(isset($set_experimental)) $gallery['experimental'] = $set_experimental;
  1313. if(isset($desc)) $gallery['description'] = $desc;
  1314. }
  1315. if($do_rw) { $this->NeedWriteImages = 1; }
  1316. }
  1317. function ClearData(){
  1318. $this->Posts = [];
  1319. $this->Threads = [];
  1320. $this->Images = [];
  1321. $this->Archive = [];
  1322. $this->ArchiveHandles = [];
  1323. }
  1324. function InsertArchivePost(&$post){
  1325. $a = NULL;
  1326. if(($a = &$this->GetArchiveHandle($post['id']))==$this->NULL_POST){
  1327. $ah = []; $ah['id'] = $post['id']; $ah['list'] = [];
  1328. $this->ArchiveHandles[] = &$ah; $a = &$ah;
  1329. }
  1330. $a['list'][] = $post;
  1331. $this->Archive[] = $post;
  1332. }
  1333. function ReadArchiveFromFile($path){
  1334. if(!file_exists($path)){
  1335. return;
  1336. }
  1337. $c = file_get_contents($path);
  1338. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1339. foreach($matches as $m){
  1340. $post = [];
  1341. $post['id'] = $m[1];
  1342. $post['content'] = trim($m[3]);
  1343. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1344. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1345. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1346. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1347. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1348. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1349. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1350. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1351. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1352. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1353. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1354. if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
  1355. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1356. foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
  1357. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1358. $post['merged_into'] = [trim($n[1]),trim($n[2])];
  1359. }
  1360. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1361. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1362. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1363. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1364. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1365. }
  1366. $this->InsertArchivePost($post);
  1367. }
  1368. }
  1369. }
  1370. function SortArchive(){
  1371. $cmpac = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1372. $cmpap = function($a, $b){ if ($a['id'] == $b['id']) return ((($a['version'] > $b['version']) ? 1 : -1));
  1373. return (($a['id'] > $b['id']) ? 1 : -1);
  1374. };
  1375. if(isset($this->Archive[0])){
  1376. usort($this->Archive,$cmpap);
  1377. $year_begin = substr($this->Archive[0]['id'],0,4);
  1378. $this->YearBegin = ($year_begin<$this->YearBegin)?$year_begin:$this->YearBegin;
  1379. }
  1380. if(isset($this->ArchiveHandles[0])){
  1381. usort($this->ArchiveHandles,$cmpac);
  1382. foreach($this->ArchiveHandles as &$a){
  1383. if(isset($a['list'])){ usort($a['list'],$cmpap);
  1384. $last_valid=NULL;
  1385. foreach($a['list'] as &$ver){ $ver['archive']= &$a;
  1386. if(isset($ver['merged_thread'])){ $ver['content']=$last_valid; }
  1387. else{ $last_valid = $ver['content']; } }
  1388. if(isset($a['list'][0]['version'])&&$a['list'][0]['version']>$a['list'][0]['id']){ /* if early versions missing. */
  1389. $origin=$a['list'][0]; $origin['version']=$origin['id']; array_unshift($a['list'], $origin);
  1390. }
  1391. }
  1392. if(($p = &$this->GetPost($a['id'],true))!=NULL){
  1393. $p['archive'] = &$a;
  1394. }
  1395. }
  1396. }
  1397. }
  1398. function ReadPostsFromFile($path){
  1399. if(!file_exists($path)){
  1400. $f = fopen($path,'w');
  1401. fclose($f);
  1402. }
  1403. $c = file_get_contents($path);
  1404. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1405. foreach($matches as $m){
  1406. $post = [];
  1407. $post['id'] = $m[1];
  1408. $post['real_content'] = trim($m[3]);
  1409. $post['content'] = &$post['real_content'];
  1410. if(preg_match('/COMMENT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['comment_to'] = $n[1];
  1411. if(preg_match('/EMAIL\s+([^;]+)\s*;/u', $m[2], $n)) $post['email'] = $n[1];
  1412. if(preg_match('/NAME\s+([^;]+)\s*;/u', $m[2], $n)) $post['name'] = $n[1];
  1413. if(preg_match('/LINK\s+([^;]+)\s*;/u', $m[2], $n)) $post['link'] = $n[1];
  1414. if(preg_match('/IP\s+([^;]+)\s*;/u', $m[2], $n)) $post['ip'] = $n[1];
  1415. if(preg_match('/NEXT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['next'] = $n[1];
  1416. if(preg_match('/PREV\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['prev'] = $n[1];
  1417. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1418. if(preg_match('/MDEL\s*;/u', $m[2])) $post['mark_delete'] = True;
  1419. if(preg_match('/MVAL\s*([^;]+);/u', $m[2], $n)) $post['mark_value'] = trim($n[1]);
  1420. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1421. if(preg_match('/REFS\s*([^;]+);/u', $m[2], $ma)){
  1422. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1423. foreach($links as $l){ $entries[] = $l[1]; } $post['refs'] = $entries; } }
  1424. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1425. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1426. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1427. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1428. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1429. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1430. if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
  1431. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1432. foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
  1433. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1434. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1435. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1436. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1437. $post['merged_into'] = [trim($n[1]),trim($n[2])]; }
  1438. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1439. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1440. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1441. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1442. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1443. }
  1444. if(preg_match('/NUM\s+([0-9]{1,})\s*;/u', $m[2], $n)){ $post['number']=$n[1]; $this->PNUMBER=max($post['number'],$this->PNUMBER); }
  1445. else{ $this->PNUMBER++; $post['number']=$this->PNUMBER; }
  1446. //$this->PNUMBER++; $post['number']=$this->PNUMBER;
  1447. if(isset($post['mark_value']) && $post['mark_value']==5){
  1448. $post['product']=[];
  1449. }
  1450. /* marks add here */
  1451. $this->Posts[] = $post;
  1452. if(isset($post['comment_to']) && ($target_post = &$this->GetPost($post['comment_to'],true))){
  1453. if(!isset($target_post['comments']) || !isset($target_post['comments'][0])) $target_post['comments']=[];
  1454. $target_post['comments'][]=&$this->Posts[count($this->Posts) - 1];
  1455. }
  1456. }
  1457. }
  1458. }
  1459. function SortPosts($wayback=false){
  1460. $cmpp = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1461. $sortlist = &$this->Posts;
  1462. if($wayback) $sortlist = &$this->WaybackPosts;
  1463. if(isset($sortlist[0])){
  1464. usort($sortlist,$cmpp);
  1465. $this->YearEnd = substr($this->TIME_STRING,0,4);
  1466. $this->YearBegin = substr($sortlist[0]['id'],0,4);
  1467. }
  1468. }
  1469. function ReadPosts(){
  1470. if ((!file_exists('la_config.md') || is_readable('la_config.md') == false) ||
  1471. (!file_exists('la_config.php') || is_readable('la_config.php') == false) ||
  1472. (!is_dir('posts') || is_readable('posts') == false) ||
  1473. (!is_dir('archive') || is_readable('archive') == false) ||
  1474. (!is_dir('images') || is_readable('images') == false) ||
  1475. (!is_dir('styles') || is_readable('styles') == false)){
  1476. $this->Install();
  1477. }
  1478. if($this->DoneReadPosts){ return; }
  1479. $file_list = [];
  1480. $glob = glob('posts/*');
  1481. foreach($glob as $file) {
  1482. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1483. $file_list[] = $file;
  1484. }
  1485. }
  1486. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1487. foreach($file_list as $f) {
  1488. $this->ReadPostsFromFile($f);
  1489. }
  1490. $this->SortPosts();
  1491. $this->DetectThreads();
  1492. $this->DoneReadPosts=1;
  1493. }
  1494. function UpdatePostRefsForWayback(){
  1495. if(!isset($this->WayBack)) return;
  1496. if(isset($this->Images[0])) foreach($this->Images as &$i){ unset($i['refs']); }
  1497. if(!isset($this->WaybackPosts[0])) return;
  1498. foreach($this->WaybackPosts as &$p){ unset($p['refs']); }
  1499. foreach($this->WaybackPosts as &$p){
  1500. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $r){
  1501. $pr = &$this->GetPost($r); if(isset($pr)){
  1502. if(!isset($pr['refs'])) $pr['refs']=[];
  1503. if(!in_array($p['id'],$pr['refs'])){ $pr['refs'][] = $p['id']; }
  1504. }
  1505. }
  1506. if(isset($p['hasi']) && isset($p['hasi'][0])) foreach($p['hasi'] as $r){
  1507. $ir = &$this->FindImage($r); if(isset($ir)){
  1508. if(!isset($ir['refs'])) $ir['refs']=[];
  1509. if(!in_array($p['id'],$ir['refs'])){ $ir['refs'][] = $p['id'];}
  1510. }
  1511. }
  1512. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1513. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1514. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$p['id']; }
  1515. }
  1516. }
  1517. }
  1518. function ReadArchive(){
  1519. if (!is_dir('archive') || is_readable('archive') == false){ $this->Install(); }
  1520. if ($this->DoneReadArchive) return;
  1521. $file_list = []; $glob = glob('archive/*');
  1522. foreach($glob as $file) {
  1523. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1524. $file_list[] = $file;
  1525. }
  1526. }
  1527. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1528. foreach($file_list as $f) {
  1529. $this->ReadArchiveFromFile($f);
  1530. }
  1531. $this->SortArchive();
  1532. $this->DoneReadArchive=1;
  1533. $this->UpdateThreadForWayback();
  1534. $this->UpdatePostRefsForWayback();
  1535. }
  1536. function GetThreadForPost(&$post){
  1537. if(isset($post['tid'])) return;
  1538. $th = []; $iterp = NULL;
  1539. $post['tid'] = &$th; $th['first'] = &$post; $th['last'] = &$post;
  1540. if(!(isset($post['prev']) || isset($post['next']))) { $this->Threads[] = &$th; return; }
  1541. if(isset($post['prev']))for($p = $post['prev']; $p!=NULL; $p = $iterp){
  1542. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1543. $np['tid'] = &$th;
  1544. $th['first'] = &$np;
  1545. $iterp = isset($np['prev'])?$np['prev']:NULL;
  1546. }
  1547. if(isset($post['next']))for($p = $post['next']; $p!=NULL; $p = $iterp){
  1548. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1549. $np['tid'] = &$th;
  1550. $th['last'] = &$np;
  1551. $iterp = isset($np['next'])?$np['next']:NULL;
  1552. }
  1553. if(isset($th['first']['mark_value'])){
  1554. if($th['first']['mark_value']==6) $th['exp'] = true;
  1555. else if($th['first']['mark_value']>=7) $th['slf'] = true;
  1556. if($th['first']['mark_value']==8) $th['sln'] = true;
  1557. }
  1558. if($th['first'] == $th['last']){ unset($post['tid']); return; }
  1559. $this->Threads[] = &$th;
  1560. }
  1561. function IdentifyThreadCategory(&$th,&$first_post){
  1562. unset($th['categories']);unset($th['interesting']);unset($th['reversed']);
  1563. if(preg_match('/^\s*\@(.*?)$/mu',$first_post['content'],$m)){
  1564. $first_post['categories']=[]; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1565. foreach($matches as $ma){ $first_post['categories'][] = $ma[1]; }
  1566. }
  1567. if(isset($th) && $th){ $th['categories'] = &$first_post['categories']; }
  1568. }
  1569. if(preg_match('/\{\s*WIDE\s*\}/imu',$first_post['content'],$m)){ $first_post['wide'] = true; }
  1570. if(preg_match('/\{\s*NO_TIME\s*\}/imu',$first_post['content'],$m)){ $first_post['no_time'] = true; }
  1571. if(preg_match('/\{\s*NO_TITLE\s*\}/imu',$first_post['content'],$m)){ $first_post['no_title'] = true; }
  1572. if(preg_match('/\{\s*SLIDES\s*\}/imu',$first_post['content'],$m)){ $first_post['slides'] = true; }
  1573. if(preg_match('/\{\s*HEADER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['header'] = trim($m[1]); }
  1574. if(preg_match('/\{\s*FOOTER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['footer'] = trim($m[1]); }
  1575. if(!isset($th)) return;
  1576. if(isset($first_post['wide'])) $th['wide']=$first_post['wide'];
  1577. if(isset($first_post['header'])) $th['header']=$first_post['header'];
  1578. if(isset($first_post['footer'])) $th['footer']=$first_post['footer'];
  1579. if(isset($first_post['no_time'])) $th['no_time']=$first_post['no_time'];
  1580. if(isset($first_post['slides'])) $th['slides']=$first_post['slides'];
  1581. if(isset($first_post['no_title'])) $th['no_title']=$first_post['no_title'];
  1582. if(preg_match('/\{\s*INTERESTING\s+(.*?)\}/imu',$first_post['content'],$m)){
  1583. $th['interesting'] = []; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1584. foreach($matches as $ma){ $th['interesting'][] = $ma[1]; }
  1585. }
  1586. }
  1587. if(preg_match('/\{\s*REVERSED(\s+.*?)?\}/imu',$first_post['content'],$m)){ $th['reversed'] = 'm';
  1588. if(isset($m[1])&&preg_match('/^\s*(y|m|d|p)/iu',$m[1],$ma)){ $th['reversed']=$ma[1]; }
  1589. }
  1590. }
  1591. function IsInterestingPost(&$p){
  1592. if(isset($p['tid']) && isset($p['tid']['interesting']) && isset($p['tid']['interesting'][0])) return true;
  1593. return false;
  1594. }
  1595. function IsReversedThread(&$th){
  1596. if(isset($th['reversed']) && $th['reversed']!=false) return true;
  1597. return false;
  1598. }
  1599. function GiveAllMergedPosts(&$po,&$arr){
  1600. if(isset($po['merged_from'])&&isset($po['merged_from'][0])) foreach($po['merged_from'] as $pm){
  1601. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr);}
  1602. }
  1603. if(isset($po['archive']) && isset($po['archive']['list'])){
  1604. foreach($po['archive']['list'] as &$ver){
  1605. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $pm){
  1606. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr); } }
  1607. }
  1608. }
  1609. }
  1610. function ThreadMakeWayback(&$th){
  1611. if(!isset($th['arr'][0])) return;
  1612. if(isset($this->WayBack)){
  1613. $remlist = [];
  1614. foreach($th['arr'] as &$pi){
  1615. $po = &$this->GetPost($pi['id'],true); if(!isset($po)){continue;/*merged*/}
  1616. if(isset($po['merged_thread']) && isset($po['version']) && $po['version']>$this->WayBack){
  1617. $remlist = array_unique(array_merge($remlist,$po['merged_thread'][0]));
  1618. }
  1619. $ah = &$this->GetArchiveHandle($po['id']);
  1620. if(isset($ah)) foreach(array_reverse($ah['list']) as &$ver){
  1621. if(!isset($ver['merged_thread'])) continue;
  1622. if((isset($ver['version']) && $ver['version'] > $this->WayBack) ||
  1623. (!isset($ver['version']) && $ver['id'] > $this->WayBack)){
  1624. $remlist = array_unique(array_merge($remlist,$ver['merged_thread'][0]));
  1625. }
  1626. }
  1627. }
  1628. if(isset($remlist[0]) && isset($th['arr'][0])){
  1629. foreach($remlist as $rem){ $this->GiveAllMergedPosts($this->GetPost($rem,true),$remlist); }
  1630. foreach($th['arr'] as $key => $pr){
  1631. foreach($remlist as $rem){ if($pr['id'] == $rem) { unset($th['arr'][$key]); break; } } }
  1632. $new_th = []; $new_arr = [];
  1633. foreach($remlist as $rem){ $np=&$this->GetPost($rem); if(isset($np)){$new_arr[]=&$np;} }
  1634. $new_th['arr'] = &$new_arr;
  1635. $this->WaybackThreads[] = &$new_th;
  1636. $this->ThreadMakeWayback($new_th);
  1637. }
  1638. }
  1639. }
  1640. function AddMergedPosts(&$p, &$array){
  1641. if(isset($p['archive']) && isset($p['archive']['list'])){
  1642. foreach($p['archive']['list'] as &$ver){
  1643. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $po){
  1644. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1645. }
  1646. }
  1647. if(isset($p['merged_from'])&&isset($p['merged_from'][0])) foreach($p['merged_from'] as $po){
  1648. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1649. }
  1650. function &array_shift_ref(&$array){if(count($array)>0){$key=key($array);$first=&$array[$key];}else{$first=null;}array_shift($array);return $first;}
  1651. function FinalizeThread(&$th, $relink_posts=false, $now=0){
  1652. $nextp=NULL; $arr=[]; $lasttime=NULL;
  1653. if(!isset($th['arr'])){
  1654. for($p = &$th['first']; $p!=$this->NULL_POST; $p = &$this->GetPost(isset($p['next'])?$p['next']:NULL,true)){
  1655. $arr[]=&$p;
  1656. } $th['arr'] = &$arr;
  1657. if(isset($this->WayBack) && $this->DoneReadArchive){ $new_arr=[];
  1658. foreach($arr as &$p){ $pa = &$this->GetPost($p['id']); if(isset($pa)) {$new_arr[]=&$pa;$this->WaybackPosts[]=&$pa;} }
  1659. foreach($arr as &$p){ $this->AddMergedPosts($p,$new_arr); }
  1660. $arr=&$new_arr; $th['arr']=&$new_arr;
  1661. $this->ThreadMakeWayback($th); }
  1662. }
  1663. $cmppt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1664. if(isset($th['arr'][0])){ usort($th['arr'],$cmppt); } $th['count'] = sizeof($th['arr']);
  1665. if($relink_posts){ $count = $th['count'];
  1666. $arr = &$th['arr'];
  1667. 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'];
  1668. $arr[$i]['tid']=&$th;}
  1669. $th['first'] = &$arr[0]; $th['last'] = &$arr[$count-1]; unset($arr[0]['prev']); unset($arr[$count-1]['next']);
  1670. }
  1671. $th['score'] = 0; if(!isset($th['first'])){ return; }
  1672. $this->IdentifyThreadCategory($th, $th['first']);
  1673. if(isset($this->WayBack)) $lasttime=$this->WayBack;
  1674. if(!isset($last_time)) $lasttime = DateTime::createFromFormat('YmdHis', $th['last']['id']);
  1675. $diff_days = ($now - date_timestamp_get($lasttime))/3600/24;
  1676. $th['score'] = (float)$th['count']*0.2 - min($diff_days,200);
  1677. if(isset($th['reversed'])){ $chunks=[]; $last_id=$last_y=$last_m=$last_d=0; $mo=$th['reversed']; $final=[];
  1678. $first_post=&$this->array_shift_ref($th['arr']); $ch=[];
  1679. while($n=&$this->array_shift_ref($th['arr'])){
  1680. $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);
  1681. if($mo=='y'&&$this_y!=$last_y){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y; }
  1682. if($mo=='m'&&$this_m!=$last_m){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y.'/'.$this_m; }
  1683. if($mo=='d'&&$this_d!=$last_d){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y.'/'.$this_m.'/'.$this_d; }
  1684. if($mo=='p'){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} }
  1685. $ch[]=&$n; $last_id=$this_id; $last_y=$this_y; $last_m=$this_m; $last_d=$this_d;
  1686. }if(isset($ch[0])){$chunks[]=$ch;} if(isset($chunks[0])){$use_chunks=array_reverse($chunks);}
  1687. $final[]=&$first_post;
  1688. foreach($use_chunks as &$ch){ foreach($ch as &$p){ $final[]=&$p;} }
  1689. $th['arr']=$final; }
  1690. }
  1691. function SortThreads(){
  1692. if (!function_exists('cmpt')) {
  1693. function cmpt($a, $b){
  1694. if ($a['score'] == $b['score']) return 0;
  1695. return ($a['score'] > $b['score']) ? -1 : 1;
  1696. }
  1697. }
  1698. usort($this->Threads,"cmpt");
  1699. }
  1700. function DetectThreads(){
  1701. foreach($this->Posts as &$p){
  1702. if(isset($p['tid'])) { continue; }
  1703. $this->GetThreadForPost($p);
  1704. if(!isset($p['tid'])) { $this->IdentifyThreadCategory($this->NULL_POST, $p); }
  1705. }
  1706. if(!isset($this->Threads) || !isset($this->Threads[0])) return;
  1707. $now = date_timestamp_get(date_create());
  1708. foreach($this->Threads as &$t){
  1709. $this->FinalizeThread($t,false,$now);
  1710. }
  1711. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1712. $this->FinalizeThread($th,false,$now);
  1713. $this->Threads[] = &$th;
  1714. }
  1715. $this->SortThreads();
  1716. }
  1717. function UpdateThreadForWayback(){$now = date_timestamp_get(date_create());
  1718. if(!isset($this->WayBack) || !$this->DoneReadArchive){ return; }
  1719. foreach($this->Threads as &$t){
  1720. unset($t['arr']); $this->FinalizeThread($t,true,$now);
  1721. }
  1722. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1723. $this->FinalizeThread($th,true,$now);
  1724. $this->Threads[] = &$th;
  1725. }
  1726. $this->SortThreads();
  1727. $this->SortPosts(true);
  1728. $this->UsePosts = &$this->WaybackPosts;
  1729. }
  1730. function &GetMergedPost($id){
  1731. $this->ReadArchive();
  1732. $ah = &$this->GetArchiveHandle($id);
  1733. if(!isset($ah) || !isset($ah['list']) || !isset($ah['list'][0])){ return $this->NULL_POST; }
  1734. $ver = &$ah['list'][sizeof($ah['list'])-1];
  1735. if(!isset($ver['merged_into'])) return $this->GetPost($id);
  1736. [$tp, $tver] = $ver['merged_into'];
  1737. if(isset($this->WayBack)){
  1738. if($tver <= $this->WayBack) return $this->GetMergedPost($tp);
  1739. else return $this->GetPost($id); /* should not happen directly. */
  1740. }
  1741. return $this->GetMergedPost($tp);
  1742. }
  1743. function &GetPost($id, $latest_only=false, $find_merged=false){
  1744. if(!isset($id)) return $this->NULL_POST;
  1745. $found=&$this->NULL_POST;
  1746. if(isset($this->Posts[0])) foreach($this->Posts as &$p){
  1747. if($p&& $p['id'] == $id) { $found = &$p; break; }
  1748. if($find_merged && isset($p['hastag'][0]) && in_array($id, $p['hastag'])){ $found = &$p; break; }
  1749. }
  1750. if($latest_only || !isset($this->WayBack)){ return $found; }
  1751. else{
  1752. if(isset($found)){
  1753. if(!isset($found['archive'])&&!isset($found['archive']['list']))
  1754. { if($found['id'] > $this->WayBack) return $this->NULL_POST; else return $found; }
  1755. $last_ver = &$this->NULL_POST;
  1756. if(isset($found['archive']['list'][0])) foreach($found['archive']['list'] as &$ver){
  1757. if($ver['version'] > $this->WayBack) return $last_ver;
  1758. $last_ver = &$ver;
  1759. }
  1760. if(isset($found['version']) && $found['version'] <= $this->WayBack) return $found;
  1761. else return $last_ver;
  1762. }else{
  1763. $ah = &$this->GetArchiveHandle($id); $last_ver = &$this->NULL_POST;
  1764. if(isset($ah) && isset($ah['list']) && isset($ah['list'][0])) foreach($ah['list'] as &$ver){
  1765. if($ver['version'] > $this->WayBack) return $last_ver;
  1766. $last_ver = &$ver;
  1767. } if(!isset($last_ver['merged_into'])) return $last_ver; else{
  1768. [$tp, $tver] = $last_ver['merged_into'];
  1769. if($tver <= $this->WayBack) {
  1770. if($find_merged && $tp!=$id) return $this->GetPost($tp); return $this->NULL_POST; }
  1771. return $last_ver;
  1772. }
  1773. }
  1774. }
  1775. return $this->NULL_POST;
  1776. }
  1777. function &GetArchiveHandle($id){
  1778. if(!isset($id)) return $this->NULL_POST;
  1779. if(isset($this->ArchiveHandles[0])) foreach($this->ArchiveHandles as &$p){
  1780. if($p && $p['id'] == $id) { return $p; }
  1781. }
  1782. return $this->NULL_POST;
  1783. }
  1784. function &GetArchive($id){
  1785. if(!isset($id)) return $this->NULL_POST;
  1786. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1787. if($p && $p['id'] == $id) { return $p; }
  1788. }
  1789. return $this->NULL_POST;
  1790. }
  1791. function &GetArchiveVersion(&$ah, $version, &$next_ver, &$last_ver){
  1792. if(!isset($ah)) return $this->NULL_POST;
  1793. $found = NULL; $last_verp=NULL;
  1794. if(isset($ah['list'][0])) foreach($ah['list'] as &$p){
  1795. if(isset($found)){ $next_ver = $p; $last_ver = $last_verp; return $found; }
  1796. if($p && $p['version'] == $version) { $found = &$p; continue; }
  1797. $last_verp = &$p;
  1798. }
  1799. if(isset($found)) { $next_ver=NULL; $last_ver = $last_verp; return $found; }
  1800. return $this->NULL_POST;
  1801. }
  1802. function CacheArchiveOwnLinks(){
  1803. if(isset($this->WayBack)) return;
  1804. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1805. $this->ConvertPost($p); unset($p['hasp']); unset($p['hasi']); unset($p['hastag']);
  1806. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$p['html'],$matches,PREG_SET_ORDER)){
  1807. foreach($matches as $m){
  1808. if(!isset($p['hasp']))$p['hasp']=[]; if(!in_array($m[1],$p['hasp'])){ $p['hasp'][]=$m[1]; }
  1809. }
  1810. }
  1811. if(preg_match_all('/\/\/([0-9]{14})/u', $p['content'],$matches,PREG_SET_ORDER)){
  1812. foreach($matches as $m){
  1813. if(!isset($p['hastag']))$p['hastag']=[]; if(!in_array($m[1],$p['hastag'])){ $p['hastag'][]=$m[1]; }
  1814. }
  1815. }
  1816. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\)/u', $p['content'],$matches,PREG_SET_ORDER)){
  1817. foreach($matches as $m){
  1818. if(!isset($p['hasi']))$p['hasi']=[]; if(!in_array($m[2],$p['hasi'])){ $p['hasi'][]=$m[2]; }
  1819. }
  1820. }
  1821. }
  1822. }
  1823. function WriteArchive(){
  1824. if(isset($this->WayBack)) return;
  1825. $cf = NULL;$opened =NULL;
  1826. $this->SortArchive();
  1827. $this->CacheArchiveOwnLinks();
  1828. if(isset($this->Archive[0])) foreach($this->Archive as $p){
  1829. $nid = substr($p['id'], 0,6);
  1830. if($cf != $nid){
  1831. if($opened){
  1832. fflush($opened);
  1833. fclose($opened);
  1834. }
  1835. $cf = $nid;
  1836. $opened = fopen("archive/$cf.md", 'w');
  1837. }
  1838. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1839. "VER {$p['version']}; ".
  1840. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1841. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1]).";"):"").
  1842. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1843. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1844. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1845. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1846. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1847. ']';
  1848. if(isset($p['merged_thread'])){ $p['content']=""; }
  1849. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['content'].PHP_EOL.PHP_EOL);
  1850. }
  1851. }
  1852. function WritePosts(){
  1853. if(isset($this->WayBack)) return;
  1854. $cf = NULL;$opened =NULL;
  1855. $this->SortPosts();
  1856. if(isset($this->Posts[0])) foreach($this->Posts as $p){
  1857. $nid = substr($p['id'], 0,6);
  1858. if($cf != $nid){
  1859. if($opened){
  1860. fflush($opened);
  1861. fclose($opened);
  1862. }
  1863. $cf = $nid;
  1864. $opened = fopen("posts/$cf.md", 'w');
  1865. }
  1866. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1867. ((isset($p['number']) && $p['number'])?"NUM {$p['number']}; ":"").
  1868. ((isset($p['version']) && $p['version'])?"VER {$p['version']}; ":"").
  1869. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1870. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1871. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1872. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1])."; "):"").
  1873. ((isset($p['comment_to']) && $p['comment_to'])?"COMMENT {$p['comment_to']}; ":"").
  1874. ((isset($p['email']) && $p['email'])?"EMAIL {$p['email']}; ":"").
  1875. ((isset($p['name']) && $p['name'])?"NAME {$p['name']}; ":"").
  1876. ((isset($p['link']) && $p['link'])?"LINK {$p['link']}; ":"").
  1877. ((isset($p['ip']) && $p['ip'])?"IP {$p['ip']}; ":"").
  1878. ((isset($p['mark_delete']) && $p['mark_delete'])?"MDEL; ":"").
  1879. ((isset($p['mark_value']) && $p['mark_value']>=0)?"MVAL {$p['mark_value']}; ":"").
  1880. ((isset($p['next']) && $p['next'])?"NEXT {$p['next']}; ":"").
  1881. ((isset($p['prev']) && $p['prev'])?"PREV {$p['prev']}; ":"").
  1882. ((isset($p['refs']) && isset($p['refs'][0]))?("REFS ".implode(" ",$p['refs'])."; "):"").
  1883. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1884. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1885. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1886. ((isset($p['mastodon_url']) && isset($p['mastodon_url']))?("MSTDN ".$p['mastodon_url']."; "):"").
  1887. ']';
  1888. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['real_content'].PHP_EOL.PHP_EOL);
  1889. }
  1890. }
  1891. function CachePostLinks(){
  1892. if(isset($this->WayBack)) return;
  1893. if(isset($this->Posts) && isset($this->Posts[0]))foreach ($this->Posts as &$post){
  1894. $this->ConvertPost($post);
  1895. unset($post['refs']);unset($post['hasp']);unset($post['hasi']);unset($post['hastag']);
  1896. //discard lost old version
  1897. //if(!isset($post['archive']) && $this->DoneReadArchive && isset($post['version'])){ unset($post['version']); }
  1898. }else return;
  1899. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1900. unset($im['refs']); unset($im['here']); unset($im['title']);
  1901. }
  1902. foreach ($this->Posts as &$post){
  1903. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$post['html'],$matches,PREG_SET_ORDER)){
  1904. foreach($matches as $m){
  1905. $ref = &$this->GetPost($m[1],true);
  1906. if($ref!=NULL){
  1907. if(!isset($ref['refs']))$ref['refs']=[]; if(!in_array($post['id'],$ref['refs']))$ref['refs'][]=$post['id'];
  1908. }
  1909. if(!isset($post['hasp']))$post['hasp']=[]; if(!in_array($m[1],$post['hasp']))$post['hasp'][]=$m[1];
  1910. }
  1911. }
  1912. if(preg_match_all('/\/\/([0-9]{14})/u', $post['content'],$matches,PREG_SET_ORDER)){
  1913. foreach($matches as $m){
  1914. if(!isset($post['hastag']))$post['hastag']=[]; if(!in_array($m[1],$post['hastag']))$post['hastag'][]=$m[1];
  1915. }
  1916. }
  1917. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\)/u', $post['content'],$matches,PREG_SET_ORDER)){
  1918. foreach($matches as $m){
  1919. if(($im = &$this->FindImage($m[2]))!=NULL){
  1920. if(!isset($im['refs']))$im['refs']=[]; if(!in_array($post['id'], $im['refs']))$im['refs'][] = $post['id'];
  1921. }
  1922. if(!isset($post['hasi']))$post['hasi']=[]; if(!in_array($m[2],$post['hasi']))$post['hasi'][]=$m[2];
  1923. }
  1924. }
  1925. if(preg_match("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\))(\R*(\R(-|\*).+){1,})/u",
  1926. $post['content'],$matches)){
  1927. $use_img_name = $matches[2];
  1928. if(($im = &$this->FindImage($use_img_name))!=NULL){
  1929. 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",
  1930. $matches[4],$mah,PREG_SET_ORDER)){
  1931. foreach($mah as $ma){
  1932. if(!isset($im['here']))$im['here']=[]; if(!$this->ImageHasHere($item, $ma[4])){
  1933. $here = [$ma[4], $ma[2], $ma[3]]; $im['here'][] = $here; }
  1934. }
  1935. }
  1936. }
  1937. }
  1938. }foreach($this->Posts as &$post){
  1939. if(isset($post['hasp']) && isset($post['hasp'][0])) foreach($post['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1940. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1941. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$post['id']; }
  1942. }
  1943. }
  1944. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1945. $min_id = '99999999999999';
  1946. if(isset($im['refs']) && isset($im['refs'][0])) foreach ($im['refs'] as &$ref){
  1947. $r = &$this->GetPost($ref,true); if(isset($r)) $title = $this->GetPostTitle($r,true,false);
  1948. if($title && $ref<$min_id) { $im['title'] = preg_replace('/;/u',' ',trim($title)); $min_id=$r['id']; }
  1949. }
  1950. }
  1951. }
  1952. function CreatePostAnchor(&$post){
  1953. $that=&$this;
  1954. $post['html'] = preg_replace_callback('/<h([0-9])>(.+?)(?=<\/h[0-9]>)/u', function ($ma) use ($that){
  1955. $id = '_heading_'.sizeof($this->Anchors);
  1956. $entry=[(int)$ma[1], $id, $ma[2]];
  1957. $that->Anchors[] = $entry;
  1958. return "<h{$ma[1]} id='{$id}'>{$ma[2]}";
  1959. }, $post['html']);
  1960. }
  1961. function RenamePost(&$post, $rename){
  1962. foreach($this->Posts as &$p){
  1963. if($p['id']==$rename && $p!==$post) { return; /* don't overwrite */ }
  1964. }
  1965. foreach($this->Posts as &$p){
  1966. if(isset($p['prev']) && $p['prev']==$post['id']) { $p['prev']=$rename; }
  1967. if(isset($p['next']) && $p['next']==$post['id']) { $p['next']=$rename; }
  1968. }
  1969. $post['id'] = $rename;
  1970. }
  1971. function DetachPost(&$th,&$post){
  1972. $p0=$p1=NULL;foreach($th['arr'] as $a) echo $a['id']." "; echo '&nbsp;&nbsp;&nbsp;-'.$post['id']."<br />";
  1973. if(isset($post['prev'])){$p0=&$this->GetPost($post['prev'],true);} if(isset($post['next'])){$p1=&$this->GetPost($post['next'],true);}
  1974. if(isset($p0)){ $p0['next']=$p1['id']; }else{ $th['first']=$p1['id']; }
  1975. if(isset($p1)){ $p1['prev'] =$p0['id']; }else{ $th['last']=$p0['id']; }
  1976. foreach($this->Posts as $key => $p){ if ($p==$post) unset($this->Posts[$key]); }
  1977. unset($th['arr']); $now = date_timestamp_get(date_create());
  1978. $this->FinalizeThread($th, true, $now);
  1979. }
  1980. function PushPostVersion(&$post, $optime_id, $mode=1, $info=NULL){
  1981. $a = &$this->GetArchiveHandle($post['id']);
  1982. $ap = []; $ap['id'] = $post['id']; $ap['content'] = $post['real_content'];
  1983. $ap['version'] = isset($post['version'])?$post['version']:$ap['id'];
  1984. if(isset($post['merged_from'])) { $ap['merged_from'] = $post['merged_from']; unset($post['merged_from']); }
  1985. if(isset($post['merged_into'])) { $ap['merged_into'] = $post['merged_into']; unset($post['merged_into']); }
  1986. if(isset($post['merged_thread'])) { $ap['merged_thread'] = $post['merged_thread']; unset($post['merged_thread']); }
  1987. $post['version'] = $optime_id;
  1988. if($mode==1){
  1989. $this->InsertArchivePost($ap);
  1990. }else if($mode==2){
  1991. $post['merged_from'] = $info;
  1992. $this->InsertArchivePost($ap);
  1993. }else if($mode==3){
  1994. $ap['merged_into'] = $info;
  1995. $this->InsertArchivePost($ap);
  1996. if(isset($post['tid']) && $post['tid']['first']!=$post['tid']['last'] && $post!=$post['tid']['first']){
  1997. $this->DetachPost($post['tid'], $post);
  1998. }
  1999. }else if($mode==4){
  2000. $post['merged_thread'] = $info;
  2001. $this->InsertArchivePost($ap);
  2002. }
  2003. }
  2004. function &MergeThreads($post_id, $post_into_id){
  2005. $this->ReadPosts();
  2006. $po = &$this->GetPost($post_id, true); $pt = &$this->GetPost($post_into_id, true);
  2007. if (!isset($po) || !isset($pt) || !isset($po['tid']) || !isset($pt['tid']) ||
  2008. !isset($po['tid']['arr'][0]) || !isset($pt['tid']['arr'][0])){ return $this->NULL_POST; }
  2009. $po = &$po['tid']['arr'][0]; $pt = &$pt['tid']['arr'][0];
  2010. $th = &$po['tid']; $tt = &$pt['tid']; $info=[[],[]];
  2011. if($po['id'] < $pt['id']){ $temp = &$th; $th=&$tt; $tt=&$temp; $temp = &$po; $po=&$pt; $pt=&$temp; }
  2012. foreach($th['arr'] as &$p){ $info[0][]=$p['id']; }
  2013. foreach($tt['arr'] as &$p){ $info[1][]=$p['id']; }
  2014. $this->EditPost($pt['id'], NULL, NULL, NULL, false, NULL, NULL, 4, $info,NULL);
  2015. $arr_combined = array_merge($tt['arr'],$th['arr']);
  2016. $cmppmt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  2017. if(isset($arr_combined[0])){ usort($arr_combined,$cmppmt); } $tt['arr']=&$arr_combined;
  2018. $tt['count'] = sizeof($tt['arr']);
  2019. $this->FinalizeThread($tt, true, $this->TIME_STRING);
  2020. $first_post = &$this->NULL_POST;
  2021. if(isset($tt['arr'][0])) $first_post= &$tt['arr'][0];
  2022. $this->NeedWritePosts=1;
  2023. $this->NeedWriteArchive=1;
  2024. return $first_post;
  2025. }
  2026. function &MergePosts($ids_string){
  2027. $ids = explode(" ", $ids_string);
  2028. $combined_content = ""; $first_id=NULL;
  2029. $this->ReadPosts(); $child_list=[];
  2030. foreach($ids as $id){
  2031. if(!preg_match('/[0-9]{14}/u',$id) || $this->GetPost($id,true)==$this->NULL_POST) continue;
  2032. if(!isset($first_id)) { $first_id = $id; } else { $combined_content.=PHP_EOL.PHP_EOL."//".$id.PHP_EOL; $child_list[]=$id; }
  2033. $combined_content.=$this->EditPost($id, NULL, NULL, NULL, true, NULL, NULL, false, NULL,NULL);
  2034. }
  2035. if(!isset($child_list[0])) return $this->NULL_POST;
  2036. $first_post = &$this->EditPost($first_id, $combined_content, NULL, NULL, false, NULL, NULL, 2, $child_list,NULL);
  2037. foreach($child_list as $id){
  2038. $this->EditPost($id, NULL, NULL, NULL, false, NULL, NULL, 3, [$first_id,$this->TIME_STRING],NULL);
  2039. }
  2040. $this->NeedWritePosts=1;
  2041. $this->NeedWriteArchive=1;
  2042. return $first_post;
  2043. }
  2044. /* push_version: 1 edit 2 post merged from ids list 3 post end into id-ver */
  2045. function &EditPost($id_if_edit, $content, $mark_delete, $reply_to,
  2046. $get_original_only=false, $mark_value=NULL, $rename=NULL,
  2047. $push_version=false, $version_info=NULL, $mastodon_url=NULL){
  2048. $this->ReadImages();
  2049. $this->ReadPosts();
  2050. if(isset($push_version) && $push_version){
  2051. $this->ReadArchive();
  2052. }
  2053. $p_success = NULL;
  2054. if(isset($id_if_edit)){
  2055. $post = &$this->GetPost($id_if_edit,true);
  2056. if($post===$this->NULL_POST) return $this->NULL_POST;
  2057. if($get_original_only){
  2058. return $post['real_content'];
  2059. }
  2060. if(isset($push_version) && $push_version){
  2061. $this->PushPostVersion($post,$this->TIME_STRING,$push_version,$version_info);
  2062. }
  2063. if(isset($content)) {$post['real_content'] = $content; $post['content'] = &$post['real_content'];}
  2064. if(isset($mark_delete)) $post['mark_delete'] = $mark_delete;
  2065. if(isset($mark_value)) $post['mark_value'] = $mark_value;
  2066. if(isset($rename) && preg_match('/^[0-9]{14}$/u',$rename)) $this->RenamePost($post,$rename);
  2067. if(isset($mastodon_url)) { if($mastodon_url!='') $post['mastodon_url']=$mastodon_url; else unset($post['mastodon_url']); }
  2068. $p_success = &$post;
  2069. }else{
  2070. if(!isset($content)) return $this->NULL_POST;
  2071. $id = date('YmdHis');
  2072. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  2073. $post = []; $post['id'] = $id;
  2074. $post['real_content'] = $content; $post['content'] = &$post['real_content'];
  2075. if(isset($mark_value) && $mark_value!==NULL) $post['mark_value'] = $mark_value;
  2076. if(isset($reply_to) && ($rep = &$this->GetPost($reply_to,true))!== $this->NULL_POST){
  2077. while($rep !== $this->NULL_POST && isset($rep['next']) && $rep['next']){ $rep = &$this->GetPost($rep['next'],true); }
  2078. if($rep !== $this->NULL_POST){ $rep['next'] = $id; $post['prev'] = $rep['id']; }
  2079. }
  2080. $this->Posts[] = $post;
  2081. $p_success = &$this->Posts[count($this->Posts) - 1];
  2082. }
  2083. $this->NeedWritePosts=1;
  2084. $this->NeedWriteImages=1;
  2085. if(isset($push_version) && $push_version){
  2086. $this->NeedWriteArchive=1;
  2087. }
  2088. return $p_success;
  2089. }
  2090. function &EditComment($id_if_edit, $comment_to_id, $content, $email, $name, $link=NULL, $ip=NULL){
  2091. $this->ReadPosts();
  2092. $p_success = NULL;
  2093. if(isset($id_if_edit)){
  2094. $post = &$this->GetPost($id_if_edit,true);
  2095. if($post===$this->NULL_POST || !isset($post['comment_to'])) return $this->NULL_POST;
  2096. if(isset($content)) $post['content'] = $content;
  2097. if(isset($comment_to_id)) $post['comment_to'] = $comment_to_id;
  2098. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  2099. if(isset($ip)) $post['ip'] = $ip;
  2100. $p_success = &$post;
  2101. }else{
  2102. if(!isset($content) || !isset($comment_to_id)) return $this->NULL_POST;
  2103. $id = date('YmdHis');
  2104. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  2105. if(!($to_post=$this->GetPost($comment_to_id,true))) return $this->NULL_POST;
  2106. $post = []; $post['id'] = $id; $post['content'] = $content; $post['comment_to'] = $comment_to_id;
  2107. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  2108. if(isset($ip)) $post['ip'] = $ip;
  2109. $this->Posts[] = $post;
  2110. $p_success = &$this->Posts[count($this->Posts) - 1];
  2111. }
  2112. $this->NeedWritePosts=1;
  2113. return $p_success;
  2114. }
  2115. function InsertReplacementSymbols($MarkdownContent, &$post_for_it_is_here){
  2116. $replacement = preg_replace('/<!--[\s\S]*-->/U',"",$MarkdownContent);
  2117. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  2118. function($matches){
  2119. $rep = preg_replace('/->/','-@>',$matches[0]);
  2120. $rep = preg_replace('/=>/','=@>',$rep);
  2121. $rep = preg_replace('/<=/','<@=',$rep);
  2122. $rep = preg_replace('/<-/','<@-',$rep);
  2123. $rep = preg_replace('/\R([+]{3,})\R/',PHP_EOL.'@$1'.PHP_EOL,$rep);
  2124. $rep = preg_replace('/\[-/','[@-',$rep);
  2125. $rep = preg_replace('/\{/','{@',$rep);
  2126. $rep = preg_replace('/(en|zh|any)\|(en|zh|any)/','$1@|$2',$rep);
  2127. return $rep;
  2128. },
  2129. $replacement);
  2130. $replacement = preg_replace("/<[-]+>/","↔",$replacement);
  2131. $replacement = preg_replace("/([^-])->/","$1→",$replacement);
  2132. $replacement = preg_replace("/<-([^-])/","←$1",$replacement);
  2133. $replacement = preg_replace("/([^-])[-]+->/","$1⟶",$replacement);
  2134. $replacement = preg_replace("/<-[-]+([^-])/","⟵$1",$replacement);
  2135. $replacement = preg_replace("/<[=]+>/","⇔",$replacement);
  2136. $replacement = preg_replace("/[=]+>/","⇒",$replacement);
  2137. $replacement = preg_replace("/<[=]+/","⇐",$replacement);
  2138. $replacement = preg_replace("/\R([+]{3,})\R/","<div class='page_break'></div>",$replacement);
  2139. $replacement = preg_replace("/\[-(.*)-\]/U","<span class='text_highlight'>$1</span>",$replacement);
  2140. $replacement = preg_replace("/{支付宝(\s+[^}]*?)?}/u","<span class='special_alipay'>支付宝$1</span>",$replacement);
  2141. $replacement = preg_replace("/{PayPal(\s+[^}]*?)?}/ui",
  2142. "<span class='special_paypal'>Pay<span class='special_paypal_inner'>Pal</span>$1</span>",$replacement);
  2143. $replacement = preg_replace("/\/\/([0-9]{14})/imu","<p class='wscroll' id='$1'>".$this->T("链接位置")."</p>",$replacement);
  2144. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  2145. function($matches){
  2146. $rep = preg_replace('/-@>/','->',$matches[0]);
  2147. $rep = preg_replace('/<@-/','<-',$rep);
  2148. $rep = preg_replace('/=@>/','=>',$rep);
  2149. $rep = preg_replace('/<@=/','<=',$rep);
  2150. $rep = preg_replace('/\R@([+]{3,})\R/',PHP_EOL.'$1'.PHP_EOL,$rep);
  2151. $rep = preg_replace('/\[@-/','[-',$rep);
  2152. $rep = preg_replace('/\{@/','{',$rep);
  2153. $rep = preg_replace('/(en|zh|any)@\|(en|zh|any)/','$1|$2',$rep);
  2154. return $rep;
  2155. }, $replacement);
  2156. $replacement = preg_replace_callback("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\))(\R*(\R.+){1,})/u",
  2157. function($matches) use (&$post_for_it_is_here){
  2158. $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]);
  2159. return $matches[1].$rep;
  2160. }, $replacement);
  2161. return $replacement;
  2162. }
  2163. function CanShowPost(&$p,$in_recent=false){
  2164. if(!isset($p) || isset($p['comment_to'])) return false;
  2165. $is_mark_exp = (isset($p['tid'])&&isset($p['tid']['exp'])&&$p['tid']['exp']) || (isset($p['mark_value'])&&$p['mark_value']==6);
  2166. $is_mark_slf = (isset($p['tid'])&&isset($p['tid']['slf'])&&$p['tid']['slf']) || (isset($p['mark_value'])&&$p['mark_value']>=7);
  2167. $is_mark_sln = (isset($p['tid'])&&isset($p['tid']['sln'])&&$p['tid']['sln']) || (isset($p['mark_value'])&&$p['mark_value']==8);
  2168. if($is_mark_slf && !$this->LoggedIn){ return false; }
  2169. if(isset($this->WayBack)){
  2170. if(isset($p['version'])) { if ($p['version']>$this->WayBack) return false; }
  2171. else if ($p['id']>$this->WayBack) return false;
  2172. }
  2173. if(!$this->InExperimentalMode){
  2174. if(!$this->LoggedIn){
  2175. if($is_mark_exp) return false;
  2176. return true;
  2177. }
  2178. if($this->NotesView && !$is_mark_sln && $in_recent){ return false; }
  2179. return true;
  2180. }else{
  2181. if($is_mark_exp) return true;
  2182. return false;
  2183. }
  2184. }
  2185. function SkipProduct(&$p){
  2186. if($this->LoggedIn) return false;
  2187. return (isset($p['mark_value']) && $p['mark_value']==5);
  2188. }
  2189. function GetRedirect($args=NULL, $force_index=NULL){ global $INDEXPHP;
  2190. $str = (isset($force_index)?$force_index:$INDEXPHP).'?';
  2191. if(isset($args['post'])) $str.='&post='.$args['post'];
  2192. else if(isset($_GET['post'])) $str.='&post='.$_GET['post'];
  2193. if(isset($args['gallery'])) $str.='&gallery='.$args['gallery'];
  2194. else if(isset($_GET['gallery'])) $str.='&gallery='.$_GET['gallery'];
  2195. if(isset($args['pic'])) $str.='&pic='.$args['pic'];
  2196. else if(isset($_GET['pic'])) $str.='&pic='.$_GET['pic'];
  2197. if(isset($args['settings'])) $str.='&settings='.$args['settings'];
  2198. else if(isset($_GET['settings'])) $str.='&settings='.$_GET['settings'];
  2199. if(isset($args['statistics'])) $str.='&statistics='.$args['statistics'];
  2200. else if(isset($_GET['statistics'])) $str.='&statistics='.$_GET['statistics'];
  2201. if(isset($args['extras'])) $str.='&extras='.$args['extras'];
  2202. else if(isset($_GET['extras'])) $str.='&extras='.$_GET['extras'];
  2203. if(isset($args['category'])) $str.='&category='.$args['category'];
  2204. else if(isset($_GET['category'])) $str.='&category='.$_GET['category'];
  2205. if(isset($args['history'])) $str.='&history='.$args['history'];
  2206. else if(isset($_GET['history'])) $str.='&history='.$_GET['history'];
  2207. if(isset($args['version'])) $str.='&version='.$args['version'];
  2208. else if(isset($_GET['version'])) $str.='&version='.$_GET['version'];
  2209. if(isset($args['search'])) $str.='&search='.$args['search'];
  2210. else if(isset($_GET['search'])) $str.='&search='.$_GET['search'];
  2211. if(isset($args['here'])) $str.='&here='.$args['here'];
  2212. else if(isset($_GET['here'])) $str.='&here='.$_GET['here'];
  2213. return $str;
  2214. }
  2215. function WriteAsNecessary(){
  2216. if(!$this->LoggedIn || isset($this->WayBack)){return;}
  2217. if($this->NeedWritePosts){ $this->CachePostLinks(); $this->WritePosts(); }
  2218. if($this->NeedWriteImages){ $this->WriteImages(); }
  2219. if($this->NeedWriteArchive){ $this->WriteArchive(); }
  2220. }
  2221. function APubEnsureWebfinger($name, $host){
  2222. if(!is_dir('.well-known')) mkdir('.well-known');
  2223. if(!is_dir('.well-known/webfinger')) mkdir('.well-known/webfinger');
  2224. $f = fopen('.well-known/webfinger/index.php',"w");
  2225. $without_protocol = parse_url($host, PHP_URL_HOST);
  2226. $finger = ["subject"=>"acct:".$name.'@'.$without_protocol,
  2227. "links"=>[["rel"=>"self", "type"=>"application/activity+json", "href"=>$host."?apub_actor=1"]]];
  2228. fwrite($f, "<?php header('Content-Type: application/json'); echo '".json_encode($finger, JSON_UNESCAPED_SLASHES)."'; ?>"); fclose($f);
  2229. if(!file_exists('.well-known/apub_public_key.pem') || !file_exists('.well-known/apub_private_key.php')){
  2230. $res = openssl_pkey_new();
  2231. $this->APubPublicKey = openssl_pkey_get_details($res)['key'];
  2232. openssl_pkey_export($res, $this->APubPrivateKey);
  2233. $f = fopen('.well-known/apub_public_key.pem',"w");
  2234. fwrite($f, $this->APubPublicKey); fclose($f);
  2235. $f = fopen('.well-known/apub_private_key.php',"w");
  2236. fwrite($f, "<?php exit; ?>".PHP_EOL.PHP_EOL.$this->APubPrivateKey); fclose($f);
  2237. }
  2238. }
  2239. function APubInit(){
  2240. $kf = file_get_contents('.well-known/apub_private_key.php'); if($kf===false) return;
  2241. preg_match("/(-----BEGIN PRIVATE KEY-----[\s\S]*)/",$kf,$ma); $this->APubPrivateKey=$ma[1];
  2242. }
  2243. function APubEnsureInfo(){
  2244. if(!isset($this->APubID) || !isset($this->HostURL)) return;
  2245. if(!file_exists('.well-known/apub_public_key.pem')){$this->APubEnsureWebfinger($this->APubID, $this->HostURL);}
  2246. $pk = file_get_contents('.well-known/apub_public_key.pem'); //$pk = preg_replace('/\n/u','\\n',$pk);
  2247. $actor = ["@context"=>["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1"],
  2248. "id"=> $this->HostURL."?apub_actor=1",
  2249. "type"=> "Person",
  2250. "name"=> $this->DisplayName,
  2251. "url"=> $this->HostURL,
  2252. "summary"=> "Lazy... No summary",
  2253. "preferredUsername"=> $this->APubID,
  2254. "inbox"=> $this->HostURL."?apub_inbox=1",
  2255. "outbox"=> $this->HostURL."?apub_outbox=1",
  2256. "publicKey"=> ["id"=> $this->HostURL."?apub_actor=1#main-key",
  2257. "owner"=> $this->HostURL."?apub_actor=1",
  2258. "publicKeyPem"=>$pk]];
  2259. $this->APubActor = json_encode($actor, JSON_UNESCAPED_SLASHES);
  2260. }
  2261. function APubMakeOutbox(){
  2262. $this->ReadPosts();$this->ReadImages();
  2263. $obj = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2264. "id"=>$this->HostURL."?apub_outbox=1",
  2265. "type"=>"OrderedCollection"];
  2266. $items=[]; $i=0;
  2267. foreach(array_reverse($this->Posts) as &$p){
  2268. $this->ConvertPost($p);
  2269. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$p['html']));
  2270. $time = DateTime::createFromFormat('YmdHis', $p['id'], new DateTimeZone('+0800'));
  2271. $ob = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2272. "type"=> "Create",
  2273. "id"=> $this->HostURL."?post=".$p['id']."?apub_object=1",
  2274. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2275. //"to"=> ["https://chatty.example/ben/"],
  2276. "actor"=> $this->HostURL."?apub_actor=1",
  2277. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2278. "object"=> ["type"=> "Note",
  2279. "id"=> $this->HostURL."?post=".$p['id'],
  2280. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2281. "attributedTo"=> $this->HostURL."?apub_actor=1",
  2282. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2283. "content"=> $text]];
  2284. $items[] = $ob;
  2285. $i++; if($i>20) break;
  2286. }
  2287. $obj['orderedItems'] = $items; $obj["totalItems"] = sizeof($items);
  2288. return json_encode($obj, JSON_UNESCAPED_SLASHES);
  2289. }
  2290. function APubDeliver($body,$target){
  2291. $head_digest = base64_encode(hash("sha256",$body,true));
  2292. $body_digest = "SHA-256=".$head_digest;
  2293. // rfc standards require the timezone be declared as GMT and PHP's built-in formats all say UTC
  2294. // so we gotta do it manually
  2295. $d = new DateTimeImmutable("now", new DateTimeZone('Asia/Shanghai'));
  2296. $d=$d->setTimezone(new DateTimeZone('UTC'));
  2297. $date=$d->format("D, d M Y H:i:s")." GMT";
  2298. $data = "(request-target): post ".parse_url($target,PHP_URL_PATH)
  2299. ."\nhost: ".parse_url($target,PHP_URL_HOST)
  2300. ."\ndate: $date"
  2301. ."\ndigest: $body_digest";
  2302. if (openssl_sign($data, $signature, $this->APubPrivateKey, OPENSSL_ALGO_SHA256) === FALSE) {
  2303. http_response_code(500); die('unable to sign');
  2304. }
  2305. $signature = base64_encode($signature);
  2306. $keyid = 'keyId="'.$this->HostURL.'?apub_actor=1#main-key"';
  2307. $algo = 'algorithm="rsa-sha256"';
  2308. $headers = 'headers="(request-target) host date digest"';
  2309. $signature = "signature=\"$signature\"";
  2310. $h = array(
  2311. 'Content-Type: application/activity+json',
  2312. 'Accept: application/activity+json',
  2313. //"Content-Length: ".strlen($body),
  2314. "Host: ". parse_url($target,PHP_URL_HOST),
  2315. "Date: $date",
  2316. "Digest: $body_digest",
  2317. "Signature: $keyid,$algo,$headers,$signature"
  2318. );
  2319. $ch = curl_init($target);
  2320. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  2321. curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
  2322. curl_setopt($ch, CURLOPT_HTTPHEADER, $h);
  2323. curl_setopt($ch, CURLOPT_USERAGENT, "laMDWiki APub");
  2324. $result = curl_exec($ch);
  2325. curl_close($ch); echo "<pre>";
  2326. print_r($body); echo "\n\n".$target."\n\n";
  2327. print_r($result); echo "\n\n"; print_r($h);
  2328. echo "\n\n"; print_r(curl_getinfo($ch)); echo "</pre>"; exit;
  2329. return $result;
  2330. }
  2331. function APubTestDeliver(){
  2332. $this->APubInit();
  2333. $obj=[];
  2334. $obj['published']=gmdate("Y-m-d\TH:i:s\Z");
  2335. $obj['id']=""; //<-------------------
  2336. $obj['url']=$this->HostURL.""; //<-------------------
  2337. $obj['type']='Note';
  2338. $obj['attributedTo']=$this->HostURL."?apub_actor=1";
  2339. $tag=[]; $tag['type']='Mention'; $tag['name']="@chengdulittlea"; $tag['href']="https://mastodon.art/users/chengdulittlea";
  2340. $obj['tag']=[$tag];
  2341. // must have cc to have notification in mastodon.
  2342. $obj['cc']=["https://mastodon.art/users/chengdulittlea"];
  2343. $obj['content']="<p>@chengdulittlea Hello activitypub from laMDWiki!</p>";
  2344. $obj['to']="https://www.w3.org/ns/activitystreams#Public";
  2345. $obj['inReplyTo']=""; //<-------------------
  2346. $arr=[];
  2347. $arr['@context']="https://www.w3.org/ns/activitystreams";
  2348. $arr['id']=""; //<-------------------
  2349. $arr['actor']=$this->HostURL."?apub_actor=1";
  2350. $arr['type']="Create";
  2351. $arr['to']="https://www.w3.org/ns/activitystreams#Public";
  2352. $arr['object']=$obj;
  2353. $this->APubDeliver(json_encode($arr),"https://mastodon.example/inbox"); //<-------------------
  2354. }
  2355. function APubProcessInbox(){
  2356. $r = file_get_contents('php://input');
  2357. file_put_contents('postdump.txt',$r);
  2358. }
  2359. function MakeRSS(){
  2360. $this->ReadPosts();$this->ReadImages();
  2361. $posts = []; if(isset($this->UsePosts[0])){
  2362. $posts = array_reverse($this->UsePosts);
  2363. $last_updated = $this->StandardTime($posts[0]['id']);
  2364. }else{ $last_updated= $this->StandardTime("20000101000000"); }
  2365. $author = "<author><name>".$this->DisplayName."</name><email>".$this->EMail."</email><uri>".$this->HostURL."</uri></author>";
  2366. $all_content="<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom'>".
  2367. "<id>".$this->HostURL."/?rss</id>".
  2368. "<updated>".$last_updated."</updated>".
  2369. "<title>".$this->T($this->Title)."</title>".
  2370. "<link href='".$this->HostURL."/index.php?rss=".($this->LanguageAppendix=='zh'?'zh':'en')."' rel='self'/>".
  2371. "<link href='".$this->HostURL."' />".$author;
  2372. $i=0;
  2373. if(isset($posts[0])) foreach($posts as &$p){
  2374. if($i>100) break;
  2375. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  2376. if(isset($p['tid'])){ /* Should always be set. */
  2377. $th = &$p['tid']; if($p['tid']['count']==0) continue; }
  2378. if(in_array($p['id'],
  2379. [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
  2380. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  2381. $is_thread = isset($p['tid']['count'])&&($p['tid']['count']>1);
  2382. $is_reversed=false;
  2383. $content="<entry>"; $title = NULL;
  2384. if($is_thread){
  2385. $use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false; if($is_reversed){
  2386. $use_arr=array_reverse($th['arr']); $fp=array_pop($use_arr); array_unshift($use_arr,$fp); }
  2387. foreach($use_arr as &$po){
  2388. $this->ConvertPost($po);
  2389. if(!isset($title)){$title = htmlspecialchars($this->GetPostTitle($po, false, false)); if(!$title){$title='untitled';}
  2390. $content.="<id>".$this->HostURL."/?post=".$po['id']."</id>";
  2391. $content.="<title type='html'>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$po['id']."' />";
  2392. $content.="<published>".$this->StandardTime($po['id'])."</published>";
  2393. $content.="<updated>".$this->StandardTime(isset($po['tid']['last']['version'])?
  2394. $po['tid']['last']['version']:$po['tid']['last']['id'])."</updated>".$author;
  2395. $content.="<content type='html'>"; }
  2396. $content.= htmlspecialchars($po['html']);
  2397. //if(isset($po['images'])&&isset($po['images'][0])) foreach($po['images'] as $im){ $content.=htmlspecialchars($im); }
  2398. }
  2399. $content.=$this->ReadableTime($p['tid']['first']['id'])." - ".
  2400. $this->ReadableTime(isset($p['tid']['last']['version'])?
  2401. $p['tid']['last']['version']:$p['tid']['last']['id']);
  2402. $content.="</content>";
  2403. }else{
  2404. $this->ConvertPost($p);
  2405. if(!isset($title)){$title = htmlspecialchars($this->GetPostTitle($p, false, false)); if(!$title){$title='untitled';}
  2406. $content.="<id>".$this->HostURL."/?post=".$p['id']."</id>";
  2407. $content.="<title type='html'>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$p['id']."' />";
  2408. $content.="<published>".$this->StandardTime($p['id'])."</published>";
  2409. $content.="<updated>".$this->StandardTime(isset($p['tid']['last']['version'])?
  2410. $p['tid']['last']['version']:$p['tid']['last']['id'])."</updated>".$author;}
  2411. $content.= "<content type='html'>".htmlspecialchars($p['html']);
  2412. //if(isset($p['images'])&&isset($p['images'][0])) foreach($p['images'] as $im){ $content.=htmlspecialchars($im); }
  2413. $content.=$this->ReadableTime($p['id'])." - ".
  2414. $this->ReadableTime(isset($p['version'])?$p['version']:$p['id']);
  2415. $content.="</content>";
  2416. }
  2417. $i++;
  2418. $content.="</entry>";
  2419. $all_content.=$content;
  2420. }
  2421. $all_content.="</feed>";
  2422. header( "Content-type: text/xml");
  2423. echo $all_content;
  2424. }
  2425. function MakeHereButtons($im, $insert_here){
  2426. if(isset($im['here'])&&isset($im['here'][0])){
  2427. $size=getimagesize($im['file']); $aspect=$size[0]/$size[1];
  2428. echo ($insert_here?"<here>":"")."<div class='here_buttons_inner' style='aspect-ratio:".$aspect.";'>";
  2429. foreach($im['here'] as $here){
  2430. if($insert_here){
  2431. echo "<a href='?show_image=".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'".
  2432. "onclick='event.preventDefault();event.stopPropagation();ShowBigImage(\"".$here[0]."\",1);'></a>";
  2433. }else{
  2434. echo "<a href='?here=images/".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'></a>";
  2435. }
  2436. }
  2437. echo "</div>".($insert_here?"</here>":"");
  2438. }
  2439. }
  2440. function ProcessRequest(&$message=NULL, &$redirect=NULL){ global $INDEXPHP;
  2441. if(isset($_GET['gallery_continue']) && $_GET['gallery']){
  2442. $this->ReadImages();
  2443. $this->GetImageBatch($_GET['gallery_continue'],0);
  2444. exit;
  2445. }
  2446. if(isset($_GET['gallery']) && $_GET['gallery']=='default'){
  2447. $redirect = "$INDEXPHP?gallery=".(isset($this->DefaultGallery)&&$this->DefaultGallery!=''?$this->DefaultGallery:"main");
  2448. return 0;
  2449. }
  2450. if(isset($_GET['set_language'])){
  2451. setcookie('la_language',$_GET['set_language'],time()+3600*24*7,'/'); $_COOKIE['la_language'] = $_GET['set_language'];
  2452. $redirect=$this->GetRedirect(); return 0;
  2453. }
  2454. if(isset($_GET['rss'])){
  2455. if(in_array($_GET['rss'],['en','zh'])){$this->LanguageAppendix=$_GET['rss'];}
  2456. $this->MakeRSS(); exit;
  2457. }
  2458. if(isset($_GET['toggle_font'])){ $use_font='local';
  2459. if(!isset($_COOKIE['la_font']) || $_COOKIE['la_font']!='remote') $use_font='remote';
  2460. setcookie('la_font',$use_font,time()+3600*24*7,'/'); $_COOKIE['la_font'] = $use_font;
  2461. $redirect=$this->GetRedirect(); return 0;
  2462. }
  2463. if(isset($_GET['set_wayback'])){
  2464. if($_GET['set_wayback']!='false'){
  2465. $wayback= date('YmdHis');
  2466. if($_GET['set_wayback']=='post'){
  2467. if(isset($_POST['wayback_year'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_year'],4,"0",STR_PAD_LEFT),0,4);
  2468. if(isset($_POST['wayback_month'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_month'],2,"0",STR_PAD_LEFT),4,2);
  2469. if(isset($_POST['wayback_day'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_day'],2,"0",STR_PAD_LEFT),6,2);
  2470. if(isset($_POST['wayback_hour'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_hour'],2,"0",STR_PAD_LEFT),8,2);
  2471. if(isset($_POST['wayback_minute'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_minute'],2,"0",STR_PAD_LEFT),10,2);
  2472. }else{ if(preg_match('/[0-9]{14}/u', $_GET['set_wayback'])) $wayback = $_GET['set_wayback']; }
  2473. setcookie('la_wayback',$wayback,'/'); $_COOKIE['la_wayback'] = $wayback;
  2474. }else{
  2475. setcookie('la_wayback', null, -1,'/'); unset($_COOKIE['la_wayback']);
  2476. }
  2477. $redirect=$this->GetRedirect(); return 0;
  2478. }
  2479. if(isset($_GET['post'])){ $this->CurrentPostID = $_GET['post']; $this->TagID = $this->CurrentPostID; }
  2480. if(isset($_GET['here'])){ $this->HereID = $_GET['here']; }
  2481. if(isset($_GET['offset'])){ $this->CurrentOffset = $_GET['offset']; }
  2482. if(isset($_GET['post'])){
  2483. $this->ExtraScripts.="window.addEventListener('load', (event) => {ScrollToPost('".$_GET['post']."');});";
  2484. }
  2485. if(isset($_GET['random_here'])){
  2486. $this->DoIdentifyExperimental(); $this->DetectPageType();
  2487. $im = &$this->GiveImageInHere(true); if(isset($im)){ $redirect='?here=images/'.$im['name']; return 0; }
  2488. }
  2489. if(isset($_POST['search_content'])){ $redirect=$INDEXPHP.'?search='.$_POST['search_content'];return 0; }
  2490. if(isset($_GET['image_info']) || isset($_GET['show_image'])){
  2491. $m=isset($_GET['image_info'])?$_GET['image_info']:$_GET['show_image'];
  2492. $direct_return = !isset($_GET['show_image']);
  2493. $this->ReadImages(); $this->ReadPosts();
  2494. $this->SwitchWayBackMode(); if(isset($this->WayBack)){$this->ReadArchive();}
  2495. $im = &$this->FindImage($m);
  2496. if($im==NULL || !isset($im['refs']) || !isset($im['refs'][0])){ echo "not_found"; exit; }
  2497. if($direct_return){
  2498. echo "<ref>".sizeof($im['refs'])."</ref>";
  2499. echo "<insert>";
  2500. }else{ ob_start(); }
  2501. $STR="";
  2502. $this->TBackup();
  2503. foreach(array_reverse($im['refs']) as $ref){
  2504. $p = $this->GetPost($ref);
  2505. if(!$p || !$this->CanShowPost($p)) continue;
  2506. $this->MakeSinglePostV2($p, false, true, "post_preview", true, false, false, false, true);
  2507. }
  2508. $STR=$this->TRestore(" compact");
  2509. if($direct_return){
  2510. echo $STR;
  2511. echo "</insert>";
  2512. $this->MakeHereButtons($im, true);
  2513. }else{
  2514. $str = $STR;
  2515. $this->MakePageBegin($this->NULL_POST);
  2516. $side = "";
  2517. if(isset($im['refs'])&&isset($im['refs'][0])){
  2518. $side.="<span class='small'>".$this->T('该图片出现在')." ".sizeof($im['refs'])." ".$this->T('个帖子中')."</span>";
  2519. }else{$side.="<span class='smaller gray'>".$this->T('该图片未被引用')."</span>";}
  2520. $static_image = isset($im['video'])?NULL:$im['file'];
  2521. $static_video = isset($im['video'])?$im['file']:NULL;
  2522. $this->MakeImageOverlay($side."<ul>".$str."</ul>",$static_image,$static_video);
  2523. $this->MakePageEnd();
  2524. }
  2525. exit;
  2526. }
  2527. if(isset($_GET['confirm_enter']) && $_GET['confirm_enter']!=false){
  2528. setcookie('la_experimental','confirmed','/'); $_COOKIE['la_experimental'] = $_GET['confirmed'];
  2529. $redirect=$INDEXPHP.(isset($_GET['post'])?'?post='.$_GET['post']:"");return 0;
  2530. }
  2531. if(isset($_GET['apub_actor'])){
  2532. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2533. echo $this->APubActor; exit;
  2534. }
  2535. if(isset($_GET['apub_outbox'])){
  2536. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2537. echo $this->APubMakeOutbox(); exit;
  2538. }
  2539. if(isset($_GET['apub_inbox'])){
  2540. $this->APubProcessInbox();
  2541. http_response_code(202); exit;
  2542. }
  2543. if($this->LoggedIn){
  2544. if(isset($_GET['TestAPubDeliver'])){
  2545. $this->APubTestDeliver();
  2546. }
  2547. if(isset($_GET['set_notes_view'])){
  2548. setcookie('la_notes_view',$_GET['set_notes_view'],time()+3600*24*7,'/'); $_COOKIE['la_notes_view'] = $_GET['set_notes_view'];
  2549. $redirect=$this->GetRedirect(); return 0;
  2550. }
  2551. $this->DoUpload();
  2552. if(isset($_POST['settings_button'])){
  2553. if(isset($_POST['settings_title'])) $this->Title=$_POST['settings_title'];
  2554. if(isset($_POST['settings_short_title'])) $this->ShortTitle=$_POST['settings_short_title'];
  2555. if(isset($_POST['settings_display_name'])) $this->DisplayName=$_POST['settings_display_name'];
  2556. if(isset($_POST['settings_email'])) $this->EMail=$_POST['settings_email'];
  2557. if(isset($_POST['settings_special_navigation'])) $this->SpecialNavigation=$_POST['settings_special_navigation'];
  2558. if(isset($_POST['settings_special_sidebar'])) $this->SpecialSidebar=$_POST['settings_special_sidebar'];
  2559. if(isset($_POST['settings_special_footer'])) $this->SpecialFooter=$_POST['settings_special_footer'];
  2560. if(isset($_POST['settings_special_footer2'])) $this->SpecialFooter2=$_POST['settings_special_footer2'];
  2561. if(isset($_POST['settings_special_pinned'])) $this->SpecialPinned=$_POST['settings_special_pinned'];
  2562. if(isset($_POST['settings_special_pinned_notes'])) $this->SpecialPinnedNotes=$_POST['settings_special_pinned_notes'];
  2563. if(isset($_POST['settings_default_gallery'])) $this->DefaultGallery=$_POST['settings_default_gallery'];
  2564. if(isset($_POST['settings_selfauth_path'])) $this->SelfAuthPath=$_POST['settings_selfauth_path'];
  2565. if(isset($_POST['settings_enable_comments'])) $this->CommentEnabled=True; else $this->CommentEnabled=False;
  2566. if(isset($_POST['settings_enable_newsletter'])) $this->NewsletterEnabled=True; else $this->NewsletterEnabled=False;
  2567. if(isset($_POST['settings_gallery_step'])) $this->GalleryStep=$_POST['settings_gallery_step'];
  2568. if(isset($_POST['settings_here_host'])) $this->HereHost=$_POST['settings_here_host'];
  2569. if(isset($_POST['settings_here_title'])) $this->HereTitle=$_POST['settings_here_title'];
  2570. if(isset($_POST['settings_here_short_title'])) $this->HereShortTitle=$_POST['settings_here_short_title'];
  2571. if(isset($_POST['settings_here_album'])) $this->HereAlbum=$_POST['settings_here_album'];
  2572. if(isset($_POST['settings_here_navigation'])) $this->HereNavigation=$_POST['settings_here_navigation'];
  2573. if(isset($_POST['settings_here_footer'])) $this->HereFooter=$_POST['settings_here_footer'];
  2574. if(isset($_POST['settings_exp_host'])) $this->ExpHost=$_POST['settings_exp_host'];
  2575. if(isset($_POST['settings_exp_title'])) $this->ExpTitle=$_POST['settings_exp_title'];
  2576. if(isset($_POST['settings_exp_short_title'])) $this->ExpShortTitle=$_POST['settings_exp_short_title'];
  2577. if(isset($_POST['settings_exp_caution'])) $this->ExpCaution=$_POST['settings_exp_caution'];
  2578. if(isset($_POST['settings_exp_album'])) $this->ExpAlbum=$_POST['settings_exp_album'];
  2579. if(isset($_POST['settings_exp_navigation'])) $this->ExpNavigation=$_POST['settings_exp_navigation'];
  2580. if(isset($_POST['settings_exp_footer'])) $this->ExpFooter=$_POST['settings_exp_footer'];
  2581. if(isset($_POST['settings_allow_language'])) $this->AllowLanguageChoices=True; else $this->AllowLanguageChoices=False;
  2582. if(isset($_POST['settings_mastodon_token'])) $this->MastodonToken=$_POST['settings_mastodon_token'];
  2583. if(isset($_POST['settings_mastodon_url'])) $this->MastodonURL=$_POST['settings_mastodon_url'];
  2584. if(isset($_POST['settings_mastodon_lang'])) $this->MastodonPreferredLang=$_POST['settings_mastodon_lang'];
  2585. if(isset($_POST['settings_host_url'])) $this->HostURL=$_POST['settings_host_url'];
  2586. if(isset($_POST['settings_apub_id']) && isset($this->HostURL)) {
  2587. $this->APubID=$_POST['settings_apub_id'];
  2588. $this->APubEnsureWebfinger($this->APubID,$this->HostURL);
  2589. }
  2590. if(isset($_POST['settings_old_password'])&&password_verify($_POST['settings_old_password'], $this->Password)){
  2591. if(isset($_POST['settings_id'])) $this->Admin=$_POST['settings_id'];
  2592. if(isset($_POST['settings_new_password']) && isset($_POST['settings_new_password_redo']) &&
  2593. $_POST['settings_new_password'] = $_POST['settings_new_password_redo'])
  2594. {$this->Password=password_hash($_POST['settings_new_password'], PASSWORD_DEFAULT);}
  2595. $redirect=$_SERVER['REQUEST_URI'];
  2596. $this->DoLogout();
  2597. }
  2598. $this->WriteConfig();
  2599. return 0;
  2600. }
  2601. if(isset($_POST['settings_save_redirect'])){
  2602. if(isset($_POST['settings_redirect'])){
  2603. $this->BuildRedirectConfig($_POST['settings_redirect']);
  2604. }
  2605. $this->WriteConfig();
  2606. $redirect = $INDEXPHP.'?extras=true'; return 0;
  2607. }
  2608. if(isset($_POST['settings_save_translation'])){
  2609. if(isset($_POST['settings_translation'])){
  2610. $f = fopen("custom_translations.md", "w"); fwrite($f,$_POST['settings_translation']); fflush($f); fclose($f);
  2611. }
  2612. $redirect = $INDEXPHP.'?extras=true'; return 0;
  2613. }
  2614. if(isset($_GET['post'])){
  2615. if(isset($_GET['post_original'])){
  2616. echo $this->EditPost($_GET['post'],NULL,false,NULL,true,NULL,NULL,false,NULL,NULL);
  2617. exit;
  2618. }
  2619. }
  2620. if(isset($_GET['mark_delete']) && isset($_GET['target'])){
  2621. $this->EditPost($_GET['target'],NULL,$_GET['mark_delete']=='true',NULL,false,NULL,NULL,false,NULL,NULL);
  2622. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2623. return 0;
  2624. }
  2625. if(isset($_GET['set_mark']) && isset($_GET['target'])){
  2626. $this->EditPost($_GET['target'],NULL,NULL,NULL,NULL,$_GET['set_mark'],NULL,false,NULL,NULL);
  2627. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2628. return 0;
  2629. }
  2630. if((isset($_POST['post_button'])||isset($_POST['post_button_note'])) && isset($_POST['post_content'])){
  2631. $c = $_POST['post_content'];
  2632. if('有什么想说的' == $c){ return 0;}
  2633. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2634. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2635. $reply_to = (isset($_POST['post_reply_to'])&&$_POST['post_reply_to']!="")?$_POST['post_reply_to']:NULL;
  2636. $edit_id = (isset($_POST['post_edit_target'])&&$_POST['post_edit_target']!="")?$_POST['post_edit_target']:NULL;
  2637. $push_history = (isset($edit_id) && isset($_POST['post_record_edit']));
  2638. $postmark=NULL;
  2639. if(isset($_POST['post_button_note'])){ $postmark=8; }
  2640. if(($edited = $this->EditPost($edit_id, $c, NULL, $reply_to,NULL,$postmark,NULL,$push_history,NULL,NULL))!=NULL){
  2641. $redirect='?post='.$edited['id']; return 0;
  2642. };
  2643. }
  2644. if(isset($_POST['post_rename_confirm']) && isset($_POST['post_rename_name']) && isset($_GET['rename_post'])){
  2645. if(($edited =$this->EditPost($_GET['rename_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,NULL))!=NULL){
  2646. $redirect='?post='.$edited['id']; return 0;
  2647. };
  2648. }
  2649. if(isset($_POST['post_mastodon_confirm']) && isset($_POST['post_mastodon_url']) && isset($_GET['mastodon_post'])){
  2650. if(($edited =$this->EditPost(
  2651. $_GET['mastodon_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,$_POST['post_mastodon_url']))!=NULL){
  2652. $redirect='?post='.$edited['id']; return 0;
  2653. };
  2654. }
  2655. if(isset($_GET['mastodon_send_post']) && preg_match('/([0-9]{14})/u',$_GET['mastodon_send_post'],$m)){
  2656. $this->ReadImages(); $this->ReadPosts(); $post = &$this->GetPost($m[1]); $err=$this->T("未知错误");
  2657. if(isset($post)){
  2658. if($mastodon_url = $this->MastodonSendPost($post, $err)){
  2659. $this->NeedWritePosts = 1; $this->WritePosts(); // for mastodon url
  2660. echo "SUCCESS ".$mastodon_url;
  2661. }else{ echo $err; }
  2662. } exit;
  2663. }
  2664. if(isset($_GET['merge_threads'])&&$_GET['merge_threads']!=""){
  2665. if(preg_match('/([0-9]{14})\s+([0-9]{14})/u',$_GET['merge_threads'],$m)){
  2666. if(($pe = &$this->MergeThreads($m[1],$m[2]))!=$this->NULL_POST){ $redirect='?post='.$pe['id']; return 0; }
  2667. }
  2668. }
  2669. if(isset($_GET['merge_posts'])&&$_GET['merge_posts']!=""){
  2670. if(($pe = &$this->MergePosts($_GET['merge_posts']))!=$this->NULL_POST){
  2671. $redirect='?post='.$pe['id']; return 0;
  2672. }
  2673. }
  2674. if ($this->CommentEnabled && isset($_POST['comment_confirm']) && (isset($_GET['comment_to']))
  2675. && isset($_POST['comment_box']) && isset($_POST['comment_email']) && isset($_POST['comment_name'])){
  2676. $c = $_POST['comment_box'];
  2677. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2678. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2679. $comment_to = ($_GET['comment_to']!="")?$_GET['comment_to']:NULL;
  2680. if(($edited = $this->EditComment(NULL,
  2681. $_GET['comment_to'], $c, $_POST['comment_email'], $_POST['comment_name'],
  2682. isset($_POST['comment_link'])?$_POST['comment_link']:NULL,
  2683. $_SERVER['REMOTE_ADDR']))!=NULL){
  2684. $redirect='?post='.$_GET['post'];
  2685. return 0;
  2686. };
  2687. }
  2688. if(isset($_POST['gallery_edit_confirm']) && isset($_POST['gallery_edit_new_name']) && $_POST['gallery_edit_new_name']!=''){
  2689. $old_name = isset($_POST['gallery_edit_old_name'])?$_POST['gallery_edit_old_name']:"";
  2690. $new_name = $_POST['gallery_edit_new_name'];
  2691. if($old_name!=''){
  2692. $desc=isset($_POST['gallery_edit_description'])?$_POST['gallery_edit_description']:null;
  2693. if(!preg_match('/[0-9]{14}/',$desc))$desc="";
  2694. $this->EditGallery($old_name, $new_name, false, true, null, null,$desc);
  2695. $redirect='?gallery='.$new_name;
  2696. }else{
  2697. $this->EditGallery(null, $new_name, false, true, null,null);
  2698. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2699. }
  2700. return 0;
  2701. }
  2702. if(isset($_GET['gallery_edit_delete'])&&$_GET['gallery_edit_delete']!=null){
  2703. $this->EditGallery($_GET['gallery_edit_delete'], null, true, true, null, null,null);
  2704. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery=main'; else $redirect=$INDEXPHP;
  2705. return 0;
  2706. }
  2707. if(isset($_POST['gallery_move_ops'])&&isset($_POST['gallery_move_ops'])){
  2708. if(preg_match('/^(REM|ADD)\s+(\S+)\s+(.*)$/u', $_POST['gallery_move_ops'], $ma)){
  2709. $this->ReadImages();
  2710. if(preg_match_all('/(\S+)/u', $ma[3], $files, PREG_SET_ORDER)) foreach($files as $name){
  2711. $this->EditImage($name[1], $ma[2], ($ma[1]=='REM'), NULL, NULL, NULL, NULL);
  2712. }
  2713. }
  2714. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2715. return 0;
  2716. }
  2717. if(isset($_GET['gallery_set_featured'])&&isset($_GET['value'])){
  2718. $this->EditGallery($_GET['gallery_set_featured'], null, false, true, $_GET['value']!='false', null);
  2719. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2720. return 0;
  2721. }
  2722. if(isset($_GET['gallery_set_experimental'])&&isset($_GET['value'])){
  2723. $this->EditGallery($_GET['gallery_set_experimental'], null, false, true, null, $_GET['value']!='false');
  2724. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2725. return 0;
  2726. }
  2727. if(isset($_GET['image_list'])&&$_GET['image_list']!=""){
  2728. $this->ReadImages();
  2729. $gallery = $_GET['image_list']; $count=0;
  2730. foreach($this->Images as $im){ if($count>25){ break; }
  2731. if($gallery=='main'){ echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; $count++; continue; }
  2732. if(isset($im['galleries']) && isset($im['galleries'][0]) && in_array($gallery,$im['galleries'])) {
  2733. echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; $count++; }
  2734. }
  2735. exit;
  2736. }
  2737. $do_image_redirect = 0;
  2738. if (isset($_POST['image_button']) && isset($_GET['pic']) &&
  2739. preg_match('/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4))/u',$_GET['pic'],$ma)){
  2740. $this->ReadImages(); $pic = $ma[1]; $picext=$ma[2];
  2741. if(isset($_POST['image_ops_product_link'])){
  2742. $this->EditImage($pic, NULL, false, $_POST['image_ops_product_link'], NULL, NULL, NULL);
  2743. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2744. }
  2745. if(isset($_POST['image_edit_new_name']) && preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_edit_new_name'],$man)){
  2746. $this->EditImage($pic, NULL, false, NULL, $man[1], NULL, NULL);
  2747. $redirect=$this->GetRedirect(['pic'=>'images/'.$man[1].'.'.$picext]);
  2748. $do_image_redirect = 1;
  2749. }
  2750. if(isset($_POST['image_parent'])){ $parent="";
  2751. if(preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_parent'],$man)){ $parent = $man[1]; }
  2752. $this->EditImage($pic, NULL, false, NULL, NULL, $parent, NULL);
  2753. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2754. }
  2755. if(isset($_POST['image_align'])){$val=$_POST['image_align'];
  2756. $this->EditImage($pic, NULL, false, NULL, NULL, NULL, $val);
  2757. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2758. }
  2759. $this->NeedWriteImages = 1;
  2760. if($do_image_redirect) return 0;
  2761. }
  2762. if(isset($_GET['rewrite_styles'])){
  2763. $this->WriteStyles(); $redirect='?extras=true'; return 0;
  2764. }
  2765. if(isset($_GET['regenerate_thumbnails'])){
  2766. $this->RegenerateThumbnails(); $redirect='?extras=true'; return 0;
  2767. }
  2768. if(isset($_GET['cleanup_image_compression'])){ $run=false;
  2769. if(isset($_GET['run'])){ $run=true; }
  2770. $this->CleanupImageCompression($run); $redirect='?extras=true'; return 0;
  2771. }
  2772. if(isset($_GET['clear_all_logins'])){
  2773. $this->LoginTokens=[]; $this->WriteTokens();
  2774. }
  2775. if($_SERVER['HTTP_HOST']=='localhost'){$this->WriteStyles();}
  2776. }
  2777. return 0;
  2778. }
  2779. function PostProcessHTML($html,&$added_images=null,$do_product_info=false, &$product_info=null, &$orig_src_list=null, &$end_wide=null, &$print_wide=null){
  2780. if(!$this->LoggedIn){
  2781. $html = preg_replace("/(<a[^>]*href=[\'\"])(.*?)([\'\"][^>]*)>(\#.*?<\/a>)/u","",$html);
  2782. }
  2783. $html = preg_replace("/(<a[^>]*href=[\'\"])([0-9]{14})([\'\"][^>]*)>(.*?<\/a>)/u","$1?post=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2784. $html = preg_replace("/(<a[^>]*href=[\'\"])\@(.*?)([\'\"][^>]*)>(.*?<\/a>)/u","$1?category=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2785. $html = preg_replace("/(<a[^>]*href=[\'\"])((.*?:\/\/).*?)([\'\"][^>]*)(>)(.*?)(<\/a>)/u",
  2786. "$1$2$4 target='_blank'$5$6<sup>↗</sup>$7",$html);
  2787. $html = preg_replace("/<p>\s*\@.*?<\/p>/mu","",$html);
  2788. $html = preg_replace("/\{\s*(REVERSED|INTERESTING|HEADER|FOOTER)\s+(.*?)\}/imu","",$html);
  2789. $html = preg_replace("/\{\s*(REVERSED|NO_TIME|NO_TITLE|SLIDES)\s*\}/imu","",$html);
  2790. $html = preg_replace("/\{\s*WIDE\s*\}/imu","",$html,-1,$rep_count); if($rep_count){$print_wide=true;}
  2791. $images = []; $images_noclick = []; $images_orig_src_list = [];
  2792. $html = preg_replace_callback(
  2793. "/(<p>\s*|<a\s.*?>\s*)?(<img([^>]*)src=[\'\"])(images\/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4)))([\'\"][^>]*)\/>(\s*<\/p>)?/u",
  2794. function($m) use (&$images,&$images_noclick,&$images_orig_src_list) {
  2795. if(isset($m[1])&&$m[1]&&$m[1][1]=='a'){ $height="";
  2796. if(preg_match("/([0-9]{1,2})em/u",$m[0],$hm)){$height=' style="height:'.$hm[1].'em;"';}
  2797. return "<a class='imbtn'".$height.substr($m[0],2); }
  2798. $orig_src = $src = $m[5]; $keep = false; $original = false; $float=false;
  2799. if (preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[3]) ||
  2800. preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[7])) { $keep=true; }
  2801. if ($keep && preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[3]) ||
  2802. preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[7])) { $original=true; }
  2803. if (preg_match('/alt=[\'\"].*float.*[\'\"]/u',$m[3]) ||
  2804. preg_match('/alt=[\'\"].*float.*[\'\"]/u',$m[7])) { $keep=true;$original=true;$float=true; }
  2805. if(($im = &$this->FindImage($m[5]))!=NULL && isset($im['thumb'])){
  2806. $src = $im['thumb']; $orig_src=$im['file'];
  2807. }if($im == NULL){ $im = &$this->NULL_IMAGE_DUMMY; }
  2808. $media_start = $m[2];
  2809. $media_end = $m[7];
  2810. $dataset = " data-imgsrc='".$m[5]."'".
  2811. (isset($im['product'])?" data-product='".$im['product']."'":"").
  2812. (isset($im['parent'])?" data-parent='".$im['parent']."'":"").
  2813. (isset($im['align'])?' data-align="'.$im["align"].'" style="object-position:'.$im['align'].';"':"").
  2814. ($original?" class='original_img'":"");
  2815. if(isset($im['video']) && isset($im['video'])!=''){
  2816. $media_start = "<video controls".$dataset."><source src='"; $media_end="' type='".$im['video']."'></video";
  2817. $src = $orig_src; $dataset="";
  2818. }
  2819. $float_add=""; if($float){ $float_add=" imd_float"; }
  2820. if($this->InHereMode){
  2821. $click = "<div class='imd$float_add'>"."<a href='?here=".$im['file']."' class='original_img'>".
  2822. $media_start.($original?$orig_src:$src).$media_end."></a></div>";
  2823. $ret=""; if($keep) { $ret = $click; }
  2824. else { $images[] = $click; }
  2825. return $ret;
  2826. }else{
  2827. $click ="<div class='imd$float_add'><a href='?show_image={$im['name']}' target='_blank' onclick='event.preventDefault();'>".
  2828. $media_start.($original?$orig_src:$src).$media_end.$dataset."></a></div>";
  2829. $images_noclick[]=$media_start.$src.$media_end.">"; $images_orig_src_list[]=$orig_src;
  2830. $ret = "";
  2831. if($keep) { $ret = $click; }
  2832. else { $images[] = $click; }
  2833. if(isset($m[1])&&isset($m[8])&&$m[1]&&$m[8]) return $ret;
  2834. else return ((isset($m[1])&&$m[1]?$m[1]:"").$ret.(isset($m[8])&&$m[8]?$m[8]:""));
  2835. }
  2836. },$html,-1,$count);
  2837. $html = preg_replace('/<p>\s*<\/p>/u',"", $html); if($html==""){$html="<p>&nbsp;</p>";}
  2838. if(sizeof($images)){
  2839. if((!$this->InHereMode) && sizeof($images)==1){$html.= $images[0]; }
  2840. else{
  2841. $html.="<div class='p_row'>";
  2842. foreach($images as $img){
  2843. $html.="<div class='p_thumb'>".$img."</div>";
  2844. }
  2845. $html.="<div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div>";
  2846. }
  2847. }
  2848. if(sizeof($images_noclick)){ $added_images = $images_noclick; }
  2849. if(sizeof($images_orig_src_list)) { $orig_src_list = $images_orig_src_list; }
  2850. if($do_product_info){
  2851. $html = preg_replace_callback("/\{PRICE\s+([^]]+?)\}/u",
  2852. function($m) use (&$product_info) { $product_info['price']=$m[1];return ""; },$html);
  2853. $html = preg_replace_callback("/\{SHORT\s+([^]]+?)\}/u",
  2854. function($m) use (&$product_info) { $product_info['short']=$m[1];return ""; },$html);
  2855. $html = preg_replace('/<p>\s*<\/p>/u',"", $html);
  2856. if (preg_match('/<h[1-5]>(.+?)<\/h/u',$html,$title)){ $product_info['title']=$title[1]; }
  2857. else { $product_info['title'] = $this->T('商品'); }
  2858. if(!isset($product_info['price'])) $product_info['price']=$this->T('未设置价格');
  2859. $html = preg_replace_callback("/\{PURCHASE\s+([^]]+?)\}/u",function($m) use (&$product_info) {
  2860. return "<a class='purchase_button' href=\"mailto:".$this->T($this->DisplayName)."<".$this->EMail.">?subject=".
  2861. $this->T('购买').' '.$product_info['title'].
  2862. "&body=".$this->T('你好!我想购买').$product_info['title'].urlencode(PHP_EOL.PHP_EOL).
  2863. $this->FullURL().urlencode(PHP_EOL.PHP_EOL)."\">".$m[1]."</a>"; },$html);
  2864. }
  2865. if(preg_match("/(<\/div>|<\/table>|<\/video>)\s*$/u",$html)){$end_wide=true;}
  2866. return $html;
  2867. }
  2868. function ConvertPost(&$post){
  2869. if(!isset($post['html'])){
  2870. $info=[];
  2871. $post['html'] = $this->TranslatePostParts($this->PostProcessHTML($this->ChoosePartsByLanguage($this->PDE->text($this->InsertReplacementSymbols($post['content'], $post)),true),
  2872. $post['images'],
  2873. isset($post['product']), $info,
  2874. $post['original_images'],
  2875. $post['end_wide'],
  2876. $post['wide']));
  2877. if(isset($post['product'])) $post['product']=$info;
  2878. }
  2879. }
  2880. function GetPostTitle(&$post, $h1_only=false, $add_unamed=true){
  2881. if($h1_only){
  2882. if(preg_match('/^#\s+(.*?)$/mu',$post['content'],$m)) return strip_tags($this->TranslatePostParts($m[1]));
  2883. else return NULL;
  2884. }
  2885. if(!isset($post['title'])){
  2886. if(preg_match('/^#{1,6}\s+(.*?)$/mu',$post['content'],$m)){$post['title']=$m[0];}
  2887. else{ $post['title'] = $add_unamed?$this->T('未命名'):"";
  2888. if(preg_match('/(.*)$/mu',$post['content'],$m)){
  2889. $post['title'].=($add_unamed?' (':'').$this->PDE->text($m[1]).($add_unamed?')':''); }
  2890. }
  2891. }
  2892. return strip_tags($this->TranslatePostParts($this->PDE->text($post['title'])));
  2893. }
  2894. function DetectPageType(){
  2895. if ($this->InExperimentalMode) $this->PageType='experimental';
  2896. else if($this->InHereMode) $this->PageType='here';
  2897. else if(isset($_GET['history'])) $this->PageType='history';
  2898. else if(isset($_GET['extras'])) $this->PageType='extras';
  2899. else if(isset($_GET['settings'])) $this->PageType='settings';
  2900. else if(isset($_GET['gallery'])) $this->PageType='gallery';
  2901. else if(isset($_GET['search'])) $this->PageType='search';
  2902. else if(isset($_GET['category'])) $this->PageType='category';
  2903. else if(isset($this->CurrentPostID)) $this->PageType = "post";
  2904. else if(isset($_GET['comments'])) $this->PageType='comments';
  2905. else if(isset($_GET['statistics'])) $this->PageType='statistics';
  2906. else $this->PageType = "main";
  2907. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  2908. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  2909. $this->VisitedHere = $_SESSION[$visited_here];
  2910. }
  2911. function MakePageBegin(&$p){ $title=$this->InExperimentalMode?$this->T($this->ExpTitle):
  2912. ($this->InHereMode?$this->T($this->HereTitle):$this->T($this->Title)) ?>
  2913. <!DOCTYPE html><html lang='zh-Hans-CN'>
  2914. <head>
  2915. <meta charset='utf-8'>
  2916. <meta content="width=device-width, initial-scale=1" name="viewport">
  2917. <title><?=$title?></title>
  2918. <meta property="og:title" content="<?=$title.(isset($p)?(" | ".$this->GetPostTitle($p)):"")?>">
  2919. <?php if(isset($p)&&isset($p['hasi'])&&isset($p['hasi'][0])){?> <meta property="twitter:card" content="summary_large_image" />
  2920. <meta property="og:image" content="<?=(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']==='on'?"https":"http").'://'.$_SERVER['HTTP_HOST'].'/images/thumb/'.$p['hasi'][0]?>"><?php } ?>
  2921. <?php if($this->UseRemoteFont){ ?><style>
  2922. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Regular.otf") format("opentype");font-weight:normal;}
  2923. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Bold.otf") format("opentype");font-weight:bold;}
  2924. </style><?php } ?>
  2925. <link href='styles/main.css' rel='stylesheet' type="text/css">
  2926. <link rel="alternate" type="application/rss+xml" title="<?=$this->T($this->Title);?>" href="?rss=<?=$this->LanguageAppendix;?>" />
  2927. <link rel="alternate" hreflang="zh" href="index.php?<?=$_SERVER['QUERY_STRING']?>" />
  2928. <link rel="alternate" hreflang="en" href="en.php?<?=$_SERVER['QUERY_STRING']?>" />
  2929. <link rel="alternate" hreflang="x-default" href="en.php?<?=$_SERVER['QUERY_STRING']?>" />
  2930. <?php if(isset($this->SelfAuthPath)&&$this->SelfAuthPath!=""){ ?>
  2931. <link rel="authorization_endpoint" href="<?=$this->SelfAuthPath?>" /><?php } ?>
  2932. <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>
  2933. </head>
  2934. <div class='page'>
  2935. <?php }
  2936. function MakeHeader(&$p){
  2937. $this->MakePageBegin($p) ?>
  2938. <script type='text/javascript'>
  2939. function toggle_mobile_show(a){a.classList.toggle('hidden_m')}
  2940. function ShowWaitingBar(){wait = document.querySelector("#waiting_bar");wait.style.display='';}
  2941. function HideWaitingBar(){wait = document.querySelector("#waiting_bar");wait.style.display='none';}
  2942. <?php if(!$this->InHereMode){ ?>
  2943. function la_auto_grow(element){
  2944. s=window.scrollY;element.style.height="30px";element.style.height=(element.scrollHeight)+"px";window.scroll(0, s);
  2945. }
  2946. function ShowBackdrop(alpha=0.5){
  2947. b = document.getElementById('backdrop');
  2948. b.style="background-color:rgba(0,0,0,"+alpha+");";
  2949. b.style.animation='backdrop_fade_in 0.3s forwards';
  2950. b.style.display = 'block';
  2951. }
  2952. function HideBackdrop(){
  2953. b = document.getElementById('backdrop');
  2954. b.style.animation='backdrop_fade_out 0.3s forwards';
  2955. setTimeout(function(e1){e1.style.display='none';}, 300, b);
  2956. }
  2957. function ShowRightSide(big,elem_to_clone){
  2958. p = document.getElementById('pop_right');
  2959. if(elem_to_clone){
  2960. c = elem_to_clone.cloneNode(true);
  2961. c.id='side_bar_cloned';c.className="";c.style="";
  2962. p.querySelector('._content').appendChild(c);
  2963. }
  2964. p.classList.remove('pop_right','pop_right_big');
  2965. if(big) {p.classList.add('pop_right_big');p.style.animation='pop_slide_in_big 0.3s forwards';}
  2966. else {p.classList.add('pop_right');p.style.animation='pop_slide_in 0.3s forwards';}
  2967. p.style.display='block';
  2968. ShowBackdrop(0.5);
  2969. }
  2970. function HideRightSide(){
  2971. p = document.getElementById('pop_right');
  2972. if(side=p.querySelector('#side_bar_cloned')){
  2973. side.remove();
  2974. }
  2975. put = document.querySelector("#_uploader");
  2976. if(p.classList.contains('pop_right')){p.style.animation='pop_slide_out 0.3s forwards';}
  2977. else{p.style.animation='pop_slide_out_big 0.3s forwards';}
  2978. setTimeout(function(e1, e2){e1.style.display='none';if(e2)e2.style.display='none';}, 300, p, put);
  2979. HideBackdrop();
  2980. }
  2981. function CssNumberID(id){ return "#\\3"+id.substr(0,1)+" "+id.substr(1); }
  2982. function ScrollToPost(id){
  2983. post=null;
  2984. if(!(post = document.querySelector("[data-post-id='"+id+"']"))){
  2985. if(!(post = document.querySelector(CssNumberID(id)))) return; }
  2986. post.scrollIntoView({ behavior: 'smooth', block: 'start'});
  2987. }
  2988. <?php } ?>
  2989. </script><input type='checkbox' class='lpctrl' id='titlectrl'>
  2990. <header<?=$this->InHereMode?' class="exp_h_f"':''?>><div>
  2991. <?php if($this->InHereMode){
  2992. $this->MakeExpNavButtons($p);
  2993. }else{
  2994. $this->MakeNavButtons($p);
  2995. if(isset($p['tid']['header'])){ ?><div style='float:right' class='show_on_print'><?=$this->ChoosePartsByLanguage($p['tid']['header']);?></div><?php }
  2996. echo "<hr class='hidden_m'>";
  2997. } ?>
  2998. <?php if(isset($this->WayBack)){
  2999. $time=(isset($_COOKIE['la_wayback']) && preg_match('/[0-9]{14}/u',$_COOKIE['la_wayback']))?$_COOKIE['la_wayback']:date('YmdHis');
  3000. $year=substr($time,0,4);$month=substr($time,4,2);$day=substr($time,6,2);
  3001. $hour=substr($time,8,2);$minute=substr($time,10,2);?> <div class='text_highlight'>
  3002. &nbsp;<b><span onclick='document.getElementById("wayback_config").classList.toggle("hidden_m")'>
  3003. <div class='wayback_close' onclick='event.stopPropagation()'><a href='<?=$this->GetRedirect()?>&set_wayback=false'>
  3004. <span class='hidden_m'><?=$this->T('退出')?></span>×&nbsp;</a></div>
  3005. + <?=$this->T('正以过去的日期浏览')?></b><div id='wayback_config' class='wayback_expand hidden_m'>
  3006. <select id="wayback_year" name="wayback_year" form="wayback_form"><?php for($y=$this->YearBegin;$y<=$this->YearEnd;$y++){ ?>
  3007. <option value="<?=$y?>"<?=$y==$year?" selected":""?>><?=$y?></option><?php } ?></select>
  3008. <br class='hidden_on_desktop' />
  3009. <select id="wayback_month" name="wayback_month" form="wayback_form"><?php for($y=1;$y<=12;$y++){ ?>
  3010. <option value="<?=$y?>"<?=$y==$month?" selected":""?>><?=$y?></option><?php } ?></select>
  3011. <select id="wayback_day" name="wayback_day" form="wayback_form"><?php for($y=1;$y<=31;$y++){ ?>
  3012. <option value="<?=$y?>"<?=$y==$day?" selected":""?>><?=$y?></option><?php } ?></select>
  3013. <br class='hidden_on_desktop' />
  3014. <select id="wayback_hour" name="wayback_hour" form="wayback_form"><?php for($y=0;$y<=23;$y++){ ?>
  3015. <option value="<?=$y?>"<?=$y==$hour?" selected":""?>><?=$y?></option><?php } ?></select>:
  3016. <select id="wayback_minute" name="wayback_minute" form="wayback_form"><?php for($y=0;$y<=59;$y++){ ?>
  3017. <option value="<?=$y?>"<?=$y==$minute?" selected":""?>><?=$y?></option><?php } ?></select>
  3018. <br class='hidden_on_desktop' />
  3019. <form action="<?=$this->GetRedirect()?>&set_wayback=post" method="post" style='display:none;' id='wayback_form'></form>
  3020. <input type='submit' style='font-weight:normal;border-bottom:none;' class='button clean_a' form='wayback_form'
  3021. id='wayback_see' name='wayback_see' value="<?=$this->T('查看')?> →">
  3022. </div></div><?php } ?>
  3023. </div></header>
  3024. <div id='waiting_bar' style='display:none;'></div>
  3025. <script>ShowWaitingBar();window.addEventListener('load',(event) =>{HideWaitingBar();}); </script>
  3026. <?php if(!$this->InHereMode){ ?>
  3027. <div id='post_menu' style='display:none;' class='pop_menu clean_a'>
  3028. <ul>
  3029. <li><span id='_time_hook' class='smaller'>时间</span>&nbsp;&nbsp;<a href='javascript:HidePopMenu();'>×</a></li>
  3030. <li><a id='share_copy'>⎘<?=$this->T('复制链接')?></a></li>
  3031. <hr />
  3032. <?php if($this->LoggedIn){ ?>
  3033. <li><a id='menu_history'><?=$this->T('历史')?></a>
  3034. <?php if(!isset($this->WayBack) && $this->PageType!='search'){ ?>
  3035. | <a id='menu_edit'><?=$this->T('修改')?></a><?php } ?></li>
  3036. <?php if(!isset($this->WayBack)){ ?><li>
  3037. <a id='menu_refer_copy'><?=$this->T('复制编号')?></a><?php if($this->PageType!='search'){ ?>
  3038. | <a id='menu_refer'><?=$this->T('引用')?></a><?php } ?><br class='hidden_on_desktop' />
  3039. </li>
  3040. <li><a id='menu_rename' href='javascript:ToggleRenameDetails()'><?=$this->T('改名')?></a> |
  3041. <a id='menu_mark' href='javascript:ToggleMarkDetails()'><?=$this->T('标记')?></a></li>
  3042. <li id='mark_details' style='display:none;'><b>
  3043. <a id='mark_set_clear' href='javascript:SetMark(-1);'>_</a>
  3044. <a id='mark_set_0' href='javascript:SetMark(0);'><?=$this->Markers[0]?></a>
  3045. <a id='mark_set_1' href='javascript:SetMark(1);'><?=$this->Markers[1]?></a>
  3046. <a id='mark_set_2' href='javascript:SetMark(2);'><?=$this->Markers[2]?></a>
  3047. <a id='mark_set_3' href='javascript:SetMark(3);'><?=$this->Markers[3]?></a>
  3048. <a id='mark_set_4' href='javascript:SetMark(4);'><?=$this->Markers[4]?></a>
  3049. <a id='mark_set_5' href='javascript:SetMark(5);'><?=$this->Markers[5]?></a>
  3050. <a id='mark_set_6' href='javascript:SetMark(6);'><?=$this->Markers[6]?></a>
  3051. <a id='mark_set_7' href='javascript:SetMark(7);'><?=$this->Markers[7]?></a>
  3052. <a id='mark_set_8' href='javascript:SetMark(8);'><?=$this->Markers[8]?></a>
  3053. </b></li>
  3054. <li id='rename_details' style='display:none;text-align:left;' class='smaller'>
  3055. <form action="" method="post" style='display:none;' id='post_rename_form'></form>
  3056. <input type='text' id='post_rename_name' name='post_rename_name' form="post_rename_form" style='width:9em;'>
  3057. <input class='button' type='submit' form='post_rename_form'
  3058. name='post_rename_confirm' id='post_rename_confirm' value='<?=$this->T('确认')?>'>
  3059. </li><hr /> <?php if(isset($this->MastodonToken)){ ?>
  3060. <li><a id='menu_mastodon_view' class='button' style='display:none;' target='_blank'><?=$this->T('转到')?></a>
  3061. <a id='menu_mastodon' href='javascript:ToggleMastodonDetails()'><?=$this->T('长毛象')?></a></li>
  3062. <li id='mastodon_details' style='display:none;text-align:left;' class='smaller'>
  3063. <a id='menu_mastodon_send' class='button' target='_blank'><?=$this->T('发送')?></a>
  3064. <form action="" method="post" style='display:none;' id='post_mastodon_form'></form>
  3065. <input type='text' id='post_mastodon_url' name='post_mastodon_url' form="post_mastodon_form" style='width:9em;'>
  3066. <input class='button' type='submit' form='post_mastodon_form'
  3067. name='post_mastodon_confirm' id='post_mastodon_confirm' value='<?=$this->T('修改')?>'></li> <?php } ?>
  3068. <hr /><li><a id='menu_delete' class='smaller'><?=$this->T('删除')?></a></li><?php } ?>
  3069. <?php }else{ ?>
  3070. <li><a id='menu_history'><?=$this->T('历史')?></a></li>
  3071. <?php } ?>
  3072. </ul>
  3073. </div>
  3074. <div id='backdrop' style='display:none;' class='backdrop' onclick='HideRightSide();HideBigImage(1);'
  3075. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"></div>
  3076. <div id='pop_right' class='pop_right' onclick='event.stopPropagation()'>
  3077. <div style='text-align:right;position:sticky;top:0;'><a class='clean_a' href='javascript:HideRightSide();'>
  3078. <?=$this->T('关闭')?>→</a></div>
  3079. <?php if($this->LoggedIn && in_array($this->PageType,['main','post'])){ ?>
  3080. <div id='_uploader' style='display:none;'>
  3081. <?php $this->MakeUploader(true); ?>
  3082. <p>&nbsp;</p>
  3083. <?php $this->MakeSideGalleryCode(); ?>
  3084. </div>
  3085. <?php } ?>
  3086. <div class='_content'></div>
  3087. </div>
  3088. <?php } ?>
  3089. <?php
  3090. }
  3091. function ChoosePartsByLanguage($content,$use_p=false){ if(!isset($content)) return $content;
  3092. $split = preg_split('/'.($use_p?'<p>\s*':'').'((en|zh|any)\|(en|zh|any))'.($use_p?'<\/p>\s*':'').'/u',$content, -1,
  3093. PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
  3094. $lang = $this->LanguageAppendix; $last_lang='0'; $reduced="";
  3095. if($split) for($i=0;$i<sizeof($split);$i+=4){
  3096. $this_lang = '0'; if($i+2>=sizeof($split)){ $this_lang = $last_lang; }else{ $this_lang = $split[$i+2]; }
  3097. if($this_lang==$lang || $this_lang=='any'){ $reduced.=$split[$i]; }
  3098. if($i+3<sizeof($split)){ $last_lang = $split[$i+3]; }
  3099. }
  3100. if(!$reduced)$reduced = $content;
  3101. return $reduced;
  3102. }
  3103. function TranslatePostParts($html){
  3104. $html = preg_replace_callback('/>(\s*)([^><]+?)(\s*)</u', function($ma){
  3105. $reduced = $this->ChoosePartsByLanguage($ma[2], false);
  3106. return ">".$ma[1].$this->T($reduced).$ma[3]."<";
  3107. }, $html);
  3108. return $html;
  3109. }
  3110. function MakeNavButtons(&$p){ global $INDEXPHP; $interesting=$this->IsInterestingPost($p); $no_title=isset($p['tid']['first']['no_title']);?>
  3111. <a href='<?=$INDEXPHP?>' class='clean_a hidden_m<?=$no_title?" hidden_on_print":""?>' onclick='ShowWaitingBar()'><b><?=$this->T($this->Title);?></b></a>
  3112. <?=$no_title?"<a class='inline_print'>&nbsp;</a>":""?>
  3113. <label for='titlectrl' id='mtitle'><b><a class='hidden_on_desktop'><?=$this->T($this->ShortTitle)?>...</a></b></label>
  3114. <div class='header_nav'>
  3115. <ul class='mobile_fold hidden_on_print' id='mobile_nav'>
  3116. <li class='hidden_m'><a href='?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  3117. <li class='hidden_on_desktop_force block_m smaller'>&nbsp;</li>
  3118. <li class='hidden_on_desktop_force block_m bigger'>
  3119. <a href='<?=$INDEXPHP?>?part=recent' onclick='ShowWaitingBar()'><?=$this->NotesView?$this->T('备忘录'):$this->T('最近')?></a>
  3120. <?php if($this->LoggedIn){ ?> | <span class='gray invert_a'>
  3121. <a href='<?=$INDEXPHP?>?set_notes_view=<?=$this->NotesView?'0':'1'?>'>N</a>
  3122. <a href='<?=$INDEXPHP?>?comments=all'>@</a> <a href='<?=$INDEXPHP?>?statistics=all'>%</a>
  3123. </span><?php } ?></li>
  3124. <li class='hidden_on_desktop_force block_m bigger'>
  3125. <a href='<?=$INDEXPHP?>?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  3126. <?php $this->SpecialNavigation;if(isset($this->SpecialNavigation) && ($p = &$this->GetPost($this->SpecialNavigation))!=NULL){
  3127. echo $this->GenerateSinglePost($p, false, false, false, false);
  3128. } ?>
  3129. <?php if($this->LanguageAppendix=='zh'){ ?>
  3130. <li class='smaller gray'>
  3131. <a href='<?=$this->GetRedirect(null,'en.php').'&set_language=en'?>' onclick='ShowWaitingBar()'><b>汉语</b>/English</a></li>
  3132. <?php }else { ?>
  3133. <li class='smaller gray'>
  3134. <a href='<?=$this->GetRedirect(null,'index.php').'&set_language=zh'?>' onclick='ShowWaitingBar()'>
  3135. 汉语/<b>English</b></a>
  3136. <br class='hidden_on_desktop' />
  3137. <a id='translate_button' target='_blank'>&nbsp;[Google Translate]&nbsp;</a></li>
  3138. <?php } ?>
  3139. </ul></div>
  3140. <?php
  3141. }
  3142. function MakeExpNavButtons(&$p){ global $INDEXPHP; ?>
  3143. <a href='<?=$INDEXPHP?>' class='hidden_m'>
  3144. <b><?=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle)?></b></a>
  3145. <a class='hidden_on_desktop'
  3146. href='javascript:toggle_mobile_show(document.getElementById("mobile_nav"))'><b class='round_btn'>
  3147. <?=$this->InExperimentalMode?$this->T($this->ExpShortTitle):$this->T($this->HereShortTitle)?></b></a>
  3148. <?php if(!$this->InExperimentalMode){ ?>
  3149. <a <?=$this->HereNumber==1?"class='gray'":("href=".$this->HereLinkFromNumber($this->HereNumber-1))?>>←</a>
  3150. <span><?=$this->HereNumber.'/'.sizeof($this->VisitedHere);?></span>
  3151. <span class='round_btn'>
  3152. <a href='<?=$this->HereNumber==sizeof($this->VisitedHere)?"?random_here=1":$this->HereLinkFromNumber($this->HereNumber+1);?>'>→</a>
  3153. <a href='?random_here=1'><?=$this->T("随机")?></a></span><span class='hidden_m'></span>
  3154. <?php } ?>
  3155. <ul class='hidden_m' id='mobile_nav' style='text-align:center;'>
  3156. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  3157. <li class='hidden_on_desktop block_m'><a href='<?=$INDEXPHP?>'><?=$this->T('主页')?></a></li>
  3158. <?php if($this->InExperimentalMode && isset($this->ExpNavigation) && ($p = &$this->GetPost($this->ExpNavigation))!=NULL){
  3159. echo $this->GenerateSinglePost($p, false, false, false, false);
  3160. }else if($this->InHereMode && isset($this->HereNavigation) && ($p = &$this->GetPost($this->HereNavigation))!=NULL){
  3161. echo $this->GenerateSinglePost($p, false, false, false, false);
  3162. } ?>
  3163. <?php if($this->AllowLanguageChoices){ ?>
  3164. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  3165. <?php if($this->LanguageAppendix=='zh'){ ?>
  3166. <li class='smaller invert_a gray'><a href='<?=$this->GetRedirect().'&set_language=en'?>'><b>汉语</b>/English</a></li>
  3167. <?php }else { ?>
  3168. <li class='smaller invert_a gray'><a href='<?=$this->GetRedirect().'&set_language=zh'?>'>汉语/<b>English</b></a></li>
  3169. <li class='smaller invert_a gray'><a id='translate_button' target='_blank'>&nbsp;Google Translate&nbsp;</a></li>
  3170. <?php } ?>
  3171. <?php } ?>
  3172. </ul>
  3173. <?php
  3174. }
  3175. function MakePostingFieldsV2($reply_to=NULL, $show_hint=false){ $STR="";
  3176. if(isset($this->WayBack)){
  3177. $STR.="<span class='gray'><i>{$this->T('以过去日期浏览时不能发帖。')}</i></span>";
  3178. $this->TFill(2,$STR); $this->TRow(); return;
  3179. }
  3180. $STR.="<form action='{$_SERVER['REQUEST_URI']}' method='post' style='display:none;' id='post_form'></form>
  3181. <div class='smaller'><div style='display:".($show_hint?"block":"none")."'>
  3182. <span id='post_hint_text'>{$this->T('继续补充该话题:')}</span></div>
  3183. <div id='post_hint_modify' style='display:none;'>
  3184. <input type='checkbox' name='post_record_edit' value='1' form='post_form' checked> {$this->T('新增历史记录')}</div></div>
  3185. <textarea id='post_content' name='post_content' rows='4' form='post_form'
  3186. onfocus=\"if (value =='{$this->T('有什么想说的')}'){value ='';}la_auto_grow(this);\"
  3187. onblur=\"if (value ==''){value='{$this->T('有什么想说的')}';la_auto_grow(this);}\"
  3188. oninput=\"la_auto_grow(this);\" onload=\"la_auto_grow(this);\">{$this->T('有什么想说的')}</textarea>
  3189. <input class='button' form=\"post_form\" type=\"submit\" name='post_button' value='{$this->T('发送')}'
  3190. onclick='ShowWaitingBar();' />
  3191. <input class='button' form=\"post_form\" type=\"submit\" name='post_button_note' value='{$this->T('备忘')}'
  3192. onclick='ShowWaitingBar();' />
  3193. | <a class='gray smaller pointer' onclick='ShowSideUploader();'>{$this->T('图片')}</a>
  3194. <div style='float:right;'>
  3195. <a class='gray smaller pointer' onclick=\"t=document.querySelector('#post_content');t.value='';la_auto_grow(t);\">
  3196. {$this->T('清空')}</a>
  3197. <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
  3198. </div>
  3199. <input style='display:none;' type=input form='post_form' id='post_edit_target' name='post_edit_target' />
  3200. <script> la_auto_grow(document.getElementById('post_content'));</script>";
  3201. if($reply_to){
  3202. $STR.="<input style='display:none;' type=input form='post_form' id='post_reply_to' name='post_reply_to' value='{$reply_to}' />";
  3203. }
  3204. $this->TFill(2,$STR);$this->TExtra("class='hidden_on_print'"); $this->TRow();
  3205. }
  3206. function MakeLinkedPostsV2(&$p){ $STR="";
  3207. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); if(!$has_ref)return; $count=0;
  3208. $STR.="<input type='checkbox' class='lpctrl' id='fake{$p["id"]}' checked='checked'>";
  3209. $count_product=0;
  3210. $STR.="<div class='linked_posts smaller'>";
  3211. $refs=sizeof($p["refs"]);
  3212. $STR.="<label class='lb ref_count' for='fake{$p["id"]}'>× $refs".$this->T("个引用").":</label><hr />";
  3213. foreach(array_reverse($p['refs']) as &$pr){
  3214. $po = $this->GetPost($pr);
  3215. if(!$this->CanShowPost($po)){ continue; } $count++;
  3216. $this->TBackup();
  3217. $this->MakeSinglePostV2($po, false, true, 0, true, true, false, false, true, false, false);
  3218. $STR.=$this->TRestore(" compact");
  3219. }
  3220. $STR.="</div>";
  3221. $this->TFill(0,$S0);
  3222. $this->TFill(1,$STR,2);$this->TExtra("style='border-bottom:none;'"); $this->TRow();
  3223. }
  3224. function MakeSinglePostV2(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
  3225. $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
  3226. $generate_thumb = false, $is_top = false, $force_hide_long=false){
  3227. $STR=""; $EXTRA="";$S0=""; $S1="";
  3228. $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
  3229. $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
  3230. $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
  3231. $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
  3232. $number = isset($post['number'])?$post['number']:0;
  3233. $title = $generate_anchor?$this->ChoosePartsByLanguage($this->GetPostTitle($post, true)):NULL;
  3234. $this->ConvertPost($post);// NEEDED FOR WIDE;
  3235. $is_wide = (isset($post['wide'])&&$post['wide']) || (isset($post['tid']) && isset($post['tid']['wide']) && $post['tid']['wide']);
  3236. if($show_link && (!$side)){ $this->MakeLinkedPostsV2($post); }
  3237. $EXTRA.="class='post $extra_class_string".($is_deleted?" deleted_post":"").($is_wide?" wide_post_print":"")."'";
  3238. if(!$side) $EXTRA.=(" data-post-id='".$post['id']."'");
  3239. if($is_deleted) $EXTRA.=" data-mark-delete='true'";
  3240. if(!$side&&isset($post['mastodon_url'])) $EXTRA.=(" data-mastodon_url='".$post['mastodon_url']."'");
  3241. //if($is_wide) $EXTRA.=" class=''";
  3242. if(!$side && !$strip_tags && $show_link){ $STR.="<div class='post_menu_button _menu_hook' >+</div>"; }
  3243. $this->TFill(2,$STR);
  3244. $symbol=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:"#";
  3245. $S1.="<a".($symbol!='#'?' class="marked"':'').
  3246. " href='?post={$post['id']}' onclick=\"".(($show_thread_link||$side)?'ShowWaitingBar()':'ClickPost(this.parentNode.parentNode,event,true)')."\">".
  3247. $symbol."<span class='mobile_fold'>".$number."</span>";
  3248. if($ref_count && !$side){
  3249. $S0.="<label class='lb' ".($show_link?"for='fake{$post["id"]}":"")."'><div class='ref_count'>+<span class='hidden_m'>{$ref_count}</span></div></label>";
  3250. }
  3251. if($is_product&&!$generate_anchor){ $STR.="<p class='smaller gray'>".$this->T('商品')."</p>";}
  3252. $STR.=$this->GenerateSinglePost($post, $strip_tags, $generate_anchor, $show_link,
  3253. $generate_thumb,($show_thread_link||$side||$force_hide_long));
  3254. if($show_thread_link && (!$side) && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) && $post['tid']['first']['id']!=$post['id']){
  3255. $STR.="<div class='gray block'>";
  3256. $STR.="<div class='smaller'>{$this->T('回复给主题帖:')}</div>";
  3257. $this->TBackup();
  3258. $this->MakeSinglePostV2($post['tid']['first'], false, false, false, false, false, false,false, true, false, false);
  3259. $STR.=$this->TRestore(" compact");
  3260. $STR.="</div>";
  3261. }
  3262. if($show_reply_count && isset($post['tid'])){
  3263. $STR.="<a class='smaller block invert_a' href='?post={$post['tid']['last']['id']}'>{$post['tid']['count']} {$this->T('个回复')}</a>";
  3264. }
  3265. $this->TFill(2,$STR); $this->TFill(1,$S1); $this->TFill(0,$S0); $this->TExtra($EXTRA); $this->TRow();
  3266. }
  3267. function MakePostSectionV2(&$post){ $STR=""; $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1;
  3268. $this->Anchors = []; if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))) $centerclass='center_slides'; else $centerclass='center';
  3269. if(isset($this->TagID)){ $STR.=<<<EOT
  3270. <style>{$this->CssNumberID($this->TagID)}{display:block;}</style>
  3271. EOT; } $th=NULL; $STR.="<br /><h2>";
  3272. $is_wide = (isset($post['wide'])&&$post['wide']) || ($is_thread && isset($post['tid']['wide']) && $post['tid']['wide']);
  3273. if($is_thread){ $th = $post['tid']; $STR.=$this->T('话题'); }else{ $STR.=$this->T('话题');$this->T('详细'); } $STR.="</h2>";
  3274. $this->TFill(2,$STR); $this->TExtra("class='hidden_on_print'"); $this->TRow();
  3275. $cat = NULL;
  3276. if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
  3277. else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
  3278. $this->MakePostTools();
  3279. if($cat){ $STR=<<<EOT
  3280. <p class='hidden_on_print'><b>{$this->T('分类')}</b> |
  3281. EOT; foreach($cat as $c){ $STR.=("<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "); }
  3282. $STR.="</p>";
  3283. }
  3284. $STR.="<br class='hidden_on_print' />"; $this->TFill(2,$STR); $this->TRow(); $is_reversed=false;
  3285. if($is_thread){ $use_arr = $th['arr']; $hinted=false;
  3286. $last_end_wide = true; $is_reversed=$this->IsReversedThread($th);
  3287. foreach($use_arr as &$p){$use_class="";if($p==$post){$use_class.=" active_post";}
  3288. if($last_end_wide){$use_class.=" last_wide";}
  3289. $make_title = ($p == $post);
  3290. if(isset($p['restart'])){ $STR="<li class='restart'><h3>{$p['restart']} …</h3></li>"; $this->TFill(0,$STR,3); $this->TRow(); }
  3291. $this->MakeSinglePostV2($p,true,false,$use_class,false, false, false, true, false, false);
  3292. if($make_title){ $STR.='<script>
  3293. document.title+=" | '.addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100))).'"</script>';
  3294. $this->TFill(2,$STR);
  3295. }
  3296. if($is_reversed && !$hinted){ $hinted = true;
  3297. if($this->LoggedIn && (!$this->InHereMode)){
  3298. $STR.="<div class='hidden_on_print'>";
  3299. $STR.=$this->MakePostingFieldsV2($is_thread?$th['last']['id']:$post['id'], true);
  3300. $STR.="</div><br />";
  3301. }
  3302. }
  3303. $last_end_wide = isset($p['end_wide']) && $p['end_wide'];
  3304. }
  3305. }else{
  3306. $this->MakeSinglePostV2($post,true, false,"active_post",false, false, false, true, false, false);
  3307. $STR.='<script>
  3308. document.title+=" | '.addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($post),0,100))).'"</script>';
  3309. $this->TFill(2,$STR); $this->TRow();
  3310. }
  3311. $STR="";
  3312. $class_add=""; if(isset($post['tid']['first']['no_time'])){ $class_add=' hidden_on_print'; }
  3313. $STR.="<div class='smaller align_right$class_add'>
  3314. <span class='gray'>".$this->ReadableTime($post['tid']['first']['id'])."</span>
  3315. <br class='hidden_on_desktop' />".
  3316. $this->ReadableTime(isset($post['tid']['last']['version'])?$post['tid']['last']['version']:$post['tid']['last']['id'])."
  3317. </div>";
  3318. $this->TFill(2,$STR); $this->TRow(); $STR="";
  3319. if(!$is_reversed && ($this->LoggedIn && (!$this->InHereMode))){
  3320. $STR.="<div class='hidden_on_print'><br />{$this->MakePostingFieldsV2($is_thread?$th['last']['id']:$post['id'], true)}</div>";
  3321. $this->TFill(2,$STR); $this->TRow();
  3322. }
  3323. if($this->NewsletterEnabled){ $STR=$this->MakeSubscription(); $this->TFill(2,$STR); $this->TRow(); }
  3324. //$this->MakeCommentSection($post);
  3325. $STR="";
  3326. if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))){
  3327. $STR.=<<<EOL
  3328. <div class='slides_buttons code' onclick="event.stopPropagation();">
  3329. <a onclick="SlidesFontCheck(-1)">T-</a> <a onclick="SlidesFontCheck(1)">T+</a>&nbsp;
  3330. <a onclick="SlidesStart(null)"><<</a> <a onclick="SlidesCheck(-1);"><</a>
  3331. <a onclick="SlidesStart(1)"><span id="slides_now">1</span>/<span id="slides_total">1</span></a>
  3332. <a onclick="SlidesCheck(1);">></a> <a onclick="SlidesEnd();">X</a>
  3333. </div>
  3334. <script>
  3335. function SlidesStart(from_here){
  3336. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  3337. sdone=0; fp=0; if(from_here){
  3338. urlParams = new URLSearchParams(window.location.search);
  3339. fp = urlParams.get('post');
  3340. }
  3341. document.querySelector("#slides_total").innerText=slides.length; cur=document.querySelector("#slides_now");
  3342. for(i=0;i<slides.length;i++){ slides[i].style.display="none";
  3343. 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; }
  3344. } if(!sdone){ slides[0].style.display="table-cell"; ClickPost(slides[0],0,true); cur.innerText=1; }
  3345. c=document.querySelector('.center'); if(!c) return;
  3346. c.classList.remove('center'); c.classList.add('center_slides'); if(c.dataset.fontSize){ c.style.fontSize=c.dataset.fontSize; }
  3347. c=document.querySelector('.left'); if(!c) return; c.style.display="none";
  3348. }
  3349. function SlidesCheck(offset){
  3350. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return; cur=document.querySelector("#slides_now");
  3351. for(i=0;i<slides.length;i++){ if(slides[i].style.display=="table-cell" && slides[i+offset] && (i+offset)>=0){
  3352. slides[i+offset].style.display="table-cell"; slides[i].style.display="none"; ClickPost(slides[i+offset],0,true); cur.innerText=i+offset+1; break;
  3353. }
  3354. }
  3355. }
  3356. function SlidesFontCheck(offset){
  3357. c=document.querySelector('.center_slides'); if(!c) return;
  3358. f=5; if(c.style.fontSize){ f=parseInt(c.style.fontSize); }
  3359. f+=offset; if(f<=0) f=1; if(f>12) f=12; c.style.fontSize=""+f+"vmin"; c.dataset.fontSize=c.style.fontSize;
  3360. }
  3361. function SlidesEnd(){
  3362. c=document.querySelector('.center_slides'); if(!c) return;
  3363. c.classList.remove('center_slides'); c.classList.add('center'); c.style.fontSize="";
  3364. c=document.querySelector('.left'); if(!c) return; c.style.display="inline-block";
  3365. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  3366. for(i=0;i<slides.length;i++){ slides[i].style.display=""; }
  3367. }
  3368. //document.addEventListener("wheel", function(event){ if(event.deltaY>0) SlidesCheck(1); else SlidesCheck(-1); }, { passive: false });
  3369. document.addEventListener("click", function(event){ SlidesCheck(1); });
  3370. document.addEventListener('keydown', function(event) {
  3371. const key = event.key; // "ArrowRight", "ArrowLeft", "ArrowUp", or "ArrowDown"
  3372. switch(key){
  3373. case "ArrowUp": case "ArrowLeft": SlidesCheck(-1); break; case "ArrowDown": case "ArrowRight": SlidesCheck(1); break;
  3374. case "Escape": SlidesEnd(); break;
  3375. }
  3376. });
  3377. </script>
  3378. EOL; $this->TAfter($STR);
  3379. }
  3380. }
  3381. function MakeSubscription($smaller=false){
  3382. $STR="";$STR.="<div".($smaller?" class='smaller hidden_on_print'":"").">
  3383. <form action='mailsub.php?subscribe=1' method='post' id='subscribe_form' style='display:none;'></form>
  3384. <br />
  3385. <h".($smaller?"3":"2").">{$this->T("订阅我的新闻")}</h".($smaller?"3":"2").">
  3386. <span class='gray'>{$this->T("输入您的邮件:")}</span>
  3387. <input type='text' id='email_subscribe_name' name='email_subscribe_name' form='subscribe_form' ".
  3388. ($smaller?"style='border-color:#f8ca9b88;background:rgba(0,0,0,0.2);max-width:16em;'":"").">
  3389. <input class='button' form='subscribe_form' type='submit' value={$this->T("订阅")}>
  3390. <br /></div>";
  3391. return $STR;
  3392. }
  3393. function MakeRecentPostsV2($search_term=NULL, $category=NULL){ global $INDEXPHP;
  3394. $STR=""; $tmppinned=$this->SpecialPinned;
  3395. if($this->LoggedIn && $this->NotesView){ $this->SpecialPinned=$this->SpecialPinnedNotes; }
  3396. if(!isset($search_term) && !isset($category) &&
  3397. (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
  3398. $this->CanShowPost($p,true)){
  3399. $this->MakeSinglePostV2($p, true, false, "active_post", false, true, false, false, false, true, false);
  3400. }
  3401. $this->SpecialPinned=$tmppinned;
  3402. if($this->NewsletterEnabled && !isset($category) && !isset($search_term) && !$this->NotesView){
  3403. $STR=$this->MakeSubscription(); $this->TFill(2,$STR); $this->TRow(); $STR='';
  3404. }
  3405. $STR.="<br /><h2>".(isset($search_term)?$this->T('搜索'):
  3406. (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
  3407. ($category=='none'?$this->T('未分类'):$this->T($category))):($this->NotesView?$this->T('备忘录'):$this->T('最近')).
  3408. "<span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
  3409. ($this->LoggedIn?" <a href='".$INDEXPHP."?set_notes_view=".($this->NotesView?'0':'1')."'>N</a> ".
  3410. "<a href='".$INDEXPHP."?comments=all'>@</a> <a href='".$INDEXPHP."?statistics=all'>%</a>":"")."</span>")).
  3411. "</h2><br />";
  3412. $this->TFill(2,$STR); $this->TRow();
  3413. if(isset($search_term)){
  3414. $STR.="<form action='".$INDEXPHP."' method='post' style='display:none;' id='search_form'></form>".
  3415. "<input id='search_content' name='search_content' rows='4' form='search_form' type='text' value='$search_term'>".
  3416. "<input class='button' form='search_form' type='submit' name='search_button' value='{$this->T('搜索')}'>";
  3417. $this->TFill(2,$STR); $this->TRow();
  3418. }else if(isset($category)){
  3419. $STR.="<div></div>";
  3420. $this->TFill(2,$STR); $this->TRow();
  3421. }else if($this->LoggedIn){
  3422. $this->TFill(2,$STR); $this->TRow();
  3423. $this->MakePostingFieldsV2(NULL,false);
  3424. }
  3425. $this->PostsPerPage=20;
  3426. $i = 0; $last_end_wide = true;
  3427. if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
  3428. if(!$this->CanShowPost($p,true) || $this->SkipProduct($p)) continue;
  3429. if(isset($p['tid'])){ /* Should always be set. */
  3430. $th = &$p['tid']; if($p['tid']['count']==0) continue;
  3431. if(!isset($search_term)) { $p = &$th['last']; }
  3432. }
  3433. if(isset($search_term)){
  3434. if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
  3435. }else if(isset($category)){
  3436. $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
  3437. (isset($p['categories'])?($p['categories']):[]);
  3438. if ($category=='none') { if($cat!=[]) continue; }
  3439. else{ if ($category=='' || !in_array($category, $cat)) continue; }
  3440. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3441. }else{
  3442. if(in_array($p['id'],
  3443. [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
  3444. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3445. }
  3446. if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
  3447. if($last_end_wide){$use_class="last_wide";}else{$use_class="";}
  3448. $this->MakeSinglePostV2($p, true, false, $use_class, false, !isset($search_term), false, false, false, false, isset($search_term));
  3449. $i++;
  3450. if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
  3451. $last_end_wide = sizeof($p['tid']['arr'])==1 && isset($p['end_wide']) && $p['end_wide'];
  3452. }
  3453. $STR=""; $EXTRA="class='clean_a'"; $STR.="<br /><br />".
  3454. "<a ".($this->CurrentOffset>0?("href='".$INDEXPHP."?offset=".($this->CurrentOffset-1).
  3455. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):"").
  3456. ($this->CurrentOffset==0?" class='gray'":"").">{$this->T('上一页')} ← </a>";
  3457. $STR.=" [ ".($this->CurrentOffset+1)." ] ";
  3458. $STR.="<a href='".$INDEXPHP."?offset=".($this->CurrentOffset+1).
  3459. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'>".
  3460. " → {$this->T('下一页')}</a>";
  3461. $this->TFill(0,$STR,3); $this->TExtra($EXTRA); $this->TRow();
  3462. }
  3463. function GeneratePage($is_section=false,$extra_classes=""){ $S="";
  3464. $S.="<table class='center print_column".($is_section?" clickable_section":"").($extra_classes)."'><tbody>";
  3465. foreach($this->PAGE as $r){ $S.="<tr ".(isset($r['extra'])?$r['extra']:"").">"; $spantotal=0; $sp="";
  3466. if(isset($r['span0'])){$sp=" colspan='".$r['span0']."'"; $spantotal+=$r['span0']; }else{ $spantotal++; };
  3467. if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[0])){ $S.=$r[0]; } $S.="</td>"; }
  3468. if(isset($r['span1'])){$sp=" colspan='".$r['span1']."'"; $spantotal+=$r['span1']; }else{ $spantotal++; };
  3469. if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[1])){ $S.=$r[1]; } $S.="</td>"; }
  3470. if(isset($r['span2'])){$sp=" colspan='".$r['span2']."'"; $spantotal+=$r['span2']; }else{ $spantotal++; };
  3471. if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[2])){ $S.=$r[2]; } $S.="</td>"; }
  3472. $S.="</tr>";
  3473. }
  3474. $S.="</tbody></table>";
  3475. return $S;
  3476. }
  3477. function GenerateLinkedPosts($ht){
  3478. $ht = preg_replace_callback('/<p>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>(.*)<\/a>[\s]*<\/p>/u',
  3479. function($m){
  3480. if(preg_match('/^\s*<img/u',$m[2])){ return $m[0]; }
  3481. $rp = &$this->GetPost($m[1], false, true);
  3482. $STR=$this->T("未找到该引用。");
  3483. if($rp!==NULL && $this->CanShowPost($rp)){
  3484. $this->TBackup();
  3485. $this->MakeSinglePostV2($rp, false, false, false, false, false, false,false, true, false, false);
  3486. $STR=$this->TRestore(" compact");
  3487. }
  3488. $s="<a class='smaller block' href='?post=".$m[1]."'>".$m[2]."</a><div class='block post gray'>".$STR."</div>";
  3489. return $s;
  3490. },
  3491. $ht
  3492. );
  3493. $ht = preg_replace_callback('/<li>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>PRODUCT\s+(.*)<\/a>[\s]*<\/li>/u',
  3494. function($m){
  3495. $rp = &$this->GetPost($m[1], false, true);
  3496. $s="<div class='product_ref block post ref_compact'><a href='?post=".$m[1]."' class='clean_a' onclick='ShowWaitingBar()'>".
  3497. (($rp!==NULL && $this->CanShowPost($rp))?
  3498. $this->GenerateSinglePost($rp,true,false,false,true,true):$this->T("未找到该引用。")).
  3499. "</a></div>";
  3500. return $s;
  3501. },
  3502. $ht
  3503. );
  3504. return $ht;
  3505. }
  3506. function GenerateSinglePost(&$post, $strip_tags, $generate_anchor=false, $generate_refs=false,
  3507. $generate_thumbs=false, $hide_long = false){
  3508. $this->ConvertPost($post);
  3509. if($generate_anchor){ $this->CreatePostAnchor($post); }
  3510. $ht = $post['html'];
  3511. if(isset($post['mark_value']) && $post['mark_value']==5 && ($generate_thumbs || !$generate_anchor)){
  3512. $ht="<div class='product_thumb'>".$post['images'][0]."</div>".
  3513. "<p class='bold'>".$post['product']['title']."</p>".
  3514. (isset($post['product']['short'])?("<p class='smaller gray'>".$post['product']['short']."</p>"):"").
  3515. "<p class='smaller bold'>".$post['product']['price']."</p>";
  3516. return $ht;
  3517. }
  3518. if($hide_long){
  3519. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>[\s\S]*/u',"<p class='smaller bold'>[".$this->T("阅读更多")."]</p>", $ht);
  3520. }else{
  3521. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>/u',"", $ht);
  3522. }
  3523. if ($strip_tags){
  3524. $ht = strip_tags($ht,'<b><i><h1><h2><h3><h4><p><blockquote><span>');
  3525. $ht = preg_replace('/<p>\s*<\/p>/u',"", $ht);
  3526. $ht = $ht;
  3527. }
  3528. else{
  3529. if($generate_refs) $ht = $this->GenerateLinkedPosts($ht);
  3530. }
  3531. if ($strip_tags && $generate_thumbs){
  3532. $ht="<div class='hide_long'>".$ht."</div>";
  3533. if(isset($post['images']) && isset($post['images'][0])){
  3534. $ht.="<div class='post_ref_images'><ul class='side_thumb ref_thumb'>";
  3535. foreach($post['images'] as $im){
  3536. $ht.="<li class='file_thumb'>".$im."</li>";
  3537. }
  3538. $ht.="</ul></div>";
  3539. }
  3540. }
  3541. return $ht;
  3542. }
  3543. function MakeSinglePostExp(&$post){ ?>
  3544. <li class='post post_dummy'>
  3545. <?=$this->GenerateSinglePost($post, false, false, true, false, false); ?>
  3546. </li>
  3547. <?php
  3548. }
  3549. function MakeSinglePost(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
  3550. $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
  3551. $generate_thumb = false, $is_top = false, $force_hide_long=false){
  3552. $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
  3553. $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
  3554. $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
  3555. $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
  3556. $title = $generate_anchor?$this->ChoosePartsByLanguage($this->GetPostTitle($post, true)):NULL;
  3557. $this->ConvertPost($post);// NEEDED FOR WIDE;
  3558. $is_wide = (isset($post['wide'])&&$post['wide']) || (isset($post['tid']) && isset($post['tid']['wide']) && $post['tid']['wide']);
  3559. ?>
  3560. <?=$title?"<div class='print_title'><h1>".$title."</h1></div>":""?>
  3561. <div class='post<?=isset($extra_class_string)?' '.$extra_class_string:''?>'
  3562. <?=(!$side)?"data-post-id='".$post['id']."'":""?> <?=$is_deleted?"data-mark-delete='true'":""?>
  3563. <?=(!$side&&isset($post['mastodon_url']))?"data-mastodon_url='".$post['mastodon_url']."'":""?>
  3564. <?=$is_wide?" style='column-span:all;'":"";?>>
  3565. <?php if($mark_value>=0 && !$show_link && $mark_value!='P'){?>
  3566. <div class='smaller <?=$is_deleted?"gray":""?>'><?=$mark_value?> <?=$this->T('标记')?></div>
  3567. <?php }
  3568. if(!$side && !$strip_tags && $show_link){?><div class='post_menu_button _menu_hook' >+</div><?php } ?>
  3569. <?php if(!$side && $show_link){ $ref_count=100; ?>
  3570. <a href='?post=<?=$post['id']?>' onclick="<?=$show_thread_link||isset($_GET['search'])?'ShowWaitingBar()':'ClickPost(this.parentNode,event,true)'?>">
  3571. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  3572. <?=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:($ref_count?"":"")?>
  3573. </div>
  3574. </a><?php if($ref_count){ ?>
  3575. <label class='lb post_access' for='fake<?=$post["id"]?>'><div class='ref_count'><?=$ref_count?></div></label><?php }
  3576. } ?>
  3577. <?=$side?"<a href='?post={$post['id']}' onclick='ShowWaitingBar()'>":""?>
  3578. <?php if(!$strip_tags){ $this->MakeLinkedPosts($post); } ?>
  3579. <div class='<?=$side?"":'post_width'?><?=$is_deleted?" deleted_post":""?>'>
  3580. <?php if($is_product&&!$generate_anchor){
  3581. echo "<p class='smaller gray'>".$this->T('商品')."</p>";
  3582. echo "<div class='product_ref clean_a'><a href='?post={$post['id']}'>";} ?>
  3583. <?=$this->GenerateSinglePost($post, $strip_tags, $generate_anchor, true,
  3584. $generate_thumb,($show_thread_link||$side||$force_hide_long)); ?>
  3585. <?php if($is_product&&!$generate_anchor){echo "</a></div>";} ?>
  3586. </div>
  3587. <?=$side?"</a>":""?> <?php
  3588. if($show_thread_link && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) &&
  3589. $post['tid']['first']['id']!=$post['id']){ ?>
  3590. <div class='gray smaller block opt_compact post'>
  3591. <a href='?post=<?=$post['tid']['first']['id']?>' onclick='ShowWaitingBar()'>#423
  3592. <div class='post_access invert_a hover_dark smaller'><?=isset($post['tid']['first']['mark_value'])?
  3593. $this->Markers[$post['tid']['first']['mark_value']]:"→"?></div></a>
  3594. <div class='post_width'><div class='smaller'><?=$this->T('回复给主题帖:')?></div>
  3595. <?=$this->GenerateSinglePost($post['tid']['first'], false, false, false, true, true);?>
  3596. </div>
  3597. </div>
  3598. <?php }
  3599. if($show_reply_count && isset($post['tid'])){ ?>
  3600. <a class='smaller block invert_a' href='?post=<?=$post['tid']['last']['id']?>'><?=$post['tid']['count']?>
  3601. <?=$this->T('个回复')?></a>
  3602. <?php } ?>
  3603. </div>
  3604. <?php
  3605. }
  3606. function MakePostingFields($reply_to=NULL, $show_hint=false){
  3607. if(isset($this->WayBack)){ ?>
  3608. <span class='gray'><i><?=$this->T('以过去日期浏览时不能发帖。')?></i></span>
  3609. <?php return; } ?>
  3610. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='post_form'></form>
  3611. <div class='smaller'><div style='display:<?=$show_hint?"block":"none"?>;'>
  3612. <span id='post_hint_text'><?=$this->T('继续补充该话题:')?></span></div>
  3613. <div id='post_hint_modify' style='display:none;'>
  3614. <input type="checkbox" name="post_record_edit" value="1" form='post_form' checked> <?=$this->T('新增历史记录');?></div></div>
  3615. <textarea id="post_content" name="post_content" rows="4" form='post_form'
  3616. onfocus="if (value =='<?=$this->T('有什么想说的')?>'){value ='';}la_auto_grow(this);"
  3617. onblur="if (value ==''){value='<?=$this->T('有什么想说的')?>';la_auto_grow(this);}"
  3618. oninput="la_auto_grow(this);" onload="la_auto_grow(this);"><?=$this->T('有什么想说的')?></textarea>
  3619. <input class='button' form="post_form" type="submit" name='post_button' value=<?=$this->T('发送')?>
  3620. onclick='ShowWaitingBar();' />
  3621. | <a class='gray smaller pointer' onclick='ShowSideUploader();'><?=$this->T('图片')?></a>
  3622. <div style='float:right;'>
  3623. <a class='gray smaller pointer' onclick='t=document.querySelector("#post_content");t.value="";la_auto_grow(t);'>
  3624. <?=$this->T('清空')?></a>
  3625. <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
  3626. </div>
  3627. <input style='display:none;' type=input form="post_form" id='post_edit_target' name='post_edit_target' />
  3628. <script> la_auto_grow(document.getElementById("post_content"));</script>
  3629. <?php if($reply_to){ ?>
  3630. <input style='display:none;' type=input form="post_form" id='post_reply_to' name='post_reply_to' value='<?=$reply_to?>' />
  3631. <?php } ?>
  3632. <?php
  3633. }
  3634. function MakeCommentPosts(){ global $INDEXPHP;
  3635. if(!$this->LoggedIn) return; ?>
  3636. <h2><?=$this->T('评论')?></h2><div class='spacer'></div>
  3637. <?php if(!$this->CommentEnabled){
  3638. echo "<p><span class='text_highlight'>&nbsp;".$this->T("已关闭评论")."&nbsp;</span></p><br />"; } ?>
  3639. <div class='comment'><ul>
  3640. <?php $i=0;
  3641. foreach(array_reverse($this->Posts) as $p){
  3642. if(!isset($p['comment_to'])) continue;
  3643. if($i < $this->CommentsPerPage * $this->CurrentOffset) {$i++; continue;}
  3644. $ht = $this->GenerateSinglePost($p, false, false, false, false, false);
  3645. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3646. $post_to = $this->GetPost($p['comment_to']); $post_title = $this->GetPostTitle($post_to);
  3647. if(!$post_to) $post_title = "?";
  3648. $mail = "<span class='gray hidden_on_print'>&nbsp;".
  3649. "<a href='mailto:".$p['email']."'>@</a>&nbsp;".
  3650. (isset($p['ip'])?$p['ip']:"?")."&nbsp;<br class='hidden_on_desktop'/>".
  3651. "<a href='$INDEXPHP?post=".$p['comment_to']."'>(".$post_title.")</a></span>";
  3652. echo "<li><p><b>".$name.":</b>".$mail."<br /></p>".$ht."</li>";
  3653. $i++;
  3654. }
  3655. ?>
  3656. </ul><br /></div>
  3657. <?php
  3658. }
  3659. function MakeRecentPosts($search_term=NULL, $category=NULL){ global $INDEXPHP; ?>
  3660. <div class='center' id='div_center'><br class='hidden_on_print' />
  3661. <?php if(!isset($search_term) && !isset($category) &&
  3662. (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
  3663. $this->CanShowPost($p)){
  3664. ?><ul class='print_column list bkg_section'><?php
  3665. $this->MakeSinglePost($p, true, false, "active_post", false, true, false, false, false, true, false);
  3666. ?></ul><br /><?php
  3667. }?>
  3668. <h2><?=isset($search_term)?$this->T('搜索'):
  3669. (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
  3670. ($category=='none'?$this->T('未分类'):$this->T($category))):($this->NotesView?$this->T('备忘录'):$this->T('最近')).
  3671. " <span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
  3672. ($this->LoggedIn?"<a href='$INDEXPHP?comments=all'>@</a> <a href='$INDEXPHP?statistics=all'>%</a>":"")."</span>")?></h2><br />
  3673. <?php if(isset($search_term)){ ?>
  3674. <form action="<?=$INDEXPHP?>" method="post" style='display:none;' id='search_form'></form>
  3675. <input id="search_content" name="search_content" rows="4" form='search_form' type='text' value='<?=$search_term?>'>
  3676. <input class='button' form="search_form" type="submit" name='search_button' value=<?=$this->T('搜索')?>
  3677. <?php }else if(isset($category)){ ?>
  3678. <div></div>
  3679. <?php }else if($this->LoggedIn){ ?>
  3680. <div class='post_box_top _input_bundle'>
  3681. <?php $this->MakePostingFields(NULL,false); ?>
  3682. </div>
  3683. <?php } ?>
  3684. <ul class='print_column list bkg_recent'>
  3685. <?php
  3686. $i = 0; $last_end_wide = true;
  3687. if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
  3688. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  3689. if(isset($p['tid'])){ /* Should always be set. */
  3690. $th = &$p['tid']; if($p['tid']['count']==0) continue;
  3691. if(!isset($search_term)) { $p = &$th['last']; }
  3692. }
  3693. if(isset($search_term)){
  3694. if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
  3695. }else if(isset($category)){
  3696. $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
  3697. (isset($p['categories'])?($p['categories']):[]);
  3698. if ($category=='none') { if($cat!=[]) continue; }
  3699. else{ if ($category=='' || !in_array($category, $cat)) continue; }
  3700. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3701. }else{
  3702. if(in_array($p['id'],
  3703. [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
  3704. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3705. }
  3706. if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
  3707. if($last_end_wide){$use_class="last_wide";}else{$use_class="";}
  3708. $this->MakeSinglePost($p, true, false, $use_class, false, !isset($search_term), false, false, false, false, isset($search_term));
  3709. $i++;
  3710. if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
  3711. $last_end_wide = sizeof($p['tid']['arr'])==1 && isset($p['end_wide']) && $p['end_wide'];
  3712. }?>
  3713. </ul>
  3714. <div class='page_selector clean_a'>
  3715. <hr />
  3716. <a <?=$this->CurrentOffset>0?("href='".$INDEXPHP."?offset=".($this->CurrentOffset-1).
  3717. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):""?>
  3718. <?=$this->CurrentOffset==0?"class='gray'":""?>><?=$this->T('上一页')?> ←</a>
  3719. <?=$this->CurrentOffset+1?>
  3720. <a href='<?=$INDEXPHP?>?offset=<?=($this->CurrentOffset+1).
  3721. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))?>'>
  3722. → <?=$this->T('下一页')?></a>
  3723. </div>
  3724. </div>
  3725. <?php
  3726. }
  3727. function MakeLinkedPosts(&$p){
  3728. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); if(!$has_ref)return; $count=0;?>
  3729. <input type='checkbox' class='lpctrl' id='fake<?=$p["id"]?>' checked='checked'>
  3730. <div class='linked_posts smaller'>
  3731. <ul><?php $count_product=0;
  3732. foreach(array_reverse($p['refs']) as &$pr){
  3733. $po = $this->GetPost($pr);
  3734. if(!$this->CanShowPost($po)){ continue; } $count++;
  3735. $this->MakeSinglePost($po, false, true, "post_preview invert_a", true, false, false, false, true, false, false);
  3736. }
  3737. ?></ul>
  3738. </div>
  3739. <?php
  3740. }
  3741. function MakeLinkedPostsExp(&$p){
  3742. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); ?>
  3743. <div class='center_exp post_dummy smaller'>
  3744. <hr />
  3745. <?php if(!$this->InExperimentalMode){ ?>
  3746. <h3<?=$has_ref?"":" class='gray'"?>><?=$this->T('链接')?></h3>
  3747. <?php if($has_ref){ ?>
  3748. <div class='smaller'><?=sizeof($p['refs'])?> <?=$this->T('个引用:')?></div>
  3749. <ul><?php $count_product=0;
  3750. foreach(array_reverse($p['refs']) as &$pr){
  3751. echo "<li class='post_dummy'><a href='?post=".$pr."'>".$this->T($this->GetPostTitle($this->GetPost($pr),false)).
  3752. "</a></li>";
  3753. }
  3754. ?></ul>
  3755. <?php if($count_product){ ?> <span class='smaller'><?=$this->T('和').' '.$count_product.' '.$this->T('个商品')?></span> <?php }
  3756. }else{ ?>
  3757. <div class='gray smaller'><?=$this->T('没有帖子链接到这里。')?></div>
  3758. <?php } }?>
  3759. <div style='margin-bottom:4rem;'>&nbsp;</div>
  3760. </div>
  3761. <?php
  3762. }
  3763. function MakePostHistoryList(&$ah, &$post,$version=NULL, $show_latest=true){
  3764. $latest_ver=isset($post['version'])?$post['version']:$post['id'];
  3765. $can_show=1; if(isset($this->WayBack) && $latest_ver>$this->WayBack) $can_show=0;
  3766. $title = NULL; if(!isset($ah) || ($show_latest && $can_show)) { $title=$this->T($this->GetPostTitle($post, false)); }
  3767. else{ $ver = &$ah['list'][sizeof($ah['list'])-1]; $title= $this->GetPostTitle($ver); }
  3768. if(!isset($title)) $title=$this->T('未命名');
  3769. if(!isset($ah)){ ?>
  3770. <h2><?=$this->T('没有历史记录')?></h2>
  3771. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$post['id']?>'><?=$title?></a></span><br />
  3772. <?php }else{ ?>
  3773. <h2><?=$this->T('历史记录')?></h2>
  3774. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$ah['id']?>'><?=$title?></a></span><br />
  3775. <div class='list'><ul>
  3776. <?php if($show_latest && $can_show){ $post['history_displayed']=1; ?>
  3777. <li class='<?=isset($version)&&$version==$latest_ver?" post_current_row bold":""?>' style='list-style:"";'>
  3778. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$latest_ver?>'><?=$this->ReadableTime($latest_ver)?></a>
  3779. <span class='smaller gray'><?=$this->T('长度').' '.strlen($post['content'])?></span>
  3780. <?php if(isset($post['merged_from'][0])){ ?><ul><?php foreach($post['merged_from'] as $from){
  3781. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3782. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3783. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3784. <?=$this->GetPostTitle($ver);?></a>
  3785. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3786. <?php } ?></ul><?php } ?>
  3787. <?php if(isset($post['merged_thread'][0][0])){ $pm=$post['merged_thread'][0][0];
  3788. $mah = &$this->GetArchiveHandle($pm);
  3789. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3790. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  3791. <span class='smaller gray'><?=sizeof($post['merged_thread'][0]);?> <?=$this->T('个帖子')?></span></li></ul>
  3792. <?php } ?>
  3793. </li><?php } ?>
  3794. <?php if(isset($ah['list'][0])) foreach(array_reverse($ah['list']) as &$ver){
  3795. if(isset($this->WayBack) && $ver['version']>$this->WayBack) continue;
  3796. if(isset($ver['history_displayed']) && $ver['history_displayed']) continue; ?>
  3797. <li<?=isset($version)&&$version==$ver['version']?" class='post_current_row bold'":""?>>
  3798. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$ver['version']?>'><?=$this->ReadableTime($ver['version'])?></a>
  3799. <span class='smaller gray'> <?=$this->T('长度').' '.strlen($ver['content'])?></span>
  3800. <?php if(isset($ver['merged_thread'][0][0])){ $pm=$ver['merged_thread'][0][0];
  3801. $mah = &$this->GetArchiveHandle($pm); $mver = &$this->GetPost($pm);
  3802. if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3803. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  3804. <span class='smaller gray'> <?=sizeof($ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></li></ul>
  3805. <?php } if(isset($ver['merged_from'][0])){ ?><ul><?php foreach($ver['merged_from'] as $from){
  3806. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3807. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3808. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3809. <?=$this->GetPostTitle($ver);?></a>
  3810. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3811. <?php } ?></ul></li><?php } ?>
  3812. <?php } ?></ul></div>
  3813. <?php } ?>
  3814. <?php
  3815. }
  3816. function MakePostDiff(&$this_ver, &$last_ver){
  3817. if(!isset($this_ver)){ ?>
  3818. <h2 class='gray'><?=$this->T('版本不存在')?></h2>
  3819. <?php }else{ ?>
  3820. <h2><?=$this->T('差异')?></h2>
  3821. <?php if(isset($this_ver['merged_thread']) && isset($this_ver['merged_thread'][0][0])){
  3822. $pm=$this_ver['merged_thread'][0][0]; $mah = &$this->GetArchiveHandle($pm);
  3823. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3824. <p><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver)?></a> <?=$this->T('并入这里')?>
  3825. <br /><span class='smaller gray'> <?=sizeof($this_ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></p>
  3826. <?php }else{ ?>
  3827. <table class='diff_table'><thead>
  3828. <tr><td><?php if(!isset($last_ver)){ ?><?=$this->T('没有更旧的版本')?><?php }else{ ?>
  3829. <?=$this->T('上一个版本')?><br /><?=$this->ReadableTime($last_ver['version'])?><?php } ?></td>
  3830. <td class='text_highlight bold'><?=$this->T('选择的版本')?><br /><?=$this->ReadableTime($this_ver['version'])?></td></tr>
  3831. </thead><tbody>
  3832. <tr><td><pre><?=isset($last_ver)?$last_ver['content']:""?></pre></td><td><pre><?=$this_ver['content']?></pre></td></tr>
  3833. </tbody>
  3834. </table>
  3835. <?php } ?>
  3836. <br /><a class='smaller' href='?post=<?=$this_ver['id']?>&set_wayback=<?=isset($this_ver['version'])?$this_ver['version']:$this_ver['id']?>'><?=$this->T('前往该版本时间')?> ←</a>
  3837. <?php } ?>
  3838. <?php
  3839. }
  3840. function MakePostHistory(&$post, $version=NULL){
  3841. $ah = &$this->GetArchiveHandle($this->CurrentPostID);
  3842. $p = &$post; if(!isset($post)){ $p=&$ah['list'][0]; }
  3843. $show_latest = isset($ah)?(!isset($ah['list'][sizeof($ah['list'])-1]['merged_into'])):true;
  3844. ?>
  3845. <div class='left mobile_fold history' id='div_left'>
  3846. <?php if (isset($version)){
  3847. $this->MakePostHistoryList($ah, $p, $version, $show_latest);
  3848. }else{ echo "&nbsp;"; } ?>
  3849. </div>
  3850. <div class='center history' id='div_center'>
  3851. <?php if (!isset($version)){
  3852. $this->MakePostHistoryList($ah, $p, NULL, $show_latest);
  3853. }else{
  3854. $this_ver = NULL; $next_ver = NULL; $last_ver=NULL;
  3855. $this_ver = &$this->GetArchiveVersion($ah, $version, $next_ver, $last_ver);
  3856. if(!isset($this_ver)){$this_ver = $p; $last_ver=$ah['list'][sizeof($ah['list'])-1];}
  3857. $this->MakePostDiff($this_ver, $last_ver, $p);
  3858. } ?>
  3859. </div>
  3860. <?php
  3861. }
  3862. function MakeCommentSection(&$post){ global $INDEXPHP;
  3863. if(!$this->CommentEnabled){ return; }
  3864. $to_post = isset($post['tid'])?$post['tid']['first']:$post;
  3865. $comment_count = (isset($to_post['comments']) && isset($to_post['comments'][0]))?count($to_post['comments']):0;
  3866. ?><div class='comment'>
  3867. <br /><h2><?=$this->T('评论')?> (<?=$comment_count;?>)</h2><div class='spacer'></div>
  3868. <?php if($comment_count) { echo "<ul>";
  3869. foreach($to_post['comments'] as $p){
  3870. $ht = $this->GenerateSinglePost($p, false, false, false, false, false);
  3871. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3872. $mail = $this->LoggedIn?("<span class='gray clean_a hidden_on_print'>&nbsp;".
  3873. "<a href='mailto:".$p['email']."'>@</a>&nbsp;</span>"):"";
  3874. echo "<li><p><b>".$name.":</b>".$mail."</p>".$ht."</li>";
  3875. }
  3876. echo "</ul>";
  3877. } else {
  3878. echo $this->T('还没有评论');
  3879. } ?>
  3880. <div class='hidden_on_print'>
  3881. <div class='spacer'></div>
  3882. <form action="<?=$INDEXPHP?>?post=<?=$this->CurrentPostID?>&comment_to=<?=$to_post['id']?>"
  3883. method="post" style="display:none;" id="comment_form"></form>
  3884. <p><a class='text_highlight bold clean_a'
  3885. onclick='document.getElementById("comment_box").style.display="block";this.parentNode.style.display="none"'>
  3886. &nbsp;<?=$this->T('写评论');?>&nbsp;</a></p>
  3887. <div id='comment_box' style='display:none;'>
  3888. <p class='gray' style='margin-bottom:0.5em;'><?=$this->T('您的邮箱不会公开展示。');?></p>
  3889. <table style='white-space:nowrap;'>
  3890. <tr><td colspan='2'>
  3891. <textarea id="comment_box" name="comment_box" rows="4" class='full_box' form='comment_form'
  3892. oninput="CommentUpdated();" ></textarea>
  3893. </td></tr>
  3894. <tr><td><?=$this->T('电子邮件')?>*</td><td><?=$this->T('称呼')?>*</td></tr>
  3895. <tr><td><input type="text" form="comment_form" id='comment_email' name='comment_email'
  3896. class='full_box' oninput="CommentUpdated();" /></td>
  3897. <td><input type="text" form="comment_form" id='comment_name' name='comment_name'
  3898. class='full_box' oninput="CommentUpdated();" /></td></tr>
  3899. <tr><td colspan='2'><?=$this->T('个人网站')?></td></tr>
  3900. <tr><td colspan='2'>
  3901. <input type="text" form="comment_form" id='comment_link' name='comment_link'
  3902. class='full_box' oninput="CommentUpdated();" />
  3903. </td></tr>
  3904. <tr><td colspan='2'>
  3905. <div class='spacer'></div>
  3906. <input class='button text_highlight bigger' type='submit' form='comment_form'
  3907. name='comment_confirm' id='comment_confirm' value='&nbsp;<?=$this->T('发送')?>&nbsp;'>
  3908. </td></tr>
  3909. </table></div>
  3910. <script>
  3911. const IsValidEmail = (email) => {
  3912. 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,}))$/);
  3913. };
  3914. function IsValidHttpUrl(string) {
  3915. let url; try{ url = new URL(string); } catch (_) { return false; }
  3916. return url.protocol === "http:" || url.protocol === "https:";
  3917. }
  3918. var cbox = document.getElementById('comment_box');
  3919. var cemail = document.getElementById('comment_email');
  3920. var cname = document.getElementById('comment_name');
  3921. var clink = document.getElementById('comment_link');
  3922. var cconfirm = document.getElementById('comment_confirm');
  3923. function CommentUpdated(){
  3924. cconfirm.disabled=true;
  3925. if (cemail.value!="" && IsValidEmail(cemail.value) &&
  3926. cbox.innerText.length>2 && cname.value.length>2 &&
  3927. clink.value=="" || IsValidHttpUrl(clink.value)){
  3928. cconfirm.removeAttribute("disabled");
  3929. }
  3930. }
  3931. CommentUpdated();
  3932. </script>
  3933. </div>
  3934. </div>
  3935. <?php
  3936. }
  3937. function MakeInterestingSection(&$th){
  3938. $this->Anchors = [];
  3939. $c = &$th['first']['content'];
  3940. $this->ConvertPost($th['first']);
  3941. $ht = $th['first']['html'];
  3942. ?>
  3943. <script>function ClickImage(post_access){im=post_access.querySelector('img');if(im){im.click();}}</script>
  3944. <div class='center_full' id='div_center'>
  3945. <?php $this->MakePostTools(); ?>
  3946. <?php $cat = NULL;
  3947. if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; }
  3948. if($cat){ ?>
  3949. <p><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  3950. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  3951. <?php } ?>
  3952. <h2 class='hidden_on_print'><?=$this->T('有趣')?>
  3953. <a class='gray clean_a' href='?post=<?=$th['first']['id']?>'>→</a></h2>
  3954. <ul><li class='post' data-post-id='<?=$th['first']['id']?>'>
  3955. <div class='post_menu_button _menu_hook' onclick='ShowPostMenu(this.parentNode);'>+</div><?=$ht?>
  3956. <?php if(isset($th['first']['refs'][0])){ ?><p class='smaller'><?=$this->T('引用')?>: </p><ul class='smaller'>
  3957. <?php foreach($th['first']['refs'] as $ref){
  3958. $po = $this->GetPost($ref);
  3959. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  3960. if(!$this->CanShowPost($po)){ continue; }
  3961. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  3962. } ?>
  3963. </ul><?php } ?>
  3964. <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  3965. <div class='hidden_on_print'><br />
  3966. <?php $this->MakePostingFields($th['last']['id'], true);?><br />
  3967. </div>
  3968. <?php } ?>
  3969. <table><thead><tr><?php foreach($th['interesting'] as $header){ ?>
  3970. <td><?=$this->T($header);?></td>
  3971. <?php } ?><td></td></tr></thead><tbody class='interesting_tbody'>
  3972. <?php $plist = array_reverse(array_slice($th['arr'],1));
  3973. foreach($plist as &$p){
  3974. $this->ConvertPost($p);
  3975. $mark_value = isset($p['mark_value'])?$this->Markers[$p['mark_value']]:-1;
  3976. $ref_count = isset($p['refs'])?sizeof($p['refs']):0;
  3977. $is_current = $p['id']==$this->CurrentPostID;
  3978. $is_deleted = (isset($p['mark_delete'])&&$p['mark_delete']); ?>
  3979. <tr class='<?=$is_current?"post_current_row":""?><?=$is_deleted?" deleted_post":""?>'
  3980. data-post-id='<?=$p['id']?>' <?=$is_deleted?"data-mark-delete='true'":""?>
  3981. onDblClick='ClickImage(this)'><td>
  3982. <?php if($ref_count){ ?>
  3983. <div class='post_access ref_count'><?=$ref_count?></div>
  3984. <?php } ?></a>
  3985. <?=$p['html'];?>
  3986. <a class='_menu_hook clean_a post_menu_button' onclick='ShowPostMenu(this.parentNode.parentNode);'>+</a>
  3987. <a <?=$is_current?"":("href='?post=".$p['id']."' onclick='ShowWaitingBar()'");?> class='clean_a paa'>
  3988. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  3989. <?=isset($p['mark_value'])?$this->Markers[$p['mark_value']]:($ref_count?"":"→")?>
  3990. </div></td></tr>
  3991. <?php if($is_current && $ref_count>0){ ?><tr class='post_current_row'><td><p>&nbsp;</p><ul class='smaller'>
  3992. <?php foreach($p['refs'] as $ref){
  3993. $po = $this->GetPost($ref);
  3994. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  3995. if(!$this->CanShowPost($po)){ continue; }
  3996. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  3997. } ?>
  3998. </ul></td></tr><?php } ?>
  3999. <?php } ?>
  4000. </tbody></table>
  4001. </li></ul>
  4002. <br />
  4003. <?php $this->MakeCommentSection($th['first']); ?>
  4004. </div>
  4005. <?php return true;
  4006. }
  4007. function CssNumberID($id){
  4008. return "#\\3".substr($id,0,1)." ".substr($id,1);
  4009. }
  4010. function MakePostTools(){
  4011. if($this->LoggedIn && !isset($this->WayBack)){ $STR=<<<EOT
  4012. <div class='smaller gray hidden_on_print clean_a'>
  4013. <a id='merge_cancel' href='javascript:{TogglePostSelectMode(false,true);ToggleThreadMerge(false,true);}'>
  4014. {$this->T('工具')}</a>:<div class='hidden_m' style='display:inline'>
  4015. <span id='merge_post_btn'><a href='javascript:TogglePostSelectMode()'>{$this->T('合并帖子')}</a></span>
  4016. | <span id='merge_thread_btn'><a href='javascript:ToggleThreadMerge()'>{$this->T('合并话题')}</a></span>
  4017. </div>
  4018. <select class='hidden_on_desktop' id='merge_select'
  4019. onchange="if(this.selectedIndex==1){TogglePostSelectMode(true);}else if(this.selectedIndex==2){ToggleThreadMerge(true);}">
  4020. <option value='-1' selected>--</option>
  4021. <option value='1'>{$this->T('合并帖子')}</option>
  4022. <option value='2'>{$this->T('合并话题')}</option></select>
  4023. <div style='display:none;' id='merge_post_dialog' class='text_highlight small_pad align_right'>
  4024. <div style='display:inline;'>{$this->T('将合并')} <span id='merge_post_count'></span> {$this->T('个帖子')}</div>
  4025. <span class='clean_a bold align_right'><a id='merge_post'>&nbsp;{$this->T('执行')}</a></span></div>
  4026. <div style='display:none;overflow:auto' id='merge_thread_dialog' class='text_highlight small_pad align_right'>
  4027. <div style='display:inline;'>{$this->T('合并到话题')}</div>
  4028. <input id="merge_thread_target" type="text" style="width:9em;display:inline" onChange='ThreadMergeInput(this);' onInput='ThreadMergeInput(this);'>
  4029. <span class='clean_a bold align_right'><a id='merge_thread'>&nbsp;{$this->T('执行')}</a></span></div>
  4030. </div><div class='spacer hidden_on_print'></div>
  4031. EOT;
  4032. }
  4033. $this->TFill(2,$STR); $this->TRow();
  4034. }
  4035. function MakeSidebar(){ ?>
  4036. <div class='left mobile_fold'><?php if(isset($this->SpecialSidebar) && ($p = &$this->GetPost($this->SpecialSidebar))!=NULL){
  4037. ?><span class='gray smaller'><br /></span><?php
  4038. //echo $this->GenerateSinglePost($p, false, false, false, false);
  4039. }?>
  4040. <div class='wayback_link clean_a smaller'><span class='gray'><br /><?=$this->T('工具')?></span><ul>
  4041. <li><a href='?search=' onclick='ShowWaitingBar()' class='bigger'><?=$this->T('搜索')?></a></li>
  4042. <li><?php if(!isset($this->WayBack)){ ?>
  4043. <a href='<?=$this->GetRedirect()?>&set_wayback=true'><?=$this->T('以过去的日期浏览')?></a>
  4044. <?php }else{ ?><a href='<?=$this->GetRedirect()?>&set_wayback=false'><?=$this->T('回到当前日期')?></a><?php } ?></li>
  4045. <li><a href='<?=$this->GetRedirect()?>&toggle_font=true'>
  4046. <?=$this->T('切换字体')?>: <?=$this->T($this->UseRemoteFont?"远程":"本地");?></a></li>
  4047. <li><a rel="alternate" type="application/rss+xml" href="?rss=<?=$this->LanguageAppendix;?>" />RSS/Atom<sup><?=$this->LanguageAppendix;?></sup></a></li>
  4048. </ul>
  4049. </div>
  4050. <?php if($this->NewsletterEnabled){ $STR=$this->MakeSubscription(1); echo $STR; }?>
  4051. <br />
  4052. <hr class="hidden_on_desktop" />
  4053. </div>
  4054. <?php }
  4055. function MakePostSection(&$post){ $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1;
  4056. $this->Anchors = []; if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))) $centerclass='center_slides'; else $centerclass='center';
  4057. if(isset($this->TagID)){ ?><style><?=$this->CssNumberID($this->TagID);?>{display:block;}</style><?php } ?>
  4058. <div class='<?=$centerclass;?>' id='div_center'><br class='hidden_on_print' />
  4059. <h2 class='hidden_on_print'>
  4060. <?php $th=NULL;
  4061. $is_wide = (isset($post['wide'])&&$post['wide']) || ($is_thread && isset($post['tid']['wide']) && $post['tid']['wide']);
  4062. if($is_thread){ $th = $post['tid'];?> <?=$this->T('话题')?> <?php }else{ ?> <?=$this->T('详细')?>
  4063. <?php } ?></h2>
  4064. <?php $cat = NULL;
  4065. if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
  4066. else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
  4067. $this->MakePostTools();
  4068. if($cat){ ?>
  4069. <p class='hidden_on_print'><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  4070. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  4071. <?php } ?><br class='hidden_on_print' />
  4072. <ul class='print_column bkg_section'>
  4073. <?php $is_reversed=false;
  4074. if($is_thread){
  4075. $use_arr = $th['arr']; $hinted=false;
  4076. $last_end_wide = true; $is_reversed=$this->IsReversedThread($th);
  4077. foreach($use_arr as &$p){$use_class="";if($p==$post){$use_class.=" active_post";}
  4078. if($last_end_wide){$use_class.=" last_wide";}
  4079. $make_title = ($p == $post);
  4080. if(isset($p['restart'])){ ?>
  4081. <li class='restart'><h3><?=$p['restart']?></h3></li><?php }
  4082. $this->MakeSinglePost($p,true,false,$use_class,false, false, false, true, false, false);
  4083. if($make_title){?>
  4084. <script>
  4085. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  4086. </script>
  4087. <?php } if($is_reversed && !$hinted){ ?><?php $hinted = true;
  4088. if($this->LoggedIn && (!$this->InHereMode)){ ?>
  4089. <div class='hidden_on_print'>
  4090. <?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?></div><br />
  4091. <?php } }
  4092. $last_end_wide = isset($p['end_wide']) && $p['end_wide'];
  4093. }
  4094. }else{
  4095. $this->MakeSinglePost($post,true, false,"active_post",false, false, false, true, false, false);
  4096. ?><script>
  4097. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($post),0,100)))?>";
  4098. </script><?php
  4099. } $class_add=""; if(isset($post['tid']['first']['no_time'])){ $class_add=' hidden_on_print'; } ?>
  4100. </ul>
  4101. <div class='smaller align_right<?=$class_add;?>'>
  4102. <span class='gray'><?=$this->ReadableTime($post['tid']['first']['id']);?></span>
  4103. <br class='hidden_on_desktop' /><?=$this->ReadableTime(isset($post['tid']['last']['version'])?
  4104. $post['tid']['last']['version']:$post['tid']['last']['id']);?>
  4105. </div>
  4106. <?php if(!$is_reversed && ($this->LoggedIn && (!$this->InHereMode))){ ?>
  4107. <div class='hidden_on_print'>
  4108. <br /><?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?>
  4109. </div>
  4110. <?php }
  4111. $this->MakeCommentSection($post);
  4112. ?>
  4113. </div>
  4114. <?php if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))){ ?>
  4115. <div class='slides_buttons code' onclick="event.stopPropagation();">
  4116. <a onclick="SlidesFontCheck(-1)">T-</a> <a onclick="SlidesFontCheck(1)">T+</a>&nbsp;
  4117. <a onclick="SlidesStart(null)"><<</a> <a onclick="SlidesCheck(-1);"><</a>
  4118. <a onclick="SlidesStart(1)"><span id="slides_now">1</span>/<span id="slides_total">1</span></a>
  4119. <a onclick="SlidesCheck(1);">></a> <a onclick="SlidesEnd();">X</a>
  4120. </div>
  4121. <script>
  4122. function SlidesStart(from_here){
  4123. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  4124. sdone=0; fp=0; if(from_here){
  4125. urlParams = new URLSearchParams(window.location.search);
  4126. fp = urlParams.get('post');
  4127. }
  4128. document.querySelector("#slides_total").innerText=slides.length; cur=document.querySelector("#slides_now");
  4129. for(i=0;i<slides.length;i++){ slides[i].style.display="none";
  4130. 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; }
  4131. } if(!sdone){ slides[0].style.display="table-cell"; ClickPost(slides[0],0,true); cur.innerText=1; }
  4132. c=document.querySelector('.center'); if(!c) return;
  4133. c.classList.remove('center'); c.classList.add('center_slides'); if(c.dataset.fontSize){ c.style.fontSize=c.dataset.fontSize; }
  4134. c=document.querySelector('.left'); if(!c) return; c.style.display="none";
  4135. }
  4136. function SlidesCheck(offset){
  4137. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return; cur=document.querySelector("#slides_now");
  4138. for(i=0;i<slides.length;i++){ if(slides[i].style.display=="table-cell" && slides[i+offset] && (i+offset)>=0){
  4139. slides[i+offset].style.display="table-cell"; slides[i].style.display="none"; ClickPost(slides[i+offset],0,true); cur.innerText=i+offset+1; break;
  4140. }
  4141. }
  4142. }
  4143. function SlidesFontCheck(offset){
  4144. c=document.querySelector('.center_slides'); if(!c) return;
  4145. f=5; if(c.style.fontSize){ f=parseInt(c.style.fontSize); }
  4146. f+=offset; if(f<=0) f=1; if(f>12) f=12; c.style.fontSize=""+f+"vmin"; c.dataset.fontSize=c.style.fontSize;
  4147. }
  4148. function SlidesEnd(){
  4149. c=document.querySelector('.center_slides'); if(!c) return;
  4150. c.classList.remove('center_slides'); c.classList.add('center'); c.style.fontSize="";
  4151. c=document.querySelector('.left'); if(!c) return; c.style.display="inline-block";
  4152. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  4153. for(i=0;i<slides.length;i++){ slides[i].style.display=""; }
  4154. }
  4155. //document.addEventListener("wheel", function(event){ if(event.deltaY>0) SlidesCheck(1); else SlidesCheck(-1); }, { passive: false });
  4156. document.addEventListener("click", function(event){ SlidesCheck(1); });
  4157. document.addEventListener('keydown', function(event) {
  4158. const key = event.key; // "ArrowRight", "ArrowLeft", "ArrowUp", or "ArrowDown"
  4159. switch(key){
  4160. case "ArrowUp": case "ArrowLeft": SlidesCheck(-1); break; case "ArrowDown": case "ArrowRight": SlidesCheck(1); break;
  4161. case "Escape": SlidesEnd(); break;
  4162. }
  4163. });
  4164. </script>
  4165. <?php }
  4166. }
  4167. function MakePostSectionExp(&$post){
  4168. $this->Anchors = []; $is_thread = isset($post['tid']);
  4169. ?>
  4170. <div class='center_exp' id='div_center'><br class='hidden_on_print' />
  4171. <ul>
  4172. <?php $is_reversed=false;
  4173. if($is_thread){ $th = &$post['tid'];$use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false;
  4174. foreach($use_arr as &$p){
  4175. $this->MakeSinglePostExp($p);
  4176. if($p == $th['first']){?>
  4177. <script>
  4178. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  4179. </script>
  4180. <?php } if($is_reversed && !$hinted){ ?>
  4181. <li class='gray smaller bold' style='text-align:center;'>
  4182. <p>&nbsp;</p><hr><?=$this->T('该话题最新帖子在前')?><hr><p>&nbsp;</p></li>
  4183. <?php $hinted = true; }
  4184. }
  4185. }else{
  4186. $this->MakeSinglePostExp($post);
  4187. ?><!--<script>
  4188. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  4189. </script>--><?php
  4190. } ?>
  4191. </ul>
  4192. </div>
  4193. <?php
  4194. }
  4195. function MakeHereSection(&$im){ $image_okay = (isset($im) && $im!=$this->NULL_IMAGE); ?>
  4196. <div class='here_image_box clean_a'>
  4197. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'>
  4198. <?=$image_okay?$this->T('请稍候'):$this->T('未找到图像')?></div>
  4199. <?php if($image_okay){ ?>
  4200. <?php if(isset($im['video']) && isset($im['video'])!=""){ ?>
  4201. <video controls><source src='<?=$im['file'];?>' type='<?=$im['video']?>'></video>
  4202. <?php }else{ ?>
  4203. <img id='big_image' onload="HideWaitingBar();" src="<?=$im['file'];?>" />
  4204. <?php } ?>
  4205. <?php } $this->MakeHereButtons($im, false); ?>
  4206. </div>
  4207. <?php }
  4208. function MakeSideGalleryCode(){?>
  4209. <div>
  4210. <h3><?=$this->T('点击图片以插入:')?></h3>
  4211. <select id="side_gallery_select" onchange="RefreshSideGallery()">
  4212. <option value="main"><?=$this->T('全部')?></option>
  4213. <?php if($this->LoggedIn){ ?>
  4214. <option value="trash"><?=$this->T('垃圾桶')?></option>
  4215. <?php }?>
  4216. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  4217. <option value="<?=$g['name']?>"><?=$g['name']?></option>
  4218. <?php } ?>
  4219. </select>
  4220. <div id='side_gallery'>
  4221. </div>
  4222. </div>
  4223. <script>
  4224. function InsertImage(imgname){
  4225. t = document.querySelector("#post_content");
  4226. v = t.value;
  4227. t.value = v.slice(0, t.selectionStart) + "![<?=$this->T('图片')?>](images/"+imgname+")"+ v.slice(t.selectionEnd);
  4228. la_auto_grow(t);
  4229. }
  4230. function RefreshSideGallery(){
  4231. let xhr = new XMLHttpRequest();
  4232. xhr.onreadystatechange = (function(){
  4233. if (this.readyState === this.DONE) {
  4234. if (this.status === 200) {
  4235. ind = document.querySelector("#side_gallery");
  4236. if(res = xhr.responseText.matchAll(/\[(.*?),(.*?)\]/gu)){
  4237. str = "<ul class='side_thumb'>"
  4238. for (const m of res) {
  4239. imgstr = "<img src='"+m[2]+"' />";
  4240. if(m[2].match('\.mp4')){
  4241. imgstr = "<video><source src='"+m[2]+"'></video>";
  4242. }
  4243. str+="<li><div class='file_thumb' onclick='InsertImage(\""+m[1]+"\")'>"+imgstr+"</div>"
  4244. }
  4245. str += "</ul>"
  4246. ind.innerHTML = str;
  4247. }
  4248. }
  4249. }
  4250. });
  4251. xhr.open("GET", "?image_list="+document.querySelector("#side_gallery_select").value, true);
  4252. xhr.send();
  4253. }
  4254. </script>
  4255. <?php
  4256. }
  4257. function MakeUploader($is_side=false){ ?>
  4258. <div id='upload_operation_area' class='hidden_on_print'>
  4259. <p><?=$this->T('选择、粘贴或者拖动到页面以上传图片。')?></p>
  4260. <input type="file" id='upload_selector' accept="image/x-png,image/png,image/gif,image/jpeg" multiple/>
  4261. <ul id='file_list'>
  4262. </ul>
  4263. <div class='smaller gray' id='upload_hint'><?=$this->T('就绪')?></div>
  4264. </div>
  4265. <a id='upload_click' class='hidden_on_print pointer' onclick='this.removeAttribute("onclick");UploadList();'
  4266. <?=$is_side?" data-is-side='true'":""?>><?=$this->T('上传列表中的文件')?></a>
  4267. <script>
  4268. function pastehandler(event){
  4269. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  4270. for (index in items) {
  4271. var item = items[index];
  4272. if (item.kind === 'file') {
  4273. put = document.querySelector("#_uploader");
  4274. if(put) ShowSideUploader();
  4275. var blob = item.getAsFile();
  4276. AddImageFile(blob);
  4277. return;
  4278. }
  4279. }
  4280. }
  4281. let _fd_list = []; var uploading=0;
  4282. let hint=document.querySelector('#upload_hint');
  4283. function ToggleCompress(button){
  4284. li = button.parentNode;
  4285. num=li.dataset.number;
  4286. for(i=0;i<_fd_list.length;i++){
  4287. if (_fd_list[i][0] == num){
  4288. state = _fd_list[i][2];
  4289. if(state){_fd_list[i][2] = 0; button.innerHTML='1920';break;}
  4290. else{_fd_list[i][2] = 1; button.innerHTML='800';break;}
  4291. }
  4292. }
  4293. }
  4294. function RemoveFromUpload(button){
  4295. li = button.parentNode;
  4296. num=li.dataset.number;
  4297. for(i=0;i<_fd_list.length;i++){
  4298. if (_fd_list[i][0] == num){
  4299. _fd_list.splice(i, 1);break;
  4300. }
  4301. }
  4302. li.parentNode.removeChild(li);
  4303. }
  4304. function EndThisUpload(){
  4305. unfinished = 0;
  4306. for(i=0;i<_fd_list.length;i++){
  4307. if (_fd_list[i][3]==0){
  4308. unfinished=1;
  4309. }
  4310. }
  4311. if(!unfinished){
  4312. uploading=0;
  4313. hint.innerHTML="<?=$this->T('上传完成。')?>";
  4314. cl=document.querySelector('#upload_click');
  4315. if(!cl.dataset.isSide){
  4316. cl.innerHTML="<?=$this->T('刷新页面')?>";
  4317. cl.href=window.location.href;
  4318. }else{
  4319. _fd_list.splice(0,_fd_list.length);
  4320. fl = document.querySelector("#file_list");
  4321. fl.innerHTML = "";
  4322. list=document.querySelector('#upload_operation_area');
  4323. list.style.pointerEvents='';
  4324. list.style.opacity='';
  4325. cl.onclick=function(){this.removeAttribute("onclick");UploadList();};
  4326. document.onpaste=pastehandler;
  4327. RefreshSideGallery();
  4328. }
  4329. }
  4330. }
  4331. function UploadList(){
  4332. if(!_fd_list.length || uploading) return;
  4333. uploading=1;
  4334. hint.innerHTML="<?=$this->T('正在上传...')?>";
  4335. list=document.querySelector('#upload_operation_area');
  4336. list.style.pointerEvents='none';
  4337. list.style.opacity='0.5';
  4338. document.onpaste="";
  4339. for(i=0;i<_fd_list.length;i++){
  4340. let xhr = new XMLHttpRequest();
  4341. var li = list.querySelector('[data-number="'+_fd_list[i][0].toString()+'"]')
  4342. xhr.open("POST", "?compress="+_fd_list[i][2].toString(), true);
  4343. function wrap(li, i){
  4344. var ind = li.querySelector('._compress_toggle')
  4345. return function(){
  4346. if (this.readyState === this.DONE) {
  4347. if (this.status === 200) {
  4348. var response = xhr.responseText;
  4349. if(res = response.match(/<uploaded>(.*)<\/uploaded>/)){
  4350. ind.innerHTML = "<?=$this->T('已上传为')?> "+res[1];
  4351. _fd_list[i][3] = 1;
  4352. }else{
  4353. ind.innerHTML = "<?=$this->T('出现错误。')?>";
  4354. _fd_list[i][3] = 1;
  4355. }
  4356. EndThisUpload();
  4357. }
  4358. }
  4359. }
  4360. }
  4361. xhr.onreadystatechange = wrap(li, i);
  4362. xhr.send(_fd_list[i][1]);
  4363. }
  4364. }
  4365. function AddImageFile(blob){
  4366. var ext="";
  4367. if(blob.name.match(/png$/i))ext = 'png';
  4368. else if(blob.name.match(/jpg$/i))ext = 'jpg';
  4369. else if(blob.name.match(/jpeg$/i))ext = 'jpeg';
  4370. else if(blob.name.match(/gif$/i))ext = 'gif';
  4371. else if(blob.name.match(/mp4$/i))ext = 'mp4';
  4372. else return;
  4373. var fd = new FormData();
  4374. blob.name = blob.name=generateUID().toString();
  4375. fd.append("upload_file_name", blob, "_upload_"+blob.name+"."+ext);
  4376. _fd_list.push([blob.name, fd, 1, 0]);/* number original is_compress uploaded */
  4377. var reader = new FileReader();
  4378. reader.onload = function(event){
  4379. fl = document.querySelector("#file_list");
  4380. ht = "<li id='_upload_"+blob.name+"' data-number='"+blob.name+"'>"+
  4381. "<a class='_remove_file pointer invert_a' onclick='RemoveFromUpload(this)'>×</a> "+"<div class='file_thumb'>"+
  4382. "<img class='no_pop' src='"+event.target.result+"'>"+"</div>"+
  4383. " →<a class='_compress_toggle pointer' onclick='ToggleCompress(this)'>800</a></li>";
  4384. fl.innerHTML+=ht;
  4385. };
  4386. reader.readAsDataURL(blob);
  4387. }
  4388. sel = document.querySelector('#upload_selector');
  4389. sel.addEventListener("change", function(){
  4390. var input = this;
  4391. function ff(file){
  4392. return function(e){
  4393. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  4394. blob.name = file.name;
  4395. AddImageFile(blob);
  4396. }
  4397. }
  4398. for(i=0;i<input.files.length;i++){
  4399. if(input.files[i].size){
  4400. let reader = new FileReader();
  4401. reader.onload = ff(input.files[i]);
  4402. reader.readAsArrayBuffer(input.files[i]);
  4403. }
  4404. }
  4405. });
  4406. function generateUID() {
  4407. var firstPart = (Math.random() * 46656) | 0;
  4408. var secondPart = (Math.random() * 46656) | 0;
  4409. firstPart = ("000" + firstPart.toString(36)).slice(-3);
  4410. secondPart = ("000" + secondPart.toString(36)).slice(-3);
  4411. return firstPart + secondPart;
  4412. }
  4413. document.onpaste = pastehandler;
  4414. function dropHandler(ev) {
  4415. put = document.querySelector("#_uploader");
  4416. if(put) ShowSideUploader();
  4417. bkg=document.querySelector('#dropping_background');
  4418. bkg.style.display="none";
  4419. console.log('File(s) dropped');
  4420. ev.preventDefault();ev.stopPropagation();
  4421. if (ev.dataTransfer && ev.dataTransfer.items) {
  4422. for (var i = 0; i < ev.dataTransfer.items.length; i++) {
  4423. if (ev.dataTransfer.items[i].kind === 'file') {
  4424. var file = ev.dataTransfer.items[i].getAsFile();
  4425. function ff(file){
  4426. return function(e){
  4427. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  4428. blob.name = file.name;
  4429. AddImageFile(blob);
  4430. }
  4431. }
  4432. if(file){
  4433. let reader = new FileReader();
  4434. reader.onload = ff(file);
  4435. reader.readAsArrayBuffer(file);
  4436. }
  4437. }
  4438. }
  4439. } else {
  4440. for (var i = 0; i < ev.dataTransfer.files.length; i++) {
  4441. function ff(file){
  4442. return function(e){
  4443. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  4444. blob.name = file.name;
  4445. AddImageFile(blob);
  4446. }
  4447. }
  4448. if(ev.dataTransfer.files[i].size){
  4449. let reader = new FileReader();
  4450. reader.onload = ff(ev.dataTransfer.files[i]);
  4451. reader.readAsArrayBuffer(ev.dataTransfer.files[i]);
  4452. }
  4453. }
  4454. }
  4455. }
  4456. function dragOverHandler(ev) {
  4457. bkg=document.querySelector('#dropping_background');
  4458. bkg.style.display="";
  4459. console.log('File(s) in drop zone');
  4460. ev.preventDefault();
  4461. }
  4462. </script>
  4463. <?php
  4464. }
  4465. function CanShowGallery(&$g){
  4466. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($g['experimental']) && $g['experimental']) return false;
  4467. return true;
  4468. }
  4469. function CanShowImage(&$im){
  4470. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($im['galleries']) && isset($im['galleries'][0])) foreach($im['galleries'] as $ga){
  4471. if(($g=$this->GetGallery($ga)) && isset($g['experimental']) && $g['experimental']) return false;
  4472. }
  4473. if(isset($this->WayBack) && substr($im['name'],0,14)>$this->WayBack) return false;
  4474. return true;
  4475. }
  4476. function GetImageBatch($from,$show_all){
  4477. if(!isset($_GET['gallery'])) return;
  4478. $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){$name=$_GET['gallery'];}
  4479. $reached=0; $count=0;
  4480. if(isset($this->Images[0])) foreach($this->Images as $im){
  4481. if(isset($from)&&!$reached){ if($from==$im['name']){ $reached=1; } continue; }
  4482. if(!$this->CanShowImage($im)){ continue; }
  4483. if($_GET['gallery']=='trash') $name='trash';
  4484. if($_GET['gallery']!='main'){ if(!isset($im['galleries']) || !in_array($name, $im['galleries'])) continue;} ?>
  4485. <div class='p_thumb<?=isset($im['parent'])?" p_thumb_narrow":""?>'>
  4486. <?php if($this->LoggedIn){ ?>
  4487. <div class="post_menu_button _select_hook white" onclick='ToggleSelectImage(this, "<?=$im["name"]?>")'>●</div>
  4488. <?php } ?>
  4489. <a href='?show_image=<?=$im['name']?>' target='_blank' onclick='event.preventDefault();'>
  4490. <?php if(isset($im['video']) && $im['video']!=""){ ?>
  4491. <video data-imgsrc='<?=$im["name"]?>'><source src='<?=$im['file']?>' type='<?=$im['video']?>'></video>
  4492. <?php }else{ ?>
  4493. <img src='<?=$im['thumb']?>' data-imgsrc='<?=$im["name"]?>'
  4494. <?=isset($im['product'])?'data-product="'.$im["product"].'"':""?>
  4495. <?=isset($im['parent'])?'data-parent="'.$im["parent"].'"':""?>
  4496. <?=isset($im['align'])?'data-align="'.$im["align"].'" style="object-position:'.$im['align'].';"':""?>/>
  4497. <?php } ?>
  4498. </a>
  4499. </div>
  4500. <?php $count+=isset($im['parent'])?0:1; if((!$show_all)&&($count>=$this->GalleryStep)){ break; }
  4501. }
  4502. if($count<$this->GalleryStep){ ?><div style='display:none'>END_GALLERY</div><?php return 0; }
  4503. return 1;
  4504. }
  4505. function MakeGallerySection(){ global $INDEXPHP;
  4506. if(!isset($_GET['gallery'])) return;
  4507. $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){ $name=$_GET['gallery'];}
  4508. $show_all=0; if(isset($_GET['show_all']) && $_GET['show_all']!='0'){ $show_all=1; } ?>
  4509. <script>
  4510. document.title+=" | <?=$this->T('画廊')?>";
  4511. </script>
  4512. <div class='center_wide' id='div_center' style='position:relative;'><br class='hidden_on_print' />
  4513. <h2><?=(isset($name) && ($gal=$this->GetGallery($name))!=NULL)?
  4514. ("<span class='gray album_hint'>".$this->T('相册').":</span>".$this->T($name)):
  4515. ($_GET['gallery']=='trash'?$this->T('垃圾桶'):$this->T('画廊'))?></h2>
  4516. <?php $description=(isset($gal) && isset($gal['description']))?$gal['description']:null; ?>
  4517. <div class='hidden_on_desktop'>
  4518. <?=$this->T('前往')?>
  4519. <select id="gallery_go_to" onchange="window.location.href='?gallery='+this.value;">
  4520. <optgroup label="<?=$this->T('精选')?>">
  4521. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4522. if(!isset($g['featured']) || !$g['featured'] ||
  4523. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  4524. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  4525. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  4526. <?php } ?></optgroup><optgroup label="<?=$this->T('其他相册')?>">
  4527. <option value="main" <?=$_GET['gallery']=='main'?"selected":""?>>[<?=$this->T('全部')?>]</option>
  4528. <?php if($this->LoggedIn){ ?>
  4529. <option value="trash" <?=$_GET['gallery']=='trash'?"selected":""?>>[<?=$this->T('垃圾桶')?>]</option>
  4530. <?php } ?>
  4531. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4532. if((isset($g['featured']) && $g['featured']) ||
  4533. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  4534. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  4535. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  4536. <?php } ?></optgroup>
  4537. </select>
  4538. </div>
  4539. <?php if($this->LoggedIn){?>
  4540. <div>
  4541. <?php if(isset($name)){ ?>
  4542. <div style='text-align:right;position:absolute;right:0;top:0;width:100%;' class='invert_a smaller hidden_on_print'>
  4543. <a href='javascript:ShowDeleteMenu();'><?=$this->T('删除相册')?></a><br />
  4544. <?php if(isset($gal['featured']) && $gal['featured']!=false){ ?>
  4545. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=false'>
  4546. <?=$this->T('取消精选')?></a>
  4547. <?php }else{ ?>
  4548. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=true'>
  4549. <?=$this->T('设为精选')?></a>
  4550. <?php } ?><br />
  4551. <?php if(isset($gal['experimental']) && $gal['experimental']!=false){ ?>
  4552. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=false'>
  4553. <?=$this->T('取消实验')?></a>
  4554. <?php }else{ ?>
  4555. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=true'>
  4556. <?=$this->T('设为实验')?></a>
  4557. <?php } ?>
  4558. <div class='pop_menu invert_a' id='gallery_delete_menu' style='display:none;'>
  4559. <div style='float:left;' class='gray'><?=$this->T('该操作不删除图片。')?></div>
  4560. <a href='javascript:HidePopMenu();'>×</a>
  4561. <hr />
  4562. <a href='?gallery=main&gallery_edit_delete=<?=$_GET['gallery']?>'><b><?=$this->T('删除相册')?></b></a>
  4563. </div>
  4564. </div>
  4565. <?php } ?>
  4566. <?php $this->MakeUploader(false); ?>
  4567. <div style='text-align:right;position:relative;' class='invert_a smaller hidden_on_print'>
  4568. <div style='position:relative'>
  4569. <?php if(isset($name)){ ?>
  4570. <a href='javascript:ShowGalleryEditMenu("<?=$name?>",null)'><?=$this->T('改名')?></a>
  4571. <a href='javascript:ShowGalleryEditMenu("<?=$name?>","<?=$description?>")'><?=$this->T('描述')?></a>
  4572. <?php } ?>
  4573. <a href='javascript:ShowGalleryEditMenu(null,null)'><?=$this->T('添加')?></a>
  4574. <div class='pop_menu invert_a' id='gallery_edit_menu' style='display:none;max-width:90%;'>
  4575. <form action="<?=$_SERVER['REQUEST_URI']?>&edit_gallery=true"
  4576. method="post" style='display:none;' id='gallery_edit_form'></form>
  4577. <a style='float:left;'><?=$this->T('设置为:')?></a>
  4578. <a href='javascript:HidePopMenu();'>×</a>
  4579. <input type='text' form='gallery_edit_form' name='gallery_edit_new_name' id='gallery_edit_new_name' style='width:10em;'>
  4580. <input type='text' form='gallery_edit_form' name='gallery_edit_old_name' id='gallery_edit_old_name' style='display:none'>
  4581. <input type='text' form='gallery_edit_form' name='gallery_edit_description' id='gallery_edit_description' style='width:10em;display:none'>
  4582. <input class='button' type='submit' form='gallery_edit_form'
  4583. name='gallery_edit_confirm' id='gallery_edit_confirm' value='<?=$this->T('确认')?>'>
  4584. </div>
  4585. </div>
  4586. </div>
  4587. <div class='smaller hidden_on_print'>
  4588. <form action="<?=$_SERVER['REQUEST_URI']?>"
  4589. method="post" style='display:none;' id='gallery_move_form'></form>
  4590. <input type='text' form='gallery_move_form' name='gallery_move_ops'
  4591. id='gallery_move_ops' style='display:none'>
  4592. <p><?=$this->T('选择了')?> <span id='gallery_selected_count'>0</span> <?=$this->T('个图片。')?>
  4593. <a href='javascript:ClearSelectedImages()'><?=$this->T('清除')?></a></p>
  4594. <p><?=$this->T('添加到')?>
  4595. <select id="gallery_move_to">
  4596. <option value="trash"><?=$this->T('垃圾桶')?></option>
  4597. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  4598. <option value="<?=$g['name']?>"><?=$this->T($g['name'])?></option>
  4599. <?php } ?>
  4600. </select>
  4601. <a href='javascript:AddToGallery()'><?=$this->T('执行')?></a>
  4602. </p>
  4603. <p>
  4604. <?=$this->T('或者')?><a href='javascript:RemoveFromGallery()'><?=$this->T('从相册移除')?></a>
  4605. </p>
  4606. </div>
  4607. </div>
  4608. <?php } $desc=isset($description)?$this->GetPost($description):null;
  4609. if(isset($desc)){ ?><ul class='print_column list'><br /><?php
  4610. $this->MakeSinglePost($desc, false, false, false, false, false, false, false, false, true, false);
  4611. ?></ul><?php } ?>
  4612. <br />
  4613. <div><div class='p_row'><?php $has_more=$this->GetImageBatch(NULL, $show_all);?>
  4614. <div class='p_thumb p_thumb_end' <?=$has_more?"onclick='ThisGetMore(this);'":""?>>
  4615. <a onclick='event.preventDefault();' href='<?=$INDEXPHP?>?gallery=<?=$_GET['gallery']?>&show_all=1'>
  4616. <h2 id="btn_more_images"><?=$has_more?$this->T("查看更多"):$this->T("没有更多的了");?></a></h2></div></div>
  4617. </div>
  4618. </div>
  4619. <script type='text/javascript'>
  4620. function ThisGetMore(end_ui){
  4621. var xhr = new XMLHttpRequest();
  4622. xhr.onreadystatechange = function() {
  4623. if (this.readyState == 4 && this.status == 200) {
  4624. doc = document.createElement("div"); doc.innerHTML=xhr.responseText.trim(); next_child=null;
  4625. for(child=doc.firstChild; child!==null; child=next_child) { next_child=child.nextSibling; end_ui.parentNode.insertBefore(child,end_ui); }
  4626. doc.remove();
  4627. if(xhr.responseText.search('END_GALLERY')>=0){ end_ui.onclick=null; end_ui.innerHTML="<h2><?=$this->T("没有更多的了");?></h2>"; }
  4628. UpdateImageClickables();
  4629. btn=document.getElementById("btn_more_images"); if(btn) btn.innerText="<?=$this->T("查看更多");?>";
  4630. }
  4631. };
  4632. btn=document.getElementById("btn_more_images"); if(btn) btn.innerText="<?=$this->T("稍等");?>";
  4633. im=end_ui.previousElementSibling.querySelector('img,video');
  4634. from=im?im.dataset.imgsrc:null; if(!from) return;
  4635. const urlParams = new URLSearchParams(window.location.search); const gallery = urlParams.get('gallery')
  4636. xhr.open("GET", "<?=$INDEXPHP?>?gallery_continue="+from+'&gallery='+gallery, true);
  4637. xhr.send();
  4638. }
  4639. <?php if($this->LoggedIn){ ?>
  4640. var selected_image = new Array();
  4641. function RemoveFromGallery(){
  4642. form = document.querySelector('#gallery_move_form');
  4643. ops = document.querySelector('#gallery_move_ops');
  4644. sel = document.querySelector('#gallery_move_to');
  4645. ops.value = "REM <?=$_GET['gallery']?>"+" "+selected_image.join(' ');
  4646. form.submit();
  4647. }
  4648. function AddToGallery(){
  4649. form = document.querySelector('#gallery_move_form');
  4650. ops = document.querySelector('#gallery_move_ops');
  4651. sel = document.querySelector('#gallery_move_to');
  4652. ops.value = "ADD "+sel.value+" "+selected_image.join(' ');
  4653. form.submit();
  4654. }
  4655. function ClearSelectedImages(){
  4656. selected_image.splice(0, selected_image.length);
  4657. checks = document.querySelectorAll('._select_hook');
  4658. [].forEach.call(checks, function(c){
  4659. c.classList.remove('p_thumb_selected');
  4660. });
  4661. count = document.querySelector('#gallery_selected_count');
  4662. count.innerHTML="0";
  4663. }
  4664. function ToggleSelectImage(elem, name){
  4665. count = document.querySelector('#gallery_selected_count');
  4666. if(selected_image.indexOf(name) == -1){ selected_image.push(name); elem.classList.add('p_thumb_selected'); }
  4667. else{ selected_image.splice(selected_image.indexOf(name), 1); elem.classList.remove('p_thumb_selected'); }
  4668. count.innerHTML=selected_image.length.toString()
  4669. }
  4670. function ShowGalleryEditMenu(old_name,desc){
  4671. m = document.querySelector('#gallery_edit_menu');
  4672. old = document.querySelector('#gallery_edit_old_name');
  4673. newname = document.querySelector('#gallery_edit_new_name');
  4674. description = document.querySelector('#gallery_edit_description');
  4675. m.style.display='block';
  4676. if(desc!==null){ description.style.display='block';newname.style.display='none';description.value=desc;}
  4677. else{ description.style.display='none';newname.style.display='';}
  4678. if(old_name!=''){ old.value=old_name; newname.value=old.value; }else{ old.value=''; }
  4679. }
  4680. function ShowDeleteMenu(){
  4681. m=document.querySelector('#gallery_delete_menu');
  4682. m.style.display='block';
  4683. }
  4684. <?php } ?>
  4685. </script>
  4686. <?php
  4687. }
  4688. function MakeGalleryLeft(){?>
  4689. <div class='left hidden_m gallery_left' id='div_left'><div><br /></div>
  4690. <h2><?=$this->T('相册')?></h2>
  4691. <div>
  4692. <span class='gray smaller bold'><?=$this->T('精选')?><hr> </span>
  4693. <ul>
  4694. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4695. if(!isset($g['featured']) || !$g['featured'] || !$this->CanShowGallery($g)){ continue; } ?>
  4696. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4697. <li class='<?=$_GET['gallery']==$g['name']?'selected':""?>'>
  4698. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4699. <?php } ?>
  4700. </ul>
  4701. <div class='smaller'><span class='gray'><?=$this->T('其他相册')?><hr></span><ul>
  4702. <a href='?gallery=main' onclick='ShowWaitingBar()'>
  4703. <li class='<?=$_GET['gallery']=='main'?' selected':""?>'>[<?=$this->T('全部图片')?>]</li></a>
  4704. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4705. if((isset($g['featured']) && $g['featured']) || !$this->CanShowGallery($g)){ continue; } ?>
  4706. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4707. <li class='<?=$_GET['gallery']==$g['name']?' selected':""?>'>
  4708. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4709. <?php } ?>
  4710. <?php if($this->LoggedIn){ ?>
  4711. <a href='?gallery=trash' onclick='ShowWaitingBar()'>
  4712. <li class='<?=$_GET['gallery']=='trash'?' selected':""?>'>[<?=$this->T('垃圾桶')?>]</li></a>
  4713. <?php } ?>
  4714. </ul></div>
  4715. <p>&nbsp;</p>
  4716. <script>
  4717. </script>
  4718. </div>
  4719. </div>
  4720. <?php
  4721. }
  4722. function MakeStatistics(){
  4723. $this->ReadPosts(); $this->ReadImages(); $this->ReadArchive();
  4724. $list=[]; $last_date=null; $info=[]; $info['count']=0; $info['edits']=0; $info['length']=0;
  4725. $imlist=[]; $imlast_date=null; $iminfo=[]; $iminfo['count']=0;
  4726. $maxposts=0; $maxlength=0; $maximages=0;
  4727. foreach($this->Posts as &$p){ $is_ref=0;
  4728. $this_date=substr($p['id'],0,8);
  4729. if($last_date!=null && $last_date!=$this_date){
  4730. if($maxposts<$info['count']+$info['edits'])$maxposts=$info['count']+$info['edits'];
  4731. if($maxlength<$info['length'])$maxlength=$info['length'];
  4732. $list[]=$info; $info=[]; $info['count']=0; $info['edits']=0; $info['length']=0;
  4733. }
  4734. $ah = &$this->GetArchiveHandle($p['id']); if(isset($ah)&&isset($ah['list'][0])) $info['edits']+=count($ah['list']);
  4735. $info['count']++; $info['id']=$this_date; if(isset($p['content']))$info['length']+=strlen($p['content']); $last_date=$this_date;
  4736. }
  4737. $last_date=null;
  4738. foreach($this->Images as &$im){ $is_ref=0;
  4739. $this_date=substr($im['name'],0,8);
  4740. if($last_date!=null && $last_date!=$this_date){
  4741. if($maximages<$iminfo['count'])$maximages=$iminfo['count'];
  4742. $imlist[]=$iminfo; $iminfo=[]; $iminfo['count']=0;
  4743. }
  4744. $iminfo['count']++; $iminfo['id']=$this_date; $last_date=$this_date;
  4745. }
  4746. if($info!=[]) $list[]=$info;
  4747. if($iminfo!=[]) $imlist[]=$iminfo;
  4748. if(!isset($list[0])) return;
  4749. $earliest=DateTimeImmutable::createFromFormat('!Ymd',$list[0]['id']); $ey=substr($list[0]['id'],0,4);
  4750. $latest=DateTimeImmutable::createFromFormat('!Ymd',end($list)['id']); $ly=substr(end($list)['id'],0,4);
  4751. $days=$earliest->diff($latest)->days; $lw=2.0; $dw=$days*$lw; $spw=20;
  4752. ?>
  4753. <style>.stastics_posts{direction:ltr;} .stastics_posts line,.stastics_posts circle{stroke:#f8ca9b; stroke-width:2px;}
  4754. .stastics_posts .line_edits{stroke:#f8ca9b40;}
  4755. .stastics_posts .line_year{stroke:#f8ca9b30; stroke-width:2px;} .stastics_posts text{fill:#f8ca9ba0; font: 0.9em serif;}
  4756. </style>
  4757. <div class='settings'><h2><?=$this->T('统计')?></h2><br />
  4758. <div style="overflow:auto;direction:rtl;width:100%;">
  4759. <svg class='stastics_posts' viewBox="-<?=$spw?> -<?=$spw?> <?=$days*$lw+$spw*6?> <?=200+4*$spw?>" height="<?=200+4*$spw?>" width="<?=$days*$lw+$spw*6?>">
  4760. <?php foreach($list as $info){ $itv=DateTimeImmutable::createFromFormat('!Ymd',$info['id'])->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);
  4761. $p1=100.0*(1-$info['count']/$maxposts); $p2=$p1-100.0*$info['edits']/$maxposts;
  4762. $p3=100.0*$info['length']/$maxlength+$spw+100; ?>
  4763. <line x1="<?=$ds?>" x2="<?=$ds?>" y1="100.0" y2="<?=$p1?>"/>
  4764. <?php if($info['edits']>0){ ?><line class='line_edits' x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=$p1?>" y2="<?=$p2?>"/><?php } ?>
  4765. <?php if($info['length']>0){ ?><line class='line_edits' x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=$spw+100?>" y2="<?=$p3?>"/><?php } ?>
  4766. <?php } ?>
  4767. <?php foreach($imlist as $im){ $itv=DateTimeImmutable::createFromFormat('!Ymd',$im['id'])->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);
  4768. $p1=100+$spw+100.0*($im['count']/$maximages); ?>
  4769. <circle cx="<?=$ds?>" cy="<?=$p1?>" r='3'/>
  4770. <?php } ?>
  4771. <?php for($y=$ey;$y<=$ly;$y++){ $itv=DateTimeImmutable::createFromFormat('!Y',$y)->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);?>
  4772. <line x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=220+$spw?>" y2="-<?=$spw?>" class='line_year'/>
  4773. <text x="<?=$ds+4?>" y="-4"><?=$y?></text>
  4774. <text x="<?=$ds+4?>" y="<?=$spw*2+200-4?>"><?=$y?></text>
  4775. <?php for($ym=1;$ym<=12;$ym++){ $st=str_pad($ym,2,'0',STR_PAD_LEFT); $itv2=DateTimeImmutable::createFromFormat('!Ym',$y.$st)->diff($earliest);
  4776. $dds=$lw/2+$lw*$itv2->days*($itv2->invert?1:-1); if($dds<0||$dds>$lw/2+$dw) continue; ?>
  4777. <line x1="<?=$dds?>" x2="<?=$dds?>" y1="<?=100+$spw?>" y2="100" class='line_year'/>
  4778. <text x="<?=$dds+4?>" y="<?=100+$spw-3?>"><?=$ym?></text>
  4779. <?php } } ?>
  4780. <line x1="<?=$lw/2+$dw?>" x2="<?=$days*$lw?>" y1="<?=220+$spw?>" y2="-<?=$spw?>" class='line_year'/>
  4781. <line x1="0" x2="<?=$dw?>" y1="0" y2="0" class='line_year'/>
  4782. <line x1="0" x2="<?=$dw?>" y1="100" y2="100" class='line_year'/>
  4783. <line x1="0" x2="<?=$dw?>" y1="<?=100+$spw?>" y2="<?=100+$spw?>" class='line_year'/>
  4784. <line x1="0" x2="<?=$dw?>" y1="<?=200+$spw?>" y2="<?=200+$spw?>" class='line_year'/>
  4785. <text x="<?=$dw+10?>" y="8"><?=$maxposts?></text>
  4786. <text x="<?=$dw+10?>" y="<?=$spw+8?>"><tspan style='fill:#f8ca9b;'>▪ <?=$this->T('新增')?></tspan></text>
  4787. <text x="<?=$dw+10?>" y="<?=$spw*2+8?>"><tspan style='fill:#f8ca9ba0;'>▪ <?=$this->T('改动')?></tspan></text>
  4788. <text x="<?=$dw+10?>" y="<?=$spw*2+200-4?>"><?=$maxlength?></text>
  4789. <text x="<?=$dw+10?>" y="<?=$spw+200-4?>"><tspan style='fill:#f8ca9b;'><?=$maximages?></tspan></text>
  4790. <text x="<?=$dw+10?>" y="<?=200-4?>"><tspan style='fill:#f8ca9b;'>▪ <?=$this->T('媒体')?></text>
  4791. <text x="<?=$dw+10?>" y="<?=200-4-$spw?>">▪ <?=$this->T('长度')?></tspan></text>
  4792. </svg></div>
  4793. <br /><br />
  4794. </div>
  4795. <?php
  4796. }
  4797. function MakeSettings(){ global $INDEXPHP; ?>
  4798. <div class='settings'>
  4799. <h2><?=$this->T('设置')?></h2>
  4800. <table style='white-space:nowrap;'>
  4801. <?php if($this->LoggedIn){ ?>
  4802. <form action="<?=$INDEXPHP?>?settings=true" method="post" style='display:none;' id='settings_form'></form>
  4803. <colgroup><col style='min-width:5em;'><col style='width:100%;min-width:5em;'></colgroup>
  4804. <thead><tr><td><?=$this->T('选项')?></td><td><?=$this->T('值')?></td></tr></thead>
  4805. <tr><td><?=$this->T('网站标题')?></td>
  4806. <td><input type="text" form="settings_form" id='settings_title' name='settings_title'
  4807. value='<?=$this->Title?>'/></td></tr>
  4808. <tr><td><?=$this->T('短标题')?></td>
  4809. <td><input type="text" form="settings_form" id='settings_short_title' name='settings_short_title'
  4810. value='<?=$this->ShortTitle?>'/></td></tr>
  4811. <tr><td><?=$this->T('显示名称')?></td>
  4812. <td><input type="text" form="settings_form" id='settings_display_name' name='settings_display_name'
  4813. value='<?=$this->DisplayName?>'/></td></tr>
  4814. <tr><td><?=$this->T('电子邮件')?></td>
  4815. <td><input type="text" form="settings_form" id='settings_email' name='settings_email'
  4816. value='<?=$this->EMail?>'/></td></tr>
  4817. <tr><td><?=$this->T('导航栏')?>
  4818. <?=isset($this->SpecialNavigation)?"<a href='?post=".$this->SpecialNavigation."'>→</a>":""?></td>
  4819. <td><input type="text" form="settings_form" id='settings_special_navigation' name='settings_special_navigation'
  4820. value='<?=$this->SpecialNavigation?>'/></td></tr>
  4821. <tr><td><?=$this->T('侧边栏')?>
  4822. <?=isset($this->SpecialSidebar)?"<a href='?post=".$this->SpecialSidebar."'>→</a>":""?></td>
  4823. <td><input type="text" form="settings_form" id='settings_special_sidebar' name='settings_special_sidebar'
  4824. value='<?=$this->SpecialSidebar?>'/></td></tr>
  4825. <tr><td><?=$this->T('脚注')?> 1<?=isset($this->SpecialFooter)?"<a href='?post=".$this->SpecialFooter."'>→</a>":""?></td>
  4826. <td><input type="text" form="settings_form" id='settings_special_footer' name='settings_special_footer'
  4827. value='<?=$this->SpecialFooter?>'/></td></tr>
  4828. <tr><td><?=$this->T('脚注')?> 2<?=isset($this->SpecialFooter2)?"<a href='?post=".$this->SpecialFooter2."'>→</a>":""?></td>
  4829. <td><input type="text" form="settings_form" id='settings_special_footer2' name='settings_special_footer2'
  4830. value='<?=$this->SpecialFooter2?>'/></td></tr>
  4831. <tr><td><?=$this->T('置顶文')?><?=isset($this->SpecialPinned)?"<a href='?post=".$this->SpecialPinned."'>→</a>":""?></td>
  4832. <td><input type="text" form="settings_form" id='settings_special_pinned' name='settings_special_pinned'
  4833. value='<?=$this->SpecialPinned?>'/></td></tr>
  4834. <tr><td><?=$this->T('置顶备忘')?><?=isset($this->SpecialPinnedNotes)?"<a href='?post=".$this->SpecialPinnedNotes."'>→</a>":""?></td>
  4835. <td><input type="text" form="settings_form" id='settings_special_pinned_notes' name='settings_special_pinned_notes'
  4836. value='<?=$this->SpecialPinnedNotes?>'/></td></tr>
  4837. <tr><td><?=$this->T('默认相册')?></td>
  4838. <td><input type="text" form="settings_form" id='settings_default_gallery' name='settings_default_gallery'
  4839. value='<?=$this->DefaultGallery?>'/></td></tr>
  4840. <tr><td><?=$this->T('相册单步')?></td>
  4841. <td><input type="text" form="settings_form" id='settings_gallery_step' name='settings_gallery_step'
  4842. value='<?=$this->GalleryStep?>'/></td></tr>
  4843. <tr><td><?=$this->T('SelfAuth 路径')?></td>
  4844. <td><input type="text" form="settings_form" id='settings_selfauth_path' name='settings_selfauth_path'
  4845. value='<?=$this->SelfAuthPath?>'/></td></tr>
  4846. <tr><td><?=$this->T('启用评论')?></td>
  4847. <td><input type="checkbox" id="settings_enable_comments" name="settings_enable_comments"
  4848. form="settings_form" <?=$this->CommentEnabled?"checked":""?>/></td></tr>
  4849. <tr><td><?=$this->T('启用新闻')?></td>
  4850. <td><input type="checkbox" id="settings_enable_newsletter" name="settings_enable_newsletter"
  4851. form="settings_form" <?=$this->NewsletterEnabled?"checked":""?>/></td></tr>
  4852. <tr><td><?=$this->T('附加操作')?></td><td><a class='gray' href='<?=$INDEXPHP?>?extras=true'><?=$this->T('进入')?></a></td></tr>
  4853. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4854. <tr><td class='smaller gray'><?=$this->T('长毛象')?></td></tr>
  4855. <tr><td><?=$this->T('长毛象实例')?></td>
  4856. <td><input type="text" form="settings_form" id='settings_mastodon_url' name='settings_mastodon_url'
  4857. value='<?=$this->MastodonURL?>'/></td></tr>
  4858. <tr><td><?=$this->T('长毛象令牌')?></td>
  4859. <td><input type="text" form="settings_form" id='settings_mastodon_token' name='settings_mastodon_token'
  4860. value='<?=$this->MastodonToken?>'/></td></tr>
  4861. <tr><td><?=$this->T('偏好语言')?></td>
  4862. <td><input type="text" form="settings_form" id='settings_mastodon_lang' name='settings_mastodon_lang'
  4863. value='<?=$this->MastodonPreferredLang?>'/></td></tr>
  4864. <tr><td><?=$this->T('本站地址')?></td>
  4865. <td><input type="text" form="settings_form" id='settings_host_url' name='settings_host_url'
  4866. value='<?=$this->HostURL?>'/></td></tr>
  4867. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4868. <tr><td class='smaller gray'><?=$this->T('Activity Pub')?></td></tr>
  4869. <tr><td><?=$this->T('用户名')?></td>
  4870. <td><input type="text" form="settings_form" id='settings_apub_id' name='settings_apub_id'
  4871. value='<?=$this->APubID?>'/></td></tr>
  4872. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4873. <tr><td class='smaller gray'><?=$this->T('这里访问')?></td></tr>
  4874. <tr><td><?=$this->T('主机')?></td>
  4875. <td><input type="text" form="settings_form" id='settings_here_host' name='settings_here_host'
  4876. value='<?=$this->HereHost?>'/></td></tr>
  4877. <tr><td><?=$this->T('网站标题')?></td>
  4878. <td><input type="text" form="settings_form" id='settings_here_title' name='settings_here_title'
  4879. value='<?=$this->HereTitle?>'/></td></tr>
  4880. <tr><td><?=$this->T('短标题')?></td>
  4881. <td><input type="text" form="settings_form" id='settings_here_short_title' name='settings_here_short_title'
  4882. value='<?=$this->HereShortTitle?>'/></td></tr>
  4883. <tr><td><?=$this->T('相册')?></td>
  4884. <td><input type="text" form="settings_form" id='settings_here_album' name='settings_here_album'
  4885. value='<?=$this->HereAlbum?>'/></td></tr>
  4886. <tr><td><?=$this->T('导航栏')?>
  4887. <?=isset($this->HereNavigation)?"<a href='?post=".$this->HereNavigation."'>→</a>":""?></td>
  4888. <td><input type="text" form="settings_form" id='settings_here_navigation' name='settings_here_navigation'
  4889. value='<?=$this->HereNavigation?>'/></td></tr>
  4890. <tr><td><?=$this->T('脚注')?><?=isset($this->HereFooter)?"<a href='?post=".$this->HereFooter."'>→</a>":""?></td>
  4891. <td><input type="text" form="settings_form" id='settings_here_footer' name='settings_here_footer'
  4892. value='<?=$this->HereFooter?>'/></td></tr>
  4893. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4894. <tr><td class='smaller gray'><?=$this->T('实验访问')?></td></tr>
  4895. <tr><td><?=$this->T('主机')?></td>
  4896. <td><input type="text" form="settings_form" id='settings_exp_host' name='settings_exp_host'
  4897. value='<?=$this->ExpHost?>'/></td></tr>
  4898. <tr><td><?=$this->T('网站标题')?></td>
  4899. <td><input type="text" form="settings_form" id='settings_exp_title' name='settings_exp_title'
  4900. value='<?=$this->ExpTitle?>'/></td></tr>
  4901. <tr><td><?=$this->T('短标题')?></td>
  4902. <td><input type="text" form="settings_form" id='settings_exp_short_title' name='settings_exp_short_title'
  4903. value='<?=$this->ExpShortTitle?>'/></td></tr>
  4904. <tr><td><?=$this->T('首次提示')?><?=isset($this->ExpCaution)?"<a href='?post=".$this->ExpCaution."'>→</a>":""?></td>
  4905. <td><input type="text" form="settings_form" id='settings_exp_caution' name='settings_exp_caution'
  4906. value='<?=$this->ExpCaution?>'/></td></tr>
  4907. <tr><td><?=$this->T('相册')?></td>
  4908. <td><input type="text" form="settings_form" id='settings_exp_album' name='settings_exp_album'
  4909. value='<?=$this->ExpAlbum?>'/></td></tr>
  4910. <tr><td><?=$this->T('导航栏')?>
  4911. <?=isset($this->ExpNavigation)?"<a href='?post=".$this->ExpNavigation."'>→</a>":""?></td>
  4912. <td><input type="text" form="settings_form" id='settings_exp_navigation' name='settings_exp_navigation'
  4913. value='<?=$this->ExpNavigation?>'/></td></tr>
  4914. <tr><td><?=$this->T('脚注')?><?=isset($this->ExpFooter)?"<a href='?post=".$this->ExpFooter."'>→</a>":""?></td>
  4915. <td><input type="text" form="settings_form" id='settings_exp_footer' name='settings_exp_footer'
  4916. value='<?=$this->ExpFooter?>'/></td></tr>
  4917. <tr><td><?=$this->T('允许选择语言')?>
  4918. <td><input type="checkbox" id="settings_allow_language" name="settings_allow_language"
  4919. form="settings_form" <?=$this->AllowLanguageChoices?"checked":""?>/></td></tr>
  4920. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4921. <tr><td class='smaller gray'><?=$this->T('管理员')?></td><td class='smaller'>
  4922. <a href='<?=$INDEXPHP?>?logout=true'><?=$this->T('登出')?></a></td></tr>
  4923. <tr><td><?=$this->T('帐号')?></td>
  4924. <td><input type="text" form="settings_form" id='settings_id' name='settings_id'
  4925. value='<?=$this->Admin?>'/></td></tr>
  4926. <tr><td><?=$this->T('新密码')?></td>
  4927. <td><input type="password" form="settings_form"
  4928. id='settings_new_password' name='settings_new_password' /></td></tr>
  4929. <tr><td><?=$this->T('再次输入')?></td>
  4930. <td><input type="password" form="settings_form"
  4931. id='settings_new_password_redo' name='settings_new_password_redo' /></td></tr>
  4932. <tr><td><?=$this->T('旧密码')?></td>
  4933. <td><input type="password" form="settings_form" id='settings_old_password' name='settings_old_password' /></td></tr>
  4934. <?php }else{ ?>
  4935. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='login_form'></form>
  4936. <colgroup><col style='min-width:3em;'><col style='width:100%;min-width:5em;'></colgroup>
  4937. <tr><td class='smaller gray'><?=$this->T('请登录')?></td></tr>
  4938. <tr><td><?=$this->T('帐号')?></td>
  4939. <td><input type="text" form="login_form" id='login_id' name='login_id' /></td></tr>
  4940. <tr><td><?=$this->T('密码')?></td>
  4941. <td><input type="password" form="login_form" id='login_password' name='login_password' /></td></tr>
  4942. <?php } ?>
  4943. </table>
  4944. <?php if($this->LoggedIn){ ?>
  4945. <input class='button' form="settings_form" type="submit" name='settings_button' value='<?=$this->T('保存设置')?>' />
  4946. <?php }else{ ?>
  4947. <input class='button' form="login_form" type="submit" name='login_button' value='<?=$this->T('登录')?>' />
  4948. <?php } ?>
  4949. </div>
  4950. <?php
  4951. }
  4952. function MakeExtraOperations(){ global $INDEXPHP; ?>
  4953. <div class='settings' style='overflow:auto;'>
  4954. <h2><?=$this->T('附加操作')?></h2>
  4955. <a href='<?=$INDEXPHP?>?&settings=true'><?=$this->T('返回一般设置')?></a>
  4956. <p>&nbsp;</p>
  4957. <h3><?=$this->T('自动重定向')?></h3>
  4958. <span class='smaller gray'>
  4959. <?=$this->T('P为帖子跳转,匹配REQUEST_URI跳到目标文章;S为站点跳转,可以重定向来源域名,例子:')?>
  4960. <br /><pre>P discount:20001001010101;<br />S old_domain:www.new_domain.com:20001001010101;</pre></span>
  4961. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form2'></form>
  4962. <textarea id="settings_redirect" name="settings_redirect" rows="4" class='full_box' wrap="off"
  4963. form='settings_form2'><?=$this->DisplayRedirectConfig()?></textarea>
  4964. <input class='button' form="settings_form2" type="submit" name='settings_save_redirect'
  4965. value='<?=$this->T('保存重定向设置')?>' />
  4966. <p>&nbsp;</p>
  4967. <h3><?=$this->T('自定义翻译')?></h3>
  4968. <span class='smaller gray'>
  4969. <?=$this->T('填写格式:')?>
  4970. <br /><pre>- 语言 | Language</pre></span>
  4971. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form3'></form>
  4972. <textarea id="settings_translation" name="settings_translation" rows="4" class='full_box' wrap="off"
  4973. form='settings_form3'><?=$this->CustomTranslationContent?></textarea>
  4974. <input class='button' form="settings_form3" type="submit" name='settings_save_translation'
  4975. value='<?=$this->T('保存翻译')?>' />
  4976. <?php if($this->NewsletterEnabled){
  4977. $subs=file_get_contents("all_subscribers.php"); ?>
  4978. <br /><br /><h3><?=$this->T('邮件订阅者')?></h3>
  4979. <textarea rows="4" class='full_box' wrap="off"><?=$subs?substr($subs,5):"error"?></textarea>
  4980. <?php } ?>
  4981. <br />
  4982. <p class='smaller gray'><?=$this->T('ActivityPub 测试:')?></p>
  4983. <ul>
  4984. <li><a href='?TestAPubDeliver=1'><?=$this->T('测试发送')?></a></li></ui>
  4985. </ui>
  4986. <br />
  4987. <p class='smaller gray'><?=$this->T('当心!下列操作将立即执行:')?></p>
  4988. <ul>
  4989. <li><label for='opbtn0' class='ref_count'><?=$this->T('重新写入默认CSS')?></label><input type="checkbox" class='lpctrl' id='opbtn0' checked='checked'/>
  4990. <a href='?rewrite_styles=true'>→</a></li>
  4991. <li><label for='opbtn1' class='ref_count'><?=$this->T('重新生成图片缩略图')?></label><input type="checkbox" class='lpctrl' id='opbtn1' checked='checked'/>
  4992. <a href='?regenerate_thumbnails=true'>→</a></li>
  4993. <li><label for='opbtn2' class='ref_count'><?=$this->T('清理未压缩的图像')?></label><input type="checkbox" class='lpctrl' id='opbtn2' checked='checked'/>
  4994. <a href='?cleanup_image_compression=true'>→</a></li>
  4995. <li><label for='opbtn3' class='ref_count'><?=$this->T('删除所有登录')?></label><input type="checkbox" class='lpctrl' id='opbtn3' checked='checked'/>
  4996. <a href='?clear_all_logins=true'>→</a></li>
  4997. </ui>
  4998. <br /><br /><br /><a href='?&settings=true'><?=$this->T('返回一般设置')?></a><br />&nbsp;
  4999. </div>
  5000. <?php
  5001. }
  5002. function MakeMainBegin(){?>
  5003. <div class='main' <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  5004. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"<?php } ?>>
  5005. <?php
  5006. }
  5007. function MakeMainEnd(){?>
  5008. </div>
  5009. <?php
  5010. }
  5011. function MakeExpFooter(){
  5012. $exptitle = isset($this->HereDisplayTitle)?('"'.trim($this->T($this->ChoosePartsByLanguage($this->HereDisplayTitle))).'"'):NULL;
  5013. if(!isset($exptitle)) $exptitle=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle);?>
  5014. <div class='small_footer exp_h_f exp_f'><div>
  5015. <?php if($this->InExperimentalMode){ ?>
  5016. <b><?=$exptitle?></b>
  5017. <?php }else{ ?>
  5018. <b><?=$exptitle?></b> ©<?=$this->T($this->DisplayName)?>
  5019. <?php }?>
  5020. <?=isset($this->HereMainImage)?("<a class='invert_a' href='?here=images/".$this->HereMainImage['name']."'>".$this->T("看全图")."</a>"):""; ?>
  5021. <div class='wayback_link gray clean_a invert_a hidden_on_print'><br class="hidden_on_desktop" />
  5022. <?php if($this->InExperimentalMode && isset($this->ExpFooter) && ($p = &$this->GetPost($this->ExpFooter,true))!=NULL){
  5023. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  5024. }else if($this->InHereMode && isset($this->HereFooter) && ($p = &$this->GetPost($this->HereFooter,true))!=NULL){
  5025. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  5026. }?></div>
  5027. </div>
  5028. </div>
  5029. </div><!-- page -->
  5030. </body>
  5031. </html>
  5032. <script>
  5033. if(trans = document.getElementById('translate_button')){
  5034. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  5035. }
  5036. </script>
  5037. <?php
  5038. }
  5039. function MakeImageOverlay($side_info=null,$static_image=null,$static_video=null){
  5040. $static=isset($side_info); ?>
  5041. <div id='big_image_overlay' <?=$static?"":"style='display:none'";?>>
  5042. <div class='big_image_box clean_a' onclick='HideBigImage(1)'>
  5043. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'><?=$this->T('请稍候')?></div>
  5044. <?php if(!$static_video){ ?>
  5045. <img id='big_image' onload="HideWaitingBar();" <?=isset($static_image)?("src='".$static_image."'"):""?>/><?php } ?>
  5046. <?php if(!$static_image){ ?>
  5047. <video id='big_video' onloadstart="HideWaitingBar();" controls><source id='big_video_src' type='video/mp4'
  5048. <?=isset($static_video)?("src='".$static_video."'"):""?>></video><?php } ?>
  5049. </div>
  5050. <div class='big_side_box' onclick='HideBigImage(1);'>
  5051. <?php if(!$static){ ?>
  5052. <div class='big_image_box clean_a image_nav' onclick='HideBigImage(1)'>
  5053. <div ><a id='prev_image' class='image_nav_prev img_btn_hidden' onclick="event.stopPropagation();">
  5054. <div class='lr_buttons'>←</div></a></div>
  5055. <div ><a id='next_image' class='image_nav_next img_btn_hidden' onclick="event.stopPropagation();">
  5056. <div class='lr_buttons'>→</div></a></div>
  5057. <div id='here_buttons'></div>
  5058. </div><?php } ?>
  5059. <div class='side_box_mobile_inner'>
  5060. <?php if(!$static){ ?>
  5061. <div class='inquiry_buttons img_btn_hidden' id='inquiry_buttons' onclick="event.stopPropagation();">
  5062. <span style='display:none;' id='image_purchase' class='clean_a'>
  5063. <b><a id='image_purchase_button' target="_blank">¥<?=$this->T('购买印刷品')?></a></b>
  5064. <br class='hidden_on_desktop block_m' /></span>
  5065. <b><a class='clean_a' id='image_download'><span id='download_processing'>↓</span><?=$this->T('下载')?></a></b>
  5066. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  5067. &nbsp;<a class='clean_a' id='image_inquiry'>
  5068. <b>@</b><?=$this->T('咨询')?></a>
  5069. <?php } ?><hr class='hidden_on_desktop block_m' />
  5070. </div>
  5071. <div id='big_image_share' class='clean_a' onclick="event.stopPropagation();">
  5072. <li class='wayback_close'><a onclick='HideBigImage(1);'><?=$this->T('关闭')?> ×</a></li>
  5073. <li><a id='big_share_copy'>⎘ <?=$this->T('复制链接')?></a></li>
  5074. <hr />
  5075. </div><?php } //static ?>
  5076. <div id='big_image_info' onclick="event.stopPropagation();"><?=$static?$side_info:""?></div>
  5077. <?php if($this->LoggedIn && !$static){ ?><div id='big_image_ops' onclick="event.stopPropagation();">
  5078. <br /><?=$this->T('印刷品链接')?>
  5079. <form action="" method="post" style='display:none;' id='image_ops_form'></form>
  5080. <input type='text' id='image_ops_product_link' name='image_ops_product_link' form="image_ops_form" >
  5081. <?=$this->T('重命名')?>
  5082. <input type='text' id='image_edit_new_name' name='image_edit_new_name' form="image_ops_form" >
  5083. <?=$this->T('主图')?>
  5084. <input type='text' id='image_parent' name='image_parent' form="image_ops_form" >
  5085. <?=$this->T('对齐')?> <select id='image_align' name='image_align' form="image_ops_form">
  5086. <option value='top'><?=$this->T('顶部')?></option>
  5087. <option value='middle'><?=$this->T('中间')?></option>
  5088. <option value='bottom'><?=$this->T('底部')?></option></select><br />
  5089. <input class='button' form="image_ops_form" type="submit" name='image_button' value=<?=$this->T('保存')?> />
  5090. <br /><br /><?=$this->T('替换图像')?>
  5091. <form action="" method="post" style='display:none;' id='image_edit_form' enctype="multipart/form-data"></form>
  5092. <input type="file" form='image_edit_form'
  5093. id='big_image_upload' name='upload_file_name' accept="image/x-png,image/png,image/gif,image/jpeg"/><br />
  5094. <input class='button' form="image_edit_form" type="submit" name='image_replace_button'
  5095. value=<?=$this->T('执行')?> />
  5096. </div><?php } ?>
  5097. </div>
  5098. </div>
  5099. </div>
  5100. <?php }
  5101. function MakePageEnd(){?>
  5102. </div><!-- page -->
  5103. </body>
  5104. </html>
  5105. <?php }
  5106. function MakeFooter(&$p){ global $INDEXPHP;
  5107. $is_slides=(isset($p['slides']) || (isset($p['tid'])&&isset($p['tid']['slides']))); $no_title=isset($p['tid']['first']['no_title']);?>
  5108. <div class='small_footer'><div>
  5109. <hr />
  5110. <?php if(isset($p['tid']['footer'])){ ?><div class='show_on_print'><?=$p['tid']['footer'];?></div><?php } ?>
  5111. <b<?=$no_title?" class='hidden_on_print'":"";?>><?=$this->T($this->Title)?></b>
  5112. <span onclick='event.stopPropagation()'<?=$no_title?" class='hidden_on_print'":"";?>
  5113. ondblclick='javascript:window.location.href="<?=$INDEXPHP?>?settings=true"'>©</span><?=$this->T($this->DisplayName)?>
  5114. <div class='smaller show_on_print'><?=$_SERVER['SERVER_NAME']?><br /><?=$this->EMail?></div>
  5115. </div></div>
  5116. <div class='footer'>
  5117. <div style='white-space:nowrap;'>
  5118. <div class='footer_additional'>
  5119. <?php if(isset($this->SpecialFooter) && ($p = &$this->GetPost($this->SpecialFooter))!=NULL){
  5120. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  5121. } ?>
  5122. </div>
  5123. <div class='footer_additional'>
  5124. <?php if(isset($this->SpecialFooter2) && ($p = &$this->GetPost($this->SpecialFooter2))!=NULL){
  5125. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  5126. } ?>
  5127. </div>
  5128. </div>
  5129. </div>
  5130. <p>&nbsp;<p>
  5131. <div id='dropping_background' style='display:none;' onclick='this.style.display="none";'
  5132. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);">
  5133. <h2 style='width:100%;'><?=$this->T('上传到这里')?></h2>
  5134. </div>
  5135. <?php $this->MakeImageOverlay(); $this->MakePageEnd(); ?>
  5136. <script>
  5137. <?php if($is_slides){ ?>SlidesStart(null);<?php } ?>
  5138. <?=$this->ExtraScripts?>
  5139. if(back = document.getElementById('button_back')){
  5140. if(document.referrer.indexOf(location.protocol + "//" + location.host) == 0){
  5141. back.href='javascript:history.back()';
  5142. }else{
  5143. back.href='<?=$INDEXPHP?>';
  5144. }
  5145. }
  5146. function copy_text(t) {
  5147. ta = document.createElement('textarea'); document.body.appendChild(ta); ta.value = t; ta.select();
  5148. document.execCommand("copy"); document.body.removeChild(ta);
  5149. }
  5150. if(trans = document.getElementById('translate_button')){
  5151. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  5152. }
  5153. function ClickPost(p,e,pushstate){if(e)e.preventDefault();
  5154. id=p.dataset.postId; if(!id)return; list=p.parentNode;active=list.getElementsByClassName('active_post');
  5155. if(active&&active[0]&&active[0]!=p){
  5156. if(pushstate){window.history.pushState('?post='+id,null,'?post='+id);}
  5157. active[0].classList.remove('active_post'); p.classList.add('active_post');
  5158. }
  5159. if(!active[0]){ window.location.href="?post="+id; }
  5160. }function InitLabel(){
  5161. lb=document.querySelector('#mtitle'); lb.removeAttribute('for'); lb.onclick=function()
  5162. {c=document.querySelector('#titlectrl');if(c.checked)c.checked=false;else c.checked=true;}
  5163. lb=document.querySelectorAll('.bkg_section label');if(!lb||!lb[0])return;
  5164. for(i=0;i<lb.length;i++){ lb[i].removeAttribute('for');lb[i].onclick=function()
  5165. {c=this.parentNode.querySelector('.lpctrl');if(!c)return;if(c.checked)c.checked=false;else c.checked=true;} }
  5166. }InitLabel();
  5167. <?php if($this->LoggedIn){ ?>
  5168. var Scenter = document.querySelector('.center');
  5169. var Sposts = Scenter?Scenter.querySelectorAll('.post'):null;
  5170. <?php if(isset($this->MastodonToken)){ ?>
  5171. function MarkPostDoneMastodon(id,mastodon_url){
  5172. for(var i=0;i<Sposts.length;i++){
  5173. if(Sposts[i].dataset.postId==id){ Sposts[i].dataset.mastodon_url= mastodon_url; break;} }
  5174. }
  5175. <?php } ?>
  5176. <?php if($this->PageType=='post' && !isset($this->WayBack)) { ?>
  5177. var Smerge_post_dialog = Scenter.querySelector('#merge_post_dialog');
  5178. var Smerge_post = Scenter.querySelector('#merge_post');
  5179. var Smerge_post_count = Smerge_post_dialog.querySelector('#merge_post_count');
  5180. var Smerge_post_btn = Scenter.querySelector('#merge_post_btn');
  5181. var Smerge_cancel = Scenter.querySelector('#merge_cancel');
  5182. var Smerge_select = Scenter.querySelector('#merge_select');
  5183. var Smerge_thread_dialog = Scenter.querySelector('#merge_thread_dialog');
  5184. var Smerge_thread = Scenter.querySelector('#merge_thread');
  5185. var Smerge_thread_target = Scenter.querySelector('#merge_thread_target');
  5186. var Smerge_thread_btn = Scenter.querySelector('#merge_thread_btn');
  5187. var select_mode = false; var merge_mode = false; var selected_posts = null;
  5188. function TogglePostSelectMode(force_on=false,force_off=false){
  5189. Scenter.classList.add('post_selecting');
  5190. if((!select_mode || force_on) && !force_off){ ToggleThreadMerge(false,true); Scenter.classList.add('post_selecting');
  5191. Smerge_post_dialog.style.display="block";Smerge_post_btn.classList.add('text_highlight');
  5192. Smerge_cancel.innerText='<?=$this->T("取消")?>'; select_mode = 1;}
  5193. else{ select_mode = 0; Scenter.classList.remove('post_selecting');
  5194. Smerge_post_dialog.style.display="none";Smerge_post_btn.classList.remove('text_highlight');
  5195. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  5196. for(var i=0;i<Sposts.length;i++){ Sposts[i].classList.remove('post_selected');
  5197. Sposts[i].onclick=select_mode?function(){TogglePostSelect(this);}:null; }
  5198. Smerge_post_count.innerText="0";
  5199. Smerge_post.href="#";
  5200. }
  5201. function TogglePostSelect(elem){
  5202. if(elem.classList.contains('post_selected')){ elem.classList.remove('post_selected'); }
  5203. else{ elem.classList.add('post_selected'); }
  5204. selected_posts = new Array();
  5205. for(var i=0;i<Sposts.length;i++){ if(Sposts[i].classList.contains('post_selected')){
  5206. selected_posts.push(Sposts[i].dataset.postId); } }
  5207. Smerge_post.href="?merge_posts="+selected_posts.join(" ");
  5208. Smerge_post_count.innerText=selected_posts.length;
  5209. }
  5210. function ThreadMergeInput(elem){
  5211. if(elem.value.match(/[0-9]{14}/)) { Smerge_thread.href="?merge_threads=<?=$this->ActualPostID?> "+elem.value; }
  5212. else{ Smerge_thread.href="#"; }
  5213. }
  5214. function ToggleThreadMerge(force_on=false,force_off=false){
  5215. if((!merge_mode || force_on) && !force_off){ TogglePostSelectMode(false,true);
  5216. Smerge_thread_dialog.style.display="block";Smerge_thread_btn.classList.add('text_highlight');
  5217. Smerge_cancel.innerText='<?=$this->T("取消")?>'; merge_mode = 1;}
  5218. else{ merge_mode = 0;
  5219. Smerge_thread_dialog.style.display="none";Smerge_thread_btn.classList.remove('text_highlight');
  5220. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  5221. Smerge_thread.href="#";
  5222. Smerge_thread_target.value='';
  5223. }
  5224. <?php } ?>
  5225. function ShowSideUploader(){
  5226. ShowRightSide(true,null);
  5227. put = document.querySelector("#_uploader");
  5228. put.style.display='block';
  5229. RefreshSideGallery();
  5230. }
  5231. dmark = document.querySelector("#mark_details");
  5232. drename = document.querySelector("#rename_details");
  5233. dmastodon = document.querySelector("#mastodon_details");
  5234. drename_form = document.querySelector("#post_rename_form");
  5235. drename_input = document.querySelector("#post_rename_name");
  5236. var rp = document.querySelector('#post_reply_to');
  5237. var _reply_to = rp?rp.defaultValue:"";
  5238. function RestoreReply(){
  5239. if(rp){
  5240. rp.defaultValue = _reply_to;
  5241. }
  5242. document.querySelector('#post_reply_restore').style.display='none';
  5243. ht = document.querySelector('#post_hint_text');
  5244. if (_reply_to!=""){
  5245. ht.style.display='block';
  5246. ht.innerHTML="<?=$this->T('继续补充该话题:')?>";
  5247. }else{
  5248. ht.style.display='none';
  5249. }
  5250. document.querySelector('#post_edit_target').value="";
  5251. ch = document.querySelector('#post_hint_modify');
  5252. ch.style.display='none';
  5253. }
  5254. function MakeRefer(id){
  5255. t = document.querySelector('#post_content')
  5256. t.focus();
  5257. v = t.value;
  5258. t.value = v.slice(0, t.selectionStart) + "[<?=$this->T('引用文章')?>]("+id.toString()+")" + v.slice(t.selectionEnd);
  5259. la_auto_grow(t);
  5260. if(rp){
  5261. rp.defaultValue = "";
  5262. ht = document.querySelector('#post_hint_text');
  5263. ht.innerHTML = "<?=$this->T('引用并发送新话题:')?>"; ht.style.display='block';
  5264. document.querySelector('#post_reply_restore').style.display='inline';
  5265. rs = document.querySelector('#post_reply_restore');
  5266. rs.style.display='inline'; rs.innerHTML="<?=$this->T('切换为回复')?>";
  5267. document.getElementById('post_menu').style.display='none';
  5268. ch = document.querySelector('#post_hint_modify');
  5269. ch.style.display='none';
  5270. }
  5271. }
  5272. function CopyRefer(id){
  5273. copy_text(id.toString());
  5274. menu.querySelector('#menu_refer_copy').innerHTML="<?=$this->T('已复制')?>";
  5275. }
  5276. function MakeEdit(id){
  5277. ed = document.getElementById('menu_edit');
  5278. ed.innerHTML="<?=$this->T('稍等')?>";
  5279. ed.href="#";
  5280. var xhr = new XMLHttpRequest();
  5281. xhr.onreadystatechange = function() {
  5282. if (this.readyState == 4 && this.status == 200) {
  5283. ed.innerHTML='——';
  5284. ch = document.querySelector('#post_hint_modify');
  5285. ch.style.display='block';
  5286. ht = document.querySelector('#post_hint_text');
  5287. ht.innerHTML = "<?=$this->T('修改帖子:')?>";
  5288. rs = document.querySelector('#post_reply_restore');
  5289. rs.style.display='inline'; rs.innerHTML="<?=$this->T('取消')?>";
  5290. t = document.querySelector('#post_content');
  5291. t.value=xhr.responseText.trim();
  5292. t.focus();
  5293. la_auto_grow(t);
  5294. document.querySelector('#post_edit_target').value=id;
  5295. document.getElementById('post_menu').style.display='none';
  5296. }
  5297. };
  5298. xhr.open("GET", "<?=$INDEXPHP?>?post="+id.toString()+'&post_original=true', true);
  5299. xhr.send();
  5300. }
  5301. function MarkDelete(id){
  5302. p = document.querySelector('[data-post-id="'+id+'"]');
  5303. op = p.dataset.markDelete?"false":"true";
  5304. window.location.href=
  5305. "<?=$INDEXPHP?>?<?=$this->GetRedirect()?>&mark_delete="+op+'&target='+id.toString();
  5306. }
  5307. function SetMark(mark){
  5308. menu = document.getElementById('post_menu');
  5309. window.location.href=
  5310. "<?=$INDEXPHP?>?<?=$this->GetRedirect()?>&target="+
  5311. menu.parentNode.dataset.postId+"&set_mark="+mark;
  5312. }
  5313. function ToggleMarkDetails(){
  5314. dmark.style.display=(dmark.style.display=='block')?'none':'block';
  5315. drename.style.display=dmastodon.style.display='none';
  5316. }
  5317. function ToggleRenameDetails(){
  5318. drename.style.display=(drename.style.display=='block')?'none':'block';
  5319. dmark.style.display=dmastodon.style.display='none';
  5320. }
  5321. function ToggleMastodonDetails(){
  5322. dmastodon.style.display=(dmastodon.style.display=='block')?'none':'block';
  5323. dmark.style.display=drename.style.display='none';
  5324. }
  5325. <?php } if(isset($_GET['post'])){ ?> ScrollToPost("<?=$_GET['post']?>"); <?php } ?>
  5326. function ShowPostMenu(post){
  5327. menu = document.getElementById('post_menu');
  5328. menu.style.display='block';
  5329. menu.parentNode.removeChild(menu);
  5330. post.appendChild(menu);
  5331. menu.style.display='block';
  5332. id = post.dataset.postId
  5333. menu.querySelector('#_time_hook').innerHTML = ''+id.substring(2,4)+'/'+id.substring(4,6)+'/'+id.substring(6,8)+
  5334. ' '+id.substring(8,10)+':'+id.substring(10,12);
  5335. window.onClick="HidePopMenu()";
  5336. menu.onClick=(function(event){
  5337. event.stopPropagation();
  5338. });
  5339. hs = menu.querySelector('#menu_history');
  5340. hs.href='?post='+id+'&history=1';
  5341. <?php if($this->LoggedIn && !isset($this->WayBack)){ ?>
  5342. <?php if($this->PageType!='search'){?>
  5343. menu.querySelector('#menu_refer').href='javascript:MakeRefer(id)';
  5344. ed = menu.querySelector('#menu_edit');ed.href='javascript:MakeEdit(id)'; ed.innerHTML="<?=$this->T('修改')?>";
  5345. <?php } ?>
  5346. ref = menu.querySelector('#menu_refer_copy')
  5347. ref.innerHTML='<?=$this->T("复制编号")?>';
  5348. ref.href='javascript:CopyRefer(id)';
  5349. d = menu.querySelector('#menu_delete');
  5350. d.href='javascript:MarkDelete(\"'+id+'\")';
  5351. p = document.querySelector('[data-post-id="'+id+'"]');
  5352. d.innerHTML = p.dataset.markDelete?"<?=$this->T('恢复')?>":"<?=$this->T('删除')?>";
  5353. menu.querySelector('#mark_details').dataset.id=id;
  5354. drename_input.value=id;
  5355. drename_form.action="<?=$this->GetRedirect()?>"+"&rename_post="+id;
  5356. <?php if(isset($this->MastodonToken)){ ?>
  5357. dmastodon_form = document.querySelector("#post_mastodon_form");
  5358. dmastodon_form.action='?mastodon_post='+id;
  5359. function MastodonSend(id){
  5360. mastodon_send.innerHTML="<?=$this->T('稍等')?>";
  5361. var xhr = new XMLHttpRequest();
  5362. function wrapidxhr(_id) { return function() {
  5363. if (this.readyState == 4 && this.status == 200) {
  5364. var response = xhr.responseText;
  5365. let content="";
  5366. if(res = response.match(/SUCCESS (\S+)/u)){
  5367. content="<?=$this->T('成功发送到长毛象')?>";
  5368. }else{content="<b><?=$this->T('出现问题')?></b><br /><span class='smaller'>"+response+"</span>";}
  5369. mastodon_send.innerHTML=content; mastodon_send.href=res[1];
  5370. MarkPostDoneMastodon(_id, res[1]);
  5371. } }
  5372. };
  5373. xhr.onreadystatechange = wrapidxhr(id);
  5374. xhr.open("GET", "<?=$INDEXPHP?>?mastodon_send_post="+id, true); xhr.send();
  5375. }
  5376. menu_mastodon = menu.querySelector("#menu_mastodon");
  5377. mastodon_send = menu.querySelector("#menu_mastodon_send");
  5378. mastodon_view = menu.querySelector("#menu_mastodon_view");
  5379. mastodon_url = menu.querySelector("#post_mastodon_url");
  5380. if(p.dataset.mastodon_url){mastodon_view.style.display='inline';mastodon_view.href=p.dataset.mastodon_url;
  5381. mastodon_send.innerHTML='<?=$this->T("重新发送")?>'; mastodon_url.value=p.dataset.mastodon_url; }
  5382. else{mastodon_view.style.display='none';mastodon_view.href=""; mastodon_send.innerHTML="<?=$this->T('发送')?>";
  5383. mastodon_url.value="";}
  5384. mastodon_send.onclick=function(){
  5385. this.onclick=function(){};
  5386. MastodonSend(id); };
  5387. <?php } } ?>
  5388. title = document.title;
  5389. copy = document.getElementById('share_copy');
  5390. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  5391. copy.addEventListener("click", function(){
  5392. url = window.location
  5393. path = location.pathname
  5394. copy_text(url.protocol+"//"+url.host+path+"?post="+id);
  5395. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  5396. });
  5397. }
  5398. function HidePopMenu(){
  5399. var menus = document.querySelectorAll('.pop_menu');
  5400. [].forEach.call(menus, function(m){m.style.display='none';});
  5401. }
  5402. var posts = document.querySelectorAll('.main>.center>tbody>.post'); if(!posts || !posts[0]) posts = document.querySelectorAll('.center_slides .post');
  5403. [].forEach.call(posts, function(p){
  5404. if(s=p.querySelector('._menu_hook')) s.addEventListener("click", function() {
  5405. ShowPostMenu(this.parentNode.parentNode);
  5406. if(document.querySelector('.clickable_section')!=null) ClickPost(this.parentNode.parentNode,null,true)
  5407. });
  5408. p.addEventListener("dblclick", function(){ ClickPost(this,null,true); lp=this.querySelector('.lpctrl'); if(lp){ if(lp.checked)lp.checked=false;else lp.checked=true; }});
  5409. });
  5410. //var post_clickables = document.querySelectorAll('.center .post a');
  5411. //[].forEach.call(post_clickables, function(p){
  5412. // p.addEventListener("click", function(event){
  5413. // event.stopPropagation();
  5414. // });
  5415. //});
  5416. function FindImage(imgsrc){
  5417. for(var i=0;i<document.images_filtered.length;i++){
  5418. if (document.images_filtered[i].dataset.imgsrc==imgsrc) return document.images_filtered[i]
  5419. }
  5420. return null
  5421. }
  5422. var dottime1;
  5423. var dottime2;
  5424. function ToDataURL(url) {
  5425. return fetch(url).then((response) => {return response.blob();}).then(blob => {
  5426. clearTimeout(dottime1);clearTimeout(dottime2);
  5427. ps = document.querySelector('#download_processing');
  5428. ps.innerHTML='↓';ps.style.opacity='';
  5429. return URL.createObjectURL(blob);});
  5430. }
  5431. async function DownloadAsImage(url,name) {
  5432. const a = document.createElement("a"); a.href = await ToDataURL(url); a.download = name;
  5433. document.body.appendChild(a); a.click(); document.body.removeChild(a);
  5434. }
  5435. function basename(url){return url.split(/[\\/]/).pop();}
  5436. pushed=0;
  5437. function ShowBigImage(imgsrc,do_push){
  5438. ShowWaitingBar();
  5439. share = document.querySelector('#big_image_share');
  5440. img = document.querySelector('#big_image');
  5441. vid = document.querySelector('#big_video');
  5442. vidsrc = document.querySelector('#big_video_src');
  5443. down = document.querySelector('#image_download');
  5444. img.src = ""; vidsrc.src="";
  5445. if(imgsrc.match(/\.mp4$/)){
  5446. vidsrc.src = src = "images/"+imgsrc; img.style.display='none'; vid.load();vid.style.display='block';
  5447. }else{
  5448. img.src = src = "images/"+imgsrc; vid.style.display='none';img.style.display='block';
  5449. }
  5450. down.href="images/"+imgsrc;
  5451. var downname='<?=$this->T($this->Title);?>_<?=$this->T($this->DisplayName);?>_<?=$this->GiveSafeEMail()?>_'+
  5452. basename(down.href);
  5453. img.alt = downname; down.download=downname;
  5454. var use_href = "images/"+imgsrc;
  5455. down.onclick=function(event){event.stopPropagation();event.preventDefault();
  5456. ps = this.querySelector('#download_processing');ps.innerText='…';
  5457. var dotwait = function(ps){ var self = this;
  5458. dottime1 = setTimeout(function(ps){
  5459. ps.style.opacity='0'; dottime2 = setTimeout(function(ps){ps.style.opacity='1'; dotwait(ps);},300,ps); },300,ps) }
  5460. dotwait(this.querySelector('#download_processing'));
  5461. DownloadAsImage(use_href,downname);};
  5462. if(do_push){PushGalleryHistory(src)}
  5463. page_url = encodeURIComponent(window.location.href);
  5464. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  5465. inqb = document.querySelector('#image_inquiry');
  5466. inqb.href="mailto:<?=$this->T($this->DisplayName);?>\<<?=$this->EMail?>\>?subject=<?=$this->T('网站图片咨询');?>&body="+
  5467. encodeURIComponent("<?=$this->T('你好!我对你网站上的这张图片感兴趣:')?>"+'\n\n')+
  5468. (page_url)+encodeURIComponent('\n\n');
  5469. <?php } ?>
  5470. this_image = FindImage(imgsrc);
  5471. if(this_image&&this_image.dataset.prevsrc){
  5472. new_image = FindImage(this_image.dataset.prevsrc);
  5473. new_prev = new_image?new_image.dataset.prevsrc:null;
  5474. im = document.querySelector('#prev_image');
  5475. if(new_prev) {im.href='javascript:ShowBigImage("'+this_image.dataset.prevsrc+'",'+do_push+')';im.style.opacity='';}
  5476. else {im.style.opacity='0';im.removeAttribute("href");}
  5477. }
  5478. if(this_image&&this_image.dataset.nextsrc){
  5479. new_image = FindImage(this_image.dataset.nextsrc);
  5480. new_next = new_image?new_image.dataset.nextsrc:null;
  5481. im = document.querySelector('#next_image');
  5482. if(new_next) {im.href='javascript:ShowBigImage("'+this_image.dataset.nextsrc+'",'+do_push+')';im.style.opacity='';}
  5483. else {im.style.opacity='0';im.removeAttribute("href");}
  5484. }
  5485. purchase = document.querySelector('#image_purchase');
  5486. purchase_btn = document.querySelector('#image_purchase_button');
  5487. <?php if($this->LoggedIn){ ?>
  5488. product_link = document.querySelector('#image_ops_product_link');
  5489. product_form = document.querySelector('#image_ops_form');
  5490. edit_form = document.querySelector('#image_edit_form');
  5491. edit_new_name = document.querySelector('#image_edit_new_name');
  5492. edit_parent = document.querySelector('#image_parent');
  5493. edit_align = document.querySelector('#image_align');
  5494. product_form.action = window.location.href;
  5495. edit_form.action = window.location.href;
  5496. edit_new_name.value = imgsrc.split('.')[0];
  5497. if(this_image){
  5498. if(this_image.dataset.product){ product_link.value = this_image.dataset.product; }else{ product_link.value = ""; }
  5499. if(this_image.dataset.parent){ edit_parent.value = this_image.dataset.parent; }else{ edit_parent.value = ""; }
  5500. if(this_image.dataset.align){ edit_align.value = this_image.dataset.align; }else{ edit_align.value = "middle"; }
  5501. }
  5502. <?php } ?>
  5503. if(this_image&&this_image.dataset.product){
  5504. purchase.style.display='';
  5505. href = this_image.dataset.product;
  5506. if(this_image.dataset.product.match('^[0-9]{14}$')){
  5507. href = '?post='+href;
  5508. }
  5509. purchase_btn.href = href;
  5510. }else{
  5511. purchase.style.display='none';
  5512. purchase_btn.removeAttribute("href");
  5513. }
  5514. DelayHideImgBtn(null);
  5515. title = encodeURIComponent(document.title);
  5516. copy = document.getElementById('big_share_copy');
  5517. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  5518. copy.addEventListener("click", function(){
  5519. copy_text(window.location.href);
  5520. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  5521. });
  5522. o = document.querySelector('#big_image_overlay');
  5523. info = document.querySelector('#big_image_info');info.innerHTML="<?=$this->T('正在查询……')?>";
  5524. here = document.querySelector('#here_buttons');here.innerHTML='';
  5525. o.style.display="block";
  5526. ShowBackdrop(0.8);
  5527. var xhr = new XMLHttpRequest();
  5528. xhr.onreadystatechange = function() {
  5529. if (this.readyState == 4 && this.status == 200) {
  5530. info = document.querySelector('#big_image_info');
  5531. var response = xhr.responseText;
  5532. let content=""
  5533. if(res = response.match(/<ref>(.*)<\/ref>/u)){
  5534. content="<span class='small'><?=$this->T('该图片出现在')?> "+res[1]+" <?=$this->T('个帖子中')?></span>"+content;
  5535. }else{content="<span class='smaller gray'><?=$this->T('该图片未被引用')?></span>"+content;}
  5536. if(res = response.match(/<insert>([\s\S]*)<\/insert>/u)){ content+=res[1]; }
  5537. info.innerHTML=content;
  5538. if(res = response.match(/<here>([\s\S]*)<\/here>/u)){
  5539. here.innerHTML=res[1]; window.here_b=document.getElementsByClassName('here_btn');
  5540. if(window.here_b)for(b=0;b<window.here_b.length;b++) {
  5541. window.here_b[b].addEventListener('mousemove',DontHideImgBtn);
  5542. window.here_b[b].addEventListener('mouseover',DontHideImgBtn);}
  5543. }
  5544. }
  5545. };
  5546. xhr.open("GET", "<?=$INDEXPHP?>?image_info="+imgsrc+"", true);
  5547. xhr.send();
  5548. }
  5549. function HideBigImage(do_push){
  5550. o = document.querySelector('#big_image_overlay');
  5551. img = document.querySelector('#big_image');
  5552. vid = document.querySelector('#big_video');
  5553. vidsrc = document.querySelector('#big_video_src');
  5554. img.src = ""; vidsrc.src="";
  5555. if(o.style.display!='none'){
  5556. o.style.display="none";
  5557. HideBackdrop();
  5558. if(do_push){PushGalleryHistory("");}
  5559. HideWaitingBar();
  5560. }
  5561. }
  5562. var lbtn=document.querySelector('#prev_image'),rbtn=document.querySelector('#next_image');
  5563. var inq=document.querySelector('#inquiry_buttons');
  5564. var overlay=document.querySelector('#big_image_overlay');
  5565. var hide_timeout;
  5566. function DontHideImgBtn(e){ clearTimeout(hide_timeout); e.stopPropagation(); }
  5567. function DelayHideImgBtn(e){
  5568. lbtn.classList.remove('img_btn_hidden'); rbtn.classList.remove('img_btn_hidden');
  5569. inq.classList.remove('img_btn_hidden');
  5570. if(window.here_b)for(b=0;b<window.here_b.length;b++){window.here_b[b].classList.remove('img_btn_hidden');}
  5571. clearTimeout(hide_timeout);
  5572. hide_timeout = setTimeout(function(e1,e2,e3,e4){e1.classList.add('img_btn_hidden');
  5573. e2.classList.add('img_btn_hidden');e3.classList.add('img_btn_hidden');
  5574. if(window.here_b)for(b=0;b<window.here_b.length;b++){
  5575. window.here_b[b].classList.add('img_btn_hidden');}}, 1000, lbtn, rbtn, inq);
  5576. }
  5577. lbtn.addEventListener('mousemove',DontHideImgBtn);lbtn.addEventListener('mouseover',DontHideImgBtn);
  5578. rbtn.addEventListener('mousemove',DontHideImgBtn);rbtn.addEventListener('mouseover',DontHideImgBtn);
  5579. inq.addEventListener('mousemove',DontHideImgBtn);inq.addEventListener('mouseover',DontHideImgBtn);
  5580. overlay.addEventListener('mousemove',DelayHideImgBtn);
  5581. function UpdateImageClickables(){
  5582. var images = document.querySelectorAll('.center img, .center video, .center_wide img, .center_wide video');
  5583. var images_filtered=new Array(); var imgadded = new Array();
  5584. var images_remaining=new Array();
  5585. [].forEach.call(images, function(img){
  5586. if(img.classList.contains("no_pop") || (!(imgsrc = img.dataset.imgsrc))) return;
  5587. if(imgadded.indexOf(imgsrc)>=0) {images_remaining.push(img); return;}
  5588. images_filtered.push(img);imgadded.push(imgsrc);
  5589. });
  5590. for(var i=0; i<images_filtered.length; i++){
  5591. previmg = nextimg = null; img = images_filtered[i];
  5592. if(i>0) previmg=images_filtered[i-1];
  5593. if(i<images_filtered.length-1) nextimg=images_filtered[i+1];
  5594. prevsrc=previmg?previmg.dataset.imgsrc:null; nextsrc=nextimg?nextimg.dataset.imgsrc:null;
  5595. img.dataset.prevsrc = prevsrc; img.dataset.nextsrc = nextsrc;
  5596. function wrap(imgsrc){return function(event){ShowBigImage(imgsrc, 1);}}
  5597. var clone = img.cloneNode(true); img.replaceWith(clone);
  5598. clone.addEventListener("click", wrap(img.dataset.imgsrc));
  5599. }
  5600. for(var i=0; i<images_remaining.length; i++){
  5601. img = images_remaining[i];
  5602. function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
  5603. var clone = img.cloneNode(true); img.replaceWith(clone);
  5604. clone.addEventListener("click", wrap(img.dataset.imgsrc));
  5605. }
  5606. document.images_filtered = images_filtered;
  5607. }
  5608. UpdateImageClickables();
  5609. function PopGalleryHistory(){
  5610. if(pushed){
  5611. pushed = 0;
  5612. try{
  5613. history.back();
  5614. }catch{
  5615. console.log("can't do it.");
  5616. }
  5617. }
  5618. }
  5619. function PushGalleryHistory(src){
  5620. abs_img = window.location.protocol+"//"+window.location.host+'/'+src
  5621. title = "照片"
  5622. extra = "?";
  5623. sp = new URLSearchParams(window.location.search)
  5624. if(sp.has('post')){extra+="post="+sp.get('post')}
  5625. if(sp.has('gallery')){extra+="&gallery="+sp.get('gallery')}
  5626. try{
  5627. window.history.pushState('&pic='+src, 'Title', extra+'&pic='+src);
  5628. }catch{
  5629. console.log("can't do it.");
  5630. }
  5631. pushed = 1;
  5632. }
  5633. document.addEventListener('keydown', function(e){
  5634. large = document.getElementById('big_image_overlay')
  5635. if (large.style.display!='block') return;
  5636. if(e.key=='Escape'||e.key=='Esc'||e.keyCode==27){
  5637. HideBigImage(1);
  5638. }
  5639. }, true);
  5640. window.addEventListener('popstate', (event) => {
  5641. href=window.location.href;
  5642. let sp = new URLSearchParams(href.substring(href.indexOf('?')))
  5643. if(sp.has('pic')){
  5644. src = sp.get('pic')
  5645. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)) ShowBigImage(onlyimg[0], 0);
  5646. else{HideBigImage(0);}
  5647. }else{HideBigImage(0);}
  5648. if(sp.has('post')){
  5649. id=sp.get('post');post=document.querySelector('.post[data-post-id="'+id+'"]');
  5650. if(post){ClickPost(post,null,false);}
  5651. }
  5652. });
  5653. let searchParams = new URLSearchParams(window.location.search)
  5654. if(searchParams.has('pic')){
  5655. src = searchParams.get('pic')
  5656. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)){
  5657. ShowBigImage(onlyimg[0], 1);
  5658. }
  5659. }
  5660. function _dropHandler(event){ if (typeof dropHandler === "function") dropHandler(event); }
  5661. function _dragOverHandler(event){ if (typeof dragOverHandler === "function") dragOverHandler(event); }
  5662. </script>
  5663. </body>
  5664. <?php
  5665. }
  5666. function DoIdentifyExperimental(){
  5667. if(isset($this->ExpHost) && $this->ExpHost && preg_match('/'.preg_quote($this->ExpHost).'/u', $_SERVER['HTTP_HOST'])){
  5668. $this->InExperimentalMode=True; $this->InHereMode=True;
  5669. if(!$this->AllowLanguageChoices){ $this->LanguageAppendix='en'; }
  5670. }
  5671. if(isset($this->HereHost) && $this->HereHost && preg_match('/'.preg_quote($this->HereHost).'/u', $_SERVER['HTTP_HOST'])){
  5672. $this->InHereMode=True;
  5673. }
  5674. //$this->InHereMode=True;
  5675. }
  5676. function DoExperimentalTopLink($p){
  5677. if($this->InHereMode && $p){
  5678. if(isset($p['tid']) && $p['tid']['first']!=$p){
  5679. header('Location: ?post='.$p['tid']['first']['id']); exit();
  5680. }
  5681. }
  5682. }
  5683. function MakeExperimentalConfirm(){ global $INDEXPHP;
  5684. if(isset($_COOKIE['la_experimental']) && $_COOKIE['la_experimental'] == 'confirmed'){
  5685. return false;
  5686. }
  5687. $caution_html =
  5688. $confirm = "<a class='text_highlight clean_a bold' href='".$INDEXPHP."?confirm_enter=1".
  5689. (isset($this->CurrentPostID)?("&post=".$this->CurrentPostID):"").
  5690. "'>&nbsp;&nbsp;".$this->T('继续')."&nbsp;&nbsp;</a>";
  5691. ?>
  5692. <div class='center_exp'><?php
  5693. if(isset($this->ExpCaution) && ($p=$this->GetPost($this->ExpCaution,true)))$this->MakeSinglePostExp($p);
  5694. else echo "<li class='post post_dummy'>".$this->TranslatePostParts("<h1>注意</h1><p>您将进入实验站。</p>")."</li>";
  5695. ?></div>
  5696. <div class='center_exp'><li class='post post_dummy'><p><?=$confirm?></p></li></div>
  5697. <?php return true;
  5698. }
  5699. }
  5700. $la = new LA;
  5701. $la->DoSiteRedirect();
  5702. $la->DoLogin();
  5703. $la->SwitchLanguageAndFont();
  5704. $err = $la->ProcessRequest($message, $redirect);
  5705. $la->WriteAsNecessary();
  5706. $la->DoIdentifyExperimental();
  5707. $la->SwitchWayBackMode();
  5708. if($err){
  5709. echo $message;
  5710. exit();
  5711. }
  5712. if(isset($redirect)){
  5713. header('Location: '.$redirect);
  5714. exit();
  5715. }
  5716. $la->DetectPageType();
  5717. $la->ReadImages(false);
  5718. $la->ReadPosts();
  5719. if(isset($la->WayBack)){
  5720. $la->ReadArchive();
  5721. }
  5722. $im = NULL;
  5723. if(isset($la->HereID) && preg_match('/images\/(.*)/u',$la->HereID,$imname) && ($im = &$la->FindImage($imname[1]))){
  5724. if(!$la->CanShowImage($im)) { $im=&$la->NULL_IMAGE; }
  5725. }
  5726. $p = &$la->GetPost($la->CurrentPostID);
  5727. if(!isset($p)){
  5728. $p = &$la->GetMergedPost($la->CurrentPostID);
  5729. }
  5730. if(isset($p) && !$la->CanShowPost($p)) $p=NULL;
  5731. else{ $la->DoExperimentalTopLink($p); }
  5732. if(isset($p)){ $la->ActualPostID = $p['id']; }
  5733. if($la->PageType=='here' ||$la->PageType=='experimental'){
  5734. if($im){
  5735. $la->SetHereMainImage($im);
  5736. $la->RecordVisitedHere($im['name'],$im?$la->ImageTitle($im):NULL);
  5737. }else if($p){
  5738. $la->RecordVisitedHere($p['id'],NULL);
  5739. }else {
  5740. $im = &$la->GiveImageInHere(false);
  5741. if($im){
  5742. $la->SetHereMainImage($im);
  5743. $la->RecordVisitedHere($im['name'],$la->ImageTitle($im));
  5744. }
  5745. }
  5746. }
  5747. $la->MakeHeader($p);
  5748. $la->MakeMainBegin();
  5749. if($la->PageType=='here' ||$la->PageType=='experimental'){
  5750. if(($la->PageType=='experimental' && (!$la->MakeExperimentalConfirm())) || $la->PageType=='here'){
  5751. if($im){
  5752. $la->MakeHereSection($im);
  5753. }else if($p){
  5754. $la->MakePostSectionExp($p);
  5755. $la->MakeLinkedPostsExp($p);
  5756. }else {
  5757. if($im){
  5758. $la->MakeHereSection($im);
  5759. }else{
  5760. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5761. "</p><p><a href='".$INDEXPHP."'>".$la->T('返回首页')."</a></p><br />";
  5762. }
  5763. }
  5764. }
  5765. $la->MakeMainEnd();
  5766. $la->MakeExpFooter();
  5767. }else{
  5768. if($la->PageType=='extras'){
  5769. $la->MakeExtraOperations();
  5770. }else if($la->PageType=='settings'){
  5771. $la->MakeSettings();
  5772. }else if($la->PageType=='gallery'){
  5773. $la->MakeGalleryLeft();
  5774. $la->MakeGallerySection();
  5775. }else if($la->PageType=='post'){
  5776. if($p){
  5777. $made_interesting = false;
  5778. if($la->IsInterestingPost($p)){
  5779. $la->MakeInterestingSection($p['tid']);
  5780. }
  5781. else{
  5782. $la->MakeSidebar();
  5783. $la->MakePostSectionV2($p);
  5784. echo $la->GeneratePage(1," section");
  5785. //$la->MakePostSection($p);
  5786. }
  5787. }else{
  5788. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5789. "</p><p><a href='".$INDEXPHP."'>".$la->T('返回首页')."</a></p><br />";
  5790. }
  5791. }else if($la->PageType=='history'){
  5792. $la->ReadArchive();
  5793. $la->MakePostHistory($p, $_GET['version']??NULL);
  5794. }else if($la->PageType=='search'){
  5795. $la->MakeSidebar();
  5796. $la->MakeRecentPostsV2($_GET['search']);
  5797. echo $la->GeneratePage();
  5798. }else if($la->PageType=='category'){
  5799. $la->MakeSidebar();
  5800. $la->MakeRecentPostsV2(NULL,$_GET['category']);
  5801. echo $la->GeneratePage();
  5802. }else if($la->PageType=='comments'){
  5803. $la->MakeCommentPosts();
  5804. }else if($la->PageType=='statistics'){
  5805. $la->MakeStatistics();
  5806. }else{
  5807. $la->MakeSidebar();
  5808. $la->MakeRecentPostsV2();
  5809. echo $la->GeneratePage();
  5810. }
  5811. $la->MakeMainEnd();
  5812. $la->MakeFooter($p);
  5813. }
  5814. ?>