*/}}

index.php 296 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268
  1. <?php
  2. include 'Parsedown.php';
  3. include 'ParsedownExtra.php';
  4. ini_set('display_errors', '1');
  5. ini_set('display_startup_errors', '1');
  6. error_reporting(E_ALL);
  7. class LA{
  8. protected $PDE;
  9. protected $style;
  10. /* config */
  11. protected $Title;
  12. protected $ShortTitle;
  13. protected $Admin;
  14. protected $Password;
  15. protected $DisplayName;
  16. protected $EMail;
  17. protected $SpecialNavigation;
  18. protected $SpecialFooter;
  19. protected $SpecialFooter2;
  20. protected $SpecialPinned;
  21. protected $DefaultGallery;
  22. protected $SelfAuthPath;
  23. protected $HereHost;
  24. protected $HereTitle;
  25. protected $HereShortTitle;
  26. protected $HereAlbum;
  27. protected $HereNavigation;
  28. protected $HereFooter;
  29. protected $ExpHost;
  30. protected $ExpAlbum;
  31. protected $ExpTitle;
  32. protected $ExpShortTitle;
  33. protected $ExpCaution;
  34. protected $ExpNavigation;
  35. protected $ExpFooter;
  36. protected $CommentEnabled;
  37. protected $MastodonToken;
  38. protected $MastodonURL;
  39. protected $MastodonPreferredLang;
  40. protected $HostURL;
  41. protected $Redirect;
  42. protected $Translations;
  43. protected $CustomTranslationContent;
  44. protected $CurrentOffset;
  45. protected $PostsPerPage;
  46. protected $HotPostCount;
  47. protected $LoggedIn;
  48. protected $LoginTokens;
  49. protected $InHereMode;
  50. protected $InExperimentalMode;
  51. protected $LanguageAppendix;
  52. protected $UseRemoteFont;
  53. protected $Posts;
  54. protected $Threads; // [ keys: first last displayed count]
  55. protected $WaybackThreads;
  56. public $Images;
  57. protected $Galleries;
  58. protected $Anchors;
  59. protected $ArchiveHandles;
  60. protected $Archive;
  61. public $WayBack;
  62. protected $YearBegin;
  63. protected $YearEnd;
  64. protected $Markers;
  65. protected $ExtraScripts;
  66. protected $APubID;
  67. protected $APubActor;
  68. protected $APubPublicKey;
  69. protected $APubPrivateKey;
  70. protected $TIME_STRING;
  71. public $NULL_POST;
  72. public $NULL_IMAGE;
  73. public $NULL_IMAGE_DUMMY;
  74. public $NULL_Gallery;
  75. protected $DoneReadPosts;
  76. protected $DoneReadImages;
  77. protected $DoneReadArchive;
  78. protected $NeedWritePosts;
  79. protected $NeedWriteImages;
  80. protected $NeedWriteArchive;
  81. protected $HereDisplayTitle;
  82. protected $VisitedHere;
  83. protected $HereNumber;
  84. protected $HereMainImage;
  85. public $PageType;
  86. public $CurrentPostID;
  87. public $HereID;
  88. public $ActualPostID;
  89. public $TagID;
  90. function ReadableTime($id){
  91. $dt = DateTime::createFromFormat('YmdHis', $id);
  92. return $dt->format('Y/m/d H:i:s');
  93. }
  94. function StandardTime($id){
  95. $dt = DateTime::createFromFormat('YmdHis', $id);
  96. return $dt->format('Y-m-d\TH:i:sP');
  97. }
  98. function FullURL(){
  99. return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?
  100. "https" : "http") . "://" . $_SERVER['HTTP_HOST'] .
  101. $_SERVER['REQUEST_URI'];
  102. }
  103. function T($str){
  104. if(!$this->LanguageAppendix) return $str;
  105. foreach($this->Translations as $entry){
  106. if($entry['zh']==$str)
  107. return $entry[$this->LanguageAppendix];
  108. }
  109. return $str;
  110. }
  111. function SwitchLanguageAndFont(){
  112. $this->LanguageAppendix = 'zh';
  113. if(isset($_COOKIE['la_language'])){
  114. $this->LanguageAppendix = $_COOKIE['la_language'];
  115. }else{
  116. if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
  117. $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  118. $lang = substr($lang,0,5);
  119. if(preg_match("/zh/i",$lang))$this->LanguageAppendix = 'zh';
  120. else $this->LanguageAppendix = 'en';
  121. }
  122. }
  123. if(isset($_COOKIE['la_font'])){
  124. $this->UseRemoteFont = ($_COOKIE['la_font']!='local');
  125. }
  126. }
  127. function SwitchWayBackMode(){
  128. if(isset($_COOKIE['la_wayback'])){
  129. $this->WayBack = $_COOKIE['la_wayback'];
  130. }else $this->WayBack = NULL;
  131. }
  132. function DisplayRedirectConfig(){
  133. $s = "";
  134. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  135. if($r['for']=='P'){
  136. $s.=("P ".$r['format'].":".$r['target'].";".PHP_EOL);
  137. }else if($r['for']=='S'){
  138. $s.=("S ".$r['format'].":".$r['domain'].":".$r['target'].";".PHP_EOL);
  139. }
  140. }
  141. return $s;
  142. }
  143. function DoSiteRedirect(){
  144. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  145. if($r['for']=='S'){
  146. if(preg_match('/'.$r['format'].'/ui', $_SERVER['HTTP_HOST'])){
  147. if($_SERVER['REQUEST_URI']=='/'||$_SERVER['REQUEST_URI']==''){
  148. header('Location:https://'.$r['domain'].'/index.php?post='.$r['target']); exit;
  149. }else{
  150. header('Location:https://'.$r['domain'].$_SERVER['REQUEST_URI']); exit;
  151. }
  152. }
  153. }
  154. }
  155. }
  156. function WriteHTACCESS(){
  157. $conf = fopen('.htaccess','w');
  158. fwrite($conf,"RewriteEngine on".PHP_EOL.PHP_EOL);
  159. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  160. if($r['for']=='P'){
  161. if(!preg_match('/[0-9]{14}/',$r['target'])){
  162. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?'.$r['target'].' [R=302,L]'.PHP_EOL.PHP_EOL);
  163. }
  164. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?post='.$r['target'].' [R=302,L]'.PHP_EOL.PHP_EOL);
  165. }// do site redirect in php.
  166. }
  167. fwrite($conf, 'RewriteCond %{HTTPS} !=on'.PHP_EOL.
  168. 'RewriteCond %{HTTP_HOST} !=localhost'.PHP_EOL.
  169. 'RewriteCond %{REQUEST_URI} !^.*(jpg|png|gif)$'.PHP_EOL.
  170. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]'.PHP_EOL.PHP_EOL);
  171. fwrite($conf, 'RewriteCond %{HTTP_HOST} !^www\.'.PHP_EOL.
  172. 'RewriteCond %{HTTP_HOST} !=localhost'.PHP_EOL.
  173. 'RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]'.PHP_EOL.PHP_EOL);
  174. fwrite($conf,'<Files ~ "\.md$">'.PHP_EOL.'deny from all'.PHP_EOL.'</Files>'.PHP_EOL);
  175. fflush($conf);fclose($conf);
  176. }
  177. function BuildRedirectConfig($conf){
  178. $this->Redirect=[];
  179. if(preg_match_all('/P\s+(.*)\:\s*([0-9]{14}|.+)\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  180. foreach($ma as $m){
  181. $redirect=[]; $redirect['for'] = 'P'; $redirect['format'] = $m[1]; $redirect['target'] = $m[2];
  182. $this->Redirect[]=$redirect;
  183. }
  184. }
  185. if(preg_match_all('/S\s+(\S+)\s*\:\s*(\S+)\s*\:\s*([0-9]{14})\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  186. foreach($ma as $m){
  187. $redirect=[]; $redirect['for'] = 'S'; $redirect['format'] = $m[1]; $redirect['domain'] = $m[2]; $redirect['target'] = $m[3];
  188. $this->Redirect[]=$redirect;
  189. }
  190. }
  191. }
  192. function WriteTokens(){
  193. $tf = fopen('la_tokens.php','w');
  194. fwrite($tf,'<?php header("Location:index.php"); exit; ?>'.PHP_EOL.PHP_EOL);
  195. if(isset($this->LoginTokens) && sizeof($this->LoginTokens)) {
  196. foreach($this->LoginTokens as $t){
  197. fwrite($tf,'- '.$t.PHP_EOL);
  198. }
  199. }
  200. fflush($tf);fclose($tf);
  201. }
  202. function WriteConfig(){
  203. if(!isset($this->Title)) $this->Title = $this->T('那么的维基');
  204. if(!isset($this->ShortTitle)) $this->ShortTitle = $this->T('基');
  205. if(!isset($this->Admin)) $this->Admin = 'admin';
  206. if(!isset($this->DisplayName)) $this->DisplayName = $this->T('管理员');
  207. if(!isset($this->Password)) $this->Password = password_hash('Admin', PASSWORD_DEFAULT).PHP_EOL;
  208. $conf = fopen('la_config.php','w');
  209. fwrite($conf,'<?php header("Location:index.php"); exit; ?> '.PHP_EOL.PHP_EOL);
  210. fwrite($conf,'- Title = '.$this->Title.PHP_EOL);
  211. fwrite($conf,'- ShortTitle = '.$this->ShortTitle.PHP_EOL);
  212. fwrite($conf,'- Admin = '.$this->Admin.PHP_EOL);
  213. fwrite($conf,'- DisplayName = '.$this->DisplayName.PHP_EOL);
  214. fwrite($conf,'- Password = '.$this->Password.PHP_EOL);
  215. fwrite($conf,'- EMail = '.$this->EMail.PHP_EOL);
  216. fwrite($conf,'- SpecialNavigation = '.$this->SpecialNavigation.PHP_EOL);
  217. fwrite($conf,'- SpecialFooter = '.$this->SpecialFooter.PHP_EOL);
  218. fwrite($conf,'- SpecialFooter2 = '.$this->SpecialFooter2.PHP_EOL);
  219. fwrite($conf,'- SpecialPinned = '.$this->SpecialPinned.PHP_EOL);
  220. fwrite($conf,'- DefaultGallery = '.$this->DefaultGallery.PHP_EOL);
  221. fwrite($conf,'- SelfAuthPath = '.$this->SelfAuthPath.PHP_EOL);
  222. fwrite($conf,'- CommentEnabled = '.($this->CommentEnabled?"True":"False").PHP_EOL);
  223. fwrite($conf,'- HereHost = '.$this->HereHost.PHP_EOL);
  224. fwrite($conf,'- HereTitle = '.$this->HereTitle.PHP_EOL);
  225. fwrite($conf,'- HereShortTitle = '.$this->HereShortTitle.PHP_EOL);
  226. fwrite($conf,'- HereAlbum = '.$this->HereAlbum.PHP_EOL);
  227. fwrite($conf,'- HereNavigation = '.$this->HereNavigation.PHP_EOL);
  228. fwrite($conf,'- HereFooter = '.$this->HereFooter.PHP_EOL);
  229. fwrite($conf,'- ExpHost = '.$this->ExpHost.PHP_EOL);
  230. fwrite($conf,'- ExpTitle = '.$this->ExpTitle.PHP_EOL);
  231. fwrite($conf,'- ExpShortTitle = '.$this->ExpShortTitle.PHP_EOL);
  232. fwrite($conf,'- ExpCaution = '.$this->ExpCaution.PHP_EOL);
  233. fwrite($conf,'- ExpAlbum = '.$this->ExpAlbum.PHP_EOL);
  234. fwrite($conf,'- ExpNavigation = '.$this->ExpNavigation.PHP_EOL);
  235. fwrite($conf,'- ExpFooter = '.$this->ExpFooter.PHP_EOL);
  236. fwrite($conf,'- MastodonToken = '.$this->MastodonToken.PHP_EOL);
  237. fwrite($conf,'- MastodonURL = '.$this->MastodonURL.PHP_EOL);
  238. fwrite($conf,'- MastodonPreferredLang = '.$this->MastodonPreferredLang.PHP_EOL);
  239. fwrite($conf,'- HostURL = '.$this->HostURL.PHP_EOL);
  240. fwrite($conf,'- APubID = '.$this->APubID.PHP_EOL);
  241. fflush($conf);fclose($conf);
  242. $conf = fopen('la_redirect.md','w');
  243. fwrite($conf,$this->DisplayRedirectConfig());fflush($conf);fclose($conf);
  244. $this->WriteHTACCESS();
  245. $this->WriteTokens();
  246. }
  247. function Install(){
  248. if(!file_exists('la_config.php')){
  249. $this->WriteConfig();
  250. }
  251. if(!is_dir('posts')) mkdir('posts');
  252. if(!is_dir('images')) mkdir('images');
  253. if(!is_dir('images/thumb')) mkdir('images/thumb');
  254. if(!is_dir('styles')) mkdir('styles');
  255. if(!is_dir('archive')) mkdir('archive');
  256. $this->WriteStyles();
  257. $this->WriteHTACCESS();
  258. }
  259. function ReadFromExistingConfig(){
  260. $f=null;
  261. if(file_exists('la_config.php')) $f='la_config.php';
  262. else if(file_exists('la_config.md')) $f='la_config.md';
  263. if(!isset($f)) return;
  264. $c = file_get_contents($f);
  265. if(preg_match_all('/-\s*(\S+)\s*=\s*(\S+)\s*$/um', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  266. $str = $m[1];
  267. $this->$str = $m[2];
  268. }
  269. $this->CommentEnabled = $this->CommentEnabled=="True";
  270. }
  271. function ReadConfig(){
  272. $this->ReadFromExistingConfig();
  273. if(file_exists('la_redirect.md')){
  274. $c = file_get_contents('la_redirect.md');
  275. $this->BuildRedirectConfig($c);
  276. }
  277. if(!file_exists('la_config.php')){
  278. $this->Install();
  279. }
  280. $this->Translations=[];
  281. if(file_exists("translations.md")){
  282. $c = file_get_contents('translations.md');
  283. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  284. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  285. $this->Translations[] = $entry;
  286. }
  287. }
  288. if(file_exists("custom_translations.md")){
  289. $this->CustomTranslationContent = file_get_contents('custom_translations.md');
  290. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$this->CustomTranslationContent, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  291. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  292. $this->Translations[] = $entry;
  293. }
  294. }
  295. $this->LoginTokens=[];
  296. if(file_exists('la_tokens.php')){
  297. $c = file_get_contents('la_tokens.php');
  298. if(preg_match_all('/-\s+(\S.*)\s*$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  299. $this->LoginTokens[] = $m[1];
  300. }
  301. }
  302. }
  303. function MastodonPostStatus($status){ return $this->MastodonCall('/api/v1/statuses', 'POST', $status); }
  304. function MastodonPostMedia($media){ return $this->MastodonCall('/api/v1/media', 'POST', $media); }
  305. function MastodonCall($endpoint, $method, $data){
  306. $headers = [
  307. 'Authorization: Bearer '.$this->MastodonToken,
  308. 'Content-Type: multipart/form-data',
  309. ];
  310. $ch = curl_init();
  311. curl_setopt($ch, CURLOPT_URL, $this->MastodonURL.$endpoint);
  312. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  313. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  314. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  315. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  316. $reply = curl_exec($ch);
  317. if (!$reply) {
  318. return json_encode(['ok'=>false, 'curl_error_code' => curl_errno($ch_status), 'curl_error' => curl_error(ch_status)]);
  319. }
  320. curl_close($ch);
  321. return json_decode($reply, true);
  322. }
  323. function MastodonSendPost(&$post, &$errmsg=NULL){
  324. if(isset($post['mark_value']) && $post['mark_value']==7){ return NULL; }
  325. $this->LanguageAppendix = 'zh';
  326. if(in_array($this->MastodonPreferredLang,['en','zh'])){ $this->LanguageAppendix = $this->MastodonPreferredLang; }
  327. $this->ConvertPost($post);
  328. $media_ids = NULL;
  329. $mastodon_post_url = NULL;
  330. $imcount = 0;
  331. if(isset($post['original_images']) && isset($post['original_images'][0])) foreach($post['original_images'] as $im){
  332. $curl_file = curl_file_create($im, mime_content_type($im), basename($im));
  333. $body = ['file' => $curl_file,]; $response = $this->MastodonPostMedia($body);
  334. if(isset($response['id'])){ if(!isset($media_ids)){$media_ids=[];} $media_ids[]=$response['id']; }
  335. else{ if(isset($response['error'])) $errmsg.=$response['error']."<br /><br />"; }
  336. $imcount++; if($imcount>=4){ break; }
  337. }
  338. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$post['html']));
  339. if(isset($this->HostURL) && $this->HostURL!=""){
  340. $text.=("\n\n".$this->T('来自').' '.$this->HostURL.'?post='.$post['id']);
  341. }
  342. $vis = (isset($post['mark_value']) && $post['mark_value']==6)?"private":"public";
  343. $status_data = [ 'status' => $text, 'visibility' => $vis, 'language' => $this->LanguageAppendix, ];
  344. if(isset($post['prev']) && ($pp=&$this->GetPost($post['prev']))!=$this->NULL_POST){
  345. if(isset($pp['mastodon_url'])){ $status_data['in_reply_to_id'] = basename($pp['mastodon_url']);
  346. }
  347. }
  348. if(isset($media_ids[0])){ $status_data['media_ids']=$media_ids; }
  349. $status_data = preg_replace('/(media_ids%5B)[0-9]+(%5D)/','$1$2', http_build_query($status_data));
  350. $status_response = $this->MastodonPostStatus($status_data);
  351. if(isset($status_response['url']) && $status_response['url']){
  352. $mastodon_post_url = $status_response['url'];
  353. $post['mastodon_url'] = $mastodon_post_url;
  354. $this->NeedWritePosts = 1;
  355. }
  356. if(isset($status_response['error'])) { $errmsg .= $status_response['error']; }
  357. return $mastodon_post_url;
  358. }
  359. function __construct() {
  360. $this->ReadConfig();
  361. $this->PDE = new ParsedownExtra();
  362. $this->PDE->SetInterlinkPath('/');
  363. $this->Posts = [];
  364. $this->Threads = [];
  365. $this->VisitedHere = [];
  366. $this->NULL_IMAGE_DUMMY = [];
  367. $this->NULL_IMAGE_DUMMY['name']=$this->NULL_IMAGE_DUMMY['file']=$this->NULL_IMAGE_DUMMY['thumb']="";
  368. $this->Markers=['●', '○', '✓', '×', '!', 'P', 'E', 'S'];
  369. $this->PostsPerPage = 40;
  370. $this->CommentsPerPage = 100;
  371. $this->HotPostCount = 15;
  372. $this->TIME_STRING = date('YmdHis');
  373. $this->WayBack = NULL;
  374. $this->YearBegin = $this->YearEnd = 2000;
  375. $this->DoneReadPosts = $this->DoneReadImages = $this->DoneReadArchive = false;
  376. $this->NeedWritePosts= $this->NeedWriteImages= $this->NeedWriteArchive= false;
  377. $this->UsePosts = &$this->Posts;
  378. }
  379. function DoLogout(){
  380. $this->LoggedIn = false;
  381. unset($_SESSION['user_id']);
  382. $this->RecordToken(true);
  383. }
  384. function RecordToken($unset_current=false){
  385. if(isset($unset_current) && isset($_COOKIE['la_token'])){
  386. $t = $_COOKIE['la_token'];
  387. setcookie('la_token', null, -1); unset($_COOKIE['la_token']);
  388. if (($key = array_search($t,$this->LoginTokens)) !== false) { unset($this->LoginTokens[$key]); }
  389. $this->WriteTokens();
  390. return null;
  391. }else{
  392. $t = uniqid('la_',true);
  393. setcookie('la_token',$t,time()+3600*24*7); $_COOKIE['la_token'] = $t;
  394. $this->LoginTokens[] = $t;
  395. $this->WriteTokens();
  396. return $t;
  397. }
  398. }
  399. function LoginThroughToken(){
  400. if(!isset($_COOKIE['la_token'])) return false;
  401. $t = $_COOKIE['la_token'];
  402. if (($key = array_search($t,$this->LoginTokens)) !== false) {
  403. $_SESSION['user_id']=$this->Admin;
  404. $this->LoggedIn = true;
  405. setcookie('la_token',$t,time()+3600*24*7);
  406. return true;
  407. }
  408. return false;
  409. }
  410. function DoLogin(){
  411. session_start();
  412. $redirect=false;
  413. if(isset($_GET['logout'])){ $this->DoLogout(); header('Location:index.php'); }
  414. else if(!isset($_SESSION['user_id'])){
  415. if(isset($_POST['login_button'])){
  416. $id = trim($_POST['login_id']);
  417. $pwd = trim($_POST['login_password']);
  418. if(strtolower($this->Admin)==strtolower($id)&&password_verify($pwd, $this->Password)){
  419. $_SESSION['user_id']=$id;
  420. $this->RecordToken(false);
  421. }
  422. $redirect = true;
  423. }else if($this->LoginThroughToken()){
  424. // nothing;
  425. }
  426. }else{
  427. if(strtolower($_SESSION['user_id']) == strtolower($this->Admin)){ $this->LoggedIn = true; }
  428. else{ $this->DoLogout();}
  429. }
  430. if($redirect){
  431. header('Location:index.php'.(isset($_GET['post'])?("?post=".$_GET['post']):"")
  432. .(isset($_GET['settings'])?"?settings=true":""));
  433. }
  434. }
  435. function SetHereMainImage($im_this){
  436. if(isset($im_this) && isset($im_this['parent'])){ $this->HereMainImage = &$this->FindImage($im_this['parent'],true);}
  437. }
  438. function RecordVisitedHere($image_or_post_name, $image_title){
  439. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  440. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  441. if(!(isset($_SESSION[$visited_here][0]) && in_array($image_or_post_name,$_SESSION[$visited_here]))){
  442. $_SESSION[$visited_here][] = $image_or_post_name;
  443. }
  444. if(isset($image_title)){ $this->HereDisplayTitle=$image_title; }
  445. $this->HereNumber = array_search($image_or_post_name,$_SESSION[$visited_here])+1;
  446. $_SESSION['here_number'] = $this->HereNumber;
  447. $this->VisitedHere = $_SESSION[$visited_here];
  448. }
  449. function HereLinkFromNumber($number){
  450. $number -= 1; if($number<0){ $number=0; }
  451. if($number>=sizeof($this->VisitedHere)){ $number = sizeof($this->VisitedHere)-1; }
  452. if(preg_match('/(jpg|jpeg|png|gif)/u',$this->VisitedHere[$number])){ return "?here=images/".$this->VisitedHere[$number]; }
  453. else{ return "?post=".$this->VisitedHere[$number]; }
  454. }
  455. function WriteStyles(){
  456. $this->style="
  457. html{font-size:18px;font-family:'Noto Serif CJK SC','Times New Roman','SimSun', Georgia, serif;}
  458. body{background-color:%white%;color:%black%;}
  459. sup,sub{line-height:0;}
  460. blockquote{border-left:2px solid %black%;padding-left:0.3em;}
  461. *{box-sizing:border-box;padding:0;margin:0;font-weight:normal;}
  462. b,strong,th{font-weight:bold;}
  463. select{font-size:inherit;}
  464. .page,.page_gallery{padding:1em;padding-top:0;padding-bottom:0;}
  465. .hidden_on_desktop,.hidden_on_wide{display:none;}
  466. .hidden_on_desktop_force{display:none !important;}
  467. ::file-selector-button{background:none;border:none;}
  468. a,button,::file-selector-button{text-decoration:underline;color:%black%;}
  469. a:hover,.button:hover,::file-selector-button:hover{text-decoration:none;color:%gray%;}
  470. .button:disabled{background-color:%gray%;pointer-events:none;}
  471. header{position:sticky;top:0;background-color:%white%;z-index:10;padding-top:0.5em;max-height:100vh;z-index:30;}
  472. 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;}
  473. header>div{overflow:auto;white-space:nowrap;}
  474. .header_nav{display:inline;}
  475. header a,.left a,.footer a,.clean_a,.clean_a a{text-decoration:none;}
  476. header a:hover,.button:hover{color:%gray% !important;}
  477. .exp_h_f{padding-top:0.3em !important;padding-bottom:0.3em !important;line-height:1.5em !important;height:2.1em !important;}
  478. .exp_f{text-align:center;}
  479. .toc_button{position:absolute;top:0.5em;right:0;text-shadow: 0px 0px 10px %white%;background-color:%white%88;}
  480. .footer{background-color:%white%;z-index:10;position:relative;}
  481. .invert_a,.invert_a a{color:%gray%;text-decoration:none;}
  482. .invert_a:hover,.invert_a a:hover{color:%black% !important;}
  483. .gray,.gray a{color:%gray%;}
  484. hr{border:1px solid %gray%;}
  485. header ul,.small_footer ul,.small_footer span,header li,.small_footer li{display:inline-block;}
  486. header li::before,.small_footer li::before{content:' - '}
  487. header h1,header h2,header h3,header h4,header h5,header p{display:inline;font-size:1rem;}
  488. .main{position:relative;word-spacing:-1em;}
  489. .main *{word-spacing:initial;}
  490. pre{overflow:auto;max-width:100%;display:block;font-size:0.75em;}
  491. ul{display:block;}
  492. li{display:block;}
  493. .clean_table{border:none;font-size:1em !important;}.clean_table thead{box-shadow:none;}.clean_table td{vertical-align:top;}
  494. table{width:100%;border-collapse:collapse;border-bottom:2px solid %black%;border-top:3px solid %black%;}
  495. table input{border:none!important;}
  496. table img{max-width:10rem !important;}
  497. td{padding-left:0.1em;padding-right:0.1em;}
  498. td:first-child{padding-left:0;}
  499. td:last-child{padding-right:0;}
  500. tbody tr:hover{box-shadow:inset 0 -2px 0 0px %black%;}
  501. thead{box-shadow:inset 0 -1px 0 0px %black%;position:sticky;top:2rem;background-color:%white%;z-index:5;}
  502. .post table{font-size:0.85em;}
  503. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 20em);}
  504. .interesting_tbody td{display:contents;}
  505. .interesting_tbody tr{position:relative;scroll-margin:4.5em}
  506. .interesting_tbody td>*{display:table-cell;}
  507. .interesting_tbody td>.wscroll{display:none !important;}
  508. .interesting_tbody .post_access{padding-top:0;}
  509. .interesting_tbody .post_menu_button{top:0;opacity:0;}
  510. .interesting_tbody td>img,.interesting_tbody td>.imd{position:absolute;left:1.4em;z-index:-1;height:1em;width:20em;
  511. display:flex;top:0.2em;object-fit:cover;max-width:calc(100% - 1.4em) !important;overflow:hidden;}
  512. .interesting_tbody td>.imd>a{display:flex;}
  513. .interesting_tbody img{object-fit:cover;width:100%;}
  514. .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);}
  515. .interesting_tbody .p_thumb{height:1em;}
  516. .interesting_tbody .p_thumb img,.interesting_tbody .p_thumb video{max-height:10rem !important;max-width:20rem !important;}
  517. tr:hover .post_menu_button{opacity:1;}
  518. .post_current_row{background-color:%graybkg%;mix-blend-mode:screen;text-shadow:0px 0px 0.1em %white%;}
  519. .align_right{text-align:right;}
  520. .left{display:inline-block;vertical-align:top;width:25%;max-height:calc(100vh - 2.6em);top:2em;
  521. position:sticky;overflow:auto;padding-right:0.2em;padding-bottom:4rem;}
  522. .center{display:inline-block;vertical-align:top;width:50%;padding-left:0.3em;overflow:visible;padding-bottom:4rem;}
  523. .center_wide{display:inline-block;vertical-align:top;width:75%;padding-left:0.3em;overflow:visible;padding-bottom:4rem;}
  524. .center_full{display:inline-block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;}
  525. .center_wide .p_thumb{height:10rem;}
  526. .sticky_title{position:sticky;top:calc(1.6rem + 2px);z-index:1;box-shadow:6em 3.5em 0.75em -3em inset %white%;pointer-events:none;}
  527. .center_exp{display:block;width:80%;margin:0 auto;overflow:visible;padding-bottom:1em;}
  528. .table_top{position:relative;left:calc(-50% - 0.45em);width:calc(200% + 0.6em);background:%white%;z-index:1;
  529. box-shadow:0px 0px 2em 1em %white%;margin-top:2em;margin-bottom:2em;}
  530. .right{display:inline-block;vertical-align:top;width:25%;position:sticky;top:2em;
  531. padding-left:0.5em;max-height:calc(100vh - 2.6em);overflow:auto;padding-bottom:4rem;}
  532. textarea,input[type=text],input[type=password]{width:100%;display:block;font-family:inherit;max-height:60vh;font-size:inherit;}
  533. select,textarea,input[type=text],input[type=password]{background:none;border:none;border-bottom:1px solid %black%;color:%black%;}
  534. .text_highlight input{border-bottom:1px solid %white%;color:%white%;}
  535. .button{background:none;border:none;font-family:inherit;color:%black%;font-size:inherit;font-weight:bold;}
  536. .post{position:relative;scroll-margin:3.5em;border-radius:0.3em;}
  537. .center_exp .post{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;border-radius:0;}
  538. .post_width li,.post_width_big li,.footer_additional li,.footer_additional li,.post_dummy li
  539. {display:list-item;margin-left:1em;list-style:disc;}
  540. .post_width li li,.post_width_big li li,.footer_additional li li,.footer_additional li li,.post_dummy li li
  541. {list-style:circle;}
  542. ol li{list-style:unset !important;}
  543. .post_width > *,.post_width_big > *,.post_dummy > *,.post_ref > *{margin:0;margin-bottom:0.5rem}
  544. .post_dummy > *{width:60%;margin:0 auto;margin-bottom:0.5rem}
  545. .post_dummy > p img{display:block;width:100%;margin:0 auto;}
  546. .gallery_left li{display:list-item;margin-left:1em;list-style:none;}
  547. .gallery_left .selected{list-style:'→';}
  548. .focused_post{font-size:1.1em;margin-top:0.1em;margin-bottom:0.1em;padding:0.5rem !important;border:2px dashed #ac7843;}
  549. .post_width{position:relative;left:1.4rem;width:calc(100% - 1.7rem);padding-left:0.2em;overflow:visible;}
  550. .post_width_big{position:relative;left:0;width:100%;overflow:visible;}
  551. .post_menu_button{position:absolute;display:none;right:0rem;width:1.5rem;
  552. text-align:center;border-radius:0.3em;user-select:none;cursor:pointer;z-index:10;}
  553. .pointer{cursor:pointer;}
  554. .post:hover .post_menu_button{display:block;}
  555. .pop_menu{position:absolute;top:0.3rem;z-index:95;background-color:%lighterbkg%;
  556. padding:0.3em;right:0.3rem;text-align:right;border-radius:0.3em;font-size:1rem;
  557. box-shadow:0px 0px 10px rgb(0, 0, 0);}
  558. .pop_menu li{list-style:none;margin-left:0;}
  559. .pop_menu hr{border:2px solid rgba(0,0,0,0.1);}
  560. .toc{left:60%;width:40%;top:0;position:absolute;}
  561. .post_access{width:1.4rem;top:0;position:absolute;height:100%;text-align:center;font-weight:bold;border-right:2px solid transparent;user-select:none;}
  562. .post_access:hover{background-color:%lightopbkg%;border-top-left-radius:0.3em;border-bottom-left-radius:0.3em;
  563. border-right:2px solid %black% !important;}
  564. .paa{width:1.4rem;min-width:1.4rem;}
  565. .opt_compact .post_access,.ref_compact .post_access{border-right:2px solid %gray%;}
  566. .post_box{border:1px solid %gray%;border-radius:0.3em;padding:0.3em;}
  567. .post_box:hover,.post_menu_button:hover{background-color:%lightopbkg%}
  568. #big_image_info .post_box:hover{background-color:%graybkg%;}
  569. .post_preview{font-size:0.9rem;overflow:hidden;margin-bottom:0.2em;}
  570. .post .post_ref{margin:0;padding-left:1.7rem;}
  571. .post_ref_main{display:inline-block;vertical-align:top;}
  572. .post_preview .post_ref_main{max-height:6rem;overflow:hidden;}
  573. .post_ref_images{overflow:hidden;}
  574. .page_selector{padding-top:2rem;text-align:center;}
  575. .smaller{font-size:0.85em;}
  576. .bigger{font-size:1.3em;}
  577. .block{display:block;}
  578. .opt_compact{margin-left:1.6rem;}
  579. .opt_compact .post_width {margin-left:0.3em;width: calc(100% - 1.8rem);}
  580. .post_box_top{padding-bottom:0.3em;padding-top:0.3em;}
  581. .post_box_fixed_bottom{position:sticky;bottom:0em;background-color:%white%;z-index:5;}
  582. .spacer{height:0.5em;}
  583. .pop_right,.pop_right_big{position:fixed;top:0;right:0;bottom:0;width:30%;z-index:100;background-color:%graybkg%;display:none;
  584. transition-timing-function:ease-out;padding:1rem;overflow:auto;}
  585. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  586. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  587. @keyframes pop_slide_in_big{0%{right:-30%;}100%{right:0%;}}
  588. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-30%;}}
  589. .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;}
  590. @keyframes backdrop_fade_in{0%{opacity:0%;}100%{opacity:100%;}}
  591. @keyframes backdrop_fade_out{0%{opacity:100%;}100%{opacity:0%;}}
  592. .toc_entry_1{font-size:1.1em;}
  593. .toc_entry_2{font-size:1.0em;padding-left:0.5rem;}
  594. .toc_entry_3{font-size:0.9em;padding-left:1rem;}
  595. .toc_entry_4{font-size:0.85em;padding-left:1.5rem;}
  596. .toc_entry_5{font-size:0.8em;padding-left:2rem;}
  597. h1,h2,h3,h4,h5{scroll-margin:2.5em;}
  598. .left ul h1,.left ul h2,.left ul h3,.left ul h4,.left ul h5,.left ul p{font-size:1em;}
  599. .deleted_post{color:%gray%;text-decoration:line-through;}
  600. #file_list{margin-top:0.5em;}
  601. .file_thumb img,.file_thumb video{max-height:100%;max-width:100%;object-fit:cover;min-width:100%;min-height:100%;}
  602. .file_thumb video{border:2px dashed %black%;}
  603. #file_list li{margin-bottom:0.3em;}
  604. .ref_thumb{white-space:nowrap;overflow:hidden;}
  605. .ref_thumb .file_thumb{width:3em;height:3em;}
  606. .side_thumb li{margin:0.4em;display:inline-block;}
  607. .file_thumb{width:4em;height:4em;display:inline-block;line-height:0;vertical-align:middle;overflow:hidden;}
  608. .p_row{display:flex;flex-wrap:wrap;width:100%;}
  609. .p_thumb{display:flex;flex-grow:1;height:6rem;margin-right:0.25rem;margin-bottom:0.25rem;overflow:hidden;position:relative;}
  610. .p_thumb_narrow{width:1rem;}
  611. .p_thumb img,.p_thumb video{object-fit:cover;max-height:100%;min-width:100%;}.p_thumb a{display:contents;}
  612. .ref_count,.p_thumb .post_menu_button{text-shadow: 0px 0px 10px rgb(0, 0, 0);}
  613. .p_thumb:hover .post_menu_button{display:block;}
  614. .p_thumb_selected{color:%black% !important;}
  615. .p_thumb_selected{display:block;}
  616. .post .p_thumb img,.post .p_thumb video{max-height:6rem;}
  617. .p_thumb video{border:2px dashed %black%;}
  618. .big_image_box{position:fixed;top:0;bottom:0;left:0;width:75%;z-index:95;text-align:center;pointer-events:none;}
  619. .big_image_box *{pointer-events:auto;}
  620. .big_image_box img,.big_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  621. .here_image_box{position:relative;width:100%;text-align:center;height:calc(100vh - 4.5em);}
  622. .here_image_box img,.here_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  623. .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;
  624. background:linear-gradient(to right, rgba(0,0,0,0), rgb(1, 1, 1));transition:background-size .2s linear;background-size: 300% 100%;}
  625. .big_side_box:hover{background-size: 100% 100%;}
  626. .big_side_box a,.big_side_box hr,#dropping_background{color:%black%;}
  627. .big_side_box a:hover{color:%gray%;}
  628. .big_side_box *{pointer-events:auto;}
  629. .image_nav{pointer-events:none;}
  630. #dropping_background{background-color:rgba(0,0,0,0.4);position:fixed;top:0;right:0;bottom:0;left:0;z-index:100;text-align:center;
  631. box-shadow:0px 0px 500px black inset;display:flex;align-items:center;}
  632. img,video{cursor:pointer;max-height:100%;max-width:100%;vertical-align:middle;}
  633. .post img,.post video{max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  634. .post > a > img,.post > a > video{display:block;margin:0.3em auto;}
  635. .post .original_img{max-width:100%;display:inline-block;vertical-align:middle;
  636. margin-left:auto;margin-right:auto;max-width:100%;max-height:90vh;}
  637. .center_exp .post .original_img{display:block;}
  638. .original_img img,.original_img video{max-height:90vh;max-width:100%;}
  639. .p_row .original_img{margin-bottom:0;}
  640. .post_ref .original_img{margin:unset;max-width:unset;max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  641. .imbtn{display:block;contain:content;padding:0.25em;margin-bottom:0.5em;text-decoration:none;text-shadow:0px 0px 5px %white%;}
  642. .imbtn img{display:block;object-fit:cover;position:absolute;top:0;left:0;bottom:0;right:0;margin:auto;z-index:-1;
  643. min-width:100% !important;min-height:100% !important;filter:opacity(40%);}
  644. .imbtn:hover img{filter:opacity(20%) blur(0.1em);} .imbtn:hover{color:%black% !important;}
  645. header .imbtn{display:inherit;border:none;padding:0em;height:unset;height:unset;margin:0em;contain:unset;}
  646. header .imbtn:hover{border:none;color:%gray% !important;} header .imbtn img{display:none;}
  647. .b ul{font-size:1.4em;}
  648. no_pop{cursor:unset;}
  649. p{min-height:0.8em;}
  650. .bold,.bold *{font-weight:bold;}
  651. .footer_additional{display:inline-block;width:50%;vertical-align:text-top;white-space:normal;}
  652. .small_footer{background-color:%white%;padding-bottom:0.5em;position:sticky;bottom:0px;z-index:10;}
  653. .small_footer>div{overflow:auto;white-space:nowrap;}
  654. .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;}
  655. .top_post_hint{margin-left:1.5em;font-weight:bold;}
  656. .white{color:%white%;}
  657. .full_box{border:1px solid %black% !important;padding:0.3rem;overflow:auto;}
  658. .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;
  659. transition:background-size .2s ease;padding:0.5em;text-shadow:0px 0px 5px black;user-select:none;pointer-events:auto;}
  660. .image_nav_prev{left:0;justify-content:left;background:linear-gradient(to left, rgba(0,0,0,0), rgba(0,0,0,0.4));
  661. background-repeat:no-repeat;background-size:0% 100%;}
  662. .image_nav_prev:hover,.image_nav_next:hover{background-size:100% 100%;}
  663. .image_nav_next{right:0;justify-content:right;background:linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.2));
  664. background-repeat:no-repeat;background-size:0% 100%;transition:background-size .2s ease;background-position-x:100%;}
  665. .inquiry_buttons{position:fixed;left:0;right:25%;text-align:center;bottom:1em;margin:0 auto;width:max-content;
  666. background-color:rgba(0,0,0,0.5);z-index:110;padding:0.2em;padding-left:1em;padding-right:1em;
  667. border-radius:1em;box-shadow:0px 0px 5px;text-shadow:0px 0px 5px black;opacity:1;user-select:none;}
  668. .lr_buttons{background-color:rgba(0,0,0,0.5);padding:0.5em;padding-top:1em;padding-bottom:1em;
  669. border-radius:1em;box-shadow:0px 0px 5px;font-size:1.2rem;text-shadow:0px 0px 5px black;}
  670. .img_btn_hidden{opacity:0;transition:opacity 0.2s;}
  671. .special_alipay{background-color:#027aff;color:white;white-space:nowrap;
  672. font-family:sans-serif;font-weight:bold;border-radius:0.7em;font-size:0.75em;padding:0.25em;}
  673. .special_paypal{background-color:white;color:#253b80;white-space:nowrap;
  674. font-family:sans-serif;font-weight:bold;border-radius:2em;font-size:0.75em;
  675. padding:0.25em;padding-left:0.5em;padding-right:0.65em;font-style: italic;}
  676. .special_paypal_inner{color:#169bd7;}
  677. #waiting_bar{position:fixed;z-index:200;top:0;left:0;right:0;height:0.2em;background-color:%black%;transform:translate(-100%,0);
  678. animation:anim_loading 1s linear infinite;}
  679. @keyframes anim_loading{0%{transform:translate(-100%,0);} 100%{transform:translate(100%,0);}}
  680. .product_ref{width:32%;padding:0.2em!important;display:inline-block;text-align:center;vertical-align:top;margin-bottom:0.8em;}
  681. .product_thumb{max-height:11em;max-width:11em;display:inline-flex;margin-bottom:0.2em;background-color:%graybkg%;}
  682. .product_thumb img,{box-shadow:none;object-fit:contain;max-height:unset;max-width:unset;width:100%;margin:0 auto !important;}
  683. .product_ref p{margin-bottom:0.2em;text-align:left;}
  684. .post_preview .product_thumb{max-height:4em;max-width:6em;}
  685. .purchase_button{background-color:%black%;color:%white%;padding-left:0.5em;padding-right:0.5em;text-decoration:none;font-weight:bold;}
  686. .page_break{page-break-after:always;}
  687. .text_highlight,.text_highlight a,.text_highlight select{background-color:%black%;color:%white%;border:none;}
  688. .gray.text_highlight,.gray.text_highlight a,.gray.text_highlight select{background-color:%gray%;color:%white%;}
  689. .print_title{display:none;}
  690. .show_on_print{display:none;}
  691. .comment{font-size:0.9em;font-family:sans-serif;overflow:auto !important;width:100%;}
  692. .comment tbody tr:hover{box-shadow:none;}
  693. .comment table{border:none;}
  694. .comment li{display:list-item;list-style:'→';padding-left:0.3em;}
  695. .comment ul{padding-left:1em;}
  696. .comment ul li *{margin-bottom:0.5em;}
  697. .history li{display:list-item;list-style:disc;padding-left:0.3em;}
  698. .history li li{list-style:circle;}
  699. .history ul{padding-left:1em;}
  700. .history a{text-decoration:underline;}
  701. .history .list{overflow:auto;white-space:nowrap;}
  702. .diff_table{table-layout:fixed;}
  703. .diff_table thead{font-size:0.9em;text-align:center;}
  704. .diff_table tbody pre{font-size:0.9rem;white-space:pre-line;}
  705. .diff_table td{vertical-align:top;}
  706. .omittable_title{display:block;width:100%;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
  707. .wayback_close{float:right;}
  708. .wayback_expand{display:inline;}
  709. .post_selecting .post *{pointer-events:none;}
  710. .post_selected{background-color:%graybkg%;}
  711. .small_pad{padding:0.2em;padding-top:0.1em;padding-bottom:0.1em;}
  712. .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%;}
  713. .wscroll:target{display:block;} .post_ref .wscroll{display:none !important;}
  714. .wayback_link{display:inline;}
  715. .imd{object-fit:cover;width:100%;}
  716. .center_exp .imd{width:60%;}
  717. #here_buttons{display:contents;}
  718. .here_buttons_inner{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;max-height:100%;max-width:100%;}
  719. .here_btn{position:absolute;z-index:110;transform:translate(-50%,-50%);
  720. width:2em;height:2em;display:block;border:1px solid %black%;background-color:rgba(0,0,0,0.5);}
  721. .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;}
  722. @media screen and (max-width:1000px) and (min-width:666px){
  723. .left{width:35%;}
  724. .center,.center_wide{width:65%;}
  725. .center_wide .p_thumb{height:8rem;}
  726. .right{display:none;}
  727. .post_width{width:calc(100% - 1.5rem);padding-left:0.2em;}
  728. .post_width_big{left:0;width:100%;}
  729. .hidden_on_wide{display:unset;}
  730. .pop_right{width:30%;}
  731. .pop_right_big{width:40%;}
  732. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  733. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  734. @keyframes pop_slide_in_big{0%{right:-40%;}100%{right:0%;}}
  735. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-40%;}}
  736. .big_side_box{width:35%;}
  737. .big_image_box{width:65%;}
  738. .inquiry_buttons{right:35%;}
  739. .table_top{left:calc(-50% - 1.7em);width:calc(154% + 0.5em);}
  740. .post_dummy > *{width:80%;max-width:55rem;}
  741. .center_exp .imd{width:80%;}
  742. .here_btn{width:1.5em;height:1.5em;}
  743. }
  744. @media screen and (max-width:666px){
  745. html{font-size:16px;}
  746. .hidden_on_mobile{display:none !important;}
  747. .block_on_mobile{display:block !important;}
  748. .hidden_on_desktop{display:unset;}
  749. .hidden_on_wide{display:unset;}
  750. header ul{display:block;}
  751. header li{display:block;}
  752. header li::before{content:''}
  753. header::before{box-shadow:none;display:none;}
  754. .small_footer::before{box-shadow:none;display:none;}
  755. .left{position:relative;width:100%;position:relative;top:unset;height:unset;min-height:80vh;padding-right:0;display:block;}
  756. .center,.center_wide,.center_full{position:relative;left:0;top:0;width:100%;padding-left:0;display:block;}
  757. .center_wide .p_thumb{height:6rem;}
  758. .pop_right,.pop_right_big{top:unset;right:0;bottom:0;left:0;width:100%;}
  759. .pop_right{height:30%;}
  760. .pop_right_big{height:70%;}
  761. @keyframes pop_slide_in{0%{bottom:-30%;}100%{bottom:0%;}}
  762. @keyframes pop_slide_out{0%{bottom:0%;}100%{bottom:-30%;}}
  763. @keyframes pop_slide_in_big{0%{bottom:-70%;}100%{bottom:0%;}}
  764. @keyframes pop_slide_out_big{0%{bottom:0%;}100%{bottom:-70%;}}
  765. .big_image_box{position:fixed;top:0;bottom:8.5rem;left:0;right:0;width:100%;}
  766. .side_box_mobile_inner{background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(1,1,1,0.9) 20%);
  767. transition:none;background-size:100% 100%;padding:0.5rem;padding-bottom: 5em;}
  768. .side_box_mobile_inner:hover{background-size:100% 100%;}
  769. .big_side_box{position:fixed;top:0;bottom:0;right:0;left:0;width:100%;
  770. height:unset;padding:0;padding-top:calc(100vh - 8.5rem);background:none;}
  771. .p_thumb{height:3rem;}
  772. .center .post{padding-right:0rem;padding-left:0rem;}
  773. .post .p_thumb img,.post .p_thumb video{max-height:3rem;}
  774. .page,.page_gallery{padding:0.2em;padding-top:0;}
  775. header{padding-top:0.3em;}
  776. .toc_button{top:0.3em;}
  777. .small_footer{padding-bottom:0.3em;}
  778. .footer_additional{display:block;width:100%;}
  779. .album_hint{display:block;font-size:1rem;}
  780. .image_nav{position:absolute !important;}
  781. .image_nav_prev,.image_nav_next{width:25%;}
  782. .image_nav_prev:hover,.image_nav_next:hover{background-size:0% 100%;color:%black% !important;}
  783. .inquiry_buttons{position:relative;left:unset;right:unset;text-align:left;bottom:unset;margin:unset;width:unset;
  784. background-color:unset;z-index:unset;padding:unset;padding-left:unset;padding-right:unset;
  785. border-radius:unset;box-shadow:unset;text-shadow:unset;}.img_btn_hidden{opacity:1;}
  786. .lr_buttons{background-color:unset;padding:unset;padding-top:unset;padding-bottom:unset;
  787. border-radius:unset;box-shadow:unset;font-size:1.3rem;text-shadow:unset;}
  788. .opt_compact,.ref_compact{line-break:anywhere;}
  789. .post_width,.post_width_big{overflow:auto;}
  790. .table_top{left:unset;width:100%;overflow:auto;}
  791. table img{max-width:30vw !important;}
  792. .product_ref{width:100%;display:block;}
  793. .post_dummy > *{width:100%;max-width:25rem;}
  794. .sticky_title{top:1.2em;}
  795. .small_footer{position:relative;}
  796. #upload_selector{width:100%;}
  797. .focused_post{padding:0.3rem !important;}
  798. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 10em);}
  799. .wayback_expand{display:block;text-align:center;}
  800. .wayback_link{display:block;}
  801. .center_exp{display:block;width:100%;margin:0 auto;padding-bottom:1em;}
  802. .center_exp .post{overflow:auto;}
  803. .center_exp .imd{width:100%;}
  804. .here_btn{width:1.2em;height:1.2em;}
  805. .exp_h_f{height:unset !important;}
  806. .exp_f{margin-bottom:1em;}
  807. }
  808. @media print{
  809. header b,.small_footer b{font-weight:normal;}
  810. header{display:table-header-group;} .main{display:table-row-group;} .small_footer{text-align:right;}
  811. header::before{box-shadow:none;display:none;} header::after{display:block;height:1em;content:' ';}
  812. .small_footer::before{box-shadow:none;display:block;height:1em;position:relative;}
  813. body,footer,header,.small_footer,a,.clean_a,.invert_a,.clean_a a,.invert_a a{background:none;color:black;}
  814. .post *,.post_dummy *{margin-bottom:0em}
  815. .p_row,.post table,.post_width>img,.post_width_big>img,.post_ref>img,.post_ref>.original_img,
  816. .post_width>.original_img,.post_width_big>.original_img,.post pre{margin-top:0.5rem;margin-bottom:0.5rem;text-indent:0;}
  817. pre{white-space:pre-wrap;line-break:anywhere;}
  818. .post p{line-height:1.3;text-indent:2em;} .product_ref p {text-indent:0;}
  819. table img{margin:0 !important;}
  820. .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;}
  821. .post ul,.post ol{margin:1rem;margin-left:1.4rem;margin-right: 0rem;}
  822. table{border-bottom:2px solid black;border-top:2px solid black;}
  823. table img{max-width:5em;max-width:8em !important;max-height:8em !important;}
  824. thead{box-shadow:inset 0 -1px 0 0px black;background:none;}
  825. .post_width,.post_width_big{overflow:clip;left:0;width:100%;padding-left:0em;}
  826. .post h1{margin-top:0.5rem;}
  827. .post h2{font-size:1.8em;margin:2.5em auto 0;}.list h2,.opt_compact h2,.ref_compact h2{margin:0 !important;}
  828. .post h3{font-size:1.5em;margin:1.5em auto 0;}.list h3,.opt_compact h3,.ref_compact h4{margin:0 !important;}
  829. .post h4{font-size:1.1em;margin:0.5em auto 0;}.list h4,.opt_compact h3,.ref_compact h4{margin:0 !important;}
  830. .post .post{margin-bottom:0.5rem;margin-top:0.5rem;}
  831. .gray,.gray a,.deleted_post{color:rgba(0,0,0,0.5);}
  832. .left,.right{display:none;}
  833. .center, .center_wide, .center_full{width:100%;padding:0;display:block;font-size:16px;line-height:1.3}
  834. hr{border:1px solid black;}
  835. .post_box_top{display:none;}
  836. .opt_compact .post_access,.ref_compact .post_access{border-right:none;display:inline;}
  837. .text_highlight,.text_highlight a,.gray.text_highlight,.gray.text_highlight a,.purchase_button{background-color:lightgray;color:black;}
  838. .focused_post{border:none;font-size:1em;padding:0 !important;}
  839. .hidden_on_print{display:none;}
  840. .print_column{column-count:2;margin-top:0.5rem;margin-bottom:0.5rem;}
  841. .post_access{display:none;}
  842. .opt_compact{margin-left:0;}
  843. .post .post_ref{padding-left:1.4rem;}
  844. .opt_compact .post_width{left:1.4rem;width:calc(100% - 1.4rem);margin-left:0;}
  845. .print_title{column-span:all;display:block;margin-top:2em;margin-bottom:0.5rem;font-size:1.2em;}
  846. .print_title:first-of-type{margin-top:1em;}
  847. .print_title+.post h1:first-of-type{display:none;}
  848. .opt_compact h1:first-of-type,.ref_compact h1:first-of-type{display:unset;}
  849. .table_top{position:relative;left:0;width:100%;background:none;z-index:1;box-shadow:none;}
  850. .header_nav{display:none;}
  851. .show_on_print{display:block;}
  852. blockquote{border-left:2px solid black;}
  853. .footer_additional{display:none;}
  854. .small_footer{margin-top:1rem;}
  855. .page{display:table;width:100%;}
  856. .page_selector{display:none;}
  857. .p_thumb{height:4rem;margin-bottom:0.25rem;}
  858. .post .p_thumb img,.post .p_thumb video{max-height:4rem;}
  859. .sticky_title{box-shadow:none;}
  860. .center_wide .p_thumb{display:inline-flex;height:5.8rem;width:5.8rem;margin-right:0;}
  861. .center_wide .p_row{display:block;}
  862. .interesting_tbody{background:none;}
  863. .interesting_tbody img{display:none !important;}
  864. .imd{margin-top:0.5em;margin-bottom:0.5em;line-height:0px;}
  865. .p_row .imd{margin-top:0em;margin-bottom:0em;}
  866. }
  867. ";
  868. $this->style=preg_replace('/%white%/','#231a0d',$this->style);
  869. $this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
  870. $this->style=preg_replace('/%gray%/','#ac7843',$this->style);
  871. $this->style=preg_replace('/%graybkg%/','#39270e',$this->style);
  872. $this->style=preg_replace('/%lightopbkg%/','#daae8010',$this->style);
  873. $this->style=preg_replace('/%lighterbkg%/','#675340',$this->style);
  874. $this->style=preg_replace('/%focusedbkg%/','#482f0c',$this->style);
  875. $f = fopen('styles/main.css','w');
  876. fwrite($f,$this->style);
  877. fclose($f);
  878. }
  879. function GiveSafeEMail(){
  880. return preg_replace('/\./u','[dot]',preg_replace('/\@/u','[at]',$this->EMail));
  881. }
  882. function &FindImage($name, $loose=false){ if(!isset($name) || !$name){ return $this->NULL_IMAGE; }
  883. if(isset($this->Images[0])) foreach($this->Images as &$im){
  884. if($loose) { if(preg_match('/'.preg_quote($name).'/u',$im['name'])) return $im; }
  885. else { if($im['name']==$name) return $im; }
  886. }
  887. return $this->NULL_IMAGE;
  888. }
  889. function &GiveImageInHere($rand=false){
  890. $this->ReadImages(); $this->DetectPageType();
  891. $album = $this->PageType=='here'?$this->HereAlbum:$this->ExpAlbum;
  892. if(!isset($album) || !$album){
  893. if(isset($this->Images[0])) return $this->Images[0]; else return $this->NULL_IMAGE; }
  894. $imlist=[]; $imlist_fallback=[];
  895. if(isset($this->Images[0])){
  896. foreach($this->Images as &$im){
  897. if(isset($im['galleries'][0]) && in_array($album,$im['galleries']) && $this->CanShowImage($im)){
  898. if(!$rand) return $im; else {
  899. $imlist_fallback[] = $im;
  900. if(!in_array($im['name'],$this->VisitedHere)) $imlist[] = $im;
  901. }
  902. }
  903. }
  904. }
  905. if(!$rand || !isset($imlist_fallback[0])) return $this->NULL_IMAGE;
  906. if(sizeof($imlist)){
  907. $r = random_int(0, sizeof($imlist)-1);
  908. return $imlist[$r];
  909. }else{
  910. $r = random_int(0, sizeof($imlist_fallback)-1);
  911. return $imlist_fallback[$r];
  912. }
  913. }
  914. function ImageTitle($im){
  915. $imtitle = (isset($im)&&isset($im['title']))?$im['title']:NULL;
  916. if(isset($im['parent'])&&($imp = &$this->FindImage($im['parent'],true))&&isset($imp['title'])){ $imtitle=$imp['title']; }
  917. return $imtitle;
  918. }
  919. function ImageHasHere(&$im, $here_name){
  920. if(!isset($im['here'])||!isset($im['here'][0])) return false;
  921. foreach($im['here'] as $h) { if($h[0] == $here_name) return true; } return false;
  922. }
  923. function ReadImages($clear_non_exist = false){
  924. $path = 'images/list.md';
  925. if($this->DoneReadImages){ return; }
  926. if(!file_exists($path)){ $f = fopen($path,'w'); fflush($f); fclose($f); }
  927. $c = file_get_contents($path);
  928. if(preg_match_all('/GALLERY\s+(\S+)(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  929. $g=[]; $g['name']=$m[1];//$g['count']=0;
  930. if(preg_match('/FEATURED([^;]*?);/u', $m[2], $arg)){ $g['featured']=true; }
  931. if(preg_match('/EXPERIMENTAL([^;]*?);/u', $m[2], $arg)){ $g['experimental']=true; }
  932. $this->Galleries[] = $g;
  933. }
  934. if(preg_match_all('/^-\s*([^;]+)\s*?;\s*?(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  935. $name = trim($m[1]);
  936. $item = []; $item['file'] = 'images/'.$name; $item['name'] = $name;
  937. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  938. if(preg_match('/REFS\s+([^;]*);/u',$m[2],$refs) && preg_match_all('/[0-9]{14}/u',$refs[1],$rs, PREG_SET_ORDER)){
  939. $item['refs']=[];
  940. foreach($rs as $r){ if(!in_array($r[0], $item['refs'])) $item['refs'][] = $r[0]; }
  941. }
  942. if(preg_match('/GAL\s+([^;]*);/u',$m[2],$gals) && preg_match_all('/(\S+)/u',$gals[1],$ga, PREG_SET_ORDER)){
  943. $item['galleries']=[];
  944. foreach($ga as $g){ if(!in_array($g[0], $item['galleries'])) $item['galleries'][] = $g[0]; }
  945. }
  946. if(preg_match('/PRODUCT\s+([^;]*);/u',$m[2],$product)){ $item['product']=$product[1]; }
  947. if(preg_match('/PARENT\s+([^;]*);/u',$m[2],$parent)){ $item['parent']=$parent[1]; }
  948. if(preg_match('/TITLE\s+([^;]*);/u',$m[2],$title)){ $item['title']=$title[1]; }
  949. if(preg_match('/HERE\s+([^;]*);/u',$m[2],$heres) && preg_match_all('/(\S+)-(\S+)-(\S+)/u',$heres[1],$here, PREG_SET_ORDER)){
  950. $item['here']=[];
  951. foreach($here as $h){ if(!$this->ImageHasHere($item, $h[1])) $item['here'][] = [$h[1],$h[2],$h[3]]; }
  952. }
  953. if(preg_match('/\.mp4/u',$item['name'])){
  954. $item['video']='video/mp4';
  955. }
  956. $this->Images[] = $item;
  957. }
  958. $files = array_merge([],glob('images/*.jpg'));
  959. $files = array_merge($files,glob('images/*.jpeg'));
  960. $files = array_merge($files,glob('images/*.png'));
  961. $files = array_merge($files,glob('images/*.gif'));
  962. $files = array_merge($files,glob('images/*.mp4'));
  963. if(isset($files[0]))foreach($files as $file) {
  964. if(preg_match('/[0-9]{14,}\.(jpg|jpeg|gif|png|mp4)/u', $file, $m)) {
  965. $name = trim($m[0]);
  966. if(!$this->FindImage($name)){
  967. $item = []; $item['name']=$name; $item['file'] = 'images/'.$name;
  968. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  969. $this->Images[] = $item;
  970. }
  971. }
  972. }
  973. if($clear_non_exist){
  974. if(isset($this->Images[0]) && isset($files[0])){
  975. foreach($this->Images as &$im){
  976. if(!in_array($im['file'],$files)){
  977. $im['deleted'] = 1;
  978. }
  979. }
  980. }
  981. }
  982. function cmpf($a, $b){
  983. if ($a['name'] == $b['name']) return 0;
  984. return (($a['name'] > $b['name']) ? 1 : -1);
  985. }
  986. function cmpaf($a, $b){
  987. if ($a['name'] == $b['name']) return 0;
  988. return ($a['name'] > $b['name']) ? -1 : 1;
  989. }
  990. if(isset($this->Galleries[0]))usort($this->Galleries,"cmpf");
  991. if(isset($this->Images[0]))usort($this->Images,"cmpaf");
  992. $this->DoneReadImages = 1;
  993. }
  994. function WriteImages(){
  995. if(isset($this->WayBack)) return;
  996. $path = 'images/list.md';
  997. $f = fopen($path,'w');
  998. if(isset($this->Galleries[0]))foreach($this->Galleries as &$g){
  999. if(isset($g['deleted'])) continue;
  1000. fwrite($f,'GALLERY '.$g['name']);
  1001. if(isset($g['featured']) && $g['featured']!=false) { fwrite($f,' FEATURED;'); }
  1002. if(isset($g['experimental']) && $g['experimental']!=false) { fwrite($f,' EXPERIMENTAL;'); }
  1003. fwrite($f, PHP_EOL);
  1004. }
  1005. if(isset($this->Images[0]))foreach($this->Images as &$im){
  1006. if(isset($im['deleted'])) continue;
  1007. fwrite($f, "- ".$im['name'].'; ');
  1008. if(isset($im['refs']) && isset($im['refs'][0])){ fwrite($f, 'REFS '.implode(" ",$im['refs'])."; "); }
  1009. if(isset($im['galleries']) && isset($im['galleries'][0])){ fwrite($f, 'GAL '.implode(" ",$im['galleries'])."; "); }
  1010. if(isset($im['product']) && $im['product']!=''){ fwrite($f, 'PRODUCT '.$im['product']."; "); }
  1011. if(isset($im['parent']) && $im['parent']!=''){ fwrite($f, 'PARENT '.$im['parent']."; "); }
  1012. if(isset($im['title']) && $im['title']!=''){ fwrite($f, 'TITLE '.$im['title']."; "); }
  1013. if(isset($im['here']) && $im['here']!=''){ fwrite($f, 'HERE ');
  1014. foreach($im['here'] as $here){ fwrite($f, implode('-',$here).' '); } fwrite($f, '; ');
  1015. }
  1016. fwrite($f, PHP_EOL);
  1017. }
  1018. fflush($f);
  1019. fclose($f);
  1020. }
  1021. function EditImage($name, $link_gallery, $do_remove = false, $product_link=NULL, $rename=NULL, $parent=NULL){
  1022. if(!($im = &$this->FindImage($name))) return;
  1023. if(isset($link_gallery)){
  1024. if($do_remove){
  1025. if(!isset($im['galleries']) || !isset($im['galleries'][0])) return;
  1026. foreach($im['galleries'] as $key => $g){ if ($g==$link_gallery) unset($im['galleries'][$key]); }
  1027. $im['galleries'] = array_merge($im['galleries']);
  1028. }else{
  1029. if(!isset($im['galleries'])) $im['galleries']=[];
  1030. foreach($im['galleries'] as &$g){ if ($g==$link_gallery) return; }
  1031. $im['galleries'][]=$link_gallery;
  1032. }
  1033. }
  1034. if(isset($product_link)){
  1035. if($product_link!=''){$im['product']=$product_link;}
  1036. else{unset($im['product']);}
  1037. }
  1038. if(isset($rename) && $rename!=$im['name']){
  1039. $ext=pathinfo($im['file'],PATHINFO_EXTENSION);
  1040. rename($im['file'], 'images/'.$rename.'.'.$ext);
  1041. if(isset($im['thumb'])) rename($im['thumb'], 'images/thumb/'.$rename.'.'.$ext);
  1042. $im['name'] = $rename.'.'.$ext;
  1043. }
  1044. if(isset($parent) && $parent!=$im['parent']){
  1045. if($parent==''){ unset($im['parent']); }
  1046. else{ $im['parent'] = $parent; }
  1047. }
  1048. $this->NeedWriteImages = 1;
  1049. }
  1050. function RegenerateThumbnails(){
  1051. $glob = glob('images/*.jpg');
  1052. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1053. foreach($glob as $file) {
  1054. $thumb_destination = 'images/thumb/'.basename($file);
  1055. $img = new Imagick($file); $geo=$img->getImageGeometry();
  1056. $width=$geo['width']; $height=$geo['height'];
  1057. $lim=400;
  1058. $scale = $lim / min($width,$height);
  1059. if($scale<1){
  1060. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1061. }
  1062. $img->setImageFormat('jpeg');
  1063. $img->setImageCompressionQuality(90);
  1064. $img->writeImage($thumb_destination);
  1065. }
  1066. }
  1067. function CompressImage($source, $destination, $thumb_destination, $quality, $sizelim, $abs_max) {
  1068. $img = new Imagick($source); $geo=$img->getImageGeometry(); $img2 = clone $img;
  1069. $width=$geo['width']; $height=$geo['height'];
  1070. $lim=400;
  1071. $scale = $lim / min($width,$height);
  1072. if($scale<1){
  1073. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1074. }
  1075. $img->setImageFormat('jpeg');
  1076. $img->setImageCompressionQuality($quality);
  1077. $img->writeImage($thumb_destination);
  1078. $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
  1079. if($scale<1){
  1080. $img2->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.5);
  1081. }
  1082. $img2->setImageFormat('jpeg');
  1083. $img2->setImageCompressionQuality($quality);
  1084. $img2->writeImage($destination);
  1085. }
  1086. function DoUpload(){
  1087. if(!isset($_FILES['upload_file_name'])) return 0;
  1088. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1089. if($_FILES['upload_file_name']['error']>0){
  1090. echo"file upload err code ".$_FILES['upload_file_name']['error']; exit;
  1091. return -1;
  1092. }else{
  1093. $ext=pathinfo($_FILES['upload_file_name']['name'],PATHINFO_EXTENSION);
  1094. if(!in_array($ext,['jpg','jpeg','png','gif','mp4'])) return 0;
  1095. $fp = fopen('.la_lock',"w");
  1096. while (!flock($fp, LOCK_EX| LOCK_NB)){
  1097. usleep(10000);
  1098. }
  1099. $num=date('YmdHis'); $replace=0;
  1100. if(isset($_POST['image_replace_button']) && isset($_GET['pic']) && preg_match('/([0-9]{14,})/u',$_GET['pic'],$mim)){
  1101. $num = $mim[1]; $replace=1;
  1102. }
  1103. $base = 'images/'.$num;
  1104. $thumb = 'images/thumb/'.$num;
  1105. if($ext=='png') $ext='jpg';
  1106. $final_path = $base.'.'.$ext; $final_thumb = $thumb.'.'.$ext; $i=0;
  1107. if(!$replace) while(file_exists($final_path)){
  1108. $final_path = $base.strval($i).'.'.$ext; $final_thumb = $thumb.strval($i).'.'.$ext; $i++;
  1109. }
  1110. if($ext!='gif' && $ext!='mp4'){
  1111. $compress = (isset($_GET['compress'])&&$_GET['compress']);
  1112. $this->CompressImage($_FILES['upload_file_name']['tmp_name'], $final_path, $final_thumb, 90,
  1113. $compress?800:1920, $compress?1920:2560);
  1114. }else{
  1115. move_uploaded_file($_FILES['upload_file_name']['tmp_name'], $final_path);
  1116. }
  1117. flock($fp, LOCK_UN);
  1118. fclose($fp);
  1119. $this->ReadImages(true);
  1120. $this->WriteImages();
  1121. echo '<uploaded>'.pathinfo($final_path,PATHINFO_BASENAME)."</uploaded>";
  1122. if(isset($_POST['image_replace_button'])){
  1123. header('Location: '.$_SERVER['REQUEST_URI']);exit;
  1124. }
  1125. exit;
  1126. return 1;
  1127. }
  1128. return 0;
  1129. }
  1130. function &GetGallery($name){
  1131. if(isset($this->Galleries[0])) foreach($this->Galleries as &$g){
  1132. if($g['name'] == $name) return $g;
  1133. }
  1134. return $this->NULL_GALLERY;
  1135. }
  1136. function EditGallery($name, $new_name=null, $delete=false, $do_rw=true, $set_featured=null, $set_experimental=null){
  1137. $this->ReadImages();
  1138. $gallery = &$this->GetGallery($name);
  1139. if(!isset($gallery)){
  1140. if(!isset($new_name) || preg_match('/main|trash|\s/u',$new_name))return;
  1141. $g = []; $g['name']=$new_name;
  1142. $this->Galleries[]=$g;
  1143. }else{
  1144. if(isset($new_name)) {
  1145. if(preg_match('/main|trash|\s/u',$new_name))return;
  1146. $gallery['name'] = $new_name;
  1147. foreach ($this->Images as &$im){
  1148. if(isset($im['galleries'])&&isset($im['galleries'][0]))foreach($im['galleries'] as &$g){
  1149. if($g == $name){ $g = $new_name; }
  1150. }
  1151. }
  1152. }
  1153. //if(isset($count)) $gallery['count'] = $count;
  1154. if(isset($delete) && $delete) $gallery['deleted'] = true;
  1155. if(isset($set_featured)) $gallery['featured'] = $set_featured;
  1156. if(isset($set_experimental)) $gallery['experimental'] = $set_experimental;
  1157. }
  1158. if($do_rw) { $this->NeedWriteImages = 1; }
  1159. }
  1160. function ClearData(){
  1161. $this->Posts = [];
  1162. $this->Threads = [];
  1163. $this->Images = [];
  1164. $this->Archive = [];
  1165. $this->ArchiveHandles = [];
  1166. }
  1167. function InsertArchivePost(&$post){
  1168. $a = NULL;
  1169. if(($a = &$this->GetArchiveHandle($post['id']))==$this->NULL_POST){
  1170. $ah = []; $ah['id'] = $post['id']; $ah['list'] = [];
  1171. $this->ArchiveHandles[] = &$ah; $a = &$ah;
  1172. }
  1173. $a['list'][] = $post;
  1174. $this->Archive[] = $post;
  1175. }
  1176. function ReadArchiveFromFile($path){
  1177. if(!file_exists($path)){
  1178. return;
  1179. }
  1180. $c = file_get_contents($path);
  1181. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1182. foreach($matches as $m){
  1183. $post = [];
  1184. $post['id'] = $m[1];
  1185. $post['content'] = trim($m[3]);
  1186. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1187. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1188. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1189. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1190. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1191. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1192. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1193. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1194. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1195. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1196. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1197. if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
  1198. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1199. foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
  1200. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1201. $post['merged_into'] = [trim($n[1]),trim($n[2])];
  1202. }
  1203. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1204. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1205. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1206. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1207. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1208. }
  1209. $this->InsertArchivePost($post);
  1210. }
  1211. }
  1212. }
  1213. function SortArchive(){
  1214. $cmpac = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1215. $cmpap = function($a, $b){ if ($a['id'] == $b['id']) return ((($a['version'] > $b['version']) ? 1 : -1));
  1216. return (($a['id'] > $b['id']) ? 1 : -1);
  1217. };
  1218. if(isset($this->Archive[0])){
  1219. usort($this->Archive,$cmpap);
  1220. $year_begin = substr($this->Archive[0]['id'],0,4);
  1221. $this->YearBegin = ($year_begin<$this->YearBegin)?$year_begin:$this->YearBegin;
  1222. }
  1223. if(isset($this->ArchiveHandles[0])){
  1224. usort($this->ArchiveHandles,$cmpac);
  1225. foreach($this->ArchiveHandles as &$a){
  1226. if(isset($a['list'])){ usort($a['list'],$cmpap);
  1227. $last_valid=NULL;
  1228. foreach($a['list'] as &$ver){ $ver['archive']= &$a;
  1229. if(isset($ver['merged_thread'])){ $ver['content']=$last_valid; }
  1230. else{ $last_valid = $ver['content']; } }
  1231. if(isset($a['list'][0]['version'])&&$a['list'][0]['version']>$a['list'][0]['id']){ /* if early versions missing. */
  1232. $origin=$a['list'][0]; $origin['version']=$origin['id']; array_unshift($a['list'], $origin);
  1233. }
  1234. }
  1235. if(($p = &$this->GetPost($a['id'],true))!=NULL){
  1236. $p['archive'] = &$a;
  1237. }
  1238. }
  1239. }
  1240. }
  1241. function ReadPostsFromFile($path){
  1242. if(!file_exists($path)){
  1243. $f = fopen($path,'w');
  1244. fclose($f);
  1245. }
  1246. $c = file_get_contents($path);
  1247. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1248. foreach($matches as $m){
  1249. $post = [];
  1250. $post['id'] = $m[1];
  1251. $post['real_content'] = trim($m[3]);
  1252. $post['content'] = &$post['real_content'];
  1253. if(preg_match('/COMMENT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['comment_to'] = $n[1];
  1254. if(preg_match('/EMAIL\s+([^;]+)\s*;/u', $m[2], $n)) $post['email'] = $n[1];
  1255. if(preg_match('/NAME\s+([^;]+)\s*;/u', $m[2], $n)) $post['name'] = $n[1];
  1256. if(preg_match('/LINK\s+([^;]+)\s*;/u', $m[2], $n)) $post['link'] = $n[1];
  1257. if(preg_match('/IP\s+([^;]+)\s*;/u', $m[2], $n)) $post['ip'] = $n[1];
  1258. if(preg_match('/NEXT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['next'] = $n[1];
  1259. if(preg_match('/PREV\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['prev'] = $n[1];
  1260. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1261. if(preg_match('/MDEL\s*;/u', $m[2])) $post['mark_delete'] = True;
  1262. if(preg_match('/MVAL\s*([^;]+);/u', $m[2], $n)) $post['mark_value'] = trim($n[1]);
  1263. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1264. if(preg_match('/REFS\s*([^;]+);/u', $m[2], $ma)){
  1265. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1266. foreach($links as $l){ $entries[] = $l[1]; } $post['refs'] = $entries; } }
  1267. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1268. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1269. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1270. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1271. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1272. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1273. if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
  1274. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1275. foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
  1276. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1277. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1278. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1279. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1280. $post['merged_into'] = [trim($n[1]),trim($n[2])]; }
  1281. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1282. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1283. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1284. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1285. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1286. }
  1287. if(isset($post['mark_value']) && $post['mark_value']==5){
  1288. $post['product']=[];
  1289. }
  1290. /* marks add here */
  1291. $this->Posts[] = $post;
  1292. if(isset($post['comment_to']) && ($target_post = &$this->GetPost($post['comment_to'],true))){
  1293. if(!isset($target_post['comments']) || !isset($target_post['comments'][0])) $target_post['comments']=[];
  1294. $target_post['comments'][]=&$this->Posts[count($this->Posts) - 1];
  1295. }
  1296. }
  1297. }
  1298. }
  1299. function SortPosts($wayback=false){
  1300. $cmpp = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1301. $sortlist = &$this->Posts;
  1302. if($wayback) $sortlist = &$this->WaybackPosts;
  1303. if(isset($sortlist[0])){
  1304. usort($sortlist,$cmpp);
  1305. $this->YearEnd = substr($this->TIME_STRING,0,4);
  1306. $this->YearBegin = substr($sortlist[0]['id'],0,4);
  1307. }
  1308. }
  1309. function ReadPosts(){
  1310. if ((!file_exists('la_config.md') || is_readable('la_config.md') == false) ||
  1311. (!file_exists('la_config.php') || is_readable('la_config.php') == false) ||
  1312. (!is_dir('posts') || is_readable('posts') == false) ||
  1313. (!is_dir('archive') || is_readable('archive') == false) ||
  1314. (!is_dir('images') || is_readable('images') == false) ||
  1315. (!is_dir('styles') || is_readable('styles') == false)){
  1316. $this->Install();
  1317. }
  1318. if($this->DoneReadPosts){ return; }
  1319. $file_list = [];
  1320. $glob = glob('posts/*');
  1321. foreach($glob as $file) {
  1322. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1323. $file_list[] = $file;
  1324. }
  1325. }
  1326. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1327. foreach($file_list as $f) {
  1328. $this->ReadPostsFromFile($f);
  1329. }
  1330. $this->SortPosts();
  1331. $this->DetectThreads();
  1332. $this->DoneReadPosts=1;
  1333. }
  1334. function UpdatePostRefsForWayback(){
  1335. if(!isset($this->WayBack)) return;
  1336. if(isset($this->Images[0])) foreach($this->Images as &$i){ unset($i['refs']); }
  1337. if(!isset($this->WaybackPosts[0])) return;
  1338. foreach($this->WaybackPosts as &$p){ unset($p['refs']); }
  1339. foreach($this->WaybackPosts as &$p){
  1340. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $r){
  1341. $pr = &$this->GetPost($r); if(isset($pr)){
  1342. if(!isset($pr['refs'])) $pr['refs']=[];
  1343. if(!in_array($p['id'],$pr['refs'])){ $pr['refs'][] = $p['id']; }
  1344. }
  1345. }
  1346. if(isset($p['hasi']) && isset($p['hasi'][0])) foreach($p['hasi'] as $r){
  1347. $ir = &$this->FindImage($r); if(isset($ir)){
  1348. if(!isset($ir['refs'])) $ir['refs']=[];
  1349. if(!in_array($p['id'],$ir['refs'])){ $ir['refs'][] = $p['id'];}
  1350. }
  1351. }
  1352. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1353. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1354. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$p['id']; }
  1355. }
  1356. }
  1357. }
  1358. function ReadArchive(){
  1359. if (!is_dir('archive') || is_readable('archive') == false){ $this->Install(); }
  1360. if ($this->DoneReadArchive) return;
  1361. $file_list = []; $glob = glob('archive/*');
  1362. foreach($glob as $file) {
  1363. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1364. $file_list[] = $file;
  1365. }
  1366. }
  1367. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1368. foreach($file_list as $f) {
  1369. $this->ReadArchiveFromFile($f);
  1370. }
  1371. $this->SortArchive();
  1372. $this->DoneReadArchive=1;
  1373. $this->UpdateThreadForWayback();
  1374. $this->UpdatePostRefsForWayback();
  1375. }
  1376. function GetThreadForPost(&$post){
  1377. if(isset($post['tid'])) return;
  1378. $th = []; $iterp = NULL;
  1379. $post['tid'] = &$th; $th['first'] = &$post; $th['last'] = &$post;
  1380. if(!(isset($post['prev']) || isset($post['next']))) { $this->Threads[] = &$th; return; }
  1381. if(isset($post['prev']))for($p = $post['prev']; $p!=NULL; $p = $iterp){
  1382. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1383. $np['tid'] = &$th;
  1384. $th['first'] = &$np;
  1385. $iterp = isset($np['prev'])?$np['prev']:NULL;
  1386. }
  1387. if(isset($post['next']))for($p = $post['next']; $p!=NULL; $p = $iterp){
  1388. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1389. $np['tid'] = &$th;
  1390. $th['last'] = &$np;
  1391. $iterp = isset($np['next'])?$np['next']:NULL;
  1392. }
  1393. if(isset($th['first']['mark_value'])){
  1394. if($th['first']['mark_value']==6) $th['exp'] = true;
  1395. else if($th['first']['mark_value']==7) $th['slf'] = true;
  1396. }
  1397. if($th['first'] == $th['last']){ unset($post['tid']); return; }
  1398. $this->Threads[] = &$th;
  1399. }
  1400. function IdentifyThreadCategory(&$th,&$first_post){
  1401. unset($th['categories']);unset($th['interesting']);unset($th['reversed']);
  1402. if(preg_match('/^\s*\@(.*?)$/mu',$first_post['content'],$m)){
  1403. $first_post['categories']=[]; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1404. foreach($matches as $ma){ $first_post['categories'][] = $ma[1]; }
  1405. }
  1406. if(isset($th) && $th){ $th['categories'] = &$first_post['categories']; }
  1407. }
  1408. if(preg_match('/\{\s*WIDE\s*\}/imu',$first_post['content'],$m)){ $first_post['wide'] = true; }
  1409. if(preg_match('/\{\s*NO_TIME\s*\}/imu',$first_post['content'],$m)){ $first_post['no_time'] = true; }
  1410. if(preg_match('/\{\s*HEADER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['header'] = trim($m[1]); }
  1411. if(preg_match('/\{\s*FOOTER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['footer'] = trim($m[1]); }
  1412. if(!isset($th)) return;
  1413. if(isset($first_post['wide'])) $th['wide']=$first_post['wide'];
  1414. if(isset($first_post['header'])) $th['header']=$first_post['header'];
  1415. if(isset($first_post['footer'])) $th['footer']=$first_post['footer'];
  1416. if(isset($first_post['no_time'])) $th['no_time']=$first_post['no_time'];
  1417. if(preg_match('/\{\s*INTERESTING\s+(.*?)\}/imu',$first_post['content'],$m)){
  1418. $th['interesting'] = []; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1419. foreach($matches as $ma){ $th['interesting'][] = $ma[1]; }
  1420. }
  1421. }
  1422. if(preg_match('/\{\s*REVERSED\s*\}/imu',$first_post['content'],$m)){ $th['reversed'] = true; }
  1423. }
  1424. function IsInterestingPost(&$p){
  1425. if(isset($p['tid']) && isset($p['tid']['interesting']) && isset($p['tid']['interesting'][0])) return true;
  1426. return false;
  1427. }
  1428. function IsReversedThread(&$th){
  1429. if(isset($th['reversed']) && $th['reversed']) return true;
  1430. return false;
  1431. }
  1432. function GiveAllMergedPosts(&$po,&$arr){
  1433. if(isset($po['merged_from'])&&isset($po['merged_from'][0])) foreach($po['merged_from'] as $pm){
  1434. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr);}
  1435. }
  1436. if(isset($po['archive']) && isset($po['archive']['list'])){
  1437. foreach($po['archive']['list'] as &$ver){
  1438. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $pm){
  1439. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr); } }
  1440. }
  1441. }
  1442. }
  1443. function ThreadMakeWayback(&$th){
  1444. if(!isset($th['arr'][0])) return;
  1445. if(isset($this->WayBack)){
  1446. $remlist = [];
  1447. foreach($th['arr'] as &$pi){
  1448. $po = &$this->GetPost($pi['id'],true);
  1449. if(isset($po['merged_thread']) && isset($po['version']) && $po['version']>$this->WayBack){
  1450. $remlist = array_unique(array_merge($remlist,$po['merged_thread'][0]));
  1451. }
  1452. $ah = &$this->GetArchiveHandle($po['id']);
  1453. if(isset($ah)) foreach(array_reverse($ah['list']) as &$ver){
  1454. if(!isset($ver['merged_thread'])) continue;
  1455. if((isset($ver['version']) && $ver['version'] > $this->WayBack) ||
  1456. (!isset($ver['version']) && $ver['id'] > $this->WayBack)){
  1457. $remlist = array_unique(array_merge($remlist,$ver['merged_thread'][0]));
  1458. }
  1459. }
  1460. }
  1461. if(isset($remlist[0]) && isset($th['arr'][0])){
  1462. foreach($remlist as $rem){ $this->GiveAllMergedPosts($this->GetPost($rem,true),$remlist); }
  1463. foreach($th['arr'] as $key => $pr){
  1464. foreach($remlist as $rem){ if($pr['id'] == $rem) { unset($th['arr'][$key]); break; } } }
  1465. $new_th = []; $new_arr = [];
  1466. foreach($remlist as $rem){ $np=&$this->GetPost($rem); if(isset($np)){$new_arr[]=&$np;} }
  1467. $new_th['arr'] = &$new_arr;
  1468. $this->WaybackThreads[] = &$new_th;
  1469. $this->ThreadMakeWayback($new_th);
  1470. }
  1471. }
  1472. }
  1473. function AddMergedPosts(&$p, &$array){
  1474. if(isset($p['archive']) && isset($p['archive']['list'])){
  1475. foreach($p['archive']['list'] as &$ver){
  1476. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $po){
  1477. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1478. }
  1479. }
  1480. if(isset($p['merged_from'])&&isset($p['merged_from'][0])) foreach($p['merged_from'] as $po){
  1481. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1482. }
  1483. function FinalizeThread(&$th, $relink_posts=false, $now){
  1484. $nextp=NULL; $arr=[]; $lasttime=NULL;
  1485. if(!isset($th['arr'])){
  1486. for($p = &$th['first']; $p!=$this->NULL_POST; $p = &$this->GetPost(isset($p['next'])?$p['next']:NULL,true)){
  1487. $arr[]=&$p;
  1488. } $th['arr'] = &$arr;
  1489. if(isset($this->WayBack) && $this->DoneReadArchive){ $new_arr=[];
  1490. foreach($arr as &$p){ $pa = &$this->GetPost($p['id']); if(isset($pa)) {$new_arr[]=&$pa;$this->WaybackPosts[]=&$pa;} }
  1491. foreach($arr as &$p){ $this->AddMergedPosts($p,$new_arr); }
  1492. $arr=&$new_arr; $th['arr']=&$new_arr;
  1493. $this->ThreadMakeWayback($th); }
  1494. }
  1495. $cmppt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1496. if(isset($th['arr'][0])){ usort($th['arr'],$cmppt); } $th['count'] = sizeof($th['arr']);
  1497. if($relink_posts){ $count = $th['count'];
  1498. $arr = &$th['arr'];
  1499. 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'];
  1500. $arr[$i]['tid']=&$th;}
  1501. $th['first'] = &$arr[0]; $th['last'] = &$arr[$count-1]; unset($arr[0]['prev']); unset($arr[$count-1]['next']);
  1502. }
  1503. $th['score'] = 0; if(!isset($th['first'])){ return; }
  1504. $this->IdentifyThreadCategory($th, $th['first']);
  1505. if(isset($this->WayBack)) $lasttime=$this->WayBack;
  1506. if(!isset($last_time)) $lasttime = DateTime::createFromFormat('YmdHis', $th['last']['id']);
  1507. $diff_days = ($now - date_timestamp_get($lasttime))/3600/24;
  1508. $th['score'] = (float)$th['count']*0.2 - min($diff_days,200);
  1509. }
  1510. function SortThreads(){
  1511. if (!function_exists('cmpt')) {
  1512. function cmpt($a, $b){
  1513. if ($a['score'] == $b['score']) return 0;
  1514. return ($a['score'] > $b['score']) ? -1 : 1;
  1515. }
  1516. }
  1517. usort($this->Threads,"cmpt");
  1518. }
  1519. function DetectThreads(){
  1520. foreach($this->Posts as &$p){
  1521. if(isset($p['tid'])) { continue; }
  1522. $this->GetThreadForPost($p);
  1523. if(!isset($p['tid'])) { $this->IdentifyThreadCategory($this->NULL_POST, $p); }
  1524. }
  1525. if(!isset($this->Threads) || !isset($this->Threads[0])) return;
  1526. $now = date_timestamp_get(date_create());
  1527. foreach($this->Threads as &$t){
  1528. $this->FinalizeThread($t,false,$now);
  1529. }
  1530. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1531. $this->FinalizeThread($th,false,$now);
  1532. $this->Threads[] = &$th;
  1533. }
  1534. $this->SortThreads();
  1535. }
  1536. function UpdateThreadForWayback(){$now = date_timestamp_get(date_create());
  1537. if(!isset($this->WayBack) || !$this->DoneReadArchive){ return; }
  1538. foreach($this->Threads as &$t){
  1539. unset($t['arr']); $this->FinalizeThread($t,true,$now);
  1540. }
  1541. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1542. $this->FinalizeThread($th,true,$now);
  1543. $this->Threads[] = &$th;
  1544. }
  1545. $this->SortThreads();
  1546. $this->SortPosts(true);
  1547. $this->UsePosts = &$this->WaybackPosts;
  1548. }
  1549. function &GetMergedPost($id){
  1550. $this->ReadArchive();
  1551. $ah = &$this->GetArchiveHandle($id);
  1552. if(!isset($ah) || !isset($ah['list']) || !isset($ah['list'][0])){ return $this->NULL_POST; }
  1553. $ver = &$ah['list'][sizeof($ah['list'])-1];
  1554. if(!isset($ver['merged_into'])) return $this->GetPost($id);
  1555. [$tp, $tver] = $ver['merged_into'];
  1556. if(isset($this->WayBack)){
  1557. if($tver <= $this->WayBack) return $this->GetMergedPost($tp);
  1558. else return $this->GetPost($id); /* should not happen directly. */
  1559. }
  1560. return $this->GetMergedPost($tp);
  1561. }
  1562. function &GetPost($id, $latest_only=false, $find_merged=false){
  1563. if(!isset($id)) return $this->NULL_POST;
  1564. $found=&$this->NULL_POST;
  1565. if(isset($this->Posts[0])) foreach($this->Posts as &$p){
  1566. if($p&& $p['id'] == $id) { $found = &$p; break; }
  1567. if($find_merged && isset($p['hastag'][0]) && in_array($id, $p['hastag'])){ $found = &$p; break; }
  1568. }
  1569. if($latest_only || !isset($this->WayBack)){ return $found; }
  1570. else{
  1571. if(isset($found)){
  1572. if(!isset($found['archive'])&&!isset($found['archive']['list']))
  1573. { if($found['id'] > $this->WayBack) return $this->NULL_POST; else return $found; }
  1574. $last_ver = &$this->NULL_POST;
  1575. if(isset($found['archive']['list'][0])) foreach($found['archive']['list'] as &$ver){
  1576. if($ver['version'] > $this->WayBack) return $last_ver;
  1577. $last_ver = &$ver;
  1578. }
  1579. if(isset($found['version']) && $found['version'] <= $this->WayBack) return $found;
  1580. else return $last_ver;
  1581. }else{
  1582. $ah = &$this->GetArchiveHandle($id); $last_ver = &$this->NULL_POST;
  1583. if(isset($ah) && isset($ah['list']) && isset($ah['list'][0])) foreach($ah['list'] as &$ver){
  1584. if($ver['version'] > $this->WayBack) return $last_ver;
  1585. $last_ver = &$ver;
  1586. } if(!isset($last_ver['merged_into'])) return $last_ver; else{
  1587. [$tp, $tver] = $last_ver['merged_into'];
  1588. if($tver <= $this->WayBack) {
  1589. if($find_merged && $tp!=$id) return $this->GetPost($tp); return $this->NULL_POST; }
  1590. return $last_ver;
  1591. }
  1592. }
  1593. }
  1594. return $this->NULL_POST;
  1595. }
  1596. function &GetArchiveHandle($id){
  1597. if(!isset($id)) return $this->NULL_POST;
  1598. if(isset($this->ArchiveHandles[0])) foreach($this->ArchiveHandles as &$p){
  1599. if($p && $p['id'] == $id) { return $p; }
  1600. }
  1601. return $this->NULL_POST;
  1602. }
  1603. function &GetArchive($id){
  1604. if(!isset($id)) return $this->NULL_POST;
  1605. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1606. if($p && $p['id'] == $id) { return $p; }
  1607. }
  1608. return $this->NULL_POST;
  1609. }
  1610. function &GetArchiveVersion(&$ah, $version, &$next_ver, &$last_ver){
  1611. if(!isset($ah)) return $this->NULL_POST;
  1612. $found = NULL; $last_verp=NULL;
  1613. if(isset($ah['list'][0])) foreach($ah['list'] as &$p){
  1614. if(isset($found)){ $next_ver = $p; $last_ver = $last_verp; return $found; }
  1615. if($p && $p['version'] == $version) { $found = &$p; continue; }
  1616. $last_verp = &$p;
  1617. }
  1618. if(isset($found)) { $next_ver=NULL; $last_ver = $last_verp; return $found; }
  1619. return $this->NULL_POST;
  1620. }
  1621. function CacheArchiveOwnLinks(){
  1622. if(isset($this->WayBack)) return;
  1623. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1624. $this->ConvertPost($p); unset($p['hasp']); unset($p['hasi']); unset($p['hastag']);
  1625. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$p['html'],$matches,PREG_SET_ORDER)){
  1626. foreach($matches as $m){
  1627. if(!isset($p['hasp']))$p['hasp']=[]; if(!in_array($m[1],$p['hasp'])){ $p['hasp'][]=$m[1]; }
  1628. }
  1629. }
  1630. if(preg_match_all('/\/\/([0-9]{14})/u', $p['content'],$matches,PREG_SET_ORDER)){
  1631. foreach($matches as $m){
  1632. if(!isset($p['hastag']))$p['hastag']=[]; if(!in_array($m[1],$p['hastag'])){ $p['hastag'][]=$m[1]; }
  1633. }
  1634. }
  1635. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\)/u', $p['content'],$matches,PREG_SET_ORDER)){
  1636. foreach($matches as $m){
  1637. if(!isset($p['hasi']))$p['hasi']=[]; if(!in_array($m[2],$p['hasi'])){ $p['hasi'][]=$m[2]; }
  1638. }
  1639. }
  1640. }
  1641. }
  1642. function WriteArchive(){
  1643. if(isset($this->WayBack)) return;
  1644. $cf = NULL;$opened =NULL;
  1645. $this->SortArchive();
  1646. $this->CacheArchiveOwnLinks();
  1647. if(isset($this->Archive[0])) foreach($this->Archive as $p){
  1648. $nid = substr($p['id'], 0,6);
  1649. if($cf != $nid){
  1650. if($opened){
  1651. fflush($opened);
  1652. fclose($opened);
  1653. }
  1654. $cf = $nid;
  1655. $opened = fopen("archive/$cf.md", 'w');
  1656. }
  1657. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1658. "VER {$p['version']}; ".
  1659. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1660. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1]).";"):"").
  1661. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1662. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1663. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1664. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1665. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1666. ']';
  1667. if(isset($p['merged_thread'])){ $p['content']=""; }
  1668. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['content'].PHP_EOL.PHP_EOL);
  1669. }
  1670. }
  1671. function WritePosts(){
  1672. if(isset($this->WayBack)) return;
  1673. $cf = NULL;$opened =NULL;
  1674. $this->SortPosts();
  1675. if(isset($this->Posts[0])) foreach($this->Posts as $p){
  1676. $nid = substr($p['id'], 0,6);
  1677. if($cf != $nid){
  1678. if($opened){
  1679. fflush($opened);
  1680. fclose($opened);
  1681. }
  1682. $cf = $nid;
  1683. $opened = fopen("posts/$cf.md", 'w');
  1684. }
  1685. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1686. ((isset($p['version']) && $p['version'])?"VER {$p['version']}; ":"").
  1687. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1688. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1689. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1690. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1])."; "):"").
  1691. ((isset($p['comment_to']) && $p['comment_to'])?"COMMENT {$p['comment_to']}; ":"").
  1692. ((isset($p['email']) && $p['email'])?"EMAIL {$p['email']}; ":"").
  1693. ((isset($p['name']) && $p['name'])?"NAME {$p['name']}; ":"").
  1694. ((isset($p['link']) && $p['link'])?"LINK {$p['link']}; ":"").
  1695. ((isset($p['ip']) && $p['ip'])?"IP {$p['ip']}; ":"").
  1696. ((isset($p['mark_delete']) && $p['mark_delete'])?"MDEL; ":"").
  1697. ((isset($p['mark_value']) && $p['mark_value']>=0)?"MVAL {$p['mark_value']}; ":"").
  1698. ((isset($p['next']) && $p['next'])?"NEXT {$p['next']}; ":"").
  1699. ((isset($p['prev']) && $p['prev'])?"PREV {$p['prev']}; ":"").
  1700. ((isset($p['refs']) && isset($p['refs'][0]))?("REFS ".implode(" ",$p['refs'])."; "):"").
  1701. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1702. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1703. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1704. ((isset($p['mastodon_url']) && isset($p['mastodon_url']))?("MSTDN ".$p['mastodon_url']."; "):"").
  1705. ']';
  1706. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['real_content'].PHP_EOL.PHP_EOL);
  1707. }
  1708. }
  1709. function CachePostLinks(){
  1710. if(isset($this->WayBack)) return;
  1711. if(isset($this->Posts) && isset($this->Posts[0]))foreach ($this->Posts as &$post){
  1712. $this->ConvertPost($post);
  1713. unset($post['refs']);unset($post['hasp']);unset($post['hasi']);unset($post['hastag']);
  1714. //discard lost old version
  1715. //if(!isset($post['archive']) && $this->DoneReadArchive && isset($post['version'])){ unset($post['version']); }
  1716. }else return;
  1717. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1718. unset($im['refs']); unset($im['here']); unset($im['title']);
  1719. }
  1720. foreach ($this->Posts as &$post){
  1721. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$post['html'],$matches,PREG_SET_ORDER)){
  1722. foreach($matches as $m){
  1723. $ref = &$this->GetPost($m[1],true);
  1724. if($ref!=NULL){
  1725. if(!isset($ref['refs']))$ref['refs']=[]; if(!in_array($post['id'],$ref['refs']))$ref['refs'][]=$post['id'];
  1726. }
  1727. if(!isset($post['hasp']))$post['hasp']=[]; if(!in_array($m[1],$post['hasp']))$post['hasp'][]=$m[1];
  1728. }
  1729. }
  1730. if(preg_match_all('/\/\/([0-9]{14})/u', $post['content'],$matches,PREG_SET_ORDER)){
  1731. foreach($matches as $m){
  1732. if(!isset($post['hastag']))$post['hastag']=[]; if(!in_array($m[1],$post['hastag']))$post['hastag'][]=$m[1];
  1733. }
  1734. }
  1735. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\)/u', $post['content'],$matches,PREG_SET_ORDER)){
  1736. foreach($matches as $m){
  1737. if(($im = &$this->FindImage($m[2]))!=NULL){
  1738. if(!isset($im['refs']))$im['refs']=[]; if(!in_array($post['id'], $im['refs']))$im['refs'][] = $post['id'];
  1739. }
  1740. if(!isset($post['hasi']))$post['hasi']=[]; if(!in_array($m[2],$post['hasi']))$post['hasi'][]=$m[2];
  1741. }
  1742. }
  1743. if(preg_match("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\))(\R*(\R(-|\*).+){1,})/u",
  1744. $post['content'],$matches)){
  1745. $use_img_name = $matches[2];
  1746. if(($im = &$this->FindImage($use_img_name))!=NULL){
  1747. 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",
  1748. $matches[4],$mah,PREG_SET_ORDER)){
  1749. foreach($mah as $ma){
  1750. if(!isset($im['here']))$im['here']=[]; if(!$this->ImageHasHere($item, $ma[4])){
  1751. $here = [$ma[4], $ma[2], $ma[3]]; $im['here'][] = $here; }
  1752. }
  1753. }
  1754. }
  1755. }
  1756. }foreach($this->Posts as &$post){
  1757. if(isset($post['hasp']) && isset($post['hasp'][0])) foreach($post['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1758. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1759. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$post['id']; }
  1760. }
  1761. }
  1762. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1763. $min_id = '99999999999999';
  1764. if(isset($im['refs']) && isset($im['refs'][0])) foreach ($im['refs'] as &$ref){
  1765. $r = &$this->GetPost($ref,true); if(isset($r)) $title = $this->GetPostTitle($r,true,false);
  1766. if($title && $ref<$min_id) { $im['title'] = preg_replace('/;/u',' ',trim($title)); $min_id=$r['id']; }
  1767. }
  1768. }
  1769. }
  1770. function CreatePostAnchor(&$post){
  1771. $that=&$this;
  1772. $post['html'] = preg_replace_callback('/<h([0-9])>(.+?)(?=<\/h[0-9]>)/u', function ($ma) use ($that){
  1773. $id = '_heading_'.sizeof($this->Anchors);
  1774. $entry=[(int)$ma[1], $id, $ma[2]];
  1775. $that->Anchors[] = $entry;
  1776. return "<h${ma[1]} id='${id}'>${ma[2]}";
  1777. }, $post['html']);
  1778. }
  1779. function RenamePost(&$post, $rename){
  1780. foreach($this->Posts as &$p){
  1781. if($p['id']==$rename && $p!==$post) { return; /* don't overwrite */ }
  1782. }
  1783. foreach($this->Posts as &$p){
  1784. if(isset($p['prev']) && $p['prev']==$post['id']) { $p['prev']=$rename; }
  1785. if(isset($p['next']) && $p['next']==$post['id']) { $p['next']=$rename; }
  1786. }
  1787. $post['id'] = $rename;
  1788. }
  1789. function DetachPost(&$th,&$post){
  1790. $p0=$p1=NULL;foreach($th['arr'] as $a) echo $a['id']." "; echo '&nbsp;&nbsp;&nbsp;-'.$post['id']."<br />";
  1791. if(isset($post['prev'])){$p0=&$this->GetPost($post['prev'],true);} if(isset($post['next'])){$p1=&$this->GetPost($post['next'],true);}
  1792. if(isset($p0)){ $p0['next']=$p1['id']; }else{ $th['first']=$p1['id']; }
  1793. if(isset($p1)){ $p1['prev'] =$p0['id']; }else{ $th['last']=$p0['id']; }
  1794. foreach($this->Posts as $key => $p){ if ($p==$post) unset($this->Posts[$key]); }
  1795. unset($th['arr']); $now = date_timestamp_get(date_create());
  1796. $this->FinalizeThread($th, true, $now);
  1797. }
  1798. function PushPostVersion(&$post, $optime_id, $mode=1, $info=NULL){
  1799. $a = &$this->GetArchiveHandle($post['id']);
  1800. $ap = []; $ap['id'] = $post['id']; $ap['content'] = $post['real_content'];
  1801. $ap['version'] = isset($post['version'])?$post['version']:$ap['id'];
  1802. if(isset($post['merged_from'])) { $ap['merged_from'] = $post['merged_from']; unset($post['merged_from']); }
  1803. if(isset($post['merged_into'])) { $ap['merged_into'] = $post['merged_into']; unset($post['merged_into']); }
  1804. if(isset($post['merged_thread'])) { $ap['merged_thread'] = $post['merged_thread']; unset($post['merged_thread']); }
  1805. $post['version'] = $optime_id;
  1806. if($mode==1){
  1807. $this->InsertArchivePost($ap);
  1808. }else if($mode==2){
  1809. $post['merged_from'] = $info;
  1810. $this->InsertArchivePost($ap);
  1811. }else if($mode==3){
  1812. $ap['merged_into'] = $info;
  1813. $this->InsertArchivePost($ap);
  1814. if(isset($post['tid']) && $post['tid']['first']!=$post['tid']['last'] && $post!=$post['tid']['first']){
  1815. $this->DetachPost($post['tid'], $post);
  1816. }
  1817. }else if($mode==4){
  1818. $post['merged_thread'] = $info;
  1819. $this->InsertArchivePost($ap);
  1820. }
  1821. }
  1822. function &MergeThreads($post_id, $post_into_id){
  1823. $this->ReadPosts();
  1824. $po = &$this->GetPost($post_id, true); $pt = &$this->GetPost($post_into_id, true);
  1825. if (!isset($po) || !isset($pt) || !isset($po['tid']) || !isset($pt['tid']) ||
  1826. !isset($po['tid']['arr'][0]) || !isset($pt['tid']['arr'][0])){ return $this->NULL_POST; }
  1827. $po = &$po['tid']['arr'][0]; $pt = &$pt['tid']['arr'][0];
  1828. $th = &$po['tid']; $tt = &$pt['tid']; $info=[[],[]];
  1829. if($po['id'] < $pt['id']){ $temp = &$th; $th=&$tt; $tt=&$temp; $temp = &$po; $po=&$pt; $pt=&$temp; }
  1830. foreach($th['arr'] as &$p){ $info[0][]=$p['id']; }
  1831. foreach($tt['arr'] as &$p){ $info[1][]=$p['id']; }
  1832. $this->EditPost($pt['id'], NULL, NULL, NULL, false, NULL, NULL, 4, $info,NULL);
  1833. $arr_combined = array_merge($tt['arr'],$th['arr']);
  1834. $cmppmt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1835. if(isset($arr_combined[0])){ usort($arr_combined,$cmppmt); } $tt['arr']=&$arr_combined;
  1836. $tt['count'] = sizeof($tt['arr']);
  1837. $this->FinalizeThread($tt, true, $this->TIME_STRING);
  1838. $first_post = &$this->NULL_POST;
  1839. if(isset($tt['arr'][0])) $first_post= &$tt['arr'][0];
  1840. $this->NeedWritePosts=1;
  1841. $this->NeedWriteArchive=1;
  1842. return $first_post;
  1843. }
  1844. function &MergePosts($ids_string){
  1845. $ids = explode(" ", $ids_string);
  1846. $combined_content = ""; $first_id=NULL;
  1847. $this->ReadPosts(); $child_list=[];
  1848. foreach($ids as $id){
  1849. if(!preg_match('/[0-9]{14}/u',$id) || $this->GetPost($id,true)==$this->NULL_POST) continue;
  1850. if(!isset($first_id)) { $first_id = $id; } else { $combined_content.=PHP_EOL.PHP_EOL."//".$id.PHP_EOL; $child_list[]=$id; }
  1851. $combined_content.=$this->EditPost($id, NULL, NULL, NULL, true, NULL, NULL, false, NULL,NULL);
  1852. }
  1853. if(!isset($child_list[0])) return $this->NULL_POST;
  1854. $first_post = &$this->EditPost($first_id, $combined_content, NULL, NULL, false, NULL, NULL, 2, $child_list,NULL);
  1855. foreach($child_list as $id){
  1856. $this->EditPost($id, NULL, NULL, NULL, false, NULL, NULL, 3, [$first_id,$this->TIME_STRING],NULL);
  1857. }
  1858. $this->NeedWritePosts=1;
  1859. $this->NeedWriteArchive=1;
  1860. return $first_post;
  1861. }
  1862. /* push_version: 1 edit 2 post merged from ids list 3 post end into id-ver */
  1863. function &EditPost($id_if_edit, $content, $mark_delete, $reply_to,
  1864. $get_original_only=false, $mark_value=NULL, $rename=NULL,
  1865. $push_version=false, $version_info=NULL, $mastodon_url=NULL){
  1866. $this->ReadImages();
  1867. $this->ReadPosts();
  1868. if(isset($push_version) && $push_version){
  1869. $this->ReadArchive();
  1870. }
  1871. $p_success = NULL;
  1872. if(isset($id_if_edit)){
  1873. $post = &$this->GetPost($id_if_edit,true);
  1874. if($post===$this->NULL_POST) return $this->NULL_POST;
  1875. if($get_original_only){
  1876. return $post['real_content'];
  1877. }
  1878. if(isset($push_version) && $push_version){
  1879. $this->PushPostVersion($post,$this->TIME_STRING,$push_version,$version_info);
  1880. }
  1881. if(isset($content)) {$post['real_content'] = $content; $post['content'] = &$post['real_content'];}
  1882. if(isset($mark_delete)) $post['mark_delete'] = $mark_delete;
  1883. if(isset($mark_value)) $post['mark_value'] = $mark_value;
  1884. if(isset($rename) && preg_match('/^[0-9]{14}$/u',$rename)) $this->RenamePost($post,$rename);
  1885. if(isset($mastodon_url)) { if($mastodon_url!='') $post['mastodon_url']=$mastodon_url; else unset($post['mastodon_url']); }
  1886. $p_success = &$post;
  1887. }else{
  1888. if(!isset($content)) return $this->NULL_POST;
  1889. $id = date('YmdHis');
  1890. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  1891. $post = []; $post['id'] = $id;
  1892. $post['real_content'] = $content; $post['content'] = &$post['real_content'];
  1893. if(isset($reply_to) && ($rep = &$this->GetPost($reply_to,true))!== $this->NULL_POST){
  1894. while($rep !== $this->NULL_POST && isset($rep['next']) && $rep['next']){ $rep = &$this->GetPost($rep['next'],true); }
  1895. if($rep !== $this->NULL_POST){ $rep['next'] = $id; $post['prev'] = $rep['id']; }
  1896. }
  1897. $this->Posts[] = $post;
  1898. $p_success = &$this->Posts[count($this->Posts) - 1];
  1899. }
  1900. $this->NeedWritePosts=1;
  1901. $this->NeedWriteImages=1;
  1902. if(isset($push_version) && $push_version){
  1903. $this->NeedWriteArchive=1;
  1904. }
  1905. return $p_success;
  1906. }
  1907. function &EditComment($id_if_edit, $comment_to_id, $content, $email, $name, $link=NULL, $ip=NULL){
  1908. $this->ReadPosts();
  1909. $p_success = NULL;
  1910. if(isset($id_if_edit)){
  1911. $post = &$this->GetPost($id_if_edit,true);
  1912. if($post===$this->NULL_POST || !isset($post['comment_to'])) return $this->NULL_POST;
  1913. if(isset($content)) $post['content'] = $content;
  1914. if(isset($comment_to_id)) $post['comment_to'] = $comment_to_id;
  1915. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  1916. if(isset($ip)) $post['ip'] = $ip;
  1917. $p_success = &$post;
  1918. }else{
  1919. if(!isset($content) || !isset($comment_to_id)) return $this->NULL_POST;
  1920. $id = date('YmdHis');
  1921. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  1922. if(!($to_post=$this->GetPost($comment_to_id,true))) return $this->NULL_POST;
  1923. $post = []; $post['id'] = $id; $post['content'] = $content; $post['comment_to'] = $comment_to_id;
  1924. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  1925. if(isset($ip)) $post['ip'] = $ip;
  1926. $this->Posts[] = $post;
  1927. $p_success = &$this->Posts[count($this->Posts) - 1];
  1928. }
  1929. $this->NeedWritePosts=1;
  1930. return $p_success;
  1931. }
  1932. function InsertReplacementSymbols($MarkdownContent, &$post_for_it_is_here){
  1933. $replacement = preg_replace('/<!--[\s\S]*-->/U',"",$MarkdownContent);
  1934. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  1935. function($matches){
  1936. $rep = preg_replace('/->/','-@>',$matches[0]);
  1937. $rep = preg_replace('/=>/','=@>',$rep);
  1938. $rep = preg_replace('/<=/','<@=',$rep);
  1939. $rep = preg_replace('/<-/','<@-',$rep);
  1940. $rep = preg_replace('/\R([+]{3,})\R/',PHP_EOL.'@$1'.PHP_EOL,$rep);
  1941. $rep = preg_replace('/\[-/','[@-',$rep);
  1942. $rep = preg_replace('/\{/','{@',$rep);
  1943. $rep = preg_replace('/(en|zh|any)\|(en|zh|any)/','$1@|$2',$rep);
  1944. return $rep;
  1945. },
  1946. $replacement);
  1947. $replacement = preg_replace("/<[-]+>/","↔",$replacement);
  1948. $replacement = preg_replace("/([^-])->/","$1→",$replacement);
  1949. $replacement = preg_replace("/<-([^-])/","←$1",$replacement);
  1950. $replacement = preg_replace("/([^-])[-]+->/","$1⟶",$replacement);
  1951. $replacement = preg_replace("/<-[-]+([^-])/","⟵$1",$replacement);
  1952. $replacement = preg_replace("/<[=]+>/","⇔",$replacement);
  1953. $replacement = preg_replace("/[=]+>/","⇒",$replacement);
  1954. $replacement = preg_replace("/<[=]+/","⇐",$replacement);
  1955. $replacement = preg_replace("/\R([+]{3,})\R/","<div class='page_break'></div>",$replacement);
  1956. $replacement = preg_replace("/\[-(.*)-\]/U","<span class='text_highlight'>$1</span>",$replacement);
  1957. $replacement = preg_replace("/{支付宝(\s+[^}]*?)?}/u","<span class='special_alipay'>支付宝$1</span>",$replacement);
  1958. $replacement = preg_replace("/{PayPal(\s+[^}]*?)?}/ui",
  1959. "<span class='special_paypal'>Pay<span class='special_paypal_inner'>Pal</span>$1</span>",$replacement);
  1960. $replacement = preg_replace("/\/\/([0-9]{14})/imu","<p class='wscroll' id='$1'>".$this->T("链接位置")."</p>",$replacement);
  1961. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  1962. function($matches){
  1963. $rep = preg_replace('/-@>/','->',$matches[0]);
  1964. $rep = preg_replace('/<@-/','<-',$rep);
  1965. $rep = preg_replace('/=@>/','=>',$rep);
  1966. $rep = preg_replace('/<@=/','<=',$rep);
  1967. $rep = preg_replace('/\R@([+]{3,})\R/',PHP_EOL.'$1'.PHP_EOL,$rep);
  1968. $rep = preg_replace('/\[@-/','[-',$rep);
  1969. $rep = preg_replace('/\{@/','{',$rep);
  1970. $rep = preg_replace('/(en|zh|any)@\|(en|zh|any)/','$1|$2',$rep);
  1971. return $rep;
  1972. }, $replacement);
  1973. $replacement = preg_replace_callback("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\))(\R*(\R.+){1,})/u",
  1974. function($matches) use (&$post_for_it_is_here){
  1975. $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]);
  1976. return $matches[1].$rep;
  1977. }, $replacement);
  1978. return $replacement;
  1979. }
  1980. function CanShowPost(&$p){
  1981. if(!isset($p) || isset($p['comment_to'])) return false;
  1982. $is_mark_exp = (isset($p['tid'])&&isset($p['tid']['exp'])&&$p['tid']['exp']) || (isset($p['mark_value'])&&$p['mark_value']==6);
  1983. $is_mark_slf = (isset($p['tid'])&&isset($p['tid']['slf'])&&$p['tid']['slf']) || (isset($p['mark_value'])&&$p['mark_value']==7);
  1984. if($is_mark_slf && !$this->LoggedIn){ return false; }
  1985. if(isset($this->WayBack)){
  1986. if(isset($p['version'])) { if ($p['version']>$this->WayBack) return false; }
  1987. else if ($p['id']>$this->WayBack) return false;
  1988. }
  1989. if(!$this->InExperimentalMode){
  1990. if(!$this->LoggedIn){
  1991. if($is_mark_exp) return false;
  1992. return true;
  1993. }
  1994. return true;
  1995. }else{
  1996. if($is_mark_exp) return true;
  1997. return false;
  1998. }
  1999. }
  2000. function SkipProduct(&$p){
  2001. if($this->LoggedIn) return false;
  2002. return (isset($p['mark_value']) && $p['mark_value']==5);
  2003. }
  2004. function GetRedirect($args=NULL){
  2005. $str = 'index.php?';
  2006. if(isset($args['post'])) $str.='&post='.$args['post'];
  2007. else if(isset($_GET['post'])) $str.='&post='.$_GET['post'];
  2008. if(isset($args['gallery'])) $str.='&gallery='.$args['gallery'];
  2009. else if(isset($_GET['gallery'])) $str.='&gallery='.$_GET['gallery'];
  2010. if(isset($args['pic'])) $str.='&pic='.$args['pic'];
  2011. else if(isset($_GET['pic'])) $str.='&pic='.$_GET['pic'];
  2012. if(isset($args['settings'])) $str.='&settings='.$args['settings'];
  2013. else if(isset($_GET['settings'])) $str.='&settings='.$_GET['settings'];
  2014. if(isset($args['extras'])) $str.='&extras='.$args['extras'];
  2015. else if(isset($_GET['extras'])) $str.='&extras='.$_GET['extras'];
  2016. if(isset($args['category'])) $str.='&category='.$args['category'];
  2017. else if(isset($_GET['category'])) $str.='&category='.$_GET['category'];
  2018. if(isset($args['history'])) $str.='&history='.$args['history'];
  2019. else if(isset($_GET['history'])) $str.='&history='.$_GET['history'];
  2020. if(isset($args['version'])) $str.='&version='.$args['version'];
  2021. else if(isset($_GET['version'])) $str.='&version='.$_GET['version'];
  2022. if(isset($args['search'])) $str.='&search='.$args['search'];
  2023. else if(isset($_GET['search'])) $str.='&search='.$_GET['search'];
  2024. if(isset($args['here'])) $str.='&here='.$args['here'];
  2025. else if(isset($_GET['here'])) $str.='&here='.$_GET['here'];
  2026. return $str;
  2027. }
  2028. function WriteAsNecessary(){
  2029. if(!$this->LoggedIn || isset($this->WayBack)){return;}
  2030. if($this->NeedWritePosts){ $this->CachePostLinks(); $this->WritePosts(); }
  2031. if($this->NeedWriteImages){ $this->WriteImages(); }
  2032. if($this->NeedWriteArchive){ $this->WriteArchive(); }
  2033. }
  2034. function APubEnsureWebfinger($name, $host){
  2035. if(!is_dir('.well-known')) mkdir('.well-known');
  2036. if(!is_dir('.well-known/webfinger')) mkdir('.well-known/webfinger');
  2037. $f = fopen('.well-known/webfinger/index.php',"w");
  2038. $without_protocol = parse_url($host, PHP_URL_HOST);
  2039. $finger = ["subject"=>"acct:".$name.'@'.$without_protocol,
  2040. "links"=>[["rel"=>"self", "type"=>"application/activity+json", "href"=>$host."?apub_actor=1"]]];
  2041. fwrite($f, "<?php header('Content-Type: application/json'); echo '".json_encode($finger, JSON_UNESCAPED_SLASHES)."'; ?>"); fclose($f);
  2042. if(!file_exists('.well-known/apub_public_key.pem') || !file_exists('.well-known/apub_private_key.php')){
  2043. $res = openssl_pkey_new();
  2044. $this->APubPublicKey = openssl_pkey_get_details($res)['key'];
  2045. openssl_pkey_export($res, $this->APubPrivateKey);
  2046. $f = fopen('.well-known/apub_public_key.pem',"w");
  2047. fwrite($f, $this->APubPublicKey); fclose($f);
  2048. $f = fopen('.well-known/apub_private_key.php',"w");
  2049. fwrite($f, "<?php exit; ?>".PHP_EOL.PHP_EOL.$this->APubPrivateKey); fclose($f);
  2050. }
  2051. }
  2052. function APubEnsureInfo(){
  2053. if(!isset($this->APubID) || !isset($this->HostURL)) return;
  2054. if(!file_exists('.well-known/apub_public_key.pem')){$this->APubEnsureWebfinger($this->APubID, $this->HostURL);}
  2055. $pk = file_get_contents('.well-known/apub_public_key.pem'); //$pk = preg_replace('/\n/u','\\n',$pk);
  2056. $actor = ["@context"=>["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1"],
  2057. "id"=> $this->HostURL."?apub_actor=1",
  2058. "type"=> "Person",
  2059. "name"=> $this->DisplayName,
  2060. "url"=> $this->HostURL,
  2061. "summary"=> "Lazy... No summary",
  2062. "preferredUsername"=> $this->APubID,
  2063. "inbox"=> $this->HostURL."?apub_inbox=1",
  2064. "outbox"=> $this->HostURL."?apub_outbox=1",
  2065. "publicKey"=> ["id"=> $this->HostURL."?apub_actor=1#main-key",
  2066. "owner"=> $this->HostURL."?apub_actor=1",
  2067. "publicKeyPem"=>$pk]];
  2068. $this->APubActor = json_encode($actor, JSON_UNESCAPED_SLASHES);
  2069. }
  2070. function APubMakeOutbox(){
  2071. $this->ReadPosts();$this->ReadImages();
  2072. $obj = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2073. "id"=>$this->HostURL."?apub_outbox=1",
  2074. "type"=>"OrderedCollection"];
  2075. $items=[]; $i=0;
  2076. foreach(array_reverse($this->Posts) as &$p){
  2077. $this->ConvertPost($p);
  2078. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$p['html']));
  2079. $time = DateTime::createFromFormat('YmdHis', $p['id'], new DateTimeZone('+0800'));
  2080. $ob = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2081. "type"=> "Create",
  2082. "id"=> $this->HostURL."?post=".$p['id']."?apub_object=1",
  2083. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2084. //"to"=> ["https://chatty.example/ben/"],
  2085. "actor"=> $this->HostURL."?apub_actor=1",
  2086. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2087. "object"=> ["type"=> "Note",
  2088. "id"=> $this->HostURL."?post=".$p['id'],
  2089. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2090. "attributedTo"=> $this->HostURL."?apub_actor=1",
  2091. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2092. "content"=> $text]];
  2093. $items[] = $ob;
  2094. $i++; if($i>20) break;
  2095. }
  2096. $obj['orderedItems'] = $items; $obj["totalItems"] = sizeof($items);
  2097. return json_encode($obj, JSON_UNESCAPED_SLASHES);
  2098. }
  2099. function MakeRSS(){
  2100. $this->ReadPosts();$this->ReadImages();
  2101. $posts = []; if(isset($this->UsePosts[0])){
  2102. $posts = array_reverse($this->UsePosts);
  2103. $last_updated = $this->StandardTime($posts[0]['id']);
  2104. }else{ $last_updated= $this->StandardTime("20000101000000"); }
  2105. $author = "<author><name>".$this->DisplayName."</name><email>".$this->EMail."</email><uri>".$this->HostURL."</uri></author>";
  2106. $all_content="<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom'>".
  2107. "<id>".$this->HostURL."/?rss</id>".
  2108. "<updated>".$last_updated."</updated>".
  2109. "<title>".$this->T($this->Title)."</title>".
  2110. "<link href='".$this->HostURL."/?rss' rel='self'/>".
  2111. "<link href='".$this->HostURL."' />".$author;
  2112. $i=0;
  2113. if(isset($posts[0])) foreach($posts as &$p){
  2114. if($i>100) break;
  2115. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  2116. if(isset($p['tid'])){ /* Should always be set. */
  2117. $th = &$p['tid']; if($p['tid']['count']==0) continue; }
  2118. if(in_array($p['id'],
  2119. [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation])) continue;
  2120. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  2121. $is_thread = isset($p['tid']['count'])&&($p['tid']['count']>1);
  2122. $is_reversed=false;
  2123. $content="<entry>"; $title = NULL;
  2124. if($is_thread){
  2125. $use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false; if($is_reversed){
  2126. $use_arr=array_reverse($th['arr']); $fp=array_pop($use_arr); array_unshift($use_arr,$fp); }
  2127. foreach($use_arr as &$po){
  2128. $this->ConvertPost($po);
  2129. if(!isset($title)){$title = $this->GetPostTitle($po, false, false);
  2130. $content.="<id>".$this->HostURL."?post=".$po['id']."</id>";
  2131. $content.="<title>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$po['id']."' />";
  2132. $content.="<published>".$this->StandardTime($po['id'])."</published>";
  2133. $content.="<updated>".$this->StandardTime(isset($po['tid']['last']['version'])?
  2134. $po['tid']['last']['version']:$po['tid']['last']['id'])."</updated>".$author;
  2135. $content.="<content type='html'>"; }
  2136. $content.= htmlspecialchars($po['html']);
  2137. //if(isset($po['images'])&&isset($po['images'][0])) foreach($po['images'] as $im){ $content.=htmlspecialchars($im); }
  2138. }
  2139. $content.=$this->ReadableTime($p['tid']['first']['id'])." - ".
  2140. $this->ReadableTime(isset($p['tid']['last']['version'])?
  2141. $p['tid']['last']['version']:$p['tid']['last']['id']);
  2142. $content.="</content>";
  2143. }else{
  2144. $this->ConvertPost($p);
  2145. if(!isset($title)){$title = $this->GetPostTitle($p, false, false);
  2146. $content.="<id>".$this->HostURL."?post=".$p['id']."</id>";
  2147. $content.="<title>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$p['id']."' />";
  2148. $content.="<published>".$this->StandardTime($p['id'])."</published>";
  2149. $content.="<updated>".$this->StandardTime(isset($p['tid']['last']['version'])?
  2150. $p['tid']['last']['version']:$p['tid']['last']['id'])."</updated>".$author;}
  2151. $content.= "<content type='html'>".htmlspecialchars($p['html']);
  2152. //if(isset($p['images'])&&isset($p['images'][0])) foreach($p['images'] as $im){ $content.=htmlspecialchars($im); }
  2153. $content.=$this->ReadableTime($p['id'])." - ".
  2154. $this->ReadableTime(isset($p['version'])?$p['version']:$p['id']);
  2155. $content.="</content>";
  2156. }
  2157. $i++;
  2158. $content.="</entry>";
  2159. $all_content.=$content;
  2160. }
  2161. $all_content.="</feed>";
  2162. header( "Content-type: text/xml");
  2163. echo $all_content;
  2164. }
  2165. function MakeHereButtons($im, $insert_here){
  2166. if(isset($im['here'])&&isset($im['here'][0])){
  2167. $size=getimagesize($im['file']); $aspect=$size[0]/$size[1];
  2168. echo ($insert_here?"<here>":"")."<div class='here_buttons_inner' style='aspect-ratio:".$aspect.";'>";
  2169. foreach($im['here'] as $here){
  2170. if($insert_here){
  2171. echo "<a href='?show_image=".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'".
  2172. "onclick='event.preventDefault();event.stopPropagation();ShowBigImage(\"".$here[0]."\",1);'></a>";
  2173. }else{
  2174. echo "<a href='?here=images/".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'></a>";
  2175. }
  2176. }
  2177. echo "</div>".($insert_here?"</here>":"");
  2178. }
  2179. }
  2180. function ProcessRequest(&$message=NULL, &$redirect=NULL){
  2181. if(isset($_GET['gallery']) && $_GET['gallery']=='default'){
  2182. $redirect = "index.php?gallery=".(isset($this->DefaultGallery)&&$this->DefaultGallery!=''?$this->DefaultGallery:"main");
  2183. return 0;
  2184. }
  2185. if(isset($_GET['set_language'])){
  2186. setcookie('la_language',$_GET['set_language'],time()+3600*24*7); $_COOKIE['la_language'] = $_GET['set_language'];
  2187. $redirect=$this->GetRedirect(); return 0;
  2188. }
  2189. if(isset($_GET['rss'])){
  2190. if(in_array($_GET['rss'],['en','zh'])){$this->LanguageAppendix=$_GET['rss'];}
  2191. $this->MakeRSS(); exit;
  2192. }
  2193. if(isset($_GET['toggle_font'])){ $use_font='local';
  2194. if(!isset($_COOKIE['la_font']) || $_COOKIE['la_font']!='remote') $use_font='remote';
  2195. setcookie('la_font',$use_font,time()+3600*24*7); $_COOKIE['la_font'] = $use_font;
  2196. $redirect=$this->GetRedirect(); return 0;
  2197. }
  2198. if(isset($_GET['set_wayback'])){
  2199. if($_GET['set_wayback']!='false'){
  2200. $wayback= date('YmdHis');
  2201. if($_GET['set_wayback']=='post'){
  2202. if(isset($_POST['wayback_year'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_year'],4,"0",STR_PAD_LEFT),0,4);
  2203. if(isset($_POST['wayback_month'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_month'],2,"0",STR_PAD_LEFT),4,2);
  2204. if(isset($_POST['wayback_day'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_day'],2,"0",STR_PAD_LEFT),6,2);
  2205. if(isset($_POST['wayback_hour'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_hour'],2,"0",STR_PAD_LEFT),8,2);
  2206. if(isset($_POST['wayback_minute'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_minute'],2,"0",STR_PAD_LEFT),10,2);
  2207. }else{ if(preg_match('/[0-9]{14}/u', $_GET['set_wayback'])) $wayback = $_GET['set_wayback']; }
  2208. setcookie('la_wayback',$wayback); $_COOKIE['la_wayback'] = $wayback;
  2209. }else{
  2210. setcookie('la_wayback', null, -1); unset($_COOKIE['la_wayback']);
  2211. }
  2212. $redirect=$this->GetRedirect(); return 0;
  2213. }
  2214. if(isset($_GET['post'])){ $this->CurrentPostID = $_GET['post']; $this->TagID = $this->CurrentPostID; }
  2215. if(isset($_GET['here'])){ $this->HereID = $_GET['here']; }
  2216. if(isset($_GET['offset'])){ $this->CurrentOffset = $_GET['offset']; }
  2217. if(isset($_GET['part'])){
  2218. if($_GET['part'] == 'hot') $this->ExtraScripts.="ShowLeftSide();";
  2219. else if ($_GET['part'] == 'recent') $this->ExtraScripts.="ShowCenterSide();";
  2220. }
  2221. if(isset($_GET['post'])){
  2222. $this->ExtraScripts.="window.addEventListener('load', (event) => {ScrollToPost('".$_GET['post']."');});";
  2223. }
  2224. if(isset($_GET['random_here'])){
  2225. $this->DoIdentifyExperimental(); $this->DetectPageType();
  2226. $im = &$this->GiveImageInHere(true); if(isset($im)){ $redirect='?here=images/'.$im['name']; return 0; }
  2227. }
  2228. if(isset($_POST['search_content'])){ $redirect='index.php?search='.$_POST['search_content'];return 0; }
  2229. if(isset($_GET['image_info']) || isset($_GET['show_image'])){
  2230. $m=isset($_GET['image_info'])?$_GET['image_info']:$_GET['show_image'];
  2231. $direct_return = !isset($_GET['show_image']);
  2232. $this->ReadImages(); $this->ReadPosts();
  2233. $this->SwitchWayBackMode(); if(isset($this->WayBack)){$this->ReadArchive();}
  2234. $im = &$this->FindImage($m);
  2235. if($im==NULL || !isset($im['refs']) || !isset($im['refs'][0])){ echo "not_found"; exit; }
  2236. if($direct_return){
  2237. echo "<ref>".sizeof($im['refs'])."</ref>";
  2238. echo "<insert><ul>";
  2239. }else{ ob_start(); }
  2240. foreach(array_reverse($im['refs']) as $ref){
  2241. $p = $this->GetPost($ref);
  2242. if(!$p || !$this->CanShowPost($p)) continue;
  2243. $this->MakeSinglePost($p, false, true, "post_preview", true, false, false, false, true);"</li>";
  2244. }
  2245. if($direct_return){
  2246. echo "</ul></insert>";
  2247. $this->MakeHereButtons($im, true);
  2248. }else{
  2249. $str = ob_get_clean();
  2250. $this->MakePageBegin();
  2251. $side = "";
  2252. if(isset($im['refs'])&&isset($im['refs'][0])){
  2253. $side.="<span class='small'>".$this->T('该图片出现在')." ".sizeof($im['refs'])." ".$this->T('个帖子中')."</span>";
  2254. }else{$side.="<span class='smaller gray'>".$this->T('该图片未被引用')."</span>";}
  2255. $static_image = isset($im['video'])?NULL:$im['file'];
  2256. $static_video = isset($im['video'])?$im['file']:NULL;
  2257. $this->MakeImageOverlay($side."<ul>".$str."</ul>",$static_image,$static_video);
  2258. $this->MakePageEnd();
  2259. }
  2260. exit;
  2261. }
  2262. if(isset($_GET['confirm_enter']) && $_GET['confirm_enter']!=false){
  2263. setcookie('la_experimental','confirmed'); $_COOKIE['la_experimental'] = $_GET['confirmed'];
  2264. $redirect='index.php'.(isset($_GET['post'])?'?post='.$_GET['post']:"");return 0;
  2265. }
  2266. if(isset($_GET['apub_actor'])){
  2267. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2268. echo $this->APubActor; exit;
  2269. }
  2270. if(isset($_GET['apub_outbox'])){
  2271. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2272. echo $this->APubMakeOutbox(); exit;
  2273. }
  2274. if($this->LoggedIn){
  2275. $this->DoUpload();
  2276. if(isset($_POST['settings_button'])){
  2277. if(isset($_POST['settings_title'])) $this->Title=$_POST['settings_title'];
  2278. if(isset($_POST['settings_short_title'])) $this->ShortTitle=$_POST['settings_short_title'];
  2279. if(isset($_POST['settings_display_name'])) $this->DisplayName=$_POST['settings_display_name'];
  2280. if(isset($_POST['settings_email'])) $this->EMail=$_POST['settings_email'];
  2281. if(isset($_POST['settings_special_navigation'])) $this->SpecialNavigation=$_POST['settings_special_navigation'];
  2282. if(isset($_POST['settings_special_footer'])) $this->SpecialFooter=$_POST['settings_special_footer'];
  2283. if(isset($_POST['settings_special_footer2'])) $this->SpecialFooter2=$_POST['settings_special_footer2'];
  2284. if(isset($_POST['settings_special_pinned'])) $this->SpecialPinned=$_POST['settings_special_pinned'];
  2285. if(isset($_POST['settings_default_gallery'])) $this->DefaultGallery=$_POST['settings_default_gallery'];
  2286. if(isset($_POST['settings_selfauth_path'])) $this->SelfAuthPath=$_POST['settings_selfauth_path'];
  2287. if(isset($_POST['settings_enable_comments'])) $this->CommentEnabled=True; else $this->CommentEnabled=False;
  2288. if(isset($_POST['settings_here_host'])) $this->HereHost=$_POST['settings_here_host'];
  2289. if(isset($_POST['settings_here_title'])) $this->HereTitle=$_POST['settings_here_title'];
  2290. if(isset($_POST['settings_here_short_title'])) $this->HereShortTitle=$_POST['settings_here_short_title'];
  2291. if(isset($_POST['settings_here_album'])) $this->HereAlbum=$_POST['settings_here_album'];
  2292. if(isset($_POST['settings_here_navigation'])) $this->HereNavigation=$_POST['settings_here_navigation'];
  2293. if(isset($_POST['settings_here_footer'])) $this->HereFooter=$_POST['settings_here_footer'];
  2294. if(isset($_POST['settings_exp_host'])) $this->ExpHost=$_POST['settings_exp_host'];
  2295. if(isset($_POST['settings_exp_title'])) $this->ExpTitle=$_POST['settings_exp_title'];
  2296. if(isset($_POST['settings_exp_short_title'])) $this->ExpShortTitle=$_POST['settings_exp_short_title'];
  2297. if(isset($_POST['settings_exp_caution'])) $this->ExpCaution=$_POST['settings_exp_caution'];
  2298. if(isset($_POST['settings_exp_album'])) $this->ExpAlbum=$_POST['settings_exp_album'];
  2299. if(isset($_POST['settings_exp_navigation'])) $this->ExpNavigation=$_POST['settings_exp_navigation'];
  2300. if(isset($_POST['settings_exp_footer'])) $this->ExpFooter=$_POST['settings_exp_footer'];
  2301. if(isset($_POST['settings_mastodon_token'])) $this->MastodonToken=$_POST['settings_mastodon_token'];
  2302. if(isset($_POST['settings_mastodon_url'])) $this->MastodonURL=$_POST['settings_mastodon_url'];
  2303. if(isset($_POST['settings_mastodon_lang'])) $this->MastodonPreferredLang=$_POST['settings_mastodon_lang'];
  2304. if(isset($_POST['settings_host_url'])) $this->HostURL=$_POST['settings_host_url'];
  2305. if(isset($_POST['settings_apub_id']) && isset($this->HostURL)) {
  2306. $this->APubID=$_POST['settings_apub_id'];
  2307. $this->APubEnsureWebfinger($this->APubID,$this->HostURL);
  2308. }
  2309. if(isset($_POST['settings_old_password'])&&password_verify($_POST['settings_old_password'], $this->Password)){
  2310. if(isset($_POST['settings_id'])) $this->Admin=$_POST['settings_id'];
  2311. if(isset($_POST['settings_new_password']) && isset($_POST['settings_new_password_redo']) &&
  2312. $_POST['settings_new_password'] = $_POST['settings_new_password_redo'])
  2313. {$this->Password=password_hash($_POST['settings_new_password'], PASSWORD_DEFAULT);}
  2314. $redirect=$_SERVER['REQUEST_URI'];
  2315. $this->DoLogout();
  2316. }
  2317. $this->WriteConfig();
  2318. return 0;
  2319. }
  2320. if(isset($_POST['settings_save_redirect'])){
  2321. if(isset($_POST['settings_redirect'])){
  2322. $this->BuildRedirectConfig($_POST['settings_redirect']);
  2323. }
  2324. $this->WriteConfig();
  2325. $redirect = 'index.php?extras=true'; return 0;
  2326. }
  2327. if(isset($_POST['settings_save_translation'])){
  2328. if(isset($_POST['settings_translation'])){
  2329. $f = fopen("custom_translations.md", "w"); fwrite($f,$_POST['settings_translation']); fflush($f); fclose($f);
  2330. }
  2331. $redirect = 'index.php?extras=true'; return 0;
  2332. }
  2333. if(isset($_GET['post'])){
  2334. if(isset($_GET['post_original'])){
  2335. echo $this->EditPost($_GET['post'],NULL,false,NULL,true,NULL,NULL,false,NULL,NULL);
  2336. exit;
  2337. }
  2338. }
  2339. if(isset($_GET['mark_delete']) && isset($_GET['target'])){
  2340. $this->EditPost($_GET['target'],NULL,$_GET['mark_delete']=='true',NULL,false,NULL,NULL,false,NULL,NULL);
  2341. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2342. return 0;
  2343. }
  2344. if(isset($_GET['set_mark']) && isset($_GET['target'])){
  2345. $this->EditPost($_GET['target'],NULL,NULL,NULL,NULL,$_GET['set_mark'],NULL,false,NULL,NULL);
  2346. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2347. return 0;
  2348. }
  2349. if(isset($_POST['post_button']) && isset($_POST['post_content'])){
  2350. $c = $_POST['post_content'];
  2351. if('有什么想说的' == $c){ return 0;}
  2352. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2353. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2354. $reply_to = (isset($_POST['post_reply_to'])&&$_POST['post_reply_to']!="")?$_POST['post_reply_to']:NULL;
  2355. $edit_id = (isset($_POST['post_edit_target'])&&$_POST['post_edit_target']!="")?$_POST['post_edit_target']:NULL;
  2356. $push_history = (isset($edit_id) && isset($_POST['post_record_edit']));
  2357. if(($edited = $this->EditPost($edit_id, $c, NULL, $reply_to,NULL,NULL,NULL,$push_history,NULL,NULL))!=NULL){
  2358. $redirect='?post='.$edited['id']; return 0;
  2359. };
  2360. }
  2361. if(isset($_POST['post_rename_confirm']) && isset($_POST['post_rename_name']) && isset($_GET['rename_post'])){
  2362. if(($edited =$this->EditPost($_GET['rename_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,NULL))!=NULL){
  2363. $redirect='?post='.$edited['id']; return 0;
  2364. };
  2365. }
  2366. if(isset($_POST['post_mastodon_confirm']) && isset($_POST['post_mastodon_url']) && isset($_GET['mastodon_post'])){
  2367. if(($edited =$this->EditPost(
  2368. $_GET['mastodon_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,$_POST['post_mastodon_url']))!=NULL){
  2369. $redirect='?post='.$edited['id']; return 0;
  2370. };
  2371. }
  2372. if(isset($_GET['mastodon_send_post']) && preg_match('/([0-9]{14})/u',$_GET['mastodon_send_post'],$m)){
  2373. $this->ReadImages(); $this->ReadPosts(); $post = &$this->GetPost($m[1]); $err=$this->T("未知错误");
  2374. if(isset($post)){
  2375. if($mastodon_url = $this->MastodonSendPost($post, $err)){
  2376. $this->NeedWritePosts = 1; $this->WritePosts(); // for mastodon url
  2377. echo "SUCCESS ".$mastodon_url;
  2378. }else{ echo $err; }
  2379. } exit;
  2380. }
  2381. if(isset($_GET['merge_threads'])&&$_GET['merge_threads']!=""){
  2382. if(preg_match('/([0-9]{14})\s+([0-9]{14})/u',$_GET['merge_threads'],$m)){
  2383. if(($pe = &$this->MergeThreads($m[1],$m[2]))!=$this->NULL_POST){ $redirect='?post='.$pe['id']; return 0; }
  2384. }
  2385. }
  2386. if(isset($_GET['merge_posts'])&&$_GET['merge_posts']!=""){
  2387. if(($pe = &$this->MergePosts($_GET['merge_posts']))!=$this->NULL_POST){
  2388. $redirect='?post='.$pe['id']; return 0;
  2389. }
  2390. }
  2391. if ($this->CommentEnabled && isset($_POST['comment_confirm']) && (isset($_GET['comment_to']))
  2392. && isset($_POST['comment_box']) && isset($_POST['comment_email']) && isset($_POST['comment_name'])){
  2393. $c = $_POST['comment_box'];
  2394. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2395. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2396. $comment_to = ($_GET['comment_to']!="")?$_GET['comment_to']:NULL;
  2397. if(($edited = $this->EditComment(NULL,
  2398. $_GET['comment_to'], $c, $_POST['comment_email'], $_POST['comment_name'],
  2399. isset($_POST['comment_link'])?$_POST['comment_link']:NULL,
  2400. $_SERVER['REMOTE_ADDR']))!=NULL){
  2401. $redirect='?post='.$_GET['post'];
  2402. return 0;
  2403. };
  2404. }
  2405. if(isset($_POST['gallery_edit_confirm']) && isset($_POST['gallery_edit_new_name']) && $_POST['gallery_edit_new_name']!=''){
  2406. $old_name = isset($_POST['gallery_edit_old_name'])?$_POST['gallery_edit_old_name']:"";
  2407. $new_name = $_POST['gallery_edit_new_name'];
  2408. if($old_name!=''){
  2409. $this->EditGallery($old_name, $new_name, false, true, null, null);
  2410. $redirect='?gallery='.$new_name;
  2411. }else{
  2412. $this->EditGallery(null, $new_name, false, true, null);
  2413. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2414. }
  2415. return 0;
  2416. }
  2417. if(isset($_GET['gallery_edit_delete'])&&$_GET['gallery_edit_delete']!=null){
  2418. $this->EditGallery($_GET['gallery_edit_delete'], null, true, true, null, null);
  2419. if(isset($_GET['gallery'])) $redirect='?gallery=main'; else $redirect='index.php';
  2420. return 0;
  2421. }
  2422. if(isset($_POST['gallery_move_ops'])&&isset($_POST['gallery_move_ops'])){
  2423. if(preg_match('/^(REM|ADD)\s+(\S+)\s+(.*)$/u', $_POST['gallery_move_ops'], $ma)){
  2424. $this->ReadImages();
  2425. if(preg_match_all('/(\S+)/u', $ma[3], $files, PREG_SET_ORDER)) foreach($files as $name){
  2426. $this->EditImage($name[1], $ma[2], ($ma[1]=='REM'), NULL, NULL, NULL);
  2427. }
  2428. }
  2429. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2430. return 0;
  2431. }
  2432. if(isset($_GET['gallery_set_featured'])&&isset($_GET['value'])){
  2433. $this->EditGallery($_GET['gallery_set_featured'], null, false, true, $_GET['value']!='false', null);
  2434. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2435. return 0;
  2436. }
  2437. if(isset($_GET['gallery_set_experimental'])&&isset($_GET['value'])){
  2438. $this->EditGallery($_GET['gallery_set_experimental'], null, false, true, null, $_GET['value']!='false');
  2439. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2440. return 0;
  2441. }
  2442. if(isset($_GET['image_list'])&&$_GET['image_list']!=""){
  2443. $this->ReadImages();
  2444. $gallery = $_GET['image_list'];
  2445. foreach($this->Images as $im){
  2446. if($gallery=='main'){ echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; continue; }
  2447. if(isset($im['galleries']) && isset($im['galleries'][0]) && in_array($gallery,$im['galleries'])) {
  2448. echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; }
  2449. }
  2450. exit;
  2451. }
  2452. $do_image_redirect = 0;
  2453. if (isset($_POST['image_button']) && isset($_GET['pic']) &&
  2454. preg_match('/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4))/u',$_GET['pic'],$ma)){
  2455. $this->ReadImages(); $pic = $ma[1]; $picext=$ma[2];
  2456. if(isset($_POST['image_ops_product_link'])){
  2457. $this->EditImage($pic, NULL, false, $_POST['image_ops_product_link'], NULL, NULL);
  2458. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2459. }
  2460. if(isset($_POST['image_edit_new_name']) && preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_edit_new_name'],$man)){
  2461. $this->EditImage($pic, NULL, false, NULL, $man[1], NULL);
  2462. $redirect=$this->GetRedirect(['pic'=>'images/'.$man[1].'.'.$picext]);
  2463. $do_image_redirect = 1;
  2464. }
  2465. if(isset($_POST['image_parent'])){ $parent="";
  2466. if(preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_parent'],$man)){ $parent = $man[1]; }
  2467. $this->EditImage($pic, NULL, false, NULL, NULL, $parent);
  2468. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2469. }
  2470. $this->NeedWriteImages = 1;
  2471. if($do_image_redirect) return 0;
  2472. }
  2473. if(isset($_GET['rewrite_styles'])){
  2474. $this->WriteStyles();
  2475. $redirect='?extras=true'; return 0;
  2476. }
  2477. if(isset($_GET['regenerate_thumbnails'])){
  2478. $this->RegenerateThumbnails();
  2479. $redirect='?extras=true'; return 0;
  2480. }
  2481. if(isset($_GET['clear_all_logins'])){
  2482. $this->LoginTokens=[];
  2483. $this->WriteTokens();
  2484. }
  2485. }
  2486. return 0;
  2487. }
  2488. function PostProcessHTML($html,&$added_images=null,$do_product_info=false, &$product_info=null, &$orig_src_list=null, &$end_wide=null, &$print_wide=null){
  2489. if(!$this->LoggedIn){
  2490. $html = preg_replace("/(<a[^>]*href=[\'\"])(.*?)([\'\"][^>]*)>(\#.*?<\/a>)/u","",$html);
  2491. }
  2492. $html = preg_replace("/(<a[^>]*href=[\'\"])([0-9]{14})([\'\"][^>]*)>(.*?<\/a>)/u","$1?post=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2493. $html = preg_replace("/(<a[^>]*href=[\'\"])\@(.*?)([\'\"][^>]*)>(.*?<\/a>)/u","$1?category=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2494. $html = preg_replace("/(<a[^>]*href=[\'\"])((.*?:\/\/).*?)([\'\"][^>]*)(>)(.*?)(<\/a>)/u",
  2495. "$1$2$4 target='_blank'$5$6<sup>↗</sup>$7",$html);
  2496. $html = preg_replace("/<p>\s*\@.*?<\/p>/mu","",$html);
  2497. $html = preg_replace("/\{\s*(INTERESTING|HEADER|FOOTER)\s+(.*?)\}/imu","",$html);
  2498. $html = preg_replace("/\{\s*(REVERSED|NO_TIME)\s*\}/imu","",$html);
  2499. $html = preg_replace("/\{\s*WIDE\s*\}/imu","",$html,-1,$rep_count); if($rep_count){$print_wide=true;}
  2500. $images = []; $images_noclick = []; $images_orig_src_list = [];
  2501. $html = preg_replace_callback(
  2502. "/(<p>\s*|<a\s.*?>\s*)?(<img([^>]*)src=[\'\"])(images\/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4)))([\'\"][^>]*)\/>(\s*<\/p>)?/u",
  2503. function($m) use (&$images,&$images_noclick,&$images_orig_src_list) {
  2504. if(isset($m[1])&&$m[1]&&$m[1][1]=='a'){ $height="";
  2505. if(preg_match("/([0-9]{1,2})em/u",$m[0],$hm)){$height=' style="height:'.$hm[1].'em;"';}
  2506. return "<a class='imbtn'".$height.substr($m[0],2); }
  2507. $orig_src = $src = $m[5]; $keep = false; $original = false;
  2508. if (preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[3]) ||
  2509. preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[7])) { $keep=true; }
  2510. if ($keep && preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[3]) ||
  2511. preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[7])) { $original=true; }
  2512. if(($im = &$this->FindImage($m[5]))!=NULL && isset($im['thumb'])){
  2513. $src = $im['thumb']; $orig_src=$im['file'];
  2514. }if($im == NULL){ $im = &$this->NULL_IMAGE_DUMMY; }
  2515. $media_start = $m[2];
  2516. $media_end = $m[7];
  2517. $dataset = " data-imgsrc='".$m[5]."'".
  2518. (isset($im['product'])?" data-product='".$im['product']."'":"").
  2519. (isset($im['parent'])?" data-parent='".$im['parent']."'":"").
  2520. ($original?" class='original_img'":"");
  2521. if(isset($im['video']) && isset($im['video'])!=''){
  2522. $media_start = "<video controls".$dataset."><source src='"; $media_end="' type='".$im['video']."'></video";
  2523. $src = $orig_src; $dataset="";
  2524. }
  2525. if($this->InHereMode){
  2526. $click = "<div class='imd'>"."<a href='?here=".$im['file']."' class='original_img'>".
  2527. $media_start.$orig_src.$media_end."></a></div>";
  2528. return $click;
  2529. }else{
  2530. $click ="<div class='imd'><a href='?show_image={$im['name']}' target='_blank' onclick='event.preventDefault();'>".
  2531. $media_start.($original?$orig_src:$src).$media_end.$dataset."></a></div>";
  2532. $images_noclick[]=$media_start.$src.$media_end.">"; $images_orig_src_list[]=$orig_src;
  2533. $ret = "";
  2534. if($keep) { $ret = $click; }
  2535. else { $images[] = $click; }
  2536. if(isset($m[1])&&isset($m[8])&&$m[1]&&$m[8]) return $ret;
  2537. else return ((isset($m[1])&&$m[1]?$m[1]:"").$ret.(isset($m[8])&&$m[8]?$m[8]:""));
  2538. }
  2539. },$html,-1,$count);
  2540. $html = preg_replace('/<p>\s*<\/p>/u',"", $html); if($html==""){$html="<p>&nbsp;</p>";}
  2541. if(sizeof($images)){
  2542. if(sizeof($images)==1){$html.= $images[0]; }
  2543. else{
  2544. $html.="<div class='p_row'>";
  2545. foreach($images as $img){
  2546. $html.="<div class='p_thumb'>".$img."</div>";
  2547. }
  2548. $html.="<div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div>";
  2549. }
  2550. }
  2551. if(sizeof($images_noclick)){ $added_images = $images_noclick; }
  2552. if(sizeof($images_orig_src_list)) { $orig_src_list = $images_orig_src_list; }
  2553. if($do_product_info){
  2554. $html = preg_replace_callback("/\{PRICE\s+([^]]+?)\}/u",
  2555. function($m) use (&$product_info) { $product_info['price']=$m[1];return ""; },$html);
  2556. $html = preg_replace_callback("/\{SHORT\s+([^]]+?)\}/u",
  2557. function($m) use (&$product_info) { $product_info['short']=$m[1];return ""; },$html);
  2558. $html = preg_replace('/<p>\s*<\/p>/u',"", $html);
  2559. if (preg_match('/<h[1-5]>(.+?)<\/h/u',$html,$title)){ $product_info['title']=$title[1]; }
  2560. else { $product_info['title'] = $this->T('商品'); }
  2561. if(!isset($product_info['price'])) $product_info['price']=$this->T('未设置价格');
  2562. $html = preg_replace_callback("/\{PURCHASE\s+([^]]+?)\}/u",function($m) use (&$product_info) {
  2563. return "<a class='purchase_button' href=\"mailto:".$this->T($this->DisplayName)."<".$this->EMail.">?subject=".
  2564. $this->T('购买').' '.$product_info['title'].
  2565. "&body=".$this->T('你好!我想购买').$product_info['title'].urlencode(PHP_EOL.PHP_EOL).
  2566. $this->FullURL().urlencode(PHP_EOL.PHP_EOL)."\">".$m[1]."</a>"; },$html);
  2567. }
  2568. if(preg_match("/(<\/div>|<\/table>|<\/video>)\s*$/u",$html)){$end_wide=true;}
  2569. return $html;
  2570. }
  2571. function ConvertPost(&$post){
  2572. if(!isset($post['html'])){
  2573. $info=[];
  2574. $post['html'] = $this->TranslatePostParts($this->PostProcessHTML($this->ChoosePartsByLanguage($this->PDE->text($this->InsertReplacementSymbols($post['content'], $post)),true),
  2575. $post['images'],
  2576. isset($post['product']), $info,
  2577. $post['original_images'],
  2578. $post['end_wide'],
  2579. $post['wide']));
  2580. if(isset($post['product'])) $post['product']=$info;
  2581. }
  2582. }
  2583. function GetPostTitle(&$post, $h1_only=false, $add_unamed=true){
  2584. if(!isset($post['title'])){
  2585. if($h1_only){
  2586. if(preg_match('/^#\s+(.*?)$/mu',$post['content'],$m)){return $m[1];}
  2587. return NULL;
  2588. }
  2589. if(preg_match('/^#{1,6}\s+(.*?)$/mu',$post['content'],$m)){$post['title']=$m[1];}
  2590. else{ $post['title'] = $add_unamed?$this->T('未命名'):"";
  2591. if(preg_match('/(.*)$/mu',$post['content'],$m)){
  2592. $post['title'].=($add_unamed?' (':'').strip_tags($this->PDE->text($m[1])).($add_unamed?')':''); }
  2593. }
  2594. }
  2595. return $this->ChoosePartsByLanguage($post['title']);
  2596. }
  2597. function DetectPageType(){
  2598. if ($this->InExperimentalMode) $this->PageType='experimental';
  2599. else if($this->InHereMode) $this->PageType='here';
  2600. else if(isset($_GET['history'])) $this->PageType='history';
  2601. else if(isset($_GET['extras'])) $this->PageType='extras';
  2602. else if(isset($_GET['settings'])) $this->PageType='settings';
  2603. else if(isset($_GET['gallery'])) $this->PageType='gallery';
  2604. else if(isset($_GET['search'])) $this->PageType='search';
  2605. else if(isset($_GET['category'])) $this->PageType='category';
  2606. else if(isset($this->CurrentPostID)) $this->PageType = "post";
  2607. else if(isset($_GET['comments'])) $this->PageType='comments';
  2608. else $this->PageType = "main";
  2609. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  2610. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  2611. $this->VisitedHere = $_SESSION[$visited_here];
  2612. }
  2613. function MakePageBegin(){ ?>
  2614. <!DOCTYPE html><html lang='zh-Hans-CN'>
  2615. <head>
  2616. <meta charset='utf-8'>
  2617. <meta content="width=device-width, initial-scale=1" name="viewport">
  2618. <title><?=$this->InExperimentalMode?$this->T($this->ExpTitle):
  2619. ($this->InHereMode?$this->T($this->HereTitle):$this->T($this->Title))?></title>
  2620. <?php if($this->UseRemoteFont){ ?><style>
  2621. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Regular.otf") format("opentype");font-weight:normal;}
  2622. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Bold.otf") format("opentype");font-weight:bold;}
  2623. </style><?php } ?>
  2624. <link href='styles/main.css' rel='stylesheet' type="text/css">
  2625. <link rel="alternate" type="application/rss+xml" title="<?=$this->T($this->Title);?>" href="?rss=<?=$this->LanguageAppendix;?>" />
  2626. <?php if(isset($this->SelfAuthPath)&&$this->SelfAuthPath!=""){ ?>
  2627. <link rel="authorization_endpoint" href="<?=$this->SelfAuthPath?>" /><?php } ?>
  2628. </head>
  2629. <div class='page'>
  2630. <?php }
  2631. function MakeHeader(&$p){
  2632. $this->MakePageBegin() ?>
  2633. <script type='text/javascript'>
  2634. function toggle_mobile_show(a){a.classList.toggle('hidden_on_mobile')}
  2635. function ShowWaitingBar(){
  2636. wait = document.querySelector("#waiting_bar");
  2637. wait.style.display='';
  2638. }
  2639. function HideWaitingBar(){
  2640. wait = document.querySelector("#waiting_bar");
  2641. wait.style.display='none';
  2642. }
  2643. <?php if(!$this->InHereMode){ ?>
  2644. function la_auto_grow(element){
  2645. s=window.scrollY;element.style.height="30px";element.style.height=(element.scrollHeight)+"px";window.scroll(0, s);
  2646. }
  2647. var scroll_l=0,scroll_c=0;in_center=1;
  2648. function ShowLeftSide(){
  2649. scroll_c = window.scrollY;
  2650. document.getElementById('div_left').classList.remove('hidden_on_mobile');
  2651. document.getElementById('div_center').classList.add('hidden_on_mobile');
  2652. window.scroll(0, scroll_l); in_center=0;
  2653. }
  2654. function ShowCenterSide(){
  2655. scroll_l = window.scrollY;
  2656. document.getElementById('div_center').classList.remove('hidden_on_mobile');
  2657. document.getElementById('div_left').classList.add('hidden_on_mobile');
  2658. window.scroll(0, scroll_c); in_center=1;
  2659. }
  2660. function ShowBackdrop(alpha=0.5){
  2661. b = document.getElementById('backdrop');
  2662. b.style="background-color:rgba(0,0,0,"+alpha+");";
  2663. b.style.animation='backdrop_fade_in 0.3s forwards';
  2664. b.style.display = 'block';
  2665. }
  2666. function HideBackdrop(){
  2667. b = document.getElementById('backdrop');
  2668. b.style.animation='backdrop_fade_out 0.3s forwards';
  2669. setTimeout(function(e1){e1.style.display='none';}, 300, b);
  2670. }
  2671. function ShowRightSide(big,elem_to_clone){
  2672. p = document.getElementById('pop_right');
  2673. if(elem_to_clone){
  2674. c = elem_to_clone.cloneNode(true);
  2675. c.id='side_bar_cloned';c.className="";c.style="";
  2676. p.querySelector('._content').appendChild(c);
  2677. }
  2678. p.classList.remove('pop_right','pop_right_big');
  2679. if(big) {p.classList.add('pop_right_big');p.style.animation='pop_slide_in_big 0.3s forwards';}
  2680. else {p.classList.add('pop_right');p.style.animation='pop_slide_in 0.3s forwards';}
  2681. p.style.display='block';
  2682. ShowBackdrop(0.5);
  2683. }
  2684. function HideRightSide(){
  2685. p = document.getElementById('pop_right');
  2686. if(side=p.querySelector('#side_bar_cloned')){
  2687. side.remove();
  2688. }
  2689. put = document.querySelector("#_uploader");
  2690. if(p.classList.contains('pop_right')){p.style.animation='pop_slide_out 0.3s forwards';}
  2691. else{p.style.animation='pop_slide_out_big 0.3s forwards';}
  2692. setTimeout(function(e1, e2){e1.style.display='none';if(e2)e2.style.display='none';}, 300, p, put);
  2693. HideBackdrop();
  2694. }
  2695. function ToggleLeftSide(){if(in_center)ShowLeftSide();else ShowCenterSide();}
  2696. function CssNumberID(id){ return "#\\3"+id.substr(0,1)+" "+id.substr(1); }
  2697. function ScrollToPost(id){
  2698. post=null;
  2699. if(!(post = document.querySelector("[data-post-id='"+id+"']"))){
  2700. if(!(post = document.querySelector(CssNumberID(id)))) return; }
  2701. post.scrollIntoView({ behavior: 'smooth', block: 'start'});
  2702. }
  2703. <?php } ?>
  2704. </script>
  2705. <header<?=$this->InHereMode?' class="exp_h_f"':''?>><div>
  2706. <?php if($this->InHereMode){
  2707. $this->MakeExpNavButtons($p);
  2708. }else{
  2709. $this->MakeNavButtons($p);
  2710. if(isset($p['tid']['header'])){ ?><div style='float:right' class='show_on_print'><?=$p['tid']['header'];?></div><?php }
  2711. echo "<hr />";
  2712. } ?>
  2713. <?php if(isset($this->WayBack)){
  2714. $time=(isset($_COOKIE['la_wayback']) && preg_match('/[0-9]{14}/u',$_COOKIE['la_wayback']))?$_COOKIE['la_wayback']:date('YmdHis');
  2715. $year=substr($time,0,4);$month=substr($time,4,2);$day=substr($time,6,2);
  2716. $hour=substr($time,8,2);$minute=substr($time,10,2);?> <div class='text_highlight'>
  2717. &nbsp;<b><span onclick='document.getElementById("wayback_config").classList.toggle("hidden_on_mobile")'>
  2718. <div class='wayback_close' onclick='event.stopPropagation()'><a href='<?=$this->GetRedirect()?>&set_wayback=false'>
  2719. <span class='hidden_on_mobile'><?=$this->T('退出')?></span>×&nbsp;</a></div>
  2720. <?=$this->T('正以过去的日期浏览')?></b><div id='wayback_config' class='wayback_expand hidden_on_mobile'>
  2721. <select id="wayback_year" name="wayback_year" form="wayback_form"><?php for($y=$this->YearBegin;$y<=$this->YearEnd;$y++){ ?>
  2722. <option value="<?=$y?>"<?=$y==$year?" selected":""?>><?=$y?></option><?php } ?></select>
  2723. <br class='hidden_on_desktop' />
  2724. <select id="wayback_month" name="wayback_month" form="wayback_form"><?php for($y=1;$y<=12;$y++){ ?>
  2725. <option value="<?=$y?>"<?=$y==$month?" selected":""?>><?=$y?></option><?php } ?></select>
  2726. <select id="wayback_day" name="wayback_day" form="wayback_form"><?php for($y=1;$y<=31;$y++){ ?>
  2727. <option value="<?=$y?>"<?=$y==$day?" selected":""?>><?=$y?></option><?php } ?></select>
  2728. <br class='hidden_on_desktop' />
  2729. <select id="wayback_hour" name="wayback_hour" form="wayback_form"><?php for($y=0;$y<=23;$y++){ ?>
  2730. <option value="<?=$y?>"<?=$y==$hour?" selected":""?>><?=$y?></option><?php } ?></select>:
  2731. <select id="wayback_minute" name="wayback_minute" form="wayback_form"><?php for($y=0;$y<=59;$y++){ ?>
  2732. <option value="<?=$y?>"<?=$y==$minute?" selected":""?>><?=$y?></option><?php } ?></select>
  2733. <br class='hidden_on_desktop' />
  2734. <form action="<?=$this->GetRedirect()?>&set_wayback=post" method="post" style='display:none;' id='wayback_form'></form>
  2735. <input type='submit' style='font-weight:normal;border-bottom:none;' class='button clean_a' form='wayback_form'
  2736. id='wayback_see' name='wayback_see' value="<?=$this->T('查看')?> →">
  2737. </div></div><?php } ?>
  2738. </div></header>
  2739. <div id='waiting_bar' style='display:none;'></div>
  2740. <script>ShowWaitingBar();window.addEventListener('load',(event) =>{HideWaitingBar();}); </script>
  2741. <?php if(!$this->InHereMode){ ?>
  2742. <div id='post_menu' style='display:none;' class='pop_menu clean_a'>
  2743. <ul>
  2744. <li><span id='_time_hook' class='smaller'>时间</span>&nbsp;&nbsp;<a href='javascript:HidePopMenu();'>×</a></li>
  2745. <li><a id='share_copy'>⎘<?=$this->T('复制链接')?></a></li>
  2746. <hr />
  2747. <?php if($this->LoggedIn){ ?>
  2748. <li><a id='menu_history'><?=$this->T('历史')?></a>
  2749. <?php if(!isset($this->WayBack) && $this->PageType!='search'){ ?>
  2750. | <a id='menu_edit'><?=$this->T('修改')?></a><?php } ?></li>
  2751. <?php if(!isset($this->WayBack)){ ?><li>
  2752. <a id='menu_refer_copy'><?=$this->T('复制编号')?></a><?php if($this->PageType!='search'){ ?>
  2753. | <a id='menu_refer'><?=$this->T('引用')?></a><?php } ?><br class='hidden_on_desktop' />
  2754. </li>
  2755. <li><a id='menu_rename' href='javascript:ToggleRenameDetails()'><?=$this->T('改名')?></a> |
  2756. <a id='menu_mark' href='javascript:ToggleMarkDetails()'><?=$this->T('标记')?></a></li>
  2757. <li id='mark_details' style='display:none;'><b>
  2758. <a id='mark_set_clear' href='javascript:SetMark(-1);'>_</a>
  2759. <a id='mark_set_0' href='javascript:SetMark(0);'><?=$this->Markers[0]?></a>
  2760. <a id='mark_set_1' href='javascript:SetMark(1);'><?=$this->Markers[1]?></a>
  2761. <a id='mark_set_2' href='javascript:SetMark(2);'><?=$this->Markers[2]?></a>
  2762. <a id='mark_set_3' href='javascript:SetMark(3);'><?=$this->Markers[3]?></a>
  2763. <a id='mark_set_4' href='javascript:SetMark(4);'><?=$this->Markers[4]?></a>
  2764. <a id='mark_set_5' href='javascript:SetMark(5);'><?=$this->Markers[5]?></a>
  2765. <a id='mark_set_6' href='javascript:SetMark(6);'><?=$this->Markers[6]?></a>
  2766. <a id='mark_set_7' href='javascript:SetMark(7);'><?=$this->Markers[7]?></a>
  2767. </b></li>
  2768. <li id='rename_details' style='display:none;text-align:left;' class='smaller'>
  2769. <form action="" method="post" style='display:none;' id='post_rename_form'></form>
  2770. <input type='text' id='post_rename_name' name='post_rename_name' form="post_rename_form" style='width:9em;'>
  2771. <input class='button' type='submit' form='post_rename_form'
  2772. name='post_rename_confirm' id='post_rename_confirm' value='<?=$this->T('确认')?>'>
  2773. </li><hr /> <?php if(isset($this->MastodonToken)){ ?>
  2774. <li><a id='menu_mastodon_view' class='button' style='display:none;' target='_blank'><?=$this->T('转到')?></a>
  2775. <a id='menu_mastodon' href='javascript:ToggleMastodonDetails()'><?=$this->T('长毛象')?></a></li>
  2776. <li id='mastodon_details' style='display:none;text-align:left;' class='smaller'>
  2777. <a id='menu_mastodon_send' class='button' target='_blank'><?=$this->T('发送')?></a>
  2778. <form action="" method="post" style='display:none;' id='post_mastodon_form'></form>
  2779. <input type='text' id='post_mastodon_url' name='post_mastodon_url' form="post_mastodon_form" style='width:9em;'>
  2780. <input class='button' type='submit' form='post_mastodon_form'
  2781. name='post_mastodon_confirm' id='post_mastodon_confirm' value='<?=$this->T('修改')?>'></li> <?php } ?>
  2782. <hr /><li><a id='menu_delete' class='smaller'><?=$this->T('删除')?></a></li><?php } ?>
  2783. <?php }else{ ?>
  2784. <li><a id='menu_history'><?=$this->T('历史')?></a></li>
  2785. <?php } ?>
  2786. </ul>
  2787. </div>
  2788. <div id='backdrop' style='display:none;' class='backdrop' onclick='HideRightSide();HideBigImage(1);'
  2789. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"></div>
  2790. <div id='pop_right' class='pop_right' onclick='event.stopPropagation()'>
  2791. <div style='text-align:right;position:sticky;top:0;'><a class='clean_a' href='javascript:HideRightSide();'>
  2792. <?=$this->T('关闭')?>→</a></div>
  2793. <?php if($this->LoggedIn && in_array($this->PageType,['main','post'])){ ?>
  2794. <div id='_uploader' style='display:none;'>
  2795. <?php $this->MakeUploader(true); ?>
  2796. <p>&nbsp;</p>
  2797. <?php $this->MakeSideGalleryCode(); ?>
  2798. </div>
  2799. <?php } ?>
  2800. <div class='_content'></div>
  2801. </div>
  2802. <?php } ?>
  2803. <?php
  2804. }
  2805. function ChoosePartsByLanguage($content,$use_p=false){
  2806. $split = preg_split('/'.($use_p?'<p>\s*':'').'((en|zh|any)\|(en|zh|any))'.($use_p?'<\/p>\s*':'').'/u',$content, -1,
  2807. PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
  2808. $lang = $this->LanguageAppendix; $last_lang='0'; $reduced="";
  2809. if($split) for($i=0;$i<sizeof($split);$i+=4){
  2810. $this_lang = '0'; if($i+2>=sizeof($split)){ $this_lang = $last_lang; }else{ $this_lang = $split[$i+2]; }
  2811. if($this_lang==$lang || $this_lang=='any'){ $reduced.=$split[$i]; }
  2812. if($i+3<sizeof($split)){ $last_lang = $split[$i+3]; }
  2813. }
  2814. if(!$reduced)$reduced = $content;
  2815. return $reduced;
  2816. }
  2817. function TranslatePostParts($html){
  2818. $html = preg_replace_callback('/>(\s*)([^><]+?)(\s*)</u', function($ma){
  2819. $reduced = $this->ChoosePartsByLanguage($ma[2], false);
  2820. return ">".$ma[1].$this->T($reduced).$ma[3]."<";
  2821. }, $html);
  2822. return $html;
  2823. }
  2824. function MakeNavButtons(&$p){ $interesting=$this->IsInterestingPost($p); ?>
  2825. <a href='index.php' class='clean_a hidden_on_mobile' onclick='ShowWaitingBar()'><b><?=$this->T($this->Title)?></b></a>
  2826. <b><a class='hidden_on_desktop'
  2827. href='javascript:toggle_mobile_show(document.getElementById("mobile_nav"))'><?=$this->T($this->ShortTitle)?>...</a></b>
  2828. <div class='header_nav'>
  2829. <?php if($this->PageType=='post'){ ?>
  2830. <div class='toc_button hidden_on_print'>
  2831. <?php if(!$interesting && isset($p) && isset($p['refs']) && isset($p['refs'][0])){ ?>
  2832. <span class='hidden_on_desktop'><a id='button_ref' href='javascript:ToggleLeftSide();'>
  2833. <?=$this->T('链接')?>(<?=sizeof($p['refs'])?>)</a></span>
  2834. <?php } if(!$interesting){ ?>
  2835. <span class='hidden_on_wide hidden_on_print'>
  2836. <a id='button_toc' href='javascript:ShowRightSide(true,document.querySelector("#div_right"));'>
  2837. <?=$this->T('目录')?></a></span><?php } ?></div>
  2838. <?php }else if($this->PageType=='history' && isset($_GET['version'])){ ?>
  2839. <div style='float:right;' class='hidden_on_print'>
  2840. <span class='hidden_on_desktop'><a id='button_ref' href='javascript:ToggleLeftSide();'>
  2841. <?=$this->T('历史')?></a></span></div>
  2842. <?php } ?>
  2843. <ul class='hidden_on_mobile hidden_on_print' id='mobile_nav' style='text-align:center;'>
  2844. <li class='hidden_on_mobile'><a href='?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  2845. <li class='hidden_on_desktop_force block_on_mobile smaller'>&nbsp;</li>
  2846. <li class='hidden_on_desktop_force block_on_mobile'>
  2847. <?php if($this->PageType!='main'){ ?>
  2848. <a href='index.php?part=recent' onclick='ShowWaitingBar()'><?=$this->T('最近')?></a> |
  2849. <a href='index.php?part=hot' onclick='ShowWaitingBar()'><?=$this->T('热门')?></a>
  2850. <?php } else { ?>
  2851. <a href='javascript:ShowCenterSide();toggle_mobile_show(document.getElementById("mobile_nav"));'><?=$this->T('最近')?></a> |
  2852. <a href='javascript:ShowLeftSide();toggle_mobile_show(document.getElementById("mobile_nav"));'><?=$this->T('热门')?></a>
  2853. <?php } ?>
  2854. <?php if($this->LoggedIn){ ?>
  2855. | <span class='gray invert_a'><a href='index.php?comments=all'>@</a></span><?php } ?></li>
  2856. <li class='hidden_on_desktop_force block_on_mobile'>
  2857. <a href='index.php?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  2858. <?php $this->SpecialNavigation;if(isset($this->SpecialNavigation) && ($p = &$this->GetPost($this->SpecialNavigation))!=NULL){
  2859. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST);
  2860. } ?>
  2861. <li><a href='?search=' onclick='ShowWaitingBar()'><?=$this->T('搜索')?></a></li>
  2862. <li class='hidden_on_desktop_force block_on_mobile smaller'>&nbsp;</li>
  2863. <?php if($this->LanguageAppendix=='zh'){ ?>
  2864. <li class='invert_a smaller'>
  2865. <a href='<?=$this->GetRedirect().'&set_language=en'?>' onclick='ShowWaitingBar()'><b>汉语</b>/English</a></li>
  2866. <?php }else { ?>
  2867. <li class='smaller'>
  2868. <a class='invert_a' href='<?=$this->GetRedirect().'&set_language=zh'?>' onclick='ShowWaitingBar()'>
  2869. 汉语/<b>English</b></a>
  2870. <br class='hidden_on_desktop' />
  2871. <a id='translate_button' target='_blank'>&nbsp;[Google Translate]&nbsp;</a></li>
  2872. <?php } ?>
  2873. </ul>
  2874. </div>
  2875. <?php
  2876. }
  2877. function MakeExpNavButtons(&$p){ ?>
  2878. <a href='index.php' class='hidden_on_mobile'>
  2879. <b><?=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle)?></b></a>
  2880. <a class='hidden_on_desktop'
  2881. href='javascript:toggle_mobile_show(document.getElementById("mobile_nav"))'><b class='round_btn'>
  2882. <?=$this->InExperimentalMode?$this->T($this->ExpShortTitle):$this->T($this->HereShortTitle)?></b></a>
  2883. <a <?=$this->HereNumber==1?"class='gray'":("href=".$this->HereLinkFromNumber($this->HereNumber-1))?>>←</a>
  2884. <span><?=$this->HereNumber.'/'.sizeof($this->VisitedHere);?></span>
  2885. <span class='round_btn'>
  2886. <a href='<?=$this->HereNumber==sizeof($this->VisitedHere)?"?random_here=1":$this->HereLinkFromNumber($this->HereNumber+1);?>'>→</a>
  2887. <a href='?random_here=1'><?=$this->T("随机")?></a></span><span class='hidden_on_mobile'></span>
  2888. <ul class='hidden_on_mobile invert_a gray' id='mobile_nav' style='text-align:center;'>
  2889. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  2890. <li class='hidden_on_desktop block_on_mobile'><a href='index.php'><?=$this->T('主页')?></a></li>
  2891. <?php if($this->InExperimentalMode && isset($this->ExpNavigation) && ($p = &$this->GetPost($this->ExpNavigation))!=NULL){
  2892. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST);
  2893. }else if($this->InHereMode && isset($this->HereNavigation) && ($p = &$this->GetPost($this->HereNavigation))!=NULL){
  2894. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST);
  2895. } ?>
  2896. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  2897. <?php if($this->LanguageAppendix=='zh'){ ?>
  2898. <li class='smaller'><a href='<?=$this->GetRedirect().'&set_language=en'?>'><b>汉语</b>/English</a></li>
  2899. <?php }else { ?>
  2900. <li class='smaller'><a href='<?=$this->GetRedirect().'&set_language=zh'?>'>汉语/<b>English</b></a></li>
  2901. <li class='smaller'><a id='translate_button' target='_blank'>&nbsp;Google Translate&nbsp;</a></li>
  2902. <?php } ?>
  2903. </ul>
  2904. <?php
  2905. }
  2906. function GenerateLinkedPosts($ht){
  2907. $ht = preg_replace_callback('/<p>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>(.*)<\/a>[\s]*<\/p>/u',
  2908. function($m){
  2909. if(preg_match('/^\s*<img/u',$m[2])){ return $m[0]; }
  2910. $rp = &$this->GetPost($m[1], false, true);
  2911. $s="<div class='smaller block post ref_compact gray'>".
  2912. "<a href='?post=".$m[1]."' class='post_access invert_a smaller' onclick='ShowWaitingBar()'>→</a>".
  2913. "<div class='post_ref'><div class='smaller'>".$m[2]."</div>".
  2914. (($rp!==NULL && $this->CanShowPost($rp))?
  2915. $this->GenerateSinglePost($rp,false,false,false,true,$this->NULL_POST,true):$this->T("未找到该引用。")).
  2916. "</div></div>";
  2917. return $s;
  2918. },
  2919. $ht
  2920. );
  2921. $ht = preg_replace_callback('/<li>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>PRODUCT\s+(.*)<\/a>[\s]*<\/li>/u',
  2922. function($m){
  2923. $rp = &$this->GetPost($m[1], false, true);
  2924. $s="<div class='product_ref block post ref_compact'><a href='?post=".$m[1]."' class='clean_a' onclick='ShowWaitingBar()'>".
  2925. (($rp!==NULL && $this->CanShowPost($rp))?
  2926. $this->GenerateSinglePost($rp,true,false,false,true,$this->NULL_POST,true):$this->T("未找到该引用。")).
  2927. "</a></div>";
  2928. return $s;
  2929. },
  2930. $ht
  2931. );
  2932. return $ht;
  2933. }
  2934. function ExtractBigTables($html, &$table_out){
  2935. $table = NULL;
  2936. $new_html = preg_replace_callback('/<p>\s*\{big_table\}\s*<\/p>\s*(<table>[\s\S]*?<\/table>)/u', function ($m) use (&$table){
  2937. $table = $m[1];
  2938. return "";
  2939. }, $html);
  2940. $table_out = $table;
  2941. return $new_html;
  2942. }
  2943. function GenerateSinglePost(&$post, $strip_tags, $generate_anchor=false, $generate_refs=false,
  2944. $generate_thumbs=false, &$table_out, $hide_long = false){
  2945. $this->ConvertPost($post);
  2946. if($generate_anchor){ $this->CreatePostAnchor($post); }
  2947. $ht = $post['html'];
  2948. if(isset($post['mark_value']) && $post['mark_value']==5 && ($generate_thumbs || !$generate_anchor)){
  2949. $ht="<div class='product_thumb'>".$post['images'][0]."</div>".
  2950. "<p class='bold'>".$post['product']['title']."</p>".
  2951. (isset($post['product']['short'])?("<p class='smaller gray'>".$post['product']['short']."</p>"):"").
  2952. "<p class='smaller bold'>".$post['product']['price']."</p>";
  2953. return $ht;
  2954. }
  2955. if($hide_long){
  2956. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>[\s\S]*/u',"<p class='smaller bold'>[".$this->T("阅读更多")."]</p>", $ht);
  2957. }else{
  2958. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>/u',"", $ht);
  2959. }
  2960. if ($strip_tags){
  2961. $ht = strip_tags($ht,'<b><i><h1><h2><h3><h4><p><blockquote><span>');
  2962. $ht = preg_replace('/<p>\s*<\/p>/u',"", $ht);
  2963. $ht = "<div class='post_ref_main'>".$ht."</div>";
  2964. }
  2965. else{
  2966. if($generate_refs) $ht = $this->GenerateLinkedPosts($ht);
  2967. if($table_out!=$this->NULL_POST){
  2968. $table = NULL; $ht = $this->ExtractBigTables($ht,$table);
  2969. $table_out = $table;
  2970. }else{
  2971. $ht = preg_replace('/<p>\s*\{big_table\}\s*<\/p>/u','',$ht);
  2972. }
  2973. }
  2974. if ($strip_tags && $generate_thumbs && isset($post['images']) && isset($post['images'][0])){
  2975. $ht.="<div class='post_ref_images'><ul class='side_thumb ref_thumb'>";
  2976. foreach($post['images'] as $im){
  2977. $ht.="<li class='file_thumb'>".$im."</li>";
  2978. }
  2979. $ht.="</ul></div>";
  2980. }
  2981. return $ht;
  2982. }
  2983. function MakeSinglePostExp(&$post){
  2984. $big_table = ""; ?>
  2985. <li class='post post_dummy'>
  2986. <?=$this->GenerateSinglePost($post, false, false, true, false, $big_table, false); ?>
  2987. </li>
  2988. <?php if($big_table!=$this->NULL_POST) echo "</ul></li><div class='table_top'>".$big_table.'</div>';?>
  2989. <?php
  2990. }
  2991. function MakeSinglePost(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
  2992. $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
  2993. $generate_thumb = false, $is_top = false, $force_hide_long=false){
  2994. $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
  2995. $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
  2996. $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
  2997. $big_table = ($show_thread_link)?$this->NULL_POST:"";
  2998. $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
  2999. $title = $generate_anchor?$this->GetPostTitle($post, true):NULL;
  3000. $this->ConvertPost($post);// NEEDED FOR WIDE;
  3001. $is_wide = (isset($post['wide'])&&$post['wide']) || (isset($post['tid']) && isset($post['tid']['wide']) && $post['tid']['wide']);
  3002. ?>
  3003. <?=$title?"<li class='print_title'><h1>".$title."</h1></li>":""?>
  3004. <li class='post<?=isset($extra_class_string)?' '.$extra_class_string:''?><?=$side?" post_box":""?>'
  3005. <?=(!$side)?"data-post-id='".$post['id']."'":""?> <?=$is_deleted?"data-mark-delete='true'":""?>
  3006. <?=(!$side&&isset($post['mastodon_url']))?"data-mastodon_url='".$post['mastodon_url']."'":""?>
  3007. <?=$is_wide?" style='column-span:all;'":"";?>>
  3008. <?php if($mark_value>=0 && !$show_link && $mark_value!='P'){?>
  3009. <div class='smaller <?=$is_deleted?"gray":""?>'><?=$mark_value?> <?=$this->T('标记')?></div>
  3010. <?php } ?>
  3011. <?php if($is_top){?>
  3012. <div class='top_post_hint'><?=$this->T('置顶帖子')?><hr /></div>
  3013. <?php } ?>
  3014. <?php if(!$side && $show_link){ ?>
  3015. <a href='?post=<?=$post['id']?>' onclick='ShowWaitingBar()'>
  3016. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  3017. <?=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:($ref_count?"":"→")?>
  3018. </div>
  3019. <?php if($ref_count){ ?>
  3020. <div class='post_access ref_count'><?=$ref_count?></div>
  3021. <?php } ?>
  3022. </a>
  3023. <?php } ?>
  3024. <?=$side?"<a href='?post={$post['id']}' onclick='ShowWaitingBar()'>":""?>
  3025. <div class='<?=$side?"":($show_link?'post_width':'post_width_big')?><?=$is_deleted?" deleted_post":""?>'>
  3026. <?php if(!$side && !$strip_tags){?>
  3027. <div class='post_menu_button _menu_hook' >+</div>
  3028. <?php } if($is_product&&!$generate_anchor){
  3029. echo "<p class='smaller gray'>".$this->T('商品')."</p>";
  3030. echo "<div class='product_ref clean_a'><a href='?post={$post['id']}'>";} ?>
  3031. <?=$this->GenerateSinglePost($post, $strip_tags, $generate_anchor, true,
  3032. $generate_thumb,$big_table,($show_thread_link||$side||$force_hide_long)); ?>
  3033. <?php if($is_product&&!$generate_anchor){echo "</a></div>";} ?>
  3034. </div>
  3035. <?=$side?"</a>":""?> <?php
  3036. if(!$show_thread_link && $big_table!=$this->NULL_POST && !$side){
  3037. echo "</ul></li><div class='table_top'>".$big_table.'</div>';
  3038. ?><ul<?=$is_wide?"":" class='print_column'"?>>
  3039. <li class='post<?=isset($extra_class_string)?' '.$extra_class_string:''?>' <?=$is_deleted?"data-mark-delete='true'":""?>>
  3040. <?php
  3041. }
  3042. if($show_thread_link && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) &&
  3043. $post['tid']['first']['id']!=$post['id']){ ?>
  3044. <div class='gray smaller block opt_compact post'>
  3045. <a href='?post=<?=$post['tid']['first']['id']?>' onclick='ShowWaitingBar()'>
  3046. <div class='post_access invert_a hover_dark smaller'><?=isset($post['tid']['first']['mark_value'])?
  3047. $this->Markers[$post['tid']['first']['mark_value']]:"→"?></div></a>
  3048. <div class='post_width'><div class='smaller'><?=$this->T('回复给主题帖:')?></div>
  3049. <?=$this->GenerateSinglePost($post['tid']['first'], false, false, false, true,$this->NULL_POST,true);?>
  3050. </div>
  3051. </div>
  3052. <?php }
  3053. if($show_reply_count && isset($post['tid'])){ ?>
  3054. <a class='smaller block invert_a' href='?post=<?=$post['tid']['last']['id']?>'><?=$post['tid']['count']?>
  3055. <?=$this->T('个回复')?></a>
  3056. <?php }
  3057. ?>
  3058. </li>
  3059. <?php
  3060. }
  3061. function MakePostingFields($reply_to=NULL, $show_hint=false){
  3062. if(isset($this->WayBack)){ ?>
  3063. <span class='gray'><i><?=$this->T('以过去日期浏览时不能发帖。')?></i></span>
  3064. <?php return; } ?>
  3065. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='post_form'></form>
  3066. <div class='smaller'><div style='display:<?=$show_hint?"block":"none"?>;'>
  3067. <span id='post_hint_text'><?=$this->T('继续补充该话题:')?></span></div>
  3068. <div id='post_hint_modify' style='display:none;'>
  3069. <input type="checkbox" name="post_record_edit" value="1" form='post_form' checked> <?=$this->T('新增历史记录');?></div></div>
  3070. <textarea id="post_content" name="post_content" rows="4" form='post_form'
  3071. onfocus="if (value =='<?=$this->T('有什么想说的')?>'){value ='';}la_auto_grow(this);"
  3072. onblur="if (value ==''){value='<?=$this->T('有什么想说的')?>';la_auto_grow(this);}"
  3073. oninput="la_auto_grow(this);" onload="la_auto_grow(this);"><?=$this->T('有什么想说的')?></textarea>
  3074. <input class='button' form="post_form" type="submit" name='post_button' value=<?=$this->T('发送')?>
  3075. onclick='ShowWaitingBar();' />
  3076. | <a class='gray smaller pointer' onclick='ShowSideUploader();'><?=$this->T('图片')?></a>
  3077. <div style='float:right;'>
  3078. <a class='gray smaller pointer' onclick='t=document.querySelector("#post_content");t.value="";la_auto_grow(t);'>
  3079. <?=$this->T('清空')?></a>
  3080. <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
  3081. </div>
  3082. <input style='display:none;' type=input form="post_form" id='post_edit_target' name='post_edit_target' />
  3083. <script> la_auto_grow(document.getElementById("post_content"));</script>
  3084. <?php if($reply_to){ ?>
  3085. <input style='display:none;' type=input form="post_form" id='post_reply_to' name='post_reply_to' value='<?=$reply_to?>' />
  3086. <?php } ?>
  3087. <?php
  3088. }
  3089. function MakeCommentPosts(){
  3090. if(!$this->LoggedIn) return; ?>
  3091. <h2><?=$this->T('评论')?></h2><div class='spacer'></div>
  3092. <?php if(!$this->CommentEnabled){
  3093. echo "<p><span class='text_highlight'>&nbsp;".$this->T("已关闭评论")."&nbsp;</span></p><br />"; } ?>
  3094. <div class='comment'><ul>
  3095. <?php $i=0;
  3096. foreach(array_reverse($this->Posts) as $p){
  3097. if(!isset($p['comment_to'])) continue;
  3098. if($i < $this->CommentsPerPage * $this->CurrentOffset) {$i++; continue;}
  3099. $ht = $this->GenerateSinglePost($p, false, false, false, false, $t, false);
  3100. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3101. $post_to = $this->GetPost($p['comment_to']); $post_title = $this->GetPostTitle($post_to);
  3102. if(!$post_to) $post_title = "?";
  3103. $mail = "<span class='gray hidden_on_print'>&nbsp;".
  3104. "<a href='mailto:".$p['email']."'>@</a>&nbsp;".
  3105. (isset($p['ip'])?$p['ip']:"?")."&nbsp;<br class='hidden_on_desktop'/>".
  3106. "<a href='index.php?post=".$p['comment_to']."'>(".$post_title.")</a></span>";
  3107. echo "<li><p><b>".$name.":</b>".$mail."<br /></p>".$ht."</li>";
  3108. $i++;
  3109. }
  3110. ?>
  3111. </ul><br /></div>
  3112. <?php
  3113. }
  3114. function MakeRecentPosts($search_term=NULL, $category=NULL){?>
  3115. <div class='center' id='div_center'>
  3116. <h2><?=isset($search_term)?$this->T('搜索'):
  3117. (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
  3118. ($category=='none'?$this->T('未分类'):$this->T($category))):($this->T('最近')).
  3119. " <span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
  3120. ($this->LoggedIn?"<a href='index.php?comments=all'>@</a>":"")."</span>")?></h2>
  3121. <?php if(isset($search_term)){ ?>
  3122. <form action="index.php" method="post" style='display:none;' id='search_form'></form>
  3123. <input id="search_content" name="search_content" rows="4" form='search_form' type='text' value='<?=$search_term?>'>
  3124. <input class='button' form="search_form" type="submit" name='search_button' value=<?=$this->T('搜索')?>
  3125. <?php }else if(isset($category)){ ?>
  3126. <div></div>
  3127. <?php }else if($this->LoggedIn){ ?>
  3128. <div class='post_box_top _input_bundle'>
  3129. <?php $this->MakePostingFields(NULL,false); ?>
  3130. </div>
  3131. <?php } ?>
  3132. <ul class='print_column list'>
  3133. <?php
  3134. if(!isset($search_term) && !isset($category) &&
  3135. (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
  3136. $this->CanShowPost($p)){
  3137. $this->MakeSinglePost($p, true, false, false, false, true, false, false, false, true, false);
  3138. }
  3139. $i = 0; $last_end_wide = true;
  3140. if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
  3141. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  3142. if(isset($p['tid'])){ /* Should always be set. */
  3143. $th = &$p['tid']; if($p['tid']['count']==0) continue;
  3144. if(!isset($search_term)) { $p = &$th['last']; }
  3145. }
  3146. if(isset($search_term)){
  3147. if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
  3148. }else if(isset($category)){
  3149. $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
  3150. (isset($p['categories'])?($p['categories']):[]);
  3151. if ($category=='none') { if($cat!=[]) continue; }
  3152. else{ if ($category=='' || !in_array($category, $cat)) continue; }
  3153. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3154. }else{
  3155. if(in_array($p['id'],
  3156. [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation])) continue;
  3157. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3158. }
  3159. if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
  3160. if($last_end_wide){$use_class="last_wide";}else{$use_class="";}
  3161. $this->MakeSinglePost($p, true, false, $use_class, false, !isset($search_term), false, false, false, false, isset($search_term));
  3162. $i++;
  3163. if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
  3164. $last_end_wide = sizeof($p['tid']['arr'])==1 && isset($p['end_wide']) && $p['end_wide'];
  3165. }?>
  3166. </ul>
  3167. <div class='page_selector clean_a'>
  3168. <hr />
  3169. <a <?=$this->CurrentOffset>0?("href='index.php?offset=".($this->CurrentOffset-1).
  3170. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):""?>
  3171. <?=$this->CurrentOffset==0?"class='gray'":""?>><?=$this->T('上一页')?> ←</a>
  3172. <?=$this->CurrentOffset+1?>
  3173. <a href='index.php?offset=<?=($this->CurrentOffset+1).
  3174. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))?>'>
  3175. → <?=$this->T('下一页')?></a>
  3176. </div>
  3177. </div>
  3178. <?php
  3179. }
  3180. function MakeHotPosts($placeholder_only=false){?>
  3181. <div class='left hidden_on_mobile' id='div_left'>
  3182. <?php if ($placeholder_only){ ?>&nbsp;
  3183. <?php }else{ ?>
  3184. <h2><?=$this->T('热门')?></h2>
  3185. <ul>
  3186. <?php
  3187. $i=0;
  3188. foreach($this->Threads as &$th){
  3189. if(!isset($th['first']) || $th['count']==0){ continue; }
  3190. if(!$this->CanShowPost($th['first'])) continue;
  3191. if($i>=$this->HotPostCount) break;
  3192. $this->MakeSinglePost($th['first'], false, true, "post_preview", true, false, true, false, true, false, false);
  3193. $i++;
  3194. } ?>
  3195. </ul>
  3196. <?php } ?>
  3197. </div>
  3198. <?php
  3199. }
  3200. function MakeLinkedPosts(&$p){
  3201. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); ?>
  3202. <div class='left hidden_on_mobile' id='div_left'>
  3203. <h2<?=$has_ref?"":" class='gray'"?>><?=$this->T('链接')?></h2>
  3204. <?php
  3205. if($has_ref){ ?>
  3206. <span class='smaller'><?=sizeof($p['refs'])?> <?=$this->T('个引用:')?></span>
  3207. <ul><?php $count_product=0;
  3208. foreach(array_reverse($p['refs']) as &$pr){
  3209. $po = $this->GetPost($pr); if(isset($post['mark_value']) && $po['mark_value']==5){ $count_product++; continue; }
  3210. if(!$this->CanShowPost($po)){ continue; }
  3211. $this->MakeSinglePost($po, false, true, "post_preview", true, false, false, false, true, false, false);
  3212. }
  3213. ?></ul>
  3214. <?php if($count_product){ ?> <span class='smaller'><?=$this->T('和').' '.$count_product.' '.$this->T('个商品')?></span> <?php }
  3215. }else{ ?>
  3216. <span class='gray smaller'><?=$this->T('没有帖子链接到这里。')?></span>
  3217. <?php } ?>
  3218. </div>
  3219. <?php
  3220. }
  3221. function MakeLinkedPostsExp(&$p){
  3222. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); ?>
  3223. <div class='center_exp post_dummy smaller'>
  3224. <hr />
  3225. <h3<?=$has_ref?"":" class='gray'"?>><?=$this->T('链接')?></h3>
  3226. <?php
  3227. if($has_ref){ ?>
  3228. <div class='smaller'><?=sizeof($p['refs'])?> <?=$this->T('个引用:')?></div>
  3229. <ul><?php $count_product=0;
  3230. foreach(array_reverse($p['refs']) as &$pr){
  3231. echo "<li class='post_dummy'><a href='?post=".$pr."'>".$this->T($this->GetPostTitle($this->GetPost($pr),false)).
  3232. "</a></li>";
  3233. }
  3234. ?></ul>
  3235. <?php if($count_product){ ?> <span class='smaller'><?=$this->T('和').' '.$count_product.' '.$this->T('个商品')?></span> <?php }
  3236. }else{ ?>
  3237. <div class='gray smaller'><?=$this->T('没有帖子链接到这里。')?></div>
  3238. <?php } ?>
  3239. <div style='margin-bottom:4rem;'>&nbsp;</div>
  3240. </div>
  3241. <?php
  3242. }
  3243. function MakePostHistoryList(&$ah, &$post,$version=NULL, $show_latest=true){
  3244. $latest_ver=isset($post['version'])?$post['version']:$post['id'];
  3245. $can_show=1; if(isset($this->WayBack) && $latest_ver>$this->WayBack) $can_show=0;
  3246. $title = NULL; if(!isset($ah) || ($show_latest && $can_show)) { $title=$this->T($this->GetPostTitle($post, false)); }
  3247. else{ $ver = &$ah['list'][sizeof($ah['list'])-1]; $title= $this->GetPostTitle($ver); }
  3248. if(!isset($title)) $title=$this->T('未命名');
  3249. if(!isset($ah)){ ?>
  3250. <h2><?=$this->T('没有历史记录')?></h2>
  3251. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$post['id']?>'><?=$title?></a></span><br />
  3252. <?php }else{ ?>
  3253. <h2><?=$this->T('历史记录')?></h2>
  3254. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$ah['id']?>'><?=$title?></a></span><br />
  3255. <div class='list'><ul>
  3256. <?php if($show_latest && $can_show){ $post['history_displayed']=1; ?>
  3257. <li class='<?=isset($version)&&$version==$latest_ver?" post_current_row bold":""?>' style='list-style:"";'>
  3258. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$latest_ver?>'><?=$this->ReadableTime($latest_ver)?></a>
  3259. <span class='smaller gray'><?=$this->T('长度').' '.strlen($post['content'])?></span>
  3260. <?php if(isset($post['merged_from'][0])){ ?><ul><?php foreach($post['merged_from'] as $from){
  3261. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3262. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3263. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3264. <?=$this->GetPostTitle($ver);?></a>
  3265. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3266. <?php } ?></ul><?php } ?>
  3267. <?php if(isset($post['merged_thread'][0][0])){ $pm=$post['merged_thread'][0][0];
  3268. $mah = &$this->GetArchiveHandle($pm);
  3269. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3270. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  3271. <span class='smaller gray'><?=sizeof($post['merged_thread'][0]);?> <?=$this->T('个帖子')?></span></li></ul>
  3272. <?php } ?>
  3273. </li><?php } ?>
  3274. <?php if(isset($ah['list'][0])) foreach(array_reverse($ah['list']) as &$ver){
  3275. if(isset($this->WayBack) && $ver['version']>$this->WayBack) continue;
  3276. if(isset($ver['history_displayed']) && $ver['history_displayed']) continue; ?>
  3277. <li<?=isset($version)&&$version==$ver['version']?" class='post_current_row bold'":""?>>
  3278. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$ver['version']?>'><?=$this->ReadableTime($ver['version'])?></a>
  3279. <span class='smaller gray'> <?=$this->T('长度').' '.strlen($ver['content'])?></span>
  3280. <?php if(isset($ver['merged_thread'][0][0])){ $pm=$ver['merged_thread'][0][0];
  3281. $mah = &$this->GetArchiveHandle($pm); $mver = &$this->GetPost($pm);
  3282. if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3283. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  3284. <span class='smaller gray'> <?=sizeof($ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></li></ul>
  3285. <?php } if(isset($ver['merged_from'][0])){ ?><ul><?php foreach($ver['merged_from'] as $from){
  3286. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3287. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3288. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3289. <?=$this->GetPostTitle($ver);?></a>
  3290. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3291. <?php } ?></ul></li><?php } ?>
  3292. <?php } ?></ul></div>
  3293. <?php } ?>
  3294. <?php
  3295. }
  3296. function MakePostDiff(&$this_ver, &$last_ver){
  3297. if(!isset($this_ver)){ ?>
  3298. <h2 class='gray'><?=$this->T('版本不存在')?></h2>
  3299. <?php }else{ ?>
  3300. <h2><?=$this->T('差异')?></h2>
  3301. <?php if(isset($this_ver['merged_thread']) && isset($this_ver['merged_thread'][0][0])){
  3302. $pm=$this_ver['merged_thread'][0][0]; $mah = &$this->GetArchiveHandle($pm);
  3303. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3304. <p><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver)?></a> <?=$this->T('并入这里')?>
  3305. <br /><span class='smaller gray'> <?=sizeof($this_ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></p>
  3306. <?php }else{ ?>
  3307. <table class='diff_table'><thead>
  3308. <tr><td><?php if(!isset($last_ver)){ ?><?=$this->T('没有更旧的版本')?><?php }else{ ?>
  3309. <?=$this->T('上一个版本')?><br /><?=$this->ReadableTime($last_ver['version'])?><?php } ?></td>
  3310. <td class='text_highlight bold'><?=$this->T('选择的版本')?><br /><?=$this->ReadableTime($this_ver['version'])?></td></tr>
  3311. </thead><tbody>
  3312. <tr><td><pre><?=isset($last_ver)?$last_ver['content']:""?></pre></td><td><pre><?=$this_ver['content']?></pre></td></tr>
  3313. </tbody>
  3314. </table>
  3315. <?php } ?>
  3316. <br /><a class='smaller' href='?post=<?=$this_ver['id']?>&set_wayback=<?=isset($this_ver['version'])?$this_ver['version']:$this_ver['id']?>'><?=$this->T('前往该版本时间')?> ←</a>
  3317. <?php } ?>
  3318. <?php
  3319. }
  3320. function MakePostHistory(&$post, $version=NULL){
  3321. $ah = &$this->GetArchiveHandle($this->CurrentPostID);
  3322. $p = &$post; if(!isset($post)){ $p=&$ah['list'][0]; }
  3323. $show_latest = isset($ah)?(!isset($ah['list'][sizeof($ah['list'])-1]['merged_into'])):true;
  3324. ?>
  3325. <div class='left hidden_on_mobile history' id='div_left'>
  3326. <?php if (isset($version)){
  3327. $this->MakePostHistoryList($ah, $p, $version, $show_latest);
  3328. }else{ echo "&nbsp;"; } ?>
  3329. </div>
  3330. <div class='center history' id='div_center'>
  3331. <?php if (!isset($version)){
  3332. $this->MakePostHistoryList($ah, $p, NULL, $show_latest);
  3333. }else{
  3334. $this_ver = NULL; $next_ver = NULL; $last_ver=NULL;
  3335. $this_ver = &$this->GetArchiveVersion($ah, $version, $next_ver, $last_ver);
  3336. if(!isset($this_ver)){$this_ver = $p; $last_ver=$ah['list'][sizeof($ah['list'])-1];}
  3337. $this->MakePostDiff($this_ver, $last_ver, $p);
  3338. } ?>
  3339. </div>
  3340. <?php
  3341. }
  3342. function MakeCommentSection(&$post){
  3343. if(!$this->CommentEnabled){ return; }
  3344. $to_post = isset($post['tid'])?$post['tid']['first']:$post;
  3345. $comment_count = (isset($to_post['comments']) && isset($to_post['comments'][0]))?count($to_post['comments']):0;
  3346. ?><div class='comment'>
  3347. <br /><h2><?=$this->T('评论')?> (<?=$comment_count;?>)</h2><div class='spacer'></div>
  3348. <?php if($comment_count) { echo "<ul>";
  3349. foreach($to_post['comments'] as $p){
  3350. $ht = $this->GenerateSinglePost($p, false, false, false, false, $t, false);
  3351. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3352. $mail = $this->LoggedIn?("<span class='gray clean_a hidden_on_print'>&nbsp;".
  3353. "<a href='mailto:".$p['email']."'>@</a>&nbsp;</span>"):"";
  3354. echo "<li><p><b>".$name.":</b>".$mail."</p>".$ht."</li>";
  3355. }
  3356. echo "</ul>";
  3357. } else {
  3358. echo $this->T('还没有评论');
  3359. } ?>
  3360. <div class='hidden_on_print'>
  3361. <div class='spacer'></div>
  3362. <form action="index.php?post=<?=$this->CurrentPostID?>&comment_to=<?=$to_post['id']?>"
  3363. method="post" style="display:none;" id="comment_form"></form>
  3364. <p><a class='text_highlight bold clean_a'
  3365. onclick='document.getElementById("comment_box").style.display="block";this.parentNode.style.display="none"'>
  3366. &nbsp;<?=$this->T('写评论');?>&nbsp;</a></p>
  3367. <div id='comment_box' style='display:none;'>
  3368. <p class='gray' style='margin-bottom:0.5em;'><?=$this->T('您的邮箱不会公开展示。');?></p>
  3369. <table style='white-space:nowrap;'>
  3370. <tr><td colspan='2'>
  3371. <textarea id="comment_box" name="comment_box" rows="4" class='full_box' form='comment_form'
  3372. oninput="CommentUpdated();" ></textarea>
  3373. </td></tr>
  3374. <tr><td><?=$this->T('电子邮件')?>*</td><td><?=$this->T('称呼')?>*</td></tr>
  3375. <tr><td><input type="text" form="comment_form" id='comment_email' name='comment_email'
  3376. class='full_box' oninput="CommentUpdated();" /></td>
  3377. <td><input type="text" form="comment_form" id='comment_name' name='comment_name'
  3378. class='full_box' oninput="CommentUpdated();" /></td></tr>
  3379. <tr><td colspan='2'><?=$this->T('个人网站')?></td></tr>
  3380. <tr><td colspan='2'>
  3381. <input type="text" form="comment_form" id='comment_link' name='comment_link'
  3382. class='full_box' oninput="CommentUpdated();" />
  3383. </td></tr>
  3384. <tr><td colspan='2'>
  3385. <div class='spacer'></div>
  3386. <input class='button text_highlight bigger' type='submit' form='comment_form'
  3387. name='comment_confirm' id='comment_confirm' value='&nbsp;<?=$this->T('发送')?>&nbsp;'>
  3388. </td></tr>
  3389. </table></div>
  3390. <script>
  3391. const IsValidEmail = (email) => {
  3392. 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,}))$/);
  3393. };
  3394. function IsValidHttpUrl(string) {
  3395. let url; try{ url = new URL(string); } catch (_) { return false; }
  3396. return url.protocol === "http:" || url.protocol === "https:";
  3397. }
  3398. var cbox = document.getElementById('comment_box');
  3399. var cemail = document.getElementById('comment_email');
  3400. var cname = document.getElementById('comment_name');
  3401. var clink = document.getElementById('comment_link');
  3402. var cconfirm = document.getElementById('comment_confirm');
  3403. function CommentUpdated(){
  3404. cconfirm.disabled=true;
  3405. if (cemail.value!="" && IsValidEmail(cemail.value) &&
  3406. cbox.innerText.length>2 && cname.value.length>2 &&
  3407. clink.value=="" || IsValidHttpUrl(clink.value)){
  3408. cconfirm.removeAttribute("disabled");
  3409. }
  3410. }
  3411. CommentUpdated();
  3412. </script>
  3413. </div>
  3414. </div>
  3415. <?php
  3416. }
  3417. function MakeInterestingSection(&$th){
  3418. $this->Anchors = [];
  3419. $c = &$th['first']['content'];
  3420. $this->ConvertPost($th['first']);
  3421. $ht = $th['first']['html'];
  3422. ?>
  3423. <script>function ClickImage(post_access){im=post_access.querySelector('img');if(im){im.click();}}</script>
  3424. <div class='center_full' id='div_center'>
  3425. <?php $this->MakePostTools(); ?>
  3426. <?php $cat = NULL;
  3427. if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; }
  3428. if($cat){ ?>
  3429. <p><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  3430. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  3431. <?php } ?>
  3432. <h2 class='hidden_on_print'><?=$this->T('有趣')?>
  3433. <a class='gray clean_a' href='?post=<?=$th['first']['id']?>'>→</a></h2>
  3434. <ul><li class='post post_width_big' data-post-id='<?=$th['first']['id']?>'>
  3435. <div class='post_menu_button _menu_hook' onclick='ShowPostMenu(this.parentNode);'>+</div><?=$ht?>
  3436. <?php if(isset($th['first']['refs'][0])){ ?><p class='smaller'><?=$this->T('引用')?>: </p><ul class='smaller'>
  3437. <?php foreach($th['first']['refs'] as $ref){
  3438. $po = $this->GetPost($ref);
  3439. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  3440. if(!$this->CanShowPost($po)){ continue; }
  3441. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  3442. } ?>
  3443. </ul><?php } ?>
  3444. <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  3445. <div class='post_width_big hidden_on_print'><br />
  3446. <?php $this->MakePostingFields($th['last']['id'], true);?><br />
  3447. </div>
  3448. <?php } ?>
  3449. <table><thead><tr><th></th><?php foreach($th['interesting'] as $header){ ?>
  3450. <th><?=$this->T($header);?></th>
  3451. <?php } ?></tr></thead><tbody class='interesting_tbody'>
  3452. <?php $plist = array_reverse(array_slice($th['arr'],1));
  3453. foreach($plist as &$p){
  3454. $this->ConvertPost($p);
  3455. $mark_value = isset($p['mark_value'])?$this->Markers[$p['mark_value']]:-1;
  3456. $ref_count = isset($p['refs'])?sizeof($p['refs']):0;
  3457. $is_current = $p['id']==$this->CurrentPostID;
  3458. $is_deleted = (isset($p['mark_delete'])&&$p['mark_delete']); ?>
  3459. <tr class='<?=$is_current?"post_current_row":""?><?=$is_deleted?" deleted_post":""?>'
  3460. data-post-id='<?=$p['id']?>' <?=$is_deleted?"data-mark-delete='true'":""?>
  3461. onDblClick='ClickImage(this)'><td>
  3462. <a <?=$is_current?"":("href='?post=".$p['id']."' onclick='ShowWaitingBar()'");?> class='clean_a paa'>
  3463. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  3464. <?=isset($p['mark_value'])?$this->Markers[$p['mark_value']]:($ref_count?"":"→")?>
  3465. </div>
  3466. <?php if($ref_count){ ?>
  3467. <div class='post_access ref_count'><?=$ref_count?></div>
  3468. <?php } ?></a>
  3469. <?=$p['html'];?>
  3470. <a class='_menu_hook clean_a post_menu_button' onclick='ShowPostMenu(this.parentNode.parentNode);'>+</a></td></tr>
  3471. <?php if($is_current && $ref_count>0){ ?><tr class='post_current_row'><td><p>&nbsp;</p><ul class='smaller'>
  3472. <?php foreach($p['refs'] as $ref){
  3473. $po = $this->GetPost($ref);
  3474. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  3475. if(!$this->CanShowPost($po)){ continue; }
  3476. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  3477. } ?>
  3478. </ul></td></tr><?php } ?>
  3479. <?php } ?>
  3480. </tbody></table>
  3481. </li></ul>
  3482. <br />
  3483. <?php $this->MakeCommentSection($th['first']); ?>
  3484. </div>
  3485. <?php return true;
  3486. }
  3487. function CssNumberID($id){
  3488. return "#\\3".substr($id,0,1)." ".substr($id,1);
  3489. }
  3490. function MakePostTools(){
  3491. if($this->LoggedIn && !isset($this->WayBack)){ ?><div class='smaller gray hidden_on_print clean_a'>
  3492. <a id='merge_cancel' href='javascript:{TogglePostSelectMode(false,true);ToggleThreadMerge(false,true);}'>
  3493. <?=$this->T('工具')?></a>:<div class='hidden_on_mobile' style='display:inline'>
  3494. <span id='merge_post_btn'><a href='javascript:TogglePostSelectMode()'><?=$this->T('合并帖子')?></a></span>
  3495. | <span id='merge_thread_btn'><a href='javascript:ToggleThreadMerge()'><?=$this->T('合并话题')?></a></span>
  3496. </div>
  3497. <select class='hidden_on_desktop' id='merge_select'
  3498. onchange="if(this.selectedIndex==1){TogglePostSelectMode(true);}else if(this.selectedIndex==2){ToggleThreadMerge(true);}">
  3499. <option value='-1' selected>--</option>
  3500. <option value='1'><?=$this->T('合并帖子')?></option>
  3501. <option value='2'><?=$this->T('合并话题')?></option></select>
  3502. <div style='display:none;' id='merge_post_dialog' class='text_highlight small_pad align_right'>
  3503. <div style='display:inline;'><?=$this->T('将合并');?> <span id='merge_post_count'></span> <?=$this->T('个帖子');?></div>
  3504. <span class='clean_a bold align_right'><a id='merge_post'>&nbsp;<?=$this->T('执行');?></a></span></div>
  3505. <div style='display:none;overflow:auto' id='merge_thread_dialog' class='text_highlight small_pad align_right'>
  3506. <div style='display:inline;'><?=$this->T('合并到话题');?></div>
  3507. <input id="merge_thread_target" type="text" style="width:9em;display:inline" onChange='ThreadMergeInput(this);' onInput='ThreadMergeInput(this);'>
  3508. <span class='clean_a bold align_right'><a id='merge_thread'>&nbsp;<?=$this->T('执行');?></a></span></div>
  3509. </div><div class='spacer hidden_on_print'></div><?php
  3510. }
  3511. }
  3512. function MakePostSection(&$post){
  3513. $this->Anchors = [];
  3514. if(isset($this->TagID)){ ?><style><?=$this->CssNumberID($this->TagID);?>{display:block;}</style><?php } ?>
  3515. <div class='center' id='div_center'>
  3516. <h2 class='hidden_on_print'>
  3517. <?php $th=NULL; $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1;
  3518. $is_wide = (isset($post['wide'])&&$post['wide']) || ($is_thread && isset($post['tid']['wide']) && $post['tid']['wide']);
  3519. if($is_thread){ $th = $post['tid'];?> <?=$this->T('话题')?> <?php }else{ ?> <?=$this->T('详细')?>
  3520. <?php } ?></h2>
  3521. <?php $cat = NULL;
  3522. if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
  3523. else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
  3524. $this->MakePostTools();
  3525. if($cat){ ?>
  3526. <p class='hidden_on_print'><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  3527. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  3528. <?php } ?>
  3529. <ul<?=$is_wide?"":" class='print_column'"?>>
  3530. <?php $is_reversed=false;
  3531. if($is_thread){
  3532. $use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false; if($is_reversed){
  3533. $use_arr=array_reverse($th['arr']); $fp=array_pop($use_arr); array_unshift($use_arr,$fp); }
  3534. $last_end_wide = true;
  3535. foreach($use_arr as &$p){
  3536. $use_class = ($p == $post)?'focused_post':'';
  3537. if($last_end_wide){$use_class.=" last_wide";}
  3538. $show_link = ($p == $post)?false:true;
  3539. $make_title = ($p == $post);
  3540. $this->MakeSinglePost($p,$show_link,false,$use_class,false, false, false, true, false, false);
  3541. if($make_title){?>
  3542. <script>
  3543. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($p['html']),0,1000)))?>";
  3544. </script>
  3545. <?php } if($is_reversed && !$hinted){ ?>
  3546. <li class='gray smaller bold' style='text-align:center;'>
  3547. <p>&nbsp;</p><hr><?=$this->T('该话题最新帖子在前')?><hr><p>&nbsp;</p></li>
  3548. <?php $hinted = true;
  3549. if($this->LoggedIn && (!$this->InHereMode)){ ?>
  3550. <div class='post_width_big hidden_on_print'>
  3551. <?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?></div><br />
  3552. <?php } }
  3553. $last_end_wide = isset($p['end_wide']) && $p['end_wide'];
  3554. }
  3555. }else{
  3556. $this->MakeSinglePost($post,false, false, 'focused_post',false, false, false, true, false, false);
  3557. ?><script>
  3558. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($post['html']),0,1000)))?>";
  3559. </script><?php
  3560. } $class_add=""; if(isset($post['tid']['first']['no_time'])){ $class_add=' hidden_on_print'; } ?>
  3561. <div class='smaller align_right<?=$class_add;?>'>
  3562. <span class='gray'><?=$this->ReadableTime($post['tid']['first']['id']);?></span>
  3563. <br class='hidden_on_desktop' /><?=$this->ReadableTime(isset($post['tid']['last']['version'])?
  3564. $post['tid']['last']['version']:$post['tid']['last']['id']);?>
  3565. </div>
  3566. <?php if(!$is_reversed && ($this->LoggedIn && (!$this->InHereMode))){ ?>
  3567. <div class='post_width_big hidden_on_print'>
  3568. <br /><?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?>
  3569. </div>
  3570. <?php }
  3571. $this->MakeCommentSection($post);
  3572. ?>
  3573. </ul>
  3574. </div>
  3575. <?php
  3576. }
  3577. function MakePostSectionExp(&$post){
  3578. $this->Anchors = []; $is_thread = isset($post['tid']);
  3579. ?>
  3580. <div class='center_exp' id='div_center'>
  3581. <ul>
  3582. <?php $is_reversed=false;
  3583. if($is_thread){ $th = &$post['tid'];$use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th);
  3584. $hinted=false; if($is_reversed){
  3585. $use_arr=array_reverse($th['arr']); $fp=array_pop($use_arr); array_unshift($use_arr,$fp); }
  3586. foreach($use_arr as &$p){
  3587. $this->MakeSinglePostExp($p);
  3588. if($p == $th['first']){?>
  3589. <script>
  3590. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($p['html']),0,1000)))?>";
  3591. </script>
  3592. <?php } if($is_reversed && !$hinted){ ?>
  3593. <li class='gray smaller bold' style='text-align:center;'>
  3594. <p>&nbsp;</p><hr><?=$this->T('该话题最新帖子在前')?><hr><p>&nbsp;</p></li>
  3595. <?php $hinted = true; }
  3596. }
  3597. }else{
  3598. $this->MakeSinglePostExp($post);
  3599. ?><!--<script>
  3600. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($post['html']),0,1000)))?>";
  3601. </script>--><?php
  3602. } ?>
  3603. </ul>
  3604. </div>
  3605. <?php
  3606. }
  3607. function MakeHereSection(&$im){ $image_okay = (isset($im) && $im!=$this->NULL_IMAGE); ?>
  3608. <div class='here_image_box clean_a'>
  3609. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'>
  3610. <?=$image_okay?$this->T('请稍候'):$this->T('未找到图像')?></div>
  3611. <?php if($image_okay){ ?>
  3612. <?php if(isset($im['video']) && isset($im['video'])!=""){ ?>
  3613. <video controls><source src='<?=$im['file'];?>' type='<?=$im['video']?>'></video>
  3614. <?php }else{ ?>
  3615. <img id='big_image' onload="HideWaitingBar();" src="<?=$im['file'];?>" />
  3616. <?php } ?>
  3617. <?php } $this->MakeHereButtons($im, false); ?>
  3618. </div>
  3619. <?php }
  3620. function MakeSideGalleryCode(){?>
  3621. <div>
  3622. <h3><?=$this->T('点击图片以插入:')?></h3>
  3623. <select id="side_gallery_select" onchange="RefreshSideGallery()">
  3624. <option value="main"><?=$this->T('全部')?></option>
  3625. <?php if($this->LoggedIn){ ?>
  3626. <option value="trash"><?=$this->T('垃圾桶')?></option>
  3627. <?php }?>
  3628. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  3629. <option value="<?=$g['name']?>"><?=$g['name']?></option>
  3630. <?php } ?>
  3631. </select>
  3632. <div id='side_gallery'>
  3633. </div>
  3634. </div>
  3635. <script>
  3636. function InsertImage(imgname){
  3637. t = document.querySelector("#post_content");
  3638. v = t.value;
  3639. t.value = v.slice(0, t.selectionStart) + "![<?=$this->T('图片')?>](images/"+imgname+")"+ v.slice(t.selectionEnd);
  3640. la_auto_grow(t);
  3641. }
  3642. function RefreshSideGallery(){
  3643. let xhr = new XMLHttpRequest();
  3644. xhr.onreadystatechange = (function(){
  3645. if (this.readyState === this.DONE) {
  3646. if (this.status === 200) {
  3647. ind = document.querySelector("#side_gallery");
  3648. if(res = xhr.responseText.matchAll(/\[(.*?),(.*?)\]/gu)){
  3649. str = "<ul class='side_thumb'>"
  3650. for (const m of res) {
  3651. imgstr = "<img src='"+m[2]+"' />";
  3652. if(m[2].match('\.mp4')){
  3653. imgstr = "<video><source src='"+m[2]+"'></video>";
  3654. }
  3655. str+="<li><div class='file_thumb' onclick='InsertImage(\""+m[1]+"\")'>"+imgstr+"</div>"
  3656. }
  3657. str += "</ul>"
  3658. ind.innerHTML = str;
  3659. }
  3660. }
  3661. }
  3662. });
  3663. xhr.open("GET", "?image_list="+document.querySelector("#side_gallery_select").value, true);
  3664. xhr.send();
  3665. }
  3666. </script>
  3667. <?php
  3668. }
  3669. function MakeUploader($is_side=false){ ?>
  3670. <div id='upload_operation_area' class='hidden_on_print'>
  3671. <p><?=$this->T('选择、粘贴或者拖动到页面以上传图片。')?></p>
  3672. <input type="file" id='upload_selector' accept="image/x-png,image/png,image/gif,image/jpeg" multiple/>
  3673. <ul id='file_list'>
  3674. </ul>
  3675. <div class='smaller gray' id='upload_hint'><?=$this->T('就绪')?></div>
  3676. </div>
  3677. <a id='upload_click' class='hidden_on_print pointer' onclick='this.removeAttribute("onclick");UploadList();'
  3678. <?=$is_side?" data-is-side='true'":""?>><?=$this->T('上传列表中的文件')?></a>
  3679. <script>
  3680. function pastehandler(event){
  3681. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  3682. for (index in items) {
  3683. var item = items[index];
  3684. if (item.kind === 'file') {
  3685. put = document.querySelector("#_uploader");
  3686. if(put) ShowSideUploader();
  3687. var blob = item.getAsFile();
  3688. AddImageFile(blob);
  3689. return;
  3690. }
  3691. }
  3692. }
  3693. let _fd_list = []; var uploading=0;
  3694. let hint=document.querySelector('#upload_hint');
  3695. function ToggleCompress(button){
  3696. li = button.parentNode;
  3697. num=li.dataset.number;
  3698. for(i=0;i<_fd_list.length;i++){
  3699. if (_fd_list[i][0] == num){
  3700. state = _fd_list[i][2];
  3701. if(state){_fd_list[i][2] = 0; button.innerHTML='1920';break;}
  3702. else{_fd_list[i][2] = 1; button.innerHTML='800';break;}
  3703. }
  3704. }
  3705. }
  3706. function RemoveFromUpload(button){
  3707. li = button.parentNode;
  3708. num=li.dataset.number;
  3709. for(i=0;i<_fd_list.length;i++){
  3710. if (_fd_list[i][0] == num){
  3711. _fd_list.splice(i, 1);break;
  3712. }
  3713. }
  3714. li.parentNode.removeChild(li);
  3715. }
  3716. function EndThisUpload(){
  3717. unfinished = 0;
  3718. for(i=0;i<_fd_list.length;i++){
  3719. if (_fd_list[i][3]==0){
  3720. unfinished=1;
  3721. }
  3722. }
  3723. if(!unfinished){
  3724. uploading=0;
  3725. hint.innerHTML="<?=$this->T('上传完成。')?>";
  3726. cl=document.querySelector('#upload_click');
  3727. if(!cl.dataset.isSide){
  3728. cl.innerHTML="<?=$this->T('刷新页面')?>";
  3729. cl.href=window.location.href;
  3730. }else{
  3731. _fd_list.splice(0,_fd_list.length);
  3732. fl = document.querySelector("#file_list");
  3733. fl.innerHTML = "";
  3734. list=document.querySelector('#upload_operation_area');
  3735. list.style.pointerEvents='';
  3736. list.style.opacity='';
  3737. cl.onclick=function(){this.removeAttribute("onclick");UploadList();};
  3738. document.onpaste=pastehandler;
  3739. RefreshSideGallery();
  3740. }
  3741. }
  3742. }
  3743. function UploadList(){
  3744. if(!_fd_list.length || uploading) return;
  3745. uploading=1;
  3746. hint.innerHTML="<?=$this->T('正在上传...')?>";
  3747. list=document.querySelector('#upload_operation_area');
  3748. list.style.pointerEvents='none';
  3749. list.style.opacity='0.5';
  3750. document.onpaste="";
  3751. for(i=0;i<_fd_list.length;i++){
  3752. let xhr = new XMLHttpRequest();
  3753. var li = list.querySelector('[data-number="'+_fd_list[i][0].toString()+'"]')
  3754. xhr.open("POST", "?compress="+_fd_list[i][2].toString(), true);
  3755. function wrap(li, i){
  3756. var ind = li.querySelector('._compress_toggle')
  3757. return function(){
  3758. if (this.readyState === this.DONE) {
  3759. if (this.status === 200) {
  3760. var response = xhr.responseText;
  3761. if(res = response.match(/<uploaded>(.*)<\/uploaded>/)){
  3762. ind.innerHTML = "<?=$this->T('已上传为')?> "+res[1];
  3763. _fd_list[i][3] = 1;
  3764. }else{
  3765. ind.innerHTML = "<?=$this->T('出现错误。')?>";
  3766. _fd_list[i][3] = 1;
  3767. }
  3768. EndThisUpload();
  3769. }
  3770. }
  3771. }
  3772. }
  3773. xhr.onreadystatechange = wrap(li, i);
  3774. xhr.send(_fd_list[i][1]);
  3775. }
  3776. }
  3777. function AddImageFile(blob){
  3778. var ext="";
  3779. if(blob.name.match(/png$/))ext = 'png';
  3780. else if(blob.name.match(/jpg$/))ext = 'jpg';
  3781. else if(blob.name.match(/jpeg$/))ext = 'jpeg';
  3782. else if(blob.name.match(/gif$/))ext = 'gif';
  3783. else if(blob.name.match(/mp4$/))ext = 'mp4';
  3784. else return;
  3785. var fd = new FormData();
  3786. blob.name = blob.name=generateUID().toString();
  3787. fd.append("upload_file_name", blob, "_upload_"+blob.name+"."+ext);
  3788. _fd_list.push([blob.name, fd, 1, 0]);/* number original is_compress uploaded */
  3789. var reader = new FileReader();
  3790. reader.onload = function(event){
  3791. fl = document.querySelector("#file_list");
  3792. ht = "<li id='_upload_"+blob.name+"' data-number='"+blob.name+"'>"+
  3793. "<a class='_remove_file pointer invert_a' onclick='RemoveFromUpload(this)'>×</a> "+"<div class='file_thumb'>"+
  3794. "<img class='no_pop' src='"+event.target.result+"'>"+"</div>"+
  3795. " →<a class='_compress_toggle pointer' onclick='ToggleCompress(this)'>800</a></li>";
  3796. fl.innerHTML+=ht;
  3797. };
  3798. reader.readAsDataURL(blob);
  3799. }
  3800. sel = document.querySelector('#upload_selector');
  3801. sel.addEventListener("change", function(){
  3802. var input = this;
  3803. function ff(file){
  3804. return function(e){
  3805. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3806. blob.name = file.name;
  3807. AddImageFile(blob);
  3808. }
  3809. }
  3810. for(i=0;i<input.files.length;i++){
  3811. if(input.files[i].size){
  3812. let reader = new FileReader();
  3813. reader.onload = ff(input.files[i]);
  3814. reader.readAsArrayBuffer(input.files[i]);
  3815. }
  3816. }
  3817. });
  3818. function generateUID() {
  3819. var firstPart = (Math.random() * 46656) | 0;
  3820. var secondPart = (Math.random() * 46656) | 0;
  3821. firstPart = ("000" + firstPart.toString(36)).slice(-3);
  3822. secondPart = ("000" + secondPart.toString(36)).slice(-3);
  3823. return firstPart + secondPart;
  3824. }
  3825. document.onpaste = pastehandler;
  3826. function dropHandler(ev) {
  3827. put = document.querySelector("#_uploader");
  3828. if(put) ShowSideUploader();
  3829. bkg=document.querySelector('#dropping_background');
  3830. bkg.style.display="none";
  3831. console.log('File(s) dropped');
  3832. ev.preventDefault();ev.stopPropagation();
  3833. if (ev.dataTransfer && ev.dataTransfer.items) {
  3834. for (var i = 0; i < ev.dataTransfer.items.length; i++) {
  3835. if (ev.dataTransfer.items[i].kind === 'file') {
  3836. var file = ev.dataTransfer.items[i].getAsFile();
  3837. function ff(file){
  3838. return function(e){
  3839. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3840. blob.name = file.name;
  3841. AddImageFile(blob);
  3842. }
  3843. }
  3844. if(file){
  3845. let reader = new FileReader();
  3846. reader.onload = ff(file);
  3847. reader.readAsArrayBuffer(file);
  3848. }
  3849. }
  3850. }
  3851. } else {
  3852. for (var i = 0; i < ev.dataTransfer.files.length; i++) {
  3853. function ff(file){
  3854. return function(e){
  3855. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3856. blob.name = file.name;
  3857. AddImageFile(blob);
  3858. }
  3859. }
  3860. if(ev.dataTransfer.files[i].size){
  3861. let reader = new FileReader();
  3862. reader.onload = ff(ev.dataTransfer.files[i]);
  3863. reader.readAsArrayBuffer(ev.dataTransfer.files[i]);
  3864. }
  3865. }
  3866. }
  3867. }
  3868. function dragOverHandler(ev) {
  3869. bkg=document.querySelector('#dropping_background');
  3870. bkg.style.display="";
  3871. console.log('File(s) in drop zone');
  3872. ev.preventDefault();
  3873. }
  3874. </script>
  3875. <?php
  3876. }
  3877. function CanShowGallery(&$g){
  3878. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($g['experimental']) && $g['experimental']) return false;
  3879. return true;
  3880. }
  3881. function CanShowImage(&$im){
  3882. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($im['galleries']) && isset($im['galleries'][0])) foreach($im['galleries'] as $ga){
  3883. if(($g=$this->GetGallery($ga)) && isset($g['experimental']) && $g['experimental']) return false;
  3884. }
  3885. if(isset($this->WayBack) && substr($im['name'],0,14)>$this->WayBack) return false;
  3886. return true;
  3887. }
  3888. function MakeGallerySection(){
  3889. if(!isset($_GET['gallery'])) return;
  3890. $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){
  3891. $name=$_GET['gallery'];}?>
  3892. <script>
  3893. document.title+=" | <?=$this->T('画廊')?>";
  3894. </script>
  3895. <div class='center_wide' id='div_center' style='position:relative;'>
  3896. <h2><?=(isset($name) && ($gal=$this->GetGallery($name))!=NULL)?
  3897. ("<span class='gray album_hint'>".$this->T('相册').":</span>".$this->T($name)):
  3898. ($_GET['gallery']=='trash'?$this->T('垃圾桶'):$this->T('画廊'))?></h2>
  3899. <div class='hidden_on_desktop'>
  3900. <?=$this->T('前往')?>
  3901. <select id="gallery_go_to" onchange="window.location.href='?gallery='+this.value;">
  3902. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  3903. if(!isset($g['featured']) || !$g['featured'] ||
  3904. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  3905. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  3906. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  3907. <?php } ?>
  3908. <option value="main" <?=$_GET['gallery']=='main'?"selected":""?>>[<?=$this->T('全部')?>]</option>
  3909. <?php if($this->LoggedIn){ ?>
  3910. <option value="trash" <?=$_GET['gallery']=='trash'?"selected":""?>>[<?=$this->T('垃圾桶')?>]</option>
  3911. <?php } ?>
  3912. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  3913. if((isset($g['featured']) && $g['featured']) ||
  3914. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  3915. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  3916. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  3917. <?php } ?>
  3918. </select>
  3919. </div>
  3920. <?php if($this->LoggedIn){?>
  3921. <div>
  3922. <?php if(isset($name)){ ?>
  3923. <div style='text-align:right;position:absolute;right:0;top:0;width:100%;' class='invert_a smaller hidden_on_print'>
  3924. <a href='javascript:ShowDeleteMenu();'><?=$this->T('删除相册')?></a><br />
  3925. <?php if(isset($gal['featured']) && $gal['featured']!=false){ ?>
  3926. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=false'>
  3927. <?=$this->T('取消精选')?></a>
  3928. <?php }else{ ?>
  3929. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=true'>
  3930. <?=$this->T('设为精选')?></a>
  3931. <?php } ?><br />
  3932. <?php if(isset($gal['experimental']) && $gal['experimental']!=false){ ?>
  3933. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=false'>
  3934. <?=$this->T('取消实验')?></a>
  3935. <?php }else{ ?>
  3936. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=true'>
  3937. <?=$this->T('设为实验')?></a>
  3938. <?php } ?>
  3939. <div class='pop_menu invert_a' id='gallery_delete_menu' style='display:none;'>
  3940. <div style='float:left;' class='gray'><?=$this->T('该操作不删除图片。')?></div>
  3941. <a href='javascript:HidePopMenu();'>×</a>
  3942. <hr />
  3943. <a href='?gallery=main&gallery_edit_delete=<?=$_GET['gallery']?>'><b><?=$this->T('删除相册')?></b></a>
  3944. </div>
  3945. </div>
  3946. <?php } ?>
  3947. <?php $this->MakeUploader(false); ?>
  3948. <div style='text-align:right;position:relative;' class='invert_a smaller hidden_on_print'>
  3949. <div style='position:relative'>
  3950. <?php if(isset($name)){ ?>
  3951. <a href='javascript:ShowGalleryEditMenu("<?=$name?>")'><?=$this->T('改名')?></a>
  3952. <?php } ?>
  3953. <a href='javascript:ShowGalleryEditMenu(null)'><?=$this->T('添加')?></a>
  3954. <div class='pop_menu invert_a' id='gallery_edit_menu' style='display:none;max-width:90%;'>
  3955. <form action="<?=$_SERVER['REQUEST_URI']?>&edit_gallery=true"
  3956. method="post" style='display:none;' id='gallery_edit_form'></form>
  3957. <a style='float:left;'><?=$this->T('相册名字:')?></a>
  3958. <a href='javascript:HidePopMenu();'>×</a>
  3959. <input type='text' form='gallery_edit_form' name='gallery_edit_new_name' id='gallery_edit_new_name' style='width:10em;'>
  3960. <input type='text' form='gallery_edit_form' name='gallery_edit_old_name' id='gallery_edit_old_name' style='display:none'>
  3961. <input class='button' type='submit' form='gallery_edit_form'
  3962. name='gallery_edit_confirm' id='gallery_edit_confirm' value='<?=$this->T('确认')?>'>
  3963. </div>
  3964. </div>
  3965. </div>
  3966. <div class='smaller hidden_on_print'>
  3967. <form action="<?=$_SERVER['REQUEST_URI']?>"
  3968. method="post" style='display:none;' id='gallery_move_form'></form>
  3969. <input type='text' form='gallery_move_form' name='gallery_move_ops'
  3970. id='gallery_move_ops' style='display:none'>
  3971. <p><?=$this->T('选择了')?> <span id='gallery_selected_count'>0</span> <?=$this->T('个图片。')?>
  3972. <a href='javascript:ClearSelectedImages()'><?=$this->T('清除')?></a></p>
  3973. <p><?=$this->T('添加到')?>
  3974. <select id="gallery_move_to">
  3975. <option value="trash"><?=$this->T('垃圾桶')?></option>
  3976. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  3977. <option value="<?=$g['name']?>"><?=$this->T($g['name'])?></option>
  3978. <?php } ?>
  3979. </select>
  3980. <a href='javascript:AddToGallery()'><?=$this->T('执行')?></a>
  3981. </p>
  3982. <p>
  3983. <?=$this->T('或者')?><a href='javascript:RemoveFromGallery()'><?=$this->T('从相册移除')?></a>
  3984. </p>
  3985. </div>
  3986. </div>
  3987. <?php } ?>
  3988. <p>&nbsp;</p>
  3989. <div>
  3990. <?php $opened=0; $prev_year=""; if(isset($this->Images[0])) foreach($this->Images as $im){
  3991. if(!$this->CanShowImage($im)){ continue; }
  3992. if($_GET['gallery']=='trash') $name='trash';
  3993. if($_GET['gallery']!='main'){ if(!isset($im['galleries']) || !in_array($name, $im['galleries'])) continue;}
  3994. $year = substr($im['name'], 0, 4);
  3995. if($year!=$prev_year){
  3996. if($opened) { ?><div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div></div><?php } ?>
  3997. <div><h2 class='sticky_title'><?=$year;?></h2><div class='p_row'><?php $prev_year=$year; $opened=1; } ?>
  3998. <div class='p_thumb<?=isset($im['parent'])?" p_thumb_narrow":""?>'>
  3999. <?php if($this->LoggedIn){ ?>
  4000. <div class="post_menu_button _select_hook white" onclick='ToggleSelectImage(this, "<?=$im["name"]?>")'>●</div>
  4001. <?php } ?>
  4002. <a href='?show_image=<?=$im['name']?>' target='_blank' onclick='event.preventDefault();'>
  4003. <?php if(isset($im['video']) && $im['video']!=""){ ?>
  4004. <video data-imgsrc='<?=$im["name"]?>'><source src='<?=$im['file']?>' type='<?=$im['video']?>'></video>
  4005. <?php }else{ ?>
  4006. <img src='<?=$im['thumb']?>' data-imgsrc='<?=$im["name"]?>'
  4007. <?=isset($im['product'])?'data-product="'.$im["product"].'"':""?>
  4008. <?=isset($im['parent'])?'data-parent="'.$im["parent"].'"':""?>/>
  4009. <?php } ?>
  4010. </a>
  4011. </div>
  4012. <?php } if($opened) { ?>
  4013. <div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div><?php } ?>
  4014. </div>
  4015. </div>
  4016. <?php if($this->LoggedIn){ ?>
  4017. <script type='text/javascript'>
  4018. var selected_image = new Array();
  4019. function RemoveFromGallery(){
  4020. form = document.querySelector('#gallery_move_form');
  4021. ops = document.querySelector('#gallery_move_ops');
  4022. sel = document.querySelector('#gallery_move_to');
  4023. ops.value = "REM <?=$_GET['gallery']?>"+" "+selected_image.join(' ');
  4024. form.submit();
  4025. }
  4026. function AddToGallery(){
  4027. form = document.querySelector('#gallery_move_form');
  4028. ops = document.querySelector('#gallery_move_ops');
  4029. sel = document.querySelector('#gallery_move_to');
  4030. ops.value = "ADD "+sel.value+" "+selected_image.join(' ');
  4031. form.submit();
  4032. }
  4033. function ClearSelectedImages(){
  4034. selected_image.splice(0, selected_image.length);
  4035. checks = document.querySelectorAll('._select_hook');
  4036. [].forEach.call(checks, function(c){
  4037. c.classList.remove('p_thumb_selected');
  4038. });
  4039. count = document.querySelector('#gallery_selected_count');
  4040. count.innerHTML="0";
  4041. }
  4042. function ToggleSelectImage(elem, name){
  4043. count = document.querySelector('#gallery_selected_count');
  4044. if(selected_image.indexOf(name) == -1){ selected_image.push(name); elem.classList.add('p_thumb_selected'); }
  4045. else{ selected_image.splice(selected_image.indexOf(name), 1); elem.classList.remove('p_thumb_selected'); }
  4046. count.innerHTML=selected_image.length.toString()
  4047. }
  4048. function ShowGalleryEditMenu(old_name){
  4049. m = document.querySelector('#gallery_edit_menu');
  4050. old = document.querySelector('#gallery_edit_old_name');
  4051. newname = document.querySelector('#gallery_edit_new_name');
  4052. m.style.display='block';
  4053. if(old_name!=''){ old.value=old_name; newname.value=old.value; }else{ old.value=''; }
  4054. }
  4055. function ShowDeleteMenu(){
  4056. m=document.querySelector('#gallery_delete_menu');
  4057. m.style.display='block';
  4058. }
  4059. </script>
  4060. <?php } ?>
  4061. <?php
  4062. }
  4063. function MakeGalleryLeft(){?>
  4064. <div class='left hidden_on_mobile gallery_left' id='div_left'>
  4065. <h2><?=$this->T('相册')?></h2>
  4066. <div>
  4067. <span class='gray smaller bold'><?=$this->T('精选')?><hr> </span>
  4068. <ul>
  4069. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4070. if(!isset($g['featured']) || !$g['featured'] || !$this->CanShowGallery($g)){ continue; } ?>
  4071. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4072. <li class='<?=$_GET['gallery']==$g['name']?'selected':""?>'>
  4073. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4074. <?php } ?>
  4075. </ul>
  4076. <div class='smaller'><span class='gray'><?=$this->T('其他相册')?><hr></span><ul>
  4077. <a href='?gallery=main' onclick='ShowWaitingBar()'>
  4078. <li class='<?=$_GET['gallery']=='main'?' selected':""?>'>[<?=$this->T('全部图片')?>]</li></a>
  4079. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4080. if((isset($g['featured']) && $g['featured']) || !$this->CanShowGallery($g)){ continue; } ?>
  4081. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4082. <li class='<?=$_GET['gallery']==$g['name']?' selected':""?>'>
  4083. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4084. <?php } ?>
  4085. <?php if($this->LoggedIn){ ?>
  4086. <a href='?gallery=trash' onclick='ShowWaitingBar()'>
  4087. <li class='<?=$_GET['gallery']=='trash'?' selected':""?>'>[<?=$this->T('垃圾桶')?>]</li></a>
  4088. <?php } ?>
  4089. </ul></div>
  4090. <p>&nbsp;</p>
  4091. <script>
  4092. </script>
  4093. </div>
  4094. </div>
  4095. <?php
  4096. }
  4097. function MakeTOC(){?>
  4098. <div class='right hidden_on_mobile' id='div_right'>
  4099. <?php if(isset($this->Anchors[0])){?>
  4100. <h2><?=$this->T('目录')?></h2><ul>
  4101. <?php
  4102. foreach($this->Anchors as $a){?>
  4103. <li class='toc_entry_<?=$a[0]>5?5:$a[0]?>'><a href='#<?=$a[1]?>'>
  4104. <?=$this->T($this->ChoosePartsByLanguage($a[2]))?></a></li>
  4105. <?php }
  4106. ?></ul>
  4107. <?php }else{ ?>
  4108. <h2 class='gray'><?=$this->T('目录')?></h2>
  4109. <span class='gray smaller'><?=$this->T('未找到目录')?></span>
  4110. <?php } ?>
  4111. </div>
  4112. <?php
  4113. }
  4114. function MakeSettings(){?>
  4115. <div class='settings'>
  4116. <h2><?=$this->T('设置')?></h2>
  4117. <table style='white-space:nowrap;'>
  4118. <?php if($this->LoggedIn){ ?>
  4119. <form action="index.php?settings=true" method="post" style='display:none;' id='settings_form'></form>
  4120. <colgroup><col style='min-width:5em;'><col style='width:100%;min-width:5em;'></colgroup>
  4121. <thead><tr><td><?=$this->T('选项')?></td><td><?=$this->T('值')?></td></tr></thead>
  4122. <tr><td><?=$this->T('网站标题')?></td>
  4123. <td><input type="text" form="settings_form" id='settings_title' name='settings_title'
  4124. value='<?=$this->Title?>'/></td></tr>
  4125. <tr><td><?=$this->T('短标题')?></td>
  4126. <td><input type="text" form="settings_form" id='settings_short_title' name='settings_short_title'
  4127. value='<?=$this->ShortTitle?>'/></td></tr>
  4128. <tr><td><?=$this->T('显示名称')?></td>
  4129. <td><input type="text" form="settings_form" id='settings_display_name' name='settings_display_name'
  4130. value='<?=$this->DisplayName?>'/></td></tr>
  4131. <tr><td><?=$this->T('电子邮件')?></td>
  4132. <td><input type="text" form="settings_form" id='settings_email' name='settings_email'
  4133. value='<?=$this->EMail?>'/></td></tr>
  4134. <tr><td><?=$this->T('导航栏')?>
  4135. <?=isset($this->SpecialNavigation)?"<a href='?post=".$this->SpecialNavigation."'>→</a>":""?></td>
  4136. <td><input type="text" form="settings_form" id='settings_special_navigation' name='settings_special_navigation'
  4137. value='<?=$this->SpecialNavigation?>'/></td></tr>
  4138. <tr><td><?=$this->T('脚注')?> 1<?=isset($this->SpecialFooter)?"<a href='?post=".$this->SpecialFooter."'>→</a>":""?></td>
  4139. <td><input type="text" form="settings_form" id='settings_special_footer' name='settings_special_footer'
  4140. value='<?=$this->SpecialFooter?>'/></td></tr>
  4141. <tr><td><?=$this->T('脚注')?> 2<?=isset($this->SpecialFooter2)?"<a href='?post=".$this->SpecialFooter2."'>→</a>":""?></td>
  4142. <td><input type="text" form="settings_form" id='settings_special_footer2' name='settings_special_footer2'
  4143. value='<?=$this->SpecialFooter2?>'/></td></tr>
  4144. <tr><td><?=$this->T('置顶文')?><?=isset($this->SpecialPinned)?"<a href='?post=".$this->SpecialPinned."'>→</a>":""?></td>
  4145. <td><input type="text" form="settings_form" id='settings_special_pinned' name='settings_special_pinned'
  4146. value='<?=$this->SpecialPinned?>'/></td></tr>
  4147. <tr><td><?=$this->T('默认相册')?></td>
  4148. <td><input type="text" form="settings_form" id='settings_default_gallery' name='settings_default_gallery'
  4149. value='<?=$this->DefaultGallery?>'/></td></tr>
  4150. <tr><td><?=$this->T('SelfAuth 路径')?></td>
  4151. <td><input type="text" form="settings_form" id='settings_selfauth_path' name='settings_selfauth_path'
  4152. value='<?=$this->SelfAuthPath?>'/></td></tr>
  4153. <tr><td><?=$this->T('启用评论')?></td>
  4154. <td><input type="checkbox" id="settings_enable_comments" name="settings_enable_comments"
  4155. form="settings_form" <?=$this->CommentEnabled?"checked":""?>/></td></tr>
  4156. <tr><td><?=$this->T('附加操作')?></td><td><a class='gray' href='index.php?extras=true'><?=$this->T('进入')?></a></td></tr>
  4157. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4158. <tr><td class='smaller gray'><?=$this->T('长毛象')?></td></tr>
  4159. <tr><td><?=$this->T('长毛象实例')?></td>
  4160. <td><input type="text" form="settings_form" id='settings_mastodon_url' name='settings_mastodon_url'
  4161. value='<?=$this->MastodonURL?>'/></td></tr>
  4162. <tr><td><?=$this->T('长毛象令牌')?></td>
  4163. <td><input type="text" form="settings_form" id='settings_mastodon_token' name='settings_mastodon_token'
  4164. value='<?=$this->MastodonToken?>'/></td></tr>
  4165. <tr><td><?=$this->T('偏好语言')?></td>
  4166. <td><input type="text" form="settings_form" id='settings_mastodon_lang' name='settings_mastodon_lang'
  4167. value='<?=$this->MastodonPreferredLang?>'/></td></tr>
  4168. <tr><td><?=$this->T('本站地址')?></td>
  4169. <td><input type="text" form="settings_form" id='settings_host_url' name='settings_host_url'
  4170. value='<?=$this->HostURL?>'/></td></tr>
  4171. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4172. <tr><td class='smaller gray'><?=$this->T('Activity Pub')?></td></tr>
  4173. <tr><td><?=$this->T('用户名')?></td>
  4174. <td><input type="text" form="settings_form" id='settings_apub_id' name='settings_apub_id'
  4175. value='<?=$this->APubID?>'/></td></tr>
  4176. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4177. <tr><td class='smaller gray'><?=$this->T('这里访问')?></td></tr>
  4178. <tr><td><?=$this->T('主机')?></td>
  4179. <td><input type="text" form="settings_form" id='settings_here_host' name='settings_here_host'
  4180. value='<?=$this->HereHost?>'/></td></tr>
  4181. <tr><td><?=$this->T('网站标题')?></td>
  4182. <td><input type="text" form="settings_form" id='settings_here_title' name='settings_here_title'
  4183. value='<?=$this->HereTitle?>'/></td></tr>
  4184. <tr><td><?=$this->T('短标题')?></td>
  4185. <td><input type="text" form="settings_form" id='settings_here_short_title' name='settings_here_short_title'
  4186. value='<?=$this->HereShortTitle?>'/></td></tr>
  4187. <tr><td><?=$this->T('相册')?></td>
  4188. <td><input type="text" form="settings_form" id='settings_here_album' name='settings_here_album'
  4189. value='<?=$this->HereAlbum?>'/></td></tr>
  4190. <tr><td><?=$this->T('导航栏')?>
  4191. <?=isset($this->HereNavigation)?"<a href='?post=".$this->HereNavigation."'>→</a>":""?></td>
  4192. <td><input type="text" form="settings_form" id='settings_here_navigation' name='settings_here_navigation'
  4193. value='<?=$this->HereNavigation?>'/></td></tr>
  4194. <tr><td><?=$this->T('脚注')?><?=isset($this->HereFooter)?"<a href='?post=".$this->HereFooter."'>→</a>":""?></td>
  4195. <td><input type="text" form="settings_form" id='settings_here_footer' name='settings_here_footer'
  4196. value='<?=$this->HereFooter?>'/></td></tr>
  4197. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4198. <tr><td class='smaller gray'><?=$this->T('实验访问')?></td></tr>
  4199. <tr><td><?=$this->T('主机')?></td>
  4200. <td><input type="text" form="settings_form" id='settings_exp_host' name='settings_exp_host'
  4201. value='<?=$this->ExpHost?>'/></td></tr>
  4202. <tr><td><?=$this->T('网站标题')?></td>
  4203. <td><input type="text" form="settings_form" id='settings_exp_title' name='settings_exp_title'
  4204. value='<?=$this->ExpTitle?>'/></td></tr>
  4205. <tr><td><?=$this->T('短标题')?></td>
  4206. <td><input type="text" form="settings_form" id='settings_exp_short_title' name='settings_exp_short_title'
  4207. value='<?=$this->ExpShortTitle?>'/></td></tr>
  4208. <tr><td><?=$this->T('首次提示')?><?=isset($this->ExpCaution)?"<a href='?post=".$this->ExpCaution."'>→</a>":""?></td>
  4209. <td><input type="text" form="settings_form" id='settings_exp_caution' name='settings_exp_caution'
  4210. value='<?=$this->ExpCaution?>'/></td></tr>
  4211. <tr><td><?=$this->T('相册')?></td>
  4212. <td><input type="text" form="settings_form" id='settings_exp_album' name='settings_exp_album'
  4213. value='<?=$this->ExpAlbum?>'/></td></tr>
  4214. <tr><td><?=$this->T('导航栏')?>
  4215. <?=isset($this->ExpNavigation)?"<a href='?post=".$this->ExpNavigation."'>→</a>":""?></td>
  4216. <td><input type="text" form="settings_form" id='settings_exp_navigation' name='settings_exp_navigation'
  4217. value='<?=$this->ExpNavigation?>'/></td></tr>
  4218. <tr><td><?=$this->T('脚注')?><?=isset($this->ExpFooter)?"<a href='?post=".$this->ExpFooter."'>→</a>":""?></td>
  4219. <td><input type="text" form="settings_form" id='settings_exp_footer' name='settings_exp_footer'
  4220. value='<?=$this->ExpFooter?>'/></td></tr>
  4221. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4222. <tr><td class='smaller gray'><?=$this->T('管理员')?></td><td class='smaller'>
  4223. <a href='index.php?logout=true'><?=$this->T('登出')?></a></td></tr>
  4224. <tr><td><?=$this->T('帐号')?></td>
  4225. <td><input type="text" form="settings_form" id='settings_id' name='settings_id'
  4226. value='<?=$this->Admin?>'/></td></tr>
  4227. <tr><td><?=$this->T('新密码')?></td>
  4228. <td><input type="password" form="settings_form"
  4229. id='settings_new_password' name='settings_new_password' /></td></tr>
  4230. <tr><td><?=$this->T('再次输入')?></td>
  4231. <td><input type="password" form="settings_form"
  4232. id='settings_new_password_redo' name='settings_new_password_redo' /></td></tr>
  4233. <tr><td><?=$this->T('旧密码')?></td>
  4234. <td><input type="password" form="settings_form" id='settings_old_password' name='settings_old_password' /></td></tr>
  4235. <?php }else{ ?>
  4236. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='login_form'></form>
  4237. <colgroup><col style='min-width:3em;'><col style='width:100%;min-width:5em;'></colgroup>
  4238. <tr><td class='smaller gray'><?=$this->T('请登录')?></td></tr>
  4239. <tr><td><?=$this->T('帐号')?></td>
  4240. <td><input type="text" form="login_form" id='login_id' name='login_id' /></td></tr>
  4241. <tr><td><?=$this->T('密码')?></td>
  4242. <td><input type="password" form="login_form" id='login_password' name='login_password' /></td></tr>
  4243. <?php } ?>
  4244. </table>
  4245. <?php if($this->LoggedIn){ ?>
  4246. <input class='button' form="settings_form" type="submit" name='settings_button' value='<?=$this->T('保存设置')?>' />
  4247. <?php }else{ ?>
  4248. <input class='button' form="login_form" type="submit" name='login_button' value='<?=$this->T('登录')?>' />
  4249. <?php } ?>
  4250. </div>
  4251. <?php
  4252. }
  4253. function MakeExtraOperations(){?>
  4254. <div class='settings' style='overflow:auto;'>
  4255. <h2><?=$this->T('附加操作')?></h2>
  4256. <a href='index.php?&settings=true'><?=$this->T('返回一般设置')?></a>
  4257. <p>&nbsp;</p>
  4258. <h3><?=$this->T('自动重定向')?></h3>
  4259. <span class='smaller gray'>
  4260. <?=$this->T('P为帖子跳转,匹配REQUEST_URI跳到目标文章;S为站点跳转,可以重定向来源域名,例子:')?>
  4261. <br /><pre>P discount:20001001010101;<br />S old_domain:www.new_domain.com:20001001010101;</pre></span>
  4262. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form2'></form>
  4263. <textarea id="settings_redirect" name="settings_redirect" rows="3" class='full_box' wrap="off"
  4264. form='settings_form2'><?=$this->DisplayRedirectConfig()?></textarea>
  4265. <input class='button' form="settings_form2" type="submit" name='settings_save_redirect'
  4266. value='<?=$this->T('保存重定向设置')?>' />
  4267. <p>&nbsp;</p>
  4268. <h3><?=$this->T('自定义翻译')?></h3>
  4269. <span class='smaller gray'>
  4270. <?=$this->T('填写格式:')?>
  4271. <br /><pre>- 语言 | Language</pre></span>
  4272. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form3'></form>
  4273. <textarea id="settings_translation" name="settings_translation" rows="3" class='full_box' wrap="off"
  4274. form='settings_form3'><?=$this->CustomTranslationContent?></textarea>
  4275. <input class='button' form="settings_form3" type="submit" name='settings_save_translation'
  4276. value='<?=$this->T('保存翻译')?>' />
  4277. <p>&nbsp;</p>
  4278. <p class='smaller gray'><?=$this->T('当心!下列操作将立即执行:')?></p>
  4279. <ul>
  4280. <li><a href='index.php?rewrite_styles=true'><?=$this->T('重新写入默认CSS')?></a></li>
  4281. <li><a href='index.php?regenerate_thumbnails=true'><?=$this->T('重新生成图片缩略图')?></a></li>
  4282. <li><a href='index.php?clear_all_logins=true'><?=$this->T('删除所有登录')?>(<?=sizeof($this->LoginTokens);?>)</a></li>
  4283. </ui>
  4284. <br /><br /><br /><a href='index.php?&settings=true'><?=$this->T('返回一般设置')?></a><br />&nbsp;
  4285. </div>
  4286. <?php
  4287. }
  4288. function MakeMainBegin(){?>
  4289. <div class='main' <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  4290. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"<?php } ?>>
  4291. <?php
  4292. }
  4293. function MakeMainEnd(){?>
  4294. </div>
  4295. <?php
  4296. }
  4297. function MakeExpFooter(){
  4298. $exptitle = isset($this->HereDisplayTitle)?('"'.trim($this->T($this->ChoosePartsByLanguage($this->HereDisplayTitle))).'"'):NULL;
  4299. if(!isset($exptitle)) $exptitle=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle);?>
  4300. <div class='small_footer exp_h_f exp_f'><div>
  4301. <b><?=$exptitle?></b> ©<?=$this->T($this->DisplayName)?>
  4302. <?=isset($this->HereMainImage)?("<a class='invert_a' href='?here=images/".$this->HereMainImage['name']."'>".$this->T("看全图")."</a>"):""; ?>
  4303. <div class='wayback_link gray clean_a invert_a hidden_on_print'><br class="hidden_on_desktop" />
  4304. <?php if($this->InExperimentalMode && isset($this->ExpFooter) && ($p = &$this->GetPost($this->ExpFooter,true))!=NULL){
  4305. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST,false);
  4306. }else if($this->InHereMode && isset($this->HereFooter) && ($p = &$this->GetPost($this->HereFooter,true))!=NULL){
  4307. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST,false);
  4308. }?></div>
  4309. </div>
  4310. </div>
  4311. </div><!-- page -->
  4312. </body>
  4313. </html>
  4314. <script>
  4315. if(trans = document.getElementById('translate_button')){
  4316. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  4317. }
  4318. </script>
  4319. <?php
  4320. }
  4321. function MakeImageOverlay($side_info=null,$static_image=null,$static_video=null){
  4322. $static=isset($side_info); ?>
  4323. <div id='big_image_overlay' <?=$static?"":"style='display:none'";?>>
  4324. <div class='big_image_box clean_a' onclick='HideBigImage(1)'>
  4325. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'><?=$this->T('请稍候')?></div>
  4326. <?php if(!$static_video){ ?>
  4327. <img id='big_image' onload="HideWaitingBar();" <?=isset($static_image)?("src='".$static_image."'"):""?>/><?php } ?>
  4328. <?php if(!$static_image){ ?>
  4329. <video id='big_video' onloadstart="HideWaitingBar();" controls><source id='big_video_src' type='video/mp4'
  4330. <?=isset($static_video)?("src='".$static_video."'"):""?>></video><?php } ?>
  4331. </div>
  4332. <div class='big_side_box' onclick='HideBigImage(1);'>
  4333. <?php if(!$static){ ?>
  4334. <div class='big_image_box clean_a image_nav' onclick='HideBigImage(1)'>
  4335. <div ><a id='prev_image' class='image_nav_prev img_btn_hidden' onclick="event.stopPropagation();">
  4336. <div class='lr_buttons'>←</div></a></div>
  4337. <div ><a id='next_image' class='image_nav_next img_btn_hidden' onclick="event.stopPropagation();">
  4338. <div class='lr_buttons'>→</div></a></div>
  4339. <div id='here_buttons'></div>
  4340. </div><?php } ?>
  4341. <div class='side_box_mobile_inner'>
  4342. <?php if(!$static){ ?>
  4343. <div class='inquiry_buttons img_btn_hidden' id='inquiry_buttons' onclick="event.stopPropagation();">
  4344. <span style='display:none;' id='image_purchase' class='clean_a'>
  4345. <b><a id='image_purchase_button' target="_blank">¥<?=$this->T('购买印刷品')?></a></b>
  4346. <br class='hidden_on_desktop block_on_mobile' /></span>
  4347. <b><a class='clean_a' id='image_download'><span id='download_processing'>↓</span><?=$this->T('下载')?></a></b>
  4348. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  4349. &nbsp;<a class='clean_a' id='image_inquiry'>
  4350. <b>@</b><?=$this->T('咨询')?></a>
  4351. <?php } ?><hr class='hidden_on_desktop block_on_mobile' />
  4352. </div>
  4353. <div id='big_image_share' class='clean_a' onclick="event.stopPropagation();">
  4354. <li class='wayback_close'><a onclick='HideBigImage(1);'><?=$this->T('关闭')?> ×</a></li>
  4355. <li><a id='big_share_copy'>⎘ <?=$this->T('复制链接')?></a></li>
  4356. <hr />
  4357. </div><?php } //static ?>
  4358. <div id='big_image_info' onclick="event.stopPropagation();"><?=$static?$side_info:""?></div>
  4359. <?php if($this->LoggedIn && !$static){ ?><div id='big_image_ops' onclick="event.stopPropagation();">
  4360. <br /><?=$this->T('印刷品链接')?>
  4361. <form action="" method="post" style='display:none;' id='image_ops_form'></form>
  4362. <input type='text' id='image_ops_product_link' name='image_ops_product_link' form="image_ops_form" >
  4363. <?=$this->T('重命名')?>
  4364. <input type='text' id='image_edit_new_name' name='image_edit_new_name' form="image_ops_form" >
  4365. <?=$this->T('主图')?>
  4366. <input type='text' id='image_parent' name='image_parent' form="image_ops_form" >
  4367. <input class='button' form="image_ops_form" type="submit" name='image_button' value=<?=$this->T('保存')?> />
  4368. <br /><br /><?=$this->T('替换图像')?>
  4369. <form action="" method="post" style='display:none;' id='image_edit_form' enctype="multipart/form-data"></form>
  4370. <input type="file" form='image_edit_form'
  4371. id='big_image_upload' name='upload_file_name' accept="image/x-png,image/png,image/gif,image/jpeg"/><br />
  4372. <input class='button' form="image_edit_form" type="submit" name='image_replace_button'
  4373. value=<?=$this->T('执行')?> />
  4374. </div><?php } ?>
  4375. </div>
  4376. </div>
  4377. </div>
  4378. <?php }
  4379. function MakePageEnd(){?>
  4380. </div><!-- page -->
  4381. </body>
  4382. </html>
  4383. <?php }
  4384. function MakeFooter(&$p){?>
  4385. <div class='small_footer'><div>
  4386. <hr />
  4387. <?php if(isset($p['tid']['footer'])){ ?><div class='show_on_print'><?=$p['tid']['footer'];?></div><?php } ?>
  4388. <b><?=$this->T($this->Title)?></b>
  4389. <span onclick='event.stopPropagation()'
  4390. ondblclick='javascript:window.location.href="index.php?settings=true"'>©</span><?=$this->T($this->DisplayName)?>
  4391. <div class='wayback_link clean_a invert_a hidden_on_print'><?php if(!isset($this->WayBack)){ ?>
  4392. - <a href='<?=$this->GetRedirect()?>&set_wayback=true'><?=$this->T('以过去的日期浏览')?></a>
  4393. <?php }else{ ?><a href='<?=$this->GetRedirect()?>&set_wayback=false'><?=$this->T('回到当前日期')?></a><?php } ?>
  4394. <br class='hidden_on_desktop' /> - <a href='<?=$this->GetRedirect()?>&toggle_font=true'>
  4395. <?=$this->T('切换字体')?>: <?=$this->T($this->UseRemoteFont?"远程":"本地");?></a>
  4396. <br class='hidden_on_desktop' />
  4397. - <a rel="alternate" type="application/rss+xml" href="?rss=<?=$this->LanguageAppendix;?>" />RSS/Atom<sup><?=$this->LanguageAppendix;?></sup></a>
  4398. </div>
  4399. <div class='smaller show_on_print'><?=$_SERVER['SERVER_NAME']?><br /><?=$this->EMail?></div>
  4400. </div></div>
  4401. <div class='footer'>
  4402. <div style='white-space:nowrap;'>
  4403. <div class='footer_additional'>
  4404. <?php if(isset($this->SpecialFooter) && ($p = &$this->GetPost($this->SpecialFooter))!=NULL){
  4405. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST,false);
  4406. } ?>
  4407. </div>
  4408. <div class='footer_additional'>
  4409. <?php if(isset($this->SpecialFooter2) && ($p = &$this->GetPost($this->SpecialFooter2))!=NULL){
  4410. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST,false);
  4411. } ?>
  4412. </div>
  4413. </div>
  4414. </div>
  4415. <p>&nbsp;<p>
  4416. <div id='dropping_background' style='display:none;' onclick='this.style.display="none";'
  4417. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);">
  4418. <h2 style='width:100%;'><?=$this->T('上传到这里')?></h2>
  4419. </div>
  4420. <?php $this->MakeImageOverlay(); $this->MakePageEnd(); ?>
  4421. <script>
  4422. <?=$this->ExtraScripts?>
  4423. if(back = document.getElementById('button_back')){
  4424. if(document.referrer.indexOf(location.protocol + "//" + location.host) == 0){
  4425. back.href='javascript:history.back()';
  4426. }else{
  4427. back.href='index.php';
  4428. }
  4429. }
  4430. function copy_text(t) {
  4431. ta = document.createElement('textarea');
  4432. document.body.appendChild(ta);
  4433. ta.value = t;
  4434. ta.select();
  4435. document.execCommand("copy");
  4436. document.body.removeChild(ta);
  4437. }
  4438. if(trans = document.getElementById('translate_button')){
  4439. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  4440. }
  4441. <?php if($this->LoggedIn){ ?>
  4442. var Scenter = document.querySelector('#div_center');
  4443. var Sposts = Scenter.querySelectorAll('.post');
  4444. <?php if(isset($this->MastodonToken)){ ?>
  4445. function MarkPostDoneMastodon(id,mastodon_url){
  4446. for(var i=0;i<Sposts.length;i++){
  4447. if(Sposts[i].dataset.postId==id){ Sposts[i].dataset.mastodon_url= mastodon_url; break;} }
  4448. }
  4449. <?php } ?>
  4450. <?php if($this->PageType=='post' && !isset($this->WayBack)) { ?>
  4451. var Smerge_post_dialog = Scenter.querySelector('#merge_post_dialog');
  4452. var Smerge_post = Scenter.querySelector('#merge_post');
  4453. var Smerge_post_count = Smerge_post_dialog.querySelector('#merge_post_count');
  4454. var Smerge_post_btn = Scenter.querySelector('#merge_post_btn');
  4455. var Smerge_cancel = Scenter.querySelector('#merge_cancel');
  4456. var Smerge_select = Scenter.querySelector('#merge_select');
  4457. var Smerge_thread_dialog = Scenter.querySelector('#merge_thread_dialog');
  4458. var Smerge_thread = Scenter.querySelector('#merge_thread');
  4459. var Smerge_thread_target = Scenter.querySelector('#merge_thread_target');
  4460. var Smerge_thread_btn = Scenter.querySelector('#merge_thread_btn');
  4461. var select_mode = false; var merge_mode = false; var selected_posts = null;
  4462. function TogglePostSelectMode(force_on=false,force_off=false){
  4463. Scenter.classList.add('post_selecting');
  4464. if((!select_mode || force_on) && !force_off){ ToggleThreadMerge(false,true); Scenter.classList.add('post_selecting');
  4465. Smerge_post_dialog.style.display="block";Smerge_post_btn.classList.add('text_highlight');
  4466. Smerge_cancel.innerText='<?=$this->T("取消")?>'; select_mode = 1;}
  4467. else{ select_mode = 0; Scenter.classList.remove('post_selecting');
  4468. Smerge_post_dialog.style.display="none";Smerge_post_btn.classList.remove('text_highlight');
  4469. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  4470. for(var i=0;i<Sposts.length;i++){ Sposts[i].classList.remove('post_selected');
  4471. Sposts[i].onclick=select_mode?function(){TogglePostSelect(this);}:null; }
  4472. Smerge_post_count.innerText="0";
  4473. Smerge_post.href="#";
  4474. }
  4475. function TogglePostSelect(elem){
  4476. if(elem.classList.contains('post_selected')){ elem.classList.remove('post_selected'); }
  4477. else{ elem.classList.add('post_selected'); }
  4478. selected_posts = new Array();
  4479. for(var i=0;i<Sposts.length;i++){ if(Sposts[i].classList.contains('post_selected')){
  4480. selected_posts.push(Sposts[i].dataset.postId); } }
  4481. Smerge_post.href="?merge_posts="+selected_posts.join(" ");
  4482. Smerge_post_count.innerText=selected_posts.length;
  4483. }
  4484. function ThreadMergeInput(elem){
  4485. if(elem.value.match(/[0-9]{14}/)) { Smerge_thread.href="?merge_threads=<?=$this->ActualPostID?> "+elem.value; }
  4486. else{ Smerge_thread.href="#"; }
  4487. }
  4488. function ToggleThreadMerge(force_on=false,force_off=false){
  4489. if((!merge_mode || force_on) && !force_off){ TogglePostSelectMode(false,true);
  4490. Smerge_thread_dialog.style.display="block";Smerge_thread_btn.classList.add('text_highlight');
  4491. Smerge_cancel.innerText='<?=$this->T("取消")?>'; merge_mode = 1;}
  4492. else{ merge_mode = 0;
  4493. Smerge_thread_dialog.style.display="none";Smerge_thread_btn.classList.remove('text_highlight');
  4494. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  4495. Smerge_thread.href="#";
  4496. Smerge_thread_target.value='';
  4497. }
  4498. <?php } ?>
  4499. function ShowSideUploader(){
  4500. ShowRightSide(true,null);
  4501. put = document.querySelector("#_uploader");
  4502. put.style.display='block';
  4503. RefreshSideGallery();
  4504. }
  4505. dmark = document.querySelector("#mark_details");
  4506. drename = document.querySelector("#rename_details");
  4507. dmastodon = document.querySelector("#mastodon_details");
  4508. drename_form = document.querySelector("#post_rename_form");
  4509. drename_input = document.querySelector("#post_rename_name");
  4510. var rp = document.querySelector('#post_reply_to');
  4511. var _reply_to = rp?rp.defaultValue:"";
  4512. function RestoreReply(){
  4513. if(rp){
  4514. rp.defaultValue = _reply_to;
  4515. }
  4516. document.querySelector('#post_reply_restore').style.display='none';
  4517. ht = document.querySelector('#post_hint_text');
  4518. if (_reply_to!=""){
  4519. ht.style.display='block';
  4520. ht.innerHTML="<?=$this->T('继续补充该话题:')?>";
  4521. }else{
  4522. ht.style.display='none';
  4523. }
  4524. document.querySelector('#post_edit_target').value="";
  4525. ch = document.querySelector('#post_hint_modify');
  4526. ch.style.display='none';
  4527. }
  4528. function MakeRefer(id){
  4529. t = document.querySelector('#post_content')
  4530. t.focus();
  4531. v = t.value;
  4532. t.value = v.slice(0, t.selectionStart) + "[<?=$this->T('引用文章')?>]("+id.toString()+")" + v.slice(t.selectionEnd);
  4533. la_auto_grow(t);
  4534. if(rp){
  4535. rp.defaultValue = "";
  4536. ht = document.querySelector('#post_hint_text');
  4537. ht.innerHTML = "<?=$this->T('引用并发送新话题:')?>"; ht.style.display='block';
  4538. document.querySelector('#post_reply_restore').style.display='inline';
  4539. rs = document.querySelector('#post_reply_restore');
  4540. rs.style.display='inline'; rs.innerHTML="<?=$this->T('切换为回复')?>";
  4541. document.getElementById('post_menu').style.display='none';
  4542. ch = document.querySelector('#post_hint_modify');
  4543. ch.style.display='none';
  4544. }
  4545. }
  4546. function CopyRefer(id){
  4547. copy_text(id.toString());
  4548. menu.querySelector('#menu_refer_copy').innerHTML="<?=$this->T('已复制')?>";
  4549. }
  4550. function MakeEdit(id){
  4551. ed = document.getElementById('menu_edit');
  4552. ed.innerHTML="<?=$this->T('稍等')?>";
  4553. ed.href="#";
  4554. var xhr = new XMLHttpRequest();
  4555. xhr.onreadystatechange = function() {
  4556. if (this.readyState == 4 && this.status == 200) {
  4557. ed.innerHTML='——';
  4558. ch = document.querySelector('#post_hint_modify');
  4559. ch.style.display='block';
  4560. ht = document.querySelector('#post_hint_text');
  4561. ht.innerHTML = "<?=$this->T('修改帖子:')?>";
  4562. rs = document.querySelector('#post_reply_restore');
  4563. rs.style.display='inline'; rs.innerHTML="<?=$this->T('取消')?>";
  4564. t = document.querySelector('#post_content');
  4565. t.value=xhr.responseText.trim();
  4566. t.focus();
  4567. la_auto_grow(t);
  4568. document.querySelector('#post_edit_target').value=id;
  4569. document.getElementById('post_menu').style.display='none';
  4570. }
  4571. };
  4572. xhr.open("GET", "index.php?post="+id.toString()+'&post_original=true', true);
  4573. xhr.send();
  4574. }
  4575. function MarkDelete(id){
  4576. p = document.querySelector('[data-post-id="'+id+'"]');
  4577. op = p.dataset.markDelete?"false":"true";
  4578. window.location.href=
  4579. "index.php?<?=$this->GetRedirect()?>&mark_delete="+op+'&target='+id.toString();
  4580. }
  4581. function SetMark(mark){
  4582. menu = document.getElementById('post_menu');
  4583. window.location.href=
  4584. "index.php?<?=$this->GetRedirect()?>&target="+
  4585. menu.parentNode.dataset.postId+"&set_mark="+mark;
  4586. }
  4587. function ToggleMarkDetails(){
  4588. dmark.style.display=(dmark.style.display=='block')?'none':'block';
  4589. drename.style.display=dmastodon.style.display='none';
  4590. }
  4591. function ToggleRenameDetails(){
  4592. drename.style.display=(drename.style.display=='block')?'none':'block';
  4593. dmark.style.display=dmastodon.style.display='none';
  4594. }
  4595. function ToggleMastodonDetails(){
  4596. dmastodon.style.display=(dmastodon.style.display=='block')?'none':'block';
  4597. dmark.style.display=drename.style.display='none';
  4598. }
  4599. <?php } ?>
  4600. function ShowPostMenu(post){
  4601. menu = document.getElementById('post_menu');
  4602. menu.style.display='block';
  4603. menu.parentNode.removeChild(menu);
  4604. post.appendChild(menu);
  4605. menu.style.display='block';
  4606. id = post.dataset.postId
  4607. menu.querySelector('#_time_hook').innerHTML = ''+id.substring(2,4)+'/'+id.substring(4,6)+'/'+id.substring(6,8)+
  4608. ' '+id.substring(8,10)+':'+id.substring(10,12);
  4609. window.onClick="HidePopMenu()";
  4610. menu.onClick=(function(event){
  4611. event.stopPropagation();
  4612. });
  4613. hs = menu.querySelector('#menu_history');
  4614. hs.href='?post='+id+'&history=1';
  4615. <?php if($this->LoggedIn && !isset($this->WayBack)){ ?>
  4616. menu.querySelector('#menu_refer').href='javascript:MakeRefer(id)';
  4617. ref = menu.querySelector('#menu_refer_copy')
  4618. ref.innerHTML='<?=$this->T("复制编号")?>';
  4619. ref.href='javascript:CopyRefer(id)';
  4620. ed = menu.querySelector('#menu_edit')
  4621. ed.href='javascript:MakeEdit(id)'; ed.innerHTML="<?=$this->T('修改')?>";
  4622. d = menu.querySelector('#menu_delete');
  4623. d.href='javascript:MarkDelete(\"'+id+'\")';
  4624. p = document.querySelector('[data-post-id="'+id+'"]');
  4625. d.innerHTML = p.dataset.markDelete?"<?=$this->T('恢复')?>":"<?=$this->T('删除')?>";
  4626. menu.querySelector('#mark_details').dataset.id=id;
  4627. drename_input.value=id;
  4628. drename_form.action="<?=$this->GetRedirect()?>"+"&rename_post="+id;
  4629. <?php if(isset($this->MastodonToken)){ ?>
  4630. dmastodon_form = document.querySelector("#post_mastodon_form");
  4631. dmastodon_form.action='?mastodon_post='+id;
  4632. function MastodonSend(id){
  4633. mastodon_send.innerHTML="<?=$this->T('稍等')?>";
  4634. var xhr = new XMLHttpRequest();
  4635. function wrapidxhr(_id) { return function() {
  4636. if (this.readyState == 4 && this.status == 200) {
  4637. var response = xhr.responseText;
  4638. let content="";
  4639. if(res = response.match(/SUCCESS (\S+)/u)){
  4640. content="<?=$this->T('成功发送到长毛象')?>";
  4641. }else{content="<b><?=$this->T('出现问题')?></b><br /><span class='smaller'>"+response+"</span>";}
  4642. mastodon_send.innerHTML=content; mastodon_send.href=res[1];
  4643. MarkPostDoneMastodon(_id, res[1]);
  4644. } }
  4645. };
  4646. xhr.onreadystatechange = wrapidxhr(id);
  4647. xhr.open("GET", "index.php?mastodon_send_post="+id, true); xhr.send();
  4648. }
  4649. menu_mastodon = menu.querySelector("#menu_mastodon");
  4650. mastodon_send = menu.querySelector("#menu_mastodon_send");
  4651. mastodon_view = menu.querySelector("#menu_mastodon_view");
  4652. mastodon_url = menu.querySelector("#post_mastodon_url");
  4653. if(p.dataset.mastodon_url){mastodon_view.style.display='inline';mastodon_view.href=p.dataset.mastodon_url;
  4654. mastodon_send.innerHTML='<?=$this->T("重新发送")?>'; mastodon_url.value=p.dataset.mastodon_url; }
  4655. else{mastodon_view.style.display='none';mastodon_view.href=""; mastodon_send.innerHTML="<?=$this->T('发送')?>";
  4656. mastodon_url.value="";}
  4657. mastodon_send.onclick=function(){
  4658. this.onclick=function(){};
  4659. MastodonSend(id); };
  4660. <?php } } ?>
  4661. title = document.title;
  4662. copy = document.getElementById('share_copy');
  4663. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  4664. copy.addEventListener("click", function(){
  4665. url = window.location
  4666. path = location.pathname
  4667. copy_text(url.protocol+"//"+url.host+path+"?post="+id);
  4668. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  4669. });
  4670. }
  4671. function HidePopMenu(){
  4672. var menus = document.querySelectorAll('.pop_menu');
  4673. [].forEach.call(menus, function(m){m.style.display='none';});
  4674. }
  4675. var posts = document.querySelectorAll('.center .post');
  4676. [].forEach.call(posts, function(p){
  4677. if(s=p.querySelector('._menu_hook')) s.addEventListener("click", function() {
  4678. ShowPostMenu(this.parentNode.parentNode);
  4679. });
  4680. });
  4681. var post_clickables = document.querySelectorAll('.center .post a');
  4682. [].forEach.call(post_clickables, function(p){
  4683. p.addEventListener("click", function(event){
  4684. event.stopPropagation();
  4685. });
  4686. });
  4687. function FindImage(imgsrc){
  4688. for(var i=0;i<document.images_filtered.length;i++){
  4689. if (document.images_filtered[i].dataset.imgsrc==imgsrc) return document.images_filtered[i]
  4690. }
  4691. return null
  4692. }
  4693. var dottime1;
  4694. var dottime2;
  4695. function ToDataURL(url) {
  4696. return fetch(url).then((response) => {return response.blob();}).then(blob => {
  4697. clearTimeout(dottime1);clearTimeout(dottime2);
  4698. ps = document.querySelector('#download_processing');
  4699. ps.innerHTML='↓';ps.style.opacity='';
  4700. return URL.createObjectURL(blob);});
  4701. }
  4702. async function DownloadAsImage(url,name) {
  4703. const a = document.createElement("a"); a.href = await ToDataURL(url); a.download = name;
  4704. document.body.appendChild(a); a.click(); document.body.removeChild(a);
  4705. }
  4706. function basename(url){return url.split(/[\\/]/).pop();}
  4707. pushed=0;
  4708. function ShowBigImage(imgsrc,do_push){
  4709. ShowWaitingBar();
  4710. share = document.querySelector('#big_image_share');
  4711. img = document.querySelector('#big_image');
  4712. vid = document.querySelector('#big_video');
  4713. vidsrc = document.querySelector('#big_video_src');
  4714. down = document.querySelector('#image_download');
  4715. img.src = ""; vidsrc.src="";
  4716. if(imgsrc.match(/\.mp4$/)){
  4717. vidsrc.src = src = "images/"+imgsrc; img.style.display='none'; vid.load();vid.style.display='block';
  4718. }else{
  4719. img.src = src = "images/"+imgsrc; vid.style.display='none';img.style.display='block';
  4720. }
  4721. down.href="images/"+imgsrc;
  4722. var downname='<?=$this->T($this->Title);?>_<?=$this->T($this->DisplayName);?>_<?=$this->GiveSafeEMail()?>_'+
  4723. basename(down.href);
  4724. img.alt = downname; down.download=downname;
  4725. var use_href = "images/"+imgsrc;
  4726. down.onclick=function(event){event.stopPropagation();event.preventDefault();
  4727. ps = this.querySelector('#download_processing');ps.innerText='…';
  4728. var dotwait = function(ps){ var self = this;
  4729. dottime1 = setTimeout(function(ps){
  4730. ps.style.opacity='0'; dottime2 = setTimeout(function(ps){ps.style.opacity='1'; dotwait(ps);},300,ps); },300,ps) }
  4731. dotwait(this.querySelector('#download_processing'));
  4732. DownloadAsImage(use_href,downname);};
  4733. if(do_push){PushGalleryHistory(src)}
  4734. page_url = encodeURIComponent(window.location.href);
  4735. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  4736. inqb = document.querySelector('#image_inquiry');
  4737. inqb.href="mailto:<?=$this->T($this->DisplayName);?>\<<?=$this->EMail?>\>?subject=<?=$this->T('网站图片咨询');?>&body="+
  4738. encodeURIComponent("<?=$this->T('你好!我对你网站上的这张图片感兴趣:')?>"+'\n\n')+
  4739. (page_url)+encodeURIComponent('\n\n');
  4740. <?php } ?>
  4741. this_image = FindImage(imgsrc);
  4742. if(this_image&&this_image.dataset.prevsrc){
  4743. new_image = FindImage(this_image.dataset.prevsrc);
  4744. new_prev = new_image?new_image.dataset.prevsrc:null;
  4745. im = document.querySelector('#prev_image');
  4746. if(new_prev) {im.href='javascript:ShowBigImage("'+this_image.dataset.prevsrc+'",'+do_push+')';im.style.opacity='';}
  4747. else {im.style.opacity='0';im.removeAttribute("href");}
  4748. }
  4749. if(this_image&&this_image.dataset.nextsrc){
  4750. new_image = FindImage(this_image.dataset.nextsrc);
  4751. new_next = new_image?new_image.dataset.nextsrc:null;
  4752. im = document.querySelector('#next_image');
  4753. if(new_next) {im.href='javascript:ShowBigImage("'+this_image.dataset.nextsrc+'",'+do_push+')';im.style.opacity='';}
  4754. else {im.style.opacity='0';im.removeAttribute("href");}
  4755. }
  4756. purchase = document.querySelector('#image_purchase');
  4757. purchase_btn = document.querySelector('#image_purchase_button');
  4758. <?php if($this->LoggedIn){ ?>
  4759. product_link = document.querySelector('#image_ops_product_link');
  4760. product_form = document.querySelector('#image_ops_form');
  4761. edit_form = document.querySelector('#image_edit_form');
  4762. edit_new_name = document.querySelector('#image_edit_new_name');
  4763. edit_parent = document.querySelector('#image_parent');
  4764. product_form.action = window.location.href;
  4765. edit_form.action = window.location.href;
  4766. edit_new_name.value = imgsrc.split('.')[0];
  4767. if(this_image&&this_image.dataset.product){ product_link.value = this_image.dataset.product; }else{ product_link.value = ""; }
  4768. if(this_image&&this_image.dataset.parent){ edit_parent.value = this_image.dataset.parent; }else{ edit_parent.value = ""; }
  4769. <?php } ?>
  4770. if(this_image&&this_image.dataset.product){
  4771. purchase.style.display='';
  4772. href = this_image.dataset.product;
  4773. if(this_image.dataset.product.match('^[0-9]{14}$')){
  4774. href = '?post='+href;
  4775. }
  4776. purchase_btn.href = href;
  4777. }else{
  4778. purchase.style.display='none';
  4779. purchase_btn.removeAttribute("href");
  4780. }
  4781. DelayHideImgBtn(null);
  4782. title = encodeURIComponent(document.title);
  4783. copy = document.getElementById('big_share_copy');
  4784. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  4785. copy.addEventListener("click", function(){
  4786. copy_text(window.location.href);
  4787. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  4788. });
  4789. o = document.querySelector('#big_image_overlay');
  4790. info = document.querySelector('#big_image_info');info.innerHTML="<?=$this->T('正在查询……')?>";
  4791. here = document.querySelector('#here_buttons');here.innerHTML='';
  4792. o.style.display="block";
  4793. ShowBackdrop(0.8);
  4794. var xhr = new XMLHttpRequest();
  4795. xhr.onreadystatechange = function() {
  4796. if (this.readyState == 4 && this.status == 200) {
  4797. info = document.querySelector('#big_image_info');
  4798. var response = xhr.responseText;
  4799. let content=""
  4800. if(res = response.match(/<ref>(.*)<\/ref>/u)){
  4801. content="<span class='small'><?=$this->T('该图片出现在')?> "+res[1]+" <?=$this->T('个帖子中')?></span>"+content;
  4802. }else{content="<span class='smaller gray'><?=$this->T('该图片未被引用')?></span>"+content;}
  4803. if(res = response.match(/<insert>([\s\S]*)<\/insert>/u)){
  4804. content+="<div class='clean_a'>"+res[1]+"</div>"; }
  4805. info.innerHTML=content;
  4806. if(res = response.match(/<here>([\s\S]*)<\/here>/u)){
  4807. here.innerHTML=res[1]; window.here_b=document.getElementsByClassName('here_btn');
  4808. if(window.here_b)for(b=0;b<window.here_b.length;b++) {
  4809. window.here_b[b].addEventListener('mousemove',DontHideImgBtn);
  4810. window.here_b[b].addEventListener('mouseover',DontHideImgBtn);}
  4811. }
  4812. }
  4813. };
  4814. xhr.open("GET", "index.php?image_info="+imgsrc+"", true);
  4815. xhr.send();
  4816. }
  4817. function HideBigImage(do_push){
  4818. o = document.querySelector('#big_image_overlay');
  4819. img = document.querySelector('#big_image');
  4820. vid = document.querySelector('#big_video');
  4821. vidsrc = document.querySelector('#big_video_src');
  4822. img.src = ""; vidsrc.src="";
  4823. if(o.style.display!='none'){
  4824. o.style.display="none";
  4825. HideBackdrop();
  4826. if(do_push){PushGalleryHistory("");}
  4827. HideWaitingBar();
  4828. }
  4829. }
  4830. var lbtn=document.querySelector('#prev_image'),rbtn=document.querySelector('#next_image');
  4831. var inq=document.querySelector('#inquiry_buttons');
  4832. var overlay=document.querySelector('#big_image_overlay');
  4833. var hide_timeout;
  4834. function DontHideImgBtn(e){ clearTimeout(hide_timeout); e.stopPropagation(); }
  4835. function DelayHideImgBtn(e){
  4836. lbtn.classList.remove('img_btn_hidden'); rbtn.classList.remove('img_btn_hidden');
  4837. inq.classList.remove('img_btn_hidden');
  4838. if(window.here_b)for(b=0;b<window.here_b.length;b++){window.here_b[b].classList.remove('img_btn_hidden');}
  4839. clearTimeout(hide_timeout);
  4840. hide_timeout = setTimeout(function(e1,e2,e3,e4){e1.classList.add('img_btn_hidden');
  4841. e2.classList.add('img_btn_hidden');e3.classList.add('img_btn_hidden');
  4842. if(window.here_b)for(b=0;b<window.here_b.length;b++){
  4843. window.here_b[b].classList.add('img_btn_hidden');}}, 1000, lbtn, rbtn, inq);
  4844. }
  4845. lbtn.addEventListener('mousemove',DontHideImgBtn);lbtn.addEventListener('mouseover',DontHideImgBtn);
  4846. rbtn.addEventListener('mousemove',DontHideImgBtn);rbtn.addEventListener('mouseover',DontHideImgBtn);
  4847. inq.addEventListener('mousemove',DontHideImgBtn);inq.addEventListener('mouseover',DontHideImgBtn);
  4848. overlay.addEventListener('mousemove',DelayHideImgBtn);
  4849. var images = document.querySelectorAll('img, video');
  4850. var images_filtered=new Array(); var imgadded = new Array();
  4851. var images_remaining=new Array();
  4852. [].forEach.call(images, function(img){
  4853. if(img.classList.contains("no_pop") || (!(imgsrc = img.dataset.imgsrc))) return;
  4854. if(imgadded.indexOf(imgsrc)>=0) {images_remaining.push(img); return;}
  4855. images_filtered.push(img);imgadded.push(imgsrc);
  4856. });
  4857. for(var i=0; i<images_filtered.length; i++){
  4858. previmg = nextimg = null; img = images_filtered[i];
  4859. if(i>0) previmg=images_filtered[i-1];
  4860. if(i<images_filtered.length-1) nextimg=images_filtered[i+1];
  4861. prevsrc=previmg?previmg.dataset.imgsrc:null; nextsrc=nextimg?nextimg.dataset.imgsrc:null;
  4862. img.dataset.prevsrc = prevsrc; img.dataset.nextsrc = nextsrc;
  4863. function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
  4864. img.addEventListener("click", wrap(img.dataset.imgsrc));
  4865. }
  4866. for(var i=0; i<images_remaining.length; i++){
  4867. img = images_remaining[i];
  4868. function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
  4869. img.addEventListener("click", wrap(img.dataset.imgsrc));
  4870. }
  4871. document.images_filtered = images_filtered;
  4872. function PopGalleryHistory(){
  4873. if(pushed){
  4874. pushed = 0;
  4875. try{
  4876. history.back();
  4877. }catch{
  4878. console.log("can't do it.");
  4879. }
  4880. }
  4881. }
  4882. function PushGalleryHistory(src){
  4883. abs_img = window.location.protocol+"//"+window.location.host+'/'+src
  4884. title = "照片"
  4885. extra = "?";
  4886. sp = new URLSearchParams(window.location.search)
  4887. if(sp.has('post')){extra+="post="+sp.get('post')}
  4888. if(sp.has('gallery')){extra+="&gallery="+sp.get('gallery')}
  4889. try{
  4890. window.history.pushState('&pic='+src, 'Title', extra+'&pic='+src);
  4891. }catch{
  4892. console.log("can't do it.");
  4893. }
  4894. pushed = 1;
  4895. }
  4896. document.addEventListener('keydown', function(e){
  4897. large = document.getElementById('big_image_overlay')
  4898. if (large.style.display!='block') return;
  4899. if(e.key=='Escape'||e.key=='Esc'||e.keyCode==27){
  4900. HideBigImage(1);
  4901. }
  4902. }, true);
  4903. window.addEventListener('popstate', (event) => {
  4904. if(event.state){
  4905. let sp = new URLSearchParams(event.state)
  4906. if(sp.has('pic')){
  4907. src = sp.get('pic')
  4908. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)) ShowBigImage(onlyimg[0], 0);
  4909. else{HideBigImage(0);}
  4910. }
  4911. }else{HideBigImage(0);}
  4912. });
  4913. let searchParams = new URLSearchParams(window.location.search)
  4914. if(searchParams.has('pic')){
  4915. src = searchParams.get('pic')
  4916. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)){
  4917. ShowBigImage(onlyimg[0], 1);
  4918. }
  4919. }
  4920. function _dropHandler(event){ if (typeof dropHandler === "function") dropHandler(event); }
  4921. function _dragOverHandler(event){ if (typeof dragOverHandler === "function") dragOverHandler(event); }
  4922. </script>
  4923. </body>
  4924. <?php
  4925. }
  4926. function DoIdentifyExperimental(){
  4927. if(isset($this->ExpHost) && $this->ExpHost && preg_match('/'.preg_quote($this->ExpHost).'/u', $_SERVER['HTTP_HOST'])){
  4928. $this->InExperimentalMode=True; $this->InHereMode=True;
  4929. }
  4930. if(isset($this->HereHost) && $this->HereHost && preg_match('/'.preg_quote($this->HereHost).'/u', $_SERVER['HTTP_HOST'])){
  4931. $this->InHereMode=True;
  4932. }
  4933. }
  4934. function DoExperimentalTopLink($p){
  4935. if($this->InHereMode && $p){
  4936. if(isset($p['tid']) && $p['tid']['first']!=$p){
  4937. header('Location: ?post='.$p['tid']['first']['id']); exit();
  4938. }
  4939. }
  4940. }
  4941. function MakeExperimentalConfirm(){
  4942. if(isset($_COOKIE['la_experimental']) && $_COOKIE['la_experimental'] == 'confirmed'){
  4943. return false;
  4944. }
  4945. $caution_html =
  4946. $confirm = "<a class='text_highlight clean_a bold' href='index.php?confirm_enter=1".
  4947. (isset($this->CurrentPostID)?("&post=".$this->CurrentPostID):"").
  4948. "'>&nbsp;&nbsp;".$this->T('继续')."&nbsp;&nbsp;</a>";
  4949. ?>
  4950. <div class='center_exp'><?php
  4951. if(isset($this->ExpCaution) && ($p=$this->GetPost($this->ExpCaution,true)))$this->MakeSinglePostExp($p);
  4952. else echo "<li class='post post_dummy'>".$this->TranslatePostParts("<h1>注意</h1><p>您将进入实验站。</p>")."</li>";
  4953. ?></div>
  4954. <div class='center_exp'><li class='post post_dummy'><p><?=$confirm?></p></li></div>
  4955. <?php return true;
  4956. }
  4957. }
  4958. $la = new LA;
  4959. $la->DoSiteRedirect();
  4960. $la->DoLogin();
  4961. $la->SwitchLanguageAndFont();
  4962. $err = $la->ProcessRequest($message, $redirect);
  4963. $la->WriteAsNecessary();
  4964. $la->DoIdentifyExperimental();
  4965. $la->SwitchWayBackMode();
  4966. if($err){
  4967. echo $message;
  4968. exit();
  4969. }
  4970. if(isset($redirect)){
  4971. header('Location: '.$redirect);
  4972. exit();
  4973. }
  4974. $la->DetectPageType();
  4975. $la->ReadImages(false);
  4976. $la->ReadPosts();
  4977. if(isset($la->WayBack)){
  4978. $la->ReadArchive();
  4979. }
  4980. $im = NULL;
  4981. if(preg_match('/images\/(.*)/u',$la->HereID,$imname) && ($im = &$la->FindImage($imname[1]))){
  4982. if(!$la->CanShowImage($im)) { $im=&$la->NULL_IMAGE; }
  4983. }
  4984. $p = &$la->GetPost($la->CurrentPostID);
  4985. if(!isset($p)){
  4986. $p = &$la->GetMergedPost($la->CurrentPostID);
  4987. }
  4988. if(isset($p) && !$la->CanShowPost($p)) $p=NULL;
  4989. else{ $la->DoExperimentalTopLink($p); }
  4990. if(isset($p)){ $la->ActualPostID = $p['id']; }
  4991. if($la->PageType=='here' ||$la->PageType=='experimental'){
  4992. if($im){
  4993. $la->SetHereMainImage($im);
  4994. $la->RecordVisitedHere($im['name'],$im?$la->ImageTitle($im):NULL);
  4995. }else if($p){
  4996. $la->RecordVisitedHere($p['id'],NULL);
  4997. }else {
  4998. $im = &$la->GiveImageInHere(false);
  4999. if($im){
  5000. $la->SetHereMainImage($im);
  5001. $la->RecordVisitedHere($im['name'],$la->ImageTitle($im));
  5002. }
  5003. }
  5004. }
  5005. $la->MakeHeader($p);
  5006. $la->MakeMainBegin();
  5007. if($la->PageType=='here' ||$la->PageType=='experimental'){
  5008. if(($la->PageType=='experimental' && (!$la->MakeExperimentalConfirm())) || $la->PageType=='here'){
  5009. if($im){
  5010. $la->MakeHereSection($im);
  5011. }else if($p){
  5012. $la->MakePostSectionExp($p);
  5013. $la->MakeLinkedPostsExp($p);
  5014. }else {
  5015. if($im){
  5016. $la->MakeHereSection($im);
  5017. }else{
  5018. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5019. "</p><p><a href='index.php'>".$la->T('返回首页')."</a></p><br />";
  5020. }
  5021. }
  5022. }
  5023. $la->MakeMainEnd();
  5024. $la->MakeExpFooter();
  5025. }else{
  5026. if($la->PageType=='extras'){
  5027. $la->MakeExtraOperations();
  5028. }else if($la->PageType=='settings'){
  5029. $la->MakeSettings();
  5030. }else if($la->PageType=='gallery'){
  5031. $la->MakeGalleryLeft();
  5032. $la->MakeGallerySection();
  5033. }else if($la->PageType=='post'){
  5034. if($p){
  5035. $made_interesting = false;
  5036. if($la->IsInterestingPost($p)){
  5037. $la->MakeInterestingSection($p['tid']);
  5038. }
  5039. else{
  5040. $la->MakeLinkedPosts($p);
  5041. $la->MakePostSection($p);
  5042. $la->MakeTOC();
  5043. }
  5044. }else{
  5045. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5046. "</p><p><a href='index.php'>".$la->T('返回首页')."</a></p><br />";
  5047. }
  5048. }else if($la->PageType=='history'){
  5049. $la->ReadArchive();
  5050. $la->MakePostHistory($p, $_GET['version']??NULL);
  5051. }else if($la->PageType=='search'){
  5052. $la->MakeHotPosts(true);
  5053. $la->MakeRecentPosts($_GET['search']);
  5054. }else if($la->PageType=='category'){
  5055. $la->MakeHotPosts(true);
  5056. $la->MakeRecentPosts(NULL,$_GET['category']);
  5057. }else if($la->PageType=='comments'){
  5058. $la->MakeCommentPosts();
  5059. }else{
  5060. $la->MakeHotPosts();
  5061. $la->MakeRecentPosts();
  5062. }
  5063. $la->MakeMainEnd();
  5064. $la->MakeFooter($p);
  5065. }
  5066. ?>