* This is the sort of extent you have to goto to use some sort of quote_c... class
http://ticker.chronolabs.org.au/?trade=DXD
It has an .htaccess and a few those ahh SQL issues, with that whole nature of a currency .. ticker -> I have made a few versions.
<?
/**
* $Id: index.php v 2.06 November 2008 Wishcraft $
* Class: Financial Quote Class
* Version: v1.09
* Release Date: 17 Oct 2008 *
* Author: Simon Roberts
* URL: http://www.chronolabs.org.au
* Licence: PSDL 1.4
*/
/*
######################################################################################################
## Data Structures - Only Require Table for RSS Ticker
######################################################################################################
## CREATE TABLE IF NOT EXISTS `currencies` (
## `currency_id` int(22) NOT NULL auto_increment,
## `default` tinyint(2) NOT NULL,
## `code` varchar(3) NOT NULL default '---',
## `to` varchar(3) NOT NULL default '---',
## `secure_uri` mediumtext NOT NULL,
## `title` varchar(128) NOT NULL,
## `rate` double(29,29) unsigned zerofill NOT NULL default '0.00000000000000000000000000000',
## `last_updated` int(11) default NULL,
## `recheck` int(11) NOT NULL default '0',
## `update_sha1` varchar(44) NOT NULL,
## `tstamp_sha1` varchar(44) NOT NULL,
## PRIMARY KEY (`currency_id`)
## );
######################################################################################################
*/
####3333333333333333333333333333333333333333
#### Trade Variables
#### ob_start("ob_gzhandler");
foreach ($_GET as $x => $k)
if(isset($_GET["$x"]))
${strtolower($x)} = (string)$k;
#############################################
class quote_rate
{
var $sessionid;
function quote_rate()
{
/* if (!session_id())
session_start();*/
//$this->sessionid = //session_id();
}
function rate($func, $from, $to)
{
return $this->$func($from, $to);
}
private function quote_oanda_currency($code, $trade) {
$uri = 'http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $code . '&format=CSV&dest=Get+Table&sel_list=' . $trade;
$page = file($uri);
$match = array();
preg_match('/(.+),(w{3}),([0-9.]+),([0-9.]+)/i', $page, $match);
if (count($match))
return array("type" => 'oanda', "match" => $match, "uri" => $uri);
}
private function quote_xe_currency($from, $to) {
$uri = "http://www.xe.net/ucc/convert.cgi?Amount=1&From=" . $from . '&To=' . $to;
$page = file($uri);
$match = array();
preg_match('/[0-9.]+s*' . $from . 's*=s*([0-9.]+)s*' . $to . '/', implode('', $page), $match);
if (count($match))
return array("type" => 'xe', "match" => $match, "uri" => $uri);
}
}
function create_clean_self($clean_self)
{
foreach ($clean_self as $element => $selfaddr)
{
$aed = (strlen($self)>0)?"&":"";
$self .= "$element=$selfaddr".$aed;
}
return $self;
}
function seed_ticker_once($clean_self)
{
global $clean_self, $xoopsDB;
error_reporting(0);
/*
if (!$xoopsUser->isAdmin())
return ;
if ((is_object($xoopsUser)&&!empty($xoopsUser))&&$xoopsUser->isAdmin());
{
if ($userhash <> sha1($xoopsUser->getVar('lastlogin').$xoopsUser->getVar('uname').$xoopsUser->getVar('pass').XOOPS_URL))
{
*/
$sql = "select count(*) as xzero " . $xoopsDB->prefix('currencies') . " where rate = 0 or rate < 0.000000000000000000078568743564543";
$debu.= $debug?"* ".__LINE__." : $sqln":'';
$xzero = $xoopsDB->fetchRow($xoopsDB->queryF($sql));
if ($xzero>2)
{
srand(microtime);
$sql = "select currency_id from " . $xoopsDB->prefix('currencies') . " where (rate = 0 or rate < 0.00000000000000000000000000000021432543653454) ORDER BY RAND()";
list($currency_id) = $xoopsDB->fetchRow($xoopsDB->queryF($sql));
$debu.= $debug?"* ".__LINE__." : $sqln":'';
$sql = "update " . $xoopsDB->prefix('currencies') . " set rate = '%s', last_updated = '%s', tstamp_sha1 = sha1('%s'), update_sha1 = '%s', source_uri = '%s', recheck = '%s' where currency_id = '%s'";
$debu.= $debug?"* ".__LINE__." : $sqln":'';
$ret = $xoopsDB->queryF(sprintf($sql, substr((string)(microtime/10001),mt_rand(3,8)), time()+((10*2)*2), time().microtime(), sha1($sql), time()+-20, $currency_id));
redirect_header(sprintf('http%s://%s/%s',$secure,$_SERVER['HTTP_HOST'],create_clean_self($clean_self)),3,"You have seeded the ticker, please resume until seeded correctly.<a href="".sprintf('http%s://%s?%s',$secure,$_SERVER['HTTP_HOST'],create_clean_self($clean_self))."'></a>Redirect back to ticker<br/>Please wait to redirect to you enter url!", true);
exit;
}
}
error_reporting(E_ALL);
define('CURRENCY_SERVER_PRIMARY', 'oanda');
define('CURRENCY_SERVER_BACKUP', 'xe');
define('SECONDARY_PRIMARY_CODE', 'AED');
include_once('../mainfile.php');
require_once(XOOPS_ROOT_PATH.'/class/module.textsanitizer.php');
global $xoopsDB, $clean_self, $xoopsUser;
#include_once(XOOPS_ROOT_PATH.'/include/checklogin.php');
$feed=array();
$clean_self = array();
$ii=1;
if (strlen($trade)!=3) {
$sql = "select currency_id, code, rate, title, last_updated, source_uri from " . $xoopsDB->prefix('currencies'). " where (not `default` = '0') or (`to` = '".SECONDARY_PRIMARY_CODE."')";
$debu.= $debug?"* ".__LINE__." : $sqln":'';
$ret = $xoopsDB->query($sql);
$default_cur=$xoopsDB->fetchArray($ret) ;
$feed[$ii]['code'] = $default_cur['code'];
$feed[$ii]['title'] = $default_cur['title'];
$feed[$ii]['rate'] = $default_cur['rate'];
$feed[$ii]['mode'] = 'trade';
$feed[$ii]['pubdate'] = $default_cur['last_updated'];
$feed[$ii]['uri'] = $default_cur['source_uri'];
$ii++;
} else {
$sql = "select currency_id, code, title, last_updated from " . $xoopsDB->prefix('currencies'). ' where `code` = "'.$trade.'" and `to` = "'.$trade.'"';
$debu.= $debug?"* ".__LINE__." : $sqln":'';
$ret = $xoopsDB->query($sql);
$default_cur=$xoopsDB->fetchArray($ret) ;
$feed[$ii]['code'] = strtoupper($trade);
if (strlen($default_cur['title']))
{
/*********************************
$rate = new quote_rate('quote_oanda_currency', $feed[1]['code'], $currency['code']);
$quote = $rate->rate('quote_oanda_currency', $feed[1]['code'], $currency['code']);
if (empty($quote['type'])) {
$rate = new quote_rate('quote_xe_currency', $feed[1]['code'], $currency['code']);
$quote = $rate->rate('quote_oanda_currency', $feed[1]['code'], $currency['code']);
}
if (!empty($quote['type']))
$title = $quote['match'][1];
*********/
} else {
$feed[$ii]['title'] = $default_cur['title'];
}
$feed[$ii]['title'] = $title;
$feed[$ii]['mode'] = 'trade';
$feed[$ii]['rate'] = '1.000000';
$feed[$ii]['pubdate'] = (0!=$item['last_updated'])?$item['last_updated']:time();
$feed[$ii]['uri'] = $item['source_uri'];
$ii++;
}
$clean_self['trade'] = (isset($feed[$ii]['code'])&&(strlen($feed[$ii]['code'])==3))?$feed[$ii]['code']:'';
if (isset($_GET['seed'])&&strlen($_GET['seed'])>0)
@seed_ticker_once($clean_self);
$sql = "select select count(a.*) as total, `b`.`code` from " . $xoopsDB->prefix('currencies'). ' a INNER JOIN ' . $xoopsDB->prefix('currencies'). ' b on a.to = b.to where `b`.`default` = 1';
$debu.= $debug?"* ".__LINE__." : $sqln":'';
list($defutotal, $default_code) = $xoopsDB->fetchRow($xoopsDB->query($sql));
$sql = "select distinct count(*) as total from ".$xoopsDB->prefix('currencies'). ' a INNER JOIN ' . $xoopsDB->prefix('currencies'). ' b on a.to = b.code where `a`.`to` = '. $feed[1]['code']."' and `a`.`code` = '". $feed[1]['code']."' having LENGTH(a.to) = 3 and LENGTH(b.code) = 3 and a.to <> '$default_code' and a.code <> '$default_code'";
$debu.= $debug?"* ".__LINE__." : $sqln":'';
// echo "* ".__LINE__." : $sqln";
list($codetotal) = $xoopsDB->fetchRow($xoopsDB->query($sql));
$sql = "select count(*) as curr_count from ". $xoopsDB->prefix('currencies'). ' b where not `b`.`to` = '. $feed[1]['curr_count']."'";
$debu.= $debug?"* ".__LINE__." : $sqln":'';
// echo "* ".__LINE__." : $sqln";
list($curr_count) = $xoopsDB->fetchRow($xoopsDB->query($sql));
if ($curr_count>=1)
{
if (strlen($feed[1]['title'])>3&&is_string($feed[1]['title']))
{
$sql = "INSERT INTO ".$xoopsDB->prefix('currencies')." (`code`, `title`, `rate`, `to`) VALUE ('".$feed[1]['code']."', '".$feed[1]['title']."', '1', '".$feed[1]['code']."')";
@$xoopsDB->queryF($sql);
$debu.= $debug?"* ".__LINE__." : $sqln":'';
$sql = "INSERT INTO ".$xoopsDB->prefix('currencies')." (`code`, `title`, `rate`, `to`) VALUE ('".$feed[1]['code']."', '".$feed[1]['title']."', '1', '".$default_code."')";
$debu.= $debug?"* ".__LINE__." : $sqln":'';
@$xoopsDB->queryF($sql);
if (strpos(XOOPS_URL,'s://')>0)
$secure = "s";
else
$secure = "";
redirect_header(sprintf('http%s://%s/%s',$secure,$_SERVER['HTTP_HOST'],create_clean_self($clean_self)),3,"Thank's you have imported a new currency;<p align="center">Update Total Currencies: $curr_count<br/>Update Currency Title: <em>".$feed[1]['title']."</em><br/>Currency Code: <a href='$uri'><em>".$feed[1]['title']."</em></a><br/></p>Please wait to redirect to the url you enter this ticker!", true, "<a href='$uri'>Goto the location of the import of currency data.</a>");
exit;
}
}
if (($codetotal < $defutotal-1)>1)
{
$sql = "INSERT INTO ".$xoopsDB->prefix('currencies')." (`code`, `title`, `rate`, `to`) select distinct (b.`code`, b.`title`, '1', '".$feed[1]['code']."') from " . $xoopsDB->prefix('currencies')." a INNER JOIN " . $xoopsDB->prefix('currencies'). ' b on a.code <> b.to where a.code = ''.$feed[1]['code'].'' OR b.code = ''.$feed[1]['code'].'' having `b`.`default` = 1 having LENGTH(a.to) = 3 and LENGTH(b.code) = 3 and a.to <> "'.$feed[1]['code'].'" and a.code <> "'.$feed[1]['code'].'" ORDER RAND()';
$debu.= $debug?"* ".__LINE__." : $sqln":'';
@$xoopsDB->queryF($sql);
redirect_header(sprintf('http%s://%s/%s',$secure,$_SERVER['HTTP_HOST'],create_clean_self($clean_self)),3,"The feed filter has been imported for a recently imported - unknown currencies.<br/>Currencies matrix build (Compare): .".($defutotal-1)-$codetotal."<br/>Currency Code: "."<a href="".sprintf('http%s://%s?%s',$secure,$_SERVER['HTTP_HOST'],create_clean_self($clean_self))."'></a>".$feed[1]['title']."</em></a><br/>Please wait to redirect to you enter url!", true);
exit;
}
$sql = sprintf("select count(*) as requote from " . $xoopsDB->prefix('currencies'). " where (not `default` = 1 or `to` = '%s') and `code` NOT LIKE '%s' and ((last_updated + %s) < '%s') or ((recheck + %s) < '%s'))",$feed[1]['code'],$feed[1]['code'],((60*60)*12),time(),(61*34),time());
$debu.= $debug?"* ".__LINE__." : $sqln":'';
list($requote) = $xoopsDB->fetchRow($xoopsDB->queryF($sql));
if ($requote>0)
{
$sql = sprintf("select code, title, rate, last_updated, source_uri from " . $xoopsDB->prefix('currencies'). " where (not last_updated = 0 and (not `default` = 1 or `to` = '%s')) and `code` NOT LIKE '%s' and (rate = 1 or ((last_updated + %s) < '%s') or ((recheck + %s) < '%s'))",$feed[1]['code'],$feed[1]['code'],((60*60)*12),time(),(61*34),time());
$debu.= $debug?"* ".__LINE__." : $sqln":'';
$ret = $xoopsDB->query($sql);
while ($item = $xoopsDB->fetchArray($ret))
{
$feed[$ii]['code'] = $item['code'];
$feed[$ii]['title'] = $item['title'];
$feed[$ii]['rate'] = $item['rate'];
$feed[$ii]['mode'] = 'no requote';
$feed[$ii]['pubdate'] = $item['last_updated'];
$feed[$ii]['uri'] = $item['source_uri'];
$ii++;
}
$sql = sprintf("select currency_id, code, title, rate from " . $xoopsDB->prefix('currencies'). " where (not last_updated = 0 and (not `default` = 1 or `to` = '%s')) and `code` NOT LIKE '%s' and ((last_updated + %s) < '%s') or ((recheck + %s) < '%s'))",$feed[1]['code'],$feed[1]['code'],((60*60)*12),time(),(61*34),time());
$debu.= $debug?"* ".__LINE__." : $sqln":'';
$retb = $xoopsDB->query($sql);
while ($currency = & $xoopsDB->fetchArray($retb)) {
$rate = new quote_rate('quote_oanda_currency', $feed[1]['code'], $currency['code']);
$quote = $rate->rate('quote_oanda_currency', $feed[1]['code'], $currency['code']);
if (empty($quote['type'])) {
$rate = new quote_rate('quote_xe_currency', $feed[1]['code'], $currency['code']);
$quote = $rate->rate('quote_oanda_currency', $feed[1]['code'], $currency['code']);
}
if (!empty($quote['type'])) {
switch ($quote['type'])
{
case "xe":
if (($quote['match'][1]!=1)&&($quote['match'][1]!=$currency[2]))
{
$sql = "update " . $xoopsDB->prefix('currencies') . " set rate = '%s', last_updated = '%s', tstamp_sha1 = sha1('%s'), update_sha1 = '%s', source_uri = '%s' where currency_id = '%s'";
$ret = $xoopsDB->queryF(sprintf($sql, $quote['match'][1], time(), time()+microtime(), sha1($sql), $currency['currency_id'], $quote['uri']));
$feed[$ii]['code'] = $currency[1];
$feed[$ii]['title'] = $currency[2];
$feed[$ii]['rate'] = ($quote['match'][1]==1)?$currency[3]:$quote['match'][1];
$feed[$ii]['mode'] = 'requote';
$feed[$ii]['pubdate'] = time();
$feed[$ii]['uri'] = $quote['uri'];
break;
} else {
$sql = "update " . $xoopsDB->prefix('currencies') . " set recheck = '%s', update_sha1 = '%s' where currency_id = '%s'";
$ret = $xoopsDB->queryF(sprintf($sql, time(), sha1($sql), $currency['currency_id']));
$sql = sprintf("select code, title, rate, last_updated, source_uri from " . $xoopsDB->prefix('currencies'). " where code = '%s'", $currency['code']);
$item = $xoopsDB->fetchArray($xoopsDB->query($sql));
if ($item['rate']!=0&&$item['rate']!=1)
{
$feed[$ii]['code'] = $item['code'];
$feed[$ii]['title'] = $item['title'];
$feed[$ii]['rate'] = $item['rate'];
$feed[$ii]['mode'] = 'no requote';
$feed[$ii]['pubdate'] = $item['last_updated'];
$feed[$ii]['uri'] = $item['source_uri'];
$ii++;
}
}
case "oanda":
if ($quote['match'][1]!=1)
{
if (($currency[3]!=$quote['match'][3])&&($quote['match'][1]!=$currency[2]))
$sql = "update " . $xoopsDB->prefix('currencies') . " set , $source_uri='%s', title = '%s', rate = '%s', last_updated = '%s', recheck = '%s',tstamp_sha1 = sha1('%s'), update_sha1 = '%s' where currency_id = '%s'";
else
$sql = "update " . $xoopsDB->prefix('currencies') . " set $source_uri='%s', rate = '%s', last_updated = '%s', recheck = '%s', tstamp_sha1 = sha1('%s'), update_sha1 = '%s' where currency_id = '%s'";
if ($currency[2]!=$quote['match'][1])
$ret = $xoopsDB->queryF(sprintf($sql, $quote['uri'], $quote['match'][1], $quote['match'][3], time(), time(), sha1($sql), $currency['currency_id']));
else
$ret = $xoopsDB->queryF(sprintf($sql, $quote['uri'], $quote['match'][3], time(), time(), sha1($sql), $currency['currency_id']));
$feed[$ii]['code'] = $quote['match'][2];
$feed[$ii]['title'] = $quote['match'][1];
$feed[$ii]['rate'] = ($quote['match'][1]==1)?$currency[3]:$quote['match'][1];
$feed[$ii]['pubdate'] = time();
$feed[$ii]['mode'] = 'requote';
$feed[$ii]['uri'] = $quote['uri'];
break;
} else {
$sql = "update " . $xoopsDB->prefix('currencies') . " set rate = '%s', last_updated = '%s', tstamp_sha1 = sha1('%s'), update_sha1 = '%s' where currency_id = '%s'";
$ret = $xoopsDB->queryF(sprintf($sql, $quote['match'][1], time(), time()+microtime(), sha1($sql), $currency['currency_id']));
$sql = sprintf("select code, title, rate, last_updated, source_uri from " . $xoopsDB->prefix('currencies'). " where code = '%s'", $currency['code']);
$item = $xoopsDB->fetchArray($xoopsDB->query($sql));
if ($item['rate']!=0&&$item['rate']!=1)
{
$feed[$ii]['code'] = $item['code'];
$feed[$ii]['title'] = $item['title'];
$feed[$ii]['rate'] = $item['rate'];
$feed[$ii]['mode'] = 'no requote';
$feed[$ii]['pubdate'] = $item['last_updated'];
$feed[$ii]['uri'] = $item['source_uri'];
$ii++;
}
}
}
$ii++;
}
}
}
else {
$sql = sprintf("select code, title, rate, last_updated, source_uri from " . $xoopsDB->prefix('currencies'). " where `to`='%s'", $feed[1]['code']);
$ret = $xoopsDB->query($sql);
while ($item = $xoopsDB->fetchArray($ret))
{
$feed[$ii]['code'] = $item['code'];
$feed[$ii]['title'] = $item['title'];
$feed[$ii]['rate'] = $item['rate'];
$feed[$ii]['pubdate'] = $item['last_updated'];
$feed[$ii]['mode'] = 'no requote';
$feed[$ii]['uri'] = $item['source_uri'];
$ii++;
}
}
$mts = &MyTextSanitizer::getInstance();
echo '<?xml version="1.0"?>'.chr(13).chr(10); ?>
<rss version="2.0">
<channel>
<description><? echo $mts->htmlSpecialChars($xoopsConfig['sitename']);?> : <? echo ($requote>0)?"$requote recheck Items : ":""; ?> : <? echo $mts->htmlSpecialChars($xoopsConfig['slogon']); ?></description>
<lastBuildDate><? echo date("D, Y-m-d H:i:s", time());?> UTC</lastBuildDate>
<docs>http://backend.userland.com/rss/</docs>
<generator><? echo $mts->htmlSpecialChars($xoopsConfig['sitename']);?></generator>
<managingEditor><? echo $mts->htmlSpecialChars($xoopsConfig['adminemail']);?></managingEditor>
<webMaster><? echo $mts->htmlSpecialChars($xoopsConfig['adminemail']);?></webMaster>
<language>en</language>
<image>
<title><? echo $mts->htmlSpecialChars($xoopsConfig['sitename']);?></title>
<url><? echo XOOPS_URL;?>/images/Spotlight.png</url>
<link><? echo XOOPS_URL;?></link>
</image>
<title><? echo $xoopsConfig['sitename'];?> : Currencies Trade</title>
<link><? echo $mts->htmlSpecialChars(sprintf('http%s://%s/%s',$secure,$_SERVER['HTTP_HOST'],create_clean_self($clean_self))); ?></link>
<?
foreach ($feed as $item)
$adv += $item['rate'];
$cout = array();
foreach ($feed as $item)
if (!in_array($item['code'],$cout)&&($feed[1]['code']!=$item['code']&&($item['rate']!=1&&$item['rate']!=0)))
{
$cout[] = $item['code'];
?>
<title>Currency :<?php echo $mts->htmlSpecialChars($item['title'] .' ('.$item['code'] .') - '.round($item['rate'],6).'' ); ?></title>
<description>Currency Exchange Rate : <?php echo $mts->htmlSpecialChars($item['title'] .' ('.$item['code'] .') - '.round($item['rate'],6).'' ); ?></description>
<? if (($adv/sizeof($feed))>$item['rate']) ?>
<category>lower</category>
<? if (($adv/sizeof($feed))<$item['rate']) ?>
<category>higher</category>
<cindex><? echo $mts->htmlSpecialChars((float)($feed[1]['rate'] * ($item['rate']/($adv/sizeof($feed))))); ?></cindex>
<mode><? echo $mts->htmlSpecialChars($item['mode']); ?></mode>
<name><? echo $mts->htmlSpecialChars($item['title']); ?></name>
<code><? echo $mts->htmlSpecialChars($item['code']); ?></code>
<rate><? echo $mts->htmlSpecialChars($item['rate']); ?></rate>
<trade><? echo$mts->htmlSpecialChars( $feed[1]['code']);?></trade>
<return><? echo $mts->htmlSpecialChars($item['code']);?></return>
<link><? echo $mts->htmlSpecialChars($item['uri']); ?></link>
<pubDate><? echo date("D, Y-m-d H:i:s", $item['pubdate']);?> UTC</pubDate>
</item>
<?php
}
if ($debu!=""&&($debug<>false))
{?>
<title>Debug : <?php echo md5($debu); ?></title>
<description><?php echo $mts->htmlSpecialChars($debu); ?></description>
<category>debug</category>
<cindex>0.0</cindex>
<mode>debug</mode>
<name>debug</name>
<code>NON</code>
<rate>0.0</rate>
<trade>0.0</trade>
<return>0.0</return>
<link><? echo XOOPS_URL; ?></link>
<pubDate><? echo date("D, Y-m-d H:i:s", time);?> UTC</pubDate>
</item>
<?php
} ?>
</channel>
</rss>
" it is one of those you needed one... " - You may have to refactorise into XOOPS classes for permissions with the grouping system...

Well like most tickers this one is self learning, no more I give you my CSV preset for your database, let it learn and search for real currencies you work'ng..
Here it he process
{- page hit cycle
1) * New Currency http://ticker.chronolabs.org.au/?trade=FOO
- Check for existence
- If none and confrm real currency make primary matrix keys
2) * Another hit http://ticker.chronolabs.org.au/?trade=GOO
- Propogates Matrix and refreshed screen
3) * Currency Appears
{- PSDL 1.1 - Currency Saftey Mechansism
1) * Internal Zero Seeder
- Unsigned rate
- Periodic Reseed on financial crisis day
2) * Light Weight XML (RSS 2.0 - Simple)
3) * Self Research and Propogation
{- PSDL 1.2.1 - Subdomains
1) * As per usual subdomain abstraction for ticker component are in reverse order.
- http://ticker.chronolabs.org.au/?trade=FXO (Master domain)
- http://currency.ticker.chronolabs.org.au/?trade=FXO (Sub Domain of Service)

www.ohloh.net/accounts/226400
Follow, Like & Read:-
* www.twitter.com/espacey
* www.chronolabs.com.au/ceo/
* www.chronolabs.coop/?gmt=10















