*/}}

index.php 347 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971
  1. <?php
  2. include 'Parsedown.php';
  3. include 'ParsedownExtra.php';
  4. ini_set('max_execution_time', 300);
  5. if($_SERVER['HTTP_HOST']=='localhost'){
  6. ini_set('display_errors', '0');
  7. ini_set('display_startup_errors', '1');
  8. error_reporting(E_ALL);
  9. }
  10. global $LA_GLOBAL_LANG;
  11. global $INDEXPHP;
  12. $INDEXPHP='index.php';
  13. if($LA_GLOBAL_LANG=='en'){
  14. $INDEXPHP='en.php';
  15. }
  16. class LA{
  17. protected $PDE;
  18. protected $style;
  19. public $PAGE;
  20. public $AFTER;
  21. public $PSTACK;
  22. protected $PNUMBER;
  23. /* config */
  24. protected $Title;
  25. protected $ShortTitle;
  26. protected $Admin;
  27. protected $Password;
  28. protected $DisplayName;
  29. protected $EMail;
  30. protected $SpecialNavigation;
  31. protected $SpecialSidebar;
  32. protected $SpecialFooter;
  33. protected $SpecialFooter2;
  34. protected $SpecialPinned;
  35. protected $DefaultGallery;
  36. protected $SelfAuthPath;
  37. protected $HereHost;
  38. protected $HereTitle;
  39. protected $HereShortTitle;
  40. protected $HereAlbum;
  41. protected $HereNavigation;
  42. protected $HereFooter;
  43. protected $ExpHost;
  44. protected $ExpAlbum;
  45. protected $ExpTitle;
  46. protected $ExpShortTitle;
  47. protected $ExpCaution;
  48. protected $ExpNavigation;
  49. protected $ExpFooter;
  50. protected $CommentEnabled;
  51. protected $MastodonToken;
  52. protected $MastodonURL;
  53. protected $MastodonPreferredLang;
  54. protected $HostURL;
  55. protected $GalleryStep;
  56. protected $AllowLanguageChoices;
  57. protected $Redirect;
  58. protected $Translations;
  59. protected $CustomTranslationContent;
  60. protected $CommentsPerPage;
  61. protected $UsePosts;
  62. protected $CurrentOffset;
  63. protected $PostsPerPage;
  64. protected $HotPostCount;
  65. protected $LoggedIn;
  66. protected $LoginTokens;
  67. protected $InHereMode;
  68. protected $InExperimentalMode;
  69. protected $LanguageAppendix;
  70. protected $UseRemoteFont;
  71. protected $Posts;
  72. protected $Threads; // [ keys: first last displayed count]
  73. protected $WaybackThreads;
  74. public $Images;
  75. protected $Galleries;
  76. protected $Anchors;
  77. protected $ArchiveHandles;
  78. protected $Archive;
  79. public $WayBack;
  80. protected $YearBegin;
  81. protected $YearEnd;
  82. protected $Markers;
  83. protected $ExtraScripts;
  84. protected $APubID;
  85. protected $APubActor;
  86. protected $APubPublicKey;
  87. protected $APubPrivateKey;
  88. protected $TIME_STRING;
  89. public $NULL_POST;
  90. public $NULL_IMAGE;
  91. public $NULL_IMAGE_DUMMY;
  92. public $NULL_Gallery;
  93. protected $DoneReadPosts;
  94. protected $DoneReadImages;
  95. protected $DoneReadArchive;
  96. protected $NeedWritePosts;
  97. protected $NeedWriteImages;
  98. protected $NeedWriteArchive;
  99. protected $HereDisplayTitle;
  100. protected $VisitedHere;
  101. protected $HereNumber;
  102. protected $HereMainImage;
  103. public $PageType;
  104. public $CurrentPostID;
  105. public $HereID;
  106. public $ActualPostID;
  107. public $TagID;
  108. function &_TRow(){ if(!isset($this->PAGE)){$this->PAGE=[];} if(!isset($this->PAGE[0])){$this->PAGE[]=[];} return $this->PAGE[array_key_last($this->PAGE)]; }
  109. function &TRow(){ $last=array_key_last($this->PAGE); if($this->PAGE[$last]==[]) return $this->PAGE[$last]; $this->PAGE[]=[]; return $this->PAGE[$last]; }
  110. function TFill($k,&$content,$span=null){ $a=&$this->_TRow();if(!isset($a[$k]))$a[$k]="";$a[$k].=$content; $content=''; if($span!=null && $span>1){ $a['span'.$k]=$span; } }
  111. function TExtra($rowextra){ $a=&$this->_TRow(); $a['extra']=$rowextra; }
  112. function TAfter(&$content){ $this->AFTER.=$content; $content=''; }
  113. function TBackup(){ if(!isset($this->PSTACK)){$this->PSTACK=[];}; $this->PSTACK[]=$this->PAGE; $this->PAGE=[]; }
  114. function TRestore($extra=""){ if(!isset($this->PSTACK) || $this->PSTACK==[]) return "";
  115. $S=$this->GeneratePage(0,$extra); $this->PAGE=end($this->PSTACK); unset($this->PSTACK[array_key_last($this->PSTACK)]); return $S;
  116. }
  117. function ReadableTime($id){
  118. $dt = DateTime::createFromFormat('YmdHis', $id);
  119. return $dt->format('Y/m/d H:i:s');
  120. }
  121. function StandardTime($id){
  122. $dt = DateTime::createFromFormat('YmdHis', $id);
  123. return $dt->format('Y-m-d\TH:i:sP');
  124. }
  125. function FullURL(){
  126. return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?
  127. "https" : "http") . "://" . $_SERVER['HTTP_HOST'] .
  128. $_SERVER['REQUEST_URI'];
  129. }
  130. function T($str){
  131. if(!$this->LanguageAppendix) return $str;
  132. foreach($this->Translations as $entry){
  133. if($entry['zh']==$str)
  134. return $entry[$this->LanguageAppendix];
  135. }
  136. return $str;
  137. }
  138. function SwitchLanguageAndFont(){ global $LA_GLOBAL_LANG;
  139. $this->LanguageAppendix = 'zh';
  140. if(isset($_COOKIE['la_language'])){
  141. $this->LanguageAppendix = $_COOKIE['la_language'];
  142. }else{
  143. if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
  144. $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  145. $lang = substr($lang,0,5);
  146. if(preg_match("/zh/i",$lang))$this->LanguageAppendix = 'zh';
  147. else $this->LanguageAppendix = 'en';
  148. }
  149. }
  150. if(isset($LA_GLOBAL_LANG)){
  151. if($LA_GLOBAL_LANG=='en'){ $this->LanguageAppendix = 'en'; setcookie('la_language','en',time()+3600*24*7); }
  152. else if($LA_GLOBAL_LANG=='zh'){ $this->LanguageAppendix = 'zh'; setcookie('la_language','zh',time()+3600*24*7); }
  153. }
  154. if(isset($_COOKIE['la_font'])){
  155. $this->UseRemoteFont = ($_COOKIE['la_font']!='local');
  156. }
  157. }
  158. function SwitchWayBackMode(){
  159. if(isset($_COOKIE['la_wayback'])){
  160. $this->WayBack = $_COOKIE['la_wayback'];
  161. }else $this->WayBack = NULL;
  162. }
  163. function DisplayRedirectConfig(){
  164. $s = "";
  165. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  166. if($r['for']=='P'){
  167. $s.=("P ".$r['format'].":".$r['target'].";".PHP_EOL);
  168. }else if($r['for']=='S'){
  169. $s.=("S ".$r['format'].":".$r['domain'].":".$r['target'].";".PHP_EOL);
  170. }
  171. }
  172. return $s;
  173. }
  174. function DoSiteRedirect(){ global $INDEXPHP;
  175. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  176. if($r['for']=='S'){
  177. if(preg_match('/'.$r['format'].'/ui', $_SERVER['HTTP_HOST'])){
  178. if($_SERVER['REQUEST_URI']=='/'||$_SERVER['REQUEST_URI']==''){
  179. header('Location:https://'.$r['domain'].'/'.$INDEXPHP.'?post='.$r['target']); exit;
  180. }else{
  181. header('Location:https://'.$r['domain'].$_SERVER['REQUEST_URI']); exit;
  182. }
  183. }
  184. }
  185. }
  186. }
  187. function WriteHTACCESS(){
  188. $conf = fopen('.htaccess','w');
  189. fwrite($conf,"RewriteEngine on".PHP_EOL.PHP_EOL);
  190. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  191. if($r['for']=='P'){
  192. if(!preg_match('/[0-9]{14}/',$r['target'])){
  193. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?'.$r['target'].' [R=302,L,NC]'.PHP_EOL.PHP_EOL);
  194. }
  195. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?post='.$r['target'].' [R=302,L,NC]'.PHP_EOL.PHP_EOL);
  196. }// do site redirect in php.
  197. }
  198. fwrite($conf, 'RewriteCond %{HTTPS} !=on'.PHP_EOL.
  199. 'RewriteCond %{HTTP_HOST} !=localhost'.PHP_EOL.
  200. 'RewriteCond %{REQUEST_URI} !^.*(jpg|png|gif)$'.PHP_EOL.
  201. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]'.PHP_EOL.PHP_EOL);
  202. fwrite($conf,'<Files ~ "\.md$">'.PHP_EOL.'deny from all'.PHP_EOL.'</Files>'.PHP_EOL);
  203. fflush($conf);fclose($conf);
  204. }
  205. function BuildRedirectConfig($conf){
  206. $this->Redirect=[];
  207. if(preg_match_all('/P\s+(.*)\:\s*([0-9]{14}|.+)\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  208. foreach($ma as $m){
  209. $redirect=[]; $redirect['for'] = 'P'; $redirect['format'] = $m[1]; $redirect['target'] = $m[2];
  210. $this->Redirect[]=$redirect;
  211. }
  212. }
  213. if(preg_match_all('/S\s+(\S+)\s*\:\s*(\S+)\s*\:\s*([0-9]{14})\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  214. foreach($ma as $m){
  215. $redirect=[]; $redirect['for'] = 'S'; $redirect['format'] = $m[1]; $redirect['domain'] = $m[2]; $redirect['target'] = $m[3];
  216. $this->Redirect[]=$redirect;
  217. }
  218. }
  219. }
  220. function WriteTokens(){
  221. $tf = fopen('la_tokens.php','w');
  222. fwrite($tf,'<?php header("Location:index.php"); exit; ?>'.PHP_EOL.PHP_EOL);
  223. if(isset($this->LoginTokens) && sizeof($this->LoginTokens)) {
  224. foreach($this->LoginTokens as $t){
  225. fwrite($tf,'- '.$t.PHP_EOL);
  226. }
  227. }
  228. fflush($tf);fclose($tf);
  229. }
  230. function WriteConfig(){
  231. if(!isset($this->Title)) $this->Title = $this->T('那么的维基');
  232. if(!isset($this->ShortTitle)) $this->ShortTitle = $this->T('基');
  233. if(!isset($this->Admin)) $this->Admin = 'admin';
  234. if(!isset($this->DisplayName)) $this->DisplayName = $this->T('管理员');
  235. if(!isset($this->Password)) $this->Password = password_hash('Admin', PASSWORD_DEFAULT).PHP_EOL;
  236. $conf = fopen('la_config.php','w');
  237. fwrite($conf,'<?php header("Location:index.php"); exit; ?> '.PHP_EOL.PHP_EOL);
  238. fwrite($conf,'- Title = '.$this->Title.PHP_EOL);
  239. fwrite($conf,'- ShortTitle = '.$this->ShortTitle.PHP_EOL);
  240. fwrite($conf,'- Admin = '.$this->Admin.PHP_EOL);
  241. fwrite($conf,'- DisplayName = '.$this->DisplayName.PHP_EOL);
  242. fwrite($conf,'- Password = '.$this->Password.PHP_EOL);
  243. fwrite($conf,'- EMail = '.$this->EMail.PHP_EOL);
  244. fwrite($conf,'- SpecialNavigation = '.$this->SpecialNavigation.PHP_EOL);
  245. fwrite($conf,'- SpecialSidebar = '.$this->SpecialSidebar.PHP_EOL);
  246. fwrite($conf,'- SpecialFooter = '.$this->SpecialFooter.PHP_EOL);
  247. fwrite($conf,'- SpecialFooter2 = '.$this->SpecialFooter2.PHP_EOL);
  248. fwrite($conf,'- SpecialPinned = '.$this->SpecialPinned.PHP_EOL);
  249. fwrite($conf,'- DefaultGallery = '.$this->DefaultGallery.PHP_EOL);
  250. fwrite($conf,'- SelfAuthPath = '.$this->SelfAuthPath.PHP_EOL);
  251. fwrite($conf,'- CommentEnabled = '.($this->CommentEnabled?"True":"False").PHP_EOL);
  252. fwrite($conf,'- HereHost = '.$this->HereHost.PHP_EOL);
  253. fwrite($conf,'- HereTitle = '.$this->HereTitle.PHP_EOL);
  254. fwrite($conf,'- HereShortTitle = '.$this->HereShortTitle.PHP_EOL);
  255. fwrite($conf,'- HereAlbum = '.$this->HereAlbum.PHP_EOL);
  256. fwrite($conf,'- HereNavigation = '.$this->HereNavigation.PHP_EOL);
  257. fwrite($conf,'- HereFooter = '.$this->HereFooter.PHP_EOL);
  258. fwrite($conf,'- ExpHost = '.$this->ExpHost.PHP_EOL);
  259. fwrite($conf,'- ExpTitle = '.$this->ExpTitle.PHP_EOL);
  260. fwrite($conf,'- ExpShortTitle = '.$this->ExpShortTitle.PHP_EOL);
  261. fwrite($conf,'- ExpCaution = '.$this->ExpCaution.PHP_EOL);
  262. fwrite($conf,'- ExpAlbum = '.$this->ExpAlbum.PHP_EOL);
  263. fwrite($conf,'- ExpNavigation = '.$this->ExpNavigation.PHP_EOL);
  264. fwrite($conf,'- ExpFooter = '.$this->ExpFooter.PHP_EOL);
  265. fwrite($conf,'- MastodonToken = '.$this->MastodonToken.PHP_EOL);
  266. fwrite($conf,'- MastodonURL = '.$this->MastodonURL.PHP_EOL);
  267. fwrite($conf,'- MastodonPreferredLang = '.$this->MastodonPreferredLang.PHP_EOL);
  268. fwrite($conf,'- HostURL = '.$this->HostURL.PHP_EOL);
  269. fwrite($conf,'- APubID = '.$this->APubID.PHP_EOL);
  270. fwrite($conf,'- GalleryStep = '.$this->GalleryStep.PHP_EOL);
  271. fwrite($conf,'- AllowLanguageChoices = '.$this->AllowLanguageChoices.PHP_EOL);
  272. fflush($conf);fclose($conf);
  273. $conf = fopen('la_redirect.md','w');
  274. fwrite($conf,$this->DisplayRedirectConfig());fflush($conf);fclose($conf);
  275. $this->WriteHTACCESS();
  276. $this->WriteTokens();
  277. }
  278. function Install(){
  279. if(!file_exists('la_config.php')){
  280. $this->WriteConfig();
  281. }
  282. if(!is_dir('posts')) mkdir('posts');
  283. if(!is_dir('images')) mkdir('images');
  284. if(!is_dir('images/thumb')) mkdir('images/thumb');
  285. if(!is_dir('styles')) mkdir('styles');
  286. if(!is_dir('archive')) mkdir('archive');
  287. $this->WriteStyles();
  288. $this->WriteHTACCESS();
  289. }
  290. function ReadFromExistingConfig(){
  291. $f=null;
  292. if(file_exists('la_config.php')) $f='la_config.php';
  293. else if(file_exists('la_config.md')) $f='la_config.md';
  294. if(!isset($f)) return;
  295. $c = file_get_contents($f);
  296. if(preg_match_all('/-\s*(\S+)\s*=\s*(\S+)\s*$/um', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  297. $str = $m[1];
  298. $this->$str = $m[2];
  299. }
  300. $this->CommentEnabled = $this->CommentEnabled=="True";
  301. if(!isset($this->GalleryStep)) $this->GalleryStep=20;
  302. }
  303. function ReadConfig(){
  304. $this->ReadFromExistingConfig();
  305. if(file_exists('la_redirect.md')){
  306. $c = file_get_contents('la_redirect.md');
  307. $this->BuildRedirectConfig($c);
  308. }
  309. if(!file_exists('la_config.php')){
  310. $this->Install();
  311. }
  312. $this->Translations=[];
  313. if(file_exists("translations.md")){
  314. $c = file_get_contents('translations.md');
  315. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  316. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  317. $this->Translations[] = $entry;
  318. }
  319. }
  320. if(file_exists("custom_translations.md")){
  321. $this->CustomTranslationContent = file_get_contents('custom_translations.md');
  322. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$this->CustomTranslationContent, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  323. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  324. $this->Translations[] = $entry;
  325. }
  326. }
  327. $this->LoginTokens=[];
  328. if(file_exists('la_tokens.php')){
  329. $c = file_get_contents('la_tokens.php');
  330. if(preg_match_all('/-\s+(\S.*)\s*$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  331. $this->LoginTokens[] = $m[1];
  332. }
  333. }
  334. }
  335. function MastodonPostStatus($status){ return $this->MastodonCall('/api/v1/statuses', 'POST', $status); }
  336. function MastodonPostMedia($media){ return $this->MastodonCall('/api/v1/media', 'POST', $media); }
  337. function MastodonCall($endpoint, $method, $data){
  338. $headers = [
  339. 'Authorization: Bearer '.$this->MastodonToken,
  340. 'Content-Type: multipart/form-data',
  341. ];
  342. $ch = curl_init();
  343. curl_setopt($ch, CURLOPT_URL, $this->MastodonURL.$endpoint);
  344. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  345. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  346. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  347. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  348. $reply = curl_exec($ch);
  349. if (!$reply) {
  350. return json_encode(['ok'=>false, 'curl_error_code' => curl_errno($ch_status), 'curl_error' => curl_error(ch_status)]);
  351. }
  352. curl_close($ch);
  353. return json_decode($reply, true);
  354. }
  355. function MastodonSendPost(&$post, &$errmsg=NULL){
  356. if(isset($post['mark_value']) && $post['mark_value']==7){ return NULL; }
  357. $this->LanguageAppendix = 'zh';
  358. if(in_array($this->MastodonPreferredLang,['en','zh'])){ $this->LanguageAppendix = $this->MastodonPreferredLang; }
  359. $this->ConvertPost($post);
  360. $media_ids = NULL;
  361. $mastodon_post_url = NULL;
  362. $imcount = 0;
  363. if(isset($post['original_images']) && isset($post['original_images'][0])) foreach($post['original_images'] as $im){
  364. $curl_file = curl_file_create($im, mime_content_type($im), basename($im));
  365. $body = ['file' => $curl_file,]; $response = $this->MastodonPostMedia($body);
  366. if(isset($response['id'])){ if(!isset($media_ids)){$media_ids=[];} $media_ids[]=$response['id']; }
  367. else{ if(isset($response['error'])) $errmsg.=$response['error']."<br /><br />"; }
  368. $imcount++; if($imcount>=4){ break; }
  369. }
  370. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$post['html']));
  371. if(isset($this->HostURL) && $this->HostURL!=""){
  372. $text.=("\n\n".$this->T('来自').' '.$this->HostURL.'?post='.$post['id']);
  373. }
  374. $vis = (isset($post['mark_value']) && $post['mark_value']==6)?"private":"public";
  375. $status_data = [ 'status' => $text, 'visibility' => $vis, 'language' => $this->LanguageAppendix, ];
  376. if(isset($post['prev']) && ($pp=&$this->GetPost($post['prev']))!=$this->NULL_POST){
  377. if(isset($pp['mastodon_url'])){ $status_data['in_reply_to_id'] = basename($pp['mastodon_url']);
  378. }
  379. }
  380. if(isset($media_ids[0])){ $status_data['media_ids']=$media_ids; }
  381. $status_data = preg_replace('/(media_ids%5B)[0-9]+(%5D)/','$1$2', http_build_query($status_data));
  382. $status_response = $this->MastodonPostStatus($status_data);
  383. if(isset($status_response['url']) && $status_response['url']){
  384. $mastodon_post_url = $status_response['url'];
  385. $post['mastodon_url'] = $mastodon_post_url;
  386. $this->NeedWritePosts = 1;
  387. }
  388. if(isset($status_response['error'])) { $errmsg .= $status_response['error']; }
  389. return $mastodon_post_url;
  390. }
  391. function __construct() {
  392. $this->ReadConfig();
  393. $this->PDE = new ParsedownExtra();
  394. $this->PDE->SetInterlinkPath('/');
  395. $this->Posts = [];
  396. $this->Threads = [];
  397. $this->VisitedHere = [];
  398. $this->NULL_IMAGE_DUMMY = [];
  399. $this->NULL_IMAGE_DUMMY['name']=$this->NULL_IMAGE_DUMMY['file']=$this->NULL_IMAGE_DUMMY['thumb']="";
  400. $this->Markers=['●', '○', '✓', '×', '!', 'P', 'E', 'S'];
  401. $this->PostsPerPage = 40;
  402. $this->CommentsPerPage = 100;
  403. $this->HotPostCount = 15;
  404. $this->TIME_STRING = date('YmdHis');
  405. $this->WayBack = NULL;
  406. $this->YearBegin = $this->YearEnd = 2000;
  407. $this->DoneReadPosts = $this->DoneReadImages = $this->DoneReadArchive = false;
  408. $this->NeedWritePosts= $this->NeedWriteImages= $this->NeedWriteArchive= false;
  409. $this->UsePosts = &$this->Posts;
  410. $this->PNUMBER=0;
  411. }
  412. function DoLogout(){
  413. $this->LoggedIn = false;
  414. unset($_SESSION['user_id']);
  415. $this->RecordToken(true);
  416. }
  417. function RecordToken($unset_current=false){
  418. if(isset($unset_current) && isset($_COOKIE['la_token'])){
  419. $t = $_COOKIE['la_token'];
  420. setcookie('la_token', null, -1); unset($_COOKIE['la_token']);
  421. if (($key = array_search($t,$this->LoginTokens)) !== false) { unset($this->LoginTokens[$key]); }
  422. $this->WriteTokens();
  423. return null;
  424. }else{
  425. $t = uniqid('la_',true);
  426. setcookie('la_token',$t,time()+3600*24*7); $_COOKIE['la_token'] = $t;
  427. $this->LoginTokens[] = $t;
  428. $this->WriteTokens();
  429. return $t;
  430. }
  431. }
  432. function LoginThroughToken(){
  433. if(!isset($_COOKIE['la_token'])) return false;
  434. $t = $_COOKIE['la_token'];
  435. if (($key = array_search($t,$this->LoginTokens)) !== false) {
  436. $_SESSION['user_id']=$this->Admin;
  437. $this->LoggedIn = true;
  438. setcookie('la_token',$t,time()+3600*24*7);
  439. return true;
  440. }
  441. return false;
  442. }
  443. function DoLogin(){
  444. session_start();
  445. $redirect=false;
  446. if(isset($_GET['logout'])){ $this->DoLogout(); header('Location:index.php'); }
  447. else if(!isset($_SESSION['user_id'])){
  448. if(isset($_POST['login_button'])){
  449. $id = trim($_POST['login_id']);
  450. $pwd = trim($_POST['login_password']);
  451. if(strtolower($this->Admin)==strtolower($id)&&password_verify($pwd, $this->Password)){
  452. $_SESSION['user_id']=$id;
  453. $this->RecordToken(false);
  454. }
  455. $redirect = true;
  456. }else if($this->LoginThroughToken()){
  457. // nothing;
  458. }
  459. }else{
  460. if(strtolower($_SESSION['user_id']) == strtolower($this->Admin)){ $this->LoggedIn = true; }
  461. else{ $this->DoLogout();}
  462. }
  463. if($redirect){
  464. header('Location:index.php'.(isset($_GET['post'])?("?post=".$_GET['post']):"")
  465. .(isset($_GET['settings'])?"?settings=true":""));
  466. }
  467. }
  468. function SetHereMainImage($im_this){
  469. if(isset($im_this) && isset($im_this['parent'])){ $this->HereMainImage = &$this->FindImage($im_this['parent'],true);}
  470. }
  471. function RecordVisitedHere($image_or_post_name, $image_title){
  472. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  473. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  474. if(!(isset($_SESSION[$visited_here][0]) && in_array($image_or_post_name,$_SESSION[$visited_here]))){
  475. $_SESSION[$visited_here][] = $image_or_post_name;
  476. }
  477. if(isset($image_title)){ $this->HereDisplayTitle=$image_title; }
  478. $this->HereNumber = array_search($image_or_post_name,$_SESSION[$visited_here])+1;
  479. $_SESSION['here_number'] = $this->HereNumber;
  480. $this->VisitedHere = $_SESSION[$visited_here];
  481. }
  482. function HereLinkFromNumber($number){
  483. $number -= 1; if($number<0){ $number=0; }
  484. if($number>=sizeof($this->VisitedHere)){ $number = sizeof($this->VisitedHere)-1; }
  485. if(preg_match('/(jpg|jpeg|png|gif)/u',$this->VisitedHere[$number])){ return "?here=images/".$this->VisitedHere[$number]; }
  486. else{ return "?post=".$this->VisitedHere[$number]; }
  487. }
  488. function WriteStyles(){
  489. $this->style="
  490. html{font-size:18px;font-family:'Noto Serif CJK SC','Times New Roman','SimSun', Georgia, serif;}
  491. .page{overflow:none;}
  492. body{background-color:%white%;color:%black%;}
  493. sup,sub{line-height:0;} .lpctrl{display:none;}
  494. blockquote{border-left:2px solid %black%;padding-left:0.3em;}
  495. *{box-sizing:border-box;padding:0;margin:0;font-weight:normal;}
  496. b,strong,th{font-weight:bold;}
  497. select{font-size:inherit;}
  498. .page,.page_gallery{padding:1em;padding-top:0;padding-bottom:0;}
  499. .hidden_on_desktop,.hidden_on_wide{display:none;}
  500. .hidden_on_desktop_force{display:none !important;}
  501. ::file-selector-button{background:none;border:none;}
  502. a,button,::file-selector-button{text-decoration:underline;color:%black%;text-decoration-thickness:2px;text-underline-offset:0.15em;}
  503. a:hover,.button:hover,::file-selector-button:hover{text-decoration:none;color:%gray%;}
  504. .button:disabled{background-color:%gray%;pointer-events:none;}
  505. header{position:sticky;top:0;background-color:%white%;z-index:10;padding-top:0.5em;box-shadow: 0.5em 0px %white%;}
  506. 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;}
  507. header>div{overflow:auto;white-space:nowrap;}
  508. .header_nav{display:inline;}
  509. header a,.left a,.footer a,.clean_a,.clean_a a{text-decoration:none;}
  510. header a:hover,.button:hover{color:%gray% !important;}
  511. .exp_h_f{padding-top:0.3em !important;padding-bottom:0.3em !important;line-height:1.5em !important;height:2.1em !important;}
  512. .exp_f{text-align:center;}
  513. .toc_button{position:absolute;top:0.5em;right:0;text-shadow: 0px 0px 10px %white%;background-color:%white%88;}
  514. .footer{background-color:%white%;z-index:10;position:relative;}
  515. .invert_a,.invert_a a{color:%gray%;text-decoration:none;}
  516. .invert_a:hover,.invert_a a:hover{color:%black% !important;}
  517. .gray,.gray a{color:%gray%;}
  518. hr{border:1px solid %gray%;}
  519. header ul,.small_footer ul,.small_footer span,header li,.small_footer li{display:inline-block;}
  520. header li::before,.small_footer li::before{content:' - '}
  521. //h1,h2,h3,h4,h5{font-size:1em;}
  522. //h1{text-decoration:underline;}
  523. header h1,header h2,header h3,header h4,header h5,header p{display:inline;font-size:1rem;}
  524. .main{position:relative;word-spacing:-1em;}
  525. .main *{word-spacing:initial;}
  526. pre{overflow:auto;display:block;line-break:anywhere;white-space:pre-wrap;}code{font-size:0.83em;}
  527. ul{display:block;}
  528. li{display:block;}
  529. .clean_table{border:none;font-size:1em !important;}.clean_table thead{box-shadow:none;}.clean_table td{vertical-align:top;}
  530. table{width:100%;border-collapse:collapse;border-bottom:2px solid %black%;border-top:3px solid %black%;}
  531. .settings input,.post inpiut{border:none!important;}
  532. .post table img{max-width:10rem !important;}
  533. td{padding-left:0.1em;padding-right:0.1em;}
  534. td:first-child{padding-left:0;}
  535. td:last-child{padding-right:0;}
  536. tbody tr:hover{box-shadow:inset 0 -2px 0 0px %black%;}
  537. thead{box-shadow:inset 0 -1px 0 0px %black%;}
  538. .post table{font-size:0.85em;}
  539. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 20em);}
  540. .interesting_tbody td{display:contents;}
  541. .interesting_tbody tr{position:relative;scroll-margin:4.5em}
  542. .interesting_tbody td>*{display:table-cell;}
  543. .interesting_tbody td>.wscroll{display:none !important;}
  544. .interesting_tbody .post_access{padding-top:0;}
  545. .interesting_tbody .post_menu_button{top:0;opacity:0;}
  546. .interesting_tbody td>img,.interesting_tbody td>.imd{position:absolute;left:1.4em;z-index:-1;height:1em;width:20em;
  547. display:flex;top:0.2em;object-fit:cover;max-width:calc(100% - 1.4em) !important;overflow:hidden;}
  548. .interesting_tbody td>.imd>a{display:flex;}
  549. .interesting_tbody img{object-fit:cover;width:100%;}
  550. .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);}
  551. .interesting_tbody .p_thumb{height:1em;}
  552. .interesting_tbody .p_thumb img,.interesting_tbody .p_thumb video{max-height:10rem !important;max-width:20rem !important;}
  553. tr:hover .post_menu_button{opacity:1;}
  554. .post_current_row{background-color:%graybkg%;mix-blend-mode:screen;text-shadow:0px 0px 0.1em %white%;}
  555. .align_right{text-align:right;}
  556. .left{display:inline-block;vertical-align:top;width:25%;padding-right:1.5em;padding-bottom:4rem;position:sticky;top:2em;
  557. overflow:auto;max-height:calc(100vh - 2.6em);}
  558. .center{display:inline-block;vertical-align:top;width:50%;overflow:visible;padding-bottom:4rem;}
  559. .center_slides{display:block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;font-size:5vmin;user-select:none;}
  560. .center_slides .print_column{display:table;position:fixed;top:0;right:0;left:0;bottom:0;width:100%;height:100%;z-index:90;}
  561. .center_slides .print_column .post{display:table-cell;vertical-align:middle;padding:5vmin !important;max-height:100vh;width:100vw;overflow:auto;}
  562. .center_slides .active_post{background-color:%white%;}.center_slides .post{background-color:%white%;}
  563. .center_slides .post_access{display:none;}
  564. .center_slides .post_menu_button{display:none !important;}
  565. .center_slides .post_width{display:block;vertical-align:middle;max-height:100vh;overflow-y:auto;overflow-x:hidden;width:100%;}
  566. .center_slides .linked_posts{display:none;}.center_slides .ref_compact{position:relative!important;display:block!important;}
  567. .slides_buttons{position:fixed;z-index:200;right:0.5rem;bottom:0.5rem;user-select:none;background-color:%white%aa;padding:0.5rem;font-family:monospace;}
  568. .slides_buttons a{text-decoration: none;}
  569. .center_slides .imd{text-align:center;pointer-events:none;}
  570. .imd_float{float:right;width:50% !important;clear:both;margin-left:0.5em !important;}
  571. .center_wide{display:inline-block;vertical-align:top;width:75%;padding-left:0.3em;overflow:visible;padding-bottom:4rem;}
  572. .center_full{display:inline-block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;}
  573. .center_wide .p_thumb{height:12rem;width:12rem;margin:0;margin-right:0.5rem;margin-bottom:0.5rem;box-shadow:5px 5px 15px 2px black;}
  574. .linked_posts{padding:0.5em;background-color:#0004;box-shadow:0px 0.2em 0.2em -0.2em inset %shadow%;}
  575. .active_post .linked_posts{background-color:%highlight_slice%;}
  576. input:checked~.linked_posts,input:checked~a{display:none;}
  577. .bkg_recent>.post,.bkg_section{background:%post_white%;box-shadow:0em 0em 0.5em %shadow%;margin-bottom:0.5em;}
  578. .bkg_recent>.post>.post_width :last-child{margin-bottom:0;}
  579. .sticky_title{position:sticky;top:calc(1.6rem + 2px);z-index:1;background-color:%white%;pointer-events:none;}
  580. .center_exp{display:block;width:80%;margin:0 auto;overflow:visible;padding-bottom:1em;}
  581. .table_top{position:relative;left:calc(-50% - 0.45em);width:calc(200% + 0.6em);background:%white%;z-index:1;
  582. box-shadow:0px 0px 2em 1em %white%;margin-top:2em;margin-bottom:2em;}
  583. textarea,input[type=text],input[type=password]{font-family:monospace;width:100%;display:block;font-family:inherit;max-height:60vh;font-size:inherit;}
  584. select,textarea,input[type=text],input[type=password]{font-family:monospace;background:none;border:none;border-bottom:1px solid %black%;color:%black%;}
  585. .text_highlight input{border-bottom:1px solid %white%;color:%white%;}
  586. .button{background:none;border:none;font-family:inherit;color:%black%;font-size:inherit;font-weight:bold;}
  587. .post{position:relative;scroll-margin:3.5em;}
  588. .active_post{background-color:%highlight_white%;}.active_post .post_access{background-color:%highlight_slice%;}
  589. .center_exp .post{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;}
  590. .post li,.footer_additional li,.footer_additional li,.post_dummy li
  591. {display:list-item;margin-left:1em;list-style:disc;}
  592. .post li li,.footer_additional li li,.footer_additional li li,.post_dummy li li
  593. {list-style:circle;}
  594. ol li{list-style:unset !important;}
  595. .post_width > *,.post_dummy > *,.post_ref > *{margin:0;margin-bottom:0.5rem}
  596. .post > td:nth-child(3) > *{margin:0;margin-bottom:0.5rem}
  597. .post_dummy > *{width:60%;margin:0 auto;margin-bottom:0.5rem}
  598. .post_dummy > p img{display:block;width:100%;margin:0 auto;}
  599. .gallery_left li{display:list-item;margin-left:1em;list-style:none;}
  600. .gallery_left .selected{list-style:'→';}
  601. .bkg_section .post_width{padding-top:0;padding-bottom:0;}
  602. .bkg_section .restart+.post .post_width{padding-top:0.5em;}
  603. .post_width{display:inline-block;margin-left:0.5em;vertical-align:top;}
  604. .opt_compact .post_width,.ref_compact .post_width{padding-top:0;padding-bottom:0;}
  605. .p_thumb .post_menu_button{right:0.3rem;top:0.3em;}
  606. .post_menu_button{position:absolute;display:none;right:0rem;width:1.5rem;box-shadow:0px 0px 3px %shadow%;
  607. text-align:center;border-radius:0.3em;user-select:none;cursor:pointer;z-index:10;background-color:%post_white%aa;}
  608. .pointer{cursor:pointer;}
  609. .post:hover .post_menu_button{display:block;}
  610. .pop_menu{position:absolute;top:0.3rem;z-index:95;background-color:%grayslice%;
  611. padding:0.3em;right:0.3rem;text-align:right;border-radius:0.3em;font-size:1rem;
  612. box-shadow:0px 0px 10px %shadow%;}
  613. .pop_menu li{list-style:none;margin-left:0;}
  614. .pop_menu hr{border:2px solid rgba(0,0,0,0.1);}
  615. .toc{left:60%;width:40%;top:0;position:absolute;}
  616. .paa{width:1.4rem;min-width:1.4rem;}
  617. .opt_compact .post_access,.ref_compact .post_access{border-right:2px solid %gray%;background-color:%post_white%;right:unset;left:-2em;}
  618. .active_post .opt_compact .post_access,.active_post .ref_compact .post_access{background-color:%highlight_white%;}
  619. .post_preview{overflow:hidden;margin-bottom:0.4em;background-color:%white%aa;box-shadow: 0px 0px 0.2em %shadow%;}
  620. .post_preview:hover{filter:contrast(90%);}
  621. .active_post .post_preview:hover{filter:contrast(90%);}
  622. .hide_long{max-height:12em;overflow:hidden !important;}
  623. .post .post_ref{margin:0;padding-left:1.5rem;}
  624. .post_ref_main{display:inline-block;vertical-align:top;max-height:6em;overflow:hidden;margin:0.4em;}
  625. .post_ref_images{overflow:hidden;margin:0.4em;margin-top:0;}
  626. .post_ref_hint{text-align:right;}
  627. .page_selector{padding-top:2rem;text-align:center;}
  628. .smaller{font-size:0.85em;} .bigger{font-size:1.3em;} .block{display:block;}
  629. .restart{text-align:left;padding-top:1rem;padding-bottom:0.5rem;}
  630. .opt_compact{margin-left:2rem;}
  631. .post_box_top{padding-bottom:0.3em;padding-top:0.3em;}
  632. .post_box_fixed_bottom{position:sticky;bottom:0em;background-color:%white%;z-index:5;}
  633. .spacer{height:0.5em;}
  634. .pop_right,.pop_right_big{position:fixed;top:0;right:0;bottom:0;width:30%;z-index:100;background-color:%graybkg%;display:none;
  635. transition-timing-function:ease-out;padding:1rem;overflow:auto;}
  636. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  637. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  638. @keyframes pop_slide_in_big{0%{right:-30%;}100%{right:0%;}}
  639. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-30%;}}
  640. .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;}
  641. @keyframes backdrop_fade_in{0%{opacity:0%;}100%{opacity:100%;}}
  642. @keyframes backdrop_fade_out{0%{opacity:100%;}100%{opacity:0%;}}
  643. .toc_entry_1{font-size:1.1em;}
  644. .toc_entry_2{font-size:1.0em;padding-left:0.5rem;}
  645. .toc_entry_3{font-size:0.9em;padding-left:1rem;}
  646. .toc_entry_4{font-size:0.85em;padding-left:1.5rem;}
  647. .toc_entry_5{font-size:0.8em;padding-left:2rem;}
  648. h1,h2,h3,h4,h5{scroll-margin:2.5em;}
  649. .post h1,.post h2,.post h3,.post h4,.post h5{margin-top:1rem;}
  650. .left ul h1,.left ul h2,.left ul h3,.left ul h4,.left ul h5,.left ul p{font-size:1em;}
  651. .deleted_post{color:%gray%;text-decoration:line-through;}
  652. #file_list{margin-top:0.5em;}
  653. .file_thumb img,.file_thumb video{max-height:100%;max-width:100%;object-fit:cover;min-width:100%;min-height:100%;}
  654. .file_thumb video{border:2px dashed %black%;}f
  655. #file_list li{margin-bottom:0.3em;}
  656. .ref_thumb{white-space:nowrap;overflow:hidden;}
  657. .ref_thumb .file_thumb{width:2em;height:2em;margin:0;margin-right:0.3em}
  658. .side_thumb li{margin:0.4em;display:inline-block;}
  659. .file_thumb{width:4em;height:4em;display:inline-block;line-height:0;vertical-align:middle;overflow:hidden;}
  660. .p_row{display:flex;flex-wrap:wrap;width:100%;}
  661. .p_thumb{display:flex;flex-grow:100;height:6rem;overflow:hidden;position:relative;margin-right:0.5em;margin-bottom:0.5em;}
  662. .p_thumb_narrow{width:1rem !important;flex-grow:1;opacity:0.2;}
  663. .p_thumb img,.p_thumb video{object-fit:cover;max-height:100%;min-width:100%;}.p_thumb a{display:contents;}
  664. .p_thumb:hover .post_menu_button{display:block;}
  665. .p_thumb_selected{color:%black% !important;}
  666. .p_thumb_selected{display:block;}
  667. .post .p_thumb img,.post .p_thumb video{max-height:6rem;}
  668. .p_thumb video{border-bottom:0.4em dashed %black%;border-top:0.4em dashed %black%;}
  669. .p_thumb_end{flex-grow:10000 !important;box-shadow:none;align-items:center;padding:2em !important;}
  670. .p_thumb_end:hover, .p_thumb_end a:hover{background-color:%gray%;cursor:pointer;}
  671. .big_image_box{position:fixed;top:0;bottom:0;left:0;width:75%;z-index:95;text-align:center;pointer-events:none;}
  672. .big_image_box *{pointer-events:auto;}
  673. .big_image_box img,.big_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  674. .here_image_box{position:relative;width:100%;text-align:center;height:calc(100vh - 4.5em);}
  675. .here_image_box img,.here_image_box video{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  676. .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;}
  677. .big_side_box a,.big_side_box hr,#dropping_background{color:%black%;}
  678. .big_side_box a:hover{color:%gray%;}
  679. .big_side_box *{pointer-events:auto;}
  680. .big_side_box .post_preview{border-bottom:1px dotted %black%;background-color:unset;}
  681. .image_nav{pointer-events:none;}
  682. #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;
  683. box-shadow:0px 0px 500px black inset;display:flex;align-items:center;}
  684. img,video{cursor:pointer;max-height:100%;max-width:100%;vertical-align:middle;}
  685. .post img,.post video{max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  686. .post > a > img,.post > a > video{display:block;margin:0.3em auto;}
  687. .post .original_img{max-width:100%;display:inline-block;vertical-align:middle;
  688. margin-left:auto;margin-right:auto;max-width:100%;max-height:90vh;}
  689. .center_exp .post .original_img{display:block;}
  690. .original_img img,.original_img video{max-height:90vh;max-width:100%;}
  691. .p_row .original_img{margin-bottom:0;}
  692. .post_ref .original_img{margin:unset;max-width:unset;max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  693. .imbtn{display:block;contain:content;padding:0.25em;margin-bottom:0.5em;text-decoration:none;text-shadow:0px 0px 5px %white%;}
  694. .imbtn img{display:block;object-fit:cover;position:absolute;top:0;left:0;bottom:0;right:0;margin:auto;z-index:-1;
  695. min-width:100% !important;min-height:100% !important;filter:opacity(40%);}
  696. .imbtn:hover img{filter:opacity(20%) blur(0.1em);} .imbtn:hover{color:%black% !important;}
  697. header .imbtn{display:inherit;border:none;padding:0em;height:unset;height:unset;margin:0em;contain:unset;}
  698. header .imbtn:hover{border:none;color:%gray% !important;} header .imbtn img{display:none;}
  699. .b ul{font-size:1.4em;}
  700. no_pop{cursor:unset;}
  701. p{min-height:0.8em;}
  702. .bold,.bold *{font-weight:bold;}
  703. .footer_additional{display:inline-block;width:50%;vertical-align:text-top;white-space:normal;}
  704. .small_footer{background-color:%white%;padding-bottom:0.5em;position:sticky;bottom:0px;z-index:10;box-shadow: 0.5em 0px %white%;}
  705. .small_footer>div{overflow:auto;white-space:nowrap;}
  706. .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;}
  707. .top_post_hint{margin-left:0.5em;font-weight:bold;}
  708. .white{color:%white%;}
  709. .full_box{border:1px solid %black% !important;padding:0.3rem;overflow:auto;}
  710. .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;
  711. transition:background-size .2s ease;padding:0.5em;text-shadow:0px 0px 5px black;user-select:none;pointer-events:auto;}
  712. .image_nav_prev{left:0;justify-content:left;background:linear-gradient(to left, rgba(0,0,0,0), rgba(0,0,0,0.4));
  713. background-repeat:no-repeat;background-size:0% 100%;}
  714. .image_nav_prev:hover,.image_nav_next:hover{background-size:100% 100%;}
  715. .image_nav_next{right:0;justify-content:right;background:linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.2));
  716. background-repeat:no-repeat;background-size:0% 100%;transition:background-size .2s ease;background-position-x:100%;}
  717. .inquiry_buttons{position:fixed;left:0;right:25%;text-align:center;bottom:1em;margin:0 auto;width:max-content;
  718. background-color:rgba(0,0,0,0.5);z-index:110;padding:0.2em;padding-left:1em;padding-right:1em;
  719. border-radius:1em;box-shadow:0px 0px 5px;text-shadow:0px 0px 5px black;opacity:1;user-select:none;}
  720. .lr_buttons{background-color:rgba(0,0,0,0.5);padding:0.5em;padding-top:1em;padding-bottom:1em;
  721. border-radius:1em;box-shadow:0px 0px 5px;font-size:1.2rem;text-shadow:0px 0px 5px black;}
  722. .img_btn_hidden{opacity:0;transition:opacity 0.2s;}
  723. .special_alipay{background-color:#027aff;color:white;white-space:nowrap;
  724. font-family:sans-serif;font-weight:bold;border-radius:0.7em;font-size:0.75em;padding:0.25em;}
  725. .special_paypal{background-color:white;color:#253b80;white-space:nowrap;
  726. font-family:sans-serif;font-weight:bold;border-radius:2em;font-size:0.75em;
  727. padding:0.25em;padding-left:0.5em;padding-right:0.65em;font-style: italic;}
  728. .special_paypal_inner{color:#169bd7;}
  729. #waiting_bar{position:fixed;z-index:200;top:0;left:0;right:0;height:0.2em;background-color:%black%;transform:translate(-100%,0);
  730. animation:anim_loading 1s linear infinite;}
  731. @keyframes anim_loading{0%{transform:translate(-100%,0);} 100%{transform:translate(100%,0);}}
  732. .product_ref{width:32%;padding:0.2em!important;display:inline-block;text-align:center;vertical-align:top;margin-bottom:0.8em;}
  733. .product_thumb{max-height:11em;max-width:11em;display:inline-flex;margin-bottom:0.2em;background-color:%graybkg%;}
  734. .product_thumb img,{box-shadow:none;object-fit:contain;max-height:unset;max-width:unset;width:100%;margin:0 auto !important;}
  735. .product_ref p{margin-bottom:0.2em;text-align:left;}
  736. .post_preview .product_thumb{max-height:4em;max-width:6em;}
  737. .purchase_button{background-color:%black%;color:%white%;padding-left:0.5em;padding-right:0.5em;text-decoration:none;font-weight:bold;}
  738. .page_break{page-break-after:always;}
  739. .text_highlight,.text_highlight a,.text_highlight select{background-color:%black%;color:%white%;border:none;}
  740. .gray.text_highlight,.gray.text_highlight a,.gray.text_highlight select{background-color:%gray%;color:%white%;}
  741. .show_on_print{display:none;}.inline_print{display:none;}
  742. .comment{font-size:0.9em;font-family:sans-serif;overflow:auto !important;width:100%;}
  743. .comment tbody tr:hover{box-shadow:none;}
  744. .comment table{border:none;}
  745. .comment li{display:list-item;list-style:'→';padding-left:0.3em;}
  746. .comment ul{padding-left:1em;}
  747. .comment ul li *{margin-bottom:0.5em;}
  748. .history li{display:list-item;list-style:disc;padding-left:0.3em;}
  749. .history li li{list-style:circle;}
  750. .history ul{padding-left:1em;}
  751. .history a{text-decoration:underline;}
  752. .history .list{overflow:auto;white-space:nowrap;}
  753. .diff_table{table-layout:fixed;}
  754. .diff_table thead{font-size:0.9em;text-align:center;}
  755. .diff_table tbody pre{font-size:0.9rem;white-space:pre-line;}
  756. .diff_table td{vertical-align:top;}
  757. .omittable_title{display:block;width:100%;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
  758. .wayback_close{float:right;}
  759. .wayback_expand{display:inline;}
  760. .post_selecting .post>*>*{pointer-events:none;}
  761. .post_selected{background-color:%graybkg%;}
  762. .small_pad{padding:0.2em;padding-top:0.1em;padding-bottom:0.1em;}
  763. .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%;}
  764. .wscroll:target{display:block;} .post_ref .wscroll{display:none !important;}
  765. .wayback_link{display:inline;}
  766. .imd{object-fit:cover;width:100%;}
  767. .center_exp .post>.imd,.center_exp .p_row{width:60%;}
  768. .center_exp .p_thumb img,.center_exp .p_thumb video{max-height:3rem;}
  769. .center_exp .p_thumb{max-height:3rem;filter:opacity(40%);}
  770. .center_exp .p_thumb:hover{filter:unset;}
  771. #here_buttons{display:contents;}
  772. .here_buttons_inner{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;max-height:100%;max-width:100%;}
  773. .here_btn{position:absolute;z-index:110;transform:translate(-50%,-50%);
  774. width:2em;height:2em;display:block;border:1px solid %black%;background-color:rgba(0,0,0,0.5);}
  775. .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;}
  776. .center .center{width:100%;padding-bottom:unset;}
  777. .center{border:none;}
  778. .center{overflow:auto;}
  779. .center>tbody>tr:hover{box-shadow:none;}
  780. .center>tbody>tr>td{white-space:normal;vertical-align:top;min-width:1em;}
  781. .center>tbody>tr>td:first-child{text-align:center;color:%gray%;padding-left:0.1em;}
  782. .center>tbody>tr>td:nth-child(1)>*{}
  783. .center>tbody>tr>td:nth-child(2){text-align:center;color:%gray%;}
  784. .center>tbody>tr>td:nth-child(2) a{color:%gray%;}
  785. .center>tbody>tr>td:nth-child(2) .marked{color:%black% !important;}
  786. .center>tbody>tr>td:nth-child(3){width:100%;text-align:left;}
  787. .center>tbody>tr>td:nth-child(3)>div{overflow:auto;}
  788. .center>tbody>tr>td:last-child{padding-right:0.5em;}
  789. .main>.center>tbody>tr{border-bottom:1px dotted %black%;}
  790. .ref_count{cursor:pointer;} td .ref_count{text-align:left;display:block;}
  791. .big_side_box .center{width:100%;}
  792. #big_image_upload{max-width:100%;}
  793. label{text-align:left;display:inline-block;}
  794. @media screen and (max-width:1000px) and (min-width:666px){
  795. .left{width:35%;}
  796. .center,.center_wide{width:65%;}
  797. .center_wide .p_thumb{height:8rem;width:8rem;margin-right:0.4rem;margin-bottom:0.4rem;box-shadow:3px 3px 12px 2px black;}
  798. .post_width{width:calc(100% - 1.5rem);padding-left:0.2em;}
  799. .hidden_on_wide{display:unset;}
  800. .pop_right{width:30%;}
  801. .pop_right_big{width:40%;}
  802. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  803. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  804. @keyframes pop_slide_in_big{0%{right:-40%;}100%{right:0%;}}
  805. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-40%;}}
  806. .big_side_box{width:35%;}
  807. .big_image_box{width:65%;}
  808. .inquiry_buttons{right:35%;}
  809. .table_top{left:calc(-50% - 1.7em);width:calc(154% + 0.5em);}
  810. .post_dummy > *{width:80%;max-width:55rem;}
  811. .center_exp .post>.imd,.center_exp .p_row{width:80%;max-width:55rem;}
  812. .here_btn{width:1.5em;height:1.5em;}
  813. }
  814. @media screen and (max-width:666px){
  815. html{font-size:16px;}
  816. pre{max-width:85vw;}
  817. #titlectrl:checked ~ header .mobile_fold{display:block !important;}
  818. #titlectrl:checked ~ .main .mobile_fold{display:block !important;}
  819. .mobile_fold{display:none !important;}
  820. .hidden_m{display:none !important;}
  821. .block_m{display:block !important;}
  822. .hidden_on_desktop{display:inherit;}
  823. .hidden_on_wide{display:inherit;}
  824. header{position:inherit;}
  825. header ul{display:block;}
  826. header li{display:block;}
  827. header li::before{content:''}
  828. header::before{box-shadow:none;display:none;}
  829. .small_footer::before{box-shadow:none;display:none;}
  830. .left{position:relative;width:100%;top:unset;height:unset;max-height:unset;padding-right:0;display:block;}
  831. .center,.center_wide,.center_full{display:block;position:relative;line-break:anywhere;left:0;top:0;width:100%;padding-left:0;}
  832. .center_wide .p_thumb{height:6rem;width:6rem;margin-right:0.3rem;margin-bottom:0.3rem;box-shadow:2px 2px 10px 1px black;}
  833. .pop_right,.pop_right_big{top:unset;right:0;bottom:0;left:0;width:100%;}
  834. .pop_right{height:30%;}
  835. .pop_right_big{height:70%;}
  836. @keyframes pop_slide_in{0%{bottom:-30%;}100%{bottom:0%;}}
  837. @keyframes pop_slide_out{0%{bottom:0%;}100%{bottom:-30%;}}
  838. @keyframes pop_slide_in_big{0%{bottom:-70%;}100%{bottom:0%;}}
  839. @keyframes pop_slide_out_big{0%{bottom:0%;}100%{bottom:-70%;}}
  840. .big_image_box{position:fixed;top:0;bottom:8.5rem;left:0;right:0;width:100%;}
  841. .side_box_mobile_inner{background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(1,1,1,0.9) 20%);
  842. transition:none;background-size:100% 100%;padding:0.5rem;padding-bottom: 5em;}
  843. .side_box_mobile_inner:hover{background-size:100% 100%;}
  844. .big_side_box{position:fixed;top:0;bottom:0;right:0;left:0;width:100%;
  845. height:unset;padding:0;padding-top:calc(100vh - 8.5rem);background:none;}
  846. .p_thumb{height:3rem;}
  847. .center .post{padding-right:0rem;padding-left:0rem;}
  848. .post .p_thumb img,.post .p_thumb video{max-height:3rem;}
  849. .page,.page_gallery{padding:0.2em;padding-top:0;}
  850. header{padding-top:0.3em;}
  851. .toc_button{top:0.3em;}
  852. .small_footer{padding-bottom:0.3em;}
  853. .footer_additional{display:block;width:100%;}
  854. .album_hint{display:block;font-size:1rem;}
  855. .image_nav{position:absolute !important;}
  856. .image_nav_prev,.image_nav_next{width:25%;}
  857. .image_nav_prev:hover,.image_nav_next:hover{background-size:0% 100%;color:%black% !important;}
  858. .inquiry_buttons{position:relative;left:unset;right:unset;text-align:left;bottom:unset;margin:unset;width:unset;
  859. background-color:unset;z-index:unset;padding:unset;padding-left:unset;padding-right:unset;
  860. border-radius:unset;box-shadow:unset;text-shadow:unset;}.img_btn_hidden{opacity:1;}
  861. .lr_buttons{background-color:unset;padding:unset;padding-top:unset;padding-bottom:unset;
  862. border-radius:unset;box-shadow:unset;font-size:1.3rem;text-shadow:unset;}
  863. .opt_compact,.ref_compact{line-break:anywhere;}
  864. .table_top{left:unset;width:100%;overflow:auto;}
  865. .post table img{max-width:30vw !important;}
  866. .product_ref{width:100%;display:block;}
  867. .post_dummy > *{width:100%;max-width:25rem;}
  868. .center_exp .post>.imd,.center_exp .p_row{width:100%;max-width:25rem;}
  869. .center_exp .post .p_thumb img,.center_exp .post .p_thumb video{max-height:2rem;}
  870. .center_exp .p_thumb{height:2rem;filter:opacity(40%);}
  871. .center_exp .p_thumb:hover{filter:unset;}
  872. .sticky_title{top:0;}
  873. .small_footer{position:relative;}
  874. #upload_selector{width:100%;}
  875. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 10em);}
  876. .wayback_expand{display:block;text-align:center;}
  877. .wayback_link{display:block;}
  878. .center_exp{display:block;width:100%;margin:0 auto;padding-bottom:1em;}
  879. .center_exp .post{overflow:auto;}
  880. .center_exp .imd{width:100%;}
  881. .here_btn{width:1.2em;height:1.2em;}
  882. .exp_h_f{height:unset !important;}
  883. .exp_f{margin-bottom:1em;}
  884. .linked_posts{padding-left:1em;}
  885. .center>tbody>tr>td{min-width:unset;}
  886. .center>tbody>tr>td:last-child{padding-right:0.1em;}
  887. }
  888. @media print{
  889. .small_footer .hidden_on_print{display:none}
  890. header b,.small_footer b{font-weight:normal;}
  891. header{display:table-header-group;box-shadow:none;} .main{display:table-row-group;} .small_footer{text-align:right;}
  892. header::before{box-shadow:none;display:none;} header::after{display:block;height:1em;content:' ';}
  893. .small_footer::before{box-shadow:none;display:block;height:1em;position:relative;}
  894. body,footer,header,.small_footer,a,.clean_a,.invert_a,.clean_a a,.invert_a a{background:none;color:black;}
  895. .bkg_section,.bkg_recent>.post,.active_post{background:none !important;box-shadow:none;}
  896. .post *,.post_dummy *{margin-bottom:0em;}
  897. .p_row,.post table,.post img,.post_ref img,.post_ref .original_img,
  898. .post_width>.original_img,.post pre{margin-top:0.5rem;margin-bottom:0.5rem;text-indent:0;}
  899. pre{white-space:pre-wrap;line-break:anywhere;}
  900. .post p{line-height:1.3;text-indent:2em;} .product_ref p {text-indent:0;}
  901. .post table img{margin:0 !important;}
  902. .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;}
  903. .post ul,.post ol{margin:0.5rem !important;margin-left:1.4rem !important;margin-right: 0rem !important;}
  904. table{border-bottom:2px solid black;border-top:2px solid black;}
  905. .post table img{max-width:5em;max-width:8em !important;max-height:8em !important;}
  906. thead{box-shadow:inset 0 -1px 0 0px black;background:none;}
  907. .linked_posts{display:none;}
  908. .post_width{overflow:clip;left:0;width:100%;padding-left:0em;padding-right:0em;}
  909. .section .post h2{font-size:1.8em;margin:1.5em auto 0 !important;}.list h2,.compact h2{margin:0 !important;}
  910. .section .post h3{font-size:1.5em;margin:1.0em auto 0 !important;}.list h3,.compact h3{margin:0 !important;}
  911. .section .post h4{font-size:1.1em;margin:0.5em auto 0 !important;}.list h4,.compact h4{margin:0 !important;}
  912. .post .post{margin-bottom:0.5rem;margin-top:0.5rem;}
  913. .gray,.gray a,.deleted_post{color:rgba(0,0,0,0.5);}
  914. .left{display:none;}
  915. .center, .center_wide, .center_full{width:100%;padding:0;font-size:16px;line-height:1.3}
  916. hr{border:1px solid black;}
  917. .post_box_top{display:none;}
  918. .post_access{display:none;}
  919. .opt_compact .post_access,.ref_compact .post_access{border-right:none;display:inline;background:unset;}
  920. .text_highlight,.text_highlight a,.gray.text_highlight,.gray.text_highlight a,.purchase_button{background-color:lightgray;color:black;}
  921. .hidden_on_print{display:none !important;}
  922. .print_column{column-count:2;margin-top:0.5rem;margin-bottom:0.5rem;}
  923. .print_column .print_column{column-count:1;margin:unset;}
  924. .opt_compact{margin-left:0;left:1.5em;}
  925. .post .post_ref{padding-left:2rem;}
  926. .section .post h1:first-of-type{column-span:all;display:block;margin-top:1rem !important;margin-bottom:0.5rem !important;}
  927. .bkg_section .restart+.post .post_width{padding-top:0;}
  928. .restart{background-color:unset;padding:unset;}
  929. .opt_compact h1:first-of-type,.ref_compact h1:first-of-type{display:unset;}
  930. .table_top{position:relative;left:0;width:100%;background:none;z-index:1;box-shadow:none;}
  931. .header_nav{display:none;}
  932. .show_on_print{display:block;}.inline_print{display:inline;}
  933. blockquote{border-left:2px solid black;}
  934. .footer_additional{display:none;}
  935. .small_footer{margin-top:1rem;box-shadow:none;}
  936. .page{display:table;width:100%;}
  937. .page_selector{display:none;}
  938. .p_thumb{height:4rem;margin-bottom:0.25rem;}
  939. .post .p_thumb img,.post .p_thumb video{max-height:4rem;}
  940. .sticky_title{box-shadow:none;}
  941. .center_wide .p_thumb{display:inline-flex;height:5.8rem;width:5.8rem;margin-right:0;}
  942. .center_wide .p_row{display:block;}
  943. .interesting_tbody{background:none;}
  944. .interesting_tbody img{display:none !important;}
  945. .imd{margin-top:0.5em;margin-bottom:0.5em;line-height:0px;}
  946. .p_row .imd{margin-top:0em;margin-bottom:0em;}
  947. .center,.center>tbody,.center>tbody>tr,.center>tbody>tr>td{display:block;}
  948. .main>.center>tbody>tr{border:none;}
  949. .center>tbody>tr>td:first-child{display:none;color:rgba(0,0,0,0.5);}
  950. .center>tbody>tr>td:nth-child(2){display:none;color:rgba(0,0,0,0.5);}
  951. .center>tbody>tr>td:nth-child(2) a{display:none;color:rgba(0,0,0,0.5);}
  952. .center>tbody>tr>td:nth-child(3){margin:unset;padding:unset;}
  953. .post > td:nth-child(3) > *{margin:unset;padding:unset;}
  954. .wide_post_print{column-span:all;margin-top:1em;margin-bottom:1em;}
  955. }
  956. ";
  957. //$this->style=preg_replace('/%highlight_white%/','#5b3607',$this->style);
  958. //$this->style=preg_replace('/%highlight_slice%/','#734307',$this->style);
  959. //$this->style=preg_replace('/%grayslice%/','#442c0b',$this->style);
  960. //$this->style=preg_replace('/%post_white%/','#2d2110',$this->style);
  961. //$this->style=preg_replace('/%white%/','#231a0d',$this->style);
  962. //$this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
  963. //$this->style=preg_replace('/%gray%/','#ac7843',$this->style);
  964. //$this->style=preg_replace('/%graybkg%/','#39270e',$this->style);
  965. //$this->style=preg_replace('/%shadow%/','#000000cc',$this->style);
  966. $this->style=preg_replace('/%highlight_white%/','#804a06',$this->style);
  967. $this->style=preg_replace('/%highlight_slice%/','#ae6407',$this->style);
  968. $this->style=preg_replace('/%grayslice%/','#6a491c',$this->style);
  969. $this->style=preg_replace('/%post_white%/','#4a3413',$this->style);
  970. $this->style=preg_replace('/%white%/','#2d2214',$this->style);
  971. $this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
  972. $this->style=preg_replace('/%gray%/','#f8ca9b88',$this->style);
  973. $this->style=preg_replace('/%graybkg%/','#a9270e',$this->style);
  974. $this->style=preg_replace('/%shadow%/','#000000ee',$this->style);
  975. $f = fopen('styles/main.css','w');
  976. fwrite($f,$this->style);
  977. fclose($f);
  978. }
  979. function GiveSafeEMail(){
  980. return preg_replace('/\./u','[dot]',preg_replace('/\@/u','[at]',$this->EMail));
  981. }
  982. function &FindImage($name, $loose=false){ if(!isset($name) || !$name){ return $this->NULL_IMAGE; }
  983. if(isset($this->Images[0])) foreach($this->Images as &$im){
  984. if($loose) { if(preg_match('/'.preg_quote($name).'/u',$im['name'])) return $im; }
  985. else { if($im['name']==$name) return $im; }
  986. }
  987. return $this->NULL_IMAGE;
  988. }
  989. function &GiveImageInHere($rand=false){
  990. $this->ReadImages(); $this->DetectPageType();
  991. $album = $this->PageType=='here'?$this->HereAlbum:$this->ExpAlbum;
  992. if(!isset($album) || !$album){
  993. if(isset($this->Images[0])) return $this->Images[0]; else return $this->NULL_IMAGE; }
  994. $imlist=[]; $imlist_fallback=[];
  995. if(isset($this->Images[0])){
  996. foreach($this->Images as &$im){
  997. if(isset($im['galleries'][0]) && in_array($album,$im['galleries']) && $this->CanShowImage($im)){
  998. if(!$rand) return $im; else {
  999. $imlist_fallback[] = $im;
  1000. if(!in_array($im['name'],$this->VisitedHere)) $imlist[] = $im;
  1001. }
  1002. }
  1003. }
  1004. }
  1005. if(!$rand || !isset($imlist_fallback[0])) return $this->NULL_IMAGE;
  1006. if(sizeof($imlist)){
  1007. $r = random_int(0, sizeof($imlist)-1);
  1008. return $imlist[$r];
  1009. }else{
  1010. $r = random_int(0, sizeof($imlist_fallback)-1);
  1011. return $imlist_fallback[$r];
  1012. }
  1013. }
  1014. function ImageTitle($im){
  1015. $imtitle = (isset($im)&&isset($im['title']))?$im['title']:NULL;
  1016. if(isset($im['parent'])&&($imp = &$this->FindImage($im['parent'],true))&&isset($imp['title'])){ $imtitle=$imp['title']; }
  1017. return $imtitle;
  1018. }
  1019. function ImageHasHere(&$im, $here_name){
  1020. if(!isset($im['here'])||!isset($im['here'][0])) return false;
  1021. foreach($im['here'] as $h) { if($h[0] == $here_name) return true; } return false;
  1022. }
  1023. function ReadImages($clear_non_exist = false){
  1024. $path = 'images/list.md';
  1025. if($this->DoneReadImages){ return; }
  1026. if(!file_exists($path)){ $f = fopen($path,'w'); fflush($f); fclose($f); }
  1027. $c = file_get_contents($path);
  1028. if(preg_match_all('/GALLERY\s+(\S+)(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  1029. $g=[]; $g['name']=$m[1];//$g['count']=0;
  1030. if(preg_match('/FEATURED([^;]*?);/u', $m[2], $arg)){ $g['featured']=true; }
  1031. if(preg_match('/EXPERIMENTAL([^;]*?);/u', $m[2], $arg)){ $g['experimental']=true; }
  1032. if(preg_match('/DESCRIPTION\s+([^;]+);/u', $m[2], $arg)){ $g['description']=$arg[1]; }
  1033. $this->Galleries[] = $g;
  1034. }
  1035. if(preg_match_all('/^-\s*([^;]+)\s*?;\s*?(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  1036. $name = trim($m[1]);
  1037. $item = []; $item['file'] = 'images/'.$name; $item['name'] = $name;
  1038. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  1039. if(preg_match('/REFS\s+([^;]*);/u',$m[2],$refs) && preg_match_all('/[0-9]{14}/u',$refs[1],$rs, PREG_SET_ORDER)){
  1040. $item['refs']=[];
  1041. foreach($rs as $r){ if(!in_array($r[0], $item['refs'])) $item['refs'][] = $r[0]; }
  1042. }
  1043. if(preg_match('/GAL\s+([^;]*);/u',$m[2],$gals) && preg_match_all('/(\S+)/u',$gals[1],$ga, PREG_SET_ORDER)){
  1044. $item['galleries']=[];
  1045. foreach($ga as $g){ if(!in_array($g[0], $item['galleries'])) $item['galleries'][] = $g[0]; }
  1046. }
  1047. if(preg_match('/PRODUCT\s+([^;]*);/u',$m[2],$product)){ $item['product']=$product[1]; }
  1048. if(preg_match('/PARENT\s+([^;]*);/u',$m[2],$parent)){ $item['parent']=$parent[1]; }
  1049. if(preg_match('/TITLE\s+([^;]*);/u',$m[2],$title)){ $item['title']=$title[1]; }
  1050. if(preg_match('/ALIGN\s+([^;]*);/u',$m[2],$align)){ $item['align']=$align[1]; }
  1051. if(preg_match('/HERE\s+([^;]*);/u',$m[2],$heres) && preg_match_all('/(\S+)-(\S+)-(\S+)/u',$heres[1],$here, PREG_SET_ORDER)){
  1052. $item['here']=[];
  1053. foreach($here as $h){ if(!$this->ImageHasHere($item, $h[1])) $item['here'][] = [$h[1],$h[2],$h[3]]; }
  1054. }
  1055. if(preg_match('/\.mp4/u',$item['name'])){
  1056. $item['video']='video/mp4';
  1057. }
  1058. $this->Images[] = $item;
  1059. }
  1060. $files = array_merge([],glob('images/*.jpg'));
  1061. $files = array_merge($files,glob('images/*.jpeg'));
  1062. $files = array_merge($files,glob('images/*.png'));
  1063. $files = array_merge($files,glob('images/*.gif'));
  1064. $files = array_merge($files,glob('images/*.mp4'));
  1065. if(isset($files[0]))foreach($files as $file) {
  1066. if(preg_match('/[0-9]{14,}\.(jpg|jpeg|gif|png|mp4)/u', $file, $m)) {
  1067. $name = trim($m[0]);
  1068. if(!$this->FindImage($name)){
  1069. $item = []; $item['name']=$name; $item['file'] = 'images/'.$name;
  1070. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  1071. $this->Images[] = $item;
  1072. }
  1073. }
  1074. }
  1075. if($clear_non_exist){
  1076. if(isset($this->Images[0]) && isset($files[0])){
  1077. foreach($this->Images as &$im){
  1078. if(!in_array($im['file'],$files)){
  1079. $im['deleted'] = 1;
  1080. }
  1081. }
  1082. }
  1083. }
  1084. function cmpf($a, $b){
  1085. if ($a['name'] == $b['name']) return 0;
  1086. return (($a['name'] > $b['name']) ? 1 : -1);
  1087. }
  1088. function cmpaf($a, $b){
  1089. if ($a['name'] == $b['name']) return 0;
  1090. return ($a['name'] > $b['name']) ? -1 : 1;
  1091. }
  1092. if(isset($this->Galleries[0]))usort($this->Galleries,"cmpf");
  1093. if(isset($this->Images[0]))usort($this->Images,"cmpaf");
  1094. $this->DoneReadImages = 1;
  1095. }
  1096. function WriteImages(){
  1097. if(isset($this->WayBack)) return;
  1098. $path = 'images/list.md';
  1099. $f = fopen($path,'w');
  1100. if(isset($this->Galleries[0]))foreach($this->Galleries as &$g){
  1101. if(isset($g['deleted'])) continue;
  1102. fwrite($f,'GALLERY '.$g['name']);
  1103. if(isset($g['featured']) && $g['featured']!=false) { fwrite($f,' FEATURED;'); }
  1104. if(isset($g['experimental']) && $g['experimental']!=false) { fwrite($f,' EXPERIMENTAL;'); }
  1105. if(isset($g['description']) && $g['description']!="") { fwrite($f,' DESCRIPTION '.$g['description'].';'); }
  1106. fwrite($f, PHP_EOL);
  1107. }
  1108. if(isset($this->Images[0]))foreach($this->Images as &$im){
  1109. if(isset($im['deleted'])) continue;
  1110. fwrite($f, "- ".$im['name'].'; ');
  1111. if(isset($im['refs']) && isset($im['refs'][0])){ fwrite($f, 'REFS '.implode(" ",$im['refs'])."; "); }
  1112. if(isset($im['galleries']) && isset($im['galleries'][0])){ fwrite($f, 'GAL '.implode(" ",$im['galleries'])."; "); }
  1113. if(isset($im['product']) && $im['product']!=''){ fwrite($f, 'PRODUCT '.$im['product']."; "); }
  1114. if(isset($im['parent']) && $im['parent']!=''){ fwrite($f, 'PARENT '.$im['parent']."; "); }
  1115. if(isset($im['title']) && $im['title']!=''){ fwrite($f, 'TITLE '.$im['title']."; "); }
  1116. if(isset($im['align']) && $im['align']!='' && $im['align']!='middle'){ fwrite($f, 'ALIGN '.$im['align']."; "); }
  1117. if(isset($im['here']) && $im['here']!=''){ fwrite($f, 'HERE ');
  1118. foreach($im['here'] as $here){ fwrite($f, implode('-',$here).' '); } fwrite($f, '; ');
  1119. }
  1120. fwrite($f, PHP_EOL);
  1121. }
  1122. fflush($f);
  1123. fclose($f);
  1124. }
  1125. function EditImage($name, $link_gallery, $do_remove = false, $product_link=NULL, $rename=NULL, $parent=NULL, $align=NULL){
  1126. if(!($im = &$this->FindImage($name))) return;
  1127. if(isset($link_gallery)){
  1128. if($do_remove){
  1129. if(!isset($im['galleries']) || !isset($im['galleries'][0])) return;
  1130. foreach($im['galleries'] as $key => $g){ if ($g==$link_gallery) unset($im['galleries'][$key]); }
  1131. $im['galleries'] = array_merge($im['galleries']);
  1132. }else{
  1133. if(!isset($im['galleries'])) $im['galleries']=[];
  1134. foreach($im['galleries'] as &$g){ if ($g==$link_gallery) return; }
  1135. $im['galleries'][]=$link_gallery;
  1136. }
  1137. }
  1138. if(isset($product_link)){
  1139. if($product_link!=''){$im['product']=$product_link;}
  1140. else{unset($im['product']);}
  1141. }
  1142. if(isset($rename) && $rename!=$im['name']){
  1143. $ext=pathinfo($im['file'],PATHINFO_EXTENSION);
  1144. rename($im['file'], 'images/'.$rename.'.'.$ext);
  1145. if(isset($im['thumb'])) rename($im['thumb'], 'images/thumb/'.$rename.'.'.$ext);
  1146. $im['name'] = $rename.'.'.$ext;
  1147. }
  1148. if(isset($parent) && $parent!=$im['parent']){
  1149. if($parent==''){ unset($im['parent']); }
  1150. else{ $im['parent'] = $parent; }
  1151. }
  1152. if(isset($align) && in_array($align,['top','middle','bottom'])){
  1153. if($align=='middle'){ unset($im['align']); }
  1154. else{ $im['align']=$align; }
  1155. }
  1156. $this->NeedWriteImages = 1;
  1157. }
  1158. function RegenerateThumbnails(){
  1159. $glob = glob('images/*.jpg');
  1160. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1161. foreach($glob as $file) {
  1162. $thumb_destination = 'images/thumb/'.basename($file);
  1163. $img = new Imagick($file); $geo=$img->getImageGeometry();
  1164. $width=$geo['width']; $height=$geo['height'];
  1165. $lim=400;
  1166. $scale = $lim / min($width,$height);
  1167. if($scale<1){
  1168. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1169. }
  1170. $img->setImageFormat('jpeg');
  1171. $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1172. $img->setImageCompressionQuality(90);
  1173. $img->writeImage($thumb_destination);
  1174. }
  1175. }
  1176. function CleanupImageCompression($run=false){
  1177. $glob = glob('images/*.jpg');
  1178. if(!$run){
  1179. echo $this->T("将重新压缩下列文件:")."<style>img{max-width:10em;max-height:10em;}</style><ul>";
  1180. }
  1181. foreach($glob as $file) {
  1182. $destination = 'images/'.basename($file);
  1183. $img = new Imagick($file); $geo=$img->getImageGeometry();
  1184. $width=$geo['width']; $height=$geo['height'];
  1185. $interlace=$img->getImageInterlaceScheme();
  1186. $progressive=($interlace==imagick::INTERLACE_NO || $interlace==imagick::INTERLACE_LINE || $interlace==imagick::INTERLACE_UNDEFINED);
  1187. $sizelim=1920;$abs_max=2560;
  1188. $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
  1189. $sz=filesize($destination);
  1190. if($scale<0.98 && $sz>2097152 && $progressive){ /* need scale, greater than 2mb, and not interlaced */
  1191. if(!$run){
  1192. echo "<li><a href='index.php?pic=$destination'><img src='images/thumb/".basename($file)."'><br />$destination, $width x $height, $interlace</a></li>";
  1193. }else{
  1194. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1195. $img->setImageFormat('jpeg');
  1196. $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1197. $img->setImageCompressionQuality(90);
  1198. $img->writeImage($destination);
  1199. }
  1200. }
  1201. $img->clear();
  1202. }
  1203. if(!$run){
  1204. echo "</ul><a href='index.php?cleanup_image_compression=true&run=true'>".$this->T("立即执行")."</a>"; exit;
  1205. }
  1206. }
  1207. function CompressImage($source, $destination, $thumb_destination, $quality, $sizelim, $abs_max, $ext) {
  1208. $img = new Imagick($source); $geo=$img->getImageGeometry(); $img2 = clone $img;
  1209. $width=$geo['width']; $height=$geo['height'];
  1210. $lim=400;
  1211. $scale = $lim / min($width,$height);
  1212. if($scale<1){
  1213. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  1214. }
  1215. $img->setImageFormat('jpeg');
  1216. $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1217. $img->setImageCompressionQuality($quality);
  1218. $img->writeImage($thumb_destination);
  1219. $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
  1220. if($scale<0.98 || ($ext!='jpg'&&$ext!='jpeg')){
  1221. $img2->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.5);
  1222. $img2->setImageFormat('jpeg');
  1223. $img2->setImageCompressionQuality($quality);
  1224. $img2->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  1225. $img2->writeImage($destination);
  1226. }else{
  1227. rename($source,$destination);
  1228. }
  1229. }
  1230. function DoUpload(){
  1231. if(!isset($_FILES['upload_file_name'])) return 0;
  1232. if(!is_dir('images/thumb')) mkdir('images/thumb');
  1233. if($_FILES['upload_file_name']['error']>0){
  1234. echo"file upload err code ".$_FILES['upload_file_name']['error']; exit;
  1235. return -1;
  1236. }else{
  1237. $ext=strtolower(pathinfo($_FILES['upload_file_name']['name'],PATHINFO_EXTENSION));
  1238. if(!in_array($ext,['jpg','jpeg','png','gif','mp4'])) return 0;
  1239. $fp = fopen('.la_lock',"w");
  1240. while (!flock($fp, LOCK_EX| LOCK_NB)){
  1241. usleep(10000);
  1242. }
  1243. $num=date('YmdHis'); $replace=0;
  1244. if(isset($_POST['image_replace_button']) && isset($_GET['pic']) && preg_match('/([0-9]{14,})/u',$_GET['pic'],$mim)){
  1245. $num = $mim[1]; $replace=1;
  1246. }
  1247. $base = 'images/'.$num;
  1248. $thumb = 'images/thumb/'.$num;
  1249. $use_ext=($ext=='gif' || $ext=='mp4')?('.'.$ext):('.jpg');
  1250. $final_path = $base.$use_ext; $final_thumb = $thumb.$use_ext; $i=0;
  1251. if(!$replace) while(file_exists($final_path)){
  1252. $final_path = $base.strval($i).$use_ext; $final_thumb = $thumb.strval($i).$use_ext; $i++;
  1253. }
  1254. if($ext!='gif' && $ext!='mp4'){
  1255. $compress = (isset($_GET['compress'])&&$_GET['compress']);
  1256. $this->CompressImage($_FILES['upload_file_name']['tmp_name'], $final_path, $final_thumb, 90,
  1257. $compress?800:1920, $compress?1920:2560, $ext);
  1258. }else{
  1259. move_uploaded_file($_FILES['upload_file_name']['tmp_name'], $final_path);
  1260. }
  1261. flock($fp, LOCK_UN);
  1262. fclose($fp);
  1263. $this->ReadImages(true);
  1264. $this->WriteImages();
  1265. echo '<uploaded>'.pathinfo($final_path,PATHINFO_BASENAME)."</uploaded>";
  1266. if(isset($_POST['image_replace_button'])){
  1267. header('Location: '.$_SERVER['REQUEST_URI']);exit;
  1268. }
  1269. exit;
  1270. return 1;
  1271. }
  1272. return 0;
  1273. }
  1274. function &GetGallery($name){
  1275. if(isset($this->Galleries[0])) foreach($this->Galleries as &$g){
  1276. if($g['name'] == $name) return $g;
  1277. }
  1278. return $this->NULL_GALLERY;
  1279. }
  1280. function EditGallery($name, $new_name=null, $delete=false, $do_rw=true, $set_featured=null, $set_experimental=null,$desc=null){
  1281. $this->ReadImages();
  1282. $gallery = &$this->GetGallery($name);
  1283. if(!isset($gallery)){
  1284. if(!isset($new_name) || preg_match('/main|trash|\s/u',$new_name))return;
  1285. $g = []; $g['name']=$new_name;
  1286. $this->Galleries[]=$g;
  1287. }else{
  1288. if(isset($new_name)) {
  1289. if(preg_match('/main|trash|\s/u',$new_name))return;
  1290. $gallery['name'] = $new_name;
  1291. foreach ($this->Images as &$im){
  1292. if(isset($im['galleries'])&&isset($im['galleries'][0]))foreach($im['galleries'] as &$g){
  1293. if($g == $name){ $g = $new_name; }
  1294. }
  1295. }
  1296. }
  1297. //if(isset($count)) $gallery['count'] = $count;
  1298. if(isset($delete) && $delete) $gallery['deleted'] = true;
  1299. if(isset($set_featured)) $gallery['featured'] = $set_featured;
  1300. if(isset($set_experimental)) $gallery['experimental'] = $set_experimental;
  1301. if(isset($desc)) $gallery['description'] = $desc;
  1302. }
  1303. if($do_rw) { $this->NeedWriteImages = 1; }
  1304. }
  1305. function ClearData(){
  1306. $this->Posts = [];
  1307. $this->Threads = [];
  1308. $this->Images = [];
  1309. $this->Archive = [];
  1310. $this->ArchiveHandles = [];
  1311. }
  1312. function InsertArchivePost(&$post){
  1313. $a = NULL;
  1314. if(($a = &$this->GetArchiveHandle($post['id']))==$this->NULL_POST){
  1315. $ah = []; $ah['id'] = $post['id']; $ah['list'] = [];
  1316. $this->ArchiveHandles[] = &$ah; $a = &$ah;
  1317. }
  1318. $a['list'][] = $post;
  1319. $this->Archive[] = $post;
  1320. }
  1321. function ReadArchiveFromFile($path){
  1322. if(!file_exists($path)){
  1323. return;
  1324. }
  1325. $c = file_get_contents($path);
  1326. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1327. foreach($matches as $m){
  1328. $post = [];
  1329. $post['id'] = $m[1];
  1330. $post['content'] = trim($m[3]);
  1331. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1332. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1333. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1334. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1335. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1336. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1337. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1338. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1339. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1340. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1341. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1342. if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
  1343. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1344. foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
  1345. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1346. $post['merged_into'] = [trim($n[1]),trim($n[2])];
  1347. }
  1348. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1349. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1350. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1351. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1352. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1353. }
  1354. $this->InsertArchivePost($post);
  1355. }
  1356. }
  1357. }
  1358. function SortArchive(){
  1359. $cmpac = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1360. $cmpap = function($a, $b){ if ($a['id'] == $b['id']) return ((($a['version'] > $b['version']) ? 1 : -1));
  1361. return (($a['id'] > $b['id']) ? 1 : -1);
  1362. };
  1363. if(isset($this->Archive[0])){
  1364. usort($this->Archive,$cmpap);
  1365. $year_begin = substr($this->Archive[0]['id'],0,4);
  1366. $this->YearBegin = ($year_begin<$this->YearBegin)?$year_begin:$this->YearBegin;
  1367. }
  1368. if(isset($this->ArchiveHandles[0])){
  1369. usort($this->ArchiveHandles,$cmpac);
  1370. foreach($this->ArchiveHandles as &$a){
  1371. if(isset($a['list'])){ usort($a['list'],$cmpap);
  1372. $last_valid=NULL;
  1373. foreach($a['list'] as &$ver){ $ver['archive']= &$a;
  1374. if(isset($ver['merged_thread'])){ $ver['content']=$last_valid; }
  1375. else{ $last_valid = $ver['content']; } }
  1376. if(isset($a['list'][0]['version'])&&$a['list'][0]['version']>$a['list'][0]['id']){ /* if early versions missing. */
  1377. $origin=$a['list'][0]; $origin['version']=$origin['id']; array_unshift($a['list'], $origin);
  1378. }
  1379. }
  1380. if(($p = &$this->GetPost($a['id'],true))!=NULL){
  1381. $p['archive'] = &$a;
  1382. }
  1383. }
  1384. }
  1385. }
  1386. function ReadPostsFromFile($path){
  1387. if(!file_exists($path)){
  1388. $f = fopen($path,'w');
  1389. fclose($f);
  1390. }
  1391. $c = file_get_contents($path);
  1392. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1393. foreach($matches as $m){
  1394. $post = [];
  1395. $post['id'] = $m[1];
  1396. $post['real_content'] = trim($m[3]);
  1397. $post['content'] = &$post['real_content'];
  1398. if(preg_match('/COMMENT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['comment_to'] = $n[1];
  1399. if(preg_match('/EMAIL\s+([^;]+)\s*;/u', $m[2], $n)) $post['email'] = $n[1];
  1400. if(preg_match('/NAME\s+([^;]+)\s*;/u', $m[2], $n)) $post['name'] = $n[1];
  1401. if(preg_match('/LINK\s+([^;]+)\s*;/u', $m[2], $n)) $post['link'] = $n[1];
  1402. if(preg_match('/IP\s+([^;]+)\s*;/u', $m[2], $n)) $post['ip'] = $n[1];
  1403. if(preg_match('/NEXT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['next'] = $n[1];
  1404. if(preg_match('/PREV\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['prev'] = $n[1];
  1405. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1406. if(preg_match('/MDEL\s*;/u', $m[2])) $post['mark_delete'] = True;
  1407. if(preg_match('/MVAL\s*([^;]+);/u', $m[2], $n)) $post['mark_value'] = trim($n[1]);
  1408. if(preg_match('/MSTDN\s+(\S+)\s*;/u', $m[2], $n)) $post['mastodon_url'] = $n[1];
  1409. if(preg_match('/REFS\s*([^;]+);/u', $m[2], $ma)){
  1410. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1411. foreach($links as $l){ $entries[] = $l[1]; } $post['refs'] = $entries; } }
  1412. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1413. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1414. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1415. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1416. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1417. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1418. if(preg_match('/HASTAG\s*([^;]+);/u', $m[2], $ma)){
  1419. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1420. foreach($links as $l){ $entries[] = $l[1]; } $post['hastag'] = $entries; } }
  1421. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1422. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1423. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1424. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1425. $post['merged_into'] = [trim($n[1]),trim($n[2])]; }
  1426. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1427. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1428. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1429. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1430. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1431. }
  1432. if(preg_match('/NUM\s+([0-9]{1,})\s*;/u', $m[2], $n)){ $post['number']=$n[1]; $this->PNUMBER=max($post['number'],$this->PNUMBER); }
  1433. else{ $this->PNUMBER++; $post['number']=$this->PNUMBER; }
  1434. $post['number']=$this->PNUMBER; $this->PNUMBER++;
  1435. if(isset($post['mark_value']) && $post['mark_value']==5){
  1436. $post['product']=[];
  1437. }
  1438. /* marks add here */
  1439. $this->Posts[] = $post;
  1440. if(isset($post['comment_to']) && ($target_post = &$this->GetPost($post['comment_to'],true))){
  1441. if(!isset($target_post['comments']) || !isset($target_post['comments'][0])) $target_post['comments']=[];
  1442. $target_post['comments'][]=&$this->Posts[count($this->Posts) - 1];
  1443. }
  1444. }
  1445. }
  1446. }
  1447. function SortPosts($wayback=false){
  1448. $cmpp = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1449. $sortlist = &$this->Posts;
  1450. if($wayback) $sortlist = &$this->WaybackPosts;
  1451. if(isset($sortlist[0])){
  1452. usort($sortlist,$cmpp);
  1453. $this->YearEnd = substr($this->TIME_STRING,0,4);
  1454. $this->YearBegin = substr($sortlist[0]['id'],0,4);
  1455. }
  1456. }
  1457. function ReadPosts(){
  1458. if ((!file_exists('la_config.md') || is_readable('la_config.md') == false) ||
  1459. (!file_exists('la_config.php') || is_readable('la_config.php') == false) ||
  1460. (!is_dir('posts') || is_readable('posts') == false) ||
  1461. (!is_dir('archive') || is_readable('archive') == false) ||
  1462. (!is_dir('images') || is_readable('images') == false) ||
  1463. (!is_dir('styles') || is_readable('styles') == false)){
  1464. $this->Install();
  1465. }
  1466. if($this->DoneReadPosts){ return; }
  1467. $file_list = [];
  1468. $glob = glob('posts/*');
  1469. foreach($glob as $file) {
  1470. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1471. $file_list[] = $file;
  1472. }
  1473. }
  1474. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1475. foreach($file_list as $f) {
  1476. $this->ReadPostsFromFile($f);
  1477. }
  1478. $this->SortPosts();
  1479. $this->DetectThreads();
  1480. $this->DoneReadPosts=1;
  1481. }
  1482. function UpdatePostRefsForWayback(){
  1483. if(!isset($this->WayBack)) return;
  1484. if(isset($this->Images[0])) foreach($this->Images as &$i){ unset($i['refs']); }
  1485. if(!isset($this->WaybackPosts[0])) return;
  1486. foreach($this->WaybackPosts as &$p){ unset($p['refs']); }
  1487. foreach($this->WaybackPosts as &$p){
  1488. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $r){
  1489. $pr = &$this->GetPost($r); if(isset($pr)){
  1490. if(!isset($pr['refs'])) $pr['refs']=[];
  1491. if(!in_array($p['id'],$pr['refs'])){ $pr['refs'][] = $p['id']; }
  1492. }
  1493. }
  1494. if(isset($p['hasi']) && isset($p['hasi'][0])) foreach($p['hasi'] as $r){
  1495. $ir = &$this->FindImage($r); if(isset($ir)){
  1496. if(!isset($ir['refs'])) $ir['refs']=[];
  1497. if(!in_array($p['id'],$ir['refs'])){ $ir['refs'][] = $p['id'];}
  1498. }
  1499. }
  1500. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1501. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1502. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$p['id']; }
  1503. }
  1504. }
  1505. }
  1506. function ReadArchive(){
  1507. if (!is_dir('archive') || is_readable('archive') == false){ $this->Install(); }
  1508. if ($this->DoneReadArchive) return;
  1509. $file_list = []; $glob = glob('archive/*');
  1510. foreach($glob as $file) {
  1511. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1512. $file_list[] = $file;
  1513. }
  1514. }
  1515. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1516. foreach($file_list as $f) {
  1517. $this->ReadArchiveFromFile($f);
  1518. }
  1519. $this->SortArchive();
  1520. $this->DoneReadArchive=1;
  1521. $this->UpdateThreadForWayback();
  1522. $this->UpdatePostRefsForWayback();
  1523. }
  1524. function GetThreadForPost(&$post){
  1525. if(isset($post['tid'])) return;
  1526. $th = []; $iterp = NULL;
  1527. $post['tid'] = &$th; $th['first'] = &$post; $th['last'] = &$post;
  1528. if(!(isset($post['prev']) || isset($post['next']))) { $this->Threads[] = &$th; return; }
  1529. if(isset($post['prev']))for($p = $post['prev']; $p!=NULL; $p = $iterp){
  1530. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1531. $np['tid'] = &$th;
  1532. $th['first'] = &$np;
  1533. $iterp = isset($np['prev'])?$np['prev']:NULL;
  1534. }
  1535. if(isset($post['next']))for($p = $post['next']; $p!=NULL; $p = $iterp){
  1536. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1537. $np['tid'] = &$th;
  1538. $th['last'] = &$np;
  1539. $iterp = isset($np['next'])?$np['next']:NULL;
  1540. }
  1541. if(isset($th['first']['mark_value'])){
  1542. if($th['first']['mark_value']==6) $th['exp'] = true;
  1543. else if($th['first']['mark_value']==7) $th['slf'] = true;
  1544. }
  1545. if($th['first'] == $th['last']){ unset($post['tid']); return; }
  1546. $this->Threads[] = &$th;
  1547. }
  1548. function IdentifyThreadCategory(&$th,&$first_post){
  1549. unset($th['categories']);unset($th['interesting']);unset($th['reversed']);
  1550. if(preg_match('/^\s*\@(.*?)$/mu',$first_post['content'],$m)){
  1551. $first_post['categories']=[]; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1552. foreach($matches as $ma){ $first_post['categories'][] = $ma[1]; }
  1553. }
  1554. if(isset($th) && $th){ $th['categories'] = &$first_post['categories']; }
  1555. }
  1556. if(preg_match('/\{\s*WIDE\s*\}/imu',$first_post['content'],$m)){ $first_post['wide'] = true; }
  1557. if(preg_match('/\{\s*NO_TIME\s*\}/imu',$first_post['content'],$m)){ $first_post['no_time'] = true; }
  1558. if(preg_match('/\{\s*NO_TITLE\s*\}/imu',$first_post['content'],$m)){ $first_post['no_title'] = true; }
  1559. if(preg_match('/\{\s*SLIDES\s*\}/imu',$first_post['content'],$m)){ $first_post['slides'] = true; }
  1560. if(preg_match('/\{\s*HEADER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['header'] = trim($m[1]); }
  1561. if(preg_match('/\{\s*FOOTER\s+(.*?)\}/imu',$first_post['content'],$m)){ $first_post['footer'] = trim($m[1]); }
  1562. if(!isset($th)) return;
  1563. if(isset($first_post['wide'])) $th['wide']=$first_post['wide'];
  1564. if(isset($first_post['header'])) $th['header']=$first_post['header'];
  1565. if(isset($first_post['footer'])) $th['footer']=$first_post['footer'];
  1566. if(isset($first_post['no_time'])) $th['no_time']=$first_post['no_time'];
  1567. if(isset($first_post['slides'])) $th['slides']=$first_post['slides'];
  1568. if(isset($first_post['no_title'])) $th['no_title']=$first_post['no_title'];
  1569. if(preg_match('/\{\s*INTERESTING\s+(.*?)\}/imu',$first_post['content'],$m)){
  1570. $th['interesting'] = []; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1571. foreach($matches as $ma){ $th['interesting'][] = $ma[1]; }
  1572. }
  1573. }
  1574. if(preg_match('/\{\s*REVERSED(\s+.*?)?\}/imu',$first_post['content'],$m)){ $th['reversed'] = 'm';
  1575. if(isset($m[1])&&preg_match('/^\s*(y|m|d|p)/iu',$m[1],$ma)){ $th['reversed']=$ma[1]; }
  1576. }
  1577. }
  1578. function IsInterestingPost(&$p){
  1579. if(isset($p['tid']) && isset($p['tid']['interesting']) && isset($p['tid']['interesting'][0])) return true;
  1580. return false;
  1581. }
  1582. function IsReversedThread(&$th){
  1583. if(isset($th['reversed']) && $th['reversed']!=false) return true;
  1584. return false;
  1585. }
  1586. function GiveAllMergedPosts(&$po,&$arr){
  1587. if(isset($po['merged_from'])&&isset($po['merged_from'][0])) foreach($po['merged_from'] as $pm){
  1588. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr);}
  1589. }
  1590. if(isset($po['archive']) && isset($po['archive']['list'])){
  1591. foreach($po['archive']['list'] as &$ver){
  1592. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $pm){
  1593. $mp=&$this->GetPost($pm); if(isset($mp)){ if(!in_array($mp['id'],$arr)) $arr[]=$mp['id']; $this->GiveAllMergedPosts($mp,$arr); } }
  1594. }
  1595. }
  1596. }
  1597. function ThreadMakeWayback(&$th){
  1598. if(!isset($th['arr'][0])) return;
  1599. if(isset($this->WayBack)){
  1600. $remlist = [];
  1601. foreach($th['arr'] as &$pi){
  1602. $po = &$this->GetPost($pi['id'],true); if(!isset($po)){continue;/*merged*/}
  1603. if(isset($po['merged_thread']) && isset($po['version']) && $po['version']>$this->WayBack){
  1604. $remlist = array_unique(array_merge($remlist,$po['merged_thread'][0]));
  1605. }
  1606. $ah = &$this->GetArchiveHandle($po['id']);
  1607. if(isset($ah)) foreach(array_reverse($ah['list']) as &$ver){
  1608. if(!isset($ver['merged_thread'])) continue;
  1609. if((isset($ver['version']) && $ver['version'] > $this->WayBack) ||
  1610. (!isset($ver['version']) && $ver['id'] > $this->WayBack)){
  1611. $remlist = array_unique(array_merge($remlist,$ver['merged_thread'][0]));
  1612. }
  1613. }
  1614. }
  1615. if(isset($remlist[0]) && isset($th['arr'][0])){
  1616. foreach($remlist as $rem){ $this->GiveAllMergedPosts($this->GetPost($rem,true),$remlist); }
  1617. foreach($th['arr'] as $key => $pr){
  1618. foreach($remlist as $rem){ if($pr['id'] == $rem) { unset($th['arr'][$key]); break; } } }
  1619. $new_th = []; $new_arr = [];
  1620. foreach($remlist as $rem){ $np=&$this->GetPost($rem); if(isset($np)){$new_arr[]=&$np;} }
  1621. $new_th['arr'] = &$new_arr;
  1622. $this->WaybackThreads[] = &$new_th;
  1623. $this->ThreadMakeWayback($new_th);
  1624. }
  1625. }
  1626. }
  1627. function AddMergedPosts(&$p, &$array){
  1628. if(isset($p['archive']) && isset($p['archive']['list'])){
  1629. foreach($p['archive']['list'] as &$ver){
  1630. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $po){
  1631. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1632. }
  1633. }
  1634. if(isset($p['merged_from'])&&isset($p['merged_from'][0])) foreach($p['merged_from'] as $po){
  1635. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1636. }
  1637. function &array_shift_ref(&$array){if(count($array)>0){$key=key($array);$first=&$array[$key];}else{$first=null;}array_shift($array);return $first;}
  1638. function FinalizeThread(&$th, $relink_posts=false, $now=0){
  1639. $nextp=NULL; $arr=[]; $lasttime=NULL;
  1640. if(!isset($th['arr'])){
  1641. for($p = &$th['first']; $p!=$this->NULL_POST; $p = &$this->GetPost(isset($p['next'])?$p['next']:NULL,true)){
  1642. $arr[]=&$p;
  1643. } $th['arr'] = &$arr;
  1644. if(isset($this->WayBack) && $this->DoneReadArchive){ $new_arr=[];
  1645. foreach($arr as &$p){ $pa = &$this->GetPost($p['id']); if(isset($pa)) {$new_arr[]=&$pa;$this->WaybackPosts[]=&$pa;} }
  1646. foreach($arr as &$p){ $this->AddMergedPosts($p,$new_arr); }
  1647. $arr=&$new_arr; $th['arr']=&$new_arr;
  1648. $this->ThreadMakeWayback($th); }
  1649. }
  1650. $cmppt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1651. if(isset($th['arr'][0])){ usort($th['arr'],$cmppt); } $th['count'] = sizeof($th['arr']);
  1652. if($relink_posts){ $count = $th['count'];
  1653. $arr = &$th['arr'];
  1654. 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'];
  1655. $arr[$i]['tid']=&$th;}
  1656. $th['first'] = &$arr[0]; $th['last'] = &$arr[$count-1]; unset($arr[0]['prev']); unset($arr[$count-1]['next']);
  1657. }
  1658. $th['score'] = 0; if(!isset($th['first'])){ return; }
  1659. $this->IdentifyThreadCategory($th, $th['first']);
  1660. if(isset($this->WayBack)) $lasttime=$this->WayBack;
  1661. if(!isset($last_time)) $lasttime = DateTime::createFromFormat('YmdHis', $th['last']['id']);
  1662. $diff_days = ($now - date_timestamp_get($lasttime))/3600/24;
  1663. $th['score'] = (float)$th['count']*0.2 - min($diff_days,200);
  1664. if(isset($th['reversed'])){ $chunks=[]; $last_id=$last_y=$last_m=$last_d=0; $mo=$th['reversed']; $final=[];
  1665. $first_post=&$this->array_shift_ref($th['arr']); $ch=[];
  1666. while($n=&$this->array_shift_ref($th['arr'])){
  1667. $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);
  1668. if($mo=='y'&&$this_y!=$last_y){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y; }
  1669. if($mo=='m'&&$this_m!=$last_m){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y.'/'.$this_m; }
  1670. if($mo=='d'&&$this_d!=$last_d){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} $n['restart']=$this_y.'/'.$this_m.'/'.$this_d; }
  1671. if($mo=='p'){ if(isset($ch[0])){$chunks[]=$ch;$ch=[];} }
  1672. $ch[]=&$n; $last_id=$this_id; $last_y=$this_y; $last_m=$this_m; $last_d=$this_d;
  1673. }if(isset($ch[0])){$chunks[]=$ch;} if(isset($chunks[0])){$use_chunks=array_reverse($chunks);}
  1674. $final[]=&$first_post;
  1675. foreach($use_chunks as &$ch){ foreach($ch as &$p){ $final[]=&$p;} }
  1676. $th['arr']=$final; }
  1677. }
  1678. function SortThreads(){
  1679. if (!function_exists('cmpt')) {
  1680. function cmpt($a, $b){
  1681. if ($a['score'] == $b['score']) return 0;
  1682. return ($a['score'] > $b['score']) ? -1 : 1;
  1683. }
  1684. }
  1685. usort($this->Threads,"cmpt");
  1686. }
  1687. function DetectThreads(){
  1688. foreach($this->Posts as &$p){
  1689. if(isset($p['tid'])) { continue; }
  1690. $this->GetThreadForPost($p);
  1691. if(!isset($p['tid'])) { $this->IdentifyThreadCategory($this->NULL_POST, $p); }
  1692. }
  1693. if(!isset($this->Threads) || !isset($this->Threads[0])) return;
  1694. $now = date_timestamp_get(date_create());
  1695. foreach($this->Threads as &$t){
  1696. $this->FinalizeThread($t,false,$now);
  1697. }
  1698. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1699. $this->FinalizeThread($th,false,$now);
  1700. $this->Threads[] = &$th;
  1701. }
  1702. $this->SortThreads();
  1703. }
  1704. function UpdateThreadForWayback(){$now = date_timestamp_get(date_create());
  1705. if(!isset($this->WayBack) || !$this->DoneReadArchive){ return; }
  1706. foreach($this->Threads as &$t){
  1707. unset($t['arr']); $this->FinalizeThread($t,true,$now);
  1708. }
  1709. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1710. $this->FinalizeThread($th,true,$now);
  1711. $this->Threads[] = &$th;
  1712. }
  1713. $this->SortThreads();
  1714. $this->SortPosts(true);
  1715. $this->UsePosts = &$this->WaybackPosts;
  1716. }
  1717. function &GetMergedPost($id){
  1718. $this->ReadArchive();
  1719. $ah = &$this->GetArchiveHandle($id);
  1720. if(!isset($ah) || !isset($ah['list']) || !isset($ah['list'][0])){ return $this->NULL_POST; }
  1721. $ver = &$ah['list'][sizeof($ah['list'])-1];
  1722. if(!isset($ver['merged_into'])) return $this->GetPost($id);
  1723. [$tp, $tver] = $ver['merged_into'];
  1724. if(isset($this->WayBack)){
  1725. if($tver <= $this->WayBack) return $this->GetMergedPost($tp);
  1726. else return $this->GetPost($id); /* should not happen directly. */
  1727. }
  1728. return $this->GetMergedPost($tp);
  1729. }
  1730. function &GetPost($id, $latest_only=false, $find_merged=false){
  1731. if(!isset($id)) return $this->NULL_POST;
  1732. $found=&$this->NULL_POST;
  1733. if(isset($this->Posts[0])) foreach($this->Posts as &$p){
  1734. if($p&& $p['id'] == $id) { $found = &$p; break; }
  1735. if($find_merged && isset($p['hastag'][0]) && in_array($id, $p['hastag'])){ $found = &$p; break; }
  1736. }
  1737. if($latest_only || !isset($this->WayBack)){ return $found; }
  1738. else{
  1739. if(isset($found)){
  1740. if(!isset($found['archive'])&&!isset($found['archive']['list']))
  1741. { if($found['id'] > $this->WayBack) return $this->NULL_POST; else return $found; }
  1742. $last_ver = &$this->NULL_POST;
  1743. if(isset($found['archive']['list'][0])) foreach($found['archive']['list'] as &$ver){
  1744. if($ver['version'] > $this->WayBack) return $last_ver;
  1745. $last_ver = &$ver;
  1746. }
  1747. if(isset($found['version']) && $found['version'] <= $this->WayBack) return $found;
  1748. else return $last_ver;
  1749. }else{
  1750. $ah = &$this->GetArchiveHandle($id); $last_ver = &$this->NULL_POST;
  1751. if(isset($ah) && isset($ah['list']) && isset($ah['list'][0])) foreach($ah['list'] as &$ver){
  1752. if($ver['version'] > $this->WayBack) return $last_ver;
  1753. $last_ver = &$ver;
  1754. } if(!isset($last_ver['merged_into'])) return $last_ver; else{
  1755. [$tp, $tver] = $last_ver['merged_into'];
  1756. if($tver <= $this->WayBack) {
  1757. if($find_merged && $tp!=$id) return $this->GetPost($tp); return $this->NULL_POST; }
  1758. return $last_ver;
  1759. }
  1760. }
  1761. }
  1762. return $this->NULL_POST;
  1763. }
  1764. function &GetArchiveHandle($id){
  1765. if(!isset($id)) return $this->NULL_POST;
  1766. if(isset($this->ArchiveHandles[0])) foreach($this->ArchiveHandles as &$p){
  1767. if($p && $p['id'] == $id) { return $p; }
  1768. }
  1769. return $this->NULL_POST;
  1770. }
  1771. function &GetArchive($id){
  1772. if(!isset($id)) return $this->NULL_POST;
  1773. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1774. if($p && $p['id'] == $id) { return $p; }
  1775. }
  1776. return $this->NULL_POST;
  1777. }
  1778. function &GetArchiveVersion(&$ah, $version, &$next_ver, &$last_ver){
  1779. if(!isset($ah)) return $this->NULL_POST;
  1780. $found = NULL; $last_verp=NULL;
  1781. if(isset($ah['list'][0])) foreach($ah['list'] as &$p){
  1782. if(isset($found)){ $next_ver = $p; $last_ver = $last_verp; return $found; }
  1783. if($p && $p['version'] == $version) { $found = &$p; continue; }
  1784. $last_verp = &$p;
  1785. }
  1786. if(isset($found)) { $next_ver=NULL; $last_ver = $last_verp; return $found; }
  1787. return $this->NULL_POST;
  1788. }
  1789. function CacheArchiveOwnLinks(){
  1790. if(isset($this->WayBack)) return;
  1791. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1792. $this->ConvertPost($p); unset($p['hasp']); unset($p['hasi']); unset($p['hastag']);
  1793. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$p['html'],$matches,PREG_SET_ORDER)){
  1794. foreach($matches as $m){
  1795. if(!isset($p['hasp']))$p['hasp']=[]; if(!in_array($m[1],$p['hasp'])){ $p['hasp'][]=$m[1]; }
  1796. }
  1797. }
  1798. if(preg_match_all('/\/\/([0-9]{14})/u', $p['content'],$matches,PREG_SET_ORDER)){
  1799. foreach($matches as $m){
  1800. if(!isset($p['hastag']))$p['hastag']=[]; if(!in_array($m[1],$p['hastag'])){ $p['hastag'][]=$m[1]; }
  1801. }
  1802. }
  1803. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\)/u', $p['content'],$matches,PREG_SET_ORDER)){
  1804. foreach($matches as $m){
  1805. if(!isset($p['hasi']))$p['hasi']=[]; if(!in_array($m[2],$p['hasi'])){ $p['hasi'][]=$m[2]; }
  1806. }
  1807. }
  1808. }
  1809. }
  1810. function WriteArchive(){
  1811. if(isset($this->WayBack)) return;
  1812. $cf = NULL;$opened =NULL;
  1813. $this->SortArchive();
  1814. $this->CacheArchiveOwnLinks();
  1815. if(isset($this->Archive[0])) foreach($this->Archive as $p){
  1816. $nid = substr($p['id'], 0,6);
  1817. if($cf != $nid){
  1818. if($opened){
  1819. fflush($opened);
  1820. fclose($opened);
  1821. }
  1822. $cf = $nid;
  1823. $opened = fopen("archive/$cf.md", 'w');
  1824. }
  1825. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1826. "VER {$p['version']}; ".
  1827. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1828. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1]).";"):"").
  1829. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1830. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1831. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1832. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1833. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1834. ']';
  1835. if(isset($p['merged_thread'])){ $p['content']=""; }
  1836. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['content'].PHP_EOL.PHP_EOL);
  1837. }
  1838. }
  1839. function WritePosts(){
  1840. if(isset($this->WayBack)) return;
  1841. $cf = NULL;$opened =NULL;
  1842. $this->SortPosts();
  1843. if(isset($this->Posts[0])) foreach($this->Posts as $p){
  1844. $nid = substr($p['id'], 0,6);
  1845. if($cf != $nid){
  1846. if($opened){
  1847. fflush($opened);
  1848. fclose($opened);
  1849. }
  1850. $cf = $nid;
  1851. $opened = fopen("posts/$cf.md", 'w');
  1852. }
  1853. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1854. ((isset($p['number']) && $p['number'])?"NUM {$p['number']}; ":"").
  1855. ((isset($p['version']) && $p['version'])?"VER {$p['version']}; ":"").
  1856. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1857. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1858. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1859. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1])."; "):"").
  1860. ((isset($p['comment_to']) && $p['comment_to'])?"COMMENT {$p['comment_to']}; ":"").
  1861. ((isset($p['email']) && $p['email'])?"EMAIL {$p['email']}; ":"").
  1862. ((isset($p['name']) && $p['name'])?"NAME {$p['name']}; ":"").
  1863. ((isset($p['link']) && $p['link'])?"LINK {$p['link']}; ":"").
  1864. ((isset($p['ip']) && $p['ip'])?"IP {$p['ip']}; ":"").
  1865. ((isset($p['mark_delete']) && $p['mark_delete'])?"MDEL; ":"").
  1866. ((isset($p['mark_value']) && $p['mark_value']>=0)?"MVAL {$p['mark_value']}; ":"").
  1867. ((isset($p['next']) && $p['next'])?"NEXT {$p['next']}; ":"").
  1868. ((isset($p['prev']) && $p['prev'])?"PREV {$p['prev']}; ":"").
  1869. ((isset($p['refs']) && isset($p['refs'][0]))?("REFS ".implode(" ",$p['refs'])."; "):"").
  1870. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1871. ((isset($p['hastag']) && isset($p['hastag'][0]))?("HASTAG ".implode(" ",$p['hastag'])."; "):"").
  1872. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1873. ((isset($p['mastodon_url']) && isset($p['mastodon_url']))?("MSTDN ".$p['mastodon_url']."; "):"").
  1874. ']';
  1875. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['real_content'].PHP_EOL.PHP_EOL);
  1876. }
  1877. }
  1878. function CachePostLinks(){
  1879. if(isset($this->WayBack)) return;
  1880. if(isset($this->Posts) && isset($this->Posts[0]))foreach ($this->Posts as &$post){
  1881. $this->ConvertPost($post);
  1882. unset($post['refs']);unset($post['hasp']);unset($post['hasi']);unset($post['hastag']);
  1883. //discard lost old version
  1884. //if(!isset($post['archive']) && $this->DoneReadArchive && isset($post['version'])){ unset($post['version']); }
  1885. }else return;
  1886. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1887. unset($im['refs']); unset($im['here']); unset($im['title']);
  1888. }
  1889. foreach ($this->Posts as &$post){
  1890. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$post['html'],$matches,PREG_SET_ORDER)){
  1891. foreach($matches as $m){
  1892. $ref = &$this->GetPost($m[1],true);
  1893. if($ref!=NULL){
  1894. if(!isset($ref['refs']))$ref['refs']=[]; if(!in_array($post['id'],$ref['refs']))$ref['refs'][]=$post['id'];
  1895. }
  1896. if(!isset($post['hasp']))$post['hasp']=[]; if(!in_array($m[1],$post['hasp']))$post['hasp'][]=$m[1];
  1897. }
  1898. }
  1899. if(preg_match_all('/\/\/([0-9]{14})/u', $post['content'],$matches,PREG_SET_ORDER)){
  1900. foreach($matches as $m){
  1901. if(!isset($post['hastag']))$post['hastag']=[]; if(!in_array($m[1],$post['hastag']))$post['hastag'][]=$m[1];
  1902. }
  1903. }
  1904. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\)/u', $post['content'],$matches,PREG_SET_ORDER)){
  1905. foreach($matches as $m){
  1906. if(($im = &$this->FindImage($m[2]))!=NULL){
  1907. if(!isset($im['refs']))$im['refs']=[]; if(!in_array($post['id'], $im['refs']))$im['refs'][] = $post['id'];
  1908. }
  1909. if(!isset($post['hasi']))$post['hasi']=[]; if(!in_array($m[2],$post['hasi']))$post['hasi'][]=$m[2];
  1910. }
  1911. }
  1912. if(preg_match("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif|mp4))\))(\R*(\R(-|\*).+){1,})/u",
  1913. $post['content'],$matches)){
  1914. $use_img_name = $matches[2];
  1915. if(($im = &$this->FindImage($use_img_name))!=NULL){
  1916. 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",
  1917. $matches[4],$mah,PREG_SET_ORDER)){
  1918. foreach($mah as $ma){
  1919. if(!isset($im['here']))$im['here']=[]; if(!$this->ImageHasHere($item, $ma[4])){
  1920. $here = [$ma[4], $ma[2], $ma[3]]; $im['here'][] = $here; }
  1921. }
  1922. }
  1923. }
  1924. }
  1925. }foreach($this->Posts as &$post){
  1926. if(isset($post['hasp']) && isset($post['hasp'][0])) foreach($post['hasp'] as $t){ if(!preg_match("/[0-9]{14}/u",$t)) continue;
  1927. $pt=&$this->GetPost($t,false,true); if(isset($pt) && isset($pt['hastag']) && isset($pt['hastag'][0]) && in_array($t,$pt['hastag'])){
  1928. if(!isset($pt['refs']))$pt['refs']=[]; $pt['refs'][]=$post['id']; }
  1929. }
  1930. }
  1931. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1932. $min_id = '99999999999999';
  1933. if(isset($im['refs']) && isset($im['refs'][0])) foreach ($im['refs'] as &$ref){
  1934. $r = &$this->GetPost($ref,true); if(isset($r)) $title = $this->GetPostTitle($r,true,false);
  1935. if($title && $ref<$min_id) { $im['title'] = preg_replace('/;/u',' ',trim($title)); $min_id=$r['id']; }
  1936. }
  1937. }
  1938. }
  1939. function CreatePostAnchor(&$post){
  1940. $that=&$this;
  1941. $post['html'] = preg_replace_callback('/<h([0-9])>(.+?)(?=<\/h[0-9]>)/u', function ($ma) use ($that){
  1942. $id = '_heading_'.sizeof($this->Anchors);
  1943. $entry=[(int)$ma[1], $id, $ma[2]];
  1944. $that->Anchors[] = $entry;
  1945. return "<h{$ma[1]} id='{$id}'>{$ma[2]}";
  1946. }, $post['html']);
  1947. }
  1948. function RenamePost(&$post, $rename){
  1949. foreach($this->Posts as &$p){
  1950. if($p['id']==$rename && $p!==$post) { return; /* don't overwrite */ }
  1951. }
  1952. foreach($this->Posts as &$p){
  1953. if(isset($p['prev']) && $p['prev']==$post['id']) { $p['prev']=$rename; }
  1954. if(isset($p['next']) && $p['next']==$post['id']) { $p['next']=$rename; }
  1955. }
  1956. $post['id'] = $rename;
  1957. }
  1958. function DetachPost(&$th,&$post){
  1959. $p0=$p1=NULL;foreach($th['arr'] as $a) echo $a['id']." "; echo '&nbsp;&nbsp;&nbsp;-'.$post['id']."<br />";
  1960. if(isset($post['prev'])){$p0=&$this->GetPost($post['prev'],true);} if(isset($post['next'])){$p1=&$this->GetPost($post['next'],true);}
  1961. if(isset($p0)){ $p0['next']=$p1['id']; }else{ $th['first']=$p1['id']; }
  1962. if(isset($p1)){ $p1['prev'] =$p0['id']; }else{ $th['last']=$p0['id']; }
  1963. foreach($this->Posts as $key => $p){ if ($p==$post) unset($this->Posts[$key]); }
  1964. unset($th['arr']); $now = date_timestamp_get(date_create());
  1965. $this->FinalizeThread($th, true, $now);
  1966. }
  1967. function PushPostVersion(&$post, $optime_id, $mode=1, $info=NULL){
  1968. $a = &$this->GetArchiveHandle($post['id']);
  1969. $ap = []; $ap['id'] = $post['id']; $ap['content'] = $post['real_content'];
  1970. $ap['version'] = isset($post['version'])?$post['version']:$ap['id'];
  1971. if(isset($post['merged_from'])) { $ap['merged_from'] = $post['merged_from']; unset($post['merged_from']); }
  1972. if(isset($post['merged_into'])) { $ap['merged_into'] = $post['merged_into']; unset($post['merged_into']); }
  1973. if(isset($post['merged_thread'])) { $ap['merged_thread'] = $post['merged_thread']; unset($post['merged_thread']); }
  1974. $post['version'] = $optime_id;
  1975. if($mode==1){
  1976. $this->InsertArchivePost($ap);
  1977. }else if($mode==2){
  1978. $post['merged_from'] = $info;
  1979. $this->InsertArchivePost($ap);
  1980. }else if($mode==3){
  1981. $ap['merged_into'] = $info;
  1982. $this->InsertArchivePost($ap);
  1983. if(isset($post['tid']) && $post['tid']['first']!=$post['tid']['last'] && $post!=$post['tid']['first']){
  1984. $this->DetachPost($post['tid'], $post);
  1985. }
  1986. }else if($mode==4){
  1987. $post['merged_thread'] = $info;
  1988. $this->InsertArchivePost($ap);
  1989. }
  1990. }
  1991. function &MergeThreads($post_id, $post_into_id){
  1992. $this->ReadPosts();
  1993. $po = &$this->GetPost($post_id, true); $pt = &$this->GetPost($post_into_id, true);
  1994. if (!isset($po) || !isset($pt) || !isset($po['tid']) || !isset($pt['tid']) ||
  1995. !isset($po['tid']['arr'][0]) || !isset($pt['tid']['arr'][0])){ return $this->NULL_POST; }
  1996. $po = &$po['tid']['arr'][0]; $pt = &$pt['tid']['arr'][0];
  1997. $th = &$po['tid']; $tt = &$pt['tid']; $info=[[],[]];
  1998. if($po['id'] < $pt['id']){ $temp = &$th; $th=&$tt; $tt=&$temp; $temp = &$po; $po=&$pt; $pt=&$temp; }
  1999. foreach($th['arr'] as &$p){ $info[0][]=$p['id']; }
  2000. foreach($tt['arr'] as &$p){ $info[1][]=$p['id']; }
  2001. $this->EditPost($pt['id'], NULL, NULL, NULL, false, NULL, NULL, 4, $info,NULL);
  2002. $arr_combined = array_merge($tt['arr'],$th['arr']);
  2003. $cmppmt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  2004. if(isset($arr_combined[0])){ usort($arr_combined,$cmppmt); } $tt['arr']=&$arr_combined;
  2005. $tt['count'] = sizeof($tt['arr']);
  2006. $this->FinalizeThread($tt, true, $this->TIME_STRING);
  2007. $first_post = &$this->NULL_POST;
  2008. if(isset($tt['arr'][0])) $first_post= &$tt['arr'][0];
  2009. $this->NeedWritePosts=1;
  2010. $this->NeedWriteArchive=1;
  2011. return $first_post;
  2012. }
  2013. function &MergePosts($ids_string){
  2014. $ids = explode(" ", $ids_string);
  2015. $combined_content = ""; $first_id=NULL;
  2016. $this->ReadPosts(); $child_list=[];
  2017. foreach($ids as $id){
  2018. if(!preg_match('/[0-9]{14}/u',$id) || $this->GetPost($id,true)==$this->NULL_POST) continue;
  2019. if(!isset($first_id)) { $first_id = $id; } else { $combined_content.=PHP_EOL.PHP_EOL."//".$id.PHP_EOL; $child_list[]=$id; }
  2020. $combined_content.=$this->EditPost($id, NULL, NULL, NULL, true, NULL, NULL, false, NULL,NULL);
  2021. }
  2022. if(!isset($child_list[0])) return $this->NULL_POST;
  2023. $first_post = &$this->EditPost($first_id, $combined_content, NULL, NULL, false, NULL, NULL, 2, $child_list,NULL);
  2024. foreach($child_list as $id){
  2025. $this->EditPost($id, NULL, NULL, NULL, false, NULL, NULL, 3, [$first_id,$this->TIME_STRING],NULL);
  2026. }
  2027. $this->NeedWritePosts=1;
  2028. $this->NeedWriteArchive=1;
  2029. return $first_post;
  2030. }
  2031. /* push_version: 1 edit 2 post merged from ids list 3 post end into id-ver */
  2032. function &EditPost($id_if_edit, $content, $mark_delete, $reply_to,
  2033. $get_original_only=false, $mark_value=NULL, $rename=NULL,
  2034. $push_version=false, $version_info=NULL, $mastodon_url=NULL){
  2035. $this->ReadImages();
  2036. $this->ReadPosts();
  2037. if(isset($push_version) && $push_version){
  2038. $this->ReadArchive();
  2039. }
  2040. $p_success = NULL;
  2041. if(isset($id_if_edit)){
  2042. $post = &$this->GetPost($id_if_edit,true);
  2043. if($post===$this->NULL_POST) return $this->NULL_POST;
  2044. if($get_original_only){
  2045. return $post['real_content'];
  2046. }
  2047. if(isset($push_version) && $push_version){
  2048. $this->PushPostVersion($post,$this->TIME_STRING,$push_version,$version_info);
  2049. }
  2050. if(isset($content)) {$post['real_content'] = $content; $post['content'] = &$post['real_content'];}
  2051. if(isset($mark_delete)) $post['mark_delete'] = $mark_delete;
  2052. if(isset($mark_value)) $post['mark_value'] = $mark_value;
  2053. if(isset($rename) && preg_match('/^[0-9]{14}$/u',$rename)) $this->RenamePost($post,$rename);
  2054. if(isset($mastodon_url)) { if($mastodon_url!='') $post['mastodon_url']=$mastodon_url; else unset($post['mastodon_url']); }
  2055. $p_success = &$post;
  2056. }else{
  2057. if(!isset($content)) return $this->NULL_POST;
  2058. $id = date('YmdHis');
  2059. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  2060. $post = []; $post['id'] = $id;
  2061. $post['real_content'] = $content; $post['content'] = &$post['real_content'];
  2062. if(isset($reply_to) && ($rep = &$this->GetPost($reply_to,true))!== $this->NULL_POST){
  2063. while($rep !== $this->NULL_POST && isset($rep['next']) && $rep['next']){ $rep = &$this->GetPost($rep['next'],true); }
  2064. if($rep !== $this->NULL_POST){ $rep['next'] = $id; $post['prev'] = $rep['id']; }
  2065. }
  2066. $this->Posts[] = $post;
  2067. $p_success = &$this->Posts[count($this->Posts) - 1];
  2068. }
  2069. $this->NeedWritePosts=1;
  2070. $this->NeedWriteImages=1;
  2071. if(isset($push_version) && $push_version){
  2072. $this->NeedWriteArchive=1;
  2073. }
  2074. return $p_success;
  2075. }
  2076. function &EditComment($id_if_edit, $comment_to_id, $content, $email, $name, $link=NULL, $ip=NULL){
  2077. $this->ReadPosts();
  2078. $p_success = NULL;
  2079. if(isset($id_if_edit)){
  2080. $post = &$this->GetPost($id_if_edit,true);
  2081. if($post===$this->NULL_POST || !isset($post['comment_to'])) return $this->NULL_POST;
  2082. if(isset($content)) $post['content'] = $content;
  2083. if(isset($comment_to_id)) $post['comment_to'] = $comment_to_id;
  2084. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  2085. if(isset($ip)) $post['ip'] = $ip;
  2086. $p_success = &$post;
  2087. }else{
  2088. if(!isset($content) || !isset($comment_to_id)) return $this->NULL_POST;
  2089. $id = date('YmdHis');
  2090. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  2091. if(!($to_post=$this->GetPost($comment_to_id,true))) return $this->NULL_POST;
  2092. $post = []; $post['id'] = $id; $post['content'] = $content; $post['comment_to'] = $comment_to_id;
  2093. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  2094. if(isset($ip)) $post['ip'] = $ip;
  2095. $this->Posts[] = $post;
  2096. $p_success = &$this->Posts[count($this->Posts) - 1];
  2097. }
  2098. $this->NeedWritePosts=1;
  2099. return $p_success;
  2100. }
  2101. function InsertReplacementSymbols($MarkdownContent, &$post_for_it_is_here){
  2102. $replacement = preg_replace('/<!--[\s\S]*-->/U',"",$MarkdownContent);
  2103. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  2104. function($matches){
  2105. $rep = preg_replace('/->/','-@>',$matches[0]);
  2106. $rep = preg_replace('/=>/','=@>',$rep);
  2107. $rep = preg_replace('/<=/','<@=',$rep);
  2108. $rep = preg_replace('/<-/','<@-',$rep);
  2109. $rep = preg_replace('/\R([+]{3,})\R/',PHP_EOL.'@$1'.PHP_EOL,$rep);
  2110. $rep = preg_replace('/\[-/','[@-',$rep);
  2111. $rep = preg_replace('/\{/','{@',$rep);
  2112. $rep = preg_replace('/(en|zh|any)\|(en|zh|any)/','$1@|$2',$rep);
  2113. return $rep;
  2114. },
  2115. $replacement);
  2116. $replacement = preg_replace("/<[-]+>/","↔",$replacement);
  2117. $replacement = preg_replace("/([^-])->/","$1→",$replacement);
  2118. $replacement = preg_replace("/<-([^-])/","←$1",$replacement);
  2119. $replacement = preg_replace("/([^-])[-]+->/","$1⟶",$replacement);
  2120. $replacement = preg_replace("/<-[-]+([^-])/","⟵$1",$replacement);
  2121. $replacement = preg_replace("/<[=]+>/","⇔",$replacement);
  2122. $replacement = preg_replace("/[=]+>/","⇒",$replacement);
  2123. $replacement = preg_replace("/<[=]+/","⇐",$replacement);
  2124. $replacement = preg_replace("/\R([+]{3,})\R/","<div class='page_break'></div>",$replacement);
  2125. $replacement = preg_replace("/\[-(.*)-\]/U","<span class='text_highlight'>$1</span>",$replacement);
  2126. $replacement = preg_replace("/{支付宝(\s+[^}]*?)?}/u","<span class='special_alipay'>支付宝$1</span>",$replacement);
  2127. $replacement = preg_replace("/{PayPal(\s+[^}]*?)?}/ui",
  2128. "<span class='special_paypal'>Pay<span class='special_paypal_inner'>Pal</span>$1</span>",$replacement);
  2129. $replacement = preg_replace("/\/\/([0-9]{14})/imu","<p class='wscroll' id='$1'>".$this->T("链接位置")."</p>",$replacement);
  2130. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  2131. function($matches){
  2132. $rep = preg_replace('/-@>/','->',$matches[0]);
  2133. $rep = preg_replace('/<@-/','<-',$rep);
  2134. $rep = preg_replace('/=@>/','=>',$rep);
  2135. $rep = preg_replace('/<@=/','<=',$rep);
  2136. $rep = preg_replace('/\R@([+]{3,})\R/',PHP_EOL.'$1'.PHP_EOL,$rep);
  2137. $rep = preg_replace('/\[@-/','[-',$rep);
  2138. $rep = preg_replace('/\{@/','{',$rep);
  2139. $rep = preg_replace('/(en|zh|any)@\|(en|zh|any)/','$1|$2',$rep);
  2140. return $rep;
  2141. }, $replacement);
  2142. $replacement = preg_replace_callback("/(\!\[.*?\]\(\s*images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\))(\R*(\R.+){1,})/u",
  2143. function($matches) use (&$post_for_it_is_here){
  2144. $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]);
  2145. return $matches[1].$rep;
  2146. }, $replacement);
  2147. return $replacement;
  2148. }
  2149. function CanShowPost(&$p){
  2150. if(!isset($p) || isset($p['comment_to'])) return false;
  2151. $is_mark_exp = (isset($p['tid'])&&isset($p['tid']['exp'])&&$p['tid']['exp']) || (isset($p['mark_value'])&&$p['mark_value']==6);
  2152. $is_mark_slf = (isset($p['tid'])&&isset($p['tid']['slf'])&&$p['tid']['slf']) || (isset($p['mark_value'])&&$p['mark_value']==7);
  2153. if($is_mark_slf && !$this->LoggedIn){ return false; }
  2154. if(isset($this->WayBack)){
  2155. if(isset($p['version'])) { if ($p['version']>$this->WayBack) return false; }
  2156. else if ($p['id']>$this->WayBack) return false;
  2157. }
  2158. if(!$this->InExperimentalMode){
  2159. if(!$this->LoggedIn){
  2160. if($is_mark_exp) return false;
  2161. return true;
  2162. }
  2163. return true;
  2164. }else{
  2165. if($is_mark_exp) return true;
  2166. return false;
  2167. }
  2168. }
  2169. function SkipProduct(&$p){
  2170. if($this->LoggedIn) return false;
  2171. return (isset($p['mark_value']) && $p['mark_value']==5);
  2172. }
  2173. function GetRedirect($args=NULL, $force_index=NULL){ global $INDEXPHP;
  2174. $str = (isset($force_index)?$force_index:$INDEXPHP).'?';
  2175. if(isset($args['post'])) $str.='&post='.$args['post'];
  2176. else if(isset($_GET['post'])) $str.='&post='.$_GET['post'];
  2177. if(isset($args['gallery'])) $str.='&gallery='.$args['gallery'];
  2178. else if(isset($_GET['gallery'])) $str.='&gallery='.$_GET['gallery'];
  2179. if(isset($args['pic'])) $str.='&pic='.$args['pic'];
  2180. else if(isset($_GET['pic'])) $str.='&pic='.$_GET['pic'];
  2181. if(isset($args['settings'])) $str.='&settings='.$args['settings'];
  2182. else if(isset($_GET['settings'])) $str.='&settings='.$_GET['settings'];
  2183. if(isset($args['statistics'])) $str.='&statistics='.$args['statistics'];
  2184. else if(isset($_GET['statistics'])) $str.='&statistics='.$_GET['statistics'];
  2185. if(isset($args['extras'])) $str.='&extras='.$args['extras'];
  2186. else if(isset($_GET['extras'])) $str.='&extras='.$_GET['extras'];
  2187. if(isset($args['category'])) $str.='&category='.$args['category'];
  2188. else if(isset($_GET['category'])) $str.='&category='.$_GET['category'];
  2189. if(isset($args['history'])) $str.='&history='.$args['history'];
  2190. else if(isset($_GET['history'])) $str.='&history='.$_GET['history'];
  2191. if(isset($args['version'])) $str.='&version='.$args['version'];
  2192. else if(isset($_GET['version'])) $str.='&version='.$_GET['version'];
  2193. if(isset($args['search'])) $str.='&search='.$args['search'];
  2194. else if(isset($_GET['search'])) $str.='&search='.$_GET['search'];
  2195. if(isset($args['here'])) $str.='&here='.$args['here'];
  2196. else if(isset($_GET['here'])) $str.='&here='.$_GET['here'];
  2197. return $str;
  2198. }
  2199. function WriteAsNecessary(){
  2200. if(!$this->LoggedIn || isset($this->WayBack)){return;}
  2201. if($this->NeedWritePosts){ $this->CachePostLinks(); $this->WritePosts(); }
  2202. if($this->NeedWriteImages){ $this->WriteImages(); }
  2203. if($this->NeedWriteArchive){ $this->WriteArchive(); }
  2204. }
  2205. function APubEnsureWebfinger($name, $host){
  2206. if(!is_dir('.well-known')) mkdir('.well-known');
  2207. if(!is_dir('.well-known/webfinger')) mkdir('.well-known/webfinger');
  2208. $f = fopen('.well-known/webfinger/index.php',"w");
  2209. $without_protocol = parse_url($host, PHP_URL_HOST);
  2210. $finger = ["subject"=>"acct:".$name.'@'.$without_protocol,
  2211. "links"=>[["rel"=>"self", "type"=>"application/activity+json", "href"=>$host."?apub_actor=1"]]];
  2212. fwrite($f, "<?php header('Content-Type: application/json'); echo '".json_encode($finger, JSON_UNESCAPED_SLASHES)."'; ?>"); fclose($f);
  2213. if(!file_exists('.well-known/apub_public_key.pem') || !file_exists('.well-known/apub_private_key.php')){
  2214. $res = openssl_pkey_new();
  2215. $this->APubPublicKey = openssl_pkey_get_details($res)['key'];
  2216. openssl_pkey_export($res, $this->APubPrivateKey);
  2217. $f = fopen('.well-known/apub_public_key.pem',"w");
  2218. fwrite($f, $this->APubPublicKey); fclose($f);
  2219. $f = fopen('.well-known/apub_private_key.php',"w");
  2220. fwrite($f, "<?php exit; ?>".PHP_EOL.PHP_EOL.$this->APubPrivateKey); fclose($f);
  2221. }
  2222. }
  2223. function APubInit(){
  2224. $kf = file_get_contents('.well-known/apub_private_key.php'); if($kf===false) return;
  2225. preg_match("/(-----BEGIN PRIVATE KEY-----[\s\S]*)/",$kf,$ma); $this->APubPrivateKey=$ma[1];
  2226. }
  2227. function APubEnsureInfo(){
  2228. if(!isset($this->APubID) || !isset($this->HostURL)) return;
  2229. if(!file_exists('.well-known/apub_public_key.pem')){$this->APubEnsureWebfinger($this->APubID, $this->HostURL);}
  2230. $pk = file_get_contents('.well-known/apub_public_key.pem'); //$pk = preg_replace('/\n/u','\\n',$pk);
  2231. $actor = ["@context"=>["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1"],
  2232. "id"=> $this->HostURL."?apub_actor=1",
  2233. "type"=> "Person",
  2234. "name"=> $this->DisplayName,
  2235. "url"=> $this->HostURL,
  2236. "summary"=> "Lazy... No summary",
  2237. "preferredUsername"=> $this->APubID,
  2238. "inbox"=> $this->HostURL."?apub_inbox=1",
  2239. "outbox"=> $this->HostURL."?apub_outbox=1",
  2240. "publicKey"=> ["id"=> $this->HostURL."?apub_actor=1#main-key",
  2241. "owner"=> $this->HostURL."?apub_actor=1",
  2242. "publicKeyPem"=>$pk]];
  2243. $this->APubActor = json_encode($actor, JSON_UNESCAPED_SLASHES);
  2244. }
  2245. function APubMakeOutbox(){
  2246. $this->ReadPosts();$this->ReadImages();
  2247. $obj = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2248. "id"=>$this->HostURL."?apub_outbox=1",
  2249. "type"=>"OrderedCollection"];
  2250. $items=[]; $i=0;
  2251. foreach(array_reverse($this->Posts) as &$p){
  2252. $this->ConvertPost($p);
  2253. $text = strip_tags(preg_replace('/<\/(p|blockquote|h[0-9])>/u',"\n\n",$p['html']));
  2254. $time = DateTime::createFromFormat('YmdHis', $p['id'], new DateTimeZone('+0800'));
  2255. $ob = ["@context"=>"https://www.w3.org/ns/activitystreams",
  2256. "type"=> "Create",
  2257. "id"=> $this->HostURL."?post=".$p['id']."?apub_object=1",
  2258. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2259. //"to"=> ["https://chatty.example/ben/"],
  2260. "actor"=> $this->HostURL."?apub_actor=1",
  2261. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2262. "object"=> ["type"=> "Note",
  2263. "id"=> $this->HostURL."?post=".$p['id'],
  2264. "published"=> $time->format('Y-m-d\TH:i:s\Z'),
  2265. "attributedTo"=> $this->HostURL."?apub_actor=1",
  2266. "to"=> ["https://www.w3.org/ns/activitystreams#Public"],
  2267. "content"=> $text]];
  2268. $items[] = $ob;
  2269. $i++; if($i>20) break;
  2270. }
  2271. $obj['orderedItems'] = $items; $obj["totalItems"] = sizeof($items);
  2272. return json_encode($obj, JSON_UNESCAPED_SLASHES);
  2273. }
  2274. function APubDeliver($body,$target){
  2275. $head_digest = base64_encode(hash("sha256",$body,true));
  2276. $body_digest = "SHA-256=".$head_digest;
  2277. // rfc standards require the timezone be declared as GMT and PHP's built-in formats all say UTC
  2278. // so we gotta do it manually
  2279. $d = new DateTimeImmutable("now", new DateTimeZone('Asia/Shanghai'));
  2280. $d=$d->setTimezone(new DateTimeZone('UTC'));
  2281. $date=$d->format("D, d M Y H:i:s")." GMT";
  2282. $data = "(request-target): post ".parse_url($target,PHP_URL_PATH)
  2283. ."\nhost: ".parse_url($target,PHP_URL_HOST)
  2284. ."\ndate: $date"
  2285. ."\ndigest: $body_digest";
  2286. if (openssl_sign($data, $signature, $this->APubPrivateKey, OPENSSL_ALGO_SHA256) === FALSE) {
  2287. http_response_code(500); die('unable to sign');
  2288. }
  2289. $signature = base64_encode($signature);
  2290. $keyid = 'keyId="'.$this->HostURL.'?apub_actor=1#main-key"';
  2291. $algo = 'algorithm="rsa-sha256"';
  2292. $headers = 'headers="(request-target) host date digest"';
  2293. $signature = "signature=\"$signature\"";
  2294. $h = array(
  2295. 'Content-Type: application/activity+json',
  2296. 'Accept: application/activity+json',
  2297. //"Content-Length: ".strlen($body),
  2298. "Host: ". parse_url($target,PHP_URL_HOST),
  2299. "Date: $date",
  2300. "Digest: $body_digest",
  2301. "Signature: $keyid,$algo,$headers,$signature"
  2302. );
  2303. $ch = curl_init($target);
  2304. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  2305. curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
  2306. curl_setopt($ch, CURLOPT_HTTPHEADER, $h);
  2307. curl_setopt($ch, CURLOPT_USERAGENT, "laMDWiki APub");
  2308. $result = curl_exec($ch);
  2309. curl_close($ch); echo "<pre>";
  2310. print_r($body); echo "\n\n".$target."\n\n";
  2311. print_r($result); echo "\n\n"; print_r($h);
  2312. echo "\n\n"; print_r(curl_getinfo($ch)); echo "</pre>"; exit;
  2313. return $result;
  2314. }
  2315. function APubTestDeliver(){
  2316. $this->APubInit();
  2317. $obj=[];
  2318. $obj['published']=gmdate("Y-m-d\TH:i:s\Z");
  2319. $obj['id']=""; //<-------------------
  2320. $obj['url']=$this->HostURL.""; //<-------------------
  2321. $obj['type']='Note';
  2322. $obj['attributedTo']=$this->HostURL."?apub_actor=1";
  2323. $tag=[]; $tag['type']='Mention'; $tag['name']="@chengdulittlea"; $tag['href']="https://mastodon.art/users/chengdulittlea";
  2324. $obj['tag']=[$tag];
  2325. // must have cc to have notification in mastodon.
  2326. $obj['cc']=["https://mastodon.art/users/chengdulittlea"];
  2327. $obj['content']="<p>@chengdulittlea Hello activitypub from laMDWiki!</p>";
  2328. $obj['to']="https://www.w3.org/ns/activitystreams#Public";
  2329. $obj['inReplyTo']=""; //<-------------------
  2330. $arr=[];
  2331. $arr['@context']="https://www.w3.org/ns/activitystreams";
  2332. $arr['id']=""; //<-------------------
  2333. $arr['actor']=$this->HostURL."?apub_actor=1";
  2334. $arr['type']="Create";
  2335. $arr['to']="https://www.w3.org/ns/activitystreams#Public";
  2336. $arr['object']=$obj;
  2337. $this->APubDeliver(json_encode($arr),"https://mastodon.example/inbox"); //<-------------------
  2338. }
  2339. function APubProcessInbox(){
  2340. $r = file_get_contents('php://input');
  2341. file_put_contents('postdump.txt',$r);
  2342. }
  2343. function MakeRSS(){
  2344. $this->ReadPosts();$this->ReadImages();
  2345. $posts = []; if(isset($this->UsePosts[0])){
  2346. $posts = array_reverse($this->UsePosts);
  2347. $last_updated = $this->StandardTime($posts[0]['id']);
  2348. }else{ $last_updated= $this->StandardTime("20000101000000"); }
  2349. $author = "<author><name>".$this->DisplayName."</name><email>".$this->EMail."</email><uri>".$this->HostURL."</uri></author>";
  2350. $all_content="<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom'>".
  2351. "<id>".$this->HostURL."/?rss</id>".
  2352. "<updated>".$last_updated."</updated>".
  2353. "<title>".$this->T($this->Title)."</title>".
  2354. "<link href='".$this->HostURL."/index.php?rss=".($this->LanguageAppendix=='zh'?'zh':'en')."' rel='self'/>".
  2355. "<link href='".$this->HostURL."' />".$author;
  2356. $i=0;
  2357. if(isset($posts[0])) foreach($posts as &$p){
  2358. if($i>100) break;
  2359. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  2360. if(isset($p['tid'])){ /* Should always be set. */
  2361. $th = &$p['tid']; if($p['tid']['count']==0) continue; }
  2362. if(in_array($p['id'],
  2363. [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
  2364. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  2365. $is_thread = isset($p['tid']['count'])&&($p['tid']['count']>1);
  2366. $is_reversed=false;
  2367. $content="<entry>"; $title = NULL;
  2368. if($is_thread){
  2369. $use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false; if($is_reversed){
  2370. $use_arr=array_reverse($th['arr']); $fp=array_pop($use_arr); array_unshift($use_arr,$fp); }
  2371. foreach($use_arr as &$po){
  2372. $this->ConvertPost($po);
  2373. if(!isset($title)){$title = htmlspecialchars($this->GetPostTitle($po, false, false)); if(!$title){$title='untitled';}
  2374. $content.="<id>".$this->HostURL."/?post=".$po['id']."</id>";
  2375. $content.="<title type='html'>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$po['id']."' />";
  2376. $content.="<published>".$this->StandardTime($po['id'])."</published>";
  2377. $content.="<updated>".$this->StandardTime(isset($po['tid']['last']['version'])?
  2378. $po['tid']['last']['version']:$po['tid']['last']['id'])."</updated>".$author;
  2379. $content.="<content type='html'>"; }
  2380. $content.= htmlspecialchars($po['html']);
  2381. //if(isset($po['images'])&&isset($po['images'][0])) foreach($po['images'] as $im){ $content.=htmlspecialchars($im); }
  2382. }
  2383. $content.=$this->ReadableTime($p['tid']['first']['id'])." - ".
  2384. $this->ReadableTime(isset($p['tid']['last']['version'])?
  2385. $p['tid']['last']['version']:$p['tid']['last']['id']);
  2386. $content.="</content>";
  2387. }else{
  2388. $this->ConvertPost($p);
  2389. if(!isset($title)){$title = htmlspecialchars($this->GetPostTitle($p, false, false)); if(!$title){$title='untitled';}
  2390. $content.="<id>".$this->HostURL."/?post=".$p['id']."</id>";
  2391. $content.="<title type='html'>".$title."</title><link rel='alternate' href='".$this->HostURL."/?post=".$p['id']."' />";
  2392. $content.="<published>".$this->StandardTime($p['id'])."</published>";
  2393. $content.="<updated>".$this->StandardTime(isset($p['tid']['last']['version'])?
  2394. $p['tid']['last']['version']:$p['tid']['last']['id'])."</updated>".$author;}
  2395. $content.= "<content type='html'>".htmlspecialchars($p['html']);
  2396. //if(isset($p['images'])&&isset($p['images'][0])) foreach($p['images'] as $im){ $content.=htmlspecialchars($im); }
  2397. $content.=$this->ReadableTime($p['id'])." - ".
  2398. $this->ReadableTime(isset($p['version'])?$p['version']:$p['id']);
  2399. $content.="</content>";
  2400. }
  2401. $i++;
  2402. $content.="</entry>";
  2403. $all_content.=$content;
  2404. }
  2405. $all_content.="</feed>";
  2406. header( "Content-type: text/xml");
  2407. echo $all_content;
  2408. }
  2409. function MakeHereButtons($im, $insert_here){
  2410. if(isset($im['here'])&&isset($im['here'][0])){
  2411. $size=getimagesize($im['file']); $aspect=$size[0]/$size[1];
  2412. echo ($insert_here?"<here>":"")."<div class='here_buttons_inner' style='aspect-ratio:".$aspect.";'>";
  2413. foreach($im['here'] as $here){
  2414. if($insert_here){
  2415. echo "<a href='?show_image=".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'".
  2416. "onclick='event.preventDefault();event.stopPropagation();ShowBigImage(\"".$here[0]."\",1);'></a>";
  2417. }else{
  2418. echo "<a href='?here=images/".$here[0]."' class='here_btn' style='left:".$here[1]."%;top:".$here[2]."%;'></a>";
  2419. }
  2420. }
  2421. echo "</div>".($insert_here?"</here>":"");
  2422. }
  2423. }
  2424. function ProcessRequest(&$message=NULL, &$redirect=NULL){ global $INDEXPHP;
  2425. if(isset($_GET['gallery_continue']) && $_GET['gallery']){
  2426. $this->ReadImages();
  2427. $this->GetImageBatch($_GET['gallery_continue'],0);
  2428. exit;
  2429. }
  2430. if(isset($_GET['gallery']) && $_GET['gallery']=='default'){
  2431. $redirect = "$INDEXPHP?gallery=".(isset($this->DefaultGallery)&&$this->DefaultGallery!=''?$this->DefaultGallery:"main");
  2432. return 0;
  2433. }
  2434. if(isset($_GET['set_language'])){
  2435. setcookie('la_language',$_GET['set_language'],time()+3600*24*7); $_COOKIE['la_language'] = $_GET['set_language'];
  2436. $redirect=$this->GetRedirect(); return 0;
  2437. }
  2438. if(isset($_GET['rss'])){
  2439. if(in_array($_GET['rss'],['en','zh'])){$this->LanguageAppendix=$_GET['rss'];}
  2440. $this->MakeRSS(); exit;
  2441. }
  2442. if(isset($_GET['toggle_font'])){ $use_font='local';
  2443. if(!isset($_COOKIE['la_font']) || $_COOKIE['la_font']!='remote') $use_font='remote';
  2444. setcookie('la_font',$use_font,time()+3600*24*7); $_COOKIE['la_font'] = $use_font;
  2445. $redirect=$this->GetRedirect(); return 0;
  2446. }
  2447. if(isset($_GET['set_wayback'])){
  2448. if($_GET['set_wayback']!='false'){
  2449. $wayback= date('YmdHis');
  2450. if($_GET['set_wayback']=='post'){
  2451. if(isset($_POST['wayback_year'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_year'],4,"0",STR_PAD_LEFT),0,4);
  2452. if(isset($_POST['wayback_month'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_month'],2,"0",STR_PAD_LEFT),4,2);
  2453. if(isset($_POST['wayback_day'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_day'],2,"0",STR_PAD_LEFT),6,2);
  2454. if(isset($_POST['wayback_hour'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_hour'],2,"0",STR_PAD_LEFT),8,2);
  2455. if(isset($_POST['wayback_minute'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_minute'],2,"0",STR_PAD_LEFT),10,2);
  2456. }else{ if(preg_match('/[0-9]{14}/u', $_GET['set_wayback'])) $wayback = $_GET['set_wayback']; }
  2457. setcookie('la_wayback',$wayback); $_COOKIE['la_wayback'] = $wayback;
  2458. }else{
  2459. setcookie('la_wayback', null, -1); unset($_COOKIE['la_wayback']);
  2460. }
  2461. $redirect=$this->GetRedirect(); return 0;
  2462. }
  2463. if(isset($_GET['post'])){ $this->CurrentPostID = $_GET['post']; $this->TagID = $this->CurrentPostID; }
  2464. if(isset($_GET['here'])){ $this->HereID = $_GET['here']; }
  2465. if(isset($_GET['offset'])){ $this->CurrentOffset = $_GET['offset']; }
  2466. if(isset($_GET['post'])){
  2467. $this->ExtraScripts.="window.addEventListener('load', (event) => {ScrollToPost('".$_GET['post']."');});";
  2468. }
  2469. if(isset($_GET['random_here'])){
  2470. $this->DoIdentifyExperimental(); $this->DetectPageType();
  2471. $im = &$this->GiveImageInHere(true); if(isset($im)){ $redirect='?here=images/'.$im['name']; return 0; }
  2472. }
  2473. if(isset($_POST['search_content'])){ $redirect=$INDEXPHP.'?search='.$_POST['search_content'];return 0; }
  2474. if(isset($_GET['image_info']) || isset($_GET['show_image'])){
  2475. $m=isset($_GET['image_info'])?$_GET['image_info']:$_GET['show_image'];
  2476. $direct_return = !isset($_GET['show_image']);
  2477. $this->ReadImages(); $this->ReadPosts();
  2478. $this->SwitchWayBackMode(); if(isset($this->WayBack)){$this->ReadArchive();}
  2479. $im = &$this->FindImage($m);
  2480. if($im==NULL || !isset($im['refs']) || !isset($im['refs'][0])){ echo "not_found"; exit; }
  2481. if($direct_return){
  2482. echo "<ref>".sizeof($im['refs'])."</ref>";
  2483. echo "<insert>";
  2484. }else{ ob_start(); }
  2485. $STR="";
  2486. $this->TBackup();
  2487. foreach(array_reverse($im['refs']) as $ref){
  2488. $p = $this->GetPost($ref);
  2489. if(!$p || !$this->CanShowPost($p)) continue;
  2490. $this->MakeSinglePostV2($p, false, true, "post_preview", true, false, false, false, true);
  2491. }
  2492. $STR=$this->TRestore(" compact");
  2493. if($direct_return){
  2494. echo $STR;
  2495. echo "</insert>";
  2496. $this->MakeHereButtons($im, true);
  2497. }else{
  2498. $str = $STR;
  2499. $this->MakePageBegin($this->NULL_POST);
  2500. $side = "";
  2501. if(isset($im['refs'])&&isset($im['refs'][0])){
  2502. $side.="<span class='small'>".$this->T('该图片出现在')." ".sizeof($im['refs'])." ".$this->T('个帖子中')."</span>";
  2503. }else{$side.="<span class='smaller gray'>".$this->T('该图片未被引用')."</span>";}
  2504. $static_image = isset($im['video'])?NULL:$im['file'];
  2505. $static_video = isset($im['video'])?$im['file']:NULL;
  2506. $this->MakeImageOverlay($side."<ul>".$str."</ul>",$static_image,$static_video);
  2507. $this->MakePageEnd();
  2508. }
  2509. exit;
  2510. }
  2511. if(isset($_GET['confirm_enter']) && $_GET['confirm_enter']!=false){
  2512. setcookie('la_experimental','confirmed'); $_COOKIE['la_experimental'] = $_GET['confirmed'];
  2513. $redirect=$INDEXPHP.(isset($_GET['post'])?'?post='.$_GET['post']:"");return 0;
  2514. }
  2515. if(isset($_GET['apub_actor'])){
  2516. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2517. echo $this->APubActor; exit;
  2518. }
  2519. if(isset($_GET['apub_outbox'])){
  2520. $this->APubEnsureInfo(); header('Content-Type: application/json'); header('Cache-Control no-store, no-cache, must-revalidate');
  2521. echo $this->APubMakeOutbox(); exit;
  2522. }
  2523. if(isset($_GET['apub_inbox'])){
  2524. $this->APubProcessInbox();
  2525. http_response_code(202); exit;
  2526. }
  2527. if($this->LoggedIn){
  2528. if(isset($_GET['TestAPubDeliver'])){
  2529. $this->APubTestDeliver();
  2530. }
  2531. $this->DoUpload();
  2532. if(isset($_POST['settings_button'])){
  2533. if(isset($_POST['settings_title'])) $this->Title=$_POST['settings_title'];
  2534. if(isset($_POST['settings_short_title'])) $this->ShortTitle=$_POST['settings_short_title'];
  2535. if(isset($_POST['settings_display_name'])) $this->DisplayName=$_POST['settings_display_name'];
  2536. if(isset($_POST['settings_email'])) $this->EMail=$_POST['settings_email'];
  2537. if(isset($_POST['settings_special_navigation'])) $this->SpecialNavigation=$_POST['settings_special_navigation'];
  2538. if(isset($_POST['settings_special_sidebar'])) $this->SpecialSidebar=$_POST['settings_special_sidebar'];
  2539. if(isset($_POST['settings_special_footer'])) $this->SpecialFooter=$_POST['settings_special_footer'];
  2540. if(isset($_POST['settings_special_footer2'])) $this->SpecialFooter2=$_POST['settings_special_footer2'];
  2541. if(isset($_POST['settings_special_pinned'])) $this->SpecialPinned=$_POST['settings_special_pinned'];
  2542. if(isset($_POST['settings_default_gallery'])) $this->DefaultGallery=$_POST['settings_default_gallery'];
  2543. if(isset($_POST['settings_selfauth_path'])) $this->SelfAuthPath=$_POST['settings_selfauth_path'];
  2544. if(isset($_POST['settings_enable_comments'])) $this->CommentEnabled=True; else $this->CommentEnabled=False;
  2545. if(isset($_POST['settings_gallery_step'])) $this->GalleryStep=$_POST['settings_gallery_step'];
  2546. if(isset($_POST['settings_here_host'])) $this->HereHost=$_POST['settings_here_host'];
  2547. if(isset($_POST['settings_here_title'])) $this->HereTitle=$_POST['settings_here_title'];
  2548. if(isset($_POST['settings_here_short_title'])) $this->HereShortTitle=$_POST['settings_here_short_title'];
  2549. if(isset($_POST['settings_here_album'])) $this->HereAlbum=$_POST['settings_here_album'];
  2550. if(isset($_POST['settings_here_navigation'])) $this->HereNavigation=$_POST['settings_here_navigation'];
  2551. if(isset($_POST['settings_here_footer'])) $this->HereFooter=$_POST['settings_here_footer'];
  2552. if(isset($_POST['settings_exp_host'])) $this->ExpHost=$_POST['settings_exp_host'];
  2553. if(isset($_POST['settings_exp_title'])) $this->ExpTitle=$_POST['settings_exp_title'];
  2554. if(isset($_POST['settings_exp_short_title'])) $this->ExpShortTitle=$_POST['settings_exp_short_title'];
  2555. if(isset($_POST['settings_exp_caution'])) $this->ExpCaution=$_POST['settings_exp_caution'];
  2556. if(isset($_POST['settings_exp_album'])) $this->ExpAlbum=$_POST['settings_exp_album'];
  2557. if(isset($_POST['settings_exp_navigation'])) $this->ExpNavigation=$_POST['settings_exp_navigation'];
  2558. if(isset($_POST['settings_exp_footer'])) $this->ExpFooter=$_POST['settings_exp_footer'];
  2559. if(isset($_POST['settings_allow_language'])) $this->AllowLanguageChoices=True; else $this->AllowLanguageChoices=False;
  2560. if(isset($_POST['settings_mastodon_token'])) $this->MastodonToken=$_POST['settings_mastodon_token'];
  2561. if(isset($_POST['settings_mastodon_url'])) $this->MastodonURL=$_POST['settings_mastodon_url'];
  2562. if(isset($_POST['settings_mastodon_lang'])) $this->MastodonPreferredLang=$_POST['settings_mastodon_lang'];
  2563. if(isset($_POST['settings_host_url'])) $this->HostURL=$_POST['settings_host_url'];
  2564. if(isset($_POST['settings_apub_id']) && isset($this->HostURL)) {
  2565. $this->APubID=$_POST['settings_apub_id'];
  2566. $this->APubEnsureWebfinger($this->APubID,$this->HostURL);
  2567. }
  2568. if(isset($_POST['settings_old_password'])&&password_verify($_POST['settings_old_password'], $this->Password)){
  2569. if(isset($_POST['settings_id'])) $this->Admin=$_POST['settings_id'];
  2570. if(isset($_POST['settings_new_password']) && isset($_POST['settings_new_password_redo']) &&
  2571. $_POST['settings_new_password'] = $_POST['settings_new_password_redo'])
  2572. {$this->Password=password_hash($_POST['settings_new_password'], PASSWORD_DEFAULT);}
  2573. $redirect=$_SERVER['REQUEST_URI'];
  2574. $this->DoLogout();
  2575. }
  2576. $this->WriteConfig();
  2577. return 0;
  2578. }
  2579. if(isset($_POST['settings_save_redirect'])){
  2580. if(isset($_POST['settings_redirect'])){
  2581. $this->BuildRedirectConfig($_POST['settings_redirect']);
  2582. }
  2583. $this->WriteConfig();
  2584. $redirect = $INDEXPHP.'?extras=true'; return 0;
  2585. }
  2586. if(isset($_POST['settings_save_translation'])){
  2587. if(isset($_POST['settings_translation'])){
  2588. $f = fopen("custom_translations.md", "w"); fwrite($f,$_POST['settings_translation']); fflush($f); fclose($f);
  2589. }
  2590. $redirect = $INDEXPHP.'?extras=true'; return 0;
  2591. }
  2592. if(isset($_GET['post'])){
  2593. if(isset($_GET['post_original'])){
  2594. echo $this->EditPost($_GET['post'],NULL,false,NULL,true,NULL,NULL,false,NULL,NULL);
  2595. exit;
  2596. }
  2597. }
  2598. if(isset($_GET['mark_delete']) && isset($_GET['target'])){
  2599. $this->EditPost($_GET['target'],NULL,$_GET['mark_delete']=='true',NULL,false,NULL,NULL,false,NULL,NULL);
  2600. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2601. return 0;
  2602. }
  2603. if(isset($_GET['set_mark']) && isset($_GET['target'])){
  2604. $this->EditPost($_GET['target'],NULL,NULL,NULL,NULL,$_GET['set_mark'],NULL,false,NULL,NULL);
  2605. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  2606. return 0;
  2607. }
  2608. if(isset($_POST['post_button']) && isset($_POST['post_content'])){
  2609. $c = $_POST['post_content'];
  2610. if('有什么想说的' == $c){ return 0;}
  2611. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2612. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2613. $reply_to = (isset($_POST['post_reply_to'])&&$_POST['post_reply_to']!="")?$_POST['post_reply_to']:NULL;
  2614. $edit_id = (isset($_POST['post_edit_target'])&&$_POST['post_edit_target']!="")?$_POST['post_edit_target']:NULL;
  2615. $push_history = (isset($edit_id) && isset($_POST['post_record_edit']));
  2616. if(($edited = $this->EditPost($edit_id, $c, NULL, $reply_to,NULL,NULL,NULL,$push_history,NULL,NULL))!=NULL){
  2617. $redirect='?post='.$edited['id']; return 0;
  2618. };
  2619. }
  2620. if(isset($_POST['post_rename_confirm']) && isset($_POST['post_rename_name']) && isset($_GET['rename_post'])){
  2621. if(($edited =$this->EditPost($_GET['rename_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,NULL))!=NULL){
  2622. $redirect='?post='.$edited['id']; return 0;
  2623. };
  2624. }
  2625. if(isset($_POST['post_mastodon_confirm']) && isset($_POST['post_mastodon_url']) && isset($_GET['mastodon_post'])){
  2626. if(($edited =$this->EditPost(
  2627. $_GET['mastodon_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL,$_POST['post_mastodon_url']))!=NULL){
  2628. $redirect='?post='.$edited['id']; return 0;
  2629. };
  2630. }
  2631. if(isset($_GET['mastodon_send_post']) && preg_match('/([0-9]{14})/u',$_GET['mastodon_send_post'],$m)){
  2632. $this->ReadImages(); $this->ReadPosts(); $post = &$this->GetPost($m[1]); $err=$this->T("未知错误");
  2633. if(isset($post)){
  2634. if($mastodon_url = $this->MastodonSendPost($post, $err)){
  2635. $this->NeedWritePosts = 1; $this->WritePosts(); // for mastodon url
  2636. echo "SUCCESS ".$mastodon_url;
  2637. }else{ echo $err; }
  2638. } exit;
  2639. }
  2640. if(isset($_GET['merge_threads'])&&$_GET['merge_threads']!=""){
  2641. if(preg_match('/([0-9]{14})\s+([0-9]{14})/u',$_GET['merge_threads'],$m)){
  2642. if(($pe = &$this->MergeThreads($m[1],$m[2]))!=$this->NULL_POST){ $redirect='?post='.$pe['id']; return 0; }
  2643. }
  2644. }
  2645. if(isset($_GET['merge_posts'])&&$_GET['merge_posts']!=""){
  2646. if(($pe = &$this->MergePosts($_GET['merge_posts']))!=$this->NULL_POST){
  2647. $redirect='?post='.$pe['id']; return 0;
  2648. }
  2649. }
  2650. if ($this->CommentEnabled && isset($_POST['comment_confirm']) && (isset($_GET['comment_to']))
  2651. && isset($_POST['comment_box']) && isset($_POST['comment_email']) && isset($_POST['comment_name'])){
  2652. $c = $_POST['comment_box'];
  2653. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  2654. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  2655. $comment_to = ($_GET['comment_to']!="")?$_GET['comment_to']:NULL;
  2656. if(($edited = $this->EditComment(NULL,
  2657. $_GET['comment_to'], $c, $_POST['comment_email'], $_POST['comment_name'],
  2658. isset($_POST['comment_link'])?$_POST['comment_link']:NULL,
  2659. $_SERVER['REMOTE_ADDR']))!=NULL){
  2660. $redirect='?post='.$_GET['post'];
  2661. return 0;
  2662. };
  2663. }
  2664. if(isset($_POST['gallery_edit_confirm']) && isset($_POST['gallery_edit_new_name']) && $_POST['gallery_edit_new_name']!=''){
  2665. $old_name = isset($_POST['gallery_edit_old_name'])?$_POST['gallery_edit_old_name']:"";
  2666. $new_name = $_POST['gallery_edit_new_name'];
  2667. if($old_name!=''){
  2668. $desc=isset($_POST['gallery_edit_description'])?$_POST['gallery_edit_description']:null;
  2669. if(!preg_match('/[0-9]{14}/',$desc))$desc="";
  2670. $this->EditGallery($old_name, $new_name, false, true, null, null,$desc);
  2671. $redirect='?gallery='.$new_name;
  2672. }else{
  2673. $this->EditGallery(null, $new_name, false, true, null,null);
  2674. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2675. }
  2676. return 0;
  2677. }
  2678. if(isset($_GET['gallery_edit_delete'])&&$_GET['gallery_edit_delete']!=null){
  2679. $this->EditGallery($_GET['gallery_edit_delete'], null, true, true, null, null,null);
  2680. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery=main'; else $redirect=$INDEXPHP;
  2681. return 0;
  2682. }
  2683. if(isset($_POST['gallery_move_ops'])&&isset($_POST['gallery_move_ops'])){
  2684. if(preg_match('/^(REM|ADD)\s+(\S+)\s+(.*)$/u', $_POST['gallery_move_ops'], $ma)){
  2685. $this->ReadImages();
  2686. if(preg_match_all('/(\S+)/u', $ma[3], $files, PREG_SET_ORDER)) foreach($files as $name){
  2687. $this->EditImage($name[1], $ma[2], ($ma[1]=='REM'), NULL, NULL, NULL, NULL);
  2688. }
  2689. }
  2690. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2691. return 0;
  2692. }
  2693. if(isset($_GET['gallery_set_featured'])&&isset($_GET['value'])){
  2694. $this->EditGallery($_GET['gallery_set_featured'], null, false, true, $_GET['value']!='false', null);
  2695. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2696. return 0;
  2697. }
  2698. if(isset($_GET['gallery_set_experimental'])&&isset($_GET['value'])){
  2699. $this->EditGallery($_GET['gallery_set_experimental'], null, false, true, null, $_GET['value']!='false');
  2700. if(isset($_GET['gallery'])) $redirect=$INDEXPHP.'?gallery='.$_GET['gallery']; else $redirect=$INDEXPHP;
  2701. return 0;
  2702. }
  2703. if(isset($_GET['image_list'])&&$_GET['image_list']!=""){
  2704. $this->ReadImages();
  2705. $gallery = $_GET['image_list']; $count=0;
  2706. foreach($this->Images as $im){ if($count>25){ break; }
  2707. if($gallery=='main'){ echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; $count++; continue; }
  2708. if(isset($im['galleries']) && isset($im['galleries'][0]) && in_array($gallery,$im['galleries'])) {
  2709. echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; $count++; }
  2710. }
  2711. exit;
  2712. }
  2713. $do_image_redirect = 0;
  2714. if (isset($_POST['image_button']) && isset($_GET['pic']) &&
  2715. preg_match('/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4))/u',$_GET['pic'],$ma)){
  2716. $this->ReadImages(); $pic = $ma[1]; $picext=$ma[2];
  2717. if(isset($_POST['image_ops_product_link'])){
  2718. $this->EditImage($pic, NULL, false, $_POST['image_ops_product_link'], NULL, NULL, NULL);
  2719. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2720. }
  2721. if(isset($_POST['image_edit_new_name']) && preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_edit_new_name'],$man)){
  2722. $this->EditImage($pic, NULL, false, NULL, $man[1], NULL, NULL);
  2723. $redirect=$this->GetRedirect(['pic'=>'images/'.$man[1].'.'.$picext]);
  2724. $do_image_redirect = 1;
  2725. }
  2726. if(isset($_POST['image_parent'])){ $parent="";
  2727. if(preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_parent'],$man)){ $parent = $man[1]; }
  2728. $this->EditImage($pic, NULL, false, NULL, NULL, $parent, NULL);
  2729. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2730. }
  2731. if(isset($_POST['image_align'])){$val=$_POST['image_align'];
  2732. $this->EditImage($pic, NULL, false, NULL, NULL, NULL, $val);
  2733. $redirect=$_SERVER['REQUEST_URI']; $do_image_redirect = 1;
  2734. }
  2735. $this->NeedWriteImages = 1;
  2736. if($do_image_redirect) return 0;
  2737. }
  2738. if(isset($_GET['rewrite_styles'])){
  2739. $this->WriteStyles(); $redirect='?extras=true'; return 0;
  2740. }
  2741. if(isset($_GET['regenerate_thumbnails'])){
  2742. $this->RegenerateThumbnails(); $redirect='?extras=true'; return 0;
  2743. }
  2744. if(isset($_GET['cleanup_image_compression'])){ $run=false;
  2745. if(isset($_GET['run'])){ $run=true; }
  2746. $this->CleanupImageCompression($run); $redirect='?extras=true'; return 0;
  2747. }
  2748. if(isset($_GET['clear_all_logins'])){
  2749. $this->LoginTokens=[]; $this->WriteTokens();
  2750. }
  2751. if($_SERVER['HTTP_HOST']=='localhost'){$this->WriteStyles();}
  2752. }
  2753. return 0;
  2754. }
  2755. function PostProcessHTML($html,&$added_images=null,$do_product_info=false, &$product_info=null, &$orig_src_list=null, &$end_wide=null, &$print_wide=null){
  2756. if(!$this->LoggedIn){
  2757. $html = preg_replace("/(<a[^>]*href=[\'\"])(.*?)([\'\"][^>]*)>(\#.*?<\/a>)/u","",$html);
  2758. }
  2759. $html = preg_replace("/(<a[^>]*href=[\'\"])([0-9]{14})([\'\"][^>]*)>(.*?<\/a>)/u","$1?post=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2760. $html = preg_replace("/(<a[^>]*href=[\'\"])\@(.*?)([\'\"][^>]*)>(.*?<\/a>)/u","$1?category=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  2761. $html = preg_replace("/(<a[^>]*href=[\'\"])((.*?:\/\/).*?)([\'\"][^>]*)(>)(.*?)(<\/a>)/u",
  2762. "$1$2$4 target='_blank'$5$6<sup>↗</sup>$7",$html);
  2763. $html = preg_replace("/<p>\s*\@.*?<\/p>/mu","",$html);
  2764. $html = preg_replace("/\{\s*(REVERSED|INTERESTING|HEADER|FOOTER)\s+(.*?)\}/imu","",$html);
  2765. $html = preg_replace("/\{\s*(REVERSED|NO_TIME|NO_TITLE|SLIDES)\s*\}/imu","",$html);
  2766. $html = preg_replace("/\{\s*WIDE\s*\}/imu","",$html,-1,$rep_count); if($rep_count){$print_wide=true;}
  2767. $images = []; $images_noclick = []; $images_orig_src_list = [];
  2768. $html = preg_replace_callback(
  2769. "/(<p>\s*|<a\s.*?>\s*)?(<img([^>]*)src=[\'\"])(images\/([0-9]{14,}\.(jpg|png|jpeg|gif|mp4)))([\'\"][^>]*)\/>(\s*<\/p>)?/u",
  2770. function($m) use (&$images,&$images_noclick,&$images_orig_src_list) {
  2771. if(isset($m[1])&&$m[1]&&$m[1][1]=='a'){ $height="";
  2772. if(preg_match("/([0-9]{1,2})em/u",$m[0],$hm)){$height=' style="height:'.$hm[1].'em;"';}
  2773. return "<a class='imbtn'".$height.substr($m[0],2); }
  2774. $orig_src = $src = $m[5]; $keep = false; $original = false; $float=false;
  2775. if (preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[3]) ||
  2776. preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[7])) { $keep=true; }
  2777. if ($keep && preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[3]) ||
  2778. preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[7])) { $original=true; }
  2779. if (preg_match('/alt=[\'\"].*float.*[\'\"]/u',$m[3]) ||
  2780. preg_match('/alt=[\'\"].*float.*[\'\"]/u',$m[7])) { $keep=true;$original=true;$float=true; }
  2781. if(($im = &$this->FindImage($m[5]))!=NULL && isset($im['thumb'])){
  2782. $src = $im['thumb']; $orig_src=$im['file'];
  2783. }if($im == NULL){ $im = &$this->NULL_IMAGE_DUMMY; }
  2784. $media_start = $m[2];
  2785. $media_end = $m[7];
  2786. $dataset = " data-imgsrc='".$m[5]."'".
  2787. (isset($im['product'])?" data-product='".$im['product']."'":"").
  2788. (isset($im['parent'])?" data-parent='".$im['parent']."'":"").
  2789. (isset($im['align'])?' data-align="'.$im["align"].'" style="object-position:'.$im['align'].';"':"").
  2790. ($original?" class='original_img'":"");
  2791. if(isset($im['video']) && isset($im['video'])!=''){
  2792. $media_start = "<video controls".$dataset."><source src='"; $media_end="' type='".$im['video']."'></video";
  2793. $src = $orig_src; $dataset="";
  2794. }
  2795. $float_add=""; if($float){ $float_add=" imd_float"; }
  2796. if($this->InHereMode){
  2797. $click = "<div class='imd$float_add'>"."<a href='?here=".$im['file']."' class='original_img'>".
  2798. $media_start.($original?$orig_src:$src).$media_end."></a></div>";
  2799. $ret=""; if($keep) { $ret = $click; }
  2800. else { $images[] = $click; }
  2801. return $ret;
  2802. }else{
  2803. $click ="<div class='imd$float_add'><a href='?show_image={$im['name']}' target='_blank' onclick='event.preventDefault();'>".
  2804. $media_start.($original?$orig_src:$src).$media_end.$dataset."></a></div>";
  2805. $images_noclick[]=$media_start.$src.$media_end.">"; $images_orig_src_list[]=$orig_src;
  2806. $ret = "";
  2807. if($keep) { $ret = $click; }
  2808. else { $images[] = $click; }
  2809. if(isset($m[1])&&isset($m[8])&&$m[1]&&$m[8]) return $ret;
  2810. else return ((isset($m[1])&&$m[1]?$m[1]:"").$ret.(isset($m[8])&&$m[8]?$m[8]:""));
  2811. }
  2812. },$html,-1,$count);
  2813. $html = preg_replace('/<p>\s*<\/p>/u',"", $html); if($html==""){$html="<p>&nbsp;</p>";}
  2814. if(sizeof($images)){
  2815. if((!$this->InHereMode) && sizeof($images)==1){$html.= $images[0]; }
  2816. else{
  2817. $html.="<div class='p_row'>";
  2818. foreach($images as $img){
  2819. $html.="<div class='p_thumb'>".$img."</div>";
  2820. }
  2821. $html.="<div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div>";
  2822. }
  2823. }
  2824. if(sizeof($images_noclick)){ $added_images = $images_noclick; }
  2825. if(sizeof($images_orig_src_list)) { $orig_src_list = $images_orig_src_list; }
  2826. if($do_product_info){
  2827. $html = preg_replace_callback("/\{PRICE\s+([^]]+?)\}/u",
  2828. function($m) use (&$product_info) { $product_info['price']=$m[1];return ""; },$html);
  2829. $html = preg_replace_callback("/\{SHORT\s+([^]]+?)\}/u",
  2830. function($m) use (&$product_info) { $product_info['short']=$m[1];return ""; },$html);
  2831. $html = preg_replace('/<p>\s*<\/p>/u',"", $html);
  2832. if (preg_match('/<h[1-5]>(.+?)<\/h/u',$html,$title)){ $product_info['title']=$title[1]; }
  2833. else { $product_info['title'] = $this->T('商品'); }
  2834. if(!isset($product_info['price'])) $product_info['price']=$this->T('未设置价格');
  2835. $html = preg_replace_callback("/\{PURCHASE\s+([^]]+?)\}/u",function($m) use (&$product_info) {
  2836. return "<a class='purchase_button' href=\"mailto:".$this->T($this->DisplayName)."<".$this->EMail.">?subject=".
  2837. $this->T('购买').' '.$product_info['title'].
  2838. "&body=".$this->T('你好!我想购买').$product_info['title'].urlencode(PHP_EOL.PHP_EOL).
  2839. $this->FullURL().urlencode(PHP_EOL.PHP_EOL)."\">".$m[1]."</a>"; },$html);
  2840. }
  2841. if(preg_match("/(<\/div>|<\/table>|<\/video>)\s*$/u",$html)){$end_wide=true;}
  2842. return $html;
  2843. }
  2844. function ConvertPost(&$post){
  2845. if(!isset($post['html'])){
  2846. $info=[];
  2847. $post['html'] = $this->TranslatePostParts($this->PostProcessHTML($this->ChoosePartsByLanguage($this->PDE->text($this->InsertReplacementSymbols($post['content'], $post)),true),
  2848. $post['images'],
  2849. isset($post['product']), $info,
  2850. $post['original_images'],
  2851. $post['end_wide'],
  2852. $post['wide']));
  2853. if(isset($post['product'])) $post['product']=$info;
  2854. }
  2855. }
  2856. function GetPostTitle(&$post, $h1_only=false, $add_unamed=true){
  2857. if($h1_only){
  2858. if(preg_match('/^#\s+(.*?)$/mu',$post['content'],$m)) return $m[1];
  2859. else return NULL;
  2860. }
  2861. if(!isset($post['title'])){
  2862. if(preg_match('/^#{1,6}\s+(.*?)$/mu',$post['content'],$m)){$post['title']=$m[1];}
  2863. else{ $post['title'] = $add_unamed?$this->T('未命名'):"";
  2864. if(preg_match('/(.*)$/mu',$post['content'],$m)){
  2865. $post['title'].=($add_unamed?' (':'').strip_tags($this->PDE->text($m[1])).($add_unamed?')':''); }
  2866. }
  2867. }
  2868. return $this->ChoosePartsByLanguage($post['title']);
  2869. }
  2870. function DetectPageType(){
  2871. if ($this->InExperimentalMode) $this->PageType='experimental';
  2872. else if($this->InHereMode) $this->PageType='here';
  2873. else if(isset($_GET['history'])) $this->PageType='history';
  2874. else if(isset($_GET['extras'])) $this->PageType='extras';
  2875. else if(isset($_GET['settings'])) $this->PageType='settings';
  2876. else if(isset($_GET['gallery'])) $this->PageType='gallery';
  2877. else if(isset($_GET['search'])) $this->PageType='search';
  2878. else if(isset($_GET['category'])) $this->PageType='category';
  2879. else if(isset($this->CurrentPostID)) $this->PageType = "post";
  2880. else if(isset($_GET['comments'])) $this->PageType='comments';
  2881. else if(isset($_GET['statistics'])) $this->PageType='statistics';
  2882. else $this->PageType = "main";
  2883. $visited_here = $this->InExperimentalMode?"visited_experimental":"visited_here";
  2884. if(!isset($_SESSION[$visited_here])){ $_SESSION[$visited_here] = []; }
  2885. $this->VisitedHere = $_SESSION[$visited_here];
  2886. }
  2887. function MakePageBegin(&$p){ $title=$this->InExperimentalMode?$this->T($this->ExpTitle):
  2888. ($this->InHereMode?$this->T($this->HereTitle):$this->T($this->Title)) ?>
  2889. <!DOCTYPE html><html lang='zh-Hans-CN'>
  2890. <head>
  2891. <meta charset='utf-8'>
  2892. <meta content="width=device-width, initial-scale=1" name="viewport">
  2893. <title><?=$title?></title>
  2894. <meta property="og:title" content="<?=$title.(isset($p)?(" | ".$this->GetPostTitle($p)):"")?>">
  2895. <?php if(isset($p)&&isset($p['hasi'])&&isset($p['hasi'][0])){?> <meta property="twitter:card" content="summary_large_image" />
  2896. <meta property="og:image" content="<?=(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']==='on'?"https":"http").'://'.$_SERVER['HTTP_HOST'].'/images/thumb/'.$p['hasi'][0]?>"><?php } ?>
  2897. <?php if($this->UseRemoteFont){ ?><style>
  2898. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Regular.otf") format("opentype");font-weight:normal;}
  2899. @font-face{font-family: "Noto Serif CJK SC";src:url("fonts/NotoSerifSC-Bold.otf") format("opentype");font-weight:bold;}
  2900. </style><?php } ?>
  2901. <link href='styles/main.css' rel='stylesheet' type="text/css">
  2902. <link rel="alternate" type="application/rss+xml" title="<?=$this->T($this->Title);?>" href="?rss=<?=$this->LanguageAppendix;?>" />
  2903. <link rel="alternate" hreflang="zh" href="index.php?<?=$_SERVER['QUERY_STRING']?>" />
  2904. <link rel="alternate" hreflang="en" href="en.php?<?=$_SERVER['QUERY_STRING']?>" />
  2905. <link rel="alternate" hreflang="x-default" href="en.php?<?=$_SERVER['QUERY_STRING']?>" />
  2906. <?php if(isset($this->SelfAuthPath)&&$this->SelfAuthPath!=""){ ?>
  2907. <link rel="authorization_endpoint" href="<?=$this->SelfAuthPath?>" /><?php } ?>
  2908. <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>
  2909. </head>
  2910. <div class='page'>
  2911. <?php }
  2912. function MakeHeader(&$p){
  2913. $this->MakePageBegin($p) ?>
  2914. <script type='text/javascript'>
  2915. function toggle_mobile_show(a){a.classList.toggle('hidden_m')}
  2916. function ShowWaitingBar(){wait = document.querySelector("#waiting_bar");wait.style.display='';}
  2917. function HideWaitingBar(){wait = document.querySelector("#waiting_bar");wait.style.display='none';}
  2918. <?php if(!$this->InHereMode){ ?>
  2919. function la_auto_grow(element){
  2920. s=window.scrollY;element.style.height="30px";element.style.height=(element.scrollHeight)+"px";window.scroll(0, s);
  2921. }
  2922. function ShowBackdrop(alpha=0.5){
  2923. b = document.getElementById('backdrop');
  2924. b.style="background-color:rgba(0,0,0,"+alpha+");";
  2925. b.style.animation='backdrop_fade_in 0.3s forwards';
  2926. b.style.display = 'block';
  2927. }
  2928. function HideBackdrop(){
  2929. b = document.getElementById('backdrop');
  2930. b.style.animation='backdrop_fade_out 0.3s forwards';
  2931. setTimeout(function(e1){e1.style.display='none';}, 300, b);
  2932. }
  2933. function ShowRightSide(big,elem_to_clone){
  2934. p = document.getElementById('pop_right');
  2935. if(elem_to_clone){
  2936. c = elem_to_clone.cloneNode(true);
  2937. c.id='side_bar_cloned';c.className="";c.style="";
  2938. p.querySelector('._content').appendChild(c);
  2939. }
  2940. p.classList.remove('pop_right','pop_right_big');
  2941. if(big) {p.classList.add('pop_right_big');p.style.animation='pop_slide_in_big 0.3s forwards';}
  2942. else {p.classList.add('pop_right');p.style.animation='pop_slide_in 0.3s forwards';}
  2943. p.style.display='block';
  2944. ShowBackdrop(0.5);
  2945. }
  2946. function HideRightSide(){
  2947. p = document.getElementById('pop_right');
  2948. if(side=p.querySelector('#side_bar_cloned')){
  2949. side.remove();
  2950. }
  2951. put = document.querySelector("#_uploader");
  2952. if(p.classList.contains('pop_right')){p.style.animation='pop_slide_out 0.3s forwards';}
  2953. else{p.style.animation='pop_slide_out_big 0.3s forwards';}
  2954. setTimeout(function(e1, e2){e1.style.display='none';if(e2)e2.style.display='none';}, 300, p, put);
  2955. HideBackdrop();
  2956. }
  2957. function CssNumberID(id){ return "#\\3"+id.substr(0,1)+" "+id.substr(1); }
  2958. function ScrollToPost(id){
  2959. post=null;
  2960. if(!(post = document.querySelector("[data-post-id='"+id+"']"))){
  2961. if(!(post = document.querySelector(CssNumberID(id)))) return; }
  2962. post.scrollIntoView({ behavior: 'smooth', block: 'start'});
  2963. }
  2964. <?php } ?>
  2965. </script><input type='checkbox' class='lpctrl' id='titlectrl'>
  2966. <header<?=$this->InHereMode?' class="exp_h_f"':''?>><div>
  2967. <?php if($this->InHereMode){
  2968. $this->MakeExpNavButtons($p);
  2969. }else{
  2970. $this->MakeNavButtons($p);
  2971. if(isset($p['tid']['header'])){ ?><div style='float:right' class='show_on_print'><?=$this->ChoosePartsByLanguage($p['tid']['header']);?></div><?php }
  2972. echo "<hr class='hidden_m'>";
  2973. } ?>
  2974. <?php if(isset($this->WayBack)){
  2975. $time=(isset($_COOKIE['la_wayback']) && preg_match('/[0-9]{14}/u',$_COOKIE['la_wayback']))?$_COOKIE['la_wayback']:date('YmdHis');
  2976. $year=substr($time,0,4);$month=substr($time,4,2);$day=substr($time,6,2);
  2977. $hour=substr($time,8,2);$minute=substr($time,10,2);?> <div class='text_highlight'>
  2978. &nbsp;<b><span onclick='document.getElementById("wayback_config").classList.toggle("hidden_m")'>
  2979. <div class='wayback_close' onclick='event.stopPropagation()'><a href='<?=$this->GetRedirect()?>&set_wayback=false'>
  2980. <span class='hidden_m'><?=$this->T('退出')?></span>×&nbsp;</a></div>
  2981. + <?=$this->T('正以过去的日期浏览')?></b><div id='wayback_config' class='wayback_expand hidden_m'>
  2982. <select id="wayback_year" name="wayback_year" form="wayback_form"><?php for($y=$this->YearBegin;$y<=$this->YearEnd;$y++){ ?>
  2983. <option value="<?=$y?>"<?=$y==$year?" selected":""?>><?=$y?></option><?php } ?></select>
  2984. <br class='hidden_on_desktop' />
  2985. <select id="wayback_month" name="wayback_month" form="wayback_form"><?php for($y=1;$y<=12;$y++){ ?>
  2986. <option value="<?=$y?>"<?=$y==$month?" selected":""?>><?=$y?></option><?php } ?></select>
  2987. <select id="wayback_day" name="wayback_day" form="wayback_form"><?php for($y=1;$y<=31;$y++){ ?>
  2988. <option value="<?=$y?>"<?=$y==$day?" selected":""?>><?=$y?></option><?php } ?></select>
  2989. <br class='hidden_on_desktop' />
  2990. <select id="wayback_hour" name="wayback_hour" form="wayback_form"><?php for($y=0;$y<=23;$y++){ ?>
  2991. <option value="<?=$y?>"<?=$y==$hour?" selected":""?>><?=$y?></option><?php } ?></select>:
  2992. <select id="wayback_minute" name="wayback_minute" form="wayback_form"><?php for($y=0;$y<=59;$y++){ ?>
  2993. <option value="<?=$y?>"<?=$y==$minute?" selected":""?>><?=$y?></option><?php } ?></select>
  2994. <br class='hidden_on_desktop' />
  2995. <form action="<?=$this->GetRedirect()?>&set_wayback=post" method="post" style='display:none;' id='wayback_form'></form>
  2996. <input type='submit' style='font-weight:normal;border-bottom:none;' class='button clean_a' form='wayback_form'
  2997. id='wayback_see' name='wayback_see' value="<?=$this->T('查看')?> →">
  2998. </div></div><?php } ?>
  2999. </div></header>
  3000. <div id='waiting_bar' style='display:none;'></div>
  3001. <script>ShowWaitingBar();window.addEventListener('load',(event) =>{HideWaitingBar();}); </script>
  3002. <?php if(!$this->InHereMode){ ?>
  3003. <div id='post_menu' style='display:none;' class='pop_menu clean_a'>
  3004. <ul>
  3005. <li><span id='_time_hook' class='smaller'>时间</span>&nbsp;&nbsp;<a href='javascript:HidePopMenu();'>×</a></li>
  3006. <li><a id='share_copy'>⎘<?=$this->T('复制链接')?></a></li>
  3007. <hr />
  3008. <?php if($this->LoggedIn){ ?>
  3009. <li><a id='menu_history'><?=$this->T('历史')?></a>
  3010. <?php if(!isset($this->WayBack) && $this->PageType!='search'){ ?>
  3011. | <a id='menu_edit'><?=$this->T('修改')?></a><?php } ?></li>
  3012. <?php if(!isset($this->WayBack)){ ?><li>
  3013. <a id='menu_refer_copy'><?=$this->T('复制编号')?></a><?php if($this->PageType!='search'){ ?>
  3014. | <a id='menu_refer'><?=$this->T('引用')?></a><?php } ?><br class='hidden_on_desktop' />
  3015. </li>
  3016. <li><a id='menu_rename' href='javascript:ToggleRenameDetails()'><?=$this->T('改名')?></a> |
  3017. <a id='menu_mark' href='javascript:ToggleMarkDetails()'><?=$this->T('标记')?></a></li>
  3018. <li id='mark_details' style='display:none;'><b>
  3019. <a id='mark_set_clear' href='javascript:SetMark(-1);'>_</a>
  3020. <a id='mark_set_0' href='javascript:SetMark(0);'><?=$this->Markers[0]?></a>
  3021. <a id='mark_set_1' href='javascript:SetMark(1);'><?=$this->Markers[1]?></a>
  3022. <a id='mark_set_2' href='javascript:SetMark(2);'><?=$this->Markers[2]?></a>
  3023. <a id='mark_set_3' href='javascript:SetMark(3);'><?=$this->Markers[3]?></a>
  3024. <a id='mark_set_4' href='javascript:SetMark(4);'><?=$this->Markers[4]?></a>
  3025. <a id='mark_set_5' href='javascript:SetMark(5);'><?=$this->Markers[5]?></a>
  3026. <a id='mark_set_6' href='javascript:SetMark(6);'><?=$this->Markers[6]?></a>
  3027. <a id='mark_set_7' href='javascript:SetMark(7);'><?=$this->Markers[7]?></a>
  3028. </b></li>
  3029. <li id='rename_details' style='display:none;text-align:left;' class='smaller'>
  3030. <form action="" method="post" style='display:none;' id='post_rename_form'></form>
  3031. <input type='text' id='post_rename_name' name='post_rename_name' form="post_rename_form" style='width:9em;'>
  3032. <input class='button' type='submit' form='post_rename_form'
  3033. name='post_rename_confirm' id='post_rename_confirm' value='<?=$this->T('确认')?>'>
  3034. </li><hr /> <?php if(isset($this->MastodonToken)){ ?>
  3035. <li><a id='menu_mastodon_view' class='button' style='display:none;' target='_blank'><?=$this->T('转到')?></a>
  3036. <a id='menu_mastodon' href='javascript:ToggleMastodonDetails()'><?=$this->T('长毛象')?></a></li>
  3037. <li id='mastodon_details' style='display:none;text-align:left;' class='smaller'>
  3038. <a id='menu_mastodon_send' class='button' target='_blank'><?=$this->T('发送')?></a>
  3039. <form action="" method="post" style='display:none;' id='post_mastodon_form'></form>
  3040. <input type='text' id='post_mastodon_url' name='post_mastodon_url' form="post_mastodon_form" style='width:9em;'>
  3041. <input class='button' type='submit' form='post_mastodon_form'
  3042. name='post_mastodon_confirm' id='post_mastodon_confirm' value='<?=$this->T('修改')?>'></li> <?php } ?>
  3043. <hr /><li><a id='menu_delete' class='smaller'><?=$this->T('删除')?></a></li><?php } ?>
  3044. <?php }else{ ?>
  3045. <li><a id='menu_history'><?=$this->T('历史')?></a></li>
  3046. <?php } ?>
  3047. </ul>
  3048. </div>
  3049. <div id='backdrop' style='display:none;' class='backdrop' onclick='HideRightSide();HideBigImage(1);'
  3050. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"></div>
  3051. <div id='pop_right' class='pop_right' onclick='event.stopPropagation()'>
  3052. <div style='text-align:right;position:sticky;top:0;'><a class='clean_a' href='javascript:HideRightSide();'>
  3053. <?=$this->T('关闭')?>→</a></div>
  3054. <?php if($this->LoggedIn && in_array($this->PageType,['main','post'])){ ?>
  3055. <div id='_uploader' style='display:none;'>
  3056. <?php $this->MakeUploader(true); ?>
  3057. <p>&nbsp;</p>
  3058. <?php $this->MakeSideGalleryCode(); ?>
  3059. </div>
  3060. <?php } ?>
  3061. <div class='_content'></div>
  3062. </div>
  3063. <?php } ?>
  3064. <?php
  3065. }
  3066. function ChoosePartsByLanguage($content,$use_p=false){ if(!isset($content)) return $content;
  3067. $split = preg_split('/'.($use_p?'<p>\s*':'').'((en|zh|any)\|(en|zh|any))'.($use_p?'<\/p>\s*':'').'/u',$content, -1,
  3068. PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
  3069. $lang = $this->LanguageAppendix; $last_lang='0'; $reduced="";
  3070. if($split) for($i=0;$i<sizeof($split);$i+=4){
  3071. $this_lang = '0'; if($i+2>=sizeof($split)){ $this_lang = $last_lang; }else{ $this_lang = $split[$i+2]; }
  3072. if($this_lang==$lang || $this_lang=='any'){ $reduced.=$split[$i]; }
  3073. if($i+3<sizeof($split)){ $last_lang = $split[$i+3]; }
  3074. }
  3075. if(!$reduced)$reduced = $content;
  3076. return $reduced;
  3077. }
  3078. function TranslatePostParts($html){
  3079. $html = preg_replace_callback('/>(\s*)([^><]+?)(\s*)</u', function($ma){
  3080. $reduced = $this->ChoosePartsByLanguage($ma[2], false);
  3081. return ">".$ma[1].$this->T($reduced).$ma[3]."<";
  3082. }, $html);
  3083. return $html;
  3084. }
  3085. function MakeNavButtons(&$p){ global $INDEXPHP; $interesting=$this->IsInterestingPost($p); $no_title=isset($p['tid']['first']['no_title']);?>
  3086. <a href='<?=$INDEXPHP?>' class='clean_a hidden_m<?=$no_title?" hidden_on_print":""?>' onclick='ShowWaitingBar()'><b><?=$this->T($this->Title);?></b></a>
  3087. <?=$no_title?"<a class='inline_print'>&nbsp;</a>":""?>
  3088. <label for='titlectrl' id='mtitle'><b><a class='hidden_on_desktop'><?=$this->T($this->ShortTitle)?>...</a></b></label>
  3089. <div class='header_nav'>
  3090. <ul class='mobile_fold hidden_on_print' id='mobile_nav'>
  3091. <li class='hidden_m'><a href='?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  3092. <li class='hidden_on_desktop_force block_m smaller'>&nbsp;</li>
  3093. <li class='hidden_on_desktop_force block_m bigger'>
  3094. <a href='<?=$INDEXPHP?>?part=recent' onclick='ShowWaitingBar()'><?=$this->T('最近')?></a>
  3095. <?php if($this->LoggedIn){ ?> | <span class='gray invert_a'>
  3096. <a href='<?=$INDEXPHP?>?comments=all'>@</a> <a href='<?=$INDEXPHP?>?statistics=all'>%</a></span><?php } ?></li>
  3097. <li class='hidden_on_desktop_force block_m bigger'>
  3098. <a href='<?=$INDEXPHP?>?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  3099. <?php $this->SpecialNavigation;if(isset($this->SpecialNavigation) && ($p = &$this->GetPost($this->SpecialNavigation))!=NULL){
  3100. echo $this->GenerateSinglePost($p, false, false, false, false);
  3101. } ?>
  3102. <?php if($this->LanguageAppendix=='zh'){ ?>
  3103. <li class='smaller gray'>
  3104. <a href='<?=$this->GetRedirect(null,'en.php').'&set_language=en'?>' onclick='ShowWaitingBar()'><b>汉语</b>/English</a></li>
  3105. <?php }else { ?>
  3106. <li class='smaller gray'>
  3107. <a href='<?=$this->GetRedirect(null,'index.php').'&set_language=zh'?>' onclick='ShowWaitingBar()'>
  3108. 汉语/<b>English</b></a>
  3109. <br class='hidden_on_desktop' />
  3110. <a id='translate_button' target='_blank'>&nbsp;[Google Translate]&nbsp;</a></li>
  3111. <?php } ?>
  3112. </ul></div>
  3113. <?php
  3114. }
  3115. function MakeExpNavButtons(&$p){ global $INDEXPHP; ?>
  3116. <a href='<?=$INDEXPHP?>' class='hidden_m'>
  3117. <b><?=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle)?></b></a>
  3118. <a class='hidden_on_desktop'
  3119. href='javascript:toggle_mobile_show(document.getElementById("mobile_nav"))'><b class='round_btn'>
  3120. <?=$this->InExperimentalMode?$this->T($this->ExpShortTitle):$this->T($this->HereShortTitle)?></b></a>
  3121. <?php if(!$this->InExperimentalMode){ ?>
  3122. <a <?=$this->HereNumber==1?"class='gray'":("href=".$this->HereLinkFromNumber($this->HereNumber-1))?>>←</a>
  3123. <span><?=$this->HereNumber.'/'.sizeof($this->VisitedHere);?></span>
  3124. <span class='round_btn'>
  3125. <a href='<?=$this->HereNumber==sizeof($this->VisitedHere)?"?random_here=1":$this->HereLinkFromNumber($this->HereNumber+1);?>'>→</a>
  3126. <a href='?random_here=1'><?=$this->T("随机")?></a></span><span class='hidden_m'></span>
  3127. <?php } ?>
  3128. <ul class='hidden_m' id='mobile_nav' style='text-align:center;'>
  3129. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  3130. <li class='hidden_on_desktop block_m'><a href='<?=$INDEXPHP?>'><?=$this->T('主页')?></a></li>
  3131. <?php if($this->InExperimentalMode && isset($this->ExpNavigation) && ($p = &$this->GetPost($this->ExpNavigation))!=NULL){
  3132. echo $this->GenerateSinglePost($p, false, false, false, false);
  3133. }else if($this->InHereMode && isset($this->HereNavigation) && ($p = &$this->GetPost($this->HereNavigation))!=NULL){
  3134. echo $this->GenerateSinglePost($p, false, false, false, false);
  3135. } ?>
  3136. <?php if($this->AllowLanguageChoices){ ?>
  3137. <li class='smaller hidden_on_desktop'>&nbsp;</li>
  3138. <?php if($this->LanguageAppendix=='zh'){ ?>
  3139. <li class='smaller invert_a gray'><a href='<?=$this->GetRedirect().'&set_language=en'?>'><b>汉语</b>/English</a></li>
  3140. <?php }else { ?>
  3141. <li class='smaller invert_a gray'><a href='<?=$this->GetRedirect().'&set_language=zh'?>'>汉语/<b>English</b></a></li>
  3142. <li class='smaller invert_a gray'><a id='translate_button' target='_blank'>&nbsp;Google Translate&nbsp;</a></li>
  3143. <?php } ?>
  3144. <?php } ?>
  3145. </ul>
  3146. <?php
  3147. }
  3148. function MakePostingFieldsV2($reply_to=NULL, $show_hint=false){ $STR="";
  3149. if(isset($this->WayBack)){
  3150. $STR.="<span class='gray'><i>{$this->T('以过去日期浏览时不能发帖。')}</i></span>";
  3151. $this->TFill(2,$STR); $this->TRow(); return;
  3152. }
  3153. $STR.="<form action='{$_SERVER['REQUEST_URI']}' method='post' style='display:none;' id='post_form'></form>
  3154. <div class='smaller'><div style='display:".($show_hint?"block":"none")."'>
  3155. <span id='post_hint_text'>{$this->T('继续补充该话题:')}</span></div>
  3156. <div id='post_hint_modify' style='display:none;'>
  3157. <input type='checkbox' name='post_record_edit' value='1' form='post_form' checked> {$this->T('新增历史记录')}</div></div>
  3158. <textarea id='post_content' name='post_content' rows='4' form='post_form'
  3159. onfocus=\"if (value =='{$this->T('有什么想说的')}'){value ='';}la_auto_grow(this);\"
  3160. onblur=\"if (value ==''){value='{$this->T('有什么想说的')}';la_auto_grow(this);}\"
  3161. oninput=\"la_auto_grow(this);\" onload=\"la_auto_grow(this);\">{$this->T('有什么想说的')}</textarea>
  3162. <input class='button' form=\"post_form\" type=\"submit\" name='post_button' value='{$this->T('发送')}'
  3163. onclick='ShowWaitingBar();' />
  3164. | <a class='gray smaller pointer' onclick='ShowSideUploader();'>{$this->T('图片')}</a>
  3165. <div style='float:right;'>
  3166. <a class='gray smaller pointer' onclick=\"t=document.querySelector('#post_content');t.value='';la_auto_grow(t);\">
  3167. {$this->T('清空')}</a>
  3168. <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
  3169. </div>
  3170. <input style='display:none;' type=input form='post_form' id='post_edit_target' name='post_edit_target' />
  3171. <script> la_auto_grow(document.getElementById('post_content'));</script>";
  3172. if($reply_to){
  3173. $STR.="<input style='display:none;' type=input form='post_form' id='post_reply_to' name='post_reply_to' value='{$reply_to}' />";
  3174. }
  3175. $this->TFill(2,$STR);$this->TExtra("class='hidden_on_print'"); $this->TRow();
  3176. }
  3177. function MakeLinkedPostsV2(&$p){ $STR="";
  3178. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); if(!$has_ref)return; $count=0;
  3179. $STR.="<input type='checkbox' class='lpctrl' id='fake{$p["id"]}' checked='checked'>";
  3180. $count_product=0;
  3181. $STR.="<div class='linked_posts smaller'>";
  3182. $refs=sizeof($p["refs"]);
  3183. $STR.="<label class='lb ref_count' for='fake{$p["id"]}'>× $refs".$this->T("个引用").":</label><hr />";
  3184. foreach(array_reverse($p['refs']) as &$pr){
  3185. $po = $this->GetPost($pr);
  3186. if(!$this->CanShowPost($po)){ continue; } $count++;
  3187. $this->TBackup();
  3188. $this->MakeSinglePostV2($po, false, true, 0, true, true, false, false, true, false, false);
  3189. $STR.=$this->TRestore(" compact");
  3190. }
  3191. $STR.="</div>";
  3192. $this->TFill(0,$S0);
  3193. $this->TFill(1,$STR,2);$this->TExtra("style='border-bottom:none;'"); $this->TRow();
  3194. }
  3195. function MakeSinglePostV2(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
  3196. $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
  3197. $generate_thumb = false, $is_top = false, $force_hide_long=false){
  3198. $STR=""; $EXTRA="";$S0=""; $S1="";
  3199. $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
  3200. $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
  3201. $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
  3202. $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
  3203. $number = isset($post['number'])?$post['number']:0;
  3204. $title = $generate_anchor?$this->ChoosePartsByLanguage($this->GetPostTitle($post, true)):NULL;
  3205. $this->ConvertPost($post);// NEEDED FOR WIDE;
  3206. $is_wide = (isset($post['wide'])&&$post['wide']) || (isset($post['tid']) && isset($post['tid']['wide']) && $post['tid']['wide']);
  3207. if($show_link && (!$side)){ $this->MakeLinkedPostsV2($post); }
  3208. $EXTRA.="class='post $extra_class_string".($is_deleted?" deleted_post":"").($is_wide?" wide_post_print":"")."'";
  3209. if(!$side) $EXTRA.=(" data-post-id='".$post['id']."'");
  3210. if($is_deleted) $EXTRA.=" data-mark-delete='true'";
  3211. if(!$side&&isset($post['mastodon_url'])) $EXTRA.=(" data-mastodon_url='".$post['mastodon_url']."'");
  3212. //if($is_wide) $EXTRA.=" class=''";
  3213. if(!$side && !$strip_tags && $show_link){ $STR.="<div class='post_menu_button _menu_hook' >+</div>"; }
  3214. $this->TFill(2,$STR);
  3215. $symbol=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:"#";
  3216. $S1.="<a".($symbol!='#'?' class="marked"':'').
  3217. " href='?post={$post['id']}' onclick=\"".(($show_thread_link||$side)?'ShowWaitingBar()':'ClickPost(this.parentNode.parentNode,event,true)')."\">".
  3218. $symbol."<span class='mobile_fold'>".$number."</span>";
  3219. if($ref_count && !$side){
  3220. $S0.="<label class='lb' ".($show_link?"for='fake{$post["id"]}":"")."'><div class='ref_count'>+<span class='hidden_m'>{$ref_count}</span></div></label>";
  3221. }
  3222. if($is_product&&!$generate_anchor){ $STR.="<p class='smaller gray'>".$this->T('商品')."</p>";}
  3223. $STR.=$this->GenerateSinglePost($post, $strip_tags, $generate_anchor, $show_link,
  3224. $generate_thumb,($show_thread_link||$side||$force_hide_long));
  3225. if($show_thread_link && (!$side) && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) && $post['tid']['first']['id']!=$post['id']){
  3226. $STR.="<div class='gray block'>";
  3227. $STR.="<div class='smaller'>{$this->T('回复给主题帖:')}</div>";
  3228. $this->TBackup();
  3229. $this->MakeSinglePostV2($post['tid']['first'], false, false, false, false, false, false,false, true, false, false);
  3230. $STR.=$this->TRestore(" compact");
  3231. $STR.="</div>";
  3232. }
  3233. if($show_reply_count && isset($post['tid'])){
  3234. $STR.="<a class='smaller block invert_a' href='?post={$post['tid']['last']['id']}'>{$post['tid']['count']} {$this->T('个回复')}</a>";
  3235. }
  3236. $this->TFill(2,$STR); $this->TFill(1,$S1); $this->TFill(0,$S0); $this->TExtra($EXTRA); $this->TRow();
  3237. }
  3238. function MakePostSectionV2(&$post){ $STR=""; $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1;
  3239. $this->Anchors = []; if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))) $centerclass='center_slides'; else $centerclass='center';
  3240. if(isset($this->TagID)){ $STR.=<<<EOT
  3241. <style>{$this->CssNumberID($this->TagID)}{display:block;}</style>
  3242. EOT; } $th=NULL; $STR.="<br /><h2>";
  3243. $is_wide = (isset($post['wide'])&&$post['wide']) || ($is_thread && isset($post['tid']['wide']) && $post['tid']['wide']);
  3244. if($is_thread){ $th = $post['tid']; $STR.=$this->T('话题'); }else{ $STR.=$this->T('话题');$this->T('详细'); } $STR.="</h2>";
  3245. $this->TFill(2,$STR); $this->TExtra("class='hidden_on_print'"); $this->TRow();
  3246. $cat = NULL;
  3247. if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
  3248. else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
  3249. $this->MakePostTools();
  3250. if($cat){ $STR=<<<EOT
  3251. <p class='hidden_on_print'><b>{$this->T('分类')}</b> |
  3252. EOT; foreach($cat as $c){ $STR.=("<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "); }
  3253. $STR.="</p>";
  3254. }
  3255. $STR.="<br class='hidden_on_print' />"; $this->TFill(2,$STR); $this->TRow(); $is_reversed=false;
  3256. if($is_thread){ $use_arr = $th['arr']; $hinted=false;
  3257. $last_end_wide = true; $is_reversed=$this->IsReversedThread($th);
  3258. foreach($use_arr as &$p){$use_class="";if($p==$post){$use_class.=" active_post";}
  3259. if($last_end_wide){$use_class.=" last_wide";}
  3260. $make_title = ($p == $post);
  3261. if(isset($p['restart'])){ $STR="<li class='restart'><h3>{$p['restart']} …</h3></li>"; $this->TFill(0,$STR,3); $this->TRow(); }
  3262. $this->MakeSinglePostV2($p,true,false,$use_class,false, false, false, true, false, false);
  3263. if($make_title){ $STR.='<script>
  3264. document.title+=" | '.addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100))).'"</script>';
  3265. $this->TFill(2,$STR);
  3266. }
  3267. if($is_reversed && !$hinted){ $hinted = true;
  3268. if($this->LoggedIn && (!$this->InHereMode)){
  3269. $STR.="<div class='hidden_on_print'>";
  3270. $STR.=$this->MakePostingFieldsV2($is_thread?$th['last']['id']:$post['id'], true);
  3271. $STR.="</div><br />";
  3272. }
  3273. }
  3274. $last_end_wide = isset($p['end_wide']) && $p['end_wide'];
  3275. }
  3276. }else{
  3277. $this->MakeSinglePostV2($post,true, false,"active_post",false, false, false, true, false, false);
  3278. $STR.='<script>
  3279. document.title+=" | '.addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($post),0,100))).'"</script>';
  3280. $this->TFill(2,$STR); $this->TRow();
  3281. }
  3282. $STR="";
  3283. $class_add=""; if(isset($post['tid']['first']['no_time'])){ $class_add=' hidden_on_print'; }
  3284. $STR.="<div class='smaller align_right$class_add'>
  3285. <span class='gray'>".$this->ReadableTime($post['tid']['first']['id'])."</span>
  3286. <br class='hidden_on_desktop' />".
  3287. $this->ReadableTime(isset($post['tid']['last']['version'])?$post['tid']['last']['version']:$post['tid']['last']['id'])."
  3288. </div>";
  3289. $this->TFill(2,$STR); $this->TRow(); $STR="";
  3290. if(!$is_reversed && ($this->LoggedIn && (!$this->InHereMode))){
  3291. $STR.="<div class='hidden_on_print'><br />{$this->MakePostingFieldsV2($is_thread?$th['last']['id']:$post['id'], true)}</div>";
  3292. $this->TFill(2,$STR); $this->TRow();
  3293. }
  3294. //$this->MakeCommentSection($post);
  3295. $STR="";
  3296. if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))){
  3297. $STR.=<<<EOL
  3298. <div class='slides_buttons code' onclick="event.stopPropagation();">
  3299. <a onclick="SlidesFontCheck(-1)">T-</a> <a onclick="SlidesFontCheck(1)">T+</a>&nbsp;
  3300. <a onclick="SlidesStart(null)"><<</a> <a onclick="SlidesCheck(-1);"><</a>
  3301. <a onclick="SlidesStart(1)"><span id="slides_now">1</span>/<span id="slides_total">1</span></a>
  3302. <a onclick="SlidesCheck(1);">></a> <a onclick="SlidesEnd();">X</a>
  3303. </div>
  3304. <script>
  3305. function SlidesStart(from_here){
  3306. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  3307. sdone=0; fp=0; if(from_here){
  3308. urlParams = new URLSearchParams(window.location.search);
  3309. fp = urlParams.get('post');
  3310. }
  3311. document.querySelector("#slides_total").innerText=slides.length; cur=document.querySelector("#slides_now");
  3312. for(i=0;i<slides.length;i++){ slides[i].style.display="none";
  3313. if(from_here && slides[i].dataset.postId==fp){ slides[i].style.display="table-cell";sdone=1; ClickPost(slides[i],0,true); cur.innerText=i+1; }
  3314. } if(!sdone){ slides[0].style.display="table-cell"; ClickPost(slides[0],0,true); cur.innerText=1; }
  3315. c=document.querySelector('.center'); if(!c) return;
  3316. c.classList.remove('center'); c.classList.add('center_slides'); if(c.dataset.fontSize){ c.style.fontSize=c.dataset.fontSize; }
  3317. c=document.querySelector('.left'); if(!c) return; c.style.display="none";
  3318. }
  3319. function SlidesCheck(offset){
  3320. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return; cur=document.querySelector("#slides_now");
  3321. for(i=0;i<slides.length;i++){ if(slides[i].style.display=="table-cell" && slides[i+offset] && (i+offset)>=0){
  3322. slides[i+offset].style.display="table-cell"; slides[i].style.display="none"; ClickPost(slides[i+offset],0,true); cur.innerText=i+offset+1; break;
  3323. }
  3324. }
  3325. }
  3326. function SlidesFontCheck(offset){
  3327. c=document.querySelector('.center_slides'); if(!c) return;
  3328. f=5; if(c.style.fontSize){ f=parseInt(c.style.fontSize); }
  3329. f+=offset; if(f<=0) f=1; if(f>12) f=12; c.style.fontSize=""+f+"vmin"; c.dataset.fontSize=c.style.fontSize;
  3330. }
  3331. function SlidesEnd(){
  3332. c=document.querySelector('.center_slides'); if(!c) return;
  3333. c.classList.remove('center_slides'); c.classList.add('center'); c.style.fontSize="";
  3334. c=document.querySelector('.left'); if(!c) return; c.style.display="inline-block";
  3335. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  3336. for(i=0;i<slides.length;i++){ slides[i].style.display=""; }
  3337. }
  3338. //document.addEventListener("wheel", function(event){ if(event.deltaY>0) SlidesCheck(1); else SlidesCheck(-1); }, { passive: false });
  3339. document.addEventListener("click", function(event){ SlidesCheck(1); });
  3340. document.addEventListener('keydown', function(event) {
  3341. const key = event.key; // "ArrowRight", "ArrowLeft", "ArrowUp", or "ArrowDown"
  3342. switch(key){
  3343. case "ArrowUp": case "ArrowLeft": SlidesCheck(-1); break; case "ArrowDown": case "ArrowRight": SlidesCheck(1); break;
  3344. case "Escape": SlidesEnd(); break;
  3345. }
  3346. });
  3347. </script>
  3348. EOL; $this->TAfter($STR);
  3349. }
  3350. }
  3351. function MakeRecentPostsV2($search_term=NULL, $category=NULL){ global $INDEXPHP;
  3352. $STR="";
  3353. if(!isset($search_term) && !isset($category) &&
  3354. (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
  3355. $this->CanShowPost($p)){
  3356. $this->MakeSinglePostV2($p, true, false, "active_post", false, true, false, false, false, true, false);
  3357. }
  3358. $STR.="<br /><h2>".(isset($search_term)?$this->T('搜索'):
  3359. (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
  3360. ($category=='none'?$this->T('未分类'):$this->T($category))):($this->T('最近')).
  3361. " <span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
  3362. ($this->LoggedIn?"<a href='".$INDEXPHP."?comments=all'>@</a> <a href='".$INDEXPHP."?statistics=all'>%</a>":"")."</span>")).
  3363. "</h2>";
  3364. $this->TFill(2,$STR); $this->TRow();
  3365. if(isset($search_term)){
  3366. $STR.="<form action='".$INDEXPHP."' method='post' style='display:none;' id='search_form'></form>".
  3367. "<input id='search_content' name='search_content' rows='4' form='search_form' type='text' value='$search_term'>".
  3368. "<input class='button' form='search_form' type='submit' name='search_button' value='{$this->T('搜索')}'>";
  3369. $this->TFill(2,$STR); $this->TRow();
  3370. }else if(isset($category)){
  3371. $STR.="<div></div>";
  3372. $this->TFill(2,$STR); $this->TRow();
  3373. }else if($this->LoggedIn){
  3374. $this->TFill(2,$STR); $this->TRow();
  3375. $this->MakePostingFieldsV2(NULL,false);
  3376. }
  3377. $this->PostsPerPage=20;
  3378. $i = 0; $last_end_wide = true;
  3379. if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
  3380. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  3381. if(isset($p['tid'])){ /* Should always be set. */
  3382. $th = &$p['tid']; if($p['tid']['count']==0) continue;
  3383. if(!isset($search_term)) { $p = &$th['last']; }
  3384. }
  3385. if(isset($search_term)){
  3386. if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
  3387. }else if(isset($category)){
  3388. $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
  3389. (isset($p['categories'])?($p['categories']):[]);
  3390. if ($category=='none') { if($cat!=[]) continue; }
  3391. else{ if ($category=='' || !in_array($category, $cat)) continue; }
  3392. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3393. }else{
  3394. if(in_array($p['id'],
  3395. [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
  3396. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3397. }
  3398. if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
  3399. if($last_end_wide){$use_class="last_wide";}else{$use_class="";}
  3400. $this->MakeSinglePostV2($p, true, false, $use_class, false, !isset($search_term), false, false, false, false, isset($search_term));
  3401. $i++;
  3402. if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
  3403. $last_end_wide = sizeof($p['tid']['arr'])==1 && isset($p['end_wide']) && $p['end_wide'];
  3404. }
  3405. $STR=""; $EXTRA="class='clean_a'"; $STR.="<br /><br />".
  3406. "<a ".($this->CurrentOffset>0?("href='".$INDEXPHP."?offset=".($this->CurrentOffset-1).
  3407. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):"").
  3408. ($this->CurrentOffset==0?" class='gray'":"").">{$this->T('上一页')} ← </a>";
  3409. $STR.=" [ ".($this->CurrentOffset+1)." ] ";
  3410. $STR.="<a href='".$INDEXPHP."?offset=".($this->CurrentOffset+1).
  3411. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'>".
  3412. " → {$this->T('下一页')}</a>";
  3413. $this->TFill(0,$STR,3); $this->TExtra($EXTRA); $this->TRow();
  3414. }
  3415. function GeneratePage($is_section=false,$extra_classes=""){ $S="";
  3416. $S.="<table class='center print_column".($is_section?" clickable_section":"").($extra_classes)."'><tbody>";
  3417. foreach($this->PAGE as $r){ $S.="<tr ".(isset($r['extra'])?$r['extra']:"").">"; $spantotal=0; $sp="";
  3418. if(isset($r['span0'])){$sp=" colspan='".$r['span0']."'"; $spantotal+=$r['span0']; }else{ $spantotal++; };
  3419. if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[0])){ $S.=$r[0]; } $S.="</td>"; }
  3420. if(isset($r['span1'])){$sp=" colspan='".$r['span1']."'"; $spantotal+=$r['span1']; }else{ $spantotal++; };
  3421. if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[1])){ $S.=$r[1]; } $S.="</td>"; }
  3422. if(isset($r['span2'])){$sp=" colspan='".$r['span2']."'"; $spantotal+=$r['span2']; }else{ $spantotal++; };
  3423. if($spantotal<=3){ $S.="<td".$sp.">"; if(isset($r[2])){ $S.=$r[2]; } $S.="</td>"; }
  3424. $S.="</tr>";
  3425. }
  3426. $S.="</tbody></table>";
  3427. return $S;
  3428. }
  3429. function GenerateLinkedPosts($ht){
  3430. $ht = preg_replace_callback('/<p>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>(.*)<\/a>[\s]*<\/p>/u',
  3431. function($m){
  3432. if(preg_match('/^\s*<img/u',$m[2])){ return $m[0]; }
  3433. $rp = &$this->GetPost($m[1], false, true);
  3434. $STR=$this->T("未找到该引用。");
  3435. if($rp!==NULL && $this->CanShowPost($rp)){
  3436. $this->TBackup();
  3437. $this->MakeSinglePostV2($rp, false, false, false, false, false, false,false, true, false, false);
  3438. $STR=$this->TRestore(" compact");
  3439. }
  3440. $s="<a class='smaller block' href='?post=".$m[1]."'>".$m[2]."</a><div class='block post gray'>".$STR."</div>";
  3441. return $s;
  3442. },
  3443. $ht
  3444. );
  3445. $ht = preg_replace_callback('/<li>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>PRODUCT\s+(.*)<\/a>[\s]*<\/li>/u',
  3446. function($m){
  3447. $rp = &$this->GetPost($m[1], false, true);
  3448. $s="<div class='product_ref block post ref_compact'><a href='?post=".$m[1]."' class='clean_a' onclick='ShowWaitingBar()'>".
  3449. (($rp!==NULL && $this->CanShowPost($rp))?
  3450. $this->GenerateSinglePost($rp,true,false,false,true,true):$this->T("未找到该引用。")).
  3451. "</a></div>";
  3452. return $s;
  3453. },
  3454. $ht
  3455. );
  3456. return $ht;
  3457. }
  3458. function GenerateSinglePost(&$post, $strip_tags, $generate_anchor=false, $generate_refs=false,
  3459. $generate_thumbs=false, $hide_long = false){
  3460. $this->ConvertPost($post);
  3461. if($generate_anchor){ $this->CreatePostAnchor($post); }
  3462. $ht = $post['html'];
  3463. if(isset($post['mark_value']) && $post['mark_value']==5 && ($generate_thumbs || !$generate_anchor)){
  3464. $ht="<div class='product_thumb'>".$post['images'][0]."</div>".
  3465. "<p class='bold'>".$post['product']['title']."</p>".
  3466. (isset($post['product']['short'])?("<p class='smaller gray'>".$post['product']['short']."</p>"):"").
  3467. "<p class='smaller bold'>".$post['product']['price']."</p>";
  3468. return $ht;
  3469. }
  3470. if($hide_long){
  3471. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>[\s\S]*/u',"<p class='smaller bold'>[".$this->T("阅读更多")."]</p>", $ht);
  3472. }else{
  3473. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>/u',"", $ht);
  3474. }
  3475. if ($strip_tags){
  3476. $ht = strip_tags($ht,'<b><i><h1><h2><h3><h4><p><blockquote><span>');
  3477. $ht = preg_replace('/<p>\s*<\/p>/u',"", $ht);
  3478. $ht = $ht;
  3479. }
  3480. else{
  3481. if($generate_refs) $ht = $this->GenerateLinkedPosts($ht);
  3482. }
  3483. if ($strip_tags && $generate_thumbs){
  3484. $ht="<div class='hide_long'>".$ht."</div>";
  3485. if(isset($post['images']) && isset($post['images'][0])){
  3486. $ht.="<div class='post_ref_images'><ul class='side_thumb ref_thumb'>";
  3487. foreach($post['images'] as $im){
  3488. $ht.="<li class='file_thumb'>".$im."</li>";
  3489. }
  3490. $ht.="</ul></div>";
  3491. }
  3492. }
  3493. return $ht;
  3494. }
  3495. function MakeSinglePostExp(&$post){ ?>
  3496. <li class='post post_dummy'>
  3497. <?=$this->GenerateSinglePost($post, false, false, true, false, false); ?>
  3498. </li>
  3499. <?php
  3500. }
  3501. function MakeSinglePost(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
  3502. $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
  3503. $generate_thumb = false, $is_top = false, $force_hide_long=false){
  3504. $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
  3505. $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
  3506. $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
  3507. $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
  3508. $title = $generate_anchor?$this->ChoosePartsByLanguage($this->GetPostTitle($post, true)):NULL;
  3509. $this->ConvertPost($post);// NEEDED FOR WIDE;
  3510. $is_wide = (isset($post['wide'])&&$post['wide']) || (isset($post['tid']) && isset($post['tid']['wide']) && $post['tid']['wide']);
  3511. ?>
  3512. <?=$title?"<div class='print_title'><h1>".$title."</h1></div>":""?>
  3513. <div class='post<?=isset($extra_class_string)?' '.$extra_class_string:''?>'
  3514. <?=(!$side)?"data-post-id='".$post['id']."'":""?> <?=$is_deleted?"data-mark-delete='true'":""?>
  3515. <?=(!$side&&isset($post['mastodon_url']))?"data-mastodon_url='".$post['mastodon_url']."'":""?>
  3516. <?=$is_wide?" style='column-span:all;'":"";?>>
  3517. <?php if($mark_value>=0 && !$show_link && $mark_value!='P'){?>
  3518. <div class='smaller <?=$is_deleted?"gray":""?>'><?=$mark_value?> <?=$this->T('标记')?></div>
  3519. <?php }
  3520. if(!$side && !$strip_tags && $show_link){?><div class='post_menu_button _menu_hook' >+</div><?php } ?>
  3521. <?php if(!$side && $show_link){ $ref_count=100; ?>
  3522. <a href='?post=<?=$post['id']?>' onclick="<?=$show_thread_link||isset($_GET['search'])?'ShowWaitingBar()':'ClickPost(this.parentNode,event,true)'?>">
  3523. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  3524. <?=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:($ref_count?"":"")?>
  3525. </div>
  3526. </a><?php if($ref_count){ ?>
  3527. <label class='lb post_access' for='fake<?=$post["id"]?>'><div class='ref_count'><?=$ref_count?></div></label><?php }
  3528. } ?>
  3529. <?=$side?"<a href='?post={$post['id']}' onclick='ShowWaitingBar()'>":""?>
  3530. <?php if(!$strip_tags){ $this->MakeLinkedPosts($post); } ?>
  3531. <div class='<?=$side?"":'post_width'?><?=$is_deleted?" deleted_post":""?>'>
  3532. <?php if($is_product&&!$generate_anchor){
  3533. echo "<p class='smaller gray'>".$this->T('商品')."</p>";
  3534. echo "<div class='product_ref clean_a'><a href='?post={$post['id']}'>";} ?>
  3535. <?=$this->GenerateSinglePost($post, $strip_tags, $generate_anchor, true,
  3536. $generate_thumb,($show_thread_link||$side||$force_hide_long)); ?>
  3537. <?php if($is_product&&!$generate_anchor){echo "</a></div>";} ?>
  3538. </div>
  3539. <?=$side?"</a>":""?> <?php
  3540. if($show_thread_link && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) &&
  3541. $post['tid']['first']['id']!=$post['id']){ ?>
  3542. <div class='gray smaller block opt_compact post'>
  3543. <a href='?post=<?=$post['tid']['first']['id']?>' onclick='ShowWaitingBar()'>#423
  3544. <div class='post_access invert_a hover_dark smaller'><?=isset($post['tid']['first']['mark_value'])?
  3545. $this->Markers[$post['tid']['first']['mark_value']]:"→"?></div></a>
  3546. <div class='post_width'><div class='smaller'><?=$this->T('回复给主题帖:')?></div>
  3547. <?=$this->GenerateSinglePost($post['tid']['first'], false, false, false, true, true);?>
  3548. </div>
  3549. </div>
  3550. <?php }
  3551. if($show_reply_count && isset($post['tid'])){ ?>
  3552. <a class='smaller block invert_a' href='?post=<?=$post['tid']['last']['id']?>'><?=$post['tid']['count']?>
  3553. <?=$this->T('个回复')?></a>
  3554. <?php } ?>
  3555. </div>
  3556. <?php
  3557. }
  3558. function MakePostingFields($reply_to=NULL, $show_hint=false){
  3559. if(isset($this->WayBack)){ ?>
  3560. <span class='gray'><i><?=$this->T('以过去日期浏览时不能发帖。')?></i></span>
  3561. <?php return; } ?>
  3562. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='post_form'></form>
  3563. <div class='smaller'><div style='display:<?=$show_hint?"block":"none"?>;'>
  3564. <span id='post_hint_text'><?=$this->T('继续补充该话题:')?></span></div>
  3565. <div id='post_hint_modify' style='display:none;'>
  3566. <input type="checkbox" name="post_record_edit" value="1" form='post_form' checked> <?=$this->T('新增历史记录');?></div></div>
  3567. <textarea id="post_content" name="post_content" rows="4" form='post_form'
  3568. onfocus="if (value =='<?=$this->T('有什么想说的')?>'){value ='';}la_auto_grow(this);"
  3569. onblur="if (value ==''){value='<?=$this->T('有什么想说的')?>';la_auto_grow(this);}"
  3570. oninput="la_auto_grow(this);" onload="la_auto_grow(this);"><?=$this->T('有什么想说的')?></textarea>
  3571. <input class='button' form="post_form" type="submit" name='post_button' value=<?=$this->T('发送')?>
  3572. onclick='ShowWaitingBar();' />
  3573. | <a class='gray smaller pointer' onclick='ShowSideUploader();'><?=$this->T('图片')?></a>
  3574. <div style='float:right;'>
  3575. <a class='gray smaller pointer' onclick='t=document.querySelector("#post_content");t.value="";la_auto_grow(t);'>
  3576. <?=$this->T('清空')?></a>
  3577. <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
  3578. </div>
  3579. <input style='display:none;' type=input form="post_form" id='post_edit_target' name='post_edit_target' />
  3580. <script> la_auto_grow(document.getElementById("post_content"));</script>
  3581. <?php if($reply_to){ ?>
  3582. <input style='display:none;' type=input form="post_form" id='post_reply_to' name='post_reply_to' value='<?=$reply_to?>' />
  3583. <?php } ?>
  3584. <?php
  3585. }
  3586. function MakeCommentPosts(){ global $INDEXPHP;
  3587. if(!$this->LoggedIn) return; ?>
  3588. <h2><?=$this->T('评论')?></h2><div class='spacer'></div>
  3589. <?php if(!$this->CommentEnabled){
  3590. echo "<p><span class='text_highlight'>&nbsp;".$this->T("已关闭评论")."&nbsp;</span></p><br />"; } ?>
  3591. <div class='comment'><ul>
  3592. <?php $i=0;
  3593. foreach(array_reverse($this->Posts) as $p){
  3594. if(!isset($p['comment_to'])) continue;
  3595. if($i < $this->CommentsPerPage * $this->CurrentOffset) {$i++; continue;}
  3596. $ht = $this->GenerateSinglePost($p, false, false, false, false, false);
  3597. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3598. $post_to = $this->GetPost($p['comment_to']); $post_title = $this->GetPostTitle($post_to);
  3599. if(!$post_to) $post_title = "?";
  3600. $mail = "<span class='gray hidden_on_print'>&nbsp;".
  3601. "<a href='mailto:".$p['email']."'>@</a>&nbsp;".
  3602. (isset($p['ip'])?$p['ip']:"?")."&nbsp;<br class='hidden_on_desktop'/>".
  3603. "<a href='$INDEXPHP?post=".$p['comment_to']."'>(".$post_title.")</a></span>";
  3604. echo "<li><p><b>".$name.":</b>".$mail."<br /></p>".$ht."</li>";
  3605. $i++;
  3606. }
  3607. ?>
  3608. </ul><br /></div>
  3609. <?php
  3610. }
  3611. function MakeRecentPosts($search_term=NULL, $category=NULL){ global $INDEXPHP; ?>
  3612. <div class='center' id='div_center'><br class='hidden_on_print' />
  3613. <?php if(!isset($search_term) && !isset($category) &&
  3614. (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
  3615. $this->CanShowPost($p)){
  3616. ?><ul class='print_column list bkg_section'><?php
  3617. $this->MakeSinglePost($p, true, false, "active_post", false, true, false, false, false, true, false);
  3618. ?></ul><br /><?php
  3619. }?>
  3620. <h2><?=isset($search_term)?$this->T('搜索'):
  3621. (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
  3622. ($category=='none'?$this->T('未分类'):$this->T($category))):($this->T('最近')).
  3623. " <span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
  3624. ($this->LoggedIn?"<a href='$INDEXPHP?comments=all'>@</a> <a href='$INDEXPHP?statistics=all'>%</a>":"")."</span>")?></h2><br />
  3625. <?php if(isset($search_term)){ ?>
  3626. <form action="<?=$INDEXPHP?>" method="post" style='display:none;' id='search_form'></form>
  3627. <input id="search_content" name="search_content" rows="4" form='search_form' type='text' value='<?=$search_term?>'>
  3628. <input class='button' form="search_form" type="submit" name='search_button' value=<?=$this->T('搜索')?>
  3629. <?php }else if(isset($category)){ ?>
  3630. <div></div>
  3631. <?php }else if($this->LoggedIn){ ?>
  3632. <div class='post_box_top _input_bundle'>
  3633. <?php $this->MakePostingFields(NULL,false); ?>
  3634. </div>
  3635. <?php } ?>
  3636. <ul class='print_column list bkg_recent'>
  3637. <?php
  3638. $i = 0; $last_end_wide = true;
  3639. if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
  3640. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  3641. if(isset($p['tid'])){ /* Should always be set. */
  3642. $th = &$p['tid']; if($p['tid']['count']==0) continue;
  3643. if(!isset($search_term)) { $p = &$th['last']; }
  3644. }
  3645. if(isset($search_term)){
  3646. if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
  3647. }else if(isset($category)){
  3648. $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
  3649. (isset($p['categories'])?($p['categories']):[]);
  3650. if ($category=='none') { if($cat!=[]) continue; }
  3651. else{ if ($category=='' || !in_array($category, $cat)) continue; }
  3652. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3653. }else{
  3654. if(in_array($p['id'],
  3655. [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
  3656. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  3657. }
  3658. if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
  3659. if($last_end_wide){$use_class="last_wide";}else{$use_class="";}
  3660. $this->MakeSinglePost($p, true, false, $use_class, false, !isset($search_term), false, false, false, false, isset($search_term));
  3661. $i++;
  3662. if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
  3663. $last_end_wide = sizeof($p['tid']['arr'])==1 && isset($p['end_wide']) && $p['end_wide'];
  3664. }?>
  3665. </ul>
  3666. <div class='page_selector clean_a'>
  3667. <hr />
  3668. <a <?=$this->CurrentOffset>0?("href='".$INDEXPHP."?offset=".($this->CurrentOffset-1).
  3669. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):""?>
  3670. <?=$this->CurrentOffset==0?"class='gray'":""?>><?=$this->T('上一页')?> ←</a>
  3671. <?=$this->CurrentOffset+1?>
  3672. <a href='<?=$INDEXPHP?>?offset=<?=($this->CurrentOffset+1).
  3673. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))?>'>
  3674. → <?=$this->T('下一页')?></a>
  3675. </div>
  3676. </div>
  3677. <?php
  3678. }
  3679. function MakeLinkedPosts(&$p){
  3680. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); if(!$has_ref)return; $count=0;?>
  3681. <input type='checkbox' class='lpctrl' id='fake<?=$p["id"]?>' checked='checked'>
  3682. <div class='linked_posts smaller'>
  3683. <ul><?php $count_product=0;
  3684. foreach(array_reverse($p['refs']) as &$pr){
  3685. $po = $this->GetPost($pr);
  3686. if(!$this->CanShowPost($po)){ continue; } $count++;
  3687. $this->MakeSinglePost($po, false, true, "post_preview invert_a", true, false, false, false, true, false, false);
  3688. }
  3689. ?></ul>
  3690. </div>
  3691. <?php
  3692. }
  3693. function MakeLinkedPostsExp(&$p){
  3694. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); ?>
  3695. <div class='center_exp post_dummy smaller'>
  3696. <hr />
  3697. <?php if(!$this->InExperimentalMode){ ?>
  3698. <h3<?=$has_ref?"":" class='gray'"?>><?=$this->T('链接')?></h3>
  3699. <?php if($has_ref){ ?>
  3700. <div class='smaller'><?=sizeof($p['refs'])?> <?=$this->T('个引用:')?></div>
  3701. <ul><?php $count_product=0;
  3702. foreach(array_reverse($p['refs']) as &$pr){
  3703. echo "<li class='post_dummy'><a href='?post=".$pr."'>".$this->T($this->GetPostTitle($this->GetPost($pr),false)).
  3704. "</a></li>";
  3705. }
  3706. ?></ul>
  3707. <?php if($count_product){ ?> <span class='smaller'><?=$this->T('和').' '.$count_product.' '.$this->T('个商品')?></span> <?php }
  3708. }else{ ?>
  3709. <div class='gray smaller'><?=$this->T('没有帖子链接到这里。')?></div>
  3710. <?php } }?>
  3711. <div style='margin-bottom:4rem;'>&nbsp;</div>
  3712. </div>
  3713. <?php
  3714. }
  3715. function MakePostHistoryList(&$ah, &$post,$version=NULL, $show_latest=true){
  3716. $latest_ver=isset($post['version'])?$post['version']:$post['id'];
  3717. $can_show=1; if(isset($this->WayBack) && $latest_ver>$this->WayBack) $can_show=0;
  3718. $title = NULL; if(!isset($ah) || ($show_latest && $can_show)) { $title=$this->T($this->GetPostTitle($post, false)); }
  3719. else{ $ver = &$ah['list'][sizeof($ah['list'])-1]; $title= $this->GetPostTitle($ver); }
  3720. if(!isset($title)) $title=$this->T('未命名');
  3721. if(!isset($ah)){ ?>
  3722. <h2><?=$this->T('没有历史记录')?></h2>
  3723. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$post['id']?>'><?=$title?></a></span><br />
  3724. <?php }else{ ?>
  3725. <h2><?=$this->T('历史记录')?></h2>
  3726. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$ah['id']?>'><?=$title?></a></span><br />
  3727. <div class='list'><ul>
  3728. <?php if($show_latest && $can_show){ $post['history_displayed']=1; ?>
  3729. <li class='<?=isset($version)&&$version==$latest_ver?" post_current_row bold":""?>' style='list-style:"";'>
  3730. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$latest_ver?>'><?=$this->ReadableTime($latest_ver)?></a>
  3731. <span class='smaller gray'><?=$this->T('长度').' '.strlen($post['content'])?></span>
  3732. <?php if(isset($post['merged_from'][0])){ ?><ul><?php foreach($post['merged_from'] as $from){
  3733. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3734. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3735. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3736. <?=$this->GetPostTitle($ver);?></a>
  3737. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3738. <?php } ?></ul><?php } ?>
  3739. <?php if(isset($post['merged_thread'][0][0])){ $pm=$post['merged_thread'][0][0];
  3740. $mah = &$this->GetArchiveHandle($pm);
  3741. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3742. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  3743. <span class='smaller gray'><?=sizeof($post['merged_thread'][0]);?> <?=$this->T('个帖子')?></span></li></ul>
  3744. <?php } ?>
  3745. </li><?php } ?>
  3746. <?php if(isset($ah['list'][0])) foreach(array_reverse($ah['list']) as &$ver){
  3747. if(isset($this->WayBack) && $ver['version']>$this->WayBack) continue;
  3748. if(isset($ver['history_displayed']) && $ver['history_displayed']) continue; ?>
  3749. <li<?=isset($version)&&$version==$ver['version']?" class='post_current_row bold'":""?>>
  3750. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$ver['version']?>'><?=$this->ReadableTime($ver['version'])?></a>
  3751. <span class='smaller gray'> <?=$this->T('长度').' '.strlen($ver['content'])?></span>
  3752. <?php if(isset($ver['merged_thread'][0][0])){ $pm=$ver['merged_thread'][0][0];
  3753. $mah = &$this->GetArchiveHandle($pm); $mver = &$this->GetPost($pm);
  3754. if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3755. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  3756. <span class='smaller gray'> <?=sizeof($ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></li></ul>
  3757. <?php } if(isset($ver['merged_from'][0])){ ?><ul><?php foreach($ver['merged_from'] as $from){
  3758. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  3759. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  3760. <li><a href='?post=<?=$ver['id']?>&history=1'>
  3761. <?=$this->GetPostTitle($ver);?></a>
  3762. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  3763. <?php } ?></ul></li><?php } ?>
  3764. <?php } ?></ul></div>
  3765. <?php } ?>
  3766. <?php
  3767. }
  3768. function MakePostDiff(&$this_ver, &$last_ver){
  3769. if(!isset($this_ver)){ ?>
  3770. <h2 class='gray'><?=$this->T('版本不存在')?></h2>
  3771. <?php }else{ ?>
  3772. <h2><?=$this->T('差异')?></h2>
  3773. <?php if(isset($this_ver['merged_thread']) && isset($this_ver['merged_thread'][0][0])){
  3774. $pm=$this_ver['merged_thread'][0][0]; $mah = &$this->GetArchiveHandle($pm);
  3775. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  3776. <p><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver)?></a> <?=$this->T('并入这里')?>
  3777. <br /><span class='smaller gray'> <?=sizeof($this_ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></p>
  3778. <?php }else{ ?>
  3779. <table class='diff_table'><thead>
  3780. <tr><td><?php if(!isset($last_ver)){ ?><?=$this->T('没有更旧的版本')?><?php }else{ ?>
  3781. <?=$this->T('上一个版本')?><br /><?=$this->ReadableTime($last_ver['version'])?><?php } ?></td>
  3782. <td class='text_highlight bold'><?=$this->T('选择的版本')?><br /><?=$this->ReadableTime($this_ver['version'])?></td></tr>
  3783. </thead><tbody>
  3784. <tr><td><pre><?=isset($last_ver)?$last_ver['content']:""?></pre></td><td><pre><?=$this_ver['content']?></pre></td></tr>
  3785. </tbody>
  3786. </table>
  3787. <?php } ?>
  3788. <br /><a class='smaller' href='?post=<?=$this_ver['id']?>&set_wayback=<?=isset($this_ver['version'])?$this_ver['version']:$this_ver['id']?>'><?=$this->T('前往该版本时间')?> ←</a>
  3789. <?php } ?>
  3790. <?php
  3791. }
  3792. function MakePostHistory(&$post, $version=NULL){
  3793. $ah = &$this->GetArchiveHandle($this->CurrentPostID);
  3794. $p = &$post; if(!isset($post)){ $p=&$ah['list'][0]; }
  3795. $show_latest = isset($ah)?(!isset($ah['list'][sizeof($ah['list'])-1]['merged_into'])):true;
  3796. ?>
  3797. <div class='left mobile_fold history' id='div_left'>
  3798. <?php if (isset($version)){
  3799. $this->MakePostHistoryList($ah, $p, $version, $show_latest);
  3800. }else{ echo "&nbsp;"; } ?>
  3801. </div>
  3802. <div class='center history' id='div_center'>
  3803. <?php if (!isset($version)){
  3804. $this->MakePostHistoryList($ah, $p, NULL, $show_latest);
  3805. }else{
  3806. $this_ver = NULL; $next_ver = NULL; $last_ver=NULL;
  3807. $this_ver = &$this->GetArchiveVersion($ah, $version, $next_ver, $last_ver);
  3808. if(!isset($this_ver)){$this_ver = $p; $last_ver=$ah['list'][sizeof($ah['list'])-1];}
  3809. $this->MakePostDiff($this_ver, $last_ver, $p);
  3810. } ?>
  3811. </div>
  3812. <?php
  3813. }
  3814. function MakeCommentSection(&$post){ global $INDEXPHP;
  3815. if(!$this->CommentEnabled){ return; }
  3816. $to_post = isset($post['tid'])?$post['tid']['first']:$post;
  3817. $comment_count = (isset($to_post['comments']) && isset($to_post['comments'][0]))?count($to_post['comments']):0;
  3818. ?><div class='comment'>
  3819. <br /><h2><?=$this->T('评论')?> (<?=$comment_count;?>)</h2><div class='spacer'></div>
  3820. <?php if($comment_count) { echo "<ul>";
  3821. foreach($to_post['comments'] as $p){
  3822. $ht = $this->GenerateSinglePost($p, false, false, false, false, false);
  3823. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  3824. $mail = $this->LoggedIn?("<span class='gray clean_a hidden_on_print'>&nbsp;".
  3825. "<a href='mailto:".$p['email']."'>@</a>&nbsp;</span>"):"";
  3826. echo "<li><p><b>".$name.":</b>".$mail."</p>".$ht."</li>";
  3827. }
  3828. echo "</ul>";
  3829. } else {
  3830. echo $this->T('还没有评论');
  3831. } ?>
  3832. <div class='hidden_on_print'>
  3833. <div class='spacer'></div>
  3834. <form action="<?=$INDEXPHP?>?post=<?=$this->CurrentPostID?>&comment_to=<?=$to_post['id']?>"
  3835. method="post" style="display:none;" id="comment_form"></form>
  3836. <p><a class='text_highlight bold clean_a'
  3837. onclick='document.getElementById("comment_box").style.display="block";this.parentNode.style.display="none"'>
  3838. &nbsp;<?=$this->T('写评论');?>&nbsp;</a></p>
  3839. <div id='comment_box' style='display:none;'>
  3840. <p class='gray' style='margin-bottom:0.5em;'><?=$this->T('您的邮箱不会公开展示。');?></p>
  3841. <table style='white-space:nowrap;'>
  3842. <tr><td colspan='2'>
  3843. <textarea id="comment_box" name="comment_box" rows="4" class='full_box' form='comment_form'
  3844. oninput="CommentUpdated();" ></textarea>
  3845. </td></tr>
  3846. <tr><td><?=$this->T('电子邮件')?>*</td><td><?=$this->T('称呼')?>*</td></tr>
  3847. <tr><td><input type="text" form="comment_form" id='comment_email' name='comment_email'
  3848. class='full_box' oninput="CommentUpdated();" /></td>
  3849. <td><input type="text" form="comment_form" id='comment_name' name='comment_name'
  3850. class='full_box' oninput="CommentUpdated();" /></td></tr>
  3851. <tr><td colspan='2'><?=$this->T('个人网站')?></td></tr>
  3852. <tr><td colspan='2'>
  3853. <input type="text" form="comment_form" id='comment_link' name='comment_link'
  3854. class='full_box' oninput="CommentUpdated();" />
  3855. </td></tr>
  3856. <tr><td colspan='2'>
  3857. <div class='spacer'></div>
  3858. <input class='button text_highlight bigger' type='submit' form='comment_form'
  3859. name='comment_confirm' id='comment_confirm' value='&nbsp;<?=$this->T('发送')?>&nbsp;'>
  3860. </td></tr>
  3861. </table></div>
  3862. <script>
  3863. const IsValidEmail = (email) => {
  3864. 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,}))$/);
  3865. };
  3866. function IsValidHttpUrl(string) {
  3867. let url; try{ url = new URL(string); } catch (_) { return false; }
  3868. return url.protocol === "http:" || url.protocol === "https:";
  3869. }
  3870. var cbox = document.getElementById('comment_box');
  3871. var cemail = document.getElementById('comment_email');
  3872. var cname = document.getElementById('comment_name');
  3873. var clink = document.getElementById('comment_link');
  3874. var cconfirm = document.getElementById('comment_confirm');
  3875. function CommentUpdated(){
  3876. cconfirm.disabled=true;
  3877. if (cemail.value!="" && IsValidEmail(cemail.value) &&
  3878. cbox.innerText.length>2 && cname.value.length>2 &&
  3879. clink.value=="" || IsValidHttpUrl(clink.value)){
  3880. cconfirm.removeAttribute("disabled");
  3881. }
  3882. }
  3883. CommentUpdated();
  3884. </script>
  3885. </div>
  3886. </div>
  3887. <?php
  3888. }
  3889. function MakeInterestingSection(&$th){
  3890. $this->Anchors = [];
  3891. $c = &$th['first']['content'];
  3892. $this->ConvertPost($th['first']);
  3893. $ht = $th['first']['html'];
  3894. ?>
  3895. <script>function ClickImage(post_access){im=post_access.querySelector('img');if(im){im.click();}}</script>
  3896. <div class='center_full' id='div_center'>
  3897. <?php $this->MakePostTools(); ?>
  3898. <?php $cat = NULL;
  3899. if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; }
  3900. if($cat){ ?>
  3901. <p><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  3902. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  3903. <?php } ?>
  3904. <h2 class='hidden_on_print'><?=$this->T('有趣')?>
  3905. <a class='gray clean_a' href='?post=<?=$th['first']['id']?>'>→</a></h2>
  3906. <ul><li class='post' data-post-id='<?=$th['first']['id']?>'>
  3907. <div class='post_menu_button _menu_hook' onclick='ShowPostMenu(this.parentNode);'>+</div><?=$ht?>
  3908. <?php if(isset($th['first']['refs'][0])){ ?><p class='smaller'><?=$this->T('引用')?>: </p><ul class='smaller'>
  3909. <?php foreach($th['first']['refs'] as $ref){
  3910. $po = $this->GetPost($ref);
  3911. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  3912. if(!$this->CanShowPost($po)){ continue; }
  3913. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  3914. } ?>
  3915. </ul><?php } ?>
  3916. <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  3917. <div class='hidden_on_print'><br />
  3918. <?php $this->MakePostingFields($th['last']['id'], true);?><br />
  3919. </div>
  3920. <?php } ?>
  3921. <table><thead><tr><?php foreach($th['interesting'] as $header){ ?>
  3922. <td><?=$this->T($header);?></td>
  3923. <?php } ?><td></td></tr></thead><tbody class='interesting_tbody'>
  3924. <?php $plist = array_reverse(array_slice($th['arr'],1));
  3925. foreach($plist as &$p){
  3926. $this->ConvertPost($p);
  3927. $mark_value = isset($p['mark_value'])?$this->Markers[$p['mark_value']]:-1;
  3928. $ref_count = isset($p['refs'])?sizeof($p['refs']):0;
  3929. $is_current = $p['id']==$this->CurrentPostID;
  3930. $is_deleted = (isset($p['mark_delete'])&&$p['mark_delete']); ?>
  3931. <tr class='<?=$is_current?"post_current_row":""?><?=$is_deleted?" deleted_post":""?>'
  3932. data-post-id='<?=$p['id']?>' <?=$is_deleted?"data-mark-delete='true'":""?>
  3933. onDblClick='ClickImage(this)'><td>
  3934. <?php if($ref_count){ ?>
  3935. <div class='post_access ref_count'><?=$ref_count?></div>
  3936. <?php } ?></a>
  3937. <?=$p['html'];?>
  3938. <a class='_menu_hook clean_a post_menu_button' onclick='ShowPostMenu(this.parentNode.parentNode);'>+</a>
  3939. <a <?=$is_current?"":("href='?post=".$p['id']."' onclick='ShowWaitingBar()'");?> class='clean_a paa'>
  3940. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  3941. <?=isset($p['mark_value'])?$this->Markers[$p['mark_value']]:($ref_count?"":"→")?>
  3942. </div></td></tr>
  3943. <?php if($is_current && $ref_count>0){ ?><tr class='post_current_row'><td><p>&nbsp;</p><ul class='smaller'>
  3944. <?php foreach($p['refs'] as $ref){
  3945. $po = $this->GetPost($ref);
  3946. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  3947. if(!$this->CanShowPost($po)){ continue; }
  3948. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</a></li>";
  3949. } ?>
  3950. </ul></td></tr><?php } ?>
  3951. <?php } ?>
  3952. </tbody></table>
  3953. </li></ul>
  3954. <br />
  3955. <?php $this->MakeCommentSection($th['first']); ?>
  3956. </div>
  3957. <?php return true;
  3958. }
  3959. function CssNumberID($id){
  3960. return "#\\3".substr($id,0,1)." ".substr($id,1);
  3961. }
  3962. function MakePostTools(){
  3963. if($this->LoggedIn && !isset($this->WayBack)){ $STR=<<<EOT
  3964. <div class='smaller gray hidden_on_print clean_a'>
  3965. <a id='merge_cancel' href='javascript:{TogglePostSelectMode(false,true);ToggleThreadMerge(false,true);}'>
  3966. {$this->T('工具')}</a>:<div class='hidden_m' style='display:inline'>
  3967. <span id='merge_post_btn'><a href='javascript:TogglePostSelectMode()'>{$this->T('合并帖子')}</a></span>
  3968. | <span id='merge_thread_btn'><a href='javascript:ToggleThreadMerge()'>{$this->T('合并话题')}</a></span>
  3969. </div>
  3970. <select class='hidden_on_desktop' id='merge_select'
  3971. onchange="if(this.selectedIndex==1){TogglePostSelectMode(true);}else if(this.selectedIndex==2){ToggleThreadMerge(true);}">
  3972. <option value='-1' selected>--</option>
  3973. <option value='1'>{$this->T('合并帖子')}</option>
  3974. <option value='2'>{$this->T('合并话题')}</option></select>
  3975. <div style='display:none;' id='merge_post_dialog' class='text_highlight small_pad align_right'>
  3976. <div style='display:inline;'>{$this->T('将合并')} <span id='merge_post_count'></span> {$this->T('个帖子')}</div>
  3977. <span class='clean_a bold align_right'><a id='merge_post'>&nbsp;{$this->T('执行')}</a></span></div>
  3978. <div style='display:none;overflow:auto' id='merge_thread_dialog' class='text_highlight small_pad align_right'>
  3979. <div style='display:inline;'>{$this->T('合并到话题')}</div>
  3980. <input id="merge_thread_target" type="text" style="width:9em;display:inline" onChange='ThreadMergeInput(this);' onInput='ThreadMergeInput(this);'>
  3981. <span class='clean_a bold align_right'><a id='merge_thread'>&nbsp;{$this->T('执行')}</a></span></div>
  3982. </div><div class='spacer hidden_on_print'></div>
  3983. EOT;
  3984. }
  3985. $this->TFill(2,$STR); $this->TRow();
  3986. }
  3987. function MakeSidebar(){ ?>
  3988. <div class='left mobile_fold'><?php if(isset($this->SpecialSidebar) && ($p = &$this->GetPost($this->SpecialSidebar))!=NULL){
  3989. ?><span class='gray smaller'><br /></span><?php
  3990. echo $this->GenerateSinglePost($p, false, false, false, false); }?>
  3991. <div class='wayback_link clean_a smaller'><span class='gray'><br /><?=$this->T('工具')?></span><ul>
  3992. <li><a href='?search=' onclick='ShowWaitingBar()' class='bigger'><?=$this->T('搜索')?></a></li>
  3993. <li><?php if(!isset($this->WayBack)){ ?>
  3994. <a href='<?=$this->GetRedirect()?>&set_wayback=true'><?=$this->T('以过去的日期浏览')?></a>
  3995. <?php }else{ ?><a href='<?=$this->GetRedirect()?>&set_wayback=false'><?=$this->T('回到当前日期')?></a><?php } ?></li>
  3996. <li><a href='<?=$this->GetRedirect()?>&toggle_font=true'>
  3997. <?=$this->T('切换字体')?>: <?=$this->T($this->UseRemoteFont?"远程":"本地");?></a></li>
  3998. <li><a rel="alternate" type="application/rss+xml" href="?rss=<?=$this->LanguageAppendix;?>" />RSS/Atom<sup><?=$this->LanguageAppendix;?></sup></a></li>
  3999. </ul>
  4000. </div>
  4001. <br />
  4002. <hr class="hidden_on_desktop" />
  4003. </div>
  4004. <?php }
  4005. function MakePostSection(&$post){ $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1;
  4006. $this->Anchors = []; if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))) $centerclass='center_slides'; else $centerclass='center';
  4007. if(isset($this->TagID)){ ?><style><?=$this->CssNumberID($this->TagID);?>{display:block;}</style><?php } ?>
  4008. <div class='<?=$centerclass;?>' id='div_center'><br class='hidden_on_print' />
  4009. <h2 class='hidden_on_print'>
  4010. <?php $th=NULL;
  4011. $is_wide = (isset($post['wide'])&&$post['wide']) || ($is_thread && isset($post['tid']['wide']) && $post['tid']['wide']);
  4012. if($is_thread){ $th = $post['tid'];?> <?=$this->T('话题')?> <?php }else{ ?> <?=$this->T('详细')?>
  4013. <?php } ?></h2>
  4014. <?php $cat = NULL;
  4015. if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
  4016. else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
  4017. $this->MakePostTools();
  4018. if($cat){ ?>
  4019. <p class='hidden_on_print'><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  4020. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  4021. <?php } ?><br class='hidden_on_print' />
  4022. <ul class='print_column bkg_section'>
  4023. <?php $is_reversed=false;
  4024. if($is_thread){
  4025. $use_arr = $th['arr']; $hinted=false;
  4026. $last_end_wide = true; $is_reversed=$this->IsReversedThread($th);
  4027. foreach($use_arr as &$p){$use_class="";if($p==$post){$use_class.=" active_post";}
  4028. if($last_end_wide){$use_class.=" last_wide";}
  4029. $make_title = ($p == $post);
  4030. if(isset($p['restart'])){ ?>
  4031. <li class='restart'><h3><?=$p['restart']?></h3></li><?php }
  4032. $this->MakeSinglePost($p,true,false,$use_class,false, false, false, true, false, false);
  4033. if($make_title){?>
  4034. <script>
  4035. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  4036. </script>
  4037. <?php } if($is_reversed && !$hinted){ ?><?php $hinted = true;
  4038. if($this->LoggedIn && (!$this->InHereMode)){ ?>
  4039. <div class='hidden_on_print'>
  4040. <?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?></div><br />
  4041. <?php } }
  4042. $last_end_wide = isset($p['end_wide']) && $p['end_wide'];
  4043. }
  4044. }else{
  4045. $this->MakeSinglePost($post,true, false,"active_post",false, false, false, true, false, false);
  4046. ?><script>
  4047. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($post),0,100)))?>";
  4048. </script><?php
  4049. } $class_add=""; if(isset($post['tid']['first']['no_time'])){ $class_add=' hidden_on_print'; } ?>
  4050. </ul>
  4051. <div class='smaller align_right<?=$class_add;?>'>
  4052. <span class='gray'><?=$this->ReadableTime($post['tid']['first']['id']);?></span>
  4053. <br class='hidden_on_desktop' /><?=$this->ReadableTime(isset($post['tid']['last']['version'])?
  4054. $post['tid']['last']['version']:$post['tid']['last']['id']);?>
  4055. </div>
  4056. <?php if(!$is_reversed && ($this->LoggedIn && (!$this->InHereMode))){ ?>
  4057. <div class='hidden_on_print'>
  4058. <br /><?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?>
  4059. </div>
  4060. <?php }
  4061. $this->MakeCommentSection($post);
  4062. ?>
  4063. </div>
  4064. <?php if(isset($post['slides']) || ($is_thread&&isset($post['tid']['slides']))){ ?>
  4065. <div class='slides_buttons code' onclick="event.stopPropagation();">
  4066. <a onclick="SlidesFontCheck(-1)">T-</a> <a onclick="SlidesFontCheck(1)">T+</a>&nbsp;
  4067. <a onclick="SlidesStart(null)"><<</a> <a onclick="SlidesCheck(-1);"><</a>
  4068. <a onclick="SlidesStart(1)"><span id="slides_now">1</span>/<span id="slides_total">1</span></a>
  4069. <a onclick="SlidesCheck(1);">></a> <a onclick="SlidesEnd();">X</a>
  4070. </div>
  4071. <script>
  4072. function SlidesStart(from_here){
  4073. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  4074. sdone=0; fp=0; if(from_here){
  4075. urlParams = new URLSearchParams(window.location.search);
  4076. fp = urlParams.get('post');
  4077. }
  4078. document.querySelector("#slides_total").innerText=slides.length; cur=document.querySelector("#slides_now");
  4079. for(i=0;i<slides.length;i++){ slides[i].style.display="none";
  4080. if(from_here && slides[i].dataset.postId==fp){ slides[i].style.display="table-cell";sdone=1; ClickPost(slides[i],0,true); cur.innerText=i+1; }
  4081. } if(!sdone){ slides[0].style.display="table-cell"; ClickPost(slides[0],0,true); cur.innerText=1; }
  4082. c=document.querySelector('.center'); if(!c) return;
  4083. c.classList.remove('center'); c.classList.add('center_slides'); if(c.dataset.fontSize){ c.style.fontSize=c.dataset.fontSize; }
  4084. c=document.querySelector('.left'); if(!c) return; c.style.display="none";
  4085. }
  4086. function SlidesCheck(offset){
  4087. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return; cur=document.querySelector("#slides_now");
  4088. for(i=0;i<slides.length;i++){ if(slides[i].style.display=="table-cell" && slides[i+offset] && (i+offset)>=0){
  4089. slides[i+offset].style.display="table-cell"; slides[i].style.display="none"; ClickPost(slides[i+offset],0,true); cur.innerText=i+offset+1; break;
  4090. }
  4091. }
  4092. }
  4093. function SlidesFontCheck(offset){
  4094. c=document.querySelector('.center_slides'); if(!c) return;
  4095. f=5; if(c.style.fontSize){ f=parseInt(c.style.fontSize); }
  4096. f+=offset; if(f<=0) f=1; if(f>12) f=12; c.style.fontSize=""+f+"vmin"; c.dataset.fontSize=c.style.fontSize;
  4097. }
  4098. function SlidesEnd(){
  4099. c=document.querySelector('.center_slides'); if(!c) return;
  4100. c.classList.remove('center_slides'); c.classList.add('center'); c.style.fontSize="";
  4101. c=document.querySelector('.left'); if(!c) return; c.style.display="inline-block";
  4102. slides=document.querySelectorAll('.print_column > .post'); if(!slides || !slides[0]) return;
  4103. for(i=0;i<slides.length;i++){ slides[i].style.display=""; }
  4104. }
  4105. //document.addEventListener("wheel", function(event){ if(event.deltaY>0) SlidesCheck(1); else SlidesCheck(-1); }, { passive: false });
  4106. document.addEventListener("click", function(event){ SlidesCheck(1); });
  4107. document.addEventListener('keydown', function(event) {
  4108. const key = event.key; // "ArrowRight", "ArrowLeft", "ArrowUp", or "ArrowDown"
  4109. switch(key){
  4110. case "ArrowUp": case "ArrowLeft": SlidesCheck(-1); break; case "ArrowDown": case "ArrowRight": SlidesCheck(1); break;
  4111. case "Escape": SlidesEnd(); break;
  4112. }
  4113. });
  4114. </script>
  4115. <?php }
  4116. }
  4117. function MakePostSectionExp(&$post){
  4118. $this->Anchors = []; $is_thread = isset($post['tid']);
  4119. ?>
  4120. <div class='center_exp' id='div_center'><br class='hidden_on_print' />
  4121. <ul>
  4122. <?php $is_reversed=false;
  4123. if($is_thread){ $th = &$post['tid'];$use_arr = $th['arr']; $is_reversed=$this->IsReversedThread($th); $hinted=false;
  4124. foreach($use_arr as &$p){
  4125. $this->MakeSinglePostExp($p);
  4126. if($p == $th['first']){?>
  4127. <script>
  4128. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  4129. </script>
  4130. <?php } if($is_reversed && !$hinted){ ?>
  4131. <li class='gray smaller bold' style='text-align:center;'>
  4132. <p>&nbsp;</p><hr><?=$this->T('该话题最新帖子在前')?><hr><p>&nbsp;</p></li>
  4133. <?php $hinted = true; }
  4134. }
  4135. }else{
  4136. $this->MakeSinglePostExp($post);
  4137. ?><!--<script>
  4138. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr($this->GetPostTitle($p),0,100)))?>";
  4139. </script>--><?php
  4140. } ?>
  4141. </ul>
  4142. </div>
  4143. <?php
  4144. }
  4145. function MakeHereSection(&$im){ $image_okay = (isset($im) && $im!=$this->NULL_IMAGE); ?>
  4146. <div class='here_image_box clean_a'>
  4147. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'>
  4148. <?=$image_okay?$this->T('请稍候'):$this->T('未找到图像')?></div>
  4149. <?php if($image_okay){ ?>
  4150. <?php if(isset($im['video']) && isset($im['video'])!=""){ ?>
  4151. <video controls><source src='<?=$im['file'];?>' type='<?=$im['video']?>'></video>
  4152. <?php }else{ ?>
  4153. <img id='big_image' onload="HideWaitingBar();" src="<?=$im['file'];?>" />
  4154. <?php } ?>
  4155. <?php } $this->MakeHereButtons($im, false); ?>
  4156. </div>
  4157. <?php }
  4158. function MakeSideGalleryCode(){?>
  4159. <div>
  4160. <h3><?=$this->T('点击图片以插入:')?></h3>
  4161. <select id="side_gallery_select" onchange="RefreshSideGallery()">
  4162. <option value="main"><?=$this->T('全部')?></option>
  4163. <?php if($this->LoggedIn){ ?>
  4164. <option value="trash"><?=$this->T('垃圾桶')?></option>
  4165. <?php }?>
  4166. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  4167. <option value="<?=$g['name']?>"><?=$g['name']?></option>
  4168. <?php } ?>
  4169. </select>
  4170. <div id='side_gallery'>
  4171. </div>
  4172. </div>
  4173. <script>
  4174. function InsertImage(imgname){
  4175. t = document.querySelector("#post_content");
  4176. v = t.value;
  4177. t.value = v.slice(0, t.selectionStart) + "![<?=$this->T('图片')?>](images/"+imgname+")"+ v.slice(t.selectionEnd);
  4178. la_auto_grow(t);
  4179. }
  4180. function RefreshSideGallery(){
  4181. let xhr = new XMLHttpRequest();
  4182. xhr.onreadystatechange = (function(){
  4183. if (this.readyState === this.DONE) {
  4184. if (this.status === 200) {
  4185. ind = document.querySelector("#side_gallery");
  4186. if(res = xhr.responseText.matchAll(/\[(.*?),(.*?)\]/gu)){
  4187. str = "<ul class='side_thumb'>"
  4188. for (const m of res) {
  4189. imgstr = "<img src='"+m[2]+"' />";
  4190. if(m[2].match('\.mp4')){
  4191. imgstr = "<video><source src='"+m[2]+"'></video>";
  4192. }
  4193. str+="<li><div class='file_thumb' onclick='InsertImage(\""+m[1]+"\")'>"+imgstr+"</div>"
  4194. }
  4195. str += "</ul>"
  4196. ind.innerHTML = str;
  4197. }
  4198. }
  4199. }
  4200. });
  4201. xhr.open("GET", "?image_list="+document.querySelector("#side_gallery_select").value, true);
  4202. xhr.send();
  4203. }
  4204. </script>
  4205. <?php
  4206. }
  4207. function MakeUploader($is_side=false){ ?>
  4208. <div id='upload_operation_area' class='hidden_on_print'>
  4209. <p><?=$this->T('选择、粘贴或者拖动到页面以上传图片。')?></p>
  4210. <input type="file" id='upload_selector' accept="image/x-png,image/png,image/gif,image/jpeg" multiple/>
  4211. <ul id='file_list'>
  4212. </ul>
  4213. <div class='smaller gray' id='upload_hint'><?=$this->T('就绪')?></div>
  4214. </div>
  4215. <a id='upload_click' class='hidden_on_print pointer' onclick='this.removeAttribute("onclick");UploadList();'
  4216. <?=$is_side?" data-is-side='true'":""?>><?=$this->T('上传列表中的文件')?></a>
  4217. <script>
  4218. function pastehandler(event){
  4219. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  4220. for (index in items) {
  4221. var item = items[index];
  4222. if (item.kind === 'file') {
  4223. put = document.querySelector("#_uploader");
  4224. if(put) ShowSideUploader();
  4225. var blob = item.getAsFile();
  4226. AddImageFile(blob);
  4227. return;
  4228. }
  4229. }
  4230. }
  4231. let _fd_list = []; var uploading=0;
  4232. let hint=document.querySelector('#upload_hint');
  4233. function ToggleCompress(button){
  4234. li = button.parentNode;
  4235. num=li.dataset.number;
  4236. for(i=0;i<_fd_list.length;i++){
  4237. if (_fd_list[i][0] == num){
  4238. state = _fd_list[i][2];
  4239. if(state){_fd_list[i][2] = 0; button.innerHTML='1920';break;}
  4240. else{_fd_list[i][2] = 1; button.innerHTML='800';break;}
  4241. }
  4242. }
  4243. }
  4244. function RemoveFromUpload(button){
  4245. li = button.parentNode;
  4246. num=li.dataset.number;
  4247. for(i=0;i<_fd_list.length;i++){
  4248. if (_fd_list[i][0] == num){
  4249. _fd_list.splice(i, 1);break;
  4250. }
  4251. }
  4252. li.parentNode.removeChild(li);
  4253. }
  4254. function EndThisUpload(){
  4255. unfinished = 0;
  4256. for(i=0;i<_fd_list.length;i++){
  4257. if (_fd_list[i][3]==0){
  4258. unfinished=1;
  4259. }
  4260. }
  4261. if(!unfinished){
  4262. uploading=0;
  4263. hint.innerHTML="<?=$this->T('上传完成。')?>";
  4264. cl=document.querySelector('#upload_click');
  4265. if(!cl.dataset.isSide){
  4266. cl.innerHTML="<?=$this->T('刷新页面')?>";
  4267. cl.href=window.location.href;
  4268. }else{
  4269. _fd_list.splice(0,_fd_list.length);
  4270. fl = document.querySelector("#file_list");
  4271. fl.innerHTML = "";
  4272. list=document.querySelector('#upload_operation_area');
  4273. list.style.pointerEvents='';
  4274. list.style.opacity='';
  4275. cl.onclick=function(){this.removeAttribute("onclick");UploadList();};
  4276. document.onpaste=pastehandler;
  4277. RefreshSideGallery();
  4278. }
  4279. }
  4280. }
  4281. function UploadList(){
  4282. if(!_fd_list.length || uploading) return;
  4283. uploading=1;
  4284. hint.innerHTML="<?=$this->T('正在上传...')?>";
  4285. list=document.querySelector('#upload_operation_area');
  4286. list.style.pointerEvents='none';
  4287. list.style.opacity='0.5';
  4288. document.onpaste="";
  4289. for(i=0;i<_fd_list.length;i++){
  4290. let xhr = new XMLHttpRequest();
  4291. var li = list.querySelector('[data-number="'+_fd_list[i][0].toString()+'"]')
  4292. xhr.open("POST", "?compress="+_fd_list[i][2].toString(), true);
  4293. function wrap(li, i){
  4294. var ind = li.querySelector('._compress_toggle')
  4295. return function(){
  4296. if (this.readyState === this.DONE) {
  4297. if (this.status === 200) {
  4298. var response = xhr.responseText;
  4299. if(res = response.match(/<uploaded>(.*)<\/uploaded>/)){
  4300. ind.innerHTML = "<?=$this->T('已上传为')?> "+res[1];
  4301. _fd_list[i][3] = 1;
  4302. }else{
  4303. ind.innerHTML = "<?=$this->T('出现错误。')?>";
  4304. _fd_list[i][3] = 1;
  4305. }
  4306. EndThisUpload();
  4307. }
  4308. }
  4309. }
  4310. }
  4311. xhr.onreadystatechange = wrap(li, i);
  4312. xhr.send(_fd_list[i][1]);
  4313. }
  4314. }
  4315. function AddImageFile(blob){
  4316. var ext="";
  4317. if(blob.name.match(/png$/i))ext = 'png';
  4318. else if(blob.name.match(/jpg$/i))ext = 'jpg';
  4319. else if(blob.name.match(/jpeg$/i))ext = 'jpeg';
  4320. else if(blob.name.match(/gif$/i))ext = 'gif';
  4321. else if(blob.name.match(/mp4$/i))ext = 'mp4';
  4322. else return;
  4323. var fd = new FormData();
  4324. blob.name = blob.name=generateUID().toString();
  4325. fd.append("upload_file_name", blob, "_upload_"+blob.name+"."+ext);
  4326. _fd_list.push([blob.name, fd, 1, 0]);/* number original is_compress uploaded */
  4327. var reader = new FileReader();
  4328. reader.onload = function(event){
  4329. fl = document.querySelector("#file_list");
  4330. ht = "<li id='_upload_"+blob.name+"' data-number='"+blob.name+"'>"+
  4331. "<a class='_remove_file pointer invert_a' onclick='RemoveFromUpload(this)'>×</a> "+"<div class='file_thumb'>"+
  4332. "<img class='no_pop' src='"+event.target.result+"'>"+"</div>"+
  4333. " →<a class='_compress_toggle pointer' onclick='ToggleCompress(this)'>800</a></li>";
  4334. fl.innerHTML+=ht;
  4335. };
  4336. reader.readAsDataURL(blob);
  4337. }
  4338. sel = document.querySelector('#upload_selector');
  4339. sel.addEventListener("change", function(){
  4340. var input = this;
  4341. function ff(file){
  4342. return function(e){
  4343. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  4344. blob.name = file.name;
  4345. AddImageFile(blob);
  4346. }
  4347. }
  4348. for(i=0;i<input.files.length;i++){
  4349. if(input.files[i].size){
  4350. let reader = new FileReader();
  4351. reader.onload = ff(input.files[i]);
  4352. reader.readAsArrayBuffer(input.files[i]);
  4353. }
  4354. }
  4355. });
  4356. function generateUID() {
  4357. var firstPart = (Math.random() * 46656) | 0;
  4358. var secondPart = (Math.random() * 46656) | 0;
  4359. firstPart = ("000" + firstPart.toString(36)).slice(-3);
  4360. secondPart = ("000" + secondPart.toString(36)).slice(-3);
  4361. return firstPart + secondPart;
  4362. }
  4363. document.onpaste = pastehandler;
  4364. function dropHandler(ev) {
  4365. put = document.querySelector("#_uploader");
  4366. if(put) ShowSideUploader();
  4367. bkg=document.querySelector('#dropping_background');
  4368. bkg.style.display="none";
  4369. console.log('File(s) dropped');
  4370. ev.preventDefault();ev.stopPropagation();
  4371. if (ev.dataTransfer && ev.dataTransfer.items) {
  4372. for (var i = 0; i < ev.dataTransfer.items.length; i++) {
  4373. if (ev.dataTransfer.items[i].kind === 'file') {
  4374. var file = ev.dataTransfer.items[i].getAsFile();
  4375. function ff(file){
  4376. return function(e){
  4377. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  4378. blob.name = file.name;
  4379. AddImageFile(blob);
  4380. }
  4381. }
  4382. if(file){
  4383. let reader = new FileReader();
  4384. reader.onload = ff(file);
  4385. reader.readAsArrayBuffer(file);
  4386. }
  4387. }
  4388. }
  4389. } else {
  4390. for (var i = 0; i < ev.dataTransfer.files.length; i++) {
  4391. function ff(file){
  4392. return function(e){
  4393. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  4394. blob.name = file.name;
  4395. AddImageFile(blob);
  4396. }
  4397. }
  4398. if(ev.dataTransfer.files[i].size){
  4399. let reader = new FileReader();
  4400. reader.onload = ff(ev.dataTransfer.files[i]);
  4401. reader.readAsArrayBuffer(ev.dataTransfer.files[i]);
  4402. }
  4403. }
  4404. }
  4405. }
  4406. function dragOverHandler(ev) {
  4407. bkg=document.querySelector('#dropping_background');
  4408. bkg.style.display="";
  4409. console.log('File(s) in drop zone');
  4410. ev.preventDefault();
  4411. }
  4412. </script>
  4413. <?php
  4414. }
  4415. function CanShowGallery(&$g){
  4416. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($g['experimental']) && $g['experimental']) return false;
  4417. return true;
  4418. }
  4419. function CanShowImage(&$im){
  4420. if((!$this->LoggedIn&&!$this->InExperimentalMode) && isset($im['galleries']) && isset($im['galleries'][0])) foreach($im['galleries'] as $ga){
  4421. if(($g=$this->GetGallery($ga)) && isset($g['experimental']) && $g['experimental']) return false;
  4422. }
  4423. if(isset($this->WayBack) && substr($im['name'],0,14)>$this->WayBack) return false;
  4424. return true;
  4425. }
  4426. function GetImageBatch($from,$show_all){
  4427. if(!isset($_GET['gallery'])) return;
  4428. $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){$name=$_GET['gallery'];}
  4429. $reached=0; $count=0;
  4430. if(isset($this->Images[0])) foreach($this->Images as $im){
  4431. if(isset($from)&&!$reached){ if($from==$im['name']){ $reached=1; } continue; }
  4432. if(!$this->CanShowImage($im)){ continue; }
  4433. if($_GET['gallery']=='trash') $name='trash';
  4434. if($_GET['gallery']!='main'){ if(!isset($im['galleries']) || !in_array($name, $im['galleries'])) continue;} ?>
  4435. <div class='p_thumb<?=isset($im['parent'])?" p_thumb_narrow":""?>'>
  4436. <?php if($this->LoggedIn){ ?>
  4437. <div class="post_menu_button _select_hook white" onclick='ToggleSelectImage(this, "<?=$im["name"]?>")'>●</div>
  4438. <?php } ?>
  4439. <a href='?show_image=<?=$im['name']?>' target='_blank' onclick='event.preventDefault();'>
  4440. <?php if(isset($im['video']) && $im['video']!=""){ ?>
  4441. <video data-imgsrc='<?=$im["name"]?>'><source src='<?=$im['file']?>' type='<?=$im['video']?>'></video>
  4442. <?php }else{ ?>
  4443. <img src='<?=$im['thumb']?>' data-imgsrc='<?=$im["name"]?>'
  4444. <?=isset($im['product'])?'data-product="'.$im["product"].'"':""?>
  4445. <?=isset($im['parent'])?'data-parent="'.$im["parent"].'"':""?>
  4446. <?=isset($im['align'])?'data-align="'.$im["align"].'" style="object-position:'.$im['align'].';"':""?>/>
  4447. <?php } ?>
  4448. </a>
  4449. </div>
  4450. <?php $count+=isset($im['parent'])?0:1; if((!$show_all)&&($count>=$this->GalleryStep)){ break; }
  4451. }
  4452. if($count<$this->GalleryStep){ ?><div style='display:none'>END_GALLERY</div><?php return 0; }
  4453. return 1;
  4454. }
  4455. function MakeGallerySection(){ global $INDEXPHP;
  4456. if(!isset($_GET['gallery'])) return;
  4457. $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){ $name=$_GET['gallery'];}
  4458. $show_all=0; if(isset($_GET['show_all']) && $_GET['show_all']!='0'){ $show_all=1; } ?>
  4459. <script>
  4460. document.title+=" | <?=$this->T('画廊')?>";
  4461. </script>
  4462. <div class='center_wide' id='div_center' style='position:relative;'><br class='hidden_on_print' />
  4463. <h2><?=(isset($name) && ($gal=$this->GetGallery($name))!=NULL)?
  4464. ("<span class='gray album_hint'>".$this->T('相册').":</span>".$this->T($name)):
  4465. ($_GET['gallery']=='trash'?$this->T('垃圾桶'):$this->T('画廊'))?></h2>
  4466. <?php $description=(isset($gal) && isset($gal['description']))?$gal['description']:null; ?>
  4467. <div class='hidden_on_desktop'>
  4468. <?=$this->T('前往')?>
  4469. <select id="gallery_go_to" onchange="window.location.href='?gallery='+this.value;">
  4470. <optgroup label="<?=$this->T('精选')?>">
  4471. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4472. if(!isset($g['featured']) || !$g['featured'] ||
  4473. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  4474. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  4475. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  4476. <?php } ?></optgroup><optgroup label="<?=$this->T('其他相册')?>">
  4477. <option value="main" <?=$_GET['gallery']=='main'?"selected":""?>>[<?=$this->T('全部')?>]</option>
  4478. <?php if($this->LoggedIn){ ?>
  4479. <option value="trash" <?=$_GET['gallery']=='trash'?"selected":""?>>[<?=$this->T('垃圾桶')?>]</option>
  4480. <?php } ?>
  4481. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4482. if((isset($g['featured']) && $g['featured']) ||
  4483. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  4484. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  4485. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  4486. <?php } ?></optgroup>
  4487. </select>
  4488. </div>
  4489. <?php if($this->LoggedIn){?>
  4490. <div>
  4491. <?php if(isset($name)){ ?>
  4492. <div style='text-align:right;position:absolute;right:0;top:0;width:100%;' class='invert_a smaller hidden_on_print'>
  4493. <a href='javascript:ShowDeleteMenu();'><?=$this->T('删除相册')?></a><br />
  4494. <?php if(isset($gal['featured']) && $gal['featured']!=false){ ?>
  4495. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=false'>
  4496. <?=$this->T('取消精选')?></a>
  4497. <?php }else{ ?>
  4498. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=true'>
  4499. <?=$this->T('设为精选')?></a>
  4500. <?php } ?><br />
  4501. <?php if(isset($gal['experimental']) && $gal['experimental']!=false){ ?>
  4502. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=false'>
  4503. <?=$this->T('取消实验')?></a>
  4504. <?php }else{ ?>
  4505. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=true'>
  4506. <?=$this->T('设为实验')?></a>
  4507. <?php } ?>
  4508. <div class='pop_menu invert_a' id='gallery_delete_menu' style='display:none;'>
  4509. <div style='float:left;' class='gray'><?=$this->T('该操作不删除图片。')?></div>
  4510. <a href='javascript:HidePopMenu();'>×</a>
  4511. <hr />
  4512. <a href='?gallery=main&gallery_edit_delete=<?=$_GET['gallery']?>'><b><?=$this->T('删除相册')?></b></a>
  4513. </div>
  4514. </div>
  4515. <?php } ?>
  4516. <?php $this->MakeUploader(false); ?>
  4517. <div style='text-align:right;position:relative;' class='invert_a smaller hidden_on_print'>
  4518. <div style='position:relative'>
  4519. <?php if(isset($name)){ ?>
  4520. <a href='javascript:ShowGalleryEditMenu("<?=$name?>",null)'><?=$this->T('改名')?></a>
  4521. <a href='javascript:ShowGalleryEditMenu("<?=$name?>","<?=$description?>")'><?=$this->T('描述')?></a>
  4522. <?php } ?>
  4523. <a href='javascript:ShowGalleryEditMenu(null,null)'><?=$this->T('添加')?></a>
  4524. <div class='pop_menu invert_a' id='gallery_edit_menu' style='display:none;max-width:90%;'>
  4525. <form action="<?=$_SERVER['REQUEST_URI']?>&edit_gallery=true"
  4526. method="post" style='display:none;' id='gallery_edit_form'></form>
  4527. <a style='float:left;'><?=$this->T('设置为:')?></a>
  4528. <a href='javascript:HidePopMenu();'>×</a>
  4529. <input type='text' form='gallery_edit_form' name='gallery_edit_new_name' id='gallery_edit_new_name' style='width:10em;'>
  4530. <input type='text' form='gallery_edit_form' name='gallery_edit_old_name' id='gallery_edit_old_name' style='display:none'>
  4531. <input type='text' form='gallery_edit_form' name='gallery_edit_description' id='gallery_edit_description' style='width:10em;display:none'>
  4532. <input class='button' type='submit' form='gallery_edit_form'
  4533. name='gallery_edit_confirm' id='gallery_edit_confirm' value='<?=$this->T('确认')?>'>
  4534. </div>
  4535. </div>
  4536. </div>
  4537. <div class='smaller hidden_on_print'>
  4538. <form action="<?=$_SERVER['REQUEST_URI']?>"
  4539. method="post" style='display:none;' id='gallery_move_form'></form>
  4540. <input type='text' form='gallery_move_form' name='gallery_move_ops'
  4541. id='gallery_move_ops' style='display:none'>
  4542. <p><?=$this->T('选择了')?> <span id='gallery_selected_count'>0</span> <?=$this->T('个图片。')?>
  4543. <a href='javascript:ClearSelectedImages()'><?=$this->T('清除')?></a></p>
  4544. <p><?=$this->T('添加到')?>
  4545. <select id="gallery_move_to">
  4546. <option value="trash"><?=$this->T('垃圾桶')?></option>
  4547. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  4548. <option value="<?=$g['name']?>"><?=$this->T($g['name'])?></option>
  4549. <?php } ?>
  4550. </select>
  4551. <a href='javascript:AddToGallery()'><?=$this->T('执行')?></a>
  4552. </p>
  4553. <p>
  4554. <?=$this->T('或者')?><a href='javascript:RemoveFromGallery()'><?=$this->T('从相册移除')?></a>
  4555. </p>
  4556. </div>
  4557. </div>
  4558. <?php } $desc=isset($description)?$this->GetPost($description):null;
  4559. if(isset($desc)){ ?><ul class='print_column list'><br /><?php
  4560. $this->MakeSinglePost($desc, false, false, false, false, false, false, false, false, true, false);
  4561. ?></ul><?php } ?>
  4562. <br />
  4563. <div><div class='p_row'><?php $has_more=$this->GetImageBatch(NULL, $show_all);?>
  4564. <div class='p_thumb p_thumb_end' <?=$has_more?"onclick='ThisGetMore(this);'":""?>>
  4565. <a onclick='event.preventDefault();' href='<?=$INDEXPHP?>?gallery=<?=$_GET['gallery']?>&show_all=1'>
  4566. <h2 id="btn_more_images"><?=$has_more?$this->T("查看更多"):$this->T("没有更多的了");?></a></h2></div></div>
  4567. </div>
  4568. </div>
  4569. <script type='text/javascript'>
  4570. function ThisGetMore(end_ui){
  4571. var xhr = new XMLHttpRequest();
  4572. xhr.onreadystatechange = function() {
  4573. if (this.readyState == 4 && this.status == 200) {
  4574. doc = document.createElement("div"); doc.innerHTML=xhr.responseText.trim(); next_child=null;
  4575. for(child=doc.firstChild; child!==null; child=next_child) { next_child=child.nextSibling; end_ui.parentNode.insertBefore(child,end_ui); }
  4576. doc.remove();
  4577. if(xhr.responseText.search('END_GALLERY')>=0){ end_ui.onclick=null; end_ui.innerHTML="<h2><?=$this->T("没有更多的了");?></h2>"; }
  4578. UpdateImageClickables();
  4579. btn=document.getElementById("btn_more_images"); if(btn) btn.innerText="<?=$this->T("查看更多");?>";
  4580. }
  4581. };
  4582. btn=document.getElementById("btn_more_images"); if(btn) btn.innerText="<?=$this->T("稍等");?>";
  4583. im=end_ui.previousElementSibling.querySelector('img,video');
  4584. from=im?im.dataset.imgsrc:null; if(!from) return;
  4585. const urlParams = new URLSearchParams(window.location.search); const gallery = urlParams.get('gallery')
  4586. xhr.open("GET", "<?=$INDEXPHP?>?gallery_continue="+from+'&gallery='+gallery, true);
  4587. xhr.send();
  4588. }
  4589. <?php if($this->LoggedIn){ ?>
  4590. var selected_image = new Array();
  4591. function RemoveFromGallery(){
  4592. form = document.querySelector('#gallery_move_form');
  4593. ops = document.querySelector('#gallery_move_ops');
  4594. sel = document.querySelector('#gallery_move_to');
  4595. ops.value = "REM <?=$_GET['gallery']?>"+" "+selected_image.join(' ');
  4596. form.submit();
  4597. }
  4598. function AddToGallery(){
  4599. form = document.querySelector('#gallery_move_form');
  4600. ops = document.querySelector('#gallery_move_ops');
  4601. sel = document.querySelector('#gallery_move_to');
  4602. ops.value = "ADD "+sel.value+" "+selected_image.join(' ');
  4603. form.submit();
  4604. }
  4605. function ClearSelectedImages(){
  4606. selected_image.splice(0, selected_image.length);
  4607. checks = document.querySelectorAll('._select_hook');
  4608. [].forEach.call(checks, function(c){
  4609. c.classList.remove('p_thumb_selected');
  4610. });
  4611. count = document.querySelector('#gallery_selected_count');
  4612. count.innerHTML="0";
  4613. }
  4614. function ToggleSelectImage(elem, name){
  4615. count = document.querySelector('#gallery_selected_count');
  4616. if(selected_image.indexOf(name) == -1){ selected_image.push(name); elem.classList.add('p_thumb_selected'); }
  4617. else{ selected_image.splice(selected_image.indexOf(name), 1); elem.classList.remove('p_thumb_selected'); }
  4618. count.innerHTML=selected_image.length.toString()
  4619. }
  4620. function ShowGalleryEditMenu(old_name,desc){
  4621. m = document.querySelector('#gallery_edit_menu');
  4622. old = document.querySelector('#gallery_edit_old_name');
  4623. newname = document.querySelector('#gallery_edit_new_name');
  4624. description = document.querySelector('#gallery_edit_description');
  4625. m.style.display='block';
  4626. if(desc!==null){ description.style.display='block';newname.style.display='none';description.value=desc;}
  4627. else{ description.style.display='none';newname.style.display='';}
  4628. if(old_name!=''){ old.value=old_name; newname.value=old.value; }else{ old.value=''; }
  4629. }
  4630. function ShowDeleteMenu(){
  4631. m=document.querySelector('#gallery_delete_menu');
  4632. m.style.display='block';
  4633. }
  4634. <?php } ?>
  4635. </script>
  4636. <?php
  4637. }
  4638. function MakeGalleryLeft(){?>
  4639. <div class='left hidden_m gallery_left' id='div_left'><div><br /></div>
  4640. <h2><?=$this->T('相册')?></h2>
  4641. <div>
  4642. <span class='gray smaller bold'><?=$this->T('精选')?><hr> </span>
  4643. <ul>
  4644. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4645. if(!isset($g['featured']) || !$g['featured'] || !$this->CanShowGallery($g)){ continue; } ?>
  4646. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4647. <li class='<?=$_GET['gallery']==$g['name']?'selected':""?>'>
  4648. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4649. <?php } ?>
  4650. </ul>
  4651. <div class='smaller'><span class='gray'><?=$this->T('其他相册')?><hr></span><ul>
  4652. <a href='?gallery=main' onclick='ShowWaitingBar()'>
  4653. <li class='<?=$_GET['gallery']=='main'?' selected':""?>'>[<?=$this->T('全部图片')?>]</li></a>
  4654. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  4655. if((isset($g['featured']) && $g['featured']) || !$this->CanShowGallery($g)){ continue; } ?>
  4656. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  4657. <li class='<?=$_GET['gallery']==$g['name']?' selected':""?>'>
  4658. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  4659. <?php } ?>
  4660. <?php if($this->LoggedIn){ ?>
  4661. <a href='?gallery=trash' onclick='ShowWaitingBar()'>
  4662. <li class='<?=$_GET['gallery']=='trash'?' selected':""?>'>[<?=$this->T('垃圾桶')?>]</li></a>
  4663. <?php } ?>
  4664. </ul></div>
  4665. <p>&nbsp;</p>
  4666. <script>
  4667. </script>
  4668. </div>
  4669. </div>
  4670. <?php
  4671. }
  4672. function MakeStatistics(){
  4673. $this->ReadPosts(); $this->ReadImages(); $this->ReadArchive();
  4674. $list=[]; $last_date=null; $info=[]; $info['count']=0; $info['edits']=0; $info['length']=0;
  4675. $imlist=[]; $imlast_date=null; $iminfo=[]; $iminfo['count']=0;
  4676. $maxposts=0; $maxlength=0; $maximages=0;
  4677. foreach($this->Posts as &$p){ $is_ref=0;
  4678. $this_date=substr($p['id'],0,8);
  4679. if($last_date!=null && $last_date!=$this_date){
  4680. if($maxposts<$info['count']+$info['edits'])$maxposts=$info['count']+$info['edits'];
  4681. if($maxlength<$info['length'])$maxlength=$info['length'];
  4682. $list[]=$info; $info=[]; $info['count']=0; $info['edits']=0; $info['length']=0;
  4683. }
  4684. $ah = &$this->GetArchiveHandle($p['id']); if(isset($ah)&&isset($ah['list'][0])) $info['edits']+=count($ah['list']);
  4685. $info['count']++; $info['id']=$this_date; if(isset($p['content']))$info['length']+=strlen($p['content']); $last_date=$this_date;
  4686. }
  4687. $last_date=null;
  4688. foreach($this->Images as &$im){ $is_ref=0;
  4689. $this_date=substr($im['name'],0,8);
  4690. if($last_date!=null && $last_date!=$this_date){
  4691. if($maximages<$iminfo['count'])$maximages=$iminfo['count'];
  4692. $imlist[]=$iminfo; $iminfo=[]; $iminfo['count']=0;
  4693. }
  4694. $iminfo['count']++; $iminfo['id']=$this_date; $last_date=$this_date;
  4695. }
  4696. if($info!=[]) $list[]=$info;
  4697. if($iminfo!=[]) $imlist[]=$iminfo;
  4698. if(!isset($list[0])) return;
  4699. $earliest=DateTimeImmutable::createFromFormat('!Ymd',$list[0]['id']); $ey=substr($list[0]['id'],0,4);
  4700. $latest=DateTimeImmutable::createFromFormat('!Ymd',end($list)['id']); $ly=substr(end($list)['id'],0,4);
  4701. $days=$earliest->diff($latest)->days; $lw=2.0; $dw=$days*$lw; $spw=20;
  4702. ?>
  4703. <style>.stastics_posts{direction:ltr;} .stastics_posts line,.stastics_posts circle{stroke:#f8ca9b; stroke-width:2px;}
  4704. .stastics_posts .line_edits{stroke:#f8ca9b40;}
  4705. .stastics_posts .line_year{stroke:#f8ca9b30; stroke-width:2px;} .stastics_posts text{fill:#f8ca9ba0; font: 0.9em serif;}
  4706. </style>
  4707. <div class='settings'><h2><?=$this->T('统计')?></h2><br />
  4708. <div style="overflow:auto;direction:rtl;width:100%;">
  4709. <svg class='stastics_posts' viewBox="-<?=$spw?> -<?=$spw?> <?=$days*$lw+$spw*6?> <?=200+4*$spw?>" height="<?=200+4*$spw?>" width="<?=$days*$lw+$spw*6?>">
  4710. <?php foreach($list as $info){ $itv=DateTimeImmutable::createFromFormat('!Ymd',$info['id'])->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);
  4711. $p1=100.0*(1-$info['count']/$maxposts); $p2=$p1-100.0*$info['edits']/$maxposts;
  4712. $p3=100.0*$info['length']/$maxlength+$spw+100; ?>
  4713. <line x1="<?=$ds?>" x2="<?=$ds?>" y1="100.0" y2="<?=$p1?>"/>
  4714. <?php if($info['edits']>0){ ?><line class='line_edits' x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=$p1?>" y2="<?=$p2?>"/><?php } ?>
  4715. <?php if($info['length']>0){ ?><line class='line_edits' x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=$spw+100?>" y2="<?=$p3?>"/><?php } ?>
  4716. <?php } ?>
  4717. <?php foreach($imlist as $im){ $itv=DateTimeImmutable::createFromFormat('!Ymd',$im['id'])->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);
  4718. $p1=100+$spw+100.0*($im['count']/$maximages); ?>
  4719. <circle cx="<?=$ds?>" cy="<?=$p1?>" r='3'/>
  4720. <?php } ?>
  4721. <?php for($y=$ey;$y<=$ly;$y++){ $itv=DateTimeImmutable::createFromFormat('!Y',$y)->diff($earliest); $ds=$lw/2+$lw*$itv->days*($itv->invert?1:-1);?>
  4722. <line x1="<?=$ds?>" x2="<?=$ds?>" y1="<?=220+$spw?>" y2="-<?=$spw?>" class='line_year'/>
  4723. <text x="<?=$ds+4?>" y="-4"><?=$y?></text>
  4724. <text x="<?=$ds+4?>" y="<?=$spw*2+200-4?>"><?=$y?></text>
  4725. <?php for($ym=1;$ym<=12;$ym++){ $st=str_pad($ym,2,'0',STR_PAD_LEFT); $itv2=DateTimeImmutable::createFromFormat('!Ym',$y.$st)->diff($earliest);
  4726. $dds=$lw/2+$lw*$itv2->days*($itv2->invert?1:-1); if($dds<0||$dds>$lw/2+$dw) continue; ?>
  4727. <line x1="<?=$dds?>" x2="<?=$dds?>" y1="<?=100+$spw?>" y2="100" class='line_year'/>
  4728. <text x="<?=$dds+4?>" y="<?=100+$spw-3?>"><?=$ym?></text>
  4729. <?php } } ?>
  4730. <line x1="<?=$lw/2+$dw?>" x2="<?=$days*$lw?>" y1="<?=220+$spw?>" y2="-<?=$spw?>" class='line_year'/>
  4731. <line x1="0" x2="<?=$dw?>" y1="0" y2="0" class='line_year'/>
  4732. <line x1="0" x2="<?=$dw?>" y1="100" y2="100" class='line_year'/>
  4733. <line x1="0" x2="<?=$dw?>" y1="<?=100+$spw?>" y2="<?=100+$spw?>" class='line_year'/>
  4734. <line x1="0" x2="<?=$dw?>" y1="<?=200+$spw?>" y2="<?=200+$spw?>" class='line_year'/>
  4735. <text x="<?=$dw+10?>" y="8"><?=$maxposts?></text>
  4736. <text x="<?=$dw+10?>" y="<?=$spw+8?>"><tspan style='fill:#f8ca9b;'>▪ <?=$this->T('新增')?></tspan></text>
  4737. <text x="<?=$dw+10?>" y="<?=$spw*2+8?>"><tspan style='fill:#f8ca9ba0;'>▪ <?=$this->T('改动')?></tspan></text>
  4738. <text x="<?=$dw+10?>" y="<?=$spw*2+200-4?>"><?=$maxlength?></text>
  4739. <text x="<?=$dw+10?>" y="<?=$spw+200-4?>"><tspan style='fill:#f8ca9b;'><?=$maximages?></tspan></text>
  4740. <text x="<?=$dw+10?>" y="<?=200-4?>"><tspan style='fill:#f8ca9b;'>▪ <?=$this->T('媒体')?></text>
  4741. <text x="<?=$dw+10?>" y="<?=200-4-$spw?>">▪ <?=$this->T('长度')?></tspan></text>
  4742. </svg></div>
  4743. <br /><br />
  4744. </div>
  4745. <?php
  4746. }
  4747. function MakeSettings(){ global $INDEXPHP; ?>
  4748. <div class='settings'>
  4749. <h2><?=$this->T('设置')?></h2>
  4750. <table style='white-space:nowrap;'>
  4751. <?php if($this->LoggedIn){ ?>
  4752. <form action="<?=$INDEXPHP?>?settings=true" method="post" style='display:none;' id='settings_form'></form>
  4753. <colgroup><col style='min-width:5em;'><col style='width:100%;min-width:5em;'></colgroup>
  4754. <thead><tr><td><?=$this->T('选项')?></td><td><?=$this->T('值')?></td></tr></thead>
  4755. <tr><td><?=$this->T('网站标题')?></td>
  4756. <td><input type="text" form="settings_form" id='settings_title' name='settings_title'
  4757. value='<?=$this->Title?>'/></td></tr>
  4758. <tr><td><?=$this->T('短标题')?></td>
  4759. <td><input type="text" form="settings_form" id='settings_short_title' name='settings_short_title'
  4760. value='<?=$this->ShortTitle?>'/></td></tr>
  4761. <tr><td><?=$this->T('显示名称')?></td>
  4762. <td><input type="text" form="settings_form" id='settings_display_name' name='settings_display_name'
  4763. value='<?=$this->DisplayName?>'/></td></tr>
  4764. <tr><td><?=$this->T('电子邮件')?></td>
  4765. <td><input type="text" form="settings_form" id='settings_email' name='settings_email'
  4766. value='<?=$this->EMail?>'/></td></tr>
  4767. <tr><td><?=$this->T('导航栏')?>
  4768. <?=isset($this->SpecialNavigation)?"<a href='?post=".$this->SpecialNavigation."'>→</a>":""?></td>
  4769. <td><input type="text" form="settings_form" id='settings_special_navigation' name='settings_special_navigation'
  4770. value='<?=$this->SpecialNavigation?>'/></td></tr>
  4771. <tr><td><?=$this->T('侧边栏')?>
  4772. <?=isset($this->SpecialSidebar)?"<a href='?post=".$this->SpecialSidebar."'>→</a>":""?></td>
  4773. <td><input type="text" form="settings_form" id='settings_special_sidebar' name='settings_special_sidebar'
  4774. value='<?=$this->SpecialSidebar?>'/></td></tr>
  4775. <tr><td><?=$this->T('脚注')?> 1<?=isset($this->SpecialFooter)?"<a href='?post=".$this->SpecialFooter."'>→</a>":""?></td>
  4776. <td><input type="text" form="settings_form" id='settings_special_footer' name='settings_special_footer'
  4777. value='<?=$this->SpecialFooter?>'/></td></tr>
  4778. <tr><td><?=$this->T('脚注')?> 2<?=isset($this->SpecialFooter2)?"<a href='?post=".$this->SpecialFooter2."'>→</a>":""?></td>
  4779. <td><input type="text" form="settings_form" id='settings_special_footer2' name='settings_special_footer2'
  4780. value='<?=$this->SpecialFooter2?>'/></td></tr>
  4781. <tr><td><?=$this->T('置顶文')?><?=isset($this->SpecialPinned)?"<a href='?post=".$this->SpecialPinned."'>→</a>":""?></td>
  4782. <td><input type="text" form="settings_form" id='settings_special_pinned' name='settings_special_pinned'
  4783. value='<?=$this->SpecialPinned?>'/></td></tr>
  4784. <tr><td><?=$this->T('默认相册')?></td>
  4785. <td><input type="text" form="settings_form" id='settings_default_gallery' name='settings_default_gallery'
  4786. value='<?=$this->DefaultGallery?>'/></td></tr>
  4787. <tr><td><?=$this->T('相册单步')?></td>
  4788. <td><input type="text" form="settings_form" id='settings_gallery_step' name='settings_gallery_step'
  4789. value='<?=$this->GalleryStep?>'/></td></tr>
  4790. <tr><td><?=$this->T('SelfAuth 路径')?></td>
  4791. <td><input type="text" form="settings_form" id='settings_selfauth_path' name='settings_selfauth_path'
  4792. value='<?=$this->SelfAuthPath?>'/></td></tr>
  4793. <tr><td><?=$this->T('启用评论')?></td>
  4794. <td><input type="checkbox" id="settings_enable_comments" name="settings_enable_comments"
  4795. form="settings_form" <?=$this->CommentEnabled?"checked":""?>/></td></tr>
  4796. <tr><td><?=$this->T('附加操作')?></td><td><a class='gray' href='<?=$INDEXPHP?>?extras=true'><?=$this->T('进入')?></a></td></tr>
  4797. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4798. <tr><td class='smaller gray'><?=$this->T('长毛象')?></td></tr>
  4799. <tr><td><?=$this->T('长毛象实例')?></td>
  4800. <td><input type="text" form="settings_form" id='settings_mastodon_url' name='settings_mastodon_url'
  4801. value='<?=$this->MastodonURL?>'/></td></tr>
  4802. <tr><td><?=$this->T('长毛象令牌')?></td>
  4803. <td><input type="text" form="settings_form" id='settings_mastodon_token' name='settings_mastodon_token'
  4804. value='<?=$this->MastodonToken?>'/></td></tr>
  4805. <tr><td><?=$this->T('偏好语言')?></td>
  4806. <td><input type="text" form="settings_form" id='settings_mastodon_lang' name='settings_mastodon_lang'
  4807. value='<?=$this->MastodonPreferredLang?>'/></td></tr>
  4808. <tr><td><?=$this->T('本站地址')?></td>
  4809. <td><input type="text" form="settings_form" id='settings_host_url' name='settings_host_url'
  4810. value='<?=$this->HostURL?>'/></td></tr>
  4811. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4812. <tr><td class='smaller gray'><?=$this->T('Activity Pub')?></td></tr>
  4813. <tr><td><?=$this->T('用户名')?></td>
  4814. <td><input type="text" form="settings_form" id='settings_apub_id' name='settings_apub_id'
  4815. value='<?=$this->APubID?>'/></td></tr>
  4816. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4817. <tr><td class='smaller gray'><?=$this->T('这里访问')?></td></tr>
  4818. <tr><td><?=$this->T('主机')?></td>
  4819. <td><input type="text" form="settings_form" id='settings_here_host' name='settings_here_host'
  4820. value='<?=$this->HereHost?>'/></td></tr>
  4821. <tr><td><?=$this->T('网站标题')?></td>
  4822. <td><input type="text" form="settings_form" id='settings_here_title' name='settings_here_title'
  4823. value='<?=$this->HereTitle?>'/></td></tr>
  4824. <tr><td><?=$this->T('短标题')?></td>
  4825. <td><input type="text" form="settings_form" id='settings_here_short_title' name='settings_here_short_title'
  4826. value='<?=$this->HereShortTitle?>'/></td></tr>
  4827. <tr><td><?=$this->T('相册')?></td>
  4828. <td><input type="text" form="settings_form" id='settings_here_album' name='settings_here_album'
  4829. value='<?=$this->HereAlbum?>'/></td></tr>
  4830. <tr><td><?=$this->T('导航栏')?>
  4831. <?=isset($this->HereNavigation)?"<a href='?post=".$this->HereNavigation."'>→</a>":""?></td>
  4832. <td><input type="text" form="settings_form" id='settings_here_navigation' name='settings_here_navigation'
  4833. value='<?=$this->HereNavigation?>'/></td></tr>
  4834. <tr><td><?=$this->T('脚注')?><?=isset($this->HereFooter)?"<a href='?post=".$this->HereFooter."'>→</a>":""?></td>
  4835. <td><input type="text" form="settings_form" id='settings_here_footer' name='settings_here_footer'
  4836. value='<?=$this->HereFooter?>'/></td></tr>
  4837. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4838. <tr><td class='smaller gray'><?=$this->T('实验访问')?></td></tr>
  4839. <tr><td><?=$this->T('主机')?></td>
  4840. <td><input type="text" form="settings_form" id='settings_exp_host' name='settings_exp_host'
  4841. value='<?=$this->ExpHost?>'/></td></tr>
  4842. <tr><td><?=$this->T('网站标题')?></td>
  4843. <td><input type="text" form="settings_form" id='settings_exp_title' name='settings_exp_title'
  4844. value='<?=$this->ExpTitle?>'/></td></tr>
  4845. <tr><td><?=$this->T('短标题')?></td>
  4846. <td><input type="text" form="settings_form" id='settings_exp_short_title' name='settings_exp_short_title'
  4847. value='<?=$this->ExpShortTitle?>'/></td></tr>
  4848. <tr><td><?=$this->T('首次提示')?><?=isset($this->ExpCaution)?"<a href='?post=".$this->ExpCaution."'>→</a>":""?></td>
  4849. <td><input type="text" form="settings_form" id='settings_exp_caution' name='settings_exp_caution'
  4850. value='<?=$this->ExpCaution?>'/></td></tr>
  4851. <tr><td><?=$this->T('相册')?></td>
  4852. <td><input type="text" form="settings_form" id='settings_exp_album' name='settings_exp_album'
  4853. value='<?=$this->ExpAlbum?>'/></td></tr>
  4854. <tr><td><?=$this->T('导航栏')?>
  4855. <?=isset($this->ExpNavigation)?"<a href='?post=".$this->ExpNavigation."'>→</a>":""?></td>
  4856. <td><input type="text" form="settings_form" id='settings_exp_navigation' name='settings_exp_navigation'
  4857. value='<?=$this->ExpNavigation?>'/></td></tr>
  4858. <tr><td><?=$this->T('脚注')?><?=isset($this->ExpFooter)?"<a href='?post=".$this->ExpFooter."'>→</a>":""?></td>
  4859. <td><input type="text" form="settings_form" id='settings_exp_footer' name='settings_exp_footer'
  4860. value='<?=$this->ExpFooter?>'/></td></tr>
  4861. <tr><td><?=$this->T('允许选择语言')?>
  4862. <td><input type="checkbox" id="settings_allow_language" name="settings_allow_language"
  4863. form="settings_form" <?=$this->AllowLanguageChoices?"checked":""?>/></td></tr>
  4864. <tr><td class='smaller gray'>&nbsp;</td></tr>
  4865. <tr><td class='smaller gray'><?=$this->T('管理员')?></td><td class='smaller'>
  4866. <a href='<?=$INDEXPHP?>?logout=true'><?=$this->T('登出')?></a></td></tr>
  4867. <tr><td><?=$this->T('帐号')?></td>
  4868. <td><input type="text" form="settings_form" id='settings_id' name='settings_id'
  4869. value='<?=$this->Admin?>'/></td></tr>
  4870. <tr><td><?=$this->T('新密码')?></td>
  4871. <td><input type="password" form="settings_form"
  4872. id='settings_new_password' name='settings_new_password' /></td></tr>
  4873. <tr><td><?=$this->T('再次输入')?></td>
  4874. <td><input type="password" form="settings_form"
  4875. id='settings_new_password_redo' name='settings_new_password_redo' /></td></tr>
  4876. <tr><td><?=$this->T('旧密码')?></td>
  4877. <td><input type="password" form="settings_form" id='settings_old_password' name='settings_old_password' /></td></tr>
  4878. <?php }else{ ?>
  4879. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='login_form'></form>
  4880. <colgroup><col style='min-width:3em;'><col style='width:100%;min-width:5em;'></colgroup>
  4881. <tr><td class='smaller gray'><?=$this->T('请登录')?></td></tr>
  4882. <tr><td><?=$this->T('帐号')?></td>
  4883. <td><input type="text" form="login_form" id='login_id' name='login_id' /></td></tr>
  4884. <tr><td><?=$this->T('密码')?></td>
  4885. <td><input type="password" form="login_form" id='login_password' name='login_password' /></td></tr>
  4886. <?php } ?>
  4887. </table>
  4888. <?php if($this->LoggedIn){ ?>
  4889. <input class='button' form="settings_form" type="submit" name='settings_button' value='<?=$this->T('保存设置')?>' />
  4890. <?php }else{ ?>
  4891. <input class='button' form="login_form" type="submit" name='login_button' value='<?=$this->T('登录')?>' />
  4892. <?php } ?>
  4893. </div>
  4894. <?php
  4895. }
  4896. function MakeExtraOperations(){ global $INDEXPHP; ?>
  4897. <div class='settings' style='overflow:auto;'>
  4898. <h2><?=$this->T('附加操作')?></h2>
  4899. <a href='<?=$INDEXPHP?>?&settings=true'><?=$this->T('返回一般设置')?></a>
  4900. <p>&nbsp;</p>
  4901. <h3><?=$this->T('自动重定向')?></h3>
  4902. <span class='smaller gray'>
  4903. <?=$this->T('P为帖子跳转,匹配REQUEST_URI跳到目标文章;S为站点跳转,可以重定向来源域名,例子:')?>
  4904. <br /><pre>P discount:20001001010101;<br />S old_domain:www.new_domain.com:20001001010101;</pre></span>
  4905. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form2'></form>
  4906. <textarea id="settings_redirect" name="settings_redirect" rows="3" class='full_box' wrap="off"
  4907. form='settings_form2'><?=$this->DisplayRedirectConfig()?></textarea>
  4908. <input class='button' form="settings_form2" type="submit" name='settings_save_redirect'
  4909. value='<?=$this->T('保存重定向设置')?>' />
  4910. <p>&nbsp;</p>
  4911. <h3><?=$this->T('自定义翻译')?></h3>
  4912. <span class='smaller gray'>
  4913. <?=$this->T('填写格式:')?>
  4914. <br /><pre>- 语言 | Language</pre></span>
  4915. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form3'></form>
  4916. <textarea id="settings_translation" name="settings_translation" rows="3" class='full_box' wrap="off"
  4917. form='settings_form3'><?=$this->CustomTranslationContent?></textarea>
  4918. <input class='button' form="settings_form3" type="submit" name='settings_save_translation'
  4919. value='<?=$this->T('保存翻译')?>' />
  4920. <p>&nbsp;</p>
  4921. <p class='smaller gray'><?=$this->T('ActivityPub 测试:')?></p>
  4922. <ul>
  4923. <li><a href='?TestAPubDeliver=1'><?=$this->T('测试发送')?></a></li></ui>
  4924. </ui>
  4925. <br />
  4926. <p class='smaller gray'><?=$this->T('当心!下列操作将立即执行:')?></p>
  4927. <ul>
  4928. <li><label for='opbtn0' class='ref_count'><?=$this->T('重新写入默认CSS')?></label><input type="checkbox" class='lpctrl' id='opbtn0' checked='checked'/>
  4929. <a href='?rewrite_styles=true'>→</a></li>
  4930. <li><label for='opbtn1' class='ref_count'><?=$this->T('重新生成图片缩略图')?></label><input type="checkbox" class='lpctrl' id='opbtn1' checked='checked'/>
  4931. <a href='?regenerate_thumbnails=true'>→</a></li>
  4932. <li><label for='opbtn2' class='ref_count'><?=$this->T('清理未压缩的图像')?></label><input type="checkbox" class='lpctrl' id='opbtn2' checked='checked'/>
  4933. <a href='?cleanup_image_compression=true'>→</a></li>
  4934. <li><label for='opbtn3' class='ref_count'><?=$this->T('删除所有登录')?></label><input type="checkbox" class='lpctrl' id='opbtn3' checked='checked'/>
  4935. <a href='?clear_all_logins=true'>→</a></li>
  4936. </ui>
  4937. <br /><br /><br /><a href='?&settings=true'><?=$this->T('返回一般设置')?></a><br />&nbsp;
  4938. </div>
  4939. <?php
  4940. }
  4941. function MakeMainBegin(){?>
  4942. <div class='main' <?php if($this->LoggedIn && (!$this->InHereMode)){ ?>
  4943. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"<?php } ?>>
  4944. <?php
  4945. }
  4946. function MakeMainEnd(){?>
  4947. </div>
  4948. <?php
  4949. }
  4950. function MakeExpFooter(){
  4951. $exptitle = isset($this->HereDisplayTitle)?('"'.trim($this->T($this->ChoosePartsByLanguage($this->HereDisplayTitle))).'"'):NULL;
  4952. if(!isset($exptitle)) $exptitle=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->HereTitle);?>
  4953. <div class='small_footer exp_h_f exp_f'><div>
  4954. <?php if($this->InExperimentalMode){ ?>
  4955. <b><?=$exptitle?></b>
  4956. <?php }else{ ?>
  4957. <b><?=$exptitle?></b> ©<?=$this->T($this->DisplayName)?>
  4958. <?php }?>
  4959. <?=isset($this->HereMainImage)?("<a class='invert_a' href='?here=images/".$this->HereMainImage['name']."'>".$this->T("看全图")."</a>"):""; ?>
  4960. <div class='wayback_link gray clean_a invert_a hidden_on_print'><br class="hidden_on_desktop" />
  4961. <?php if($this->InExperimentalMode && isset($this->ExpFooter) && ($p = &$this->GetPost($this->ExpFooter,true))!=NULL){
  4962. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  4963. }else if($this->InHereMode && isset($this->HereFooter) && ($p = &$this->GetPost($this->HereFooter,true))!=NULL){
  4964. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  4965. }?></div>
  4966. </div>
  4967. </div>
  4968. </div><!-- page -->
  4969. </body>
  4970. </html>
  4971. <script>
  4972. if(trans = document.getElementById('translate_button')){
  4973. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  4974. }
  4975. </script>
  4976. <?php
  4977. }
  4978. function MakeImageOverlay($side_info=null,$static_image=null,$static_video=null){
  4979. $static=isset($side_info); ?>
  4980. <div id='big_image_overlay' <?=$static?"":"style='display:none'";?>>
  4981. <div class='big_image_box clean_a' onclick='HideBigImage(1)'>
  4982. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'><?=$this->T('请稍候')?></div>
  4983. <?php if(!$static_video){ ?>
  4984. <img id='big_image' onload="HideWaitingBar();" <?=isset($static_image)?("src='".$static_image."'"):""?>/><?php } ?>
  4985. <?php if(!$static_image){ ?>
  4986. <video id='big_video' onloadstart="HideWaitingBar();" controls><source id='big_video_src' type='video/mp4'
  4987. <?=isset($static_video)?("src='".$static_video."'"):""?>></video><?php } ?>
  4988. </div>
  4989. <div class='big_side_box' onclick='HideBigImage(1);'>
  4990. <?php if(!$static){ ?>
  4991. <div class='big_image_box clean_a image_nav' onclick='HideBigImage(1)'>
  4992. <div ><a id='prev_image' class='image_nav_prev img_btn_hidden' onclick="event.stopPropagation();">
  4993. <div class='lr_buttons'>←</div></a></div>
  4994. <div ><a id='next_image' class='image_nav_next img_btn_hidden' onclick="event.stopPropagation();">
  4995. <div class='lr_buttons'>→</div></a></div>
  4996. <div id='here_buttons'></div>
  4997. </div><?php } ?>
  4998. <div class='side_box_mobile_inner'>
  4999. <?php if(!$static){ ?>
  5000. <div class='inquiry_buttons img_btn_hidden' id='inquiry_buttons' onclick="event.stopPropagation();">
  5001. <span style='display:none;' id='image_purchase' class='clean_a'>
  5002. <b><a id='image_purchase_button' target="_blank">¥<?=$this->T('购买印刷品')?></a></b>
  5003. <br class='hidden_on_desktop block_m' /></span>
  5004. <b><a class='clean_a' id='image_download'><span id='download_processing'>↓</span><?=$this->T('下载')?></a></b>
  5005. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  5006. &nbsp;<a class='clean_a' id='image_inquiry'>
  5007. <b>@</b><?=$this->T('咨询')?></a>
  5008. <?php } ?><hr class='hidden_on_desktop block_m' />
  5009. </div>
  5010. <div id='big_image_share' class='clean_a' onclick="event.stopPropagation();">
  5011. <li class='wayback_close'><a onclick='HideBigImage(1);'><?=$this->T('关闭')?> ×</a></li>
  5012. <li><a id='big_share_copy'>⎘ <?=$this->T('复制链接')?></a></li>
  5013. <hr />
  5014. </div><?php } //static ?>
  5015. <div id='big_image_info' onclick="event.stopPropagation();"><?=$static?$side_info:""?></div>
  5016. <?php if($this->LoggedIn && !$static){ ?><div id='big_image_ops' onclick="event.stopPropagation();">
  5017. <br /><?=$this->T('印刷品链接')?>
  5018. <form action="" method="post" style='display:none;' id='image_ops_form'></form>
  5019. <input type='text' id='image_ops_product_link' name='image_ops_product_link' form="image_ops_form" >
  5020. <?=$this->T('重命名')?>
  5021. <input type='text' id='image_edit_new_name' name='image_edit_new_name' form="image_ops_form" >
  5022. <?=$this->T('主图')?>
  5023. <input type='text' id='image_parent' name='image_parent' form="image_ops_form" >
  5024. <?=$this->T('对齐')?> <select id='image_align' name='image_align' form="image_ops_form">
  5025. <option value='top'><?=$this->T('顶部')?></option>
  5026. <option value='middle'><?=$this->T('中间')?></option>
  5027. <option value='bottom'><?=$this->T('底部')?></option></select><br />
  5028. <input class='button' form="image_ops_form" type="submit" name='image_button' value=<?=$this->T('保存')?> />
  5029. <br /><br /><?=$this->T('替换图像')?>
  5030. <form action="" method="post" style='display:none;' id='image_edit_form' enctype="multipart/form-data"></form>
  5031. <input type="file" form='image_edit_form'
  5032. id='big_image_upload' name='upload_file_name' accept="image/x-png,image/png,image/gif,image/jpeg"/><br />
  5033. <input class='button' form="image_edit_form" type="submit" name='image_replace_button'
  5034. value=<?=$this->T('执行')?> />
  5035. </div><?php } ?>
  5036. </div>
  5037. </div>
  5038. </div>
  5039. <?php }
  5040. function MakePageEnd(){?>
  5041. </div><!-- page -->
  5042. </body>
  5043. </html>
  5044. <?php }
  5045. function MakeFooter(&$p){ global $INDEXPHP;
  5046. $is_slides=(isset($p['slides']) || (isset($p['tid'])&&isset($p['tid']['slides']))); $no_title=isset($p['tid']['first']['no_title']);?>
  5047. <div class='small_footer'><div>
  5048. <hr />
  5049. <?php if(isset($p['tid']['footer'])){ ?><div class='show_on_print'><?=$p['tid']['footer'];?></div><?php } ?>
  5050. <b<?=$no_title?" class='hidden_on_print'":"";?>><?=$this->T($this->Title)?></b>
  5051. <span onclick='event.stopPropagation()'<?=$no_title?" class='hidden_on_print'":"";?>
  5052. ondblclick='javascript:window.location.href="<?=$INDEXPHP?>?settings=true"'>©</span><?=$this->T($this->DisplayName)?>
  5053. <div class='smaller show_on_print'><?=$_SERVER['SERVER_NAME']?><br /><?=$this->EMail?></div>
  5054. </div></div>
  5055. <div class='footer'>
  5056. <div style='white-space:nowrap;'>
  5057. <div class='footer_additional'>
  5058. <?php if(isset($this->SpecialFooter) && ($p = &$this->GetPost($this->SpecialFooter))!=NULL){
  5059. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  5060. } ?>
  5061. </div>
  5062. <div class='footer_additional'>
  5063. <?php if(isset($this->SpecialFooter2) && ($p = &$this->GetPost($this->SpecialFooter2))!=NULL){
  5064. echo $this->GenerateSinglePost($p, false, false, false, false, false);
  5065. } ?>
  5066. </div>
  5067. </div>
  5068. </div>
  5069. <p>&nbsp;<p>
  5070. <div id='dropping_background' style='display:none;' onclick='this.style.display="none";'
  5071. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);">
  5072. <h2 style='width:100%;'><?=$this->T('上传到这里')?></h2>
  5073. </div>
  5074. <?php $this->MakeImageOverlay(); $this->MakePageEnd(); ?>
  5075. <script>
  5076. <?php if($is_slides){ ?>SlidesStart(null);<?php } ?>
  5077. <?=$this->ExtraScripts?>
  5078. if(back = document.getElementById('button_back')){
  5079. if(document.referrer.indexOf(location.protocol + "//" + location.host) == 0){
  5080. back.href='javascript:history.back()';
  5081. }else{
  5082. back.href='<?=$INDEXPHP?>';
  5083. }
  5084. }
  5085. function copy_text(t) {
  5086. ta = document.createElement('textarea'); document.body.appendChild(ta); ta.value = t; ta.select();
  5087. document.execCommand("copy"); document.body.removeChild(ta);
  5088. }
  5089. if(trans = document.getElementById('translate_button')){
  5090. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  5091. }
  5092. function ClickPost(p,e,pushstate){if(e)e.preventDefault();
  5093. id=p.dataset.postId; if(!id)return; list=p.parentNode;active=list.getElementsByClassName('active_post');
  5094. if(active&&active[0]&&active[0]!=p){
  5095. if(pushstate){window.history.pushState('?post='+id,null,'?post='+id);}
  5096. active[0].classList.remove('active_post'); p.classList.add('active_post');
  5097. }
  5098. if(!active[0]){ window.location.href="?post="+id; }
  5099. }function InitLabel(){
  5100. lb=document.querySelector('#mtitle'); lb.removeAttribute('for'); lb.onclick=function()
  5101. {c=document.querySelector('#titlectrl');if(c.checked)c.checked=false;else c.checked=true;}
  5102. lb=document.querySelectorAll('.bkg_section label');if(!lb||!lb[0])return;
  5103. for(i=0;i<lb.length;i++){ lb[i].removeAttribute('for');lb[i].onclick=function()
  5104. {c=this.parentNode.querySelector('.lpctrl');if(!c)return;if(c.checked)c.checked=false;else c.checked=true;} }
  5105. }InitLabel();
  5106. <?php if($this->LoggedIn){ ?>
  5107. var Scenter = document.querySelector('.center');
  5108. var Sposts = Scenter?Scenter.querySelectorAll('.post'):null;
  5109. <?php if(isset($this->MastodonToken)){ ?>
  5110. function MarkPostDoneMastodon(id,mastodon_url){
  5111. for(var i=0;i<Sposts.length;i++){
  5112. if(Sposts[i].dataset.postId==id){ Sposts[i].dataset.mastodon_url= mastodon_url; break;} }
  5113. }
  5114. <?php } ?>
  5115. <?php if($this->PageType=='post' && !isset($this->WayBack)) { ?>
  5116. var Smerge_post_dialog = Scenter.querySelector('#merge_post_dialog');
  5117. var Smerge_post = Scenter.querySelector('#merge_post');
  5118. var Smerge_post_count = Smerge_post_dialog.querySelector('#merge_post_count');
  5119. var Smerge_post_btn = Scenter.querySelector('#merge_post_btn');
  5120. var Smerge_cancel = Scenter.querySelector('#merge_cancel');
  5121. var Smerge_select = Scenter.querySelector('#merge_select');
  5122. var Smerge_thread_dialog = Scenter.querySelector('#merge_thread_dialog');
  5123. var Smerge_thread = Scenter.querySelector('#merge_thread');
  5124. var Smerge_thread_target = Scenter.querySelector('#merge_thread_target');
  5125. var Smerge_thread_btn = Scenter.querySelector('#merge_thread_btn');
  5126. var select_mode = false; var merge_mode = false; var selected_posts = null;
  5127. function TogglePostSelectMode(force_on=false,force_off=false){
  5128. Scenter.classList.add('post_selecting');
  5129. if((!select_mode || force_on) && !force_off){ ToggleThreadMerge(false,true); Scenter.classList.add('post_selecting');
  5130. Smerge_post_dialog.style.display="block";Smerge_post_btn.classList.add('text_highlight');
  5131. Smerge_cancel.innerText='<?=$this->T("取消")?>'; select_mode = 1;}
  5132. else{ select_mode = 0; Scenter.classList.remove('post_selecting');
  5133. Smerge_post_dialog.style.display="none";Smerge_post_btn.classList.remove('text_highlight');
  5134. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  5135. for(var i=0;i<Sposts.length;i++){ Sposts[i].classList.remove('post_selected');
  5136. Sposts[i].onclick=select_mode?function(){TogglePostSelect(this);}:null; }
  5137. Smerge_post_count.innerText="0";
  5138. Smerge_post.href="#";
  5139. }
  5140. function TogglePostSelect(elem){
  5141. if(elem.classList.contains('post_selected')){ elem.classList.remove('post_selected'); }
  5142. else{ elem.classList.add('post_selected'); }
  5143. selected_posts = new Array();
  5144. for(var i=0;i<Sposts.length;i++){ if(Sposts[i].classList.contains('post_selected')){
  5145. selected_posts.push(Sposts[i].dataset.postId); } }
  5146. Smerge_post.href="?merge_posts="+selected_posts.join(" ");
  5147. Smerge_post_count.innerText=selected_posts.length;
  5148. }
  5149. function ThreadMergeInput(elem){
  5150. if(elem.value.match(/[0-9]{14}/)) { Smerge_thread.href="?merge_threads=<?=$this->ActualPostID?> "+elem.value; }
  5151. else{ Smerge_thread.href="#"; }
  5152. }
  5153. function ToggleThreadMerge(force_on=false,force_off=false){
  5154. if((!merge_mode || force_on) && !force_off){ TogglePostSelectMode(false,true);
  5155. Smerge_thread_dialog.style.display="block";Smerge_thread_btn.classList.add('text_highlight');
  5156. Smerge_cancel.innerText='<?=$this->T("取消")?>'; merge_mode = 1;}
  5157. else{ merge_mode = 0;
  5158. Smerge_thread_dialog.style.display="none";Smerge_thread_btn.classList.remove('text_highlight');
  5159. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  5160. Smerge_thread.href="#";
  5161. Smerge_thread_target.value='';
  5162. }
  5163. <?php } ?>
  5164. function ShowSideUploader(){
  5165. ShowRightSide(true,null);
  5166. put = document.querySelector("#_uploader");
  5167. put.style.display='block';
  5168. RefreshSideGallery();
  5169. }
  5170. dmark = document.querySelector("#mark_details");
  5171. drename = document.querySelector("#rename_details");
  5172. dmastodon = document.querySelector("#mastodon_details");
  5173. drename_form = document.querySelector("#post_rename_form");
  5174. drename_input = document.querySelector("#post_rename_name");
  5175. var rp = document.querySelector('#post_reply_to');
  5176. var _reply_to = rp?rp.defaultValue:"";
  5177. function RestoreReply(){
  5178. if(rp){
  5179. rp.defaultValue = _reply_to;
  5180. }
  5181. document.querySelector('#post_reply_restore').style.display='none';
  5182. ht = document.querySelector('#post_hint_text');
  5183. if (_reply_to!=""){
  5184. ht.style.display='block';
  5185. ht.innerHTML="<?=$this->T('继续补充该话题:')?>";
  5186. }else{
  5187. ht.style.display='none';
  5188. }
  5189. document.querySelector('#post_edit_target').value="";
  5190. ch = document.querySelector('#post_hint_modify');
  5191. ch.style.display='none';
  5192. }
  5193. function MakeRefer(id){
  5194. t = document.querySelector('#post_content')
  5195. t.focus();
  5196. v = t.value;
  5197. t.value = v.slice(0, t.selectionStart) + "[<?=$this->T('引用文章')?>]("+id.toString()+")" + v.slice(t.selectionEnd);
  5198. la_auto_grow(t);
  5199. if(rp){
  5200. rp.defaultValue = "";
  5201. ht = document.querySelector('#post_hint_text');
  5202. ht.innerHTML = "<?=$this->T('引用并发送新话题:')?>"; ht.style.display='block';
  5203. document.querySelector('#post_reply_restore').style.display='inline';
  5204. rs = document.querySelector('#post_reply_restore');
  5205. rs.style.display='inline'; rs.innerHTML="<?=$this->T('切换为回复')?>";
  5206. document.getElementById('post_menu').style.display='none';
  5207. ch = document.querySelector('#post_hint_modify');
  5208. ch.style.display='none';
  5209. }
  5210. }
  5211. function CopyRefer(id){
  5212. copy_text(id.toString());
  5213. menu.querySelector('#menu_refer_copy').innerHTML="<?=$this->T('已复制')?>";
  5214. }
  5215. function MakeEdit(id){
  5216. ed = document.getElementById('menu_edit');
  5217. ed.innerHTML="<?=$this->T('稍等')?>";
  5218. ed.href="#";
  5219. var xhr = new XMLHttpRequest();
  5220. xhr.onreadystatechange = function() {
  5221. if (this.readyState == 4 && this.status == 200) {
  5222. ed.innerHTML='——';
  5223. ch = document.querySelector('#post_hint_modify');
  5224. ch.style.display='block';
  5225. ht = document.querySelector('#post_hint_text');
  5226. ht.innerHTML = "<?=$this->T('修改帖子:')?>";
  5227. rs = document.querySelector('#post_reply_restore');
  5228. rs.style.display='inline'; rs.innerHTML="<?=$this->T('取消')?>";
  5229. t = document.querySelector('#post_content');
  5230. t.value=xhr.responseText.trim();
  5231. t.focus();
  5232. la_auto_grow(t);
  5233. document.querySelector('#post_edit_target').value=id;
  5234. document.getElementById('post_menu').style.display='none';
  5235. }
  5236. };
  5237. xhr.open("GET", "<?=$INDEXPHP?>?post="+id.toString()+'&post_original=true', true);
  5238. xhr.send();
  5239. }
  5240. function MarkDelete(id){
  5241. p = document.querySelector('[data-post-id="'+id+'"]');
  5242. op = p.dataset.markDelete?"false":"true";
  5243. window.location.href=
  5244. "<?=$INDEXPHP?>?<?=$this->GetRedirect()?>&mark_delete="+op+'&target='+id.toString();
  5245. }
  5246. function SetMark(mark){
  5247. menu = document.getElementById('post_menu');
  5248. window.location.href=
  5249. "<?=$INDEXPHP?>?<?=$this->GetRedirect()?>&target="+
  5250. menu.parentNode.dataset.postId+"&set_mark="+mark;
  5251. }
  5252. function ToggleMarkDetails(){
  5253. dmark.style.display=(dmark.style.display=='block')?'none':'block';
  5254. drename.style.display=dmastodon.style.display='none';
  5255. }
  5256. function ToggleRenameDetails(){
  5257. drename.style.display=(drename.style.display=='block')?'none':'block';
  5258. dmark.style.display=dmastodon.style.display='none';
  5259. }
  5260. function ToggleMastodonDetails(){
  5261. dmastodon.style.display=(dmastodon.style.display=='block')?'none':'block';
  5262. dmark.style.display=drename.style.display='none';
  5263. }
  5264. <?php } if(isset($_GET['post'])){ ?> ScrollToPost("<?=$_GET['post']?>"); <?php } ?>
  5265. function ShowPostMenu(post){
  5266. menu = document.getElementById('post_menu');
  5267. menu.style.display='block';
  5268. menu.parentNode.removeChild(menu);
  5269. post.appendChild(menu);
  5270. menu.style.display='block';
  5271. id = post.dataset.postId
  5272. menu.querySelector('#_time_hook').innerHTML = ''+id.substring(2,4)+'/'+id.substring(4,6)+'/'+id.substring(6,8)+
  5273. ' '+id.substring(8,10)+':'+id.substring(10,12);
  5274. window.onClick="HidePopMenu()";
  5275. menu.onClick=(function(event){
  5276. event.stopPropagation();
  5277. });
  5278. hs = menu.querySelector('#menu_history');
  5279. hs.href='?post='+id+'&history=1';
  5280. <?php if($this->LoggedIn && !isset($this->WayBack)){ ?>
  5281. <?php if($this->PageType!='search'){?>
  5282. menu.querySelector('#menu_refer').href='javascript:MakeRefer(id)';
  5283. ed = menu.querySelector('#menu_edit');ed.href='javascript:MakeEdit(id)'; ed.innerHTML="<?=$this->T('修改')?>";
  5284. <?php } ?>
  5285. ref = menu.querySelector('#menu_refer_copy')
  5286. ref.innerHTML='<?=$this->T("复制编号")?>';
  5287. ref.href='javascript:CopyRefer(id)';
  5288. d = menu.querySelector('#menu_delete');
  5289. d.href='javascript:MarkDelete(\"'+id+'\")';
  5290. p = document.querySelector('[data-post-id="'+id+'"]');
  5291. d.innerHTML = p.dataset.markDelete?"<?=$this->T('恢复')?>":"<?=$this->T('删除')?>";
  5292. menu.querySelector('#mark_details').dataset.id=id;
  5293. drename_input.value=id;
  5294. drename_form.action="<?=$this->GetRedirect()?>"+"&rename_post="+id;
  5295. <?php if(isset($this->MastodonToken)){ ?>
  5296. dmastodon_form = document.querySelector("#post_mastodon_form");
  5297. dmastodon_form.action='?mastodon_post='+id;
  5298. function MastodonSend(id){
  5299. mastodon_send.innerHTML="<?=$this->T('稍等')?>";
  5300. var xhr = new XMLHttpRequest();
  5301. function wrapidxhr(_id) { return function() {
  5302. if (this.readyState == 4 && this.status == 200) {
  5303. var response = xhr.responseText;
  5304. let content="";
  5305. if(res = response.match(/SUCCESS (\S+)/u)){
  5306. content="<?=$this->T('成功发送到长毛象')?>";
  5307. }else{content="<b><?=$this->T('出现问题')?></b><br /><span class='smaller'>"+response+"</span>";}
  5308. mastodon_send.innerHTML=content; mastodon_send.href=res[1];
  5309. MarkPostDoneMastodon(_id, res[1]);
  5310. } }
  5311. };
  5312. xhr.onreadystatechange = wrapidxhr(id);
  5313. xhr.open("GET", "<?=$INDEXPHP?>?mastodon_send_post="+id, true); xhr.send();
  5314. }
  5315. menu_mastodon = menu.querySelector("#menu_mastodon");
  5316. mastodon_send = menu.querySelector("#menu_mastodon_send");
  5317. mastodon_view = menu.querySelector("#menu_mastodon_view");
  5318. mastodon_url = menu.querySelector("#post_mastodon_url");
  5319. if(p.dataset.mastodon_url){mastodon_view.style.display='inline';mastodon_view.href=p.dataset.mastodon_url;
  5320. mastodon_send.innerHTML='<?=$this->T("重新发送")?>'; mastodon_url.value=p.dataset.mastodon_url; }
  5321. else{mastodon_view.style.display='none';mastodon_view.href=""; mastodon_send.innerHTML="<?=$this->T('发送')?>";
  5322. mastodon_url.value="";}
  5323. mastodon_send.onclick=function(){
  5324. this.onclick=function(){};
  5325. MastodonSend(id); };
  5326. <?php } } ?>
  5327. title = document.title;
  5328. copy = document.getElementById('share_copy');
  5329. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  5330. copy.addEventListener("click", function(){
  5331. url = window.location
  5332. path = location.pathname
  5333. copy_text(url.protocol+"//"+url.host+path+"?post="+id);
  5334. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  5335. });
  5336. }
  5337. function HidePopMenu(){
  5338. var menus = document.querySelectorAll('.pop_menu');
  5339. [].forEach.call(menus, function(m){m.style.display='none';});
  5340. }
  5341. var posts = document.querySelectorAll('.main>.center>tbody>.post'); if(!posts || !posts[0]) posts = document.querySelectorAll('.center_slides .post');
  5342. [].forEach.call(posts, function(p){
  5343. if(s=p.querySelector('._menu_hook')) s.addEventListener("click", function() {
  5344. ShowPostMenu(this.parentNode.parentNode);
  5345. if(document.querySelector('.clickable_section')!=null) ClickPost(this.parentNode.parentNode,null,true)
  5346. });
  5347. p.addEventListener("dblclick", function(){ ClickPost(this,null,true); lp=this.querySelector('.lpctrl'); if(lp){ if(lp.checked)lp.checked=false;else lp.checked=true; }});
  5348. });
  5349. //var post_clickables = document.querySelectorAll('.center .post a');
  5350. //[].forEach.call(post_clickables, function(p){
  5351. // p.addEventListener("click", function(event){
  5352. // event.stopPropagation();
  5353. // });
  5354. //});
  5355. function FindImage(imgsrc){
  5356. for(var i=0;i<document.images_filtered.length;i++){
  5357. if (document.images_filtered[i].dataset.imgsrc==imgsrc) return document.images_filtered[i]
  5358. }
  5359. return null
  5360. }
  5361. var dottime1;
  5362. var dottime2;
  5363. function ToDataURL(url) {
  5364. return fetch(url).then((response) => {return response.blob();}).then(blob => {
  5365. clearTimeout(dottime1);clearTimeout(dottime2);
  5366. ps = document.querySelector('#download_processing');
  5367. ps.innerHTML='↓';ps.style.opacity='';
  5368. return URL.createObjectURL(blob);});
  5369. }
  5370. async function DownloadAsImage(url,name) {
  5371. const a = document.createElement("a"); a.href = await ToDataURL(url); a.download = name;
  5372. document.body.appendChild(a); a.click(); document.body.removeChild(a);
  5373. }
  5374. function basename(url){return url.split(/[\\/]/).pop();}
  5375. pushed=0;
  5376. function ShowBigImage(imgsrc,do_push){
  5377. ShowWaitingBar();
  5378. share = document.querySelector('#big_image_share');
  5379. img = document.querySelector('#big_image');
  5380. vid = document.querySelector('#big_video');
  5381. vidsrc = document.querySelector('#big_video_src');
  5382. down = document.querySelector('#image_download');
  5383. img.src = ""; vidsrc.src="";
  5384. if(imgsrc.match(/\.mp4$/)){
  5385. vidsrc.src = src = "images/"+imgsrc; img.style.display='none'; vid.load();vid.style.display='block';
  5386. }else{
  5387. img.src = src = "images/"+imgsrc; vid.style.display='none';img.style.display='block';
  5388. }
  5389. down.href="images/"+imgsrc;
  5390. var downname='<?=$this->T($this->Title);?>_<?=$this->T($this->DisplayName);?>_<?=$this->GiveSafeEMail()?>_'+
  5391. basename(down.href);
  5392. img.alt = downname; down.download=downname;
  5393. var use_href = "images/"+imgsrc;
  5394. down.onclick=function(event){event.stopPropagation();event.preventDefault();
  5395. ps = this.querySelector('#download_processing');ps.innerText='…';
  5396. var dotwait = function(ps){ var self = this;
  5397. dottime1 = setTimeout(function(ps){
  5398. ps.style.opacity='0'; dottime2 = setTimeout(function(ps){ps.style.opacity='1'; dotwait(ps);},300,ps); },300,ps) }
  5399. dotwait(this.querySelector('#download_processing'));
  5400. DownloadAsImage(use_href,downname);};
  5401. if(do_push){PushGalleryHistory(src)}
  5402. page_url = encodeURIComponent(window.location.href);
  5403. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  5404. inqb = document.querySelector('#image_inquiry');
  5405. inqb.href="mailto:<?=$this->T($this->DisplayName);?>\<<?=$this->EMail?>\>?subject=<?=$this->T('网站图片咨询');?>&body="+
  5406. encodeURIComponent("<?=$this->T('你好!我对你网站上的这张图片感兴趣:')?>"+'\n\n')+
  5407. (page_url)+encodeURIComponent('\n\n');
  5408. <?php } ?>
  5409. this_image = FindImage(imgsrc);
  5410. if(this_image&&this_image.dataset.prevsrc){
  5411. new_image = FindImage(this_image.dataset.prevsrc);
  5412. new_prev = new_image?new_image.dataset.prevsrc:null;
  5413. im = document.querySelector('#prev_image');
  5414. if(new_prev) {im.href='javascript:ShowBigImage("'+this_image.dataset.prevsrc+'",'+do_push+')';im.style.opacity='';}
  5415. else {im.style.opacity='0';im.removeAttribute("href");}
  5416. }
  5417. if(this_image&&this_image.dataset.nextsrc){
  5418. new_image = FindImage(this_image.dataset.nextsrc);
  5419. new_next = new_image?new_image.dataset.nextsrc:null;
  5420. im = document.querySelector('#next_image');
  5421. if(new_next) {im.href='javascript:ShowBigImage("'+this_image.dataset.nextsrc+'",'+do_push+')';im.style.opacity='';}
  5422. else {im.style.opacity='0';im.removeAttribute("href");}
  5423. }
  5424. purchase = document.querySelector('#image_purchase');
  5425. purchase_btn = document.querySelector('#image_purchase_button');
  5426. <?php if($this->LoggedIn){ ?>
  5427. product_link = document.querySelector('#image_ops_product_link');
  5428. product_form = document.querySelector('#image_ops_form');
  5429. edit_form = document.querySelector('#image_edit_form');
  5430. edit_new_name = document.querySelector('#image_edit_new_name');
  5431. edit_parent = document.querySelector('#image_parent');
  5432. edit_align = document.querySelector('#image_align');
  5433. product_form.action = window.location.href;
  5434. edit_form.action = window.location.href;
  5435. edit_new_name.value = imgsrc.split('.')[0];
  5436. if(this_image){
  5437. if(this_image.dataset.product){ product_link.value = this_image.dataset.product; }else{ product_link.value = ""; }
  5438. if(this_image.dataset.parent){ edit_parent.value = this_image.dataset.parent; }else{ edit_parent.value = ""; }
  5439. if(this_image.dataset.align){ edit_align.value = this_image.dataset.align; }else{ edit_align.value = "middle"; }
  5440. }
  5441. <?php } ?>
  5442. if(this_image&&this_image.dataset.product){
  5443. purchase.style.display='';
  5444. href = this_image.dataset.product;
  5445. if(this_image.dataset.product.match('^[0-9]{14}$')){
  5446. href = '?post='+href;
  5447. }
  5448. purchase_btn.href = href;
  5449. }else{
  5450. purchase.style.display='none';
  5451. purchase_btn.removeAttribute("href");
  5452. }
  5453. DelayHideImgBtn(null);
  5454. title = encodeURIComponent(document.title);
  5455. copy = document.getElementById('big_share_copy');
  5456. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  5457. copy.addEventListener("click", function(){
  5458. copy_text(window.location.href);
  5459. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  5460. });
  5461. o = document.querySelector('#big_image_overlay');
  5462. info = document.querySelector('#big_image_info');info.innerHTML="<?=$this->T('正在查询……')?>";
  5463. here = document.querySelector('#here_buttons');here.innerHTML='';
  5464. o.style.display="block";
  5465. ShowBackdrop(0.8);
  5466. var xhr = new XMLHttpRequest();
  5467. xhr.onreadystatechange = function() {
  5468. if (this.readyState == 4 && this.status == 200) {
  5469. info = document.querySelector('#big_image_info');
  5470. var response = xhr.responseText;
  5471. let content=""
  5472. if(res = response.match(/<ref>(.*)<\/ref>/u)){
  5473. content="<span class='small'><?=$this->T('该图片出现在')?> "+res[1]+" <?=$this->T('个帖子中')?></span>"+content;
  5474. }else{content="<span class='smaller gray'><?=$this->T('该图片未被引用')?></span>"+content;}
  5475. if(res = response.match(/<insert>([\s\S]*)<\/insert>/u)){ content+=res[1]; }
  5476. info.innerHTML=content;
  5477. if(res = response.match(/<here>([\s\S]*)<\/here>/u)){
  5478. here.innerHTML=res[1]; window.here_b=document.getElementsByClassName('here_btn');
  5479. if(window.here_b)for(b=0;b<window.here_b.length;b++) {
  5480. window.here_b[b].addEventListener('mousemove',DontHideImgBtn);
  5481. window.here_b[b].addEventListener('mouseover',DontHideImgBtn);}
  5482. }
  5483. }
  5484. };
  5485. xhr.open("GET", "<?=$INDEXPHP?>?image_info="+imgsrc+"", true);
  5486. xhr.send();
  5487. }
  5488. function HideBigImage(do_push){
  5489. o = document.querySelector('#big_image_overlay');
  5490. img = document.querySelector('#big_image');
  5491. vid = document.querySelector('#big_video');
  5492. vidsrc = document.querySelector('#big_video_src');
  5493. img.src = ""; vidsrc.src="";
  5494. if(o.style.display!='none'){
  5495. o.style.display="none";
  5496. HideBackdrop();
  5497. if(do_push){PushGalleryHistory("");}
  5498. HideWaitingBar();
  5499. }
  5500. }
  5501. var lbtn=document.querySelector('#prev_image'),rbtn=document.querySelector('#next_image');
  5502. var inq=document.querySelector('#inquiry_buttons');
  5503. var overlay=document.querySelector('#big_image_overlay');
  5504. var hide_timeout;
  5505. function DontHideImgBtn(e){ clearTimeout(hide_timeout); e.stopPropagation(); }
  5506. function DelayHideImgBtn(e){
  5507. lbtn.classList.remove('img_btn_hidden'); rbtn.classList.remove('img_btn_hidden');
  5508. inq.classList.remove('img_btn_hidden');
  5509. if(window.here_b)for(b=0;b<window.here_b.length;b++){window.here_b[b].classList.remove('img_btn_hidden');}
  5510. clearTimeout(hide_timeout);
  5511. hide_timeout = setTimeout(function(e1,e2,e3,e4){e1.classList.add('img_btn_hidden');
  5512. e2.classList.add('img_btn_hidden');e3.classList.add('img_btn_hidden');
  5513. if(window.here_b)for(b=0;b<window.here_b.length;b++){
  5514. window.here_b[b].classList.add('img_btn_hidden');}}, 1000, lbtn, rbtn, inq);
  5515. }
  5516. lbtn.addEventListener('mousemove',DontHideImgBtn);lbtn.addEventListener('mouseover',DontHideImgBtn);
  5517. rbtn.addEventListener('mousemove',DontHideImgBtn);rbtn.addEventListener('mouseover',DontHideImgBtn);
  5518. inq.addEventListener('mousemove',DontHideImgBtn);inq.addEventListener('mouseover',DontHideImgBtn);
  5519. overlay.addEventListener('mousemove',DelayHideImgBtn);
  5520. function UpdateImageClickables(){
  5521. var images = document.querySelectorAll('.center img, .center video, .center_wide img, .center_wide video');
  5522. var images_filtered=new Array(); var imgadded = new Array();
  5523. var images_remaining=new Array();
  5524. [].forEach.call(images, function(img){
  5525. if(img.classList.contains("no_pop") || (!(imgsrc = img.dataset.imgsrc))) return;
  5526. if(imgadded.indexOf(imgsrc)>=0) {images_remaining.push(img); return;}
  5527. images_filtered.push(img);imgadded.push(imgsrc);
  5528. });
  5529. for(var i=0; i<images_filtered.length; i++){
  5530. previmg = nextimg = null; img = images_filtered[i];
  5531. if(i>0) previmg=images_filtered[i-1];
  5532. if(i<images_filtered.length-1) nextimg=images_filtered[i+1];
  5533. prevsrc=previmg?previmg.dataset.imgsrc:null; nextsrc=nextimg?nextimg.dataset.imgsrc:null;
  5534. img.dataset.prevsrc = prevsrc; img.dataset.nextsrc = nextsrc;
  5535. function wrap(imgsrc){return function(event){ShowBigImage(imgsrc, 1);}}
  5536. var clone = img.cloneNode(true); img.replaceWith(clone);
  5537. clone.addEventListener("click", wrap(img.dataset.imgsrc));
  5538. }
  5539. for(var i=0; i<images_remaining.length; i++){
  5540. img = images_remaining[i];
  5541. function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
  5542. var clone = img.cloneNode(true); img.replaceWith(clone);
  5543. clone.addEventListener("click", wrap(img.dataset.imgsrc));
  5544. }
  5545. document.images_filtered = images_filtered;
  5546. }
  5547. UpdateImageClickables();
  5548. function PopGalleryHistory(){
  5549. if(pushed){
  5550. pushed = 0;
  5551. try{
  5552. history.back();
  5553. }catch{
  5554. console.log("can't do it.");
  5555. }
  5556. }
  5557. }
  5558. function PushGalleryHistory(src){
  5559. abs_img = window.location.protocol+"//"+window.location.host+'/'+src
  5560. title = "照片"
  5561. extra = "?";
  5562. sp = new URLSearchParams(window.location.search)
  5563. if(sp.has('post')){extra+="post="+sp.get('post')}
  5564. if(sp.has('gallery')){extra+="&gallery="+sp.get('gallery')}
  5565. try{
  5566. window.history.pushState('&pic='+src, 'Title', extra+'&pic='+src);
  5567. }catch{
  5568. console.log("can't do it.");
  5569. }
  5570. pushed = 1;
  5571. }
  5572. document.addEventListener('keydown', function(e){
  5573. large = document.getElementById('big_image_overlay')
  5574. if (large.style.display!='block') return;
  5575. if(e.key=='Escape'||e.key=='Esc'||e.keyCode==27){
  5576. HideBigImage(1);
  5577. }
  5578. }, true);
  5579. window.addEventListener('popstate', (event) => {
  5580. href=window.location.href;
  5581. let sp = new URLSearchParams(href.substring(href.indexOf('?')))
  5582. if(sp.has('pic')){
  5583. src = sp.get('pic')
  5584. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)) ShowBigImage(onlyimg[0], 0);
  5585. else{HideBigImage(0);}
  5586. }else{HideBigImage(0);}
  5587. if(sp.has('post')){
  5588. id=sp.get('post');post=document.querySelector('.post[data-post-id="'+id+'"]');
  5589. if(post){ClickPost(post,null,false);}
  5590. }
  5591. });
  5592. let searchParams = new URLSearchParams(window.location.search)
  5593. if(searchParams.has('pic')){
  5594. src = searchParams.get('pic')
  5595. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif|mp4)/u)){
  5596. ShowBigImage(onlyimg[0], 1);
  5597. }
  5598. }
  5599. function _dropHandler(event){ if (typeof dropHandler === "function") dropHandler(event); }
  5600. function _dragOverHandler(event){ if (typeof dragOverHandler === "function") dragOverHandler(event); }
  5601. </script>
  5602. </body>
  5603. <?php
  5604. }
  5605. function DoIdentifyExperimental(){
  5606. if(isset($this->ExpHost) && $this->ExpHost && preg_match('/'.preg_quote($this->ExpHost).'/u', $_SERVER['HTTP_HOST'])){
  5607. $this->InExperimentalMode=True; $this->InHereMode=True;
  5608. if(!$this->AllowLanguageChoices){ $this->LanguageAppendix='en'; }
  5609. }
  5610. if(isset($this->HereHost) && $this->HereHost && preg_match('/'.preg_quote($this->HereHost).'/u', $_SERVER['HTTP_HOST'])){
  5611. $this->InHereMode=True;
  5612. }
  5613. //$this->InHereMode=True;
  5614. }
  5615. function DoExperimentalTopLink($p){
  5616. if($this->InHereMode && $p){
  5617. if(isset($p['tid']) && $p['tid']['first']!=$p){
  5618. header('Location: ?post='.$p['tid']['first']['id']); exit();
  5619. }
  5620. }
  5621. }
  5622. function MakeExperimentalConfirm(){ global $INDEXPHP;
  5623. if(isset($_COOKIE['la_experimental']) && $_COOKIE['la_experimental'] == 'confirmed'){
  5624. return false;
  5625. }
  5626. $caution_html =
  5627. $confirm = "<a class='text_highlight clean_a bold' href='".$INDEXPHP."?confirm_enter=1".
  5628. (isset($this->CurrentPostID)?("&post=".$this->CurrentPostID):"").
  5629. "'>&nbsp;&nbsp;".$this->T('继续')."&nbsp;&nbsp;</a>";
  5630. ?>
  5631. <div class='center_exp'><?php
  5632. if(isset($this->ExpCaution) && ($p=$this->GetPost($this->ExpCaution,true)))$this->MakeSinglePostExp($p);
  5633. else echo "<li class='post post_dummy'>".$this->TranslatePostParts("<h1>注意</h1><p>您将进入实验站。</p>")."</li>";
  5634. ?></div>
  5635. <div class='center_exp'><li class='post post_dummy'><p><?=$confirm?></p></li></div>
  5636. <?php return true;
  5637. }
  5638. }
  5639. $la = new LA;
  5640. $la->DoSiteRedirect();
  5641. $la->DoLogin();
  5642. $la->SwitchLanguageAndFont();
  5643. $err = $la->ProcessRequest($message, $redirect);
  5644. $la->WriteAsNecessary();
  5645. $la->DoIdentifyExperimental();
  5646. $la->SwitchWayBackMode();
  5647. if($err){
  5648. echo $message;
  5649. exit();
  5650. }
  5651. if(isset($redirect)){
  5652. header('Location: '.$redirect);
  5653. exit();
  5654. }
  5655. $la->DetectPageType();
  5656. $la->ReadImages(false);
  5657. $la->ReadPosts();
  5658. if(isset($la->WayBack)){
  5659. $la->ReadArchive();
  5660. }
  5661. $im = NULL;
  5662. if(isset($la->HereID) && preg_match('/images\/(.*)/u',$la->HereID,$imname) && ($im = &$la->FindImage($imname[1]))){
  5663. if(!$la->CanShowImage($im)) { $im=&$la->NULL_IMAGE; }
  5664. }
  5665. $p = &$la->GetPost($la->CurrentPostID);
  5666. if(!isset($p)){
  5667. $p = &$la->GetMergedPost($la->CurrentPostID);
  5668. }
  5669. if(isset($p) && !$la->CanShowPost($p)) $p=NULL;
  5670. else{ $la->DoExperimentalTopLink($p); }
  5671. if(isset($p)){ $la->ActualPostID = $p['id']; }
  5672. if($la->PageType=='here' ||$la->PageType=='experimental'){
  5673. if($im){
  5674. $la->SetHereMainImage($im);
  5675. $la->RecordVisitedHere($im['name'],$im?$la->ImageTitle($im):NULL);
  5676. }else if($p){
  5677. $la->RecordVisitedHere($p['id'],NULL);
  5678. }else {
  5679. $im = &$la->GiveImageInHere(false);
  5680. if($im){
  5681. $la->SetHereMainImage($im);
  5682. $la->RecordVisitedHere($im['name'],$la->ImageTitle($im));
  5683. }
  5684. }
  5685. }
  5686. $la->MakeHeader($p);
  5687. $la->MakeMainBegin();
  5688. if($la->PageType=='here' ||$la->PageType=='experimental'){
  5689. if(($la->PageType=='experimental' && (!$la->MakeExperimentalConfirm())) || $la->PageType=='here'){
  5690. if($im){
  5691. $la->MakeHereSection($im);
  5692. }else if($p){
  5693. $la->MakePostSectionExp($p);
  5694. $la->MakeLinkedPostsExp($p);
  5695. }else {
  5696. if($im){
  5697. $la->MakeHereSection($im);
  5698. }else{
  5699. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5700. "</p><p><a href='".$INDEXPHP."'>".$la->T('返回首页')."</a></p><br />";
  5701. }
  5702. }
  5703. }
  5704. $la->MakeMainEnd();
  5705. $la->MakeExpFooter();
  5706. }else{
  5707. if($la->PageType=='extras'){
  5708. $la->MakeExtraOperations();
  5709. }else if($la->PageType=='settings'){
  5710. $la->MakeSettings();
  5711. }else if($la->PageType=='gallery'){
  5712. $la->MakeGalleryLeft();
  5713. $la->MakeGallerySection();
  5714. }else if($la->PageType=='post'){
  5715. if($p){
  5716. $made_interesting = false;
  5717. if($la->IsInterestingPost($p)){
  5718. $la->MakeInterestingSection($p['tid']);
  5719. }
  5720. else{
  5721. $la->MakeSidebar();
  5722. $la->MakePostSectionV2($p);
  5723. echo $la->GeneratePage(1," section");
  5724. //$la->MakePostSection($p);
  5725. }
  5726. }else{
  5727. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  5728. "</p><p><a href='".$INDEXPHP."'>".$la->T('返回首页')."</a></p><br />";
  5729. }
  5730. }else if($la->PageType=='history'){
  5731. $la->ReadArchive();
  5732. $la->MakePostHistory($p, $_GET['version']??NULL);
  5733. }else if($la->PageType=='search'){
  5734. $la->MakeSidebar();
  5735. $la->MakeRecentPostsV2($_GET['search']);
  5736. echo $la->GeneratePage();
  5737. }else if($la->PageType=='category'){
  5738. $la->MakeSidebar();
  5739. $la->MakeRecentPostsV2(NULL,$_GET['category']);
  5740. echo $la->GeneratePage();
  5741. }else if($la->PageType=='comments'){
  5742. $la->MakeCommentPosts();
  5743. }else if($la->PageType=='statistics'){
  5744. $la->MakeStatistics();
  5745. }else{
  5746. $la->MakeSidebar();
  5747. $la->MakeRecentPostsV2();
  5748. echo $la->GeneratePage();
  5749. }
  5750. $la->MakeMainEnd();
  5751. $la->MakeFooter($p);
  5752. }
  5753. ?>