*/}}

index.php 315 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491
  1. <?php
  2. include 'Parsedown.php';
  3. include 'ParsedownExtra.php';
  4. ini_set('max_execution_time', 300);
  5. ini_set('display_errors', '1');
  6. ini_set('display_startup_errors', '1');
  7. error_reporting(E_ALL);
  8. class LA{
  9. protected $PDE;
  10. protected $style;
  11. /* config */
  12. protected $Title;
  13. protected $ShortTitle;
  14. protected $Admin;
  15. protected $Password;
  16. protected $DisplayName;
  17. protected $EMail;
  18. protected $SpecialNavigation;
  19. protected $SpecialSidebar;
  20. protected $SpecialFooter;
  21. protected $SpecialFooter2;
  22. protected $SpecialPinned;
  23. protected $DefaultGallery;
  24. protected $SelfAuthPath;
  25. protected $HereHost;
  26. protected $HereTitle;
  27. protected $HereShortTitle;
  28. protected $HereAlbum;
  29. protected $HereNavigation;
  30. protected $HereFooter;
  31. protected $ExpHost;
  32. protected $ExpAlbum;
  33. protected $ExpTitle;
  34. protected $ExpShortTitle;
  35. protected $ExpCaution;
  36. protected $ExpNavigation;
  37. protected $ExpFooter;
  38. protected $CommentEnabled;
  39. protected $MastodonToken;
  40. protected $MastodonURL;
  41. protected $MastodonPreferredLang;
  42. protected $HostURL;
  43. protected $GalleryStep;
  44. protected $AllowLanguageChoices;
  45. protected $Redirect;
  46. protected $Translations;
  47. protected $CustomTranslationContent;
  48. protected $CurrentOffset;
  49. protected $PostsPerPage;
  50. protected $HotPostCount;
  51. protected $LoggedIn;
  52. protected $LoginTokens;
  53. protected $InHereMode;
  54. protected $InExperimentalMode;
  55. protected $LanguageAppendix;
  56. protected $UseRemoteFont;
  57. protected $Posts;
  58. protected $Threads; // [ keys: first last displayed count]
  59. protected $WaybackThreads;
  60. public $Images;
  61. protected $Galleries;
  62. protected $Anchors;
  63. protected $ArchiveHandles;
  64. protected $Archive;
  65. public $WayBack;
  66. protected $YearBegin;
  67. protected $YearEnd;
  68. protected $Markers;
  69. protected $ExtraScripts;
  70. protected $APubID;
  71. protected $APubActor;
  72. protected $APubPublicKey;
  73. protected $APubPrivateKey;
  74. protected $TIME_STRING;
  75. public $NULL_POST;
  76. public $NULL_IMAGE;
  77. public $NULL_IMAGE_DUMMY;
  78. public $NULL_Gallery;
  79. protected $DoneReadPosts;
  80. protected $DoneReadImages;
  81. protected $DoneReadArchive;
  82. protected $NeedWritePosts;
  83. protected $NeedWriteImages;
  84. protected $NeedWriteArchive;
  85. protected $HereDisplayTitle;
  86. protected $VisitedHere;
  87. protected $HereNumber;
  88. protected $HereMainImage;
  89. public $PageType;
  90. public $CurrentPostID;
  91. public $HereID;
  92. public $ActualPostID;
  93. public $TagID;
  94. function ReadableTime($id){
  95. $dt = DateTime::createFromFormat('YmdHis', $id);
  96. return $dt->format('Y/m/d H:i:s');
  97. }
  98. function StandardTime($id){
  99. $dt = DateTime::createFromFormat('YmdHis', $id);
  100. return $dt->format('Y-m-d\TH:i:sP');
  101. }
  102. function FullURL(){
  103. return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?
  104. "https" : "http") . "://" . $_SERVER['HTTP_HOST'] .
  105. $_SERVER['REQUEST_URI'];
  106. }
  107. function T($str){
  108. if(!$this->LanguageAppendix) return $str;
  109. foreach($this->Translations as $entry){
  110. if($entry['zh']==$str)
  111. return $entry[$this->LanguageAppendix];
  112. }
  113. return $str;
  114. }
  115. function SwitchLanguageAndFont(){
  116. $this->LanguageAppendix = 'zh';
  117. if(isset($_COOKIE['la_language'])){
  118. $this->LanguageAppendix = $_COOKIE['la_language'];
  119. }else{
  120. if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
  121. $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  122. $lang = substr($lang,0,5);
  123. if(preg_match("/zh/i",$lang))$this->LanguageAppendix = 'zh';
  124. else $this->LanguageAppendix = 'en';
  125. }
  126. }
  127. if(isset($_COOKIE['la_font'])){
  128. $this->UseRemoteFont = ($_COOKIE['la_font']!='local');
  129. }
  130. }
  131. function SwitchWayBackMode(){
  132. if(isset($_COOKIE['la_wayback'])){
  133. $this->WayBack = $_COOKIE['la_wayback'];
  134. }else $this->WayBack = NULL;
  135. }
  136. function DisplayRedirectConfig(){
  137. $s = "";
  138. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  139. if($r['for']=='P'){
  140. $s.=("P ".$r['format'].":".$r['target'].";".PHP_EOL);
  141. }else if($r['for']=='S'){
  142. $s.=("S ".$r['format'].":".$r['domain'].":".$r['target'].";".PHP_EOL);
  143. }
  144. }
  145. return $s;
  146. }
  147. function DoSiteRedirect(){
  148. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  149. if($r['for']=='S'){
  150. if(preg_match('/'.$r['format'].'/ui', $_SERVER['HTTP_HOST'])){
  151. if($_SERVER['REQUEST_URI']=='/'||$_SERVER['REQUEST_URI']==''){
  152. header('Location:https://'.$r['domain'].'/index.php?post='.$r['target']); exit;
  153. }else{
  154. header('Location:https://'.$r['domain'].$_SERVER['REQUEST_URI']); exit;
  155. }
  156. }
  157. }
  158. }
  159. }
  160. function WriteHTACCESS(){
  161. $conf = fopen('.htaccess','w');
  162. fwrite($conf,"RewriteEngine on".PHP_EOL.PHP_EOL);
  163. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  164. if($r['for']=='P'){
  165. if(!preg_match('/[0-9]{14}/',$r['target'])){
  166. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?'.$r['target'].' [R=302,L]'.PHP_EOL.PHP_EOL);
  167. }
  168. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?post='.$r['target'].' [R=302,L]'.PHP_EOL.PHP_EOL);
  169. }// do site redirect in php.
  170. }
  171. fwrite($conf, 'RewriteCond %{HTTPS} !=on'.PHP_EOL.
  172. 'RewriteCond %{HTTP_HOST} !=localhost'.PHP_EOL.
  173. 'RewriteCond %{REQUEST_URI} !^.*(jpg|png|gif)$'.PHP_EOL.
  174. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]'.PHP_EOL.PHP_EOL);
  175. fwrite($conf,'<Files ~ "\.md$">'.PHP_EOL.'deny from all'.PHP_EOL.'</Files>'.PHP_EOL);
  176. fflush($conf);fclose($conf);
  177. }
  178. function BuildRedirectConfig($conf){
  179. $this->Redirect=[];
  180. if(preg_match_all('/P\s+(.*)\:\s*([0-9]{14}|.+)\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  181. foreach($ma as $m){
  182. $redirect=[]; $redirect['for'] = 'P'; $redirect['format'] = $m[1]; $redirect['target'] = $m[2];
  183. $this->Redirect[]=$redirect;
  184. }
  185. }
  186. if(preg_match_all('/S\s+(\S+)\s*\:\s*(\S+)\s*\:\s*([0-9]{14})\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  187. foreach($ma as $m){
  188. $redirect=[]; $redirect['for'] = 'S'; $redirect['format'] = $m[1]; $redirect['domain'] = $m[2]; $redirect['target'] = $m[3];
  189. $this->Redirect[]=$redirect;
  190. }
  191. }
  192. }
  193. function WriteTokens(){
  194. $tf = fopen('la_tokens.php','w');
  195. fwrite($tf,'<?php header("Location:index.php"); exit; ?>'.PHP_EOL.PHP_EOL);
  196. if(isset($this->LoginTokens) && sizeof($this->LoginTokens)) {
  197. foreach($this->LoginTokens as $t){
  198. fwrite($tf,'- '.$t.PHP_EOL);
  199. }
  200. }
  201. fflush($tf);fclose($tf);
  202. }
  203. function WriteConfig(){
  204. if(!isset($this->Title)) $this->Title = $this->T('那么的维基');
  205. if(!isset($this->ShortTitle)) $this->ShortTitle = $this->T('基');
  206. if(!isset($this->Admin)) $this->Admin = 'admin';
  207. if(!isset($this->DisplayName)) $this->DisplayName = $this->T('管理员');
  208. if(!isset($this->Password)) $this->Password = password_hash('Admin', PASSWORD_DEFAULT).PHP_EOL;
  209. $conf = fopen('la_config.php','w');
  210. fwrite($conf,'<?php header("Location:index.php"); exit; ?> '.PHP_EOL.PHP_EOL);
  211. fwrite($conf,'- Title = '.$this->Title.PHP_EOL);
  212. fwrite($conf,'- ShortTitle = '.$this->ShortTitle.PHP_EOL);
  213. fwrite($conf,'- Admin = '.$this->Admin.PHP_EOL);
  214. fwrite($conf,'- DisplayName = '.$this->DisplayName.PHP_EOL);
  215. fwrite($conf,'- Password = '.$this->Password.PHP_EOL);
  216. fwrite($conf,'- EMail = '.$this->EMail.PHP_EOL);
  217. fwrite($conf,'- SpecialNavigation = '.$this->SpecialNavigation.PHP_EOL);
  218. fwrite($conf,'- SpecialSidebar = '.$this->SpecialSidebar.PHP_EOL);
  219. fwrite($conf,'- SpecialFooter = '.$this->SpecialFooter.PHP_EOL);
  220. fwrite($conf,'- SpecialFooter2 = '.$this->SpecialFooter2.PHP_EOL);
  221. fwrite($conf,'- SpecialPinned = '.$this->SpecialPinned.PHP_EOL);
  222. fwrite($conf,'- DefaultGallery = '.$this->DefaultGallery.PHP_EOL);
  223. fwrite($conf,'- SelfAuthPath = '.$this->SelfAuthPath.PHP_EOL);
  224. fwrite($conf,'- CommentEnabled = '.($this->CommentEnabled?"True":"False").PHP_EOL);
  225. fwrite($conf,'- HereHost = '.$this->HereHost.PHP_EOL);
  226. fwrite($conf,'- HereTitle = '.$this->HereTitle.PHP_EOL);
  227. fwrite($conf,'- HereShortTitle = '.$this->HereShortTitle.PHP_EOL);
  228. fwrite($conf,'- HereAlbum = '.$this->HereAlbum.PHP_EOL);
  229. fwrite($conf,'- HereNavigation = '.$this->HereNavigation.PHP_EOL);
  230. fwrite($conf,'- HereFooter = '.$this->HereFooter.PHP_EOL);
  231. fwrite($conf,'- ExpHost = '.$this->ExpHost.PHP_EOL);
  232. fwrite($conf,'- ExpTitle = '.$this->ExpTitle.PHP_EOL);
  233. fwrite($conf,'- ExpShortTitle = '.$this->ExpShortTitle.PHP_EOL);
  234. fwrite($conf,'- ExpCaution = '.$this->ExpCaution.PHP_EOL);
  235. fwrite($conf,'- ExpAlbum = '.$this->ExpAlbum.PHP_EOL);
  236. fwrite($conf,'- ExpNavigation = '.$this->ExpNavigation.PHP_EOL);
  237. fwrite($conf,'- ExpFooter = '.$this->ExpFooter.PHP_EOL);
  238. fwrite($conf,'- MastodonToken = '.$this->MastodonToken.PHP_EOL);
  239. fwrite($conf,'- MastodonURL = '.$this->MastodonURL.PHP_EOL);
  240. fwrite($conf,'- MastodonPreferredLang = '.$this->MastodonPreferredLang.PHP_EOL);
  241. fwrite($conf,'- HostURL = '.$this->HostURL.PHP_EOL);
  242. fwrite($conf,'- APubID = '.$this->APubID.PHP_EOL);
  243. fwrite($conf,'- GalleryStep = '.$this->GalleryStep.PHP_EOL);
  244. fwrite($conf,'- AllowLanguageChoices = '.$this->AllowLanguageChoices.PHP_EOL);
  245. fflush($conf);fclose($conf);
  246. $conf = fopen('la_redirect.md','w');
  247. fwrite($conf,$this->DisplayRedirectConfig());fflush($conf);fclose($conf);
  248. $this->WriteHTACCESS();
  249. $this->WriteTokens();
  250. }
  251. function Install(){
  252. if(!file_exists('la_config.php')){
  253. $this->WriteConfig();
  254. }
  255. if(!is_dir('posts')) mkdir('posts');
  256. if(!is_dir('images')) mkdir('images');
  257. if(!is_dir('images/thumb')) mkdir('images/thumb');
  258. if(!is_dir('styles')) mkdir('styles');
  259. if(!is_dir('archive')) mkdir('archive');
  260. $this->WriteStyles();
  261. $this->WriteHTACCESS();
  262. }
  263. function ReadFromExistingConfig(){
  264. $f=null;
  265. if(file_exists('la_config.php')) $f='la_config.php';
  266. else if(file_exists('la_config.md')) $f='la_config.md';
  267. if(!isset($f)) return;
  268. $c = file_get_contents($f);
  269. if(preg_match_all('/-\s*(\S+)\s*=\s*(\S+)\s*$/um', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  270. $str = $m[1];
  271. $this->$str = $m[2];
  272. }
  273. $this->CommentEnabled = $this->CommentEnabled=="True";
  274. if(!isset($this->GalleryStep)) $this->GalleryStep=20;
  275. }
  276. function ReadConfig(){
  277. $this->ReadFromExistingConfig();
  278. if(file_exists('la_redirect.md')){
  279. $c = file_get_contents('la_redirect.md');
  280. $this->BuildRedirectConfig($c);
  281. }
  282. if(!file_exists('la_config.php')){
  283. $this->Install();
  284. }
  285. $this->Translations=[];
  286. if(file_exists("translations.md")){
  287. $c = file_get_contents('translations.md');
  288. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  289. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  290. $this->Translations[] = $entry;
  291. }
  292. }
  293. if(file_exists("custom_translations.md")){
  294. $this->CustomTranslationContent = file_get_contents('custom_translations.md');
  295. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$this->CustomTranslationContent, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  296. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  297. $this->Translations[] = $entry;
  298. }
  299. }
  300. $this->LoginTokens=[];
  301. if(file_exists('la_tokens.php')){
  302. $c = file_get_contents('la_tokens.php');
  303. if(preg_match_all('/-\s+(\S.*)\s*$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  304. $this->LoginTokens[] = $m[1];
  305. }
  306. }
  307. }
  308. function MastodonPostStatus($status){ return $this->MastodonCall('/api/v1/statuses', 'POST', $status); }
  309. function MastodonPostMedia($media){ return $this->MastodonCall('/api/v1/media', 'POST', $media); }
  310. function MastodonCall($endpoint, $method, $data){
  311. $headers = [
  312. 'Authorization: Bearer '.$this->MastodonToken,
  313. 'Content-Type: multipart/form-data',
  314. ];
  315. $ch = curl_init();
  316. curl_setopt($ch, CURLOPT_URL, $this->MastodonURL.$endpoint);
  317. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  318. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  319. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  320. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  321. $reply = curl_exec($ch);
  322. if (!$reply) {
  323. return json_encode(['ok'=>false, 'curl_error_code' => curl_errno($ch_status), 'curl_error' => curl_error(ch_status)]);
  324. }
  325. curl_close($ch);
  326. return json_decode($reply, true);
  327. }
  328. function MastodonSendPost(&$post, &$errmsg=NULL){
  329. if(isset($post['mark_value']) && $post['mark_value']==7){ return NULL; }
  330. $this->LanguageAppendix = 'zh';
  331. if(in_array($this->MastodonPreferredLang,['en','zh'])){ $this->LanguageAppendix = $this->MastodonPreferredLang; }
  332. $this->ConvertPost($post);
  333. $media_ids = NULL;
  334. $mastodon_post_url = NULL;
  335. $imcount = 0;
  336. if(isset($post['original_images']) && isset($post['original_images'][0])) foreach($post['original_images'] as $im){
  337. $curl_file = curl_file_create($im, mime_content_type($im), basename($im));
  338. $body = ['file' => $curl_file,]; $response = $this->MastodonPostMedia($body);
  339. if(isset($response['id'])){ if(!isset($media_ids)){$media_ids=[];} $media_ids[]=$response['id']; }
  340. else{ if(isset($response['error'])) $errmsg.=$response['error']."<br /><br />"; }
  341. $imcount++; if($imcount>=4){ break; }
  342. }
  343. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$post['html']));
  344. if(isset($this->HostURL) && $this->HostURL!=""){
  345. $text.=("\n\n".$this->T('来自').' '.$this->HostURL.'?post='.$post['id']);
  346. }
  347. $vis = (isset($post['mark_value']) && $post['mark_value']==6)?"private":"public";
  348. $status_data = [ 'status' => $text, 'visibility' => $vis, 'language' => $this->LanguageAppendix, ];
  349. if(isset($post['prev']) && ($pp=&$this->GetPost($post['prev']))!=$this->NULL_POST){
  350. if(isset($pp['mastodon_url'])){ $status_data['in_reply_to_id'] = basename($pp['mastodon_url']);
  351. }
  352. }
  353. if(isset($media_ids[0])){ $status_data['media_ids']=$media_ids; }
  354. $status_data = preg_replace('/(media_ids%5B)[0-9]+(%5D)/','$1$2', http_build_query($status_data));
  355. $status_response = $this->MastodonPostStatus($status_data);
  356. if(isset($status_response['url']) && $status_response['url']){
  357. $mastodon_post_url = $status_response['url'];
  358. $post['mastodon_url'] = $mastodon_post_url;
  359. $this->NeedWritePosts = 1;
  360. }
  361. if(isset($status_response['error'])) { $errmsg .= $status_response['error']; }
  362. return $mastodon_post_url;
  363. }
  364. function __construct() {
  365. $this->ReadConfig();
  366. $this->PDE = new ParsedownExtra();
  367. $this->PDE->SetInterlinkPath('/');
  368. $this->Posts = [];
  369. $this->Threads = [];
  370. $this->VisitedHere = [];
  371. $this->NULL_IMAGE_DUMMY = [];
  372. $this->NULL_IMAGE_DUMMY['name']=$this->NULL_IMAGE_DUMMY['file']=$this->NULL_IMAGE_DUMMY['thumb']="";
  373. $this->Markers=['●', '○', '✓', '×', '!', 'P', 'E', 'S'];
  374. $this->PostsPerPage = 40;
  375. $this->CommentsPerPage = 100;
  376. $this->HotPostCount = 15;
  377. $this->TIME_STRING = date('YmdHis');
  378. $this->WayBack = NULL;
  379. $this->YearBegin = $this->YearEnd = 2000;
  380. $this->DoneReadPosts = $this->DoneReadImages = $this->DoneReadArchive = false;
  381. $this->NeedWritePosts= $this->NeedWriteImages= $this->NeedWriteArchive= false;
  382. $this->UsePosts = &$this->Posts;
  383. }
  384. function DoLogout(){
  385. $this->LoggedIn = false;
  386. unset($_SESSION['user_id']);
  387. $this->RecordToken(true);
  388. }
  389. function RecordToken($unset_current=false){
  390. if(isset($unset_current) && isset($_COOKIE['la_token'])){
  391. $t = $_COOKIE['la_token'];
  392. setcookie('la_token', null, -1); unset($_COOKIE['la_token']);
  393. if (($key = array_search($t,$this->LoginTokens)) !== false) { unset($this->LoginTokens[$key]); }
  394. $this->WriteTokens();
  395. return null;
  396. }else{
  397. $t = uniqid('la_',true);
  398. setcookie('la_token',$t,time()+3600*24*7); $_COOKIE['la_token'] = $t;
  399. $this->LoginTokens[] = $t;
  400. $this->WriteTokens();
  401. return $t;
  402. }
  403. }
  404. function LoginThroughToken(){
  405. if(!isset($_COOKIE['la_token'])) return false;
  406. $t = $_COOKIE['la_token'];
  407. if (($key = array_search($t,$this->LoginTokens)) !== false) {
  408. $_SESSION['user_id']=$this->Admin;
  409. $this->LoggedIn = true;
  410. setcookie('la_token',$t,time()+3600*24*7);
  411. return true;
  412. }
  413. return false;
  414. }
  415. function DoLogin(){
  416. session_start();
  417. $redirect=false;
  418. if(isset($_GET['logout'])){ $this->DoLogout(); header('Location:index.php'); }
  419. else if(!isset($_SESSION['user_id'])){
  420. if(isset($_POST['login_button'])){
  421. $id = trim($_POST['login_id']);
  422. $pwd = trim($_POST['login_password']);
  423. if(strtolower($this->Admin)==strtolower($id)&&password_verify($pwd, $this->Password)){
  424. $_SESSION['user_id']=$id;
  425. $this->RecordToken(false);
  426. }
  427. $redirect = true;
  428. }else if($this->LoginThroughToken()){
  429. // nothing;
  430. }
  431. }else{
  432. if(strtolower($_SESSION['user_id']) == strtolower($this->Admin)){ $this->LoggedIn = true; }
  433. else{ $this->DoLogout();}
  434. }
  435. if($redirect){
  436. header('Location:index.php'.(isset($_GET['post'])?("?post=".$_GET['post']):"")
  437. .(isset($_GET['settings'])?"?settings=true":""));
  438. }
  439. }
  440. function SetHereMainImage($im_this){
  441. if(isset($im_this) && isset($im_this['parent'])){ $this->HereMainImage = &$this->FindImage($im_this['parent'],true);}
  442. }
  443. function RecordVisitedHere($image_or_post_name, $image_title){
  444. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  445. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  446. if(!(isset($_SESSION[$visited_here][0]) && in_array($image_or_post_name,$_SESSION[$visited_here]))){
  447. $_SESSION[$visited_here][] = $image_or_post_name;
  448. }
  449. if(isset($image_title)){ $this->HereDisplayTitle=$image_title; }
  450. $this->HereNumber = array_search($image_or_post_name,$_SESSION[$visited_here])+1;
  451. $_SESSION['here_number'] = $this->HereNumber;
  452. $this->VisitedHere = $_SESSION[$visited_here];
  453. }
  454. function HereLinkFromNumber($number){
  455. $number -= 1; if($number<0){ $number=0; }
  456. if($number>=sizeof($this->VisitedHere)){ $number = sizeof($this->VisitedHere)-1; }
  457. if(preg_match('/(jpg|jpeg|png|gif)/u',$this->VisitedHere[$number])){ return "?here=images/".$this->VisitedHere[$number]; }
  458. else{ return "?post=".$this->VisitedHere[$number]; }
  459. }
  460. function WriteStyles(){
  461. $this->style="
  462. html{font-size:18px;font-family:'Noto Serif CJK SC','Times New Roman','SimSun', Georgia, serif;}
  463. body{background-color:%white%;color:%black%;}
  464. sup,sub{line-height:0;} .lpctrl{display:none;}
  465. blockquote{border-left:2px solid %black%;padding-left:0.3em;}
  466. *{box-sizing:border-box;padding:0;margin:0;font-weight:normal;}
  467. b,strong,th{font-weight:bold;}
  468. select{font-size:inherit;}
  469. .page,.page_gallery{padding:1em;padding-top:0;padding-bottom:0;}
  470. .hidden_on_desktop,.hidden_on_wide{display:none;}
  471. .hidden_on_desktop_force{display:none !important;}
  472. ::file-selector-button{background:none;border:none;}
  473. a,button,::file-selector-button{text-decoration:underline;color:%black%;}
  474. a:hover,.button:hover,::file-selector-button:hover{text-decoration:none;color:%gray%;}
  475. .button:disabled{background-color:%gray%;pointer-events:none;}
  476. header{position:sticky;top:0;background-color:%white%;z-index:10;padding-top:0.5em;box-shadow: 0.5em 0px %white%;}
  477. 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;}
  478. header>div{overflow:auto;white-space:nowrap;}
  479. .header_nav{display:inline;}
  480. header a,.left a,.footer a,.clean_a,.clean_a a{text-decoration:none;}
  481. header a:hover,.button:hover{color:%gray% !important;}
  482. .exp_h_f{padding-top:0.3em !important;padding-bottom:0.3em !important;line-height:1.5em !important;height:2.1em !important;}
  483. .exp_f{text-align:center;}
  484. .toc_button{position:absolute;top:0.5em;right:0;text-shadow: 0px 0px 10px %white%;background-color:%white%88;}
  485. .footer{background-color:%white%;z-index:10;position:relative;}
  486. .invert_a,.invert_a a{color:%gray%;text-decoration:none;}
  487. .invert_a:hover,.invert_a a:hover{color:%black% !important;}
  488. .gray,.gray a{color:%gray%;}
  489. hr{border:1px solid %gray%;}
  490. header ul,.small_footer ul,.small_footer span,header li,.small_footer li{display:inline-block;}
  491. header li::before,.small_footer li::before{content:' - '}
  492. header h1,header h2,header h3,header h4,header h5,header p{display:inline;font-size:1rem;}
  493. .main{position:relative;word-spacing:-1em;}
  494. .main *{word-spacing:initial;}
  495. pre{overflow:auto;max-width:100%;display:block;}code{font-size:0.83em;}
  496. ul{display:block;}
  497. li{display:block;}
  498. .clean_table{border:none;font-size:1em !important;}.clean_table thead{box-shadow:none;}.clean_table td{vertical-align:top;}
  499. table{width:100%;border-collapse:collapse;border-bottom:2px solid %black%;border-top:3px solid %black%;}
  500. table input{border:none!important;}
  501. table img{max-width:10rem !important;}
  502. td{padding-left:0.1em;padding-right:0.1em;}
  503. td:first-child{padding-left:0;}
  504. td:last-child{padding-right:0;}
  505. tbody tr:hover{box-shadow:inset 0 -2px 0 0px %black%;}
  506. thead{box-shadow:inset 0 -1px 0 0px %black%;}
  507. .post table{font-size:0.85em;}
  508. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 20em);}
  509. .interesting_tbody td{display:contents;}
  510. .interesting_tbody tr{position:relative;scroll-margin:4.5em}
  511. .interesting_tbody td>*{display:table-cell;}
  512. .interesting_tbody td>.wscroll{display:none !important;}
  513. .interesting_tbody .post_access{padding-top:0;}
  514. .interesting_tbody .post_menu_button{top:0;opacity:0;}
  515. .interesting_tbody td>img,.interesting_tbody td>.imd{position:absolute;left:1.4em;z-index:-1;height:1em;width:20em;
  516. display:flex;top:0.2em;object-fit:cover;max-width:calc(100% - 1.4em) !important;overflow:hidden;}
  517. .interesting_tbody td>.imd>a{display:flex;}
  518. .interesting_tbody img{object-fit:cover;width:100%;}
  519. .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);}
  520. .interesting_tbody .p_thumb{height:1em;}
  521. .interesting_tbody .p_thumb img,.interesting_tbody .p_thumb video{max-height:10rem !important;max-width:20rem !important;}
  522. tr:hover .post_menu_button{opacity:1;}
  523. .post_current_row{background-color:%graybkg%;mix-blend-mode:screen;text-shadow:0px 0px 0.1em %white%;}
  524. .align_right{text-align:right;}
  525. .left{display:inline-block;vertical-align:top;width:25%;padding-right:1.5em;padding-bottom:4rem;position:sticky;top:2em;
  526. overflow:auto;max-height:calc(100vh - 2.6em);}
  527. .center{display:inline-block;vertical-align:top;width:50%;overflow:visible;padding-bottom:4rem;}
  528. .center_wide{display:inline-block;vertical-align:top;width:75%;padding-left:0.3em;overflow:visible;padding-bottom:4rem;}
  529. .center_full{display:inline-block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;}
  530. .center_wide .p_thumb{height:12rem;margin:0;}
  531. .linked_posts{margin-right:1.5em;padding:0.5em;padding-left:2.5em;background-color:%grayslice%;box-shadow:0px 0.2em 0.2em -0.2em inset %shadow%;}
  532. .active_post .linked_posts{background-color:%highlight_slice%;}
  533. input:checked~.linked_posts{display:none;}
  534. .bkg_recent>.post,.bkg_section{background:%post_white%;box-shadow:0em 0em 0.5em %shadow%;margin-bottom:0.5em;}
  535. .bkg_recent>.post>.post_width :last-child{margin-bottom:0;}
  536. .sticky_title{position:sticky;top:calc(1.6rem + 2px);z-index:1;background-color:%white%;pointer-events:none;}
  537. .center_exp{display:block;width:80%;margin:0 auto;overflow:visible;padding-bottom:1em;}
  538. .table_top{position:relative;left:calc(-50% - 0.45em);width:calc(200% + 0.6em);background:%white%;z-index:1;
  539. box-shadow:0px 0px 2em 1em %white%;margin-top:2em;margin-bottom:2em;}
  540. textarea,input[type=text],input[type=password]{width:100%;display:block;font-family:inherit;max-height:60vh;font-size:inherit;}
  541. select,textarea,input[type=text],input[type=password]{background:none;border:none;border-bottom:1px solid %black%;color:%black%;}
  542. .text_highlight input{border-bottom:1px solid %white%;color:%white%;}
  543. .button{background:none;border:none;font-family:inherit;color:%black%;font-size:inherit;font-weight:bold;}
  544. .post{position:relative;scroll-margin:3.5em;}
  545. .active_post{background-color:%highlight_white%;}.active_post .post_access{background-color:%highlight_slice%;}
  546. .center_exp .post{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;}
  547. .post_width li,.footer_additional li,.footer_additional li,.post_dummy li
  548. {display:list-item;margin-left:1em;list-style:disc;}
  549. .post_width li li,.footer_additional li li,.footer_additional li li,.post_dummy li li
  550. {list-style:circle;}
  551. ol li{list-style:unset !important;}
  552. .post_width > *,.post_dummy > *,.post_ref > *{margin:0;margin-bottom:0.5rem}
  553. .post_dummy > *{width:60%;margin:0 auto;margin-bottom:0.5rem}
  554. .post_dummy > p img{display:block;width:100%;margin:0 auto;}
  555. .gallery_left li{display:list-item;margin-left:1em;list-style:none;}
  556. .gallery_left .selected{list-style:'→';}
  557. .bkg_section .post_width{padding-top:0;padding-bottom:0;}
  558. .bkg_section .print_title+.post .post_width{padding-top:0.5em;}
  559. .bkg_section .post:not(.print_title):first-of-type .post_width{padding-top:0.5em;}
  560. .bkg_section .restart+.post .post_width{padding-top:0.5em;}
  561. .post_width{position:relative;width:calc(100% - 1.5rem);overflow:auto;padding:0.5rem;}
  562. .ref_count{position:absolute;width:100%;bottom:0.5em;font-weight:bold;color:%gray%;}
  563. .active_post .ref_count{color:%black%;}
  564. .ref_count::after{content: \" \";display:block;width:10em;background:linear-gradient(to right,#0000,%gray%);height:2px;
  565. bottom:-0.5em;position:absolute;right:0;}
  566. //.ref_count::after{content: \" \";display:block;width:0.1em;background-color:%gray%;height:100%;margin-left:0.7em;}
  567. //.lpctrl:checked~.post_width{box-shadow: 1px 1px 1px 1px inset black;}
  568. .opt_compact .post_width,.ref_compact .post_width{padding-top:0;padding-bottom:0;}
  569. .p_thumb .post_menu_button{right:0.3rem;}
  570. .post_menu_button{position:absolute;display:none;top:0.3em;right:1.8rem;width:1.5rem;box-shadow:0px 0px 3px %shadow%;
  571. text-align:center;border-radius:0.3em;user-select:none;cursor:pointer;z-index:10;background-color:%post_white%aa;}
  572. .pointer{cursor:pointer;}
  573. .post:hover .post_menu_button{display:block;}
  574. .pop_menu{position:absolute;top:0.3rem;z-index:95;background-color:%grayslice%;
  575. padding:0.3em;right:1.8rem;text-align:right;border-radius:0.3em;font-size:1rem;
  576. box-shadow:0px 0px 10px %shadow%;}
  577. .pop_menu li{list-style:none;margin-left:0;}
  578. .pop_menu hr{border:2px solid rgba(0,0,0,0.1);}
  579. .toc{left:60%;width:40%;top:0;position:absolute;}
  580. .post_access{width:1.5rem;top:0;right:0;position:absolute;height:100%;text-align:center;font-weight:bold;background-color:%grayslice%;user-select:none;}
  581. .post_access:hover{filter:brightness(150%);}.post label{pointer-events:none;}.active_post label{pointer-events:all;}
  582. .paa{width:1.4rem;min-width:1.4rem;}
  583. .opt_compact .post_access,.ref_compact .post_access{border-right:2px solid %gray%;background-color:%post_white%;right:unset;left:-2em;}
  584. .active_post .opt_compact .post_access,.active_post .ref_compact .post_access{background-color:%highlight_white%;}
  585. .post_preview{overflow:hidden;margin-bottom:0.4em;background-color:%white%aa;box-shadow: 0px 0px 0.2em %shadow%;}
  586. .post_preview:hover{filter:contrast(90%);}
  587. .active_post .post_preview:hover{filter:contrast(90%);}
  588. .post .post_ref{margin:0;padding-left:1.5rem;}
  589. .post_ref_main{display:inline-block;vertical-align:top;max-height:6em;overflow:hidden;margin:0.4em;}
  590. .post_ref_images{overflow:hidden;margin:0.4em;margin-top:0;}
  591. .post_ref_hint{text-align:right;}
  592. .page_selector{padding-top:2rem;text-align:center;}
  593. .smaller{font-size:0.85em;} .bigger{font-size:1.3em;} .block{display:block;}
  594. .restart{text-align:right;padding:0.5rem;background:linear-gradient(to left, %grayslice% 1.5em, %grayslice%00 10em);}
  595. .opt_compact{margin-left:2rem;}.ref_compact{margin-left:1.5rem;}
  596. .post_box_top{padding-bottom:0.3em;padding-top:0.3em;}
  597. .post_box_fixed_bottom{position:sticky;bottom:0em;background-color:%white%;z-index:5;}
  598. .spacer{height:0.5em;}
  599. .pop_right,.pop_right_big{position:fixed;top:0;right:0;bottom:0;width:30%;z-index:100;background-color:%graybkg%;display:none;
  600. transition-timing-function:ease-out;padding:1rem;overflow:auto;}
  601. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  602. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  603. @keyframes pop_slide_in_big{0%{right:-30%;}100%{right:0%;}}
  604. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-30%;}}
  605. .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;}
  606. @keyframes backdrop_fade_in{0%{opacity:0%;}100%{opacity:100%;}}
  607. @keyframes backdrop_fade_out{0%{opacity:100%;}100%{opacity:0%;}}
  608. .toc_entry_1{font-size:1.1em;}
  609. .toc_entry_2{font-size:1.0em;padding-left:0.5rem;}
  610. .toc_entry_3{font-size:0.9em;padding-left:1rem;}
  611. .toc_entry_4{font-size:0.85em;padding-left:1.5rem;}
  612. .toc_entry_5{font-size:0.8em;padding-left:2rem;}
  613. h1,h2,h3,h4,h5{scroll-margin:2.5em;}
  614. .post h1,.post h2,.post h3,.post h4,.post h5{margin-top:1rem;}
  615. .left ul h1,.left ul h2,.left ul h3,.left ul h4,.left ul h5,.left ul p{font-size:1em;}
  616. .deleted_post{color:%gray%;text-decoration:line-through;}
  617. #file_list{margin-top:0.5em;}
  618. .file_thumb img,.file_thumb video{max-height:100%;max-width:100%;object-fit:cover;min-width:100%;min-height:100%;}
  619. .file_thumb video{border:2px dashed %black%;}f
  620. #file_list li{margin-bottom:0.3em;}
  621. .ref_thumb{white-space:nowrap;overflow:hidden;}
  622. .ref_thumb .file_thumb{width:2em;height:2em;margin:0;}
  623. .side_thumb li{margin:0.4em;display:inline-block;}
  624. .file_thumb{width:4em;height:4em;display:inline-block;line-height:0;vertical-align:middle;overflow:hidden;}
  625. .p_row{display:flex;flex-wrap:wrap;width:100%;}
  626. .p_thumb{display:flex;flex-grow:100;height:6rem;margin-right:0.25rem;margin-bottom:0.25rem;overflow:hidden;position:relative;}
  627. .p_thumb_narrow{width:1rem;flex-grow:1;opacity:0.2;}
  628. .p_thumb img,.p_thumb video{object-fit:cover;max-height:100%;min-width:100%;}.p_thumb a{display:contents;}
  629. .p_thumb:hover .post_menu_button{display:block;}
  630. .p_thumb_selected{color:%black% !important;}
  631. .p_thumb_selected{display:block;}
  632. .post .p_thumb img,.post .p_thumb video{max-height:6rem;}
  633. .p_thumb video{border-bottom:0.4em dashed %black%;border-top:0.4em dashed %black%;}
  634. .p_thumb_end{flex-grow:10000 !important;box-shadow:none;align-items:center;padding:2em !important;}
  635. .p_thumb_end:hover, .p_thumb_end a:hover{background-color:%gray%;cursor:pointer;}
  636. .big_image_box{position:fixed;top:0;bottom:0;left:0;width:75%;z-index:95;text-align:center;pointer-events:none;}
  637. .big_image_box *{pointer-events:auto;}
  638. .big_image_box img,.big_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  639. .here_image_box{position:relative;width:100%;text-align:center;height:calc(100vh - 4.5em);}
  640. .here_image_box img,.here_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  641. .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;}
  642. .big_side_box a,.big_side_box hr,#dropping_background{color:%black%;}
  643. .big_side_box a:hover{color:%gray%;}
  644. .big_side_box *{pointer-events:auto;}
  645. .big_side_box .post_preview{border:1px solid %gray%;background-color:unset;border-radius:0.3em;}
  646. .image_nav{pointer-events:none;}
  647. #dropping_background{background-color:rgba(255,255,255,0.4);position:fixed;top:0;right:0;bottom:0;left:0;z-index:100;text-align:center;
  648. box-shadow:0px 0px 500px black inset;display:flex;align-items:center;}
  649. img,video{cursor:pointer;max-height:100%;max-width:100%;vertical-align:middle;}
  650. .post img,.post video{max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  651. .post > a > img,.post > a > video{display:block;margin:0.3em auto;}
  652. .post .original_img{max-width:100%;display:inline-block;vertical-align:middle;
  653. margin-left:auto;margin-right:auto;max-width:100%;max-height:90vh;}
  654. .center_exp .post .original_img{display:block;}
  655. .original_img img,.original_img video{max-height:90vh;max-width:100%;}
  656. .p_row .original_img{margin-bottom:0;}
  657. .post_ref .original_img{margin:unset;max-width:unset;max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  658. .imbtn{display:block;contain:content;padding:0.25em;margin-bottom:0.5em;text-decoration:none;text-shadow:0px 0px 5px %white%;}
  659. .imbtn img{display:block;object-fit:cover;position:absolute;top:0;left:0;bottom:0;right:0;margin:auto;z-index:-1;
  660. min-width:100% !important;min-height:100% !important;filter:opacity(40%);}
  661. .imbtn:hover img{filter:opacity(20%) blur(0.1em);} .imbtn:hover{color:%black% !important;}
  662. header .imbtn{display:inherit;border:none;padding:0em;height:unset;height:unset;margin:0em;contain:unset;}
  663. header .imbtn:hover{border:none;color:%gray% !important;} header .imbtn img{display:none;}
  664. .b ul{font-size:1.4em;}
  665. no_pop{cursor:unset;}
  666. p{min-height:0.8em;}
  667. .bold,.bold *{font-weight:bold;}
  668. .footer_additional{display:inline-block;width:50%;vertical-align:text-top;white-space:normal;}
  669. .small_footer{background-color:%white%;padding-bottom:0.5em;position:sticky;bottom:0px;z-index:10;box-shadow: 0.5em 0px %white%;}
  670. .small_footer>div{overflow:auto;white-space:nowrap;}
  671. .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;}
  672. .top_post_hint{margin-left:0.5em;font-weight:bold;}
  673. .white{color:%white%;}
  674. .full_box{border:1px solid %black% !important;padding:0.3rem;overflow:auto;}
  675. .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;
  676. transition:background-size .2s ease;padding:0.5em;text-shadow:0px 0px 5px black;user-select:none;pointer-events:auto;}
  677. .image_nav_prev{left:0;justify-content:left;background:linear-gradient(to left, rgba(0,0,0,0), rgba(0,0,0,0.4));
  678. background-repeat:no-repeat;background-size:0% 100%;}
  679. .image_nav_prev:hover,.image_nav_next:hover{background-size:100% 100%;}
  680. .image_nav_next{right:0;justify-content:right;background:linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.2));
  681. background-repeat:no-repeat;background-size:0% 100%;transition:background-size .2s ease;background-position-x:100%;}
  682. .inquiry_buttons{position:fixed;left:0;right:25%;text-align:center;bottom:1em;margin:0 auto;width:max-content;
  683. background-color:rgba(0,0,0,0.5);z-index:110;padding:0.2em;padding-left:1em;padding-right:1em;
  684. border-radius:1em;box-shadow:0px 0px 5px;text-shadow:0px 0px 5px black;opacity:1;user-select:none;}
  685. .lr_buttons{background-color:rgba(0,0,0,0.5);padding:0.5em;padding-top:1em;padding-bottom:1em;
  686. border-radius:1em;box-shadow:0px 0px 5px;font-size:1.2rem;text-shadow:0px 0px 5px black;}
  687. .img_btn_hidden{opacity:0;transition:opacity 0.2s;}
  688. .special_alipay{background-color:#027aff;color:white;white-space:nowrap;
  689. font-family:sans-serif;font-weight:bold;border-radius:0.7em;font-size:0.75em;padding:0.25em;}
  690. .special_paypal{background-color:white;color:#253b80;white-space:nowrap;
  691. font-family:sans-serif;font-weight:bold;border-radius:2em;font-size:0.75em;
  692. padding:0.25em;padding-left:0.5em;padding-right:0.65em;font-style: italic;}
  693. .special_paypal_inner{color:#169bd7;}
  694. #waiting_bar{position:fixed;z-index:200;top:0;left:0;right:0;height:0.2em;background-color:%black%;transform:translate(-100%,0);
  695. animation:anim_loading 1s linear infinite;}
  696. @keyframes anim_loading{0%{transform:translate(-100%,0);} 100%{transform:translate(100%,0);}}
  697. .product_ref{width:32%;padding:0.2em!important;display:inline-block;text-align:center;vertical-align:top;margin-bottom:0.8em;}
  698. .product_thumb{max-height:11em;max-width:11em;display:inline-flex;margin-bottom:0.2em;background-color:%graybkg%;}
  699. .product_thumb img,{box-shadow:none;object-fit:contain;max-height:unset;max-width:unset;width:100%;margin:0 auto !important;}
  700. .product_ref p{margin-bottom:0.2em;text-align:left;}
  701. .post_preview .product_thumb{max-height:4em;max-width:6em;}
  702. .purchase_button{background-color:%black%;color:%white%;padding-left:0.5em;padding-right:0.5em;text-decoration:none;font-weight:bold;}
  703. .page_break{page-break-after:always;}
  704. .text_highlight,.text_highlight a,.text_highlight select{background-color:%black%;color:%white%;border:none;}
  705. .gray.text_highlight,.gray.text_highlight a,.gray.text_highlight select{background-color:%gray%;color:%white%;}
  706. .print_title{display:none;}.show_on_print{display:none;}.inline_print{display:none;}
  707. .comment{font-size:0.9em;font-family:sans-serif;overflow:auto !important;width:100%;}
  708. .comment tbody tr:hover{box-shadow:none;}
  709. .comment table{border:none;}
  710. .comment li{display:list-item;list-style:'→';padding-left:0.3em;}
  711. .comment ul{padding-left:1em;}
  712. .comment ul li *{margin-bottom:0.5em;}
  713. .history li{display:list-item;list-style:disc;padding-left:0.3em;}
  714. .history li li{list-style:circle;}
  715. .history ul{padding-left:1em;}
  716. .history a{text-decoration:underline;}
  717. .history .list{overflow:auto;white-space:nowrap;}
  718. .diff_table{table-layout:fixed;}
  719. .diff_table thead{font-size:0.9em;text-align:center;}
  720. .diff_table tbody pre{font-size:0.9rem;white-space:pre-line;}
  721. .diff_table td{vertical-align:top;}
  722. .omittable_title{display:block;width:100%;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
  723. .wayback_close{float:right;}
  724. .wayback_expand{display:inline;}
  725. .post_selecting .post *{pointer-events:none;}
  726. .post_selected{background-color:%graybkg%;}
  727. .small_pad{padding:0.2em;padding-top:0.1em;padding-bottom:0.1em;}
  728. .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%;}
  729. .wscroll:target{display:block;} .post_ref .wscroll{display:none !important;}
  730. .wayback_link{display:inline;}
  731. .imd{object-fit:cover;width:100%;}
  732. .center_exp .post>.imd,.center_exp .p_row{width:60%;}
  733. .center_exp .p_thumb img,.center_exp .p_thumb video{max-height:3rem;}
  734. .center_exp .p_thumb{max-height:3rem;filter:opacity(40%);}
  735. .center_exp .p_thumb:hover{filter:unset;}
  736. #here_buttons{display:contents;}
  737. .here_buttons_inner{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;max-height:100%;max-width:100%;}
  738. .here_btn{position:absolute;z-index:110;transform:translate(-50%,-50%);
  739. width:2em;height:2em;display:block;border:1px solid %black%;background-color:rgba(0,0,0,0.5);}
  740. .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;}
  741. @media screen and (max-width:1000px) and (min-width:666px){
  742. .left{width:35%;}
  743. .center,.center_wide{width:65%;}
  744. .center_wide .p_thumb{height:8rem;}
  745. .post_width{width:calc(100% - 1.5rem);padding-left:0.2em;}
  746. .hidden_on_wide{display:unset;}
  747. .pop_right{width:30%;}
  748. .pop_right_big{width:40%;}
  749. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  750. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  751. @keyframes pop_slide_in_big{0%{right:-40%;}100%{right:0%;}}
  752. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-40%;}}
  753. .big_side_box{width:35%;}
  754. .big_image_box{width:65%;}
  755. .inquiry_buttons{right:35%;}
  756. .table_top{left:calc(-50% - 1.7em);width:calc(154% + 0.5em);}
  757. .post_dummy > *{width:80%;max-width:55rem;}
  758. .center_exp .post>.imd,.center_exp .p_row{width:80%;max-width:55rem;}
  759. .here_btn{width:1.5em;height:1.5em;}
  760. }
  761. @media screen and (max-width:666px){
  762. html{font-size:16px;}
  763. #titlectrl:checked ~ header .mobile_fold{display:block !important;}
  764. #titlectrl:checked ~ .main .mobile_fold{display:block !important;}
  765. .mobile_fold{display:none !important;}
  766. .hidden_m{display:none !important;}
  767. .block_m{display:block !important;}
  768. .hidden_on_desktop{display:unset;}
  769. .hidden_on_wide{display:unset;}
  770. header{position:unset;}
  771. header ul{display:block;}
  772. header li{display:block;}
  773. header li::before{content:''}
  774. header::before{box-shadow:none;display:none;}
  775. .small_footer::before{box-shadow:none;display:none;}
  776. .left{position:relative;width:100%;top:unset;height:unset;max-height:unset;padding-right:0;display:block;}
  777. .center,.center_wide,.center_full{position:relative;left:0;top:0;width:100%;padding-left:0;display:block;}
  778. .center_wide .p_thumb{height:6rem;}
  779. .pop_right,.pop_right_big{top:unset;right:0;bottom:0;left:0;width:100%;}
  780. .pop_right{height:30%;}
  781. .pop_right_big{height:70%;}
  782. @keyframes pop_slide_in{0%{bottom:-30%;}100%{bottom:0%;}}
  783. @keyframes pop_slide_out{0%{bottom:0%;}100%{bottom:-30%;}}
  784. @keyframes pop_slide_in_big{0%{bottom:-70%;}100%{bottom:0%;}}
  785. @keyframes pop_slide_out_big{0%{bottom:0%;}100%{bottom:-70%;}}
  786. .big_image_box{position:fixed;top:0;bottom:8.5rem;left:0;right:0;width:100%;}
  787. .side_box_mobile_inner{background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(1,1,1,0.9) 20%);
  788. transition:none;background-size:100% 100%;padding:0.5rem;padding-bottom: 5em;}
  789. .side_box_mobile_inner:hover{background-size:100% 100%;}
  790. .big_side_box{position:fixed;top:0;bottom:0;right:0;left:0;width:100%;
  791. height:unset;padding:0;padding-top:calc(100vh - 8.5rem);background:none;}
  792. .p_thumb{height:3rem;}
  793. .center .post{padding-right:0rem;padding-left:0rem;}
  794. .post .p_thumb img,.post .p_thumb video{max-height:3rem;}
  795. .page,.page_gallery{padding:0.2em;padding-top:0;}
  796. header{padding-top:0.3em;}
  797. .toc_button{top:0.3em;}
  798. .small_footer{padding-bottom:0.3em;}
  799. .footer_additional{display:block;width:100%;}
  800. .album_hint{display:block;font-size:1rem;}
  801. .image_nav{position:absolute !important;}
  802. .image_nav_prev,.image_nav_next{width:25%;}
  803. .image_nav_prev:hover,.image_nav_next:hover{background-size:0% 100%;color:%black% !important;}
  804. .inquiry_buttons{position:relative;left:unset;right:unset;text-align:left;bottom:unset;margin:unset;width:unset;
  805. background-color:unset;z-index:unset;padding:unset;padding-left:unset;padding-right:unset;
  806. border-radius:unset;box-shadow:unset;text-shadow:unset;}.img_btn_hidden{opacity:1;}
  807. .lr_buttons{background-color:unset;padding:unset;padding-top:unset;padding-bottom:unset;
  808. border-radius:unset;box-shadow:unset;font-size:1.3rem;text-shadow:unset;}
  809. .opt_compact,.ref_compact{line-break:anywhere;}
  810. .table_top{left:unset;width:100%;overflow:auto;}
  811. table img{max-width:30vw !important;}
  812. .product_ref{width:100%;display:block;}
  813. .post_dummy > *{width:100%;max-width:25rem;}
  814. .center_exp .post>.imd,.center_exp .p_row{width:100%;max-width:25rem;}
  815. .center_exp .post .p_thumb img,.center_exp .post .p_thumb video{max-height:2rem;}
  816. .center_exp .p_thumb{height:2rem;filter:opacity(40%);}
  817. .center_exp .p_thumb:hover{filter:unset;}
  818. .sticky_title{top:0;}
  819. .small_footer{position:relative;}
  820. #upload_selector{width:100%;}
  821. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 10em);}
  822. .wayback_expand{display:block;text-align:center;}
  823. .wayback_link{display:block;}
  824. .center_exp{display:block;width:100%;margin:0 auto;padding-bottom:1em;}
  825. .center_exp .post{overflow:auto;}
  826. .center_exp .imd{width:100%;}
  827. .here_btn{width:1.2em;height:1.2em;}
  828. .exp_h_f{height:unset !important;}
  829. .exp_f{margin-bottom:1em;}
  830. .linked_posts{padding-left:1em;}
  831. }
  832. @media print{
  833. .small_footer .hidden_on_print{display:none;}
  834. header b,.small_footer b{font-weight:normal;}
  835. header{display:table-header-group;box-shadow:none;} .main{display:table-row-group;} .small_footer{text-align:right;}
  836. header::before{box-shadow:none;display:none;} header::after{display:block;height:1em;content:' ';}
  837. .small_footer::before{box-shadow:none;display:block;height:1em;position:relative;}
  838. body,footer,header,.small_footer,a,.clean_a,.invert_a,.clean_a a,.invert_a a{background:none;color:black;}
  839. .bkg_section,.bkg_recent>.post,.active_post{background:none !important;box-shadow:none;}
  840. .post *,.post_dummy *{margin-bottom:0em;}
  841. .p_row,.post table,.post_width>img,.post_ref>img,.post_ref>.original_img,
  842. .post_width>.original_img,.post pre{margin-top:0.5rem;margin-bottom:0.5rem;text-indent:0;}
  843. pre{white-space:pre-wrap;line-break:anywhere;}
  844. .post p{line-height:1.3;text-indent:2em;} .product_ref p {text-indent:0;}
  845. table img{margin:0 !important;}
  846. .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;}
  847. .post ul,.post ol{margin:1rem;margin-left:1.4rem;margin-right: 0rem;}
  848. table{border-bottom:2px solid black;border-top:2px solid black;}
  849. table img{max-width:5em;max-width:8em !important;max-height:8em !important;}
  850. thead{box-shadow:inset 0 -1px 0 0px black;background:none;}
  851. .linked_posts{display:none;}
  852. .post_width{overflow:clip;left:0;width:100%;padding-left:0em;padding-right:0em;}
  853. .post h1{margin-top:0.5rem;}
  854. .post h2{font-size:1.8em;margin:2.5em auto 0;}.list h2,.opt_compact h2,.ref_compact h2{margin:0 !important;}
  855. .post h3{font-size:1.5em;margin:1.5em auto 0;}.list h3,.opt_compact h3,.ref_compact h3{margin:0 !important;}
  856. .post h4{font-size:1.1em;margin:0.5em auto 0;}.list h4,.opt_compact h3,.ref_compact h4{margin:0 !important;}
  857. .post .post{margin-bottom:0.5rem;margin-top:0.5rem;}
  858. .gray,.gray a,.deleted_post{color:rgba(0,0,0,0.5);}
  859. .left{display:none;}
  860. .center, .center_wide, .center_full{width:100%;padding:0;display:block;font-size:16px;line-height:1.3}
  861. hr{border:1px solid black;}
  862. .post_box_top{display:none;}
  863. .post_access{display:none;}
  864. .opt_compact .post_access,.ref_compact .post_access{border-right:none;display:inline;background:unset;}
  865. .text_highlight,.text_highlight a,.gray.text_highlight,.gray.text_highlight a,.purchase_button{background-color:lightgray;color:black;}
  866. .hidden_on_print{display:none;}
  867. .print_column{column-count:2;margin-top:0.5rem;margin-bottom:0.5rem;}
  868. .opt_compact{margin-left:0;left:1.5em;}
  869. .post .post_ref{padding-left:2rem;}
  870. .print_title{column-span:all;display:block;margin-top:2em;margin-bottom:0.5rem;font-size:1.2em;}
  871. .print_title:first-of-type{margin-top:1em;}
  872. .print_title+.post h1:first-of-type{display:none;}
  873. .bkg_section .print_title+.post .post_width{padding-top:0;}
  874. .bkg_section .post:not(.print_title):first-of-type .post_width{padding-top:0;}
  875. .bkg_section .restart+.post .post_width{padding-top:0;}
  876. .restart{background-color:unset;padding:unset;}
  877. .opt_compact h1:first-of-type,.ref_compact h1:first-of-type{display:unset;}
  878. .table_top{position:relative;left:0;width:100%;background:none;z-index:1;box-shadow:none;}
  879. .header_nav{display:none;}
  880. .show_on_print{display:block;}.inline_print{display:inline;}
  881. blockquote{border-left:2px solid black;}
  882. .footer_additional{display:none;}
  883. .small_footer{margin-top:1rem;box-shadow:none;}
  884. .page{display:table;width:100%;}
  885. .page_selector{display:none;}
  886. .p_thumb{height:4rem;margin-bottom:0.25rem;}
  887. .post .p_thumb img,.post .p_thumb video{max-height:4rem;}
  888. .sticky_title{box-shadow:none;}
  889. .center_wide .p_thumb{display:inline-flex;height:5.8rem;width:5.8rem;margin-right:0;}
  890. .center_wide .p_row{display:block;}
  891. .interesting_tbody{background:none;}
  892. .interesting_tbody img{display:none !important;}
  893. .imd{margin-top:0.5em;margin-bottom:0.5em;line-height:0px;}
  894. .p_row .imd{margin-top:0em;margin-bottom:0em;}
  895. }
  896. ";
  897. //$this->style=preg_replace('/%highlight_white%/','#5b3607',$this->style);
  898. //$this->style=preg_replace('/%highlight_slice%/','#734307',$this->style);
  899. //$this->style=preg_replace('/%grayslice%/','#442c0b',$this->style);
  900. //$this->style=preg_replace('/%post_white%/','#2d2110',$this->style);
  901. //$this->style=preg_replace('/%white%/','#231a0d',$this->style);
  902. //$this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
  903. //$this->style=preg_replace('/%gray%/','#ac7843',$this->style);
  904. //$this->style=preg_replace('/%graybkg%/','#39270e',$this->style);
  905. //$this->style=preg_replace('/%shadow%/','#000000cc',$this->style);
  906. $this->style=preg_replace('/%highlight_white%/','#804a06',$this->style);
  907. $this->style=preg_replace('/%highlight_slice%/','#ae6407',$this->style);
  908. $this->style=preg_replace('/%grayslice%/','#6a491c',$this->style);
  909. $this->style=preg_replace('/%post_white%/','#4a3413',$this->style);
  910. $this->style=preg_replace('/%white%/','#2d2214',$this->style);
  911. $this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
  912. $this->style=preg_replace('/%gray%/','#f8ca9b88',$this->style);
  913. $this->style=preg_replace('/%graybkg%/','#a9270e',$this->style);
  914. $this->style=preg_replace('/%shadow%/','#000000ee',$this->style);
  915. $f = fopen('styles/main.css','w');
  916. fwrite($f,$this->style);
  917. fclose($f);
  918. }
  919. function GiveSafeEMail(){
  920. return preg_replace('/\./u','[dot]',preg_replace('/\@/u','[at]',$this->EMail));
  921. }
  922. function &FindImage($name, $loose=false){ if(!isset($name) || !$name){ return $this->NULL_IMAGE; }
  923. if(isset($this->Images[0])) foreach($this->Images as &$im){
  924. if($loose) { if(preg_match('/'.preg_quote($name).'/u',$im['name'])) return $im; }
  925. else { if($im['name']==$name) return $im; }
  926. }
  927. return $this->NULL_IMAGE;
  928. }
  929. function &GiveImageInHere($rand=false){
  930. $this->ReadImages(); $this->DetectPageType();
  931. $album = $this->PageType=='here'?$this->HereAlbum:$this->ExpAlbum;
  932. if(!isset($album) || !$album){
  933. if(isset($this->Images[0])) return $this->Images[0]; else return $this->NULL_IMAGE; }
  934. $imlist=[]; $imlist_fallback=[];
  935. if(isset($this->Images[0])){
  936. foreach($this->Images as &$im){
  937. if(isset($im['galleries'][0]) && in_array($album,$im['galleries']) && $this->CanShowImage($im)){
  938. if(!$rand) return $im; else {
  939. $imlist_fallback[] = $im;
  940. if(!in_array($im['name'],$this->VisitedHere)) $imlist[] = $im;
  941. }
  942. }
  943. }
  944. }
  945. if(!$rand || !isset($imlist_fallback[0])) return $this->NULL_IMAGE;
  946. if(sizeof($imlist)){
  947. $r = random_int(0, sizeof($imlist)-1);
  948. return $imlist[$r];
  949. }else{
  950. $r = random_int(0, sizeof($imlist_fallback)-1);
  951. return $imlist_fallback[$r];
  952. }
  953. }
  954. function ImageTitle($im){
  955. $imtitle = (isset($im)&&isset($im['title']))?$im['title']:NULL;
  956. if(isset($im['parent'])&&($imp = &$this->FindImage($im['parent'],true))&&isset($imp['title'])){ $imtitle=$imp['title']; }
  957. return $imtitle;
  958. }
  959. function ImageHasHere(&$im, $here_name){
  960. if(!isset($im['here'])||!isset($im['here'][0])) return false;
  961. foreach($im['here'] as $h) { if($h[0] == $here_name) return true; } return false;
  962. }
  963. function ReadImages($clear_non_exist = false){
  964. $path = 'images/list.md';
  965. if($this->DoneReadImages){ return; }
  966. if(!file_exists($path)){ $f = fopen($path,'w'); fflush($f); fclose($f); }
  967. $c = file_get_contents($path);
  968. if(preg_match_all('/GALLERY\s+(\S+)(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  969. $g=[]; $g['name']=$m[1];//$g['count']=0;
  970. if(preg_match('/FEATURED([^;]*?);/u', $m[2], $arg)){ $g['featured']=true; }
  971. if(preg_match('/EXPERIMENTAL([^;]*?);/u', $m[2], $arg)){ $g['experimental']=true; }
  972. if(preg_match('/DESCRIPTION\s+([^;]+);/u', $m[2], $arg)){ $g['description']=$arg[1]; }
  973. $this->Galleries[] = $g;
  974. }
  975. if(preg_match_all('/^-\s*([^;]+)\s*?;\s*?(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  976. $name = trim($m[1]);
  977. $item = []; $item['file'] = 'images/'.$name; $item['name'] = $name;
  978. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  979. if(preg_match('/REFS\s+([^;]*);/u',$m[2],$refs) && preg_match_all('/[0-9]{14}/u',$refs[1],$rs, PREG_SET_ORDER)){
  980. $item['refs']=[];
  981. foreach($rs as $r){ if(!in_array($r[0], $item['refs'])) $item['refs'][] = $r[0]; }
  982. }
  983. if(preg_match('/GAL\s+([^;]*);/u',$m[2],$gals) && preg_match_all('/(\S+)/u',$gals[1],$ga, PREG_SET_ORDER)){
  984. $item['galleries']=[];
  985. foreach($ga as $g){ if(!in_array($g[0], $item['galleries'])) $item['galleries'][] = $g[0]; }
  986. }
  987. if(preg_match('/PRODUCT\s+([^;]*);/u',$m[2],$product)){ $item['product']=$product[1]; }
  988. if(preg_match('/PARENT\s+([^;]*);/u',$m[2],$parent)){ $item['parent']=$parent[1]; }
  989. if(preg_match('/TITLE\s+([^;]*);/u',$m[2],$title)){ $item['title']=$title[1]; }
  990. if(preg_match('/ALIGN\s+([^;]*);/u',$m[2],$align)){ $item['align']=$align[1]; }
  991. if(preg_match('/HERE\s+([^;]*);/u',$m[2],$heres) && preg_match_all('/(\S+)-(\S+)-(\S+)/u',$heres[1],$here, PREG_SET_ORDER)){
  992. $item['here']=[];
  993. foreach($here as $h){ if(!$this->ImageHasHere($item, $h[1])) $item['here'][] = [$h[1],$h[2],$h[3]]; }
  994. }
  995. if(preg_match('/\.mp4/u',$item['name'])){
  996. $item['video']='video/mp4';
  997. }
  998. $this->Images[] = $item;
  999. }
  1000. $files = array_merge([],glob('images/*.jpg'));
  1001. $files = array_merge($files,glob('images/*.jpeg'));
  1002. $files = array_merge($files,glob('images/*.png'));
  1003. $files = array_merge($files,glob('images/*.gif'));
  1004. $files = array_merge($files,glob('images/*.mp4'));
  1005. if(isset($files[0]))foreach($files as $file) {
  1006. if(preg_match('/[0-9]{14,}\.(jpg|jpeg|gif|png|mp4)/u', $file, $m)) {
  1007. $name = trim($m[0]);
  1008. if(!$this->FindImage($name)){
  1009. $item = []; $item['name']=$name; $item['file'] = 'images/'.$name;
  1010. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  1011. $this->Images[] = $item;
  1012. }
  1013. }
  1014. }
  1015. if($clear_non_exist){
  1016. if(isset($this->Images[0]) && isset($files[0])){
  1017. foreach($this->Images as &$im){
  1018. if(!in_array($im['file'],$files)){
  1019. $im['deleted'] = 1;
  1020. }
  1021. }
  1022. }
  1023. }
  1024. function cmpf($a, $b){
  1025. if ($a['name'] == $b['name']) return 0;
  1026. return (($a['name'] > $b['name']) ? 1 : -1);
  1027. }
  1028. function cmpaf($a, $b){
  1029. if ($a['name'] == $b['name']) return 0;
  1030. return ($a['name'] > $b['name']) ? -1 : 1;
  1031. }
  1032. if(isset($this->Galleries[0]))usort($this->Galleries,"cmpf");
  1033. if(isset($this->Images[0]))usort($this->Images,"cmpaf");
  1034. $this->DoneReadImages = 1;
  1035. }
  1036. function WriteImages(){
  1037. if(isset($this->WayBack)) return;
  1038. $path = 'images/list.md';
  1039. $f = fopen($path,'w');
  1040. if(isset($this->Galleries[0]))foreach($this->Galleries as &$g){
  1041. if(isset($g['deleted'])) continue;
  1042. fwrite($f,'GALLERY '.$g['name']);
  1043. if(isset($g['featured']) && $g['featured']!=false) { fwrite($f,' FEATURED;'); }
  1044. if(isset($g['experimental']) && $g['experimental']!=false) { fwrite($f,' EXPERIMENTAL;'); }
  1045. if(isset($g['description']) && $g['description']!="") { fwrite($f,' DESCRIPTION '.$g['description'].';'); }
  1046. fwrite($f, PHP_EOL);
  1047. }
  1048. if(isset($this->Images[0]))foreach($this->Images as &$im){
  1049. if(isset($im['deleted'])) continue;
  1050. fwrite($f, "- ".$im['name'].'; ');
  1051. if(isset($im['refs']) && isset($im['refs'][0])){ fwrite($f, 'REFS '.implode(" ",$im['refs'])."; "); }
  1052. if(isset($im['galleries']) && isset($im['galleries'][0])){ fwrite($f, 'GAL '.implode(" ",$im['galleries'])."; "); }
  1053. if(isset($im['product']) && $im['product']!=''){ fwrite($f, 'PRODUCT '.$im['product']."; "); }
  1054. if(isset($im['parent']) && $im['parent']!=''){ fwrite($f, 'PARENT '.$im['parent']."; "); }
  1055. if(isset($im['title']) && $im['title']!=''){ fwrite($f, 'TITLE '.$im['title']."; "); }
  1056. if(isset($im['align']) && $im['align']!='' && $im['align']!='middle'){ fwrite($f, 'ALIGN '.$im['align']."; "); }
  1057. if(isset($im['here']) && $im['here']!=''){ fwrite($f, 'HERE ');
  1058. foreach($im['here'] as $here){ fwrite($f, implode('-',$here).' '); } fwrite($f, '; ');
  1059. }
  1060. fwrite($f, PHP_EOL);
  1061. }
  1062. fflush($f);
  1063. fclose($f);
  1064. }
  1065. function EditImage($name, $link_gallery, $do_remove = false, $product_link=NULL, $rename=NULL, $parent=NULL, $align=NULL){
  1066. if(!($im = &$this->FindImage($name))) return;
  1067. if(isset($link_gallery)){
  1068. if($do_remove){
  1069. if(!isset($im['galleries']) || !isset($im['galleries'][0])) return;
  1070. foreach($im['galleries'] as $key => $g){ if ($g==$link_gallery) unset($im['galleries'][$key]); }
  1071. $im['galleries'] = array_merge($im['galleries']);
  1072. }else{
  1073. if(!isset($im['galleries'])) $im['galleries']=[];
  1074. foreach($im['galleries'] as &$g){ if ($g==$link_gallery) return; }
  1075. $im['galleries'][]=$link_gallery;
  1076. }
  1077. }
  1078. if(isset($product_link)){
  1079. if($product_link!=''){$im['product']=$product_link;}
  1080. else{unset($im['product']);}
  1081. }
  1082. if(isset($rename) && $rename!=$im['name']){
  1083. $ext=pathinfo($im['file'],PATHINFO_EXTENSION);
  1084. rename($im['file'], 'images/'.$rename.'.'.$ext);
  1085. if(isset($im['thumb'])) rename($im['thumb'], 'images/thumb/'.$rename.'.'.$ext);
  1086. $im['name'] = $rename.'.'.$ext;
  1087. }
  1088. if(isset($parent) && $parent!=$im['parent']){
  1089. if($parent==''){ unset($im['parent']); }
  1090. else{ $im['parent'] = $parent; }
  1091. }
  1092. if(isset($align) && in_array($align,['top','middle','bottom'])){
  1093. if($align=='middle'){ unset($im['align']); }
  1094. else{ $im['align']=$align; }
  1095. }
  1096. $this->NeedWriteImages = 1;
  1097. }
  1098. function RegenerateThumbnails(){
  1099. $glob = glob('images/*.jpg');
  1100. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1101. foreach($glob as $file) {
  1102. $thumb_destination = 'images/thumb/'.basename($file);
  1103. $img = new Imagick($file); $geo=$img->getImageGeometry();
  1104. $width=$geo['width']; $height=$geo['height'];
  1105. $lim=400;
  1106. $scale = $lim / min($width,$height);
  1107. if($scale<1){
  1108. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1109. }
  1110. $img->setImageFormat('jpeg');
  1111. $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1112. $img->setImageCompressionQuality(90);
  1113. $img->writeImage($thumb_destination);
  1114. }
  1115. }
  1116. function CompressImage($source, $destination, $thumb_destination, $quality, $sizelim, $abs_max, $ext) {
  1117. $img = new Imagick($source); $geo=$img->getImageGeometry(); $img2 = clone $img;
  1118. $width=$geo['width']; $height=$geo['height'];
  1119. $lim=400;
  1120. $scale = $lim / min($width,$height);
  1121. if($scale<1){
  1122. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1123. }
  1124. $img->setImageFormat('jpeg');
  1125. $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1126. $img->setImageCompressionQuality($quality);
  1127. $img->writeImage($thumb_destination);
  1128. $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
  1129. if($scale<1){
  1130. $img2->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.5);
  1131. }
  1132. if($ext!='jpg'){
  1133. $img2->setImageFormat('jpeg');
  1134. $img2->setImageCompressionQuality($quality);
  1135. $img2->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1136. $img2->writeImage($destination);
  1137. }else{
  1138. rename($source,$destination);
  1139. }
  1140. }
  1141. function DoUpload(){
  1142. if(!isset($_FILES['upload_file_name'])) return 0;
  1143. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1144. if($_FILES['upload_file_name']['error']>0){
  1145. echo"file upload err code ".$_FILES['upload_file_name']['error']; exit;
  1146. return -1;
  1147. }else{
  1148. $ext=pathinfo($_FILES['upload_file_name']['name'],PATHINFO_EXTENSION);
  1149. if(!in_array($ext,['jpg','jpeg','png','gif','mp4'])) return 0;
  1150. $fp = fopen('.la_lock',"w");
  1151. while (!flock($fp, LOCK_EX| LOCK_NB)){
  1152. usleep(10000);
  1153. }
  1154. $num=date('YmdHis'); $replace=0;
  1155. if(isset($_POST['image_replace_button']) && isset($_GET['pic']) && preg_match('/([0-9]{14,})/u',$_GET['pic'],$mim)){
  1156. $num = $mim[1]; $replace=1;
  1157. }
  1158. $base = 'images/'.$num;
  1159. $thumb = 'images/thumb/'.$num;
  1160. $use_ext=($ext=='gif' || $ext=='mp4')?('.'.$ext):('.jpg');
  1161. $final_path = $base.$use_ext; $final_thumb = $thumb.$use_ext; $i=0;
  1162. if(!$replace) while(file_exists($final_path)){
  1163. $final_path = $base.strval($i).$use_ext; $final_thumb = $thumb.strval($i).$use_ext; $i++;
  1164. }
  1165. if($ext!='gif' && $ext!='mp4'){
  1166. $compress = (isset($_GET['compress'])&&$_GET['compress']);
  1167. $this->CompressImage($_FILES['upload_file_name']['tmp_name'], $final_path, $final_thumb, 90,
  1168. $compress?800:1920, $compress?1920:2560, $ext);
  1169. }else{
  1170. move_uploaded_file($_FILES['upload_file_name']['tmp_name'], $final_path);
  1171. }
  1172. flock($fp, LOCK_UN);
  1173. fclose($fp);
  1174. $this->ReadImages(true);
  1175. $this->WriteImages();
  1176. echo '<uploaded>'.pathinfo($final_path,PATHINFO_BASENAME)."</uploaded>";
  1177. if(isset($_POST['image_replace_button'])){
  1178. header('Location: '.$_SERVER['REQUEST_URI']);exit;
  1179. }
  1180. exit;
  1181. return 1;
  1182. }
  1183. return 0;
  1184. }
  1185. function &GetGallery($name){
  1186. if(isset($this->Galleries[0])) foreach($this->Galleries as &$g){
  1187. if($g['name'] == $name) return $g;
  1188. }
  1189. return $this->NULL_GALLERY;
  1190. }
  1191. function EditGallery($name, $new_name=null, $delete=false, $do_rw=true, $set_featured=null, $set_experimental=null,$desc=null){
  1192. $this->ReadImages();
  1193. $gallery = &$this->GetGallery($name);
  1194. if(!isset($gallery)){
  1195. if(!isset($new_name) || preg_match('/main|trash|\s/u',$new_name))return;
  1196. $g = []; $g['name']=$new_name;
  1197. $this->Galleries[]=$g;
  1198. }else{
  1199. if(isset($new_name)) {
  1200. if(preg_match('/main|trash|\s/u',$new_name))return;
  1201. $gallery['name'] = $new_name;
  1202. foreach ($this->Images as &$im){
  1203. if(isset($im['galleries'])&&isset($im['galleries'][0]))foreach($im['galleries'] as &$g){
  1204. if($g == $name){ $g = $new_name; }
  1205. }
  1206. }
  1207. }
  1208. //if(isset($count)) $gallery['count'] = $count;
  1209. if(isset($delete) && $delete) $gallery['deleted'] = true;
  1210. if(isset($set_featured)) $gallery['featured'] = $set_featured;
  1211. if(isset($set_experimental)) $gallery['experimental'] = $set_experimental;
  1212. if(isset($desc)) $gallery['description'] = $desc;
  1213. }
  1214. if($do_rw) { $this->NeedWriteImages = 1; }
  1215. }
  1216. function ClearData(){
  1217. $this->Posts = [];
  1218. $this->Threads = [];
  1219. $this->Images = [];
  1220. $this->Archive = [];
  1221. $this->ArchiveHandles = [];
  1222. }
  1223. function InsertArchivePost(&$post){
  1224. $a = NULL;
  1225. if(($a = &$this->GetArchiveHandle($post['id']))==$this->NULL_POST){
  1226. $ah = []; $ah['id'] = $post['id']; $ah['list'] = [];
  1227. $this->ArchiveHandles[] = &$ah; $a = &$ah;
  1228. }
  1229. $a['list'][] = $post;
  1230. $this->Archive[] = $post;
  1231. }
  1232. function ReadArchiveFromFile($path){
  1233. if(!file_exists($path)){
  1234. return;
  1235. }
  1236. $c = file_get_contents($path);
  1237. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1238. foreach($matches as $m){
  1239. $post = [];
  1240. $post['id'] = $m[1];
  1241. $post['content'] = trim($m[3]);
  1242. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1243. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1244. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1245. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1246. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1247. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1248. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1249. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1250. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1251. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1252. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1253. if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
  1254. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1255. foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
  1256. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1257. $post['merged_into'] = [trim($n[1]),trim($n[2])];
  1258. }
  1259. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1260. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1261. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1262. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1263. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1264. }
  1265. $this->InsertArchivePost($post);
  1266. }
  1267. }
  1268. }
  1269. function SortArchive(){
  1270. $cmpac = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1271. $cmpap = function($a, $b){ if ($a['id'] == $b['id']) return ((($a['version'] > $b['version']) ? 1 : -1));
  1272. return (($a['id'] > $b['id']) ? 1 : -1);
  1273. };
  1274. if(isset($this->Archive[0])){
  1275. usort($this->Archive,$cmpap);
  1276. $year_begin = substr($this->Archive[0]['id'],0,4);
  1277. $this->YearBegin = ($year_begin<$this->YearBegin)?$year_begin:$this->YearBegin;
  1278. }
  1279. if(isset($this->ArchiveHandles[0])){
  1280. usort($this->ArchiveHandles,$cmpac);
  1281. foreach($this->ArchiveHandles as &$a){
  1282. if(isset($a['list'])){ usort($a['list'],$cmpap);
  1283. $last_valid=NULL;
  1284. foreach($a['list'] as &$ver){ $ver['archive']= &$a;
  1285. if(isset($ver['merged_thread'])){ $ver['content']=$last_valid; }
  1286. else{ $last_valid = $ver['content']; } }
  1287. if(isset($a['list'][0]['version'])&&$a['list'][0]['version']>$a['list'][0]['id']){ /* if early versions missing. */
  1288. $origin=$a['list'][0]; $origin['version']=$origin['id']; array_unshift($a['list'], $origin);
  1289. }
  1290. }
  1291. if(($p = &$this->GetPost($a['id'],true))!=NULL){
  1292. $p['archive'] = &$a;
  1293. }
  1294. }
  1295. }
  1296. }
  1297. function ReadPostsFromFile($path){
  1298. if(!file_exists($path)){
  1299. $f = fopen($path,'w');
  1300. fclose($f);
  1301. }
  1302. $c = file_get_contents($path);
  1303. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1304. foreach($matches as $m){
  1305. $post = [];
  1306. $post['id'] = $m[1];
  1307. $post['real_content'] = trim($m[3]);
  1308. $post['content'] = &$post['real_content'];
  1309. if(preg_match('/COMMENT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['comment_to'] = $n[1];
  1310. if(preg_match('/EMAIL\s+([^;]+)\s*;/u', $m[2], $n)) $post['email'] = $n[1];
  1311. if(preg_match('/NAME\s+([^;]+)\s*;/u', $m[2], $n)) $post['name'] = $n[1];
  1312. if(preg_match('/LINK\s+([^;]+)\s*;/u', $m[2], $n)) $post['link'] = $n[1];
  1313. if(preg_match('/IP\s+([^;]+)\s*;/u', $m[2], $n)) $post['ip'] = $n[1];
  1314. if(preg_match('/NEXT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['next'] = $n[1];
  1315. if(preg_match('/PREV\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['prev'] = $n[1];
  1316. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1317. if(preg_match('/MDEL\s*;/u', $m[2])) $post['mark_delete'] = True;
  1318. if(preg_match('/MVAL\s*([^;]+);/u', $m[2], $n)) $post['mark_value'] = trim($n[1]);
  1319. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1320. if(preg_match('/REFS\s*([^;]+);/u', $m[2], $ma)){
  1321. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1322. foreach($links as $l){ $entries[] = $l[1]; } $post['refs'] = $entries; } }
  1323. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1324. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1325. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1326. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1327. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1328. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1329. if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
  1330. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1331. foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
  1332. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1333. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1334. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1335. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1336. $post['merged_into'] = [trim($n[1]),trim($n[2])]; }
  1337. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1338. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1339. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1340. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1341. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1342. }
  1343. if(isset($post['mark_value']) && $post['mark_value']==5){
  1344. $post['product']=[];
  1345. }
  1346. /* marks add here */
  1347. $this->Posts[] = $post;
  1348. if(isset($post['comment_to']) && ($target_post = &$this->GetPost($post['comment_to'],true))){
  1349. if(!isset($target_post['comments']) || !isset($target_post['comments'][0])) $target_post['comments']=[];
  1350. $target_post['comments'][]=&$this->Posts[count($this->Posts) - 1];
  1351. }
  1352. }
  1353. }
  1354. }
  1355. function SortPosts($wayback=false){
  1356. $cmpp = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1357. $sortlist = &$this->Posts;
  1358. if($wayback) $sortlist = &$this->WaybackPosts;
  1359. if(isset($sortlist[0])){
  1360. usort($sortlist,$cmpp);
  1361. $this->YearEnd = substr($this->TIME_STRING,0,4);
  1362. $this->YearBegin = substr($sortlist[0]['id'],0,4);
  1363. }
  1364. }
  1365. function ReadPosts(){
  1366. if ((!file_exists('la_config.md') || is_readable('la_config.md') == false) ||
  1367. (!file_exists('la_config.php') || is_readable('la_config.php') == false) ||
  1368. (!is_dir('posts') || is_readable('posts') == false) ||
  1369. (!is_dir('archive') || is_readable('archive') == false) ||
  1370. (!is_dir('images') || is_readable('images') == false) ||
  1371. (!is_dir('styles') || is_readable('styles') == false)){
  1372. $this->Install();
  1373. }
  1374. if($this->DoneReadPosts){ return; }
  1375. $file_list = [];
  1376. $glob = glob('posts/*');
  1377. foreach($glob as $file) {
  1378. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1379. $file_list[] = $file;
  1380. }
  1381. }
  1382. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1383. foreach($file_list as $f) {
  1384. $this->ReadPostsFromFile($f);
  1385. }
  1386. $this->SortPosts();
  1387. $this->DetectThreads();
  1388. $this->DoneReadPosts=1;
  1389. }
  1390. function UpdatePostRefsForWayback(){
  1391. if(!isset($this->WayBack)) return;
  1392. if(isset($this->Images[0])) foreach($this->Images as &$i){ unset($i['refs']); }
  1393. if(!isset($this->WaybackPosts[0])) return;
  1394. foreach($this->WaybackPosts as &$p){ unset($p['refs']); }
  1395. foreach($this->WaybackPosts as &$p){
  1396. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $r){
  1397. $pr = &$this->GetPost($r); if(isset($pr)){
  1398. if(!isset($pr['refs'])) $pr['refs']=[];
  1399. if(!in_array($p['id'],$pr['refs'])){ $pr['refs'][] = $p['id']; }
  1400. }
  1401. }
  1402. if(isset($p['hasi']) && isset($p['hasi'][0])) foreach($p['hasi'] as $r){
  1403. $ir = &$this->FindImage($r); if(isset($ir)){
  1404. if(!isset($ir['refs'])) $ir['refs']=[];
  1405. if(!in_array($p['id'],$ir['refs'])){ $ir['refs'][] = $p['id'];}
  1406. }
  1407. }
  1408. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1409. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1410. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$p['id']; }
  1411. }
  1412. }
  1413. }
  1414. function ReadArchive(){
  1415. if (!is_dir('archive') || is_readable('archive') == false){ $this->Install(); }
  1416. if ($this->DoneReadArchive) return;
  1417. $file_list = []; $glob = glob('archive/*');
  1418. foreach($glob as $file) {
  1419. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1420. $file_list[] = $file;
  1421. }
  1422. }
  1423. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1424. foreach($file_list as $f) {
  1425. $this->ReadArchiveFromFile($f);
  1426. }
  1427. $this->SortArchive();
  1428. $this->DoneReadArchive=1;
  1429. $this->UpdateThreadForWayback();
  1430. $this->UpdatePostRefsForWayback();
  1431. }
  1432. function GetThreadForPost(&$post){
  1433. if(isset($post['tid'])) return;
  1434. $th = []; $iterp = NULL;
  1435. $post['tid'] = &$th; $th['first'] = &$post; $th['last'] = &$post;
  1436. if(!(isset($post['prev']) || isset($post['next']))) { $this->Threads[] = &$th; return; }
  1437. if(isset($post['prev']))for($p = $post['prev']; $p!=NULL; $p = $iterp){
  1438. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1439. $np['tid'] = &$th;
  1440. $th['first'] = &$np;
  1441. $iterp = isset($np['prev'])?$np['prev']:NULL;
  1442. }
  1443. if(isset($post['next']))for($p = $post['next']; $p!=NULL; $p = $iterp){
  1444. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1445. $np['tid'] = &$th;
  1446. $th['last'] = &$np;
  1447. $iterp = isset($np['next'])?$np['next']:NULL;
  1448. }
  1449. if(isset($th['first']['mark_value'])){
  1450. if($th['first']['mark_value']==6) $th['exp'] = true;
  1451. else if($th['first']['mark_value']==7) $th['slf'] = true;
  1452. }
  1453. if($th['first'] == $th['last']){ unset($post['tid']); return; }
  1454. $this->Threads[] = &$th;
  1455. }
  1456. function IdentifyThreadCategory(&$th,&$first_post){
  1457. unset($th['categories']);unset($th['interesting']);unset($th['reversed']);
  1458. if(preg_match('/^\s*\@(.*?)$/mu',$first_post['content'],$m)){
  1459. $first_post['categories']=[]; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1460. foreach($matches as $ma){ $first_post['categories'][] = $ma[1]; }
  1461. }
  1462. if(isset($th) && $th){ $th['categories'] = &$first_post['categories']; }
  1463. }
  1464. if(preg_match('/\{\s*WIDE\s*\}/imu',$first_post['content'],$m)){ $first_post['wide'] = true; }
  1465. if(preg_match('/\{\s*NO_TIME\s*\}/imu',$first_post['content'],$m)){ $first_post['no_time'] = true; }
  1466. if(preg_match('/\{\s*NO_TITLE\s*\}/imu',$first_post['content'],$m)){ $first_post['no_title'] = true; }
  1467. if(preg_match('/\{\s*HEADER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['header'] = trim($m[1]); }
  1468. if(preg_match('/\{\s*FOOTER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['footer'] = trim($m[1]); }
  1469. if(!isset($th)) return;
  1470. if(isset($first_post['wide'])) $th['wide']=$first_post['wide'];
  1471. if(isset($first_post['header'])) $th['header']=$first_post['header'];
  1472. if(isset($first_post['footer'])) $th['footer']=$first_post['footer'];
  1473. if(isset($first_post['no_time'])) $th['no_time']=$first_post['no_time'];
  1474. if(isset($first_post['no_title'])) $th['no_title']=$first_post['no_title'];
  1475. if(preg_match('/\{\s*INTERESTING\s+(.*?)\}/imu',$first_post['content'],$m)){
  1476. $th['interesting'] = []; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1477. foreach($matches as $ma){ $th['interesting'][] = $ma[1]; }
  1478. }
  1479. }
  1480. if(preg_match('/\{\s*REVERSED(\s+.*?)?\}/imu',$first_post['content'],$m)){ $th['reversed'] = 'm';
  1481. if(isset($m[1])&&preg_match('/^\s*(y|m|d|p)/iu',$m[1],$ma)){ $th['reversed']=$ma[1]; }
  1482. }
  1483. }
  1484. function IsInterestingPost(&$p){
  1485. if(isset($p['tid']) && isset($p['tid']['interesting']) && isset($p['tid']['interesting'][0])) return true;
  1486. return false;
  1487. }
  1488. function IsReversedThread(&$th){
  1489. if(isset($th['reversed']) && $th['reversed']!=false) return true;
  1490. return false;
  1491. }
  1492. function GiveAllMergedPosts(&$po,&$arr){
  1493. if(isset($po['merged_from'])&&isset($po['merged_from'][0])) foreach($po['merged_from'] as $pm){
  1494. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr);}
  1495. }
  1496. if(isset($po['archive']) && isset($po['archive']['list'])){
  1497. foreach($po['archive']['list'] as &$ver){
  1498. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $pm){
  1499. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr); } }
  1500. }
  1501. }
  1502. }
  1503. function ThreadMakeWayback(&$th){
  1504. if(!isset($th['arr'][0])) return;
  1505. if(isset($this->WayBack)){
  1506. $remlist = [];
  1507. foreach($th['arr'] as &$pi){
  1508. $po = &$this->GetPost($pi['id'],true); if(!isset($po)){continue;/*merged*/}
  1509. if(isset($po['merged_thread']) && isset($po['version']) && $po['version']>$this->WayBack){
  1510. $remlist = array_unique(array_merge($remlist,$po['merged_thread'][0]));
  1511. }
  1512. $ah = &$this->GetArchiveHandle($po['id']);
  1513. if(isset($ah)) foreach(array_reverse($ah['list']) as &$ver){
  1514. if(!isset($ver['merged_thread'])) continue;
  1515. if((isset($ver['version']) && $ver['version'] > $this->WayBack) ||
  1516. (!isset($ver['version']) && $ver['id'] > $this->WayBack)){
  1517. $remlist = array_unique(array_merge($remlist,$ver['merged_thread'][0]));
  1518. }
  1519. }
  1520. }
  1521. if(isset($remlist[0]) && isset($th['arr'][0])){
  1522. foreach($remlist as $rem){ $this->GiveAllMergedPosts($this->GetPost($rem,true),$remlist); }
  1523. foreach($th['arr'] as $key => $pr){
  1524. foreach($remlist as $rem){ if($pr['id'] == $rem) { unset($th['arr'][$key]); break; } } }
  1525. $new_th = []; $new_arr = [];
  1526. foreach($remlist as $rem){ $np=&$this->GetPost($rem); if(isset($np)){$new_arr[]=&$np;} }
  1527. $new_th['arr'] = &$new_arr;
  1528. $this->WaybackThreads[] = &$new_th;
  1529. $this->ThreadMakeWayback($new_th);
  1530. }
  1531. }
  1532. }
  1533. function AddMergedPosts(&$p, &$array){
  1534. if(isset($p['archive']) && isset($p['archive']['list'])){
  1535. foreach($p['archive']['list'] as &$ver){
  1536. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $po){
  1537. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1538. }
  1539. }
  1540. if(isset($p['merged_from'])&&isset($p['merged_from'][0])) foreach($p['merged_from'] as $po){
  1541. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1542. }
  1543. function &array_shift_ref(&$array){if(count($array)>0){$key=key($array);$first=&$array[$key];}else{$first=null;}array_shift($array);return $first;}
  1544. function FinalizeThread(&$th, $relink_posts=false, $now){
  1545. $nextp=NULL; $arr=[]; $lasttime=NULL;
  1546. if(!isset($th['arr'])){
  1547. for($p = &$th['first']; $p!=$this->NULL_POST; $p = &$this->GetPost(isset($p['next'])?$p['next']:NULL,true)){
  1548. $arr[]=&$p;
  1549. } $th['arr'] = &$arr;
  1550. if(isset($this->WayBack) && $this->DoneReadArchive){ $new_arr=[];
  1551. foreach($arr as &$p){ $pa = &$this->GetPost($p['id']); if(isset($pa)) {$new_arr[]=&$pa;$this->WaybackPosts[]=&$pa;} }
  1552. foreach($arr as &$p){ $this->AddMergedPosts($p,$new_arr); }
  1553. $arr=&$new_arr; $th['arr']=&$new_arr;
  1554. $this->ThreadMakeWayback($th); }
  1555. }
  1556. $cmppt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1557. if(isset($th['arr'][0])){ usort($th['arr'],$cmppt); } $th['count'] = sizeof($th['arr']);
  1558. if($relink_posts){ $count = $th['count'];
  1559. $arr = &$th['arr'];
  1560. 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'];
  1561. $arr[$i]['tid']=&$th;}
  1562. $th['first'] = &$arr[0]; $th['last'] = &$arr[$count-1]; unset($arr[0]['prev']); unset($arr[$count-1]['next']);
  1563. }
  1564. $th['score'] = 0; if(!isset($th['first'])){ return; }
  1565. $this->IdentifyThreadCategory($th, $th['first']);
  1566. if(isset($this->WayBack)) $lasttime=$this->WayBack;
  1567. if(!isset($last_time)) $lasttime = DateTime::createFromFormat('YmdHis', $th['last']['id']);
  1568. $diff_days = ($now - date_timestamp_get($lasttime))/3600/24;
  1569. $th['score'] = (float)$th['count']*0.2 - min($diff_days,200);
  1570. if(isset($th['reversed'])){ $chunks=[]; $last_id=$last_y=$last_m=$last_d=0; $mo=$th['reversed']; $final=[];
  1571. $first_post=&$this->array_shift_ref($th['arr']); $ch=[];
  1572. while($n=&$this->array_shift_ref($th['arr'])){
  1573. $this_id=$n['id']; $this_y=substr($this_id,0,4); $this_m=substr($this_id,4,2); $this_d=substr($this_id,6,2);
  1574. if($mo=='y'&&$this_y!=$last_y){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y; }
  1575. if($mo=='m'&&$this_m!=$last_m){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y.'/'.$this_m; }
  1576. if($mo=='d'&&$this_d!=$last_d){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y.'/'.$this_m.'/'.$this_d; }
  1577. if($mo=='p'){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} }
  1578. $ch[]=&$n; $last_id=$this_id; $last_y=$this_y; $last_m=$this_m; $last_d=$this_d;
  1579. }if(isset($ch[0])){$chunks[]=$ch;} if(isset($chunks[0])){$use_chunks=array_reverse($chunks);}
  1580. $final[]=&$first_post;
  1581. foreach($use_chunks as &$ch){ foreach($ch as &$p){ $final[]=&$p;} }
  1582. $th['arr']=$final; }
  1583. }
  1584. function SortThreads(){
  1585. if (!function_exists('cmpt')) {
  1586. function cmpt($a, $b){
  1587. if ($a['score'] == $b['score']) return 0;
  1588. return ($a['score'] > $b['score']) ? -1 : 1;
  1589. }
  1590. }
  1591. usort($this->Threads,"cmpt");
  1592. }
  1593. function DetectThreads(){
  1594. foreach($this->Posts as &$p){
  1595. if(isset($p['tid'])) { continue; }
  1596. $this->GetThreadForPost($p);
  1597. if(!isset($p['tid'])) { $this->IdentifyThreadCategory($this->NULL_POST, $p); }
  1598. }
  1599. if(!isset($this->Threads) || !isset($this->Threads[0])) return;
  1600. $now = date_timestamp_get(date_create());
  1601. foreach($this->Threads as &$t){
  1602. $this->FinalizeThread($t,false,$now);
  1603. }
  1604. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1605. $this->FinalizeThread($th,false,$now);
  1606. $this->Threads[] = &$th;
  1607. }
  1608. $this->SortThreads();
  1609. }
  1610. function UpdateThreadForWayback(){$now = date_timestamp_get(date_create());
  1611. if(!isset($this->WayBack) || !$this->DoneReadArchive){ return; }
  1612. foreach($this->Threads as &$t){
  1613. unset($t['arr']); $this->FinalizeThread($t,true,$now);
  1614. }
  1615. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1616. $this->FinalizeThread($th,true,$now);
  1617. $this->Threads[] = &$th;
  1618. }
  1619. $this->SortThreads();
  1620. $this->SortPosts(true);
  1621. $this->UsePosts = &$this->WaybackPosts;
  1622. }
  1623. function &GetMergedPost($id){
  1624. $this->ReadArchive();
  1625. $ah = &$this->GetArchiveHandle($id);
  1626. if(!isset($ah) || !isset($ah['list']) || !isset($ah['list'][0])){ return $this->NULL_POST; }
  1627. $ver = &$ah['list'][sizeof($ah['list'])-1];
  1628. if(!isset($ver['merged_into'])) return $this->GetPost($id);
  1629. [$tp, $tver] = $ver['merged_into'];
  1630. if(isset($this->WayBack)){
  1631. if($tver <= $this->WayBack) return $this->GetMergedPost($tp);
  1632. else return $this->GetPost($id); /* should not happen directly. */
  1633. }
  1634. return $this->GetMergedPost($tp);
  1635. }
  1636. function &GetPost($id, $latest_only=false, $find_merged=false){
  1637. if(!isset($id)) return $this->NULL_POST;
  1638. $found=&$this->NULL_POST;
  1639. if(isset($this->Posts[0])) foreach($this->Posts as &$p){
  1640. if($p&& $p['id'] == $id) { $found = &$p; break; }
  1641. if($find_merged && isset($p['hastag'][0]) && in_array($id, $p['hastag'])){ $found = &$p; break; }
  1642. }
  1643. if($latest_only || !isset($this->WayBack)){ return $found; }
  1644. else{
  1645. if(isset($found)){
  1646. if(!isset($found['archive'])&&!isset($found['archive']['list']))
  1647. { if($found['id'] > $this->WayBack) return $this->NULL_POST; else return $found; }
  1648. $last_ver = &$this->NULL_POST;
  1649. if(isset($found['archive']['list'][0])) foreach($found['archive']['list'] as &$ver){
  1650. if($ver['version'] > $this->WayBack) return $last_ver;
  1651. $last_ver = &$ver;
  1652. }
  1653. if(isset($found['version']) && $found['version'] <= $this->WayBack) return $found;
  1654. else return $last_ver;
  1655. }else{
  1656. $ah = &$this->GetArchiveHandle($id); $last_ver = &$this->NULL_POST;
  1657. if(isset($ah) && isset($ah['list']) && isset($ah['list'][0])) foreach($ah['list'] as &$ver){
  1658. if($ver['version'] > $this->WayBack) return $last_ver;
  1659. $last_ver = &$ver;
  1660. } if(!isset($last_ver['merged_into'])) return $last_ver; else{
  1661. [$tp, $tver] = $last_ver['merged_into'];
  1662. if($tver <= $this->WayBack) {
  1663. if($find_merged && $tp!=$id) return $this->GetPost($tp); return $this->NULL_POST; }
  1664. return $last_ver;
  1665. }
  1666. }
  1667. }
  1668. return $this->NULL_POST;
  1669. }
  1670. function &GetArchiveHandle($id){
  1671. if(!isset($id)) return $this->NULL_POST;
  1672. if(isset($this->ArchiveHandles[0])) foreach($this->ArchiveHandles as &$p){
  1673. if($p && $p['id'] == $id) { return $p; }
  1674. }
  1675. return $this->NULL_POST;
  1676. }
  1677. function &GetArchive($id){
  1678. if(!isset($id)) return $this->NULL_POST;
  1679. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1680. if($p && $p['id'] == $id) { return $p; }
  1681. }
  1682. return $this->NULL_POST;
  1683. }
  1684. function &GetArchiveVersion(&$ah, $version, &$next_ver, &$last_ver){
  1685. if(!isset($ah)) return $this->NULL_POST;
  1686. $found = NULL; $last_verp=NULL;
  1687. if(isset($ah['list'][0])) foreach($ah['list'] as &$p){
  1688. if(isset($found)){ $next_ver = $p; $last_ver = $last_verp; return $found; }
  1689. if($p && $p['version'] == $version) { $found = &$p; continue; }
  1690. $last_verp = &$p;
  1691. }
  1692. if(isset($found)) { $next_ver=NULL; $last_ver = $last_verp; return $found; }
  1693. return $this->NULL_POST;
  1694. }
  1695. function CacheArchiveOwnLinks(){
  1696. if(isset($this->WayBack)) return;
  1697. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1698. $this->ConvertPost($p); unset($p['hasp']); unset($p['hasi']); unset($p['hastag']);
  1699. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$p['html'],$matches,PREG_SET_ORDER)){
  1700. foreach($matches as $m){
  1701. if(!isset($p['hasp']))$p['hasp']=[]; if(!in_array($m[1],$p['hasp'])){ $p['hasp'][]=$m[1]; }
  1702. }
  1703. }
  1704. if(preg_match_all('/\/\/([0-9]{14})/u', $p['content'],$matches,PREG_SET_ORDER)){
  1705. foreach($matches as $m){
  1706. if(!isset($p['hastag']))$p['hastag']=[]; if(!in_array($m[1],$p['hastag'])){ $p['hastag'][]=$m[1]; }
  1707. }
  1708. }
  1709. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\)/u', $p['content'],$matches,PREG_SET_ORDER)){
  1710. foreach($matches as $m){
  1711. if(!isset($p['hasi']))$p['hasi']=[]; if(!in_array($m[2],$p['hasi'])){ $p['hasi'][]=$m[2]; }
  1712. }
  1713. }
  1714. }
  1715. }
  1716. function WriteArchive(){
  1717. if(isset($this->WayBack)) return;
  1718. $cf = NULL;$opened =NULL;
  1719. $this->SortArchive();
  1720. $this->CacheArchiveOwnLinks();
  1721. if(isset($this->Archive[0])) foreach($this->Archive as $p){
  1722. $nid = substr($p['id'], 0,6);
  1723. if($cf != $nid){
  1724. if($opened){
  1725. fflush($opened);
  1726. fclose($opened);
  1727. }
  1728. $cf = $nid;
  1729. $opened = fopen("archive/$cf.md", 'w');
  1730. }
  1731. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1732. "VER {$p['version']}; ".
  1733. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1734. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1]).";"):"").
  1735. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1736. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1737. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1738. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1739. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1740. ']';
  1741. if(isset($p['merged_thread'])){ $p['content']=""; }
  1742. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['content'].PHP_EOL.PHP_EOL);
  1743. }
  1744. }
  1745. function WritePosts(){
  1746. if(isset($this->WayBack)) return;
  1747. $cf = NULL;$opened =NULL;
  1748. $this->SortPosts();
  1749. if(isset($this->Posts[0])) foreach($this->Posts as $p){
  1750. $nid = substr($p['id'], 0,6);
  1751. if($cf != $nid){
  1752. if($opened){
  1753. fflush($opened);
  1754. fclose($opened);
  1755. }
  1756. $cf = $nid;
  1757. $opened = fopen("posts/$cf.md", 'w');
  1758. }
  1759. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1760. ((isset($p['version']) && $p['version'])?"VER {$p['version']}; ":"").
  1761. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1762. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1763. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1764. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1])."; "):"").
  1765. ((isset($p['comment_to']) && $p['comment_to'])?"COMMENT {$p['comment_to']}; ":"").
  1766. ((isset($p['email']) && $p['email'])?"EMAIL {$p['email']}; ":"").
  1767. ((isset($p['name']) && $p['name'])?"NAME {$p['name']}; ":"").
  1768. ((isset($p['link']) && $p['link'])?"LINK {$p['link']}; ":"").
  1769. ((isset($p['ip']) && $p['ip'])?"IP {$p['ip']}; ":"").
  1770. ((isset($p['mark_delete']) && $p['mark_delete'])?"MDEL; ":"").
  1771. ((isset($p['mark_value']) && $p['mark_value']>=0)?"MVAL {$p['mark_value']}; ":"").
  1772. ((isset($p['next']) && $p['next'])?"NEXT {$p['next']}; ":"").
  1773. ((isset($p['prev']) && $p['prev'])?"PREV {$p['prev']}; ":"").
  1774. ((isset($p['refs']) && isset($p['refs'][0]))?("REFS ".implode(" ",$p['refs'])."; "):"").
  1775. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1776. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1777. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1778. ((isset($p['mastodon_url']) && isset($p['mastodon_url']))?("MSTDN ".$p['mastodon_url']."; "):"").
  1779. ']';
  1780. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['real_content'].PHP_EOL.PHP_EOL);
  1781. }
  1782. }
  1783. function CachePostLinks(){
  1784. if(isset($this->WayBack)) return;
  1785. if(isset($this->Posts) && isset($this->Posts[0]))foreach ($this->Posts as &$post){
  1786. $this->ConvertPost($post);
  1787. unset($post['refs']);unset($post['hasp']);unset($post['hasi']);unset($post['hastag']);
  1788. //discard lost old version
  1789. //if(!isset($post['archive']) && $this->DoneReadArchive && isset($post['version'])){ unset($post['version']); }
  1790. }else return;
  1791. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1792. unset($im['refs']); unset($im['here']); unset($im['title']);
  1793. }
  1794. foreach ($this->Posts as &$post){
  1795. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$post['html'],$matches,PREG_SET_ORDER)){
  1796. foreach($matches as $m){
  1797. $ref = &$this->GetPost($m[1],true);
  1798. if($ref!=NULL){
  1799. if(!isset($ref['refs']))$ref['refs']=[]; if(!in_array($post['id'],$ref['refs']))$ref['refs'][]=$post['id'];
  1800. }
  1801. if(!isset($post['hasp']))$post['hasp']=[]; if(!in_array($m[1],$post['hasp']))$post['hasp'][]=$m[1];
  1802. }
  1803. }
  1804. if(preg_match_all('/\/\/([0-9]{14})/u', $post['content'],$matches,PREG_SET_ORDER)){
  1805. foreach($matches as $m){
  1806. if(!isset($post['hastag']))$post['hastag']=[]; if(!in_array($m[1],$post['hastag']))$post['hastag'][]=$m[1];
  1807. }
  1808. }
  1809. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\)/u', $post['content'],$matches,PREG_SET_ORDER)){
  1810. foreach($matches as $m){
  1811. if(($im = &$this->FindImage($m[2]))!=NULL){
  1812. if(!isset($im['refs']))$im['refs']=[]; if(!in_array($post['id'], $im['refs']))$im['refs'][] = $post['id'];
  1813. }
  1814. if(!isset($post['hasi']))$post['hasi']=[]; if(!in_array($m[2],$post['hasi']))$post['hasi'][]=$m[2];
  1815. }
  1816. }
  1817. if(preg_match("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\))(\R*(\R(-|\*).+){1,})/u",
  1818. $post['content'],$matches)){
  1819. $use_img_name = $matches[2];
  1820. if(($im = &$this->FindImage($use_img_name))!=NULL){
  1821. 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",
  1822. $matches[4],$mah,PREG_SET_ORDER)){
  1823. foreach($mah as $ma){
  1824. if(!isset($im['here']))$im['here']=[]; if(!$this->ImageHasHere($item, $ma[4])){
  1825. $here = [$ma[4], $ma[2], $ma[3]]; $im['here'][] = $here; }
  1826. }
  1827. }
  1828. }
  1829. }
  1830. }foreach($this->Posts as &$post){
  1831. if(isset($post['hasp']) && isset($post['hasp'][0])) foreach($post['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1832. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1833. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$post['id']; }
  1834. }
  1835. }
  1836. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1837. $min_id = '99999999999999';
  1838. if(isset($im['refs']) && isset($im['refs'][0])) foreach ($im['refs'] as &$ref){
  1839. $r = &$this->GetPost($ref,true); if(isset($r)) $title = $this->GetPostTitle($r,true,false);
  1840. if($title && $ref<$min_id) { $im['title'] = preg_replace('/;/u',' ',trim($title)); $min_id=$r['id']; }
  1841. }
  1842. }
  1843. }
  1844. function CreatePostAnchor(&$post){
  1845. $that=&$this;
  1846. $post['html'] = preg_replace_callback('/<h([0-9])>(.+?)(?=<\/h[0-9]>)/u', function ($ma) use ($that){
  1847. $id = '_heading_'.sizeof($this->Anchors);
  1848. $entry=[(int)$ma[1], $id, $ma[2]];
  1849. $that->Anchors[] = $entry;
  1850. return "<h${ma[1]} id='${id}'>${ma[2]}";
  1851. }, $post['html']);
  1852. }
  1853. function RenamePost(&$post, $rename){
  1854. foreach($this->Posts as &$p){
  1855. if($p['id']==$rename && $p!==$post) { return; /* don't overwrite */ }
  1856. }
  1857. foreach($this->Posts as &$p){
  1858. if(isset($p['prev']) && $p['prev']==$post['id']) { $p['prev']=$rename; }
  1859. if(isset($p['next']) && $p['next']==$post['id']) { $p['next']=$rename; }
  1860. }
  1861. $post['id'] = $rename;
  1862. }
  1863. function DetachPost(&$th,&$post){
  1864. $p0=$p1=NULL;foreach($th['arr'] as $a) echo $a['id']." "; echo '&nbsp;&nbsp;&nbsp;-'.$post['id']."<br />";
  1865. if(isset($post['prev'])){$p0=&$this->GetPost($post['prev'],true);} if(isset($post['next'])){$p1=&$this->GetPost($post['next'],true);}
  1866. if(isset($p0)){ $p0['next']=$p1['id']; }else{ $th['first']=$p1['id']; }
  1867. if(isset($p1)){ $p1['prev'] =$p0['id']; }else{ $th['last']=$p0['id']; }
  1868. foreach($this->Posts as $key => $p){ if ($p==$post) unset($this->Posts[$key]); }
  1869. unset($th['arr']); $now = date_timestamp_get(date_create());
  1870. $this->FinalizeThread($th, true, $now);
  1871. }
  1872. function PushPostVersion(&$post, $optime_id, $mode=1, $info=NULL){
  1873. $a = &$this->GetArchiveHandle($post['id']);
  1874. $ap = []; $ap['id'] = $post['id']; $ap['content'] = $post['real_content'];
  1875. $ap['version'] = isset($post['version'])?$post['version']:$ap['id'];
  1876. if(isset($post['merged_from'])) { $ap['merged_from'] = $post['merged_from']; unset($post['merged_from']); }
  1877. if(isset($post['merged_into'])) { $ap['merged_into'] = $post['merged_into']; unset($post['merged_into']); }
  1878. if(isset($post['merged_thread'])) { $ap['merged_thread'] = $post['merged_thread']; unset($post['merged_thread']); }
  1879. $post['version'] = $optime_id;
  1880. if($mode==1){
  1881. $this->InsertArchivePost($ap);
  1882. }else if($mode==2){
  1883. $post['merged_from'] = $info;
  1884. $this->InsertArchivePost($ap);
  1885. }else if($mode==3){
  1886. $ap['merged_into'] = $info;
  1887. $this->InsertArchivePost($ap);
  1888. if(isset($post['tid']) && $post['tid']['first']!=$post['tid']['last'] && $post!=$post['tid']['first']){
  1889. $this->DetachPost($post['tid'], $post);
  1890. }
  1891. }else if($mode==4){
  1892. $post['merged_thread'] = $info;
  1893. $this->InsertArchivePost($ap);
  1894. }
  1895. }
  1896. function &MergeThreads($post_id, $post_into_id){
  1897. $this->ReadPosts();
  1898. $po = &$this->GetPost($post_id, true); $pt = &$this->GetPost($post_into_id, true);
  1899. if (!isset($po) || !isset($pt) || !isset($po['tid']) || !isset($pt['tid']) ||
  1900. !isset($po['tid']['arr'][0]) || !isset($pt['tid']['arr'][0])){ return $this->NULL_POST; }
  1901. $po = &$po['tid']['arr'][0]; $pt = &$pt['tid']['arr'][0];
  1902. $th = &$po['tid']; $tt = &$pt['tid']; $info=[[],[]];
  1903. if($po['id'] < $pt['id']){ $temp = &$th; $th=&$tt; $tt=&$temp; $temp = &$po; $po=&$pt; $pt=&$temp; }
  1904. foreach($th['arr'] as &$p){ $info[0][]=$p['id']; }
  1905. foreach($tt['arr'] as &$p){ $info[1][]=$p['id']; }
  1906. $this->EditPost($pt['id'], NULL, NULL, NULL, false, NULL, NULL, 4, $info,NULL);
  1907. $arr_combined = array_merge($tt['arr'],$th['arr']);
  1908. $cmppmt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1909. if(isset($arr_combined[0])){ usort($arr_combined,$cmppmt); } $tt['arr']=&$arr_combined;
  1910. $tt['count'] = sizeof($tt['arr']);
  1911. $this->FinalizeThread($tt, true, $this->TIME_STRING);
  1912. $first_post = &$this->NULL_POST;
  1913. if(isset($tt['arr'][0])) $first_post= &$tt['arr'][0];
  1914. $this->NeedWritePosts=1;
  1915. $this->NeedWriteArchive=1;
  1916. return $first_post;
  1917. }
  1918. function &MergePosts($ids_string){
  1919. $ids = explode(" ", $ids_string);
  1920. $combined_content = ""; $first_id=NULL;
  1921. $this->ReadPosts(); $child_list=[];
  1922. foreach($ids as $id){
  1923. if(!preg_match('/[0-9]{14}/u',$id) || $this->GetPost($id,true)==$this->NULL_POST) continue;
  1924. if(!isset($first_id)) { $first_id = $id; } else { $combined_content.=PHP_EOL.PHP_EOL."//".$id.PHP_EOL; $child_list[]=$id; }
  1925. $combined_content.=$this->EditPost($id, NULL, NULL, NULL, true, NULL, NULL, false, NULL,NULL);
  1926. }
  1927. if(!isset($child_list[0])) return $this->NULL_POST;
  1928. $first_post = &$this->EditPost($first_id, $combined_content, NULL, NULL, false, NULL, NULL, 2, $child_list,NULL);
  1929. foreach($child_list as $id){
  1930. $this->EditPost($id, NULL, NULL, NULL, false, NULL, NULL, 3, [$first_id,$this->TIME_STRING],NULL);
  1931. }
  1932. $this->NeedWritePosts=1;
  1933. $this->NeedWriteArchive=1;
  1934. return $first_post;
  1935. }
  1936. /* push_version: 1 edit 2 post merged from ids list 3 post end into id-ver */
  1937. function &EditPost($id_if_edit, $content, $mark_delete, $reply_to,
  1938. $get_original_only=false, $mark_value=NULL, $rename=NULL,
  1939. $push_version=false, $version_info=NULL, $mastodon_url=NULL){
  1940. $this->ReadImages();
  1941. $this->ReadPosts();
  1942. if(isset($push_version) && $push_version){
  1943. $this->ReadArchive();
  1944. }
  1945. $p_success = NULL;
  1946. if(isset($id_if_edit)){
  1947. $post = &$this->GetPost($id_if_edit,true);
  1948. if($post===$this->NULL_POST) return $this->NULL_POST;
  1949. if($get_original_only){
  1950. return $post['real_content'];
  1951. }
  1952. if(isset($push_version) && $push_version){
  1953. $this->PushPostVersion($post,$this->TIME_STRING,$push_version,$version_info);
  1954. }
  1955. if(isset($content)) {$post['real_content'] = $content; $post['content'] = &$post['real_content'];}
  1956. if(isset($mark_delete)) $post['mark_delete'] = $mark_delete;
  1957. if(isset($mark_value)) $post['mark_value'] = $mark_value;
  1958. if(isset($rename) && preg_match('/^[0-9]{14}$/u',$rename)) $this->RenamePost($post,$rename);
  1959. if(isset($mastodon_url)) { if($mastodon_url!='') $post['mastodon_url']=$mastodon_url; else unset($post['mastodon_url']); }
  1960. $p_success = &$post;
  1961. }else{
  1962. if(!isset($content)) return $this->NULL_POST;
  1963. $id = date('YmdHis');
  1964. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  1965. $post = []; $post['id'] = $id;
  1966. $post['real_content'] = $content; $post['content'] = &$post['real_content'];
  1967. if(isset($reply_to) && ($rep = &$this->GetPost($reply_to,true))!== $this->NULL_POST){
  1968. while($rep !== $this->NULL_POST && isset($rep['next']) && $rep['next']){ $rep = &$this->GetPost($rep['next'],true); }
  1969. if($rep !== $this->NULL_POST){ $rep['next'] = $id; $post['prev'] = $rep['id']; }
  1970. }
  1971. $this->Posts[] = $post;
  1972. $p_success = &$this->Posts[count($this->Posts) - 1];
  1973. }
  1974. $this->NeedWritePosts=1;
  1975. $this->NeedWriteImages=1;
  1976. if(isset($push_version) && $push_version){
  1977. $this->NeedWriteArchive=1;
  1978. }
  1979. return $p_success;
  1980. }
  1981. function &EditComment($id_if_edit, $comment_to_id, $content, $email, $name, $link=NULL, $ip=NULL){
  1982. $this->ReadPosts();
  1983. $p_success = NULL;
  1984. if(isset($id_if_edit)){
  1985. $post = &$this->GetPost($id_if_edit,true);
  1986. if($post===$this->NULL_POST || !isset($post['comment_to'])) return $this->NULL_POST;
  1987. if(isset($content)) $post['content'] = $content;
  1988. if(isset($comment_to_id)) $post['comment_to'] = $comment_to_id;
  1989. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  1990. if(isset($ip)) $post['ip'] = $ip;
  1991. $p_success = &$post;
  1992. }else{
  1993. if(!isset($content) || !isset($comment_to_id)) return $this->NULL_POST;
  1994. $id = date('YmdHis');
  1995. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  1996. if(!($to_post=$this->GetPost($comment_to_id,true))) return $this->NULL_POST;
  1997. $post = []; $post['id'] = $id; $post['content'] = $content; $post['comment_to'] = $comment_to_id;
  1998. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  1999. if(isset($ip)) $post['ip'] = $ip;
  2000. $this->Posts[] = $post;
  2001. $p_success = &$this->Posts[count($this->Posts) - 1];
  2002. }
  2003. $this->NeedWritePosts=1;
  2004. return $p_success;
  2005. }
  2006. function InsertReplacementSymbols($MarkdownContent, &$post_for_it_is_here){
  2007. $replacement = preg_replace('/<!--[\s\S]*-->/U',"",$MarkdownContent);
  2008. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  2009. function($matches){
  2010. $rep = preg_replace('/->/','-@>',$matches[0]);
  2011. $rep = preg_replace('/=>/','=@>',$rep);
  2012. $rep = preg_replace('/<=/','<@=',$rep);
  2013. $rep = preg_replace('/<-/','<@-',$rep);
  2014. $rep = preg_replace('/\R([+]{3,})\R/',PHP_EOL.'@$1'.PHP_EOL,$rep);
  2015. $rep = preg_replace('/\[-/','[@-',$rep);
  2016. $rep = preg_replace('/\{/','{@',$rep);
  2017. $rep = preg_replace('/(en|zh|any)\|(en|zh|any)/','$1@|$2',$rep);
  2018. return $rep;
  2019. },
  2020. $replacement);
  2021. $replacement = preg_replace("/<[-]+>/","↔",$replacement);
  2022. $replacement = preg_replace("/([^-])->/","$1→",$replacement);
  2023. $replacement = preg_replace("/<-([^-])/","←$1",$replacement);
  2024. $replacement = preg_replace("/([^-])[-]+->/","$1⟶",$replacement);
  2025. $replacement = preg_replace("/<-[-]+([^-])/","⟵$1",$replacement);
  2026. $replacement = preg_replace("/<[=]+>/","⇔",$replacement);
  2027. $replacement = preg_replace("/[=]+>/","⇒",$replacement);
  2028. $replacement = preg_replace("/<[=]+/","⇐",$replacement);
  2029. $replacement = preg_replace("/\R([+]{3,})\R/","<div class='page_break'></div>",$replacement);
  2030. $replacement = preg_replace("/\[-(.*)-\]/U","<span class='text_highlight'>$1</span>",$replacement);
  2031. $replacement = preg_replace("/{支付宝(\s+[^}]*?)?}/u","<span class='special_alipay'>支付宝$1</span>",$replacement);
  2032. $replacement = preg_replace("/{PayPal(\s+[^}]*?)?}/ui",
  2033. "<span class='special_paypal'>Pay<span class='special_paypal_inner'>Pal</span>$1</span>",$replacement);
  2034. $replacement = preg_replace("/\/\/([0-9]{14})/imu","<p class='wscroll' id='$1'>".$this->T("链接位置")."</p>",$replacement);
  2035. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  2036. function($matches){
  2037. $rep = preg_replace('/-@>/','->',$matches[0]);
  2038. $rep = preg_replace('/<@-/','<-',$rep);
  2039. $rep = preg_replace('/=@>/','=>',$rep);
  2040. $rep = preg_replace('/<@=/','<=',$rep);
  2041. $rep = preg_replace('/\R@([+]{3,})\R/',PHP_EOL.'$1'.PHP_EOL,$rep);
  2042. $rep = preg_replace('/\[@-/','[-',$rep);
  2043. $rep = preg_replace('/\{@/','{',$rep);
  2044. $rep = preg_replace('/(en|zh|any)@\|(en|zh|any)/','$1|$2',$rep);
  2045. return $rep;
  2046. }, $replacement);
  2047. $replacement = preg_replace_callback("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\))(\R*(\R.+){1,})/u",
  2048. function($matches) use (&$post_for_it_is_here){
  2049. $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]);
  2050. return $matches[1].$rep;
  2051. }, $replacement);
  2052. return $replacement;
  2053. }
  2054. function CanShowPost(&$p){
  2055. if(!isset($p) || isset($p['comment_to'])) return false;
  2056. $is_mark_exp = (isset($p['tid'])&&isset($p['tid']['exp'])&&$p['tid']['exp']) || (isset($p['mark_value'])&&$p['mark_value']==6);
  2057. $is_mark_slf = (isset($p['tid'])&&isset($p['tid']['slf'])&&$p['tid']['slf']) || (isset($p['mark_value'])&&$p['mark_value']==7);
  2058. if($is_mark_slf && !$this->LoggedIn){ return false; }
  2059. if(isset($this->WayBack)){
  2060. if(isset($p['version'])) { if ($p['version']>$this->WayBack) return false; }
  2061. else if ($p['id']>$this->WayBack) return false;
  2062. }
  2063. if(!$this->InExperimentalMode){
  2064. if(!$this->LoggedIn){
  2065. if($is_mark_exp) return false;
  2066. return true;
  2067. }
  2068. return true;
  2069. }else{
  2070. if($is_mark_exp) return true;
  2071. return false;
  2072. }
  2073. }
  2074. function SkipProduct(&$p){
  2075. if($this->LoggedIn) return false;
  2076. return (isset($p['mark_value']) && $p['mark_value']==5);
  2077. }
  2078. function GetRedirect($args=NULL){
  2079. $str = 'index.php?';
  2080. if(isset($args['post'])) $str.='&post='.$args['post'];
  2081. else if(isset($_GET['post'])) $str.='&post='.$_GET['post'];
  2082. if(isset($args['gallery'])) $str.='&gallery='.$args['gallery'];
  2083. else if(isset($_GET['gallery'])) $str.='&gallery='.$_GET['gallery'];
  2084. if(isset($args['pic'])) $str.='&pic='.$args['pic'];
  2085. else if(isset($_GET['pic'])) $str.='&pic='.$_GET['pic'];
  2086. if(isset($args['settings'])) $str.='&settings='.$args['settings'];
  2087. else if(isset($_GET['settings'])) $str.='&settings='.$_GET['settings'];
  2088. if(isset($args['statistics'])) $str.='&statistics='.$args['statistics'];
  2089. else if(isset($_GET['statistics'])) $str.='&statistics='.$_GET['statistics'];
  2090. if(isset($args['extras'])) $str.='&extras='.$args['extras'];
  2091. else if(isset($_GET['extras'])) $str.='&extras='.$_GET['extras'];
  2092. if(isset($args['category'])) $str.='&category='.$args['category'];
  2093. else if(isset($_GET['category'])) $str.='&category='.$_GET['category'];
  2094. if(isset($args['history'])) $str.='&history='.$args['history'];
  2095. else if(isset($_GET['history'])) $str.='&history='.$_GET['history'];
  2096. if(isset($args['version'])) $str.='&version='.$args['version'];
  2097. else if(isset($_GET['version'])) $str.='&version='.$_GET['version'];
  2098. if(isset($args['search'])) $str.='&search='.$args['search'];
  2099. else if(isset($_GET['search'])) $str.='&search='.$_GET['search'];
  2100. if(isset($args['here'])) $str.='&here='.$args['here'];
  2101. else if(isset($_GET['here'])) $str.='&here='.$_GET['here'];
  2102. return $str;
  2103. }
  2104. function WriteAsNecessary(){
  2105. if(!$this->LoggedIn || isset($this->WayBack)){return;}
  2106. if($this->NeedWritePosts){ $this->CachePostLinks(); $this->WritePosts(); }
  2107. if($this->NeedWriteImages){ $this->WriteImages(); }
  2108. if($this->NeedWriteArchive){ $this->WriteArchive(); }
  2109. }
  2110. function APubEnsureWebfinger($name, $host){
  2111. if(!is_dir('.well-known')) mkdir('.well-known');
  2112. if(!is_dir('.well-known/webfinger')) mkdir('.well-known/webfinger');
  2113. $f = fopen('.well-known/webfinger/index.php',"w");
  2114. $without_protocol = parse_url($host, PHP_URL_HOST);
  2115. $finger = ["subject"=>"acct:".$name.'@'.$without_protocol,
  2116. "links"=>[["rel"=>"self", "type"=>"application/activity+json", "href"=>$host."?apub_actor=1"]]];
  2117. fwrite($f, "<?php header('Content-Type: application/json'); echo '".json_encode($finger, JSON_UNESCAPED_SLASHES)."'; ?>"); fclose($f);
  2118. if(!file_exists('.well-known/apub_public_key.pem') || !file_exists('.well-known/apub_private_key.php')){
  2119. $res = openssl_pkey_new();
  2120. $this->APubPublicKey = openssl_pkey_get_details($res)['key'];
  2121. openssl_pkey_export($res, $this->APubPrivateKey);
  2122. $f = fopen('.well-known/apub_public_key.pem',"w");
  2123. fwrite($f, $this->APubPublicKey); fclose($f);
  2124. $f = fopen('.well-known/apub_private_key.php',"w");
  2125. fwrite($f, "<?php exit; ?>".PHP_EOL.PHP_EOL.$this->APubPrivateKey); fclose($f);
  2126. }
  2127. }
  2128. function APubInit(){
  2129. $kf = file_get_contents('.well-known/apub_private_key.php'); if($kf===false) return;
  2130. preg_match("/(-----BEGIN PRIVATE KEY-----[\s\S]*)/",$kf,$ma); $this->APubPrivateKey=$ma[1];
  2131. }
  2132. function APubEnsureInfo(){
  2133. if(!isset($this->APubID) || !isset($this->HostURL)) return;
  2134. if(!file_exists('.well-known/apub_public_key.pem')){$this->APubEnsureWebfinger($this->APubID, $this->HostURL);}
  2135. $pk = file_get_contents('.well-known/apub_public_key.pem'); //$pk = preg_replace('/\n/u','\\n',$pk);
  2136. $actor = ["@context"=>["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1"],
  2137. "id"=> $this->HostURL."?apub_actor=1",
  2138. "type"=> "Person",
  2139. "name"=> $this->DisplayName,
  2140. "url"=> $this->HostURL,
  2141. "summary"=> "Lazy... No summary",
  2142. "preferredUsername"=> $this->APubID,
  2143. "inbox"=> $this->HostURL."?apub_inbox=1",
  2144. "outbox"=> $this->HostURL."?apub_outbox=1",
  2145. "publicKey"=> ["id"=> $this->HostURL."?apub_actor=1#main-key",
  2146. "owner"=> $this->HostURL."?apub_actor=1",
  2147. "publicKeyPem"=>$pk]];
  2148. $this->APubActor = json_encode($actor, JSON_UNESCAPED_SLASHES);
  2149. }
  2150. function APubMakeOutbox(){
  2151. $this->ReadPosts();$this->ReadImages();
  2152. $obj = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2153. "id"=>$this->HostURL."?apub_outbox=1",
  2154. "type"=>"OrderedCollection"];
  2155. $items=[]; $i=0;
  2156. foreach(array_reverse($this->Posts) as &$p){
  2157. $this->ConvertPost($p);
  2158. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$p['html']));
  2159. $time = DateTime::createFromFormat('YmdHis', $p['id'], new DateTimeZone('+0800'));
  2160. $ob = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2161. "type"=> "Create",
  2162. "id"=> $this->HostURL."?post=".$p['id']."?apub_object=1",
  2163. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2164. //"to"=> ["https://chatty.example/ben/"],
  2165. "actor"=> $this->HostURL."?apub_actor=1",
  2166. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2167. "object"=> ["type"=> "Note",
  2168. "id"=> $this->HostURL."?post=".$p['id'],
  2169. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2170. "attributedTo"=> $this->HostURL."?apub_actor=1",
  2171. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2172. "content"=> $text]];
  2173. $items[] = $ob;
  2174. $i++; if($i>20) break;
  2175. }
  2176. $obj['orderedItems'] = $items; $obj["totalItems"] = sizeof($items);
  2177. return json_encode($obj, JSON_UNESCAPED_SLASHES);
  2178. }
  2179. function APubDeliver($body,$target){
  2180. $head_digest = base64_encode(hash("sha256",$body,true));
  2181. $body_digest = "SHA-256=".$head_digest;
  2182. // rfc standards require the timezone be declared as GMT and PHP's built-in formats all say UTC
  2183. // so we gotta do it manually
  2184. $d = new DateTimeImmutable("now", new DateTimeZone('Asia/Shanghai'));
  2185. $d=$d->setTimezone(new DateTimeZone('UTC'));
  2186. $date=$d->format("D, d M Y H:i:s")." GMT";
  2187. $data = "(request-target): post ".parse_url($target,PHP_URL_PATH)
  2188. ."\nhost: ".parse_url($target,PHP_URL_HOST)
  2189. ."\ndate: $date"
  2190. ."\ndigest: $body_digest";
  2191. if (openssl_sign($data, $signature, $this->APubPrivateKey, OPENSSL_ALGO_SHA256) === FALSE) {
  2192. http_response_code(500); die('unable to sign');
  2193. }
  2194. $signature = base64_encode($signature);
  2195. $keyid = 'keyId="'.$this->HostURL.'?apub_actor=1#main-key"';
  2196. $algo = 'algorithm="rsa-sha256"';
  2197. $headers = 'headers="(request-target) host date digest"';
  2198. $signature = "signature=\"$signature\"";
  2199. $h = array(
  2200. 'Content-Type: application/activity+json',
  2201. 'Accept: application/activity+json',
  2202. //"Content-Length: ".strlen($body),
  2203. "Host: ". parse_url($target,PHP_URL_HOST),
  2204. "Date: $date",
  2205. "Digest: $body_digest",
  2206. "Signature: $keyid,$algo,$headers,$signature"
  2207. );
  2208. $ch = curl_init($target);
  2209. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  2210. curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
  2211. curl_setopt($ch, CURLOPT_HTTPHEADER, $h);
  2212. curl_setopt($ch, CURLOPT_USERAGENT, "laMDWiki APub");
  2213. $result = curl_exec($ch);
  2214. curl_close($ch); echo "<pre>";
  2215. print_r($body); echo "\n\n".$target."\n\n";
  2216. print_r($result); echo "\n\n"; print_r($h);
  2217. echo "\n\n"; print_r(curl_getinfo($ch)); echo "</pre>"; exit;
  2218. return $result;
  2219. }
  2220. function APubTestDeliver(){
  2221. $this->APubInit();
  2222. $obj=[];
  2223. $obj['published']=gmdate("Y-m-d\TH:i:s\Z");
  2224. $obj['id']=""; //<-------------------
  2225. $obj['url']=$this->HostURL.""; //<-------------------
  2226. $obj['type']='Note';
  2227. $obj['attributedTo']=$this->HostURL."?apub_actor=1";
  2228. $tag=[]; $tag['type']='Mention'; $tag['name']="@chengdulittlea"; $tag['href']="https://mastodon.art/users/chengdulittlea";
  2229. $obj['tag']=[$tag];
  2230. // must have cc to have notification in mastodon.
  2231. $obj['cc']=["https://mastodon.art/users/chengdulittlea"];
  2232. $obj['content']="<p>@chengdulittlea Hello activitypub from laMDWiki!</p>";
  2233. $obj['to']="https://www.w3.org/ns/activitystreams#Public";
  2234. $obj['inReplyTo']=""; //<-------------------
  2235. $arr=[];
  2236. $arr['@context']="https://www.w3.org/ns/activitystreams";
  2237. $arr['id']=""; //<-------------------
  2238. $arr['actor']=$this->HostURL."?apub_actor=1";
  2239. $arr['type']="Create";
  2240. $arr['to']="https://www.w3.org/ns/activitystreams#Public";
  2241. $arr['object']=$obj;
  2242. $this->APubDeliver(json_encode($arr),"https://mastodon.example/inbox"); //<-------------------
  2243. }
  2244. function APubProcessInbox(){
  2245. $r = file_get_contents('php://input');
  2246. file_put_contents('postdump.txt',$r);
  2247. }
  2248. function MakeRSS(){
  2249. $this->ReadPosts();$this->ReadImages();
  2250. $posts = []; if(isset($this->UsePosts[0])){
  2251. $posts = array_reverse($this->UsePosts);
  2252. $last_updated = $this->StandardTime($posts[0]['id']);
  2253. }else{ $last_updated= $this->StandardTime("20000101000000"); }
  2254. $author = "<author><name>".$this->DisplayName."</name><email>".$this->EMail."</email><uri>".$this->HostURL."</uri></author>";
  2255. $all_content="<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom'>".
  2256. "<id>".$this->HostURL."/?rss</id>".
  2257. "<updated>".$last_updated."</updated>".
  2258. "<title>".$this->T($this->Title)."</title>".
  2259. "<link href='".$this->HostURL."/index.php?rss=".($this->LanguageAppendix=='zh'?'zh':'en')."' rel='self'/>".
  2260. "<link href='".$this->HostURL."' />".$author;
  2261. $i=0;
  2262. if(isset($posts[0])) foreach($posts as &$p){
  2263. if($i>100) break;
  2264. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  2265. if(isset($p['tid'])){ /* Should always be set. */
  2266. $th = &$p['tid']; if($p['tid']['count']==0) continue; }
  2267. if(in_array($p['id'],
  2268. [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
  2269. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  2270. $is_thread = isset($p['tid']['count'])&&($p['tid']['count']>1);
  2271. $is_reversed=false;
  2272. $content="<entry>"; $title = NULL;
  2273. if($is_thread){
  2274. $use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false; if($is_reversed){
  2275. $use_arr=array_reverse($th['arr']); $fp=array_pop($use_arr); array_unshift($use_arr,$fp); }
  2276. foreach($use_arr as &$po){
  2277. $this->ConvertPost($po);
  2278. if(!isset($title)){$title = htmlspecialchars($this->GetPostTitle($po, false, false)); if(!$title){$title='untitled';}
  2279. $content.="<id>".$this->HostURL."/?post=".$po['id']."</id>";
  2280. $content.="<title type='html'>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$po['id']."' />";
  2281. $content.="<published>".$this->StandardTime($po['id'])."</published>";
  2282. $content.="<updated>".$this->StandardTime(isset($po['tid']['last']['version'])?
  2283. $po['tid']['last']['version']:$po['tid']['last']['id'])."</updated>".$author;
  2284. $content.="<content type='html'>"; }
  2285. $content.= htmlspecialchars($po['html']);
  2286. //if(isset($po['images'])&&isset($po['images'][0])) foreach($po['images'] as $im){ $content.=htmlspecialchars($im); }
  2287. }
  2288. $content.=$this->ReadableTime($p['tid']['first']['id'])." - ".
  2289. $this->ReadableTime(isset($p['tid']['last']['version'])?
  2290. $p['tid']['last']['version']:$p['tid']['last']['id']);
  2291. $content.="</content>";
  2292. }else{
  2293. $this->ConvertPost($p);
  2294. if(!isset($title)){$title = htmlspecialchars($this->GetPostTitle($p, false, false)); if(!$title){$title='untitled';}
  2295. $content.="<id>".$this->HostURL."/?post=".$p['id']."</id>";
  2296. $content.="<title type='html'>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$p['id']."' />";
  2297. $content.="<published>".$this->StandardTime($p['id'])."</published>";
  2298. $content.="<updated>".$this->StandardTime(isset($p['tid']['last']['version'])?
  2299. $p['tid']['last']['version']:$p['tid']['last']['id'])."</updated>".$author;}
  2300. $content.= "<content type='html'>".htmlspecialchars($p['html']);
  2301. //if(isset($p['images'])&&isset($p['images'][0])) foreach($p['images'] as $im){ $content.=htmlspecialchars($im); }
  2302. $content.=$this->ReadableTime($p['id'])." - ".
  2303. $this->ReadableTime(isset($p['version'])?$p['version']:$p['id']);
  2304. $content.="</content>";
  2305. }
  2306. $i++;
  2307. $content.="</entry>";
  2308. $all_content.=$content;
  2309. }
  2310. $all_content.="</feed>";
  2311. header( "Content-type: text/xml");
  2312. echo $all_content;
  2313. }
  2314. function MakeHereButtons($im, $insert_here){
  2315. if(isset($im['here'])&&isset($im['here'][0])){
  2316. $size=getimagesize($im['file']); $aspect=$size[0]/$size[1];
  2317. echo ($insert_here?"<here>":"")."<div class='here_buttons_inner' style='aspect-ratio:".$aspect.";'>";
  2318. foreach($im['here'] as $here){
  2319. if($insert_here){
  2320. echo "<a href='?show_image=".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'".
  2321. "onclick='event.preventDefault();event.stopPropagation();ShowBigImage(\"".$here[0]."\",1);'></a>";
  2322. }else{
  2323. echo "<a href='?here=images/".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'></a>";
  2324. }
  2325. }
  2326. echo "</div>".($insert_here?"</here>":"");
  2327. }
  2328. }
  2329. function ProcessRequest(&$message=NULL, &$redirect=NULL){
  2330. if(isset($_GET['gallery_continue']) && $_GET['gallery']){
  2331. $this->ReadImages();
  2332. $this->GetImageBatch($_GET['gallery_continue'],0);
  2333. exit;
  2334. }
  2335. if(isset($_GET['gallery']) && $_GET['gallery']=='default'){
  2336. $redirect = "index.php?gallery=".(isset($this->DefaultGallery)&&$this->DefaultGallery!=''?$this->DefaultGallery:"main");
  2337. return 0;
  2338. }
  2339. if(isset($_GET['set_language'])){
  2340. setcookie('la_language',$_GET['set_language'],time()+3600*24*7); $_COOKIE['la_language'] = $_GET['set_language'];
  2341. $redirect=$this->GetRedirect(); return 0;
  2342. }
  2343. if(isset($_GET['rss'])){
  2344. if(in_array($_GET['rss'],['en','zh'])){$this->LanguageAppendix=$_GET['rss'];}
  2345. $this->MakeRSS(); exit;
  2346. }
  2347. if(isset($_GET['toggle_font'])){ $use_font='local';
  2348. if(!isset($_COOKIE['la_font']) || $_COOKIE['la_font']!='remote') $use_font='remote';
  2349. setcookie('la_font',$use_font,time()+3600*24*7); $_COOKIE['la_font'] = $use_font;
  2350. $redirect=$this->GetRedirect(); return 0;
  2351. }
  2352. if(isset($_GET['set_wayback'])){
  2353. if($_GET['set_wayback']!='false'){
  2354. $wayback= date('YmdHis');
  2355. if($_GET['set_wayback']=='post'){
  2356. if(isset($_POST['wayback_year'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_year'],4,"0",STR_PAD_LEFT),0,4);
  2357. if(isset($_POST['wayback_month'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_month'],2,"0",STR_PAD_LEFT),4,2);
  2358. if(isset($_POST['wayback_day'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_day'],2,"0",STR_PAD_LEFT),6,2);
  2359. if(isset($_POST['wayback_hour'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_hour'],2,"0",STR_PAD_LEFT),8,2);
  2360. if(isset($_POST['wayback_minute'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_minute'],2,"0",STR_PAD_LEFT),10,2);
  2361. }else{ if(preg_match('/[0-9]{14}/u', $_GET['set_wayback'])) $wayback = $_GET['set_wayback']; }
  2362. setcookie('la_wayback',$wayback); $_COOKIE['la_wayback'] = $wayback;
  2363. }else{
  2364. setcookie('la_wayback', null, -1); unset($_COOKIE['la_wayback']);
  2365. }
  2366. $redirect=$this->GetRedirect(); return 0;
  2367. }
  2368. if(isset($_GET['post'])){ $this->CurrentPostID = $_GET['post']; $this->TagID = $this->CurrentPostID; }
  2369. if(isset($_GET['here'])){ $this->HereID = $_GET['here']; }
  2370. if(isset($_GET['offset'])){ $this->CurrentOffset = $_GET['offset']; }
  2371. if(isset($_GET['post'])){
  2372. $this->ExtraScripts.="window.addEventListener('load', (event) => {ScrollToPost('".$_GET['post']."');});";
  2373. }
  2374. if(isset($_GET['random_here'])){
  2375. $this->DoIdentifyExperimental(); $this->DetectPageType();
  2376. $im = &$this->GiveImageInHere(true); if(isset($im)){ $redirect='?here=images/'.$im['name']; return 0; }
  2377. }
  2378. if(isset($_POST['search_content'])){ $redirect='index.php?search='.$_POST['search_content'];return 0; }
  2379. if(isset($_GET['image_info']) || isset($_GET['show_image'])){
  2380. $m=isset($_GET['image_info'])?$_GET['image_info']:$_GET['show_image'];
  2381. $direct_return = !isset($_GET['show_image']);
  2382. $this->ReadImages(); $this->ReadPosts();
  2383. $this->SwitchWayBackMode(); if(isset($this->WayBack)){$this->ReadArchive();}
  2384. $im = &$this->FindImage($m);
  2385. if($im==NULL || !isset($im['refs']) || !isset($im['refs'][0])){ echo "not_found"; exit; }
  2386. if($direct_return){
  2387. echo "<ref>".sizeof($im['refs'])."</ref>";
  2388. echo "<insert><ul>";
  2389. }else{ ob_start(); }
  2390. foreach(array_reverse($im['refs']) as $ref){
  2391. $p = $this->GetPost($ref);
  2392. if(!$p || !$this->CanShowPost($p)) continue;
  2393. $this->MakeSinglePost($p, false, true, "post_preview invert_a", true, false, false, false, true);"</li>";
  2394. }
  2395. if($direct_return){
  2396. echo "</ul></insert>";
  2397. $this->MakeHereButtons($im, true);
  2398. }else{
  2399. $str = ob_get_clean();
  2400. $this->MakePageBegin($this->NULL_POST);
  2401. $side = "";
  2402. if(isset($im['refs'])&&isset($im['refs'][0])){
  2403. $side.="<span class='small'>".$this->T('该图片出现在')." ".sizeof($im['refs'])." ".$this->T('个帖子中')."</span>";
  2404. }else{$side.="<span class='smaller gray'>".$this->T('该图片未被引用')."</span>";}
  2405. $static_image = isset($im['video'])?NULL:$im['file'];
  2406. $static_video = isset($im['video'])?$im['file']:NULL;
  2407. $this->MakeImageOverlay($side."<ul>".$str."</ul>",$static_image,$static_video);
  2408. $this->MakePageEnd();
  2409. }
  2410. exit;
  2411. }
  2412. if(isset($_GET['confirm_enter']) && $_GET['confirm_enter']!=false){
  2413. setcookie('la_experimental','confirmed'); $_COOKIE['la_experimental'] = $_GET['confirmed'];
  2414. $redirect='index.php'.(isset($_GET['post'])?'?post='.$_GET['post']:"");return 0;
  2415. }
  2416. if(isset($_GET['apub_actor'])){
  2417. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2418. echo $this->APubActor; exit;
  2419. }
  2420. if(isset($_GET['apub_outbox'])){
  2421. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2422. echo $this->APubMakeOutbox(); exit;
  2423. }
  2424. if(isset($_GET['apub_inbox'])){
  2425. $this->APubProcessInbox();
  2426. http_response_code(202); exit;
  2427. }
  2428. if($this->LoggedIn){
  2429. if(isset($_GET['TestAPubDeliver'])){
  2430. $this->APubTestDeliver();
  2431. }
  2432. $this->DoUpload();
  2433. if(isset($_POST['settings_button'])){
  2434. if(isset($_POST['settings_title'])) $this->Title=$_POST['settings_title'];
  2435. if(isset($_POST['settings_short_title'])) $this->ShortTitle=$_POST['settings_short_title'];
  2436. if(isset($_POST['settings_display_name'])) $this->DisplayName=$_POST['settings_display_name'];
  2437. if(isset($_POST['settings_email'])) $this->EMail=$_POST['settings_email'];
  2438. if(isset($_POST['settings_special_navigation'])) $this->SpecialNavigation=$_POST['settings_special_navigation'];
  2439. if(isset($_POST['settings_special_sidebar'])) $this->SpecialSidebar=$_POST['settings_special_sidebar'];
  2440. if(isset($_POST['settings_special_footer'])) $this->SpecialFooter=$_POST['settings_special_footer'];
  2441. if(isset($_POST['settings_special_footer2'])) $this->SpecialFooter2=$_POST['settings_special_footer2'];
  2442. if(isset($_POST['settings_special_pinned'])) $this->SpecialPinned=$_POST['settings_special_pinned'];
  2443. if(isset($_POST['settings_default_gallery'])) $this->DefaultGallery=$_POST['settings_default_gallery'];
  2444. if(isset($_POST['settings_selfauth_path'])) $this->SelfAuthPath=$_POST['settings_selfauth_path'];
  2445. if(isset($_POST['settings_enable_comments'])) $this->CommentEnabled=True; else $this->CommentEnabled=False;
  2446. if(isset($_POST['settings_gallery_step'])) $this->GalleryStep=$_POST['settings_gallery_step'];
  2447. if(isset($_POST['settings_here_host'])) $this->HereHost=$_POST['settings_here_host'];
  2448. if(isset($_POST['settings_here_title'])) $this->HereTitle=$_POST['settings_here_title'];
  2449. if(isset($_POST['settings_here_short_title'])) $this->HereShortTitle=$_POST['settings_here_short_title'];
  2450. if(isset($_POST['settings_here_album'])) $this->HereAlbum=$_POST['settings_here_album'];
  2451. if(isset($_POST['settings_here_navigation'])) $this->HereNavigation=$_POST['settings_here_navigation'];
  2452. if(isset($_POST['settings_here_footer'])) $this->HereFooter=$_POST['settings_here_footer'];
  2453. if(isset($_POST['settings_exp_host'])) $this->ExpHost=$_POST['settings_exp_host'];
  2454. if(isset($_POST['settings_exp_title'])) $this->ExpTitle=$_POST['settings_exp_title'];
  2455. if(isset($_POST['settings_exp_short_title'])) $this->ExpShortTitle=$_POST['settings_exp_short_title'];
  2456. if(isset($_POST['settings_exp_caution'])) $this->ExpCaution=$_POST['settings_exp_caution'];
  2457. if(isset($_POST['settings_exp_album'])) $this->ExpAlbum=$_POST['settings_exp_album'];
  2458. if(isset($_POST['settings_exp_navigation'])) $this->ExpNavigation=$_POST['settings_exp_navigation'];
  2459. if(isset($_POST['settings_exp_footer'])) $this->ExpFooter=$_POST['settings_exp_footer'];
  2460. if(isset($_POST['settings_allow_language'])) $this->AllowLanguageChoices=True; else $this->AllowLanguageChoices=False;
  2461. if(isset($_POST['settings_mastodon_token'])) $this->MastodonToken=$_POST['settings_mastodon_token'];
  2462. if(isset($_POST['settings_mastodon_url'])) $this->MastodonURL=$_POST['settings_mastodon_url'];
  2463. if(isset($_POST['settings_mastodon_lang'])) $this->MastodonPreferredLang=$_POST['settings_mastodon_lang'];
  2464. if(isset($_POST['settings_host_url'])) $this->HostURL=$_POST['settings_host_url'];
  2465. if(isset($_POST['settings_apub_id']) && isset($this->HostURL)) {
  2466. $this->APubID=$_POST['settings_apub_id'];
  2467. $this->APubEnsureWebfinger($this->APubID,$this->HostURL);
  2468. }
  2469. if(isset($_POST['settings_old_password'])&&password_verify($_POST['settings_old_password'], $this->Password)){
  2470. if(isset($_POST['settings_id'])) $this->Admin=$_POST['settings_id'];
  2471. if(isset($_POST['settings_new_password']) && isset($_POST['settings_new_password_redo']) &&
  2472. $_POST['settings_new_password'] = $_POST['settings_new_password_redo'])
  2473. {$this->Password=password_hash($_POST['settings_new_password'], PASSWORD_DEFAULT);}
  2474. $redirect=$_SERVER['REQUEST_URI'];
  2475. $this->DoLogout();
  2476. }
  2477. $this->WriteConfig();
  2478. return 0;
  2479. }
  2480. if(isset($_POST['settings_save_redirect'])){
  2481. if(isset($_POST['settings_redirect'])){
  2482. $this->BuildRedirectConfig($_POST['settings_redirect']);
  2483. }
  2484. $this->WriteConfig();
  2485. $redirect = 'index.php?extras=true'; return 0;
  2486. }
  2487. if(isset($_POST['settings_save_translation'])){
  2488. if(isset($_POST['settings_translation'])){
  2489. $f = fopen("custom_translations.md", "w"); fwrite($f,$_POST['settings_translation']); fflush($f); fclose($f);
  2490. }
  2491. $redirect = 'index.php?extras=true'; return 0;
  2492. }
  2493. if(isset($_GET['post'])){
  2494. if(isset($_GET['post_original'])){
  2495. echo $this->EditPost($_GET['post'],NULL,false,NULL,true,NULL,NULL,false,NULL,NULL);
  2496. exit;
  2497. }
  2498. }
  2499. if(isset($_GET['mark_delete']) && isset($_GET['target'])){
  2500. $this->EditPost($_GET['target'],NULL,$_GET['mark_delete']=='true',NULL,false,NULL,NULL,false,NULL,NULL);
  2501. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2502. return 0;
  2503. }
  2504. if(isset($_GET['set_mark']) && isset($_GET['target'])){
  2505. $this->EditPost($_GET['target'],NULL,NULL,NULL,NULL,$_GET['set_mark'],NULL,false,NULL,NULL);
  2506. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2507. return 0;
  2508. }
  2509. if(isset($_POST['post_button']) && isset($_POST['post_content'])){
  2510. $c = $_POST['post_content'];
  2511. if('有什么想说的' == $c){ return 0;}
  2512. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2513. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2514. $reply_to = (isset($_POST['post_reply_to'])&&$_POST['post_reply_to']!="")?$_POST['post_reply_to']:NULL;
  2515. $edit_id = (isset($_POST['post_edit_target'])&&$_POST['post_edit_target']!="")?$_POST['post_edit_target']:NULL;
  2516. $push_history = (isset($edit_id) && isset($_POST['post_record_edit']));
  2517. if(($edited = $this->EditPost($edit_id, $c, NULL, $reply_to,NULL,NULL,NULL,$push_history,NULL,NULL))!=NULL){
  2518. $redirect='?post='.$edited['id']; return 0;
  2519. };
  2520. }
  2521. if(isset($_POST['post_rename_confirm']) && isset($_POST['post_rename_name']) && isset($_GET['rename_post'])){
  2522. if(($edited =$this->EditPost($_GET['rename_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,NULL))!=NULL){
  2523. $redirect='?post='.$edited['id']; return 0;
  2524. };
  2525. }
  2526. if(isset($_POST['post_mastodon_confirm']) && isset($_POST['post_mastodon_url']) && isset($_GET['mastodon_post'])){
  2527. if(($edited =$this->EditPost(
  2528. $_GET['mastodon_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,$_POST['post_mastodon_url']))!=NULL){
  2529. $redirect='?post='.$edited['id']; return 0;
  2530. };
  2531. }
  2532. if(isset($_GET['mastodon_send_post']) && preg_match('/([0-9]{14})/u',$_GET['mastodon_send_post'],$m)){
  2533. $this->ReadImages(); $this->ReadPosts(); $post = &$this->GetPost($m[1]); $err=$this->T("未知错误");
  2534. if(isset($post)){
  2535. if($mastodon_url = $this->MastodonSendPost($post, $err)){
  2536. $this->NeedWritePosts = 1; $this->WritePosts(); // for mastodon url
  2537. echo "SUCCESS ".$mastodon_url;
  2538. }else{ echo $err; }
  2539. } exit;
  2540. }
  2541. if(isset($_GET['merge_threads'])&&$_GET['merge_threads']!=""){
  2542. if(preg_match('/([0-9]{14})\s+([0-9]{14})/u',$_GET['merge_threads'],$m)){
  2543. if(($pe = &$this->MergeThreads($m[1],$m[2]))!=$this->NULL_POST){ $redirect='?post='.$pe['id']; return 0; }
  2544. }
  2545. }
  2546. if(isset($_GET['merge_posts'])&&$_GET['merge_posts']!=""){
  2547. if(($pe = &$this->MergePosts($_GET['merge_posts']))!=$this->NULL_POST){
  2548. $redirect='?post='.$pe['id']; return 0;
  2549. }
  2550. }
  2551. if ($this->CommentEnabled && isset($_POST['comment_confirm']) && (isset($_GET['comment_to']))
  2552. && isset($_POST['comment_box']) && isset($_POST['comment_email']) && isset($_POST['comment_name'])){
  2553. $c = $_POST['comment_box'];
  2554. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2555. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2556. $comment_to = ($_GET['comment_to']!="")?$_GET['comment_to']:NULL;
  2557. if(($edited = $this->EditComment(NULL,
  2558. $_GET['comment_to'], $c, $_POST['comment_email'], $_POST['comment_name'],
  2559. isset($_POST['comment_link'])?$_POST['comment_link']:NULL,
  2560. $_SERVER['REMOTE_ADDR']))!=NULL){
  2561. $redirect='?post='.$_GET['post'];
  2562. return 0;
  2563. };
  2564. }
  2565. if(isset($_POST['gallery_edit_confirm']) && isset($_POST['gallery_edit_new_name']) && $_POST['gallery_edit_new_name']!=''){
  2566. $old_name = isset($_POST['gallery_edit_old_name'])?$_POST['gallery_edit_old_name']:"";
  2567. $new_name = $_POST['gallery_edit_new_name'];
  2568. if($old_name!=''){
  2569. $desc=isset($_POST['gallery_edit_description'])?$_POST['gallery_edit_description']:null;
  2570. if(!preg_match('/[0-9]{14}/',$desc))$desc="";
  2571. $this->EditGallery($old_name, $new_name, false, true, null, null,$desc);
  2572. $redirect='?gallery='.$new_name;
  2573. }else{
  2574. $this->EditGallery(null, $new_name, false, true, null,null);
  2575. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2576. }
  2577. return 0;
  2578. }
  2579. if(isset($_GET['gallery_edit_delete'])&&$_GET['gallery_edit_delete']!=null){
  2580. $this->EditGallery($_GET['gallery_edit_delete'], null, true, true, null, null,null);
  2581. if(isset($_GET['gallery'])) $redirect='?gallery=main'; else $redirect='index.php';
  2582. return 0;
  2583. }
  2584. if(isset($_POST['gallery_move_ops'])&&isset($_POST['gallery_move_ops'])){
  2585. if(preg_match('/^(REM|ADD)\s+(\S+)\s+(.*)$/u', $_POST['gallery_move_ops'], $ma)){
  2586. $this->ReadImages();
  2587. if(preg_match_all('/(\S+)/u', $ma[3], $files, PREG_SET_ORDER)) foreach($files as $name){
  2588. $this->EditImage($name[1], $ma[2], ($ma[1]=='REM'), NULL, NULL, NULL, NULL);
  2589. }
  2590. }
  2591. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2592. return 0;
  2593. }
  2594. if(isset($_GET['gallery_set_featured'])&&isset($_GET['value'])){
  2595. $this->EditGallery($_GET['gallery_set_featured'], null, false, true, $_GET['value']!='false', null);
  2596. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2597. return 0;
  2598. }
  2599. if(isset($_GET['gallery_set_experimental'])&&isset($_GET['value'])){
  2600. $this->EditGallery($_GET['gallery_set_experimental'], null, false, true, null, $_GET['value']!='false');
  2601. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  2602. return 0;
  2603. }
  2604. if(isset($_GET['image_list'])&&$_GET['image_list']!=""){
  2605. $this->ReadImages();
  2606. $gallery = $_GET['image_list'];
  2607. foreach($this->Images as $im){
  2608. if($gallery=='main'){ echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; continue; }
  2609. if(isset($im['galleries']) && isset($im['galleries'][0]) && in_array($gallery,$im['galleries'])) {
  2610. echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; }
  2611. }
  2612. exit;
  2613. }
  2614. $do_image_redirect = 0;
  2615. if (isset($_POST['image_button']) && isset($_GET['pic']) &&
  2616. preg_match('/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4))/u',$_GET['pic'],$ma)){
  2617. $this->ReadImages(); $pic = $ma[1]; $picext=$ma[2];
  2618. if(isset($_POST['image_ops_product_link'])){
  2619. $this->EditImage($pic, NULL, false, $_POST['image_ops_product_link'], NULL, NULL, NULL);
  2620. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2621. }
  2622. if(isset($_POST['image_edit_new_name']) && preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_edit_new_name'],$man)){
  2623. $this->EditImage($pic, NULL, false, NULL, $man[1], NULL, NULL);
  2624. $redirect=$this->GetRedirect(['pic'=>'images/'.$man[1].'.'.$picext]);
  2625. $do_image_redirect = 1;
  2626. }
  2627. if(isset($_POST['image_parent'])){ $parent="";
  2628. if(preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_parent'],$man)){ $parent = $man[1]; }
  2629. $this->EditImage($pic, NULL, false, NULL, NULL, $parent, NULL);
  2630. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2631. }
  2632. if(isset($_POST['image_align'])){$val=$_POST['image_align'];
  2633. $this->EditImage($pic, NULL, false, NULL, NULL, NULL, $val);
  2634. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2635. }
  2636. $this->NeedWriteImages = 1;
  2637. if($do_image_redirect) return 0;
  2638. }
  2639. //if(isset($_GET['rewrite_styles'])){
  2640. $this->WriteStyles();
  2641. // $redirect='?extras=true'; return 0;
  2642. //}
  2643. if(isset($_GET['regenerate_thumbnails'])){
  2644. $this->RegenerateThumbnails();
  2645. $redirect='?extras=true'; return 0;
  2646. }
  2647. if(isset($_GET['clear_all_logins'])){
  2648. $this->LoginTokens=[];
  2649. $this->WriteTokens();
  2650. }
  2651. }
  2652. return 0;
  2653. }
  2654. function PostProcessHTML($html,&$added_images=null,$do_product_info=false, &$product_info=null, &$orig_src_list=null, &$end_wide=null, &$print_wide=null){
  2655. if(!$this->LoggedIn){
  2656. $html = preg_replace("/(<a[^>]*href=[\'\"])(.*?)([\'\"][^>]*)>(\#.*?<\/a>)/u","",$html);
  2657. }
  2658. $html = preg_replace("/(<a[^>]*href=[\'\"])([0-9]{14})([\'\"][^>]*)>(.*?<\/a>)/u","$1?post=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2659. $html = preg_replace("/(<a[^>]*href=[\'\"])\@(.*?)([\'\"][^>]*)>(.*?<\/a>)/u","$1?category=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2660. $html = preg_replace("/(<a[^>]*href=[\'\"])((.*?:\/\/).*?)([\'\"][^>]*)(>)(.*?)(<\/a>)/u",
  2661. "$1$2$4 target='_blank'$5$6<sup>↗</sup>$7",$html);
  2662. $html = preg_replace("/<p>\s*\@.*?<\/p>/mu","",$html);
  2663. $html = preg_replace("/\{\s*(REVERSED|INTERESTING|HEADER|FOOTER)\s+(.*?)\}/imu","",$html);
  2664. $html = preg_replace("/\{\s*(REVERSED|NO_TIME|NO_TITLE)\s*\}/imu","",$html);
  2665. $html = preg_replace("/\{\s*WIDE\s*\}/imu","",$html,-1,$rep_count); if($rep_count){$print_wide=true;}
  2666. $images = []; $images_noclick = []; $images_orig_src_list = [];
  2667. $html = preg_replace_callback(
  2668. "/(<p>\s*|<a\s.*?>\s*)?(<img([^>]*)src=[\'\"])(images\/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4)))([\'\"][^>]*)\/>(\s*<\/p>)?/u",
  2669. function($m) use (&$images,&$images_noclick,&$images_orig_src_list) {
  2670. if(isset($m[1])&&$m[1]&&$m[1][1]=='a'){ $height="";
  2671. if(preg_match("/([0-9]{1,2})em/u",$m[0],$hm)){$height=' style="height:'.$hm[1].'em;"';}
  2672. return "<a class='imbtn'".$height.substr($m[0],2); }
  2673. $orig_src = $src = $m[5]; $keep = false; $original = false;
  2674. if (preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[3]) ||
  2675. preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[7])) { $keep=true; }
  2676. if ($keep && preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[3]) ||
  2677. preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[7])) { $original=true; }
  2678. if(($im = &$this->FindImage($m[5]))!=NULL && isset($im['thumb'])){
  2679. $src = $im['thumb']; $orig_src=$im['file'];
  2680. }if($im == NULL){ $im = &$this->NULL_IMAGE_DUMMY; }
  2681. $media_start = $m[2];
  2682. $media_end = $m[7];
  2683. $dataset = " data-imgsrc='".$m[5]."'".
  2684. (isset($im['product'])?" data-product='".$im['product']."'":"").
  2685. (isset($im['parent'])?" data-parent='".$im['parent']."'":"").
  2686. (isset($im['align'])?' data-align="'.$im["align"].'" style="object-position:'.$im['align'].';"':"").
  2687. ($original?" class='original_img'":"");
  2688. if(isset($im['video']) && isset($im['video'])!=''){
  2689. $media_start = "<video controls".$dataset."><source src='"; $media_end="' type='".$im['video']."'></video";
  2690. $src = $orig_src; $dataset="";
  2691. }
  2692. if($this->InHereMode){
  2693. $click = "<div class='imd'>"."<a href='?here=".$im['file']."' class='original_img'>".
  2694. $media_start.($original?$orig_src:$src).$media_end."></a></div>";
  2695. $ret=""; if($keep) { $ret = $click; }
  2696. else { $images[] = $click; }
  2697. return $ret;
  2698. }else{
  2699. $click ="<div class='imd'><a href='?show_image={$im['name']}' target='_blank' onclick='event.preventDefault();'>".
  2700. $media_start.($original?$orig_src:$src).$media_end.$dataset."></a></div>";
  2701. $images_noclick[]=$media_start.$src.$media_end.">"; $images_orig_src_list[]=$orig_src;
  2702. $ret = "";
  2703. if($keep) { $ret = $click; }
  2704. else { $images[] = $click; }
  2705. if(isset($m[1])&&isset($m[8])&&$m[1]&&$m[8]) return $ret;
  2706. else return ((isset($m[1])&&$m[1]?$m[1]:"").$ret.(isset($m[8])&&$m[8]?$m[8]:""));
  2707. }
  2708. },$html,-1,$count);
  2709. $html = preg_replace('/<p>\s*<\/p>/u',"", $html); if($html==""){$html="<p>&nbsp;</p>";}
  2710. if(sizeof($images)){
  2711. if((!$this->InHereMode) && sizeof($images)==1){$html.= $images[0]; }
  2712. else{
  2713. $html.="<div class='p_row'>";
  2714. foreach($images as $img){
  2715. $html.="<div class='p_thumb'>".$img."</div>";
  2716. }
  2717. $html.="<div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div>";
  2718. }
  2719. }
  2720. if(sizeof($images_noclick)){ $added_images = $images_noclick; }
  2721. if(sizeof($images_orig_src_list)) { $orig_src_list = $images_orig_src_list; }
  2722. if($do_product_info){
  2723. $html = preg_replace_callback("/\{PRICE\s+([^]]+?)\}/u",
  2724. function($m) use (&$product_info) { $product_info['price']=$m[1];return ""; },$html);
  2725. $html = preg_replace_callback("/\{SHORT\s+([^]]+?)\}/u",
  2726. function($m) use (&$product_info) { $product_info['short']=$m[1];return ""; },$html);
  2727. $html = preg_replace('/<p>\s*<\/p>/u',"", $html);
  2728. if (preg_match('/<h[1-5]>(.+?)<\/h/u',$html,$title)){ $product_info['title']=$title[1]; }
  2729. else { $product_info['title'] = $this->T('商品'); }
  2730. if(!isset($product_info['price'])) $product_info['price']=$this->T('未设置价格');
  2731. $html = preg_replace_callback("/\{PURCHASE\s+([^]]+?)\}/u",function($m) use (&$product_info) {
  2732. return "<a class='purchase_button' href=\"mailto:".$this->T($this->DisplayName)."<".$this->EMail.">?subject=".
  2733. $this->T('购买').' '.$product_info['title'].
  2734. "&body=".$this->T('你好!我想购买').$product_info['title'].urlencode(PHP_EOL.PHP_EOL).
  2735. $this->FullURL().urlencode(PHP_EOL.PHP_EOL)."\">".$m[1]."</a>"; },$html);
  2736. }
  2737. if(preg_match("/(<\/div>|<\/table>|<\/video>)\s*$/u",$html)){$end_wide=true;}
  2738. return $html;
  2739. }
  2740. function ConvertPost(&$post){
  2741. if(!isset($post['html'])){
  2742. $info=[];
  2743. $post['html'] = $this->TranslatePostParts($this->PostProcessHTML($this->ChoosePartsByLanguage($this->PDE->text($this->InsertReplacementSymbols($post['content'], $post)),true),
  2744. $post['images'],
  2745. isset($post['product']), $info,
  2746. $post['original_images'],
  2747. $post['end_wide'],
  2748. $post['wide']));
  2749. if(isset($post['product'])) $post['product']=$info;
  2750. }
  2751. }
  2752. function GetPostTitle(&$post, $h1_only=false, $add_unamed=true){
  2753. if($h1_only){
  2754. if(preg_match('/^#\s+(.*?)$/mu',$post['content'],$m)) return $m[1];
  2755. else return NULL;
  2756. }
  2757. if(!isset($post['title'])){
  2758. if(preg_match('/^#{1,6}\s+(.*?)$/mu',$post['content'],$m)){$post['title']=$m[1];}
  2759. else{ $post['title'] = $add_unamed?$this->T('未命名'):"";
  2760. if(preg_match('/(.*)$/mu',$post['content'],$m)){
  2761. $post['title'].=($add_unamed?' (':'').strip_tags($this->PDE->text($m[1])).($add_unamed?')':''); }
  2762. }
  2763. }
  2764. return $this->ChoosePartsByLanguage($post['title']);
  2765. }
  2766. function DetectPageType(){
  2767. if ($this->InExperimentalMode) $this->PageType='experimental';
  2768. else if($this->InHereMode) $this->PageType='here';
  2769. else if(isset($_GET['history'])) $this->PageType='history';
  2770. else if(isset($_GET['extras'])) $this->PageType='extras';
  2771. else if(isset($_GET['settings'])) $this->PageType='settings';
  2772. else if(isset($_GET['gallery'])) $this->PageType='gallery';
  2773. else if(isset($_GET['search'])) $this->PageType='search';
  2774. else if(isset($_GET['category'])) $this->PageType='category';
  2775. else if(isset($this->CurrentPostID)) $this->PageType = "post";
  2776. else if(isset($_GET['comments'])) $this->PageType='comments';
  2777. else if(isset($_GET['statistics'])) $this->PageType='statistics';
  2778. else $this->PageType = "main";
  2779. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  2780. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  2781. $this->VisitedHere = $_SESSION[$visited_here];
  2782. }
  2783. function MakePageBegin(&$p){ $title=$this->InExperimentalMode?$this->T($this->ExpTitle):
  2784. ($this->InHereMode?$this->T($this->HereTitle):$this->T($this->Title)) ?>
  2785. <!DOCTYPE html><html lang='zh-Hans-CN'>
  2786. <head>
  2787. <meta charset='utf-8'>
  2788. <meta content="width=device-width, initial-scale=1" name="viewport">
  2789. <title><?=$title?></title>
  2790. <meta property="og:title" content="<?=$title.(isset($p)?(" | ".$this->GetPostTitle($p)):"")?>">
  2791. <?php if(isset($p)&&isset($p['hasi'])&&isset($p['hasi'][0])){?> <meta property="twitter:card" content="summary_large_image" />
  2792. <meta property="og:image" content="<?=(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']==='on'?"https":"http").'://'.$_SERVER['HTTP_HOST'].'/images/thumb/'.$p['hasi'][0]?>"><?php } ?>
  2793. <?php if($this->UseRemoteFont){ ?><style>
  2794. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Regular.otf") format("opentype");font-weight:normal;}
  2795. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Bold.otf") format("opentype");font-weight:bold;}
  2796. </style><?php } ?>
  2797. <link href='styles/main.css' rel='stylesheet' type="text/css">
  2798. <link rel="alternate" type="application/rss+xml" title="<?=$this->T($this->Title);?>" href="?rss=<?=$this->LanguageAppendix;?>" />
  2799. <?php if(isset($this->SelfAuthPath)&&$this->SelfAuthPath!=""){ ?>
  2800. <link rel="authorization_endpoint" href="<?=$this->SelfAuthPath?>" /><?php } ?>
  2801. <noscript><style>.lb.post_access{top:unset;bottom:0;height:2em;} .active_post .lb.post_access{height:100%;}.post label{pointer-events:all;}</style></noscript>
  2802. </head>
  2803. <div class='page'>
  2804. <?php }
  2805. function MakeHeader(&$p){
  2806. $this->MakePageBegin($p) ?>
  2807. <script type='text/javascript'>
  2808. function toggle_mobile_show(a){a.classList.toggle('hidden_m')}
  2809. function ShowWaitingBar(){wait = document.querySelector("#waiting_bar");wait.style.display='';}
  2810. function HideWaitingBar(){wait = document.querySelector("#waiting_bar");wait.style.display='none';}
  2811. <?php if(!$this->InHereMode){ ?>
  2812. function la_auto_grow(element){
  2813. s=window.scrollY;element.style.height="30px";element.style.height=(element.scrollHeight)+"px";window.scroll(0, s);
  2814. }
  2815. function ShowBackdrop(alpha=0.5){
  2816. b = document.getElementById('backdrop');
  2817. b.style="background-color:rgba(0,0,0,"+alpha+");";
  2818. b.style.animation='backdrop_fade_in 0.3s forwards';
  2819. b.style.display = 'block';
  2820. }
  2821. function HideBackdrop(){
  2822. b = document.getElementById('backdrop');
  2823. b.style.animation='backdrop_fade_out 0.3s forwards';
  2824. setTimeout(function(e1){e1.style.display='none';}, 300, b);
  2825. }
  2826. function ShowRightSide(big,elem_to_clone){
  2827. p = document.getElementById('pop_right');
  2828. if(elem_to_clone){
  2829. c = elem_to_clone.cloneNode(true);
  2830. c.id='side_bar_cloned';c.className="";c.style="";
  2831. p.querySelector('._content').appendChild(c);
  2832. }
  2833. p.classList.remove('pop_right','pop_right_big');
  2834. if(big) {p.classList.add('pop_right_big');p.style.animation='pop_slide_in_big 0.3s forwards';}
  2835. else {p.classList.add('pop_right');p.style.animation='pop_slide_in 0.3s forwards';}
  2836. p.style.display='block';
  2837. ShowBackdrop(0.5);
  2838. }
  2839. function HideRightSide(){
  2840. p = document.getElementById('pop_right');
  2841. if(side=p.querySelector('#side_bar_cloned')){
  2842. side.remove();
  2843. }
  2844. put = document.querySelector("#_uploader");
  2845. if(p.classList.contains('pop_right')){p.style.animation='pop_slide_out 0.3s forwards';}
  2846. else{p.style.animation='pop_slide_out_big 0.3s forwards';}
  2847. setTimeout(function(e1, e2){e1.style.display='none';if(e2)e2.style.display='none';}, 300, p, put);
  2848. HideBackdrop();
  2849. }
  2850. function CssNumberID(id){ return "#\\3"+id.substr(0,1)+" "+id.substr(1); }
  2851. function ScrollToPost(id){
  2852. post=null;
  2853. if(!(post = document.querySelector("[data-post-id='"+id+"']"))){
  2854. if(!(post = document.querySelector(CssNumberID(id)))) return; }
  2855. post.scrollIntoView({ behavior: 'smooth', block: 'start'});
  2856. }
  2857. <?php } ?>
  2858. </script><input type='checkbox' class='lpctrl' id='titlectrl'>
  2859. <header<?=$this->InHereMode?' class="exp_h_f"':''?>><div>
  2860. <?php if($this->InHereMode){
  2861. $this->MakeExpNavButtons($p);
  2862. }else{
  2863. $this->MakeNavButtons($p);
  2864. if(isset($p['tid']['header'])){ ?><div style='float:right' class='show_on_print'><?=$this->ChoosePartsByLanguage($p['tid']['header']);?></div><?php }
  2865. echo "<hr class='hidden_m'>";
  2866. } ?>
  2867. <?php if(isset($this->WayBack)){
  2868. $time=(isset($_COOKIE['la_wayback']) && preg_match('/[0-9]{14}/u',$_COOKIE['la_wayback']))?$_COOKIE['la_wayback']:date('YmdHis');
  2869. $year=substr($time,0,4);$month=substr($time,4,2);$day=substr($time,6,2);
  2870. $hour=substr($time,8,2);$minute=substr($time,10,2);?> <div class='text_highlight'>
  2871. &nbsp;<b><span onclick='document.getElementById("wayback_config").classList.toggle("hidden_m")'>
  2872. <div class='wayback_close' onclick='event.stopPropagation()'><a href='<?=$this->GetRedirect()?>&set_wayback=false'>
  2873. <span class='hidden_m'><?=$this->T('退出')?></span>×&nbsp;</a></div>
  2874. + <?=$this->T('正以过去的日期浏览')?></b><div id='wayback_config' class='wayback_expand hidden_m'>
  2875. <select id="wayback_year" name="wayback_year" form="wayback_form"><?php for($y=$this->YearBegin;$y<=$this->YearEnd;$y++){ ?>
  2876. <option value="<?=$y?>"<?=$y==$year?" selected":""?>><?=$y?></option><?php } ?></select>
  2877. <br class='hidden_on_desktop' />
  2878. <select id="wayback_month" name="wayback_month" form="wayback_form"><?php for($y=1;$y<=12;$y++){ ?>
  2879. <option value="<?=$y?>"<?=$y==$month?" selected":""?>><?=$y?></option><?php } ?></select>
  2880. <select id="wayback_day" name="wayback_day" form="wayback_form"><?php for($y=1;$y<=31;$y++){ ?>
  2881. <option value="<?=$y?>"<?=$y==$day?" selected":""?>><?=$y?></option><?php } ?></select>
  2882. <br class='hidden_on_desktop' />
  2883. <select id="wayback_hour" name="wayback_hour" form="wayback_form"><?php for($y=0;$y<=23;$y++){ ?>
  2884. <option value="<?=$y?>"<?=$y==$hour?" selected":""?>><?=$y?></option><?php } ?></select>:
  2885. <select id="wayback_minute" name="wayback_minute" form="wayback_form"><?php for($y=0;$y<=59;$y++){ ?>
  2886. <option value="<?=$y?>"<?=$y==$minute?" selected":""?>><?=$y?></option><?php } ?></select>
  2887. <br class='hidden_on_desktop' />
  2888. <form action="<?=$this->GetRedirect()?>&set_wayback=post" method="post" style='display:none;' id='wayback_form'></form>
  2889. <input type='submit' style='font-weight:normal;border-bottom:none;' class='button clean_a' form='wayback_form'
  2890. id='wayback_see' name='wayback_see' value="<?=$this->T('查看')?> →">
  2891. </div></div><?php } ?>
  2892. </div></header>
  2893. <div id='waiting_bar' style='display:none;'></div>
  2894. <script>ShowWaitingBar();window.addEventListener('load',(event) =>{HideWaitingBar();}); </script>
  2895. <?php if(!$this->InHereMode){ ?>
  2896. <div id='post_menu' style='display:none;' class='pop_menu clean_a'>
  2897. <ul>
  2898. <li><span id='_time_hook' class='smaller'>时间</span>&nbsp;&nbsp;<a href='javascript:HidePopMenu();'>×</a></li>
  2899. <li><a id='share_copy'>⎘<?=$this->T('复制链接')?></a></li>
  2900. <hr />
  2901. <?php if($this->LoggedIn){ ?>
  2902. <li><a id='menu_history'><?=$this->T('历史')?></a>
  2903. <?php if(!isset($this->WayBack) && $this->PageType!='search'){ ?>
  2904. | <a id='menu_edit'><?=$this->T('修改')?></a><?php } ?></li>
  2905. <?php if(!isset($this->WayBack)){ ?><li>
  2906. <a id='menu_refer_copy'><?=$this->T('复制编号')?></a><?php if($this->PageType!='search'){ ?>
  2907. | <a id='menu_refer'><?=$this->T('引用')?></a><?php } ?><br class='hidden_on_desktop' />
  2908. </li>
  2909. <li><a id='menu_rename' href='javascript:ToggleRenameDetails()'><?=$this->T('改名')?></a> |
  2910. <a id='menu_mark' href='javascript:ToggleMarkDetails()'><?=$this->T('标记')?></a></li>
  2911. <li id='mark_details' style='display:none;'><b>
  2912. <a id='mark_set_clear' href='javascript:SetMark(-1);'>_</a>
  2913. <a id='mark_set_0' href='javascript:SetMark(0);'><?=$this->Markers[0]?></a>
  2914. <a id='mark_set_1' href='javascript:SetMark(1);'><?=$this->Markers[1]?></a>
  2915. <a id='mark_set_2' href='javascript:SetMark(2);'><?=$this->Markers[2]?></a>
  2916. <a id='mark_set_3' href='javascript:SetMark(3);'><?=$this->Markers[3]?></a>
  2917. <a id='mark_set_4' href='javascript:SetMark(4);'><?=$this->Markers[4]?></a>
  2918. <a id='mark_set_5' href='javascript:SetMark(5);'><?=$this->Markers[5]?></a>
  2919. <a id='mark_set_6' href='javascript:SetMark(6);'><?=$this->Markers[6]?></a>
  2920. <a id='mark_set_7' href='javascript:SetMark(7);'><?=$this->Markers[7]?></a>
  2921. </b></li>
  2922. <li id='rename_details' style='display:none;text-align:left;' class='smaller'>
  2923. <form action="" method="post" style='display:none;' id='post_rename_form'></form>
  2924. <input type='text' id='post_rename_name' name='post_rename_name' form="post_rename_form" style='width:9em;'>
  2925. <input class='button' type='submit' form='post_rename_form'
  2926. name='post_rename_confirm' id='post_rename_confirm' value='<?=$this->T('确认')?>'>
  2927. </li><hr /> <?php if(isset($this->MastodonToken)){ ?>
  2928. <li><a id='menu_mastodon_view' class='button' style='display:none;' target='_blank'><?=$this->T('转到')?></a>
  2929. <a id='menu_mastodon' href='javascript:ToggleMastodonDetails()'><?=$this->T('长毛象')?></a></li>
  2930. <li id='mastodon_details' style='display:none;text-align:left;' class='smaller'>
  2931. <a id='menu_mastodon_send' class='button' target='_blank'><?=$this->T('发送')?></a>
  2932. <form action="" method="post" style='display:none;' id='post_mastodon_form'></form>
  2933. <input type='text' id='post_mastodon_url' name='post_mastodon_url' form="post_mastodon_form" style='width:9em;'>
  2934. <input class='button' type='submit' form='post_mastodon_form'
  2935. name='post_mastodon_confirm' id='post_mastodon_confirm' value='<?=$this->T('修改')?>'></li> <?php } ?>
  2936. <hr /><li><a id='menu_delete' class='smaller'><?=$this->T('删除')?></a></li><?php } ?>
  2937. <?php }else{ ?>
  2938. <li><a id='menu_history'><?=$this->T('历史')?></a></li>
  2939. <?php } ?>
  2940. </ul>
  2941. </div>
  2942. <div id='backdrop' style='display:none;' class='backdrop' onclick='HideRightSide();HideBigImage(1);'
  2943. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"></div>
  2944. <div id='pop_right' class='pop_right' onclick='event.stopPropagation()'>
  2945. <div style='text-align:right;position:sticky;top:0;'><a class='clean_a' href='javascript:HideRightSide();'>
  2946. <?=$this->T('关闭')?>→</a></div>
  2947. <?php if($this->LoggedIn && in_array($this->PageType,['main','post'])){ ?>
  2948. <div id='_uploader' style='display:none;'>
  2949. <?php $this->MakeUploader(true); ?>
  2950. <p>&nbsp;</p>
  2951. <?php $this->MakeSideGalleryCode(); ?>
  2952. </div>
  2953. <?php } ?>
  2954. <div class='_content'></div>
  2955. </div>
  2956. <?php } ?>
  2957. <?php
  2958. }
  2959. function ChoosePartsByLanguage($content,$use_p=false){
  2960. $split = preg_split('/'.($use_p?'<p>\s*':'').'((en|zh|any)\|(en|zh|any))'.($use_p?'<\/p>\s*':'').'/u',$content, -1,
  2961. PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
  2962. $lang = $this->LanguageAppendix; $last_lang='0'; $reduced="";
  2963. if($split) for($i=0;$i<sizeof($split);$i+=4){
  2964. $this_lang = '0'; if($i+2>=sizeof($split)){ $this_lang = $last_lang; }else{ $this_lang = $split[$i+2]; }
  2965. if($this_lang==$lang || $this_lang=='any'){ $reduced.=$split[$i]; }
  2966. if($i+3<sizeof($split)){ $last_lang = $split[$i+3]; }
  2967. }
  2968. if(!$reduced)$reduced = $content;
  2969. return $reduced;
  2970. }
  2971. function TranslatePostParts($html){
  2972. $html = preg_replace_callback('/>(\s*)([^><]+?)(\s*)</u', function($ma){
  2973. $reduced = $this->ChoosePartsByLanguage($ma[2], false);
  2974. return ">".$ma[1].$this->T($reduced).$ma[3]."<";
  2975. }, $html);
  2976. return $html;
  2977. }
  2978. function MakeNavButtons(&$p){ $interesting=$this->IsInterestingPost($p); $no_title=isset($p['tid']['first']['no_title']);?>
  2979. <a href='index.php' class='clean_a hidden_m<?=$no_title?" hidden_on_print":""?>' onclick='ShowWaitingBar()'><b><?=$this->T($this->Title);?></b></a>
  2980. <?=$no_title?"<a class='inline_print'>&nbsp;</a>":""?>
  2981. <label for='titlectrl' id='mtitle'><b><a class='hidden_on_desktop'><?=$this->T($this->ShortTitle)?>...</a></b></label>
  2982. <div class='header_nav'>
  2983. <ul class='mobile_fold hidden_on_print' id='mobile_nav'>
  2984. <li class='hidden_m'><a href='?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  2985. <li class='hidden_on_desktop_force block_m smaller'>&nbsp;</li>
  2986. <li class='hidden_on_desktop_force block_m bigger'>
  2987. <a href='index.php?part=recent' onclick='ShowWaitingBar()'><?=$this->T('最近')?></a>
  2988. <?php if($this->LoggedIn){ ?> | <span class='gray invert_a'>
  2989. <a href='index.php?comments=all'>@</a> <a href='index.php?statistics=all'>%</a></span><?php } ?></li>
  2990. <li class='hidden_on_desktop_force block_m bigger'>
  2991. <a href='index.php?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  2992. <?php $this->SpecialNavigation;if(isset($this->SpecialNavigation) && ($p = &$this->GetPost($this->SpecialNavigation))!=NULL){
  2993. echo $this->GenerateSinglePost($p, false, false, false, false);
  2994. } ?>
  2995. <?php if($this->LanguageAppendix=='zh'){ ?>
  2996. <li class='smaller gray'>
  2997. <a href='<?=$this->GetRedirect().'&set_language=en'?>' onclick='ShowWaitingBar()'><b>汉语</b>/English</a></li>
  2998. <?php }else { ?>
  2999. <li class='smaller gray'>
  3000. <a href='<?=$this->GetRedirect().'&set_language=zh'?>' onclick='ShowWaitingBar()'>
  3001. 汉语/<b>English</b></a>
  3002. <br class='hidden_on_desktop' />
  3003. <a id='translate_button' target='_blank'>&nbsp;[Google Translate]&nbsp;</a></li>
  3004. <?php } ?>
  3005. </ul></div>
  3006. <?php
  3007. }
  3008. function MakeExpNavButtons(&$p){ ?>
  3009. <a href='index.php' class='hidden_m'>
  3010. <b><?=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle)?></b></a>
  3011. <a class='hidden_on_desktop'
  3012. href='javascript:toggle_mobile_show(document.getElementById("mobile_nav"))'><b class='round_btn'>
  3013. <?=$this->InExperimentalMode?$this->T($this->ExpShortTitle):$this->T($this->HereShortTitle)?></b></a>
  3014. <?php if(!$this->InExperimentalMode){ ?>
  3015. <a <?=$this->HereNumber==1?"class='gray'":("href=".$this->HereLinkFromNumber($this->HereNumber-1))?>>←</a>
  3016. <span><?=$this->HereNumber.'/'.sizeof($this->VisitedHere);?></span>
  3017. <span class='round_btn'>
  3018. <a href='<?=$this->HereNumber==sizeof($this->VisitedHere)?"?random_here=1":$this->HereLinkFromNumber($this->HereNumber+1);?>'>→</a>
  3019. <a href='?random_here=1'><?=$this->T("随机")?></a></span><span class='hidden_m'></span>
  3020. <?php } ?>
  3021. <ul class='hidden_m' id='mobile_nav' style='text-align:center;'>
  3022. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  3023. <li class='hidden_on_desktop block_m'><a href='index.php'><?=$this->T('主页')?></a></li>
  3024. <?php if($this->InExperimentalMode && isset($this->ExpNavigation) && ($p = &$this->GetPost($this->ExpNavigation))!=NULL){
  3025. echo $this->GenerateSinglePost($p, false, false, false, false);
  3026. }else if($this->InHereMode && isset($this->HereNavigation) && ($p = &$this->GetPost($this->HereNavigation))!=NULL){
  3027. echo $this->GenerateSinglePost($p, false, false, false, false);
  3028. } ?>
  3029. <?php if($this->AllowLanguageChoices){ ?>
  3030. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  3031. <?php if($this->LanguageAppendix=='zh'){ ?>
  3032. <li class='smaller invert_a gray'><a href='<?=$this->GetRedirect().'&set_language=en'?>'><b>汉语</b>/English</a></li>
  3033. <?php }else { ?>
  3034. <li class='smaller invert_a gray'><a href='<?=$this->GetRedirect().'&set_language=zh'?>'>汉语/<b>English</b></a></li>
  3035. <li class='smaller invert_a gray'><a id='translate_button' target='_blank'>&nbsp;Google Translate&nbsp;</a></li>
  3036. <?php } ?>
  3037. <?php } ?>
  3038. </ul>
  3039. <?php
  3040. }
  3041. function GenerateLinkedPosts($ht){
  3042. $ht = preg_replace_callback('/<p>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>(.*)<\/a>[\s]*<\/p>/u',
  3043. function($m){
  3044. if(preg_match('/^\s*<img/u',$m[2])){ return $m[0]; }
  3045. $rp = &$this->GetPost($m[1], false, true);
  3046. $s="<div class='smaller block post ref_compact gray'>".
  3047. "<a href='?post=".$m[1]."' class='post_access invert_a smaller' onclick='ShowWaitingBar()'>→</a>".
  3048. "<div class='post_width'><div class='smaller'>".$m[2]."</div>".
  3049. (($rp!==NULL && $this->CanShowPost($rp))?
  3050. $this->GenerateSinglePost($rp,false,false,false,true,true):$this->T("未找到该引用。")).
  3051. "</div></div>";
  3052. return $s;
  3053. },
  3054. $ht
  3055. );
  3056. $ht = preg_replace_callback('/<li>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>PRODUCT\s+(.*)<\/a>[\s]*<\/li>/u',
  3057. function($m){
  3058. $rp = &$this->GetPost($m[1], false, true);
  3059. $s="<div class='product_ref block post ref_compact'><a href='?post=".$m[1]."' class='clean_a' onclick='ShowWaitingBar()'>".
  3060. (($rp!==NULL && $this->CanShowPost($rp))?
  3061. $this->GenerateSinglePost($rp,true,false,false,true,true):$this->T("未找到该引用。")).
  3062. "</a></div>";
  3063. return $s;
  3064. },
  3065. $ht
  3066. );
  3067. return $ht;
  3068. }
  3069. function GenerateSinglePost(&$post, $strip_tags, $generate_anchor=false, $generate_refs=false,
  3070. $generate_thumbs=false, $hide_long = false){
  3071. $this->ConvertPost($post);
  3072. if($generate_anchor){ $this->CreatePostAnchor($post); }
  3073. $ht = $post['html'];
  3074. if(isset($post['mark_value']) && $post['mark_value']==5 && ($generate_thumbs || !$generate_anchor)){
  3075. $ht="<div class='product_thumb'>".$post['images'][0]."</div>".
  3076. "<p class='bold'>".$post['product']['title']."</p>".
  3077. (isset($post['product']['short'])?("<p class='smaller gray'>".$post['product']['short']."</p>"):"").
  3078. "<p class='smaller bold'>".$post['product']['price']."</p>";
  3079. return $ht;
  3080. }
  3081. if($hide_long){
  3082. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>[\s\S]*/u',"<p class='smaller bold'>[".$this->T("阅读更多")."]</p>", $ht);
  3083. }else{
  3084. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>/u',"", $ht);
  3085. }
  3086. if ($strip_tags){
  3087. $ht = strip_tags($ht,'<b><i><h1><h2><h3><h4><p><blockquote><span>');
  3088. $ht = preg_replace('/<p>\s*<\/p>/u',"", $ht);
  3089. $ht = "<div class='post_ref_main'>".$ht."</div>";
  3090. }
  3091. else{
  3092. if($generate_refs) $ht = $this->GenerateLinkedPosts($ht);
  3093. }
  3094. if ($strip_tags && $generate_thumbs && isset($post['images']) && isset($post['images'][0])){
  3095. $ht.="<div class='post_ref_images'><ul class='side_thumb ref_thumb'>";
  3096. foreach($post['images'] as $im){
  3097. $ht.="<li class='file_thumb'>".$im."</li>";
  3098. }
  3099. $ht.="</ul></div>";
  3100. }
  3101. return $ht;
  3102. }
  3103. function MakeSinglePostExp(&$post){ ?>
  3104. <li class='post post_dummy'>
  3105. <?=$this->GenerateSinglePost($post, false, false, true, false, false); ?>
  3106. </li>
  3107. <?php
  3108. }
  3109. function MakeSinglePost(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
  3110. $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
  3111. $generate_thumb = false, $is_top = false, $force_hide_long=false){
  3112. $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
  3113. $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
  3114. $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
  3115. $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
  3116. $title = $generate_anchor?$this->ChoosePartsByLanguage($this->GetPostTitle($post, true)):NULL;
  3117. $this->ConvertPost($post);// NEEDED FOR WIDE;
  3118. $is_wide = (isset($post['wide'])&&$post['wide']) || (isset($post['tid']) && isset($post['tid']['wide']) && $post['tid']['wide']);
  3119. ?>
  3120. <?=$title?"<li class='print_title'><h1>".$title."</h1></li>":""?>
  3121. <li class='post<?=isset($extra_class_string)?' '.$extra_class_string:''?>'
  3122. <?=(!$side)?"data-post-id='".$post['id']."'":""?> <?=$is_deleted?"data-mark-delete='true'":""?>
  3123. <?=(!$side&&isset($post['mastodon_url']))?"data-mastodon_url='".$post['mastodon_url']."'":""?>
  3124. <?=$is_wide?" style='column-span:all;'":"";?>>
  3125. <?php if($mark_value>=0 && !$show_link && $mark_value!='P'){?>
  3126. <div class='smaller <?=$is_deleted?"gray":""?>'><?=$mark_value?> <?=$this->T('标记')?></div>
  3127. <?php }
  3128. if(!$side && !$strip_tags && $show_link){?><div class='post_menu_button _menu_hook' >+</div><?php } ?>
  3129. <?=$side?"<a href='?post={$post['id']}' onclick='ShowWaitingBar()'>":""?>
  3130. <div class='<?=$side?"":'post_width'?><?=$is_deleted?" deleted_post":""?>'>
  3131. <?php if($is_product&&!$generate_anchor){
  3132. echo "<p class='smaller gray'>".$this->T('商品')."</p>";
  3133. echo "<div class='product_ref clean_a'><a href='?post={$post['id']}'>";} ?>
  3134. <?=$this->GenerateSinglePost($post, $strip_tags, $generate_anchor, true,
  3135. $generate_thumb,($show_thread_link||$side||$force_hide_long)); ?>
  3136. <?php if($is_product&&!$generate_anchor){echo "</a></div>";} ?>
  3137. </div>
  3138. <?=$side?"</a>":""?> <?php
  3139. if($show_thread_link && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) &&
  3140. $post['tid']['first']['id']!=$post['id']){ ?>
  3141. <div class='gray smaller block opt_compact post'>
  3142. <a href='?post=<?=$post['tid']['first']['id']?>' onclick='ShowWaitingBar()'>
  3143. <div class='post_access invert_a hover_dark smaller'><?=isset($post['tid']['first']['mark_value'])?
  3144. $this->Markers[$post['tid']['first']['mark_value']]:"→"?></div></a>
  3145. <div class='post_width'><div class='smaller'><?=$this->T('回复给主题帖:')?></div>
  3146. <?=$this->GenerateSinglePost($post['tid']['first'], false, false, false, true, true);?>
  3147. </div>
  3148. </div>
  3149. <?php }if(!$side && $show_link){ if($ref_count){ ?><?php } ?>
  3150. <a href='?post=<?=$post['id']?>' onclick="<?=$show_thread_link||isset($_GET['search'])?'ShowWaitingBar()':'ClickPost(this.parentNode,event,true)'?>">
  3151. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  3152. <?=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:($ref_count?"":"")?>
  3153. </div>
  3154. </a><?php if($ref_count){ ?>
  3155. <label class='lb post_access' for='fake<?=$post["id"]?>'><div class='ref_count'><?=$ref_count?></div></label><?php }
  3156. }
  3157. if($show_reply_count && isset($post['tid'])){ ?>
  3158. <a class='smaller block invert_a' href='?post=<?=$post['tid']['last']['id']?>'><?=$post['tid']['count']?>
  3159. <?=$this->T('个回复')?></a>
  3160. <?php } if(!$strip_tags){
  3161. $this->MakeLinkedPosts($post);
  3162. } ?>
  3163. </li>
  3164. <?php
  3165. }
  3166. function MakePostingFields($reply_to=NULL, $show_hint=false){
  3167. if(isset($this->WayBack)){ ?>
  3168. <span class='gray'><i><?=$this->T('以过去日期浏览时不能发帖。')?></i></span>
  3169. <?php return; } ?>
  3170. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='post_form'></form>
  3171. <div class='smaller'><div style='display:<?=$show_hint?"block":"none"?>;'>
  3172. <span id='post_hint_text'><?=$this->T('继续补充该话题:')?></span></div>
  3173. <div id='post_hint_modify' style='display:none;'>
  3174. <input type="checkbox" name="post_record_edit" value="1" form='post_form' checked> <?=$this->T('新增历史记录');?></div></div>
  3175. <textarea id="post_content" name="post_content" rows="4" form='post_form'
  3176. onfocus="if (value =='<?=$this->T('有什么想说的')?>'){value ='';}la_auto_grow(this);"
  3177. onblur="if (value ==''){value='<?=$this->T('有什么想说的')?>';la_auto_grow(this);}"
  3178. oninput="la_auto_grow(this);" onload="la_auto_grow(this);"><?=$this->T('有什么想说的')?></textarea>
  3179. <input class='button' form="post_form" type="submit" name='post_button' value=<?=$this->T('发送')?>
  3180. onclick='ShowWaitingBar();' />
  3181. | <a class='gray smaller pointer' onclick='ShowSideUploader();'><?=$this->T('图片')?></a>
  3182. <div style='float:right;'>
  3183. <a class='gray smaller pointer' onclick='t=document.querySelector("#post_content");t.value="";la_auto_grow(t);'>
  3184. <?=$this->T('清空')?></a>
  3185. <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
  3186. </div>
  3187. <input style='display:none;' type=input form="post_form" id='post_edit_target' name='post_edit_target' />
  3188. <script> la_auto_grow(document.getElementById("post_content"));</script>
  3189. <?php if($reply_to){ ?>
  3190. <input style='display:none;' type=input form="post_form" id='post_reply_to' name='post_reply_to' value='<?=$reply_to?>' />
  3191. <?php } ?>
  3192. <?php
  3193. }
  3194. function MakeCommentPosts(){
  3195. if(!$this->LoggedIn) return; ?>
  3196. <h2><?=$this->T('评论')?></h2><div class='spacer'></div>
  3197. <?php if(!$this->CommentEnabled){
  3198. echo "<p><span class='text_highlight'>&nbsp;".$this->T("已关闭评论")."&nbsp;</span></p><br />"; } ?>
  3199. <div class='comment'><ul>
  3200. <?php $i=0;
  3201. foreach(array_reverse($this->Posts) as $p){
  3202. if(!isset($p['comment_to'])) continue;
  3203. if($i < $this->CommentsPerPage * $this->CurrentOffset) {$i++; continue;}
  3204. $ht = $this->GenerateSinglePost($p, false, false, false, false, false);
  3205. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3206. $post_to = $this->GetPost($p['comment_to']); $post_title = $this->GetPostTitle($post_to);
  3207. if(!$post_to) $post_title = "?";
  3208. $mail = "<span class='gray hidden_on_print'>&nbsp;".
  3209. "<a href='mailto:".$p['email']."'>@</a>&nbsp;".
  3210. (isset($p['ip'])?$p['ip']:"?")."&nbsp;<br class='hidden_on_desktop'/>".
  3211. "<a href='index.php?post=".$p['comment_to']."'>(".$post_title.")</a></span>";
  3212. echo "<li><p><b>".$name.":</b>".$mail."<br /></p>".$ht."</li>";
  3213. $i++;
  3214. }
  3215. ?>
  3216. </ul><br /></div>
  3217. <?php
  3218. }
  3219. function MakeRecentPosts($search_term=NULL, $category=NULL){?>
  3220. <div class='center' id='div_center'><br class='hidden_on_print' />
  3221. <?php if(!isset($search_term) && !isset($category) &&
  3222. (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
  3223. $this->CanShowPost($p)){
  3224. ?><ul class='print_column list bkg_section'><?php
  3225. $this->MakeSinglePost($p, true, false, "active_post", false, true, false, false, false, true, false);
  3226. ?></ul><br /><?php
  3227. }?>
  3228. <h2><?=isset($search_term)?$this->T('搜索'):
  3229. (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
  3230. ($category=='none'?$this->T('未分类'):$this->T($category))):($this->T('最近')).
  3231. " <span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
  3232. ($this->LoggedIn?"<a href='index.php?comments=all'>@</a> <a href='index.php?statistics=all'>%</a>":"")."</span>")?></h2><br />
  3233. <?php if(isset($search_term)){ ?>
  3234. <form action="index.php" method="post" style='display:none;' id='search_form'></form>
  3235. <input id="search_content" name="search_content" rows="4" form='search_form' type='text' value='<?=$search_term?>'>
  3236. <input class='button' form="search_form" type="submit" name='search_button' value=<?=$this->T('搜索')?>
  3237. <?php }else if(isset($category)){ ?>
  3238. <div></div>
  3239. <?php }else if($this->LoggedIn){ ?>
  3240. <div class='post_box_top _input_bundle'>
  3241. <?php $this->MakePostingFields(NULL,false); ?>
  3242. </div>
  3243. <?php } ?>
  3244. <ul class='print_column list bkg_recent'>
  3245. <?php
  3246. $i = 0; $last_end_wide = true;
  3247. if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
  3248. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  3249. if(isset($p['tid'])){ /* Should always be set. */
  3250. $th = &$p['tid']; if($p['tid']['count']==0) continue;
  3251. if(!isset($search_term)) { $p = &$th['last']; }
  3252. }
  3253. if(isset($search_term)){
  3254. if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
  3255. }else if(isset($category)){
  3256. $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
  3257. (isset($p['categories'])?($p['categories']):[]);
  3258. if ($category=='none') { if($cat!=[]) continue; }
  3259. else{ if ($category=='' || !in_array($category, $cat)) continue; }
  3260. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3261. }else{
  3262. if(in_array($p['id'],
  3263. [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
  3264. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3265. }
  3266. if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
  3267. if($last_end_wide){$use_class="last_wide";}else{$use_class="";}
  3268. $this->MakeSinglePost($p, true, false, $use_class, false, !isset($search_term), false, false, false, false, isset($search_term));
  3269. $i++;
  3270. if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
  3271. $last_end_wide = sizeof($p['tid']['arr'])==1 && isset($p['end_wide']) && $p['end_wide'];
  3272. }?>
  3273. </ul>
  3274. <div class='page_selector clean_a'>
  3275. <hr />
  3276. <a <?=$this->CurrentOffset>0?("href='index.php?offset=".($this->CurrentOffset-1).
  3277. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):""?>
  3278. <?=$this->CurrentOffset==0?"class='gray'":""?>><?=$this->T('上一页')?> ←</a>
  3279. <?=$this->CurrentOffset+1?>
  3280. <a href='index.php?offset=<?=($this->CurrentOffset+1).
  3281. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))?>'>
  3282. → <?=$this->T('下一页')?></a>
  3283. </div>
  3284. </div>
  3285. <?php
  3286. }
  3287. function MakeLinkedPosts(&$p){
  3288. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); if(!$has_ref)return; $count=0;?>
  3289. <input type='checkbox' class='lpctrl' id='fake<?=$p["id"]?>' checked='checked'>
  3290. <div class='linked_posts smaller'>
  3291. <ul><?php $count_product=0;
  3292. foreach(array_reverse($p['refs']) as &$pr){
  3293. $po = $this->GetPost($pr);
  3294. if(!$this->CanShowPost($po)){ continue; } $count++;
  3295. $this->MakeSinglePost($po, false, true, "post_preview invert_a", true, false, false, false, true, false, false);
  3296. }
  3297. ?></ul>
  3298. </div>
  3299. <?php
  3300. }
  3301. function MakeLinkedPostsExp(&$p){
  3302. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); ?>
  3303. <div class='center_exp post_dummy smaller'>
  3304. <hr />
  3305. <?php if(!$this->InExperimentalMode){ ?>
  3306. <h3<?=$has_ref?"":" class='gray'"?>><?=$this->T('链接')?></h3>
  3307. <?php if($has_ref){ ?>
  3308. <div class='smaller'><?=sizeof($p['refs'])?> <?=$this->T('个引用:')?></div>
  3309. <ul><?php $count_product=0;
  3310. foreach(array_reverse($p['refs']) as &$pr){
  3311. echo "<li class='post_dummy'><a href='?post=".$pr."'>".$this->T($this->GetPostTitle($this->GetPost($pr),false)).
  3312. "</a></li>";
  3313. }
  3314. ?></ul>
  3315. <?php if($count_product){ ?> <span class='smaller'><?=$this->T('和').' '.$count_product.' '.$this->T('个商品')?></span> <?php }
  3316. }else{ ?>
  3317. <div class='gray smaller'><?=$this->T('没有帖子链接到这里。')?></div>
  3318. <?php } }?>
  3319. <div style='margin-bottom:4rem;'>&nbsp;</div>
  3320. </div>
  3321. <?php
  3322. }
  3323. function MakePostHistoryList(&$ah, &$post,$version=NULL, $show_latest=true){
  3324. $latest_ver=isset($post['version'])?$post['version']:$post['id'];
  3325. $can_show=1; if(isset($this->WayBack) && $latest_ver>$this->WayBack) $can_show=0;
  3326. $title = NULL; if(!isset($ah) || ($show_latest && $can_show)) { $title=$this->T($this->GetPostTitle($post, false)); }
  3327. else{ $ver = &$ah['list'][sizeof($ah['list'])-1]; $title= $this->GetPostTitle($ver); }
  3328. if(!isset($title)) $title=$this->T('未命名');
  3329. if(!isset($ah)){ ?>
  3330. <h2><?=$this->T('没有历史记录')?></h2>
  3331. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$post['id']?>'><?=$title?></a></span><br />
  3332. <?php }else{ ?>
  3333. <h2><?=$this->T('历史记录')?></h2>
  3334. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$ah['id']?>'><?=$title?></a></span><br />
  3335. <div class='list'><ul>
  3336. <?php if($show_latest && $can_show){ $post['history_displayed']=1; ?>
  3337. <li class='<?=isset($version)&&$version==$latest_ver?" post_current_row bold":""?>' style='list-style:"";'>
  3338. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$latest_ver?>'><?=$this->ReadableTime($latest_ver)?></a>
  3339. <span class='smaller gray'><?=$this->T('长度').' '.strlen($post['content'])?></span>
  3340. <?php if(isset($post['merged_from'][0])){ ?><ul><?php foreach($post['merged_from'] as $from){
  3341. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3342. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3343. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3344. <?=$this->GetPostTitle($ver);?></a>
  3345. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3346. <?php } ?></ul><?php } ?>
  3347. <?php if(isset($post['merged_thread'][0][0])){ $pm=$post['merged_thread'][0][0];
  3348. $mah = &$this->GetArchiveHandle($pm);
  3349. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3350. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  3351. <span class='smaller gray'><?=sizeof($post['merged_thread'][0]);?> <?=$this->T('个帖子')?></span></li></ul>
  3352. <?php } ?>
  3353. </li><?php } ?>
  3354. <?php if(isset($ah['list'][0])) foreach(array_reverse($ah['list']) as &$ver){
  3355. if(isset($this->WayBack) && $ver['version']>$this->WayBack) continue;
  3356. if(isset($ver['history_displayed']) && $ver['history_displayed']) continue; ?>
  3357. <li<?=isset($version)&&$version==$ver['version']?" class='post_current_row bold'":""?>>
  3358. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$ver['version']?>'><?=$this->ReadableTime($ver['version'])?></a>
  3359. <span class='smaller gray'> <?=$this->T('长度').' '.strlen($ver['content'])?></span>
  3360. <?php if(isset($ver['merged_thread'][0][0])){ $pm=$ver['merged_thread'][0][0];
  3361. $mah = &$this->GetArchiveHandle($pm); $mver = &$this->GetPost($pm);
  3362. if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3363. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  3364. <span class='smaller gray'> <?=sizeof($ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></li></ul>
  3365. <?php } if(isset($ver['merged_from'][0])){ ?><ul><?php foreach($ver['merged_from'] as $from){
  3366. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3367. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3368. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3369. <?=$this->GetPostTitle($ver);?></a>
  3370. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3371. <?php } ?></ul></li><?php } ?>
  3372. <?php } ?></ul></div>
  3373. <?php } ?>
  3374. <?php
  3375. }
  3376. function MakePostDiff(&$this_ver, &$last_ver){
  3377. if(!isset($this_ver)){ ?>
  3378. <h2 class='gray'><?=$this->T('版本不存在')?></h2>
  3379. <?php }else{ ?>
  3380. <h2><?=$this->T('差异')?></h2>
  3381. <?php if(isset($this_ver['merged_thread']) && isset($this_ver['merged_thread'][0][0])){
  3382. $pm=$this_ver['merged_thread'][0][0]; $mah = &$this->GetArchiveHandle($pm);
  3383. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3384. <p><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver)?></a> <?=$this->T('并入这里')?>
  3385. <br /><span class='smaller gray'> <?=sizeof($this_ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></p>
  3386. <?php }else{ ?>
  3387. <table class='diff_table'><thead>
  3388. <tr><td><?php if(!isset($last_ver)){ ?><?=$this->T('没有更旧的版本')?><?php }else{ ?>
  3389. <?=$this->T('上一个版本')?><br /><?=$this->ReadableTime($last_ver['version'])?><?php } ?></td>
  3390. <td class='text_highlight bold'><?=$this->T('选择的版本')?><br /><?=$this->ReadableTime($this_ver['version'])?></td></tr>
  3391. </thead><tbody>
  3392. <tr><td><pre><?=isset($last_ver)?$last_ver['content']:""?></pre></td><td><pre><?=$this_ver['content']?></pre></td></tr>
  3393. </tbody>
  3394. </table>
  3395. <?php } ?>
  3396. <br /><a class='smaller' href='?post=<?=$this_ver['id']?>&set_wayback=<?=isset($this_ver['version'])?$this_ver['version']:$this_ver['id']?>'><?=$this->T('前往该版本时间')?> ←</a>
  3397. <?php } ?>
  3398. <?php
  3399. }
  3400. function MakePostHistory(&$post, $version=NULL){
  3401. $ah = &$this->GetArchiveHandle($this->CurrentPostID);
  3402. $p = &$post; if(!isset($post)){ $p=&$ah['list'][0]; }
  3403. $show_latest = isset($ah)?(!isset($ah['list'][sizeof($ah['list'])-1]['merged_into'])):true;
  3404. ?>
  3405. <div class='left mobile_fold history' id='div_left'>
  3406. <?php if (isset($version)){
  3407. $this->MakePostHistoryList($ah, $p, $version, $show_latest);
  3408. }else{ echo "&nbsp;"; } ?>
  3409. </div>
  3410. <div class='center history' id='div_center'>
  3411. <?php if (!isset($version)){
  3412. $this->MakePostHistoryList($ah, $p, NULL, $show_latest);
  3413. }else{
  3414. $this_ver = NULL; $next_ver = NULL; $last_ver=NULL;
  3415. $this_ver = &$this->GetArchiveVersion($ah, $version, $next_ver, $last_ver);
  3416. if(!isset($this_ver)){$this_ver = $p; $last_ver=$ah['list'][sizeof($ah['list'])-1];}
  3417. $this->MakePostDiff($this_ver, $last_ver, $p);
  3418. } ?>
  3419. </div>
  3420. <?php
  3421. }
  3422. function MakeCommentSection(&$post){
  3423. if(!$this->CommentEnabled){ return; }
  3424. $to_post = isset($post['tid'])?$post['tid']['first']:$post;
  3425. $comment_count = (isset($to_post['comments']) && isset($to_post['comments'][0]))?count($to_post['comments']):0;
  3426. ?><div class='comment'>
  3427. <br /><h2><?=$this->T('评论')?> (<?=$comment_count;?>)</h2><div class='spacer'></div>
  3428. <?php if($comment_count) { echo "<ul>";
  3429. foreach($to_post['comments'] as $p){
  3430. $ht = $this->GenerateSinglePost($p, false, false, false, false, false);
  3431. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3432. $mail = $this->LoggedIn?("<span class='gray clean_a hidden_on_print'>&nbsp;".
  3433. "<a href='mailto:".$p['email']."'>@</a>&nbsp;</span>"):"";
  3434. echo "<li><p><b>".$name.":</b>".$mail."</p>".$ht."</li>";
  3435. }
  3436. echo "</ul>";
  3437. } else {
  3438. echo $this->T('还没有评论');
  3439. } ?>
  3440. <div class='hidden_on_print'>
  3441. <div class='spacer'></div>
  3442. <form action="index.php?post=<?=$this->CurrentPostID?>&comment_to=<?=$to_post['id']?>"
  3443. method="post" style="display:none;" id="comment_form"></form>
  3444. <p><a class='text_highlight bold clean_a'
  3445. onclick='document.getElementById("comment_box").style.display="block";this.parentNode.style.display="none"'>
  3446. &nbsp;<?=$this->T('写评论');?>&nbsp;</a></p>
  3447. <div id='comment_box' style='display:none;'>
  3448. <p class='gray' style='margin-bottom:0.5em;'><?=$this->T('您的邮箱不会公开展示。');?></p>
  3449. <table style='white-space:nowrap;'>
  3450. <tr><td colspan='2'>
  3451. <textarea id="comment_box" name="comment_box" rows="4" class='full_box' form='comment_form'
  3452. oninput="CommentUpdated();" ></textarea>
  3453. </td></tr>
  3454. <tr><td><?=$this->T('电子邮件')?>*</td><td><?=$this->T('称呼')?>*</td></tr>
  3455. <tr><td><input type="text" form="comment_form" id='comment_email' name='comment_email'
  3456. class='full_box' oninput="CommentUpdated();" /></td>
  3457. <td><input type="text" form="comment_form" id='comment_name' name='comment_name'
  3458. class='full_box' oninput="CommentUpdated();" /></td></tr>
  3459. <tr><td colspan='2'><?=$this->T('个人网站')?></td></tr>
  3460. <tr><td colspan='2'>
  3461. <input type="text" form="comment_form" id='comment_link' name='comment_link'
  3462. class='full_box' oninput="CommentUpdated();" />
  3463. </td></tr>
  3464. <tr><td colspan='2'>
  3465. <div class='spacer'></div>
  3466. <input class='button text_highlight bigger' type='submit' form='comment_form'
  3467. name='comment_confirm' id='comment_confirm' value='&nbsp;<?=$this->T('发送')?>&nbsp;'>
  3468. </td></tr>
  3469. </table></div>
  3470. <script>
  3471. const IsValidEmail = (email) => {
  3472. 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,}))$/);
  3473. };
  3474. function IsValidHttpUrl(string) {
  3475. let url; try{ url = new URL(string); } catch (_) { return false; }
  3476. return url.protocol === "http:" || url.protocol === "https:";
  3477. }
  3478. var cbox = document.getElementById('comment_box');
  3479. var cemail = document.getElementById('comment_email');
  3480. var cname = document.getElementById('comment_name');
  3481. var clink = document.getElementById('comment_link');
  3482. var cconfirm = document.getElementById('comment_confirm');
  3483. function CommentUpdated(){
  3484. cconfirm.disabled=true;
  3485. if (cemail.value!="" && IsValidEmail(cemail.value) &&
  3486. cbox.innerText.length>2 && cname.value.length>2 &&
  3487. clink.value=="" || IsValidHttpUrl(clink.value)){
  3488. cconfirm.removeAttribute("disabled");
  3489. }
  3490. }
  3491. CommentUpdated();
  3492. </script>
  3493. </div>
  3494. </div>
  3495. <?php
  3496. }
  3497. function MakeInterestingSection(&$th){
  3498. $this->Anchors = [];
  3499. $c = &$th['first']['content'];
  3500. $this->ConvertPost($th['first']);
  3501. $ht = $th['first']['html'];
  3502. ?>
  3503. <script>function ClickImage(post_access){im=post_access.querySelector('img');if(im){im.click();}}</script>
  3504. <div class='center_full' id='div_center'>
  3505. <?php $this->MakePostTools(); ?>
  3506. <?php $cat = NULL;
  3507. if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; }
  3508. if($cat){ ?>
  3509. <p><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  3510. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  3511. <?php } ?>
  3512. <h2 class='hidden_on_print'><?=$this->T('有趣')?>
  3513. <a class='gray clean_a' href='?post=<?=$th['first']['id']?>'>→</a></h2>
  3514. <ul><li class='post' data-post-id='<?=$th['first']['id']?>'>
  3515. <div class='post_menu_button _menu_hook' onclick='ShowPostMenu(this.parentNode);'>+</div><?=$ht?>
  3516. <?php if(isset($th['first']['refs'][0])){ ?><p class='smaller'><?=$this->T('引用')?>: </p><ul class='smaller'>
  3517. <?php foreach($th['first']['refs'] as $ref){
  3518. $po = $this->GetPost($ref);
  3519. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  3520. if(!$this->CanShowPost($po)){ continue; }
  3521. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  3522. } ?>
  3523. </ul><?php } ?>
  3524. <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  3525. <div class='hidden_on_print'><br />
  3526. <?php $this->MakePostingFields($th['last']['id'], true);?><br />
  3527. </div>
  3528. <?php } ?>
  3529. <table><thead><tr><?php foreach($th['interesting'] as $header){ ?>
  3530. <td><?=$this->T($header);?></td>
  3531. <?php } ?><td></td></tr></thead><tbody class='interesting_tbody'>
  3532. <?php $plist = array_reverse(array_slice($th['arr'],1));
  3533. foreach($plist as &$p){
  3534. $this->ConvertPost($p);
  3535. $mark_value = isset($p['mark_value'])?$this->Markers[$p['mark_value']]:-1;
  3536. $ref_count = isset($p['refs'])?sizeof($p['refs']):0;
  3537. $is_current = $p['id']==$this->CurrentPostID;
  3538. $is_deleted = (isset($p['mark_delete'])&&$p['mark_delete']); ?>
  3539. <tr class='<?=$is_current?"post_current_row":""?><?=$is_deleted?" deleted_post":""?>'
  3540. data-post-id='<?=$p['id']?>' <?=$is_deleted?"data-mark-delete='true'":""?>
  3541. onDblClick='ClickImage(this)'><td>
  3542. <?php if($ref_count){ ?>
  3543. <div class='post_access ref_count'><?=$ref_count?></div>
  3544. <?php } ?></a>
  3545. <?=$p['html'];?>
  3546. <a class='_menu_hook clean_a post_menu_button' onclick='ShowPostMenu(this.parentNode.parentNode);'>+</a>
  3547. <a <?=$is_current?"":("href='?post=".$p['id']."' onclick='ShowWaitingBar()'");?> class='clean_a paa'>
  3548. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  3549. <?=isset($p['mark_value'])?$this->Markers[$p['mark_value']]:($ref_count?"":"→")?>
  3550. </div></td></tr>
  3551. <?php if($is_current && $ref_count>0){ ?><tr class='post_current_row'><td><p>&nbsp;</p><ul class='smaller'>
  3552. <?php foreach($p['refs'] as $ref){
  3553. $po = $this->GetPost($ref);
  3554. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  3555. if(!$this->CanShowPost($po)){ continue; }
  3556. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  3557. } ?>
  3558. </ul></td></tr><?php } ?>
  3559. <?php } ?>
  3560. </tbody></table>
  3561. </li></ul>
  3562. <br />
  3563. <?php $this->MakeCommentSection($th['first']); ?>
  3564. </div>
  3565. <?php return true;
  3566. }
  3567. function CssNumberID($id){
  3568. return "#\\3".substr($id,0,1)." ".substr($id,1);
  3569. }
  3570. function MakePostTools(){
  3571. if($this->LoggedIn && !isset($this->WayBack)){ ?><div class='smaller gray hidden_on_print clean_a'>
  3572. <a id='merge_cancel' href='javascript:{TogglePostSelectMode(false,true);ToggleThreadMerge(false,true);}'>
  3573. <?=$this->T('工具')?></a>:<div class='hidden_m' style='display:inline'>
  3574. <span id='merge_post_btn'><a href='javascript:TogglePostSelectMode()'><?=$this->T('合并帖子')?></a></span>
  3575. | <span id='merge_thread_btn'><a href='javascript:ToggleThreadMerge()'><?=$this->T('合并话题')?></a></span>
  3576. </div>
  3577. <select class='hidden_on_desktop' id='merge_select'
  3578. onchange="if(this.selectedIndex==1){TogglePostSelectMode(true);}else if(this.selectedIndex==2){ToggleThreadMerge(true);}">
  3579. <option value='-1' selected>--</option>
  3580. <option value='1'><?=$this->T('合并帖子')?></option>
  3581. <option value='2'><?=$this->T('合并话题')?></option></select>
  3582. <div style='display:none;' id='merge_post_dialog' class='text_highlight small_pad align_right'>
  3583. <div style='display:inline;'><?=$this->T('将合并');?> <span id='merge_post_count'></span> <?=$this->T('个帖子');?></div>
  3584. <span class='clean_a bold align_right'><a id='merge_post'>&nbsp;<?=$this->T('执行');?></a></span></div>
  3585. <div style='display:none;overflow:auto' id='merge_thread_dialog' class='text_highlight small_pad align_right'>
  3586. <div style='display:inline;'><?=$this->T('合并到话题');?></div>
  3587. <input id="merge_thread_target" type="text" style="width:9em;display:inline" onChange='ThreadMergeInput(this);' onInput='ThreadMergeInput(this);'>
  3588. <span class='clean_a bold align_right'><a id='merge_thread'>&nbsp;<?=$this->T('执行');?></a></span></div>
  3589. </div><div class='spacer hidden_on_print'></div><?php
  3590. }
  3591. }
  3592. function MakeSidebar(){ ?>
  3593. <div class='left mobile_fold'><?php if(isset($this->SpecialSidebar) && ($p = &$this->GetPost($this->SpecialSidebar))!=NULL){
  3594. ?><span class='gray smaller'><br /></span><?php
  3595. echo $this->GenerateSinglePost($p, false, false, false, false); }?>
  3596. <div class='wayback_link clean_a smaller'><span class='gray'><br /><?=$this->T('工具')?></span><ul>
  3597. <li><a href='?search=' onclick='ShowWaitingBar()' class='bigger'><?=$this->T('搜索')?></a></li>
  3598. <li><?php if(!isset($this->WayBack)){ ?>
  3599. <a href='<?=$this->GetRedirect()?>&set_wayback=true'><?=$this->T('以过去的日期浏览')?></a>
  3600. <?php }else{ ?><a href='<?=$this->GetRedirect()?>&set_wayback=false'><?=$this->T('回到当前日期')?></a><?php } ?></li>
  3601. <li><a href='<?=$this->GetRedirect()?>&toggle_font=true'>
  3602. <?=$this->T('切换字体')?>: <?=$this->T($this->UseRemoteFont?"远程":"本地");?></a></li>
  3603. <li><a rel="alternate" type="application/rss+xml" href="?rss=<?=$this->LanguageAppendix;?>" />RSS/Atom<sup><?=$this->LanguageAppendix;?></sup></a></li>
  3604. </ul>
  3605. </div>
  3606. </div>
  3607. <?php }
  3608. function MakePostSection(&$post){
  3609. $this->Anchors = [];
  3610. if(isset($this->TagID)){ ?><style><?=$this->CssNumberID($this->TagID);?>{display:block;}</style><?php } ?>
  3611. <div class='center' id='div_center'><br class='hidden_on_print' />
  3612. <h2 class='hidden_on_print'>
  3613. <?php $th=NULL; $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1;
  3614. $is_wide = (isset($post['wide'])&&$post['wide']) || ($is_thread && isset($post['tid']['wide']) && $post['tid']['wide']);
  3615. if($is_thread){ $th = $post['tid'];?> <?=$this->T('话题')?> <?php }else{ ?> <?=$this->T('详细')?>
  3616. <?php } ?></h2>
  3617. <?php $cat = NULL;
  3618. if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
  3619. else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
  3620. $this->MakePostTools();
  3621. if($cat){ ?>
  3622. <p class='hidden_on_print'><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  3623. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  3624. <?php } ?><br class='hidden_on_print' />
  3625. <ul class='print_column bkg_section'>
  3626. <?php $is_reversed=false;
  3627. if($is_thread){
  3628. $use_arr = $th['arr']; $hinted=false;
  3629. $last_end_wide = true; $is_reversed=$this->IsReversedThread($th);
  3630. foreach($use_arr as &$p){$use_class="";if($p==$post){$use_class.=" active_post";}
  3631. if($last_end_wide){$use_class.=" last_wide";}
  3632. $make_title = ($p == $post);
  3633. if(isset($p['restart'])){ ?>
  3634. <li class='restart'><h3><?=$p['restart']?></h3></li><?php }
  3635. $this->MakeSinglePost($p,true,false,$use_class,false, false, false, true, false, false);
  3636. if($make_title){?>
  3637. <script>
  3638. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  3639. </script>
  3640. <?php } if($is_reversed && !$hinted){ ?><?php $hinted = true;
  3641. if($this->LoggedIn && (!$this->InHereMode)){ ?>
  3642. <div class='hidden_on_print'>
  3643. <?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?></div><br />
  3644. <?php } }
  3645. $last_end_wide = isset($p['end_wide']) && $p['end_wide'];
  3646. }
  3647. }else{
  3648. $this->MakeSinglePost($post,true, false,"active_post",false, false, false, true, false, false);
  3649. ?><script>
  3650. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($post),0,100)))?>";
  3651. </script><?php
  3652. } $class_add=""; if(isset($post['tid']['first']['no_time'])){ $class_add=' hidden_on_print'; } ?>
  3653. </ul>
  3654. <div class='smaller align_right<?=$class_add;?>'>
  3655. <span class='gray'><?=$this->ReadableTime($post['tid']['first']['id']);?></span>
  3656. <br class='hidden_on_desktop' /><?=$this->ReadableTime(isset($post['tid']['last']['version'])?
  3657. $post['tid']['last']['version']:$post['tid']['last']['id']);?>
  3658. </div>
  3659. <?php if(!$is_reversed && ($this->LoggedIn && (!$this->InHereMode))){ ?>
  3660. <div class='hidden_on_print'>
  3661. <br /><?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?>
  3662. </div>
  3663. <?php }
  3664. $this->MakeCommentSection($post);
  3665. ?>
  3666. </div>
  3667. <?php
  3668. }
  3669. function MakePostSectionExp(&$post){
  3670. $this->Anchors = []; $is_thread = isset($post['tid']);
  3671. ?>
  3672. <div class='center_exp' id='div_center'><br class='hidden_on_print' />
  3673. <ul>
  3674. <?php $is_reversed=false;
  3675. if($is_thread){ $th = &$post['tid'];$use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false;
  3676. foreach($use_arr as &$p){
  3677. $this->MakeSinglePostExp($p);
  3678. if($p == $th['first']){?>
  3679. <script>
  3680. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  3681. </script>
  3682. <?php } if($is_reversed && !$hinted){ ?>
  3683. <li class='gray smaller bold' style='text-align:center;'>
  3684. <p>&nbsp;</p><hr><?=$this->T('该话题最新帖子在前')?><hr><p>&nbsp;</p></li>
  3685. <?php $hinted = true; }
  3686. }
  3687. }else{
  3688. $this->MakeSinglePostExp($post);
  3689. ?><!--<script>
  3690. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  3691. </script>--><?php
  3692. } ?>
  3693. </ul>
  3694. </div>
  3695. <?php
  3696. }
  3697. function MakeHereSection(&$im){ $image_okay = (isset($im) && $im!=$this->NULL_IMAGE); ?>
  3698. <div class='here_image_box clean_a'>
  3699. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'>
  3700. <?=$image_okay?$this->T('请稍候'):$this->T('未找到图像')?></div>
  3701. <?php if($image_okay){ ?>
  3702. <?php if(isset($im['video']) && isset($im['video'])!=""){ ?>
  3703. <video controls><source src='<?=$im['file'];?>' type='<?=$im['video']?>'></video>
  3704. <?php }else{ ?>
  3705. <img id='big_image' onload="HideWaitingBar();" src="<?=$im['file'];?>" />
  3706. <?php } ?>
  3707. <?php } $this->MakeHereButtons($im, false); ?>
  3708. </div>
  3709. <?php }
  3710. function MakeSideGalleryCode(){?>
  3711. <div>
  3712. <h3><?=$this->T('点击图片以插入:')?></h3>
  3713. <select id="side_gallery_select" onchange="RefreshSideGallery()">
  3714. <option value="main"><?=$this->T('全部')?></option>
  3715. <?php if($this->LoggedIn){ ?>
  3716. <option value="trash"><?=$this->T('垃圾桶')?></option>
  3717. <?php }?>
  3718. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  3719. <option value="<?=$g['name']?>"><?=$g['name']?></option>
  3720. <?php } ?>
  3721. </select>
  3722. <div id='side_gallery'>
  3723. </div>
  3724. </div>
  3725. <script>
  3726. function InsertImage(imgname){
  3727. t = document.querySelector("#post_content");
  3728. v = t.value;
  3729. t.value = v.slice(0, t.selectionStart) + "![<?=$this->T('图片')?>](images/"+imgname+")"+ v.slice(t.selectionEnd);
  3730. la_auto_grow(t);
  3731. }
  3732. function RefreshSideGallery(){
  3733. let xhr = new XMLHttpRequest();
  3734. xhr.onreadystatechange = (function(){
  3735. if (this.readyState === this.DONE) {
  3736. if (this.status === 200) {
  3737. ind = document.querySelector("#side_gallery");
  3738. if(res = xhr.responseText.matchAll(/\[(.*?),(.*?)\]/gu)){
  3739. str = "<ul class='side_thumb'>"
  3740. for (const m of res) {
  3741. imgstr = "<img src='"+m[2]+"' />";
  3742. if(m[2].match('\.mp4')){
  3743. imgstr = "<video><source src='"+m[2]+"'></video>";
  3744. }
  3745. str+="<li><div class='file_thumb' onclick='InsertImage(\""+m[1]+"\")'>"+imgstr+"</div>"
  3746. }
  3747. str += "</ul>"
  3748. ind.innerHTML = str;
  3749. }
  3750. }
  3751. }
  3752. });
  3753. xhr.open("GET", "?image_list="+document.querySelector("#side_gallery_select").value, true);
  3754. xhr.send();
  3755. }
  3756. </script>
  3757. <?php
  3758. }
  3759. function MakeUploader($is_side=false){ ?>
  3760. <div id='upload_operation_area' class='hidden_on_print'>
  3761. <p><?=$this->T('选择、粘贴或者拖动到页面以上传图片。')?></p>
  3762. <input type="file" id='upload_selector' accept="image/x-png,image/png,image/gif,image/jpeg" multiple/>
  3763. <ul id='file_list'>
  3764. </ul>
  3765. <div class='smaller gray' id='upload_hint'><?=$this->T('就绪')?></div>
  3766. </div>
  3767. <a id='upload_click' class='hidden_on_print pointer' onclick='this.removeAttribute("onclick");UploadList();'
  3768. <?=$is_side?" data-is-side='true'":""?>><?=$this->T('上传列表中的文件')?></a>
  3769. <script>
  3770. function pastehandler(event){
  3771. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  3772. for (index in items) {
  3773. var item = items[index];
  3774. if (item.kind === 'file') {
  3775. put = document.querySelector("#_uploader");
  3776. if(put) ShowSideUploader();
  3777. var blob = item.getAsFile();
  3778. AddImageFile(blob);
  3779. return;
  3780. }
  3781. }
  3782. }
  3783. let _fd_list = []; var uploading=0;
  3784. let hint=document.querySelector('#upload_hint');
  3785. function ToggleCompress(button){
  3786. li = button.parentNode;
  3787. num=li.dataset.number;
  3788. for(i=0;i<_fd_list.length;i++){
  3789. if (_fd_list[i][0] == num){
  3790. state = _fd_list[i][2];
  3791. if(state){_fd_list[i][2] = 0; button.innerHTML='1920';break;}
  3792. else{_fd_list[i][2] = 1; button.innerHTML='800';break;}
  3793. }
  3794. }
  3795. }
  3796. function RemoveFromUpload(button){
  3797. li = button.parentNode;
  3798. num=li.dataset.number;
  3799. for(i=0;i<_fd_list.length;i++){
  3800. if (_fd_list[i][0] == num){
  3801. _fd_list.splice(i, 1);break;
  3802. }
  3803. }
  3804. li.parentNode.removeChild(li);
  3805. }
  3806. function EndThisUpload(){
  3807. unfinished = 0;
  3808. for(i=0;i<_fd_list.length;i++){
  3809. if (_fd_list[i][3]==0){
  3810. unfinished=1;
  3811. }
  3812. }
  3813. if(!unfinished){
  3814. uploading=0;
  3815. hint.innerHTML="<?=$this->T('上传完成。')?>";
  3816. cl=document.querySelector('#upload_click');
  3817. if(!cl.dataset.isSide){
  3818. cl.innerHTML="<?=$this->T('刷新页面')?>";
  3819. cl.href=window.location.href;
  3820. }else{
  3821. _fd_list.splice(0,_fd_list.length);
  3822. fl = document.querySelector("#file_list");
  3823. fl.innerHTML = "";
  3824. list=document.querySelector('#upload_operation_area');
  3825. list.style.pointerEvents='';
  3826. list.style.opacity='';
  3827. cl.onclick=function(){this.removeAttribute("onclick");UploadList();};
  3828. document.onpaste=pastehandler;
  3829. RefreshSideGallery();
  3830. }
  3831. }
  3832. }
  3833. function UploadList(){
  3834. if(!_fd_list.length || uploading) return;
  3835. uploading=1;
  3836. hint.innerHTML="<?=$this->T('正在上传...')?>";
  3837. list=document.querySelector('#upload_operation_area');
  3838. list.style.pointerEvents='none';
  3839. list.style.opacity='0.5';
  3840. document.onpaste="";
  3841. for(i=0;i<_fd_list.length;i++){
  3842. let xhr = new XMLHttpRequest();
  3843. var li = list.querySelector('[data-number="'+_fd_list[i][0].toString()+'"]')
  3844. xhr.open("POST", "?compress="+_fd_list[i][2].toString(), true);
  3845. function wrap(li, i){
  3846. var ind = li.querySelector('._compress_toggle')
  3847. return function(){
  3848. if (this.readyState === this.DONE) {
  3849. if (this.status === 200) {
  3850. var response = xhr.responseText;
  3851. if(res = response.match(/<uploaded>(.*)<\/uploaded>/)){
  3852. ind.innerHTML = "<?=$this->T('已上传为')?> "+res[1];
  3853. _fd_list[i][3] = 1;
  3854. }else{
  3855. ind.innerHTML = "<?=$this->T('出现错误。')?>";
  3856. _fd_list[i][3] = 1;
  3857. }
  3858. EndThisUpload();
  3859. }
  3860. }
  3861. }
  3862. }
  3863. xhr.onreadystatechange = wrap(li, i);
  3864. xhr.send(_fd_list[i][1]);
  3865. }
  3866. }
  3867. function AddImageFile(blob){
  3868. var ext="";
  3869. if(blob.name.match(/png$/))ext = 'png';
  3870. else if(blob.name.match(/jpg$/))ext = 'jpg';
  3871. else if(blob.name.match(/jpeg$/))ext = 'jpeg';
  3872. else if(blob.name.match(/gif$/))ext = 'gif';
  3873. else if(blob.name.match(/mp4$/))ext = 'mp4';
  3874. else return;
  3875. var fd = new FormData();
  3876. blob.name = blob.name=generateUID().toString();
  3877. fd.append("upload_file_name", blob, "_upload_"+blob.name+"."+ext);
  3878. _fd_list.push([blob.name, fd, 1, 0]);/* number original is_compress uploaded */
  3879. var reader = new FileReader();
  3880. reader.onload = function(event){
  3881. fl = document.querySelector("#file_list");
  3882. ht = "<li id='_upload_"+blob.name+"' data-number='"+blob.name+"'>"+
  3883. "<a class='_remove_file pointer invert_a' onclick='RemoveFromUpload(this)'>×</a> "+"<div class='file_thumb'>"+
  3884. "<img class='no_pop' src='"+event.target.result+"'>"+"</div>"+
  3885. " →<a class='_compress_toggle pointer' onclick='ToggleCompress(this)'>800</a></li>";
  3886. fl.innerHTML+=ht;
  3887. };
  3888. reader.readAsDataURL(blob);
  3889. }
  3890. sel = document.querySelector('#upload_selector');
  3891. sel.addEventListener("change", function(){
  3892. var input = this;
  3893. function ff(file){
  3894. return function(e){
  3895. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3896. blob.name = file.name;
  3897. AddImageFile(blob);
  3898. }
  3899. }
  3900. for(i=0;i<input.files.length;i++){
  3901. if(input.files[i].size){
  3902. let reader = new FileReader();
  3903. reader.onload = ff(input.files[i]);
  3904. reader.readAsArrayBuffer(input.files[i]);
  3905. }
  3906. }
  3907. });
  3908. function generateUID() {
  3909. var firstPart = (Math.random() * 46656) | 0;
  3910. var secondPart = (Math.random() * 46656) | 0;
  3911. firstPart = ("000" + firstPart.toString(36)).slice(-3);
  3912. secondPart = ("000" + secondPart.toString(36)).slice(-3);
  3913. return firstPart + secondPart;
  3914. }
  3915. document.onpaste = pastehandler;
  3916. function dropHandler(ev) {
  3917. put = document.querySelector("#_uploader");
  3918. if(put) ShowSideUploader();
  3919. bkg=document.querySelector('#dropping_background');
  3920. bkg.style.display="none";
  3921. console.log('File(s) dropped');
  3922. ev.preventDefault();ev.stopPropagation();
  3923. if (ev.dataTransfer && ev.dataTransfer.items) {
  3924. for (var i = 0; i < ev.dataTransfer.items.length; i++) {
  3925. if (ev.dataTransfer.items[i].kind === 'file') {
  3926. var file = ev.dataTransfer.items[i].getAsFile();
  3927. function ff(file){
  3928. return function(e){
  3929. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3930. blob.name = file.name;
  3931. AddImageFile(blob);
  3932. }
  3933. }
  3934. if(file){
  3935. let reader = new FileReader();
  3936. reader.onload = ff(file);
  3937. reader.readAsArrayBuffer(file);
  3938. }
  3939. }
  3940. }
  3941. } else {
  3942. for (var i = 0; i < ev.dataTransfer.files.length; i++) {
  3943. function ff(file){
  3944. return function(e){
  3945. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3946. blob.name = file.name;
  3947. AddImageFile(blob);
  3948. }
  3949. }
  3950. if(ev.dataTransfer.files[i].size){
  3951. let reader = new FileReader();
  3952. reader.onload = ff(ev.dataTransfer.files[i]);
  3953. reader.readAsArrayBuffer(ev.dataTransfer.files[i]);
  3954. }
  3955. }
  3956. }
  3957. }
  3958. function dragOverHandler(ev) {
  3959. bkg=document.querySelector('#dropping_background');
  3960. bkg.style.display="";
  3961. console.log('File(s) in drop zone');
  3962. ev.preventDefault();
  3963. }
  3964. </script>
  3965. <?php
  3966. }
  3967. function CanShowGallery(&$g){
  3968. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($g['experimental']) && $g['experimental']) return false;
  3969. return true;
  3970. }
  3971. function CanShowImage(&$im){
  3972. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($im['galleries']) && isset($im['galleries'][0])) foreach($im['galleries'] as $ga){
  3973. if(($g=$this->GetGallery($ga)) && isset($g['experimental']) && $g['experimental']) return false;
  3974. }
  3975. if(isset($this->WayBack) && substr($im['name'],0,14)>$this->WayBack) return false;
  3976. return true;
  3977. }
  3978. function GetImageBatch($from,$show_all){
  3979. if(!isset($_GET['gallery'])) return;
  3980. $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){$name=$_GET['gallery'];}
  3981. $reached=0; $count=0;
  3982. if(isset($this->Images[0])) foreach($this->Images as $im){
  3983. if(isset($from)&&!$reached){ if($from==$im['name']){ $reached=1; } continue; }
  3984. if(!$this->CanShowImage($im)){ continue; }
  3985. if($_GET['gallery']=='trash') $name='trash';
  3986. if($_GET['gallery']!='main'){ if(!isset($im['galleries']) || !in_array($name, $im['galleries'])) continue;} ?>
  3987. <div class='p_thumb<?=isset($im['parent'])?" p_thumb_narrow":""?>'>
  3988. <?php if($this->LoggedIn){ ?>
  3989. <div class="post_menu_button _select_hook white" onclick='ToggleSelectImage(this, "<?=$im["name"]?>")'>●</div>
  3990. <?php } ?>
  3991. <a href='?show_image=<?=$im['name']?>' target='_blank' onclick='event.preventDefault();'>
  3992. <?php if(isset($im['video']) && $im['video']!=""){ ?>
  3993. <video data-imgsrc='<?=$im["name"]?>'><source src='<?=$im['file']?>' type='<?=$im['video']?>'></video>
  3994. <?php }else{ ?>
  3995. <img src='<?=$im['thumb']?>' data-imgsrc='<?=$im["name"]?>'
  3996. <?=isset($im['product'])?'data-product="'.$im["product"].'"':""?>
  3997. <?=isset($im['parent'])?'data-parent="'.$im["parent"].'"':""?>
  3998. <?=isset($im['align'])?'data-align="'.$im["align"].'" style="object-position:'.$im['align'].';"':""?>/>
  3999. <?php } ?>
  4000. </a>
  4001. </div>
  4002. <?php $count+=isset($im['parent'])?0:1; if((!$show_all)&&($count>=$this->GalleryStep)){ break; }
  4003. }
  4004. if($count<$this->GalleryStep){ ?><div style='display:none'>END_GALLERY</div><?php return 0; }
  4005. return 1;
  4006. }
  4007. function MakeGallerySection(){
  4008. if(!isset($_GET['gallery'])) return;
  4009. $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){ $name=$_GET['gallery'];}
  4010. $show_all=0; if(isset($_GET['show_all']) && $_GET['show_all']!='0'){ $show_all=1; } ?>
  4011. <script>
  4012. document.title+=" | <?=$this->T('画廊')?>";
  4013. </script>
  4014. <div class='center_wide' id='div_center' style='position:relative;'><br class='hidden_on_print' />
  4015. <h2><?=(isset($name) && ($gal=$this->GetGallery($name))!=NULL)?
  4016. ("<span class='gray album_hint'>".$this->T('相册').":</span>".$this->T($name)):
  4017. ($_GET['gallery']=='trash'?$this->T('垃圾桶'):$this->T('画廊'))?></h2>
  4018. <?php $description=(isset($gal) && isset($gal['description']))?$gal['description']:null; ?>
  4019. <div class='hidden_on_desktop'>
  4020. <?=$this->T('前往')?>
  4021. <select id="gallery_go_to" onchange="window.location.href='?gallery='+this.value;">
  4022. <optgroup label="<?=$this->T('精选')?>">
  4023. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4024. if(!isset($g['featured']) || !$g['featured'] ||
  4025. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  4026. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  4027. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  4028. <?php } ?></optgroup><optgroup label="<?=$this->T('其他相册')?>">
  4029. <option value="main" <?=$_GET['gallery']=='main'?"selected":""?>>[<?=$this->T('全部')?>]</option>
  4030. <?php if($this->LoggedIn){ ?>
  4031. <option value="trash" <?=$_GET['gallery']=='trash'?"selected":""?>>[<?=$this->T('垃圾桶')?>]</option>
  4032. <?php } ?>
  4033. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4034. if((isset($g['featured']) && $g['featured']) ||
  4035. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  4036. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  4037. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  4038. <?php } ?></optgroup>
  4039. </select>
  4040. </div>
  4041. <?php if($this->LoggedIn){?>
  4042. <div>
  4043. <?php if(isset($name)){ ?>
  4044. <div style='text-align:right;position:absolute;right:0;top:0;width:100%;' class='invert_a smaller hidden_on_print'>
  4045. <a href='javascript:ShowDeleteMenu();'><?=$this->T('删除相册')?></a><br />
  4046. <?php if(isset($gal['featured']) && $gal['featured']!=false){ ?>
  4047. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=false'>
  4048. <?=$this->T('取消精选')?></a>
  4049. <?php }else{ ?>
  4050. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=true'>
  4051. <?=$this->T('设为精选')?></a>
  4052. <?php } ?><br />
  4053. <?php if(isset($gal['experimental']) && $gal['experimental']!=false){ ?>
  4054. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=false'>
  4055. <?=$this->T('取消实验')?></a>
  4056. <?php }else{ ?>
  4057. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=true'>
  4058. <?=$this->T('设为实验')?></a>
  4059. <?php } ?>
  4060. <div class='pop_menu invert_a' id='gallery_delete_menu' style='display:none;'>
  4061. <div style='float:left;' class='gray'><?=$this->T('该操作不删除图片。')?></div>
  4062. <a href='javascript:HidePopMenu();'>×</a>
  4063. <hr />
  4064. <a href='?gallery=main&gallery_edit_delete=<?=$_GET['gallery']?>'><b><?=$this->T('删除相册')?></b></a>
  4065. </div>
  4066. </div>
  4067. <?php } ?>
  4068. <?php $this->MakeUploader(false); ?>
  4069. <div style='text-align:right;position:relative;' class='invert_a smaller hidden_on_print'>
  4070. <div style='position:relative'>
  4071. <?php if(isset($name)){ ?>
  4072. <a href='javascript:ShowGalleryEditMenu("<?=$name?>",null)'><?=$this->T('改名')?></a>
  4073. <a href='javascript:ShowGalleryEditMenu("<?=$name?>","<?=$description?>")'><?=$this->T('描述')?></a>
  4074. <?php } ?>
  4075. <a href='javascript:ShowGalleryEditMenu(null,null)'><?=$this->T('添加')?></a>
  4076. <div class='pop_menu invert_a' id='gallery_edit_menu' style='display:none;max-width:90%;'>
  4077. <form action="<?=$_SERVER['REQUEST_URI']?>&edit_gallery=true"
  4078. method="post" style='display:none;' id='gallery_edit_form'></form>
  4079. <a style='float:left;'><?=$this->T('设置为:')?></a>
  4080. <a href='javascript:HidePopMenu();'>×</a>
  4081. <input type='text' form='gallery_edit_form' name='gallery_edit_new_name' id='gallery_edit_new_name' style='width:10em;'>
  4082. <input type='text' form='gallery_edit_form' name='gallery_edit_old_name' id='gallery_edit_old_name' style='display:none'>
  4083. <input type='text' form='gallery_edit_form' name='gallery_edit_description' id='gallery_edit_description' style='width:10em;display:none'>
  4084. <input class='button' type='submit' form='gallery_edit_form'
  4085. name='gallery_edit_confirm' id='gallery_edit_confirm' value='<?=$this->T('确认')?>'>
  4086. </div>
  4087. </div>
  4088. </div>
  4089. <div class='smaller hidden_on_print'>
  4090. <form action="<?=$_SERVER['REQUEST_URI']?>"
  4091. method="post" style='display:none;' id='gallery_move_form'></form>
  4092. <input type='text' form='gallery_move_form' name='gallery_move_ops'
  4093. id='gallery_move_ops' style='display:none'>
  4094. <p><?=$this->T('选择了')?> <span id='gallery_selected_count'>0</span> <?=$this->T('个图片。')?>
  4095. <a href='javascript:ClearSelectedImages()'><?=$this->T('清除')?></a></p>
  4096. <p><?=$this->T('添加到')?>
  4097. <select id="gallery_move_to">
  4098. <option value="trash"><?=$this->T('垃圾桶')?></option>
  4099. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  4100. <option value="<?=$g['name']?>"><?=$this->T($g['name'])?></option>
  4101. <?php } ?>
  4102. </select>
  4103. <a href='javascript:AddToGallery()'><?=$this->T('执行')?></a>
  4104. </p>
  4105. <p>
  4106. <?=$this->T('或者')?><a href='javascript:RemoveFromGallery()'><?=$this->T('从相册移除')?></a>
  4107. </p>
  4108. </div>
  4109. </div>
  4110. <?php } $desc=isset($description)?$this->GetPost($description):null;
  4111. if(isset($desc)){ ?><ul class='print_column list'><br /><?php
  4112. $this->MakeSinglePost($desc, false, false, false, false, false, false, false, false, true, false);
  4113. ?></ul><?php } ?>
  4114. <br />
  4115. <div><div class='p_row'><?php $has_more=$this->GetImageBatch(NULL, $show_all);?>
  4116. <div class='p_thumb p_thumb_end' <?=$has_more?"onclick='ThisGetMore(this);'":""?>>
  4117. <a onclick='event.preventDefault();' href='index.php?gallery=<?=$_GET['gallery']?>&show_all=1'>
  4118. <h2 id="btn_more_images"><?=$has_more?$this->T("查看更多"):$this->T("没有更多的了");?></a></h2></div></div>
  4119. </div>
  4120. </div>
  4121. <script type='text/javascript'>
  4122. function ThisGetMore(end_ui){
  4123. var xhr = new XMLHttpRequest();
  4124. xhr.onreadystatechange = function() {
  4125. if (this.readyState == 4 && this.status == 200) {
  4126. doc = document.createElement("div"); doc.innerHTML=xhr.responseText.trim(); next_child=null;
  4127. for(child=doc.firstChild; child!==null; child=next_child) { next_child=child.nextSibling; end_ui.parentNode.insertBefore(child,end_ui); }
  4128. doc.remove();
  4129. if(xhr.responseText.search('END_GALLERY')>=0){ end_ui.onclick=null; end_ui.innerHTML="<h2><?=$this->T("没有更多的了");?></h2>"; }
  4130. UpdateImageClickables();
  4131. btn=document.getElementById("btn_more_images"); if(btn) btn.innerText="<?=$this->T("查看更多");?>";
  4132. }
  4133. };
  4134. btn=document.getElementById("btn_more_images"); if(btn) btn.innerText="<?=$this->T("稍等");?>";
  4135. im=end_ui.previousElementSibling.querySelector('img,video');
  4136. from=im?im.dataset.imgsrc:null; if(!from) return;
  4137. const urlParams = new URLSearchParams(window.location.search); const gallery = urlParams.get('gallery')
  4138. xhr.open("GET", "index.php?gallery_continue="+from+'&gallery='+gallery, true);
  4139. xhr.send();
  4140. }
  4141. <?php if($this->LoggedIn){ ?>
  4142. var selected_image = new Array();
  4143. function RemoveFromGallery(){
  4144. form = document.querySelector('#gallery_move_form');
  4145. ops = document.querySelector('#gallery_move_ops');
  4146. sel = document.querySelector('#gallery_move_to');
  4147. ops.value = "REM <?=$_GET['gallery']?>"+" "+selected_image.join(' ');
  4148. form.submit();
  4149. }
  4150. function AddToGallery(){
  4151. form = document.querySelector('#gallery_move_form');
  4152. ops = document.querySelector('#gallery_move_ops');
  4153. sel = document.querySelector('#gallery_move_to');
  4154. ops.value = "ADD "+sel.value+" "+selected_image.join(' ');
  4155. form.submit();
  4156. }
  4157. function ClearSelectedImages(){
  4158. selected_image.splice(0, selected_image.length);
  4159. checks = document.querySelectorAll('._select_hook');
  4160. [].forEach.call(checks, function(c){
  4161. c.classList.remove('p_thumb_selected');
  4162. });
  4163. count = document.querySelector('#gallery_selected_count');
  4164. count.innerHTML="0";
  4165. }
  4166. function ToggleSelectImage(elem, name){
  4167. count = document.querySelector('#gallery_selected_count');
  4168. if(selected_image.indexOf(name) == -1){ selected_image.push(name); elem.classList.add('p_thumb_selected'); }
  4169. else{ selected_image.splice(selected_image.indexOf(name), 1); elem.classList.remove('p_thumb_selected'); }
  4170. count.innerHTML=selected_image.length.toString()
  4171. }
  4172. function ShowGalleryEditMenu(old_name,desc){
  4173. m = document.querySelector('#gallery_edit_menu');
  4174. old = document.querySelector('#gallery_edit_old_name');
  4175. newname = document.querySelector('#gallery_edit_new_name');
  4176. description = document.querySelector('#gallery_edit_description');
  4177. m.style.display='block';
  4178. if(desc!==null){ description.style.display='block';newname.style.display='none';description.value=desc;}
  4179. else{ description.style.display='none';newname.style.display='';}
  4180. if(old_name!=''){ old.value=old_name; newname.value=old.value; }else{ old.value=''; }
  4181. }
  4182. function ShowDeleteMenu(){
  4183. m=document.querySelector('#gallery_delete_menu');
  4184. m.style.display='block';
  4185. }
  4186. <?php } ?>
  4187. </script>
  4188. <?php
  4189. }
  4190. function MakeGalleryLeft(){?>
  4191. <div class='left hidden_m gallery_left' id='div_left'><div><br /></div>
  4192. <h2><?=$this->T('相册')?></h2>
  4193. <div>
  4194. <span class='gray smaller bold'><?=$this->T('精选')?><hr> </span>
  4195. <ul>
  4196. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4197. if(!isset($g['featured']) || !$g['featured'] || !$this->CanShowGallery($g)){ continue; } ?>
  4198. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4199. <li class='<?=$_GET['gallery']==$g['name']?'selected':""?>'>
  4200. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4201. <?php } ?>
  4202. </ul>
  4203. <div class='smaller'><span class='gray'><?=$this->T('其他相册')?><hr></span><ul>
  4204. <a href='?gallery=main' onclick='ShowWaitingBar()'>
  4205. <li class='<?=$_GET['gallery']=='main'?' selected':""?>'>[<?=$this->T('全部图片')?>]</li></a>
  4206. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4207. if((isset($g['featured']) && $g['featured']) || !$this->CanShowGallery($g)){ continue; } ?>
  4208. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4209. <li class='<?=$_GET['gallery']==$g['name']?' selected':""?>'>
  4210. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4211. <?php } ?>
  4212. <?php if($this->LoggedIn){ ?>
  4213. <a href='?gallery=trash' onclick='ShowWaitingBar()'>
  4214. <li class='<?=$_GET['gallery']=='trash'?' selected':""?>'>[<?=$this->T('垃圾桶')?>]</li></a>
  4215. <?php } ?>
  4216. </ul></div>
  4217. <p>&nbsp;</p>
  4218. <script>
  4219. </script>
  4220. </div>
  4221. </div>
  4222. <?php
  4223. }
  4224. function MakeStatistics(){
  4225. $this->ReadPosts(); $this->ReadImages(); $this->ReadArchive();
  4226. $list=[]; $last_date=null; $info=[]; $info['count']=0; $info['edits']=0; $info['length']=0;
  4227. $imlist=[]; $imlast_date=null; $iminfo=[]; $iminfo['count']=0;
  4228. $maxposts=0; $maxlength=0; $maximages=0;
  4229. foreach($this->Posts as &$p){ $is_ref=0;
  4230. $this_date=substr($p['id'],0,8);
  4231. if($last_date!=null && $last_date!=$this_date){
  4232. if($maxposts<$info['count']+$info['edits'])$maxposts=$info['count']+$info['edits'];
  4233. if($maxlength<$info['length'])$maxlength=$info['length'];
  4234. $list[]=$info; $info=[]; $info['count']=0; $info['edits']=0; $info['length']=0;
  4235. }
  4236. $ah = &$this->GetArchiveHandle($p['id']); if(isset($ah)&&isset($ah['list'][0])) $info['edits']+=count($ah['list']);
  4237. $info['count']++; $info['id']=$this_date; if(isset($p['content']))$info['length']+=strlen($p['content']); $last_date=$this_date;
  4238. }
  4239. $last_date=null;
  4240. foreach($this->Images as &$im){ $is_ref=0;
  4241. $this_date=substr($im['name'],0,8);
  4242. if($last_date!=null && $last_date!=$this_date){
  4243. if($maximages<$iminfo['count'])$maximages=$iminfo['count'];
  4244. $imlist[]=$iminfo; $iminfo=[]; $iminfo['count']=0;
  4245. }
  4246. $iminfo['count']++; $iminfo['id']=$this_date; $last_date=$this_date;
  4247. }
  4248. if($info!=[]) $list[]=$info;
  4249. if($iminfo!=[]) $imlist[]=$iminfo;
  4250. if(!isset($list[0])) return;
  4251. $earliest=DateTimeImmutable::createFromFormat('!Ymd',$list[0]['id']); $ey=substr($list[0]['id'],0,4);
  4252. $latest=DateTimeImmutable::createFromFormat('!Ymd',end($list)['id']); $ly=substr(end($list)['id'],0,4);
  4253. $days=$earliest->diff($latest)->days; $lw=2.0; $dw=$days*$lw; $spw=20;
  4254. ?>
  4255. <style>.stastics_posts{direction:ltr;} .stastics_posts line,.stastics_posts circle{stroke:#f8ca9b; stroke-width:2px;}
  4256. .stastics_posts .line_edits{stroke:#f8ca9b40;}
  4257. .stastics_posts .line_year{stroke:#f8ca9b30; stroke-width:2px;} .stastics_posts text{fill:#f8ca9ba0; font: 0.9em serif;}
  4258. </style>
  4259. <div class='settings'><h2><?=$this->T('统计')?></h2><br />
  4260. <div style="overflow:auto;direction:rtl;width:100%;">
  4261. <svg class='stastics_posts' viewBox="-<?=$spw?> -<?=$spw?> <?=$days*$lw+$spw*6?> <?=200+4*$spw?>" height="<?=200+4*$spw?>" width="<?=$days*$lw+$spw*6?>">
  4262. <?php foreach($list as $info){ $itv=DateTimeImmutable::createFromFormat('!Ymd',$info['id'])->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);
  4263. $p1=100.0*(1-$info['count']/$maxposts); $p2=$p1-100.0*$info['edits']/$maxposts;
  4264. $p3=100.0*$info['length']/$maxlength+$spw+100; ?>
  4265. <line x1="<?=$ds?>" x2="<?=$ds?>" y1="100.0" y2="<?=$p1?>"/>
  4266. <?php if($info['edits']>0){ ?><line class='line_edits' x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=$p1?>" y2="<?=$p2?>"/><?php } ?>
  4267. <?php if($info['length']>0){ ?><line class='line_edits' x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=$spw+100?>" y2="<?=$p3?>"/><?php } ?>
  4268. <?php } ?>
  4269. <?php foreach($imlist as $im){ $itv=DateTimeImmutable::createFromFormat('!Ymd',$im['id'])->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);
  4270. $p1=100+$spw+100.0*($im['count']/$maximages); ?>
  4271. <circle cx="<?=$ds?>" cy="<?=$p1?>" r='3'/>
  4272. <?php } ?>
  4273. <?php for($y=$ey;$y<=$ly;$y++){ $itv=DateTimeImmutable::createFromFormat('!Y',$y)->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);?>
  4274. <line x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=220+$spw?>" y2="-<?=$spw?>" class='line_year'/>
  4275. <text x="<?=$ds+4?>" y="-4"><?=$y?></text>
  4276. <text x="<?=$ds+4?>" y="<?=$spw*2+200-4?>"><?=$y?></text>
  4277. <?php for($ym=1;$ym<=12;$ym++){ $st=str_pad($ym,2,'0',STR_PAD_LEFT); $itv2=DateTimeImmutable::createFromFormat('!Ym',$y.$st)->diff($earliest);
  4278. $dds=$lw/2+$lw*$itv2->days*($itv2->invert?1:-1); if($dds<0||$dds>$lw/2+$dw) continue; ?>
  4279. <line x1="<?=$dds?>" x2="<?=$dds?>" y1="<?=100+$spw?>" y2="100" class='line_year'/>
  4280. <text x="<?=$dds+4?>" y="<?=100+$spw-3?>"><?=$ym?></text>
  4281. <?php } } ?>
  4282. <line x1="<?=$lw/2+$dw?>" x2="<?=$days*$lw?>" y1="<?=220+$spw?>" y2="-<?=$spw?>" class='line_year'/>
  4283. <line x1="0" x2="<?=$dw?>" y1="0" y2="0" class='line_year'/>
  4284. <line x1="0" x2="<?=$dw?>" y1="100" y2="100" class='line_year'/>
  4285. <line x1="0" x2="<?=$dw?>" y1="<?=100+$spw?>" y2="<?=100+$spw?>" class='line_year'/>
  4286. <line x1="0" x2="<?=$dw?>" y1="<?=200+$spw?>" y2="<?=200+$spw?>" class='line_year'/>
  4287. <text x="<?=$dw+10?>" y="8"><?=$maxposts?></text>
  4288. <text x="<?=$dw+10?>" y="<?=$spw+8?>"><tspan style='fill:#f8ca9b;'>▪ <?=$this->T('新增')?></tspan></text>
  4289. <text x="<?=$dw+10?>" y="<?=$spw*2+8?>"><tspan style='fill:#f8ca9ba0;'>▪ <?=$this->T('改动')?></tspan></text>
  4290. <text x="<?=$dw+10?>" y="<?=$spw*2+200-4?>"><?=$maxlength?></text>
  4291. <text x="<?=$dw+10?>" y="<?=$spw+200-4?>"><tspan style='fill:#f8ca9b;'><?=$maximages?></tspan></text>
  4292. <text x="<?=$dw+10?>" y="<?=200-4?>"><tspan style='fill:#f8ca9b;'>▪ <?=$this->T('媒体')?></text>
  4293. <text x="<?=$dw+10?>" y="<?=200-4-$spw?>">▪ <?=$this->T('长度')?></tspan></text>
  4294. </svg></div>
  4295. <br /><br />
  4296. </div>
  4297. <?php
  4298. }
  4299. function MakeSettings(){?>
  4300. <div class='settings'>
  4301. <h2><?=$this->T('设置')?></h2>
  4302. <table style='white-space:nowrap;'>
  4303. <?php if($this->LoggedIn){ ?>
  4304. <form action="index.php?settings=true" method="post" style='display:none;' id='settings_form'></form>
  4305. <colgroup><col style='min-width:5em;'><col style='width:100%;min-width:5em;'></colgroup>
  4306. <thead><tr><td><?=$this->T('选项')?></td><td><?=$this->T('值')?></td></tr></thead>
  4307. <tr><td><?=$this->T('网站标题')?></td>
  4308. <td><input type="text" form="settings_form" id='settings_title' name='settings_title'
  4309. value='<?=$this->Title?>'/></td></tr>
  4310. <tr><td><?=$this->T('短标题')?></td>
  4311. <td><input type="text" form="settings_form" id='settings_short_title' name='settings_short_title'
  4312. value='<?=$this->ShortTitle?>'/></td></tr>
  4313. <tr><td><?=$this->T('显示名称')?></td>
  4314. <td><input type="text" form="settings_form" id='settings_display_name' name='settings_display_name'
  4315. value='<?=$this->DisplayName?>'/></td></tr>
  4316. <tr><td><?=$this->T('电子邮件')?></td>
  4317. <td><input type="text" form="settings_form" id='settings_email' name='settings_email'
  4318. value='<?=$this->EMail?>'/></td></tr>
  4319. <tr><td><?=$this->T('导航栏')?>
  4320. <?=isset($this->SpecialNavigation)?"<a href='?post=".$this->SpecialNavigation."'>→</a>":""?></td>
  4321. <td><input type="text" form="settings_form" id='settings_special_navigation' name='settings_special_navigation'
  4322. value='<?=$this->SpecialNavigation?>'/></td></tr>
  4323. <tr><td><?=$this->T('侧边栏')?>
  4324. <?=isset($this->SpecialSidebar)?"<a href='?post=".$this->SpecialSidebar."'>→</a>":""?></td>
  4325. <td><input type="text" form="settings_form" id='settings_special_sidebar' name='settings_special_sidebar'
  4326. value='<?=$this->SpecialSidebar?>'/></td></tr>
  4327. <tr><td><?=$this->T('脚注')?> 1<?=isset($this->SpecialFooter)?"<a href='?post=".$this->SpecialFooter."'>→</a>":""?></td>
  4328. <td><input type="text" form="settings_form" id='settings_special_footer' name='settings_special_footer'
  4329. value='<?=$this->SpecialFooter?>'/></td></tr>
  4330. <tr><td><?=$this->T('脚注')?> 2<?=isset($this->SpecialFooter2)?"<a href='?post=".$this->SpecialFooter2."'>→</a>":""?></td>
  4331. <td><input type="text" form="settings_form" id='settings_special_footer2' name='settings_special_footer2'
  4332. value='<?=$this->SpecialFooter2?>'/></td></tr>
  4333. <tr><td><?=$this->T('置顶文')?><?=isset($this->SpecialPinned)?"<a href='?post=".$this->SpecialPinned."'>→</a>":""?></td>
  4334. <td><input type="text" form="settings_form" id='settings_special_pinned' name='settings_special_pinned'
  4335. value='<?=$this->SpecialPinned?>'/></td></tr>
  4336. <tr><td><?=$this->T('默认相册')?></td>
  4337. <td><input type="text" form="settings_form" id='settings_default_gallery' name='settings_default_gallery'
  4338. value='<?=$this->DefaultGallery?>'/></td></tr>
  4339. <tr><td><?=$this->T('相册单步')?></td>
  4340. <td><input type="text" form="settings_form" id='settings_gallery_step' name='settings_gallery_step'
  4341. value='<?=$this->GalleryStep?>'/></td></tr>
  4342. <tr><td><?=$this->T('SelfAuth 路径')?></td>
  4343. <td><input type="text" form="settings_form" id='settings_selfauth_path' name='settings_selfauth_path'
  4344. value='<?=$this->SelfAuthPath?>'/></td></tr>
  4345. <tr><td><?=$this->T('启用评论')?></td>
  4346. <td><input type="checkbox" id="settings_enable_comments" name="settings_enable_comments"
  4347. form="settings_form" <?=$this->CommentEnabled?"checked":""?>/></td></tr>
  4348. <tr><td><?=$this->T('附加操作')?></td><td><a class='gray' href='index.php?extras=true'><?=$this->T('进入')?></a></td></tr>
  4349. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4350. <tr><td class='smaller gray'><?=$this->T('长毛象')?></td></tr>
  4351. <tr><td><?=$this->T('长毛象实例')?></td>
  4352. <td><input type="text" form="settings_form" id='settings_mastodon_url' name='settings_mastodon_url'
  4353. value='<?=$this->MastodonURL?>'/></td></tr>
  4354. <tr><td><?=$this->T('长毛象令牌')?></td>
  4355. <td><input type="text" form="settings_form" id='settings_mastodon_token' name='settings_mastodon_token'
  4356. value='<?=$this->MastodonToken?>'/></td></tr>
  4357. <tr><td><?=$this->T('偏好语言')?></td>
  4358. <td><input type="text" form="settings_form" id='settings_mastodon_lang' name='settings_mastodon_lang'
  4359. value='<?=$this->MastodonPreferredLang?>'/></td></tr>
  4360. <tr><td><?=$this->T('本站地址')?></td>
  4361. <td><input type="text" form="settings_form" id='settings_host_url' name='settings_host_url'
  4362. value='<?=$this->HostURL?>'/></td></tr>
  4363. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4364. <tr><td class='smaller gray'><?=$this->T('Activity Pub')?></td></tr>
  4365. <tr><td><?=$this->T('用户名')?></td>
  4366. <td><input type="text" form="settings_form" id='settings_apub_id' name='settings_apub_id'
  4367. value='<?=$this->APubID?>'/></td></tr>
  4368. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4369. <tr><td class='smaller gray'><?=$this->T('这里访问')?></td></tr>
  4370. <tr><td><?=$this->T('主机')?></td>
  4371. <td><input type="text" form="settings_form" id='settings_here_host' name='settings_here_host'
  4372. value='<?=$this->HereHost?>'/></td></tr>
  4373. <tr><td><?=$this->T('网站标题')?></td>
  4374. <td><input type="text" form="settings_form" id='settings_here_title' name='settings_here_title'
  4375. value='<?=$this->HereTitle?>'/></td></tr>
  4376. <tr><td><?=$this->T('短标题')?></td>
  4377. <td><input type="text" form="settings_form" id='settings_here_short_title' name='settings_here_short_title'
  4378. value='<?=$this->HereShortTitle?>'/></td></tr>
  4379. <tr><td><?=$this->T('相册')?></td>
  4380. <td><input type="text" form="settings_form" id='settings_here_album' name='settings_here_album'
  4381. value='<?=$this->HereAlbum?>'/></td></tr>
  4382. <tr><td><?=$this->T('导航栏')?>
  4383. <?=isset($this->HereNavigation)?"<a href='?post=".$this->HereNavigation."'>→</a>":""?></td>
  4384. <td><input type="text" form="settings_form" id='settings_here_navigation' name='settings_here_navigation'
  4385. value='<?=$this->HereNavigation?>'/></td></tr>
  4386. <tr><td><?=$this->T('脚注')?><?=isset($this->HereFooter)?"<a href='?post=".$this->HereFooter."'>→</a>":""?></td>
  4387. <td><input type="text" form="settings_form" id='settings_here_footer' name='settings_here_footer'
  4388. value='<?=$this->HereFooter?>'/></td></tr>
  4389. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4390. <tr><td class='smaller gray'><?=$this->T('实验访问')?></td></tr>
  4391. <tr><td><?=$this->T('主机')?></td>
  4392. <td><input type="text" form="settings_form" id='settings_exp_host' name='settings_exp_host'
  4393. value='<?=$this->ExpHost?>'/></td></tr>
  4394. <tr><td><?=$this->T('网站标题')?></td>
  4395. <td><input type="text" form="settings_form" id='settings_exp_title' name='settings_exp_title'
  4396. value='<?=$this->ExpTitle?>'/></td></tr>
  4397. <tr><td><?=$this->T('短标题')?></td>
  4398. <td><input type="text" form="settings_form" id='settings_exp_short_title' name='settings_exp_short_title'
  4399. value='<?=$this->ExpShortTitle?>'/></td></tr>
  4400. <tr><td><?=$this->T('首次提示')?><?=isset($this->ExpCaution)?"<a href='?post=".$this->ExpCaution."'>→</a>":""?></td>
  4401. <td><input type="text" form="settings_form" id='settings_exp_caution' name='settings_exp_caution'
  4402. value='<?=$this->ExpCaution?>'/></td></tr>
  4403. <tr><td><?=$this->T('相册')?></td>
  4404. <td><input type="text" form="settings_form" id='settings_exp_album' name='settings_exp_album'
  4405. value='<?=$this->ExpAlbum?>'/></td></tr>
  4406. <tr><td><?=$this->T('导航栏')?>
  4407. <?=isset($this->ExpNavigation)?"<a href='?post=".$this->ExpNavigation."'>→</a>":""?></td>
  4408. <td><input type="text" form="settings_form" id='settings_exp_navigation' name='settings_exp_navigation'
  4409. value='<?=$this->ExpNavigation?>'/></td></tr>
  4410. <tr><td><?=$this->T('脚注')?><?=isset($this->ExpFooter)?"<a href='?post=".$this->ExpFooter."'>→</a>":""?></td>
  4411. <td><input type="text" form="settings_form" id='settings_exp_footer' name='settings_exp_footer'
  4412. value='<?=$this->ExpFooter?>'/></td></tr>
  4413. <tr><td><?=$this->T('允许选择语言')?>
  4414. <td><input type="checkbox" id="settings_allow_language" name="settings_allow_language"
  4415. form="settings_form" <?=$this->AllowLanguageChoices?"checked":""?>/></td></tr>
  4416. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4417. <tr><td class='smaller gray'><?=$this->T('管理员')?></td><td class='smaller'>
  4418. <a href='index.php?logout=true'><?=$this->T('登出')?></a></td></tr>
  4419. <tr><td><?=$this->T('帐号')?></td>
  4420. <td><input type="text" form="settings_form" id='settings_id' name='settings_id'
  4421. value='<?=$this->Admin?>'/></td></tr>
  4422. <tr><td><?=$this->T('新密码')?></td>
  4423. <td><input type="password" form="settings_form"
  4424. id='settings_new_password' name='settings_new_password' /></td></tr>
  4425. <tr><td><?=$this->T('再次输入')?></td>
  4426. <td><input type="password" form="settings_form"
  4427. id='settings_new_password_redo' name='settings_new_password_redo' /></td></tr>
  4428. <tr><td><?=$this->T('旧密码')?></td>
  4429. <td><input type="password" form="settings_form" id='settings_old_password' name='settings_old_password' /></td></tr>
  4430. <?php }else{ ?>
  4431. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='login_form'></form>
  4432. <colgroup><col style='min-width:3em;'><col style='width:100%;min-width:5em;'></colgroup>
  4433. <tr><td class='smaller gray'><?=$this->T('请登录')?></td></tr>
  4434. <tr><td><?=$this->T('帐号')?></td>
  4435. <td><input type="text" form="login_form" id='login_id' name='login_id' /></td></tr>
  4436. <tr><td><?=$this->T('密码')?></td>
  4437. <td><input type="password" form="login_form" id='login_password' name='login_password' /></td></tr>
  4438. <?php } ?>
  4439. </table>
  4440. <?php if($this->LoggedIn){ ?>
  4441. <input class='button' form="settings_form" type="submit" name='settings_button' value='<?=$this->T('保存设置')?>' />
  4442. <?php }else{ ?>
  4443. <input class='button' form="login_form" type="submit" name='login_button' value='<?=$this->T('登录')?>' />
  4444. <?php } ?>
  4445. </div>
  4446. <?php
  4447. }
  4448. function MakeExtraOperations(){?>
  4449. <div class='settings' style='overflow:auto;'>
  4450. <h2><?=$this->T('附加操作')?></h2>
  4451. <a href='index.php?&settings=true'><?=$this->T('返回一般设置')?></a>
  4452. <p>&nbsp;</p>
  4453. <h3><?=$this->T('自动重定向')?></h3>
  4454. <span class='smaller gray'>
  4455. <?=$this->T('P为帖子跳转,匹配REQUEST_URI跳到目标文章;S为站点跳转,可以重定向来源域名,例子:')?>
  4456. <br /><pre>P discount:20001001010101;<br />S old_domain:www.new_domain.com:20001001010101;</pre></span>
  4457. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form2'></form>
  4458. <textarea id="settings_redirect" name="settings_redirect" rows="3" class='full_box' wrap="off"
  4459. form='settings_form2'><?=$this->DisplayRedirectConfig()?></textarea>
  4460. <input class='button' form="settings_form2" type="submit" name='settings_save_redirect'
  4461. value='<?=$this->T('保存重定向设置')?>' />
  4462. <p>&nbsp;</p>
  4463. <h3><?=$this->T('自定义翻译')?></h3>
  4464. <span class='smaller gray'>
  4465. <?=$this->T('填写格式:')?>
  4466. <br /><pre>- 语言 | Language</pre></span>
  4467. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form3'></form>
  4468. <textarea id="settings_translation" name="settings_translation" rows="3" class='full_box' wrap="off"
  4469. form='settings_form3'><?=$this->CustomTranslationContent?></textarea>
  4470. <input class='button' form="settings_form3" type="submit" name='settings_save_translation'
  4471. value='<?=$this->T('保存翻译')?>' />
  4472. <p>&nbsp;</p>
  4473. <p class='smaller gray'><?=$this->T('ActivityPub 测试:')?></p>
  4474. <ul>
  4475. <li><a href='index.php?TestAPubDeliver=1'><?=$this->T('测试发送')?></a></li></ui>
  4476. </ui>
  4477. <p class='smaller gray'><?=$this->T('当心!下列操作将立即执行:')?></p>
  4478. <ul>
  4479. <li><a href='index.php?rewrite_styles=true'><?=$this->T('重新写入默认CSS')?></a></li>
  4480. <li><a href='index.php?regenerate_thumbnails=true'><?=$this->T('重新生成图片缩略图')?></a></li>
  4481. <li><a href='index.php?clear_all_logins=true'><?=$this->T('删除所有登录')?>(<?=sizeof($this->LoginTokens);?>)</a></li>
  4482. </ui>
  4483. <br /><br /><br /><a href='index.php?&settings=true'><?=$this->T('返回一般设置')?></a><br />&nbsp;
  4484. </div>
  4485. <?php
  4486. }
  4487. function MakeMainBegin(){?>
  4488. <div class='main' <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  4489. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"<?php } ?>>
  4490. <?php
  4491. }
  4492. function MakeMainEnd(){?>
  4493. </div>
  4494. <?php
  4495. }
  4496. function MakeExpFooter(){
  4497. $exptitle = isset($this->HereDisplayTitle)?('"'.trim($this->T($this->ChoosePartsByLanguage($this->HereDisplayTitle))).'"'):NULL;
  4498. if(!isset($exptitle)) $exptitle=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle);?>
  4499. <div class='small_footer exp_h_f exp_f'><div>
  4500. <?php if($this->InExperimentalMode){ ?>
  4501. <b><?=$exptitle?></b>
  4502. <?php }else{ ?>
  4503. <b><?=$exptitle?></b> ©<?=$this->T($this->DisplayName)?>
  4504. <?php }?>
  4505. <?=isset($this->HereMainImage)?("<a class='invert_a' href='?here=images/".$this->HereMainImage['name']."'>".$this->T("看全图")."</a>"):""; ?>
  4506. <div class='wayback_link gray clean_a invert_a hidden_on_print'><br class="hidden_on_desktop" />
  4507. <?php if($this->InExperimentalMode && isset($this->ExpFooter) && ($p = &$this->GetPost($this->ExpFooter,true))!=NULL){
  4508. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  4509. }else if($this->InHereMode && isset($this->HereFooter) && ($p = &$this->GetPost($this->HereFooter,true))!=NULL){
  4510. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  4511. }?></div>
  4512. </div>
  4513. </div>
  4514. </div><!-- page -->
  4515. </body>
  4516. </html>
  4517. <script>
  4518. if(trans = document.getElementById('translate_button')){
  4519. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  4520. }
  4521. </script>
  4522. <?php
  4523. }
  4524. function MakeImageOverlay($side_info=null,$static_image=null,$static_video=null){
  4525. $static=isset($side_info); ?>
  4526. <div id='big_image_overlay' <?=$static?"":"style='display:none'";?>>
  4527. <div class='big_image_box clean_a' onclick='HideBigImage(1)'>
  4528. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'><?=$this->T('请稍候')?></div>
  4529. <?php if(!$static_video){ ?>
  4530. <img id='big_image' onload="HideWaitingBar();" <?=isset($static_image)?("src='".$static_image."'"):""?>/><?php } ?>
  4531. <?php if(!$static_image){ ?>
  4532. <video id='big_video' onloadstart="HideWaitingBar();" controls><source id='big_video_src' type='video/mp4'
  4533. <?=isset($static_video)?("src='".$static_video."'"):""?>></video><?php } ?>
  4534. </div>
  4535. <div class='big_side_box' onclick='HideBigImage(1);'>
  4536. <?php if(!$static){ ?>
  4537. <div class='big_image_box clean_a image_nav' onclick='HideBigImage(1)'>
  4538. <div ><a id='prev_image' class='image_nav_prev img_btn_hidden' onclick="event.stopPropagation();">
  4539. <div class='lr_buttons'>←</div></a></div>
  4540. <div ><a id='next_image' class='image_nav_next img_btn_hidden' onclick="event.stopPropagation();">
  4541. <div class='lr_buttons'>→</div></a></div>
  4542. <div id='here_buttons'></div>
  4543. </div><?php } ?>
  4544. <div class='side_box_mobile_inner'>
  4545. <?php if(!$static){ ?>
  4546. <div class='inquiry_buttons img_btn_hidden' id='inquiry_buttons' onclick="event.stopPropagation();">
  4547. <span style='display:none;' id='image_purchase' class='clean_a'>
  4548. <b><a id='image_purchase_button' target="_blank">¥<?=$this->T('购买印刷品')?></a></b>
  4549. <br class='hidden_on_desktop block_m' /></span>
  4550. <b><a class='clean_a' id='image_download'><span id='download_processing'>↓</span><?=$this->T('下载')?></a></b>
  4551. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  4552. &nbsp;<a class='clean_a' id='image_inquiry'>
  4553. <b>@</b><?=$this->T('咨询')?></a>
  4554. <?php } ?><hr class='hidden_on_desktop block_m' />
  4555. </div>
  4556. <div id='big_image_share' class='clean_a' onclick="event.stopPropagation();">
  4557. <li class='wayback_close'><a onclick='HideBigImage(1);'><?=$this->T('关闭')?> ×</a></li>
  4558. <li><a id='big_share_copy'>⎘ <?=$this->T('复制链接')?></a></li>
  4559. <hr />
  4560. </div><?php } //static ?>
  4561. <div id='big_image_info' onclick="event.stopPropagation();"><?=$static?$side_info:""?></div>
  4562. <?php if($this->LoggedIn && !$static){ ?><div id='big_image_ops' onclick="event.stopPropagation();">
  4563. <br /><?=$this->T('印刷品链接')?>
  4564. <form action="" method="post" style='display:none;' id='image_ops_form'></form>
  4565. <input type='text' id='image_ops_product_link' name='image_ops_product_link' form="image_ops_form" >
  4566. <?=$this->T('重命名')?>
  4567. <input type='text' id='image_edit_new_name' name='image_edit_new_name' form="image_ops_form" >
  4568. <?=$this->T('主图')?>
  4569. <input type='text' id='image_parent' name='image_parent' form="image_ops_form" >
  4570. <?=$this->T('对齐')?> <select id='image_align' name='image_align' form="image_ops_form">
  4571. <option value='top'><?=$this->T('顶部')?></option>
  4572. <option value='middle'><?=$this->T('中间')?></option>
  4573. <option value='bottom'><?=$this->T('底部')?></option></select><br />
  4574. <input class='button' form="image_ops_form" type="submit" name='image_button' value=<?=$this->T('保存')?> />
  4575. <br /><br /><?=$this->T('替换图像')?>
  4576. <form action="" method="post" style='display:none;' id='image_edit_form' enctype="multipart/form-data"></form>
  4577. <input type="file" form='image_edit_form'
  4578. id='big_image_upload' name='upload_file_name' accept="image/x-png,image/png,image/gif,image/jpeg"/><br />
  4579. <input class='button' form="image_edit_form" type="submit" name='image_replace_button'
  4580. value=<?=$this->T('执行')?> />
  4581. </div><?php } ?>
  4582. </div>
  4583. </div>
  4584. </div>
  4585. <?php }
  4586. function MakePageEnd(){?>
  4587. </div><!-- page -->
  4588. </body>
  4589. </html>
  4590. <?php }
  4591. function MakeFooter(&$p){ $no_title=isset($p['tid']['first']['no_title']);?>
  4592. <div class='small_footer'><div>
  4593. <hr />
  4594. <?php if(isset($p['tid']['footer'])){ ?><div class='show_on_print'><?=$p['tid']['footer'];?></div><?php } ?>
  4595. <b<?=$no_title?" class='hidden_on_print'":"";?>><?=$this->T($this->Title)?></b>
  4596. <span onclick='event.stopPropagation()'<?=$no_title?" class='hidden_on_print'":"";?>
  4597. ondblclick='javascript:window.location.href="index.php?settings=true"'>©</span><?=$this->T($this->DisplayName)?>
  4598. <div class='smaller show_on_print'><?=$_SERVER['SERVER_NAME']?><br /><?=$this->EMail?></div>
  4599. </div></div>
  4600. <div class='footer'>
  4601. <div style='white-space:nowrap;'>
  4602. <div class='footer_additional'>
  4603. <?php if(isset($this->SpecialFooter) && ($p = &$this->GetPost($this->SpecialFooter))!=NULL){
  4604. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  4605. } ?>
  4606. </div>
  4607. <div class='footer_additional'>
  4608. <?php if(isset($this->SpecialFooter2) && ($p = &$this->GetPost($this->SpecialFooter2))!=NULL){
  4609. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  4610. } ?>
  4611. </div>
  4612. </div>
  4613. </div>
  4614. <p>&nbsp;<p>
  4615. <div id='dropping_background' style='display:none;' onclick='this.style.display="none";'
  4616. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);">
  4617. <h2 style='width:100%;'><?=$this->T('上传到这里')?></h2>
  4618. </div>
  4619. <?php $this->MakeImageOverlay(); $this->MakePageEnd(); ?>
  4620. <script>
  4621. <?=$this->ExtraScripts?>
  4622. if(back = document.getElementById('button_back')){
  4623. if(document.referrer.indexOf(location.protocol + "//" + location.host) == 0){
  4624. back.href='javascript:history.back()';
  4625. }else{
  4626. back.href='index.php';
  4627. }
  4628. }
  4629. function copy_text(t) {
  4630. ta = document.createElement('textarea'); document.body.appendChild(ta); ta.value = t; ta.select();
  4631. document.execCommand("copy"); document.body.removeChild(ta);
  4632. }
  4633. if(trans = document.getElementById('translate_button')){
  4634. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  4635. }
  4636. function ClickPost(p,e,pushstate){if(e)e.preventDefault();
  4637. id=p.dataset.postId; list=p.parentNode;active=list.getElementsByClassName('active_post');
  4638. lp=p.querySelector('.lpctrl');
  4639. if(active&&active[0]&&active[0]!=p){
  4640. if(pushstate){window.history.pushState('?post='+id,null,'?post='+id);}
  4641. active[0].classList.remove('active_post'); p.classList.add('active_post');
  4642. }
  4643. }function InitLabel(){
  4644. lb=document.querySelector('#mtitle'); lb.removeAttribute('for'); lb.onclick=function()
  4645. {c=document.querySelector('#titlectrl');if(c.checked)c.checked=false;else c.checked=true;}
  4646. lb=document.querySelectorAll('.bkg_section label');if(!lb||!lb[0])return;
  4647. for(i=0;i<lb.length;i++){ lb[i].removeAttribute('for');lb[i].onclick=function()
  4648. {c=this.parentNode.querySelector('.lpctrl');if(!c)return;if(c.checked)c.checked=false;else c.checked=true;} }
  4649. }InitLabel();
  4650. <?php if($this->LoggedIn){ ?>
  4651. var Scenter = document.querySelector('#div_center');
  4652. var Sposts = Scenter?Scenter.querySelectorAll('.post'):null;
  4653. <?php if(isset($this->MastodonToken)){ ?>
  4654. function MarkPostDoneMastodon(id,mastodon_url){
  4655. for(var i=0;i<Sposts.length;i++){
  4656. if(Sposts[i].dataset.postId==id){ Sposts[i].dataset.mastodon_url= mastodon_url; break;} }
  4657. }
  4658. <?php } ?>
  4659. <?php if($this->PageType=='post' && !isset($this->WayBack)) { ?>
  4660. var Smerge_post_dialog = Scenter.querySelector('#merge_post_dialog');
  4661. var Smerge_post = Scenter.querySelector('#merge_post');
  4662. var Smerge_post_count = Smerge_post_dialog.querySelector('#merge_post_count');
  4663. var Smerge_post_btn = Scenter.querySelector('#merge_post_btn');
  4664. var Smerge_cancel = Scenter.querySelector('#merge_cancel');
  4665. var Smerge_select = Scenter.querySelector('#merge_select');
  4666. var Smerge_thread_dialog = Scenter.querySelector('#merge_thread_dialog');
  4667. var Smerge_thread = Scenter.querySelector('#merge_thread');
  4668. var Smerge_thread_target = Scenter.querySelector('#merge_thread_target');
  4669. var Smerge_thread_btn = Scenter.querySelector('#merge_thread_btn');
  4670. var select_mode = false; var merge_mode = false; var selected_posts = null;
  4671. function TogglePostSelectMode(force_on=false,force_off=false){
  4672. Scenter.classList.add('post_selecting');
  4673. if((!select_mode || force_on) && !force_off){ ToggleThreadMerge(false,true); Scenter.classList.add('post_selecting');
  4674. Smerge_post_dialog.style.display="block";Smerge_post_btn.classList.add('text_highlight');
  4675. Smerge_cancel.innerText='<?=$this->T("取消")?>'; select_mode = 1;}
  4676. else{ select_mode = 0; Scenter.classList.remove('post_selecting');
  4677. Smerge_post_dialog.style.display="none";Smerge_post_btn.classList.remove('text_highlight');
  4678. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  4679. for(var i=0;i<Sposts.length;i++){ Sposts[i].classList.remove('post_selected');
  4680. Sposts[i].onclick=select_mode?function(){TogglePostSelect(this);}:null; }
  4681. Smerge_post_count.innerText="0";
  4682. Smerge_post.href="#";
  4683. }
  4684. function TogglePostSelect(elem){
  4685. if(elem.classList.contains('post_selected')){ elem.classList.remove('post_selected'); }
  4686. else{ elem.classList.add('post_selected'); }
  4687. selected_posts = new Array();
  4688. for(var i=0;i<Sposts.length;i++){ if(Sposts[i].classList.contains('post_selected')){
  4689. selected_posts.push(Sposts[i].dataset.postId); } }
  4690. Smerge_post.href="?merge_posts="+selected_posts.join(" ");
  4691. Smerge_post_count.innerText=selected_posts.length;
  4692. }
  4693. function ThreadMergeInput(elem){
  4694. if(elem.value.match(/[0-9]{14}/)) { Smerge_thread.href="?merge_threads=<?=$this->ActualPostID?> "+elem.value; }
  4695. else{ Smerge_thread.href="#"; }
  4696. }
  4697. function ToggleThreadMerge(force_on=false,force_off=false){
  4698. if((!merge_mode || force_on) && !force_off){ TogglePostSelectMode(false,true);
  4699. Smerge_thread_dialog.style.display="block";Smerge_thread_btn.classList.add('text_highlight');
  4700. Smerge_cancel.innerText='<?=$this->T("取消")?>'; merge_mode = 1;}
  4701. else{ merge_mode = 0;
  4702. Smerge_thread_dialog.style.display="none";Smerge_thread_btn.classList.remove('text_highlight');
  4703. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  4704. Smerge_thread.href="#";
  4705. Smerge_thread_target.value='';
  4706. }
  4707. <?php } ?>
  4708. function ShowSideUploader(){
  4709. ShowRightSide(true,null);
  4710. put = document.querySelector("#_uploader");
  4711. put.style.display='block';
  4712. RefreshSideGallery();
  4713. }
  4714. dmark = document.querySelector("#mark_details");
  4715. drename = document.querySelector("#rename_details");
  4716. dmastodon = document.querySelector("#mastodon_details");
  4717. drename_form = document.querySelector("#post_rename_form");
  4718. drename_input = document.querySelector("#post_rename_name");
  4719. var rp = document.querySelector('#post_reply_to');
  4720. var _reply_to = rp?rp.defaultValue:"";
  4721. function RestoreReply(){
  4722. if(rp){
  4723. rp.defaultValue = _reply_to;
  4724. }
  4725. document.querySelector('#post_reply_restore').style.display='none';
  4726. ht = document.querySelector('#post_hint_text');
  4727. if (_reply_to!=""){
  4728. ht.style.display='block';
  4729. ht.innerHTML="<?=$this->T('继续补充该话题:')?>";
  4730. }else{
  4731. ht.style.display='none';
  4732. }
  4733. document.querySelector('#post_edit_target').value="";
  4734. ch = document.querySelector('#post_hint_modify');
  4735. ch.style.display='none';
  4736. }
  4737. function MakeRefer(id){
  4738. t = document.querySelector('#post_content')
  4739. t.focus();
  4740. v = t.value;
  4741. t.value = v.slice(0, t.selectionStart) + "[<?=$this->T('引用文章')?>]("+id.toString()+")" + v.slice(t.selectionEnd);
  4742. la_auto_grow(t);
  4743. if(rp){
  4744. rp.defaultValue = "";
  4745. ht = document.querySelector('#post_hint_text');
  4746. ht.innerHTML = "<?=$this->T('引用并发送新话题:')?>"; ht.style.display='block';
  4747. document.querySelector('#post_reply_restore').style.display='inline';
  4748. rs = document.querySelector('#post_reply_restore');
  4749. rs.style.display='inline'; rs.innerHTML="<?=$this->T('切换为回复')?>";
  4750. document.getElementById('post_menu').style.display='none';
  4751. ch = document.querySelector('#post_hint_modify');
  4752. ch.style.display='none';
  4753. }
  4754. }
  4755. function CopyRefer(id){
  4756. copy_text(id.toString());
  4757. menu.querySelector('#menu_refer_copy').innerHTML="<?=$this->T('已复制')?>";
  4758. }
  4759. function MakeEdit(id){
  4760. ed = document.getElementById('menu_edit');
  4761. ed.innerHTML="<?=$this->T('稍等')?>";
  4762. ed.href="#";
  4763. var xhr = new XMLHttpRequest();
  4764. xhr.onreadystatechange = function() {
  4765. if (this.readyState == 4 && this.status == 200) {
  4766. ed.innerHTML='——';
  4767. ch = document.querySelector('#post_hint_modify');
  4768. ch.style.display='block';
  4769. ht = document.querySelector('#post_hint_text');
  4770. ht.innerHTML = "<?=$this->T('修改帖子:')?>";
  4771. rs = document.querySelector('#post_reply_restore');
  4772. rs.style.display='inline'; rs.innerHTML="<?=$this->T('取消')?>";
  4773. t = document.querySelector('#post_content');
  4774. t.value=xhr.responseText.trim();
  4775. t.focus();
  4776. la_auto_grow(t);
  4777. document.querySelector('#post_edit_target').value=id;
  4778. document.getElementById('post_menu').style.display='none';
  4779. }
  4780. };
  4781. xhr.open("GET", "index.php?post="+id.toString()+'&post_original=true', true);
  4782. xhr.send();
  4783. }
  4784. function MarkDelete(id){
  4785. p = document.querySelector('[data-post-id="'+id+'"]');
  4786. op = p.dataset.markDelete?"false":"true";
  4787. window.location.href=
  4788. "index.php?<?=$this->GetRedirect()?>&mark_delete="+op+'&target='+id.toString();
  4789. }
  4790. function SetMark(mark){
  4791. menu = document.getElementById('post_menu');
  4792. window.location.href=
  4793. "index.php?<?=$this->GetRedirect()?>&target="+
  4794. menu.parentNode.dataset.postId+"&set_mark="+mark;
  4795. }
  4796. function ToggleMarkDetails(){
  4797. dmark.style.display=(dmark.style.display=='block')?'none':'block';
  4798. drename.style.display=dmastodon.style.display='none';
  4799. }
  4800. function ToggleRenameDetails(){
  4801. drename.style.display=(drename.style.display=='block')?'none':'block';
  4802. dmark.style.display=dmastodon.style.display='none';
  4803. }
  4804. function ToggleMastodonDetails(){
  4805. dmastodon.style.display=(dmastodon.style.display=='block')?'none':'block';
  4806. dmark.style.display=drename.style.display='none';
  4807. }
  4808. <?php } if(isset($_GET['post'])){ ?> ScrollToPost("<?=$_GET['post']?>"); <?php } ?>
  4809. function ShowPostMenu(post){
  4810. menu = document.getElementById('post_menu');
  4811. menu.style.display='block';
  4812. menu.parentNode.removeChild(menu);
  4813. post.appendChild(menu);
  4814. menu.style.display='block';
  4815. id = post.dataset.postId
  4816. menu.querySelector('#_time_hook').innerHTML = ''+id.substring(2,4)+'/'+id.substring(4,6)+'/'+id.substring(6,8)+
  4817. ' '+id.substring(8,10)+':'+id.substring(10,12);
  4818. window.onClick="HidePopMenu()";
  4819. menu.onClick=(function(event){
  4820. event.stopPropagation();
  4821. });
  4822. hs = menu.querySelector('#menu_history');
  4823. hs.href='?post='+id+'&history=1';
  4824. <?php if($this->LoggedIn && !isset($this->WayBack)){ ?>
  4825. <?php if($this->PageType!='search'){?>
  4826. menu.querySelector('#menu_refer').href='javascript:MakeRefer(id)';
  4827. ed = menu.querySelector('#menu_edit');ed.href='javascript:MakeEdit(id)'; ed.innerHTML="<?=$this->T('修改')?>";
  4828. <?php } ?>
  4829. ref = menu.querySelector('#menu_refer_copy')
  4830. ref.innerHTML='<?=$this->T("复制编号")?>';
  4831. ref.href='javascript:CopyRefer(id)';
  4832. d = menu.querySelector('#menu_delete');
  4833. d.href='javascript:MarkDelete(\"'+id+'\")';
  4834. p = document.querySelector('[data-post-id="'+id+'"]');
  4835. d.innerHTML = p.dataset.markDelete?"<?=$this->T('恢复')?>":"<?=$this->T('删除')?>";
  4836. menu.querySelector('#mark_details').dataset.id=id;
  4837. drename_input.value=id;
  4838. drename_form.action="<?=$this->GetRedirect()?>"+"&rename_post="+id;
  4839. <?php if(isset($this->MastodonToken)){ ?>
  4840. dmastodon_form = document.querySelector("#post_mastodon_form");
  4841. dmastodon_form.action='?mastodon_post='+id;
  4842. function MastodonSend(id){
  4843. mastodon_send.innerHTML="<?=$this->T('稍等')?>";
  4844. var xhr = new XMLHttpRequest();
  4845. function wrapidxhr(_id) { return function() {
  4846. if (this.readyState == 4 && this.status == 200) {
  4847. var response = xhr.responseText;
  4848. let content="";
  4849. if(res = response.match(/SUCCESS (\S+)/u)){
  4850. content="<?=$this->T('成功发送到长毛象')?>";
  4851. }else{content="<b><?=$this->T('出现问题')?></b><br /><span class='smaller'>"+response+"</span>";}
  4852. mastodon_send.innerHTML=content; mastodon_send.href=res[1];
  4853. MarkPostDoneMastodon(_id, res[1]);
  4854. } }
  4855. };
  4856. xhr.onreadystatechange = wrapidxhr(id);
  4857. xhr.open("GET", "index.php?mastodon_send_post="+id, true); xhr.send();
  4858. }
  4859. menu_mastodon = menu.querySelector("#menu_mastodon");
  4860. mastodon_send = menu.querySelector("#menu_mastodon_send");
  4861. mastodon_view = menu.querySelector("#menu_mastodon_view");
  4862. mastodon_url = menu.querySelector("#post_mastodon_url");
  4863. if(p.dataset.mastodon_url){mastodon_view.style.display='inline';mastodon_view.href=p.dataset.mastodon_url;
  4864. mastodon_send.innerHTML='<?=$this->T("重新发送")?>'; mastodon_url.value=p.dataset.mastodon_url; }
  4865. else{mastodon_view.style.display='none';mastodon_view.href=""; mastodon_send.innerHTML="<?=$this->T('发送')?>";
  4866. mastodon_url.value="";}
  4867. mastodon_send.onclick=function(){
  4868. this.onclick=function(){};
  4869. MastodonSend(id); };
  4870. <?php } } ?>
  4871. title = document.title;
  4872. copy = document.getElementById('share_copy');
  4873. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  4874. copy.addEventListener("click", function(){
  4875. url = window.location
  4876. path = location.pathname
  4877. copy_text(url.protocol+"//"+url.host+path+"?post="+id);
  4878. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  4879. });
  4880. }
  4881. function HidePopMenu(){
  4882. var menus = document.querySelectorAll('.pop_menu');
  4883. [].forEach.call(menus, function(m){m.style.display='none';});
  4884. }
  4885. var posts = document.querySelectorAll('.center .post');
  4886. [].forEach.call(posts, function(p){
  4887. if(s=p.querySelector('._menu_hook')) s.addEventListener("click", function() {
  4888. ShowPostMenu(this.parentNode);ClickPost(this.parentNode,null,true)
  4889. });
  4890. });
  4891. var post_clickables = document.querySelectorAll('.center .post a');
  4892. [].forEach.call(post_clickables, function(p){
  4893. p.addEventListener("click", function(event){
  4894. event.stopPropagation();
  4895. });
  4896. });
  4897. function FindImage(imgsrc){
  4898. for(var i=0;i<document.images_filtered.length;i++){
  4899. if (document.images_filtered[i].dataset.imgsrc==imgsrc) return document.images_filtered[i]
  4900. }
  4901. return null
  4902. }
  4903. var dottime1;
  4904. var dottime2;
  4905. function ToDataURL(url) {
  4906. return fetch(url).then((response) => {return response.blob();}).then(blob => {
  4907. clearTimeout(dottime1);clearTimeout(dottime2);
  4908. ps = document.querySelector('#download_processing');
  4909. ps.innerHTML='↓';ps.style.opacity='';
  4910. return URL.createObjectURL(blob);});
  4911. }
  4912. async function DownloadAsImage(url,name) {
  4913. const a = document.createElement("a"); a.href = await ToDataURL(url); a.download = name;
  4914. document.body.appendChild(a); a.click(); document.body.removeChild(a);
  4915. }
  4916. function basename(url){return url.split(/[\\/]/).pop();}
  4917. pushed=0;
  4918. function ShowBigImage(imgsrc,do_push){
  4919. ShowWaitingBar();
  4920. share = document.querySelector('#big_image_share');
  4921. img = document.querySelector('#big_image');
  4922. vid = document.querySelector('#big_video');
  4923. vidsrc = document.querySelector('#big_video_src');
  4924. down = document.querySelector('#image_download');
  4925. img.src = ""; vidsrc.src="";
  4926. if(imgsrc.match(/\.mp4$/)){
  4927. vidsrc.src = src = "images/"+imgsrc; img.style.display='none'; vid.load();vid.style.display='block';
  4928. }else{
  4929. img.src = src = "images/"+imgsrc; vid.style.display='none';img.style.display='block';
  4930. }
  4931. down.href="images/"+imgsrc;
  4932. var downname='<?=$this->T($this->Title);?>_<?=$this->T($this->DisplayName);?>_<?=$this->GiveSafeEMail()?>_'+
  4933. basename(down.href);
  4934. img.alt = downname; down.download=downname;
  4935. var use_href = "images/"+imgsrc;
  4936. down.onclick=function(event){event.stopPropagation();event.preventDefault();
  4937. ps = this.querySelector('#download_processing');ps.innerText='…';
  4938. var dotwait = function(ps){ var self = this;
  4939. dottime1 = setTimeout(function(ps){
  4940. ps.style.opacity='0'; dottime2 = setTimeout(function(ps){ps.style.opacity='1'; dotwait(ps);},300,ps); },300,ps) }
  4941. dotwait(this.querySelector('#download_processing'));
  4942. DownloadAsImage(use_href,downname);};
  4943. if(do_push){PushGalleryHistory(src)}
  4944. page_url = encodeURIComponent(window.location.href);
  4945. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  4946. inqb = document.querySelector('#image_inquiry');
  4947. inqb.href="mailto:<?=$this->T($this->DisplayName);?>\<<?=$this->EMail?>\>?subject=<?=$this->T('网站图片咨询');?>&body="+
  4948. encodeURIComponent("<?=$this->T('你好!我对你网站上的这张图片感兴趣:')?>"+'\n\n')+
  4949. (page_url)+encodeURIComponent('\n\n');
  4950. <?php } ?>
  4951. this_image = FindImage(imgsrc);
  4952. if(this_image&&this_image.dataset.prevsrc){
  4953. new_image = FindImage(this_image.dataset.prevsrc);
  4954. new_prev = new_image?new_image.dataset.prevsrc:null;
  4955. im = document.querySelector('#prev_image');
  4956. if(new_prev) {im.href='javascript:ShowBigImage("'+this_image.dataset.prevsrc+'",'+do_push+')';im.style.opacity='';}
  4957. else {im.style.opacity='0';im.removeAttribute("href");}
  4958. }
  4959. if(this_image&&this_image.dataset.nextsrc){
  4960. new_image = FindImage(this_image.dataset.nextsrc);
  4961. new_next = new_image?new_image.dataset.nextsrc:null;
  4962. im = document.querySelector('#next_image');
  4963. if(new_next) {im.href='javascript:ShowBigImage("'+this_image.dataset.nextsrc+'",'+do_push+')';im.style.opacity='';}
  4964. else {im.style.opacity='0';im.removeAttribute("href");}
  4965. }
  4966. purchase = document.querySelector('#image_purchase');
  4967. purchase_btn = document.querySelector('#image_purchase_button');
  4968. <?php if($this->LoggedIn){ ?>
  4969. product_link = document.querySelector('#image_ops_product_link');
  4970. product_form = document.querySelector('#image_ops_form');
  4971. edit_form = document.querySelector('#image_edit_form');
  4972. edit_new_name = document.querySelector('#image_edit_new_name');
  4973. edit_parent = document.querySelector('#image_parent');
  4974. edit_align = document.querySelector('#image_align');
  4975. product_form.action = window.location.href;
  4976. edit_form.action = window.location.href;
  4977. edit_new_name.value = imgsrc.split('.')[0];
  4978. if(this_image){
  4979. if(this_image.dataset.product){ product_link.value = this_image.dataset.product; }else{ product_link.value = ""; }
  4980. if(this_image.dataset.parent){ edit_parent.value = this_image.dataset.parent; }else{ edit_parent.value = ""; }
  4981. if(this_image.dataset.align){ edit_align.value = this_image.dataset.align; }else{ edit_align.value = "middle"; }
  4982. }
  4983. <?php } ?>
  4984. if(this_image&&this_image.dataset.product){
  4985. purchase.style.display='';
  4986. href = this_image.dataset.product;
  4987. if(this_image.dataset.product.match('^[0-9]{14}$')){
  4988. href = '?post='+href;
  4989. }
  4990. purchase_btn.href = href;
  4991. }else{
  4992. purchase.style.display='none';
  4993. purchase_btn.removeAttribute("href");
  4994. }
  4995. DelayHideImgBtn(null);
  4996. title = encodeURIComponent(document.title);
  4997. copy = document.getElementById('big_share_copy');
  4998. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  4999. copy.addEventListener("click", function(){
  5000. copy_text(window.location.href);
  5001. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  5002. });
  5003. o = document.querySelector('#big_image_overlay');
  5004. info = document.querySelector('#big_image_info');info.innerHTML="<?=$this->T('正在查询……')?>";
  5005. here = document.querySelector('#here_buttons');here.innerHTML='';
  5006. o.style.display="block";
  5007. ShowBackdrop(0.8);
  5008. var xhr = new XMLHttpRequest();
  5009. xhr.onreadystatechange = function() {
  5010. if (this.readyState == 4 && this.status == 200) {
  5011. info = document.querySelector('#big_image_info');
  5012. var response = xhr.responseText;
  5013. let content=""
  5014. if(res = response.match(/<ref>(.*)<\/ref>/u)){
  5015. content="<span class='small'><?=$this->T('该图片出现在')?> "+res[1]+" <?=$this->T('个帖子中')?></span>"+content;
  5016. }else{content="<span class='smaller gray'><?=$this->T('该图片未被引用')?></span>"+content;}
  5017. if(res = response.match(/<insert>([\s\S]*)<\/insert>/u)){
  5018. content+="<div class='clean_a'>"+res[1]+"</div>"; }
  5019. info.innerHTML=content;
  5020. if(res = response.match(/<here>([\s\S]*)<\/here>/u)){
  5021. here.innerHTML=res[1]; window.here_b=document.getElementsByClassName('here_btn');
  5022. if(window.here_b)for(b=0;b<window.here_b.length;b++) {
  5023. window.here_b[b].addEventListener('mousemove',DontHideImgBtn);
  5024. window.here_b[b].addEventListener('mouseover',DontHideImgBtn);}
  5025. }
  5026. }
  5027. };
  5028. xhr.open("GET", "index.php?image_info="+imgsrc+"", true);
  5029. xhr.send();
  5030. }
  5031. function HideBigImage(do_push){
  5032. o = document.querySelector('#big_image_overlay');
  5033. img = document.querySelector('#big_image');
  5034. vid = document.querySelector('#big_video');
  5035. vidsrc = document.querySelector('#big_video_src');
  5036. img.src = ""; vidsrc.src="";
  5037. if(o.style.display!='none'){
  5038. o.style.display="none";
  5039. HideBackdrop();
  5040. if(do_push){PushGalleryHistory("");}
  5041. HideWaitingBar();
  5042. }
  5043. }
  5044. var lbtn=document.querySelector('#prev_image'),rbtn=document.querySelector('#next_image');
  5045. var inq=document.querySelector('#inquiry_buttons');
  5046. var overlay=document.querySelector('#big_image_overlay');
  5047. var hide_timeout;
  5048. function DontHideImgBtn(e){ clearTimeout(hide_timeout); e.stopPropagation(); }
  5049. function DelayHideImgBtn(e){
  5050. lbtn.classList.remove('img_btn_hidden'); rbtn.classList.remove('img_btn_hidden');
  5051. inq.classList.remove('img_btn_hidden');
  5052. if(window.here_b)for(b=0;b<window.here_b.length;b++){window.here_b[b].classList.remove('img_btn_hidden');}
  5053. clearTimeout(hide_timeout);
  5054. hide_timeout = setTimeout(function(e1,e2,e3,e4){e1.classList.add('img_btn_hidden');
  5055. e2.classList.add('img_btn_hidden');e3.classList.add('img_btn_hidden');
  5056. if(window.here_b)for(b=0;b<window.here_b.length;b++){
  5057. window.here_b[b].classList.add('img_btn_hidden');}}, 1000, lbtn, rbtn, inq);
  5058. }
  5059. lbtn.addEventListener('mousemove',DontHideImgBtn);lbtn.addEventListener('mouseover',DontHideImgBtn);
  5060. rbtn.addEventListener('mousemove',DontHideImgBtn);rbtn.addEventListener('mouseover',DontHideImgBtn);
  5061. inq.addEventListener('mousemove',DontHideImgBtn);inq.addEventListener('mouseover',DontHideImgBtn);
  5062. overlay.addEventListener('mousemove',DelayHideImgBtn);
  5063. function UpdateImageClickables(){
  5064. var images = document.querySelectorAll('img, video');
  5065. var images_filtered=new Array(); var imgadded = new Array();
  5066. var images_remaining=new Array();
  5067. [].forEach.call(images, function(img){
  5068. if(img.classList.contains("no_pop") || (!(imgsrc = img.dataset.imgsrc))) return;
  5069. if(imgadded.indexOf(imgsrc)>=0) {images_remaining.push(img); return;}
  5070. images_filtered.push(img);imgadded.push(imgsrc);
  5071. });
  5072. for(var i=0; i<images_filtered.length; i++){
  5073. previmg = nextimg = null; img = images_filtered[i];
  5074. if(i>0) previmg=images_filtered[i-1];
  5075. if(i<images_filtered.length-1) nextimg=images_filtered[i+1];
  5076. prevsrc=previmg?previmg.dataset.imgsrc:null; nextsrc=nextimg?nextimg.dataset.imgsrc:null;
  5077. img.dataset.prevsrc = prevsrc; img.dataset.nextsrc = nextsrc;
  5078. function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
  5079. var clone = img.cloneNode(true); img.replaceWith(clone);
  5080. clone.addEventListener("click", wrap(img.dataset.imgsrc));
  5081. }
  5082. for(var i=0; i<images_remaining.length; i++){
  5083. img = images_remaining[i];
  5084. function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
  5085. var clone = img.cloneNode(true); img.replaceWith(clone);
  5086. clone.addEventListener("click", wrap(img.dataset.imgsrc));
  5087. }
  5088. document.images_filtered = images_filtered;
  5089. }
  5090. UpdateImageClickables();
  5091. function PopGalleryHistory(){
  5092. if(pushed){
  5093. pushed = 0;
  5094. try{
  5095. history.back();
  5096. }catch{
  5097. console.log("can't do it.");
  5098. }
  5099. }
  5100. }
  5101. function PushGalleryHistory(src){
  5102. abs_img = window.location.protocol+"//"+window.location.host+'/'+src
  5103. title = "照片"
  5104. extra = "?";
  5105. sp = new URLSearchParams(window.location.search)
  5106. if(sp.has('post')){extra+="post="+sp.get('post')}
  5107. if(sp.has('gallery')){extra+="&gallery="+sp.get('gallery')}
  5108. try{
  5109. window.history.pushState('&pic='+src, 'Title', extra+'&pic='+src);
  5110. }catch{
  5111. console.log("can't do it.");
  5112. }
  5113. pushed = 1;
  5114. }
  5115. document.addEventListener('keydown', function(e){
  5116. large = document.getElementById('big_image_overlay')
  5117. if (large.style.display!='block') return;
  5118. if(e.key=='Escape'||e.key=='Esc'||e.keyCode==27){
  5119. HideBigImage(1);
  5120. }
  5121. }, true);
  5122. window.addEventListener('popstate', (event) => {
  5123. href=window.location.href;
  5124. let sp = new URLSearchParams(href.substring(href.indexOf('?')))
  5125. if(sp.has('pic')){
  5126. src = sp.get('pic')
  5127. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)) ShowBigImage(onlyimg[0], 0);
  5128. else{HideBigImage(0);}
  5129. }else{HideBigImage(0);}
  5130. if(sp.has('post')){
  5131. id=sp.get('post');post=document.querySelector('.post[data-post-id="'+id+'"]');
  5132. if(post){ClickPost(post,null,false);}
  5133. }
  5134. });
  5135. let searchParams = new URLSearchParams(window.location.search)
  5136. if(searchParams.has('pic')){
  5137. src = searchParams.get('pic')
  5138. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)){
  5139. ShowBigImage(onlyimg[0], 1);
  5140. }
  5141. }
  5142. function _dropHandler(event){ if (typeof dropHandler === "function") dropHandler(event); }
  5143. function _dragOverHandler(event){ if (typeof dragOverHandler === "function") dragOverHandler(event); }
  5144. </script>
  5145. </body>
  5146. <?php
  5147. }
  5148. function DoIdentifyExperimental(){
  5149. if(isset($this->ExpHost) && $this->ExpHost && preg_match('/'.preg_quote($this->ExpHost).'/u', $_SERVER['HTTP_HOST'])){
  5150. $this->InExperimentalMode=True; $this->InHereMode=True;
  5151. if(!$this->AllowLanguageChoices){ $this->LanguageAppendix='en'; }
  5152. }
  5153. if(isset($this->HereHost) && $this->HereHost && preg_match('/'.preg_quote($this->HereHost).'/u', $_SERVER['HTTP_HOST'])){
  5154. $this->InHereMode=True;
  5155. }
  5156. }
  5157. function DoExperimentalTopLink($p){
  5158. if($this->InHereMode && $p){
  5159. if(isset($p['tid']) && $p['tid']['first']!=$p){
  5160. header('Location: ?post='.$p['tid']['first']['id']); exit();
  5161. }
  5162. }
  5163. }
  5164. function MakeExperimentalConfirm(){
  5165. if(isset($_COOKIE['la_experimental']) && $_COOKIE['la_experimental'] == 'confirmed'){
  5166. return false;
  5167. }
  5168. $caution_html =
  5169. $confirm = "<a class='text_highlight clean_a bold' href='index.php?confirm_enter=1".
  5170. (isset($this->CurrentPostID)?("&post=".$this->CurrentPostID):"").
  5171. "'>&nbsp;&nbsp;".$this->T('继续')."&nbsp;&nbsp;</a>";
  5172. ?>
  5173. <div class='center_exp'><?php
  5174. if(isset($this->ExpCaution) && ($p=$this->GetPost($this->ExpCaution,true)))$this->MakeSinglePostExp($p);
  5175. else echo "<li class='post post_dummy'>".$this->TranslatePostParts("<h1>注意</h1><p>您将进入实验站。</p>")."</li>";
  5176. ?></div>
  5177. <div class='center_exp'><li class='post post_dummy'><p><?=$confirm?></p></li></div>
  5178. <?php return true;
  5179. }
  5180. }
  5181. $la = new LA;
  5182. $la->DoSiteRedirect();
  5183. $la->DoLogin();
  5184. $la->SwitchLanguageAndFont();
  5185. $err = $la->ProcessRequest($message, $redirect);
  5186. $la->WriteAsNecessary();
  5187. $la->DoIdentifyExperimental();
  5188. $la->SwitchWayBackMode();
  5189. if($err){
  5190. echo $message;
  5191. exit();
  5192. }
  5193. if(isset($redirect)){
  5194. header('Location: '.$redirect);
  5195. exit();
  5196. }
  5197. $la->DetectPageType();
  5198. $la->ReadImages(false);
  5199. $la->ReadPosts();
  5200. if(isset($la->WayBack)){
  5201. $la->ReadArchive();
  5202. }
  5203. $im = NULL;
  5204. if(preg_match('/images\/(.*)/u',$la->HereID,$imname) && ($im = &$la->FindImage($imname[1]))){
  5205. if(!$la->CanShowImage($im)) { $im=&$la->NULL_IMAGE; }
  5206. }
  5207. $p = &$la->GetPost($la->CurrentPostID);
  5208. if(!isset($p)){
  5209. $p = &$la->GetMergedPost($la->CurrentPostID);
  5210. }
  5211. if(isset($p) && !$la->CanShowPost($p)) $p=NULL;
  5212. else{ $la->DoExperimentalTopLink($p); }
  5213. if(isset($p)){ $la->ActualPostID = $p['id']; }
  5214. if($la->PageType=='here' ||$la->PageType=='experimental'){
  5215. if($im){
  5216. $la->SetHereMainImage($im);
  5217. $la->RecordVisitedHere($im['name'],$im?$la->ImageTitle($im):NULL);
  5218. }else if($p){
  5219. $la->RecordVisitedHere($p['id'],NULL);
  5220. }else {
  5221. $im = &$la->GiveImageInHere(false);
  5222. if($im){
  5223. $la->SetHereMainImage($im);
  5224. $la->RecordVisitedHere($im['name'],$la->ImageTitle($im));
  5225. }
  5226. }
  5227. }
  5228. $la->MakeHeader($p);
  5229. $la->MakeMainBegin();
  5230. if($la->PageType=='here' ||$la->PageType=='experimental'){
  5231. if(($la->PageType=='experimental' && (!$la->MakeExperimentalConfirm())) || $la->PageType=='here'){
  5232. if($im){
  5233. $la->MakeHereSection($im);
  5234. }else if($p){
  5235. $la->MakePostSectionExp($p);
  5236. $la->MakeLinkedPostsExp($p);
  5237. }else {
  5238. if($im){
  5239. $la->MakeHereSection($im);
  5240. }else{
  5241. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5242. "</p><p><a href='index.php'>".$la->T('返回首页')."</a></p><br />";
  5243. }
  5244. }
  5245. }
  5246. $la->MakeMainEnd();
  5247. $la->MakeExpFooter();
  5248. }else{
  5249. if($la->PageType=='extras'){
  5250. $la->MakeExtraOperations();
  5251. }else if($la->PageType=='settings'){
  5252. $la->MakeSettings();
  5253. }else if($la->PageType=='gallery'){
  5254. $la->MakeGalleryLeft();
  5255. $la->MakeGallerySection();
  5256. }else if($la->PageType=='post'){
  5257. if($p){
  5258. $made_interesting = false;
  5259. if($la->IsInterestingPost($p)){
  5260. $la->MakeInterestingSection($p['tid']);
  5261. }
  5262. else{
  5263. $la->MakeSidebar();
  5264. $la->MakePostSection($p);
  5265. }
  5266. }else{
  5267. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5268. "</p><p><a href='index.php'>".$la->T('返回首页')."</a></p><br />";
  5269. }
  5270. }else if($la->PageType=='history'){
  5271. $la->ReadArchive();
  5272. $la->MakePostHistory($p, $_GET['version']??NULL);
  5273. }else if($la->PageType=='search'){
  5274. $la->MakeSidebar();
  5275. $la->MakeRecentPosts($_GET['search']);
  5276. }else if($la->PageType=='category'){
  5277. $la->MakeSidebar();
  5278. $la->MakeRecentPosts(NULL,$_GET['category']);
  5279. }else if($la->PageType=='comments'){
  5280. $la->MakeCommentPosts();
  5281. }else if($la->PageType=='statistics'){
  5282. $la->MakeStatistics();
  5283. }else{
  5284. $la->MakeSidebar();
  5285. $la->MakeRecentPosts();
  5286. }
  5287. $la->MakeMainEnd();
  5288. $la->MakeFooter($p);
  5289. }
  5290. ?>