*/}}

index.php 194 KB

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