summaryrefslogtreecommitdiffstats
path: root/newsentry.php
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2015-10-05 13:46:54 -0500
committerTimothy Pearson <[email protected]>2015-10-05 13:46:54 -0500
commit5ed01bd42b0aaf222f3b04b611e31b3d0974b6a4 (patch)
treee2adf4f018d79bce5853d42cdbda6c05c25955fa /newsentry.php
downloadwebsite-core-5ed01bd42b0aaf222f3b04b611e31b3d0974b6a4.tar.gz
website-core-5ed01bd42b0aaf222f3b04b611e31b3d0974b6a4.zip
Initial import of static files
Diffstat (limited to 'newsentry.php')
-rw-r--r--newsentry.php81
1 files changed, 81 insertions, 0 deletions
diff --git a/newsentry.php b/newsentry.php
new file mode 100644
index 0000000..c4fe2f4
--- /dev/null
+++ b/newsentry.php
@@ -0,0 +1,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();
+?>
+
+