Attention ! Gitlab fournissant maintenant nativement des certificats Let’s Encrypt aux domaines personnalisés des Gitlab Pages, nous avons coupé notre service qui le faisait automatiquement pour vous.

Il est impératif, pour que votre domaine personnalisé continue à avoir un certificat Let’s Encrypt à jour, d’activer la fonctionnalité native dans les paramètres de votre projet. Cette activation remplacera votre certificat actuel par un nouveau certificat Let’s Encrypt géré par Gitlab.

Voir les détails sur https://docs.framasoft.org/fr/gitlab/gitlab-pages-le.html

Commit 6372e948 authored by JonathanMM's avatar JonathanMM

Initial commit

parent 9c87f601
script/config.py
script/config.server.py
config.php
config.server.php
script/velibLib.py
script/__pycache__/
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
<?php
function displayCodeStation($code)
{
if($code < 10000)
return '0'.$code;
return $code;
}
\ No newline at end of file
<?php
require_once('config.php');
include_once('functions.php');
//Filtre 24 heures
$hier = new DateTime("-1day");
$filtreDate = $hier->format('Y-m-d H:i:s');
//Dernière conso
$requete = $pdo->query('SELECT * FROM `statusConso` where nbStation Is not null and date >= "'.$filtreDate.'" Order by id desc limit 0,1');
$conso = $requete->fetch();
//Stations
$requete = $pdo->query('SELECT * FROM status inner join `stations` on stations.code = status.code WHERE idConso = '.$conso['id'].' order by status.code asc');
$statusStation = $requete->fetchAll();
?>
<!DOCTYPE html>
<html>
<head>
<title>Vélib Stats (site non officiel)</title>
<script type="application/javascript" src="Chart.min.js"></script>
<script type="application/javascript" src="jquery-3.2.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="datatables.min.js"></script>
<style type="text/css">
table, tr, td, th
{
border: 1px solid black;
}
td
{
text-align: center;
}
</style>
</head>
<body>
<h1>Vélib Stats (site non officiel)</h1>
<ul>
<li>Nombre de stations : <?php echo $conso['nbStation']; ?></li>
<li>Nombre de vélos mécaniques disponible : <?php echo $conso['nbBike']; ?></li>
<li>Nombre de vélos électiques disponible : <?php echo $conso['nbEbike']; ?></li>
<li>Nombre de bornes libres : <?php echo $conso['nbFreeEDock']; ?></li>
</ul>
<i>Dernière mise à jour : <?php echo $conso['date']; ?></i>
<canvas id="chartNbStations" width="1000" height="400"></canvas>
<canvas id="chartBikes" width="1000" height="400"></canvas>
<i>Ce site n'est pas un site officiel de vélib métropole. Les données utilisées proviennent de <a href="http://www.velib-metropole.fr">www.velib-metropole.fr</a> et appartienne à leur propriétaire. - <a href="https://framagit.org/JonathanMM/velibstats">Site du projet</a></i>
<h2>Stations</h2>
<table id="stations">
<thead>
<tr>
<th>Code</th>
<th>Nom</th>
<th>Date d'ouverture</th>
<th>Statut</th>
<th>Vélos mécaniques dispo</th>
<th>Vélos électriques dispo</th>
<th>Bornes libres</th>
</tr>
</thead>
<tbody>
<?php
foreach($statusStation as $station)
{
echo '<tr>';
echo '<td><a href="station.php?code='.$station['code'].'">'.displayCodeStation($station['code']).'</a></td>';
echo '<td>'.$station['name'].'</td>';
echo '<td>'.$station['dateOuverture'].'</td>';
echo '<td>'.(($station['state'] == 'Operative' && $station['nbEDock'] != 0) ? 'OK' : 'KO').'</td>';
echo '<td>'.$station['nbBike'].'</td>';
echo '<td>'.$station['nbEBike'].'</td>';
echo '<td>'.$station['nbFreeEDock'].'/'.$station['nbEDock'].'</td>';
echo '</tr>';
}
?>
</tbody>
</table>
<script type="text/javascript">
<?php
//On définit les points
$requete = $pdo->query('SELECT * FROM `statusConso` Where date >= "'.$filtreDate.'" Order by id asc');
$allConso = $requete->fetchAll();
$dates = [];
$nbStationsData = [];
$nbBikeData = [];
$nbEbikeData = [];
$nbFreeEdockData = [];
foreach($allConso as $i => $c)
{
if($c['nbStation'] > 0)
{
$dates[] = $c['date'];
$nbStationsData[] = $c['nbStation'];
$nbBikeData[] = $c['nbBike'];
$nbEbikeData[] = $c['nbEbike'];
$nbFreeEdockData[] = $c['nbFreeEDock'];
}
}
echo 'var datesData = ["'.implode('","', $dates).'"];';
echo 'var nbStationsData = ['.implode(',', $nbStationsData).'];';
echo 'var nbBikeData = ['.implode(',', $nbBikeData).'];';
echo 'var nbEbikeData = ['.implode(',', $nbEbikeData).'];';
echo 'var nbFreeEdockData = ['.implode(',', $nbFreeEdockData).'];';
?>
</script>
<script type="application/javascript">
var chartNbStations = document.getElementById("chartNbStations").getContext('2d');
var data = {
labels: datesData,
datasets: [
{
backgroundColor : "rgba(173,0,130,0.5)",
data : nbStationsData,
label: 'Nombre de stations'
}
]
};
var options = {
responsive: false,
scales: {
yAxes: [{
stacked: true
}]
}
};
new Chart(chartNbStations, {
type: 'line',
data: data,
options: options
});
var chartBikes = document.getElementById("chartBikes").getContext('2d');
var dataBike = {
labels: datesData,
datasets: [
{
backgroundColor : "rgba(104,221,46,0.5)",
data : nbBikeData,
label: 'Vélos mécaniques'
},
{
backgroundColor : "rgba(76, 213, 233, 0.5)",
data : nbEbikeData,
label: 'Vélos électriques'
}
]
};
new Chart(chartBikes, {
type: 'line',
data: dataBike,
options: options
});
$(document).ready( function () {
$('#stations').DataTable();
} );
</script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Order deny,allow
Deny from all
\ No newline at end of file
from adresseLib import getAdresse
import pymysql
from config import getMysqlConnection
mysql = getMysqlConnection()
requete = mysql.cursor()
requete.execute('SELECT code, latitude, longitude FROM stations')
stations = requete.fetchall()
for station in stations:
adresse = getAdresse(station[1], station[2])
requete = mysql.cursor()
requete.execute('UPDATE stations SET adresse = "'+adresse+'" WHERE code = '+str(station[0]))
\ No newline at end of file
import urllib.request, json, os
def getAdresse(lat, lon):
urlBAN = 'https://api-adresse.data.gouv.fr/reverse/?lat='+str(lat)+'&lon='+str(lon)
tmpFileName = 'adresse.json'
urllib.request.urlretrieve(urlBAN, tmpFileName)
data = json.load(open(tmpFileName))
adresse = data['features'][0]['properties']['label']
os.remove(tmpFileName)
return adresse
\ No newline at end of file
import velibLib
velibLib.getAllStation()
\ No newline at end of file
from resumeLib import calculerResume
import datetime
dureeConso = 5 #En minutes
#for i in range(0, 11):
#dateConsoDT = datetime.datetime(2018,1,9,11,i * dureeConso,0)
dateConsoDT = datetime.datetime.now() - datetime.timedelta(minutes=dureeConso)
dateConsoDT = dateConsoDT.replace(second = 0)
calculerResume(dateConsoDT, dureeConso)
\ No newline at end of file
import urllib.request, json, os, pymysql, datetime
from config import getMysqlConnection
def calculerResume(dateConsoDT, dureeConso):
dateConso = dateConsoDT.strftime("%Y-%m-%d %H:%M:%S")
minuteAvant = dateConsoDT - datetime.timedelta(minutes=1)
dateConsoAvant = minuteAvant.strftime("%Y-%m-%d %H:%M:%S")
finConso = dateConsoDT + datetime.timedelta(minutes=dureeConso)
dateConsoFin = finConso.strftime("%Y-%m-%d %H:%M:%S")
proprietes = ['nbBike', 'nbEBike', 'nbFreeEDock', 'nbEDock', 'nbBikeOverflow', 'nbEBikeOverflow', 'maxBikeOverflow']
mysql = getMysqlConnection()
#On récupère la minute d'avant pour les bases de conso
requete = mysql.cursor()
requete.execute("SELECT s.code, s."+', s.'.join(proprietes)+" \
FROM status s \
INNER JOIN `statusConso` c ON c.id = s.idConso \
WHERE (c.`date` >= '"+dateConsoAvant+"' AND c.`date` < '"+dateConso+"') \
ORDER BY c.id DESC")
statusConsoPrecedent = requete.fetchall()
precedents = {}
for row in statusConsoPrecedent:
codeStation = int(row[0])
for i, cle in enumerate(proprietes):
if cle in ['nbBike', 'nbEBike']:
valeurProp = int(row[i+1])
if not codeStation in precedents:
precedents[codeStation] = {}
precedents[codeStation][cle] = valeurProp
requete = mysql.cursor()
requete.execute("SELECT s.code, s."+', s.'.join(proprietes)+" \
FROM status s \
INNER JOIN `statusConso` c ON c.id = s.idConso \
WHERE (c.`date` >= '"+dateConso+"' AND c.`date` < '"+dateConsoFin+"') \
ORDER BY c.id ASC")
statusConso = requete.fetchall()
bikeList = {}
for row in statusConso:
codeStation = int(row[0])
for i, cle in enumerate(proprietes):
valeurProp = int(row[i+1])
if cle in ['nbEDock', 'maxBikeOverflow']:
bikeList[codeStation][cle] = valeurProp
else:
if not codeStation in bikeList:
bikeList[codeStation] = {cle: {'data': [], 'min': valeurProp, 'max': valeurProp}}
if cle in ['nbBike', 'nbEBike']:
bikeList[codeStation][cle]['pris'] = 0
bikeList[codeStation][cle]['remis'] = 0
elif not cle in bikeList[codeStation]:
bikeList[codeStation][cle] = {'data': [], 'min': valeurProp, 'max': valeurProp}
if cle in ['nbBike', 'nbEBike']:
bikeList[codeStation][cle]['pris'] = 0
bikeList[codeStation][cle]['remis'] = 0
else:
bikeList[codeStation][cle]['max'] = max(bikeList[codeStation][cle]['max'], valeurProp)
bikeList[codeStation][cle]['min'] = min(bikeList[codeStation][cle]['min'], valeurProp)
if cle in ['nbBike', 'nbEBike']:
if not codeStation in precedents:
precedents[codeStation] = {}
if len(bikeList[codeStation][cle]['data']) > 0 and cle in precedents[codeStation]:
delta = valeurProp - precedents[codeStation][cle]
if delta > 0:
bikeList[codeStation][cle]['remis'] += delta
if delta < 0:
bikeList[codeStation][cle]['pris'] -= delta
precedents[codeStation][cle] = valeurProp
bikeList[codeStation][cle]['data'].append(valeurProp)
for codeStation in bikeList:
for cle in bikeList[codeStation]:
info = bikeList[codeStation][cle]
if type(info) is dict:
data = info['data']
bikeList[codeStation][cle]['moyenne'] = sum(data) / max(len(data), 1)
for codeStation in bikeList:
valeurs = bikeList[codeStation]
requete = mysql.cursor()
requete.execute('INSERT INTO `resumeStatus` (`id`, `code`, `date`, `duree`, `nbBikeMin`, `nbBikeMax`, `nbBikeMoyenne`, `nbBikePris`, `nbBikeRendu`, `nbEBikeMin`, `nbEBikeMax`, `nbEBikeMoyenne`, `nbEBikePris`, `nbEBikeRendu`, `nbFreeEDockMin`, `nbFreeEDockMax`, `nbFreeEDockMoyenne`, `nbEDock`, `nbBikeOverflowMin`, `nbBikeOverflowMax`, `nbBikeOverflowMoyenne`, `nbEBikeOverflowMin`, `nbEBikeOverflowMax`, `nbEBikeOverflowMoyenne`, `maxBikeOverflow`) VALUES \
(NULL, '+str(codeStation)+', "'+dateConso+'", '+str(dureeConso)+', '+str(valeurs['nbBike']['min'])+', '+str(valeurs['nbBike']['max'])+', '+str(valeurs['nbBike']['moyenne'])+', '+str(valeurs['nbBike']['pris'])+', '+str(valeurs['nbBike']['remis'])+', '+str(valeurs['nbEBike']['min'])+', '+str(valeurs['nbEBike']['max'])+', '+str(valeurs['nbEBike']['moyenne'])+', '+str(valeurs['nbEBike']['pris'])+', '+str(valeurs['nbEBike']['remis'])+', '+str(valeurs['nbFreeEDock']['min'])+', '+str(valeurs['nbFreeEDock']['max'])+', '+str(valeurs['nbFreeEDock']['moyenne'])+', '+str(valeurs['nbEDock'])+', '+str(valeurs['nbBikeOverflow']['min'])+', '+str(valeurs['nbBikeOverflow']['max'])+', '+str(valeurs['nbBikeOverflow']['moyenne'])+', '+str(valeurs['nbEBikeOverflow']['min'])+', '+str(valeurs['nbEBikeOverflow']['max'])+', '+str(valeurs['nbEBikeOverflow']['moyenne'])+', '+str(valeurs['maxBikeOverflow'])+')')
\ No newline at end of file
This diff is collapsed.
-- phpMyAdmin SQL Dump
-- version 4.6.6deb4
-- https://www.phpmyadmin.net/
--
-- Client : localhost:3306
-- Généré le : Jeu 11 Janvier 2018 à 07:58
-- Version du serveur : 10.1.25-MariaDB-
-- Version de PHP : 7.0.22-0ubuntu0.17.04.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de données : `c6velib`
--
-- --------------------------------------------------------
--
-- Structure de la table `resumeStatus`
--
CREATE TABLE `resumeStatus` (
`id` int(11) NOT NULL,
`code` int(11) NOT NULL,
`date` datetime NOT NULL,
`duree` int(4) NOT NULL,
`nbBikeMin` int(3) NOT NULL,
`nbBikeMax` int(3) NOT NULL,
`nbBikeMoyenne` decimal(5,2) NOT NULL,
`nbBikePris` int(3) NOT NULL,
`nbBikeRendu` int(3) NOT NULL,
`nbEBikeMin` int(3) NOT NULL,
`nbEBikeMax` int(3) NOT NULL,
`nbEBikeMoyenne` decimal(5,2) NOT NULL,
`nbEBikePris` int(3) NOT NULL,
`nbEBikeRendu` int(3) NOT NULL,
`nbFreeEDockMin` int(3) NOT NULL,
`nbFreeEDockMax` int(3) NOT NULL,
`nbFreeEDockMoyenne` decimal(5,2) NOT NULL,
`nbEDock` int(3) NOT NULL,
`nbBikeOverflowMin` int(3) NOT NULL,
`nbBikeOverflowMax` int(3) NOT NULL,
`nbBikeOverflowMoyenne` decimal(5,2) NOT NULL,
`nbEBikeOverflowMin` int(3) NOT NULL,
`nbEBikeOverflowMax` int(3) NOT NULL,
`nbEBikeOverflowMoyenne` decimal(5,2) NOT NULL,
`maxBikeOverflow` int(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
-- --------------------------------------------------------
--
-- Structure de la table `stations`
--
CREATE TABLE `stations` (
`code` int(11) NOT NULL,
`name` varchar(256) NOT NULL,
`latitude` decimal(16,14) NOT NULL,
`longitude` decimal(16,14) NOT NULL,
`type` varchar(256) NOT NULL,
`dateOuverture` date NOT NULL,
`adresse` text
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Structure de la table `status`
--
CREATE TABLE `status` (
`id` int(11) NOT NULL,
`code` int(11) NOT NULL,
`idConso` int(11) NOT NULL,
`state` varchar(32) NOT NULL,
`nbBike` int(3) NOT NULL,
`nbEBike` int(3) NOT NULL,
`nbFreeEDock` int(3) NOT NULL,
`nbEDock` int(3) NOT NULL,
`nbBikeOverflow` int(3) NOT NULL,
`nbEBikeOverflow` int(3) NOT NULL,
`maxBikeOverflow` int(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Structure de la table `statusConso`
--
CREATE TABLE `statusConso` (
`id` int(11) NOT NULL,
`date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`nbStation` int(11) DEFAULT NULL,
`nbBike` int(11) DEFAULT NULL,
`nbEbike` int(11) DEFAULT NULL,
`nbFreeEDock` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;
--
-- Index pour les tables exportées
--
--
-- Index pour la table `resumeStatus`
--
ALTER TABLE `resumeStatus`
ADD PRIMARY KEY (`id`),
ADD KEY `date` (`date`),
ADD KEY `duree` (`duree`);
--
-- Index pour la table `stations`
--
ALTER TABLE `stations`
ADD PRIMARY KEY (`code`);
--
-- Index pour la table `status`
--
ALTER TABLE `status`
ADD PRIMARY KEY (`id`),
ADD KEY `station` (`code`);
--
-- Index pour la table `statusConso`
--
ALTER TABLE `statusConso`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT pour les tables exportées
--
--
-- AUTO_INCREMENT pour la table `resumeStatus`
--
ALTER TABLE `resumeStatus`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pour la table `status`
--
ALTER TABLE `status`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pour la table `statusConso`
--
ALTER TABLE `statusConso`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Markdown is supported
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