<?php $nowPage = 1; if (isset($_GET['page'])) { $nowPage = $_GET['page']; } $categoryId = -1; if (isset($_GET['category'])) { $categoryId = $_GET['category']; } $nextPage = $nowPage + 1; $befPage = $nowPage - 1; $pageMaxRow = 15; $startCnt = ($nowPage - 1) * $pageMaxRow; $pageData = loadPageInfo(); $cnt = count($pageData); $tmpPages = []; $allRowCnt = 0; for ($i = 0; $i < $cnt; $i++) { if ($pageData[$i] == "") { continue; } $row = explode(DELIMITER, $pageData[$i]); if ($categoryId >= 0 && $row[1] != $categoryId) { continue; } $tmpPages[count($tmpPages)] = $pageData[$i]; $allRowCnt += 1; } $pageData = $tmpPages; $cnt = count($pageData);
function deletePage($delId) { // 本文を削除 // pagesから削除 $pageData = loadPageInfo(); $cnt = count($pageData); $pageInfo = ''; for ($i = 0; $i < $cnt; $i++) { if ($pageData[$i] == "") { continue; } $row = explode(DELIMITER, $pageData[$i]); $id = $row[0]; $category = $row[1]; $title = $row[2]; $description = $row[3]; if ($id == $delId) { $markdown = 'data/posts/' . $id . '.txt'; } else { $pageInfo .= $id . DELIMITER . $category . DELIMITER . $title . DELIMITER . $description . "\n"; } } // ページ情報を上書き try { file_put_contents('data/pages', $pageInfo); unlink($markdown); } catch (Exception $e) { return false; } return true; }