aboutsummaryrefslogtreecommitdiffstats
path: root/web/include/news.php
blob: fe1a2c8f8699a91ab7ddbff3f9130bcfbebb002c (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
<?php
require("/webspace/icculus.org/news/IcculusNews.php");

$id = $_GET['id'];
if (empty($_GET['news_index']))
	$news_index = false;
else
	$news_index = $_GET['news_index'];
$news_queue = 2;
$news_item_max = 5;

if ($err = news_login($sock, 'localhost', 263, NULL, NULL, $news_queue))
	$err = "Failed to log in: $err";
else
{
	if ($err = news_digest($sock, $digestarray, $news_index, $news_item_max))
	{
		$err = "Failed to get news digest: $err";
	}
	
	$current_post = 0;
	$news_item_count = count($digestarray);
	
	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'] . " - <em>" . date("F j, Y", strtotime($item['postdate'])) . "</em></h3>\n<p>" . $item['text'] . "</p>";
			if ($current_post++ == $news_item_count - 1)
				$lastid = $digestItem['id'];
			}
		}
		echo "<p>";
		if ($news_item_count == $news_item_max)
			echo "<a class=\"left\" href=\"?page=news&amp;news_index=$lastid\">&larr;Backpedal</a>";
		if ($news_index != false)
			echo "<a class=\"right\" href=\"?page=news\">To Newest&rarr;</a>";
		echo "</p>";
}

news_logout($sock);

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