Showing
1 changed file
with
9 additions
and
3 deletions
@@ -46,14 +46,20 @@ class CommonController extends WebAction | @@ -46,14 +46,20 @@ class CommonController extends WebAction | ||
46 | HomeModel::COOKIE_NAME_LIFESTYLE | 46 | HomeModel::COOKIE_NAME_LIFESTYLE |
47 | ); | 47 | ); |
48 | $channel = $this->post('type', ''); | 48 | $channel = $this->post('type', ''); |
49 | - $pageIndex = $this->post('pageIndex', 1); | ||
50 | - $pageCount = $this->post('pageCount', 8); | 49 | + $pageIndex = intval($this->post('pageIndex', 1)); |
50 | + $pageCount = intval($this->post('pageCount', 8)); | ||
51 | if (! in_array($channel, $channels)) { | 51 | if (! in_array($channel, $channels)) { |
52 | break; | 52 | break; |
53 | } else { | 53 | } else { |
54 | $data = HomeModel::getNewArrival($channel); | 54 | $data = HomeModel::getNewArrival($channel); |
55 | } | 55 | } |
56 | - $result = array_slice($data, ($pageIndex - 1) * $pageCount, $pageCount); | 56 | + if($pageIndex < 1) { |
57 | + $pageIndex = 1; | ||
58 | + } | ||
59 | + if($pageCount < 1 || $pageCount > 50) { | ||
60 | + $pageCount = 20; | ||
61 | + } | ||
62 | + $result = array_slice($data, $pageIndex - 1, $pageCount); | ||
57 | if (empty($result)) { | 63 | if (empty($result)) { |
58 | break; | 64 | break; |
59 | } | 65 | } |
-
Please register or login to post a comment