The following files exists in this folder. Click to view.
Foogler_blog/pages
PAuthor.php
PCommentProcess.php
PDeleteCommentProcess.php
PDeletePost.php
PDeletePostProcess.php
PEditPost.php
PEditPostProcess.php
PErDiagramme.php
PIndex.php
PInstall.php
PInstallProcess.php
PNewPost.php
PNewPostProcess.php
PRssFeed.php
PShowPost.php
PStatistics.php
PValidate.php
login/
<?php
//------------------------
//PRssFeed.php
//
//Prints XML for RSS 1.0 feed
//------------------------
//---------------------
//DB stuff
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE); //New DB object
$tablePost = DB_PREFIX . 'Post';
$tableAuthor = DB_PREFIX . 'Author';
if (mysqli_connect_error()) {
echo "Connect failed: ".mysqli_connect_error()."<br>";
exit();
}
$mysqli->set_charset("utf8");
//-------------------
//SQL query
$query = <<<END
--
-- Gets all posts and author screenname for each post
--
SELECT
idPost,
postTitle,
UNIX_TIMESTAMP(postDate) AS 'postDate',
postText,
screenname
FROM mom07_10_Post
JOIN mom07_10_Author
ON (idAuthor = Post_idAuthor)
ORDER BY postDate DESC;
END;
//Performs query
$res = $mysqli->query($query) or die("Could not query database");
//For each post, get formatted RSS item
$itemsXML = "";
while($row = $res->fetch_object()) {
$itemsXML .= getRssItem($row);
}
$res->close();
$mysqli->close(); //Closes DB connection
header("Content-Type: text/xml;charset=iso-8859-1"); //XML header
echo getRssHeader(); //Prints RSS header
echo $itemsXML; //Prints post items
echo getRssCloseTag(); //Closes RSS
//--------------------------
//Returns header for RSS
function GetRssHeader() {
$title = WS_TITLE;
$siteLink = WS_SITELINK;
$imageLink = WS_SITELINK . "images/FooglerIcon_large.png";
$html = <<<END
<?xml version= "1.0" encoding="ISO-8859-1"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<channel rdf:about="{$siteLink}">
<title>{$title}</title>
<link>{$siteLink}</link>
<description>{$title}</description>
<image rdf:resource="{$imageLink}" />
<items></items>
</channel>
END;
return $html;
}
//------------------------
//Returns close tag fšr RSS feed XML
function getRssCloseTag() {
return "</rdf:RDF>";
}
//------------------------
//Returns XML for RSS item (post)
function getRssItem($row) {
$postLink = WS_SITELINK . "?p=post&id={$row->idPost}";
$teaser = strip_tags(substr($row->postText, 0, 150)) . "...";
$postDate = date("Y-m-d", $row->postDate);
$html = <<<END
<item rdf:about="{$postLink}">
<title>{$row->postTitle}</title>
<link>{$postLink}</link>
<description>{$teaser}</description>
<dc:date>{$postDate}</dc:date>
<dc:creator>{$row->screenname}</dc:creator>
</item>
END;
return $html;
}