'.tr('error_date_start_invalid').''; exit; } if (!empty($_GET['end_date'])){ if ($_GET['end_date'] !=0){ $end_date = $_GET['end_date']; if (!isDate($end_date, $format)){ echo '
'.tr('error_date_end_invalid').'
'; exit; }elseif ($end_date < $start_date) { echo '
'.tr('error_date_end_invalid').'
'; exit; } } } }else{ // Si pas de start_date, on prend le mois courant $start_date = new DateTime('first day of this month'); $end_date = new DateTime('last day of this month'); } $start_date->setTime(0,0,0); if (isset($end_date)){ $classcol = 'col-3'; if ($end_date < $today){ $days_left = 0; }else{ $dteDiff = $end_date->diff($today); $days_left = $dteDiff->format('%a'); } } // Vérification du format de la pubkey if (!empty($_GET['pubkey'])){ if (preg_match($format_pubkey, $_GET['pubkey'])){ $pubkey = $_GET['pubkey']; $contribution_url = 'https://' . $api_node . '/api/#/v1/payment/' . $pubkey . '?amount=10|20|50|100|1000&comment=don&redirect_url=https%3A%252F%252F' . $api_node . '&cancel_url=https%3A%252F%252F' . $api_node; $display_pubkey = (!empty($_GET['display_pubkey'])); $display_button = (!empty($_GET['display_button'])); $display_graph = (!empty($_GET['display_graph'])); // Génération du QRcode $display_qrcode = (!empty($_GET['display_qrcode'])); $qrcode_path = 'img/qrcodes/' . $pubkey . '.png'; if (($display_qrcode) && (!file_exists($qrcode_path))) { QRcode::png($pubkey, $qrcode_path); } } else { echo '
'.tr('error_pubkey_invalid').'
'; exit; } }else{ echo '
'.tr('error_pubkey_missing').'
'; exit; } // Vérification du format de la valeur cible à atteindre if (!empty($_GET['target'])){ $target = (int)$_GET['target']; if (!is_int($target)){ echo '
'.tr('error_target_not_int').'
'; exit; }elseif ($target<=0){ echo '
'.tr('error_target_negative').'
'; exit; } }else{ echo '
'.tr('error_target_missing').'
'; exit; } // Récupération des transactions entrantes entre la date de début et la date du jour $start_timestamp = $start_date->getTimestamp(); $today_timestamp = $today->getTimestamp(); $url_json = 'https://' . $node . '/tx/history/' . $pubkey . '/times/' . $start_timestamp . '/' . $today_timestamp; $json = @file_get_contents($url_json); if ($json === false){ echo '
'.tr('error_connect_node').'
'; exit; } $json = json_decode($json); $transactions = $json->history->received; $total = 0; $donneurs = []; $tmp_timestamp = $start_timestamp; $array_final = []; $map_delta = []; foreach ($transactions as $transaction){ $donneur = $transaction->issuers[0]; if ($donneur != $pubkey){ if(!in_array($donneur, $donneurs)){ array_push($donneurs, $donneur); } $outputs = $transaction->outputs; foreach ($outputs as $output){ if (strstr($output,$pubkey)){ $timestamp = $transaction->time; $output = explode(':', $output); $montant_transaction = $output[0]/100; if ($timestamp != $tmp_timestamp){ array_push($array_final, ['t'=>$tmp_timestamp*1000, 'y'=>(string) $total]); } $tday = 43200 + $timestamp - $timestamp%86400; if(isset($map_delta[$tday])) $map_delta[$tday] += intval($montant_transaction); else $map_delta[$tday] = intval($montant_transaction); $total += $montant_transaction; $tmp_timestamp = $timestamp; } } } } $donors = count($donneurs); if ($display_graph){ // On complète le tableau avec la derniere transaction et pour la date de visualisation du graph array_push($array_final, ['t'=>$tmp_timestamp*1000, 'y'=>(string) $total]); array_push($array_final, ['t'=>$today_timestamp*1000, 'y'=>(string) $total]); $array_line = [['t'=>$start_timestamp*1000, 'y'=>(string) $target],['t'=>$today_timestamp*1000, 'y'=>(string) $target]]; $array_delta = array(); foreach($map_delta as $k=> $v) { $array_delta[] = array('t'=>$k*1000, 'y'=>$v); } } // Vérification de l'unité $unit = (!empty($_GET['unit'])) ? ((!in_array($_GET['unit'], $units)) ? 'quantitative' : $_GET['unit']) : 'quantitative'; // Si l'unité est relative if ($unit == 'relative'){ // On récupère le dernier block qui contient le DU $url_json = 'https://' . $node . '/blockchain/with/ud'; $json = file_get_contents($url_json); $json = json_decode($json); $last_block_with_ud = end($json->result->blocks); // Puis on récupère le montant du DU pour mettre à jour les données $url_json = 'https://' . $node . '/blockchain/block/' . $last_block_with_ud; $json = file_get_contents($url_json); $json = json_decode($json); $ud = $json->dividend/100; $total = round($total/$ud); if ($display_graph){ for($i=0;$i <?php if (!empty($_GET['title'])){echo $_GET['title'];}else{echo tr('title_default');} ?>
' . $_GET['title'] . '';} ?> ' . tr('label_pubkey') . ' ' . $pubkey . '';} ?> ';} ?>
0%

%

Ğ1

$target, 'unit'=>(($unit=='relative') ? tr('ud').'Ğ1
' : 'Ğ1'))); ?>