Show sourcecode

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/

PRssFeed.php

113 lines ISO-8859-1 Unix (LF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
//------------------------
//PRssFeed.php
//
//Prints XML for RSS 1.0 feed
//------------------------

//---------------------
//DB stuff
$mysqli = new mysqli(DB_HOSTDB_USERDB_PASSWORDDB_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&amp;id={$row->idPost}";
  
$teaser strip_tags(substr($row->postText0150)) . "...";
  
$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;
}