*/}}

index.php 241 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446
  1. <?php
  2. include 'Parsedown.php';
  3. include 'ParsedownExtra.php';
  4. ini_set('display_errors', '1');
  5. ini_set('display_startup_errors', '1');
  6. error_reporting(E_ALL);
  7. class LA{
  8. protected $PDE;
  9. protected $style;
  10. /* config */
  11. protected $Title;
  12. protected $ShortTitle;
  13. protected $Admin;
  14. protected $Password;
  15. protected $DisplayName;
  16. protected $EMail;
  17. protected $SpecialNavigation;
  18. protected $SpecialFooter;
  19. protected $SpecialFooter2;
  20. protected $SpecialPinned;
  21. protected $DefaultGallery;
  22. protected $ExpHost;
  23. protected $ExpTitle;
  24. protected $ExpShortTitle;
  25. protected $ExpCaution;
  26. protected $ExpIndex;
  27. protected $ExpNavigation;
  28. protected $ExpFooter;
  29. protected $CommentEnabled;
  30. protected $Redirect;
  31. protected $Translations;
  32. protected $CustomTranslationContent;
  33. protected $CurrentOffset;
  34. protected $PostsPerPage;
  35. protected $HotPostCount;
  36. protected $LoggedIn;
  37. protected $LoginTokens;
  38. protected $InExperimentalMode;
  39. protected $LanguageAppendix;
  40. protected $Posts;
  41. protected $Threads; // [ keys: first last displayed count]
  42. protected $WaybackThreads;
  43. protected $Images;
  44. protected $Galleries;
  45. protected $Anchors;
  46. protected $ArchiveHandles;
  47. protected $Archive;
  48. public $WayBack;
  49. protected $YearBegin;
  50. protected $YearEnd;
  51. protected $Markers;
  52. protected $ExtraScripts;
  53. protected $TIME_STRING;
  54. protected $NULL_POST;
  55. protected $NULL_IMAGE;
  56. protected $NULL_Gallery;
  57. protected $DoneReadPosts;
  58. protected $DoneReadImages;
  59. protected $DoneReadArchive;
  60. protected $NeedWritePosts;
  61. protected $NeedWriteImages;
  62. protected $NeedWriteArchive;
  63. public $PageType;
  64. public $CurrentPostID;
  65. public $ActualPostID;
  66. public $TagID;
  67. function ReadableTime($id){
  68. $dt = DateTime::createFromFormat('YmdHis', $id);
  69. return $dt->format('Y/m/d H:i:s');
  70. }
  71. function FullURL(){
  72. return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?
  73. "https" : "http") . "://" . $_SERVER['HTTP_HOST'] .
  74. $_SERVER['REQUEST_URI'];
  75. }
  76. function T($str){
  77. if(!$this->LanguageAppendix) return $str;
  78. foreach($this->Translations as $entry){
  79. if($entry['zh']==$str)
  80. return $entry[$this->LanguageAppendix];
  81. }
  82. return $str;
  83. }
  84. function SwitchLanguage(){
  85. if(isset($_COOKIE['la_language'])){
  86. $this->LanguageAppendix = $_COOKIE['la_language'];
  87. }else{
  88. if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
  89. $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  90. $lang = substr($lang,0,5);
  91. if(preg_match("/zh/i",$lang))$this->LanguageAppendix = 'zh';
  92. else $this->LanguageAppendix = 'en';
  93. }
  94. }
  95. }
  96. function SwitchWayBackMode(){
  97. if(isset($_COOKIE['la_wayback'])){
  98. $this->WayBack = $_COOKIE['la_wayback'];
  99. }else $this->WayBack = NULL;
  100. }
  101. function DisplayRedirectConfig(){
  102. $s = "";
  103. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  104. if($r['for']=='P'){
  105. $s.=("P ".$r['format'].":".$r['target'].";".PHP_EOL);
  106. }else if($r['for']=='S'){
  107. $s.=("S ".$r['format'].":".$r['domain'].":".$r['target'].";".PHP_EOL);
  108. }
  109. }
  110. return $s;
  111. }
  112. function DoSiteRedirect(){
  113. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  114. if($r['for']=='S'){
  115. if(preg_match('/'.$r['format'].'/ui', $_SERVER['HTTP_HOST'])){
  116. if($_SERVER['REQUEST_URI']=='/'||$_SERVER['REQUEST_URI']==''){
  117. header('Location:https://'.$r['domain'].'/index.php?post='.$r['target']); exit;
  118. }else{
  119. header('Location:https://'.$r['domain'].$_SERVER['REQUEST_URI']); exit;
  120. }
  121. }
  122. }
  123. }
  124. }
  125. function WriteHTACCESS(){
  126. $conf = fopen('.htaccess','w');
  127. fwrite($conf,"RewriteEngine on".PHP_EOL.PHP_EOL);
  128. if(isset($this->Redirect) && isset($this->Redirect[0])) foreach($this->Redirect as $r){
  129. if($r['for']=='P'){
  130. fwrite($conf,"RewriteRule ^".$r['format'].'$ /index.php?post='.$r['target'].' [R=302,L]'.PHP_EOL.PHP_EOL);
  131. }// do site redirect in php.
  132. }
  133. fwrite($conf, 'RewriteCond %{HTTPS} !=on'.PHP_EOL.
  134. 'RewriteCond %{HTTP_HOST} !=localhost'.PHP_EOL.
  135. 'RewriteCond %{REQUEST_URI} !^.*(jpg|png|gif)$'.PHP_EOL.
  136. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]'.PHP_EOL.PHP_EOL);
  137. fwrite($conf, 'RewriteCond %{HTTP_HOST} !^www\.'.PHP_EOL.
  138. 'RewriteCond %{HTTP_HOST} !=localhost'.PHP_EOL.
  139. 'RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]'.PHP_EOL.PHP_EOL);
  140. fwrite($conf,'<Files ~ "\.md$">'.PHP_EOL.'deny from all'.PHP_EOL.'</Files>'.PHP_EOL);
  141. fflush($conf);fclose($conf);
  142. }
  143. function BuildRedirectConfig($conf){
  144. $this->Redirect=[];
  145. if(preg_match_all('/P\s+(.*)\:\s*([0-9]{14})\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  146. foreach($ma as $m){
  147. $redirect=[]; $redirect['for'] = 'P'; $redirect['format'] = $m[1]; $redirect['target'] = $m[2];
  148. $this->Redirect[]=$redirect;
  149. }
  150. }
  151. if(preg_match_all('/S\s+(\S+)\s*\:\s*(\S+)\s*\:\s*([0-9]{14})\s*;/u',$conf,$ma,PREG_SET_ORDER)){
  152. foreach($ma as $m){
  153. $redirect=[]; $redirect['for'] = 'S'; $redirect['format'] = $m[1]; $redirect['domain'] = $m[2]; $redirect['target'] = $m[3];
  154. $this->Redirect[]=$redirect;
  155. }
  156. }
  157. }
  158. function WriteTokens(){
  159. $tf = fopen('la_tokens.md','w');
  160. if(isset($this->LoginTokens) && sizeof($this->LoginTokens)) {
  161. foreach($this->LoginTokens as $t){
  162. fwrite($tf,'- '.$t.PHP_EOL);
  163. }
  164. }
  165. fflush($tf);fclose($tf);
  166. }
  167. function WriteConfig(){
  168. if(!isset($this->Title)) $this->Title = $this->T('那么的维基');
  169. if(!isset($this->ShortTitle)) $this->ShortTitle = $this->T('基');
  170. if(!isset($this->Admin)) $this->Admin = 'admin';
  171. if(!isset($this->DisplayName)) $this->DisplayName = $this->T('管理员');
  172. if(!isset($this->Password)) $this->Password = password_hash('Admin', PASSWORD_DEFAULT).PHP_EOL;
  173. $conf = fopen('la_config.md','w');
  174. fwrite($conf,'- Title = '.$this->Title.PHP_EOL);
  175. fwrite($conf,'- ShortTitle = '.$this->ShortTitle.PHP_EOL);
  176. fwrite($conf,'- Admin = '.$this->Admin.PHP_EOL);
  177. fwrite($conf,'- DisplayName = '.$this->DisplayName.PHP_EOL);
  178. fwrite($conf,'- Password = '.$this->Password.PHP_EOL);
  179. fwrite($conf,'- EMail = '.$this->EMail.PHP_EOL);
  180. fwrite($conf,'- SpecialNavigation = '.$this->SpecialNavigation.PHP_EOL);
  181. fwrite($conf,'- SpecialFooter = '.$this->SpecialFooter.PHP_EOL);
  182. fwrite($conf,'- SpecialFooter2 = '.$this->SpecialFooter2.PHP_EOL);
  183. fwrite($conf,'- SpecialPinned = '.$this->SpecialPinned.PHP_EOL);
  184. fwrite($conf,'- DefaultGallery = '.$this->DefaultGallery.PHP_EOL);
  185. fwrite($conf,'- CommentEnabled = '.($this->CommentEnabled?"True":"False").PHP_EOL);
  186. fwrite($conf,'- ExpHost = '.$this->ExpHost.PHP_EOL);
  187. fwrite($conf,'- ExpTitle = '.$this->ExpTitle.PHP_EOL);
  188. fwrite($conf,'- ExpShortTitle = '.$this->ExpShortTitle.PHP_EOL);
  189. fwrite($conf,'- ExpCaution = '.$this->ExpCaution.PHP_EOL);
  190. fwrite($conf,'- ExpIndex = '.$this->ExpIndex.PHP_EOL);
  191. fwrite($conf,'- ExpNavigation = '.$this->ExpNavigation.PHP_EOL);
  192. fwrite($conf,'- ExpFooter = '.$this->ExpFooter.PHP_EOL);
  193. fflush($conf);fclose($conf);
  194. $conf = fopen('la_redirect.md','w');
  195. fwrite($conf,$this->DisplayRedirectConfig());fflush($conf);fclose($conf);
  196. $this->WriteHTACCESS();
  197. $this->WriteTokens();
  198. }
  199. function Install(){
  200. if(!file_exists('la_config.md')){
  201. $this->WriteConfig();
  202. }
  203. if(!is_dir('posts')) mkdir('posts');
  204. if(!is_dir('images')) mkdir('images');
  205. if(!is_dir('images/thumb')) mkdir('images/thumb');
  206. if(!is_dir('styles')) mkdir('styles');
  207. if(!is_dir('archive')) mkdir('archive');
  208. $this->WriteStyles();
  209. $this->WriteHTACCESS();
  210. }
  211. function ReadConfig(){
  212. if(!file_exists('la_config.md')){
  213. $this->Install();
  214. }
  215. $c = file_get_contents('la_config.md');
  216. if(preg_match('/-\s*Title\s*=\s*(\S+)\s*$/um', $c, $m)) $this->Title = $m[1]; else $this->Title=$this->T("那么的维基");
  217. if(preg_match('/-\s*ShortTitle\s*=\s*(\S+)\s*$/um', $c, $m)) $this->ShortTitle = $m[1]; else $this->ShortTitle=$this->T("基");
  218. if(preg_match('/-\s*Admin\s*=\s*(\S+)\s*$/um', $c, $m)) $this->Admin = $m[1];
  219. if(preg_match('/-\s*Password\s*=\s*(\S+)\s*$/um', $c, $m)) $this->Password = $m[1];
  220. if(preg_match('/-\s*DisplayName\s*=\s*(\S+)\s*$/um', $c, $m)) $this->DisplayName = $m[1];
  221. if(preg_match('/-\s*EMail\s*=\s*(\S+)\s*$/um', $c, $m)) $this->EMail = $m[1];
  222. if(preg_match('/-\s*SpecialNavigation\s*=\s*(\S+)\s*$/um', $c, $m)) $this->SpecialNavigation = $m[1];
  223. if(preg_match('/-\s*SpecialFooter\s*=\s*(\S+)\s*$/um', $c, $m)) $this->SpecialFooter = $m[1];
  224. if(preg_match('/-\s*SpecialFooter2\s*=\s*(\S+)\s*$/um', $c, $m)) $this->SpecialFooter2 = $m[1];
  225. if(preg_match('/-\s*SpecialPinned\s*=\s*(\S+)\s*$/um', $c, $m)) $this->SpecialPinned = $m[1];
  226. if(preg_match('/-\s*DefaultGallery\s*=\s*(\S+)\s*$/um', $c, $m)) $this->DefaultGallery = $m[1];
  227. if(preg_match('/-\s*CommentEnabled\s*=\s*(\S+)\s*$/um', $c, $m)) $this->CommentEnabled = ($m[1]=="True");
  228. if(preg_match('/-\s*ExpHost\s*=\s*(\S+)\s*$/um', $c, $m)) $this->ExpHost = $m[1];
  229. if(preg_match('/-\s*ExpTitle\s*=\s*(\S+)\s*$/um', $c, $m)) $this->ExpTitle = $m[1]; else $this->ExpTitle=$this->T("实验访问");
  230. if(preg_match('/-\s*ExpShortTitle\s*=\s*(\S+)\s*$/um', $c, $m)) $this->ExpShortTitle = $m[1]; else
  231. $this->ExpShortTitle = $this->ExpTitle;
  232. if(preg_match('/-\s*ExpCaution\s*=\s*(\S+)\s*$/um', $c, $m)) $this->ExpCaution = $m[1];
  233. if(preg_match('/-\s*ExpIndex\s*=\s*(\S+)\s*$/um', $c, $m)) $this->ExpIndex = $m[1];
  234. if(preg_match('/-\s*ExpNavigation\s*=\s*(\S+)\s*$/um', $c, $m)) $this->ExpNavigation = $m[1];
  235. if(preg_match('/-\s*ExpFooter\s*=\s*(\S+)\s*$/um', $c, $m)) $this->ExpFooter = $m[1];
  236. if(file_exists('la_redirect.md')){
  237. $c = file_get_contents('la_redirect.md');
  238. $this->BuildRedirectConfig($c);
  239. }
  240. $this->Translations=[];
  241. if(file_exists("translations.md")){
  242. $c = file_get_contents('translations.md');
  243. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  244. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  245. $this->Translations[] = $entry;
  246. }
  247. }
  248. if(file_exists("custom_translations.md")){
  249. $this->CustomTranslationContent = file_get_contents('custom_translations.md');
  250. if(preg_match_all('/-\s+(\S.*)\s*\|\s*(\S.*)$/um',$this->CustomTranslationContent, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  251. $entry = []; $entry['zh'] = trim($m[1]); $entry['en'] = trim($m[2]);
  252. $this->Translations[] = $entry;
  253. }
  254. }
  255. $this->LoginTokens=[];
  256. if(file_exists('la_tokens.md')){
  257. $c = file_get_contents('la_tokens.md');
  258. if(preg_match_all('/-\s+(\S.*)\s*$/um',$c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  259. $this->LoginTokens[] = $m[1];
  260. }
  261. }
  262. }
  263. function __construct() {
  264. $this->ReadConfig();
  265. $this->PDE = new ParsedownExtra();
  266. $this->PDE->SetInterlinkPath('/');
  267. $this->Posts = [];
  268. $this->Threads = [];
  269. $this->Markers=['●', '○', '✓', '×', '!', 'P', 'E', 'S'];
  270. $this->PostsPerPage = 40;
  271. $this->CommentsPerPage = 100;
  272. $this->HotPostCount = 15;
  273. $this->TIME_STRING = date('YmdHis');
  274. $this->WayBack = NULL;
  275. $this->YearBegin = $this->YearEnd = 2000;
  276. $this->DoneReadPosts = $this->DoneReadImages = $this->DoneReadArchive = false;
  277. $this->NeedWritePosts= $this->NeedWriteImages= $this->NeedWriteArchive= false;
  278. $this->UsePosts = &$this->Posts;
  279. }
  280. function DoLogout(){
  281. $this->LoggedIn = false;
  282. unset($_SESSION['user_id']);
  283. $this->RecordToken(true);
  284. }
  285. function RecordToken($unset_current=false){
  286. if(isset($unset_current) && isset($_COOKIE['la_token'])){
  287. $t = $_COOKIE['la_token'];
  288. setcookie('la_token', null, -1); unset($_COOKIE['la_token']);
  289. if (($key = array_search($t,$this->LoginTokens)) !== false) { unset($this->LoginTokens[$key]); }
  290. $this->WriteTokens();
  291. return null;
  292. }else{
  293. $t = uniqid('la_',true);
  294. setcookie('la_token',$t,time()+3600*24*7); $_COOKIE['la_token'] = $t;
  295. $this->LoginTokens[] = $t;
  296. $this->WriteTokens();
  297. return $t;
  298. }
  299. }
  300. function LoginThroughToken(){
  301. if(!isset($_COOKIE['la_token'])) return false;
  302. $t = $_COOKIE['la_token'];
  303. if (($key = array_search($t,$this->LoginTokens)) !== false) {
  304. $_SESSION['user_id']=$this->Admin;
  305. $this->LoggedIn = true;
  306. setcookie('la_token',$t,time()+3600*24*7);
  307. return true;
  308. }
  309. return false;
  310. }
  311. function DoLogin(){
  312. session_start();
  313. $redirect=false;
  314. if(isset($_GET['logout'])){ $this->DoLogout(); header('Location:index.php'); }
  315. else if(!isset($_SESSION['user_id'])){
  316. if(isset($_POST['login_button'])){
  317. $id = trim($_POST['login_id']);
  318. $pwd = trim($_POST['login_password']);
  319. if(strtolower($this->Admin)==strtolower($id)&&password_verify($pwd, $this->Password)){
  320. $_SESSION['user_id']=$id;
  321. $this->RecordToken(false);
  322. }
  323. $redirect = true;
  324. }else if($this->LoginThroughToken()){
  325. // nothing;
  326. }
  327. }else{
  328. if(strtolower($_SESSION['user_id']) == strtolower($this->Admin)){ $this->LoggedIn = true; }
  329. else{ $this->DoLogout();}
  330. }
  331. if($redirect){
  332. header('Location:index.php'.(isset($_GET['post'])?("?post=".$_GET['post']):"")
  333. .(isset($_GET['settings'])?"?settings=true":""));
  334. }
  335. }
  336. function WriteStyles(){
  337. $this->style="
  338. html{font-size:18px;font-family:'Noto Serif CJK SC','Times New Roman','SimSun', Georgia, serif;}
  339. body{background-color:%white%;color:%black%;}
  340. sup,sub{line-height:0;}
  341. blockquote{border-left:2px solid %black%;padding-left:0.3em;}
  342. *{box-sizing:border-box;padding:0;margin:0;font-weight:normal;}
  343. b,strong,th{font-weight:bold;}
  344. select{font-size:inherit;}
  345. .page,.page_gallery{padding:1em;padding-top:0;}
  346. .hidden_on_desktop,.hidden_on_wide{display:none;}
  347. .hidden_on_desktop_force{display:none !important;}
  348. ::file-selector-button{background:none;border:none;}
  349. a,button,::file-selector-button{text-decoration:underline;color:%black%;}
  350. a:hover,.button:hover,::file-selector-button:hover{text-decoration:none;color:%gray%;}
  351. .button:disabled{background-color:%gray%;pointer-events:none;}
  352. header{position:sticky;top:0;background-color:%white%;z-index:10;padding-top:0.5em;max-height:100vh;overflow:auto;z-index:30;}
  353. .header_nav{display:inline;}
  354. header a,.left a,.footer a,.clean_a,.clean_a a{text-decoration:none;}
  355. header a:hover,.button:hover{color:%gray% !important;}
  356. .footer{background-color:%white%;z-index:10;position:relative;}
  357. .invert_a,.invert_a a{color:%gray%;text-decoration:none;}
  358. .invert_a:hover,.invert_a a:hover{color:%black% !important;}
  359. .gray,.gray a{color:%gray%;}
  360. hr{border:1px solid %gray%;}
  361. header ul{display:inline-block;}
  362. header li{display:inline-block;}
  363. header li::before{content:' - '}
  364. header h1,header h2,header h3,header h4,header h5,header p{display:inline;font-size:1rem;}
  365. .main{position:relative;word-spacing:-1em;}
  366. .main *{word-spacing:initial;}
  367. pre{overflow:auto;max-width:100%;display:block;font-size:0.75em;}
  368. ul{display:block;}
  369. li{display:block;}
  370. table{width:100%;border-collapse:collapse;border-bottom:2px solid %black%;border-top:3px solid %black%;}
  371. table input{border:none!important;}
  372. table img{max-width:10rem !important;}
  373. td{padding-left:0.1em;padding-right:0.1em;}
  374. td:first-child{padding-left:0;}
  375. td:last-child{padding-right:0;}
  376. tbody tr:hover{box-shadow:inset 0 -2px 0 0px %black%;}
  377. thead{box-shadow:inset 0 -1px 0 0px %black%;position:sticky;top:2rem;background-color:%white%;z-index:5;}
  378. .post table{font-size:0.85em;}
  379. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 20em);}
  380. .interesting_tbody td{display:contents;}
  381. .interesting_tbody tr{position:relative;scroll-margin:4.5em}
  382. .interesting_tbody td>*{display:table-cell;}
  383. .interesting_tbody .post_access{padding-top:0;}
  384. .interesting_tbody .post_menu_button{top:0;opacity:0;}
  385. .interesting_tbody td>img,.interesting_tbody td>.imd{position:absolute;left:1.4em;z-index:-1;height:1em;width:20em;
  386. display:block;top:0.2em;object-fit:cover;max-width:calc(100% - 1.4em) !important;overflow:hidden;}
  387. .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);}
  388. .interesting_tbody .p_thumb{height:1em;}
  389. .interesting_tbody .p_thumb img{max-height:10rem !important;max-width:20rem !important;}
  390. tr:hover .post_menu_button{opacity:1;}
  391. .post_current_row{background-color:%graybkg%;mix-blend-mode:screen;text-shadow:0px 0px 0.1em %white%;}
  392. .align_right{text-align:right;}
  393. .left{display:inline-block;vertical-align:top;width:25%;max-height:calc(100vh - 2.6em);top:2em;
  394. position:sticky;overflow:auto;padding-right:0.2em;padding-bottom:4rem;}
  395. .center{display:inline-block;vertical-align:top;width:50%;padding-left:0.3em;overflow:visible;padding-bottom:4rem;}
  396. .center_wide{display:inline-block;vertical-align:top;width:75%;padding-left:0.3em;overflow:visible;padding-bottom:4rem;}
  397. .center_full{display:inline-block;vertical-align:top;width:100%;overflow:visible;padding-bottom:4rem;}
  398. .center_wide .p_thumb{height:10rem;}
  399. .sticky_title{position:sticky;top:1.35em;z-index:1;box-shadow:6em 3.5em 0.75em -3em inset %white%;pointer-events:none;}
  400. .center_exp{display:block;width:80%;margin:0 auto;overflow:visible;padding-bottom:1em;}
  401. .table_top{position:relative;left:calc(-50% - 0.45em);width:calc(200% + 0.6em);background:%white%;z-index:1;
  402. box-shadow:0px 0px 2em 1em %white%;margin-top:2em;margin-bottom:2em;}
  403. .right{display:inline-block;vertical-align:top;width:25%;position:sticky;top:2em;
  404. padding-left:0.5em;max-height:calc(100vh - 2.6em);overflow:auto;padding-bottom:4rem;}
  405. textarea,input[type=text],input[type=password]{width:100%;display:block;font-family:inherit;max-height:60vh;font-size:inherit;}
  406. select,textarea,input[type=text],input[type=password]{background:none;border:none;border-bottom:1px solid %black%;color:%black%;}
  407. .text_highlight input{border-bottom:1px solid %white%;color:%white%;}
  408. .button{background:none;border:none;font-family:inherit;color:%black%;font-size:inherit;font-weight:bold;}
  409. .post{position:relative;scroll-margin:3.5em;border-radius:0.3em;}
  410. .center_exp .post{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;border-radius:0;}
  411. .post_width li,.post_width_big li,.footer_additional li,.footer_additional li,.post_dummy li
  412. {display:list-item;margin-left:1em;list-style:disc;}
  413. .post_width li li,.post_width_big li li,.footer_additional li li,.footer_additional li li,.post_dummy li li{list-style:circle;}
  414. .post_width > *,.post_width_big > *,.post_dummy > *,.post_ref > *{margin:0;margin-bottom:0.5rem}
  415. .post_dummy > *{width:60%;margin:0 auto;margin-bottom:0.5rem}
  416. .post_dummy > p img{display:block;width:100%;margin:0 auto;}
  417. .gallery_left li{display:list-item;margin-left:1em;list-style:none;}
  418. .gallery_left .selected{list-style:'→';}
  419. .focused_post{font-size:1.2em;margin-top:0.1em;margin-bottom:0.1em;padding:0.5rem !important;border:2px dashed #ac7843;}
  420. .post_width{position:relative;left:1.4rem;width:calc(100% - 1.7rem);padding-left:0.2em;overflow:visible;}
  421. .post_width_big{position:relative;left:0;width:100%;overflow:visible;}
  422. .post_menu_button{position:absolute;display:none;right:0rem;width:1.5rem;
  423. text-align:center;border-radius:0.3em;user-select:none;cursor:pointer;z-index:10;}
  424. .pointer{cursor:pointer;}
  425. .post:hover .post_menu_button{display:block;}
  426. .pop_menu{position:absolute;top:0.3rem;z-index:95;background-color:%lighterbkg%;
  427. padding:0.3em;right:0.3rem;text-align:right;border-radius:0.3em;font-size:1rem;
  428. box-shadow:0px 0px 10px rgb(0, 0, 0);}
  429. .pop_menu li{list-style:none;margin-left:0;}
  430. .pop_menu hr{border:2px solid rgba(0,0,0,0.1);}
  431. .toc{left:60%;width:40%;top:0;position:absolute;}
  432. .post_access{width:1.4rem;top:0;position:absolute;height:100%;text-align:center;font-weight:bold;border-right:2px solid transparent;}
  433. .post_access:hover{background-color:%lightopbkg%;border-top-left-radius:0.3em;border-bottom-left-radius:0.3em;
  434. border-right:2px solid %black% !important;}
  435. .paa{width:1.4rem;min-width:1.4rem;}
  436. .opt_compact .post_access,.ref_compact .post_access{border-right:2px solid %gray%;}
  437. .post_box{border:1px solid %gray%;border-radius:0.3em;padding:0.3em;}
  438. .post_box:hover,.post_menu_button:hover{background-color:%lightopbkg%}
  439. #big_image_info .post_box:hover{background-color:%graybkg%;}
  440. .post_preview{font-size:0.9rem;overflow:hidden;margin-bottom:0.2em;}
  441. .post .post_ref{margin:0;padding-left:1.7rem;}
  442. .post_ref_main{display:inline-block;vertical-align:top;}
  443. .post_preview .post_ref_main{max-height:6rem;overflow:hidden;}
  444. .post_ref_images{overflow:hidden;}
  445. .page_selector{padding-top:2rem;text-align:center;}
  446. .smaller{font-size:0.85em;}
  447. .bigger{font-size:1.3em;}
  448. .block{display:block;}
  449. .opt_compact{margin-left:1.6rem;}
  450. .opt_compact .post_width {margin-left:0.3em;width: calc(100% - 1.8rem);}
  451. .post_box_top{padding-bottom:0.3em;padding-top:0.3em;}
  452. .post_box_fixed_bottom{position:sticky;bottom:0em;background-color:%white%;z-index:5;}
  453. .spacer{height:0.5em;}
  454. .pop_right,.pop_right_big{position:fixed;top:0;right:0;bottom:0;width:30%;z-index:100;background-color:%graybkg%;display:none;
  455. transition-timing-function:ease-out;padding:1rem;overflow:auto;}
  456. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  457. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  458. @keyframes pop_slide_in_big{0%{right:-30%;}100%{right:0%;}}
  459. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-30%;}}
  460. .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;}
  461. @keyframes backdrop_fade_in{0%{opacity:0%;}100%{opacity:100%;}}
  462. @keyframes backdrop_fade_out{0%{opacity:100%;}100%{opacity:0%;}}
  463. .toc_entry_1{font-size:1.1em;}
  464. .toc_entry_2{font-size:1.0em;padding-left:0.5rem;}
  465. .toc_entry_3{font-size:0.9em;padding-left:1rem;}
  466. .toc_entry_4{font-size:0.85em;padding-left:1.5rem;}
  467. .toc_entry_5{font-size:0.8em;padding-left:2rem;}
  468. h1,h2,h3,h4,h5{scroll-margin:2.5em;}
  469. .left ul h1,.left ul h2,.left ul h3,.left ul h4,.left ul h5,.left ul p{font-size:1em;}
  470. .deleted_post{color:%gray%;text-decoration:line-through;}
  471. #file_list{margin-top:0.5em;}
  472. .file_thumb img{max-height:100%;max-width:100%;object-fit:cover;min-width:100%;min-height:100%;}
  473. #file_list li{margin-bottom:0.3em;}
  474. .ref_thumb{white-space:nowrap;overflow:hidden;}
  475. .ref_thumb .file_thumb{width:3em;height:3em;}
  476. .side_thumb li{margin:0.4em;display:inline-block;}
  477. .file_thumb{width:4em;height:4em;display:inline-block;line-height:0;vertical-align:middle;overflow:hidden;}
  478. .p_row{display:flex;flex-wrap:wrap;width:calc(100% + 0.25rem);}
  479. .p_thumb{display:flex;flex-grow:1;height:6rem;margin-right:0.25rem;margin-bottom:0.25rem;overflow:hidden;position:relative;}
  480. .p_thumb img{object-fit:cover;max-height:100%;min-width:100%;}.p_thumb a{display:contents;}
  481. .ref_count,.p_thumb .post_menu_button{text-shadow: 0px 0px 10px rgb(0, 0, 0);}
  482. .p_thumb:hover .post_menu_button{display:block;}
  483. .p_thumb_selected{color:%black% !important;}
  484. .p_thumb_selected{display:block;}
  485. .post .p_thumb img{max-height:6rem;}
  486. .big_image_box{position:fixed;top:0;bottom:0;left:0;width:75%;z-index:95;text-align:center;pointer-events:none;}
  487. .big_image_box *{pointer-events:auto;}
  488. .big_image_box img{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;cursor:unset;}
  489. .big_side_box{position:fixed;top:0;bottom:0;right:0;width:25%;overflow:auto;z-index:98;color:%black%;padding:1rem;
  490. background:linear-gradient(to right, rgba(0,0,0,0), rgb(1, 1, 1));transition:background-size .2s linear;background-size: 300% 100%;}
  491. .big_side_box:hover{background-size: 100% 100%;}
  492. .big_side_box a,.big_side_box hr,#dropping_background{color:%black%;}
  493. .big_side_box a:hover{color:%gray%;}
  494. #dropping_background{background-color:rgba(0,0,0,0.4);position:fixed;top:0;right:0;bottom:0;left:0;z-index:100;text-align:center;
  495. box-shadow:0px 0px 500px black inset;display:flex;align-items:center;}
  496. img{cursor:pointer;max-height:100%;max-width:100%;}
  497. .post img{max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  498. .post > a > img{display:block;margin:0.3em auto;}
  499. .post .original_img{max-width:100%;display:inline-block;vertical-align:middle;
  500. margin-left:auto;margin-right:auto;max-width:100%;max-height:90vh;}
  501. .center_exp .post .original_img{display:block;}
  502. .original_img img{max-height:90vh;max-width:100%;}
  503. .p_row .original_img{margin-bottom:0;}
  504. .post_ref .original_img{margin:unset;max-width:unset;max-height:min(70vh, 20rem);max-width:min(100%, 20rem);}
  505. .b ul{font-size:1.4em;}
  506. no_pop{cursor:unset;}
  507. p{min-height:0.8em;}
  508. .bold,.bold *{font-weight:bold;}
  509. .footer_additional{display:inline-block;width:50%;vertical-align:text-top;white-space:normal;}
  510. .small_footer{background-color:%white%;padding-bottom:0.5em;overflow:auto;white-space:nowrap;position:sticky;bottom:0px;}
  511. .top_post_hint{margin-left:1.5em;font-weight:bold;}
  512. .white{color:%white%;}
  513. .full_box{border:1px solid %black% !important;padding:0.3rem;overflow:auto;}
  514. .image_nav_prev,.image_nav_next{z-index:100;position:absolute;line-height:0;height:100%;width:20%;display:flex;align-items:center;
  515. transition:background-size .2s ease;padding:0.5em;text-shadow:0px 0px 5px black;user-select:none;pointer-events:auto;}
  516. .image_nav_prev{left:0;justify-content:left;background:linear-gradient(to left, rgba(0,0,0,0), rgba(0,0,0,0.2));
  517. background-repeat:no-repeat;background-size:0% 100%;}
  518. .image_nav_prev:hover,.image_nav_next:hover{background-size:100% 100%;}
  519. .image_nav_next{right:0;justify-content:right;background:linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.2));
  520. background-repeat:no-repeat;background-size:0% 100%;transition:background-size .2s ease;background-position-x:100%;}
  521. .inquiry_buttons{position:fixed;left:0;right:25%;text-align:center;bottom:1em;margin:0 auto;width:max-content;
  522. background-color:rgba(0,0,0,0.5);z-index:110;padding:0.2em;padding-left:1em;padding-right:1em;
  523. border-radius:1em;box-shadow:0px 0px 5px;text-shadow:0px 0px 5px black;opacity:1;user-select:none;}
  524. .lr_buttons{background-color:rgba(0,0,0,0.5);padding:0.5em;padding-top:1em;padding-bottom:1em;
  525. border-radius:1em;box-shadow:0px 0px 5px;font-size:1.2rem;text-shadow:0px 0px 5px black;}
  526. .img_btn_hidden{opacity:0;transition:opacity 0.2s;}
  527. .special_alipay{background-color:#027aff;color:white;white-space:nowrap;
  528. font-family:sans-serif;font-weight:bold;border-radius:0.7em;font-size:0.75em;padding:0.25em;}
  529. .special_paypal{background-color:white;color:#253b80;white-space:nowrap;
  530. font-family:sans-serif;font-weight:bold;border-radius:2em;font-size:0.75em;
  531. padding:0.25em;padding-left:0.5em;padding-right:0.65em;font-style: italic;}
  532. .special_paypal_inner{color:#169bd7;}
  533. #waiting_bar{position:fixed;z-index:200;top:0;left:0;right:0;height:0.2em;background-color:%black%;transform:translate(-100%,0);
  534. animation:anim_loading 1s linear infinite;}
  535. @keyframes anim_loading{0%{transform:translate(-100%,0);} 100%{transform:translate(100%,0);}}
  536. .product_ref{width:32%;padding:0.2em!important;display:inline-block;text-align:center;vertical-align:top;margin-bottom:0.8em;}
  537. .product_thumb{max-height:11em;max-width:11em;display:inline-flex;margin-bottom:0.2em;background-color:%graybkg%;}
  538. .product_thumb img{box-shadow:none;object-fit:contain;max-height:unset;max-width:unset;width:100%;margin:0 auto !important;}
  539. .product_ref p{margin-bottom:0.2em;text-align:left;}
  540. .post_preview .product_thumb{max-height:4em;max-width:6em;}
  541. .purchase_button{background-color:%black%;color:%white%;padding-left:0.5em;padding-right:0.5em;text-decoration:none;font-weight:bold;}
  542. .page_break{page-break-after:always;}
  543. .text_highlight,.text_highlight a,.text_highlight select{background-color:%black%;color:%white%;border:none;}
  544. .gray.text_highlight,.gray.text_highlight a,.gray.text_highlight select{background-color:%gray%;color:%white%;}
  545. .print_title{display:none;}
  546. .show_on_print{display:none;}
  547. .comment{font-size:0.9em;font-family:sans-serif;overflow:auto !important;width:100%;}
  548. .comment tbody tr:hover{box-shadow:none;}
  549. .comment table{border:none;}
  550. .comment li{display:list-item;list-style:'→';padding-left:0.3em;}
  551. .comment ul{padding-left:1em;}
  552. .comment ul li *{margin-bottom:0.5em;}
  553. .history li{display:list-item;list-style:disc;padding-left:0.3em;}
  554. .history li li{list-style:circle;}
  555. .history ul{padding-left:1em;}
  556. .history a{text-decoration:underline;}
  557. .history .list{overflow:auto;white-space:nowrap;}
  558. .diff_table{table-layout:fixed;}
  559. .diff_table thead{font-size:0.9em;text-align:center;}
  560. .diff_table tbody pre{font-size:0.9rem;white-space:pre-line;}
  561. .diff_table td{vertical-align:top;}
  562. .omittable_title{display:block;width:100%;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
  563. .wayback_close{float:right;}
  564. .wayback_expand{display:inline;}
  565. .post_selecting .post *{pointer-events:none;}
  566. .post_selected{background-color:%graybkg%;}
  567. .small_pad{padding:0.2em;padding-top:0.1em;padding-bottom:0.1em;}
  568. .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%;}
  569. .wscroll:target{display:block;}
  570. .wayback_link{display:inline;}
  571. @media screen and (max-width:1000px){
  572. .left{width:35%;}
  573. .center,.center_wide{width:65%;}
  574. .center_wide .p_thumb{height:8rem;}
  575. .right{display:none;}
  576. .post_width{width:calc(100% - 1.5rem);padding-left:0.2em;}
  577. .post_width_big{left:0;width:100%;}
  578. .hidden_on_wide{display:unset;}
  579. .hidden_on_narrow{display:none;}
  580. .pop_right{width:30%;}
  581. .pop_right_big{width:40%;}
  582. @keyframes pop_slide_in{0%{right:-30%;}100%{right:0%;}}
  583. @keyframes pop_slide_out{0%{right:0%;}100%{right:-30%;}}
  584. @keyframes pop_slide_in_big{0%{right:-40%;}100%{right:0%;}}
  585. @keyframes pop_slide_out_big{0%{right:0%;}100%{right:-40%;}}
  586. .big_side_box{width:35%;}
  587. .big_image_box{width:65%;}
  588. .inquiry_buttons{right:35%;}
  589. .table_top{left:calc(-50% - 1.7em);width: calc(154% + 0.5em);}
  590. .center_exp{display:block;width:100%;margin:0 auto;overflow:none;padding-bottom:1em;}
  591. .center_exp .post{overflow:auto;}
  592. }
  593. @media screen and (max-width:666px){
  594. html{font-size:16px;}
  595. .hidden_on_mobile{display:none !important;}
  596. .block_on_mobile{display:block !important;}
  597. .hidden_on_desktop{display:unset;}
  598. header ul{display:block;}
  599. header li{display:block;}
  600. header li::before{content:''}
  601. .left{position:relative;width:100%;position:relative;top:unset;height:unset;min-height:80vh;padding-right:0;display:block;}
  602. .center,.center_wide,.center_full{position:relative;left:0;top:0;width:100%;padding-left:0;display:block;}
  603. .center_wide .p_thumb{height:6rem;}
  604. .pop_right,.pop_right_big{top:unset;right:0;bottom:0;left:0;width:100%;}
  605. .pop_right{height:30%;}
  606. .pop_right_big{height:70%;}
  607. @keyframes pop_slide_in{0%{bottom:-30%;}100%{bottom:0%;}}
  608. @keyframes pop_slide_out{0%{bottom:0%;}100%{bottom:-30%;}}
  609. @keyframes pop_slide_in_big{0%{bottom:-70%;}100%{bottom:0%;}}
  610. @keyframes pop_slide_out_big{0%{bottom:0%;}100%{bottom:-70%;}}
  611. .big_image_box{position:fixed;top:0;bottom:8.5rem;left:0;right:0;width:100%;}
  612. .side_box_mobile_inner{background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(1,1,1,0.9) 20%);
  613. transition:none;background-size:100% 100%;padding:0.5rem;padding-bottom: 5em;}
  614. .side_box_mobile_inner:hover{background-size:100% 100%;}
  615. .big_side_box{position:fixed;top:0;bottom:0;right:0;left:0;width:100%;
  616. height:unset;padding:0;padding-top:calc(100vh - 8.5rem);background:none;}
  617. .p_thumb{height:3rem;}
  618. .center .post{padding-right:0rem;padding-left:0rem;}
  619. .post .p_thumb img{max-height:3rem;}
  620. .page,.page_gallery{padding:0.2em;padding-top:0;}
  621. header{padding-top:0.3em;}
  622. .small_footer{padding-bottom:0.3em;}
  623. .footer_additional{display:block;width:100%;}
  624. .album_hint{display:block;font-size:1rem;}
  625. .image_nav{position:absolute !important;}
  626. .image_nav_prev,.image_nav_next{width:25%;}
  627. .image_nav_prev:hover,.image_nav_next:hover{background-size:0% 100%;color:%black% !important;}
  628. .inquiry_buttons{position:relative;left:unset;right:unset;text-align:left;bottom:unset;margin:unset;width:unset;
  629. background-color:unset;z-index:unset;padding:unset;padding-left:unset;padding-right:unset;
  630. border-radius:unset;box-shadow:unset;text-shadow:unset;}.img_btn_hidden{opacity:1;}
  631. .lr_buttons{background-color:unset;padding:unset;padding-top:unset;padding-bottom:unset;
  632. border-radius:unset;box-shadow:unset;font-size:1.3rem;text-shadow:unset;}
  633. .opt_compact,.ref_compact{line-break:anywhere;}
  634. .post_width,.post_width_big{overflow:auto;}
  635. .table_top{left:unset;width:100%;overflow:auto;}
  636. table img{max-width:30vw !important;}
  637. .product_ref{width:100%;display:block;}
  638. .post_dummy > *{width:100%;max-width:25rem;}
  639. .sticky_title{top:1.2em;}
  640. .small_footer{position:relative;}
  641. #upload_selector{width:100%;}
  642. .focused_post{padding:0.3rem !important;}
  643. .interesting_tbody{background:linear-gradient(90deg, %white%ff, %white%88 10em);}
  644. .wayback_expand{display:block;text-align:center;}
  645. .wayback_link{display:block;}
  646. }
  647. @media print{
  648. body,footer,header,.small_footer,a,.clean_a,.invert_a,.clean_a a,.invert_a a{background:none;color:black;}
  649. .post *,.post_dummy *{margin-bottom:0em}
  650. .p_row,.post table,.post_width>img,.post_width_big>img,.post_ref>img,.post_ref>.original_img,
  651. .post_width>.original_img,.post_width_big>.original_img,.post pre{margin-top:0.5rem;margin-bottom:0.5rem;text-indent:0;}
  652. .post p{line-height:1.3;text-indent:2em;}
  653. table img{margin:0 !important;}
  654. .post h1+p,.post h2+p,.post img+p,.post table+p,.post p:first-child{text-indent:0;}
  655. .post ul,.post ol{margin:1rem;margin-left:1.4rem;margin-right: 0rem;}
  656. table{border-bottom:2px solid black;border-top:2px solid black;}
  657. table img{max-width:5em;max-width:8em !important;max-height:8em !important;}
  658. thead{box-shadow:inset 0 -1px 0 0px black;background:none;}
  659. .post_width,.post_width_big{overflow:clip;left:0;width:100%;padding-left:0em;}
  660. .post h1,{margin-top:0.5rem;}
  661. .post h2{font-size:1.8em;margin:2.5em auto 0;}.list h2,.opt_compact h2,.ref_compact h2{margin:0 !important;}
  662. .post h3{font-size:1.5em;margin:1.5em auto 0;}.list h3,.opt_compact h3,.ref_compact h4{margin:0 !important;}
  663. .post h4{font-size:1.1em;margin:0.5em auto 0;}.list h4,.opt_compact h3,.ref_compact h4{margin:0 !important;}
  664. .post .post{margin-bottom:0.5rem;margin-top:0.5rem;}
  665. .gray,.gray a,.deleted_post{color:rgba(0,0,0,0.5);}
  666. .left,.right{display:none;}
  667. .center, .center_wide, .center_full{width:100%;padding:0;display:block;font-size:16px;line-height:1.3}
  668. hr{border:1px solid black;}
  669. .post_box_top{display:none;}
  670. .opt_compact .post_access,.ref_compact .post_access{border-right:none;display:inline;}
  671. .text_highlight,.text_highlight a,.gray.text_highlight,.gray.text_highlight a,.purchase_button{background-color:lightgray;color:black;}
  672. .focused_post{border:none;font-size:1em;padding:0 !important;}
  673. .hidden_on_print{display:none;}
  674. .print_column{column-count:2;margin-top:0.5rem;margin-bottom:0.5rem;}
  675. .post_access{display:none;}
  676. .opt_compact{margin-left:0;}
  677. .post .post_ref{padding-left:1.4rem;}
  678. .opt_compact .post_width{left:1.4rem;width:calc(100% - 1.4rem);margin-left:0;}
  679. .print_title{column-span:all;display:block;margin-top:2em;margin-bottom:0.5rem;font-size:1.2em;}
  680. .print_title:first-of-type{margin-top:1em;}
  681. .print_title+.post h1:first-of-type{display:none;}
  682. .opt_compact h1:first-of-type,.ref_compact h1:first-of-type{display:unset;}
  683. .table_top{position:relative;left:0;width:100%;background:none;z-index:1;box-shadow:none;}
  684. .header_nav{display:none;}
  685. .show_on_print{display:block;}
  686. blockquote{border-left:2px solid black;}
  687. .footer_additional{display:none;}
  688. .small_footer{margin-top:1rem;}
  689. .page_selector{display:none;}
  690. .p_thumb{height:4rem;margin-bottom:0.25rem;}
  691. .post .p_thumb img{max-height:4rem;}
  692. .sticky_title{box-shadow:none;}
  693. .center_wide .p_thumb{display:inline-flex;height:5.8rem;width:5.8rem;margin-right:0;}
  694. .center_wide .p_row{display:block;}
  695. .interesting_tbody{background:none;}
  696. .interesting_tbody img{display:none !important;}
  697. .imd{margin-top:0.5em;margin-bottom:0.5em;line-height:0px;}
  698. }
  699. ";
  700. $this->style=preg_replace('/%white%/','#231a0d',$this->style);
  701. $this->style=preg_replace('/%black%/','#f8ca9b',$this->style);
  702. $this->style=preg_replace('/%gray%/','#ac7843',$this->style);
  703. $this->style=preg_replace('/%graybkg%/','#39270e',$this->style);
  704. $this->style=preg_replace('/%lightopbkg%/','#daae8010',$this->style);
  705. $this->style=preg_replace('/%lighterbkg%/','#675340',$this->style);
  706. $this->style=preg_replace('/%focusedbkg%/','#482f0c',$this->style);
  707. $f = fopen('styles/main.css','w');
  708. fwrite($f,$this->style);
  709. fclose($f);
  710. }
  711. function GiveSafeEMail(){
  712. return preg_replace('/\./u','[dot]',preg_replace('/\@/u','[at]',$this->EMail));
  713. }
  714. function &FindImage($name){
  715. if(isset($this->Images[0]))foreach($this->Images as &$im){
  716. if($im['name']==$name) return $im;
  717. }
  718. return $this->NULL_IMAGE;
  719. }
  720. function ReadImages($clear_non_exist = false){
  721. $path = 'images/list.md';
  722. if($this->DoneReadImages){ return; }
  723. if(!file_exists($path)){ $f = fopen($path,'w'); fflush($f); fclose($f); }
  724. $c = file_get_contents($path);
  725. if(preg_match_all('/GALLERY\s+(\S+)(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  726. $g=[]; $g['name']=$m[1];//$g['count']=0;
  727. if(preg_match('/FEATURED([^;]*?);/u', $m[2], $arg)){ $g['featured']=true; }
  728. if(preg_match('/EXPERIMENTAL([^;]*?);/u', $m[2], $arg)){ $g['experimental']=true; }
  729. $this->Galleries[] = $g;
  730. }
  731. if(preg_match_all('/^-\s*([^;]+)\s*?;\s*?(.*)$/mu', $c, $ma, PREG_SET_ORDER)) foreach($ma as $m){
  732. $name = trim($m[1]);
  733. $item = []; $item['file'] = 'images/'.$name; $item['name'] = $name;
  734. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  735. if(preg_match('/REFS\s+([^;]*);/u',$m[2],$refs) && preg_match_all('/[0-9]{14}/u',$refs[1],$rs, PREG_SET_ORDER)){
  736. $item['refs']=[];
  737. foreach($rs as $r){ if(!in_array($r[0], $item['refs'])) $item['refs'][] = $r[0]; }
  738. }
  739. if(preg_match('/GAL\s+([^;]*);/u',$m[2],$gals) && preg_match_all('/(\S+)/u',$gals[1],$ga, PREG_SET_ORDER)){
  740. $item['galleries']=[];
  741. foreach($ga as $g){ if(!in_array($g[0], $item['galleries'])) $item['galleries'][] = $g[0]; }
  742. }
  743. if(preg_match('/PRODUCT\s+([^;]*);/u',$m[2],$product)){
  744. $item['product']=$product[1];
  745. }
  746. $this->Images[] = $item;
  747. }
  748. $files = array_merge([],glob('images/*.jpg'));
  749. $files = array_merge($files,glob('images/*.jpeg'));
  750. $files = array_merge($files,glob('images/*.png'));
  751. $files = array_merge($files,glob('images/*.gif'));
  752. if(isset($files[0]))foreach($files as $file) {
  753. if(preg_match('/[0-9]{14,}\.(jpg|jpeg|gif|png)/u', $file, $m)) {
  754. $name = trim($m[0]);
  755. if(!$this->FindImage($name)){
  756. $item = []; $item['name']=$name; $item['file'] = 'images/'.$name;
  757. if(file_exists('images/thumb/'.$name)){$item['thumb']='images/thumb/'.$name;}else{$item['thumb']='images/'.$name;}
  758. $this->Images[] = $item;
  759. }
  760. }
  761. }
  762. if($clear_non_exist){
  763. if(isset($this->Images[0]) && isset($files[0])){
  764. foreach($this->Images as &$im){
  765. if(!in_array($im['file'],$files)){
  766. $im['deleted'] = 1;
  767. }
  768. }
  769. }
  770. }
  771. function cmpf($a, $b){
  772. if ($a['name'] == $b['name']) return 0;
  773. return (($a['name'] > $b['name']) ? 1 : -1);
  774. }
  775. function cmpaf($a, $b){
  776. if ($a['name'] == $b['name']) return 0;
  777. return ($a['name'] > $b['name']) ? -1 : 1;
  778. }
  779. if(isset($this->Galleries[0]))usort($this->Galleries,"cmpf");
  780. if(isset($this->Images[0]))usort($this->Images,"cmpaf");
  781. $this->DoneReadImages = 1;
  782. }
  783. function WriteImages(){
  784. if(isset($this->WayBack)) return;
  785. $path = 'images/list.md';
  786. $f = fopen($path,'w');
  787. if(isset($this->Galleries[0]))foreach($this->Galleries as &$g){
  788. if(isset($g['deleted'])) continue;
  789. fwrite($f,'GALLERY '.$g['name']);
  790. if(isset($g['featured']) && $g['featured']!=false) { fwrite($f,' FEATURED;'); }
  791. if(isset($g['experimental']) && $g['experimental']!=false) { fwrite($f,' EXPERIMENTAL;'); }
  792. fwrite($f, PHP_EOL);
  793. }
  794. if(isset($this->Images[0]))foreach($this->Images as &$im){
  795. if(isset($im['deleted'])) continue;
  796. fwrite($f, "- ".$im['name'].'; ');
  797. if(isset($im['refs']) && isset($im['refs'][0])){ fwrite($f, 'REFS '.implode(" ",$im['refs'])."; "); }
  798. if(isset($im['galleries']) && isset($im['galleries'][0])){ fwrite($f, 'GAL '.implode(" ",$im['galleries'])."; "); }
  799. if(isset($im['product']) && $im['product']!=''){ fwrite($f, 'PRODUCT '.$im['product']."; "); }
  800. fwrite($f, PHP_EOL);
  801. }
  802. fflush($f);
  803. fclose($f);
  804. }
  805. function EditImage($name, $link_gallery, $do_remove = false, $product_link=NULL, $rename=NULL){
  806. if(!($im = &$this->FindImage($name))) return;
  807. if(isset($link_gallery)){
  808. if($do_remove){
  809. if(!isset($im['galleries']) || !isset($im['galleries'][0])) return;
  810. foreach($im['galleries'] as $key => $g){ if ($g==$link_gallery) unset($im['galleries'][$key]); }
  811. $im['galleries'] = array_merge($im['galleries']);
  812. }else{
  813. if(!isset($im['galleries'])) $im['galleries']=[];
  814. foreach($im['galleries'] as &$g){ if ($g==$link_gallery) return; }
  815. $im['galleries'][]=$link_gallery;
  816. }
  817. }
  818. if(isset($product_link)){
  819. if($product_link!=''){$im['product']=$product_link;}
  820. else{unset($im['product']);}
  821. }
  822. if(isset($rename)){
  823. $ext=pathinfo($im['file'],PATHINFO_EXTENSION);
  824. rename($im['file'], 'images/'.$rename.'.'.$ext);
  825. if(isset($im['thumb'])) rename($im['thumb'], 'images/thumb/'.$rename.'.'.$ext);
  826. $im['name'] = $rename.'.'.$ext;
  827. }
  828. $this->NeedWriteImages = 1;
  829. }
  830. function RegenerateThumbnails(){
  831. $glob = glob('images/*.jpg');
  832. if(!is_dir('images/thumb')) mkdir('images/thumb');
  833. foreach($glob as $file) {
  834. $thumb_destination = 'images/thumb/'.basename($file);
  835. $img = new Imagick($file); $geo=$img->getImageGeometry();
  836. $width=$geo['width']; $height=$geo['height'];
  837. $lim=400;
  838. $scale = $lim / min($width,$height);
  839. if($scale<1){
  840. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  841. }
  842. $img->setImageFormat('jpeg');
  843. $img->setImageCompressionQuality(90);
  844. $img->writeImage($thumb_destination);
  845. }
  846. }
  847. function CompressImage($source, $destination, $thumb_destination, $quality, $sizelim, $abs_max) {
  848. $img = new Imagick($source); $geo=$img->getImageGeometry(); $img2 = clone $img;
  849. $width=$geo['width']; $height=$geo['height'];
  850. $lim=400;
  851. $scale = $lim / min($width,$height);
  852. if($scale<1){
  853. $img->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.7);
  854. }
  855. $img->setImageFormat('jpeg');
  856. $img->setImageCompressionQuality($quality);
  857. $img->writeImage($thumb_destination);
  858. $scale = min( $sizelim / min($width,$height), $abs_max / max($width,$height));
  859. if($scale<1){
  860. $img2->resizeImage($width*$scale,$height*$scale,imagick::FILTER_GAUSSIAN,0.5);
  861. }
  862. $img2->setImageFormat('jpeg');
  863. $img2->setImageCompressionQuality($quality);
  864. $img2->writeImage($destination);
  865. }
  866. function DoUpload(){
  867. if(!isset($_FILES['upload_file_name'])) return 0;
  868. if(!is_dir('images/thumb')) mkdir('images/thumb');
  869. if($_FILES['upload_file_name']['error']>0){
  870. echo"file upload err code ".$_FILES['upload_file_name']['error']; exit;
  871. return -1;
  872. }else{
  873. $ext=pathinfo($_FILES['upload_file_name']['name'],PATHINFO_EXTENSION);
  874. if(!in_array($ext,['jpg','jpeg','png','gif'])) return 0;
  875. $fp = fopen('.la_lock',"w");
  876. while (!flock($fp, LOCK_EX| LOCK_NB)){
  877. usleep(10000);
  878. }
  879. $num=date('YmdHis'); $replace=0;
  880. if(isset($_POST['image_replace_button']) && isset($_GET['pic']) && preg_match('/([0-9]{14,})/u',$_GET['pic'],$mim)){
  881. $num = $mim[1]; $replace=1;
  882. }
  883. $base = 'images/'.$num;
  884. $thumb = 'images/thumb/'.$num;
  885. if($ext=='png') $ext='jpg';
  886. $final_path = $base.'.'.$ext; $final_thumb = $thumb.'.'.$ext; $i=0;
  887. if(!$replace) while(file_exists($final_path)){
  888. $final_path = $base.strval($i).'.'.$ext; $final_thumb = $thumb.strval($i).'.'.$ext; $i++;
  889. }
  890. if($ext!='gif'){
  891. $compress = (isset($_GET['compress'])&&$_GET['compress']);
  892. $this->CompressImage($_FILES['upload_file_name']['tmp_name'], $final_path, $final_thumb, 90,
  893. $compress?800:1920, $compress?1920:2560);
  894. }else{
  895. move_uploaded_file($_FILES['upload_file_name']['tmp_name'], $final_path);
  896. }
  897. flock($fp, LOCK_UN);
  898. fclose($fp);
  899. $this->ReadImages(true);
  900. $this->WriteImages();
  901. echo '<uploaded>'.pathinfo($final_path,PATHINFO_BASENAME)."</uploaded>";
  902. if(isset($_POST['image_replace_button'])){
  903. header('Location: '.$_SERVER['REQUEST_URI']);exit;
  904. }
  905. exit;
  906. return 1;
  907. }
  908. return 0;
  909. }
  910. function &GetGallery($name){
  911. if(isset($this->Galleries[0])) foreach($this->Galleries as &$g){
  912. if($g['name'] == $name) return $g;
  913. }
  914. return $this->NULL_GALLERY;
  915. }
  916. function EditGallery($name, $new_name=null, $delete=false, $do_rw=true, $set_featured=null, $set_experimental=null){
  917. $this->ReadImages();
  918. $gallery = &$this->GetGallery($name);
  919. if(!isset($gallery)){
  920. if(!isset($new_name) || preg_match('/main|trash|\s/u',$new_name))return;
  921. $g = []; $g['name']=$new_name;
  922. $this->Galleries[]=$g;
  923. }else{
  924. if(isset($new_name)) {
  925. if(preg_match('/main|trash|\s/u',$new_name))return;
  926. $gallery['name'] = $new_name;
  927. foreach ($this->Images as &$im){
  928. if(isset($im['galleries'])&&isset($im['galleries'][0]))foreach($im['galleries'] as &$g){
  929. if($g == $name){ $g = $new_name; }
  930. }
  931. }
  932. }
  933. //if(isset($count)) $gallery['count'] = $count;
  934. if(isset($delete) && $delete) $gallery['deleted'] = true;
  935. if(isset($set_featured)) $gallery['featured'] = $set_featured;
  936. if(isset($set_experimental)) $gallery['experimental'] = $set_experimental;
  937. }
  938. if($do_rw) { $this->NeedWriteImages = 1; }
  939. }
  940. function ClearData(){
  941. $this->Posts = [];
  942. $this->Threads = [];
  943. $this->Images = [];
  944. $this->Archive = [];
  945. $this->ArchiveHandles = [];
  946. }
  947. function InsertArchivePost(&$post){
  948. $a = NULL;
  949. if(($a = &$this->GetArchiveHandle($post['id']))==$this->NULL_POST){
  950. $ah = []; $ah['id'] = $post['id']; $ah['list'] = [];
  951. $this->ArchiveHandles[] = &$ah; $a = &$ah;
  952. }
  953. $a['list'][] = $post;
  954. $this->Archive[] = $post;
  955. }
  956. function ReadArchiveFromFile($path){
  957. if(!file_exists($path)){
  958. return;
  959. }
  960. $c = file_get_contents($path);
  961. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  962. foreach($matches as $m){
  963. $post = [];
  964. $post['id'] = $m[1];
  965. $post['content'] = trim($m[3]);
  966. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  967. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  968. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  969. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  970. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  971. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  972. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  973. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  974. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  975. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  976. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  977. $post['merged_into'] = [trim($n[1]),trim($n[2])];
  978. }
  979. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  980. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  981. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  982. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  983. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  984. }
  985. $this->InsertArchivePost($post);
  986. }
  987. }
  988. }
  989. function SortArchive(){
  990. $cmpac = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  991. $cmpap = function($a, $b){ if ($a['id'] == $b['id']) return ((($a['version'] > $b['version']) ? 1 : -1));
  992. return (($a['id'] > $b['id']) ? 1 : -1);
  993. };
  994. if(isset($this->Archive[0])){
  995. usort($this->Archive,$cmpap);
  996. $year_begin = substr($this->Archive[0]['id'],0,4);
  997. $this->YearBegin = ($year_begin<$this->YearBegin)?$year_begin:$this->YearBegin;
  998. }
  999. if(isset($this->ArchiveHandles[0])){
  1000. usort($this->ArchiveHandles,$cmpac);
  1001. foreach($this->ArchiveHandles as &$a){
  1002. if(isset($a['list'])){ usort($a['list'],$cmpap);
  1003. $last_valid=NULL;
  1004. foreach($a['list'] as &$ver){ $ver['archive']= &$a;
  1005. if(isset($ver['merged_thread'])){ $ver['content']=$last_valid; }
  1006. else{ $last_valid = $ver['content']; } } }
  1007. if(($p = &$this->GetPost($a['id'],true))!=NULL){
  1008. $p['archive'] = &$a;
  1009. }
  1010. }
  1011. }
  1012. }
  1013. function ReadPostsFromFile($path){
  1014. if(!file_exists($path)){
  1015. $f = fopen($path,'w');
  1016. fclose($f);
  1017. }
  1018. $c = file_get_contents($path);
  1019. if(preg_match_all('/\[LAMDWIKIPOST\s+([0-9]{14})\s*;\s*([\s\S]*?)\]([\S\s]*?)(?=\[LAMDWIKIPOST|$)/u',$c,$matches,PREG_SET_ORDER)){
  1020. foreach($matches as $m){
  1021. $post = [];
  1022. $post['id'] = $m[1];
  1023. $post['real_content'] = trim($m[3]);
  1024. $post['content'] = &$post['real_content'];
  1025. if(preg_match('/COMMENT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['comment_to'] = $n[1];
  1026. if(preg_match('/EMAIL\s+([^;]+)\s*;/u', $m[2], $n)) $post['email'] = $n[1];
  1027. if(preg_match('/NAME\s+([^;]+)\s*;/u', $m[2], $n)) $post['name'] = $n[1];
  1028. if(preg_match('/LINK\s+([^;]+)\s*;/u', $m[2], $n)) $post['link'] = $n[1];
  1029. if(preg_match('/IP\s+([^;]+)\s*;/u', $m[2], $n)) $post['ip'] = $n[1];
  1030. if(preg_match('/NEXT\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['next'] = $n[1];
  1031. if(preg_match('/PREV\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['prev'] = $n[1];
  1032. if(preg_match('/VER\s+([0-9]{14})\s*;/u', $m[2], $n)) $post['version'] = $n[1];
  1033. if(preg_match('/MDEL\s*;/u', $m[2])) $post['mark_delete'] = True;
  1034. if(preg_match('/MVAL\s*([^;]+);/u', $m[2], $n)) $post['mark_value'] = trim($n[1]);
  1035. if(preg_match('/REFS\s*([^;]+);/u', $m[2], $ma)){
  1036. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1037. foreach($links as $l){ $entries[] = $l[1]; } $post['refs'] = $entries; } }
  1038. if(preg_match('/HASP\s*([^;]+);/u', $m[2], $ma)){
  1039. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1040. foreach($links as $l){ $entries[] = $l[1]; } $post['hasp'] = $entries; } }
  1041. if(preg_match('/HASI\s*([^;]+);/u', $m[2], $ma)){
  1042. $entries = []; if(preg_match_all('/([0-9]{14}\.(jpg|jpeg|png|gif))/u',$ma[1],$links,PREG_SET_ORDER)){
  1043. foreach($links as $l){ $entries[] = $l[1]; } $post['hasi'] = $entries; } }
  1044. if(preg_match('/FROM\s*([^;]+);/u', $m[2], $ma)){
  1045. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1046. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_from'] = $entries; } }
  1047. if(preg_match('/INTO\s*([0-9]{14})\s*V\s*([0-9]{14})\s*;/u', $m[2], $n)){
  1048. $post['merged_into'] = [trim($n[1]),trim($n[2])]; }
  1049. if(preg_match('/MTHREAD\s*([^;|]+)\s*\|\s*([^;]+);/u', $m[2], $ma)){
  1050. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[1],$links,PREG_SET_ORDER)){
  1051. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][0] = $entries; }
  1052. $entries = []; if(preg_match_all('/([0-9]{14})/u',$ma[2],$links,PREG_SET_ORDER)){
  1053. foreach($links as $l){ $entries[] = $l[1]; } $post['merged_thread'][1] = $entries; }
  1054. }
  1055. if(isset($post['mark_value']) && $post['mark_value']==5){
  1056. $post['product']=[];
  1057. }
  1058. /* marks add here */
  1059. $this->Posts[] = $post;
  1060. if(isset($post['comment_to']) && ($target_post = &$this->GetPost($post['comment_to'],true))){
  1061. if(!isset($target_post['comments']) || !isset($target_post['comments'][0])) $target_post['comments']=[];
  1062. $target_post['comments'][]=&$this->Posts[count($this->Posts) - 1];
  1063. }
  1064. }
  1065. }
  1066. }
  1067. function SortPosts($wayback=false){
  1068. $cmpp = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1069. $sortlist = &$this->Posts;
  1070. if($wayback) $sortlist = &$this->WaybackPosts;
  1071. if(isset($sortlist[0])){
  1072. usort($sortlist,$cmpp);
  1073. $this->YearEnd = substr($this->TIME_STRING,0,4);
  1074. $this->YearBegin = substr($sortlist[0]['id'],0,4);
  1075. }
  1076. }
  1077. function ReadPosts(){
  1078. if ((!file_exists('la_config.md') || is_readable('la_config.md') == false) ||
  1079. (!is_dir('posts') || is_readable('posts') == false) ||
  1080. (!is_dir('history') || is_readable('history') == false) ||
  1081. (!is_dir('images') || is_readable('images') == false) ||
  1082. (!is_dir('styles') || is_readable('styles') == false)){
  1083. $this->Install();
  1084. }
  1085. if($this->DoneReadPosts){ return; }
  1086. $file_list = [];
  1087. $glob = glob('posts/*');
  1088. foreach($glob as $file) {
  1089. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1090. $file_list[] = $file;
  1091. }
  1092. }
  1093. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1094. foreach($file_list as $f) {
  1095. $this->ReadPostsFromFile($f);
  1096. }
  1097. $this->SortPosts();
  1098. $this->DetectThreads();
  1099. $this->DoneReadPosts=1;
  1100. }
  1101. function UpdatePostRefsForWayback(){
  1102. if(!isset($this->WayBack)) return;
  1103. if(isset($this->Images[0])) foreach($this->Images as &$i){ unset($i['refs']); }
  1104. if(!isset($this->WaybackPosts[0])) return;
  1105. foreach($this->WaybackPosts as &$p){ unset($p['refs']); }
  1106. foreach($this->WaybackPosts as &$p){
  1107. if(isset($p['hasp']) && isset($p['hasp'][0])) foreach($p['hasp'] as $r){
  1108. $pr = &$this->GetPost($r); if(isset($pr)){
  1109. if(!isset($pr['refs'])) $pr['refs']=[];
  1110. if(!in_array($p['id'],$pr['refs'])){ $pr['refs'][] = $p['id']; }
  1111. }
  1112. }
  1113. if(isset($p['hasi']) && isset($p['hasi'][0])) foreach($p['hasi'] as $r){
  1114. $ir = &$this->FindImage($r); if(isset($ir)){
  1115. if(!isset($ir['refs'])) $ir['refs']=[];
  1116. if(!in_array($p['id'],$ir['refs'])){ $ir['refs'][] = $p['id'];}
  1117. }
  1118. }
  1119. }
  1120. }
  1121. function ReadArchive(){
  1122. if (!is_dir('archive') || is_readable('archive') == false){ $this->Install(); }
  1123. if ($this->DoneReadArchive) return;
  1124. $file_list = []; $glob = glob('archive/*');
  1125. foreach($glob as $file) {
  1126. if(preg_match('/[0-9]{6}\.md/', $file)) {
  1127. $file_list[] = $file;
  1128. }
  1129. }
  1130. sort($file_list, SORT_NATURAL | SORT_FLAG_CASE);
  1131. foreach($file_list as $f) {
  1132. $this->ReadArchiveFromFile($f);
  1133. }
  1134. $this->SortArchive();
  1135. $this->DoneReadArchive=1;
  1136. $this->UpdateThreadForWayback();
  1137. $this->UpdatePostRefsForWayback();
  1138. }
  1139. function GetThreadForPost(&$post){
  1140. if(isset($post['tid'])) return;
  1141. $th = []; $iterp = NULL;
  1142. $post['tid'] = &$th; $th['first'] = &$post; $th['last'] = &$post;
  1143. if(!(isset($post['prev']) || isset($post['next']))) { $this->Threads[] = &$th; return; }
  1144. if(isset($post['prev']))for($p = $post['prev']; $p!=NULL; $p = $iterp){
  1145. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1146. $np['tid'] = &$th;
  1147. $th['first'] = &$np;
  1148. $iterp = isset($np['prev'])?$np['prev']:NULL;
  1149. }
  1150. if(isset($post['next']))for($p = $post['next']; $p!=NULL; $p = $iterp){
  1151. $np = &$this->GetPost($p,true); if(!$np) { break; }//err
  1152. $np['tid'] = &$th;
  1153. $th['last'] = &$np;
  1154. $iterp = isset($np['next'])?$np['next']:NULL;
  1155. }
  1156. if(isset($th['first']['mark_value'])){
  1157. if($th['first']['mark_value']==6) $th['exp'] = true;
  1158. else if($th['first']['mark_value']==7) $th['slf'] = true;
  1159. }
  1160. if($th['first'] == $th['last']){ unset($post['tid']); return; }
  1161. $this->Threads[] = &$th;
  1162. }
  1163. function IdentifyThreadCategory(&$th,&$first_post){
  1164. if(preg_match('/^\s*\@(.*?)$/mu',$first_post['content'],$m)){
  1165. $first_post['categories']=[]; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1166. foreach($matches as $ma){ $first_post['categories'][] = $ma[1]; }
  1167. }
  1168. if(isset($th) && $th){ $th['categories'] = &$first_post['categories']; }
  1169. }
  1170. if(isset($th) && preg_match('/\{\s*INTERESTING\s+(.*?)\}/imu',$first_post['content'],$m)){
  1171. $th['interesting'] = []; if(preg_match_all('/(\S+)(\s|$)/u',$m[1],$matches,PREG_SET_ORDER)){
  1172. foreach($matches as $ma){ $th['interesting'][] = $ma[1]; }
  1173. }
  1174. }
  1175. }
  1176. function IsInterestingPost(&$p){
  1177. if(isset($p['tid']) && isset($p['tid']['interesting']) && isset($p['tid']['interesting'][0])) return true;
  1178. return false;
  1179. }
  1180. function ThreadMakeWayback(&$th){
  1181. if(!isset($th['arr'][0])) return;
  1182. if(isset($this->WayBack)){
  1183. $remlist = []; $po = &$this->GetPost($th['arr'][0]['id'],true);
  1184. if(isset($po['merged_thread']) && isset($po['version']) && $po['version']>$this->WayBack){
  1185. $remlist = array_merge($remlist,$po['merged_thread'][0]);
  1186. }
  1187. $ah = &$this->GetArchiveHandle($po['id']);
  1188. if(isset($ah)) foreach($ah['list'] as &$ver){
  1189. if(!isset($ver['merged_thread'])) continue;
  1190. if((isset($ver['version']) && $ver['version'] > $this->WayBack) ||
  1191. (!isset($ver['version']) && $ver['id'] > $this->WayBack)){
  1192. $remlist = array_merge($remlist,$ver['merged_thread'][0]);
  1193. }
  1194. }
  1195. if(isset($remlist[0]) && isset($th['arr'][0])){
  1196. foreach($th['arr'] as $key => $pr){
  1197. foreach($remlist as $rem){ if($pr['id'] == $rem) { unset($th['arr'][$key]); break; } } }
  1198. $new_th = []; $new_arr = [];
  1199. foreach($remlist as $rem){ $np=&$this->GetPost($rem); if(isset($np)){$new_arr[]=&$np;} }
  1200. $new_th['arr'] = &$new_arr;
  1201. $this->WaybackThreads[] = &$new_th;
  1202. $this->ThreadMakeWayback($new_th);
  1203. }
  1204. }
  1205. }
  1206. function AddMergedPosts(&$p, &$array){
  1207. if(isset($p['archive']) && isset($p['archive']['list'])){
  1208. foreach($p['archive']['list'] as &$ver){
  1209. if(isset($ver['merged_from'])&&isset($ver['merged_from'][0])) foreach($ver['merged_from'] as $po){
  1210. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1211. }
  1212. }
  1213. if(isset($p['merged_from'])&&isset($p['merged_from'][0])) foreach($p['merged_from'] as $po){
  1214. $mp=&$this->GetPost($po); if(isset($mp)){ $array[]=&$mp; $this->WaybackPosts[]=&$mp; $this->AddMergedPosts($mp, $array); } }
  1215. }
  1216. function FinalizeThread(&$th, $relink_posts=false, $now){
  1217. $nextp=NULL; $arr=[]; $lasttime=NULL;
  1218. if(!isset($th['arr'])){
  1219. for($p = &$th['first']; $p!=$this->NULL_POST; $p = &$this->GetPost(isset($p['next'])?$p['next']:NULL,true)){
  1220. $arr[]=&$p;
  1221. } $th['arr'] = &$arr;
  1222. if(isset($this->WayBack) && $this->DoneReadArchive){ $new_arr=[];
  1223. foreach($arr as &$p){ $pa = &$this->GetPost($p['id']); if(isset($pa)) {$new_arr[]=&$pa;$this->WaybackPosts[]=&$pa;} }
  1224. foreach($arr as &$p){ $this->AddMergedPosts($p,$new_arr); }
  1225. $arr=&$new_arr; $th['arr']=&$new_arr;
  1226. $this->ThreadMakeWayback($th); }
  1227. }
  1228. $cmppt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1229. if(isset($th['arr'][0])){ usort($th['arr'],$cmppt); } $th['count'] = sizeof($th['arr']);
  1230. if($relink_posts){ $count = $th['count'];
  1231. $arr = &$th['arr'];
  1232. 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'];
  1233. $arr[$i]['tid']=&$th;}
  1234. $th['first'] = &$arr[0]; $th['last'] = &$arr[$count-1]; unset($arr[0]['prev']); unset($arr[$count-1]['next']);
  1235. }
  1236. $th['score'] = 0; if(!isset($th['first'])){ return; }
  1237. $this->IdentifyThreadCategory($th, $th['first']);
  1238. if(isset($this->WayBack)) $lasttime=$this->WayBack;
  1239. if(!isset($last_time)) $lasttime = DateTime::createFromFormat('YmdHis', $th['last']['id']);
  1240. $diff_days = ($now - date_timestamp_get($lasttime))/3600/24;
  1241. $th['score'] = (float)$th['count']*0.2 - min($diff_days,200);
  1242. }
  1243. function SortThreads(){
  1244. if (!function_exists('cmpt')) {
  1245. function cmpt($a, $b){
  1246. if ($a['score'] == $b['score']) return 0;
  1247. return ($a['score'] > $b['score']) ? -1 : 1;
  1248. }
  1249. }
  1250. usort($this->Threads,"cmpt");
  1251. }
  1252. function DetectThreads(){
  1253. foreach($this->Posts as &$p){
  1254. if(isset($p['tid'])) { continue; }
  1255. $this->GetThreadForPost($p);
  1256. if(!isset($p['tid'])) { $this->IdentifyThreadCategory($this->NULL_POST, $p); }
  1257. }
  1258. if(!isset($this->Threads) || !isset($this->Threads[0])) return;
  1259. $now = date_timestamp_get(date_create());
  1260. foreach($this->Threads as &$t){
  1261. $this->FinalizeThread($t,false,$now);
  1262. }
  1263. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1264. $this->FinalizeThread($th,false,$now);
  1265. $this->Threads[] = &$th;
  1266. }
  1267. $this->SortThreads();
  1268. }
  1269. function UpdateThreadForWayback(){$now = date_timestamp_get(date_create());
  1270. if(!isset($this->WayBack) || !$this->DoneReadArchive){ return; }
  1271. foreach($this->Threads as &$t){
  1272. unset($t['arr']); $this->FinalizeThread($t,true,$now);
  1273. }
  1274. if(isset($this->WaybackThreads[0])) foreach($this->WaybackThreads as &$th){
  1275. $this->FinalizeThread($th,true,$now);
  1276. $this->Threads[] = &$th;
  1277. }
  1278. $this->SortThreads();
  1279. $this->SortPosts(true);
  1280. $this->UsePosts = &$this->WaybackPosts;
  1281. }
  1282. function &GetMergedPost($id){
  1283. $this->ReadArchive();
  1284. $ah = &$this->GetArchiveHandle($id);
  1285. if(!isset($ah) || !isset($ah['list']) || !isset($ah['list'][0])){ return $this->NULL_POST; }
  1286. $ver = &$ah['list'][sizeof($ah['list'])-1];
  1287. if(!isset($ver['merged_into'])) return $this->GetPost($id);
  1288. [$tp, $tver] = $ver['merged_into'];
  1289. if(isset($this->WayBack)){
  1290. if($tver <= $this->WayBack) return $this->GetMergedPost($tp);
  1291. else return $this->GetPost($id); /* should not happen directly. */
  1292. }
  1293. return $this->GetMergedPost($tp);
  1294. }
  1295. function &GetPost($id, $latest_only=false){
  1296. if(!isset($id)) return $this->NULL_POST;
  1297. $found=&$this->NULL_POST;
  1298. if(isset($this->Posts[0])) foreach($this->Posts as &$p){
  1299. if($p&& $p['id'] == $id) { $found = &$p; break; }
  1300. }
  1301. if($latest_only || !isset($this->WayBack)){ return $found; }
  1302. else{
  1303. if(isset($found)){
  1304. if(!isset($found['archive'])&&!isset($found['archive']['list']))
  1305. { if($found['id'] > $this->WayBack) return $this->NULL_POST; else return $found; }
  1306. $last_ver = &$this->NULL_POST;
  1307. if(isset($found['archive']['list'][0])) foreach($found['archive']['list'] as &$ver){
  1308. if($ver['version'] > $this->WayBack) return $last_ver;
  1309. $last_ver = &$ver;
  1310. }
  1311. if(isset($found['version']) && $found['version'] <= $this->WayBack) return $found;
  1312. else return $last_ver;
  1313. }else{
  1314. $ah = &$this->GetArchiveHandle($id); $last_ver = &$this->NULL_POST;
  1315. if(isset($ah) && isset($ah['list']) && isset($ah['list'][0])) foreach($ah['list'] as &$ver){
  1316. if($ver['version'] > $this->WayBack) return $last_ver;
  1317. $last_ver = &$ver;
  1318. } if(!isset($last_ver['merged_into'])) return $last_ver; else{
  1319. [$tp, $tver] = $last_ver['merged_into'];
  1320. if($tver <= $this->WayBack) return $this->NULL_POST;
  1321. return $last_ver;
  1322. }
  1323. }
  1324. }
  1325. return $this->NULL_POST;
  1326. }
  1327. function &GetArchiveHandle($id){
  1328. if(!isset($id)) return $this->NULL_POST;
  1329. if(isset($this->ArchiveHandles[0])) foreach($this->ArchiveHandles as &$p){
  1330. if($p && $p['id'] == $id) { return $p; }
  1331. }
  1332. return $this->NULL_POST;
  1333. }
  1334. function &GetArchive($id){
  1335. if(!isset($id)) return $this->NULL_POST;
  1336. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1337. if($p && $p['id'] == $id) { return $p; }
  1338. }
  1339. return $this->NULL_POST;
  1340. }
  1341. function &GetArchiveVersion(&$ah, $version, &$next_ver, &$last_ver){
  1342. if(!isset($ah)) return $this->NULL_POST;
  1343. $found = NULL; $last_verp=NULL;
  1344. if(isset($ah['list'][0])) foreach($ah['list'] as &$p){
  1345. if(isset($found)){ $next_ver = $p; $last_ver = $last_verp; return $found; }
  1346. if($p && $p['version'] == $version) { $found = &$p; continue; }
  1347. $last_verp = &$p;
  1348. }
  1349. if(isset($found)) { $next_ver=NULL; $last_ver = $last_verp; return $found; }
  1350. return $this->NULL_POST;
  1351. }
  1352. function CacheArchiveOwnLinks(){
  1353. if(isset($this->WayBack)) return;
  1354. if(isset($this->Archive[0])) foreach($this->Archive as &$p){
  1355. $this->ConvertPost($p);
  1356. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$p['html'],$matches,PREG_SET_ORDER)){
  1357. foreach($matches as $m){
  1358. if(!isset($p['hasp']))$p['hasp']=[];
  1359. if(!in_array($m[1],$p['hasp'])){ $p['hasp'][]=$m[1]; }
  1360. }
  1361. }
  1362. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\)/u', $p['content'],$matches,PREG_SET_ORDER)){
  1363. foreach($matches as $m){
  1364. if(!isset($p['hasi']))$p['hasi']=[];
  1365. if(!in_array($m[2],$p['hasi'])){ $p['hasi'][]=$m[2]; }
  1366. }
  1367. }
  1368. }
  1369. }
  1370. function WriteArchive(){
  1371. if(isset($this->WayBack)) return;
  1372. $cf = NULL;$opened =NULL;
  1373. $this->SortArchive();
  1374. $this->CacheArchiveOwnLinks();
  1375. if(isset($this->Archive[0])) foreach($this->Archive as $p){
  1376. $nid = substr($p['id'], 0,6);
  1377. if($cf != $nid){
  1378. if($opened){
  1379. fflush($opened);
  1380. fclose($opened);
  1381. }
  1382. $cf = $nid;
  1383. $opened = fopen("archive/$cf.md", 'w');
  1384. }
  1385. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1386. "VER {$p['version']}; ".
  1387. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1388. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1]).";"):"").
  1389. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1390. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1391. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1392. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1393. ']';
  1394. if(isset($p['merged_thread'])){ $p['content']=""; }
  1395. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['content'].PHP_EOL.PHP_EOL);
  1396. }
  1397. }
  1398. function WritePosts(){
  1399. if(isset($this->WayBack)) return;
  1400. $cf = NULL;$opened =NULL;
  1401. $this->SortPosts();
  1402. if(isset($this->Posts[0])) foreach($this->Posts as $p){
  1403. $nid = substr($p['id'], 0,6);
  1404. if($cf != $nid){
  1405. if($opened){
  1406. fflush($opened);
  1407. fclose($opened);
  1408. }
  1409. $cf = $nid;
  1410. $opened = fopen("posts/$cf.md", 'w');
  1411. }
  1412. $info = "[LAMDWIKIPOST {$p['id']}; ".
  1413. ((isset($p['version']) && $p['version'])?"VER {$p['version']}; ":"").
  1414. ((isset($p['merged_from']) && isset($p['merged_from'][0]))?("FROM ".implode(" ",$p['merged_from'])."; "):"").
  1415. ((isset($p['merged_into']) && isset($p['merged_into'][0]))?("INTO {$p['merged_into'][0]}V{$p['merged_into'][1]}; "):"").
  1416. ((isset($p['merged_thread']) && isset($p['merged_thread'][0]))?
  1417. ("MTHREAD ".implode(" ",$p['merged_thread'][0])." | ".implode(" ",$p['merged_thread'][1])."; "):"").
  1418. ((isset($p['comment_to']) && $p['comment_to'])?"COMMENT {$p['comment_to']}; ":"").
  1419. ((isset($p['email']) && $p['email'])?"EMAIL {$p['email']}; ":"").
  1420. ((isset($p['name']) && $p['name'])?"NAME {$p['name']}; ":"").
  1421. ((isset($p['link']) && $p['link'])?"LINK {$p['link']}; ":"").
  1422. ((isset($p['ip']) && $p['ip'])?"IP {$p['ip']}; ":"").
  1423. ((isset($p['mark_delete']) && $p['mark_delete'])?"MDEL; ":"").
  1424. ((isset($p['mark_value']) && $p['mark_value']>=0)?"MVAL {$p['mark_value']}; ":"").
  1425. ((isset($p['next']) && $p['next'])?"NEXT {$p['next']}; ":"").
  1426. ((isset($p['prev']) && $p['prev'])?"PREV {$p['prev']}; ":"").
  1427. ((isset($p['refs']) && isset($p['refs'][0]))?("REFS ".implode(" ",$p['refs'])."; "):"").
  1428. ((isset($p['hasp']) && isset($p['hasp'][0]))?("HASP ".implode(" ",$p['hasp'])."; "):"").
  1429. ((isset($p['hasi']) && isset($p['hasi'][0]))?("HASI ".implode(" ",$p['hasi'])."; "):"").
  1430. ']';
  1431. fwrite($opened, $info.PHP_EOL.PHP_EOL.$p['real_content'].PHP_EOL.PHP_EOL);
  1432. }
  1433. }
  1434. function CachePostLinks(){
  1435. if(isset($this->Posts) && isset($this->Posts[0]))foreach ($this->Posts as &$post){
  1436. $this->ConvertPost($post);
  1437. unset($post['refs']);unset($post['hasp']);unset($post['hasi']);
  1438. }else return;
  1439. if(isset($this->Images) && isset($this->Images[0])) foreach ($this->Images as &$im){
  1440. unset($im['refs']);
  1441. }
  1442. foreach ($this->Posts as &$post){
  1443. if(preg_match_all('/<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>.*?<\/a>/u',$post['html'],$matches,PREG_SET_ORDER)){
  1444. foreach($matches as $m){
  1445. $ref = &$this->GetPost($m[1],true);
  1446. if($ref!=NULL){
  1447. if(!isset($ref['refs']))$ref['refs']=[]; if(!in_array($post['id'],$ref['refs']))$ref['refs'][]=$post['id'];
  1448. }
  1449. if(!isset($post['hasp']))$post['hasp']=[]; if(!in_array($m[1],$post['hasp']))$post['hasp'][]=$m[1];
  1450. }
  1451. }
  1452. if(preg_match_all('/!\[([^\]]*)\]\(images\/([0-9]{14,}\.(jpg|jpeg|png|gif))\)/u', $post['content'],$matches,PREG_SET_ORDER)){
  1453. foreach($matches as $m){
  1454. if(($im = &$this->FindImage($m[2]))!=NULL){
  1455. if(!isset($im['refs']))$im['refs']=[]; if(!in_array($post['id'], $im['refs']))$im['refs'][] = $post['id'];
  1456. }
  1457. if(!isset($post['hasi']))$post['hasi']=[]; if(!in_array($m[2],$post['hasi']))$post['hasi'][]=$m[2];
  1458. }
  1459. }
  1460. }
  1461. }
  1462. function CreatePostAnchor(&$post){
  1463. $that=&$this;
  1464. $post['html'] = preg_replace_callback('/<h([0-9])>(.+?)(?=<\/h[0-9]>)/u', function ($ma) use ($that){
  1465. $id = '_heading_'.sizeof($this->Anchors);
  1466. $entry=[(int)$ma[1], $id, $ma[2]];
  1467. $that->Anchors[] = $entry;
  1468. return "<h${ma[1]} id='${id}'>${ma[2]}";
  1469. }, $post['html']);
  1470. }
  1471. function RenamePost(&$post, $rename){
  1472. foreach($this->Posts as &$p){
  1473. if($p['id']==$rename && $p!==$post) { return; /* don't overwrite */ }
  1474. }
  1475. foreach($this->Posts as &$p){
  1476. if(isset($p['prev']) && $p['prev']==$post['id']) { $p['prev']=$rename; }
  1477. if(isset($p['next']) && $p['next']==$post['id']) { $p['next']=$rename; }
  1478. }
  1479. $post['id'] = $rename;
  1480. }
  1481. function DetachPost(&$th,&$post){
  1482. $p0=$p1=NULL;foreach($th['arr'] as $a) echo $a['id']." "; echo '&nbsp;&nbsp;&nbsp;-'.$post['id']."<br />";
  1483. if(isset($post['prev'])){$p0=&$this->GetPost($post['prev'],true);} if(isset($post['next'])){$p1=&$this->GetPost($post['next'],true);}
  1484. if(isset($p0)){ $p0['next']=$p1['id']; }else{ $th['first']=$p1['id']; }
  1485. if(isset($p1)){ $p1['prev'] =$p0['id']; }else{ $th['last']=$p0['id']; }
  1486. foreach($this->Posts as $key => $p){ if ($p==$post) unset($this->Posts[$key]); }
  1487. unset($th['arr']); $now = date_timestamp_get(date_create());
  1488. $this->FinalizeThread($th, true, $now);
  1489. }
  1490. function PushPostVersion(&$post, $optime_id, $mode=1, $info=NULL){
  1491. $a = &$this->GetArchiveHandle($post['id']);
  1492. $ap = []; $ap['id'] = $post['id']; $ap['content'] = $post['real_content'];
  1493. $ap['version'] = isset($post['version'])?$post['version']:$ap['id'];
  1494. if(isset($post['merged_from'])) { $ap['merged_from'] = $post['merged_from']; unset($post['merged_from']); }
  1495. if(isset($post['merged_into'])) { $ap['merged_into'] = $post['merged_into']; unset($post['merged_into']); }
  1496. if(isset($post['merged_thread'])) { $ap['merged_thread'] = $post['merged_thread']; unset($post['merged_thread']); }
  1497. $post['version'] = $optime_id;
  1498. if($mode==1){
  1499. $this->InsertArchivePost($ap);
  1500. }else if($mode==2){
  1501. $post['merged_from'] = $info;
  1502. $this->InsertArchivePost($ap);
  1503. }else if($mode==3){
  1504. $ap['merged_into'] = $info;
  1505. $this->InsertArchivePost($ap);
  1506. if(isset($post['tid']) && $post['tid']['first']!=$post['tid']['last'] && $post!=$post['tid']['first']){
  1507. $this->DetachPost($post['tid'], $post);
  1508. }
  1509. }else if($mode==4){
  1510. $post['merged_thread'] = $info;
  1511. $this->InsertArchivePost($ap);
  1512. }
  1513. }
  1514. function &MergeThreads($post_id, $post_into_id){
  1515. $this->ReadPosts();
  1516. $po = &$this->GetPost($post_id, true); $pt = &$this->GetPost($post_into_id, true);
  1517. if (!isset($po) || !isset($pt) || !isset($po['tid']) || !isset($pt['tid']) ||
  1518. !isset($po['tid']['arr'][0]) || !isset($pt['tid']['arr'][0])){ return $this->NULL_POST; }
  1519. $po = &$po['tid']['arr'][0]; $pt = &$pt['tid']['arr'][0];
  1520. $th = &$po['tid']; $tt = &$pt['tid']; $info=[[],[]];
  1521. if($po['id'] < $pt['id']){ $temp = &$th; $th=&$tt; $tt=&$temp; $temp = &$po; $po=&$pt; $pt=&$temp; }
  1522. foreach($th['arr'] as &$p){ $info[0][]=$p['id']; }
  1523. foreach($tt['arr'] as &$p){ $info[1][]=$p['id']; }
  1524. $this->EditPost($pt['id'], NULL, NULL, NULL, false, NULL, NULL, 4, $info);
  1525. $arr_combined = array_merge($tt['arr'],$th['arr']);
  1526. $cmppmt = function($a, $b){ if ($a['id'] == $b['id']) return 0; return (($a['id'] > $b['id']) ? 1 : -1); };
  1527. if(isset($arr_combined[0])){ usort($arr_combined,$cmppmt); } $tt['arr']=&$arr_combined;
  1528. $tt['count'] = sizeof($tt['arr']);
  1529. $this->FinalizeThread($tt, true, $this->TIME_STRING);
  1530. $first_post = &$this->NULL_POST;
  1531. if(isset($tt['arr'][0])) $first_post= &$tt['arr'][0];
  1532. $this->NeedWritePosts=1;
  1533. $this->NeedWriteArchive=1;
  1534. return $first_post;
  1535. }
  1536. function &MergePosts($ids_string){
  1537. $ids = explode(" ", $ids_string);
  1538. $combined_content = ""; $first_id=NULL;
  1539. $this->ReadPosts(); $child_list=[];
  1540. foreach($ids as $id){
  1541. if(!preg_match('/[0-9]{14}/u',$id) || $this->GetPost($id,true)==$this->NULL_POST) continue;
  1542. if(!isset($first_id)) { $first_id = $id; } else { $combined_content.=PHP_EOL.PHP_EOL."//".$id.PHP_EOL; $child_list[]=$id; }
  1543. $combined_content.=$this->EditPost($id, NULL, NULL, NULL, true, NULL, NULL, false, NULL);
  1544. }
  1545. if(!isset($child_list[0])) return $this->NULL_POST;
  1546. $first_post = &$this->EditPost($first_id, $combined_content, NULL, NULL, false, NULL, NULL, 2, $child_list);
  1547. foreach($child_list as $id){
  1548. $this->EditPost($id, NULL, NULL, NULL, false, NULL, NULL, 3, [$first_id,$this->TIME_STRING]);
  1549. }
  1550. $this->NeedWritePosts=1;
  1551. $this->NeedWriteArchive=1;
  1552. return $first_post;
  1553. }
  1554. /* push_version: 1 edit 2 post merged from ids list 3 post end into id-ver */
  1555. function &EditPost($id_if_edit, $content, $mark_delete, $reply_to,
  1556. $get_original_only=false, $mark_value=NULL, $rename=NULL,
  1557. $push_version=false, $version_info=NULL){
  1558. $this->ReadImages();
  1559. $this->ReadPosts();
  1560. if(isset($push_version) && $push_version){
  1561. $this->ReadArchive();
  1562. }
  1563. $p_success = NULL;
  1564. if(isset($id_if_edit)){
  1565. $post = &$this->GetPost($id_if_edit,true);
  1566. if($post===$this->NULL_POST) return $this->NULL_POST;
  1567. if($get_original_only){
  1568. return $post['real_content'];
  1569. }
  1570. if(isset($push_version) && $push_version){
  1571. $this->PushPostVersion($post,$this->TIME_STRING,$push_version,$version_info);
  1572. }
  1573. if(isset($content)) $post['real_content'] = $content;
  1574. if(isset($mark_delete)) $post['mark_delete'] = $mark_delete;
  1575. if(isset($mark_value)) $post['mark_value'] = $mark_value;
  1576. if(isset($rename) && preg_match('/^[0-9]{14}$/u',$rename)) $this->RenamePost($post,$rename);
  1577. $p_success = &$post;
  1578. }else{
  1579. if(!isset($content)) return $this->NULL_POST;
  1580. $id = date('YmdHis');
  1581. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  1582. $post = [];
  1583. $post['id'] = $id;
  1584. $post['real_content'] = $content;
  1585. if(isset($reply_to) && ($rep = &$this->GetPost($reply_to,true))!== $this->NULL_POST){
  1586. if(!(isset($rep['next']) && $rep['next'])){$rep['next'] = $id; $post['prev'] = $rep['id'];}
  1587. else $post['real_content'] = "[引用的文章]($reply_to)".$post['content'];
  1588. }
  1589. $this->Posts[] = $post;
  1590. $p_success = &$this->Posts[count($this->Posts) - 1];
  1591. }
  1592. $this->NeedWritePosts=1;
  1593. $this->NeedWriteImages=1;
  1594. if(isset($push_version) && $push_version){
  1595. $this->NeedWriteArchive=1;
  1596. }
  1597. return $p_success;
  1598. }
  1599. function &EditComment($id_if_edit, $comment_to_id, $content, $email, $name, $link=NULL, $ip=NULL){
  1600. $this->ReadPosts();
  1601. $p_success = NULL;
  1602. if(isset($id_if_edit)){
  1603. $post = &$this->GetPost($id_if_edit,true);
  1604. if($post===$this->NULL_POST || !isset($post['comment_to'])) return $this->NULL_POST;
  1605. if(isset($content)) $post['content'] = $content;
  1606. if(isset($comment_to_id)) $post['comment_to'] = $comment_to_id;
  1607. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  1608. if(isset($ip)) $post['ip'] = $ip;
  1609. $p_success = &$post;
  1610. }else{
  1611. if(!isset($content) || !isset($comment_to_id)) return $this->NULL_POST;
  1612. $id = date('YmdHis');
  1613. if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
  1614. if(!($to_post=$this->GetPost($comment_to_id,true))) return $this->NULL_POST;
  1615. $post = []; $post['id'] = $id; $post['content'] = $content; $post['comment_to'] = $comment_to_id;
  1616. if(isset($email)) $post['email'] = $email; if(isset($name)) $post['name'] = $name; if(isset($link)) $post['link'] = $link;
  1617. if(isset($ip)) $post['ip'] = $ip;
  1618. $this->Posts[] = $post;
  1619. $p_success = &$this->Posts[count($this->Posts) - 1];
  1620. }
  1621. $this->NeedWritePosts=1;
  1622. return $p_success;
  1623. }
  1624. function InsertReplacementSymbols($MarkdownContent){
  1625. $replacement = preg_replace('/<!--[\s\S]*-->/U',"",$MarkdownContent);
  1626. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  1627. function($matches){
  1628. $rep = preg_replace('/->/','-@>',$matches[0]);
  1629. $rep = preg_replace('/=>/','=@>',$rep);
  1630. $rep = preg_replace('/<=/','<@=',$rep);
  1631. $rep = preg_replace('/<-/','<@-',$rep);
  1632. $rep = preg_replace('/\R([+]{3,})\R/',PHP_EOL.'@$1'.PHP_EOL,$rep);
  1633. $rep = preg_replace('/\[-/','[@-',$rep);
  1634. $rep = preg_replace('/\{/','{@',$rep);
  1635. return $rep;
  1636. },
  1637. $replacement);
  1638. $replacement = preg_replace("/<[-]+>/","↔",$replacement);
  1639. $replacement = preg_replace("/([^-])->/","$1→",$replacement);
  1640. $replacement = preg_replace("/<-([^-])/","←$1",$replacement);
  1641. $replacement = preg_replace("/([^-])[-]+->/","$1⟶",$replacement);
  1642. $replacement = preg_replace("/<-[-]+([^-])/","⟵$1",$replacement);
  1643. $replacement = preg_replace("/<[=]+>/","⇔",$replacement);
  1644. $replacement = preg_replace("/[=]+>/","⇒",$replacement);
  1645. $replacement = preg_replace("/<[=]+/","⇐",$replacement);
  1646. $replacement = preg_replace("/\R([+]{3,})\R/","<div class='page_break'></div>",$replacement);
  1647. $replacement = preg_replace("/\[-(.*)-\]/U","<span class='text_highlight'>$1</span>",$replacement);
  1648. $replacement = preg_replace("/{支付宝(\s+[^}]*?)?}/u","<span class='special_alipay'>支付宝$1</span>",$replacement);
  1649. $replacement = preg_replace("/{PayPal(\s+[^}]*?)?}/ui",
  1650. "<span class='special_paypal'>Pay<span class='special_paypal_inner'>Pal</span>$1</span>",$replacement);
  1651. $replacement = preg_replace_callback("/(```|`)([^`]*)(?1)/U",
  1652. function($matches){
  1653. $rep = preg_replace('/-@>/','->',$matches[0]);
  1654. $rep = preg_replace('/<@-/','<-',$rep);
  1655. $rep = preg_replace('/=@>/','=>',$rep);
  1656. $rep = preg_replace('/<@=/','<=',$rep);
  1657. $rep = preg_replace('/\R@([+]{3,})\R/',PHP_EOL.'$1'.PHP_EOL,$rep);
  1658. $rep = preg_replace('/\[@-/','[-',$rep);
  1659. $rep = preg_replace('/\{@/','{',$rep);
  1660. return $rep;
  1661. },
  1662. $replacement);
  1663. return $replacement;
  1664. }
  1665. function CanShowPost(&$p){
  1666. if(!isset($p) || isset($p['comment_to'])) return false;
  1667. $is_mark_exp = (isset($p['tid'])&&isset($p['tid']['exp'])&&$p['tid']['exp']) || (isset($p['mark_value'])&&$p['mark_value']==6);
  1668. $is_mark_slf = (isset($p['tid'])&&isset($p['tid']['slf'])&&$p['tid']['slf']) || (isset($p['mark_value'])&&$p['mark_value']==7);
  1669. if($is_mark_slf && !$this->LoggedIn){ return false; }
  1670. if(isset($this->WayBack)){
  1671. if(isset($p['version'])) { if ($p['version']>$this->WayBack) return false; }
  1672. else if ($p['id']>$this->WayBack) return false;
  1673. }
  1674. if(!$this->InExperimentalMode){
  1675. if(!$this->LoggedIn){
  1676. if($is_mark_exp) return false;
  1677. return true;
  1678. }
  1679. return true;
  1680. }else{
  1681. if($is_mark_exp) return true;
  1682. return false;
  1683. }
  1684. }
  1685. function SkipProduct(&$p){
  1686. if($this->LoggedIn) return false;
  1687. return (isset($p['mark_value']) && $p['mark_value']==5);
  1688. }
  1689. function GetRedirect($args=NULL){
  1690. $str = 'index.php?';
  1691. if(isset($args['post'])) $str.='&post='.$args['post'];
  1692. else if(isset($_GET['post'])) $str.='&post='.$_GET['post'];
  1693. if(isset($args['gallery'])) $str.='&gallery='.$args['gallery'];
  1694. else if(isset($_GET['gallery'])) $str.='&gallery='.$_GET['gallery'];
  1695. if(isset($args['pic'])) $str.='&pic='.$args['pic'];
  1696. else if(isset($_GET['pic'])) $str.='&pic='.$_GET['pic'];
  1697. if(isset($args['settings'])) $str.='&settings='.$args['settings'];
  1698. else if(isset($_GET['settings'])) $str.='&settings='.$_GET['settings'];
  1699. if(isset($args['extras'])) $str.='&extras='.$args['extras'];
  1700. else if(isset($_GET['extras'])) $str.='&extras='.$_GET['extras'];
  1701. if(isset($args['category'])) $str.='&category='.$args['category'];
  1702. else if(isset($_GET['category'])) $str.='&category='.$_GET['category'];
  1703. if(isset($args['history'])) $str.='&history='.$args['history'];
  1704. else if(isset($_GET['history'])) $str.='&history='.$_GET['history'];
  1705. if(isset($args['version'])) $str.='&version='.$args['version'];
  1706. else if(isset($_GET['version'])) $str.='&version='.$_GET['version'];
  1707. if(isset($args['search'])) $str.='&search='.$args['search'];
  1708. else if(isset($_GET['search'])) $str.='&search='.$_GET['search'];
  1709. return $str;
  1710. }
  1711. function WriteAsNecessary(){
  1712. if(!$this->LoggedIn){return;}
  1713. if($this->NeedWritePosts){ $this->CachePostLinks(); $this->WritePosts(); }
  1714. if($this->NeedWriteImages){ $this->WriteImages(); }
  1715. if($this->NeedWriteArchive){ $this->WriteArchive(); }
  1716. }
  1717. function ProcessRequest(&$message=NULL, &$redirect=NULL){
  1718. if(isset($_GET['gallery']) && $_GET['gallery']=='default'){
  1719. $redirect = "index.php?gallery=".(isset($this->DefaultGallery)&&$this->DefaultGallery!=''?$this->DefaultGallery:"main");
  1720. return 0;
  1721. }
  1722. if(isset($_GET['set_language'])){
  1723. setcookie('la_language',$_GET['set_language'],time()+3600*24*7); $_COOKIE['la_language'] = $_GET['set_language'];
  1724. $redirect=$this->GetRedirect(); return 0;
  1725. }
  1726. if(isset($_GET['set_wayback'])){
  1727. if($_GET['set_wayback']!='false'){
  1728. $wayback=$wayback = date('YmdHis');
  1729. if(preg_match('/[0-9]{14}/u', $_GET['set_wayback'])) $wayback = $_GET['set_wayback'];
  1730. setcookie('la_wayback',$wayback); $_COOKIE['la_wayback'] = $wayback;
  1731. }else{
  1732. setcookie('la_wayback', null, -1); unset($_COOKIE['la_wayback']);
  1733. }
  1734. $redirect=$this->GetRedirect(); return 0;
  1735. }
  1736. if(isset($_GET['post'])){
  1737. $this->CurrentPostID = $_GET['post'];
  1738. $this->TagID = $this->CurrentPostID;
  1739. }
  1740. if(isset($_GET['offset'])){
  1741. $this->CurrentOffset = $_GET['offset'];
  1742. }
  1743. if(isset($_GET['part'])){
  1744. if($_GET['part'] == 'hot') $this->ExtraScripts.="ShowLeftSide();";
  1745. else if ($_GET['part'] == 'recent') $this->ExtraScripts.="ShowCenterSide();";
  1746. }
  1747. if(isset($_GET['post'])){
  1748. $this->ExtraScripts.="window.addEventListener('load', (event) => {ScrollToPost('".$_GET['post']."');});";
  1749. }
  1750. if(isset($_POST['search_content'])){
  1751. $redirect='index.php?search='.$_POST['search_content'];return 0;
  1752. }
  1753. if(isset($_GET['image_info'])){
  1754. $m=$_GET['image_info'];
  1755. $this->ReadImages();
  1756. $this->ReadPosts();
  1757. $this->SwitchWayBackMode(); if(isset($this->WayBack)){$this->ReadArchive();echo"a";}
  1758. $im = &$this->FindImage($m);
  1759. if($im==NULL || !isset($im['refs']) || !isset($im['refs'][0])){ echo "not_found"; exit; }
  1760. echo "<ref>".sizeof($im['refs'])."</ref>";
  1761. echo "<insert><ul>";
  1762. foreach(array_reverse($im['refs']) as $ref){
  1763. $p = $this->GetPost($ref);
  1764. if(!$p || !$this->CanShowPost($p)) continue;
  1765. $this->MakeSinglePost($p, false, true, "post_preview", true, false, false, false, true);"</li>";
  1766. }
  1767. echo "</ul></insert>";
  1768. exit;
  1769. }
  1770. if(isset($_GET['confirm_enter']) && $_GET['confirm_enter']!=false){
  1771. setcookie('la_experimental','confirmed'); $_COOKIE['la_experimental'] = $_GET['confirmed'];
  1772. $redirect='index.php'.(isset($_GET['post'])?'?post='.$_GET['post']:"");return 0;
  1773. }
  1774. if($this->LoggedIn){
  1775. $this->DoUpload();
  1776. if(isset($_POST['settings_button'])){
  1777. if(isset($_POST['settings_title'])) $this->Title=$_POST['settings_title'];
  1778. if(isset($_POST['settings_short_title'])) $this->ShortTitle=$_POST['settings_short_title'];
  1779. if(isset($_POST['settings_display_name'])) $this->DisplayName=$_POST['settings_display_name'];
  1780. if(isset($_POST['settings_email'])) $this->EMail=$_POST['settings_email'];
  1781. if(isset($_POST['settings_special_navigation'])) $this->SpecialNavigation=$_POST['settings_special_navigation'];
  1782. if(isset($_POST['settings_special_footer'])) $this->SpecialFooter=$_POST['settings_special_footer'];
  1783. if(isset($_POST['settings_special_footer2'])) $this->SpecialFooter2=$_POST['settings_special_footer2'];
  1784. if(isset($_POST['settings_special_pinned'])) $this->SpecialPinned=$_POST['settings_special_pinned'];
  1785. if(isset($_POST['settings_default_gallery'])) $this->DefaultGallery=$_POST['settings_default_gallery'];
  1786. if(isset($_POST['settings_enable_comments'])) $this->CommentEnabled=True; else $this->CommentEnabled=False;
  1787. if(isset($_POST['settings_exp_host'])) $this->ExpHost=$_POST['settings_exp_host'];
  1788. if(isset($_POST['settings_exp_title'])) $this->ExpTitle=$_POST['settings_exp_title'];
  1789. if(isset($_POST['settings_exp_short_title'])) $this->ExpShortTitle=$_POST['settings_exp_short_title'];
  1790. if(isset($_POST['settings_exp_caution'])) $this->ExpCaution=$_POST['settings_exp_caution'];
  1791. if(isset($_POST['settings_exp_index'])) $this->ExpIndex=$_POST['settings_exp_index'];
  1792. if(isset($_POST['settings_exp_navigation'])) $this->ExpNavigation=$_POST['settings_exp_navigation'];
  1793. if(isset($_POST['settings_exp_footer'])) $this->ExpFooter=$_POST['settings_exp_footer'];
  1794. if(isset($_POST['settings_old_password'])&&password_verify($_POST['settings_old_password'], $this->Password)){
  1795. if(isset($_POST['settings_id'])) $this->Admin=$_POST['settings_id'];
  1796. if(isset($_POST['settings_new_password']) && isset($_POST['settings_new_password_redo']) &&
  1797. $_POST['settings_new_password'] = $_POST['settings_new_password_redo'])
  1798. {$this->Password=password_hash($_POST['settings_new_password'], PASSWORD_DEFAULT);}
  1799. $redirect=$_SERVER['REQUEST_URI'];
  1800. $this->DoLogout();
  1801. }
  1802. $this->WriteConfig();
  1803. return 0;
  1804. }
  1805. if(isset($_POST['settings_save_redirect'])){
  1806. if(isset($_POST['settings_redirect'])){
  1807. $this->BuildRedirectConfig($_POST['settings_redirect']);
  1808. }
  1809. $this->WriteConfig();
  1810. $redirect = 'index.php?extras=true'; return 0;
  1811. }
  1812. if(isset($_POST['settings_save_translation'])){
  1813. if(isset($_POST['settings_translation'])){
  1814. $f = fopen("custom_translations.md", "w"); fwrite($f,$_POST['settings_translation']); fflush($f); fclose($f);
  1815. }
  1816. $redirect = 'index.php?extras=true'; return 0;
  1817. }
  1818. if(isset($_GET['post'])){
  1819. if(isset($_GET['post_original'])){
  1820. echo $this->EditPost($_GET['post'],NULL,false,NULL,true,NULL,NULL,false,NULL);
  1821. exit;
  1822. }
  1823. }
  1824. if(isset($_GET['mark_delete']) && isset($_GET['target'])){
  1825. $this->EditPost($_GET['target'],NULL,$_GET['mark_delete']=='true',NULL,false,NULL,NULL,false,NULL);
  1826. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  1827. return 0;
  1828. }
  1829. if(isset($_GET['set_mark']) && isset($_GET['target'])){
  1830. $this->EditPost($_GET['target'],NULL,NULL,NULL,NULL,$_GET['set_mark'],NULL,false,NULL);
  1831. if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
  1832. return 0;
  1833. }
  1834. if(isset($_POST['post_button']) && isset($_POST['post_content'])){
  1835. $c = $_POST['post_content'];
  1836. if('有什么想说的' == $c){ return 0;}
  1837. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  1838. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  1839. $reply_to = (isset($_POST['post_reply_to'])&&$_POST['post_reply_to']!="")?$_POST['post_reply_to']:NULL;
  1840. $edit_id = (isset($_POST['post_edit_target'])&&$_POST['post_edit_target']!="")?$_POST['post_edit_target']:NULL;
  1841. $push_history = (isset($edit_id) && isset($_POST['post_record_edit']));
  1842. if(($edited = $this->EditPost($edit_id, $c, NULL, $reply_to,NULL,NULL,NULL,$push_history,NULL))!=NULL){
  1843. $redirect='?post='.$edited['id']; return 0;
  1844. };
  1845. }
  1846. if(isset($_POST['post_rename_confirm']) && isset($_POST['post_rename_name']) && isset($_GET['rename_post'])){
  1847. if(($edited =$this->EditPost($_GET['rename_post'],NULL,NULL,NULL,NULL,NULL,$_POST['post_rename_name'],false,NULL))!=NULL){
  1848. $redirect='?post='.$edited['id']; return 0;
  1849. };
  1850. }
  1851. if(isset($_GET['merge_threads'])&&$_GET['merge_threads']!=""){
  1852. if(preg_match('/([0-9]{14})\s+([0-9]{14})/u',$_GET['merge_threads'],$m)){
  1853. if(($pe = &$this->MergeThreads($m[1],$m[2]))!=$this->NULL_POST){ $redirect='?post='.$pe['id']; return 0; }
  1854. }
  1855. }
  1856. if(isset($_GET['merge_posts'])&&$_GET['merge_posts']!=""){
  1857. if(($pe = &$this->MergePosts($_GET['merge_posts']))!=$this->NULL_POST){
  1858. $redirect='?post='.$pe['id']; return 0;
  1859. }
  1860. }
  1861. if ($this->CommentEnabled && isset($_POST['comment_confirm']) && (isset($_GET['comment_to']))
  1862. && isset($_POST['comment_box']) && isset($_POST['comment_email']) && isset($_POST['comment_name'])){
  1863. $c = $_POST['comment_box'];
  1864. if(preg_match('/\[LAMDWIKIPOST/u',$c))
  1865. { $message='Can\'t use character sequence"[LAMDWIKIPOST" anywhere in the post...'; return 1; }
  1866. $comment_to = ($_GET['comment_to']!="")?$_GET['comment_to']:NULL;
  1867. if(($edited = $this->EditComment(NULL,
  1868. $_GET['comment_to'], $c, $_POST['comment_email'], $_POST['comment_name'],
  1869. isset($_POST['comment_link'])?$_POST['comment_link']:NULL,
  1870. $_SERVER['REMOTE_ADDR']))!=NULL){
  1871. $redirect='?post='.$_GET['post'];
  1872. return 0;
  1873. };
  1874. }
  1875. if(isset($_POST['gallery_edit_confirm']) && isset($_POST['gallery_edit_new_name']) && $_POST['gallery_edit_new_name']!=''){
  1876. $old_name = isset($_POST['gallery_edit_old_name'])?$_POST['gallery_edit_old_name']:"";
  1877. $new_name = $_POST['gallery_edit_new_name'];
  1878. if($old_name!=''){
  1879. $this->EditGallery($old_name, $new_name, false, true, null, null);
  1880. $redirect='?gallery='.$new_name;
  1881. }else{
  1882. $this->EditGallery(null, $new_name, false, true, null);
  1883. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  1884. }
  1885. return 0;
  1886. }
  1887. if(isset($_GET['gallery_edit_delete'])&&$_GET['gallery_edit_delete']!=null){
  1888. $this->EditGallery($_GET['gallery_edit_delete'], null, true, true, null, null);
  1889. if(isset($_GET['gallery'])) $redirect='?gallery=main'; else $redirect='index.php';
  1890. return 0;
  1891. }
  1892. if(isset($_POST['gallery_move_ops'])&&isset($_POST['gallery_move_ops'])){
  1893. if(preg_match('/^(REM|ADD)\s+(\S+)\s+(.*)$/u', $_POST['gallery_move_ops'], $ma)){
  1894. $this->ReadImages();
  1895. if(preg_match_all('/(\S+)/u', $ma[3], $files, PREG_SET_ORDER)) foreach($files as $name){
  1896. $this->EditImage($name[1], $ma[2], ($ma[1]=='REM'), NULL, NULL);
  1897. }
  1898. }
  1899. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  1900. return 0;
  1901. }
  1902. if(isset($_GET['gallery_set_featured'])&&isset($_GET['value'])){
  1903. $this->EditGallery($_GET['gallery_set_featured'], null, false, true, $_GET['value']!='false', null);
  1904. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  1905. return 0;
  1906. }
  1907. if(isset($_GET['gallery_set_experimental'])&&isset($_GET['value'])){
  1908. $this->EditGallery($_GET['gallery_set_experimental'], null, false, true, null, $_GET['value']!='false');
  1909. if(isset($_GET['gallery'])) $redirect='?gallery='.$_GET['gallery']; else $redirect='index.php';
  1910. return 0;
  1911. }
  1912. if(isset($_GET['image_list'])&&$_GET['image_list']!=""){
  1913. $this->ReadImages();
  1914. $gallery = $_GET['image_list'];
  1915. foreach($this->Images as $im){
  1916. if($gallery=='main'){ echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; continue; }
  1917. if(isset($im['galleries']) && isset($im['galleries'][0]) && in_array($gallery,$im['galleries'])) {
  1918. echo "[".$im['name'].",".(isset($im['thumb'])?$im['thumb']:$im['name'])."]"; }
  1919. }
  1920. exit;
  1921. }
  1922. $do_image_redirect = 0;
  1923. if(isset($_POST['image_button'])){
  1924. $this->ReadImages();
  1925. if(isset($_POST['image_ops_product_link'])){
  1926. if(preg_match('/([0-9]{14,}\.(jpg|png|jpeg|gif))/u',$_SERVER['REQUEST_URI'],$ma)){
  1927. $this->EditImage($ma[1], NULL, false, $_POST['image_ops_product_link'], NULL);
  1928. $redirect=$_SERVER['REQUEST_URI'];
  1929. $do_image_redirect = 1;
  1930. }
  1931. }
  1932. if(isset($_GET['pic'])&&isset($_POST['image_edit_new_name'])){
  1933. if (preg_match('/([0-9]{14,}\.(jpg|png|jpeg|gif))/u',$_GET['pic'],$ma) &&
  1934. preg_match('/\s*([0-9]{14,})\s*/u',$_POST['image_edit_new_name'],$man)){
  1935. $this->EditImage($ma[1], NULL, false, NULL, $man[1]);
  1936. $redirect=$this->GetRedirect(['pic'=>'images/'.$man[1].'.'.$ma[2]]);
  1937. $do_image_redirect = 1;
  1938. }
  1939. }
  1940. $this->NeedWriteImages = 1;
  1941. if($do_image_redirect) return 0;
  1942. }
  1943. //if(isset($_GET['rewrite_styles'])){
  1944. $this->WriteStyles();
  1945. // $redirect='?extras=true'; return 0;
  1946. //}
  1947. if(isset($_GET['regenerate_thumbnails'])){
  1948. $this->RegenerateThumbnails();
  1949. $redirect='?extras=true'; return 0;
  1950. }
  1951. if(isset($_GET['clear_all_logins'])){
  1952. $this->LoginTokens=[];
  1953. $this->WriteTokens();
  1954. }
  1955. }
  1956. return 0;
  1957. }
  1958. function PostProcessHTML($html,&$added_images=null,$do_product_info=false, &$product_info=null){
  1959. if(!$this->LoggedIn){
  1960. $html = preg_replace("/(<a[^>]*href=[\'\"])(.*?)([\'\"][^>]*)>(\#.*?<\/a>)/u","",$html);
  1961. }
  1962. $html = preg_replace("/(<a[^>]*href=[\'\"])([0-9]{14})([\'\"][^>]*)>(.*?<\/a>)/u","$1?post=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  1963. $html = preg_replace("/(<a[^>]*href=[\'\"])\@(.*?)([\'\"][^>]*)>(.*?<\/a>)/u","$1?category=$2$3 onclick='ShowWaitingBar()'>$4",$html);
  1964. $html = preg_replace("/(<a[^>]*href=[\'\"])((.*?:\/\/).*?)([\'\"][^>]*)(>)(.*?)(<\/a>)/u",
  1965. "$1$2$4 target='_blank'$5$6<sup>↗</sup>$7",$html);
  1966. $html = preg_replace("/<p>\s*\@.*?<\/p>/mu","",$html);
  1967. $html = preg_replace("/<p>\s*\{\s*INTERESTING\s+(.*?)\}\s*<\/p>/imu","",$html);
  1968. $html = preg_replace("/\/\/([0-9]{14})/imu","<span class='wscroll' id='$1'>".$this->T("链接位置")."</span>",$html);
  1969. $images = [];
  1970. $images_noclick = [];
  1971. $html = preg_replace_callback(
  1972. "/(<p>\s*)?(<img([^>]*)src=[\'\"])(images\/([0-9]{14,}\.(jpg|png|jpeg|gif)))([\'\"][^>]*)\/>(\s*<\/p>)?/u",
  1973. function($m) use (&$images,&$images_noclick) {
  1974. $orig_src = $src = $m[5]; $keep = false; $original = false;
  1975. if (preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[3]) ||
  1976. preg_match('/alt=[\'\"].*keep_inline.*[\'\"]/u',$m[7])) { $keep=true; }
  1977. if ($keep && preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[3]) ||
  1978. preg_match('/alt=[\'\"].*original.*[\'\"]/u',$m[7])) { $original=true; }
  1979. if(($im = &$this->FindImage($m[5]))!=NULL && isset($im['thumb'])){
  1980. $src = $im['thumb']; $orig_src=$im['file'];
  1981. }
  1982. if($this->InExperimentalMode){
  1983. $click = "<a href='".$orig_src."' class='original_img' target='_blank'>".
  1984. $m[2].$orig_src.$m[7]."></a>";
  1985. return $click;
  1986. }else{
  1987. $click = "<div class='imd'><a href='$orig_src' target='_blank' onclick='event.preventDefault();'>".
  1988. $m[2].($original?$orig_src:$src).$m[7]." data-imgsrc='".$m[5]."'".
  1989. (isset($im['product'])?" data-product='".$im['product']."'":"").
  1990. ($original?" class='original_img'":"")."></a></div>";
  1991. $images_noclick[]=$m[2].$src.$m[7].">";
  1992. $ret = "";
  1993. if($keep) { $ret = $click; }
  1994. else { $images[] = $click; }
  1995. if(isset($m[1])&&isset($m[8])&&$m[1]&&$m[8]) return $ret;
  1996. else return ((isset($m[1])&&$m[1]?$m[1]:"").$ret.(isset($m[8])&&$m[8]?$m[8]:""));
  1997. }
  1998. },$html,-1,$count);
  1999. $html = preg_replace('/<p>\s*<\/p>/u',"", $html); if($html==""){$html="<p>&nbsp;</p>";}
  2000. if(sizeof($images)){
  2001. if(sizeof($images)==1){$html.= $images[0];}
  2002. else{
  2003. $html.="<div class='p_row'>";
  2004. foreach($images as $img){
  2005. $html.="<div class='p_thumb'>".$img."</div>";
  2006. }
  2007. $html.="<div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div>";
  2008. }
  2009. }
  2010. if(sizeof($images_noclick)){
  2011. $added_images = $images_noclick;
  2012. }
  2013. if($do_product_info){
  2014. $html = preg_replace_callback("/\{PRICE\s+([^]]+?)\}/u",
  2015. function($m) use (&$product_info) { $product_info['price']=$m[1];return ""; },$html);
  2016. $html = preg_replace_callback("/\{SHORT\s+([^]]+?)\}/u",
  2017. function($m) use (&$product_info) { $product_info['short']=$m[1];return ""; },$html);
  2018. $html = preg_replace('/<p>\s*<\/p>/u',"", $html);
  2019. if (preg_match('/<h[1-5]>(.+?)<\/h/u',$html,$title)){ $product_info['title']=$title[1]; }
  2020. else { $product_info['title'] = $this->T('商品'); }
  2021. if(!isset($product_info['price'])) $product_info['price']=$this->T('未设置价格');
  2022. $html = preg_replace_callback("/\{PURCHASE\s+([^]]+?)\}/u",function($m) use (&$product_info) {
  2023. return "<a class='purchase_button' href=\"mailto:".$this->T($this->DisplayName)."<".$this->EMail.">?subject=".
  2024. $this->T('购买').' '.$product_info['title'].
  2025. "&body=".$this->T('你好!我想购买').$product_info['title'].urlencode(PHP_EOL.PHP_EOL).
  2026. $this->FullURL().urlencode(PHP_EOL.PHP_EOL)."\">".$m[1]."</a>"; },$html);
  2027. }
  2028. return $html;
  2029. }
  2030. function ConvertPost(&$post){
  2031. if(!isset($post['html'])){
  2032. $info=[];
  2033. $post['html'] = $this->PostProcessHTML($this->PDE->text($this->InsertReplacementSymbols($post['content'])),
  2034. $post['images'],
  2035. isset($post['product']), $info);
  2036. if(isset($post['product'])) $post['product']=$info;
  2037. }
  2038. }
  2039. function GetPostTitle(&$post, $h1_only=false){
  2040. if(!isset($post['title'])){
  2041. if($h1_only){
  2042. if(preg_match('/^#\s+(.*?)$/mu',$post['content'],$m)){return $m[1];}
  2043. return NULL;
  2044. }
  2045. if(preg_match('/^#{1,6}\s+(.*?)$/mu',$post['content'],$m)){$post['title']=$m[1];}
  2046. else{ $post['title'] = $this->T('未命名'); if(preg_match('/(.*)$/mu',$post['content'],$m))
  2047. {$post['title'].=' ('.strip_tags($this->PDE->text($m[1])).')';} }
  2048. }
  2049. return $post['title'];
  2050. }
  2051. function DetectPageType(){
  2052. if($this->InExperimentalMode) $this->PageType='experimental';
  2053. else if(isset($_GET['history'])) $this->PageType='history';
  2054. else if(isset($_GET['extras'])) $this->PageType='extras';
  2055. else if(isset($_GET['settings'])) $this->PageType='settings';
  2056. else if(isset($_GET['gallery'])) $this->PageType='gallery';
  2057. else if(isset($_GET['search'])) $this->PageType='search';
  2058. else if(isset($_GET['category'])) $this->PageType='category';
  2059. else if(isset($this->CurrentPostID)) $this->PageType = "post";
  2060. else if(isset($_GET['comments'])) $this->PageType='comments';
  2061. else $this->PageType = "main";
  2062. }
  2063. function MakeHeader(&$p){?>
  2064. <!DOCTYPE html><html lang='zh-Hans-CN'>
  2065. <head>
  2066. <meta charset='utf-8'>
  2067. <meta content="width=device-width, initial-scale=1" name="viewport">
  2068. <title><?=$this->InExperimentalMode?$this->T($this->ExpTitle):$this->T($this->Title)?></title>
  2069. <link href='styles/main.css' rel='stylesheet' type="text/css">
  2070. </head>
  2071. <div class='page'>
  2072. <script type='text/javascript'>
  2073. function toggle_mobile_show(a){a.classList.toggle('hidden_on_mobile')}
  2074. function ShowWaitingBar(){
  2075. wait = document.querySelector("#waiting_bar");
  2076. wait.style.display='';
  2077. }
  2078. function HideWaitingBar(){
  2079. wait = document.querySelector("#waiting_bar");
  2080. wait.style.display='none';
  2081. }
  2082. <?php if(!$this->InExperimentalMode){ ?>
  2083. function la_auto_grow(element){
  2084. s=window.scrollY;element.style.height="30px";element.style.height=(element.scrollHeight)+"px";window.scroll(0, s);
  2085. }
  2086. var scroll_l=0,scroll_c=0;in_center=1;
  2087. function ShowLeftSide(){
  2088. scroll_c = window.scrollY;
  2089. document.getElementById('div_left').classList.remove('hidden_on_mobile');
  2090. document.getElementById('div_center').classList.add('hidden_on_mobile');
  2091. window.scroll(0, scroll_l); in_center=0;
  2092. }
  2093. function ShowCenterSide(){
  2094. scroll_l = window.scrollY;
  2095. document.getElementById('div_center').classList.remove('hidden_on_mobile');
  2096. document.getElementById('div_left').classList.add('hidden_on_mobile');
  2097. window.scroll(0, scroll_c); in_center=1;
  2098. }
  2099. function ShowBackdrop(alpha=0.5){
  2100. b = document.getElementById('backdrop');
  2101. b.style="background-color:rgba(0,0,0,"+alpha+");";
  2102. b.style.animation='backdrop_fade_in 0.3s forwards';
  2103. b.style.display = 'block';
  2104. }
  2105. function HideBackdrop(){
  2106. b = document.getElementById('backdrop');
  2107. b.style.animation='backdrop_fade_out 0.3s forwards';
  2108. setTimeout(function(e1){e1.style.display='none';}, 300, b);
  2109. }
  2110. function ShowRightSide(big,elem_to_clone){
  2111. p = document.getElementById('pop_right');
  2112. if(elem_to_clone){
  2113. c = elem_to_clone.cloneNode(true);
  2114. c.id='side_bar_cloned';c.className="";c.style="";
  2115. p.querySelector('._content').appendChild(c);
  2116. }
  2117. p.classList.remove('pop_right','pop_right_big');
  2118. if(big) {p.classList.add('pop_right_big');p.style.animation='pop_slide_in_big 0.3s forwards';}
  2119. else {p.classList.add('pop_right');p.style.animation='pop_slide_in 0.3s forwards';}
  2120. p.style.display='block';
  2121. ShowBackdrop(0.5);
  2122. }
  2123. function HideRightSide(){
  2124. p = document.getElementById('pop_right');
  2125. if(side=p.querySelector('#side_bar_cloned')){
  2126. side.remove();
  2127. }
  2128. put = document.querySelector("#_uploader");
  2129. if(p.classList.contains('pop_right')){p.style.animation='pop_slide_out 0.3s forwards';}
  2130. else{p.style.animation='pop_slide_out_big 0.3s forwards';}
  2131. setTimeout(function(e1, e2){e1.style.display='none';if(e2)e2.style.display='none';}, 300, p, put);
  2132. HideBackdrop();
  2133. }
  2134. function ToggleLeftSide(){if(in_center)ShowLeftSide();else ShowCenterSide();}
  2135. function ScrollToPost(id){
  2136. if(!(post = document.querySelector("[data-post-id='"+id+"']"))) return;
  2137. post.scrollIntoView({ behavior: 'smooth', block: 'start'});
  2138. }
  2139. <?php } ?>
  2140. </script>
  2141. <header>
  2142. <?php if($this->InExperimentalMode){
  2143. $this->MakeExpNavButtons($p);
  2144. }else{
  2145. $this->MakeNavButtons($p);
  2146. } ?>
  2147. <hr />
  2148. <?php if(isset($this->WayBack)){
  2149. $time=(isset($_COOKIE['la_wayback']) && preg_match('/[0-9]{14}/u',$_COOKIE['la_wayback']))?$_COOKIE['la_wayback']:date('YmdHis');
  2150. $year=substr($time,0,4);$month=substr($time,4,2);$day=substr($time,6,2);
  2151. $hour=substr($time,8,2);$minute=substr($time,10,2);?> <div class='text_highlight'>
  2152. &nbsp;<b><span onclick='document.getElementById("wayback_config").classList.toggle("hidden_on_mobile")'>
  2153. <div class='wayback_close' onclick='event.stopPropagation()'><a href='<?=$this->GetRedirect()?>&set_wayback=false'>
  2154. <span class='hidden_on_mobile'><?=$this->T('退出')?></span>×&nbsp;</a></div>
  2155. <?=$this->T('正以过去的日期浏览')?></b><div id='wayback_config' class='wayback_expand hidden_on_mobile'>
  2156. <select id="wayback_year" onchange="UpdateWayback()"><?php for($y=$this->YearBegin;$y<=$this->YearEnd;$y++){ ?>
  2157. <option value="<?=$y?>"<?=$y==$year?" selected":""?>><?=$y?></option><?php } ?></select>
  2158. <br class='hidden_on_desktop' />
  2159. <select id="wayback_month" onchange="UpdateWayback()"><?php for($y=1;$y<=12;$y++){ ?>
  2160. <option value="<?=$y?>"<?=$y==$month?" selected":""?>><?=$y?></option><?php } ?></select>
  2161. <select id="wayback_day" onchange="UpdateWayback()"><?php for($y=1;$y<=31;$y++){ ?>
  2162. <option value="<?=$y?>"<?=$y==$day?" selected":""?>><?=$y?></option><?php } ?></select>
  2163. <br class='hidden_on_desktop' />
  2164. <select id="wayback_hour" onchange="UpdateWayback()"><?php for($y=0;$y<=23;$y++){ ?>
  2165. <option value="<?=$y?>"<?=$y==$hour?" selected":""?>><?=$y?></option><?php } ?></select>:
  2166. <select id="wayback_minute" onchange="UpdateWayback()"><?php for($y=0;$y<=59;$y++){ ?>
  2167. <option value="<?=$y?>"<?=$y==$minute?" selected":""?>><?=$y?></option><?php } ?></select>
  2168. <br class='hidden_on_desktop' />
  2169. <a id='wayback_see' href='#'><?=$this->T('查看')?> →</a>
  2170. </div><script>
  2171. var wbyear=document.querySelector('#wayback_year');
  2172. var wbmonth=document.querySelector('#wayback_month');
  2173. var wbday=document.querySelector('#wayback_day');
  2174. var wbhour=document.querySelector('#wayback_hour');
  2175. var wbminute=document.querySelector('#wayback_minute');
  2176. var wbsee=document.querySelector('#wayback_see');
  2177. getCookie = function(name) { var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
  2178. if (match) return match[2]; }
  2179. function UpdateWayback(){
  2180. str=getCookie("la_wayback");if(!str.match(/[0-9]{14}/g)){str="".padStart(14,"0");}
  2181. str = ""+wbyear.value.padStart(2,"0")+wbmonth.value.padStart(2,"0")+wbday.value.padStart(2,"0")
  2182. +wbhour.value.padStart(2,"0")+wbminute.value.padStart(2,"0")+str.substr(12);
  2183. wbsee.href='<?=$this->GetRedirect()?>&set_wayback='+str;
  2184. }
  2185. </script></div><?php } ?>
  2186. </header>
  2187. <div id='waiting_bar' style='display:none;'></div>
  2188. <script>ShowWaitingBar();window.addEventListener('load',(event) =>{HideWaitingBar();}); </script>
  2189. <?php if(!$this->InExperimentalMode){ ?>
  2190. <div id='post_menu' style='display:none;' class='pop_menu clean_a'>
  2191. <ul>
  2192. <li><span id='_time_hook' class='smaller'>时间</span>&nbsp;&nbsp;<a href='javascript:HidePopMenu();'>×</a></li>
  2193. <li><a id='share_copy'>⎘<?=$this->T('复制链接')?></a></li>
  2194. <hr />
  2195. <?php if($this->LoggedIn){ ?>
  2196. <li><a id='menu_history'><?=$this->T('历史')?></a>
  2197. <?php if(!isset($this->WayBack) && $this->PageType!='search'){ ?>
  2198. | <a id='menu_edit'><?=$this->T('修改')?></a><?php } ?></li>
  2199. <?php if(!isset($this->WayBack)){ ?><li>
  2200. <a id='menu_refer_copy'><?=$this->T('复制编号')?></a><?php if($this->PageType!='search'){ ?>
  2201. | <a id='menu_refer'><?=$this->T('引用')?></a><?php } ?><br class='hidden_on_desktop' />
  2202. </li>
  2203. <li><a id='menu_mark' href='javascript:ToggleRenameDetails()'><?=$this->T('改名')?></a> |
  2204. <a id='menu_mark' href='javascript:ToggleMarkDetails()'><?=$this->T('标记')?></a></li>
  2205. <li id='mark_details' style='display:none;'><b>
  2206. <a id='mark_set_clear' href='javascript:SetMark(-1);'>_</a>
  2207. <a id='mark_set_0' href='javascript:SetMark(0);'><?=$this->Markers[0]?></a>
  2208. <a id='mark_set_1' href='javascript:SetMark(1);'><?=$this->Markers[1]?></a>
  2209. <a id='mark_set_2' href='javascript:SetMark(2);'><?=$this->Markers[2]?></a>
  2210. <a id='mark_set_3' href='javascript:SetMark(3);'><?=$this->Markers[3]?></a>
  2211. <a id='mark_set_4' href='javascript:SetMark(4);'><?=$this->Markers[4]?></a>
  2212. <a id='mark_set_5' href='javascript:SetMark(5);'><?=$this->Markers[5]?></a>
  2213. <a id='mark_set_6' href='javascript:SetMark(6);'><?=$this->Markers[6]?></a>
  2214. <a id='mark_set_7' href='javascript:SetMark(7);'><?=$this->Markers[7]?></a>
  2215. </b></li>
  2216. <li id='rename_details' style='display:none;text-align:left;' class='smaller'>
  2217. <form action="" method="post" style='display:none;' id='post_rename_form'></form>
  2218. <input type='text' id='post_rename_name' name='post_rename_name' form="post_rename_form" style='width:9em;'>
  2219. <input class='button' type='submit' form='post_rename_form'
  2220. name='post_rename_confirm' id='post_rename_confirm' value='<?=$this->T('确认')?>'>
  2221. </li>
  2222. <hr />
  2223. <li><a id='menu_delete' class='smaller'></a></li><?php } ?>
  2224. <?php }else{ ?>
  2225. <li><a id='menu_history'><?=$this->T('历史')?></a></li>
  2226. <?php } ?>
  2227. </ul>
  2228. </div>
  2229. <div id='backdrop' style='display:none;' class='backdrop' onclick='HideRightSide()'
  2230. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"></div>
  2231. <div id='pop_right' class='pop_right' onclick='event.stopPropagation()'>
  2232. <div style='text-align:right;position:sticky;top:0;'><a class='clean_a' href='javascript:HideRightSide();'>
  2233. <?=$this->T('关闭')?>→</a></div>
  2234. <?php if($this->LoggedIn && in_array($this->PageType,['main','post'])){ ?>
  2235. <div id='_uploader' style='display:none;'>
  2236. <?php $this->MakeUploader(true); ?>
  2237. <p>&nbsp;</p>
  2238. <?php $this->MakeSideGalleryCode(); ?>
  2239. </div>
  2240. <?php } ?>
  2241. <div class='_content'></div>
  2242. </div>
  2243. <?php } ?>
  2244. <?php
  2245. }
  2246. function TranslatePostParts($html){
  2247. $html = preg_replace_callback('/>([^><]+?)</u', function($ma){
  2248. return ">".$this->T($ma[1])."<";
  2249. }, $html);
  2250. return $html;
  2251. }
  2252. function MakeNavButtons(&$p){?>
  2253. <a href='index.php' class='clean_a hidden_on_mobile' onclick='ShowWaitingBar()'><b><?=$this->T($this->Title)?></b></a>
  2254. <b><a class='hidden_on_desktop'
  2255. href='javascript:toggle_mobile_show(document.getElementById("mobile_nav"))'><?=$this->T($this->ShortTitle)?>...</a></b>
  2256. <div class='header_nav'>
  2257. <?php if($this->PageType=='post'){ ?>
  2258. <div style='float:right;' class='hidden_on_print'>
  2259. <?php if(isset($p) && isset($p['refs']) && isset($p['refs'][0])){ ?>
  2260. <span class='hidden_on_desktop'><a id='button_ref' href='javascript:ToggleLeftSide();'>
  2261. <?=$this->T('链接')?>(<?=sizeof($p['refs'])?>)</a></span>
  2262. <?php } ?>
  2263. <span class='hidden_on_wide hidden_on_print'>
  2264. <a id='button_toc'
  2265. href='javascript:ShowRightSide(true,document.querySelector("#div_right"));'><?=$this->T('目录')?></a></span></div>
  2266. <?php }else if($this->PageType=='history' && isset($_GET['version'])){ ?>
  2267. <div style='float:right;' class='hidden_on_print'>
  2268. <span class='hidden_on_desktop'><a id='button_ref' href='javascript:ToggleLeftSide();'>
  2269. <?=$this->T('历史')?></a></span></div>
  2270. <?php } ?>
  2271. <ul class='hidden_on_mobile hidden_on_print' id='mobile_nav' style='text-align:center;'>
  2272. <li class='hidden_on_mobile'><a href='?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
  2273. <li class='hidden_on_desktop_force block_on_mobile'>
  2274. <?php if($this->PageType!='main'){ ?>
  2275. <a href='index.php?part=recent' onclick='ShowWaitingBar()'><?=$this->T('最近')?></a> |
  2276. <a href='index.php?part=hot' onclick='ShowWaitingBar()'><?=$this->T('热门')?></a> |
  2277. <?php } else { ?>
  2278. <li class='hidden_on_desktop_force block_on_mobile'>
  2279. <a href='javascript:ShowCenterSide();toggle_mobile_show(document.getElementById("mobile_nav"));'><?=$this->T('最近')?></a> |
  2280. <a href='javascript:ShowLeftSide();toggle_mobile_show(document.getElementById("mobile_nav"));'><?=$this->T('热门')?></a> |
  2281. <?php } ?>
  2282. <a href='index.php?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a>
  2283. <?php if($this->LoggedIn){ ?>
  2284. | <span class='gray invert_a'><a href='index.php?comments=al最近l'>@</a></span><?php } ?></li>
  2285. <?php $this->SpecialNavigation;if(isset($this->SpecialNavigation) && ($p = &$this->GetPost($this->SpecialNavigation))!=NULL){
  2286. echo $this->TranslatePostParts($this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST));
  2287. } ?>
  2288. <li><a href='?search=' onclick='ShowWaitingBar()'><?=$this->T('搜索')?></a></li>
  2289. <?php if($this->LanguageAppendix=='zh'){ ?>
  2290. <li class='invert_a smaller'>
  2291. <a href='<?=$this->GetRedirect().'&set_language=en'?>' onclick='ShowWaitingBar()'><b>汉语</b>/English</a></li>
  2292. <?php }else { ?>
  2293. <li class='smaller'>
  2294. <a class='invert_a' href='<?=$this->GetRedirect().'&set_language=zh'?>' onclick='ShowWaitingBar()'>
  2295. 汉语/<b>English</b></a>
  2296. <br class='hidden_on_desktop' />
  2297. <span class='text_highlight'><a id='translate_button' target='_blank'>&nbsp;Google Translate&nbsp;</a></span></li>
  2298. <?php } ?>
  2299. </ul>
  2300. </div>
  2301. <?php
  2302. }
  2303. function MakeExpNavButtons(&$p){?>
  2304. <b><a href='index.php' class='hidden_on_mobile'><?=$this->T($this->ExpTitle)?></a></b>
  2305. <b><a class='hidden_on_desktop'
  2306. href='javascript:toggle_mobile_show(document.getElementById("mobile_nav"))'><?=$this->T($this->ExpShortTitle)?>...</a></b>
  2307. <ul class='hidden_on_mobile' id='mobile_nav' style='text-align:center;'>
  2308. <li class='hidden_on_desktop block_on_mobile'><a href='index.php'><?=$this->T('索引')?></a></li>
  2309. <?php $this->ExpNavigation;if(isset($this->ExpNavigation) && ($p = &$this->GetPost($this->ExpNavigation))!=NULL){
  2310. echo $this->TranslatePostParts($this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST));
  2311. } ?>
  2312. <?php if($this->LanguageAppendix=='zh'){ ?>
  2313. <li class='invert_a smaller'><a href='<?=$this->GetRedirect().'&set_language=en'?>'><b>汉语</b>/English</a></li>
  2314. <?php }else { ?>
  2315. <li class='invert_a smaller'><a href='<?=$this->GetRedirect().'&set_language=zh'?>'>汉语/<b>English</b></a></li>
  2316. <span class='text_highlight'><a id='translate_button' target='_blank'>&nbsp;Google Translate&nbsp;</a></span></li>
  2317. <?php } ?>
  2318. </ul>
  2319. <?php
  2320. }
  2321. function GenerateLinkedPosts($ht){
  2322. $ht = preg_replace_callback('/<p>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>(.*)<\/a>[\s]*<\/p>/u',
  2323. function($m){
  2324. $rp = &$this->GetPost($m[1]);
  2325. $s="<div class='smaller block post ref_compact gray'>".
  2326. "<a href='?post=".$m[1]."' class='post_access invert_a smaller' onclick='ShowWaitingBar()'>→</a>".
  2327. "<div class='post_ref'><div class='smaller'>".$m[2]."</div>".
  2328. (($rp!==NULL && $this->CanShowPost($rp))?$this->TranslatePostParts(
  2329. $this->GenerateSinglePost($rp,false,false,false,true,$this->NULL_POST,true)):$this->T("未找到该引用。")).
  2330. "</div></div>";
  2331. return $s;
  2332. },
  2333. $ht
  2334. );
  2335. $ht = preg_replace_callback('/<li>[\s]*<a[^>]*href=[\'\"]\?post=([0-9]{14})[\'\"][^>]*>PRODUCT\s+(.*)<\/a>[\s]*<\/li>/u',
  2336. function($m){
  2337. $rp = &$this->GetPost($m[1]);
  2338. $s="<div class='product_ref block post ref_compact'><a href='?post=".$m[1]."' class='clean_a' onclick='ShowWaitingBar()'>".
  2339. (($rp!==NULL && $this->CanShowPost($rp))?$this->TranslatePostParts(
  2340. $this->GenerateSinglePost($rp,true,false,false,true,$this->NULL_POST,true)):$this->T("未找到该引用。")).
  2341. "</a></div>";
  2342. return $s;
  2343. },
  2344. $ht
  2345. );
  2346. return $ht;
  2347. }
  2348. function ExtractBigTables($html, &$table_out){
  2349. $table = NULL;
  2350. $new_html = preg_replace_callback('/<p>\s*\{big_table\}\s*<\/p>\s*(<table>[\s\S]*?<\/table>)/u', function ($m) use (&$table){
  2351. $table = $m[1];
  2352. return "";
  2353. }, $html);
  2354. $table_out = $table;
  2355. return $new_html;
  2356. }
  2357. function GenerateSinglePost(&$post, $strip_tags, $generate_anchor=false, $generate_refs=false,
  2358. $generate_thumbs=false, &$table_out, $hide_long = false){
  2359. $this->ConvertPost($post);
  2360. if($generate_anchor){ $this->CreatePostAnchor($post); }
  2361. $ht = $post['html'];
  2362. if(isset($post['mark_value']) && $post['mark_value']==5 && ($generate_thumbs || !$generate_anchor)){
  2363. $ht="<div class='product_thumb'>".$post['images'][0]."</div>".
  2364. "<p class='bold'>".$post['product']['title']."</p>".
  2365. (isset($post['product']['short'])?("<p class='smaller gray'>".$post['product']['short']."</p>"):"").
  2366. "<p class='smaller bold'>".$post['product']['price']."</p>";
  2367. return $ht;
  2368. }
  2369. if($hide_long){
  2370. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>[\s\S]*/u',"<p class='smaller bold'>[".$this->T("阅读更多")."]</p>", $ht);
  2371. }else{
  2372. $ht = preg_replace('/<p>\s*\{read_more\}\s*<\/p>/u',"", $ht);
  2373. }
  2374. if ($strip_tags){
  2375. $ht = strip_tags($ht,'<b><i><h1><h2><h3><h4><p><blockquote><span>');
  2376. $ht = preg_replace('/<p>\s*<\/p>/u',"", $ht);
  2377. $ht = "<div class='post_ref_main'>".$ht."</div>";
  2378. }
  2379. else{
  2380. if($generate_refs) $ht = $this->GenerateLinkedPosts($ht);
  2381. if($table_out!=$this->NULL_POST){
  2382. $table = NULL; $ht = $this->ExtractBigTables($ht,$table);
  2383. $table_out = $table;
  2384. }else{
  2385. $ht = preg_replace('/<p>\s*\{big_table\}\s*<\/p>/u','',$ht);
  2386. }
  2387. }
  2388. if ($strip_tags && $generate_thumbs && isset($post['images']) && isset($post['images'][0])){
  2389. $ht.="<div class='post_ref_images'><ul class='side_thumb ref_thumb'>";
  2390. foreach($post['images'] as $im){
  2391. $ht.="<li class='file_thumb'>".$im."</li>";
  2392. }
  2393. $ht.="</ul></div>";
  2394. }
  2395. return $ht;
  2396. }
  2397. function MakeSinglePostExp(&$post){
  2398. $big_table = ""; ?>
  2399. <li class='post post_dummy'>
  2400. <?=$this->TranslatePostParts(
  2401. $this->GenerateSinglePost($post, false, false, true, false, $big_table, false)); ?>
  2402. </li>
  2403. <?php if($big_table!=$this->NULL_POST) echo "</ul></li><div class='table_top'>".$big_table.'</div>';?>
  2404. <?php
  2405. }
  2406. function MakeSinglePost(&$post, $show_link=false, $side=false, $extra_class_string=NULL,
  2407. $strip_tags=false, $show_thread_link=false, $show_reply_count=false, $generate_anchor=false,
  2408. $generate_thumb = false, $is_top = false, $force_hide_long=false){
  2409. $is_deleted = (isset($post['mark_delete'])&&$post['mark_delete']);
  2410. $mark_value = isset($post['mark_value'])?$this->Markers[$post['mark_value']]:-1;
  2411. $ref_count = isset($post['refs'])?sizeof($post['refs']):0;
  2412. $big_table = ($show_thread_link)?$this->NULL_POST:"";
  2413. $is_product = isset($post['mark_value'])&&$post['mark_value']==5;
  2414. $title = $generate_anchor?$this->GetPostTitle($post, true):NULL;
  2415. ?>
  2416. <?=$title?"<li class='print_title'><h1>".$title."</h1></li>":""?>
  2417. <li class='post<?=isset($extra_class_string)?' '.$extra_class_string:''?><?=$side?" post_box":""?>'
  2418. data-post-id='<?=$post['id']?>' <?=$is_deleted?"data-mark-delete='true'":""?>>
  2419. <?php if($mark_value>=0 && !$show_link && $mark_value!='P'){?>
  2420. <div class='smaller <?=$is_deleted?"gray":""?>'><?=$mark_value?> <?=$this->T('标记')?></div>
  2421. <?php } ?>
  2422. <?php if($is_top){?>
  2423. <div class='top_post_hint'><?=$this->T('置顶帖子')?><hr /></div>
  2424. <?php } ?>
  2425. <?php if(!$side && $show_link){ ?>
  2426. <a href='?post=<?=$post['id']?>' onclick='ShowWaitingBar()'>
  2427. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  2428. <?=isset($post['mark_value'])?$this->Markers[$post['mark_value']]:($ref_count?"":"→")?>
  2429. </div>
  2430. <?php if($ref_count){ ?>
  2431. <div class='post_access ref_count'><?=$ref_count?></div>
  2432. <?php } ?>
  2433. </a>
  2434. <?php } ?>
  2435. <?=$side?"<a href='?post={$post['id']}' onclick='ShowWaitingBar()'>":""?>
  2436. <div class='<?=$side?"":($show_link?'post_width':'post_width_big')?><?=$is_deleted?" deleted_post":""?>'>
  2437. <?php if(!$side && !$strip_tags){?>
  2438. <div class='post_menu_button _menu_hook' >+</div>
  2439. <?php } if($is_product&&!$generate_anchor){
  2440. echo "<p class='smaller gray'>".$this->T('商品')."</p>";
  2441. echo "<div class='product_ref clean_a'><a href='?post={$post['id']}'>";} ?>
  2442. <?=$this->TranslatePostParts(
  2443. $this->GenerateSinglePost($post, $strip_tags, $generate_anchor, true,
  2444. $generate_thumb,$big_table,($show_thread_link||$side||$force_hide_long))); ?>
  2445. <?php if($is_product&&!$generate_anchor){echo "</a></div>";} ?>
  2446. </div>
  2447. <?=$side?"</a>":""?> <?php
  2448. if(!$show_thread_link && $big_table!=$this->NULL_POST && !$side){
  2449. echo "</ul></li><div class='table_top'>".$big_table.'</div>';
  2450. ?><ul class='print_column'>
  2451. <li class='post<?=isset($extra_class_string)?' '.$extra_class_string:''?>' <?=$is_deleted?"data-mark-delete='true'":""?>>
  2452. <?php
  2453. }
  2454. if($show_thread_link && isset($post['tid']) && $this->CanShowPost($post['tid']['first']) &&
  2455. $post['tid']['first']['id']!=$post['id']){ ?>
  2456. <div class='gray smaller block opt_compact post'>
  2457. <a href='?post=<?=$post['tid']['first']['id']?>' onclick='ShowWaitingBar()'>
  2458. <div class='post_access invert_a hover_dark smaller'><?=isset($post['tid']['first']['mark_value'])?
  2459. $this->Markers[$post['tid']['first']['mark_value']]:"→"?></div></a>
  2460. <div class='post_width'><div class='smaller'><?=$this->T('回复给主题帖:')?></div>
  2461. <?=$this->TranslatePostParts(
  2462. $this->GenerateSinglePost($post['tid']['first'], false, false, false, true,$this->NULL_POST,true));?>
  2463. </div>
  2464. </div>
  2465. <?php }
  2466. if($show_reply_count && isset($post['tid'])){ ?>
  2467. <a class='smaller block invert_a' href='?post=<?=$post['tid']['last']['id']?>'><?=$post['tid']['count']?>
  2468. <?=$this->T('个回复')?></a>
  2469. <?php }
  2470. ?>
  2471. </li>
  2472. <?php
  2473. }
  2474. function MakePostingFields($reply_to=NULL, $show_hint=false){
  2475. if(isset($this->WayBack)){ ?>
  2476. <span class='gray'><i><?=$this->T('以过去日期浏览时不能发帖。')?></i></span>
  2477. <?php return; } ?>
  2478. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='post_form'></form>
  2479. <div class='smaller'><div style='display:<?=$show_hint?"block":"none"?>;'>
  2480. <span id='post_hint_text'><?=$this->T('继续补充该话题:')?></span></div>
  2481. <div id='post_hint_modify' style='display:none;'>
  2482. <input type="checkbox" name="post_record_edit" value="1" form='post_form' checked> <?=$this->T('新增历史记录');?></div></div>
  2483. <textarea id="post_content" name="post_content" rows="4" form='post_form'
  2484. onfocus="if (value =='<?=$this->T('有什么想说的')?>'){value ='';}la_auto_grow(this);"
  2485. onblur="if (value ==''){value='<?=$this->T('有什么想说的')?>';la_auto_grow(this);}"
  2486. oninput="la_auto_grow(this);" onload="la_auto_grow(this);"><?=$this->T('有什么想说的')?></textarea>
  2487. <input class='button' form="post_form" type="submit" name='post_button' value=<?=$this->T('发送')?>
  2488. onclick='ShowWaitingBar();' />
  2489. | <a class='gray smaller pointer' onclick='ShowSideUploader();'><?=$this->T('图片')?></a>
  2490. <div style='float:right;'>
  2491. <a class='gray smaller pointer' onclick='t=document.querySelector("#post_content");t.value="";la_auto_grow(t);'>
  2492. <?=$this->T('清空')?></a>
  2493. <a class='gray smaller pointer' style='display:none;' id='post_reply_restore' href='javascript:RestoreReply()'></a>
  2494. </div>
  2495. <input style='display:none;' type=input form="post_form" id='post_edit_target' name='post_edit_target' />
  2496. <script> la_auto_grow(document.getElementById("post_content"));</script>
  2497. <?php if($reply_to){ ?>
  2498. <input style='display:none;' type=input form="post_form" id='post_reply_to' name='post_reply_to' value='<?=$reply_to?>' />
  2499. <?php } ?>
  2500. <?php
  2501. }
  2502. function MakeCommentPosts(){
  2503. if(!$this->LoggedIn) return; ?>
  2504. <h2><?=$this->T('评论')?></h2><div class='spacer'></div>
  2505. <?php if(!$this->CommentEnabled){
  2506. echo "<p><span class='text_highlight'>&nbsp;".$this->T("已关闭评论")."&nbsp;</span></p><br />"; } ?>
  2507. <div class='comment'><ul>
  2508. <?php $i=0;
  2509. foreach(array_reverse($this->Posts) as $p){
  2510. if(!isset($p['comment_to'])) continue;
  2511. if($i < $this->CommentsPerPage * $this->CurrentOffset) {$i++; continue;}
  2512. $ht = $this->TranslatePostParts($this->GenerateSinglePost($p, false, false, false, false, $t, false));
  2513. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  2514. $post_to = $this->GetPost($p['comment_to']); $post_title = $this->GetPostTitle($post_to);
  2515. if(!$post_to) $post_title = "?";
  2516. $mail = "<span class='gray hidden_on_print'>&nbsp;".
  2517. "<a href='mailto:".$p['email']."'>@</a>&nbsp;".
  2518. (isset($p['ip'])?$p['ip']:"?")."&nbsp;<br class='hidden_on_desktop'/>".
  2519. "<a href='index.php?post=".$p['comment_to']."'>(".$post_title.")</a></span>";
  2520. echo "<li><p><b>".$name.":</b>".$mail."<br /></p>".$ht."</li>";
  2521. $i++;
  2522. }
  2523. ?>
  2524. </ul><br /></div>
  2525. <?php
  2526. }
  2527. function MakeRecentPosts($search_term=NULL, $category=NULL){?>
  2528. <div class='center' id='div_center'>
  2529. <h2><?=isset($search_term)?$this->T('搜索'):
  2530. (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
  2531. ($category=='none'?$this->T('未分类'):$this->T($category))):($this->T('最近')).
  2532. " <span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
  2533. ($this->LoggedIn?"<a href='index.php?comments=all'>@</a>":"")."</span>")?></h2>
  2534. <?php if(isset($search_term)){ ?>
  2535. <form action="index.php" method="post" style='display:none;' id='search_form'></form>
  2536. <input id="search_content" name="search_content" rows="4" form='search_form' type='text' value='<?=$search_term?>'>
  2537. <input class='button' form="search_form" type="submit" name='search_button' value=<?=$this->T('搜索')?>
  2538. <?php }else if(isset($category)){ ?>
  2539. <div></div>
  2540. <?php }else if($this->LoggedIn){ ?>
  2541. <div class='post_box_top _input_bundle'>
  2542. <?php $this->MakePostingFields(NULL,false); ?>
  2543. </div>
  2544. <?php } ?>
  2545. <ul class='print_column list'>
  2546. <?php
  2547. if(!isset($search_term) && !isset($category) &&
  2548. (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
  2549. $this->CanShowPost($p)){
  2550. $this->MakeSinglePost($p, true, false, false, false, true, false, false, false, true, false);
  2551. }
  2552. $i = 0;
  2553. if(isset($this->UsePosts[0])) foreach(array_reverse($this->UsePosts) as &$p){
  2554. if(!$this->CanShowPost($p) || $this->SkipProduct($p)) continue;
  2555. if(isset($p['tid'])){ /* Should always be set. */
  2556. $th = &$p['tid']; if($p['tid']['count']==0) continue;
  2557. if(!isset($search_term)) { $p = &$th['last']; }
  2558. }
  2559. if(isset($search_term)){
  2560. if ($search_term=='' || !preg_match("/".preg_quote($search_term)."/iu", $p['content'])) continue;
  2561. }else if(isset($category)){
  2562. $cat = isset($p['tid'])?(isset($p['tid']['categories'])?($p['tid']['categories']):[]):
  2563. (isset($p['categories'])?($p['categories']):[]);
  2564. if ($category=='none') { if($cat!=[]) continue; }
  2565. else{ if ($category=='' || !in_array($category, $cat)) continue; }
  2566. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  2567. }else{
  2568. if(in_array($p['id'],
  2569. [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation])) continue;
  2570. if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
  2571. }
  2572. if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
  2573. $this->MakeSinglePost($p, true, false, NULL, false, !isset($search_term), false, false, false, false, isset($search_term));
  2574. $i++;
  2575. if($i >= $this->PostsPerPage * (1+$this->CurrentOffset)) {break;}
  2576. }?>
  2577. </ul>
  2578. <div class='page_selector clean_a'>
  2579. <hr />
  2580. <a <?=$this->CurrentOffset>0?("href='index.php?offset=".($this->CurrentOffset-1).
  2581. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))."'"):""?>
  2582. <?=$this->CurrentOffset==0?"class='gray'":""?>><?=$this->T('上一页')?> ←</a>
  2583. <?=$this->CurrentOffset+1?>
  2584. <a href='index.php?offset=<?=($this->CurrentOffset+1).
  2585. (isset($search_term)?"&search=".$search_term:(isset($category)?"&category=".$category:""))?>'>
  2586. → <?=$this->T('下一页')?></a>
  2587. </div>
  2588. </div>
  2589. <?php
  2590. }
  2591. function MakeHotPosts($placeholder_only=false){?>
  2592. <div class='left hidden_on_mobile' id='div_left'>
  2593. <?php if ($placeholder_only){ ?>&nbsp;
  2594. <?php }else{ ?>
  2595. <h2><?=$this->T('热门')?></h2>
  2596. <ul>
  2597. <?php
  2598. $i=0;
  2599. foreach($this->Threads as &$th){
  2600. if(!isset($th['first']) || $th['count']==0){ continue; }
  2601. if(!$this->CanShowPost($th['first'])) continue;
  2602. if($i>=$this->HotPostCount) break;
  2603. $this->MakeSinglePost($th['first'], false, true, "post_preview", true, false, true, false, true, false, false);
  2604. $i++;
  2605. } ?>
  2606. </ul>
  2607. <?php } ?>
  2608. </div>
  2609. <?php
  2610. }
  2611. function MakeLinkedPosts(&$p){
  2612. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); ?>
  2613. <div class='left hidden_on_mobile' id='div_left'>
  2614. <h2<?=$has_ref?"":" class='gray'"?>><?=$this->T('链接')?></h2>
  2615. <?php
  2616. if($has_ref){ ?>
  2617. <span class='smaller'><?=sizeof($p['refs'])?> <?=$this->T('个引用:')?></span>
  2618. <ul><?php $count_product=0;
  2619. foreach(array_reverse($p['refs']) as &$pr){
  2620. $po = $this->GetPost($pr); if(isset($post['mark_value']) && $po['mark_value']==5){ $count_product++; continue; }
  2621. if(!$this->CanShowPost($po)){ continue; }
  2622. $this->MakeSinglePost($po, false, true, "post_preview", true, false, false, false, true, false, false);
  2623. }
  2624. ?></ul>
  2625. <?php if($count_product){ ?> <span class='smaller'><?=$this->T('和').' '.$count_product.' '.$this->T('个商品')?></span> <?php }
  2626. }else{ ?>
  2627. <span class='gray smaller'><?=$this->T('没有帖子链接到这里。')?></span>
  2628. <?php } ?>
  2629. </div>
  2630. <?php
  2631. }
  2632. function MakeLinkedPostsExp(&$p){
  2633. $has_ref = isset($p['refs'])&&isset($p['refs'][0]); ?>
  2634. <div class='center_exp post_dummy smaller'>
  2635. <hr />
  2636. <h3<?=$has_ref?"":" class='gray'"?>><?=$this->T('链接')?></h3>
  2637. <?php
  2638. if($has_ref){ ?>
  2639. <div class='smaller'><?=sizeof($p['refs'])?> <?=$this->T('个引用:')?></div>
  2640. <ul><?php $count_product=0;
  2641. foreach(array_reverse($p['refs']) as &$pr){
  2642. echo "<li class='post_dummy'><a href='?post=".$pr."'>".$this->T($this->GetPostTitle($this->GetPost($pr),false)).
  2643. "</a></li>";
  2644. }
  2645. ?></ul>
  2646. <?php if($count_product){ ?> <span class='smaller'><?=$this->T('和').' '.$count_product.' '.$this->T('个商品')?></span> <?php }
  2647. }else{ ?>
  2648. <div class='gray smaller'><?=$this->T('没有帖子链接到这里。')?></div>
  2649. <?php } ?>
  2650. <div style='margin-bottom:4rem;'>&nbsp;</div>
  2651. </div>
  2652. <?php
  2653. }
  2654. function MakePostHistoryList(&$ah, &$post,$version=NULL, $show_latest=true){
  2655. $latest_ver=isset($post['version'])?$post['version']:$post['id'];
  2656. $can_show=1; if(isset($this->WayBack) && $latest_ver>$this->WayBack) $can_show=0;
  2657. $title = NULL; if(!isset($ah) || ($show_latest && $can_show)) { $title=$this->T($this->GetPostTitle($post, false)); }
  2658. else{ $ver = &$ah['list'][sizeof($ah['list'])-1]; $title= $this->GetPostTitle($ver); }
  2659. if(!isset($title)) $title=$this->T('未命名');
  2660. if(!isset($ah)){ ?>
  2661. <h2><?=$this->T('没有历史记录')?></h2>
  2662. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$post['id']?>'><?=$title?></a></span><br />
  2663. <?php }else{ ?>
  2664. <h2><?=$this->T('历史记录')?></h2>
  2665. <span class='omittable_title smaller'><?=$this->T('帖子')?> <a href='?post=<?=$ah['id']?>'><?=$title?></a></span><br />
  2666. <div class='list'><ul>
  2667. <?php if($show_latest && $can_show){ $post['history_displayed']=1; ?>
  2668. <li class='<?=isset($version)&&$version==$latest_ver?" post_current_row bold":""?>' style='list-style:"";'>
  2669. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$latest_ver?>'><?=$this->ReadableTime($latest_ver)?></a>
  2670. <span class='smaller gray'><?=$this->T('长度').' '.strlen($post['content'])?></span>
  2671. <?php if(isset($post['merged_from'][0])){ ?><ul><?php foreach($post['merged_from'] as $from){
  2672. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  2673. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  2674. <li><a href='?post=<?=$ver['id']?>&history=1'>
  2675. <?=$this->GetPostTitle($ver);?></a>
  2676. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  2677. <?php } ?></ul><?php } ?>
  2678. <?php if(isset($post['merged_thread'][0][0])){ $pm=$post['merged_thread'][0][0];
  2679. $mah = &$this->GetArchiveHandle($pm);
  2680. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  2681. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  2682. <span class='smaller gray'><?=sizeof($post['merged_thread'][0]);?> <?=$this->T('个帖子')?></span></li></ul>
  2683. <? } ?>
  2684. </li><?php } ?>
  2685. <?php if(isset($ah['list'][0])) foreach(array_reverse($ah['list']) as &$ver){
  2686. if(isset($this->WayBack) && $ver['version']>$this->WayBack) continue;
  2687. if(isset($ver['history_displayed']) && $ver['history_displayed']) continue; ?>
  2688. <li<?=isset($version)&&$version==$ver['version']?" class='post_current_row bold'":""?>>
  2689. <a href='?post=<?=$this->CurrentPostID?>&history=1&version=<?=$ver['version']?>'><?=$this->ReadableTime($ver['version'])?></a>
  2690. <span class='smaller gray'> <?=$this->T('长度').' '.strlen($ver['content'])?></span>
  2691. <?php if(isset($ver['merged_thread'][0][0])){ $pm=$ver['merged_thread'][0][0];
  2692. $mah = &$this->GetArchiveHandle($pm); $mver = &$this->GetPost($pm);
  2693. if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  2694. <ul><li><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver);?></a> <?=$this->T('并入这里')?>
  2695. <span class='smaller gray'> <?=sizeof($ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></li></ul>
  2696. <? } if(isset($ver['merged_from'][0])){ ?><ul><?php foreach($ver['merged_from'] as $from){
  2697. $fromah = &$this->GetArchiveHandle($from); if(!isset($fromah)) continue;
  2698. $ver = &$fromah['list'][sizeof($fromah['list'])-1];?>
  2699. <li><a href='?post=<?=$ver['id']?>&history=1'>
  2700. <?=$this->GetPostTitle($ver);?></a>
  2701. <span class='smaller gray'><?=$this->T('长度').' '.strlen($ver['content'])?></span></li>
  2702. <?php } ?></ul></li><?php } ?>
  2703. <?php } ?></ul></div>
  2704. <?php } ?>
  2705. <?php
  2706. }
  2707. function MakePostDiff(&$this_ver, &$last_ver){
  2708. if(!isset($this_ver)){ ?>
  2709. <h2 class='gray'><?=$this->T('版本不存在')?></h2>
  2710. <?php }else{ ?>
  2711. <h2><?=$this->T('差异')?></h2>
  2712. <?php if(isset($this_ver['merged_thread']) && isset($this_ver['merged_thread'][0][0])){
  2713. $pm=$this_ver['merged_thread'][0][0]; $mah = &$this->GetArchiveHandle($pm);
  2714. $mver = &$this->GetPost($pm); if(!isset($mver) && isset($mah)) $mver = &$mah['list'][sizeof($mah['list'])-1]; ?>
  2715. <p><?=$this->T('话题')?> <a href='?post=<?=$mver['id']?>&history=1'><?=$this->GetPostTitle($mver)?></a> <?=$this->T('并入这里')?>
  2716. <br /><span class='smaller gray'> <?=sizeof($this_ver['merged_thread'][0]);?> <?=$this->T('个帖子')?> </span></p>
  2717. <? }else{ ?>
  2718. <table class='diff_table'><thead>
  2719. <tr><td><?php if(!isset($last_ver)){ ?><?=$this->T('没有更旧的版本')?><?php }else{ ?>
  2720. <?=$this->T('上一个版本')?><br /><?=$this->ReadableTime($last_ver['version'])?><?php } ?></td>
  2721. <td class='text_highlight bold'><?=$this->T('选择的版本')?><br /><?=$this->ReadableTime($this_ver['version'])?></td></tr>
  2722. </thead><tbody>
  2723. <tr><td><pre><?=isset($last_ver)?$last_ver['content']:""?></pre></td><td><pre><?=$this_ver['content']?></pre></td></tr>
  2724. </tbody>
  2725. </table>
  2726. <?php } ?>
  2727. <br /><a class='smaller' href='?post=<?=$this_ver['id']?>&set_wayback=<?=isset($this_ver['version'])?$this_ver['version']:$this_ver['id']?>'><?=$this->T('前往该版本时间')?> ←</a>
  2728. <?php } ?>
  2729. <?php
  2730. }
  2731. function MakePostHistory(&$post, $version=NULL){
  2732. $ah = &$this->GetArchiveHandle($this->CurrentPostID);
  2733. $p = &$post; if(!isset($post)){ $p=&$ah['list'][0]; }
  2734. $show_latest = isset($ah)?(!isset($ah['list'][sizeof($ah['list'])-1]['merged_into'])):true;
  2735. ?>
  2736. <div class='left hidden_on_mobile history' id='div_left'>
  2737. <?php if (isset($version)){
  2738. $this->MakePostHistoryList($ah, $p, $version, $show_latest);
  2739. }else{ echo "&nbsp;"; } ?>
  2740. </div>
  2741. <div class='center history' id='div_center'>
  2742. <?php if (!isset($version)){
  2743. $this->MakePostHistoryList($ah, $p, NULL, $show_latest);
  2744. }else{
  2745. $this_ver = NULL; $next_ver = NULL; $last_ver=NULL;
  2746. $this_ver = &$this->GetArchiveVersion($ah, $version, $next_ver, $last_ver);
  2747. if(!isset($this_ver)){$this_ver = $p; $last_ver=$ah['list'][sizeof($ah['list'])-1];}
  2748. $this->MakePostDiff($this_ver, $last_ver, $p);
  2749. } ?>
  2750. </div>
  2751. <?php
  2752. }
  2753. function MakeCommentSection(&$post){
  2754. if(!$this->CommentEnabled){ return; }
  2755. $to_post = isset($post['tid'])?$post['tid']['first']:$post;
  2756. $comment_count = (isset($to_post['comments']) && isset($to_post['comments'][0]))?count($to_post['comments']):0;
  2757. ?><div class='comment'>
  2758. <br /><h2><?=$this->T('评论')?> (<?=$comment_count;?>)</h2><div class='spacer'></div>
  2759. <?php if($comment_count) { echo "<ul>";
  2760. foreach($to_post['comments'] as $p){
  2761. $ht = $this->TranslatePostParts($this->GenerateSinglePost($p, false, false, false, false, $t, false));
  2762. $name = isset($p['link'])?("<a href='".$p['link']."'>".$p['name']."↗</a>"):$p['name'];
  2763. $mail = $this->LoggedIn?("<span class='gray clean_a hidden_on_print'>&nbsp;".
  2764. "<a href='mailto:".$p['email']."'>@</a>&nbsp;</span>"):"";
  2765. echo "<li><p><b>".$name.":</b>".$mail."</p>".$ht."</li>";
  2766. }
  2767. echo "</ul>";
  2768. } else {
  2769. echo $this->T('还没有评论');
  2770. } ?>
  2771. <div class='hidden_on_print'>
  2772. <div class='spacer'></div>
  2773. <form action="index.php?post=<?=$this->CurrentPostID?>&comment_to=<?=$to_post['id']?>"
  2774. method="post" style="display:none;" id="comment_form"></form>
  2775. <p><a class='text_highlight bold clean_a'
  2776. onclick='document.getElementById("comment_box").style.display="block";this.parentNode.style.display="none"'>
  2777. &nbsp;<?=$this->T('写评论');?>&nbsp;</a></p>
  2778. <div id='comment_box' style='display:none;'>
  2779. <p class='gray' style='margin-bottom:0.5em;'><?=$this->T('您的邮箱不会公开展示。');?></p>
  2780. <table style='white-space:nowrap;'>
  2781. <tr><td colspan='2'>
  2782. <textarea id="comment_box" name="comment_box" rows="4" class='full_box' form='comment_form'
  2783. oninput="CommentUpdated();" ></textarea>
  2784. </td></tr>
  2785. <tr><td><?=$this->T('电子邮件')?>*</td><td><?=$this->T('称呼')?>*</td></tr>
  2786. <tr><td><input type="text" form="comment_form" id='comment_email' name='comment_email'
  2787. class='full_box' oninput="CommentUpdated();" /></td>
  2788. <td><input type="text" form="comment_form" id='comment_name' name='comment_name'
  2789. class='full_box' oninput="CommentUpdated();" /></td></tr>
  2790. <tr><td colspan='2'><?=$this->T('个人网站')?></td></tr>
  2791. <tr><td colspan='2'>
  2792. <input type="text" form="comment_form" id='comment_link' name='comment_link'
  2793. class='full_box' oninput="CommentUpdated();" />
  2794. </td></tr>
  2795. <tr><td colspan='2'>
  2796. <div class='spacer'></div>
  2797. <input class='button text_highlight bigger' type='submit' form='comment_form'
  2798. name='comment_confirm' id='comment_confirm' value='&nbsp;<?=$this->T('发送')?>&nbsp;'>
  2799. </td></tr>
  2800. </table></div>
  2801. <script>
  2802. const IsValidEmail = (email) => {
  2803. 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,}))$/);
  2804. };
  2805. function IsValidHttpUrl(string) {
  2806. let url; try{ url = new URL(string); } catch (_) { return false; }
  2807. return url.protocol === "http:" || url.protocol === "https:";
  2808. }
  2809. var cbox = document.getElementById('comment_box');
  2810. var cemail = document.getElementById('comment_email');
  2811. var cname = document.getElementById('comment_name');
  2812. var clink = document.getElementById('comment_link');
  2813. var cconfirm = document.getElementById('comment_confirm');
  2814. function CommentUpdated(){
  2815. cconfirm.disabled=true;
  2816. if (cemail.value!="" && IsValidEmail(cemail.value) &&
  2817. cbox.innerText.length>2 && cname.value.length>2 &&
  2818. clink.value=="" || IsValidHttpUrl(clink.value)){
  2819. cconfirm.removeAttribute("disabled");
  2820. }
  2821. }
  2822. CommentUpdated();
  2823. </script>
  2824. </div>
  2825. </div>
  2826. <?php
  2827. }
  2828. function MakeInterestingSection(&$th){
  2829. $this->Anchors = [];
  2830. $c = &$th['first']['content'];
  2831. $this->ConvertPost($th['first']);
  2832. $ht = $th['first']['html'];
  2833. ?>
  2834. <script>function ClickImage(post_access){im=post_access.querySelector('img');if(im){im.click();}}</script>
  2835. <div class='center_full' id='div_center'>
  2836. <?php $this->MakePostTools(); ?>
  2837. <h2 class='hidden_on_print'><?=$this->T('有趣')?>
  2838. <a class='gray clean_a' href='?post=<?=$th['first']['id']?>'>→</a></h2>
  2839. <ul><li class='post post_width_big' data-post-id='<?=$th['first']['id']?>'>
  2840. <div class='post_menu_button _menu_hook' onclick='ShowPostMenu(this.parentNode);'>+</div><?=$this->TranslatePostParts($ht)?>
  2841. <?php if($this->LoggedIn && (!$this->InExperimentalMode)){ ?>
  2842. <div class='post_width_big hidden_on_print'><br />
  2843. <?php $this->MakePostingFields($th['last']['id'], true);?><br />
  2844. </div>
  2845. <?php } ?>
  2846. <table><thead><tr><th></th><?php foreach($th['interesting'] as $header){ ?>
  2847. <th><?=$this->T($header);?></th>
  2848. <?php } ?></tr></thead><tbody class='interesting_tbody'>
  2849. <?php $plist = array_reverse(array_slice($th['arr'],1));
  2850. foreach($plist as &$p){
  2851. $this->ConvertPost($p);
  2852. $mark_value = isset($p['mark_value'])?$this->Markers[$p['mark_value']]:-1;
  2853. $ref_count = isset($p['refs'])?sizeof($p['refs']):0;
  2854. $is_current = $p['id']==$this->CurrentPostID;
  2855. $is_deleted = (isset($p['mark_delete'])&&$p['mark_delete']); ?>
  2856. <tr class='<?=$is_current?"post_current_row":""?><?=$is_deleted?" deleted_post":""?>'
  2857. data-post-id='<?=$p['id']?>' <?=$is_deleted?"data-mark-delete='true'":""?>
  2858. onDblClick='ClickImage(this)'><td>
  2859. <a <?=$is_current?"":("href='?post=".$p['id']."' onclick='ShowWaitingBar()'");?> class='clean_a paa'>
  2860. <div class='post_access <?=($mark_value<0 || $ref_count)?"invert_a":""?> hover_dark'>
  2861. <?=isset($p['mark_value'])?$this->Markers[$p['mark_value']]:($ref_count?"":"→")?>
  2862. </div>
  2863. <?php if($ref_count){ ?>
  2864. <div class='post_access ref_count'><?=$ref_count?></div>
  2865. <?php } ?></a>
  2866. <?=$this->TranslatePostParts($p['html']);?>
  2867. <a class='_menu_hook clean_a post_menu_button' onclick='ShowPostMenu(this.parentNode.parentNode);'>+</a></td></tr>
  2868. <?php if($is_current && $ref_count>0){ ?><tr class='post_current_row'><td><p>&nbsp;</p><ul class='smaller'>
  2869. <?php foreach($p['refs'] as $ref){
  2870. $po = $this->GetPost($ref);
  2871. if(isset($post['mark_value']) && $post['mark_value']==5){ $count_product++; continue; }
  2872. if(!$this->CanShowPost($po)){ continue; }
  2873. echo "<li><a href='?post=".$po['id']."'>".$this->GetPostTitle($po)."</li>";
  2874. } ?>
  2875. </ul></td></tr><?php } ?>
  2876. <?php } ?>
  2877. </tbody></table>
  2878. </li></ul>
  2879. <br />
  2880. <?php $this->MakeCommentSection($th['first']); ?>
  2881. </div>
  2882. <?php return true;
  2883. }
  2884. function CssNumberID($id){
  2885. return "#\\3".substr($id,0,1)." ".substr($id,1);
  2886. }
  2887. function MakePostTools(){
  2888. if($this->LoggedIn && !isset($this->WayBack)){ ?><div class='smaller gray hidden_on_print clean_a'>
  2889. <a id='merge_cancel' href='javascript:{TogglePostSelectMode(false,true);ToggleThreadMerge(false,true);}'>
  2890. <?=$this->T('工具')?></a>:<div class='hidden_on_mobile' style='display:inline'>
  2891. <span id='merge_post_btn'><a href='javascript:TogglePostSelectMode()'><?=$this->T('合并帖子')?></a></span>
  2892. | <span id='merge_thread_btn'><a href='javascript:ToggleThreadMerge()'><?=$this->T('合并话题')?></a></span>
  2893. </div>
  2894. <select class='hidden_on_desktop' id='merge_select'
  2895. onchange="if(this.selectedIndex==1){TogglePostSelectMode(true);}else if(this.selectedIndex==2){ToggleThreadMerge(true);}">
  2896. <option value='-1' selected>--</option>
  2897. <option value='1'><?=$this->T('合并帖子')?></option>
  2898. <option value='2'><?=$this->T('合并话题')?></option></select>
  2899. <div style='display:none;' id='merge_post_dialog' class='text_highlight small_pad align_right'>
  2900. <div style='display:inline;'><?=$this->T('将合并');?> <span id='merge_post_count'></span> <?=$this->T('个帖子');?></div>
  2901. <span class='clean_a bold align_right'><a id='merge_post'>&nbsp;<?=$this->T('执行');?></a></span></div>
  2902. <div style='display:none;overflow:auto' id='merge_thread_dialog' class='text_highlight small_pad align_right'>
  2903. <div style='display:inline;'><?=$this->T('合并到话题');?></div>
  2904. <input id="merge_thread_target" type="text" style="width:9em;display:inline" onChange='ThreadMergeInput(this);' onInput='ThreadMergeInput(this);'>
  2905. <span class='clean_a bold align_right'><a id='merge_thread'>&nbsp;<?=$this->T('执行');?></a></span></div>
  2906. </div><div class='spacer'></div><?php
  2907. }
  2908. }
  2909. function MakePostSection(&$post){
  2910. $this->Anchors = [];
  2911. if(isset($this->TagID)){ ?><style><?=$this->CssNumberID($this->TagID);?>{display:block;}</style><?php } ?>
  2912. <div class='center' id='div_center'>
  2913. <h2 class='hidden_on_print'>
  2914. <?php $th=NULL; $is_thread = isset($post['tid']['count'])&&$post['tid']['count']>1; if($is_thread){ $th = $post['tid'];?>
  2915. <?=$this->T('话题')?> <?php }else{ ?> <?=$this->T('详细')?>
  2916. <?php } ?></h2>
  2917. <?php $cat = NULL;
  2918. if($is_thread) { if(isset($th['categories']) && isset($th['categories'][0])){ $cat = $th['categories']; } }
  2919. else { if(isset($post['categories']) && isset($post['categories'][0])) { $cat = $post['categories']; } }
  2920. $this->MakePostTools();
  2921. if($cat){ ?>
  2922. <p><b><?=$this->T('分类')?></b> | <?php foreach($cat as $c){
  2923. echo "<a href='?category=".$c."'>".($c=='none'?$this->T('未分类'):$this->T($c))."</a> "; } ?></p>
  2924. <?php } ?>
  2925. <ul class='print_column'>
  2926. <?php
  2927. if($is_thread){
  2928. foreach($th['arr'] as &$p){
  2929. $use_class = ($p == $post)?'focused_post':'';
  2930. $show_link = ($p == $post)?false:true;
  2931. $make_title = ($p == $post);
  2932. $this->MakeSinglePost($p,$show_link,false,$use_class,false, false, false, true, false, false);
  2933. if($make_title){?>
  2934. <script>
  2935. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($p['html']),0,1000)))?>";
  2936. </script>
  2937. <?php }
  2938. }
  2939. }else{
  2940. $this->MakeSinglePost($post,false, false, 'focused_post',false, false, false, true, false, false);
  2941. ?><script>
  2942. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($post['html']),0,1000)))?>";
  2943. </script><?php
  2944. } ?>
  2945. <div class='smaller align_right'>
  2946. <span class='gray'><?=$this->ReadableTime($post['tid']['first']['id']);?></span>
  2947. <br class='hidden_on_desktop' /><?=$this->ReadableTime(isset($post['tid']['last']['version'])?
  2948. $post['tid']['last']['version']:$post['tid']['last']['id']);?>
  2949. </div>
  2950. <?php if($this->LoggedIn && (!$this->InExperimentalMode)){ ?>
  2951. <div class='post_width_big hidden_on_print'>
  2952. <br /><?php $this->MakePostingFields($is_thread?$th['last']['id']:$post['id'], true);?>
  2953. </div>
  2954. <?php }
  2955. $this->MakeCommentSection($post);
  2956. ?>
  2957. </ul>
  2958. </div>
  2959. <?php
  2960. }
  2961. function MakePostSectionExp(&$post){
  2962. $this->Anchors = []; $is_thread = isset($post['tid']);
  2963. ?>
  2964. <div class='center_exp' id='div_center'>
  2965. <ul>
  2966. <?php
  2967. if($is_thread){
  2968. $th = &$post['tid'];
  2969. foreach($th['arr'] as &$p){
  2970. $this->MakeSinglePostExp($p);
  2971. if($p == $th['first']){?>
  2972. <script>
  2973. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($p['html']),0,1000)))?>";
  2974. </script>
  2975. <?php }
  2976. }
  2977. }else{
  2978. $this->MakeSinglePostExp($post);
  2979. if($post['id']!=$this->ExpIndex){ ?><script>
  2980. document.title+=" | <?=addslashes(preg_replace('/\r|\n/u', ' ', mb_substr(strip_tags($post['html']),0,1000)))?>";
  2981. </script><?php }
  2982. } ?>
  2983. </ul>
  2984. </div>
  2985. <?php
  2986. }
  2987. function MakeSideGalleryCode(){?>
  2988. <div>
  2989. <h3><?=$this->T('点击图片以插入:')?></h3>
  2990. <select id="side_gallery_select" onchange="RefreshSideGallery()">
  2991. <option value="main"><?=$this->T('全部')?></option>
  2992. <?php if($this->LoggedIn){ ?>
  2993. <option value="trash"><?=$this->T('垃圾桶')?></option>
  2994. <?php }?>
  2995. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  2996. <option value="<?=$g['name']?>"><?=$g['name']?></option>
  2997. <?php } ?>
  2998. </select>
  2999. <div id='side_gallery'>
  3000. </div>
  3001. </div>
  3002. <script>
  3003. function InsertImage(imgname){
  3004. t = document.querySelector("#post_content");
  3005. v = t.value;
  3006. t.value = v.slice(0, t.selectionStart) + "![<?=$this->T('图片')?>](images/"+imgname+")"+ v.slice(t.selectionEnd);
  3007. la_auto_grow(t);
  3008. }
  3009. function RefreshSideGallery(){
  3010. let xhr = new XMLHttpRequest();
  3011. xhr.onreadystatechange = (function(){
  3012. if (this.readyState === this.DONE) {
  3013. if (this.status === 200) {
  3014. ind = document.querySelector("#side_gallery");
  3015. if(res = xhr.responseText.matchAll(/\[(.*?),(.*?)\]/gu)){
  3016. str = "<ul class='side_thumb'>"
  3017. for (const m of res) {
  3018. str+="<li><div class='file_thumb' onclick='InsertImage(\""+m[1]+"\")'>"+
  3019. "<img src='"+m[2]+"' /></div>"
  3020. }
  3021. str += "</ul>"
  3022. ind.innerHTML = str;
  3023. }
  3024. }
  3025. }
  3026. });
  3027. xhr.open("GET", "?image_list="+document.querySelector("#side_gallery_select").value, true);
  3028. xhr.send();
  3029. }
  3030. </script>
  3031. <?php
  3032. }
  3033. function MakeUploader($is_side=false){ ?>
  3034. <div id='upload_operation_area' class='hidden_on_print'>
  3035. <p><?=$this->T('选择、粘贴或者拖动到页面以上传图片。')?></p>
  3036. <input type="file" id='upload_selector' accept="image/x-png,image/png,image/gif,image/jpeg" multiple/>
  3037. <ul id='file_list'>
  3038. </ul>
  3039. <div class='smaller gray' id='upload_hint'><?=$this->T('就绪')?></div>
  3040. </div>
  3041. <a id='upload_click' class='hidden_on_print'
  3042. href='javascript:UploadList()'<?=$is_side?" data-is-side='true'":""?>><?=$this->T('上传列表中的文件')?></a>
  3043. <script>
  3044. function pastehandler(event){
  3045. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  3046. for (index in items) {
  3047. var item = items[index];
  3048. if (item.kind === 'file') {
  3049. put = document.querySelector("#_uploader");
  3050. if(put) ShowSideUploader();
  3051. var blob = item.getAsFile();
  3052. AddImageFile(blob);
  3053. return;
  3054. }
  3055. }
  3056. }
  3057. let _fd_list = [];
  3058. let hint=document.querySelector('#upload_hint');
  3059. function ToggleCompress(button){
  3060. li = button.parentNode;
  3061. num=li.dataset.number;
  3062. for(i=0;i<_fd_list.length;i++){
  3063. if (_fd_list[i][0] == num){
  3064. state = _fd_list[i][2];
  3065. if(state){_fd_list[i][2] = 0; button.innerHTML='1920';break;}
  3066. else{_fd_list[i][2] = 1; button.innerHTML='800';break;}
  3067. }
  3068. }
  3069. }
  3070. function RemoveFromUpload(button){
  3071. li = button.parentNode;
  3072. num=li.dataset.number;
  3073. for(i=0;i<_fd_list.length;i++){
  3074. if (_fd_list[i][0] == num){
  3075. _fd_list.splice(i, 1);break;
  3076. }
  3077. }
  3078. li.parentNode.removeChild(li);
  3079. }
  3080. function EndThisUpload(){
  3081. unfinished = 0;
  3082. for(i=0;i<_fd_list.length;i++){
  3083. if (_fd_list[i][3]==0){
  3084. unfinished=1;
  3085. }
  3086. }
  3087. if(!unfinished){
  3088. hint.innerHTML="<?=$this->T('上传完成。')?>";
  3089. cl=document.querySelector('#upload_click');
  3090. if(!cl.dataset.isSide){
  3091. cl.innerHTML="<?=$this->T('刷新页面')?>";
  3092. cl.href=window.location.href;
  3093. }else{
  3094. _fd_list.splice(0,_fd_list.length);
  3095. fl = document.querySelector("#file_list");
  3096. fl.innerHTML = "";
  3097. list=document.querySelector('#upload_operation_area');
  3098. list.style.pointerEvents='';
  3099. list.style.opacity='';
  3100. document.onpaste=pastehandler;
  3101. RefreshSideGallery();
  3102. }
  3103. }
  3104. }
  3105. function UploadList(){
  3106. if(!_fd_list.length) return;
  3107. hint.innerHTML="<?=$this->T('正在上传...')?>";
  3108. list=document.querySelector('#upload_operation_area');
  3109. list.style.pointerEvents='none';
  3110. list.style.opacity='0.5';
  3111. document.onpaste="";
  3112. for(i=0;i<_fd_list.length;i++){
  3113. let xhr = new XMLHttpRequest();
  3114. //xmlHTTP.upload.addEventListener("loadstart", loadStartFunction, false);
  3115. //xmlHTTP.upload.addEventListener("progress", progressFunction, false);
  3116. //xmlHTTP.addEventListener("load", transferCompleteFunction, false);
  3117. //xmlHTTP.addEventListener("error", uploadFailed, false);
  3118. //xmlHTTP.addEventListener("abort", uploadCanceled, false);
  3119. var li = list.querySelector('[data-number="'+_fd_list[i][0].toString()+'"]')
  3120. xhr.open("POST", "?compress="+_fd_list[i][2].toString(), true);
  3121. function wrap(li, i){
  3122. var ind = li.querySelector('._compress_toggle')
  3123. return function(){
  3124. if (this.readyState === this.DONE) {
  3125. if (this.status === 200) {
  3126. var response = xhr.responseText;
  3127. if(res = response.match(/<uploaded>(.*)<\/uploaded>/)){
  3128. ind.innerHTML = "<?=$this->T('已上传为')?> "+res[1];
  3129. _fd_list[i][3] = 1;
  3130. }else{
  3131. ind.innerHTML = "<?=$this->T('出现错误。')?>";
  3132. _fd_list[i][3] = 1;
  3133. }
  3134. EndThisUpload();
  3135. }
  3136. }
  3137. }
  3138. }
  3139. xhr.onreadystatechange = wrap(li, i);
  3140. xhr.send(_fd_list[i][1]);
  3141. }
  3142. }
  3143. function AddImageFile(blob){
  3144. var ext="";
  3145. if(blob.name.match(/png$/))ext = 'png';
  3146. else if(blob.name.match(/jpg$/))ext = 'jpg';
  3147. else if(blob.name.match(/jpeg$/))ext = 'jpeg';
  3148. else if(blob.name.match(/gif$/))ext = 'gif';
  3149. else return;
  3150. var fd = new FormData();
  3151. blob.name = blob.name=generateUID().toString();
  3152. fd.append("upload_file_name", blob, "_upload_"+blob.name+"."+ext);
  3153. _fd_list.push([blob.name, fd, 1, 0]);/* number original is_compress uploaded */
  3154. var reader = new FileReader();
  3155. reader.onload = function(event){
  3156. fl = document.querySelector("#file_list");
  3157. ht = "<li id='_upload_"+blob.name+"' data-number='"+blob.name+"'>"+
  3158. "<a class='_remove_file pointer invert_a' onclick='RemoveFromUpload(this)'>×</a> "+"<div class='file_thumb'>"+
  3159. "<img class='no_pop' src='"+event.target.result+"'>"+"</div>"+
  3160. " →<a class='_compress_toggle pointer' onclick='ToggleCompress(this)'>800</a></li>";
  3161. fl.innerHTML+=ht;
  3162. };
  3163. reader.readAsDataURL(blob);
  3164. }
  3165. sel = document.querySelector('#upload_selector');
  3166. sel.addEventListener("change", function(){
  3167. var input = this;
  3168. function ff(file){
  3169. return function(e){
  3170. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3171. blob.name = file.name;
  3172. AddImageFile(blob);
  3173. }
  3174. }
  3175. for(i=0;i<input.files.length;i++){
  3176. if(input.files[i].size){
  3177. let reader = new FileReader();
  3178. reader.onload = ff(input.files[i]);
  3179. reader.readAsArrayBuffer(input.files[i]);
  3180. }
  3181. }
  3182. });
  3183. function generateUID() {
  3184. var firstPart = (Math.random() * 46656) | 0;
  3185. var secondPart = (Math.random() * 46656) | 0;
  3186. firstPart = ("000" + firstPart.toString(36)).slice(-3);
  3187. secondPart = ("000" + secondPart.toString(36)).slice(-3);
  3188. return firstPart + secondPart;
  3189. }
  3190. document.onpaste = pastehandler;
  3191. function dropHandler(ev) {
  3192. put = document.querySelector("#_uploader");
  3193. if(put) ShowSideUploader();
  3194. bkg=document.querySelector('#dropping_background');
  3195. bkg.style.display="none";
  3196. console.log('File(s) dropped');
  3197. ev.preventDefault();
  3198. if (ev.dataTransfer && ev.dataTransfer.items) {
  3199. for (var i = 0; i < ev.dataTransfer.items.length; i++) {
  3200. if (ev.dataTransfer.items[i].kind === 'file') {
  3201. var file = ev.dataTransfer.items[i].getAsFile();
  3202. function ff(file){
  3203. return function(e){
  3204. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3205. blob.name = file.name;
  3206. AddImageFile(blob);
  3207. }
  3208. }
  3209. if(file){
  3210. let reader = new FileReader();
  3211. reader.onload = ff(file);
  3212. reader.readAsArrayBuffer(file);
  3213. }
  3214. }
  3215. }
  3216. } else {
  3217. for (var i = 0; i < ev.dataTransfer.files.length; i++) {
  3218. function ff(file){
  3219. return function(e){
  3220. let blob = new Blob([new Uint8Array(e.target.result)], {type: file.type});
  3221. blob.name = file.name;
  3222. AddImageFile(blob);
  3223. }
  3224. }
  3225. if(ev.dataTransfer.files[i].size){
  3226. let reader = new FileReader();
  3227. reader.onload = ff(ev.dataTransfer.files[i]);
  3228. reader.readAsArrayBuffer(ev.dataTransfer.files[i]);
  3229. }
  3230. }
  3231. }
  3232. }
  3233. function dragOverHandler(ev) {
  3234. bkg=document.querySelector('#dropping_background');
  3235. bkg.style.display="";
  3236. console.log('File(s) in drop zone');
  3237. ev.preventDefault();
  3238. }
  3239. </script>
  3240. <?php
  3241. }
  3242. function CanShowGallery(&$g){
  3243. if(!$this->LoggedIn && isset($g['experimental']) && $g['experimental']) return false;
  3244. return true;
  3245. }
  3246. function CanShowImage(&$im){
  3247. if(!$this->LoggedIn && isset($im['galleries']) && isset($im['galleries'][0])) foreach($im['galleries'] as $ga){
  3248. if(($g=$this->GetGallery($ga)) && isset($g['experimental']) && $g['experimental']) return false;
  3249. }
  3250. if(isset($this->WayBack) && substr($im['name'],0,14)>$this->WayBack) return false;
  3251. return true;
  3252. }
  3253. function MakeGallerySection(){
  3254. if(!isset($_GET['gallery'])) return;
  3255. $name=NULL; if($_GET['gallery']!='main' && $_GET['gallery']!='trash'){
  3256. $name=$_GET['gallery'];}?>
  3257. <script>
  3258. document.title+=" | <?=$this->T('画廊')?>";
  3259. </script>
  3260. <div class='center_wide' id='div_center' style='position:relative;'>
  3261. <h2><?=(isset($name) && ($gal=$this->GetGallery($name))!=NULL)?
  3262. ("<span class='gray album_hint'>".$this->T('相册').":</span>".$this->T($name)):
  3263. ($_GET['gallery']=='trash'?$this->T('垃圾桶'):$this->T('画廊'))?></h2>
  3264. <div class='hidden_on_desktop'>
  3265. <?=$this->T('前往')?>
  3266. <select id="gallery_go_to" onchange="window.location.href='?gallery='+this.value;">
  3267. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  3268. if(!isset($g['featured']) || !$g['featured'] ||
  3269. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  3270. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  3271. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  3272. <?php } ?>
  3273. <option value="main" <?=$_GET['gallery']=='main'?"selected":""?>>[<?=$this->T('全部')?>]</option>
  3274. <?php if($this->LoggedIn){ ?>
  3275. <option value="trash" <?=$_GET['gallery']=='trash'?"selected":""?>>[<?=$this->T('垃圾桶')?>]</option>
  3276. <?php } ?>
  3277. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  3278. if((isset($g['featured']) && $g['featured']) ||
  3279. !$this->CanShowGallery($g)){ continue; } $is_this = ($_GET['gallery']==$g['name']);?>
  3280. <option value="<?=$g['name']?>" <?=$is_this?"selected":""?>>
  3281. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></option>
  3282. <?php } ?>
  3283. </select>
  3284. </div>
  3285. <?php if($this->LoggedIn){?>
  3286. <div>
  3287. <?php if(isset($name)){ ?>
  3288. <div style='text-align:right;position:absolute;right:0;top:0;width:100%;' class='invert_a smaller hidden_on_print'>
  3289. <a href='javascript:ShowDeleteMenu();' class='smaller'><?=$this->T('删除相册')?></a><br />
  3290. <?php if(isset($gal['featured']) && $gal['featured']!=false){ ?>
  3291. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=false'
  3292. class='smaller'><?=$this->T('取消精选')?></a>
  3293. <?php }else{ ?>
  3294. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_featured=<?=$_GET['gallery']?>&value=true'
  3295. class='smaller'><?=$this->T('设为精选')?></a>
  3296. <?php } ?><br />
  3297. <?php if(isset($gal['experimental']) && $gal['experimental']!=false){ ?>
  3298. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=false'
  3299. class='smaller'><?=$this->T('取消实验')?></a>
  3300. <?php }else{ ?>
  3301. <a href='?gallery=<?=$_GET['gallery']?>&gallery_set_experimental=<?=$_GET['gallery']?>&value=true'
  3302. class='smaller'><?=$this->T('设为实验')?></a>
  3303. <?php } ?>
  3304. <div class='pop_menu smaller invert_a' id='gallery_delete_menu' style='display:none;'>
  3305. <div style='float:left;' class='gray'><?=$this->T('该操作不删除图片。')?></div>
  3306. <a href='javascript:HidePopMenu();'>×</a>
  3307. <hr />
  3308. <a href='?gallery=main&gallery_edit_delete=<?=$_GET['gallery']?>'><b><?=$this->T('删除相册')?></b></a>
  3309. </div>
  3310. </div>
  3311. <?php } ?>
  3312. <?php $this->MakeUploader(false); ?>
  3313. <div style='text-align:right;position:relative;' class='invert_a smaller hidden_on_print'>
  3314. <div style='position:relative'>
  3315. <?php if(isset($name)){ ?>
  3316. <a href='javascript:ShowGalleryEditMenu("<?=$name?>")'><?=$this->T('改名')?></a>
  3317. <?php } ?>
  3318. <a href='javascript:ShowGalleryEditMenu(null)'><?=$this->T('添加')?></a>
  3319. <div class='pop_menu smaller invert_a' id='gallery_edit_menu' style='display:none;max-width:90%;'>
  3320. <form action="<?=$_SERVER['REQUEST_URI']?>&edit_gallery=true"
  3321. method="post" style='display:none;' id='gallery_edit_form'></form>
  3322. <a style='float:left;'><?=$this->T('相册名字:')?></a>
  3323. <a href='javascript:HidePopMenu();'>×</a>
  3324. <input type='text' form='gallery_edit_form' name='gallery_edit_new_name' id='gallery_edit_new_name'>
  3325. <input type='text' form='gallery_edit_form' name='gallery_edit_old_name'
  3326. id='gallery_edit_old_name' style='display:none'>
  3327. <input class='button' type='submit' form='gallery_edit_form'
  3328. name='gallery_edit_confirm' id='gallery_edit_confirm' value='<?=$this->T('确认')?>'>
  3329. </div>
  3330. </div>
  3331. </div>
  3332. <div class='smaller hidden_on_print'>
  3333. <form action="<?=$_SERVER['REQUEST_URI']?>"
  3334. method="post" style='display:none;' id='gallery_move_form'></form>
  3335. <input type='text' form='gallery_move_form' name='gallery_move_ops'
  3336. id='gallery_move_ops' style='display:none'>
  3337. <p><?=$this->T('选择了')?> <span id='gallery_selected_count'>0</span> <?=$this->T('个图片。')?>
  3338. <a href='javascript:ClearSelectedImages()'><?=$this->T('清除')?></a></p>
  3339. <p><?=$this->T('添加到')?>
  3340. <select id="gallery_move_to">
  3341. <option value="trash"><?=$this->T('垃圾桶')?></option>
  3342. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){ ?>
  3343. <option value="<?=$g['name']?>"><?=$this->T($g['name'])?></option>
  3344. <?php } ?>
  3345. </select>
  3346. <a href='javascript:AddToGallery()'><?=$this->T('执行')?></a>
  3347. </p>
  3348. <p>
  3349. <?=$this->T('或者')?><a href='javascript:RemoveFromGallery()'><?=$this->T('从相册移除')?></a>
  3350. </p>
  3351. </div>
  3352. </div>
  3353. <?php } ?>
  3354. <p>&nbsp;</p>
  3355. <div>
  3356. <?php $opened=0; $prev_year=""; if(isset($this->Images[0])) foreach($this->Images as $im){
  3357. $year = substr($im['name'], 0, 4);
  3358. if($year!=$prev_year){
  3359. if($opened) { ?><div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div></div></div><?php } ?>
  3360. <div><h2 class='sticky_title'><?=$year;?></h2><div class='p_row'><?php $prev_year=$year; $opened=1;
  3361. }
  3362. if($_GET['gallery']=='trash') $name='trash';
  3363. if($_GET['gallery']!='main'){ if(!isset($im['galleries']) || !in_array($name, $im['galleries'])) continue;}
  3364. if(!$this->CanShowImage($im)){ continue; } ?>
  3365. <div class='p_thumb'>
  3366. <?php if($this->LoggedIn){ ?>
  3367. <div class="post_menu_button _select_hook white" onclick='ToggleSelectImage(this, "<?=$im["name"]?>")'>●</div>
  3368. <?php } ?>
  3369. <a href='<?=$im['file']?>' target='_blank' onclick='event.preventDefault();'><img src='<?=$im['thumb']?>' data-imgsrc='<?=$im["name"]?>'<?=isset($im['product'])?
  3370. 'data-product="'.$im["product"].'"':""?>/></a>
  3371. </div>
  3372. <?php } ?>
  3373. <div class='p_thumb' style='flex-grow:10000;box-shadow:none;height:0;'></div>
  3374. </div>
  3375. </div>
  3376. </div>
  3377. <?php if($this->LoggedIn){ ?>
  3378. <script type='text/javascript'>
  3379. var selected_image = new Array();
  3380. function RemoveFromGallery(){
  3381. form = document.querySelector('#gallery_move_form');
  3382. ops = document.querySelector('#gallery_move_ops');
  3383. sel = document.querySelector('#gallery_move_to');
  3384. ops.value = "REM <?=$_GET['gallery']?>"+" "+selected_image.join(' ');
  3385. form.submit();
  3386. }
  3387. function AddToGallery(){
  3388. form = document.querySelector('#gallery_move_form');
  3389. ops = document.querySelector('#gallery_move_ops');
  3390. sel = document.querySelector('#gallery_move_to');
  3391. ops.value = "ADD "+sel.value+" "+selected_image.join(' ');
  3392. form.submit();
  3393. }
  3394. function ClearSelectedImages(){
  3395. selected_image.splice(0, selected_image.length);
  3396. checks = document.querySelectorAll('._select_hook');
  3397. [].forEach.call(checks, function(c){
  3398. c.classList.remove('p_thumb_selected');
  3399. });
  3400. count = document.querySelector('#gallery_selected_count');
  3401. count.innerHTML="0";
  3402. }
  3403. function ToggleSelectImage(elem, name){
  3404. count = document.querySelector('#gallery_selected_count');
  3405. if(selected_image.indexOf(name) == -1){ selected_image.push(name); elem.classList.add('p_thumb_selected'); }
  3406. else{ selected_image.splice(selected_image.indexOf(name), 1); elem.classList.remove('p_thumb_selected'); }
  3407. count.innerHTML=selected_image.length.toString()
  3408. }
  3409. function ShowGalleryEditMenu(old_name){
  3410. m = document.querySelector('#gallery_edit_menu');
  3411. old = document.querySelector('#gallery_edit_old_name');
  3412. m.style.display='block';
  3413. if(old_name!=''){ old.value=old_name; }else{ old.value=''; }
  3414. }
  3415. function ShowDeleteMenu(){
  3416. m=document.querySelector('#gallery_delete_menu');
  3417. m.style.display='block';
  3418. }
  3419. </script>
  3420. <?php } ?>
  3421. <?php
  3422. }
  3423. function MakeGalleryLeft(){?>
  3424. <div class='left hidden_on_mobile gallery_left' id='div_left'>
  3425. <h2><?=$this->T('相册')?></h2>
  3426. <div>
  3427. <span class='gray smaller bold'><?=$this->T('精选')?><hr> </span>
  3428. <ul>
  3429. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  3430. if(!isset($g['featured']) || !$g['featured'] || !$this->CanShowGallery($g)){ continue; } ?>
  3431. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  3432. <li class='<?=$_GET['gallery']==$g['name']?'selected':""?>'>
  3433. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  3434. <?php } ?>
  3435. </ul>
  3436. <div class='smaller'><span class='gray'><?=$this->T('其他相册')?><hr></span><ul>
  3437. <a href='?gallery=main' onclick='ShowWaitingBar()'>
  3438. <li class='<?=$_GET['gallery']=='main'?' selected':""?>'>[<?=$this->T('全部图片')?>]</li></a>
  3439. <?php if(isset($this->Galleries[0])) foreach($this->Galleries as $g){
  3440. if((isset($g['featured']) && $g['featured']) || !$this->CanShowGallery($g)){ continue; } ?>
  3441. <a href='?gallery=<?=$g['name']?>' onclick='ShowWaitingBar()'>
  3442. <li class='<?=$_GET['gallery']==$g['name']?' selected':""?>'>
  3443. <?=(isset($g['experimental'])&&$g['experimental'])?'E ':''?><?=$this->T($g['name'])?></li></a>
  3444. <?php } ?>
  3445. <?php if($this->LoggedIn){ ?>
  3446. <a href='?gallery=trash' onclick='ShowWaitingBar()'>
  3447. <li class='<?=$_GET['gallery']=='trash'?' selected':""?>'>[<?=$this->T('垃圾桶')?>]</li></a>
  3448. <?php } ?>
  3449. </ul></div>
  3450. <p>&nbsp;</p>
  3451. <script>
  3452. </script>
  3453. </div>
  3454. </div>
  3455. <?php
  3456. }
  3457. function MakeTOC(){?>
  3458. <div class='right hidden_on_mobile' id='div_right'>
  3459. <?php if(isset($this->Anchors[0])){?>
  3460. <h2><?=$this->T('目录')?></h2><ul>
  3461. <?php
  3462. foreach($this->Anchors as $a){?>
  3463. <li class='toc_entry_<?=$a[0]>5?5:$a[0]?>'><a href='#<?=$a[1]?>'><?=$this->T($a[2])?></a></li>
  3464. <?php }
  3465. ?></ul>
  3466. <?php }else{ ?>
  3467. <h2 class='gray'><?=$this->T('目录')?></h2>
  3468. <span class='gray smaller'><?=$this->T('未找到目录')?></span>
  3469. <?php } ?>
  3470. </div>
  3471. <?php
  3472. }
  3473. function MakeSettings(){?>
  3474. <div class='settings'>
  3475. <h2><?=$this->T('设置')?></h2>
  3476. <table style='white-space:nowrap;'>
  3477. <?php if($this->LoggedIn){ ?>
  3478. <form action="index.php?settings=true" method="post" style='display:none;' id='settings_form'></form>
  3479. <colgroup><col style='min-width:5em;'><col style='width:100%;min-width:5em;'></colgroup>
  3480. <thead><tr><td><?=$this->T('选项')?></td><td><?=$this->T('值')?></td></tr></thead>
  3481. <tr><td><?=$this->T('网站标题')?></td>
  3482. <td><input type="text" form="settings_form" id='settings_title' name='settings_title'
  3483. value='<?=$this->Title?>'/></td></tr>
  3484. <tr><td><?=$this->T('短标题')?></td>
  3485. <td><input type="text" form="settings_form" id='settings_short_title' name='settings_short_title'
  3486. value='<?=$this->ShortTitle?>'/></td></tr>
  3487. <tr><td><?=$this->T('显示名称')?></td>
  3488. <td><input type="text" form="settings_form" id='settings_display_name' name='settings_display_name'
  3489. value='<?=$this->DisplayName?>'/></td></tr>
  3490. <tr><td><?=$this->T('电子邮件')?></td>
  3491. <td><input type="text" form="settings_form" id='settings_email' name='settings_email'
  3492. value='<?=$this->EMail?>'/></td></tr>
  3493. <tr><td><?=$this->T('导航栏')?>
  3494. <?=isset($this->SpecialNavigation)?"<a href='?post=".$this->SpecialNavigation."'>→</a>":""?></td>
  3495. <td><input type="text" form="settings_form" id='settings_special_navigation' name='settings_special_navigation'
  3496. value='<?=$this->SpecialNavigation?>'/></td></tr>
  3497. <tr><td><?=$this->T('脚注')?> 1<?=isset($this->SpecialFooter)?"<a href='?post=".$this->SpecialFooter."'>→</a>":""?></td>
  3498. <td><input type="text" form="settings_form" id='settings_special_footer' name='settings_special_footer'
  3499. value='<?=$this->SpecialFooter?>'/></td></tr>
  3500. <tr><td><?=$this->T('脚注')?> 2<?=isset($this->SpecialFooter2)?"<a href='?post=".$this->SpecialFooter2."'>→</a>":""?></td>
  3501. <td><input type="text" form="settings_form" id='settings_special_footer2' name='settings_special_footer2'
  3502. value='<?=$this->SpecialFooter2?>'/></td></tr>
  3503. <tr><td><?=$this->T('置顶文')?><?=isset($this->SpecialPinned)?"<a href='?post=".$this->SpecialPinned."'>→</a>":""?></td>
  3504. <td><input type="text" form="settings_form" id='settings_special_pinned' name='settings_special_pinned'
  3505. value='<?=$this->SpecialPinned?>'/></td></tr>
  3506. <tr><td><?=$this->T('默认相册')?></td>
  3507. <td><input type="text" form="settings_form" id='settings_default_gallery' name='settings_default_gallery'
  3508. value='<?=$this->DefaultGallery?>'/></td></tr>
  3509. <tr><td><?=$this->T('启用评论')?></td>
  3510. <td><input type="checkbox" id="settings_enable_comments" name="settings_enable_comments"
  3511. form="settings_form" <?=$this->CommentEnabled?"checked":""?>/></td></tr>
  3512. <tr><td><?=$this->T('附加操作')?></td><td><a class='gray' href='index.php?extras=true'><?=$this->T('进入')?></a></td></tr>
  3513. <tr><td class='smaller gray'>&nbsp;</td></tr>
  3514. <tr><td class='smaller gray'><?=$this->T('实验访问')?></td></tr>
  3515. <tr><td><?=$this->T('主机')?><?=isset($this->ExpHost)?"<a href='?post=".$this->ExpHost."'>→</a>":""?></td>
  3516. <td><input type="text" form="settings_form" id='settings_exp_host' name='settings_exp_host'
  3517. value='<?=$this->ExpHost?>'/></td></tr>
  3518. <tr><td><?=$this->T('网站标题')?></td>
  3519. <td><input type="text" form="settings_form" id='settings_exp_title' name='settings_exp_title'
  3520. value='<?=$this->ExpTitle?>'/></td></tr>
  3521. <tr><td><?=$this->T('短标题')?></td>
  3522. <td><input type="text" form="settings_form" id='settings_exp_short_title' name='settings_exp_short_title'
  3523. value='<?=$this->ExpShortTitle?>'/></td></tr>
  3524. <tr><td><?=$this->T('首次提示')?><?=isset($this->ExpCaution)?"<a href='?post=".$this->ExpCaution."'>→</a>":""?></td>
  3525. <td><input type="text" form="settings_form" id='settings_exp_caution' name='settings_exp_caution'
  3526. value='<?=$this->ExpCaution?>'/></td></tr>
  3527. <tr><td><?=$this->T('索引')?><?=isset($this->ExpIndex)?"<a href='?post=".$this->ExpIndex."'>→</a>":""?></td>
  3528. <td><input type="text" form="settings_form" id='settings_exp_index' name='settings_exp_index'
  3529. value='<?=$this->ExpIndex?>'/></td></tr>
  3530. <tr><td><?=$this->T('导航栏')?>
  3531. <?=isset($this->ExpNavigation)?"<a href='?post=".$this->ExpNavigation."'>→</a>":""?></td>
  3532. <td><input type="text" form="settings_form" id='settings_exp_navigation' name='settings_exp_navigation'
  3533. value='<?=$this->ExpNavigation?>'/></td></tr>
  3534. <tr><td><?=$this->T('脚注')?><?=isset($this->ExpFooter)?"<a href='?post=".$this->ExpFooter."'>→</a>":""?></td>
  3535. <td><input type="text" form="settings_form" id='settings_exp_footer' name='settings_exp_footer'
  3536. value='<?=$this->ExpFooter?>'/></td></tr>
  3537. <tr><td class='smaller gray'>&nbsp;</td></tr>
  3538. <tr><td class='smaller gray'><?=$this->T('管理员')?></td><td class='smaller'>
  3539. <a href='index.php?logout=true'><?=$this->T('登出')?></a></td></tr>
  3540. <tr><td><?=$this->T('帐号')?></td>
  3541. <td><input type="text" form="settings_form" id='settings_id' name='settings_id'
  3542. value='<?=$this->Admin?>'/></td></tr>
  3543. <tr><td><?=$this->T('新密码')?></td>
  3544. <td><input type="password" form="settings_form"
  3545. id='settings_new_password' name='settings_new_password' /></td></tr>
  3546. <tr><td><?=$this->T('再次输入')?></td>
  3547. <td><input type="password" form="settings_form"
  3548. id='settings_new_password_redo' name='settings_new_password_redo' /></td></tr>
  3549. <tr><td><?=$this->T('旧密码')?></td>
  3550. <td><input type="password" form="settings_form" id='settings_old_password' name='settings_old_password' /></td></tr>
  3551. <?php }else{ ?>
  3552. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='login_form'></form>
  3553. <colgroup><col style='min-width:3em;'><col style='width:100%;min-width:5em;'></colgroup>
  3554. <tr><td class='smaller gray'><?=$this->T('请登录')?></td></tr>
  3555. <tr><td><?=$this->T('帐号')?></td>
  3556. <td><input type="text" form="login_form" id='login_id' name='login_id' /></td></tr>
  3557. <tr><td><?=$this->T('密码')?></td>
  3558. <td><input type="password" form="login_form" id='login_password' name='login_password' /></td></tr>
  3559. <?php } ?>
  3560. </table>
  3561. <?php if($this->LoggedIn){ ?>
  3562. <input class='button' form="settings_form" type="submit" name='settings_button' value='<?=$this->T('保存设置')?>' />
  3563. <?php }else{ ?>
  3564. <input class='button' form="login_form" type="submit" name='login_button' value='<?=$this->T('登录')?>' />
  3565. <?php } ?>
  3566. </div>
  3567. <?php
  3568. }
  3569. function MakeExtraOperations(){?>
  3570. <div class='settings' style='overflow:auto;'>
  3571. <h2><?=$this->T('附加操作')?></h2>
  3572. <a href='index.php?&settings=true'><?=$this->T('返回一般设置')?></a>
  3573. <p>&nbsp;</p>
  3574. <h3><?=$this->T('自动重定向')?></h3>
  3575. <span class='smaller gray'>
  3576. <?=$this->T('P为帖子跳转,匹配REQUEST_URI跳到目标文章;S为站点跳转,可以重定向来源域名,例子:')?>
  3577. <br /><pre>P discount:20001001010101;<br />S old_domain:www.new_domain.com:20001001010101;</pre></span>
  3578. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form2'></form>
  3579. <textarea id="settings_redirect" name="settings_redirect" rows="3" class='full_box' wrap="off"
  3580. form='settings_form2'><?=$this->DisplayRedirectConfig()?></textarea>
  3581. <input class='button' form="settings_form2" type="submit" name='settings_save_redirect'
  3582. value='<?=$this->T('保存重定向设置')?>' />
  3583. <p>&nbsp;</p>
  3584. <h3><?=$this->T('自定义翻译')?></h3>
  3585. <span class='smaller gray'>
  3586. <?=$this->T('填写格式:')?>
  3587. <br /><pre>- 语言 | Language</pre></span>
  3588. <form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style='display:none;' id='settings_form3'></form>
  3589. <textarea id="settings_translation" name="settings_translation" rows="3" class='full_box' wrap="off"
  3590. form='settings_form3'><?=$this->CustomTranslationContent?></textarea>
  3591. <input class='button' form="settings_form3" type="submit" name='settings_save_translation'
  3592. value='<?=$this->T('保存翻译')?>' />
  3593. <p>&nbsp;</p>
  3594. <p class='smaller gray'><?=$this->T('当心!下列操作将立即执行:')?></p>
  3595. <ul>
  3596. <li><a href='index.php?rewrite_styles=true'><?=$this->T('重新写入默认CSS')?></a></li>
  3597. <li><a href='index.php?regenerate_thumbnails=true'><?=$this->T('重新生成图片缩略图')?></a></li>
  3598. <li><a href='index.php?clear_all_logins=true'><?=$this->T('删除所有登录')?>(<?=sizeof($this->LoginTokens);?>)</a></li>
  3599. </ui>
  3600. <br /><br /><br /><a href='index.php?&settings=true'><?=$this->T('返回一般设置')?></a><br />&nbsp;
  3601. </div>
  3602. <?php
  3603. }
  3604. function MakeMainBegin(){?>
  3605. <div class='main' <?php if(!$this->InExperimentalMode){ ?>
  3606. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);"<?php } ?>>
  3607. <?php
  3608. }
  3609. function MakeMainEnd(){?>
  3610. </div>
  3611. <?php
  3612. }
  3613. function MakeExpFooter(){?>
  3614. <div class='small_footer'>
  3615. <hr />
  3616. <b><?=$this->T($this->ExpTitle)?></b>&nbsp;©<?=$this->T($this->DisplayName)?>
  3617. </div>
  3618. <div class='footer'>
  3619. <div style='white-space:nowrap;'>
  3620. <div class='footer_additional'>
  3621. <?php if(isset($this->ExpFooter) && ($p = &$this->GetPost($this->ExpFooter,true))!=NULL){
  3622. echo $this->TranslatePostParts($this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST,false));
  3623. } ?>
  3624. </div>
  3625. </div>
  3626. </div>
  3627. </div><!-- page -->
  3628. </body>
  3629. </html>
  3630. <script>
  3631. if(trans = document.getElementById('translate_button')){
  3632. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  3633. }
  3634. </script>
  3635. <?php
  3636. }
  3637. function MakeFooter(){?>
  3638. <div class='small_footer'>
  3639. <hr />
  3640. <b><?=$this->T($this->Title)?></b>
  3641. <span onclick='event.stopPropagation()'
  3642. ondblclick='javascript:window.location.href="index.php?settings=true"'>©</span><?=$this->T($this->DisplayName)?>
  3643. <?php if(!isset($this->WayBack)){ ?><div class='wayback_link clean_a invert_a'>
  3644. <a class='hidden_on_print' href='<?=$this->GetRedirect()?>&set_wayback=true'><?=$this->T('以过去的日期浏览')?></a></div>
  3645. <?php } ?>
  3646. </div>
  3647. <div class='footer'>
  3648. <div style='white-space:nowrap;'>
  3649. <div class='footer_additional'>
  3650. <?php if(isset($this->SpecialFooter) && ($p = &$this->GetPost($this->SpecialFooter))!=NULL){
  3651. echo $this->TranslatePostParts($this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST,false));
  3652. } ?>
  3653. </div>
  3654. <div class='footer_additional'>
  3655. <?php if(isset($this->SpecialFooter2) && ($p = &$this->GetPost($this->SpecialFooter2))!=NULL){
  3656. echo $this->TranslatePostParts($this->GenerateSinglePost($p, false, false, false, false,$this->NULL_POST,false));
  3657. } ?>
  3658. </div>
  3659. </div>
  3660. </div>
  3661. <p>&nbsp;<p>
  3662. <div id='dropping_background' style='display:none;' onclick='this.style.display="none";'
  3663. ondrop="_dropHandler(event);" ondragover="_dragOverHandler(event);">
  3664. <h2 style='width:100%;'><?=$this->T('上传到这里')?></h2>
  3665. </div>
  3666. <div id='big_image_overlay' style='display:none'>
  3667. <div class='big_image_box clean_a' onclick='HideBigImage(1)'>
  3668. <div style='display:flex;align-items:center;height:100%;justify-content:center;width:100%;'><?=$this->T('请稍候')?></div>
  3669. <img id='big_image' onload="HideWaitingBar();"/>
  3670. </div>
  3671. <div class='big_side_box' onclick='HideBigImage(1);'>
  3672. <div class='big_image_box clean_a image_nav' onclick='HideBigImage(1)'>
  3673. <div ><a id='prev_image' class='image_nav_prev img_btn_hidden' onclick="event.stopPropagation();">
  3674. <div class='lr_buttons'>←</div></a></div>
  3675. <div ><a id='next_image' class='image_nav_next img_btn_hidden' onclick="event.stopPropagation();">
  3676. <div class='lr_buttons'>→</div></a></div>
  3677. </div>
  3678. <div class='side_box_mobile_inner'>
  3679. <div class='inquiry_buttons img_btn_hidden' id='inquiry_buttons' onclick="event.stopPropagation();">
  3680. <span style='display:none;' id='image_purchase' class='clean_a'>
  3681. <b><a id='image_purchase_button' target="_blank">¥<?=$this->T('购买印刷品')?></a></b>
  3682. <br class='hidden_on_desktop block_on_mobile' /></span>
  3683. <b><a class='clean_a' id='image_download'><span id='download_processing'>↓</span><?=$this->T('下载')?></a></b>
  3684. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  3685. &nbsp;<a class='clean_a' id='image_inquiry'>
  3686. <b>@</b><?=$this->T('咨询')?></a>
  3687. <?php } ?><hr class='hidden_on_desktop block_on_mobile' />
  3688. </div>
  3689. <div id='big_image_share' class='clean_a' onclick="event.stopPropagation();">
  3690. <li><a id='big_share_copy'>⎘ <?=$this->T('复制链接')?></a></li>
  3691. <hr />
  3692. </div>
  3693. <div id='big_image_info' onclick="event.stopPropagation();"></div>
  3694. <?php if($this->LoggedIn){ ?><div id='big_image_ops' onclick="event.stopPropagation();">
  3695. <br /><?=$this->T('印刷品链接')?>
  3696. <form action="" method="post" style='display:none;' id='image_ops_form'></form>
  3697. <input type='text' id='image_ops_product_link' name='image_ops_product_link' form="image_ops_form" >
  3698. <?=$this->T('重命名')?>
  3699. <input type='text' id='image_edit_new_name' name='image_edit_new_name' form="image_ops_form" >
  3700. <input class='button' form="image_ops_form" type="submit" name='image_button' value=<?=$this->T('保存')?> />
  3701. <br /><br /><?=$this->T('替换图像')?>
  3702. <form action="" method="post" style='display:none;' id='image_edit_form' enctype="multipart/form-data"></form>
  3703. <input type="file" form='image_edit_form'
  3704. id='big_image_upload' name='upload_file_name' accept="image/x-png,image/png,image/gif,image/jpeg"/><br />
  3705. <input class='button' form="image_edit_form" type="submit" name='image_replace_button'
  3706. value=<?=$this->T('执行')?> />
  3707. </div><?php } ?>
  3708. </div>
  3709. </div>
  3710. </div>
  3711. </div><!-- page -->
  3712. </body>
  3713. </html>
  3714. <script>
  3715. <?=$this->ExtraScripts?>
  3716. if(back = document.getElementById('button_back')){
  3717. if(document.referrer.indexOf(location.protocol + "//" + location.host) == 0){
  3718. back.href='javascript:history.back()';
  3719. }else{
  3720. back.href='index.php';
  3721. }
  3722. }
  3723. function copy_text(t) {
  3724. ta = document.createElement('textarea');
  3725. document.body.appendChild(ta);
  3726. ta.value = t;
  3727. ta.select();
  3728. document.execCommand("copy");
  3729. document.body.removeChild(ta);
  3730. }
  3731. if(trans = document.getElementById('translate_button')){
  3732. trans.href='https://translate.google.com/translate?sl=auto&tl=en-US&u='+encodeURIComponent(document.location.href);
  3733. }
  3734. <?php if($this->LoggedIn){ ?>
  3735. <?php if($this->PageType=='post' && !isset($this->WayBack)) { ?>
  3736. var Scenter = document.querySelector('#div_center');
  3737. var Sposts = Scenter.querySelectorAll('.post');
  3738. var Smerge_post_dialog = Scenter.querySelector('#merge_post_dialog');
  3739. var Smerge_post = Scenter.querySelector('#merge_post');
  3740. var Smerge_post_count = Smerge_post_dialog.querySelector('#merge_post_count');
  3741. var Smerge_post_btn = Scenter.querySelector('#merge_post_btn');
  3742. var Smerge_cancel = Scenter.querySelector('#merge_cancel');
  3743. var Smerge_select = Scenter.querySelector('#merge_select');
  3744. var Smerge_thread_dialog = Scenter.querySelector('#merge_thread_dialog');
  3745. var Smerge_thread = Scenter.querySelector('#merge_thread');
  3746. var Smerge_thread_target = Scenter.querySelector('#merge_thread_target');
  3747. var Smerge_thread_btn = Scenter.querySelector('#merge_thread_btn');
  3748. var select_mode = false; var merge_mode = false; var selected_posts = null;
  3749. function TogglePostSelectMode(force_on=false,force_off=false){
  3750. Scenter.classList.add('post_selecting');
  3751. if((!select_mode || force_on) && !force_off){ ToggleThreadMerge(false,true); Scenter.classList.add('post_selecting');
  3752. Smerge_post_dialog.style.display="block";Smerge_post_btn.classList.add('text_highlight');
  3753. Smerge_cancel.innerText='<?=$this->T("取消")?>'; select_mode = 1;}
  3754. else{ select_mode = 0; Scenter.classList.remove('post_selecting');
  3755. Smerge_post_dialog.style.display="none";Smerge_post_btn.classList.remove('text_highlight');
  3756. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  3757. for(var i=0;i<Sposts.length;i++){ Sposts[i].classList.remove('post_selected');
  3758. Sposts[i].onclick=select_mode?function(){TogglePostSelect(this);}:null; }
  3759. Smerge_post_count.innerText="0";
  3760. Smerge_post.href="#";
  3761. }
  3762. function TogglePostSelect(elem){
  3763. if(elem.classList.contains('post_selected')){ elem.classList.remove('post_selected'); }
  3764. else{ elem.classList.add('post_selected'); }
  3765. selected_posts = new Array();
  3766. for(var i=0;i<Sposts.length;i++){ if(Sposts[i].classList.contains('post_selected')){
  3767. selected_posts.push(Sposts[i].dataset.postId); } }
  3768. Smerge_post.href="?merge_posts="+selected_posts.join(" ");
  3769. Smerge_post_count.innerText=selected_posts.length;
  3770. }
  3771. function ThreadMergeInput(elem){
  3772. if(elem.value.match(/[0-9]{14}/)) { Smerge_thread.href="?merge_threads=<?=$this->ActualPostID?> "+elem.value; }
  3773. else{ Smerge_thread.href="#"; }
  3774. }
  3775. function ToggleThreadMerge(force_on=false,force_off=false){
  3776. if((!merge_mode || force_on) && !force_off){ TogglePostSelectMode(false,true);
  3777. Smerge_thread_dialog.style.display="block";Smerge_thread_btn.classList.add('text_highlight');
  3778. Smerge_cancel.innerText='<?=$this->T("取消")?>'; merge_mode = 1;}
  3779. else{ merge_mode = 0;
  3780. Smerge_thread_dialog.style.display="none";Smerge_thread_btn.classList.remove('text_highlight');
  3781. Smerge_cancel.innerText='<?=$this->T("工具")?>';Smerge_select.selectedIndex='0'; }
  3782. Smerge_thread.href="#";
  3783. Smerge_thread_target.value='';
  3784. }
  3785. <?php } ?>
  3786. function ShowSideUploader(){
  3787. ShowRightSide(true,null);
  3788. put = document.querySelector("#_uploader");
  3789. put.style.display='block';
  3790. RefreshSideGallery();
  3791. }
  3792. dmark = document.querySelector("#mark_details");
  3793. drename = document.querySelector("#rename_details");
  3794. drename_form = document.querySelector("#post_rename_form");
  3795. drename_input = document.querySelector("#post_rename_name");
  3796. var rp = document.querySelector('#post_reply_to');
  3797. var _reply_to = rp?rp.defaultValue:"";
  3798. function RestoreReply(){
  3799. if(rp){
  3800. rp.defaultValue = _reply_to;
  3801. }
  3802. document.querySelector('#post_reply_restore').style.display='none';
  3803. ht = document.querySelector('#post_hint_text');
  3804. if (_reply_to!=""){
  3805. ht.style.display='block';
  3806. ht.innerHTML="<?=$this->T('继续补充该话题:')?>";
  3807. }else{
  3808. ht.style.display='none';
  3809. }
  3810. document.querySelector('#post_edit_target').value="";
  3811. ch = document.querySelector('#post_hint_modify');
  3812. ch.style.display='none';
  3813. }
  3814. function MakeRefer(id){
  3815. t = document.querySelector('#post_content')
  3816. t.focus();
  3817. v = t.value;
  3818. t.value = v.slice(0, t.selectionStart) + "[<?=$this->T('引用文章')?>]("+id.toString()+")" + v.slice(t.selectionEnd);
  3819. la_auto_grow(t);
  3820. if(rp){
  3821. rp.defaultValue = "";
  3822. ht = document.querySelector('#post_hint_text');
  3823. ht.innerHTML = "<?=$this->T('引用并发送新话题:')?>"; ht.style.display='block';
  3824. document.querySelector('#post_reply_restore').style.display='inline';
  3825. rs = document.querySelector('#post_reply_restore');
  3826. rs.style.display='inline'; rs.innerHTML="<?=$this->T('切换为回复')?>";
  3827. document.getElementById('post_menu').style.display='none';
  3828. ch = document.querySelector('#post_hint_modify');
  3829. ch.style.display='none';
  3830. }
  3831. }
  3832. function CopyRefer(id){
  3833. copy_text(id.toString());
  3834. menu.querySelector('#menu_refer_copy').innerHTML="<?=$this->T('已复制')?>";
  3835. }
  3836. function MakeEdit(id){
  3837. ed = document.getElementById('menu_edit');
  3838. ed.innerHTML="<?=$this->T('稍等')?>";
  3839. ed.href="#";
  3840. var xhr = new XMLHttpRequest();
  3841. xhr.onreadystatechange = function() {
  3842. if (this.readyState == 4 && this.status == 200) {
  3843. ed.innerHTML='——';
  3844. ch = document.querySelector('#post_hint_modify');
  3845. ch.style.display='block';
  3846. ht = document.querySelector('#post_hint_text');
  3847. ht.innerHTML = "<?=$this->T('修改帖子:')?>";
  3848. rs = document.querySelector('#post_reply_restore');
  3849. rs.style.display='inline'; rs.innerHTML="<?=$this->T('取消')?>";
  3850. t = document.querySelector('#post_content');
  3851. t.value=xhr.responseText.trim();
  3852. t.focus();
  3853. la_auto_grow(t);
  3854. document.querySelector('#post_edit_target').value=id;
  3855. document.getElementById('post_menu').style.display='none';
  3856. }
  3857. };
  3858. xhr.open("GET", "index.php?post="+id.toString()+'&post_original=true', true);
  3859. xhr.send();
  3860. }
  3861. function MarkDelete(id){
  3862. p = document.querySelector('[data-post-id="'+id+'"]');
  3863. op = p.dataset.markDelete?"false":"true";
  3864. window.location.href=
  3865. "index.php?<?=$this->GetRedirect()?>&mark_delete="+op+'&target='+id.toString();
  3866. }
  3867. function SetMark(mark){
  3868. menu = document.getElementById('post_menu');
  3869. window.location.href=
  3870. "index.php?<?=$this->GetRedirect()?>&target="+
  3871. menu.parentNode.dataset.postId+"&set_mark="+mark;
  3872. }
  3873. function ToggleMarkDetails(){
  3874. if(dmark.style.display=='block') dmark.style.display='none';
  3875. else dmark.style.display='block';
  3876. }
  3877. function ToggleRenameDetails(){
  3878. if(drename.style.display=='block') drename.style.display='none';
  3879. else drename.style.display='block';
  3880. }
  3881. <?php } ?>
  3882. function ShowPostMenu(post){
  3883. menu = document.getElementById('post_menu');
  3884. menu.style.display='block';
  3885. menu.parentNode.removeChild(menu);
  3886. post.appendChild(menu);
  3887. menu.style.display='block';
  3888. id = post.dataset.postId
  3889. menu.querySelector('#_time_hook').innerHTML = ''+id.substring(2,4)+'/'+id.substring(4,6)+'/'+id.substring(6,8)+
  3890. ' '+id.substring(8,10)+':'+id.substring(10,12);
  3891. window.onClick="HidePopMenu()";
  3892. menu.onClick=(function(event){
  3893. event.stopPropagation();
  3894. });
  3895. hs = menu.querySelector('#menu_history');
  3896. hs.href='?post='+id+'&history=1';
  3897. <?php if($this->LoggedIn && !isset($this->WayBack)){ ?>
  3898. menu.querySelector('#menu_refer').href='javascript:MakeRefer(id)';
  3899. ref = menu.querySelector('#menu_refer_copy')
  3900. ref.innerHTML='<?=$this->T("复制编号")?>';
  3901. ref.href='javascript:CopyRefer(id)';
  3902. ed = menu.querySelector('#menu_edit')
  3903. ed.href='javascript:MakeEdit(id)'; ed.innerHTML="<?=$this->T('修改')?>";
  3904. d = menu.querySelector('#menu_delete');
  3905. d.href='javascript:MarkDelete(\"'+id+'\")';
  3906. p = document.querySelector('[data-post-id="'+id+'"]');
  3907. d.innerHTML = p.dataset.markDelete?"<?=$this->T('恢复')?>":"<?=$this->T('删除')?>";
  3908. menu.querySelector('#mark_details').dataset.id=id;
  3909. drename_input.value=id;
  3910. drename_form.action="<?=$_SERVER['REQUEST_URI'];?>"+"&rename_post="+id;
  3911. <?php } ?>
  3912. title = document.title;
  3913. copy = document.getElementById('share_copy');
  3914. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  3915. copy.addEventListener("click", function(){
  3916. url = window.location
  3917. path = location.pathname
  3918. copy_text(url.protocol+"//"+url.host+path+"?post="+id);
  3919. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  3920. });
  3921. }
  3922. function HidePopMenu(){
  3923. var menus = document.querySelectorAll('.pop_menu');
  3924. [].forEach.call(menus, function(m){m.style.display='none';});
  3925. }
  3926. var posts = document.querySelectorAll('.center .post');
  3927. [].forEach.call(posts, function(p){
  3928. if(s=p.querySelector('._menu_hook')) s.addEventListener("click", function() {
  3929. ShowPostMenu(this.parentNode.parentNode);
  3930. });
  3931. });
  3932. var post_clickables = document.querySelectorAll('.center .post a');
  3933. [].forEach.call(post_clickables, function(p){
  3934. p.addEventListener("click", function(event){
  3935. event.stopPropagation();
  3936. });
  3937. });
  3938. function FindImage(imgsrc){
  3939. for(var i=0;i<document.images_filtered.length;i++){
  3940. if (document.images_filtered[i].dataset.imgsrc==imgsrc) return document.images_filtered[i]
  3941. }
  3942. return null
  3943. }
  3944. var dottime1;
  3945. var dottime2;
  3946. function ToDataURL(url) {
  3947. return fetch(url).then((response) => {return response.blob();}).then(blob => {
  3948. clearTimeout(dottime1);clearTimeout(dottime2);
  3949. ps = document.querySelector('#download_processing');
  3950. ps.innerHTML='↓';ps.style.opacity='';
  3951. return URL.createObjectURL(blob);});
  3952. }
  3953. async function DownloadAsImage(url,name) {
  3954. const a = document.createElement("a"); a.href = await ToDataURL(url); a.download = name;
  3955. document.body.appendChild(a); a.click(); document.body.removeChild(a);
  3956. }
  3957. function basename(url){return url.split(/[\\/]/).pop();}
  3958. pushed=0;
  3959. function ShowBigImage(imgsrc,do_push){
  3960. ShowWaitingBar();
  3961. share = document.querySelector('#big_image_share');
  3962. img = document.querySelector('#big_image');
  3963. down = document.querySelector('#image_download');
  3964. img.src = "";
  3965. img.src = src = "images/"+imgsrc;
  3966. down.href="images/"+imgsrc;
  3967. var downname='<?=$this->T($this->Title);?>_<?=$this->T($this->DisplayName);?>_+<?=$this->GiveSafeEMail()?>+_'+
  3968. basename(down.href);
  3969. img.alt = downname; down.download=downname;
  3970. var use_href = "images/"+imgsrc;
  3971. down.onclick=function(event){event.stopPropagation();event.preventDefault();
  3972. ps = this.querySelector('#download_processing');ps.innerText='…';
  3973. var dotwait = function(ps){ var self = this;
  3974. dottime1 = setTimeout(function(ps){
  3975. ps.style.opacity='0'; dottime2 = setTimeout(function(ps){ps.style.opacity='1'; dotwait(ps);},300,ps); },300,ps) }
  3976. dotwait(this.querySelector('#download_processing'));
  3977. DownloadAsImage(use_href,downname);};
  3978. if(do_push){PushGalleryHistory(src)}
  3979. page_url = encodeURIComponent(window.location.href);
  3980. <?php if(isset($this->EMail) && $this->EMail!=""){ ?>
  3981. inqb = document.querySelector('#image_inquiry');
  3982. inqb.href="mailto:<?=$this->T($this->DisplayName);?>\<<?=$this->EMail?>\>?subject=<?=$this->T('网站图片咨询');?>&body="+
  3983. encodeURIComponent("<?=$this->T('你好!我对你网站上的这张图片感兴趣:')?>"+'\n\n')+
  3984. (page_url)+encodeURIComponent('\n\n');
  3985. <?php } ?>
  3986. this_image = FindImage(imgsrc);
  3987. if(this_image.dataset.prevsrc){
  3988. new_image = FindImage(this_image.dataset.prevsrc);
  3989. new_prev = new_image?new_image.dataset.prevsrc:null;
  3990. im = document.querySelector('#prev_image');
  3991. if(new_prev) {im.href='javascript:ShowBigImage("'+this_image.dataset.prevsrc+'",'+do_push+')';im.style.opacity='';}
  3992. else {im.style.opacity='0';im.removeAttribute("href");}
  3993. }
  3994. if(this_image.dataset.nextsrc){
  3995. new_image = FindImage(this_image.dataset.nextsrc);
  3996. new_next = new_image?new_image.dataset.nextsrc:null;
  3997. im = document.querySelector('#next_image');
  3998. if(new_next) {im.href='javascript:ShowBigImage("'+this_image.dataset.nextsrc+'",'+do_push+')';im.style.opacity='';}
  3999. else {im.style.opacity='0';im.removeAttribute("href");}
  4000. }
  4001. purchase = document.querySelector('#image_purchase');
  4002. purchase_btn = document.querySelector('#image_purchase_button');
  4003. <?php if($this->LoggedIn){ ?>
  4004. product_link = document.querySelector('#image_ops_product_link');
  4005. product_form = document.querySelector('#image_ops_form');
  4006. edit_form = document.querySelector('#image_edit_form');
  4007. edit_new_name = document.querySelector('#image_edit_new_name');
  4008. product_form.action = window.location.href;
  4009. edit_form.action = window.location.href;
  4010. edit_new_name.value = imgsrc.split('.')[0];
  4011. if(this_image.dataset.product){
  4012. product_link.value = this_image.dataset.product;
  4013. }else{
  4014. product_link.value = "";
  4015. }
  4016. <?php } ?>
  4017. if(this_image.dataset.product){
  4018. purchase.style.display='';
  4019. href = this_image.dataset.product;
  4020. if(this_image.dataset.product.match('^[0-9]{14}$')){
  4021. href = '?post='+href;
  4022. }
  4023. purchase_btn.href = href;
  4024. }else{
  4025. purchase.style.display='none';
  4026. purchase_btn.removeAttribute("href");
  4027. }
  4028. DelayHideImgBtn(null);
  4029. title = encodeURIComponent(document.title);
  4030. copy = document.getElementById('big_share_copy');
  4031. copy.innerHTML='⎘ <?=$this->T("复制链接")?>';
  4032. copy.addEventListener("click", function(){
  4033. copy_text(window.location.href);
  4034. this.innerHTML='&#10003;&#xfe0e; <?=$this->T("复制链接")?>';
  4035. });
  4036. o = document.querySelector('#big_image_overlay');
  4037. info = document.querySelector('#big_image_info');
  4038. info.innerHTML="<?=$this->T('正在查询……')?>";
  4039. o.style.display="block";
  4040. ShowBackdrop(0.8);
  4041. var xhr = new XMLHttpRequest();
  4042. xhr.onreadystatechange = function() {
  4043. if (this.readyState == 4 && this.status == 200) {
  4044. info = document.querySelector('#big_image_info');
  4045. var response = xhr.responseText;
  4046. let content=""
  4047. if(res = response.match(/<ref>(.*)<\/ref>/u)){
  4048. content="<span class='small'><?=$this->T('该图片出现在')?> "+res[1]+" <?=$this->T('个帖子中')?></span>"+content;
  4049. }else{content="<span class='smaller gray'><?=$this->T('该图片未被引用')?></span>"+content;}
  4050. if(res = response.match(/<insert>([\s\S]*)<\/insert>/u)){
  4051. content+="<div class='clean_a'>"+res[1]+"</div>";
  4052. }
  4053. info.innerHTML=content;
  4054. }
  4055. };
  4056. xhr.open("GET", "index.php?image_info="+imgsrc+"", true);
  4057. xhr.send();
  4058. }
  4059. function HideBigImage(do_push){
  4060. o = document.querySelector('#big_image_overlay');
  4061. img = document.querySelector('#big_image');
  4062. img.src = "";
  4063. if(o.style.display!='none'){
  4064. o.style.display="none";
  4065. HideBackdrop();
  4066. if(do_push){PushGalleryHistory("");}
  4067. HideWaitingBar();
  4068. }
  4069. }
  4070. var lbtn=document.querySelector('#prev_image'),rbtn=document.querySelector('#next_image');
  4071. var inq=document.querySelector('#inquiry_buttons');
  4072. var overlay=document.querySelector('#big_image_overlay');
  4073. var hide_timeout;
  4074. function DontHideImgBtn(e){ clearTimeout(hide_timeout); e.stopPropagation(); }
  4075. function DelayHideImgBtn(e){
  4076. lbtn.classList.remove('img_btn_hidden');
  4077. rbtn.classList.remove('img_btn_hidden');
  4078. inq.classList.remove('img_btn_hidden');
  4079. clearTimeout(hide_timeout);
  4080. hide_timeout = setTimeout(function(e1,e2,e3){e1.classList.add('img_btn_hidden');
  4081. e2.classList.add('img_btn_hidden');
  4082. e3.classList.add('img_btn_hidden');}, 1000, lbtn, rbtn, inq);
  4083. }
  4084. lbtn.addEventListener('mousemove',DontHideImgBtn);lbtn.addEventListener('mouseover',DontHideImgBtn);
  4085. rbtn.addEventListener('mousemove',DontHideImgBtn);rbtn.addEventListener('mouseover',DontHideImgBtn);
  4086. inq.addEventListener('mousemove',DontHideImgBtn);inq.addEventListener('mouseover',DontHideImgBtn);
  4087. overlay.addEventListener('mousemove',DelayHideImgBtn);
  4088. var images = document.querySelectorAll('img');
  4089. var images_filtered=new Array(); var imgadded = new Array();
  4090. var images_remaining=new Array();
  4091. [].forEach.call(images, function(img){
  4092. if(img.classList.contains("no_pop") || (!(imgsrc = img.dataset.imgsrc))) return;
  4093. if(imgadded.indexOf(imgsrc)>=0) {images_remaining.push(img); return;}
  4094. images_filtered.push(img);imgadded.push(imgsrc);
  4095. });
  4096. for(var i=0; i<images_filtered.length; i++){
  4097. previmg = nextimg = null; img = images_filtered[i];
  4098. if(i>0) previmg=images_filtered[i-1];
  4099. if(i<images_filtered.length-1) nextimg=images_filtered[i+1];
  4100. prevsrc=previmg?previmg.dataset.imgsrc:null; nextsrc=nextimg?nextimg.dataset.imgsrc:null;
  4101. img.dataset.prevsrc = prevsrc; img.dataset.nextsrc = nextsrc;
  4102. function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
  4103. img.addEventListener("click", wrap(img.dataset.imgsrc));
  4104. }
  4105. for(var i=0; i<images_remaining.length; i++){
  4106. img = images_remaining[i];
  4107. function wrap(imgsrc){return function(){ShowBigImage(imgsrc, 1);}}
  4108. img.addEventListener("click", wrap(img.dataset.imgsrc));
  4109. }
  4110. document.images_filtered = images_filtered;
  4111. function PopGalleryHistory(){
  4112. if(pushed){
  4113. pushed = 0;
  4114. try{
  4115. history.back();
  4116. }catch{
  4117. console.log("can't do it.");
  4118. }
  4119. }
  4120. }
  4121. function PushGalleryHistory(src){
  4122. abs_img = window.location.protocol+"//"+window.location.host+'/'+src
  4123. title = "照片"
  4124. extra = "?";
  4125. sp = new URLSearchParams(window.location.search)
  4126. if(sp.has('post')){extra+="post="+sp.get('post')}
  4127. if(sp.has('gallery')){extra+="&gallery="+sp.get('gallery')}
  4128. try{
  4129. window.history.pushState('&pic='+src, 'Title', extra+'&pic='+src);
  4130. }catch{
  4131. console.log("can't do it.");
  4132. }
  4133. pushed = 1;
  4134. }
  4135. document.addEventListener('keydown', function(e){
  4136. large = document.getElementById('big_image_overlay')
  4137. if (large.style.display!='block') return;
  4138. if(e.key=='Escape'||e.key=='Esc'||e.keyCode==27){
  4139. HideBigImage(1);
  4140. }
  4141. }, true);
  4142. window.addEventListener('popstate', (event) => {
  4143. if(event.state){
  4144. let sp = new URLSearchParams(event.state)
  4145. if(sp.has('pic')){
  4146. src = sp.get('pic')
  4147. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif)/u)) ShowBigImage(onlyimg[0], 0);
  4148. else{HideBigImage(0);}
  4149. }
  4150. }else{HideBigImage(0);}
  4151. });
  4152. let searchParams = new URLSearchParams(window.location.search)
  4153. if(searchParams.has('pic')){
  4154. src = searchParams.get('pic')
  4155. if(onlyimg = src.match(/[0-9]{14,}.(jpg|png|jpeg|gif)/u)){
  4156. ShowBigImage(onlyimg[0], 1);
  4157. }
  4158. }
  4159. function _dropHandler(event){ if (typeof dropHandler === "function") dropHandler(event); }
  4160. function _dragOverHandler(event){ if (typeof dragOverHandler === "function") dragOverHandler(event); }
  4161. </script>
  4162. </body>
  4163. <?php
  4164. }
  4165. function DoIdentiyExperimental(){
  4166. if(!isset($this->ExpHost) || $this->ExpHost=="") return;
  4167. if(preg_match('/'.preg_quote($this->ExpHost).'/u', $_SERVER['HTTP_HOST'])){
  4168. $this->InExperimentalMode=True;
  4169. }
  4170. if(!$this->CurrentPostID && $this->InExperimentalMode){
  4171. $this->CurrentPostID = $this->ExpIndex;
  4172. }
  4173. }
  4174. function DoExperimentalTopLink($p){
  4175. if($this->InExperimentalMode && $p){
  4176. if(isset($p['tid']) && $p['tid']['first']!=$p){
  4177. header('Location: ?post='.$p['tid']['first']['id']); exit();
  4178. }
  4179. }
  4180. }
  4181. function MakeExperimentalConfirm(){
  4182. if(isset($_COOKIE['la_experimental']) && $_COOKIE['la_experimental'] == 'confirmed'){
  4183. return false;
  4184. }
  4185. $caution_html =
  4186. $confirm = "<a class='text_highlight clean_a bold' href='index.php?confirm_enter=1".
  4187. (isset($this->CurrentPostID)?("&post=".$this->CurrentPostID):"").
  4188. "'>&nbsp;&nbsp;".$this->T('继续')."&nbsp;&nbsp;</a>";
  4189. ?>
  4190. <div class='center_exp'><?php
  4191. if(isset($this->ExpCaution) && ($p=$this->GetPost($this->ExpCaution,true)))$this->MakeSinglePostExp($p);
  4192. else echo "<li class='post post_dummy'>".$this->TranslatePostParts("<h1>注意</h1><p>您将进入实验站。</p>")."</li>";
  4193. ?></div>
  4194. <div class='center_exp'><li class='post post_dummy'><p><?=$confirm?></p></li></div>
  4195. <?php return true;
  4196. }
  4197. }
  4198. $la = new LA;
  4199. $la->DoSiteRedirect();
  4200. $la->DoLogin();
  4201. $err = $la->ProcessRequest($message, $redirect);
  4202. $la->WriteAsNecessary();
  4203. $la->DoIdentiyExperimental();
  4204. $la->SwitchLanguage();
  4205. $la->SwitchWayBackMode();
  4206. if($err){
  4207. echo $message;
  4208. exit();
  4209. }
  4210. if(isset($redirect)){
  4211. header('Location: '.$redirect);
  4212. exit();
  4213. }
  4214. $la->DetectPageType();
  4215. $la->ReadImages(false);
  4216. $la->ReadPosts();
  4217. if(isset($la->WayBack)){
  4218. $la->ReadArchive();
  4219. }
  4220. $p = &$la->GetPost($la->CurrentPostID);
  4221. if(!isset($p)){
  4222. $p = &$la->GetMergedPost($la->CurrentPostID);
  4223. }
  4224. if(isset($p) && !$la->CanShowPost($p)) $p=NULL;
  4225. else{ $la->DoExperimentalTopLink($p); }
  4226. if(isset($p)){ $la->ActualPostID = $p['id']; }
  4227. $la->MakeHeader($p);
  4228. $la->MakeMainBegin();
  4229. if($la->PageType=='experimental'){
  4230. if(!$la->MakeExperimentalConfirm()){
  4231. if($p){
  4232. $la->MakePostSectionExp($p);
  4233. $la->MakeLinkedPostsExp($p);
  4234. }else{
  4235. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  4236. "</p><p><a href='index.php'>".$la->T('返回首页')."</a></p><br />";
  4237. }
  4238. }
  4239. $la->MakeMainEnd();
  4240. $la->MakeExpFooter();
  4241. }else{
  4242. if($la->PageType=='extras'){
  4243. $la->MakeExtraOperations();
  4244. }else if($la->PageType=='settings'){
  4245. $la->MakeSettings();
  4246. }else if($la->PageType=='gallery'){
  4247. $la->MakeGalleryLeft();
  4248. $la->MakeGallerySection();
  4249. }else if($la->PageType=='post'){
  4250. if($p){
  4251. $made_interesting = false;
  4252. if($la->IsInterestingPost($p)){
  4253. $la->MakeInterestingSection($p['tid']);
  4254. }
  4255. else{
  4256. $la->MakeLinkedPosts($p);
  4257. $la->MakePostSection($p);
  4258. $la->MakeTOC();
  4259. }
  4260. }else{
  4261. echo "<h2>".$la->T('未找到这个帖子')."</h2><p>".$_SERVER['REQUEST_URI'].
  4262. "</p><p><a href='index.php'>".$la->T('返回首页')."</a></p><br />";
  4263. }
  4264. }else if($la->PageType=='history'){
  4265. $la->ReadArchive();
  4266. $la->MakePostHistory($p, $_GET['version']??NULL);
  4267. }else if($la->PageType=='search'){
  4268. $la->MakeHotPosts(true);
  4269. $la->MakeRecentPosts($_GET['search']);
  4270. }else if($la->PageType=='category'){
  4271. $la->MakeHotPosts(true);
  4272. $la->MakeRecentPosts(NULL,$_GET['category']);
  4273. }else if($la->PageType=='comments'){
  4274. $la->MakeCommentPosts();
  4275. }else{
  4276. $la->MakeHotPosts();
  4277. $la->MakeRecentPosts();
  4278. }
  4279. $la->MakeMainEnd();
  4280. $la->MakeFooter();
  4281. }
  4282. ?>