*/}}
YimingWu 1 week ago
parent
commit
9baeae4687
2 changed files with 55 additions and 26 deletions
  1. 52 26
      index.php
  2. 3 0
      translations.md

+ 52 - 26
index.php

@@ -42,6 +42,7 @@ class LA{
     protected $SpecialFooter;
     protected $SpecialFooter2;
     protected $SpecialPinned;
+    protected $SpecialPinnedNotes;
     protected $DefaultGallery;
     protected $SelfAuthPath;
     protected $HereHost;
@@ -83,6 +84,7 @@ class LA{
     protected $InExperimentalMode;
     protected $LanguageAppendix;
     protected $UseRemoteFont;
+    protected $NotesView;
     
     protected $Posts;
     protected $Threads; // [ keys: first last displayed count]
@@ -175,12 +177,13 @@ class LA{
             }
         }
         if(isset($LA_GLOBAL_LANG)){
-            if($LA_GLOBAL_LANG=='en'){ $this->LanguageAppendix = 'en'; setcookie('la_language','en',time()+3600*24*7); }
-            else if($LA_GLOBAL_LANG=='zh'){ $this->LanguageAppendix = 'zh'; setcookie('la_language','zh',time()+3600*24*7); }
+            if($LA_GLOBAL_LANG=='en'){ $this->LanguageAppendix = 'en'; setcookie('la_language','en',time()+3600*24*7,'/'); }
+            else if($LA_GLOBAL_LANG=='zh'){ $this->LanguageAppendix = 'zh'; setcookie('la_language','zh',time()+3600*24*7,'/'); }
         }
         if(isset($_COOKIE['la_font'])){
             $this->UseRemoteFont = ($_COOKIE['la_font']!='local');
         }
+        if($this->LoggedIn && isset($_COOKIE['la_notes_view'])){ $this->NotesView=$_COOKIE['la_notes_view']; }
     }
     function SwitchWayBackMode(){        
         if(isset($_COOKIE['la_wayback'])){
@@ -279,6 +282,7 @@ class LA{
         fwrite($conf,'- SpecialFooter = '.$this->SpecialFooter.PHP_EOL);
         fwrite($conf,'- SpecialFooter2 = '.$this->SpecialFooter2.PHP_EOL);
         fwrite($conf,'- SpecialPinned = '.$this->SpecialPinned.PHP_EOL);
+        fwrite($conf,'- SpecialPinnedNotes = '.$this->SpecialPinnedNotes.PHP_EOL);
         fwrite($conf,'- DefaultGallery = '.$this->DefaultGallery.PHP_EOL);
         fwrite($conf,'- SelfAuthPath = '.$this->SelfAuthPath.PHP_EOL);
         fwrite($conf,'- CommentEnabled = '.($this->CommentEnabled?"True":"False").PHP_EOL);
@@ -449,7 +453,7 @@ class LA{
         $this->NULL_IMAGE_DUMMY = [];
         $this->NULL_IMAGE_DUMMY['name']=$this->NULL_IMAGE_DUMMY['file']=$this->NULL_IMAGE_DUMMY['thumb']="";
         
-        $this->Markers=['●', '○', '✓', '×', '!', 'P', 'E', 'S'];
+        $this->Markers=['●', '○', '✓', '×', '!', 'P', 'E', 'S', 'N'];
         
         $this->PostsPerPage = 40;
         $this->CommentsPerPage = 100;
@@ -474,13 +478,13 @@ class LA{
     function RecordToken($unset_current=false){
         if(isset($unset_current) && isset($_COOKIE['la_token'])){
             $t = $_COOKIE['la_token'];
-            setcookie('la_token', null, -1); unset($_COOKIE['la_token']);
+            setcookie('la_token', null, -1,'/'); unset($_COOKIE['la_token']);
             if (($key = array_search($t,$this->LoginTokens)) !== false) { unset($this->LoginTokens[$key]); }
             $this->WriteTokens();
             return null;
         }else{
             $t = uniqid('la_',true);
-            setcookie('la_token',$t,time()+3600*24*7); $_COOKIE['la_token'] = $t;
+            setcookie('la_token',$t,time()+3600*24*7,'/'); $_COOKIE['la_token'] = $t;
             $this->LoginTokens[] = $t;
             $this->WriteTokens();
             return $t;
@@ -493,7 +497,7 @@ class LA{
         if (($key = array_search($t,$this->LoginTokens)) !== false) {
             $_SESSION['user_id']=$this->Admin;
             $this->LoggedIn = true;
-            setcookie('la_token',$t,time()+3600*24*7);
+            setcookie('la_token',$t,time()+3600*24*7,'/');
             return true;
         }
         return false;
@@ -1641,7 +1645,8 @@ blockquote{border-left:2px solid black;}
         }
         if(isset($th['first']['mark_value'])){
             if($th['first']['mark_value']==6)      $th['exp'] = true;
-            else if($th['first']['mark_value']==7) $th['slf'] = true;
+            else if($th['first']['mark_value']>=7) $th['slf'] = true;
+            if($th['first']['mark_value']==8)      $th['sln'] = true;
         }
         if($th['first'] == $th['last']){ unset($post['tid']); return; }
         $this->Threads[] = &$th;
@@ -2183,6 +2188,7 @@ blockquote{border-left:2px solid black;}
             if($this->GetPost($id,true)!== $this->NULL_POST) return $this->NULL_POST;
             $post = []; $post['id'] = $id;
             $post['real_content'] = $content; $post['content'] = &$post['real_content'];
+            if(isset($mark_value) && $mark_value!==NULL) $post['mark_value'] = $mark_value;
             if(isset($reply_to) && ($rep = &$this->GetPost($reply_to,true))!== $this->NULL_POST){
                 while($rep !== $this->NULL_POST && isset($rep['next']) && $rep['next']){ $rep = &$this->GetPost($rep['next'],true); }
                 if($rep !== $this->NULL_POST){ $rep['next'] = $id; $post['prev'] = $rep['id']; }
@@ -2276,7 +2282,8 @@ blockquote{border-left:2px solid black;}
     function CanShowPost(&$p){
         if(!isset($p) || isset($p['comment_to'])) return false;
         $is_mark_exp = (isset($p['tid'])&&isset($p['tid']['exp'])&&$p['tid']['exp']) || (isset($p['mark_value'])&&$p['mark_value']==6);
-        $is_mark_slf = (isset($p['tid'])&&isset($p['tid']['slf'])&&$p['tid']['slf']) || (isset($p['mark_value'])&&$p['mark_value']==7);
+        $is_mark_slf = (isset($p['tid'])&&isset($p['tid']['slf'])&&$p['tid']['slf']) || (isset($p['mark_value'])&&$p['mark_value']>=7);
+        $is_mark_sln = (isset($p['tid'])&&isset($p['tid']['sln'])&&$p['tid']['sln']) || (isset($p['mark_value'])&&$p['mark_value']==8);
         if($is_mark_slf && !$this->LoggedIn){ return false; }
         if(isset($this->WayBack)){
             if(isset($p['version'])) { if ($p['version']>$this->WayBack) return false; }
@@ -2287,6 +2294,7 @@ blockquote{border-left:2px solid black;}
                 if($is_mark_exp) return false;
                 return true;
             }
+            if($this->NotesView && !$is_mark_sln){ return false; }
             return true;
         }else{
             if($is_mark_exp) return true;
@@ -2494,7 +2502,7 @@ blockquote{border-left:2px solid black;}
                 $th = &$p['tid']; if($p['tid']['count']==0) continue; }
             
             if(in_array($p['id'],
-                [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
+                [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
             if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
             
             
@@ -2570,7 +2578,7 @@ blockquote{border-left:2px solid black;}
             return 0;
         }
         if(isset($_GET['set_language'])){
-            setcookie('la_language',$_GET['set_language'],time()+3600*24*7); $_COOKIE['la_language'] = $_GET['set_language'];
+            setcookie('la_language',$_GET['set_language'],time()+3600*24*7,'/'); $_COOKIE['la_language'] = $_GET['set_language'];
             $redirect=$this->GetRedirect(); return 0;
         }
         if(isset($_GET['rss'])){
@@ -2579,7 +2587,7 @@ blockquote{border-left:2px solid black;}
         }
         if(isset($_GET['toggle_font'])){ $use_font='local';
             if(!isset($_COOKIE['la_font']) || $_COOKIE['la_font']!='remote') $use_font='remote';
-            setcookie('la_font',$use_font,time()+3600*24*7); $_COOKIE['la_font'] = $use_font;
+            setcookie('la_font',$use_font,time()+3600*24*7,'/'); $_COOKIE['la_font'] = $use_font;
             $redirect=$this->GetRedirect(); return 0;
         }
         if(isset($_GET['set_wayback'])){
@@ -2592,9 +2600,9 @@ blockquote{border-left:2px solid black;}
                     if(isset($_POST['wayback_hour'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_hour'],2,"0",STR_PAD_LEFT),8,2);
                     if(isset($_POST['wayback_minute'])) $wayback=substr_replace($wayback,str_pad($_POST['wayback_minute'],2,"0",STR_PAD_LEFT),10,2);
                 }else{ if(preg_match('/[0-9]{14}/u', $_GET['set_wayback'])) $wayback = $_GET['set_wayback']; }
-                setcookie('la_wayback',$wayback); $_COOKIE['la_wayback'] = $wayback;
+                setcookie('la_wayback',$wayback,'/'); $_COOKIE['la_wayback'] = $wayback;
             }else{
-                setcookie('la_wayback', null, -1); unset($_COOKIE['la_wayback']);
+                setcookie('la_wayback', null, -1,'/'); unset($_COOKIE['la_wayback']);
             }
             $redirect=$this->GetRedirect(); return 0;
         }
@@ -2647,7 +2655,7 @@ blockquote{border-left:2px solid black;}
             exit;
         }
         if(isset($_GET['confirm_enter']) && $_GET['confirm_enter']!=false){
-            setcookie('la_experimental','confirmed'); $_COOKIE['la_experimental'] = $_GET['confirmed'];
+            setcookie('la_experimental','confirmed','/'); $_COOKIE['la_experimental'] = $_GET['confirmed'];
             $redirect=$INDEXPHP.(isset($_GET['post'])?'?post='.$_GET['post']:"");return 0;
         }
         if(isset($_GET['apub_actor'])){
@@ -2666,6 +2674,10 @@ blockquote{border-left:2px solid black;}
             if(isset($_GET['TestAPubDeliver'])){
                 $this->APubTestDeliver();
             }
+            if(isset($_GET['set_notes_view'])){
+                setcookie('la_notes_view',$_GET['set_notes_view'],time()+3600*24*7,'/'); $_COOKIE['la_notes_view'] = $_GET['set_notes_view'];
+                $redirect=$this->GetRedirect(); return 0;
+            }
         
             $this->DoUpload();
             
@@ -2679,6 +2691,7 @@ blockquote{border-left:2px solid black;}
                 if(isset($_POST['settings_special_footer'])) $this->SpecialFooter=$_POST['settings_special_footer'];
                 if(isset($_POST['settings_special_footer2'])) $this->SpecialFooter2=$_POST['settings_special_footer2'];
                 if(isset($_POST['settings_special_pinned'])) $this->SpecialPinned=$_POST['settings_special_pinned'];
+                if(isset($_POST['settings_special_pinned_notes'])) $this->SpecialPinnedNotes=$_POST['settings_special_pinned_notes'];
                 if(isset($_POST['settings_default_gallery'])) $this->DefaultGallery=$_POST['settings_default_gallery'];
                 if(isset($_POST['settings_selfauth_path'])) $this->SelfAuthPath=$_POST['settings_selfauth_path'];
                 if(isset($_POST['settings_enable_comments'])) $this->CommentEnabled=True; else $this->CommentEnabled=False;
@@ -2746,7 +2759,7 @@ blockquote{border-left:2px solid black;}
                 if(isset($_GET['post'])) $redirect='?post='.$_GET['target']; else $redirect=$this->GetRedirect();
                 return 0;
             }
-            if(isset($_POST['post_button']) && isset($_POST['post_content'])){
+            if((isset($_POST['post_button'])||isset($_POST['post_button_note'])) && isset($_POST['post_content'])){
                 $c = $_POST['post_content'];
                 if('有什么想说的' == $c){ return 0;}
                 if(preg_match('/\[LAMDWIKIPOST/u',$c))
@@ -2754,7 +2767,9 @@ blockquote{border-left:2px solid black;}
                 $reply_to = (isset($_POST['post_reply_to'])&&$_POST['post_reply_to']!="")?$_POST['post_reply_to']:NULL;
                 $edit_id = (isset($_POST['post_edit_target'])&&$_POST['post_edit_target']!="")?$_POST['post_edit_target']:NULL;
                 $push_history = (isset($edit_id) && isset($_POST['post_record_edit']));
-                if(($edited = $this->EditPost($edit_id, $c, NULL, $reply_to,NULL,NULL,NULL,$push_history,NULL,NULL))!=NULL){
+                $postmark=NULL;
+                if(isset($_POST['post_button_note'])){ $postmark=8; }
+                if(($edited = $this->EditPost($edit_id, $c, NULL, $reply_to,NULL,$postmark,NULL,$push_history,NULL,NULL))!=NULL){
                     $redirect='?post='.$edited['id']; return 0;
                 };
             }
@@ -3172,6 +3187,7 @@ blockquote{border-left:2px solid black;}
                     <a id='mark_set_5' href='javascript:SetMark(5);'><?=$this->Markers[5]?></a>
                     <a id='mark_set_6' href='javascript:SetMark(6);'><?=$this->Markers[6]?></a>
                     <a id='mark_set_7' href='javascript:SetMark(7);'><?=$this->Markers[7]?></a>
+                    <a id='mark_set_8' href='javascript:SetMark(8);'><?=$this->Markers[8]?></a>
                 </b></li>
                 <li id='rename_details' style='display:none;text-align:left;' class='smaller'>
                     <form action="" method="post" style='display:none;' id='post_rename_form'></form>
@@ -3240,9 +3256,11 @@ blockquote{border-left:2px solid black;}
             <li class='hidden_m'><a href='?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
             <li class='hidden_on_desktop_force block_m smaller'>&nbsp;</li>
             <li class='hidden_on_desktop_force block_m bigger'>
-                <a href='<?=$INDEXPHP?>?part=recent' onclick='ShowWaitingBar()'><?=$this->T('最近')?></a>
+                <a href='<?=$INDEXPHP?>?part=recent' onclick='ShowWaitingBar()'><?=$this->NotesView?$this->T('笔记'):$this->T('最近')?></a>
                 <?php if($this->LoggedIn){ ?> | <span class='gray invert_a'>
-                    <a href='<?=$INDEXPHP?>?comments=all'>@</a> <a href='<?=$INDEXPHP?>?statistics=all'>%</a></span><?php } ?></li>
+                    <a href='<?=$INDEXPHP?>?set_notes_view=<?=$this->NotesView?'0':'1'?>'>N</a>
+                    <a href='<?=$INDEXPHP?>?comments=all'>@</a> <a href='<?=$INDEXPHP?>?statistics=all'>%</a>
+                </span><?php } ?></li>
             <li class='hidden_on_desktop_force block_m bigger'>
                 <a href='<?=$INDEXPHP?>?gallery=default' onclick='ShowWaitingBar()'><?=$this->T('画廊')?></a></li>
             <?php $this->SpecialNavigation;if(isset($this->SpecialNavigation) && ($p = &$this->GetPost($this->SpecialNavigation))!=NULL){
@@ -3311,6 +3329,8 @@ blockquote{border-left:2px solid black;}
                   oninput=\"la_auto_grow(this);\" onload=\"la_auto_grow(this);\">{$this->T('有什么想说的')}</textarea>
         <input class='button' form=\"post_form\" type=\"submit\" name='post_button' value='{$this->T('发送')}' 
             onclick='ShowWaitingBar();' />
+        <input class='button' form=\"post_form\" type=\"submit\" name='post_button_note' value='{$this->T('笔记')}' 
+            onclick='ShowWaitingBar();' />
         | <a class='gray smaller pointer' onclick='ShowSideUploader();'>{$this->T('图片')}</a>
         <div style='float:right;'>
             <a class='gray smaller pointer' onclick=\"t=document.querySelector('#post_content');t.value='';la_auto_grow(t);\">
@@ -3521,20 +3541,23 @@ blockquote{border-left:2px solid black;}
     }
 
     function MakeRecentPostsV2($search_term=NULL, $category=NULL){ global $INDEXPHP;
-        $STR="";
+        $STR=""; $tmppinned=$this->SpecialPinned;
+        if($this->LoggedIn && $this->NotesView){ $this->SpecialPinned=$this->SpecialPinnedNotes; }
         if(!isset($search_term) && !isset($category) &&
             (isset($this->SpecialPinned) && ($p = &$this->GetPost($this->SpecialPinned))!=NULL && !$this->CurrentOffset) &&
             $this->CanShowPost($p)){
             $this->MakeSinglePostV2($p, true, false, "active_post", false, true, false, false, false, true, false);
         }
-        if($this->NewsletterEnabled && !isset($category) && !isset($search_term)){
+        $this->SpecialPinned=$tmppinned;
+        if($this->NewsletterEnabled && !isset($category) && !isset($search_term) && !$this->NotesView){
             $STR=$this->MakeSubscription(); $this->TFill(2,$STR); $this->TRow(); $STR='';
         }
         $STR.="<br /><h2>".(isset($search_term)?$this->T('搜索'):
                                 (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
-                                    ($category=='none'?$this->T('未分类'):$this->T($category))):($this->T('最近')).
-                                    " <span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
-                                    ($this->LoggedIn?"<a href='".$INDEXPHP."?comments=all'>@</a> <a href='".$INDEXPHP."?statistics=all'>%</a>":"")."</span>")).
+                                    ($category=='none'?$this->T('未分类'):$this->T($category))):($this->NotesView?$this->T('笔记'):$this->T('最近')).
+                                    "<span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
+                                    ($this->LoggedIn?" <a href='".$INDEXPHP."?set_notes_view=".($this->NotesView?'0':'1')."'>N</a> ".
+                                    "<a href='".$INDEXPHP."?comments=all'>@</a> <a href='".$INDEXPHP."?statistics=all'>%</a>":"")."</span>")).
                     "</h2><br />";
         $this->TFill(2,$STR); $this->TRow();
         if(isset($search_term)){
@@ -3567,7 +3590,7 @@ blockquote{border-left:2px solid black;}
                 if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
             }else{
                 if(in_array($p['id'],
-                    [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
+                    [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
                 if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
             }
             if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
@@ -3803,7 +3826,7 @@ blockquote{border-left:2px solid black;}
             }?>
             <h2><?=isset($search_term)?$this->T('搜索'):
                                 (isset($category)?("<span class='gray'>".$this->T('分类')."</span> ".
-                                    ($category=='none'?$this->T('未分类'):$this->T($category))):($this->T('最近')).
+                                    ($category=='none'?$this->T('未分类'):$this->T($category))):($this->NotesView?$this->T('笔记'):$this->T('最近')).
                                     " <span class='gray invert_a hidden_on_print'>".//"<a href='index.php?&set_wayback=true'>↶</a>".
                                     ($this->LoggedIn?"<a href='$INDEXPHP?comments=all'>@</a> <a href='$INDEXPHP?statistics=all'>%</a>":"")."</span>")?></h2><br />
             <?php if(isset($search_term)){ ?>
@@ -3836,7 +3859,7 @@ blockquote{border-left:2px solid black;}
                             if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
                         }else{
                             if(in_array($p['id'],
-                                [$this->SpecialPinned,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
+                                [$this->SpecialPinned,$this->SpecialPinnedNotes,$this->SpecialFooter,$this->SpecialFooter2,$this->SpecialNavigation,$this->SpecialSidebar])) continue;
                             if(isset($p['tid'])){ if(isset($p['tid']['displayed'])) continue; $p['tid']['displayed'] = True; }
                         }
                         if($i < $this->PostsPerPage * $this->CurrentOffset) {$i++; continue;}
@@ -4980,6 +5003,9 @@ blockquote{border-left:2px solid black;}
                     <tr><td><?=$this->T('置顶文')?><?=isset($this->SpecialPinned)?"<a href='?post=".$this->SpecialPinned."'>→</a>":""?></td>
                         <td><input type="text" form="settings_form" id='settings_special_pinned' name='settings_special_pinned'
                         value='<?=$this->SpecialPinned?>'/></td></tr>
+                    <tr><td><?=$this->T('置顶笔记')?><?=isset($this->SpecialPinnedNotes)?"<a href='?post=".$this->SpecialPinnedNotes."'>→</a>":""?></td>
+                        <td><input type="text" form="settings_form" id='settings_special_pinned_notes' name='settings_special_pinned_notes'
+                        value='<?=$this->SpecialPinnedNotes?>'/></td></tr>
                     <tr><td><?=$this->T('默认相册')?></td>
                         <td><input type="text" form="settings_form" id='settings_default_gallery' name='settings_default_gallery'
                         value='<?=$this->DefaultGallery?>'/></td></tr>

+ 3 - 0
translations.md

@@ -1,3 +1,6 @@
+- 置顶备忘 | Pinned Reminder
+- 备忘录 | Reminders
+- 备忘 | Remind
 - 订阅 | Subscribe
 - 输入您的邮件: | Enter your email:
 - 订阅我的新闻 | Newsletters