From ff06c39d6de06f708e4ca2241610e669ed10a2e0 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Wed, 27 Dec 2017 21:54:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=A1=B5=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- explore.php | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/explore.php b/explore.php index 42b9991..dad1559 100644 --- a/explore.php +++ b/explore.php @@ -4,6 +4,9 @@ include_once('./config.php'); //载入header include_once('./header.php'); + //获取页数 + $page = $_GET['page']; + $current_time = date('ym',time()); //当前月份 $time = $_GET['time']; @@ -52,13 +55,38 @@ } return $files; } + + //如果页数不存在或者小于1 + if((!isset($page)) || ($page <= 1)) { + $page = 1; + $i = 0; + $num = 15; + } + if($page > 1) { + $i = ($page - 1) * 15; + $num = $i + 15; + } $path = $mydir.'/'.$time; $dir = new RecursiveDirectoryIterator($path); $fname = get_files($dir); - $num = count($fname) - 1; + $allnum = count($fname) - 1; //文件总数 + //echo $allnum; + //最大页数 + $allpage = round($allnum / 15,0); + $uppage = $page - 1; //上一页 + $downpage = $page + 1; //下一页 + + $downpage = ($page >= $allpage) ? $page : $downpage; + //echo $allpage; + + //如果文件数小于15 + //$num = count($allnum < 15) ? $allnum : $num; + if($allnum <= 15) { + $num = $allnum; + } - for($i = 0;$i <= $num;$i++) { + for($i;$i <= $num;$i++) { $fname[$i] = str_replace("\\","/",$fname[$i]); //如果文件是空的,则终止循环 ?> @@ -79,6 +107,8 @@ + 上一页 + 下一页