*/}}

index.php 295 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255
  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. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?post='.$r['target'].' [R=302,L]'.PHP_EOL.PHP_EOL);
  162. }// do site redirect in php.
  163. }
  164. fwrite($conf, 'RewriteCond %{HTTPS} !=on'.PHP_EOL.
  165. 'RewriteCond %{HTTP_HOST} !=localhost'.PHP_EOL.
  166. 'RewriteCond %{REQUEST_URI} !^.*(jpg|png|gif)$'.PHP_EOL.
  167. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]'.PHP_EOL.PHP_EOL);
  168. fwrite($conf, 'RewriteCond %{HTTP_HOST} !^www\.'.PHP_EOL.
  169. 'RewriteCond %{HTTP_HOST} !=localhost'.PHP_EOL.
  170. 'RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]'.PHP_EOL.PHP_EOL);
  171. fwrite($conf,'<Files ~ "\.md$">'.PHP_EOL.'deny from all'.PHP_EOL.'</Files>'.PHP_EOL);
  172. fflush($conf);fclose($conf);
  173. }
  174. function BuildRedirectConfig($conf){
  175. $this->Redirect=[];
  176. if(preg_match_all('/P\s+(.*)\:\s*([0-9]{14})\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  177. foreach($ma as $m){
  178. $redirect=[]; $redirect['for'] = 'P'; $redirect['format'] = $m[1]; $redirect['target'] = $m[2];
  179. $this->Redirect[]=$redirect;
  180. }
  181. }
  182. if(preg_match_all('/S\s+(\S+)\s*\:\s*(\S+)\s*\:\s*([0-9]{14})\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  183. foreach($ma as $m){
  184. $redirect=[]; $redirect['for'] = 'S'; $redirect['format'] = $m[1]; $redirect['domain'] = $m[2]; $redirect['target'] = $m[3];
  185. $this->Redirect[]=$redirect;
  186. }
  187. }
  188. }
  189. function WriteTokens(){
  190. $tf = fopen('la_tokens.php','w');
  191. fwrite($tf,'<?php header("Location:index.php"); exit; ?>'.PHP_EOL.PHP_EOL);
  192. if(isset($this->LoginTokens) && sizeof($this->LoginTokens)) {
  193. foreach($this->LoginTokens as $t){
  194. fwrite($tf,'- '.$t.PHP_EOL);
  195. }
  196. }
  197. fflush($tf);fclose($tf);
  198. }
  199. function WriteConfig(){
  200. if(!isset($this->Title)) $this->Title = $this->T('那么的维基');
  201. if(!isset($this->ShortTitle)) $this->ShortTitle = $this->T('基');
  202. if(!isset($this->Admin)) $this->Admin = 'admin';
  203. if(!isset($this->DisplayName)) $this->DisplayName = $this->T('管理员');
  204. if(!isset($this->Password)) $this->Password = password_hash('Admin', PASSWORD_DEFAULT).PHP_EOL;
  205. $conf = fopen('la_config.php','w');
  206. fwrite($conf,'<?php header("Location:index.php"); exit; ?> '.PHP_EOL.PHP_EOL);
  207. fwrite($conf,'- Title = '.$this->Title.PHP_EOL);
  208. fwrite($conf,'- ShortTitle = '.$this->ShortTitle.PHP_EOL);
  209. fwrite($conf,'- Admin = '.$this->Admin.PHP_EOL);
  210. fwrite($conf,'- DisplayName = '.$this->DisplayName.PHP_EOL);
  211. fwrite($conf,'- Password = '.$this->Password.PHP_EOL);
  212. fwrite($conf,'- EMail = '.$this->EMail.PHP_EOL);
  213. fwrite($conf,'- SpecialNavigation = '.$this->SpecialNavigation.PHP_EOL);
  214. fwrite($conf,'- SpecialFooter = '.$this->SpecialFooter.PHP_EOL);
  215. fwrite($conf,'- SpecialFooter2 = '.$this->SpecialFooter2.PHP_EOL);
  216. fwrite($conf,'- SpecialPinned = '.$this->SpecialPinned.PHP_EOL);
  217. fwrite($conf,'- DefaultGallery = '.$this->DefaultGallery.PHP_EOL);
  218. fwrite($conf,'- SelfAuthPath = '.$this->SelfAuthPath.PHP_EOL);
  219. fwrite($conf,'- CommentEnabled = '.($this->CommentEnabled?"True":"False").PHP_EOL);
  220. fwrite($conf,'- HereHost = '.$this->HereHost.PHP_EOL);
  221. fwrite($conf,'- HereTitle = '.$this->HereTitle.PHP_EOL);
  222. fwrite($conf,'- HereShortTitle = '.$this->HereShortTitle.PHP_EOL);
  223. fwrite($conf,'- HereAlbum = '.$this->HereAlbum.PHP_EOL);
  224. fwrite($conf,'- HereNavigation = '.$this->HereNavigation.PHP_EOL);
  225. fwrite($conf,'- HereFooter = '.$this->HereFooter.PHP_EOL);
  226. fwrite($conf,'- ExpHost = '.$this->ExpHost.PHP_EOL);
  227. fwrite($conf,'- ExpTitle = '.$this->ExpTitle.PHP_EOL);
  228. fwrite($conf,'- ExpShortTitle = '.$this->ExpShortTitle.PHP_EOL);
  229. fwrite($conf,'- ExpCaution = '.$this->ExpCaution.PHP_EOL);
  230. fwrite($conf,'- ExpAlbum = '.$this->ExpAlbum.PHP_EOL);
  231. fwrite($conf,'- ExpNavigation = '.$this->ExpNavigation.PHP_EOL);
  232. fwrite($conf,'- ExpFooter = '.$this->ExpFooter.PHP_EOL);
  233. fwrite($conf,'- MastodonToken = '.$this->MastodonToken.PHP_EOL);
  234. fwrite($conf,'- MastodonURL = '.$this->MastodonURL.PHP_EOL);
  235. fwrite($conf,'- MastodonPreferredLang = '.$this->MastodonPreferredLang.PHP_EOL);
  236. fwrite($conf,'- HostURL = '.$this->HostURL.PHP_EOL);
  237. fwrite($conf,'- APubID = '.$this->APubID.PHP_EOL);
  238. fflush($conf);fclose($conf);
  239. $conf = fopen('la_redirect.md','w');
  240. fwrite($conf,$this->DisplayRedirectConfig());fflush($conf);fclose($conf);
  241. $this->WriteHTACCESS();
  242. $this->WriteTokens();
  243. }
  244. function Install(){
  245. if(!file_exists('la_config.php')){
  246. $this->WriteConfig();
  247. }
  248. if(!is_dir('posts')) mkdir('posts');
  249. if(!is_dir('images')) mkdir('images');
  250. if(!is_dir('images/thumb')) mkdir('images/thumb');
  251. if(!is_dir('styles')) mkdir('styles');
  252. if(!is_dir('archive')) mkdir('archive');
  253. $this->WriteStyles();
  254. $this->WriteHTACCESS();
  255. }
  256. function ReadFromExistingConfig(){
  257. $f=null;
  258. if(file_exists('la_config.php')) $f='la_config.php';
  259. else if(file_exists('la_config.md')) $f='la_config.md';
  260. if(!isset($f)) return;
  261. $c = file_get_contents($f);
  262. if(preg_match_all('/-\s*(\S+)\s*=\s*(\S+)\s*$/um', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  263. $str = $m[1];
  264. $this->$str = $m[2];
  265. }
  266. $this->CommentEnabled = $this->CommentEnabled=="True";
  267. }
  268. function ReadConfig(){
  269. $this->ReadFromExistingConfig();
  270. if(file_exists('la_redirect.md')){
  271. $c = file_get_contents('la_redirect.md');
  272. $this->BuildRedirectConfig($c);
  273. }
  274. if(!file_exists('la_config.php')){
  275. $this->Install();
  276. }
  277. $this->Translations=[];
  278. if(file_exists("translations.md")){
  279. $c = file_get_contents('translations.md');
  280. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  281. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  282. $this->Translations[] = $entry;
  283. }
  284. }
  285. if(file_exists("custom_translations.md")){
  286. $this->CustomTranslationContent = file_get_contents('custom_translations.md');
  287. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$this->CustomTranslationContent, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  288. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  289. $this->Translations[] = $entry;
  290. }
  291. }
  292. $this->LoginTokens=[];
  293. if(file_exists('la_tokens.php')){
  294. $c = file_get_contents('la_tokens.php');
  295. if(preg_match_all('/-\s+(\S.*)\s*$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  296. $this->LoginTokens[] = $m[1];
  297. }
  298. }
  299. }
  300. function MastodonPostStatus($status){ return $this->MastodonCall('/api/v1/statuses', 'POST', $status); }
  301. function MastodonPostMedia($media){ return $this->MastodonCall('/api/v1/media', 'POST', $media); }
  302. function MastodonCall($endpoint, $method, $data){
  303. $headers = [
  304. 'Authorization: Bearer '.$this->MastodonToken,
  305. 'Content-Type: multipart/form-data',
  306. ];
  307. $ch = curl_init();
  308. curl_setopt($ch, CURLOPT_URL, $this->MastodonURL.$endpoint);
  309. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  310. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  311. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  312. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  313. $reply = curl_exec($ch);
  314. if (!$reply) {
  315. return json_encode(['ok'=>false, 'curl_error_code' => curl_errno($ch_status), 'curl_error' => curl_error(ch_status)]);
  316. }
  317. curl_close($ch);
  318. return json_decode($reply, true);
  319. }
  320. function MastodonSendPost(&$post, &$errmsg=NULL){
  321. if(isset($post['mark_value']) && $post['mark_value']==7){ return NULL; }
  322. $this->LanguageAppendix = 'zh';
  323. if(in_array($this->MastodonPreferredLang,['en','zh'])){ $this->LanguageAppendix = $this->MastodonPreferredLang; }
  324. $this->ConvertPost($post);
  325. $media_ids = NULL;
  326. $mastodon_post_url = NULL;
  327. $imcount = 0;
  328. if(isset($post['original_images']) && isset($post['original_images'][0])) foreach($post['original_images'] as $im){
  329. $curl_file = curl_file_create($im, mime_content_type($im), basename($im));
  330. $body = ['file' => $curl_file,]; $response = $this->MastodonPostMedia($body);
  331. if(isset($response['id'])){ if(!isset($media_ids)){$media_ids=[];} $media_ids[]=$response['id']; }
  332. else{ if(isset($response['error'])) $errmsg.=$response['error']."<br /><br />"; }
  333. $imcount++; if($imcount>=4){ break; }
  334. }
  335. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$post['html']));
  336. if(isset($this->HostURL) && $this->HostURL!=""){
  337. $text.=("\n\n".$this->T('来自').' '.$this->HostURL.'?post='.$post['id']);
  338. }
  339. $vis = (isset($post['mark_value']) && $post['mark_value']==6)?"private":"public";
  340. $status_data = [ 'status' => $text, 'visibility' => $vis, 'language' => $this->LanguageAppendix, ];
  341. if(isset($post['prev']) && ($pp=&$this->GetPost($post['prev']))!=$this->NULL_POST){
  342. if(isset($pp['mastodon_url'])){ $status_data['in_reply_to_id'] = basename($pp['mastodon_url']);
  343. }
  344. }
  345. if(isset($media_ids[0])){ $status_data['media_ids']=$media_ids; }
  346. $status_data = preg_replace('/(media_ids%5B)[0-9]+(%5D)/','$1$2', http_build_query($status_data));
  347. $status_response = $this->MastodonPostStatus($status_data);
  348. if(isset($status_response['url']) && $status_response['url']){
  349. $mastodon_post_url = $status_response['url'];
  350. $post['mastodon_url'] = $mastodon_post_url;
  351. $this->NeedWritePosts = 1;
  352. }
  353. if(isset($status_response['error'])) { $errmsg .= $status_response['error']; }
  354. return $mastodon_post_url;
  355. }
  356. function __construct() {
  357. $this->ReadConfig();
  358. $this->PDE = new ParsedownExtra();
  359. $this->PDE->SetInterlinkPath('/');
  360. $this->Posts = [];
  361. $this->Threads = [];
  362. $this->VisitedHere = [];
  363. $this->NULL_IMAGE_DUMMY = [];
  364. $this->NULL_IMAGE_DUMMY['name']=$this->NULL_IMAGE_DUMMY['file']=$this->NULL_IMAGE_DUMMY['thumb']="";
  365. $this->Markers=['●', '○', '✓', '×', '!', 'P', 'E', 'S'];
  366. $this->PostsPerPage = 40;
  367. $this->CommentsPerPage = 100;
  368. $this->HotPostCount = 15;
  369. $this->TIME_STRING = date('YmdHis');
  370. $this->WayBack = NULL;
  371. $this->YearBegin = $this->YearEnd = 2000;
  372. $this->DoneReadPosts = $this->DoneReadImages = $this->DoneReadArchive = false;
  373. $this->NeedWritePosts= $this->NeedWriteImages= $this->NeedWriteArchive= false;
  374. $this->UsePosts = &$this->Posts;
  375. }
  376. function DoLogout(){
  377. $this->LoggedIn = false;
  378. unset($_SESSION['user_id']);
  379. $this->RecordToken(true);
  380. }
  381. function RecordToken($unset_current=false){
  382. if(isset($unset_current) && isset($_COOKIE['la_token'])){
  383. $t = $_COOKIE['la_token'];
  384. setcookie('la_token', null, -1); unset($_COOKIE['la_token']);
  385. if (($key = array_search($t,$this->LoginTokens)) !== false) { unset($this->LoginTokens[$key]); }
  386. $this->WriteTokens();
  387. return null;
  388. }else{
  389. $t = uniqid('la_',true);
  390. setcookie('la_token',$t,time()+3600*24*7); $_COOKIE['la_token'] = $t;
  391. $this->LoginTokens[] = $t;
  392. $this->WriteTokens();
  393. return $t;
  394. }
  395. }
  396. function LoginThroughToken(){
  397. if(!isset($_COOKIE['la_token'])) return false;
  398. $t = $_COOKIE['la_token'];
  399. if (($key = array_search($t,$this->LoginTokens)) !== false) {
  400. $_SESSION['user_id']=$this->Admin;
  401. $this->LoggedIn = true;
  402. setcookie('la_token',$t,time()+3600*24*7);
  403. return true;
  404. }
  405. return false;
  406. }
  407. function DoLogin(){
  408. session_start();
  409. $redirect=false;
  410. if(isset($_GET['logout'])){ $this->DoLogout(); header('Location:index.php'); }
  411. else if(!isset($_SESSION['user_id'])){
  412. if(isset($_POST['login_button'])){
  413. $id = trim($_POST['login_id']);
  414. $pwd = trim($_POST['login_password']);
  415. if(strtolower($this->Admin)==strtolower($id)&&password_verify($pwd, $this->Password)){
  416. $_SESSION['user_id']=$id;
  417. $this->RecordToken(false);
  418. }
  419. $redirect = true;
  420. }else if($this->LoginThroughToken()){
  421. // nothing;
  422. }
  423. }else{
  424. if(strtolower($_SESSION['user_id']) == strtolower($this->Admin)){ $this->LoggedIn = true; }
  425. else{ $this->DoLogout();}
  426. }
  427. if($redirect){
  428. header('Location:index.php'.(isset($_GET['post'])?("?post=".$_GET['post']):"")
  429. .(isset($_GET['settings'])?"?settings=true":""));
  430. }
  431. }
  432. function SetHereMainImage($im_this){
  433. if(isset($im_this) && isset($im_this['parent'])){ $this->HereMainImage = &$this->FindImage($im_this['parent'],true);}
  434. }
  435. function RecordVisitedHere($image_or_post_name, $image_title){
  436. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  437. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  438. if(!(isset($_SESSION[$visited_here][0]) && in_array($image_or_post_name,$_SESSION[$visited_here]))){
  439. $_SESSION[$visited_here][] = $image_or_post_name;
  440. }
  441. if(isset($image_title)){ $this->HereDisplayTitle=$image_title; }
  442. $this->HereNumber = array_search($image_or_post_name,$_SESSION[$visited_here])+1;
  443. $_SESSION['here_number'] = $this->HereNumber;
  444. $this->VisitedHere = $_SESSION[$visited_here];
  445. }
  446. function HereLinkFromNumber($number){
  447. $number -= 1; if($number<0){ $number=0; }
  448. if($number>=sizeof($this->VisitedHere)){ $number = sizeof($this->VisitedHere)-1; }
  449. if(preg_match('/(jpg|jpeg|png|gif)/u',$this->VisitedHere[$number])){ return "?here=images/".$this->VisitedHere[$number]; }
  450. else{ return "?post=".$this->VisitedHere[$number]; }
  451. }
  452. function WriteStyles(){
  453. $this->style="
  454. html{font-size:18px;font-family:'Noto Serif CJK SC','Times New Roman','SimSun', Georgia, serif;}
  455. body{background-color:%white%;color:%black%;}
  456. sup,sub{line-height:0;}
  457. blockquote{border-left:2px solid %black%;padding-left:0.3em;}
  458. *{box-sizing:border-box;padding:0;margin:0;font-weight:normal;}
  459. b,strong,th{font-weight:bold;}
  460. select{font-size:inherit;}
  461. .page,.page_gallery{padding:1em;padding-top:0;padding-bottom:0;}
  462. .hidden_on_desktop,.hidden_on_wide{display:none;}
  463. .hidden_on_desktop_force{display:none !important;}
  464. ::file-selector-button{background:none;border:none;}
  465. a,button,::file-selector-button{text-decoration:underline;color:%black%;}
  466. a:hover,.button:hover,::file-selector-button:hover{text-decoration:none;color:%gray%;}
  467. .button:disabled{background-color:%gray%;pointer-events:none;}
  468. header{position:sticky;top:0;background-color:%white%;z-index:10;padding-top:0.5em;max-height:100vh;z-index:30;}
  469. 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;}
  470. header>div{overflow:auto;white-space:nowrap;}
  471. .header_nav{display:inline;}
  472. header a,.left a,.footer a,.clean_a,.clean_a a{text-decoration:none;}
  473. header a:hover,.button:hover{color:%gray% !important;}
  474. .exp_h_f{padding-top:0.3em !important;padding-bottom:0.3em !important;line-height:1.5em !important;height:2.1em !important;}
  475. .exp_f{text-align:center;}
  476. .toc_button{position:absolute;top:0.5em;right:0;text-shadow: 0px 0px 10px %white%;background-color:%white%88;}
  477. .footer{background-color:%white%;z-index:10;position:relative;}
  478. .invert_a,.invert_a a{color:%gray%;text-decoration:none;}
  479. .invert_a:hover,.invert_a a:hover{color:%black% !important;}
  480. .gray,.gray a{color:%gray%;}
  481. hr{border:1px solid %gray%;}
  482. header ul,.small_footer ul,.small_footer span,header li,.small_footer li{display:inline-block;}
  483. header li::before,.small_footer li::before{content:' - '}
  484. header h1,header h2,header h3,header h4,header h5,header p{display:inline;font-size:1rem;}
  485. .main{position:relative;word-spacing:-1em;}
  486. .main *{word-spacing:initial;}
  487. pre{overflow:auto;max-width:100%;display:block;font-size:0.75em;}
  488. ul{display:block;}
  489. li{display:block;}
  490. .clean_table{border:none;font-size:1em !important;}.clean_table thead{box-shadow:none;}.clean_table td{vertical-align:top;}
  491. table{width:100%;border-collapse:collapse;border-bottom:2px solid %black%;border-top:3px solid %black%;}
  492. table input{border:none!important;}
  493. table img{max-width:10rem !important;}
  494. td{padding-left:0.1em;padding-right:0.1em;}
  495. td:first-child{padding-left:0;}
  496. td:last-child{padding-right:0;}
  497. tbody tr:hover{box-shadow:inset 0 -2px 0 0px %black%;}
  498. thead{box-shadow:inset 0 -1px 0 0px %black%;position:sticky;top:2rem;background-color:%white%;z-index:5;}
  499. .post table{font-size:0.85em;}
  500. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 20em);}
  501. .interesting_tbody td{display:contents;}
  502. .interesting_tbody tr{position:relative;scroll-margin:4.5em}
  503. .interesting_tbody td>*{display:table-cell;}
  504. .interesting_tbody td>.wscroll{display:none !important;}
  505. .interesting_tbody .post_access{padding-top:0;}
  506. .interesting_tbody .post_menu_button{top:0;opacity:0;}
  507. .interesting_tbody td>img,.interesting_tbody td>.imd{position:absolute;left:1.4em;z-index:-1;height:1em;width:20em;
  508. display:flex;top:0.2em;object-fit:cover;max-width:calc(100% - 1.4em) !important;overflow:hidden;}
  509. .interesting_tbody td>.imd>a{display:flex;}
  510. .interesting_tbody img{object-fit:cover;width:100%;}
  511. .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);}
  512. .interesting_tbody .p_thumb{height:1em;}
  513. .interesting_tbody .p_thumb img,.interesting_tbody .p_thumb video{max-height:10rem !important;max-width:20rem !important;}
  514. tr:hover .post_menu_button{opacity:1;}
  515. .post_current_row{background-color:%graybkg%;mix-blend-mode:screen;text-shadow:0px 0px 0.1em %white%;}
  516. .align_right{text-align:right;}
  517. .left{display:inline-block;vertical-align:top;width:25%;max-height:calc(100vh - 2.6em);top:2em;
  518. position:sticky;overflow:auto;padding-right:0.2em;padding-bottom:4rem;}
  519. .center{display:inline-block;vertical-align:top;width:50%;padding-left:0.3em;overflow:visible;padding-bottom:4rem;}
  520. .center_wide{display:inline-block;vertical-align:top;width:75%;padding-left:0.3em;overflow:visible;padding-bottom:4rem;}
  521. .center_full{display:inline-block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;}
  522. .center_wide .p_thumb{height:10rem;}
  523. .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;}
  524. .center_exp{display:block;width:80%;margin:0 auto;overflow:visible;padding-bottom:1em;}
  525. .table_top{position:relative;left:calc(-50% - 0.45em);width:calc(200% + 0.6em);background:%white%;z-index:1;
  526. box-shadow:0px 0px 2em 1em %white%;margin-top:2em;margin-bottom:2em;}
  527. .right{display:inline-block;vertical-align:top;width:25%;position:sticky;top:2em;
  528. padding-left:0.5em;max-height:calc(100vh - 2.6em);overflow:auto;padding-bottom:4rem;}
  529. textarea,input[type=text],input[type=password]{width:100%;display:block;font-family:inherit;max-height:60vh;font-size:inherit;}
  530. select,textarea,input[type=text],input[type=password]{background:none;border:none;border-bottom:1px solid %black%;color:%black%;}
  531. .text_highlight input{border-bottom:1px solid %white%;color:%white%;}
  532. .button{background:none;border:none;font-family:inherit;color:%black%;font-size:inherit;font-weight:bold;}
  533. .post{position:relative;scroll-margin:3.5em;border-radius:0.3em;}
  534. .center_exp .post{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;border-radius:0;}
  535. .post_width li,.post_width_big li,.footer_additional li,.footer_additional li,.post_dummy li
  536. {display:list-item;margin-left:1em;list-style:disc;}
  537. .post_width li li,.post_width_big li li,.footer_additional li li,.footer_additional li li,.post_dummy li li
  538. {list-style:circle;}
  539. ol li{list-style:unset !important;}
  540. .post_width > *,.post_width_big > *,.post_dummy > *,.post_ref > *{margin:0;margin-bottom:0.5rem}
  541. .post_dummy > *{width:60%;margin:0 auto;margin-bottom:0.5rem}
  542. .post_dummy > p img{display:block;width:100%;margin:0 auto;}
  543. .gallery_left li{display:list-item;margin-left:1em;list-style:none;}
  544. .gallery_left .selected{list-style:'→';}
  545. .focused_post{font-size:1.1em;margin-top:0.1em;margin-bottom:0.1em;padding:0.5rem !important;border:2px dashed #ac7843;}
  546. .post_width{position:relative;left:1.4rem;width:calc(100% - 1.7rem);padding-left:0.2em;overflow:visible;}
  547. .post_width_big{position:relative;left:0;width:100%;overflow:visible;}
  548. .post_menu_button{position:absolute;display:none;right:0rem;width:1.5rem;
  549. text-align:center;border-radius:0.3em;user-select:none;cursor:pointer;z-index:10;}
  550. .pointer{cursor:pointer;}
  551. .post:hover .post_menu_button{display:block;}
  552. .pop_menu{position:absolute;top:0.3rem;z-index:95;background-color:%lighterbkg%;
  553. padding:0.3em;right:0.3rem;text-align:right;border-radius:0.3em;font-size:1rem;
  554. box-shadow:0px 0px 10px rgb(0, 0, 0);}
  555. .pop_menu li{list-style:none;margin-left:0;}
  556. .pop_menu hr{border:2px solid rgba(0,0,0,0.1);}
  557. .toc{left:60%;width:40%;top:0;position:absolute;}
  558. .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;}
  559. .post_access:hover{background-color:%lightopbkg%;border-top-left-radius:0.3em;border-bottom-left-radius:0.3em;
  560. border-right:2px solid %black% !important;}
  561. .paa{width:1.4rem;min-width:1.4rem;}
  562. .opt_compact .post_access,.ref_compact .post_access{border-right:2px solid %gray%;}
  563. .post_box{border:1px solid %gray%;border-radius:0.3em;padding:0.3em;}
  564. .post_box:hover,.post_menu_button:hover{background-color:%lightopbkg%}
  565. #big_image_info .post_box:hover{background-color:%graybkg%;}
  566. .post_preview{font-size:0.9rem;overflow:hidden;margin-bottom:0.2em;}
  567. .post .post_ref{margin:0;padding-left:1.7rem;}
  568. .post_ref_main{display:inline-block;vertical-align:top;}
  569. .post_preview .post_ref_main{max-height:6rem;overflow:hidden;}
  570. .post_ref_images{overflow:hidden;}
  571. .page_selector{padding-top:2rem;text-align:center;}
  572. .smaller{font-size:0.85em;}
  573. .bigger{font-size:1.3em;}
  574. .block{display:block;}
  575. .opt_compact{margin-left:1.6rem;}
  576. .opt_compact .post_width {margin-left:0.3em;width: calc(100% - 1.8rem);}
  577. .post_box_top{padding-bottom:0.3em;padding-top:0.3em;}
  578. .post_box_fixed_bottom{position:sticky;bottom:0em;background-color:%white%;z-index:5;}
  579. .spacer{height:0.5em;}
  580. .pop_right,.pop_right_big{position:fixed;top:0;right:0;bottom:0;width:30%;z-index:100;background-color:%graybkg%;display:none;
  581. transition-timing-function:ease-out;padding:1rem;overflow:auto;}
  582. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  583. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  584. @keyframes pop_slide_in_big{0%{right:-30%;}100%{right:0%;}}
  585. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-30%;}}
  586. .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;}
  587. @keyframes backdrop_fade_in{0%{opacity:0%;}100%{opacity:100%;}}
  588. @keyframes backdrop_fade_out{0%{opacity:100%;}100%{opacity:0%;}}
  589. .toc_entry_1{font-size:1.1em;}
  590. .toc_entry_2{font-size:1.0em;padding-left:0.5rem;}
  591. .toc_entry_3{font-size:0.9em;padding-left:1rem;}
  592. .toc_entry_4{font-size:0.85em;padding-left:1.5rem;}
  593. .toc_entry_5{font-size:0.8em;padding-left:2rem;}
  594. h1,h2,h3,h4,h5{scroll-margin:2.5em;}
  595. .left ul h1,.left ul h2,.left ul h3,.left ul h4,.left ul h5,.left ul p{font-size:1em;}
  596. .deleted_post{color:%gray%;text-decoration:line-through;}
  597. #file_list{margin-top:0.5em;}
  598. .file_thumb img,.file_thumb video{max-height:100%;max-width:100%;object-fit:cover;min-width:100%;min-height:100%;}
  599. .file_thumb video{border:2px dashed %black%;}
  600. #file_list li{margin-bottom:0.3em;}
  601. .ref_thumb{white-space:nowrap;overflow:hidden;}
  602. .ref_thumb .file_thumb{width:3em;height:3em;}
  603. .side_thumb li{margin:0.4em;display:inline-block;}
  604. .file_thumb{width:4em;height:4em;display:inline-block;line-height:0;vertical-align:middle;overflow:hidden;}
  605. .p_row{display:flex;flex-wrap:wrap;width:100%;}
  606. .p_thumb{display:flex;flex-grow:1;height:6rem;margin-right:0.25rem;margin-bottom:0.25rem;overflow:hidden;position:relative;}
  607. .p_thumb_narrow{width:1rem;}
  608. .p_thumb img,.p_thumb video{object-fit:cover;max-height:100%;min-width:100%;}.p_thumb a{display:contents;}
  609. .ref_count,.p_thumb .post_menu_button{text-shadow: 0px 0px 10px rgb(0, 0, 0);}
  610. .p_thumb:hover .post_menu_button{display:block;}
  611. .p_thumb_selected{color:%black% !important;}
  612. .p_thumb_selected{display:block;}
  613. .post .p_thumb img,.post .p_thumb video{max-height:6rem;}
  614. .p_thumb video{border:2px dashed %black%;}
  615. .big_image_box{position:fixed;top:0;bottom:0;left:0;width:75%;z-index:95;text-align:center;pointer-events:none;}
  616. .big_image_box *{pointer-events:auto;}
  617. .big_image_box img,.big_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  618. .here_image_box{position:relative;width:100%;text-align:center;height:calc(100vh - 4.5em);}
  619. .here_image_box img,.here_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  620. .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;
  621. background:linear-gradient(to right, rgba(0,0,0,0), rgb(1, 1, 1));transition:background-size .2s linear;background-size: 300% 100%;}
  622. .big_side_box:hover{background-size: 100% 100%;}
  623. .big_side_box a,.big_side_box hr,#dropping_background{color:%black%;}
  624. .big_side_box a:hover{color:%gray%;}
  625. .big_side_box *{pointer-events:auto;}
  626. .image_nav{pointer-events:none;}
  627. #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;
  628. box-shadow:0px 0px 500px black inset;display:flex;align-items:center;}
  629. img,video{cursor:pointer;max-height:100%;max-width:100%;vertical-align:middle;}
  630. .post img,.post video{max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  631. .post > a > img,.post > a > video{display:block;margin:0.3em auto;}
  632. .post .original_img{max-width:100%;display:inline-block;vertical-align:middle;
  633. margin-left:auto;margin-right:auto;max-width:100%;max-height:90vh;}
  634. .center_exp .post .original_img{display:block;}
  635. .original_img img,.original_img video{max-height:90vh;max-width:100%;}
  636. .p_row .original_img{margin-bottom:0;}
  637. .post_ref .original_img{margin:unset;max-width:unset;max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  638. .b ul{font-size:1.4em;}
  639. no_pop{cursor:unset;}
  640. p{min-height:0.8em;}
  641. .bold,.bold *{font-weight:bold;}
  642. .footer_additional{display:inline-block;width:50%;vertical-align:text-top;white-space:normal;}
  643. .small_footer{background-color:%white%;padding-bottom:0.5em;position:sticky;bottom:0px;z-index:10;}
  644. .small_footer>div{overflow:auto;white-space:nowrap;}
  645. .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;}
  646. .top_post_hint{margin-left:1.5em;font-weight:bold;}
  647. .white{color:%white%;}
  648. .full_box{border:1px solid %black% !important;padding:0.3rem;overflow:auto;}
  649. .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;
  650. transition:background-size .2s ease;padding:0.5em;text-shadow:0px 0px 5px black;user-select:none;pointer-events:auto;}
  651. .image_nav_prev{left:0;justify-content:left;background:linear-gradient(to left, rgba(0,0,0,0), rgba(0,0,0,0.4));
  652. background-repeat:no-repeat;background-size:0% 100%;}
  653. .image_nav_prev:hover,.image_nav_next:hover{background-size:100% 100%;}
  654. .image_nav_next{right:0;justify-content:right;background:linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.2));
  655. background-repeat:no-repeat;background-size:0% 100%;transition:background-size .2s ease;background-position-x:100%;}
  656. .inquiry_buttons{position:fixed;left:0;right:25%;text-align:center;bottom:1em;margin:0 auto;width:max-content;
  657. background-color:rgba(0,0,0,0.5);z-index:110;padding:0.2em;padding-left:1em;padding-right:1em;
  658. border-radius:1em;box-shadow:0px 0px 5px;text-shadow:0px 0px 5px black;opacity:1;user-select:none;}
  659. .lr_buttons{background-color:rgba(0,0,0,0.5);padding:0.5em;padding-top:1em;padding-bottom:1em;
  660. border-radius:1em;box-shadow:0px 0px 5px;font-size:1.2rem;text-shadow:0px 0px 5px black;}
  661. .img_btn_hidden{opacity:0;transition:opacity 0.2s;}
  662. .special_alipay{background-color:#027aff;color:white;white-space:nowrap;
  663. font-family:sans-serif;font-weight:bold;border-radius:0.7em;font-size:0.75em;padding:0.25em;}
  664. .special_paypal{background-color:white;color:#253b80;white-space:nowrap;
  665. font-family:sans-serif;font-weight:bold;border-radius:2em;font-size:0.75em;
  666. padding:0.25em;padding-left:0.5em;padding-right:0.65em;font-style: italic;}
  667. .special_paypal_inner{color:#169bd7;}
  668. #waiting_bar{position:fixed;z-index:200;top:0;left:0;right:0;height:0.2em;background-color:%black%;transform:translate(-100%,0);
  669. animation:anim_loading 1s linear infinite;}
  670. @keyframes anim_loading{0%{transform:translate(-100%,0);} 100%{transform:translate(100%,0);}}
  671. .product_ref{width:32%;padding:0.2em!important;display:inline-block;text-align:center;vertical-align:top;margin-bottom:0.8em;}
  672. .product_thumb{max-height:11em;max-width:11em;display:inline-flex;margin-bottom:0.2em;background-color:%graybkg%;}
  673. .product_thumb img,{box-shadow:none;object-fit:contain;max-height:unset;max-width:unset;width:100%;margin:0 auto !important;}
  674. .product_ref p{margin-bottom:0.2em;text-align:left;}
  675. .post_preview .product_thumb{max-height:4em;max-width:6em;}
  676. .purchase_button{background-color:%black%;color:%white%;padding-left:0.5em;padding-right:0.5em;text-decoration:none;font-weight:bold;}
  677. .page_break{page-break-after:always;}
  678. .text_highlight,.text_highlight a,.text_highlight select{background-color:%black%;color:%white%;border:none;}
  679. .gray.text_highlight,.gray.text_highlight a,.gray.text_highlight select{background-color:%gray%;color:%white%;}
  680. .print_title{display:none;}
  681. .show_on_print{display:none;}
  682. .comment{font-size:0.9em;font-family:sans-serif;overflow:auto !important;width:100%;}
  683. .comment tbody tr:hover{box-shadow:none;}
  684. .comment table{border:none;}
  685. .comment li{display:list-item;list-style:'→';padding-left:0.3em;}
  686. .comment ul{padding-left:1em;}
  687. .comment ul li *{margin-bottom:0.5em;}
  688. .history li{display:list-item;list-style:disc;padding-left:0.3em;}
  689. .history li li{list-style:circle;}
  690. .history ul{padding-left:1em;}
  691. .history a{text-decoration:underline;}
  692. .history .list{overflow:auto;white-space:nowrap;}
  693. .diff_table{table-layout:fixed;}
  694. .diff_table thead{font-size:0.9em;text-align:center;}
  695. .diff_table tbody pre{font-size:0.9rem;white-space:pre-line;}
  696. .diff_table td{vertical-align:top;}
  697. .omittable_title{display:block;width:100%;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
  698. .wayback_close{float:right;}
  699. .wayback_expand{display:inline;}
  700. .post_selecting .post *{pointer-events:none;}
  701. .post_selected{background-color:%graybkg%;}
  702. .small_pad{padding:0.2em;padding-top:0.1em;padding-bottom:0.1em;}
  703. .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%;}
  704. .wscroll:target{display:block;} .post_ref .wscroll{display:none !important;}
  705. .wayback_link{display:inline;}
  706. .imd{object-fit:cover;width:100%;}
  707. .center_exp .imd{width:60%;}
  708. #here_buttons{display:contents;}
  709. .here_buttons_inner{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;max-height:100%;max-width:100%;}
  710. .here_btn{position:absolute;z-index:110;transform:translate(-50%,-50%);
  711. width:2em;height:2em;display:block;border:1px solid %black%;background-color:rgba(0,0,0,0.5);}
  712. .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;}
  713. @media screen and (max-width:1000px) and (min-width:666px){
  714. .left{width:35%;}
  715. .center,.center_wide{width:65%;}
  716. .center_wide .p_thumb{height:8rem;}
  717. .right{display:none;}
  718. .post_width{width:calc(100% - 1.5rem);padding-left:0.2em;}
  719. .post_width_big{left:0;width:100%;}
  720. .hidden_on_wide{display:unset;}
  721. .pop_right{width:30%;}
  722. .pop_right_big{width:40%;}
  723. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  724. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  725. @keyframes pop_slide_in_big{0%{right:-40%;}100%{right:0%;}}
  726. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-40%;}}
  727. .big_side_box{width:35%;}
  728. .big_image_box{width:65%;}
  729. .inquiry_buttons{right:35%;}
  730. .table_top{left:calc(-50% - 1.7em);width:calc(154% + 0.5em);}
  731. .post_dummy > *{width:80%;max-width:55rem;}
  732. .center_exp .imd{width:80%;}
  733. .here_btn{width:1.5em;height:1.5em;}
  734. }
  735. @media screen and (max-width:666px){
  736. html{font-size:16px;}
  737. .hidden_on_mobile{display:none !important;}
  738. .block_on_mobile{display:block !important;}
  739. .hidden_on_desktop{display:unset;}
  740. .hidden_on_wide{display:unset;}
  741. header ul{display:block;}
  742. header li{display:block;}
  743. header li::before{content:''}
  744. header::before{box-shadow:none;display:none;}
  745. .small_footer::before{box-shadow:none;display:none;}
  746. .left{position:relative;width:100%;position:relative;top:unset;height:unset;min-height:80vh;padding-right:0;display:block;}
  747. .center,.center_wide,.center_full{position:relative;left:0;top:0;width:100%;padding-left:0;display:block;}
  748. .center_wide .p_thumb{height:6rem;}
  749. .pop_right,.pop_right_big{top:unset;right:0;bottom:0;left:0;width:100%;}
  750. .pop_right{height:30%;}
  751. .pop_right_big{height:70%;}
  752. @keyframes pop_slide_in{0%{bottom:-30%;}100%{bottom:0%;}}
  753. @keyframes pop_slide_out{0%{bottom:0%;}100%{bottom:-30%;}}
  754. @keyframes pop_slide_in_big{0%{bottom:-70%;}100%{bottom:0%;}}
  755. @keyframes pop_slide_out_big{0%{bottom:0%;}100%{bottom:-70%;}}
  756. .big_image_box{position:fixed;top:0;bottom:8.5rem;left:0;right:0;width:100%;}
  757. .side_box_mobile_inner{background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(1,1,1,0.9) 20%);
  758. transition:none;background-size:100% 100%;padding:0.5rem;padding-bottom: 5em;}
  759. .side_box_mobile_inner:hover{background-size:100% 100%;}
  760. .big_side_box{position:fixed;top:0;bottom:0;right:0;left:0;width:100%;
  761. height:unset;padding:0;padding-top:calc(100vh - 8.5rem);background:none;}
  762. .p_thumb{height:3rem;}
  763. .center .post{padding-right:0rem;padding-left:0rem;}
  764. .post .p_thumb img,.post .p_thumb video{max-height:3rem;}
  765. .page,.page_gallery{padding:0.2em;padding-top:0;}
  766. header{padding-top:0.3em;}
  767. .toc_button{top:0.3em;}
  768. .small_footer{padding-bottom:0.3em;}
  769. .footer_additional{display:block;width:100%;}
  770. .album_hint{display:block;font-size:1rem;}
  771. .image_nav{position:absolute !important;}
  772. .image_nav_prev,.image_nav_next{width:25%;}
  773. .image_nav_prev:hover,.image_nav_next:hover{background-size:0% 100%;color:%black% !important;}
  774. .inquiry_buttons{position:relative;left:unset;right:unset;text-align:left;bottom:unset;margin:unset;width:unset;
  775. background-color:unset;z-index:unset;padding:unset;padding-left:unset;padding-right:unset;
  776. border-radius:unset;box-shadow:unset;text-shadow:unset;}.img_btn_hidden{opacity:1;}
  777. .lr_buttons{background-color:unset;padding:unset;padding-top:unset;padding-bottom:unset;
  778. border-radius:unset;box-shadow:unset;font-size:1.3rem;text-shadow:unset;}
  779. .opt_compact,.ref_compact{line-break:anywhere;}
  780. .post_width,.post_width_big{overflow:auto;}
  781. .table_top{left:unset;width:100%;overflow:auto;}
  782. table img{max-width:30vw !important;}
  783. .product_ref{width:100%;display:block;}
  784. .post_dummy > *{width:100%;max-width:25rem;}
  785. .sticky_title{top:1.2em;}
  786. .small_footer{position:relative;}
  787. #upload_selector{width:100%;}
  788. .focused_post{padding:0.3rem !important;}
  789. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 10em);}
  790. .wayback_expand{display:block;text-align:center;}
  791. .wayback_link{display:block;}
  792. .center_exp{display:block;width:100%;margin:0 auto;padding-bottom:1em;}
  793. .center_exp .post{overflow:auto;}
  794. .center_exp .imd{width:100%;}
  795. .here_btn{width:1.2em;height:1.2em;}
  796. .exp_h_f{height:unset !important;}
  797. .exp_f{margin-bottom:1em;}
  798. }
  799. @media print{
  800. header b,.small_footer b{font-weight:normal;}
  801. header{display:table-header-group;} .main{display:table-row-group;} .small_footer{text-align:right;}
  802. header::before{box-shadow:none;display:none;} header::after{display:block;height:1em;content:' ';}
  803. .small_footer::before{box-shadow:none;display:block;height:1em;position:relative;}
  804. body,footer,header,.small_footer,a,.clean_a,.invert_a,.clean_a a,.invert_a a{background:none;color:black;}
  805. .post *,.post_dummy *{margin-bottom:0em}
  806. .p_row,.post table,.post_width>img,.post_width_big>img,.post_ref>img,.post_ref>.original_img,
  807. .post_width>.original_img,.post_width_big>.original_img,.post pre{margin-top:0.5rem;margin-bottom:0.5rem;text-indent:0;}
  808. pre{white-space:pre-wrap;line-break:anywhere;}
  809. .post p{line-height:1.3;text-indent:2em;} .product_ref p {text-indent:0;}
  810. table img{margin:0 !important;}
  811. .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;}
  812. .post ul,.post ol{margin:1rem;margin-left:1.4rem;margin-right: 0rem;}
  813. table{border-bottom:2px solid black;border-top:2px solid black;}
  814. table img{max-width:5em;max-width:8em !important;max-height:8em !important;}
  815. thead{box-shadow:inset 0 -1px 0 0px black;background:none;}
  816. .post_width,.post_width_big{overflow:clip;left:0;width:100%;padding-left:0em;}
  817. .post h1{margin-top:0.5rem;}
  818. .post h2{font-size:1.8em;margin:2.5em auto 0;}.list h2,.opt_compact h2,.ref_compact h2{margin:0 !important;}
  819. .post h3{font-size:1.5em;margin:1.5em auto 0;}.list h3,.opt_compact h3,.ref_compact h4{margin:0 !important;}
  820. .post h4{font-size:1.1em;margin:0.5em auto 0;}.list h4,.opt_compact h3,.ref_compact h4{margin:0 !important;}
  821. .post .post{margin-bottom:0.5rem;margin-top:0.5rem;}
  822. .gray,.gray a,.deleted_post{color:rgba(0,0,0,0.5);}
  823. .left,.right{display:none;}
  824. .center, .center_wide, .center_full{width:100%;padding:0;display:block;font-size:16px;line-height:1.3}
  825. hr{border:1px solid black;}
  826. .post_box_top{display:none;}
  827. .opt_compact .post_access,.ref_compact .post_access{border-right:none;display:inline;}
  828. .text_highlight,.text_highlight a,.gray.text_highlight,.gray.text_highlight a,.purchase_button{background-color:lightgray;color:black;}
  829. .focused_post{border:none;font-size:1em;padding:0 !important;}
  830. .hidden_on_print{display:none;}
  831. .print_column{column-count:2;margin-top:0.5rem;margin-bottom:0.5rem;}
  832. .post_access{display:none;}
  833. .opt_compact{margin-left:0;}
  834. .post .post_ref{padding-left:1.4rem;}
  835. .opt_compact .post_width{left:1.4rem;width:calc(100% - 1.4rem);margin-left:0;}
  836. .print_title{column-span:all;display:block;margin-top:2em;margin-bottom:0.5rem;font-size:1.2em;}
  837. .print_title:first-of-type{margin-top:1em;}
  838. .print_title+.post h1:first-of-type{display:none;}
  839. .opt_compact h1:first-of-type,.ref_compact h1:first-of-type{display:unset;}
  840. .table_top{position:relative;left:0;width:100%;background:none;z-index:1;box-shadow:none;}
  841. .header_nav{display:none;}
  842. .show_on_print{display:block;}
  843. blockquote{border-left:2px solid black;}
  844. .footer_additional{display:none;}
  845. .small_footer{margin-top:1rem;}
  846. .page{display:table;width:100%;}
  847. .page_selector{display:none;}
  848. .p_thumb{height:4rem;margin-bottom:0.25rem;}
  849. .post .p_thumb img,.post .p_thumb video{max-height:4rem;}
  850. .sticky_title{box-shadow:none;}
  851. .center_wide .p_thumb{display:inline-flex;height:5.8rem;width:5.8rem;margin-right:0;}
  852. .center_wide .p_row{display:block;}
  853. .interesting_tbody{background:none;}
  854. .interesting_tbody img{display:none !important;}
  855. .imd{margin-top:0.5em;margin-bottom:0.5em;line-height:0px;}
  856. .p_row .imd{margin-top:0em;margin-bottom:0em;}
  857. }
  858. ";
  859. $this->style=preg_replace('/%white%/','#231a0d',$this->style);
  860. $this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
  861. $this->style=preg_replace('/%gray%/','#ac7843',$this->style);
  862. $this->style=preg_replace('/%graybkg%/','#39270e',$this->style);
  863. $this->style=preg_replace('/%lightopbkg%/','#daae8010',$this->style);
  864. $this->style=preg_replace('/%lighterbkg%/','#675340',$this->style);
  865. $this->style=preg_replace('/%focusedbkg%/','#482f0c',$this->style);
  866. $f = fopen('styles/main.css','w');
  867. fwrite($f,$this->style);
  868. fclose($f);
  869. }
  870. function GiveSafeEMail(){
  871. return preg_replace('/\./u','[dot]',preg_replace('/\@/u','[at]',$this->EMail));
  872. }
  873. function &FindImage($name, $loose=false){ if(!isset($name) || !$name){ return $this->NULL_IMAGE; }
  874. if(isset($this->Images[0])) foreach($this->Images as &$im){
  875. if($loose) { if(preg_match('/'.preg_quote($name).'/u',$im['name'])) return $im; }
  876. else { if($im['name']==$name) return $im; }
  877. }
  878. return $this->NULL_IMAGE;
  879. }
  880. function &GiveImageInHere($rand=false){
  881. $this->ReadImages(); $this->DetectPageType();
  882. $album = $this->PageType=='here'?$this->HereAlbum:$this->ExpAlbum;
  883. if(!isset($album) || !$album){
  884. if(isset($this->Images[0])) return $this->Images[0]; else return $this->NULL_IMAGE; }
  885. $imlist=[]; $imlist_fallback=[];
  886. if(isset($this->Images[0])){
  887. foreach($this->Images as &$im){
  888. if(isset($im['galleries'][0]) && in_array($album,$im['galleries']) && $this->CanShowImage($im)){
  889. if(!$rand) return $im; else {
  890. $imlist_fallback[] = $im;
  891. if(!in_array($im['name'],$this->VisitedHere)) $imlist[] = $im;
  892. }
  893. }
  894. }
  895. }
  896. if(!$rand || !isset($imlist_fallback[0])) return $this->NULL_IMAGE;
  897. if(sizeof($imlist)){
  898. $r = random_int(0, sizeof($imlist)-1);
  899. return $imlist[$r];
  900. }else{
  901. $r = random_int(0, sizeof($imlist_fallback)-1);
  902. return $imlist_fallback[$r];
  903. }
  904. }
  905. function ImageTitle($im){
  906. $imtitle = (isset($im)&&isset($im['title']))?$im['title']:NULL;
  907. if(isset($im['parent'])&&($imp = &$this->FindImage($im['parent'],true))&&isset($imp['title'])){ $imtitle=$imp['title']; }
  908. return $imtitle;
  909. }
  910. function ImageHasHere(&$im, $here_name){
  911. if(!isset($im['here'])||!isset($im['here'][0])) return false;
  912. foreach($im['here'] as $h) { if($h[0] == $here_name) return true; } return false;
  913. }
  914. function ReadImages($clear_non_exist = false){
  915. $path = 'images/list.md';
  916. if($this->DoneReadImages){ return; }
  917. if(!file_exists($path)){ $f = fopen($path,'w'); fflush($f); fclose($f); }
  918. $c = file_get_contents($path);
  919. if(preg_match_all('/GALLERY\s+(\S+)(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  920. $g=[]; $g['name']=$m[1];//$g['count']=0;
  921. if(preg_match('/FEATURED([^;]*?);/u', $m[2], $arg)){ $g['featured']=true; }
  922. if(preg_match('/EXPERIMENTAL([^;]*?);/u', $m[2], $arg)){ $g['experimental']=true; }
  923. $this->Galleries[] = $g;
  924. }
  925. if(preg_match_all('/^-\s*([^;]+)\s*?;\s*?(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  926. $name = trim($m[1]);
  927. $item = []; $item['file'] = 'images/'.$name; $item['name'] = $name;
  928. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  929. if(preg_match('/REFS\s+([^;]*);/u',$m[2],$refs) && preg_match_all('/[0-9]{14}/u',$refs[1],$rs, PREG_SET_ORDER)){
  930. $item['refs']=[];
  931. foreach($rs as $r){ if(!in_array($r[0], $item['refs'])) $item['refs'][] = $r[0]; }
  932. }
  933. if(preg_match('/GAL\s+([^;]*);/u',$m[2],$gals) && preg_match_all('/(\S+)/u',$gals[1],$ga, PREG_SET_ORDER)){
  934. $item['galleries']=[];
  935. foreach($ga as $g){ if(!in_array($g[0], $item['galleries'])) $item['galleries'][] = $g[0]; }
  936. }
  937. if(preg_match('/PRODUCT\s+([^;]*);/u',$m[2],$product)){ $item['product']=$product[1]; }
  938. if(preg_match('/PARENT\s+([^;]*);/u',$m[2],$parent)){ $item['parent']=$parent[1]; }
  939. if(preg_match('/TITLE\s+([^;]*);/u',$m[2],$title)){ $item['title']=$title[1]; }
  940. if(preg_match('/HERE\s+([^;]*);/u',$m[2],$heres) && preg_match_all('/(\S+)-(\S+)-(\S+)/u',$heres[1],$here, PREG_SET_ORDER)){
  941. $item['here']=[];
  942. foreach($here as $h){ if(!$this->ImageHasHere($item, $h[1])) $item['here'][] = [$h[1],$h[2],$h[3]]; }
  943. }
  944. if(preg_match('/\.mp4/u',$item['name'])){
  945. $item['video']='video/mp4';
  946. }
  947. $this->Images[] = $item;
  948. }
  949. $files = array_merge([],glob('images/*.jpg'));
  950. $files = array_merge($files,glob('images/*.jpeg'));
  951. $files = array_merge($files,glob('images/*.png'));
  952. $files = array_merge($files,glob('images/*.gif'));
  953. $files = array_merge($files,glob('images/*.mp4'));
  954. if(isset($files[0]))foreach($files as $file) {
  955. if(preg_match('/[0-9]{14,}\.(jpg|jpeg|gif|png|mp4)/u', $file, $m)) {
  956. $name = trim($m[0]);
  957. if(!$this->FindImage($name)){
  958. $item = []; $item['name']=$name; $item['file'] = 'images/'.$name;
  959. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  960. $this->Images[] = $item;
  961. }
  962. }
  963. }
  964. if($clear_non_exist){
  965. if(isset($this->Images[0]) && isset($files[0])){
  966. foreach($this->Images as &$im){
  967. if(!in_array($im['file'],$files)){
  968. $im['deleted'] = 1;
  969. }
  970. }
  971. }
  972. }
  973. function cmpf($a, $b){
  974. if ($a['name'] == $b['name']) return 0;
  975. return (($a['name'] > $b['name']) ? 1 : -1);
  976. }
  977. function cmpaf($a, $b){
  978. if ($a['name'] == $b['name']) return 0;
  979. return ($a['name'] > $b['name']) ? -1 : 1;
  980. }
  981. if(isset($this->Galleries[0]))usort($this->Galleries,"cmpf");
  982. if(isset($this->Images[0]))usort($this->Images,"cmpaf");
  983. $this->DoneReadImages = 1;
  984. }
  985. function WriteImages(){
  986. if(isset($this->WayBack)) return;
  987. $path = 'images/list.md';
  988. $f = fopen($path,'w');
  989. if(isset($this->Galleries[0]))foreach($this->Galleries as &$g){
  990. if(isset($g['deleted'])) continue;
  991. fwrite($f,'GALLERY '.$g['name']);
  992. if(isset($g['featured']) && $g['featured']!=false) { fwrite($f,' FEATURED;'); }
  993. if(isset($g['experimental']) && $g['experimental']!=false) { fwrite($f,' EXPERIMENTAL;'); }
  994. fwrite($f, PHP_EOL);
  995. }
  996. if(isset($this->Images[0]))foreach($this->Images as &$im){
  997. if(isset($im['deleted'])) continue;
  998. fwrite($f, "- ".$im['name'].'; ');
  999. if(isset($im['refs']) && isset($im['refs'][0])){ fwrite($f, 'REFS '.implode(" ",$im['refs'])."; "); }
  1000. if(isset($im['galleries']) && isset($im['galleries'][0])){ fwrite($f, 'GAL '.implode(" ",$im['galleries'])."; "); }
  1001. if(isset($im['product']) && $im['product']!=''){ fwrite($f, 'PRODUCT '.$im['product']."; "); }
  1002. if(isset($im['parent']) && $im['parent']!=''){ fwrite($f, 'PARENT '.$im['parent']."; "); }
  1003. if(isset($im['title']) && $im['title']!=''){ fwrite($f, 'TITLE '.$im['title']."; "); }
  1004. if(isset($im['here']) && $im['here']!=''){ fwrite($f, 'HERE ');
  1005. foreach($im['here'] as $here){ fwrite($f, implode('-',$here).' '); } fwrite($f, '; ');
  1006. }
  1007. fwrite($f, PHP_EOL);
  1008. }
  1009. fflush($f);
  1010. fclose($f);
  1011. }
  1012. function EditImage($name, $link_gallery, $do_remove = false, $product_link=NULL, $rename=NULL, $parent=NULL){
  1013. if(!($im = &$this->FindImage($name))) return;
  1014. if(isset($link_gallery)){
  1015. if($do_remove){
  1016. if(!isset($im['galleries']) || !isset($im['galleries'][0])) return;
  1017. foreach($im['galleries'] as $key => $g){ if ($g==$link_gallery) unset($im['galleries'][$key]); }
  1018. $im['galleries'] = array_merge($im['galleries']);
  1019. }else{
  1020. if(!isset($im['galleries'])) $im['galleries']=[];
  1021. foreach($im['galleries'] as &$g){ if ($g==$link_gallery) return; }
  1022. $im['galleries'][]=$link_gallery;
  1023. }
  1024. }
  1025. if(isset($product_link)){
  1026. if($product_link!=''){$im['product']=$product_link;}
  1027. else{unset($im['product']);}
  1028. }
  1029. if(isset($rename) && $rename!=$im['name']){
  1030. $ext=pathinfo($im['file'],PATHINFO_EXTENSION);
  1031. rename($im['file'], 'images/'.$rename.'.'.$ext);
  1032. if(isset($im['thumb'])) rename($im['thumb'], 'images/thumb/'.$rename.'.'.$ext);
  1033. $im['name'] = $rename.'.'.$ext;
  1034. }
  1035. if(isset($parent) && $parent!=$im['parent']){
  1036. if($parent==''){ unset($im['parent']); }
  1037. else{ $im['parent'] = $parent; }
  1038. }
  1039. $this->NeedWriteImages = 1;
  1040. }
  1041. function RegenerateThumbnails(){
  1042. $glob = glob('images/*.jpg');
  1043. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1044. foreach($glob as $file) {
  1045. $thumb_destination = 'images/thumb/'.basename($file);
  1046. $img = new Imagick($file); $geo=$img->getImageGeometry();
  1047. $width=$geo['width']; $height=$geo['height'];
  1048. $lim=400;
  1049. $scale = $lim / min($width,$height);
  1050. if($scale<1){
  1051. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1052. }
  1053. $img->setImageFormat('jpeg');
  1054. $img->setImageCompressionQuality(90);
  1055. $img->writeImage($thumb_destination);
  1056. }
  1057. }
  1058. function CompressImage($source, $destination, $thumb_destination, $quality, $sizelim, $abs_max) {
  1059. $img = new Imagick($source); $geo=$img->getImageGeometry(); $img2 = clone $img;
  1060. $width=$geo['width']; $height=$geo['height'];
  1061. $lim=400;
  1062. $scale = $lim / min($width,$height);
  1063. if($scale<1){
  1064. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1065. }
  1066. $img->setImageFormat('jpeg');
  1067. $img->setImageCompressionQuality($quality);
  1068. $img->writeImage($thumb_destination);
  1069. $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
  1070. if($scale<1){
  1071. $img2->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.5);
  1072. }
  1073. $img2->setImageFormat('jpeg');
  1074. $img2->setImageCompressionQuality($quality);
  1075. $img2->writeImage($destination);
  1076. }
  1077. function DoUpload(){
  1078. if(!isset($_FILES['upload_file_name'])) return 0;
  1079. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1080. if($_FILES['upload_file_name']['error']>0){
  1081. echo"file upload err code ".$_FILES['upload_file_name']['error']; exit;
  1082. return -1;
  1083. }else{
  1084. $ext=pathinfo($_FILES['upload_file_name']['name'],PATHINFO_EXTENSION);
  1085. if(!in_array($ext,['jpg','jpeg','png','gif','mp4'])) return 0;
  1086. $fp = fopen('.la_lock',"w");
  1087. while (!flock($fp, LOCK_EX| LOCK_NB)){
  1088. usleep(10000);
  1089. }
  1090. $num=date('YmdHis'); $replace=0;
  1091. if(isset($_POST['image_replace_button']) && isset($_GET['pic']) && preg_match('/([0-9]{14,})/u',$_GET['pic'],$mim)){
  1092. $num = $mim[1]; $replace=1;
  1093. }
  1094. $base = 'images/'.$num;
  1095. $thumb = 'images/thumb/'.$num;
  1096. if($ext=='png') $ext='jpg';
  1097. $final_path = $base.'.'.$ext; $final_thumb = $thumb.'.'.$ext; $i=0;
  1098. if(!$replace) while(file_exists($final_path)){
  1099. $final_path = $base.strval($i).'.'.$ext; $final_thumb = $thumb.strval($i).'.'.$ext; $i++;
  1100. }
  1101. if($ext!='gif' && $ext!='mp4'){
  1102. $compress = (isset($_GET['compress'])&&$_GET['compress']);
  1103. $this->CompressImage($_FILES['upload_file_name']['tmp_name'], $final_path, $final_thumb, 90,
  1104. $compress?800:1920, $compress?1920:2560);
  1105. }else{
  1106. move_uploaded_file($_FILES['upload_file_name']['tmp_name'], $final_path);
  1107. }
  1108. flock($fp, LOCK_UN);
  1109. fclose($fp);
  1110. $this->ReadImages(true);
  1111. $this->WriteImages();
  1112. echo '<uploaded>'.pathinfo($final_path,PATHINFO_BASENAME)."</uploaded>";
  1113. if(isset($_POST['image_replace_button'])){
  1114. header('Location: '.$_SERVER['REQUEST_URI']);exit;
  1115. }
  1116. exit;
  1117. return 1;
  1118. }
  1119. return 0;
  1120. }
  1121. function &GetGallery($name){
  1122. if(isset($this->Galleries[0])) foreach($this->Galleries as &$g){
  1123. if($g['name'] == $name) return $g;
  1124. }
  1125. return $this->NULL_GALLERY;
  1126. }
  1127. function EditGallery($name, $new_name=null, $delete=false, $do_rw=true, $set_featured=null, $set_experimental=null){
  1128. $this->ReadImages();
  1129. $gallery = &$this->GetGallery($name);
  1130. if(!isset($gallery)){
  1131. if(!isset($new_name) || preg_match('/main|trash|\s/u',$new_name))return;
  1132. $g = []; $g['name']=$new_name;
  1133. $this->Galleries[]=$g;
  1134. }else{
  1135. if(isset($new_name)) {
  1136. if(preg_match('/main|trash|\s/u',$new_name))return;
  1137. $gallery['name'] = $new_name;
  1138. foreach ($this->Images as &$im){
  1139. if(isset($im['galleries'])&&isset($im['galleries'][0]))foreach($im['galleries'] as &$g){
  1140. if($g == $name){ $g = $new_name; }
  1141. }
  1142. }
  1143. }
  1144. //if(isset($count)) $gallery['count'] = $count;
  1145. if(isset($delete) && $delete) $gallery['deleted'] = true;
  1146. if(isset($set_featured)) $gallery['featured'] = $set_featured;
  1147. if(isset($set_experimental)) $gallery['experimental'] = $set_experimental;
  1148. }
  1149. if($do_rw) { $this->NeedWriteImages = 1; }
  1150. }
  1151. function ClearData(){
  1152. $this->Posts = [];
  1153. $this->Threads = [];
  1154. $this->Images = [];
  1155. $this->Archive = [];
  1156. $this->ArchiveHandles = [];
  1157. }
  1158. function InsertArchivePost(&$post){
  1159. $a = NULL;
  1160. if(($a = &$this->GetArchiveHandle($post['id']))==$this->NULL_POST){
  1161. $ah = []; $ah['id'] = $post['id']; $ah['list'] = [];
  1162. $this->ArchiveHandles[] = &$ah; $a = &$ah;
  1163. }
  1164. $a['list'][] = $post;
  1165. $this->Archive[] = $post;
  1166. }
  1167. function ReadArchiveFromFile($path){
  1168. if(!file_exists($path)){
  1169. return;
  1170. }
  1171. $c = file_get_contents($path);
  1172. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1173. foreach($matches as $m){
  1174. $post = [];
  1175. $post['id'] = $m[1];
  1176. $post['content'] = trim($m[3]);
  1177. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1178. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1179. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1180. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1181. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1182. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1183. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1184. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1185. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1186. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1187. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1188. if(preg_match('/HASTAG\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['hastag'] = $entries; } }
  1191. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1192. $post['merged_into'] = [trim($n[1]),trim($n[2])];
  1193. }
  1194. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1195. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1196. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1197. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1198. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1199. }
  1200. $this->InsertArchivePost($post);
  1201. }
  1202. }
  1203. }
  1204. function SortArchive(){
  1205. $cmpac = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1206. $cmpap = function($a, $b){ if ($a['id'] == $b['id']) return ((($a['version'] > $b['version']) ? 1 : -1));
  1207. return (($a['id'] > $b['id']) ? 1 : -1);
  1208. };
  1209. if(isset($this->Archive[0])){
  1210. usort($this->Archive,$cmpap);
  1211. $year_begin = substr($this->Archive[0]['id'],0,4);
  1212. $this->YearBegin = ($year_begin<$this->YearBegin)?$year_begin:$this->YearBegin;
  1213. }
  1214. if(isset($this->ArchiveHandles[0])){
  1215. usort($this->ArchiveHandles,$cmpac);
  1216. foreach($this->ArchiveHandles as &$a){
  1217. if(isset($a['list'])){ usort($a['list'],$cmpap);
  1218. $last_valid=NULL;
  1219. foreach($a['list'] as &$ver){ $ver['archive']= &$a;
  1220. if(isset($ver['merged_thread'])){ $ver['content']=$last_valid; }
  1221. else{ $last_valid = $ver['content']; } }
  1222. if(isset($a['list'][0]['version'])&&$a['list'][0]['version']>$a['list'][0]['id']){ /* if early versions missing. */
  1223. $origin=$a['list'][0]; $origin['version']=$origin['id']; array_unshift($a['list'], $origin);
  1224. }
  1225. }
  1226. if(($p = &$this->GetPost($a['id'],true))!=NULL){
  1227. $p['archive'] = &$a;
  1228. }
  1229. }
  1230. }
  1231. }
  1232. function ReadPostsFromFile($path){
  1233. if(!file_exists($path)){
  1234. $f = fopen($path,'w');
  1235. fclose($f);
  1236. }
  1237. $c = file_get_contents($path);
  1238. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1239. foreach($matches as $m){
  1240. $post = [];
  1241. $post['id'] = $m[1];
  1242. $post['real_content'] = trim($m[3]);
  1243. $post['content'] = &$post['real_content'];
  1244. if(preg_match('/COMMENT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['comment_to'] = $n[1];
  1245. if(preg_match('/EMAIL\s+([^;]+)\s*;/u', $m[2], $n)) $post['email'] = $n[1];
  1246. if(preg_match('/NAME\s+([^;]+)\s*;/u', $m[2], $n)) $post['name'] = $n[1];
  1247. if(preg_match('/LINK\s+([^;]+)\s*;/u', $m[2], $n)) $post['link'] = $n[1];
  1248. if(preg_match('/IP\s+([^;]+)\s*;/u', $m[2], $n)) $post['ip'] = $n[1];
  1249. if(preg_match('/NEXT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['next'] = $n[1];
  1250. if(preg_match('/PREV\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['prev'] = $n[1];
  1251. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1252. if(preg_match('/MDEL\s*;/u', $m[2])) $post['mark_delete'] = True;
  1253. if(preg_match('/MVAL\s*([^;]+);/u', $m[2], $n)) $post['mark_value'] = trim($n[1]);
  1254. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1255. if(preg_match('/REFS\s*([^;]+);/u', $m[2], $ma)){
  1256. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1257. foreach($links as $l){ $entries[] = $l[1]; } $post['refs'] = $entries; } }
  1258. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1259. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1260. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1261. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1262. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1263. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1264. if(preg_match('/HASTAG\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['hastag'] = $entries; } }
  1267. if(preg_match('/FROM\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['merged_from'] = $entries; } }
  1270. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1271. $post['merged_into'] = [trim($n[1]),trim($n[2])]; }
  1272. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1273. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1274. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1275. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1276. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1277. }
  1278. if(isset($post['mark_value']) && $post['mark_value']==5){
  1279. $post['product']=[];
  1280. }
  1281. /* marks add here */
  1282. $this->Posts[] = $post;
  1283. if(isset($post['comment_to']) && ($target_post = &$this->GetPost($post['comment_to'],true))){
  1284. if(!isset($target_post['comments']) || !isset($target_post['comments'][0])) $target_post['comments']=[];
  1285. $target_post['comments'][]=&$this->Posts[count($this->Posts) - 1];
  1286. }
  1287. }
  1288. }
  1289. }
  1290. function SortPosts($wayback=false){
  1291. $cmpp = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1292. $sortlist = &$this->Posts;
  1293. if($wayback) $sortlist = &$this->WaybackPosts;
  1294. if(isset($sortlist[0])){
  1295. usort($sortlist,$cmpp);
  1296. $this->YearEnd = substr($this->TIME_STRING,0,4);
  1297. $this->YearBegin = substr($sortlist[0]['id'],0,4);
  1298. }
  1299. }
  1300. function ReadPosts(){
  1301. if ((!file_exists('la_config.md') || is_readable('la_config.md') == false) ||
  1302. (!file_exists('la_config.php') || is_readable('la_config.php') == false) ||
  1303. (!is_dir('posts') || is_readable('posts') == false) ||
  1304. (!is_dir('archive') || is_readable('archive') == false) ||
  1305. (!is_dir('images') || is_readable('images') == false) ||
  1306. (!is_dir('styles') || is_readable('styles') == false)){
  1307. $this->Install();
  1308. }
  1309. if($this->DoneReadPosts){ return; }
  1310. $file_list = [];
  1311. $glob = glob('posts/*');
  1312. foreach($glob as $file) {
  1313. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1314. $file_list[] = $file;
  1315. }
  1316. }
  1317. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1318. foreach($file_list as $f) {
  1319. $this->ReadPostsFromFile($f);
  1320. }
  1321. $this->SortPosts();
  1322. $this->DetectThreads();
  1323. $this->DoneReadPosts=1;
  1324. }
  1325. function UpdatePostRefsForWayback(){
  1326. if(!isset($this->WayBack)) return;
  1327. if(isset($this->Images[0])) foreach($this->Images as &$i){ unset($i['refs']); }
  1328. if(!isset($this->WaybackPosts[0])) return;
  1329. foreach($this->WaybackPosts as &$p){ unset($p['refs']); }
  1330. foreach($this->WaybackPosts as &$p){
  1331. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $r){
  1332. $pr = &$this->GetPost($r); if(isset($pr)){
  1333. if(!isset($pr['refs'])) $pr['refs']=[];
  1334. if(!in_array($p['id'],$pr['refs'])){ $pr['refs'][] = $p['id']; }
  1335. }
  1336. }
  1337. if(isset($p['hasi']) && isset($p['hasi'][0])) foreach($p['hasi'] as $r){
  1338. $ir = &$this->FindImage($r); if(isset($ir)){
  1339. if(!isset($ir['refs'])) $ir['refs']=[];
  1340. if(!in_array($p['id'],$ir['refs'])){ $ir['refs'][] = $p['id'];}
  1341. }
  1342. }
  1343. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1344. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1345. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$p['id']; }
  1346. }
  1347. }
  1348. }
  1349. function ReadArchive(){
  1350. if (!is_dir('archive') || is_readable('archive') == false){ $this->Install(); }
  1351. if ($this->DoneReadArchive) return;
  1352. $file_list = []; $glob = glob('archive/*');
  1353. foreach($glob as $file) {
  1354. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1355. $file_list[] = $file;
  1356. }
  1357. }
  1358. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1359. foreach($file_list as $f) {
  1360. $this->ReadArchiveFromFile($f);
  1361. }
  1362. $this->SortArchive();
  1363. $this->DoneReadArchive=1;
  1364. $this->UpdateThreadForWayback();
  1365. $this->UpdatePostRefsForWayback();
  1366. }
  1367. function GetThreadForPost(&$post){
  1368. if(isset($post['tid'])) return;
  1369. $th = []; $iterp = NULL;
  1370. $post['tid'] = &$th; $th['first'] = &$post; $th['last'] = &$post;
  1371. if(!(isset($post['prev']) || isset($post['next']))) { $this->Threads[] = &$th; return; }
  1372. if(isset($post['prev']))for($p = $post['prev']; $p!=NULL; $p = $iterp){
  1373. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1374. $np['tid'] = &$th;
  1375. $th['first'] = &$np;
  1376. $iterp = isset($np['prev'])?$np['prev']:NULL;
  1377. }
  1378. if(isset($post['next']))for($p = $post['next']; $p!=NULL; $p = $iterp){
  1379. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1380. $np['tid'] = &$th;
  1381. $th['last'] = &$np;
  1382. $iterp = isset($np['next'])?$np['next']:NULL;
  1383. }
  1384. if(isset($th['first']['mark_value'])){
  1385. if($th['first']['mark_value']==6) $th['exp'] = true;
  1386. else if($th['first']['mark_value']==7) $th['slf'] = true;
  1387. }
  1388. if($th['first'] == $th['last']){ unset($post['tid']); return; }
  1389. $this->Threads[] = &$th;
  1390. }
  1391. function IdentifyThreadCategory(&$th,&$first_post){
  1392. unset($th['categories']);unset($th['interesting']);unset($th['reversed']);
  1393. if(preg_match('/^\s*\@(.*?)$/mu',$first_post['content'],$m)){
  1394. $first_post['categories']=[]; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1395. foreach($matches as $ma){ $first_post['categories'][] = $ma[1]; }
  1396. }
  1397. if(isset($th) && $th){ $th['categories'] = &$first_post['categories']; }
  1398. }
  1399. if(preg_match('/\{\s*WIDE\s*\}/imu',$first_post['content'],$m)){ $first_post['wide'] = true; }
  1400. if(preg_match('/\{\s*NO_TIME\s*\}/imu',$first_post['content'],$m)){ $first_post['no_time'] = true; }
  1401. if(preg_match('/\{\s*HEADER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['header'] = trim($m[1]); }
  1402. if(preg_match('/\{\s*FOOTER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['footer'] = trim($m[1]); }
  1403. if(!isset($th)) return;
  1404. if(isset($first_post['wide'])) $th['wide']=$first_post['wide'];
  1405. if(isset($first_post['header'])) $th['header']=$first_post['header'];
  1406. if(isset($first_post['footer'])) $th['footer']=$first_post['footer'];
  1407. if(isset($first_post['no_time'])) $th['no_time']=$first_post['no_time'];
  1408. if(preg_match('/\{\s*INTERESTING\s+(.*?)\}/imu',$first_post['content'],$m)){
  1409. $th['interesting'] = []; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1410. foreach($matches as $ma){ $th['interesting'][] = $ma[1]; }
  1411. }
  1412. }
  1413. if(preg_match('/\{\s*REVERSED\s*\}/imu',$first_post['content'],$m)){ $th['reversed'] = true; }
  1414. }
  1415. function IsInterestingPost(&$p){
  1416. if(isset($p['tid']) && isset($p['tid']['interesting']) && isset($p['tid']['interesting'][0])) return true;
  1417. return false;
  1418. }
  1419. function IsReversedThread(&$th){
  1420. if(isset($th['reversed']) && $th['reversed']) return true;
  1421. return false;
  1422. }
  1423. function GiveAllMergedPosts(&$po,&$arr){
  1424. if(isset($po['merged_from'])&&isset($po['merged_from'][0])) foreach($po['merged_from'] as $pm){
  1425. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr);}
  1426. }
  1427. if(isset($po['archive']) && isset($po['archive']['list'])){
  1428. foreach($po['archive']['list'] as &$ver){
  1429. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $pm){
  1430. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr); } }
  1431. }
  1432. }
  1433. }
  1434. function ThreadMakeWayback(&$th){
  1435. if(!isset($th['arr'][0])) return;
  1436. if(isset($this->WayBack)){
  1437. $remlist = [];
  1438. foreach($th['arr'] as &$pi){
  1439. $po = &$this->GetPost($pi['id'],true);
  1440. if(isset($po['merged_thread']) && isset($po['version']) && $po['version']>$this->WayBack){
  1441. $remlist = array_unique(array_merge($remlist,$po['merged_thread'][0]));
  1442. }
  1443. $ah = &$this->GetArchiveHandle($po['id']);
  1444. if(isset($ah)) foreach(array_reverse($ah['list']) as &$ver){
  1445. if(!isset($ver['merged_thread'])) continue;
  1446. if((isset($ver['version']) && $ver['version'] > $this->WayBack) ||
  1447. (!isset($ver['version']) && $ver['id'] > $this->WayBack)){
  1448. $remlist = array_unique(array_merge($remlist,$ver['merged_thread'][0]));
  1449. }
  1450. }
  1451. }
  1452. if(isset($remlist[0]) && isset($th['arr'][0])){
  1453. foreach($remlist as $rem){ $this->GiveAllMergedPosts($this->GetPost($rem,true),$remlist); }
  1454. foreach($th['arr'] as $key => $pr){
  1455. foreach($remlist as $rem){ if($pr['id'] == $rem) { unset($th['arr'][$key]); break; } } }
  1456. $new_th = []; $new_arr = [];
  1457. foreach($remlist as $rem){ $np=&$this->GetPost($rem); if(isset($np)){$new_arr[]=&$np;} }
  1458. $new_th['arr'] = &$new_arr;
  1459. $this->WaybackThreads[] = &$new_th;
  1460. $this->ThreadMakeWayback($new_th);
  1461. }
  1462. }
  1463. }
  1464. function AddMergedPosts(&$p, &$array){
  1465. if(isset($p['archive']) && isset($p['archive']['list'])){
  1466. foreach($p['archive']['list'] as &$ver){
  1467. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $po){
  1468. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1469. }
  1470. }
  1471. if(isset($p['merged_from'])&&isset($p['merged_from'][0])) foreach($p['merged_from'] as $po){
  1472. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1473. }
  1474. function FinalizeThread(&$th, $relink_posts=false, $now){
  1475. $nextp=NULL; $arr=[]; $lasttime=NULL;
  1476. if(!isset($th['arr'])){
  1477. for($p = &$th['first']; $p!=$this->NULL_POST; $p = &$this->GetPost(isset($p['next'])?$p['next']:NULL,true)){
  1478. $arr[]=&$p;
  1479. } $th['arr'] = &$arr;
  1480. if(isset($this->WayBack) && $this->DoneReadArchive){ $new_arr=[];
  1481. foreach($arr as &$p){ $pa = &$this->GetPost($p['id']); if(isset($pa)) {$new_arr[]=&$pa;$this->WaybackPosts[]=&$pa;} }
  1482. foreach($arr as &$p){ $this->AddMergedPosts($p,$new_arr); }
  1483. $arr=&$new_arr; $th['arr']=&$new_arr;
  1484. $this->ThreadMakeWayback($th); }
  1485. }
  1486. $cmppt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1487. if(isset($th['arr'][0])){ usort($th['arr'],$cmppt); } $th['count'] = sizeof($th['arr']);
  1488. if($relink_posts){ $count = $th['count'];
  1489. $arr = &$th['arr'];
  1490. 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'];
  1491. $arr[$i]['tid']=&$th;}
  1492. $th['first'] = &$arr[0]; $th['last'] = &$arr[$count-1]; unset($arr[0]['prev']); unset($arr[$count-1]['next']);
  1493. }
  1494. $th['score'] = 0; if(!isset($th['first'])){ return; }
  1495. $this->IdentifyThreadCategory($th, $th['first']);
  1496. if(isset($this->WayBack)) $lasttime=$this->WayBack;
  1497. if(!isset($last_time)) $lasttime = DateTime::createFromFormat('YmdHis', $th['last']['id']);
  1498. $diff_days = ($now - date_timestamp_get($lasttime))/3600/24;
  1499. $th['score'] = (float)$th['count']*0.2 - min($diff_days,200);
  1500. }
  1501. function SortThreads(){
  1502. if (!function_exists('cmpt')) {
  1503. function cmpt($a, $b){
  1504. if ($a['score'] == $b['score']) return 0;
  1505. return ($a['score'] > $b['score']) ? -1 : 1;
  1506. }
  1507. }
  1508. usort($this->Threads,"cmpt");
  1509. }
  1510. function DetectThreads(){
  1511. foreach($this->Posts as &$p){
  1512. if(isset($p['tid'])) { continue; }
  1513. $this->GetThreadForPost($p);
  1514. if(!isset($p['tid'])) { $this->IdentifyThreadCategory($this->NULL_POST, $p); }
  1515. }
  1516. if(!isset($this->Threads) || !isset($this->Threads[0])) return;
  1517. $now = date_timestamp_get(date_create());
  1518. foreach($this->Threads as &$t){
  1519. $this->FinalizeThread($t,false,$now);
  1520. }
  1521. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1522. $this->FinalizeThread($th,false,$now);
  1523. $this->Threads[] = &$th;
  1524. }
  1525. $this->SortThreads();
  1526. }
  1527. function UpdateThreadForWayback(){$now = date_timestamp_get(date_create());
  1528. if(!isset($this->WayBack) || !$this->DoneReadArchive){ return; }
  1529. foreach($this->Threads as &$t){
  1530. unset($t['arr']); $this->FinalizeThread($t,true,$now);
  1531. }
  1532. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1533. $this->FinalizeThread($th,true,$now);
  1534. $this->Threads[] = &$th;
  1535. }
  1536. $this->SortThreads();
  1537. $this->SortPosts(true);
  1538. $this->UsePosts = &$this->WaybackPosts;
  1539. }
  1540. function &GetMergedPost($id){
  1541. $this->ReadArchive();
  1542. $ah = &$this->GetArchiveHandle($id);
  1543. if(!isset($ah) || !isset($ah['list']) || !isset($ah['list'][0])){ return $this->NULL_POST; }
  1544. $ver = &$ah['list'][sizeof($ah['list'])-1];
  1545. if(!isset($ver['merged_into'])) return $this->GetPost($id);
  1546. [$tp, $tver] = $ver['merged_into'];
  1547. if(isset($this->WayBack)){
  1548. if($tver <= $this->WayBack) return $this->GetMergedPost($tp);
  1549. else return $this->GetPost($id); /* should not happen directly. */
  1550. }
  1551. return $this->GetMergedPost($tp);
  1552. }
  1553. function &GetPost($id, $latest_only=false, $find_merged=false){
  1554. if(!isset($id)) return $this->NULL_POST;
  1555. $found=&$this->NULL_POST;
  1556. if(isset($this->Posts[0])) foreach($this->Posts as &$p){
  1557. if($p&& $p['id'] == $id) { $found = &$p; break; }
  1558. if($find_merged && isset($p['hastag'][0]) && in_array($id, $p['hastag'])){ $found = &$p; break; }
  1559. }
  1560. if($latest_only || !isset($this->WayBack)){ return $found; }
  1561. else{
  1562. if(isset($found)){
  1563. if(!isset($found['archive'])&&!isset($found['archive']['list']))
  1564. { if($found['id'] > $this->WayBack) return $this->NULL_POST; else return $found; }
  1565. $last_ver = &$this->NULL_POST;
  1566. if(isset($found['archive']['list'][0])) foreach($found['archive']['list'] as &$ver){
  1567. if($ver['version'] > $this->WayBack) return $last_ver;
  1568. $last_ver = &$ver;
  1569. }
  1570. if(isset($found['version']) && $found['version'] <= $this->WayBack) return $found;
  1571. else return $last_ver;
  1572. }else{
  1573. $ah = &$this->GetArchiveHandle($id); $last_ver = &$this->NULL_POST;
  1574. if(isset($ah) && isset($ah['list']) && isset($ah['list'][0])) foreach($ah['list'] as &$ver){
  1575. if($ver['version'] > $this->WayBack) return $last_ver;
  1576. $last_ver = &$ver;
  1577. } if(!isset($last_ver['merged_into'])) return $last_ver; else{
  1578. [$tp, $tver] = $last_ver['merged_into'];
  1579. if($tver <= $this->WayBack) {
  1580. if($find_merged && $tp!=$id) return $this->GetPost($tp); return $this->NULL_POST; }
  1581. return $last_ver;
  1582. }
  1583. }
  1584. }
  1585. return $this->NULL_POST;
  1586. }
  1587. function &GetArchiveHandle($id){
  1588. if(!isset($id)) return $this->NULL_POST;
  1589. if(isset($this->ArchiveHandles[0])) foreach($this->ArchiveHandles as &$p){
  1590. if($p && $p['id'] == $id) { return $p; }
  1591. }
  1592. return $this->NULL_POST;
  1593. }
  1594. function &GetArchive($id){
  1595. if(!isset($id)) return $this->NULL_POST;
  1596. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1597. if($p && $p['id'] == $id) { return $p; }
  1598. }
  1599. return $this->NULL_POST;
  1600. }
  1601. function &GetArchiveVersion(&$ah, $version, &$next_ver, &$last_ver){
  1602. if(!isset($ah)) return $this->NULL_POST;
  1603. $found = NULL; $last_verp=NULL;
  1604. if(isset($ah['list'][0])) foreach($ah['list'] as &$p){
  1605. if(isset($found)){ $next_ver = $p; $last_ver = $last_verp; return $found; }
  1606. if($p && $p['version'] == $version) { $found = &$p; continue; }
  1607. $last_verp = &$p;
  1608. }
  1609. if(isset($found)) { $next_ver=NULL; $last_ver = $last_verp; return $found; }
  1610. return $this->NULL_POST;
  1611. }
  1612. function CacheArchiveOwnLinks(){
  1613. if(isset($this->WayBack)) return;
  1614. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1615. $this->ConvertPost($p); unset($p['hasp']); unset($p['hasi']); unset($p['hastag']);
  1616. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$p['html'],$matches,PREG_SET_ORDER)){
  1617. foreach($matches as $m){
  1618. if(!isset($p['hasp']))$p['hasp']=[]; if(!in_array($m[1],$p['hasp'])){ $p['hasp'][]=$m[1]; }
  1619. }
  1620. }
  1621. if(preg_match_all('/\/\/([0-9]{14})/u', $p['content'],$matches,PREG_SET_ORDER)){
  1622. foreach($matches as $m){
  1623. if(!isset($p['hastag']))$p['hastag']=[]; if(!in_array($m[1],$p['hastag'])){ $p['hastag'][]=$m[1]; }
  1624. }
  1625. }
  1626. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\)/u', $p['content'],$matches,PREG_SET_ORDER)){
  1627. foreach($matches as $m){
  1628. if(!isset($p['hasi']))$p['hasi']=[]; if(!in_array($m[2],$p['hasi'])){ $p['hasi'][]=$m[2]; }
  1629. }
  1630. }
  1631. }
  1632. }
  1633. function WriteArchive(){
  1634. if(isset($this->WayBack)) return;
  1635. $cf = NULL;$opened =NULL;
  1636. $this->SortArchive();
  1637. $this->CacheArchiveOwnLinks();
  1638. if(isset($this->Archive[0])) foreach($this->Archive as $p){
  1639. $nid = substr($p['id'], 0,6);
  1640. if($cf != $nid){
  1641. if($opened){
  1642. fflush($opened);
  1643. fclose($opened);
  1644. }
  1645. $cf = $nid;
  1646. $opened = fopen("archive/$cf.md", 'w');
  1647. }
  1648. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1649. "VER {$p['version']}; ".
  1650. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1651. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1]).";"):"").
  1652. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1653. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1654. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1655. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1656. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1657. ']';
  1658. if(isset($p['merged_thread'])){ $p['content']=""; }
  1659. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['content'].PHP_EOL.PHP_EOL);
  1660. }
  1661. }
  1662. function WritePosts(){
  1663. if(isset($this->WayBack)) return;
  1664. $cf = NULL;$opened =NULL;
  1665. $this->SortPosts();
  1666. if(isset($this->Posts[0])) foreach($this->Posts as $p){
  1667. $nid = substr($p['id'], 0,6);
  1668. if($cf != $nid){
  1669. if($opened){
  1670. fflush($opened);
  1671. fclose($opened);
  1672. }
  1673. $cf = $nid;
  1674. $opened = fopen("posts/$cf.md", 'w');
  1675. }
  1676. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1677. ((isset($p['version']) && $p['version'])?"VER {$p['version']}; ":"").
  1678. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1679. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1680. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1681. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1])."; "):"").
  1682. ((isset($p['comment_to']) && $p['comment_to'])?"COMMENT {$p['comment_to']}; ":"").
  1683. ((isset($p['email']) && $p['email'])?"EMAIL {$p['email']}; ":"").
  1684. ((isset($p['name']) && $p['name'])?"NAME {$p['name']}; ":"").
  1685. ((isset($p['link']) && $p['link'])?"LINK {$p['link']}; ":"").
  1686. ((isset($p['ip']) && $p['ip'])?"IP {$p['ip']}; ":"").
  1687. ((isset($p['mark_delete']) && $p['mark_delete'])?"MDEL; ":"").
  1688. ((isset($p['mark_value']) && $p['mark_value']>=0)?"MVAL {$p['mark_value']}; ":"").
  1689. ((isset($p['next']) && $p['next'])?"NEXT {$p['next']}; ":"").
  1690. ((isset($p['prev']) && $p['prev'])?"PREV {$p['prev']}; ":"").
  1691. ((isset($p['refs']) && isset($p['refs'][0]))?("REFS ".implode(" ",$p['refs'])."; "):"").
  1692. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1693. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1694. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1695. ((isset($p['mastodon_url']) && isset($p['mastodon_url']))?("MSTDN ".$p['mastodon_url']."; "):"").
  1696. ']';
  1697. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['real_content'].PHP_EOL.PHP_EOL);
  1698. }
  1699. }
  1700. function CachePostLinks(){
  1701. if(isset($this->WayBack)) return;
  1702. if(isset($this->Posts) && isset($this->Posts[0]))foreach ($this->Posts as &$post){
  1703. $this->ConvertPost($post);
  1704. unset($post['refs']);unset($post['hasp']);unset($post['hasi']);unset($post['hastag']);
  1705. //discard lost old version
  1706. //if(!isset($post['archive']) && $this->DoneReadArchive && isset($post['version'])){ unset($post['version']); }
  1707. }else return;
  1708. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1709. unset($im['refs']); unset($im['here']); unset($im['title']);
  1710. }
  1711. foreach ($this->Posts as &$post){
  1712. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$post['html'],$matches,PREG_SET_ORDER)){
  1713. foreach($matches as $m){
  1714. $ref = &$this->GetPost($m[1],true);
  1715. if($ref!=NULL){
  1716. if(!isset($ref['refs']))$ref['refs']=[]; if(!in_array($post['id'],$ref['refs']))$ref['refs'][]=$post['id'];
  1717. }
  1718. if(!isset($post['hasp']))$post['hasp']=[]; if(!in_array($m[1],$post['hasp']))$post['hasp'][]=$m[1];
  1719. }
  1720. }
  1721. if(preg_match_all('/\/\/([0-9]{14})/u', $post['content'],$matches,PREG_SET_ORDER)){
  1722. foreach($matches as $m){
  1723. if(!isset($post['hastag']))$post['hastag']=[]; if(!in_array($m[1],$post['hastag']))$post['hastag'][]=$m[1];
  1724. }
  1725. }
  1726. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\)/u', $post['content'],$matches,PREG_SET_ORDER)){
  1727. foreach($matches as $m){
  1728. if(($im = &$this->FindImage($m[2]))!=NULL){
  1729. if(!isset($im['refs']))$im['refs']=[]; if(!in_array($post['id'], $im['refs']))$im['refs'][] = $post['id'];
  1730. }
  1731. if(!isset($post['hasi']))$post['hasi']=[]; if(!in_array($m[2],$post['hasi']))$post['hasi'][]=$m[2];
  1732. }
  1733. }
  1734. if(preg_match("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\))(\R*(\R(-|\*).+){1,})/u",
  1735. $post['content'],$matches)){
  1736. $use_img_name = $matches[2];
  1737. if(($im = &$this->FindImage($use_img_name))!=NULL){
  1738. 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",
  1739. $matches[4],$mah,PREG_SET_ORDER)){
  1740. foreach($mah as $ma){
  1741. if(!isset($im['here']))$im['here']=[]; if(!$this->ImageHasHere($item, $ma[4])){
  1742. $here = [$ma[4], $ma[2], $ma[3]]; $im['here'][] = $here; }
  1743. }
  1744. }
  1745. }
  1746. }
  1747. }foreach($this->Posts as &$post){
  1748. if(isset($post['hasp']) && isset($post['hasp'][0])) foreach($post['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1749. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1750. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$post['id']; }
  1751. }
  1752. }
  1753. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1754. $min_id = '99999999999999';
  1755. if(isset($im['refs']) && isset($im['refs'][0])) foreach ($im['refs'] as &$ref){
  1756. $r = &$this->GetPost($ref,true); if(isset($r)) $title = $this->GetPostTitle($r,true,false);
  1757. if($title && $ref<$min_id) { $im['title'] = preg_replace('/;/u',' ',trim($title)); $min_id=$r['id']; }
  1758. }
  1759. }
  1760. }
  1761. function CreatePostAnchor(&$post){
  1762. $that=&$this;
  1763. $post['html'] = preg_replace_callback('/<h([0-9])>(.+?)(?=<\/h[0-9]>)/u', function ($ma) use ($that){
  1764. $id = '_heading_'.sizeof($this->Anchors);
  1765. $entry=[(int)$ma[1], $id, $ma[2]];
  1766. $that->Anchors[] = $entry;
  1767. return "<h${ma[1]} id='${id}'>${ma[2]}";
  1768. }, $post['html']);
  1769. }
  1770. function RenamePost(&$post, $rename){
  1771. foreach($this->Posts as &$p){
  1772. if($p['id']==$rename && $p!==$post) { return; /* don't overwrite */ }
  1773. }
  1774. foreach($this->Posts as &$p){
  1775. if(isset($p['prev']) && $p['prev']==$post['id']) { $p['prev']=$rename; }
  1776. if(isset($p['next']) && $p['next']==$post['id']) { $p['next']=$rename; }
  1777. }
  1778. $post['id'] = $rename;
  1779. }
  1780. function DetachPost(&$th,&$post){
  1781. $p0=$p1=NULL;foreach($th['arr'] as $a) echo $a['id']." "; echo '&nbsp;&nbsp;&nbsp;-'.$post['id']."<br />";
  1782. if(isset($post['prev'])){$p0=&$this->GetPost($post['prev'],true);} if(isset($post['next'])){$p1=&$this->GetPost($post['next'],true);}
  1783. if(isset($p0)){ $p0['next']=$p1['id']; }else{ $th['first']=$p1['id']; }
  1784. if(isset($p1)){ $p1['prev'] =$p0['id']; }else{ $th['last']=$p0['id']; }
  1785. foreach($this->Posts as $key => $p){ if ($p==$post) unset($this->Posts[$key]); }
  1786. unset($th['arr']); $now = date_timestamp_get(date_create());
  1787. $this->FinalizeThread($th, true, $now);
  1788. }
  1789. function PushPostVersion(&$post, $optime_id, $mode=1, $info=NULL){
  1790. $a = &$this->GetArchiveHandle($post['id']);
  1791. $ap = []; $ap['id'] = $post['id']; $ap['content'] = $post['real_content'];
  1792. $ap['version'] = isset($post['version'])?$post['version']:$ap['id'];
  1793. if(isset($post['merged_from'])) { $ap['merged_from'] = $post['merged_from']; unset($post['merged_from']); }
  1794. if(isset($post['merged_into'])) { $ap['merged_into'] = $post['merged_into']; unset($post['merged_into']); }
  1795. if(isset($post['merged_thread'])) { $ap['merged_thread'] = $post['merged_thread']; unset($post['merged_thread']); }
  1796. $post['version'] = $optime_id;
  1797. if($mode==1){
  1798. $this->InsertArchivePost($ap);
  1799. }else if($mode==2){
  1800. $post['merged_from'] = $info;
  1801. $this->InsertArchivePost($ap);
  1802. }else if($mode==3){
  1803. $ap['merged_into'] = $info;
  1804. $this->InsertArchivePost($ap);
  1805. if(isset($post['tid']) && $post['tid']['first']!=$post['tid']['last'] && $post!=$post['tid']['first']){
  1806. $this->DetachPost($post['tid'], $post);
  1807. }
  1808. }else if($mode==4){
  1809. $post['merged_thread'] = $info;
  1810. $this->InsertArchivePost($ap);
  1811. }
  1812. }
  1813. function &MergeThreads($post_id, $post_into_id){
  1814. $this->ReadPosts();
  1815. $po = &$this->GetPost($post_id, true); $pt = &$this->GetPost($post_into_id, true);
  1816. if (!isset($po) || !isset($pt) || !isset($po['tid']) || !isset($pt['tid']) ||
  1817. !isset($po['tid']['arr'][0]) || !isset($pt['tid']['arr'][0])){ return $this->NULL_POST; }
  1818. $po = &$po['tid']['arr'][0]; $pt = &$pt['tid']['arr'][0];
  1819. $th = &$po['tid']; $tt = &$pt['tid']; $info=[[],[]];
  1820. if($po['id'] < $pt['id']){ $temp = &$th; $th=&$tt; $tt=&$temp; $temp = &$po; $po=&$pt; $pt=&$temp; }
  1821. foreach($th['arr'] as &$p){ $info[0][]=$p['id']; }
  1822. foreach($tt['arr'] as &$p){ $info[1][]=$p['id']; }
  1823. $this->EditPost($pt['id'], NULL, NULL, NULL, false, NULL, NULL, 4, $info,NULL);
  1824. $arr_combined = array_merge($tt['arr'],$th['arr']);
  1825. $cmppmt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1826. if(isset($arr_combined[0])){ usort($arr_combined,$cmppmt); } $tt['arr']=&$arr_combined;
  1827. $tt['count'] = sizeof($tt['arr']);
  1828. $this->FinalizeThread($tt, true, $this->TIME_STRING);
  1829. $first_post = &$this->NULL_POST;
  1830. if(isset($tt['arr'][0])) $first_post= &$tt['arr'][0];
  1831. $this->NeedWritePosts=1;
  1832. $this->NeedWriteArchive=1;
  1833. return $first_post;
  1834. }
  1835. function &MergePosts($ids_string){
  1836. $ids = explode(" ", $ids_string);
  1837. $combined_content = ""; $first_id=NULL;
  1838. $this->ReadPosts(); $child_list=[];
  1839. foreach($ids as $id){
  1840. if(!preg_match('/[0-9]{14}/u',$id) || $this->GetPost($id,true)==$this->NULL_POST) continue;
  1841. if(!isset($first_id)) { $first_id = $id; } else { $combined_content.=PHP_EOL.PHP_EOL."//".$id.PHP_EOL; $child_list[]=$id; }
  1842. $combined_content.=$this->EditPost($id, NULL, NULL, NULL, true, NULL, NULL, false, NULL,NULL);
  1843. }
  1844. if(!isset($child_list[0])) return $this->NULL_POST;
  1845. $first_post = &$this->EditPost($first_id, $combined_content, NULL, NULL, false, NULL, NULL, 2, $child_list,NULL);
  1846. foreach($child_list as $id){
  1847. $this->EditPost($id, NULL, NULL, NULL, false, NULL, NULL, 3, [$first_id,$this->TIME_STRING],NULL);
  1848. }
  1849. $this->NeedWritePosts=1;
  1850. $this->NeedWriteArchive=1;
  1851. return $first_post;
  1852. }
  1853. /* push_version: 1 edit 2 post merged from ids list 3 post end into id-ver */
  1854. function &EditPost($id_if_edit, $content, $mark_delete, $reply_to,
  1855. $get_original_only=false, $mark_value=NULL, $rename=NULL,
  1856. $push_version=false, $version_info=NULL, $mastodon_url=NULL){
  1857. $this->ReadImages();
  1858. $this->ReadPosts();
  1859. if(isset($push_version) && $push_version){
  1860. $this->ReadArchive();
  1861. }
  1862. $p_success = NULL;
  1863. if(isset($id_if_edit)){
  1864. $post = &$this->GetPost($id_if_edit,true);
  1865. if($post===$this->NULL_POST) return $this->NULL_POST;
  1866. if($get_original_only){
  1867. return $post['real_content'];
  1868. }
  1869. if(isset($push_version) && $push_version){
  1870. $this->PushPostVersion($post,$this->TIME_STRING,$push_version,$version_info);
  1871. }
  1872. if(isset($content)) {$post['real_content'] = $content; $post['content'] = &$post['real_content'];}
  1873. if(isset($mark_delete)) $post['mark_delete'] = $mark_delete;
  1874. if(isset($mark_value)) $post['mark_value'] = $mark_value;
  1875. if(isset($rename) && preg_match('/^[0-9]{14}$/u',$rename)) $this->RenamePost($post,$rename);
  1876. if(isset($mastodon_url)) { if($mastodon_url!='') $post['mastodon_url']=$mastodon_url; else unset($post['mastodon_url']); }
  1877. $p_success = &$post;
  1878. }else{
  1879. if(!isset($content)) return $this->NULL_POST;
  1880. $id = date('YmdHis');
  1881. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  1882. $post = []; $post['id'] = $id;
  1883. $post['real_content'] = $content; $post['content'] = &$post['real_content'];
  1884. if(isset($reply_to) && ($rep = &$this->GetPost($reply_to,true))!== $this->NULL_POST){
  1885. while($rep !== $this->NULL_POST && isset($rep['next']) && $rep['next']){ $rep = &$this->GetPost($rep['next'],true); }
  1886. if($rep !== $this->NULL_POST){ $rep['next'] = $id; $post['prev'] = $rep['id']; }
  1887. }
  1888. $this->Posts[] = $post;
  1889. $p_success = &$this->Posts[count($this->Posts) - 1];
  1890. }
  1891. $this->NeedWritePosts=1;
  1892. $this->NeedWriteImages=1;
  1893. if(isset($push_version) && $push_version){
  1894. $this->NeedWriteArchive=1;
  1895. }
  1896. return $p_success;
  1897. }
  1898. function &EditComment($id_if_edit, $comment_to_id, $content, $email, $name, $link=NULL, $ip=NULL){
  1899. $this->ReadPosts();
  1900. $p_success = NULL;
  1901. if(isset($id_if_edit)){
  1902. $post = &$this->GetPost($id_if_edit,true);
  1903. if($post===$this->NULL_POST || !isset($post['comment_to'])) return $this->NULL_POST;
  1904. if(isset($content)) $post['content'] = $content;
  1905. if(isset($comment_to_id)) $post['comment_to'] = $comment_to_id;
  1906. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  1907. if(isset($ip)) $post['ip'] = $ip;
  1908. $p_success = &$post;
  1909. }else{
  1910. if(!isset($content) || !isset($comment_to_id)) return $this->NULL_POST;
  1911. $id = date('YmdHis');
  1912. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  1913. if(!($to_post=$this->GetPost($comment_to_id,true))) return $this->NULL_POST;
  1914. $post = []; $post['id'] = $id; $post['content'] = $content; $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. $this->Posts[] = $post;
  1918. $p_success = &$this->Posts[count($this->Posts) - 1];
  1919. }
  1920. $this->NeedWritePosts=1;
  1921. return $p_success;
  1922. }
  1923. function InsertReplacementSymbols($MarkdownContent, &$post_for_it_is_here){
  1924. $replacement = preg_replace('/<!--[\s\S]*-->/U',"",$MarkdownContent);
  1925. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  1926. function($matches){
  1927. $rep = preg_replace('/->/','-@>',$matches[0]);
  1928. $rep = preg_replace('/=>/','=@>',$rep);
  1929. $rep = preg_replace('/<=/','<@=',$rep);
  1930. $rep = preg_replace('/<-/','<@-',$rep);
  1931. $rep = preg_replace('/\R([+]{3,})\R/',PHP_EOL.'@$1'.PHP_EOL,$rep);
  1932. $rep = preg_replace('/\[-/','[@-',$rep);
  1933. $rep = preg_replace('/\{/','{@',$rep);
  1934. $rep = preg_replace('/(en|zh|any)\|(en|zh|any)/','$1@|$2',$rep);
  1935. return $rep;
  1936. },
  1937. $replacement);
  1938. $replacement = preg_replace("/<[-]+>/","↔",$replacement);
  1939. $replacement = preg_replace("/([^-])->/","$1→",$replacement);
  1940. $replacement = preg_replace("/<-([^-])/","←$1",$replacement);
  1941. $replacement = preg_replace("/([^-])[-]+->/","$1⟶",$replacement);
  1942. $replacement = preg_replace("/<-[-]+([^-])/","⟵$1",$replacement);
  1943. $replacement = preg_replace("/<[=]+>/","⇔",$replacement);
  1944. $replacement = preg_replace("/[=]+>/","⇒",$replacement);
  1945. $replacement = preg_replace("/<[=]+/","⇐",$replacement);
  1946. $replacement = preg_replace("/\R([+]{3,})\R/","<div class='page_break'></div>",$replacement);
  1947. $replacement = preg_replace("/\[-(.*)-\]/U","<span class='text_highlight'>$1</span>",$replacement);
  1948. $replacement = preg_replace("/{支付宝(\s+[^}]*?)?}/u","<span class='special_alipay'>支付宝$1</span>",$replacement);
  1949. $replacement = preg_replace("/{PayPal(\s+[^}]*?)?}/ui",
  1950. "<span class='special_paypal'>Pay<span class='special_paypal_inner'>Pal</span>$1</span>",$replacement);
  1951. $replacement = preg_replace("/\/\/([0-9]{14})/imu","<p class='wscroll' id='$1'>".$this->T("链接位置")."</p>",$replacement);
  1952. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  1953. function($matches){
  1954. $rep = preg_replace('/-@>/','->',$matches[0]);
  1955. $rep = preg_replace('/<@-/','<-',$rep);
  1956. $rep = preg_replace('/=@>/','=>',$rep);
  1957. $rep = preg_replace('/<@=/','<=',$rep);
  1958. $rep = preg_replace('/\R@([+]{3,})\R/',PHP_EOL.'$1'.PHP_EOL,$rep);
  1959. $rep = preg_replace('/\[@-/','[-',$rep);
  1960. $rep = preg_replace('/\{@/','{',$rep);
  1961. $rep = preg_replace('/(en|zh|any)@\|(en|zh|any)/','$1|$2',$rep);
  1962. return $rep;
  1963. }, $replacement);
  1964. $replacement = preg_replace_callback("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\))(\R*(\R.+){1,})/u",
  1965. function($matches) use (&$post_for_it_is_here){
  1966. $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]);
  1967. return $matches[1].$rep;
  1968. }, $replacement);
  1969. return $replacement;
  1970. }
  1971. function CanShowPost(&$p){
  1972. if(!isset($p) || isset($p['comment_to'])) return false;
  1973. $is_mark_exp = (isset($p['tid'])&&isset($p['tid']['exp'])&&$p['tid']['exp']) || (isset($p['mark_value'])&&$p['mark_value']==6);
  1974. $is_mark_slf = (isset($p['tid'])&&isset($p['tid']['slf'])&&$p['tid']['slf']) || (isset($p['mark_value'])&&$p['mark_value']==7);
  1975. if($is_mark_slf && !$this->LoggedIn){ return false; }
  1976. if(isset($this->WayBack)){
  1977. if(isset($p['version'])) { if ($p['version']>$this->WayBack) return false; }
  1978. else if ($p['id']>$this->WayBack) return false;
  1979. }
  1980. if(!$this->InExperimentalMode){
  1981. if(!$this->LoggedIn){
  1982. if($is_mark_exp) return false;
  1983. return true;
  1984. }
  1985. return true;
  1986. }else{
  1987. if($is_mark_exp) return true;
  1988. return false;
  1989. }
  1990. }
  1991. function SkipProduct(&$p){
  1992. if($this->LoggedIn) return false;
  1993. return (isset($p['mark_value']) && $p['mark_value']==5);
  1994. }
  1995. function GetRedirect($args=NULL){
  1996. $str = 'index.php?';
  1997. if(isset($args['post'])) $str.='&post='.$args['post'];
  1998. else if(isset($_GET['post'])) $str.='&post='.$_GET['post'];
  1999. if(isset($args['gallery'])) $str.='&gallery='.$args['gallery'];
  2000. else if(isset($_GET['gallery'])) $str.='&gallery='.$_GET['gallery'];
  2001. if(isset($args['pic'])) $str.='&pic='.$args['pic'];
  2002. else if(isset($_GET['pic'])) $str.='&pic='.$_GET['pic'];
  2003. if(isset($args['settings'])) $str.='&settings='.$args['settings'];
  2004. else if(isset($_GET['settings'])) $str.='&settings='.$_GET['settings'];
  2005. if(isset($args['extras'])) $str.='&extras='.$args['extras'];
  2006. else if(isset($_GET['extras'])) $str.='&extras='.$_GET['extras'];
  2007. if(isset($args['category'])) $str.='&category='.$args['category'];
  2008. else if(isset($_GET['category'])) $str.='&category='.$_GET['category'];
  2009. if(isset($args['history'])) $str.='&history='.$args['history'];
  2010. else if(isset($_GET['history'])) $str.='&history='.$_GET['history'];
  2011. if(isset($args['version'])) $str.='&version='.$args['version'];
  2012. else if(isset($_GET['version'])) $str.='&version='.$_GET['version'];
  2013. if(isset($args['search'])) $str.='&search='.$args['search'];
  2014. else if(isset($_GET['search'])) $str.='&search='.$_GET['search'];
  2015. if(isset($args['here'])) $str.='&here='.$args['here'];
  2016. else if(isset($_GET['here'])) $str.='&here='.$_GET['here'];
  2017. return $str;
  2018. }
  2019. function WriteAsNecessary(){
  2020. if(!$this->LoggedIn || isset($this->WayBack)){return;}
  2021. if($this->NeedWritePosts){ $this->CachePostLinks(); $this->WritePosts(); }
  2022. if($this->NeedWriteImages){ $this->WriteImages(); }
  2023. if($this->NeedWriteArchive){ $this->WriteArchive(); }
  2024. }
  2025. function APubEnsureWebfinger($name, $host){
  2026. if(!is_dir('.well-known')) mkdir('.well-known');
  2027. if(!is_dir('.well-known/webfinger')) mkdir('.well-known/webfinger');
  2028. $f = fopen('.well-known/webfinger/index.php',"w");
  2029. $without_protocol = parse_url($host, PHP_URL_HOST);
  2030. $finger = ["subject"=>"acct:".$name.'@'.$without_protocol,
  2031. "links"=>[["rel"=>"self", "type"=>"application/activity+json", "href"=>$host."?apub_actor=1"]]];
  2032. fwrite($f, "<?php header('Content-Type: application/json'); echo '".json_encode($finger, JSON_UNESCAPED_SLASHES)."'; ?>"); fclose($f);
  2033. if(!file_exists('.well-known/apub_public_key.pem') || !file_exists('.well-known/apub_private_key.php')){
  2034. $res = openssl_pkey_new();
  2035. $this->APubPublicKey = openssl_pkey_get_details($res)['key'];
  2036. openssl_pkey_export($res, $this->APubPrivateKey);
  2037. $f = fopen('.well-known/apub_public_key.pem',"w");
  2038. fwrite($f, $this->APubPublicKey); fclose($f);
  2039. $f = fopen('.well-known/apub_private_key.php',"w");
  2040. fwrite($f, "<?php exit; ?>".PHP_EOL.PHP_EOL.$this->APubPrivateKey); fclose($f);
  2041. }
  2042. }
  2043. function APubEnsureInfo(){
  2044. if(!isset($this->APubID) || !isset($this->HostURL)) return;
  2045. if(!file_exists('.well-known/apub_public_key.pem')){$this->APubEnsureWebfinger($this->APubID, $this->HostURL);}
  2046. $pk = file_get_contents('.well-known/apub_public_key.pem'); //$pk = preg_replace('/\n/u','\\n',$pk);
  2047. $actor = ["@context"=>["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1"],
  2048. "id"=> $this->HostURL."?apub_actor=1",
  2049. "type"=> "Person",
  2050. "name"=> $this->DisplayName,
  2051. "url"=> $this->HostURL,
  2052. "summary"=> "Lazy... No summary",
  2053. "preferredUsername"=> $this->APubID,
  2054. "inbox"=> $this->HostURL."?apub_inbox=1",
  2055. "outbox"=> $this->HostURL."?apub_outbox=1",
  2056. "publicKey"=> ["id"=> $this->HostURL."?apub_actor=1#main-key",
  2057. "owner"=> $this->HostURL."?apub_actor=1",
  2058. "publicKeyPem"=>$pk]];
  2059. $this->APubActor = json_encode($actor, JSON_UNESCAPED_SLASHES);
  2060. }
  2061. function APubMakeOutbox(){
  2062. $this->ReadPosts();$this->ReadImages();
  2063. $obj = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2064. "id"=>$this->HostURL."?apub_outbox=1",
  2065. "type"=>"OrderedCollection"];
  2066. $items=[]; $i=0;
  2067. foreach(array_reverse($this->Posts) as &$p){
  2068. $this->ConvertPost($p);
  2069. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$p['html']));
  2070. $time = DateTime::createFromFormat('YmdHis', $p['id'], new DateTimeZone('+0800'));
  2071. $ob = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2072. "type"=> "Create",
  2073. "id"=> $this->HostURL."?post=".$p['id']."?apub_object=1",
  2074. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2075. //"to"=> ["https://chatty.example/ben/"],
  2076. "actor"=> $this->HostURL."?apub_actor=1",
  2077. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2078. "object"=> ["type"=> "Note",
  2079. "id"=> $this->HostURL."?post=".$p['id'],
  2080. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2081. "attributedTo"=> $this->HostURL."?apub_actor=1",
  2082. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2083. "content"=> $text]];
  2084. $items[] = $ob;
  2085. $i++; if($i>20) break;
  2086. }
  2087. $obj['orderedItems'] = $items; $obj["totalItems"] = sizeof($items);
  2088. return json_encode($obj, JSON_UNESCAPED_SLASHES);
  2089. }
  2090. function MakeRSS(){
  2091. $this->ReadPosts();$this->ReadImages();
  2092. $posts = []; if(isset($this->UsePosts[0])){
  2093. $posts = array_reverse($this->UsePosts);
  2094. $last_updated = $this->StandardTime($posts[0]['id']);
  2095. }else{ $last_updated= $this->StandardTime("20000101000000"); }
  2096. $author = "<author><name>".$this->DisplayName."</name><email>".$this->EMail."</email><uri>".$this->HostURL."</uri></author>";
  2097. $all_content="<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom'>".
  2098. "<id>".$this->HostURL."/?rss</id>".
  2099. "<updated>".$last_updated."</updated>".
  2100. "<title>".$this->T($this->Title)."</title>".
  2101. "<link href='".$this->HostURL."/?rss' rel='self'/>".
  2102. "<link href='".$this->HostURL."' />".$author;
  2103. $i=0;
  2104. if(isset($posts[0])) foreach($posts as &$p){
  2105. if($i>100) break;
  2106. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  2107. if(isset($p['tid'])){ /* Should always be set. */
  2108. $th = &$p['tid']; if($p['tid']['count']==0) continue; }
  2109. if(in_array($p['id'],
  2110. [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation])) continue;
  2111. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  2112. $is_thread = isset($p['tid']['count'])&&($p['tid']['count']>1);
  2113. $is_reversed=false;
  2114. $content="<entry>"; $title = NULL;
  2115. if($is_thread){
  2116. $use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false; if($is_reversed){
  2117. $use_arr=array_reverse($th['arr']); $fp=array_pop($use_arr); array_unshift($use_arr,$fp); }
  2118. foreach($use_arr as &$po){
  2119. $this->ConvertPost($po);
  2120. if(!isset($title)){$title = $this->GetPostTitle($po, false, false);
  2121. $content.="<id>".$this->HostURL."?post=".$po['id']."</id>";
  2122. $content.="<title>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$po['id']."' />";
  2123. $content.="<published>".$this->StandardTime($po['id'])."</published>";
  2124. $content.="<updated>".$this->StandardTime(isset($po['tid']['last']['version'])?
  2125. $po['tid']['last']['version']:$po['tid']['last']['id'])."</updated>".$author;
  2126. $content.="<content type='html'>"; }
  2127. $content.= htmlspecialchars($po['html']);
  2128. //if(isset($po['images'])&&isset($po['images'][0])) foreach($po['images'] as $im){ $content.=htmlspecialchars($im); }
  2129. }
  2130. $content.=$this->ReadableTime($p['tid']['first']['id'])." - ".
  2131. $this->ReadableTime(isset($p['tid']['last']['version'])?
  2132. $p['tid']['last']['version']:$p['tid']['last']['id']);
  2133. $content.="</content>";
  2134. }else{
  2135. $this->ConvertPost($p);
  2136. if(!isset($title)){$title = $this->GetPostTitle($p, false, false);
  2137. $content.="<id>".$this->HostURL."?post=".$p['id']."</id>";
  2138. $content.="<title>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$p['id']."' />";
  2139. $content.="<published>".$this->StandardTime($p['id'])."</published>";
  2140. $content.="<updated>".$this->StandardTime(isset($p['tid']['last']['version'])?
  2141. $p['tid']['last']['version']:$p['tid']['last']['id'])."</updated>".$author;}
  2142. $content.= "<content type='html'>".htmlspecialchars($p['html']);
  2143. //if(isset($p['images'])&&isset($p['images'][0])) foreach($p['images'] as $im){ $content.=htmlspecialchars($im); }
  2144. $content.=$this->ReadableTime($p['id'])." - ".
  2145. $this->ReadableTime(isset($p['version'])?$p['version']:$p['id']);
  2146. $content.="</content>";
  2147. }
  2148. $i++;
  2149. $content.="</entry>";
  2150. $all_content.=$content;
  2151. }
  2152. $all_content.="</feed>";
  2153. header( "Content-type: text/xml");
  2154. echo $all_content;
  2155. }
  2156. function MakeHereButtons($im, $insert_here){
  2157. if(isset($im['here'])&&isset($im['here'][0])){
  2158. $size=getimagesize($im['file']); $aspect=$size[0]/$size[1];
  2159. echo ($insert_here?"<here>":"")."<div class='here_buttons_inner' style='aspect-ratio:".$aspect.";'>";
  2160. foreach($im['here'] as $here){
  2161. if($insert_here){
  2162. echo "<a href='?show_image=".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'".
  2163. "onclick='event.preventDefault();event.stopPropagation();ShowBigImage(\"".$here[0]."\",1);'></a>";
  2164. }else{
  2165. echo "<a href='?here=images/".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'></a>";
  2166. }
  2167. }
  2168. echo "</div>".($insert_here?"</here>":"");
  2169. }
  2170. }
  2171. function ProcessRequest(&$message=NULL, &$redirect=NULL){
  2172. if(isset($_GET['gallery']) && $_GET['gallery']=='default'){
  2173. $redirect = "index.php?gallery=".(isset($this->DefaultGallery)&&$this->DefaultGallery!=''?$this->DefaultGallery:"main");
  2174. return 0;
  2175. }
  2176. if(isset($_GET['set_language'])){
  2177. setcookie('la_language',$_GET['set_language'],time()+3600*24*7); $_COOKIE['la_language'] = $_GET['set_language'];
  2178. $redirect=$this->GetRedirect(); return 0;
  2179. }
  2180. if(isset($_GET['rss'])){
  2181. if(in_array($_GET['rss'],['en','zh'])){$this->LanguageAppendix=$_GET['rss'];}
  2182. $this->MakeRSS(); exit;
  2183. }
  2184. if(isset($_GET['toggle_font'])){ $use_font='local';
  2185. if(!isset($_COOKIE['la_font']) || $_COOKIE['la_font']!='remote') $use_font='remote';
  2186. setcookie('la_font',$use_font,time()+3600*24*7); $_COOKIE['la_font'] = $use_font;
  2187. $redirect=$this->GetRedirect(); return 0;
  2188. }
  2189. if(isset($_GET['set_wayback'])){
  2190. if($_GET['set_wayback']!='false'){
  2191. $wayback= date('YmdHis');
  2192. if($_GET['set_wayback']=='post'){
  2193. if(isset($_POST['wayback_year'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_year'],4,"0",STR_PAD_LEFT),0,4);
  2194. if(isset($_POST['wayback_month'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_month'],2,"0",STR_PAD_LEFT),4,2);
  2195. if(isset($_POST['wayback_day'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_day'],2,"0",STR_PAD_LEFT),6,2);
  2196. if(isset($_POST['wayback_hour'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_hour'],2,"0",STR_PAD_LEFT),8,2);
  2197. if(isset($_POST['wayback_minute'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_minute'],2,"0",STR_PAD_LEFT),10,2);
  2198. }else{ if(preg_match('/[0-9]{14}/u', $_GET['set_wayback'])) $wayback = $_GET['set_wayback']; }
  2199. setcookie('la_wayback',$wayback); $_COOKIE['la_wayback'] = $wayback;
  2200. }else{
  2201. setcookie('la_wayback', null, -1); unset($_COOKIE['la_wayback']);
  2202. }
  2203. $redirect=$this->GetRedirect(); return 0;
  2204. }
  2205. if(isset($_GET['post'])){ $this->CurrentPostID = $_GET['post']; $this->TagID = $this->CurrentPostID; }
  2206. if(isset($_GET['here'])){ $this->HereID = $_GET['here']; }
  2207. if(isset($_GET['offset'])){ $this->CurrentOffset = $_GET['offset']; }
  2208. if(isset($_GET['part'])){
  2209. if($_GET['part'] == 'hot') $this->ExtraScripts.="ShowLeftSide();";
  2210. else if ($_GET['part'] == 'recent') $this->ExtraScripts.="ShowCenterSide();";
  2211. }
  2212. if(isset($_GET['post'])){
  2213. $this->ExtraScripts.="window.addEventListener('load', (event) => {ScrollToPost('".$_GET['post']."');});";
  2214. }
  2215. if(isset($_GET['random_here'])){
  2216. $this->DoIdentifyExperimental(); $this->DetectPageType();
  2217. $im = &$this->GiveImageInHere(true); if(isset($im)){ $redirect='?here=images/'.$im['name']; return 0; }
  2218. }
  2219. if(isset($_POST['search_content'])){ $redirect='index.php?search='.$_POST['search_content'];return 0; }
  2220. if(isset($_GET['image_info']) || isset($_GET['show_image'])){
  2221. $m=isset($_GET['image_info'])?$_GET['image_info']:$_GET['show_image'];
  2222. $direct_return = !isset($_GET['show_image']);
  2223. $this->ReadImages(); $this->ReadPosts();
  2224. $this->SwitchWayBackMode(); if(isset($this->WayBack)){$this->ReadArchive();}
  2225. $im = &$this->FindImage($m);
  2226. if($im==NULL || !isset($im['refs']) || !isset($im['refs'][0])){ echo "not_found"; exit; }
  2227. if($direct_return){
  2228. echo "<ref>".sizeof($im['refs'])."</ref>";
  2229. echo "<insert><ul>";
  2230. }else{ ob_start(); }
  2231. foreach(array_reverse($im['refs']) as $ref){
  2232. $p = $this->GetPost($ref);
  2233. if(!$p || !$this->CanShowPost($p)) continue;
  2234. $this->MakeSinglePost($p, false, true, "post_preview", true, false, false, false, true);"</li>";
  2235. }
  2236. if($direct_return){
  2237. echo "</ul></insert>";
  2238. $this->MakeHereButtons($im, true);
  2239. }else{
  2240. $str = ob_get_clean();
  2241. $this->MakePageBegin();
  2242. $side = "";
  2243. if(isset($im['refs'])&&isset($im['refs'][0])){
  2244. $side.="<span class='small'>".$this->T('该图片出现在')." ".sizeof($im['refs'])." ".$this->T('个帖子中')."</span>";
  2245. }else{$side.="<span class='smaller gray'>".$this->T('该图片未被引用')."</span>";}
  2246. $static_image = isset($im['video'])?NULL:$im['file'];
  2247. $static_video = isset($im['video'])?$im['file']:NULL;
  2248. $this->MakeImageOverlay($side."<ul>".$str."</ul>",$static_image,$static_video);
  2249. $this->MakePageEnd();
  2250. }
  2251. exit;
  2252. }
  2253. if(isset($_GET['confirm_enter']) && $_GET['confirm_enter']!=false){
  2254. setcookie('la_experimental','confirmed'); $_COOKIE['la_experimental'] = $_GET['confirmed'];
  2255. $redirect='index.php'.(isset($_GET['post'])?'?post='.$_GET['post']:"");return 0;
  2256. }
  2257. if(isset($_GET['apub_actor'])){
  2258. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2259. echo $this->APubActor; exit;
  2260. }
  2261. if(isset($_GET['apub_outbox'])){
  2262. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2263. echo $this->APubMakeOutbox(); exit;
  2264. }
  2265. if($this->LoggedIn){
  2266. $this->DoUpload();
  2267. if(isset($_POST['settings_button'])){
  2268. if(isset($_POST['settings_title'])) $this->Title=$_POST['settings_title'];
  2269. if(isset($_POST['settings_short_title'])) $this->ShortTitle=$_POST['settings_short_title'];
  2270. if(isset($_POST['settings_display_name'])) $this->DisplayName=$_POST['settings_display_name'];
  2271. if(isset($_POST['settings_email'])) $this->EMail=$_POST['settings_email'];
  2272. if(isset($_POST['settings_special_navigation'])) $this->SpecialNavigation=$_POST['settings_special_navigation'];
  2273. if(isset($_POST['settings_special_footer'])) $this->SpecialFooter=$_POST['settings_special_footer'];
  2274. if(isset($_POST['settings_special_footer2'])) $this->SpecialFooter2=$_POST['settings_special_footer2'];
  2275. if(isset($_POST['settings_special_pinned'])) $this->SpecialPinned=$_POST['settings_special_pinned'];
  2276. if(isset($_POST['settings_default_gallery'])) $this->DefaultGallery=$_POST['settings_default_gallery'];
  2277. if(isset($_POST['settings_selfauth_path'])) $this->SelfAuthPath=$_POST['settings_selfauth_path'];
  2278. if(isset($_POST['settings_enable_comments'])) $this->CommentEnabled=True; else $this->CommentEnabled=False;
  2279. if(isset($_POST['settings_here_host'])) $this->HereHost=$_POST['settings_here_host'];
  2280. if(isset($_POST['settings_here_title'])) $this->HereTitle=$_POST['settings_here_title'];
  2281. if(isset($_POST['settings_here_short_title'])) $this->HereShortTitle=$_POST['settings_here_short_title'];
  2282. if(isset($_POST['settings_here_album'])) $this->HereAlbum=$_POST['settings_here_album'];
  2283. if(isset($_POST['settings_here_navigation'])) $this->HereNavigation=$_POST['settings_here_navigation'];
  2284. if(isset($_POST['settings_here_footer'])) $this->HereFooter=$_POST['settings_here_footer'];
  2285. if(isset($_POST['settings_exp_host'])) $this->ExpHost=$_POST['settings_exp_host'];
  2286. if(isset($_POST['settings_exp_title'])) $this->ExpTitle=$_POST['settings_exp_title'];
  2287. if(isset($_POST['settings_exp_short_title'])) $this->ExpShortTitle=$_POST['settings_exp_short_title'];
  2288. if(isset($_POST['settings_exp_caution'])) $this->ExpCaution=$_POST['settings_exp_caution'];
  2289. if(isset($_POST['settings_exp_album'])) $this->ExpAlbum=$_POST['settings_exp_album'];
  2290. if(isset($_POST['settings_exp_navigation'])) $this->ExpNavigation=$_POST['settings_exp_navigation'];
  2291. if(isset($_POST['settings_exp_footer'])) $this->ExpFooter=$_POST['settings_exp_footer'];
  2292. if(isset($_POST['settings_mastodon_token'])) $this->MastodonToken=$_POST['settings_mastodon_token'];
  2293. if(isset($_POST['settings_mastodon_url'])) $this->MastodonURL=$_POST['settings_mastodon_url'];
  2294. if(isset($_POST['settings_mastodon_lang'])) $this->MastodonPreferredLang=$_POST['settings_mastodon_lang'];
  2295. if(isset($_POST['settings_host_url'])) $this->HostURL=$_POST['settings_host_url'];
  2296. if(isset($_POST['settings_apub_id']) && isset($this->HostURL)) {
  2297. $this->APubID=$_POST['settings_apub_id'];
  2298. $this->APubEnsureWebfinger($this->APubID,$this->HostURL);
  2299. }
  2300. if(isset($_POST['settings_old_password'])&&password_verify($_POST['settings_old_password'], $this->Password)){
  2301. if(isset($_POST['settings_id'])) $this->Admin=$_POST['settings_id'];
  2302. if(isset($_POST['settings_new_password']) && isset($_POST['settings_new_password_redo']) &&
  2303. $_POST['settings_new_password'] = $_POST['settings_new_password_redo'])
  2304. {$this->Password=password_hash($_POST['settings_new_password'], PASSWORD_DEFAULT);}
  2305. $redirect=$_SERVER['REQUEST_URI'];
  2306. $this->DoLogout();
  2307. }
  2308. $this->WriteConfig();
  2309. return 0;
  2310. }
  2311. if(isset($_POST['settings_save_redirect'])){
  2312. if(isset($_POST['settings_redirect'])){
  2313. $this->BuildRedirectConfig($_POST['settings_redirect']);
  2314. }
  2315. $this->WriteConfig();
  2316. $redirect = 'index.php?extras=true'; return 0;
  2317. }
  2318. if(isset($_POST['settings_save_translation'])){
  2319. if(isset($_POST['settings_translation'])){
  2320. $f = fopen("custom_translations.md", "w"); fwrite($f,$_POST['settings_translation']); fflush($f); fclose($f);
  2321. }
  2322. $redirect = 'index.php?extras=true'; return 0;
  2323. }
  2324. if(isset($_GET['post'])){
  2325. if(isset($_GET['post_original'])){
  2326. echo $this->EditPost($_GET['post'],NULL,false,NULL,true,NULL,NULL,false,NULL,NULL);
  2327. exit;
  2328. }
  2329. }
  2330. if(isset($_GET['mark_delete']) && isset($_GET['target'])){
  2331. $this->EditPost($_GET['target'],NULL,$_GET['mark_delete']=='true',NULL,false,NULL,NULL,false,NULL,NULL);
  2332. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2333. return 0;
  2334. }
  2335. if(isset($_GET['set_mark']) && isset($_GET['target'])){
  2336. $this->EditPost($_GET['target'],NULL,NULL,NULL,NULL,$_GET['set_mark'],NULL,false,NULL,NULL);
  2337. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2338. return 0;
  2339. }
  2340. if(isset($_POST['post_button']) && isset($_POST['post_content'])){
  2341. $c = $_POST['post_content'];
  2342. if('有什么想说的' == $c){ return 0;}
  2343. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2344. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2345. $reply_to = (isset($_POST['post_reply_to'])&&$_POST['post_reply_to']!="")?$_POST['post_reply_to']:NULL;
  2346. $edit_id = (isset($_POST['post_edit_target'])&&$_POST['post_edit_target']!="")?$_POST['post_edit_target']:NULL;
  2347. $push_history = (isset($edit_id) && isset($_POST['post_record_edit']));
  2348. if(($edited = $this->EditPost($edit_id, $c, NULL, $reply_to,NULL,NULL,NULL,$push_history,NULL,NULL))!=NULL){
  2349. $redirect='?post='.$edited['id']; return 0;
  2350. };
  2351. }
  2352. if(isset($_POST['post_rename_confirm']) && isset($_POST['post_rename_name']) && isset($_GET['rename_post'])){
  2353. if(($edited =$this->EditPost($_GET['rename_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,NULL))!=NULL){
  2354. $redirect='?post='.$edited['id']; return 0;
  2355. };
  2356. }
  2357. if(isset($_POST['post_mastodon_confirm']) && isset($_POST['post_mastodon_url']) && isset($_GET['mastodon_post'])){
  2358. if(($edited =$this->EditPost(
  2359. $_GET['mastodon_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,$_POST['post_mastodon_url']))!=NULL){
  2360. $redirect='?post='.$edited['id']; return 0;
  2361. };
  2362. }
  2363. if(isset($_GET['mastodon_send_post']) && preg_match('/([0-9]{14})/u',$_GET['mastodon_send_post'],$m)){
  2364. $this->ReadImages(); $this->ReadPosts(); $post = &$this->GetPost($m[1]); $err=$this->T("未知错误");
  2365. if(isset($post)){
  2366. if($mastodon_url = $this->MastodonSendPost($post, $err)){
  2367. $this->NeedWritePosts = 1; $this->WritePosts(); // for mastodon url
  2368. echo "SUCCESS ".$mastodon_url;
  2369. }else{ echo $err; }
  2370. } exit;
  2371. }
  2372. if(isset($_GET['merge_threads'])&&$_GET['merge_threads']!=""){
  2373. if(preg_match('/([0-9]{14})\s+([0-9]{14})/u',$_GET['merge_threads'],$m)){
  2374. if(($pe = &$this->MergeThreads($m[1],$m[2]))!=$this->NULL_POST){ $redirect='?post='.$pe['id']; return 0; }
  2375. }
  2376. }
  2377. if(isset($_GET['merge_posts'])&&$_GET['merge_posts']!=""){
  2378. if(($pe = &$this->MergePosts($_GET['merge_posts']))!=$this->NULL_POST){
  2379. $redirect='?post='.$pe['id']; return 0;
  2380. }
  2381. }
  2382. if ($this->CommentEnabled && isset($_POST['comment_confirm']) && (isset($_GET['comment_to']))
  2383. && isset($_POST['comment_box']) && isset($_POST['comment_email']) && isset($_POST['comment_name'])){
  2384. $c = $_POST['comment_box'];
  2385. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2386. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2387. $comment_to = ($_GET['comment_to']!="")?$_GET['comment_to']:NULL;
  2388. if(($edited = $this->EditComment(NULL,
  2389. $_GET['comment_to'], $c, $_POST['comment_email'], $_POST['comment_name'],
  2390. isset($_POST['comment_link'])?$_POST['comment_link']:NULL,
  2391. $_SERVER['REMOTE_ADDR']))!=NULL){
  2392. $redirect='?post='.$_GET['post'];
  2393. return 0;
  2394. };
  2395. }
  2396. if(isset($_POST['gallery_edit_confirm']) && isset($_POST['gallery_edit_new_name']) && $_POST['gallery_edit_new_name']!=''){
  2397. $old_name = isset($_POST['gallery_edit_old_name'])?$_POST['gallery_edit_old_name']:"";
  2398. $new_name = $_POST['gallery_edit_new_name'];
  2399. if($old_name!=''){
  2400. $this->EditGallery($old_name, $new_name, false, true, null, null);
  2401. $redirect='?gallery='.$new_name;
  2402. }else{
  2403. $this->EditGallery(null, $new_name, false, true, null);
  2404. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2405. }
  2406. return 0;
  2407. }
  2408. if(isset($_GET['gallery_edit_delete'])&&$_GET['gallery_edit_delete']!=null){
  2409. $this->EditGallery($_GET['gallery_edit_delete'], null, true, true, null, null);
  2410. if(isset($_GET['gallery'])) $redirect='?gallery=main'; else $redirect='index.php';
  2411. return 0;
  2412. }
  2413. if(isset($_POST['gallery_move_ops'])&&isset($_POST['gallery_move_ops'])){
  2414. if(preg_match('/^(REM|ADD)\s+(\S+)\s+(.*)$/u', $_POST['gallery_move_ops'], $ma)){
  2415. $this->ReadImages();
  2416. if(preg_match_all('/(\S+)/u', $ma[3], $files, PREG_SET_ORDER)) foreach($files as $name){
  2417. $this->EditImage($name[1], $ma[2], ($ma[1]=='REM'), NULL, NULL, NULL);
  2418. }
  2419. }
  2420. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2421. return 0;
  2422. }
  2423. if(isset($_GET['gallery_set_featured'])&&isset($_GET['value'])){
  2424. $this->EditGallery($_GET['gallery_set_featured'], null, false, true, $_GET['value']!='false', null);
  2425. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2426. return 0;
  2427. }
  2428. if(isset($_GET['gallery_set_experimental'])&&isset($_GET['value'])){
  2429. $this->EditGallery($_GET['gallery_set_experimental'], null, false, true, null, $_GET['value']!='false');
  2430. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2431. return 0;
  2432. }
  2433. if(isset($_GET['image_list'])&&$_GET['image_list']!=""){
  2434. $this->ReadImages();
  2435. $gallery = $_GET['image_list'];
  2436. foreach($this->Images as $im){
  2437. if($gallery=='main'){ echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; continue; }
  2438. if(isset($im['galleries']) && isset($im['galleries'][0]) && in_array($gallery,$im['galleries'])) {
  2439. echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; }
  2440. }
  2441. exit;
  2442. }
  2443. $do_image_redirect = 0;
  2444. if (isset($_POST['image_button']) && isset($_GET['pic']) &&
  2445. preg_match('/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4))/u',$_GET['pic'],$ma)){
  2446. $this->ReadImages(); $pic = $ma[1]; $picext=$ma[2];
  2447. if(isset($_POST['image_ops_product_link'])){
  2448. $this->EditImage($pic, NULL, false, $_POST['image_ops_product_link'], NULL, NULL);
  2449. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2450. }
  2451. if(isset($_POST['image_edit_new_name']) && preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_edit_new_name'],$man)){
  2452. $this->EditImage($pic, NULL, false, NULL, $man[1], NULL);
  2453. $redirect=$this->GetRedirect(['pic'=>'images/'.$man[1].'.'.$picext]);
  2454. $do_image_redirect = 1;
  2455. }
  2456. if(isset($_POST['image_parent'])){ $parent="";
  2457. if(preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_parent'],$man)){ $parent = $man[1]; }
  2458. $this->EditImage($pic, NULL, false, NULL, NULL, $parent);
  2459. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2460. }
  2461. $this->NeedWriteImages = 1;
  2462. if($do_image_redirect) return 0;
  2463. }
  2464. if(isset($_GET['rewrite_styles'])){
  2465. $this->WriteStyles();
  2466. $redirect='?extras=true'; return 0;
  2467. }
  2468. if(isset($_GET['regenerate_thumbnails'])){
  2469. $this->RegenerateThumbnails();
  2470. $redirect='?extras=true'; return 0;
  2471. }
  2472. if(isset($_GET['clear_all_logins'])){
  2473. $this->LoginTokens=[];
  2474. $this->WriteTokens();
  2475. }
  2476. }
  2477. return 0;
  2478. }
  2479. function PostProcessHTML($html,&$added_images=null,$do_product_info=false, &$product_info=null, &$orig_src_list=null, &$end_wide=null, &$print_wide=null){
  2480. if(!$this->LoggedIn){
  2481. $html = preg_replace("/(<a[^>]*href=[\'\"])(.*?)([\'\"][^>]*)>(\#.*?<\/a>)/u","",$html);
  2482. }
  2483. $html = preg_replace("/(<a[^>]*href=[\'\"])([0-9]{14})([\'\"][^>]*)>(.*?<\/a>)/u","$1?post=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2484. $html = preg_replace("/(<a[^>]*href=[\'\"])\@(.*?)([\'\"][^>]*)>(.*?<\/a>)/u","$1?category=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2485. $html = preg_replace("/(<a[^>]*href=[\'\"])((.*?:\/\/).*?)([\'\"][^>]*)(>)(.*?)(<\/a>)/u",
  2486. "$1$2$4 target='_blank'$5$6<sup>↗</sup>$7",$html);
  2487. $html = preg_replace("/<p>\s*\@.*?<\/p>/mu","",$html);
  2488. $html = preg_replace("/\{\s*(INTERESTING|HEADER|FOOTER)\s+(.*?)\}/imu","",$html);
  2489. $html = preg_replace("/\{\s*(REVERSED|NO_TIME)\s*\}/imu","",$html);
  2490. $html = preg_replace("/\{\s*WIDE\s*\}/imu","",$html,-1,$rep_count); if($rep_count){$print_wide=true;}
  2491. $images = []; $images_noclick = []; $images_orig_src_list = [];
  2492. $html = preg_replace_callback(
  2493. "/(<p>\s*)?(<img([^>]*)src=[\'\"])(images\/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4)))([\'\"][^>]*)\/>(\s*<\/p>)?/u",
  2494. function($m) use (&$images,&$images_noclick,&$images_orig_src_list) {
  2495. $orig_src = $src = $m[5]; $keep = false; $original = false;
  2496. if (preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[3]) ||
  2497. preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[7])) { $keep=true; }
  2498. if ($keep && preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[3]) ||
  2499. preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[7])) { $original=true; }
  2500. if(($im = &$this->FindImage($m[5]))!=NULL && isset($im['thumb'])){
  2501. $src = $im['thumb']; $orig_src=$im['file'];
  2502. }if($im == NULL){ $im = &$this->NULL_IMAGE_DUMMY; }
  2503. $media_start = $m[2];
  2504. $media_end = $m[7];
  2505. $dataset = " data-imgsrc='".$m[5]."'".
  2506. (isset($im['product'])?" data-product='".$im['product']."'":"").
  2507. (isset($im['parent'])?" data-parent='".$im['parent']."'":"").
  2508. ($original?" class='original_img'":"");
  2509. if(isset($im['video']) && isset($im['video'])!=''){
  2510. $media_start = "<video controls".$dataset."><source src='"; $media_end="' type='".$im['video']."'></video";
  2511. $src = $orig_src; $dataset="";
  2512. }
  2513. if($this->InHereMode){
  2514. $click = "<div class='imd'>"."<a href='?here=".$im['file']."' class='original_img'>".
  2515. $media_start.$orig_src.$media_end."></a></div>";
  2516. return $click;
  2517. }else{
  2518. $click ="<div class='imd'><a href='?show_image={$im['name']}' target='_blank' onclick='event.preventDefault();'>".
  2519. $media_start.($original?$orig_src:$src).$media_end.$dataset."></a></div>";
  2520. $images_noclick[]=$media_start.$src.$media_end.">"; $images_orig_src_list[]=$orig_src;
  2521. $ret = "";
  2522. if($keep) { $ret = $click; }
  2523. else { $images[] = $click; }
  2524. if(isset($m[1])&&isset($m[8])&&$m[1]&&$m[8]) return $ret;
  2525. else return ((isset($m[1])&&$m[1]?$m[1]:"").$ret.(isset($m[8])&&$m[8]?$m[8]:""));
  2526. }
  2527. },$html,-1,$count);
  2528. $html = preg_replace('/<p>\s*<\/p>/u',"", $html); if($html==""){$html="<p>&nbsp;</p>";}
  2529. if(sizeof($images)){
  2530. if(sizeof($images)==1){$html.= $images[0]; }
  2531. else{
  2532. $html.="<div class='p_row'>";
  2533. foreach($images as $img){
  2534. $html.="<div class='p_thumb'>".$img."</div>";
  2535. }
  2536. $html.="<div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div>";
  2537. }
  2538. }
  2539. if(sizeof($images_noclick)){ $added_images = $images_noclick; }
  2540. if(sizeof($images_orig_src_list)) { $orig_src_list = $images_orig_src_list; }
  2541. if($do_product_info){
  2542. $html = preg_replace_callback("/\{PRICE\s+([^]]+?)\}/u",
  2543. function($m) use (&$product_info) { $product_info['price']=$m[1];return ""; },$html);
  2544. $html = preg_replace_callback("/\{SHORT\s+([^]]+?)\}/u",
  2545. function($m) use (&$product_info) { $product_info['short']=$m[1];return ""; },$html);
  2546. $html = preg_replace('/<p>\s*<\/p>/u',"", $html);
  2547. if (preg_match('/<h[1-5]>(.+?)<\/h/u',$html,$title)){ $product_info['title']=$title[1]; }
  2548. else { $product_info['title'] = $this->T('商品'); }
  2549. if(!isset($product_info['price'])) $product_info['price']=$this->T('未设置价格');
  2550. $html = preg_replace_callback("/\{PURCHASE\s+([^]]+?)\}/u",function($m) use (&$product_info) {
  2551. return "<a class='purchase_button' href=\"mailto:".$this->T($this->DisplayName)."<".$this->EMail.">?subject=".
  2552. $this->T('购买').' '.$product_info['title'].
  2553. "&body=".$this->T('你好!我想购买').$product_info['title'].urlencode(PHP_EOL.PHP_EOL).
  2554. $this->FullURL().urlencode(PHP_EOL.PHP_EOL)."\">".$m[1]."</a>"; },$html);
  2555. }
  2556. if(preg_match("/(<\/div>|<\/table>|<\/video>)\s*$/u",$html)){$end_wide=true;}
  2557. return $html;
  2558. }
  2559. function ConvertPost(&$post){
  2560. if(!isset($post['html'])){
  2561. $info=[];
  2562. $post['html'] = $this->TranslatePostParts($this->PostProcessHTML($this->ChoosePartsByLanguage($this->PDE->text($this->InsertReplacementSymbols($post['content'], $post)),true),
  2563. $post['images'],
  2564. isset($post['product']), $info,
  2565. $post['original_images'],
  2566. $post['end_wide'],
  2567. $post['wide']));
  2568. if(isset($post['product'])) $post['product']=$info;
  2569. }
  2570. }
  2571. function GetPostTitle(&$post, $h1_only=false, $add_unamed=true){
  2572. if(!isset($post['title'])){
  2573. if($h1_only){
  2574. if(preg_match('/^#\s+(.*?)$/mu',$post['content'],$m)){return $m[1];}
  2575. return NULL;
  2576. }
  2577. if(preg_match('/^#{1,6}\s+(.*?)$/mu',$post['content'],$m)){$post['title']=$m[1];}
  2578. else{ $post['title'] = $add_unamed?$this->T('未命名'):"";
  2579. if(preg_match('/(.*)$/mu',$post['content'],$m)){
  2580. $post['title'].=($add_unamed?' (':'').strip_tags($this->PDE->text($m[1])).($add_unamed?')':''); }
  2581. }
  2582. }
  2583. return $this->ChoosePartsByLanguage($post['title']);
  2584. }
  2585. function DetectPageType(){
  2586. if ($this->InExperimentalMode) $this->PageType='experimental';
  2587. else if($this->InHereMode) $this->PageType='here';
  2588. else if(isset($_GET['history'])) $this->PageType='history';
  2589. else if(isset($_GET['extras'])) $this->PageType='extras';
  2590. else if(isset($_GET['settings'])) $this->PageType='settings';
  2591. else if(isset($_GET['gallery'])) $this->PageType='gallery';
  2592. else if(isset($_GET['search'])) $this->PageType='search';
  2593. else if(isset($_GET['category'])) $this->PageType='category';
  2594. else if(isset($this->CurrentPostID)) $this->PageType = "post";
  2595. else if(isset($_GET['comments'])) $this->PageType='comments';
  2596. else $this->PageType = "main";
  2597. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  2598. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  2599. $this->VisitedHere = $_SESSION[$visited_here];
  2600. }
  2601. function MakePageBegin(){ ?>
  2602. <!DOCTYPE html><html lang='zh-Hans-CN'>
  2603. <head>
  2604. <meta charset='utf-8'>
  2605. <meta content="width=device-width, initial-scale=1" name="viewport">
  2606. <title><?=$this->InExperimentalMode?$this->T($this->ExpTitle):
  2607. ($this->InHereMode?$this->T($this->HereTitle):$this->T($this->Title))?></title>
  2608. <?php if($this->UseRemoteFont){ ?><style>
  2609. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Regular.otf") format("opentype");font-weight:normal;}
  2610. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Bold.otf") format("opentype");font-weight:bold;}
  2611. </style><?php } ?>
  2612. <link href='styles/main.css' rel='stylesheet' type="text/css">
  2613. <link rel="alternate" type="application/rss+xml" title="<?=$this->T($this->Title);?>" href="?rss=<?=$this->LanguageAppendix;?>" />
  2614. <?php if(isset($this->SelfAuthPath)&&$this->SelfAuthPath!=""){ ?>
  2615. <link rel="authorization_endpoint" href="<?=$this->SelfAuthPath?>" /><?php } ?>
  2616. </head>
  2617. <div class='page'>
  2618. <?php }
  2619. function MakeHeader(&$p){
  2620. $this->MakePageBegin() ?>
  2621. <script type='text/javascript'>
  2622. function toggle_mobile_show(a){a.classList.toggle('hidden_on_mobile')}
  2623. function ShowWaitingBar(){
  2624. wait = document.querySelector("#waiting_bar");
  2625. wait.style.display='';
  2626. }
  2627. function HideWaitingBar(){
  2628. wait = document.querySelector("#waiting_bar");
  2629. wait.style.display='none';
  2630. }
  2631. <?php if(!$this->InHereMode){ ?>
  2632. function la_auto_grow(element){
  2633. s=window.scrollY;element.style.height="30px";element.style.height=(element.scrollHeight)+"px";window.scroll(0, s);
  2634. }
  2635. var scroll_l=0,scroll_c=0;in_center=1;
  2636. function ShowLeftSide(){
  2637. scroll_c = window.scrollY;
  2638. document.getElementById('div_left').classList.remove('hidden_on_mobile');
  2639. document.getElementById('div_center').classList.add('hidden_on_mobile');
  2640. window.scroll(0, scroll_l); in_center=0;
  2641. }
  2642. function ShowCenterSide(){
  2643. scroll_l = window.scrollY;
  2644. document.getElementById('div_center').classList.remove('hidden_on_mobile');
  2645. document.getElementById('div_left').classList.add('hidden_on_mobile');
  2646. window.scroll(0, scroll_c); in_center=1;
  2647. }
  2648. function ShowBackdrop(alpha=0.5){
  2649. b = document.getElementById('backdrop');
  2650. b.style="background-color:rgba(0,0,0,"+alpha+");";
  2651. b.style.animation='backdrop_fade_in 0.3s forwards';
  2652. b.style.display = 'block';
  2653. }
  2654. function HideBackdrop(){
  2655. b = document.getElementById('backdrop');
  2656. b.style.animation='backdrop_fade_out 0.3s forwards';
  2657. setTimeout(function(e1){e1.style.display='none';}, 300, b);
  2658. }
  2659. function ShowRightSide(big,elem_to_clone){
  2660. p = document.getElementById('pop_right');
  2661. if(elem_to_clone){
  2662. c = elem_to_clone.cloneNode(true);
  2663. c.id='side_bar_cloned';c.className="";c.style="";
  2664. p.querySelector('._content').appendChild(c);
  2665. }
  2666. p.classList.remove('pop_right','pop_right_big');
  2667. if(big) {p.classList.add('pop_right_big');p.style.animation='pop_slide_in_big 0.3s forwards';}
  2668. else {p.classList.add('pop_right');p.style.animation='pop_slide_in 0.3s forwards';}
  2669. p.style.display='block';
  2670. ShowBackdrop(0.5);
  2671. }
  2672. function HideRightSide(){
  2673. p = document.getElementById('pop_right');
  2674. if(side=p.querySelector('#side_bar_cloned')){
  2675. side.remove();
  2676. }
  2677. put = document.querySelector("#_uploader");
  2678. if(p.classList.contains('pop_right')){p.style.animation='pop_slide_out 0.3s forwards';}
  2679. else{p.style.animation='pop_slide_out_big 0.3s forwards';}
  2680. setTimeout(function(e1, e2){e1.style.display='none';if(e2)e2.style.display='none';}, 300, p, put);
  2681. HideBackdrop();
  2682. }
  2683. function ToggleLeftSide(){if(in_center)ShowLeftSide();else ShowCenterSide();}
  2684. function CssNumberID(id){ return "#\\3"+id.substr(0,1)+" "+id.substr(1); }
  2685. function ScrollToPost(id){
  2686. post=null;
  2687. if(!(post = document.querySelector("[data-post-id='"+id+"']"))){
  2688. if(!(post = document.querySelector(CssNumberID(id)))) return; }
  2689. post.scrollIntoView({ behavior: 'smooth', block: 'start'});
  2690. }
  2691. <?php } ?>
  2692. </script>
  2693. <header<?=$this->InHereMode?' class="exp_h_f"':''?>><div>
  2694. <?php if($this->InHereMode){
  2695. $this->MakeExpNavButtons($p);
  2696. }else{
  2697. $this->MakeNavButtons($p);
  2698. if(isset($p['tid']['header'])){ ?><div style='float:right' class='show_on_print'><?=$p['tid']['header'];?></div><?php }
  2699. echo "<hr />";
  2700. } ?>
  2701. <?php if(isset($this->WayBack)){
  2702. $time=(isset($_COOKIE['la_wayback']) && preg_match('/[0-9]{14}/u',$_COOKIE['la_wayback']))?$_COOKIE['la_wayback']:date('YmdHis');
  2703. $year=substr($time,0,4);$month=substr($time,4,2);$day=substr($time,6,2);
  2704. $hour=substr($time,8,2);$minute=substr($time,10,2);?> <div class='text_highlight'>
  2705. &nbsp;<b><span onclick='document.getElementById("wayback_config").classList.toggle("hidden_on_mobile")'>
  2706. <div class='wayback_close' onclick='event.stopPropagation()'><a href='<?=$this->GetRedirect()?>&set_wayback=false'>
  2707. <span class='hidden_on_mobile'><?=$this->T('退出')?></span>×&nbsp;</a></div>
  2708. <?=$this->T('正以过去的日期浏览')?></b><div id='wayback_config' class='wayback_expand hidden_on_mobile'>
  2709. <select id="wayback_year" name="wayback_year" form="wayback_form"><?php for($y=$this->YearBegin;$y<=$this->YearEnd;$y++){ ?>
  2710. <option value="<?=$y?>"<?=$y==$year?" selected":""?>><?=$y?></option><?php } ?></select>
  2711. <br class='hidden_on_desktop' />
  2712. <select id="wayback_month" name="wayback_month" form="wayback_form"><?php for($y=1;$y<=12;$y++){ ?>
  2713. <option value="<?=$y?>"<?=$y==$month?" selected":""?>><?=$y?></option><?php } ?></select>
  2714. <select id="wayback_day" name="wayback_day" form="wayback_form"><?php for($y=1;$y<=31;$y++){ ?>
  2715. <option value="<?=$y?>"<?=$y==$day?" selected":""?>><?=$y?></option><?php } ?></select>
  2716. <br class='hidden_on_desktop' />
  2717. <select id="wayback_hour" name="wayback_hour" form="wayback_form"><?php for($y=0;$y<=23;$y++){ ?>
  2718. <option value="<?=$y?>"<?=$y==$hour?" selected":""?>><?=$y?></option><?php } ?></select>:
  2719. <select id="wayback_minute" name="wayback_minute" form="wayback_form"><?php for($y=0;$y<=59;$y++){ ?>
  2720. <option value="<?=$y?>"<?=$y==$minute?" selected":""?>><?=$y?></option><?php } ?></select>
  2721. <br class='hidden_on_desktop' />
  2722. <form action="<?=$this->GetRedirect()?>&set_wayback=post" method="post" style='display:none;' id='wayback_form'></form>
  2723. <input type='submit' style='font-weight:normal;border-bottom:none;' class='button clean_a' form='wayback_form'
  2724. id='wayback_see' name='wayback_see' value="<?=$this->T('查看')?> →">
  2725. </div></div><?php } ?>
  2726. </div></header>
  2727. <div id='waiting_bar' style='display:none;'></div>
  2728. <script>ShowWaitingBar();window.addEventListener('load',(event) =>{HideWaitingBar();}); </script>
  2729. <?php if(!$this->InHereMode){ ?>
  2730. <div id='post_menu' style='display:none;' class='pop_menu clean_a'>
  2731. <ul>
  2732. <li><span id='_time_hook' class='smaller'>时间</span>&nbsp;&nbsp;<a href='javascript:HidePopMenu();'>×</a></li>
  2733. <li><a id='share_copy'>⎘<?=$this->T('复制链接')?></a></li>
  2734. <hr />
  2735. <?php if($this->LoggedIn){ ?>
  2736. <li><a id='menu_history'><?=$this->T('历史')?></a>
  2737. <?php if(!isset($this->WayBack) && $this->PageType!='search'){ ?>
  2738. | <a id='menu_edit'><?=$this->T('修改')?></a><?php } ?></li>
  2739. <?php if(!isset($this->WayBack)){ ?><li>
  2740. <a id='menu_refer_copy'><?=$this->T('复制编号')?></a><?php if($this->PageType!='search'){ ?>
  2741. | <a id='menu_refer'><?=$this->T('引用')?></a><?php } ?><br class='hidden_on_desktop' />
  2742. </li>
  2743. <li><a id='menu_rename' href='javascript:ToggleRenameDetails()'><?=$this->T('改名')?></a> |
  2744. <a id='menu_mark' href='javascript:ToggleMarkDetails()'><?=$this->T('标记')?></a></li>
  2745. <li id='mark_details' style='display:none;'><b>
  2746. <a id='mark_set_clear' href='javascript:SetMark(-1);'>_</a>
  2747. <a id='mark_set_0' href='javascript:SetMark(0);'><?=$this->Markers[0]?></a>
  2748. <a id='mark_set_1' href='javascript:SetMark(1);'><?=$this->Markers[1]?></a>
  2749. <a id='mark_set_2' href='javascript:SetMark(2);'><?=$this->Markers[2]?></a>
  2750. <a id='mark_set_3' href='javascript:SetMark(3);'><?=$this->Markers[3]?></a>
  2751. <a id='mark_set_4' href='javascript:SetMark(4);'><?=$this->Markers[4]?></a>
  2752. <a id='mark_set_5' href='javascript:SetMark(5);'><?=$this->Markers[5]?></a>
  2753. <a id='mark_set_6' href='javascript:SetMark(6);'><?=$this->Markers[6]?></a>
  2754. <a id='mark_set_7' href='javascript:SetMark(7);'><?=$this->Markers[7]?></a>
  2755. </b></li>
  2756. <li id='rename_details' style='display:none;text-align:left;' class='smaller'>
  2757. <form action="" method="post" style='display:none;' id='post_rename_form'></form>
  2758. <input type='text' id='post_rename_name' name='post_rename_name' form="post_rename_form" style='width:9em;'>
  2759. <input class='button' type='submit' form='post_rename_form'
  2760. name='post_rename_confirm' id='post_rename_confirm' value='<?=$this->T('确认')?>'>
  2761. </li><hr /> <?php if(isset($this->MastodonToken)){ ?>
  2762. <li><a id='menu_mastodon_view' class='button' style='display:none;' target='_blank'><?=$this->T('转到')?></a>
  2763. <a id='menu_mastodon' href='javascript:ToggleMastodonDetails()'><?=$this->T('长毛象')?></a></li>
  2764. <li id='mastodon_details' style='display:none;text-align:left;' class='smaller'>
  2765. <a id='menu_mastodon_send' class='button' target='_blank'><?=$this->T('发送')?></a>
  2766. <form action="" method="post" style='display:none;' id='post_mastodon_form'></form>
  2767. <input type='text' id='post_mastodon_url' name='post_mastodon_url' form="post_mastodon_form" style='width:9em;'>
  2768. <input class='button' type='submit' form='post_mastodon_form'
  2769. name='post_mastodon_confirm' id='post_mastodon_confirm' value='<?=$this->T('修改')?>'></li> <?php } ?>
  2770. <hr /><li><a id='menu_delete' class='smaller'><?=$this->T('删除')?></a></li><?php } ?>
  2771. <?php }else{ ?>
  2772. <li><a id='menu_history'><?=$this->T('历史')?></a></li>
  2773. <?php } ?>
  2774. </ul>
  2775. </div>
  2776. <div id='backdrop' style='display:none;' class='backdrop' onclick='HideRightSide();HideBigImage(1);'
  2777. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"></div>
  2778. <div id='pop_right' class='pop_right' onclick='event.stopPropagation()'>
  2779. <div style='text-align:right;position:sticky;top:0;'><a class='clean_a' href='javascript:HideRightSide();'>
  2780. <?=$this->T('关闭')?>→</a></div>
  2781. <?php if($this->LoggedIn && in_array($this->PageType,['main','post'])){ ?>
  2782. <div id='_uploader' style='display:none;'>
  2783. <?php $this->MakeUploader(true); ?>
  2784. <p>&nbsp;</p>
  2785. <?php $this->MakeSideGalleryCode(); ?>
  2786. </div>
  2787. <?php } ?>
  2788. <div class='_content'></div>
  2789. </div>
  2790. <?php } ?>
  2791. <?php
  2792. }
  2793. function ChoosePartsByLanguage($content,$use_p=false){
  2794. $split = preg_split('/'.($use_p?'<p>\s*':'').'((en|zh|any)\|(en|zh|any))'.($use_p?'<\/p>\s*':'').'/u',$content, -1,
  2795. PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
  2796. $lang = $this->LanguageAppendix; $last_lang='0'; $reduced="";
  2797. if($split) for($i=0;$i<sizeof($split);$i+=4){
  2798. $this_lang = '0'; if($i+2>=sizeof($split)){ $this_lang = $last_lang; }else{ $this_lang = $split[$i+2]; }
  2799. if($this_lang==$lang || $this_lang=='any'){ $reduced.=$split[$i]; }
  2800. if($i+3<sizeof($split)){ $last_lang = $split[$i+3]; }
  2801. }
  2802. if(!$reduced)$reduced = $content;
  2803. return trim($reduced);
  2804. }
  2805. function TranslatePostParts($html){
  2806. $html = preg_replace_callback('/>([^><]+?)</u', function($ma){
  2807. $reduced = $this->ChoosePartsByLanguage($ma[1], false);
  2808. return ">".$this->T($reduced)."<";
  2809. }, $html);
  2810. return $html;
  2811. }
  2812. function MakeNavButtons(&$p){ $interesting=$this->IsInterestingPost($p); ?>
  2813. <a href='index.php' class='clean_a hidden_on_mobile' onclick='ShowWaitingBar()'><b><?=$this->T($this->Title)?></b></a>
  2814. <b><a class='hidden_on_desktop'
  2815. href='javascript:toggle_mobile_show(document.getElementById("mobile_nav"))'><?=$this->T($this->ShortTitle)?>...</a></b>
  2816. <div class='header_nav'>
  2817. <?php if($this->PageType=='post'){ ?>
  2818. <div class='toc_button hidden_on_print'>
  2819. <?php if(!$interesting && isset($p) && isset($p['refs']) && isset($p['refs'][0])){ ?>
  2820. <span class='hidden_on_desktop'><a id='button_ref' href='javascript:ToggleLeftSide();'>
  2821. <?=$this->T('链接')?>(<?=sizeof($p['refs'])?>)</a></span>
  2822. <?php } if(!$interesting){ ?>
  2823. <span class='hidden_on_wide hidden_on_print'>
  2824. <a id='button_toc' href='javascript:ShowRightSide(true,document.querySelector("#div_right"));'>
  2825. <?=$this->T('目录')?></a></span><?php } ?></div>
  2826. <?php }else if($this->PageType=='history' && isset($_GET['version'])){ ?>
  2827. <div style='float:right;' class='hidden_on_print'>
  2828. <span class='hidden_on_desktop'><a id='button_ref' href='javascript:ToggleLeftSide();'>
  2829. <?=$this->T('历史')?></a></span></div>
  2830. <?php } ?>
  2831. <ul class='hidden_on_mobile hidden_on_print' id='mobile_nav' style='text-align:center;'>
  2832. <li class='hidden_on_mobile'><a href='?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  2833. <li class='hidden_on_desktop_force block_on_mobile smaller'>&nbsp;</li>
  2834. <li class='hidden_on_desktop_force block_on_mobile'>
  2835. <?php if($this->PageType!='main'){ ?>
  2836. <a href='index.php?part=recent' onclick='ShowWaitingBar()'><?=$this->T('最近')?></a> |
  2837. <a href='index.php?part=hot' onclick='ShowWaitingBar()'><?=$this->T('热门')?></a>
  2838. <?php } else { ?>
  2839. <a href='javascript:ShowCenterSide();toggle_mobile_show(document.getElementById("mobile_nav"));'><?=$this->T('最近')?></a> |
  2840. <a href='javascript:ShowLeftSide();toggle_mobile_show(document.getElementById("mobile_nav"));'><?=$this->T('热门')?></a>
  2841. <?php } ?>
  2842. <?php if($this->LoggedIn){ ?>
  2843. | <span class='gray invert_a'><a href='index.php?comments=all'>@</a></span><?php } ?></li>
  2844. <li class='hidden_on_desktop_force block_on_mobile'>
  2845. <a href='index.php?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  2846. <?php $this->SpecialNavigation;if(isset($this->SpecialNavigation) && ($p = &$this->GetPost($this->SpecialNavigation))!=NULL){
  2847. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST);
  2848. } ?>
  2849. <li><a href='?search=' onclick='ShowWaitingBar()'><?=$this->T('搜索')?></a></li>
  2850. <li class='hidden_on_desktop_force block_on_mobile smaller'>&nbsp;</li>
  2851. <?php if($this->LanguageAppendix=='zh'){ ?>
  2852. <li class='invert_a smaller'>
  2853. <a href='<?=$this->GetRedirect().'&set_language=en'?>' onclick='ShowWaitingBar()'><b>汉语</b>/English</a></li>
  2854. <?php }else { ?>
  2855. <li class='smaller'>
  2856. <a class='invert_a' href='<?=$this->GetRedirect().'&set_language=zh'?>' onclick='ShowWaitingBar()'>
  2857. 汉语/<b>English</b></a>
  2858. <br class='hidden_on_desktop' />
  2859. <a id='translate_button' target='_blank'>&nbsp;[Google Translate]&nbsp;</a></li>
  2860. <?php } ?>
  2861. </ul>
  2862. </div>
  2863. <?php
  2864. }
  2865. function MakeExpNavButtons(&$p){ ?>
  2866. <a href='index.php' class='hidden_on_mobile'>
  2867. <b><?=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle)?></b></a>
  2868. <a class='hidden_on_desktop'
  2869. href='javascript:toggle_mobile_show(document.getElementById("mobile_nav"))'><b class='round_btn'>
  2870. <?=$this->InExperimentalMode?$this->T($this->ExpShortTitle):$this->T($this->HereShortTitle)?></b></a>
  2871. <a <?=$this->HereNumber==1?"class='gray'":("href=".$this->HereLinkFromNumber($this->HereNumber-1))?>>←</a>
  2872. <span><?=$this->HereNumber.'/'.sizeof($this->VisitedHere);?></span>
  2873. <span class='round_btn'>
  2874. <a href='<?=$this->HereNumber==sizeof($this->VisitedHere)?"?random_here=1":$this->HereLinkFromNumber($this->HereNumber+1);?>'>→</a>
  2875. <a href='?random_here=1'><?=$this->T("随机")?></a></span><span class='hidden_on_mobile'></span>
  2876. <ul class='hidden_on_mobile invert_a gray' id='mobile_nav' style='text-align:center;'>
  2877. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  2878. <li class='hidden_on_desktop block_on_mobile'><a href='index.php'><?=$this->T('主页')?></a></li>
  2879. <?php if($this->InExperimentalMode && isset($this->ExpNavigation) && ($p = &$this->GetPost($this->ExpNavigation))!=NULL){
  2880. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST);
  2881. }else if($this->InHereMode && isset($this->HereNavigation) && ($p = &$this->GetPost($this->HereNavigation))!=NULL){
  2882. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST);
  2883. } ?>
  2884. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  2885. <?php if($this->LanguageAppendix=='zh'){ ?>
  2886. <li class='smaller'><a href='<?=$this->GetRedirect().'&set_language=en'?>'><b>汉语</b>/English</a></li>
  2887. <?php }else { ?>
  2888. <li class='smaller'><a href='<?=$this->GetRedirect().'&set_language=zh'?>'>汉语/<b>English</b></a></li>
  2889. <li class='smaller'><a id='translate_button' target='_blank'>&nbsp;Google Translate&nbsp;</a></li>
  2890. <?php } ?>
  2891. </ul>
  2892. <?php
  2893. }
  2894. function GenerateLinkedPosts($ht){
  2895. $ht = preg_replace_callback('/<p>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>(.*)<\/a>[\s]*<\/p>/u',
  2896. function($m){
  2897. $rp = &$this->GetPost($m[1], false, true);
  2898. $s="<div class='smaller block post ref_compact gray'>".
  2899. "<a href='?post=".$m[1]."' class='post_access invert_a smaller' onclick='ShowWaitingBar()'>→</a>".
  2900. "<div class='post_ref'><div class='smaller'>".$m[2]."</div>".
  2901. (($rp!==NULL && $this->CanShowPost($rp))?
  2902. $this->GenerateSinglePost($rp,false,false,false,true,$this->NULL_POST,true):$this->T("未找到该引用。")).
  2903. "</div></div>";
  2904. return $s;
  2905. },
  2906. $ht
  2907. );
  2908. $ht = preg_replace_callback('/<li>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>PRODUCT\s+(.*)<\/a>[\s]*<\/li>/u',
  2909. function($m){
  2910. $rp = &$this->GetPost($m[1], false, true);
  2911. $s="<div class='product_ref block post ref_compact'><a href='?post=".$m[1]."' class='clean_a' onclick='ShowWaitingBar()'>".
  2912. (($rp!==NULL && $this->CanShowPost($rp))?
  2913. $this->GenerateSinglePost($rp,true,false,false,true,$this->NULL_POST,true):$this->T("未找到该引用。")).
  2914. "</a></div>";
  2915. return $s;
  2916. },
  2917. $ht
  2918. );
  2919. return $ht;
  2920. }
  2921. function ExtractBigTables($html, &$table_out){
  2922. $table = NULL;
  2923. $new_html = preg_replace_callback('/<p>\s*\{big_table\}\s*<\/p>\s*(<table>[\s\S]*?<\/table>)/u', function ($m) use (&$table){
  2924. $table = $m[1];
  2925. return "";
  2926. }, $html);
  2927. $table_out = $table;
  2928. return $new_html;
  2929. }
  2930. function GenerateSinglePost(&$post, $strip_tags, $generate_anchor=false, $generate_refs=false,
  2931. $generate_thumbs=false, &$table_out, $hide_long = false){
  2932. $this->ConvertPost($post);
  2933. if($generate_anchor){ $this->CreatePostAnchor($post); }
  2934. $ht = $post['html'];
  2935. if(isset($post['mark_value']) && $post['mark_value']==5 && ($generate_thumbs || !$generate_anchor)){
  2936. $ht="<div class='product_thumb'>".$post['images'][0]."</div>".
  2937. "<p class='bold'>".$post['product']['title']."</p>".
  2938. (isset($post['product']['short'])?("<p class='smaller gray'>".$post['product']['short']."</p>"):"").
  2939. "<p class='smaller bold'>".$post['product']['price']."</p>";
  2940. return $ht;
  2941. }
  2942. if($hide_long){
  2943. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>[\s\S]*/u',"<p class='smaller bold'>[".$this->T("阅读更多")."]</p>", $ht);
  2944. }else{
  2945. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>/u',"", $ht);
  2946. }
  2947. if ($strip_tags){
  2948. $ht = strip_tags($ht,'<b><i><h1><h2><h3><h4><p><blockquote><span>');
  2949. $ht = preg_replace('/<p>\s*<\/p>/u',"", $ht);
  2950. $ht = "<div class='post_ref_main'>".$ht."</div>";
  2951. }
  2952. else{
  2953. if($generate_refs) $ht = $this->GenerateLinkedPosts($ht);
  2954. if($table_out!=$this->NULL_POST){
  2955. $table = NULL; $ht = $this->ExtractBigTables($ht,$table);
  2956. $table_out = $table;
  2957. }else{
  2958. $ht = preg_replace('/<p>\s*\{big_table\}\s*<\/p>/u','',$ht);
  2959. }
  2960. }
  2961. if ($strip_tags && $generate_thumbs && isset($post['images']) && isset($post['images'][0])){
  2962. $ht.="<div class='post_ref_images'><ul class='side_thumb ref_thumb'>";
  2963. foreach($post['images'] as $im){
  2964. $ht.="<li class='file_thumb'>".$im."</li>";
  2965. }
  2966. $ht.="</ul></div>";
  2967. }
  2968. return $ht;
  2969. }
  2970. function MakeSinglePostExp(&$post){
  2971. $big_table = ""; ?>
  2972. <li class='post post_dummy'>
  2973. <?=$this->GenerateSinglePost($post, false, false, true, false, $big_table, false); ?>
  2974. </li>
  2975. <?php if($big_table!=$this->NULL_POST) echo "</ul></li><div class='table_top'>".$big_table.'</div>';?>
  2976. <?php
  2977. }
  2978. function MakeSinglePost(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
  2979. $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
  2980. $generate_thumb = false, $is_top = false, $force_hide_long=false){
  2981. $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
  2982. $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
  2983. $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
  2984. $big_table = ($show_thread_link)?$this->NULL_POST:"";
  2985. $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
  2986. $title = $generate_anchor?$this->GetPostTitle($post, true):NULL;
  2987. $this->ConvertPost($post);// NEEDED FOR WIDE;
  2988. $is_wide = (isset($post['wide'])&&$post['wide']) || (isset($post['tid']) && isset($post['tid']['wide']) && $post['tid']['wide']);
  2989. ?>
  2990. <?=$title?"<li class='print_title'><h1>".$title."</h1></li>":""?>
  2991. <li class='post<?=isset($extra_class_string)?' '.$extra_class_string:''?><?=$side?" post_box":""?>'
  2992. <?=(!$side)?"data-post-id='".$post['id']."'":""?> <?=$is_deleted?"data-mark-delete='true'":""?>
  2993. <?=(!$side&&isset($post['mastodon_url']))?"data-mastodon_url='".$post['mastodon_url']."'":""?>
  2994. <?=$is_wide?" style='column-span:all;'":"";?>>
  2995. <?php if($mark_value>=0 && !$show_link && $mark_value!='P'){?>
  2996. <div class='smaller <?=$is_deleted?"gray":""?>'><?=$mark_value?> <?=$this->T('标记')?></div>
  2997. <?php } ?>
  2998. <?php if($is_top){?>
  2999. <div class='top_post_hint'><?=$this->T('置顶帖子')?><hr /></div>
  3000. <?php } ?>
  3001. <?php if(!$side && $show_link){ ?>
  3002. <a href='?post=<?=$post['id']?>' onclick='ShowWaitingBar()'>
  3003. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  3004. <?=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:($ref_count?"":"→")?>
  3005. </div>
  3006. <?php if($ref_count){ ?>
  3007. <div class='post_access ref_count'><?=$ref_count?></div>
  3008. <?php } ?>
  3009. </a>
  3010. <?php } ?>
  3011. <?=$side?"<a href='?post={$post['id']}' onclick='ShowWaitingBar()'>":""?>
  3012. <div class='<?=$side?"":($show_link?'post_width':'post_width_big')?><?=$is_deleted?" deleted_post":""?>'>
  3013. <?php if(!$side && !$strip_tags){?>
  3014. <div class='post_menu_button _menu_hook' >+</div>
  3015. <?php } if($is_product&&!$generate_anchor){
  3016. echo "<p class='smaller gray'>".$this->T('商品')."</p>";
  3017. echo "<div class='product_ref clean_a'><a href='?post={$post['id']}'>";} ?>
  3018. <?=$this->GenerateSinglePost($post, $strip_tags, $generate_anchor, true,
  3019. $generate_thumb,$big_table,($show_thread_link||$side||$force_hide_long)); ?>
  3020. <?php if($is_product&&!$generate_anchor){echo "</a></div>";} ?>
  3021. </div>
  3022. <?=$side?"</a>":""?> <?php
  3023. if(!$show_thread_link && $big_table!=$this->NULL_POST && !$side){
  3024. echo "</ul></li><div class='table_top'>".$big_table.'</div>';
  3025. ?><ul<?=$is_wide?"":" class='print_column'"?>>
  3026. <li class='post<?=isset($extra_class_string)?' '.$extra_class_string:''?>' <?=$is_deleted?"data-mark-delete='true'":""?>>
  3027. <?php
  3028. }
  3029. if($show_thread_link && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) &&
  3030. $post['tid']['first']['id']!=$post['id']){ ?>
  3031. <div class='gray smaller block opt_compact post'>
  3032. <a href='?post=<?=$post['tid']['first']['id']?>' onclick='ShowWaitingBar()'>
  3033. <div class='post_access invert_a hover_dark smaller'><?=isset($post['tid']['first']['mark_value'])?
  3034. $this->Markers[$post['tid']['first']['mark_value']]:"→"?></div></a>
  3035. <div class='post_width'><div class='smaller'><?=$this->T('回复给主题帖:')?></div>
  3036. <?=$this->GenerateSinglePost($post['tid']['first'], false, false, false, true,$this->NULL_POST,true);?>
  3037. </div>
  3038. </div>
  3039. <?php }
  3040. if($show_reply_count && isset($post['tid'])){ ?>
  3041. <a class='smaller block invert_a' href='?post=<?=$post['tid']['last']['id']?>'><?=$post['tid']['count']?>
  3042. <?=$this->T('个回复')?></a>
  3043. <?php }
  3044. ?>
  3045. </li>
  3046. <?php
  3047. }
  3048. function MakePostingFields($reply_to=NULL, $show_hint=false){
  3049. if(isset($this->WayBack)){ ?>
  3050. <span class='gray'><i><?=$this->T('以过去日期浏览时不能发帖。')?></i></span>
  3051. <?php return; } ?>
  3052. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='post_form'></form>
  3053. <div class='smaller'><div style='display:<?=$show_hint?"block":"none"?>;'>
  3054. <span id='post_hint_text'><?=$this->T('继续补充该话题:')?></span></div>
  3055. <div id='post_hint_modify' style='display:none;'>
  3056. <input type="checkbox" name="post_record_edit" value="1" form='post_form' checked> <?=$this->T('新增历史记录');?></div></div>
  3057. <textarea id="post_content" name="post_content" rows="4" form='post_form'
  3058. onfocus="if (value =='<?=$this->T('有什么想说的')?>'){value ='';}la_auto_grow(this);"
  3059. onblur="if (value ==''){value='<?=$this->T('有什么想说的')?>';la_auto_grow(this);}"
  3060. oninput="la_auto_grow(this);" onload="la_auto_grow(this);"><?=$this->T('有什么想说的')?></textarea>
  3061. <input class='button' form="post_form" type="submit" name='post_button' value=<?=$this->T('发送')?>
  3062. onclick='ShowWaitingBar();' />
  3063. | <a class='gray smaller pointer' onclick='ShowSideUploader();'><?=$this->T('图片')?></a>
  3064. <div style='float:right;'>
  3065. <a class='gray smaller pointer' onclick='t=document.querySelector("#post_content");t.value="";la_auto_grow(t);'>
  3066. <?=$this->T('清空')?></a>
  3067. <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
  3068. </div>
  3069. <input style='display:none;' type=input form="post_form" id='post_edit_target' name='post_edit_target' />
  3070. <script> la_auto_grow(document.getElementById("post_content"));</script>
  3071. <?php if($reply_to){ ?>
  3072. <input style='display:none;' type=input form="post_form" id='post_reply_to' name='post_reply_to' value='<?=$reply_to?>' />
  3073. <?php } ?>
  3074. <?php
  3075. }
  3076. function MakeCommentPosts(){
  3077. if(!$this->LoggedIn) return; ?>
  3078. <h2><?=$this->T('评论')?></h2><div class='spacer'></div>
  3079. <?php if(!$this->CommentEnabled){
  3080. echo "<p><span class='text_highlight'>&nbsp;".$this->T("已关闭评论")."&nbsp;</span></p><br />"; } ?>
  3081. <div class='comment'><ul>
  3082. <?php $i=0;
  3083. foreach(array_reverse($this->Posts) as $p){
  3084. if(!isset($p['comment_to'])) continue;
  3085. if($i < $this->CommentsPerPage * $this->CurrentOffset) {$i++; continue;}
  3086. $ht = $this->GenerateSinglePost($p, false, false, false, false, $t, false);
  3087. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3088. $post_to = $this->GetPost($p['comment_to']); $post_title = $this->GetPostTitle($post_to);
  3089. if(!$post_to) $post_title = "?";
  3090. $mail = "<span class='gray hidden_on_print'>&nbsp;".
  3091. "<a href='mailto:".$p['email']."'>@</a>&nbsp;".
  3092. (isset($p['ip'])?$p['ip']:"?")."&nbsp;<br class='hidden_on_desktop'/>".
  3093. "<a href='index.php?post=".$p['comment_to']."'>(".$post_title.")</a></span>";
  3094. echo "<li><p><b>".$name.":</b>".$mail."<br /></p>".$ht."</li>";
  3095. $i++;
  3096. }
  3097. ?>
  3098. </ul><br /></div>
  3099. <?php
  3100. }
  3101. function MakeRecentPosts($search_term=NULL, $category=NULL){?>
  3102. <div class='center' id='div_center'>
  3103. <h2><?=isset($search_term)?$this->T('搜索'):
  3104. (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
  3105. ($category=='none'?$this->T('未分类'):$this->T($category))):($this->T('最近')).
  3106. " <span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
  3107. ($this->LoggedIn?"<a href='index.php?comments=all'>@</a>":"")."</span>")?></h2>
  3108. <?php if(isset($search_term)){ ?>
  3109. <form action="index.php" method="post" style='display:none;' id='search_form'></form>
  3110. <input id="search_content" name="search_content" rows="4" form='search_form' type='text' value='<?=$search_term?>'>
  3111. <input class='button' form="search_form" type="submit" name='search_button' value=<?=$this->T('搜索')?>
  3112. <?php }else if(isset($category)){ ?>
  3113. <div></div>
  3114. <?php }else if($this->LoggedIn){ ?>
  3115. <div class='post_box_top _input_bundle'>
  3116. <?php $this->MakePostingFields(NULL,false); ?>
  3117. </div>
  3118. <?php } ?>
  3119. <ul class='print_column list'>
  3120. <?php
  3121. if(!isset($search_term) && !isset($category) &&
  3122. (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
  3123. $this->CanShowPost($p)){
  3124. $this->MakeSinglePost($p, true, false, false, false, true, false, false, false, true, false);
  3125. }
  3126. $i = 0; $last_end_wide = true;
  3127. if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
  3128. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  3129. if(isset($p['tid'])){ /* Should always be set. */
  3130. $th = &$p['tid']; if($p['tid']['count']==0) continue;
  3131. if(!isset($search_term)) { $p = &$th['last']; }
  3132. }
  3133. if(isset($search_term)){
  3134. if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
  3135. }else if(isset($category)){
  3136. $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
  3137. (isset($p['categories'])?($p['categories']):[]);
  3138. if ($category=='none') { if($cat!=[]) continue; }
  3139. else{ if ($category=='' || !in_array($category, $cat)) continue; }
  3140. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3141. }else{
  3142. if(in_array($p['id'],
  3143. [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation])) continue;
  3144. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3145. }
  3146. if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
  3147. if($last_end_wide){$use_class="last_wide";}else{$use_class="";}
  3148. $this->MakeSinglePost($p, true, false, $use_class, false, !isset($search_term), false, false, false, false, isset($search_term));
  3149. $i++;
  3150. if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
  3151. $last_end_wide = sizeof($p['tid']['arr'])==1 && isset($p['end_wide']) && $p['end_wide'];
  3152. }?>
  3153. </ul>
  3154. <div class='page_selector clean_a'>
  3155. <hr />
  3156. <a <?=$this->CurrentOffset>0?("href='index.php?offset=".($this->CurrentOffset-1).
  3157. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):""?>
  3158. <?=$this->CurrentOffset==0?"class='gray'":""?>><?=$this->T('上一页')?> ←</a>
  3159. <?=$this->CurrentOffset+1?>
  3160. <a href='index.php?offset=<?=($this->CurrentOffset+1).
  3161. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))?>'>
  3162. → <?=$this->T('下一页')?></a>
  3163. </div>
  3164. </div>
  3165. <?php
  3166. }
  3167. function MakeHotPosts($placeholder_only=false){?>
  3168. <div class='left hidden_on_mobile' id='div_left'>
  3169. <?php if ($placeholder_only){ ?>&nbsp;
  3170. <?php }else{ ?>
  3171. <h2><?=$this->T('热门')?></h2>
  3172. <ul>
  3173. <?php
  3174. $i=0;
  3175. foreach($this->Threads as &$th){
  3176. if(!isset($th['first']) || $th['count']==0){ continue; }
  3177. if(!$this->CanShowPost($th['first'])) continue;
  3178. if($i>=$this->HotPostCount) break;
  3179. $this->MakeSinglePost($th['first'], false, true, "post_preview", true, false, true, false, true, false, false);
  3180. $i++;
  3181. } ?>
  3182. </ul>
  3183. <?php } ?>
  3184. </div>
  3185. <?php
  3186. }
  3187. function MakeLinkedPosts(&$p){
  3188. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); ?>
  3189. <div class='left hidden_on_mobile' id='div_left'>
  3190. <h2<?=$has_ref?"":" class='gray'"?>><?=$this->T('链接')?></h2>
  3191. <?php
  3192. if($has_ref){ ?>
  3193. <span class='smaller'><?=sizeof($p['refs'])?> <?=$this->T('个引用:')?></span>
  3194. <ul><?php $count_product=0;
  3195. foreach(array_reverse($p['refs']) as &$pr){
  3196. $po = $this->GetPost($pr); if(isset($post['mark_value']) && $po['mark_value']==5){ $count_product++; continue; }
  3197. if(!$this->CanShowPost($po)){ continue; }
  3198. $this->MakeSinglePost($po, false, true, "post_preview", true, false, false, false, true, false, false);
  3199. }
  3200. ?></ul>
  3201. <?php if($count_product){ ?> <span class='smaller'><?=$this->T('和').' '.$count_product.' '.$this->T('个商品')?></span> <?php }
  3202. }else{ ?>
  3203. <span class='gray smaller'><?=$this->T('没有帖子链接到这里。')?></span>
  3204. <?php } ?>
  3205. </div>
  3206. <?php
  3207. }
  3208. function MakeLinkedPostsExp(&$p){
  3209. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); ?>
  3210. <div class='center_exp post_dummy smaller'>
  3211. <hr />
  3212. <h3<?=$has_ref?"":" class='gray'"?>><?=$this->T('链接')?></h3>
  3213. <?php
  3214. if($has_ref){ ?>
  3215. <div class='smaller'><?=sizeof($p['refs'])?> <?=$this->T('个引用:')?></div>
  3216. <ul><?php $count_product=0;
  3217. foreach(array_reverse($p['refs']) as &$pr){
  3218. echo "<li class='post_dummy'><a href='?post=".$pr."'>".$this->T($this->GetPostTitle($this->GetPost($pr),false)).
  3219. "</a></li>";
  3220. }
  3221. ?></ul>
  3222. <?php if($count_product){ ?> <span class='smaller'><?=$this->T('和').' '.$count_product.' '.$this->T('个商品')?></span> <?php }
  3223. }else{ ?>
  3224. <div class='gray smaller'><?=$this->T('没有帖子链接到这里。')?></div>
  3225. <?php } ?>
  3226. <div style='margin-bottom:4rem;'>&nbsp;</div>
  3227. </div>
  3228. <?php
  3229. }
  3230. function MakePostHistoryList(&$ah, &$post,$version=NULL, $show_latest=true){
  3231. $latest_ver=isset($post['version'])?$post['version']:$post['id'];
  3232. $can_show=1; if(isset($this->WayBack) && $latest_ver>$this->WayBack) $can_show=0;
  3233. $title = NULL; if(!isset($ah) || ($show_latest && $can_show)) { $title=$this->T($this->GetPostTitle($post, false)); }
  3234. else{ $ver = &$ah['list'][sizeof($ah['list'])-1]; $title= $this->GetPostTitle($ver); }
  3235. if(!isset($title)) $title=$this->T('未命名');
  3236. if(!isset($ah)){ ?>
  3237. <h2><?=$this->T('没有历史记录')?></h2>
  3238. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$post['id']?>'><?=$title?></a></span><br />
  3239. <?php }else{ ?>
  3240. <h2><?=$this->T('历史记录')?></h2>
  3241. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$ah['id']?>'><?=$title?></a></span><br />
  3242. <div class='list'><ul>
  3243. <?php if($show_latest && $can_show){ $post['history_displayed']=1; ?>
  3244. <li class='<?=isset($version)&&$version==$latest_ver?" post_current_row bold":""?>' style='list-style:"";'>
  3245. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$latest_ver?>'><?=$this->ReadableTime($latest_ver)?></a>
  3246. <span class='smaller gray'><?=$this->T('长度').' '.strlen($post['content'])?></span>
  3247. <?php if(isset($post['merged_from'][0])){ ?><ul><?php foreach($post['merged_from'] as $from){
  3248. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3249. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3250. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3251. <?=$this->GetPostTitle($ver);?></a>
  3252. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3253. <?php } ?></ul><?php } ?>
  3254. <?php if(isset($post['merged_thread'][0][0])){ $pm=$post['merged_thread'][0][0];
  3255. $mah = &$this->GetArchiveHandle($pm);
  3256. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3257. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  3258. <span class='smaller gray'><?=sizeof($post['merged_thread'][0]);?> <?=$this->T('个帖子')?></span></li></ul>
  3259. <?php } ?>
  3260. </li><?php } ?>
  3261. <?php if(isset($ah['list'][0])) foreach(array_reverse($ah['list']) as &$ver){
  3262. if(isset($this->WayBack) && $ver['version']>$this->WayBack) continue;
  3263. if(isset($ver['history_displayed']) && $ver['history_displayed']) continue; ?>
  3264. <li<?=isset($version)&&$version==$ver['version']?" class='post_current_row bold'":""?>>
  3265. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$ver['version']?>'><?=$this->ReadableTime($ver['version'])?></a>
  3266. <span class='smaller gray'> <?=$this->T('长度').' '.strlen($ver['content'])?></span>
  3267. <?php if(isset($ver['merged_thread'][0][0])){ $pm=$ver['merged_thread'][0][0];
  3268. $mah = &$this->GetArchiveHandle($pm); $mver = &$this->GetPost($pm);
  3269. 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($ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></li></ul>
  3272. <?php } if(isset($ver['merged_from'][0])){ ?><ul><?php foreach($ver['merged_from'] as $from){
  3273. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3274. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3275. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3276. <?=$this->GetPostTitle($ver);?></a>
  3277. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3278. <?php } ?></ul></li><?php } ?>
  3279. <?php } ?></ul></div>
  3280. <?php } ?>
  3281. <?php
  3282. }
  3283. function MakePostDiff(&$this_ver, &$last_ver){
  3284. if(!isset($this_ver)){ ?>
  3285. <h2 class='gray'><?=$this->T('版本不存在')?></h2>
  3286. <?php }else{ ?>
  3287. <h2><?=$this->T('差异')?></h2>
  3288. <?php if(isset($this_ver['merged_thread']) && isset($this_ver['merged_thread'][0][0])){
  3289. $pm=$this_ver['merged_thread'][0][0]; $mah = &$this->GetArchiveHandle($pm);
  3290. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3291. <p><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver)?></a> <?=$this->T('并入这里')?>
  3292. <br /><span class='smaller gray'> <?=sizeof($this_ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></p>
  3293. <?php }else{ ?>
  3294. <table class='diff_table'><thead>
  3295. <tr><td><?php if(!isset($last_ver)){ ?><?=$this->T('没有更旧的版本')?><?php }else{ ?>
  3296. <?=$this->T('上一个版本')?><br /><?=$this->ReadableTime($last_ver['version'])?><?php } ?></td>
  3297. <td class='text_highlight bold'><?=$this->T('选择的版本')?><br /><?=$this->ReadableTime($this_ver['version'])?></td></tr>
  3298. </thead><tbody>
  3299. <tr><td><pre><?=isset($last_ver)?$last_ver['content']:""?></pre></td><td><pre><?=$this_ver['content']?></pre></td></tr>
  3300. </tbody>
  3301. </table>
  3302. <?php } ?>
  3303. <br /><a class='smaller' href='?post=<?=$this_ver['id']?>&set_wayback=<?=isset($this_ver['version'])?$this_ver['version']:$this_ver['id']?>'><?=$this->T('前往该版本时间')?> ←</a>
  3304. <?php } ?>
  3305. <?php
  3306. }
  3307. function MakePostHistory(&$post, $version=NULL){
  3308. $ah = &$this->GetArchiveHandle($this->CurrentPostID);
  3309. $p = &$post; if(!isset($post)){ $p=&$ah['list'][0]; }
  3310. $show_latest = isset($ah)?(!isset($ah['list'][sizeof($ah['list'])-1]['merged_into'])):true;
  3311. ?>
  3312. <div class='left hidden_on_mobile history' id='div_left'>
  3313. <?php if (isset($version)){
  3314. $this->MakePostHistoryList($ah, $p, $version, $show_latest);
  3315. }else{ echo "&nbsp;"; } ?>
  3316. </div>
  3317. <div class='center history' id='div_center'>
  3318. <?php if (!isset($version)){
  3319. $this->MakePostHistoryList($ah, $p, NULL, $show_latest);
  3320. }else{
  3321. $this_ver = NULL; $next_ver = NULL; $last_ver=NULL;
  3322. $this_ver = &$this->GetArchiveVersion($ah, $version, $next_ver, $last_ver);
  3323. if(!isset($this_ver)){$this_ver = $p; $last_ver=$ah['list'][sizeof($ah['list'])-1];}
  3324. $this->MakePostDiff($this_ver, $last_ver, $p);
  3325. } ?>
  3326. </div>
  3327. <?php
  3328. }
  3329. function MakeCommentSection(&$post){
  3330. if(!$this->CommentEnabled){ return; }
  3331. $to_post = isset($post['tid'])?$post['tid']['first']:$post;
  3332. $comment_count = (isset($to_post['comments']) && isset($to_post['comments'][0]))?count($to_post['comments']):0;
  3333. ?><div class='comment'>
  3334. <br /><h2><?=$this->T('评论')?> (<?=$comment_count;?>)</h2><div class='spacer'></div>
  3335. <?php if($comment_count) { echo "<ul>";
  3336. foreach($to_post['comments'] as $p){
  3337. $ht = $this->GenerateSinglePost($p, false, false, false, false, $t, false);
  3338. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3339. $mail = $this->LoggedIn?("<span class='gray clean_a hidden_on_print'>&nbsp;".
  3340. "<a href='mailto:".$p['email']."'>@</a>&nbsp;</span>"):"";
  3341. echo "<li><p><b>".$name.":</b>".$mail."</p>".$ht."</li>";
  3342. }
  3343. echo "</ul>";
  3344. } else {
  3345. echo $this->T('还没有评论');
  3346. } ?>
  3347. <div class='hidden_on_print'>
  3348. <div class='spacer'></div>
  3349. <form action="index.php?post=<?=$this->CurrentPostID?>&comment_to=<?=$to_post['id']?>"
  3350. method="post" style="display:none;" id="comment_form"></form>
  3351. <p><a class='text_highlight bold clean_a'
  3352. onclick='document.getElementById("comment_box").style.display="block";this.parentNode.style.display="none"'>
  3353. &nbsp;<?=$this->T('写评论');?>&nbsp;</a></p>
  3354. <div id='comment_box' style='display:none;'>
  3355. <p class='gray' style='margin-bottom:0.5em;'><?=$this->T('您的邮箱不会公开展示。');?></p>
  3356. <table style='white-space:nowrap;'>
  3357. <tr><td colspan='2'>
  3358. <textarea id="comment_box" name="comment_box" rows="4" class='full_box' form='comment_form'
  3359. oninput="CommentUpdated();" ></textarea>
  3360. </td></tr>
  3361. <tr><td><?=$this->T('电子邮件')?>*</td><td><?=$this->T('称呼')?>*</td></tr>
  3362. <tr><td><input type="text" form="comment_form" id='comment_email' name='comment_email'
  3363. class='full_box' oninput="CommentUpdated();" /></td>
  3364. <td><input type="text" form="comment_form" id='comment_name' name='comment_name'
  3365. class='full_box' oninput="CommentUpdated();" /></td></tr>
  3366. <tr><td colspan='2'><?=$this->T('个人网站')?></td></tr>
  3367. <tr><td colspan='2'>
  3368. <input type="text" form="comment_form" id='comment_link' name='comment_link'
  3369. class='full_box' oninput="CommentUpdated();" />
  3370. </td></tr>
  3371. <tr><td colspan='2'>
  3372. <div class='spacer'></div>
  3373. <input class='button text_highlight bigger' type='submit' form='comment_form'
  3374. name='comment_confirm' id='comment_confirm' value='&nbsp;<?=$this->T('发送')?>&nbsp;'>
  3375. </td></tr>
  3376. </table></div>
  3377. <script>
  3378. const IsValidEmail = (email) => {
  3379. 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,}))$/);
  3380. };
  3381. function IsValidHttpUrl(string) {
  3382. let url; try{ url = new URL(string); } catch (_) { return false; }
  3383. return url.protocol === "http:" || url.protocol === "https:";
  3384. }
  3385. var cbox = document.getElementById('comment_box');
  3386. var cemail = document.getElementById('comment_email');
  3387. var cname = document.getElementById('comment_name');
  3388. var clink = document.getElementById('comment_link');
  3389. var cconfirm = document.getElementById('comment_confirm');
  3390. function CommentUpdated(){
  3391. cconfirm.disabled=true;
  3392. if (cemail.value!="" && IsValidEmail(cemail.value) &&
  3393. cbox.innerText.length>2 && cname.value.length>2 &&
  3394. clink.value=="" || IsValidHttpUrl(clink.value)){
  3395. cconfirm.removeAttribute("disabled");
  3396. }
  3397. }
  3398. CommentUpdated();
  3399. </script>
  3400. </div>
  3401. </div>
  3402. <?php
  3403. }
  3404. function MakeInterestingSection(&$th){
  3405. $this->Anchors = [];
  3406. $c = &$th['first']['content'];
  3407. $this->ConvertPost($th['first']);
  3408. $ht = $th['first']['html'];
  3409. ?>
  3410. <script>function ClickImage(post_access){im=post_access.querySelector('img');if(im){im.click();}}</script>
  3411. <div class='center_full' id='div_center'>
  3412. <?php $this->MakePostTools(); ?>
  3413. <?php $cat = NULL;
  3414. if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; }
  3415. if($cat){ ?>
  3416. <p><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  3417. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  3418. <?php } ?>
  3419. <h2 class='hidden_on_print'><?=$this->T('有趣')?>
  3420. <a class='gray clean_a' href='?post=<?=$th['first']['id']?>'>→</a></h2>
  3421. <ul><li class='post post_width_big' data-post-id='<?=$th['first']['id']?>'>
  3422. <div class='post_menu_button _menu_hook' onclick='ShowPostMenu(this.parentNode);'>+</div><?=$ht?>
  3423. <?php if(isset($th['first']['refs'][0])){ ?><p class='smaller'><?=$this->T('引用')?>: </p><ul class='smaller'>
  3424. <?php foreach($th['first']['refs'] as $ref){
  3425. $po = $this->GetPost($ref);
  3426. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  3427. if(!$this->CanShowPost($po)){ continue; }
  3428. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  3429. } ?>
  3430. </ul><?php } ?>
  3431. <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  3432. <div class='post_width_big hidden_on_print'><br />
  3433. <?php $this->MakePostingFields($th['last']['id'], true);?><br />
  3434. </div>
  3435. <?php } ?>
  3436. <table><thead><tr><th></th><?php foreach($th['interesting'] as $header){ ?>
  3437. <th><?=$this->T($header);?></th>
  3438. <?php } ?></tr></thead><tbody class='interesting_tbody'>
  3439. <?php $plist = array_reverse(array_slice($th['arr'],1));
  3440. foreach($plist as &$p){
  3441. $this->ConvertPost($p);
  3442. $mark_value = isset($p['mark_value'])?$this->Markers[$p['mark_value']]:-1;
  3443. $ref_count = isset($p['refs'])?sizeof($p['refs']):0;
  3444. $is_current = $p['id']==$this->CurrentPostID;
  3445. $is_deleted = (isset($p['mark_delete'])&&$p['mark_delete']); ?>
  3446. <tr class='<?=$is_current?"post_current_row":""?><?=$is_deleted?" deleted_post":""?>'
  3447. data-post-id='<?=$p['id']?>' <?=$is_deleted?"data-mark-delete='true'":""?>
  3448. onDblClick='ClickImage(this)'><td>
  3449. <a <?=$is_current?"":("href='?post=".$p['id']."' onclick='ShowWaitingBar()'");?> class='clean_a paa'>
  3450. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  3451. <?=isset($p['mark_value'])?$this->Markers[$p['mark_value']]:($ref_count?"":"→")?>
  3452. </div>
  3453. <?php if($ref_count){ ?>
  3454. <div class='post_access ref_count'><?=$ref_count?></div>
  3455. <?php } ?></a>
  3456. <?=$p['html'];?>
  3457. <a class='_menu_hook clean_a post_menu_button' onclick='ShowPostMenu(this.parentNode.parentNode);'>+</a></td></tr>
  3458. <?php if($is_current && $ref_count>0){ ?><tr class='post_current_row'><td><p>&nbsp;</p><ul class='smaller'>
  3459. <?php foreach($p['refs'] as $ref){
  3460. $po = $this->GetPost($ref);
  3461. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  3462. if(!$this->CanShowPost($po)){ continue; }
  3463. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  3464. } ?>
  3465. </ul></td></tr><?php } ?>
  3466. <?php } ?>
  3467. </tbody></table>
  3468. </li></ul>
  3469. <br />
  3470. <?php $this->MakeCommentSection($th['first']); ?>
  3471. </div>
  3472. <?php return true;
  3473. }
  3474. function CssNumberID($id){
  3475. return "#\\3".substr($id,0,1)." ".substr($id,1);
  3476. }
  3477. function MakePostTools(){
  3478. if($this->LoggedIn && !isset($this->WayBack)){ ?><div class='smaller gray hidden_on_print clean_a'>
  3479. <a id='merge_cancel' href='javascript:{TogglePostSelectMode(false,true);ToggleThreadMerge(false,true);}'>
  3480. <?=$this->T('工具')?></a>:<div class='hidden_on_mobile' style='display:inline'>
  3481. <span id='merge_post_btn'><a href='javascript:TogglePostSelectMode()'><?=$this->T('合并帖子')?></a></span>
  3482. | <span id='merge_thread_btn'><a href='javascript:ToggleThreadMerge()'><?=$this->T('合并话题')?></a></span>
  3483. </div>
  3484. <select class='hidden_on_desktop' id='merge_select'
  3485. onchange="if(this.selectedIndex==1){TogglePostSelectMode(true);}else if(this.selectedIndex==2){ToggleThreadMerge(true);}">
  3486. <option value='-1' selected>--</option>
  3487. <option value='1'><?=$this->T('合并帖子')?></option>
  3488. <option value='2'><?=$this->T('合并话题')?></option></select>
  3489. <div style='display:none;' id='merge_post_dialog' class='text_highlight small_pad align_right'>
  3490. <div style='display:inline;'><?=$this->T('将合并');?> <span id='merge_post_count'></span> <?=$this->T('个帖子');?></div>
  3491. <span class='clean_a bold align_right'><a id='merge_post'>&nbsp;<?=$this->T('执行');?></a></span></div>
  3492. <div style='display:none;overflow:auto' id='merge_thread_dialog' class='text_highlight small_pad align_right'>
  3493. <div style='display:inline;'><?=$this->T('合并到话题');?></div>
  3494. <input id="merge_thread_target" type="text" style="width:9em;display:inline" onChange='ThreadMergeInput(this);' onInput='ThreadMergeInput(this);'>
  3495. <span class='clean_a bold align_right'><a id='merge_thread'>&nbsp;<?=$this->T('执行');?></a></span></div>
  3496. </div><div class='spacer hidden_on_print'></div><?php
  3497. }
  3498. }
  3499. function MakePostSection(&$post){
  3500. $this->Anchors = [];
  3501. if(isset($this->TagID)){ ?><style><?=$this->CssNumberID($this->TagID);?>{display:block;}</style><?php } ?>
  3502. <div class='center' id='div_center'>
  3503. <h2 class='hidden_on_print'>
  3504. <?php $th=NULL; $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1;
  3505. $is_wide = (isset($post['wide'])&&$post['wide']) || ($is_thread && isset($post['tid']['wide']) && $post['tid']['wide']);
  3506. if($is_thread){ $th = $post['tid'];?> <?=$this->T('话题')?> <?php }else{ ?> <?=$this->T('详细')?>
  3507. <?php } ?></h2>
  3508. <?php $cat = NULL;
  3509. if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
  3510. else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
  3511. $this->MakePostTools();
  3512. if($cat){ ?>
  3513. <p class='hidden_on_print'><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  3514. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  3515. <?php } ?>
  3516. <ul<?=$is_wide?"":" class='print_column'"?>>
  3517. <?php $is_reversed=false;
  3518. if($is_thread){
  3519. $use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false; if($is_reversed){
  3520. $use_arr=array_reverse($th['arr']); $fp=array_pop($use_arr); array_unshift($use_arr,$fp); }
  3521. $last_end_wide = true;
  3522. foreach($use_arr as &$p){
  3523. $use_class = ($p == $post)?'focused_post':'';
  3524. if($last_end_wide){$use_class.=" last_wide";}
  3525. $show_link = ($p == $post)?false:true;
  3526. $make_title = ($p == $post);
  3527. $this->MakeSinglePost($p,$show_link,false,$use_class,false, false, false, true, false, false);
  3528. if($make_title){?>
  3529. <script>
  3530. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($p['html']),0,1000)))?>";
  3531. </script>
  3532. <?php } if($is_reversed && !$hinted){ ?>
  3533. <li class='gray smaller bold' style='text-align:center;'>
  3534. <p>&nbsp;</p><hr><?=$this->T('该话题最新帖子在前')?><hr><p>&nbsp;</p></li>
  3535. <?php $hinted = true;
  3536. if($this->LoggedIn && (!$this->InHereMode)){ ?>
  3537. <div class='post_width_big hidden_on_print'>
  3538. <?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?></div><br />
  3539. <?php } }
  3540. $last_end_wide = isset($p['end_wide']) && $p['end_wide'];
  3541. }
  3542. }else{
  3543. $this->MakeSinglePost($post,false, false, 'focused_post',false, false, false, true, false, false);
  3544. ?><script>
  3545. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($post['html']),0,1000)))?>";
  3546. </script><?php
  3547. } $class_add=""; if(isset($post['tid']['first']['no_time'])){ $class_add=' hidden_on_print'; } ?>
  3548. <div class='smaller align_right<?=$class_add;?>'>
  3549. <span class='gray'><?=$this->ReadableTime($post['tid']['first']['id']);?></span>
  3550. <br class='hidden_on_desktop' /><?=$this->ReadableTime(isset($post['tid']['last']['version'])?
  3551. $post['tid']['last']['version']:$post['tid']['last']['id']);?>
  3552. </div>
  3553. <?php if(!$is_reversed && ($this->LoggedIn && (!$this->InHereMode))){ ?>
  3554. <div class='post_width_big hidden_on_print'>
  3555. <br /><?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?>
  3556. </div>
  3557. <?php }
  3558. $this->MakeCommentSection($post);
  3559. ?>
  3560. </ul>
  3561. </div>
  3562. <?php
  3563. }
  3564. function MakePostSectionExp(&$post){
  3565. $this->Anchors = []; $is_thread = isset($post['tid']);
  3566. ?>
  3567. <div class='center_exp' id='div_center'>
  3568. <ul>
  3569. <?php $is_reversed=false;
  3570. if($is_thread){ $th = &$post['tid'];$use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th);
  3571. $hinted=false; if($is_reversed){
  3572. $use_arr=array_reverse($th['arr']); $fp=array_pop($use_arr); array_unshift($use_arr,$fp); }
  3573. foreach($use_arr as &$p){
  3574. $this->MakeSinglePostExp($p);
  3575. if($p == $th['first']){?>
  3576. <script>
  3577. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($p['html']),0,1000)))?>";
  3578. </script>
  3579. <?php } if($is_reversed && !$hinted){ ?>
  3580. <li class='gray smaller bold' style='text-align:center;'>
  3581. <p>&nbsp;</p><hr><?=$this->T('该话题最新帖子在前')?><hr><p>&nbsp;</p></li>
  3582. <?php $hinted = true; }
  3583. }
  3584. }else{
  3585. $this->MakeSinglePostExp($post);
  3586. ?><!--<script>
  3587. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($post['html']),0,1000)))?>";
  3588. </script>--><?php
  3589. } ?>
  3590. </ul>
  3591. </div>
  3592. <?php
  3593. }
  3594. function MakeHereSection(&$im){ $image_okay = (isset($im) && $im!=$this->NULL_IMAGE); ?>
  3595. <div class='here_image_box clean_a'>
  3596. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'>
  3597. <?=$image_okay?$this->T('请稍候'):$this->T('未找到图像')?></div>
  3598. <?php if($image_okay){ ?>
  3599. <?php if(isset($im['video']) && isset($im['video'])!=""){ ?>
  3600. <video controls><source src='<?=$im['file'];?>' type='<?=$im['video']?>'></video>
  3601. <?php }else{ ?>
  3602. <img id='big_image' onload="HideWaitingBar();" src="<?=$im['file'];?>" />
  3603. <?php } ?>
  3604. <?php } $this->MakeHereButtons($im, false); ?>
  3605. </div>
  3606. <?php }
  3607. function MakeSideGalleryCode(){?>
  3608. <div>
  3609. <h3><?=$this->T('点击图片以插入:')?></h3>
  3610. <select id="side_gallery_select" onchange="RefreshSideGallery()">
  3611. <option value="main"><?=$this->T('全部')?></option>
  3612. <?php if($this->LoggedIn){ ?>
  3613. <option value="trash"><?=$this->T('垃圾桶')?></option>
  3614. <?php }?>
  3615. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  3616. <option value="<?=$g['name']?>"><?=$g['name']?></option>
  3617. <?php } ?>
  3618. </select>
  3619. <div id='side_gallery'>
  3620. </div>
  3621. </div>
  3622. <script>
  3623. function InsertImage(imgname){
  3624. t = document.querySelector("#post_content");
  3625. v = t.value;
  3626. t.value = v.slice(0, t.selectionStart) + "![<?=$this->T('图片')?>](images/"+imgname+")"+ v.slice(t.selectionEnd);
  3627. la_auto_grow(t);
  3628. }
  3629. function RefreshSideGallery(){
  3630. let xhr = new XMLHttpRequest();
  3631. xhr.onreadystatechange = (function(){
  3632. if (this.readyState === this.DONE) {
  3633. if (this.status === 200) {
  3634. ind = document.querySelector("#side_gallery");
  3635. if(res = xhr.responseText.matchAll(/\[(.*?),(.*?)\]/gu)){
  3636. str = "<ul class='side_thumb'>"
  3637. for (const m of res) {
  3638. imgstr = "<img src='"+m[2]+"' />";
  3639. if(m[2].match('\.mp4')){
  3640. imgstr = "<video><source src='"+m[2]+"'></video>";
  3641. }
  3642. str+="<li><div class='file_thumb' onclick='InsertImage(\""+m[1]+"\")'>"+imgstr+"</div>"
  3643. }
  3644. str += "</ul>"
  3645. ind.innerHTML = str;
  3646. }
  3647. }
  3648. }
  3649. });
  3650. xhr.open("GET", "?image_list="+document.querySelector("#side_gallery_select").value, true);
  3651. xhr.send();
  3652. }
  3653. </script>
  3654. <?php
  3655. }
  3656. function MakeUploader($is_side=false){ ?>
  3657. <div id='upload_operation_area' class='hidden_on_print'>
  3658. <p><?=$this->T('选择、粘贴或者拖动到页面以上传图片。')?></p>
  3659. <input type="file" id='upload_selector' accept="image/x-png,image/png,image/gif,image/jpeg" multiple/>
  3660. <ul id='file_list'>
  3661. </ul>
  3662. <div class='smaller gray' id='upload_hint'><?=$this->T('就绪')?></div>
  3663. </div>
  3664. <a id='upload_click' class='hidden_on_print pointer' onclick='this.removeAttribute("onclick");UploadList();'
  3665. <?=$is_side?" data-is-side='true'":""?>><?=$this->T('上传列表中的文件')?></a>
  3666. <script>
  3667. function pastehandler(event){
  3668. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  3669. for (index in items) {
  3670. var item = items[index];
  3671. if (item.kind === 'file') {
  3672. put = document.querySelector("#_uploader");
  3673. if(put) ShowSideUploader();
  3674. var blob = item.getAsFile();
  3675. AddImageFile(blob);
  3676. return;
  3677. }
  3678. }
  3679. }
  3680. let _fd_list = []; var uploading=0;
  3681. let hint=document.querySelector('#upload_hint');
  3682. function ToggleCompress(button){
  3683. li = button.parentNode;
  3684. num=li.dataset.number;
  3685. for(i=0;i<_fd_list.length;i++){
  3686. if (_fd_list[i][0] == num){
  3687. state = _fd_list[i][2];
  3688. if(state){_fd_list[i][2] = 0; button.innerHTML='1920';break;}
  3689. else{_fd_list[i][2] = 1; button.innerHTML='800';break;}
  3690. }
  3691. }
  3692. }
  3693. function RemoveFromUpload(button){
  3694. li = button.parentNode;
  3695. num=li.dataset.number;
  3696. for(i=0;i<_fd_list.length;i++){
  3697. if (_fd_list[i][0] == num){
  3698. _fd_list.splice(i, 1);break;
  3699. }
  3700. }
  3701. li.parentNode.removeChild(li);
  3702. }
  3703. function EndThisUpload(){
  3704. unfinished = 0;
  3705. for(i=0;i<_fd_list.length;i++){
  3706. if (_fd_list[i][3]==0){
  3707. unfinished=1;
  3708. }
  3709. }
  3710. if(!unfinished){
  3711. uploading=0;
  3712. hint.innerHTML="<?=$this->T('上传完成。')?>";
  3713. cl=document.querySelector('#upload_click');
  3714. if(!cl.dataset.isSide){
  3715. cl.innerHTML="<?=$this->T('刷新页面')?>";
  3716. cl.href=window.location.href;
  3717. }else{
  3718. _fd_list.splice(0,_fd_list.length);
  3719. fl = document.querySelector("#file_list");
  3720. fl.innerHTML = "";
  3721. list=document.querySelector('#upload_operation_area');
  3722. list.style.pointerEvents='';
  3723. list.style.opacity='';
  3724. cl.onclick=function(){this.removeAttribute("onclick");UploadList();};
  3725. document.onpaste=pastehandler;
  3726. RefreshSideGallery();
  3727. }
  3728. }
  3729. }
  3730. function UploadList(){
  3731. if(!_fd_list.length || uploading) return;
  3732. uploading=1;
  3733. hint.innerHTML="<?=$this->T('正在上传...')?>";
  3734. list=document.querySelector('#upload_operation_area');
  3735. list.style.pointerEvents='none';
  3736. list.style.opacity='0.5';
  3737. document.onpaste="";
  3738. for(i=0;i<_fd_list.length;i++){
  3739. let xhr = new XMLHttpRequest();
  3740. var li = list.querySelector('[data-number="'+_fd_list[i][0].toString()+'"]')
  3741. xhr.open("POST", "?compress="+_fd_list[i][2].toString(), true);
  3742. function wrap(li, i){
  3743. var ind = li.querySelector('._compress_toggle')
  3744. return function(){
  3745. if (this.readyState === this.DONE) {
  3746. if (this.status === 200) {
  3747. var response = xhr.responseText;
  3748. if(res = response.match(/<uploaded>(.*)<\/uploaded>/)){
  3749. ind.innerHTML = "<?=$this->T('已上传为')?> "+res[1];
  3750. _fd_list[i][3] = 1;
  3751. }else{
  3752. ind.innerHTML = "<?=$this->T('出现错误。')?>";
  3753. _fd_list[i][3] = 1;
  3754. }
  3755. EndThisUpload();
  3756. }
  3757. }
  3758. }
  3759. }
  3760. xhr.onreadystatechange = wrap(li, i);
  3761. xhr.send(_fd_list[i][1]);
  3762. }
  3763. }
  3764. function AddImageFile(blob){
  3765. var ext="";
  3766. if(blob.name.match(/png$/))ext = 'png';
  3767. else if(blob.name.match(/jpg$/))ext = 'jpg';
  3768. else if(blob.name.match(/jpeg$/))ext = 'jpeg';
  3769. else if(blob.name.match(/gif$/))ext = 'gif';
  3770. else if(blob.name.match(/mp4$/))ext = 'mp4';
  3771. else return;
  3772. var fd = new FormData();
  3773. blob.name = blob.name=generateUID().toString();
  3774. fd.append("upload_file_name", blob, "_upload_"+blob.name+"."+ext);
  3775. _fd_list.push([blob.name, fd, 1, 0]);/* number original is_compress uploaded */
  3776. var reader = new FileReader();
  3777. reader.onload = function(event){
  3778. fl = document.querySelector("#file_list");
  3779. ht = "<li id='_upload_"+blob.name+"' data-number='"+blob.name+"'>"+
  3780. "<a class='_remove_file pointer invert_a' onclick='RemoveFromUpload(this)'>×</a> "+"<div class='file_thumb'>"+
  3781. "<img class='no_pop' src='"+event.target.result+"'>"+"</div>"+
  3782. " →<a class='_compress_toggle pointer' onclick='ToggleCompress(this)'>800</a></li>";
  3783. fl.innerHTML+=ht;
  3784. };
  3785. reader.readAsDataURL(blob);
  3786. }
  3787. sel = document.querySelector('#upload_selector');
  3788. sel.addEventListener("change", function(){
  3789. var input = this;
  3790. function ff(file){
  3791. return function(e){
  3792. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3793. blob.name = file.name;
  3794. AddImageFile(blob);
  3795. }
  3796. }
  3797. for(i=0;i<input.files.length;i++){
  3798. if(input.files[i].size){
  3799. let reader = new FileReader();
  3800. reader.onload = ff(input.files[i]);
  3801. reader.readAsArrayBuffer(input.files[i]);
  3802. }
  3803. }
  3804. });
  3805. function generateUID() {
  3806. var firstPart = (Math.random() * 46656) | 0;
  3807. var secondPart = (Math.random() * 46656) | 0;
  3808. firstPart = ("000" + firstPart.toString(36)).slice(-3);
  3809. secondPart = ("000" + secondPart.toString(36)).slice(-3);
  3810. return firstPart + secondPart;
  3811. }
  3812. document.onpaste = pastehandler;
  3813. function dropHandler(ev) {
  3814. put = document.querySelector("#_uploader");
  3815. if(put) ShowSideUploader();
  3816. bkg=document.querySelector('#dropping_background');
  3817. bkg.style.display="none";
  3818. console.log('File(s) dropped');
  3819. ev.preventDefault();ev.stopPropagation();
  3820. if (ev.dataTransfer && ev.dataTransfer.items) {
  3821. for (var i = 0; i < ev.dataTransfer.items.length; i++) {
  3822. if (ev.dataTransfer.items[i].kind === 'file') {
  3823. var file = ev.dataTransfer.items[i].getAsFile();
  3824. function ff(file){
  3825. return function(e){
  3826. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3827. blob.name = file.name;
  3828. AddImageFile(blob);
  3829. }
  3830. }
  3831. if(file){
  3832. let reader = new FileReader();
  3833. reader.onload = ff(file);
  3834. reader.readAsArrayBuffer(file);
  3835. }
  3836. }
  3837. }
  3838. } else {
  3839. for (var i = 0; i < ev.dataTransfer.files.length; i++) {
  3840. function ff(file){
  3841. return function(e){
  3842. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3843. blob.name = file.name;
  3844. AddImageFile(blob);
  3845. }
  3846. }
  3847. if(ev.dataTransfer.files[i].size){
  3848. let reader = new FileReader();
  3849. reader.onload = ff(ev.dataTransfer.files[i]);
  3850. reader.readAsArrayBuffer(ev.dataTransfer.files[i]);
  3851. }
  3852. }
  3853. }
  3854. }
  3855. function dragOverHandler(ev) {
  3856. bkg=document.querySelector('#dropping_background');
  3857. bkg.style.display="";
  3858. console.log('File(s) in drop zone');
  3859. ev.preventDefault();
  3860. }
  3861. </script>
  3862. <?php
  3863. }
  3864. function CanShowGallery(&$g){
  3865. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($g['experimental']) && $g['experimental']) return false;
  3866. return true;
  3867. }
  3868. function CanShowImage(&$im){
  3869. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($im['galleries']) && isset($im['galleries'][0])) foreach($im['galleries'] as $ga){
  3870. if(($g=$this->GetGallery($ga)) && isset($g['experimental']) && $g['experimental']) return false;
  3871. }
  3872. if(isset($this->WayBack) && substr($im['name'],0,14)>$this->WayBack) return false;
  3873. return true;
  3874. }
  3875. function MakeGallerySection(){
  3876. if(!isset($_GET['gallery'])) return;
  3877. $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){
  3878. $name=$_GET['gallery'];}?>
  3879. <script>
  3880. document.title+=" | <?=$this->T('画廊')?>";
  3881. </script>
  3882. <div class='center_wide' id='div_center' style='position:relative;'>
  3883. <h2><?=(isset($name) && ($gal=$this->GetGallery($name))!=NULL)?
  3884. ("<span class='gray album_hint'>".$this->T('相册').":</span>".$this->T($name)):
  3885. ($_GET['gallery']=='trash'?$this->T('垃圾桶'):$this->T('画廊'))?></h2>
  3886. <div class='hidden_on_desktop'>
  3887. <?=$this->T('前往')?>
  3888. <select id="gallery_go_to" onchange="window.location.href='?gallery='+this.value;">
  3889. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  3890. if(!isset($g['featured']) || !$g['featured'] ||
  3891. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  3892. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  3893. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  3894. <?php } ?>
  3895. <option value="main" <?=$_GET['gallery']=='main'?"selected":""?>>[<?=$this->T('全部')?>]</option>
  3896. <?php if($this->LoggedIn){ ?>
  3897. <option value="trash" <?=$_GET['gallery']=='trash'?"selected":""?>>[<?=$this->T('垃圾桶')?>]</option>
  3898. <?php } ?>
  3899. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  3900. if((isset($g['featured']) && $g['featured']) ||
  3901. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  3902. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  3903. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  3904. <?php } ?>
  3905. </select>
  3906. </div>
  3907. <?php if($this->LoggedIn){?>
  3908. <div>
  3909. <?php if(isset($name)){ ?>
  3910. <div style='text-align:right;position:absolute;right:0;top:0;width:100%;' class='invert_a smaller hidden_on_print'>
  3911. <a href='javascript:ShowDeleteMenu();'><?=$this->T('删除相册')?></a><br />
  3912. <?php if(isset($gal['featured']) && $gal['featured']!=false){ ?>
  3913. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=false'>
  3914. <?=$this->T('取消精选')?></a>
  3915. <?php }else{ ?>
  3916. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=true'>
  3917. <?=$this->T('设为精选')?></a>
  3918. <?php } ?><br />
  3919. <?php if(isset($gal['experimental']) && $gal['experimental']!=false){ ?>
  3920. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=false'>
  3921. <?=$this->T('取消实验')?></a>
  3922. <?php }else{ ?>
  3923. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=true'>
  3924. <?=$this->T('设为实验')?></a>
  3925. <?php } ?>
  3926. <div class='pop_menu invert_a' id='gallery_delete_menu' style='display:none;'>
  3927. <div style='float:left;' class='gray'><?=$this->T('该操作不删除图片。')?></div>
  3928. <a href='javascript:HidePopMenu();'>×</a>
  3929. <hr />
  3930. <a href='?gallery=main&gallery_edit_delete=<?=$_GET['gallery']?>'><b><?=$this->T('删除相册')?></b></a>
  3931. </div>
  3932. </div>
  3933. <?php } ?>
  3934. <?php $this->MakeUploader(false); ?>
  3935. <div style='text-align:right;position:relative;' class='invert_a smaller hidden_on_print'>
  3936. <div style='position:relative'>
  3937. <?php if(isset($name)){ ?>
  3938. <a href='javascript:ShowGalleryEditMenu("<?=$name?>")'><?=$this->T('改名')?></a>
  3939. <?php } ?>
  3940. <a href='javascript:ShowGalleryEditMenu(null)'><?=$this->T('添加')?></a>
  3941. <div class='pop_menu invert_a' id='gallery_edit_menu' style='display:none;max-width:90%;'>
  3942. <form action="<?=$_SERVER['REQUEST_URI']?>&edit_gallery=true"
  3943. method="post" style='display:none;' id='gallery_edit_form'></form>
  3944. <a style='float:left;'><?=$this->T('相册名字:')?></a>
  3945. <a href='javascript:HidePopMenu();'>×</a>
  3946. <input type='text' form='gallery_edit_form' name='gallery_edit_new_name' id='gallery_edit_new_name' style='width:10em;'>
  3947. <input type='text' form='gallery_edit_form' name='gallery_edit_old_name' id='gallery_edit_old_name' style='display:none'>
  3948. <input class='button' type='submit' form='gallery_edit_form'
  3949. name='gallery_edit_confirm' id='gallery_edit_confirm' value='<?=$this->T('确认')?>'>
  3950. </div>
  3951. </div>
  3952. </div>
  3953. <div class='smaller hidden_on_print'>
  3954. <form action="<?=$_SERVER['REQUEST_URI']?>"
  3955. method="post" style='display:none;' id='gallery_move_form'></form>
  3956. <input type='text' form='gallery_move_form' name='gallery_move_ops'
  3957. id='gallery_move_ops' style='display:none'>
  3958. <p><?=$this->T('选择了')?> <span id='gallery_selected_count'>0</span> <?=$this->T('个图片。')?>
  3959. <a href='javascript:ClearSelectedImages()'><?=$this->T('清除')?></a></p>
  3960. <p><?=$this->T('添加到')?>
  3961. <select id="gallery_move_to">
  3962. <option value="trash"><?=$this->T('垃圾桶')?></option>
  3963. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  3964. <option value="<?=$g['name']?>"><?=$this->T($g['name'])?></option>
  3965. <?php } ?>
  3966. </select>
  3967. <a href='javascript:AddToGallery()'><?=$this->T('执行')?></a>
  3968. </p>
  3969. <p>
  3970. <?=$this->T('或者')?><a href='javascript:RemoveFromGallery()'><?=$this->T('从相册移除')?></a>
  3971. </p>
  3972. </div>
  3973. </div>
  3974. <?php } ?>
  3975. <p>&nbsp;</p>
  3976. <div>
  3977. <?php $opened=0; $prev_year=""; if(isset($this->Images[0])) foreach($this->Images as $im){
  3978. if(!$this->CanShowImage($im)){ continue; }
  3979. if($_GET['gallery']=='trash') $name='trash';
  3980. if($_GET['gallery']!='main'){ if(!isset($im['galleries']) || !in_array($name, $im['galleries'])) continue;}
  3981. $year = substr($im['name'], 0, 4);
  3982. if($year!=$prev_year){
  3983. if($opened) { ?><div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div></div><?php } ?>
  3984. <div><h2 class='sticky_title'><?=$year;?></h2><div class='p_row'><?php $prev_year=$year; $opened=1; } ?>
  3985. <div class='p_thumb<?=isset($im['parent'])?" p_thumb_narrow":""?>'>
  3986. <?php if($this->LoggedIn){ ?>
  3987. <div class="post_menu_button _select_hook white" onclick='ToggleSelectImage(this, "<?=$im["name"]?>")'>●</div>
  3988. <?php } ?>
  3989. <a href='?show_image=<?=$im['name']?>' target='_blank' onclick='event.preventDefault();'>
  3990. <?php if(isset($im['video']) && $im['video']!=""){ ?>
  3991. <video data-imgsrc='<?=$im["name"]?>'><source src='<?=$im['file']?>' type='<?=$im['video']?>'></video>
  3992. <?php }else{ ?>
  3993. <img src='<?=$im['thumb']?>' data-imgsrc='<?=$im["name"]?>'
  3994. <?=isset($im['product'])?'data-product="'.$im["product"].'"':""?>
  3995. <?=isset($im['parent'])?'data-parent="'.$im["parent"].'"':""?>/>
  3996. <?php } ?>
  3997. </a>
  3998. </div>
  3999. <?php } if($opened) { ?>
  4000. <div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div><?php } ?>
  4001. </div>
  4002. </div>
  4003. <?php if($this->LoggedIn){ ?>
  4004. <script type='text/javascript'>
  4005. var selected_image = new Array();
  4006. function RemoveFromGallery(){
  4007. form = document.querySelector('#gallery_move_form');
  4008. ops = document.querySelector('#gallery_move_ops');
  4009. sel = document.querySelector('#gallery_move_to');
  4010. ops.value = "REM <?=$_GET['gallery']?>"+" "+selected_image.join(' ');
  4011. form.submit();
  4012. }
  4013. function AddToGallery(){
  4014. form = document.querySelector('#gallery_move_form');
  4015. ops = document.querySelector('#gallery_move_ops');
  4016. sel = document.querySelector('#gallery_move_to');
  4017. ops.value = "ADD "+sel.value+" "+selected_image.join(' ');
  4018. form.submit();
  4019. }
  4020. function ClearSelectedImages(){
  4021. selected_image.splice(0, selected_image.length);
  4022. checks = document.querySelectorAll('._select_hook');
  4023. [].forEach.call(checks, function(c){
  4024. c.classList.remove('p_thumb_selected');
  4025. });
  4026. count = document.querySelector('#gallery_selected_count');
  4027. count.innerHTML="0";
  4028. }
  4029. function ToggleSelectImage(elem, name){
  4030. count = document.querySelector('#gallery_selected_count');
  4031. if(selected_image.indexOf(name) == -1){ selected_image.push(name); elem.classList.add('p_thumb_selected'); }
  4032. else{ selected_image.splice(selected_image.indexOf(name), 1); elem.classList.remove('p_thumb_selected'); }
  4033. count.innerHTML=selected_image.length.toString()
  4034. }
  4035. function ShowGalleryEditMenu(old_name){
  4036. m = document.querySelector('#gallery_edit_menu');
  4037. old = document.querySelector('#gallery_edit_old_name');
  4038. newname = document.querySelector('#gallery_edit_new_name');
  4039. m.style.display='block';
  4040. if(old_name!=''){ old.value=old_name; newname.value=old.value; }else{ old.value=''; }
  4041. }
  4042. function ShowDeleteMenu(){
  4043. m=document.querySelector('#gallery_delete_menu');
  4044. m.style.display='block';
  4045. }
  4046. </script>
  4047. <?php } ?>
  4048. <?php
  4049. }
  4050. function MakeGalleryLeft(){?>
  4051. <div class='left hidden_on_mobile gallery_left' id='div_left'>
  4052. <h2><?=$this->T('相册')?></h2>
  4053. <div>
  4054. <span class='gray smaller bold'><?=$this->T('精选')?><hr> </span>
  4055. <ul>
  4056. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4057. if(!isset($g['featured']) || !$g['featured'] || !$this->CanShowGallery($g)){ continue; } ?>
  4058. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4059. <li class='<?=$_GET['gallery']==$g['name']?'selected':""?>'>
  4060. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4061. <?php } ?>
  4062. </ul>
  4063. <div class='smaller'><span class='gray'><?=$this->T('其他相册')?><hr></span><ul>
  4064. <a href='?gallery=main' onclick='ShowWaitingBar()'>
  4065. <li class='<?=$_GET['gallery']=='main'?' selected':""?>'>[<?=$this->T('全部图片')?>]</li></a>
  4066. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4067. if((isset($g['featured']) && $g['featured']) || !$this->CanShowGallery($g)){ continue; } ?>
  4068. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4069. <li class='<?=$_GET['gallery']==$g['name']?' selected':""?>'>
  4070. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4071. <?php } ?>
  4072. <?php if($this->LoggedIn){ ?>
  4073. <a href='?gallery=trash' onclick='ShowWaitingBar()'>
  4074. <li class='<?=$_GET['gallery']=='trash'?' selected':""?>'>[<?=$this->T('垃圾桶')?>]</li></a>
  4075. <?php } ?>
  4076. </ul></div>
  4077. <p>&nbsp;</p>
  4078. <script>
  4079. </script>
  4080. </div>
  4081. </div>
  4082. <?php
  4083. }
  4084. function MakeTOC(){?>
  4085. <div class='right hidden_on_mobile' id='div_right'>
  4086. <?php if(isset($this->Anchors[0])){?>
  4087. <h2><?=$this->T('目录')?></h2><ul>
  4088. <?php
  4089. foreach($this->Anchors as $a){?>
  4090. <li class='toc_entry_<?=$a[0]>5?5:$a[0]?>'><a href='#<?=$a[1]?>'>
  4091. <?=$this->T($this->ChoosePartsByLanguage($a[2]))?></a></li>
  4092. <?php }
  4093. ?></ul>
  4094. <?php }else{ ?>
  4095. <h2 class='gray'><?=$this->T('目录')?></h2>
  4096. <span class='gray smaller'><?=$this->T('未找到目录')?></span>
  4097. <?php } ?>
  4098. </div>
  4099. <?php
  4100. }
  4101. function MakeSettings(){?>
  4102. <div class='settings'>
  4103. <h2><?=$this->T('设置')?></h2>
  4104. <table style='white-space:nowrap;'>
  4105. <?php if($this->LoggedIn){ ?>
  4106. <form action="index.php?settings=true" method="post" style='display:none;' id='settings_form'></form>
  4107. <colgroup><col style='min-width:5em;'><col style='width:100%;min-width:5em;'></colgroup>
  4108. <thead><tr><td><?=$this->T('选项')?></td><td><?=$this->T('值')?></td></tr></thead>
  4109. <tr><td><?=$this->T('网站标题')?></td>
  4110. <td><input type="text" form="settings_form" id='settings_title' name='settings_title'
  4111. value='<?=$this->Title?>'/></td></tr>
  4112. <tr><td><?=$this->T('短标题')?></td>
  4113. <td><input type="text" form="settings_form" id='settings_short_title' name='settings_short_title'
  4114. value='<?=$this->ShortTitle?>'/></td></tr>
  4115. <tr><td><?=$this->T('显示名称')?></td>
  4116. <td><input type="text" form="settings_form" id='settings_display_name' name='settings_display_name'
  4117. value='<?=$this->DisplayName?>'/></td></tr>
  4118. <tr><td><?=$this->T('电子邮件')?></td>
  4119. <td><input type="text" form="settings_form" id='settings_email' name='settings_email'
  4120. value='<?=$this->EMail?>'/></td></tr>
  4121. <tr><td><?=$this->T('导航栏')?>
  4122. <?=isset($this->SpecialNavigation)?"<a href='?post=".$this->SpecialNavigation."'>→</a>":""?></td>
  4123. <td><input type="text" form="settings_form" id='settings_special_navigation' name='settings_special_navigation'
  4124. value='<?=$this->SpecialNavigation?>'/></td></tr>
  4125. <tr><td><?=$this->T('脚注')?> 1<?=isset($this->SpecialFooter)?"<a href='?post=".$this->SpecialFooter."'>→</a>":""?></td>
  4126. <td><input type="text" form="settings_form" id='settings_special_footer' name='settings_special_footer'
  4127. value='<?=$this->SpecialFooter?>'/></td></tr>
  4128. <tr><td><?=$this->T('脚注')?> 2<?=isset($this->SpecialFooter2)?"<a href='?post=".$this->SpecialFooter2."'>→</a>":""?></td>
  4129. <td><input type="text" form="settings_form" id='settings_special_footer2' name='settings_special_footer2'
  4130. value='<?=$this->SpecialFooter2?>'/></td></tr>
  4131. <tr><td><?=$this->T('置顶文')?><?=isset($this->SpecialPinned)?"<a href='?post=".$this->SpecialPinned."'>→</a>":""?></td>
  4132. <td><input type="text" form="settings_form" id='settings_special_pinned' name='settings_special_pinned'
  4133. value='<?=$this->SpecialPinned?>'/></td></tr>
  4134. <tr><td><?=$this->T('默认相册')?></td>
  4135. <td><input type="text" form="settings_form" id='settings_default_gallery' name='settings_default_gallery'
  4136. value='<?=$this->DefaultGallery?>'/></td></tr>
  4137. <tr><td><?=$this->T('SelfAuth 路径')?></td>
  4138. <td><input type="text" form="settings_form" id='settings_selfauth_path' name='settings_selfauth_path'
  4139. value='<?=$this->SelfAuthPath?>'/></td></tr>
  4140. <tr><td><?=$this->T('启用评论')?></td>
  4141. <td><input type="checkbox" id="settings_enable_comments" name="settings_enable_comments"
  4142. form="settings_form" <?=$this->CommentEnabled?"checked":""?>/></td></tr>
  4143. <tr><td><?=$this->T('附加操作')?></td><td><a class='gray' href='index.php?extras=true'><?=$this->T('进入')?></a></td></tr>
  4144. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4145. <tr><td class='smaller gray'><?=$this->T('长毛象')?></td></tr>
  4146. <tr><td><?=$this->T('长毛象实例')?></td>
  4147. <td><input type="text" form="settings_form" id='settings_mastodon_url' name='settings_mastodon_url'
  4148. value='<?=$this->MastodonURL?>'/></td></tr>
  4149. <tr><td><?=$this->T('长毛象令牌')?></td>
  4150. <td><input type="text" form="settings_form" id='settings_mastodon_token' name='settings_mastodon_token'
  4151. value='<?=$this->MastodonToken?>'/></td></tr>
  4152. <tr><td><?=$this->T('偏好语言')?></td>
  4153. <td><input type="text" form="settings_form" id='settings_mastodon_lang' name='settings_mastodon_lang'
  4154. value='<?=$this->MastodonPreferredLang?>'/></td></tr>
  4155. <tr><td><?=$this->T('本站地址')?></td>
  4156. <td><input type="text" form="settings_form" id='settings_host_url' name='settings_host_url'
  4157. value='<?=$this->HostURL?>'/></td></tr>
  4158. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4159. <tr><td class='smaller gray'><?=$this->T('Activity Pub')?></td></tr>
  4160. <tr><td><?=$this->T('用户名')?></td>
  4161. <td><input type="text" form="settings_form" id='settings_apub_id' name='settings_apub_id'
  4162. value='<?=$this->APubID?>'/></td></tr>
  4163. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4164. <tr><td class='smaller gray'><?=$this->T('这里访问')?></td></tr>
  4165. <tr><td><?=$this->T('主机')?></td>
  4166. <td><input type="text" form="settings_form" id='settings_here_host' name='settings_here_host'
  4167. value='<?=$this->HereHost?>'/></td></tr>
  4168. <tr><td><?=$this->T('网站标题')?></td>
  4169. <td><input type="text" form="settings_form" id='settings_here_title' name='settings_here_title'
  4170. value='<?=$this->HereTitle?>'/></td></tr>
  4171. <tr><td><?=$this->T('短标题')?></td>
  4172. <td><input type="text" form="settings_form" id='settings_here_short_title' name='settings_here_short_title'
  4173. value='<?=$this->HereShortTitle?>'/></td></tr>
  4174. <tr><td><?=$this->T('相册')?></td>
  4175. <td><input type="text" form="settings_form" id='settings_here_album' name='settings_here_album'
  4176. value='<?=$this->HereAlbum?>'/></td></tr>
  4177. <tr><td><?=$this->T('导航栏')?>
  4178. <?=isset($this->HereNavigation)?"<a href='?post=".$this->HereNavigation."'>→</a>":""?></td>
  4179. <td><input type="text" form="settings_form" id='settings_here_navigation' name='settings_here_navigation'
  4180. value='<?=$this->HereNavigation?>'/></td></tr>
  4181. <tr><td><?=$this->T('脚注')?><?=isset($this->HereFooter)?"<a href='?post=".$this->HereFooter."'>→</a>":""?></td>
  4182. <td><input type="text" form="settings_form" id='settings_here_footer' name='settings_here_footer'
  4183. value='<?=$this->HereFooter?>'/></td></tr>
  4184. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4185. <tr><td class='smaller gray'><?=$this->T('实验访问')?></td></tr>
  4186. <tr><td><?=$this->T('主机')?></td>
  4187. <td><input type="text" form="settings_form" id='settings_exp_host' name='settings_exp_host'
  4188. value='<?=$this->ExpHost?>'/></td></tr>
  4189. <tr><td><?=$this->T('网站标题')?></td>
  4190. <td><input type="text" form="settings_form" id='settings_exp_title' name='settings_exp_title'
  4191. value='<?=$this->ExpTitle?>'/></td></tr>
  4192. <tr><td><?=$this->T('短标题')?></td>
  4193. <td><input type="text" form="settings_form" id='settings_exp_short_title' name='settings_exp_short_title'
  4194. value='<?=$this->ExpShortTitle?>'/></td></tr>
  4195. <tr><td><?=$this->T('首次提示')?><?=isset($this->ExpCaution)?"<a href='?post=".$this->ExpCaution."'>→</a>":""?></td>
  4196. <td><input type="text" form="settings_form" id='settings_exp_caution' name='settings_exp_caution'
  4197. value='<?=$this->ExpCaution?>'/></td></tr>
  4198. <tr><td><?=$this->T('相册')?></td>
  4199. <td><input type="text" form="settings_form" id='settings_exp_album' name='settings_exp_album'
  4200. value='<?=$this->ExpAlbum?>'/></td></tr>
  4201. <tr><td><?=$this->T('导航栏')?>
  4202. <?=isset($this->ExpNavigation)?"<a href='?post=".$this->ExpNavigation."'>→</a>":""?></td>
  4203. <td><input type="text" form="settings_form" id='settings_exp_navigation' name='settings_exp_navigation'
  4204. value='<?=$this->ExpNavigation?>'/></td></tr>
  4205. <tr><td><?=$this->T('脚注')?><?=isset($this->ExpFooter)?"<a href='?post=".$this->ExpFooter."'>→</a>":""?></td>
  4206. <td><input type="text" form="settings_form" id='settings_exp_footer' name='settings_exp_footer'
  4207. value='<?=$this->ExpFooter?>'/></td></tr>
  4208. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4209. <tr><td class='smaller gray'><?=$this->T('管理员')?></td><td class='smaller'>
  4210. <a href='index.php?logout=true'><?=$this->T('登出')?></a></td></tr>
  4211. <tr><td><?=$this->T('帐号')?></td>
  4212. <td><input type="text" form="settings_form" id='settings_id' name='settings_id'
  4213. value='<?=$this->Admin?>'/></td></tr>
  4214. <tr><td><?=$this->T('新密码')?></td>
  4215. <td><input type="password" form="settings_form"
  4216. id='settings_new_password' name='settings_new_password' /></td></tr>
  4217. <tr><td><?=$this->T('再次输入')?></td>
  4218. <td><input type="password" form="settings_form"
  4219. id='settings_new_password_redo' name='settings_new_password_redo' /></td></tr>
  4220. <tr><td><?=$this->T('旧密码')?></td>
  4221. <td><input type="password" form="settings_form" id='settings_old_password' name='settings_old_password' /></td></tr>
  4222. <?php }else{ ?>
  4223. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='login_form'></form>
  4224. <colgroup><col style='min-width:3em;'><col style='width:100%;min-width:5em;'></colgroup>
  4225. <tr><td class='smaller gray'><?=$this->T('请登录')?></td></tr>
  4226. <tr><td><?=$this->T('帐号')?></td>
  4227. <td><input type="text" form="login_form" id='login_id' name='login_id' /></td></tr>
  4228. <tr><td><?=$this->T('密码')?></td>
  4229. <td><input type="password" form="login_form" id='login_password' name='login_password' /></td></tr>
  4230. <?php } ?>
  4231. </table>
  4232. <?php if($this->LoggedIn){ ?>
  4233. <input class='button' form="settings_form" type="submit" name='settings_button' value='<?=$this->T('保存设置')?>' />
  4234. <?php }else{ ?>
  4235. <input class='button' form="login_form" type="submit" name='login_button' value='<?=$this->T('登录')?>' />
  4236. <?php } ?>
  4237. </div>
  4238. <?php
  4239. }
  4240. function MakeExtraOperations(){?>
  4241. <div class='settings' style='overflow:auto;'>
  4242. <h2><?=$this->T('附加操作')?></h2>
  4243. <a href='index.php?&settings=true'><?=$this->T('返回一般设置')?></a>
  4244. <p>&nbsp;</p>
  4245. <h3><?=$this->T('自动重定向')?></h3>
  4246. <span class='smaller gray'>
  4247. <?=$this->T('P为帖子跳转,匹配REQUEST_URI跳到目标文章;S为站点跳转,可以重定向来源域名,例子:')?>
  4248. <br /><pre>P discount:20001001010101;<br />S old_domain:www.new_domain.com:20001001010101;</pre></span>
  4249. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form2'></form>
  4250. <textarea id="settings_redirect" name="settings_redirect" rows="3" class='full_box' wrap="off"
  4251. form='settings_form2'><?=$this->DisplayRedirectConfig()?></textarea>
  4252. <input class='button' form="settings_form2" type="submit" name='settings_save_redirect'
  4253. value='<?=$this->T('保存重定向设置')?>' />
  4254. <p>&nbsp;</p>
  4255. <h3><?=$this->T('自定义翻译')?></h3>
  4256. <span class='smaller gray'>
  4257. <?=$this->T('填写格式:')?>
  4258. <br /><pre>- 语言 | Language</pre></span>
  4259. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form3'></form>
  4260. <textarea id="settings_translation" name="settings_translation" rows="3" class='full_box' wrap="off"
  4261. form='settings_form3'><?=$this->CustomTranslationContent?></textarea>
  4262. <input class='button' form="settings_form3" type="submit" name='settings_save_translation'
  4263. value='<?=$this->T('保存翻译')?>' />
  4264. <p>&nbsp;</p>
  4265. <p class='smaller gray'><?=$this->T('当心!下列操作将立即执行:')?></p>
  4266. <ul>
  4267. <li><a href='index.php?rewrite_styles=true'><?=$this->T('重新写入默认CSS')?></a></li>
  4268. <li><a href='index.php?regenerate_thumbnails=true'><?=$this->T('重新生成图片缩略图')?></a></li>
  4269. <li><a href='index.php?clear_all_logins=true'><?=$this->T('删除所有登录')?>(<?=sizeof($this->LoginTokens);?>)</a></li>
  4270. </ui>
  4271. <br /><br /><br /><a href='index.php?&settings=true'><?=$this->T('返回一般设置')?></a><br />&nbsp;
  4272. </div>
  4273. <?php
  4274. }
  4275. function MakeMainBegin(){?>
  4276. <div class='main' <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  4277. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"<?php } ?>>
  4278. <?php
  4279. }
  4280. function MakeMainEnd(){?>
  4281. </div>
  4282. <?php
  4283. }
  4284. function MakeExpFooter(){
  4285. $exptitle = isset($this->HereDisplayTitle)?('"'.$this->T($this->ChoosePartsByLanguage($this->HereDisplayTitle)).'"'):NULL;
  4286. if(!isset($exptitle)) $exptitle=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle);?>
  4287. <div class='small_footer exp_h_f exp_f'><div>
  4288. <b><?=$exptitle?></b> ©<?=$this->T($this->DisplayName)?>
  4289. <?=isset($this->HereMainImage)?("<a class='invert_a' href='?here=images/".$this->HereMainImage['name']."'>".$this->T("看全图")."</a>"):""; ?>
  4290. <div class='wayback_link gray clean_a invert_a hidden_on_print'><br class="hidden_on_desktop" />
  4291. <?php if($this->InExperimentalMode && isset($this->ExpFooter) && ($p = &$this->GetPost($this->ExpFooter,true))!=NULL){
  4292. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST,false);
  4293. }else if($this->InHereMode && isset($this->HereFooter) && ($p = &$this->GetPost($this->HereFooter,true))!=NULL){
  4294. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST,false);
  4295. }?></div>
  4296. </div>
  4297. </div>
  4298. </div><!-- page -->
  4299. </body>
  4300. </html>
  4301. <script>
  4302. if(trans = document.getElementById('translate_button')){
  4303. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  4304. }
  4305. </script>
  4306. <?php
  4307. }
  4308. function MakeImageOverlay($side_info=null,$static_image=null,$static_video=null){
  4309. $static=isset($side_info); ?>
  4310. <div id='big_image_overlay' <?=$static?"":"style='display:none'";?>>
  4311. <div class='big_image_box clean_a' onclick='HideBigImage(1)'>
  4312. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'><?=$this->T('请稍候')?></div>
  4313. <?php if(!$static_video){ ?>
  4314. <img id='big_image' onload="HideWaitingBar();" <?=isset($static_image)?("src='".$static_image."'"):""?>/><?php } ?>
  4315. <?php if(!$static_image){ ?>
  4316. <video id='big_video' onloadstart="HideWaitingBar();" controls><source id='big_video_src' type='video/mp4'
  4317. <?=isset($static_video)?("src='".$static_video."'"):""?>></video><?php } ?>
  4318. </div>
  4319. <div class='big_side_box' onclick='HideBigImage(1);'>
  4320. <?php if(!$static){ ?>
  4321. <div class='big_image_box clean_a image_nav' onclick='HideBigImage(1)'>
  4322. <div ><a id='prev_image' class='image_nav_prev img_btn_hidden' onclick="event.stopPropagation();">
  4323. <div class='lr_buttons'>←</div></a></div>
  4324. <div ><a id='next_image' class='image_nav_next img_btn_hidden' onclick="event.stopPropagation();">
  4325. <div class='lr_buttons'>→</div></a></div>
  4326. <div id='here_buttons'></div>
  4327. </div><?php } ?>
  4328. <div class='side_box_mobile_inner'>
  4329. <?php if(!$static){ ?>
  4330. <div class='inquiry_buttons img_btn_hidden' id='inquiry_buttons' onclick="event.stopPropagation();">
  4331. <span style='display:none;' id='image_purchase' class='clean_a'>
  4332. <b><a id='image_purchase_button' target="_blank">¥<?=$this->T('购买印刷品')?></a></b>
  4333. <br class='hidden_on_desktop block_on_mobile' /></span>
  4334. <b><a class='clean_a' id='image_download'><span id='download_processing'>↓</span><?=$this->T('下载')?></a></b>
  4335. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  4336. &nbsp;<a class='clean_a' id='image_inquiry'>
  4337. <b>@</b><?=$this->T('咨询')?></a>
  4338. <?php } ?><hr class='hidden_on_desktop block_on_mobile' />
  4339. </div>
  4340. <div id='big_image_share' class='clean_a' onclick="event.stopPropagation();">
  4341. <li class='wayback_close'><a onclick='HideBigImage(1);'><?=$this->T('关闭')?> ×</a></li>
  4342. <li><a id='big_share_copy'>⎘ <?=$this->T('复制链接')?></a></li>
  4343. <hr />
  4344. </div><?php } //static ?>
  4345. <div id='big_image_info' onclick="event.stopPropagation();"><?=$static?$side_info:""?></div>
  4346. <?php if($this->LoggedIn && !$static){ ?><div id='big_image_ops' onclick="event.stopPropagation();">
  4347. <br /><?=$this->T('印刷品链接')?>
  4348. <form action="" method="post" style='display:none;' id='image_ops_form'></form>
  4349. <input type='text' id='image_ops_product_link' name='image_ops_product_link' form="image_ops_form" >
  4350. <?=$this->T('重命名')?>
  4351. <input type='text' id='image_edit_new_name' name='image_edit_new_name' form="image_ops_form" >
  4352. <?=$this->T('主图')?>
  4353. <input type='text' id='image_parent' name='image_parent' form="image_ops_form" >
  4354. <input class='button' form="image_ops_form" type="submit" name='image_button' value=<?=$this->T('保存')?> />
  4355. <br /><br /><?=$this->T('替换图像')?>
  4356. <form action="" method="post" style='display:none;' id='image_edit_form' enctype="multipart/form-data"></form>
  4357. <input type="file" form='image_edit_form'
  4358. id='big_image_upload' name='upload_file_name' accept="image/x-png,image/png,image/gif,image/jpeg"/><br />
  4359. <input class='button' form="image_edit_form" type="submit" name='image_replace_button'
  4360. value=<?=$this->T('执行')?> />
  4361. </div><?php } ?>
  4362. </div>
  4363. </div>
  4364. </div>
  4365. <?php }
  4366. function MakePageEnd(){?>
  4367. </div><!-- page -->
  4368. </body>
  4369. </html>
  4370. <?php }
  4371. function MakeFooter(&$p){?>
  4372. <div class='small_footer'><div>
  4373. <hr />
  4374. <?php if(isset($p['tid']['footer'])){ ?><div class='show_on_print'><?=$p['tid']['footer'];?></div><?php } ?>
  4375. <b><?=$this->T($this->Title)?></b>
  4376. <span onclick='event.stopPropagation()'
  4377. ondblclick='javascript:window.location.href="index.php?settings=true"'>©</span><?=$this->T($this->DisplayName)?>
  4378. <div class='wayback_link clean_a invert_a hidden_on_print'><?php if(!isset($this->WayBack)){ ?>
  4379. - <a href='<?=$this->GetRedirect()?>&set_wayback=true'><?=$this->T('以过去的日期浏览')?></a>
  4380. <?php }else{ ?><a href='<?=$this->GetRedirect()?>&set_wayback=false'><?=$this->T('回到当前日期')?></a><?php } ?>
  4381. <br class='hidden_on_desktop' /> - <a href='<?=$this->GetRedirect()?>&toggle_font=true'>
  4382. <?=$this->T('切换字体')?>: <?=$this->T($this->UseRemoteFont?"远程":"本地");?></a>
  4383. <br class='hidden_on_desktop' />
  4384. - <a rel="alternate" type="application/rss+xml" href="?rss=<?=$this->LanguageAppendix;?>" />RSS/Atom<sup><?=$this->LanguageAppendix;?></sup></a>
  4385. </div>
  4386. <div class='smaller show_on_print'><?=$_SERVER['SERVER_NAME']?><br /><?=$this->EMail?></div>
  4387. </div></div>
  4388. <div class='footer'>
  4389. <div style='white-space:nowrap;'>
  4390. <div class='footer_additional'>
  4391. <?php if(isset($this->SpecialFooter) && ($p = &$this->GetPost($this->SpecialFooter))!=NULL){
  4392. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST,false);
  4393. } ?>
  4394. </div>
  4395. <div class='footer_additional'>
  4396. <?php if(isset($this->SpecialFooter2) && ($p = &$this->GetPost($this->SpecialFooter2))!=NULL){
  4397. echo $this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST,false);
  4398. } ?>
  4399. </div>
  4400. </div>
  4401. </div>
  4402. <p>&nbsp;<p>
  4403. <div id='dropping_background' style='display:none;' onclick='this.style.display="none";'
  4404. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);">
  4405. <h2 style='width:100%;'><?=$this->T('上传到这里')?></h2>
  4406. </div>
  4407. <?php $this->MakeImageOverlay(); $this->MakePageEnd(); ?>
  4408. <script>
  4409. <?=$this->ExtraScripts?>
  4410. if(back = document.getElementById('button_back')){
  4411. if(document.referrer.indexOf(location.protocol + "//" + location.host) == 0){
  4412. back.href='javascript:history.back()';
  4413. }else{
  4414. back.href='index.php';
  4415. }
  4416. }
  4417. function copy_text(t) {
  4418. ta = document.createElement('textarea');
  4419. document.body.appendChild(ta);
  4420. ta.value = t;
  4421. ta.select();
  4422. document.execCommand("copy");
  4423. document.body.removeChild(ta);
  4424. }
  4425. if(trans = document.getElementById('translate_button')){
  4426. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  4427. }
  4428. <?php if($this->LoggedIn){ ?>
  4429. var Scenter = document.querySelector('#div_center');
  4430. var Sposts = Scenter.querySelectorAll('.post');
  4431. <?php if(isset($this->MastodonToken)){ ?>
  4432. function MarkPostDoneMastodon(id,mastodon_url){
  4433. for(var i=0;i<Sposts.length;i++){
  4434. if(Sposts[i].dataset.postId==id){ Sposts[i].dataset.mastodon_url= mastodon_url; break;} }
  4435. }
  4436. <?php } ?>
  4437. <?php if($this->PageType=='post' && !isset($this->WayBack)) { ?>
  4438. var Smerge_post_dialog = Scenter.querySelector('#merge_post_dialog');
  4439. var Smerge_post = Scenter.querySelector('#merge_post');
  4440. var Smerge_post_count = Smerge_post_dialog.querySelector('#merge_post_count');
  4441. var Smerge_post_btn = Scenter.querySelector('#merge_post_btn');
  4442. var Smerge_cancel = Scenter.querySelector('#merge_cancel');
  4443. var Smerge_select = Scenter.querySelector('#merge_select');
  4444. var Smerge_thread_dialog = Scenter.querySelector('#merge_thread_dialog');
  4445. var Smerge_thread = Scenter.querySelector('#merge_thread');
  4446. var Smerge_thread_target = Scenter.querySelector('#merge_thread_target');
  4447. var Smerge_thread_btn = Scenter.querySelector('#merge_thread_btn');
  4448. var select_mode = false; var merge_mode = false; var selected_posts = null;
  4449. function TogglePostSelectMode(force_on=false,force_off=false){
  4450. Scenter.classList.add('post_selecting');
  4451. if((!select_mode || force_on) && !force_off){ ToggleThreadMerge(false,true); Scenter.classList.add('post_selecting');
  4452. Smerge_post_dialog.style.display="block";Smerge_post_btn.classList.add('text_highlight');
  4453. Smerge_cancel.innerText='<?=$this->T("取消")?>'; select_mode = 1;}
  4454. else{ select_mode = 0; Scenter.classList.remove('post_selecting');
  4455. Smerge_post_dialog.style.display="none";Smerge_post_btn.classList.remove('text_highlight');
  4456. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  4457. for(var i=0;i<Sposts.length;i++){ Sposts[i].classList.remove('post_selected');
  4458. Sposts[i].onclick=select_mode?function(){TogglePostSelect(this);}:null; }
  4459. Smerge_post_count.innerText="0";
  4460. Smerge_post.href="#";
  4461. }
  4462. function TogglePostSelect(elem){
  4463. if(elem.classList.contains('post_selected')){ elem.classList.remove('post_selected'); }
  4464. else{ elem.classList.add('post_selected'); }
  4465. selected_posts = new Array();
  4466. for(var i=0;i<Sposts.length;i++){ if(Sposts[i].classList.contains('post_selected')){
  4467. selected_posts.push(Sposts[i].dataset.postId); } }
  4468. Smerge_post.href="?merge_posts="+selected_posts.join(" ");
  4469. Smerge_post_count.innerText=selected_posts.length;
  4470. }
  4471. function ThreadMergeInput(elem){
  4472. if(elem.value.match(/[0-9]{14}/)) { Smerge_thread.href="?merge_threads=<?=$this->ActualPostID?> "+elem.value; }
  4473. else{ Smerge_thread.href="#"; }
  4474. }
  4475. function ToggleThreadMerge(force_on=false,force_off=false){
  4476. if((!merge_mode || force_on) && !force_off){ TogglePostSelectMode(false,true);
  4477. Smerge_thread_dialog.style.display="block";Smerge_thread_btn.classList.add('text_highlight');
  4478. Smerge_cancel.innerText='<?=$this->T("取消")?>'; merge_mode = 1;}
  4479. else{ merge_mode = 0;
  4480. Smerge_thread_dialog.style.display="none";Smerge_thread_btn.classList.remove('text_highlight');
  4481. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  4482. Smerge_thread.href="#";
  4483. Smerge_thread_target.value='';
  4484. }
  4485. <?php } ?>
  4486. function ShowSideUploader(){
  4487. ShowRightSide(true,null);
  4488. put = document.querySelector("#_uploader");
  4489. put.style.display='block';
  4490. RefreshSideGallery();
  4491. }
  4492. dmark = document.querySelector("#mark_details");
  4493. drename = document.querySelector("#rename_details");
  4494. dmastodon = document.querySelector("#mastodon_details");
  4495. drename_form = document.querySelector("#post_rename_form");
  4496. drename_input = document.querySelector("#post_rename_name");
  4497. var rp = document.querySelector('#post_reply_to');
  4498. var _reply_to = rp?rp.defaultValue:"";
  4499. function RestoreReply(){
  4500. if(rp){
  4501. rp.defaultValue = _reply_to;
  4502. }
  4503. document.querySelector('#post_reply_restore').style.display='none';
  4504. ht = document.querySelector('#post_hint_text');
  4505. if (_reply_to!=""){
  4506. ht.style.display='block';
  4507. ht.innerHTML="<?=$this->T('继续补充该话题:')?>";
  4508. }else{
  4509. ht.style.display='none';
  4510. }
  4511. document.querySelector('#post_edit_target').value="";
  4512. ch = document.querySelector('#post_hint_modify');
  4513. ch.style.display='none';
  4514. }
  4515. function MakeRefer(id){
  4516. t = document.querySelector('#post_content')
  4517. t.focus();
  4518. v = t.value;
  4519. t.value = v.slice(0, t.selectionStart) + "[<?=$this->T('引用文章')?>]("+id.toString()+")" + v.slice(t.selectionEnd);
  4520. la_auto_grow(t);
  4521. if(rp){
  4522. rp.defaultValue = "";
  4523. ht = document.querySelector('#post_hint_text');
  4524. ht.innerHTML = "<?=$this->T('引用并发送新话题:')?>"; ht.style.display='block';
  4525. document.querySelector('#post_reply_restore').style.display='inline';
  4526. rs = document.querySelector('#post_reply_restore');
  4527. rs.style.display='inline'; rs.innerHTML="<?=$this->T('切换为回复')?>";
  4528. document.getElementById('post_menu').style.display='none';
  4529. ch = document.querySelector('#post_hint_modify');
  4530. ch.style.display='none';
  4531. }
  4532. }
  4533. function CopyRefer(id){
  4534. copy_text(id.toString());
  4535. menu.querySelector('#menu_refer_copy').innerHTML="<?=$this->T('已复制')?>";
  4536. }
  4537. function MakeEdit(id){
  4538. ed = document.getElementById('menu_edit');
  4539. ed.innerHTML="<?=$this->T('稍等')?>";
  4540. ed.href="#";
  4541. var xhr = new XMLHttpRequest();
  4542. xhr.onreadystatechange = function() {
  4543. if (this.readyState == 4 && this.status == 200) {
  4544. ed.innerHTML='——';
  4545. ch = document.querySelector('#post_hint_modify');
  4546. ch.style.display='block';
  4547. ht = document.querySelector('#post_hint_text');
  4548. ht.innerHTML = "<?=$this->T('修改帖子:')?>";
  4549. rs = document.querySelector('#post_reply_restore');
  4550. rs.style.display='inline'; rs.innerHTML="<?=$this->T('取消')?>";
  4551. t = document.querySelector('#post_content');
  4552. t.value=xhr.responseText.trim();
  4553. t.focus();
  4554. la_auto_grow(t);
  4555. document.querySelector('#post_edit_target').value=id;
  4556. document.getElementById('post_menu').style.display='none';
  4557. }
  4558. };
  4559. xhr.open("GET", "index.php?post="+id.toString()+'&post_original=true', true);
  4560. xhr.send();
  4561. }
  4562. function MarkDelete(id){
  4563. p = document.querySelector('[data-post-id="'+id+'"]');
  4564. op = p.dataset.markDelete?"false":"true";
  4565. window.location.href=
  4566. "index.php?<?=$this->GetRedirect()?>&mark_delete="+op+'&target='+id.toString();
  4567. }
  4568. function SetMark(mark){
  4569. menu = document.getElementById('post_menu');
  4570. window.location.href=
  4571. "index.php?<?=$this->GetRedirect()?>&target="+
  4572. menu.parentNode.dataset.postId+"&set_mark="+mark;
  4573. }
  4574. function ToggleMarkDetails(){
  4575. dmark.style.display=(dmark.style.display=='block')?'none':'block';
  4576. drename.style.display=dmastodon.style.display='none';
  4577. }
  4578. function ToggleRenameDetails(){
  4579. drename.style.display=(drename.style.display=='block')?'none':'block';
  4580. dmark.style.display=dmastodon.style.display='none';
  4581. }
  4582. function ToggleMastodonDetails(){
  4583. dmastodon.style.display=(dmastodon.style.display=='block')?'none':'block';
  4584. dmark.style.display=drename.style.display='none';
  4585. }
  4586. <?php } ?>
  4587. function ShowPostMenu(post){
  4588. menu = document.getElementById('post_menu');
  4589. menu.style.display='block';
  4590. menu.parentNode.removeChild(menu);
  4591. post.appendChild(menu);
  4592. menu.style.display='block';
  4593. id = post.dataset.postId
  4594. menu.querySelector('#_time_hook').innerHTML = ''+id.substring(2,4)+'/'+id.substring(4,6)+'/'+id.substring(6,8)+
  4595. ' '+id.substring(8,10)+':'+id.substring(10,12);
  4596. window.onClick="HidePopMenu()";
  4597. menu.onClick=(function(event){
  4598. event.stopPropagation();
  4599. });
  4600. hs = menu.querySelector('#menu_history');
  4601. hs.href='?post='+id+'&history=1';
  4602. <?php if($this->LoggedIn && !isset($this->WayBack)){ ?>
  4603. menu.querySelector('#menu_refer').href='javascript:MakeRefer(id)';
  4604. ref = menu.querySelector('#menu_refer_copy')
  4605. ref.innerHTML='<?=$this->T("复制编号")?>';
  4606. ref.href='javascript:CopyRefer(id)';
  4607. ed = menu.querySelector('#menu_edit')
  4608. ed.href='javascript:MakeEdit(id)'; ed.innerHTML="<?=$this->T('修改')?>";
  4609. d = menu.querySelector('#menu_delete');
  4610. d.href='javascript:MarkDelete(\"'+id+'\")';
  4611. p = document.querySelector('[data-post-id="'+id+'"]');
  4612. d.innerHTML = p.dataset.markDelete?"<?=$this->T('恢复')?>":"<?=$this->T('删除')?>";
  4613. menu.querySelector('#mark_details').dataset.id=id;
  4614. drename_input.value=id;
  4615. drename_form.action="<?=$this->GetRedirect()?>"+"&rename_post="+id;
  4616. <?php if(isset($this->MastodonToken)){ ?>
  4617. dmastodon_form = document.querySelector("#post_mastodon_form");
  4618. dmastodon_form.action='?mastodon_post='+id;
  4619. function MastodonSend(id){
  4620. mastodon_send.innerHTML="<?=$this->T('稍等')?>";
  4621. var xhr = new XMLHttpRequest();
  4622. function wrapidxhr(_id) { return function() {
  4623. if (this.readyState == 4 && this.status == 200) {
  4624. var response = xhr.responseText;
  4625. let content="";
  4626. if(res = response.match(/SUCCESS (\S+)/u)){
  4627. content="<?=$this->T('成功发送到长毛象')?>";
  4628. }else{content="<b><?=$this->T('出现问题')?></b><br /><span class='smaller'>"+response+"</span>";}
  4629. mastodon_send.innerHTML=content; mastodon_send.href=res[1];
  4630. MarkPostDoneMastodon(_id, res[1]);
  4631. } }
  4632. };
  4633. xhr.onreadystatechange = wrapidxhr(id);
  4634. xhr.open("GET", "index.php?mastodon_send_post="+id, true); xhr.send();
  4635. }
  4636. menu_mastodon = menu.querySelector("#menu_mastodon");
  4637. mastodon_send = menu.querySelector("#menu_mastodon_send");
  4638. mastodon_view = menu.querySelector("#menu_mastodon_view");
  4639. mastodon_url = menu.querySelector("#post_mastodon_url");
  4640. if(p.dataset.mastodon_url){mastodon_view.style.display='inline';mastodon_view.href=p.dataset.mastodon_url;
  4641. mastodon_send.innerHTML='<?=$this->T("重新发送")?>'; mastodon_url.value=p.dataset.mastodon_url; }
  4642. else{mastodon_view.style.display='none';mastodon_view.href=""; mastodon_send.innerHTML="<?=$this->T('发送')?>";
  4643. mastodon_url.value="";}
  4644. mastodon_send.onclick=function(){
  4645. this.onclick=function(){};
  4646. MastodonSend(id); };
  4647. <?php } } ?>
  4648. title = document.title;
  4649. copy = document.getElementById('share_copy');
  4650. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  4651. copy.addEventListener("click", function(){
  4652. url = window.location
  4653. path = location.pathname
  4654. copy_text(url.protocol+"//"+url.host+path+"?post="+id);
  4655. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  4656. });
  4657. }
  4658. function HidePopMenu(){
  4659. var menus = document.querySelectorAll('.pop_menu');
  4660. [].forEach.call(menus, function(m){m.style.display='none';});
  4661. }
  4662. var posts = document.querySelectorAll('.center .post');
  4663. [].forEach.call(posts, function(p){
  4664. if(s=p.querySelector('._menu_hook')) s.addEventListener("click", function() {
  4665. ShowPostMenu(this.parentNode.parentNode);
  4666. });
  4667. });
  4668. var post_clickables = document.querySelectorAll('.center .post a');
  4669. [].forEach.call(post_clickables, function(p){
  4670. p.addEventListener("click", function(event){
  4671. event.stopPropagation();
  4672. });
  4673. });
  4674. function FindImage(imgsrc){
  4675. for(var i=0;i<document.images_filtered.length;i++){
  4676. if (document.images_filtered[i].dataset.imgsrc==imgsrc) return document.images_filtered[i]
  4677. }
  4678. return null
  4679. }
  4680. var dottime1;
  4681. var dottime2;
  4682. function ToDataURL(url) {
  4683. return fetch(url).then((response) => {return response.blob();}).then(blob => {
  4684. clearTimeout(dottime1);clearTimeout(dottime2);
  4685. ps = document.querySelector('#download_processing');
  4686. ps.innerHTML='↓';ps.style.opacity='';
  4687. return URL.createObjectURL(blob);});
  4688. }
  4689. async function DownloadAsImage(url,name) {
  4690. const a = document.createElement("a"); a.href = await ToDataURL(url); a.download = name;
  4691. document.body.appendChild(a); a.click(); document.body.removeChild(a);
  4692. }
  4693. function basename(url){return url.split(/[\\/]/).pop();}
  4694. pushed=0;
  4695. function ShowBigImage(imgsrc,do_push){
  4696. ShowWaitingBar();
  4697. share = document.querySelector('#big_image_share');
  4698. img = document.querySelector('#big_image');
  4699. vid = document.querySelector('#big_video');
  4700. vidsrc = document.querySelector('#big_video_src');
  4701. down = document.querySelector('#image_download');
  4702. img.src = ""; vidsrc.src="";
  4703. if(imgsrc.match(/\.mp4$/)){
  4704. vidsrc.src = src = "images/"+imgsrc; img.style.display='none'; vid.load();vid.style.display='block';
  4705. }else{
  4706. img.src = src = "images/"+imgsrc; vid.style.display='none';img.style.display='block';
  4707. }
  4708. down.href="images/"+imgsrc;
  4709. var downname='<?=$this->T($this->Title);?>_<?=$this->T($this->DisplayName);?>_<?=$this->GiveSafeEMail()?>_'+
  4710. basename(down.href);
  4711. img.alt = downname; down.download=downname;
  4712. var use_href = "images/"+imgsrc;
  4713. down.onclick=function(event){event.stopPropagation();event.preventDefault();
  4714. ps = this.querySelector('#download_processing');ps.innerText='…';
  4715. var dotwait = function(ps){ var self = this;
  4716. dottime1 = setTimeout(function(ps){
  4717. ps.style.opacity='0'; dottime2 = setTimeout(function(ps){ps.style.opacity='1'; dotwait(ps);},300,ps); },300,ps) }
  4718. dotwait(this.querySelector('#download_processing'));
  4719. DownloadAsImage(use_href,downname);};
  4720. if(do_push){PushGalleryHistory(src)}
  4721. page_url = encodeURIComponent(window.location.href);
  4722. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  4723. inqb = document.querySelector('#image_inquiry');
  4724. inqb.href="mailto:<?=$this->T($this->DisplayName);?>\<<?=$this->EMail?>\>?subject=<?=$this->T('网站图片咨询');?>&body="+
  4725. encodeURIComponent("<?=$this->T('你好!我对你网站上的这张图片感兴趣:')?>"+'\n\n')+
  4726. (page_url)+encodeURIComponent('\n\n');
  4727. <?php } ?>
  4728. this_image = FindImage(imgsrc);
  4729. if(this_image&&this_image.dataset.prevsrc){
  4730. new_image = FindImage(this_image.dataset.prevsrc);
  4731. new_prev = new_image?new_image.dataset.prevsrc:null;
  4732. im = document.querySelector('#prev_image');
  4733. if(new_prev) {im.href='javascript:ShowBigImage("'+this_image.dataset.prevsrc+'",'+do_push+')';im.style.opacity='';}
  4734. else {im.style.opacity='0';im.removeAttribute("href");}
  4735. }
  4736. if(this_image&&this_image.dataset.nextsrc){
  4737. new_image = FindImage(this_image.dataset.nextsrc);
  4738. new_next = new_image?new_image.dataset.nextsrc:null;
  4739. im = document.querySelector('#next_image');
  4740. if(new_next) {im.href='javascript:ShowBigImage("'+this_image.dataset.nextsrc+'",'+do_push+')';im.style.opacity='';}
  4741. else {im.style.opacity='0';im.removeAttribute("href");}
  4742. }
  4743. purchase = document.querySelector('#image_purchase');
  4744. purchase_btn = document.querySelector('#image_purchase_button');
  4745. <?php if($this->LoggedIn){ ?>
  4746. product_link = document.querySelector('#image_ops_product_link');
  4747. product_form = document.querySelector('#image_ops_form');
  4748. edit_form = document.querySelector('#image_edit_form');
  4749. edit_new_name = document.querySelector('#image_edit_new_name');
  4750. edit_parent = document.querySelector('#image_parent');
  4751. product_form.action = window.location.href;
  4752. edit_form.action = window.location.href;
  4753. edit_new_name.value = imgsrc.split('.')[0];
  4754. if(this_image&&this_image.dataset.product){ product_link.value = this_image.dataset.product; }else{ product_link.value = ""; }
  4755. if(this_image&&this_image.dataset.parent){ edit_parent.value = this_image.dataset.parent; }else{ edit_parent.value = ""; }
  4756. <?php } ?>
  4757. if(this_image&&this_image.dataset.product){
  4758. purchase.style.display='';
  4759. href = this_image.dataset.product;
  4760. if(this_image.dataset.product.match('^[0-9]{14}$')){
  4761. href = '?post='+href;
  4762. }
  4763. purchase_btn.href = href;
  4764. }else{
  4765. purchase.style.display='none';
  4766. purchase_btn.removeAttribute("href");
  4767. }
  4768. DelayHideImgBtn(null);
  4769. title = encodeURIComponent(document.title);
  4770. copy = document.getElementById('big_share_copy');
  4771. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  4772. copy.addEventListener("click", function(){
  4773. copy_text(window.location.href);
  4774. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  4775. });
  4776. o = document.querySelector('#big_image_overlay');
  4777. info = document.querySelector('#big_image_info');info.innerHTML="<?=$this->T('正在查询……')?>";
  4778. here = document.querySelector('#here_buttons');here.innerHTML='';
  4779. o.style.display="block";
  4780. ShowBackdrop(0.8);
  4781. var xhr = new XMLHttpRequest();
  4782. xhr.onreadystatechange = function() {
  4783. if (this.readyState == 4 && this.status == 200) {
  4784. info = document.querySelector('#big_image_info');
  4785. var response = xhr.responseText;
  4786. let content=""
  4787. if(res = response.match(/<ref>(.*)<\/ref>/u)){
  4788. content="<span class='small'><?=$this->T('该图片出现在')?> "+res[1]+" <?=$this->T('个帖子中')?></span>"+content;
  4789. }else{content="<span class='smaller gray'><?=$this->T('该图片未被引用')?></span>"+content;}
  4790. if(res = response.match(/<insert>([\s\S]*)<\/insert>/u)){
  4791. content+="<div class='clean_a'>"+res[1]+"</div>"; }
  4792. info.innerHTML=content;
  4793. if(res = response.match(/<here>([\s\S]*)<\/here>/u)){
  4794. here.innerHTML=res[1]; window.here_b=document.getElementsByClassName('here_btn');
  4795. if(window.here_b)for(b=0;b<window.here_b.length;b++) {
  4796. window.here_b[b].addEventListener('mousemove',DontHideImgBtn);
  4797. window.here_b[b].addEventListener('mouseover',DontHideImgBtn);}
  4798. }
  4799. }
  4800. };
  4801. xhr.open("GET", "index.php?image_info="+imgsrc+"", true);
  4802. xhr.send();
  4803. }
  4804. function HideBigImage(do_push){
  4805. o = document.querySelector('#big_image_overlay');
  4806. img = document.querySelector('#big_image');
  4807. vid = document.querySelector('#big_video');
  4808. vidsrc = document.querySelector('#big_video_src');
  4809. img.src = ""; vidsrc.src="";
  4810. if(o.style.display!='none'){
  4811. o.style.display="none";
  4812. HideBackdrop();
  4813. if(do_push){PushGalleryHistory("");}
  4814. HideWaitingBar();
  4815. }
  4816. }
  4817. var lbtn=document.querySelector('#prev_image'),rbtn=document.querySelector('#next_image');
  4818. var inq=document.querySelector('#inquiry_buttons');
  4819. var overlay=document.querySelector('#big_image_overlay');
  4820. var hide_timeout;
  4821. function DontHideImgBtn(e){ clearTimeout(hide_timeout); e.stopPropagation(); }
  4822. function DelayHideImgBtn(e){
  4823. lbtn.classList.remove('img_btn_hidden'); rbtn.classList.remove('img_btn_hidden');
  4824. inq.classList.remove('img_btn_hidden');
  4825. if(window.here_b)for(b=0;b<window.here_b.length;b++){window.here_b[b].classList.remove('img_btn_hidden');}
  4826. clearTimeout(hide_timeout);
  4827. hide_timeout = setTimeout(function(e1,e2,e3,e4){e1.classList.add('img_btn_hidden');
  4828. e2.classList.add('img_btn_hidden');e3.classList.add('img_btn_hidden');
  4829. if(window.here_b)for(b=0;b<window.here_b.length;b++){
  4830. window.here_b[b].classList.add('img_btn_hidden');}}, 1000, lbtn, rbtn, inq);
  4831. }
  4832. lbtn.addEventListener('mousemove',DontHideImgBtn);lbtn.addEventListener('mouseover',DontHideImgBtn);
  4833. rbtn.addEventListener('mousemove',DontHideImgBtn);rbtn.addEventListener('mouseover',DontHideImgBtn);
  4834. inq.addEventListener('mousemove',DontHideImgBtn);inq.addEventListener('mouseover',DontHideImgBtn);
  4835. overlay.addEventListener('mousemove',DelayHideImgBtn);
  4836. var images = document.querySelectorAll('img, video');
  4837. var images_filtered=new Array(); var imgadded = new Array();
  4838. var images_remaining=new Array();
  4839. [].forEach.call(images, function(img){
  4840. if(img.classList.contains("no_pop") || (!(imgsrc = img.dataset.imgsrc))) return;
  4841. if(imgadded.indexOf(imgsrc)>=0) {images_remaining.push(img); return;}
  4842. images_filtered.push(img);imgadded.push(imgsrc);
  4843. });
  4844. for(var i=0; i<images_filtered.length; i++){
  4845. previmg = nextimg = null; img = images_filtered[i];
  4846. if(i>0) previmg=images_filtered[i-1];
  4847. if(i<images_filtered.length-1) nextimg=images_filtered[i+1];
  4848. prevsrc=previmg?previmg.dataset.imgsrc:null; nextsrc=nextimg?nextimg.dataset.imgsrc:null;
  4849. img.dataset.prevsrc = prevsrc; img.dataset.nextsrc = nextsrc;
  4850. function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
  4851. img.addEventListener("click", wrap(img.dataset.imgsrc));
  4852. }
  4853. for(var i=0; i<images_remaining.length; i++){
  4854. img = images_remaining[i];
  4855. function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
  4856. img.addEventListener("click", wrap(img.dataset.imgsrc));
  4857. }
  4858. document.images_filtered = images_filtered;
  4859. function PopGalleryHistory(){
  4860. if(pushed){
  4861. pushed = 0;
  4862. try{
  4863. history.back();
  4864. }catch{
  4865. console.log("can't do it.");
  4866. }
  4867. }
  4868. }
  4869. function PushGalleryHistory(src){
  4870. abs_img = window.location.protocol+"//"+window.location.host+'/'+src
  4871. title = "照片"
  4872. extra = "?";
  4873. sp = new URLSearchParams(window.location.search)
  4874. if(sp.has('post')){extra+="post="+sp.get('post')}
  4875. if(sp.has('gallery')){extra+="&gallery="+sp.get('gallery')}
  4876. try{
  4877. window.history.pushState('&pic='+src, 'Title', extra+'&pic='+src);
  4878. }catch{
  4879. console.log("can't do it.");
  4880. }
  4881. pushed = 1;
  4882. }
  4883. document.addEventListener('keydown', function(e){
  4884. large = document.getElementById('big_image_overlay')
  4885. if (large.style.display!='block') return;
  4886. if(e.key=='Escape'||e.key=='Esc'||e.keyCode==27){
  4887. HideBigImage(1);
  4888. }
  4889. }, true);
  4890. window.addEventListener('popstate', (event) => {
  4891. if(event.state){
  4892. let sp = new URLSearchParams(event.state)
  4893. if(sp.has('pic')){
  4894. src = sp.get('pic')
  4895. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)) ShowBigImage(onlyimg[0], 0);
  4896. else{HideBigImage(0);}
  4897. }
  4898. }else{HideBigImage(0);}
  4899. });
  4900. let searchParams = new URLSearchParams(window.location.search)
  4901. if(searchParams.has('pic')){
  4902. src = searchParams.get('pic')
  4903. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)){
  4904. ShowBigImage(onlyimg[0], 1);
  4905. }
  4906. }
  4907. function _dropHandler(event){ if (typeof dropHandler === "function") dropHandler(event); }
  4908. function _dragOverHandler(event){ if (typeof dragOverHandler === "function") dragOverHandler(event); }
  4909. </script>
  4910. </body>
  4911. <?php
  4912. }
  4913. function DoIdentifyExperimental(){
  4914. if(isset($this->ExpHost) && $this->ExpHost && preg_match('/'.preg_quote($this->ExpHost).'/u', $_SERVER['HTTP_HOST'])){
  4915. $this->InExperimentalMode=True; $this->InHereMode=True;
  4916. }
  4917. if(isset($this->HereHost) && $this->HereHost && preg_match('/'.preg_quote($this->HereHost).'/u', $_SERVER['HTTP_HOST'])){
  4918. $this->InHereMode=True;
  4919. }
  4920. }
  4921. function DoExperimentalTopLink($p){
  4922. if($this->InHereMode && $p){
  4923. if(isset($p['tid']) && $p['tid']['first']!=$p){
  4924. header('Location: ?post='.$p['tid']['first']['id']); exit();
  4925. }
  4926. }
  4927. }
  4928. function MakeExperimentalConfirm(){
  4929. if(isset($_COOKIE['la_experimental']) && $_COOKIE['la_experimental'] == 'confirmed'){
  4930. return false;
  4931. }
  4932. $caution_html =
  4933. $confirm = "<a class='text_highlight clean_a bold' href='index.php?confirm_enter=1".
  4934. (isset($this->CurrentPostID)?("&post=".$this->CurrentPostID):"").
  4935. "'>&nbsp;&nbsp;".$this->T('继续')."&nbsp;&nbsp;</a>";
  4936. ?>
  4937. <div class='center_exp'><?php
  4938. if(isset($this->ExpCaution) && ($p=$this->GetPost($this->ExpCaution,true)))$this->MakeSinglePostExp($p);
  4939. else echo "<li class='post post_dummy'>".$this->TranslatePostParts("<h1>注意</h1><p>您将进入实验站。</p>")."</li>";
  4940. ?></div>
  4941. <div class='center_exp'><li class='post post_dummy'><p><?=$confirm?></p></li></div>
  4942. <?php return true;
  4943. }
  4944. }
  4945. $la = new LA;
  4946. $la->DoSiteRedirect();
  4947. $la->DoLogin();
  4948. $la->SwitchLanguageAndFont();
  4949. $err = $la->ProcessRequest($message, $redirect);
  4950. $la->WriteAsNecessary();
  4951. $la->DoIdentifyExperimental();
  4952. $la->SwitchWayBackMode();
  4953. if($err){
  4954. echo $message;
  4955. exit();
  4956. }
  4957. if(isset($redirect)){
  4958. header('Location: '.$redirect);
  4959. exit();
  4960. }
  4961. $la->DetectPageType();
  4962. $la->ReadImages(false);
  4963. $la->ReadPosts();
  4964. if(isset($la->WayBack)){
  4965. $la->ReadArchive();
  4966. }
  4967. $im = NULL;
  4968. if(preg_match('/images\/(.*)/u',$la->HereID,$imname) && ($im = &$la->FindImage($imname[1]))){
  4969. if(!$la->CanShowImage($im)) { $im=&$la->NULL_IMAGE; }
  4970. }
  4971. $p = &$la->GetPost($la->CurrentPostID);
  4972. if(!isset($p)){
  4973. $p = &$la->GetMergedPost($la->CurrentPostID);
  4974. }
  4975. if(isset($p) && !$la->CanShowPost($p)) $p=NULL;
  4976. else{ $la->DoExperimentalTopLink($p); }
  4977. if(isset($p)){ $la->ActualPostID = $p['id']; }
  4978. if($la->PageType=='here' ||$la->PageType=='experimental'){
  4979. if($im){
  4980. $la->SetHereMainImage($im);
  4981. $la->RecordVisitedHere($im['name'],$im?$la->ImageTitle($im):NULL);
  4982. }else if($p){
  4983. $la->RecordVisitedHere($p['id'],NULL);
  4984. }else {
  4985. $im = &$la->GiveImageInHere(false);
  4986. if($im){
  4987. $la->SetHereMainImage($im);
  4988. $la->RecordVisitedHere($im['name'],$la->ImageTitle($im));
  4989. }
  4990. }
  4991. }
  4992. $la->MakeHeader($p);
  4993. $la->MakeMainBegin();
  4994. if($la->PageType=='here' ||$la->PageType=='experimental'){
  4995. if(($la->PageType=='experimental' && (!$la->MakeExperimentalConfirm())) || $la->PageType=='here'){
  4996. if($im){
  4997. $la->MakeHereSection($im);
  4998. }else if($p){
  4999. $la->MakePostSectionExp($p);
  5000. $la->MakeLinkedPostsExp($p);
  5001. }else {
  5002. if($im){
  5003. $la->MakeHereSection($im);
  5004. }else{
  5005. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5006. "</p><p><a href='index.php'>".$la->T('返回首页')."</a></p><br />";
  5007. }
  5008. }
  5009. }
  5010. $la->MakeMainEnd();
  5011. $la->MakeExpFooter();
  5012. }else{
  5013. if($la->PageType=='extras'){
  5014. $la->MakeExtraOperations();
  5015. }else if($la->PageType=='settings'){
  5016. $la->MakeSettings();
  5017. }else if($la->PageType=='gallery'){
  5018. $la->MakeGalleryLeft();
  5019. $la->MakeGallerySection();
  5020. }else if($la->PageType=='post'){
  5021. if($p){
  5022. $made_interesting = false;
  5023. if($la->IsInterestingPost($p)){
  5024. $la->MakeInterestingSection($p['tid']);
  5025. }
  5026. else{
  5027. $la->MakeLinkedPosts($p);
  5028. $la->MakePostSection($p);
  5029. $la->MakeTOC();
  5030. }
  5031. }else{
  5032. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5033. "</p><p><a href='index.php'>".$la->T('返回首页')."</a></p><br />";
  5034. }
  5035. }else if($la->PageType=='history'){
  5036. $la->ReadArchive();
  5037. $la->MakePostHistory($p, $_GET['version']??NULL);
  5038. }else if($la->PageType=='search'){
  5039. $la->MakeHotPosts(true);
  5040. $la->MakeRecentPosts($_GET['search']);
  5041. }else if($la->PageType=='category'){
  5042. $la->MakeHotPosts(true);
  5043. $la->MakeRecentPosts(NULL,$_GET['category']);
  5044. }else if($la->PageType=='comments'){
  5045. $la->MakeCommentPosts();
  5046. }else{
  5047. $la->MakeHotPosts();
  5048. $la->MakeRecentPosts();
  5049. }
  5050. $la->MakeMainEnd();
  5051. $la->MakeFooter($p);
  5052. }
  5053. ?>