aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2012-09-24 11:11:03 -0700
committerAdam Soltys <[email protected]>2012-09-24 11:11:03 -0700
commit6faa6d5e36e64372026e52a838334a3bb2353853 (patch)
treefe03b4c856fc3235de9889199fef19388e54beb0
parent5b5053420d59d5cb7b53e905c1e183f37f3d660c (diff)
downloadcoinos-server-6faa6d5e36e64372026e52a838334a3bb2353853.tar.gz
coinos-server-6faa6d5e36e64372026e52a838334a3bb2353853.zip
Basic transaction recording
-rw-r--r--index.html22
-rw-r--r--record_transaction.php14
-rw-r--r--ticker.json1
-rw-r--r--transactions.csv10
4 files changed, 45 insertions, 2 deletions
diff --git a/index.html b/index.html
index 724cc489..74f190ea 100644
--- a/index.html
+++ b/index.html
@@ -26,6 +26,7 @@
websocket.onmessage = function(e) {
var results = eval('(' + e.data + ')');
+ var from_address = '';
$.each(results.x.out, function(i, v) {
if (v.addr == address) {
@@ -34,6 +35,7 @@
});
$.each(results.x.inputs, function(i, v) {
+ from_address = v.prev_out.addr
if (v.prev_out.addr == address) {
input -= v.prev_out.value / 100000000;
}
@@ -43,10 +45,19 @@
if (total <= received) {
$('#status').css('color', 'green');
}
+
+ $.get('record_transaction.php',
+ {
+ address: from_address,
+ date: getFormattedDate(),
+ received: received,
+ exchange: exchange
+ }
+ );
}
- $.getJSON('ticker', function (data) {
- exchange = data.return.last.value;
+ $.getJSON('ticker.json', function (data) {
+ exchange = data.return.last_local.value;
$('#exchange').html(exchange);
updateTotal();
});
@@ -73,6 +84,13 @@
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
+
+ function getFormattedDate() {
+ var date = new Date();
+ var str = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
+
+ return str;
+ }
</script>
<style>
diff --git a/record_transaction.php b/record_transaction.php
new file mode 100644
index 00000000..c587a3e8
--- /dev/null
+++ b/record_transaction.php
@@ -0,0 +1,14 @@
+<?php
+
+$list = array (
+ array($_GET['address'], $_GET['date'], $_GET['received'], $_GET['exchange'])
+);
+
+$fp = fopen('transactions.csv', 'a');
+
+foreach ($list as $fields) {
+ fputcsv($fp, $fields);
+}
+
+fclose($fp);
+?>
diff --git a/ticker.json b/ticker.json
new file mode 100644
index 00000000..926e9b72
--- /dev/null
+++ b/ticker.json
@@ -0,0 +1 @@
+{"result":"success","return":{"high":{"value":"10.89000","value_int":"1089000","display":"CA$10.89000","display_short":"CA$10.89","currency":"CAD"},"low":{"value":"10.89000","value_int":"1089000","display":"CA$10.89000","display_short":"CA$10.89","currency":"CAD"},"avg":{"value":"10.89000","value_int":"1089000","display":"CA$10.89000","display_short":"CA$10.89","currency":"CAD"},"vwap":{"value":"10.89000","value_int":"1089000","display":"CA$10.89000","display_short":"CA$10.89","currency":"CAD"},"vol":{"value":"3.40000000","value_int":"340000000","display":"3.40000000\u00a0BTC","display_short":"3.40\u00a0BTC","currency":"BTC"},"last_local":{"value":"10.89000","value_int":"1089000","display":"CA$10.89000","display_short":"CA$10.89","currency":"CAD"},"last":{"value":"10.89000","value_int":"1089000","display":"CA$10.89000","display_short":"CA$10.89","currency":"CAD"},"last_orig":{"value":"11.10629","value_int":"1110629","display":"$11.10629","display_short":"$11.11","currency":"USD"},"last_all":{"value":"10.79535","value_int":"1079535","display":"CA$10.79535","display_short":"CA$10.80","currency":"CAD"},"buy":{"value":"10.64177","value_int":"1064177","display":"CA$10.64177","display_short":"CA$10.64","currency":"CAD"},"sell":{"value":"10.95000","value_int":"1095000","display":"CA$10.95000","display_short":"CA$10.95","currency":"CAD"}}} \ No newline at end of file
diff --git a/transactions.csv b/transactions.csv
new file mode 100644
index 00000000..4ec85bba
--- /dev/null
+++ b/transactions.csv
@@ -0,0 +1,10 @@
+12345,2012-09-09,5,10
+1AYCpRBw4JZkC66QMF6LjZmMVkV2F2r5rD,"2012-8-9 17:13:40",0.001,9.62462
+12345,2012-09-09,5,10
+12345,2012-09-09,5,10
+12345,2012-09-09,5,10
+12345,2012-09-09,5,10
+12345,2012-09-09,5,10
+12345,2012-09-09,5,10
+12345,2012-09-09,5,10
+12345,2012-09-09,5,10