<?php
// edit these two lines
$url="http://www.affordable-wombles.org";
$password="mypassword";
// everything below here can be left alone
$title=date("d/m/y"); // this line and the next generate a title which
// includes the date as a handy reference
$title=$title." - ".$_POST["title"];
$post=$_POST["post"];
// the next few lines do the fiddling required to make sure the data
// looks right, whether it's viewed via the RSS feed or via the database
$longpost=str_replace("<br />", "\n", $post);
$shortpost=substr($post,0,600);
$shortpost=str_replace("<br />", "\n", $shortpost);
$pass=$_POST["pass"];
if ($pass == $password) {
include "db.inc";
// this line actually inserts the data
mysql_query("INSERT INTO entries VALUES (NULL, '$title', '$post')");
$getid=mysql_query("SELECT id FROM entries WHERE title='$title'");
$myrow=mysql_fetch_array($getid);
$postid=$myrow["id"];
// from here on in, we're building the RSS feed.
$arrFp = file("rss/feed.xml");
$lines = count($arrFp);
$insertat = $lines-2;
for ($i=0; $i<$insertat; $i++) {
$rsstext=$rsstext.$arrFp[$i];
}
$rsstext=$rsstext."<item>\n";
$rsstext=$rsstext."<title>".stripslashes($title)."</title>\n";
$rsstext=$rsstext."<description>".stripslashes($shortpost);
if (strlen($shortpost)<strlen($longpost)) {
$rsstext=$rsstext."...";
}
$rsstext=$rsstext."</description>\n";
$rsstext=$rsstext."<link>$url/comment.php?post=$postid</link>\n";
$rsstext=$rsstext."</item>\n";
$rsstext=$rsstext."</channel>\n";
$rsstext=$rsstext."</rss>";
$fp=fopen("rss/feed.xml", "w");
fwrite( $fp, $rsstext );
fclose($fp);
echo "Post successfully submitted!";
} else {
echo "You are not authorised to post to this server!";
}
?>