site-accueil-insa/stats.php

59 lines
1.7 KiB
PHP
Raw Normal View History

2018-05-24 13:17:51 +02:00
<?php
ob_start(); // Start reading html
2018-05-24 14:01:44 +02:00
function get_stats($is_urss){
2018-06-05 20:03:33 +02:00
$json_source = file_get_contents('https://raw.githubusercontent.com/Keplyx/site-accueil-insa/master/historique.json');
2018-05-24 14:01:44 +02:00
$json_data = json_decode($json_source, true);
$root = "usa";
if ($is_urss)
$root = "urss";
foreach($json_data[$root] as $v){
if ($v['points'] > 0)
echo "<tr id='positive'>";
else
echo "<tr id='negative'>";
echo "<td>".$v['text']."</td>";
echo "<td>".$v['points']."</td>";
echo "</tr>";
}
}
2018-05-24 13:17:51 +02:00
2018-05-24 14:01:44 +02:00
?>
<h1>Stats</h1>
<p>
Les stats de la semaine.
<br>
Remporte le plus de points possible pour faire gagner ton équipe, mais attention à ne pas lui en faire perdre !
</p>
2018-06-05 20:03:33 +02:00
<div id="stats-container">
<table class="stats-table" id="stats-usa">
2018-05-24 14:01:44 +02:00
<tr>
<th colspan="2">USA</th>
</tr>
<tr>
2018-06-05 20:03:33 +02:00
<td class="stat-log">Log</td>
<td class="stat-points">Points</td>
2018-05-24 14:01:44 +02:00
</tr>
<?php get_stats(false) ?>
</table>
2018-06-05 20:03:33 +02:00
<table class="stats-table" id="stats-urss">
2018-05-24 14:01:44 +02:00
<tr>
<th colspan="2">URSS</th>
</tr>
<tr>
2018-06-05 20:03:33 +02:00
<td class="stat-log">Log</td>
<td class="stat-points">Points</td>
2018-05-24 14:01:44 +02:00
</tr>
<?php get_stats(true) ?>
</table>
</div>
2018-05-24 13:17:51 +02:00
<?php
$pageContent = ob_get_clean(); // Store html content in variable
2018-06-05 20:03:33 +02:00
$pageTitle = "Stats";
2018-05-24 14:01:44 +02:00
ob_start(); // Start reading html
?>
2018-06-05 20:03:33 +02:00
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/stats.css">
2018-05-24 14:01:44 +02:00
<?php
$pageMeta = ob_get_clean(); // Store html content in variable
2018-05-24 13:17:51 +02:00
include("template.php"); // Display template with variable content
2018-06-05 20:03:33 +02:00
?>