topical media & game development
mashup-delicious-10-freshtags-index.php / php
<?php
//mysql database information
define('MYSQL_HOST','localhost');
define('MYSQL_DATABASE','freshtags');
define('MYSQL_USERNAME','delicious_sql');
define('MYSQL_PASSWORD','password');
//create the MySQL Database Connection
_GET['tag'] exits (and if not the script dies)
if (isset(feed_url = BASE_TAG_FEED_URL.rss = fetch_rss(rss->items as link_exists_check = "select count(*) from bookmarks where link LIKE '".mysql_real_escape_string(_GET['tag'])."'";
link_exists_check) or die(mysql_error());
//if no rows were returned then add the link to the database
if (!mysql_result(bookmark_insert_query ="insert into bookmarks (
tag,
link,
title,
description,
dc_date
) values (
'".mysql_real_escape_string(item['link'])."',
'".mysql_real_escape_string(item['description'])."',
'".mysql_real_escape_string(bookmark_insert_query) or die(mysql_error());
}
}
//select the last NUM_RSS_ITEMS added and output a new feed
_GET['tag'])."' order by id desc limit ".NUM_RSS_ITEMS."";
bookmarks_select_query) or die(mysql_error());
//setup the headers
header ("Content-type: text/xml"); // Output file as XML
echo ("<?xml version=\"1.0\" encoding=\"US-ASCII\"?>\n");
//standard RSS 2.0 bits including dc
?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>del.icio.us/tag/<?php echo _GET['tag']; ?></link>
<description>Filtered tag feed for the del.icio.us <?php echo this_bookmark = mysql_fetch_assoc(this_bookmark['id']); ?>@http://del.icio.us/tag/ echo this_bookmark['title']); ?></title>
<link><?php echo sanitize_for_xml(this_bookmark['description']); ?></description>
<dc:date><?php echo sanitize_for_xml(this_bookmark);
}
?>
</channel>
</rss>
<?php
} else {
//no tag provided as a query string
die('No tag defined!');
}
//make non xml-friendly characters safe for xml
function sanitize_for_xml(final = '';
//remove high bit characters
i = 0; string); string_chars[] = i];
}
foreach (char) {
if (ord(final .= final );
}
//close the database connection
mysql_close(
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.