It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
$data = curl_grab_page('https://mtgox.com/code/data/ticker.php');
$data = str_replace('{"ticker":','',$data);
$data = str_replace('}}','}',$data);
$mtgox = json_decode($data,true);
var_dump($mtgox); //This is your mtgox data, use this to perform some math and update the currency table
function
curl_grab_page($url,$ref_url,$data,$login,$proxy,$proxystatus){
if($login == 'true') {
$fp = fopen("cookie.txt", "w");
fclose($fp);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_TIMEOUT, 40);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
if ($proxystatus == 'true') {
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $ref_url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
ob_start();
$output = curl_exec ($ch);
ob_end_clean();
curl_close ($ch);
unset($ch);
return $output;// execute the curl command
}
#!/usr/bin/php
/**
* Automatic Currency Update v4.0
* Originally by Richard Fink (masterblaster) based on Zen Cart manual currency update
* updated by Kuroi to include Zen Cart's currency uplift ratio
* further updated by Kuroi to use European Central Bank reference rates (adapted from ECB-supplied code)
*
* Rework for PHP 5.3 compatibility (ereg and mysql_db_query functions deprecated in PHP 5.3.0)
* switched to using SimpleXML and mysqli instead.
* JeRo www.jero.co.nz 18/06/2010
*
* license: GNU Public License V2.0
*
**/
# Set this to the physical path of your installation.
# Make sure to include the trailing "/"
define('PATH_TO_STORE_ROOT','');
// Get Zen Cart configuration data
require_once(PATH_TO_STORE_ROOT . 'includes/configure.php');
require_once(PATH_TO_STORE_ROOT . 'includes/database_tables.php');
if (! $mysqli=new mysqli(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE))
die("Can't connect to DB");
# Get default currency.
$row=$mysqli->query("select configuration_value from " . TABLE_CONFIGURATION .
" WHERE configuration_key='DEFAULT_CURRENCY' LIMIT 1 ")->fetch_row();
define('DEFAULT_CURRENCY', $row[0]);
#Get currency conversion ratio.
$row=$mysqli->query("select configuration_value from " . TABLE_CONFIGURATION .
" WHERE configuration_key='CURRENCY_UPLIFT_RATIO' LIMIT 1 ")->fetch_row();
define('CURRENCY_UPLIFT_RATIO', $row[0]);
# Create new SimpleXML element from the Euro zone file
# If your PHP configuration does not have allow_url_fopen, you may need to
# write a script to pick it up using wget:
# wget -O eurofxref-daily.xml www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml
# and then uncomment/comment these next two lines:
#$xml = new SimpleXMLElement(file_get_contents("eurofxref-daily.xml"));
$xml= new SimpleXMLElement(file_get_contents("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"));
# extract your preferred currency's exchange rate.
$nzd = $xml->xpath("//*[@currency='".DEFAULT_CURRENCY."']");
$base = (float)$nzd[0]['rate'];
# If our default currency is the Euro, it won't be in the XML,
# so set the base exchange rate to 1
if (DEFAULT_CURRENCY == 'EUR')
$base=(float)1;
# Get array of currency data from the XML file.
$currencies=$xml->xpath("//*[@currency]");
# Use a prepared query for slightly faster execution.
# Note this is an update, not and insert or replace.
# This statement assumes that your currency codes are the same
# as the international standard ones.
$stmt=$mysqli->prepare("update ".TABLE_CURRENCIES. " set value=?,last_updated=now() where code=?");
# Iterate over array, pulling out currency code and rate.
# Convert into your preferred currency.
# Pump it into the database.
foreach ($currencies as $curr) {
$cc = $curr[0]['currency'];
$rr = (float)$curr[0]['rate'] * CURRENCY_UPLIFT_RATIO;
$new = $rr/$base;
# But don't uplift your default currency!
if ( $cc != DEFAULT_CURRENCY ) {
$stmt->bind_param("ds",$new,$cc);
$stmt->execute();
}
}
# Feed is based on the Euro, which is not included in the feed,
# therefore we need to update it manually,
# unless of course our preferred currency is the Euro
$cc='EUR';
$rr=1/$base*CURRENCY_UPLIFT_RATIO;
if (DEFAULT_CURRENCY != $cc) {
$stmt->bind_param("ds",$rr,$cc);
$stmt->execute();
}
$mysqli->close();
?>