You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.6 KiB

<?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();
?>