summaryrefslogtreecommitdiffstats
path: root/newsentry.php
blob: 12835a32a17455032232507e858552d32dc128ed (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
	// (c) 2014 Trinity Desktop Project
	// All Rights Reserved
	// Authors: Elizabeth Liddell, Timothy Pearson, and Calvin Morrison

	include("globals.php");
	include("tde-head-and-foot.php");
	doHeader("Trinity News", "Main", "News");
?>

<?php

function writeNewsEntry($file, $prefix) {
	// sort($handle, SORT_NUMERIC);
	if (($file != ".") && ($file != "..") && ($file{0} != '.')) {
		echo '<div class="news">';
		echo "<h3>$file: ";
		
		$data = file_get_contents($prefix . "/$file"); //read the file
		$convert = explode("\n", $data); //create array separate by new line
		for ($i=0;$i<count($convert);$i++) {
			echo $convert[$i]. '<br>'; //write value by index
			if ($i == 0){
				echo "</h3>";
			}
		}
		echo '</div>';
	}
}

$entryFound = false;
if (!empty($_GET['entry']))
{
	$sources = ['news', 'rssentries'];
	foreach ($sources as $source)
	{
		$filenames = scandir('./'.$source.'/', SCANDIR_SORT_DESCENDING);
		if (in_array($_GET['entry'], $filenames))
		{
			writeNewsEntry($_GET['entry'], $source);
			$entryFound = true;
			break;
		}
	}
}
if (!$entryFound)
{
	echo '<font color="red">Requested news entry not found!</font>';
	echo "<p>";
}

echo '<a href="/news.php">Go back to News</a>';
echo "<p>";

?>

<?php
	doFooter();
?>