*/}}

index.php 195 KB

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