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.

60 lines
1.2 KiB

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