\n"; $rss .= "\n\n"; $rss .= " \n"; $rss .= " DarwinPorts Project News\n"; $rss .= " http://darwinports.opendarwin.org/\n"; $rss .= " DarwinPorts Project News\n"; $rss .= " en-us\n"; $rss .= " Jim Mock (mij@opendarwin.org)\n"; $rss .= " Copyright 2002-2003\n"; $rss .= " $rssdate\n"; $rss .= " \n"; if(mysql_num_rows($result) > 0) { while($row = mysql_fetch_object($result)) { $rss .= " \n"; $rss .= " $row->title\n"; $rss .= " http://darwinports.opendarwin.org/archives/$row->id.php\n"; $desc_query = "SELECT SUBSTRING_INDEX(news, ' ', 26) FROM headlines WHERE id=$row->id"; $desc_result = mysql_query($desc_query); $desc_row = mysql_fetch_row($desc_result); $description = $desc_row[0]; $rss .= " ]]>\n"; $rss .= " http://darwinports.opendarwin.org/archives/$row->id.php\n"; $rss .= " news]]>\n"; $rss .= " \n"; } } $rss .= " \n"; $rss .= "\n"; $write = fwrite($open, $rss); $close = fclose($open); } ###################################################################### # print the project news function print_headlines() { global $connect; $query = "SELECT id, DATE_FORMAT(timestamp, '%e %b %Y, %l:%i %p') AS f_timestamp, title, news FROM headlines ORDER BY id DESC LIMIT 5"; $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 "
$row->title
\n"; echo "
$row->f_timestamp
\n"; echo "$row->news\n\n"; } } else { echo "

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 "
$row->title
\n"; echo "
$row->f_timestamp
\n"; echo "$row->news\n\n"; } else { echo "

Error!

\n"; 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"; echo "

Title:  

\n"; echo "

News:

\n"; echo "

\n"; echo "

\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 "\n\n"; } } } ###################################################################### # print the form used to edit project news function print_edit_headline($id) { global $PHP_SELF, $connect; if(!$_POST['submit']) { $id = $_GET['id']; $query = "SELECT title, news FROM headlines WHERE id='$id'"; $result = mysql_query($query) or die("Error: $query."); if(!$result) { die("Error: $result."); } if(mysql_num_rows($result) > 0) { $row = mysql_fetch_object($result); echo "

Use the form below to edit project news.

\n\n"; echo "
\n"; echo "

Title:  title\" />

\n"; echo "

News:

\n"; echo "

\n"; echo "

\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 "\n\n"; } } } ###################################################################### # print a list of all existing headlines function print_all_headlines() { global $connect; 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.php\">$row->title
  $row->f_timestamp  |  id\">edit

\n\n"; } } else { echo "

No headlines are available.

\n\n"; } } ?>