Commit 86bb16f8 authored by Chancellier Pierre-Jean's avatar Chancellier Pierre-Jean
Browse files

Correction + remplacement des double quotes par des simples

parent 9595bef8
......@@ -5,28 +5,28 @@
}
require('lib/locales.php');
include('lib/phpqrcode/qrlib.php');
$api_node = "g1.duniter.fr";
$format_pubkey = "#^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44}$#";
$units = ["quantitative","relative"];
$api_node = 'g1.duniter.fr';
$format_pubkey = '#^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44}$#';
$units = ['quantitative','relative'];
$today = new DateTime();
$format = "d/m/Y";
$format = 'd/m/Y';
function isDate(&$date, $format){
$champsDate = date_parse_from_format($format, $date);
$date = DateTime::createFromFormat($format, $date);
return checkdate($champsDate["month"], $champsDate["day"], $champsDate["year"]);
return checkdate($champsDate['month'], $champsDate['day'], $champsDate['year']);
}
// Vérification du node et des couleurs
$node = (!empty($_GET["node"])) ? $_GET["node"] : "g1.duniter.org";
$font_color = (!empty($_GET["font_color"])) ? "#" . $_GET["font_color"] : "#212529";
$background_color = (!empty($_GET["background_color"])) ? "#" . $_GET["background_color"] : "#FFF";
$border_color = (!empty($_GET["border_color"])) ? "#" . $_GET["border_color"] : "#343a40";
$progress_color = (!empty($_GET["progress_color"])) ? "#" . $_GET["progress_color"] : "#ffc107";
$node = (!empty($_GET['node'])) ? $_GET['node'] : 'g1.duniter.org';
$font_color = (!empty($_GET['font_color'])) ? "#" . $_GET['font_color'] : '#212529';
$background_color = (!empty($_GET["background_color"])) ? '#' . $_GET['background_color'] : '#FFF';
$border_color = (!empty($_GET['border_color'])) ? '#' . $_GET['border_color'] : '#343a40';
$progress_color = (!empty($_GET['progress_color'])) ? '#' . $_GET['progress_color'] : '#ffc107';
// Vérification des dates et calcul du nombre de jours entre la date du jour et la date de fin
if (!empty($_GET["start_date"])){
$start_date = $_GET["start_date"];
$classcol = "col-4";
if (!empty($_GET['start_date'])){
$start_date = $_GET['start_date'];
$classcol = 'col-4';
if (!isDate($start_date, $format)){
echo '<div>'.tr('error_date_start_invalid').'</div>';
exit;
......@@ -37,10 +37,10 @@
exit;
}
if (!empty($_GET["end_date"])){
if ($_GET["end_date"] !=0){
$end_date = $_GET["end_date"];
$classcol = "col-3";
if (!empty($_GET['end_date'])){
if ($_GET['end_date'] !=0){
$end_date = $_GET['end_date'];
$classcol = 'col-3';
if (!isDate($end_date, $format)){
echo '<div>'.tr('error_date_end_invalid').'</div>';
exit;
......@@ -57,15 +57,15 @@
}
// Vérification du format de la pubkey
if (!empty($_GET["pubkey"])){
if (preg_match($format_pubkey, $_GET["pubkey"])){
$pubkey = $_GET["pubkey"];
$display_pubkey = (!empty($_GET["display_pubkey"]));
$display_button = (!empty($_GET["display_button"]));
$display_graph = (!empty($_GET["display_graph"]));
if (!empty($_GET['pubkey'])){
if (preg_match($format_pubkey, $_GET['pubkey'])){
$pubkey = $_GET['pubkey'];
$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 = "qrcodes/" . $pubkey . ".png";
$display_qrcode = (!empty($_GET['display_qrcode']));
$qrcode_path = 'qrcodes/' . $pubkey . '.png';
if (($display_qrcode) && (!file_exists($qrcode_path))) {
QRcode::png($pubkey, $qrcode_path);
}
......@@ -80,8 +80,8 @@
}
// Vérification du format de la valeur cible à atteindre
if (!empty($_GET["target"])){
$target = (int)$_GET["target"];
if (!empty($_GET['target'])){
$target = (int)$_GET['target'];
if (!is_int($target)){
echo '<div>'.tr('error_target_not_int').'</div>';
exit;
......@@ -95,7 +95,7 @@
}
// Récupération des transactions entrantes entre la date de début et la date du jour
$url_json = "https://" . $node . "/tx/history/" . $pubkey . "/times/" . $start_date->getTimestamp() . "/" . $today->getTimestamp();
$url_json = 'https://' . $node . '/tx/history/' . $pubkey . '/times/' . $start_date->getTimestamp() . '/' . $today->getTimestamp();
$json = file_get_contents($url_json);
$json = json_decode($json);
$transactions = $json->history->received;
......@@ -120,7 +120,7 @@
array_push($array_montants, $total);
$current_date = $date_transaction;
}
$output = explode(":", $output);
$output = explode(':', $output);
$montant = $output[0]/100;
$total += $montant;
}
......@@ -131,20 +131,20 @@
$donors = count($donneurs);
// Vérification de l'unité
$unit = (!empty($_GET["unit"]))
? ((!in_array($_GET["unit"], $units)) ? "quantitative" : $_GET["unit"])
: "quantitative";
$unit = (!empty($_GET['unit']))
? ((!in_array($_GET['unit'], $units)) ? 'quantitative' : $_GET['unit'])
: 'quantitative';
// Si l'unité est relative
if ($unit == "relative"){
if ($unit == 'relative'){
// On récupère le dernier block qui contient le DU
$url_json = "https://" . $node . "/blockchain/with/ud";
$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
$url_json = "https://" . $node . "/blockchain/block/" . $last_block_with_ud;
$url_json = 'https://' . $node . '/blockchain/block/' . $last_block_with_ud;
$json = file_get_contents($url_json);
$json = json_decode($json);
$ud = $json->dividend/100;
......@@ -152,13 +152,13 @@
}
$percentage = round($total/$target*100);
$contribution_url = "https://" . $api_node . "/api/#/v1/payment/" . $pubkey . "?amount=10|20|50|100|1000&amp;comment=don&amp;redirect_url=https%3A%252F%252F" . $api_node . "&amp;cancel_url=https%3A%252F%252F" . $api_node;
$contribution_url = 'https://' . $api_node . '/api/#/v1/payment/' . $pubkey . '?amount=10|20|50|100|1000&amp;comment=don&amp;redirect_url=https%3A%252F%252F' . $api_node . '&amp;cancel_url=https%3A%252F%252F' . $api_node;
?>
<!DOCTYPE html>
<html lang="<?php echo $lang; ?>">
<head>
<meta charset="utf-8">
<title><?php if (!empty($_GET["title"])){echo $_GET["title"];}else{echo tr('title_default');} ?></title>
<title><?php if (!empty($_GET['title'])){echo $_GET['title'];}else{echo tr('title_default');} ?></title>
<link rel="stylesheet" href="style.css">
</head>
<body style="color:<?php echo $font_color; ?>;background-color:<?php echo $background_color; ?>;">
......@@ -166,8 +166,8 @@
<div class="container">
<div class="row">
<div class="col">
<?php if (!empty($_GET["title"])){echo "<h1>" . $_GET["title"] . "</h1>";} ?>
<?php if ($display_pubkey){echo '<h2 class="pubkey">' . $tr['label_pubkey'] . ' ' . $pubkey . '</h2>';} ?>
<?php if (!empty($_GET['title'])){echo '<h1>' . $_GET['title'] . '</h1>';} ?>
<?php if ($display_pubkey){echo '<h2 class="pubkey">' . tr('label_pubkey') . ' ' . $pubkey . '</h2>';} ?>
<?php if ($display_qrcode){echo '<img src="' . $qrcode_path . '" alt="'.tr('label_qrcode').'">';} ?>
<div id="progressbar" class="progress border rounded-0" style="border-color:<?php echo $border_color; ?> !important;">
<div class="progress-bar progress-bar-animated" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%;background:<?php echo $progress_color; ?> !important;"><span class="sr-only">0%</span></div>
......@@ -187,7 +187,7 @@
</div>
<div class="column <?php echo $classcol; ?>">
<p><i class="far fa-money-bill-alt" aria-hidden="true"></i></p>
<p> <span class="count"><?php echo $total; ?></span><?php if ($unit == "relative"){echo ' '.tr('ud');} ?><span class="sub">Ğ1</span></p>
<p> <span class="count"><?php echo $total; ?></span><?php if ($unit == 'relative'){echo ' '.tr('ud');} ?><span class="sub">Ğ1</span></p>
<h3><?php echo tr('label_ontotal', array('total'=>$target, 'unit'=>(($unit=='relative') ? tr('ud').'<span class="sub">Ğ1<br></span>' : 'Ğ1'))); ?></h3>
</div>
<?php if (isset($end_date)){ ?>
......
......@@ -10,7 +10,7 @@ $ttr = array(
'error_target_negative' => 'Target is negative or null. Please check your syntax.',
'error_target_missing' => 'Missing target. Please check your syntax.',
'title_default' => 'Crowdfunding in libre currency',
'label_pubkey' => 'Accout pubkey:',
'label_pubkey' => 'Account pubkey:',
'label_qrcode' => 'QRcode',
'label_reached' => 'reached',
'label_donators' => 'Donators',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment