diff options
-rw-r--r-- | web/include/news.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/web/include/news.php b/web/include/news.php index 07dc3cf..a1c4c2a 100644 --- a/web/include/news.php +++ b/web/include/news.php @@ -2,7 +2,9 @@ require("/webspace/icculus.org/news/IcculusNews.php"); $id = $_GET['id']; +if (empty($_GET['news_index'])) { $news_index = 0; } $news_queue = 2; +$news_item_count = 5; if ($err = news_login($sock, 'localhost', 263, NULL, NULL, $news_queue)) $err = "Failed to log in: $err"; @@ -13,7 +15,7 @@ else $digestarray[] = array( 'id' => $id ); } - else if ($err = news_digest($sock, $digestarray, false, 10)) + else if ($err = news_digest($sock, $digestarray, $news_index, $news_item_count)) { $err = "Failed to get news digest: $err"; } @@ -29,6 +31,21 @@ else } echo "<h3>" . $item['title'] . "-" . $item['postdate'] . "</h3>\n<p>" . $item['text'] . "</p>"; } + + $post_count = count($digestarray); + + if ($news_index != 0) + { + $ncount = ($news_index - $news_item_count); + if ($ncount == 0) { unset($ncount); } + echo "<a class=\"floater right\" href=\"?page=news&news_index=" . $ncount . "\">Newer→</a>"; + } + if ($post_count == $news_item_count) { + $ncount = ($news_index + $news_item_count); + if ($ncount == 0) { unset($ncount); } + echo "<a class=\"floater left\" href=\"?page=news&news_index=" . $ncount . "\">←Older</a>"; +} + } } |