Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MySQLiToRSS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Clément Février
MySQLiToRSS
Compare Revisions
87584359607905366d5c27a609b8cfc74964656e...47f9691a4cd3d43f24c1022ebbf207cd78613a0b
Source
47f9691a4cd3d43f24c1022ebbf207cd78613a0b
Select Git revision
...
Target
87584359607905366d5c27a609b8cfc74964656e
Select Git revision
Compare
Commits (5)
Add generator tag
· 6f6fba07
Clément Février
authored
Nov 21, 2017
6f6fba07
Proper indentation for <category>
· 92d927e7
Clément Février
authored
Nov 21, 2017
92d927e7
comment section
· 429cdc97
Clément Février
authored
Nov 21, 2017
429cdc97
Proper end of line at the end of the file
· 72919141
Clément Février
authored
Nov 21, 2017
72919141
add pubDate and lastBuildDate for the channel
· 47f9691a
Clément Février
authored
Nov 21, 2017
47f9691a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
rss/index.php.dist
rss/index.php.dist
+25
-1
No files found.
rss/index.php.dist
View file @
47f9691a
...
...
@@ -105,6 +105,8 @@
// Probably the same than the blog's description.
$author
=
'contact+rss@yourdomain.tld (My Name)'
;
// author's contact informations. If you are the sole author,
// you do not need to fetch this information through MySQL.
$commentLink
=
'#comments'
;
// Pattern for commentary section.
// In this case $articleLink . '#comments'
// Header
...
...
@@ -162,6 +164,8 @@
// There is no reason to change this item.
$rssfeed
.
=
' <docs>http://www.rssboard.org/rss-specification</docs>'
;
$rssfeed
.
=
"
\n
"
;
$rssfeed
.
=
' <generator>MySQLiToRSS</generator>'
;
$rssfeed
.
=
"
\n
"
;
// MySQL connect
$conn
=
new
mysqli
(
$servername
,
$username
,
$password
,
$dbname
);
...
...
@@ -178,11 +182,27 @@
// Store the SQL query in $result
$result
=
$conn
->
query
(
$query
)
or
die
(
"Could not execute query"
);
// Boolean used to create pubDate and lastBuildDate
// for the channel
// Because it is not clear the different between the 2,
// I set them equal.
$pubDate
=
false
;
// For each article
while
(
$row
=
$result
->
fetch_assoc
())
{
// Extract row
extract
(
$row
);
// If pubDate is not set for the channel
if
(
!
$pubDate
)
{
// Add pubDate and lastBuildDate to match the date of last published article
$rssfeed
.
=
' <pubDate>'
.
date
(
"D, d M Y H:i:s O"
,
strtotime
(
$creationdate
))
.
'</pubDate>'
;
$rssfeed
.
=
"
\n
"
;
$rssfeed
.
=
' <lastBuildDate>'
.
date
(
"D, d M Y H:i:s O"
,
strtotime
(
$creationdate
))
.
'</lastBuildDate>'
;
$rssfeed
.
=
"
\n
"
;
// Do not add pubDate and lastBuildDate for the channel anymore
$pubDate
=
true
;
}
// Begin <item>
$rssfeed
.
=
' <item>'
;
$rssfeed
.
=
"
\n
"
;
...
...
@@ -222,6 +242,9 @@
// Author's contact informations
$rssfeed
.
=
' <author>'
.
$author
.
'</author>'
;
$rssfeed
.
=
"
\n
"
;
// URL to the commentary section of the article
$rssfeed
.
=
' <comments>'
.
$articleLink
.
$commentLink
.
'</comments>'
;
$rssfeed
.
=
"
\n
"
;
// Tags
// MySQL Query to fetch all tag's ids for this article, referenced as $id
...
...
@@ -239,7 +262,7 @@
// Extract the tag from the MySQL Query
extract
(
$tags
);
// Add tag
$rssfeed
.
=
'<category>'
.
$tag
.
'</category>'
;
$rssfeed
.
=
'
<category>'
.
$tag
.
'</category>'
;
$rssfeed
.
=
"
\n
"
;
}
...
...
@@ -253,6 +276,7 @@
$rssfeed
.
=
"
\n
"
;
// End <rss>
$rssfeed
.
=
'</rss>'
;
$rssfeed
.
=
"
\n
"
;
// Print the string
echo
$rssfeed
;
...
...