Skip to content

Commit 1fd6f39

Browse files
committed
いいねボタンとの相性がわるいため、ページ目のJSONによるcacheを廃止(タイムスタンプとしての利用は継続)
1 parent a56d11b commit 1fd6f39

2 files changed

Lines changed: 53 additions & 55 deletions

File tree

‎petitnote/clap.inc.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ public static function addclap(): void
135135
$newline .= implode("", $lines);
136136
writeFile($cp, $newline);
137137
closeFile($cp);
138-
delete_res_cache();
139138
$_SESSION['clapped']["{$no}_{$id}"] = true;
140139
header('Content-type: text/plain');
141140
echo h($_clap);

‎petitnote/index.php‎

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
//https://paintbbs.sakura.ne.jp/
44
//1スレッド1ログファイル形式のスレッド式画像掲示板
55

6-
$petit_ver='v3.10.3';
7-
$petit_lot='lot.20260822.1';
6+
$petit_ver='v3.10.6';
7+
$petit_lot='lot.20260822.3';
88

99
$lang = ($http_langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '')
1010
? explode( ',', $http_langs )[0] : '';
@@ -2597,58 +2597,51 @@ function view(): void {
25972597
}
25982598
fclose($fp);
25992599

2600-
$index_cache_json = __DIR__.'/template/cache/index_cache.json';
2601-
26022600
$out=[];
2603-
if($page===0 && !$admindel && !$userdel && !$adminpost && !$is_badhost){
2604-
$out = is_file($index_cache_json) ? json_decode(file_get_contents($index_cache_json),true) : [];
2605-
}
2606-
if(empty($out)){
2607-
//oyaのループ
2608-
foreach($article_nos as $oya => $no){
2601+
//oyaのループ
2602+
foreach($article_nos as $oya => $no){
26092603

2610-
//個別スレッドのループ
2611-
if(!is_file(LOG_DIR."{$no}.log")){
2612-
continue;
2613-
}
2614-
$_res=[];
2615-
$out[$oya]=[];
2616-
$find_hide_thumbnail=false;
2617-
check_open_no($no);
2618-
$claps = clap::create_claplog_array($no);
2619-
$rp = fopen(LOG_DIR."{$no}.log", "r");//個別スレッドのログを開く
2620-
$lines=create_array_from_fp($rp);
2621-
fclose($rp);
2622-
$countres=count($lines);
2623-
$com_skipres= $dispres ? ($countres-($dispres+1)) : 0;
2624-
2625-
if($userdel || $admindel){
2626-
$com_skipres = 0; //削除モードの時はレスを省略しない
2627-
}
2604+
//個別スレッドのループ
2605+
if(!is_file(LOG_DIR."{$no}.log")){
2606+
continue;
2607+
}
2608+
$_res=[];
2609+
$out[$oya]=[];
2610+
$find_hide_thumbnail=false;
2611+
check_open_no($no);
2612+
$claps = clap::create_claplog_array($no);
2613+
$rp = fopen(LOG_DIR."{$no}.log", "r");//個別スレッドのログを開く
2614+
$lines=create_array_from_fp($rp);
2615+
fclose($rp);
2616+
$countres=count($lines);
2617+
$com_skipres= $dispres ? ($countres-($dispres+1)) : 0;
26282618

2629-
foreach($lines as $i => $line){
2619+
if($userdel || $admindel){
2620+
$com_skipres = 0; //削除モードの時はレスを省略しない
2621+
}
26302622

2631-
$_res=[];
2632-
$_res['clap_count'] = 0;
2633-
$_res['alreadyClapped'] = false;
2634-
if($fetch_articles_to_skip ||($i===0 || $i>$com_skipres)){//省略するレスは処理しない
2635-
$_res = create_res(explode("\t",trim($line)),['is_badhost'=>$is_badhost]);//$lineから、情報を取り出す
2636-
$_res['clap_count'] = $claps[$_res['first_posted_time']]['clapCount'] ?? 0;
2637-
$_res['alreadyClapped'] = $claps[$_res['first_posted_time']]['alreadyClapped'] ?? false;
2638-
}
2639-
if(isset($_res['img']) && $_res['img']){
2640-
if($_res['hide_thumbnail']){
2641-
$find_hide_thumbnail=true;
2642-
}
2623+
foreach($lines as $i => $line){
2624+
2625+
$_res=[];
2626+
$_res['clap_count'] = 0;
2627+
$_res['alreadyClapped'] = false;
2628+
if($fetch_articles_to_skip ||($i===0 || $i>$com_skipres)){//省略するレスは処理しない
2629+
$_res = create_res(explode("\t",trim($line)),['is_badhost'=>$is_badhost]);//$lineから、情報を取り出す
2630+
$_res['clap_count'] = $claps[$_res['first_posted_time']]['clapCount'] ?? 0;
2631+
$_res['alreadyClapped'] = $claps[$_res['first_posted_time']]['alreadyClapped'] ?? false;
2632+
}
2633+
if(isset($_res['img']) && $_res['img']){
2634+
if($_res['hide_thumbnail']){
2635+
$find_hide_thumbnail=true;
26432636
}
2644-
$out[$oya][]=$_res;
2645-
unset($lines[$i]);
2646-
}
2647-
$out[$oya][0]['find_hide_thumbnail']=$find_hide_thumbnail;
2648-
$out[$oya][0]['countres']=$countres;
2649-
if(empty($out[$oya])||$out[$oya][0]['oya']!=='oya'){
2650-
unset($out[$oya]);
26512637
}
2638+
$out[$oya][]=$_res;
2639+
unset($lines[$i]);
2640+
}
2641+
$out[$oya][0]['find_hide_thumbnail']=$find_hide_thumbnail;
2642+
$out[$oya][0]['countres']=$countres;
2643+
if(empty($out[$oya])||$out[$oya][0]['oya']!=='oya'){
2644+
unset($out[$oya]);
26522645
}
26532646
}
26542647
unset($article_nos);
@@ -2685,12 +2678,6 @@ function view(): void {
26852678
/** @var int|false $next */
26862679
[$prev,$next]=get_prev_next_pages($page,$pagedef,$count_alllog);
26872680

2688-
if($page===0 && !$admindel && !$adminpost && !$is_badhost){
2689-
if(!is_file($index_cache_json)){
2690-
file_put_contents($index_cache_json,json_encode($out),LOCK_EX);
2691-
chmod($index_cache_json,0600);
2692-
}
2693-
}
26942681
$use_misskey_note = $use_diary ? ($adminpost||$admindel) : $use_misskey_note;
26952682
$lightbox_gallery=false;
26962683
$resmode=false;
@@ -2702,6 +2689,12 @@ function view(): void {
27022689
//フォームの表示時刻をセット
27032690
set_form_display_time();
27042691

2692+
$index_cache_json = __DIR__.'/template/cache/index_cache.json';
2693+
if(!is_file($index_cache_json)){
2694+
file_put_contents($index_cache_json,json_encode([]),LOCK_EX);
2695+
chmod($index_cache_json,0600);
2696+
}
2697+
27052698
$admin_pass= null;
27062699
// HTML出力
27072700
$templete='main.html';
@@ -2947,6 +2940,12 @@ function res (): void {
29472940
if($res_catalog){
29482941
krsort($out[0]);
29492942
}
2943+
2944+
$index_cache_json = __DIR__.'/template/cache/index_cache.json';
2945+
if(!is_file($index_cache_json)){
2946+
file_put_contents($index_cache_json,json_encode([]),LOCK_EX);
2947+
chmod($index_cache_json,0600);
2948+
}
29502949

29512950
$admin_pass= null;
29522951
$templete= $res_catalog ? 'res_catalog.html' : 'res.html';

0 commit comments

Comments
 (0)