aboutsummaryrefslogtreecommitdiffstats
path: root/web/include/news.php
blob: a1c4c2ab7c38855882afbbdbf7ca68637d0e624d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
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";
else
{
	if (isset($id))
	{
		$digestarray[] = array( 'id' => $id );
	}

	else if ($err = news_digest($sock, $digestarray, $news_index, $news_item_count))
	{
		$err = "Failed to get news digest: $err";
	}

	if (!isset($err))
	{
		foreach($digestarray as $digestItem)
		{
			if ($err = news_get($sock, $digestItem['id'], $item))
			{
				$err = "Failed to grab news item: $err";
				break;
			}
			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&amp;news_index=" . $ncount . "\">Newer&rarr;</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&amp;news_index=" . $ncount . "\">&larr;Older</a>";
}

	}
}

news_logout($sock);

if ($err) {
	$code = 500;
	$detail = $err;
	require("errors.php");
}
?>