use updated coingecko.php
This commit is contained in:
parent
d162e90c7e
commit
75a0632af7
4 changed files with 131 additions and 60 deletions
1
coingecko-original.json
Normal file
1
coingecko-original.json
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,57 @@
|
||||||
<?php
|
<?php
|
||||||
|
$new_array = array();
|
||||||
|
$array = array("EUR",
|
||||||
|
"BTC",
|
||||||
|
"USD",
|
||||||
|
"GBP",
|
||||||
|
"CHF",
|
||||||
|
"RUB",
|
||||||
|
"CNY",
|
||||||
|
"JPY",
|
||||||
|
"IDR",
|
||||||
|
"KRW",
|
||||||
|
"TRY",
|
||||||
|
"AUD",
|
||||||
|
"BMD",
|
||||||
|
"CAD",
|
||||||
|
"HKD",
|
||||||
|
"NZD",
|
||||||
|
"SGD",
|
||||||
|
"TWD",
|
||||||
|
"ILS",
|
||||||
|
"PLN",
|
||||||
|
"ZAR",
|
||||||
|
"CZK",
|
||||||
|
"DKK",
|
||||||
|
"NOK",
|
||||||
|
"SEK",
|
||||||
|
"ARS",
|
||||||
|
"CLP",
|
||||||
|
"PHP",
|
||||||
|
"MXN",
|
||||||
|
"BHD",
|
||||||
|
"KWD",
|
||||||
|
"BRL",
|
||||||
|
"MYR",
|
||||||
|
"VEF",
|
||||||
|
"UAH",
|
||||||
|
"VND",
|
||||||
|
"BDT",
|
||||||
|
"HUF",
|
||||||
|
"MMK",
|
||||||
|
"NGN",
|
||||||
|
"THB",
|
||||||
|
"AED",
|
||||||
|
"SAR",
|
||||||
|
"PKR",
|
||||||
|
"LKR",
|
||||||
|
"INR",
|
||||||
|
"BTC",
|
||||||
|
"LTC",
|
||||||
|
"ETH",
|
||||||
|
"XAG",
|
||||||
|
"XAU");
|
||||||
|
|
||||||
//echo "<h1>coingecko.com</h1>";
|
//echo "<h1>coingecko.com</h1>";
|
||||||
|
|
||||||
// Die Standard-Zeitzone, die verwendet werden soll, setzen.
|
// Die Standard-Zeitzone, die verwendet werden soll, setzen.
|
||||||
|
@ -10,9 +63,9 @@ $xmrdatas = json_decode(file_get_contents("coingecko.json"), true);
|
||||||
// Liefert den aktuellen Unix-Zeitstempel
|
// Liefert den aktuellen Unix-Zeitstempel
|
||||||
$zeit = time();
|
$zeit = time();
|
||||||
|
|
||||||
// Sind 5 Sekunden vergangen?
|
// Sind ~30 Minuten vergangen?
|
||||||
if(($zeit - $xmrdatas['time']) >= 5){
|
if(($zeit - $xmrdatas['time']) >= 5){
|
||||||
//echo "Gespeicherte Zeit: ".$xmrdatas['time']."<br/>Aktuelle Zeit: ".$zeit;
|
//echo "Gespeicherte Zeit: ".$xmrdatas['time']."<br/>Aktuelle Zeit: ".$zeit;
|
||||||
|
|
||||||
// Initialize CURL
|
// Initialize CURL
|
||||||
$ch = curl_init('https://api.coingecko.com/api/v3/simple/price?ids=monero&vs_currencies=btc%2Ceth%2Cltc%2Cbch%2Cbnb%2Ceos%2Cxrp%2Cxlm%2Clink%2Cdot%2Cyfi%2Cusd%2Caed%2Cars%2Caud%2Cbdt%2Cbhd%2Cbmd%2Cbrl%2Ccad%2Cchf%2Cclp%2Ccny%2Cczk%2Cdkk%2Ceur%2Cgbp%2Chkd%2Chuf%2Cidr%2Cils%2Cinr%2Cjpy%2Ckrw%2Ckwd%2Clkr%2Cmmk%2Cmxn%2Cmyr%2Cngn%2Cnok%2Cnzd%2Cphp%2Cpkr%2Cpln%2Crub%2Csar%2Csek%2Csgd%2Cthb%2Ctry%2Ctwd%2Cuah%2Cvef%2Cvnd%2Czar%2Cxdr%2Cxag%2Cxau%2Cbits%2Csats&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true&include_last_updated_at=true');
|
$ch = curl_init('https://api.coingecko.com/api/v3/simple/price?ids=monero&vs_currencies=btc%2Ceth%2Cltc%2Cbch%2Cbnb%2Ceos%2Cxrp%2Cxlm%2Clink%2Cdot%2Cyfi%2Cusd%2Caed%2Cars%2Caud%2Cbdt%2Cbhd%2Cbmd%2Cbrl%2Ccad%2Cchf%2Cclp%2Ccny%2Cczk%2Cdkk%2Ceur%2Cgbp%2Chkd%2Chuf%2Cidr%2Cils%2Cinr%2Cjpy%2Ckrw%2Ckwd%2Clkr%2Cmmk%2Cmxn%2Cmyr%2Cngn%2Cnok%2Cnzd%2Cphp%2Cpkr%2Cpln%2Crub%2Csar%2Csek%2Csgd%2Cthb%2Ctry%2Ctwd%2Cuah%2Cvef%2Cvnd%2Czar%2Cxdr%2Cxag%2Cxau%2Cbits%2Csats&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true&include_last_updated_at=true');
|
||||||
|
@ -22,19 +75,36 @@ if(($zeit - $xmrdatas['time']) >= 5){
|
||||||
$json = curl_exec($ch);
|
$json = curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
// Sortiert/Formatiert die Ausgabe
|
// Sortiert/Formatiert die Ausgabe
|
||||||
$sort_array = json_decode($json, true);
|
$sort_array = json_decode($json, true);
|
||||||
$new_sort_array = $sort_array['monero'];
|
$new_sort_array = $sort_array['monero'];
|
||||||
|
|
||||||
// Zeit wird ergänzt
|
// Zeit wird ergänzt
|
||||||
|
$new_array['time'] = $zeit;
|
||||||
$new_sort_array['time'] = $zeit;
|
$new_sort_array['time'] = $zeit;
|
||||||
|
|
||||||
|
foreach ($array as $fiatValue) {
|
||||||
|
$fiatValue = strtolower($fiatValue);
|
||||||
|
if (array_key_exists($fiatValue, $sort_array['monero'])) {
|
||||||
|
$new_array[$fiatValue]['lastValue'] = $sort_array['monero'][$fiatValue];
|
||||||
|
$new_array[$fiatValue]['lastDate'] = $zeit;
|
||||||
|
}else{
|
||||||
|
$new_array[$fiatValue]['lastValue'] = $xmrdatas[$fiatValue]['lastValue'];
|
||||||
|
$new_array[$fiatValue]['lastDate'] = $xmrdatas[$fiatValue]['lastDate'];
|
||||||
|
}
|
||||||
|
//print_r($new_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Werte in die .json gespeichert
|
// Werte in die .json gespeichert
|
||||||
file_put_contents("coingecko.json", json_encode($new_sort_array));
|
file_put_contents("coingecko.json", json_encode($new_array));
|
||||||
|
file_put_contents("coingecko-original.json", json_encode($new_sort_array));
|
||||||
|
|
||||||
// echo "<br/>Sync.<hr/>";
|
// echo "<br/>Sync.<hr/>";
|
||||||
|
|
||||||
}//else{
|
}//else{
|
||||||
//echo "Keine Daten, noch zu früh!<br/><br/>";
|
//echo "Keine Daten, noch zu früh!<br/><br/>";
|
||||||
//echo "Gespeicherte Zeit: ".$xmrdatas['time']."<br/>Aktuelle Zeit: ".$zeit."<br/><br/>Differenz: ".$zeit - $xmrdatas['time']."<br/><hr/>";
|
//echo "Gespeicherte Zeit: ".$xmrdatas['time']."<br/>Aktuelle Zeit: ".$zeit."<br/><br/>Differenz: ".$zeit - $xmrdatas['time']."<br/><hr/>";
|
||||||
//}
|
//}
|
||||||
?>
|
?>
|
||||||
|
|
100
index.php
100
index.php
|
@ -66,56 +66,56 @@ $time_cg = date("H:i:s", $api_cg->time);
|
||||||
$time = $time_cg;
|
$time = $time_cg;
|
||||||
|
|
||||||
// Holt die einzelnen Werte für die Berechnung
|
// Holt die einzelnen Werte für die Berechnung
|
||||||
$BTC = $api_cg->btc;
|
$BTC = $api_cg->btc->lastValue;
|
||||||
$EUR = $api_cg->eur;
|
$EUR = $api_cg->eur->lastValue;
|
||||||
$USD = $api_cg->usd;
|
$USD = $api_cg->usd->lastValue;
|
||||||
$CHF = $api_cg->chf;
|
$CHF = $api_cg->chf->lastValue;
|
||||||
$LTC = $api_cg->ltc;
|
$LTC = $api_cg->ltc->lastValue;
|
||||||
$CAD = $api_cg->cad;
|
$CAD = $api_cg->cad->lastValue;
|
||||||
$AUD = $api_cg->aud;
|
$AUD = $api_cg->aud->lastValue;
|
||||||
$HKD = $api_cg->hkd;
|
$HKD = $api_cg->hkd->lastValue;
|
||||||
$SGD = $api_cg->sgd;
|
$SGD = $api_cg->sgd->lastValue;
|
||||||
$GBP = $api_cg->gbp;
|
$GBP = $api_cg->gbp->lastValue;
|
||||||
$RUB = $api_cg->rub;
|
$RUB = $api_cg->rub->lastValue;
|
||||||
$ZAR = $api_cg->zar;
|
$ZAR = $api_cg->zar->lastValue;
|
||||||
$TRY = $api_cg->try;
|
$TRY = $api_cg->try->lastValue;
|
||||||
$JPY = $api_cg->jpy;
|
$JPY = $api_cg->jpy->lastValue;
|
||||||
$PLN = $api_cg->pln;
|
$PLN = $api_cg->pln->lastValue;
|
||||||
$INR = $api_cg->inr;
|
$INR = $api_cg->inr->lastValue;
|
||||||
$AED = $api_cg->aed;
|
$AED = $api_cg->aed->lastValue;
|
||||||
$ETH = $api_cg->eth;
|
$ETH = $api_cg->eth->lastValue;
|
||||||
$UAH = $api_cg->uah;
|
$UAH = $api_cg->uah->lastValue;
|
||||||
$KRW = $api_cg->krw;
|
$KRW = $api_cg->krw->lastValue;
|
||||||
$BRL = $api_cg->brl;
|
$BRL = $api_cg->brl->lastValue;
|
||||||
$MYR = $api_cg->myr;
|
$MYR = $api_cg->myr->lastValue;
|
||||||
$CNY = $api_cg->cny;
|
$CNY = $api_cg->cny->lastValue;
|
||||||
$XAU = $api_cg->xau;
|
$XAU = $api_cg->xau->lastValue;
|
||||||
$XAG = $api_cg->xag;
|
$XAG = $api_cg->xag->lastValue;
|
||||||
$VND = $api_cg->vnd;
|
$VND = $api_cg->vnd->lastValue;
|
||||||
$VEF = $api_cg->vef;
|
$VEF = $api_cg->vef->lastValue;
|
||||||
$THB = $api_cg->thb;
|
$THB = $api_cg->thb->lastValue;
|
||||||
$SAR = $api_cg->sar;
|
$SAR = $api_cg->sar->lastValue;
|
||||||
$SEK = $api_cg->sek;
|
$SEK = $api_cg->sek->lastValue;
|
||||||
$PKR = $api_cg->pkr;
|
$PKR = $api_cg->pkr->lastValue;
|
||||||
$NOK = $api_cg->nok;
|
$NOK = $api_cg->nok->lastValue;
|
||||||
$LKR = $api_cg->lkr;
|
$LKR = $api_cg->lkr->lastValue;
|
||||||
$MMK = $api_cg->mmk;
|
$MMK = $api_cg->mmk->lastValue;
|
||||||
$HUF = $api_cg->huf;
|
$HUF = $api_cg->huf->lastValue;
|
||||||
$ILS = $api_cg->ils;
|
$ILS = $api_cg->ils->lastValue;
|
||||||
$KWD = $api_cg->kwd;
|
$KWD = $api_cg->kwd->lastValue;
|
||||||
$NGN = $api_cg->ngn;
|
$NGN = $api_cg->ngn->lastValue;
|
||||||
$NZD = $api_cg->nzd;
|
$NZD = $api_cg->nzd->lastValue;
|
||||||
$PHP = $api_cg->php;
|
$PHP = $api_cg->php->lastValue;
|
||||||
$IDR = $api_cg->idr;
|
$IDR = $api_cg->idr->lastValue;
|
||||||
$TWD = $api_cg->twd;
|
$TWD = $api_cg->twd->lastValue;
|
||||||
$ARS = $api_cg->ars;
|
$ARS = $api_cg->ars->lastValue;
|
||||||
$BDT = $api_cg->bdt;
|
$BDT = $api_cg->bdt->lastValue;
|
||||||
$BHD = $api_cg->bhd;
|
$BHD = $api_cg->bhd->lastValue;
|
||||||
$BMD = $api_cg->bmd;
|
$BMD = $api_cg->bmd->lastValue;
|
||||||
$CLP = $api_cg->clp;
|
$CLP = $api_cg->clp->lastValue;
|
||||||
$CZK = $api_cg->czk;
|
$CZK = $api_cg->czk->lastValue;
|
||||||
$DKK = $api_cg->dkk;
|
$DKK = $api_cg->dkk->lastValue;
|
||||||
$MXN = $api_cg->mxn;
|
$MXN = $api_cg->mxn->lastValue;
|
||||||
|
|
||||||
// Lädt die Sprachdatei, nach der Sprache die im Browser eingestellt wurde
|
// Lädt die Sprachdatei, nach der Sprache die im Browser eingestellt wurde
|
||||||
if(array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)){
|
if(array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)){
|
||||||
|
|
Loading…
Reference in a new issue