\n";
$rss .= "
No headlines are available at this time.
\n"; } } ###################################################################### # display a single headline function print_headline() { global $connect; $id = $_GET['id']; $query = "SELECT id, DATE_FORMAT(timestamp, '%e %b %Y, %l:%i %p') AS f_timestamp, title, news FROM headlines WHERE id='$id'"; $result = mysql_query($query) or die("Error: $query."); if(!$result) { die("Error: $result."); } $row = mysql_fetch_object($result); if($row) { echo "The requested headline could not be found. It is either not in the database, or an error has occurred.
\n"; } } ###################################################################### # print the form used to add project news function print_add_headline() { global $PHP_SELF, $connect; if(!$_POST['submit']) { echo "Use the form below to add project news.
\n\n"; echo "\n\n"; } else { $title = $_POST['title']; $news = $_POST['news']; $errorList = array(); $count = 0; if(!$title) { $errorList[$count] = 'Invalid entry: Title'; $count++; } if(!$news) { $errorList[$count] = 'Invalid entry: News'; $count++; } if(sizeof($errorList) == 0) { $query = "INSERT INTO headlines (timestamp, title, news) VALUES (NOW(), '$title', '$news')"; $result = mysql_query($query) or die("Error: $query."); if(!$result) { die("Error: $result."); } echo "The addition was successful. You can either list all existing headlines, add another headline, or return to the DarwinPorts site.
\n\n"; create_rss(); } else { echo "The following errors have occurred:
\n\n"; echo "Use the form below to edit project news.
\n\n"; echo "\n\n"; } else { echo "The requested news headline could not be found. It is either not in the database, or an error has occurred. Please try again.
\n\n"; } } else { $title = $_POST['title']; $news = $_POST['news']; $errorList = array(); $count = 0; if(!$title) { $errorList[$count] = 'Invalid entry: Title'; $count++; } if(!$news) { $errorList[$count] = 'Invalid entry: News'; $count++; } if(sizeof($errorList) == 0) { $query = "UPDATE headlines SET title='$title', news='$news' WHERE id='$id'"; $result = mysql_query($query) or die("Error: $query."); if(!$result) { die("Error: $result."); } echo "The update was successful. You can either list all existing headlines, add another headline, or return to the DarwinPorts site.
\n\n"; create_rss(); } else { echo "The following errors have occurred:
\n\n"; echo "Below is a list of all existing news headlines. They can be viewed, edited, or deleted from this interface. Alternatively, you can also add news.
\n\n"; $query = "SELECT id, title, DATE_FORMAT(timestamp, '%e %b %Y, %l:%i %p') AS f_timestamp FROM headlines ORDER BY id DESC"; $result = mysql_query($query) or die("Error: $query."); if(!$result) { die("Error: $result."); } if(mysql_num_rows($result) > 0) { while($row = mysql_fetch_object($result)) { echo "id\">$row->title
$row->f_timestamp | id\">edit
No headlines are available.
\n\n"; } } ###################################################################### # print a list of all existing headlines without the admin foobage # (this is cheap and could be better) function print_all_headlines_nonadmin() { global $connect; $query = "SELECT id, title, DATE_FORMAT(timestamp, '%e %b %Y, %l:%i %p') AS f_timestamp FROM headlines ORDER BY id DESC"; $result = mysql_query($query) or die("Error: $query."); if(!$result) { die("Error: $result."); } if(mysql_num_rows($result) > 0) { while($row = mysql_fetch_object($result)) { echo "id\">$row->title
$row->f_timestamp
No headlines are available.
\n\n"; } } ?>