|i', "\n",$string);
$string = preg_replace('/',' <',$string);
$string = strip_tags($string);
$string = preg_replace('/^ */','',$string);
$string = preg_replace('/ /',' ',$string);
return htmlspecialchars($string);
}
# Function to try to find a URL in the cache, given its ID.
function lookupUrl($anId) {
$value = null;
$result = mysql_query('select url from urlmap where url_id=' . $anId);
if ($row = mysql_fetch_assoc($result)) {
$value = $row["url"];
}
mysql_free_result($result);
mysql_query('update urlmap set url_last_used=null,url_use_count=url_use_count+1 where url_id=' . $anId);
return $value;
}
# Function to put a URL in the cache (or update the timestamp if it already
# exists).
function cacheUrl($aUrl) {
$value = null;
$result = mysql_query("select url_id from urlmap where url='" . $aUrl . "'");
if ($row = mysql_fetch_assoc($result)) {
$value = $row["url_id"];
}
mysql_free_result($result);
if ($value) {
# We found a result, we're done
return $value;
}
# We need to create a new entry
mysql_query("insert into urlmap(url) values('" . $aUrl . "')");
return mysql_insert_id();
}
header("Content-type: text/xml");
ini_set('display_errors', 0);
//ini_set('error_reporting', E_ALL);
require_once('magpierss/rss_fetch.inc');
# Find the URL and cache ID associated with it, either creating or using
# the cache entry depending on whether we were given the ID or URL.
$uid = $_GET['uid'];
if ($uid) {
$url = lookupUrl($uid);
} else {
$url = $_GET['url'];
$uid = cacheUrl($url);
}
# See if we were given an item to display
$item = $_GET['item'];
$maxTitleLength = 31;
if ( $url ) {
$rss = fetch_rss( $url );
if ($rss) {
if ($item) {
$body = $rss->items[$item - 1];
if ($body) {
?>
= makePhoneFriendly($rss->channel['title'], $maxTitleLength) ?>
Description of selected item
= makePhoneFriendly($body['title']) ?>
= makePhoneFriendly($body['description']) ?>
Item Not Found
Requested Item Missing
The item you requested from the RSS feed was not found. Perhaps the feed was updated between when you viewed the menu of items and when you made your selection.
You might want to try again.
= makePhoneFriendly($rss->channel['title'], $maxTitleLength) ?>
Choose item for description
items); $i++) {
?>
RSS Feed Problem
Error Retrieving RSS Feed
Error: = magpie_error() ?>
URL: = $url ?>
Please have your system administrator look into your service configuration and subscription.
Subscription Problem
Service Not Configured
In order to use the free Berbee RSS Feed Translator, your phone's service subscription must include a parameter "url" which specifies the URL of the RSS feed to be displayed on your phone.
Please have your system administrator look into your service configuration and subscription.