*/}}

index.php 146 KB

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