瀏覽代碼

新增单页加载表白数限制

UnknownO 3 年之前
父節點
當前提交
83513233c5
共有 2 個文件被更改,包括 12 次插入3 次删除
  1. 3 2
      config.php
  2. 9 1
      pages/homepage.php

+ 3 - 2
config.php

@@ -16,9 +16,10 @@ $ADMIN_PASS="kagamine1234";
 //是否开启伪静态(请先配置伪静态规则后再开启,否则可能导致404)
 $REWRITE=false;
 //随便一个字符串
-$VERIFICATION_KEY="KAGAMINE YES!"
+$VERIFICATION_KEY="KAGAMINE YES!";
+//单页允许加载的最多表白数
+$PAGEMAX=10;
 /*
 伪静态规则
 当前只支持nginx,apache规则的话...实在不会写,热心的童鞋可以帮忙写一下啊(谢谢各位大佬了)
 */
-?>

+ 9 - 1
pages/homepage.php

@@ -2,6 +2,12 @@
 if ($templateMode) {
     include('./includes/header.php');
 }
+
+if (empty($QueryArr['p'])) {
+    $nowPage = 0;
+} else {
+    $nowPage = intval($QueryArr['p']) - 1;
+}
 ?>
 <script>
     function RandomNumBoth(Min, Max) {
@@ -56,7 +62,9 @@ if ($templateMode) {
 $flag = true;
 try {
     $pdo = pdoConnect();
-    $stmt = $pdo->prepare("select * from loveway_data ORDER BY time DESC");
+    $stmt = $pdo->prepare("select * from loveway_data ORDER BY time DESC limit ?,?");
+    $stmt->bindValue(1, $nowPage * 20, PDO::PARAM_INT);
+    $stmt->bindValue(2, $PAGEMAX, PDO::PARAM_INT);
     if ($stmt->execute()) {
         while ($row = $stmt->fetch()) {
             $flag = false;