summaryrefslogtreecommitdiffstats
path: root/newsentry.php
blob: c4fe2f46cba5691ae8a93920b3fbffa24d218d44 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
	// (c) 2014 Trinity Desktop Project
	// All Rights Reserved
	// Authors: Elizabeth Liddell, Timothy Pearson, and Calvin Morrison

	include("globals.php");
	include("header.php");
	include("footer.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>';
	}
}

if ($handle = opendir('./news/')) {
$filenames = array();
while ($file = readdir($handle)) {
	$filenames[] = $file;
}
rsort($filenames);

$entryfound = 0;
foreach($filenames as $file) {
	if ($file == $_GET["entry"]) {
		writeNewsEntry($file, 'news');
		$entryfound = 1;
	}
}
closedir($handle);

if ($entryfound == 0) {
	if ($handle = opendir('./rssentries/')) {
		$filenames = array();
		while ($file = readdir($handle)) {
			$filenames[] = $file;
		}
		rsort($filenames);
		
		$entryfound = 0;
		foreach($filenames as $file) {
			if ($file == $_GET["entry"]) {
				writeNewsEntry($file, 'rssentries');
				$entryfound = 1;
			}
		}
		closedir($handle);
	
		if ($entryfound == 0) {
			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();
?>