Merge pull request #12 from LeOSW42/copilot/comment-code-base
Document templates and styles with file headers
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Point d'entrée web : charge la configuration et le routeur principal.
|
||||||
|
*/
|
||||||
|
|
||||||
require_once __DIR__ . '/../src/Core/config.php';
|
require_once __DIR__ . '/../src/Core/config.php';
|
||||||
require_once __DIR__ . '/../src/Core/routes.php';
|
require_once __DIR__ . '/../src/Core/routes.php';
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- Template: blocks/d.footer.html -->
|
||||||
<footer>
|
<footer>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<p class="flex-element"><a target="_blank" href="https://www.facebook.com/kabano09"><i class="fab fa-facebook-square"></i></a> Léo Serre — <script>document.write("06 " + "1" + "8 6" + "2 3" + "2 ");</script>05</p>
|
<p class="flex-element"><a target="_blank" href="https://www.facebook.com/kabano09"><i class="fab fa-facebook-square"></i></a> Léo Serre — <script>document.write("06 " + "1" + "8 6" + "2 3" + "2 ");</script>05</p>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- Template: blocks/d.head.html -->
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- Template: blocks/d.nav.html -->
|
||||||
<header>
|
<header>
|
||||||
<div id="Hcontent">
|
<div id="Hcontent">
|
||||||
<a href="<?=$config['rel_root_folder']?>" id="logo">
|
<a href="<?=$config['rel_root_folder']?>" id="logo">
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* Feuille de style: css/d.admin.css */
|
||||||
/*********************************/
|
/*********************************/
|
||||||
/** Wiki files page **/
|
/** Wiki files page **/
|
||||||
/*********************************/
|
/*********************************/
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* Feuille de style: css/d.blog.css */
|
||||||
/*********************************/
|
/*********************************/
|
||||||
/** Blog list page **/
|
/** Blog list page **/
|
||||||
/*********************************/
|
/*********************************/
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* Feuille de style: css/d.index.css */
|
||||||
* {
|
* {
|
||||||
border: 0;
|
border: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* Feuille de style: css/d.map.css */
|
||||||
/* Custom configuration for the map page */
|
/* Custom configuration for the map page */
|
||||||
|
|
||||||
html {
|
html {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* Feuille de style: css/d.poi.css */
|
||||||
/*********************************/
|
/*********************************/
|
||||||
/** Common **/
|
/** Common **/
|
||||||
/*********************************/
|
/*********************************/
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* Feuille de style: css/d.user.css */
|
||||||
/*********************************/
|
/*********************************/
|
||||||
/** Login page **/
|
/** Login page **/
|
||||||
/*********************************/
|
/*********************************/
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* Feuille de style: css/d.wiki.css */
|
||||||
/*********************************/
|
/*********************************/
|
||||||
/** View page **/
|
/** View page **/
|
||||||
/*********************************/
|
/*********************************/
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.admin.backup.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.admin.git-pull.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.admin.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.admin.logs.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.admin.stats.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.admin.wiki-files.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.blog.edit.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.blog.list.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php /* Template: d.blog.list.rss */
|
||||||
|
|
||||||
$ts = gmdate("D, d M Y H:i:s", time() + 60) . " GMT";
|
$ts = gmdate("D, d M Y H:i:s", time() + 60) . " GMT";
|
||||||
header("Content-disposition: filename=blog.rss");
|
header("Content-disposition: filename=blog.rss");
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.blog.view.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.community.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.contact.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.index.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.map.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.poi.edit.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.poi.view.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.user.login.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.user.member_list.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.user.password_lost.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.user.profile.edit.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.user.profile.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.user.signin.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.wiki.edit.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<!-- Template: d.wiki.view.html -->
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
|
||||||
<?php include('blocks/d.head.html'); ?>
|
<?php include('blocks/d.head.html'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
// Gestion de l'upload et suppression d'avatar côté client.
|
||||||
$(window).ready(function() {
|
$(window).ready(function() {
|
||||||
$("#deleteavatar").click(function() {
|
$("#deleteavatar").click(function() {
|
||||||
$("aside").removeClass("avatar").addClass("noavatar");
|
$("aside").removeClass("avatar").addClass("noavatar");
|
||||||
@@ -27,6 +28,7 @@ $(window).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Prévisualisation du fichier image dans le profil.
|
||||||
function readURL(input) {
|
function readURL(input) {
|
||||||
if (input.files && input.files[0]) {
|
if (input.files && input.files[0]) {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
@@ -37,4 +39,4 @@ function readURL(input) {
|
|||||||
|
|
||||||
reader.readAsDataURL(input.files[0]);
|
reader.readAsDataURL(input.files[0]);
|
||||||
}
|
}
|
||||||
}$
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
// Compte à rebours du captcha.
|
||||||
var time = 9;
|
var time = 9;
|
||||||
|
|
||||||
|
// Active le bouton lorsque le délai est écoulé.
|
||||||
$(window).ready(function() {
|
$(window).ready(function() {
|
||||||
var interval = setInterval(function() {
|
var interval = setInterval(function() {
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
@@ -19,4 +21,3 @@ $(window).ready(function() {
|
|||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// Gestion des animations du header en scroll.
|
||||||
var small = 2;
|
var small = 2;
|
||||||
|
|
||||||
function reduce() {
|
function reduce() {
|
||||||
|
// Réduit la hauteur du header.
|
||||||
$( "header" ).animate({
|
$( "header" ).animate({
|
||||||
height: "45px"
|
height: "45px"
|
||||||
}, 100, function() {
|
}, 100, function() {
|
||||||
@@ -36,6 +38,7 @@ function reduce() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function enlarge() {
|
function enlarge() {
|
||||||
|
// Restaure la taille du header.
|
||||||
$( "header" ).animate({
|
$( "header" ).animate({
|
||||||
height: "65px"
|
height: "65px"
|
||||||
}, 100, function() {
|
}, 100, function() {
|
||||||
@@ -70,6 +73,7 @@ function enlarge() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Déclenche les animations selon le scroll.
|
||||||
$(window).scroll(function() {
|
$(window).scroll(function() {
|
||||||
var position = $(window).scrollTop();
|
var position = $(window).scrollTop();
|
||||||
if (position>80 && small!=1 && $('body').width() > 800) {
|
if (position>80 && small!=1 && $('body').width() > 800) {
|
||||||
@@ -82,6 +86,7 @@ $(window).scroll(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Affichage du texte du logo au survol.
|
||||||
$(window).ready(function() {
|
$(window).ready(function() {
|
||||||
$( "#logo" ).hover(
|
$( "#logo" ).hover(
|
||||||
function() {
|
function() {
|
||||||
@@ -90,4 +95,4 @@ $(window).ready(function() {
|
|||||||
$("#kabanologotext").hide(100);
|
$("#kabanologotext").hide(100);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
|
// Carte principale et marqueurs de POI.
|
||||||
var mymap;
|
var mymap;
|
||||||
var markers = [];
|
var markers = [];
|
||||||
|
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
// Differents layers for the map
|
// Différentes couches pour la carte.
|
||||||
var topo_maptiler = L.tileLayer('https://api.maptiler.com/maps/topographique/{z}/{x}/{y}.png?key=Sm8M7mJ53GtYdl773rpi', {tms: false, attribution: 'Carte © <a href="https://www.maptiler.com/copyright/" target="_blank">MapTiler</a>, Données © <a href="http://www.openstreetmap.org/copyright" target="_blank">Contributeurs OpenStreetMap</a>', tileSize: 512, zoomOffset: -1, minZoom: 1});
|
var topo_maptiler = L.tileLayer('https://api.maptiler.com/maps/topographique/{z}/{x}/{y}.png?key=Sm8M7mJ53GtYdl773rpi', {tms: false, attribution: 'Carte © <a href="https://www.maptiler.com/copyright/" target="_blank">MapTiler</a>, Données © <a href="http://www.openstreetmap.org/copyright" target="_blank">Contributeurs OpenStreetMap</a>', tileSize: 512, zoomOffset: -1, minZoom: 1});
|
||||||
var ign = L.tileLayer('https://data.geopf.fr/private/wmts?&REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/jpeg&LAYER=GEOGRAPHICALGRIDSYSTEMS.MAPS&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&apikey=ign_scan_ws', {attribution: 'Carte & Connées © <a href="http://ign.fr/" target="_blank">IGN-F/Géoportail</a>'});
|
var ign = L.tileLayer('https://data.geopf.fr/private/wmts?&REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/jpeg&LAYER=GEOGRAPHICALGRIDSYSTEMS.MAPS&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&apikey=ign_scan_ws', {attribution: 'Carte & Connées © <a href="http://ign.fr/" target="_blank">IGN-F/Géoportail</a>'});
|
||||||
|
|
||||||
// Base layers
|
// Couches de base.
|
||||||
var baseLayers = {
|
var baseLayers = {
|
||||||
"OpenStreetMap": topo_maptiler,
|
"OpenStreetMap": topo_maptiler,
|
||||||
"IGN France": ign
|
"IGN France": ign
|
||||||
@@ -63,6 +64,7 @@ $( document ).ready(function() {
|
|||||||
$("#map-credits").html(e.layer.getAttribution());
|
$("#map-credits").html(e.layer.getAttribution());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Ajuste la taille des icônes selon le niveau de zoom.
|
||||||
mymap.on("zoomend", function () {
|
mymap.on("zoomend", function () {
|
||||||
var z = mymap.getZoom();
|
var z = mymap.getZoom();
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// Carte des POIs et marqueur principal.
|
||||||
var mymap;
|
var mymap;
|
||||||
var poi_layer;
|
var poi_layer;
|
||||||
|
|
||||||
@@ -5,7 +6,7 @@ $(document).ready(function() {
|
|||||||
// Mode : edit (formulaire) ou view (affichage)
|
// Mode : edit (formulaire) ou view (affichage)
|
||||||
var isEdit = (typeof poi_mode === "undefined" || poi_mode === "edit");
|
var isEdit = (typeof poi_mode === "undefined" || poi_mode === "edit");
|
||||||
|
|
||||||
// Differents layers for the map
|
// Différentes couches pour la carte.
|
||||||
var topo_maptiler = L.tileLayer(
|
var topo_maptiler = L.tileLayer(
|
||||||
'https://api.maptiler.com/maps/topographique/{z}/{x}/{y}.png?key=Sm8M7mJ53GtYdl773rpi',
|
'https://api.maptiler.com/maps/topographique/{z}/{x}/{y}.png?key=Sm8M7mJ53GtYdl773rpi',
|
||||||
{
|
{
|
||||||
@@ -22,7 +23,7 @@ $(document).ready(function() {
|
|||||||
attribution: 'Carte & Connées © <a href="http://ign.fr/" target="_blank">IGN-F/Géoportail</a>'
|
attribution: 'Carte & Connées © <a href="http://ign.fr/" target="_blank">IGN-F/Géoportail</a>'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// Base layers
|
// Couches de base.
|
||||||
var baseLayers = {
|
var baseLayers = {
|
||||||
"OpenStreetMap": topo_maptiler,
|
"OpenStreetMap": topo_maptiler,
|
||||||
"IGN France": ign
|
"IGN France": ign
|
||||||
@@ -80,6 +81,7 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
|
// Mise à jour des coordonnées à chaque déplacement.
|
||||||
poi_layer.bindTooltip("Glissez moi au bon endroit.", {permanent: true, direction: 'auto'}).openTooltip();
|
poi_layer.bindTooltip("Glissez moi au bon endroit.", {permanent: true, direction: 'auto'}).openTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +98,7 @@ $(document).ready(function() {
|
|||||||
$("#elevation_icon").show();
|
$("#elevation_icon").show();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Si l'utilisateur modifie les champs lat/lon manuellement.
|
||||||
$("#lat,#lon").change(function() { // If the user changes the lat/lon input values manualy
|
$("#lat,#lon").change(function() { // If the user changes the lat/lon input values manualy
|
||||||
if(isNaN($("#lat").val()) || isNaN($("#lon").val()) || $("#lat").val().length==0 || $("#lon").val()==null)
|
if(isNaN($("#lat").val()) || isNaN($("#lon").val()) || $("#lat").val().length==0 || $("#lon").val()==null)
|
||||||
$("#elevation_icon").hide();
|
$("#elevation_icon").hide();
|
||||||
@@ -116,6 +119,7 @@ $(document).ready(function() {
|
|||||||
poi_layer.setIcon(editPoiIcon);
|
poi_layer.setIcon(editPoiIcon);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Chargement de l'altitude via le proxy.
|
||||||
$("#elevation_icon").click(function(e) {
|
$("#elevation_icon").click(function(e) {
|
||||||
$(this).find($(".fas")).removeClass('fa-search-location').addClass('fa-spinner').addClass('fa-spin');
|
$(this).find($(".fas")).removeClass('fa-search-location').addClass('fa-spinner').addClass('fa-spin');
|
||||||
$.get(root+"poi/elevation_proxy", {location:$("#lat").val()+","+$("#lon").val()}, function(result){
|
$.get(root+"poi/elevation_proxy", {location:$("#lat").val()+","+$("#lon").val()}, function(result){
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contrôleur des pages d'administration (logs, sauvegardes, stats).
|
||||||
|
*/
|
||||||
|
|
||||||
if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) {
|
if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) {
|
||||||
switch ($controller->splitted_url[1]) {
|
switch ($controller->splitted_url[1]) {
|
||||||
case '': case 'admin':
|
case '': case 'admin':
|
||||||
@@ -7,6 +11,7 @@ if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) {
|
|||||||
include ($config['views_folder']."d.admin.html");
|
include ($config['views_folder']."d.admin.html");
|
||||||
break;
|
break;
|
||||||
case 'git-pull':
|
case 'git-pull':
|
||||||
|
// Mise à jour du dépôt depuis l'interface d'administration.
|
||||||
if ($user->rankIsHigher("administrator")) {
|
if ($user->rankIsHigher("administrator")) {
|
||||||
$head['title'] = "Mise à jour";
|
$head['title'] = "Mise à jour";
|
||||||
|
|
||||||
@@ -29,6 +34,7 @@ if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) {
|
|||||||
$logs_folder = realpath($config['logs_folder']);
|
$logs_folder = realpath($config['logs_folder']);
|
||||||
$logs_folder_root = $logs_folder !== false ? rtrim($logs_folder, DIRECTORY_SEPARATOR) : null;
|
$logs_folder_root = $logs_folder !== false ? rtrim($logs_folder, DIRECTORY_SEPARATOR) : null;
|
||||||
|
|
||||||
|
// Sélection du fichier de log à afficher.
|
||||||
if (isset($controller->splitted_url[2]) && is_numeric($controller->splitted_url[2]) && intval($controller->splitted_url[2]) < count($files_list)-2) {
|
if (isset($controller->splitted_url[2]) && is_numeric($controller->splitted_url[2]) && intval($controller->splitted_url[2]) < count($files_list)-2) {
|
||||||
$filenb = $controller->splitted_url[2];
|
$filenb = $controller->splitted_url[2];
|
||||||
}
|
}
|
||||||
@@ -141,6 +147,7 @@ if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) {
|
|||||||
if ($user->rankIsHigher("moderator")) {
|
if ($user->rankIsHigher("moderator")) {
|
||||||
$head['title'] = "Statistiques";
|
$head['title'] = "Statistiques";
|
||||||
|
|
||||||
|
// Génération du rapport statistiques (GoAccess).
|
||||||
$report = $config['abs_root_folder'].'tmp/report.html';
|
$report = $config['abs_root_folder'].'tmp/report.html';
|
||||||
|
|
||||||
$files = glob('/var/log/nginx/kabano.org-access.log*.gz');
|
$files = glob('/var/log/nginx/kabano.org-access.log*.gz');
|
||||||
@@ -174,6 +181,7 @@ if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) {
|
|||||||
if ($user->rankIsHigher("administrator")) {
|
if ($user->rankIsHigher("administrator")) {
|
||||||
$head['title'] = "Export SQL";
|
$head['title'] = "Export SQL";
|
||||||
|
|
||||||
|
// Suppression d'une sauvegarde existante.
|
||||||
if(isset($controller->splitted_url[2]) && $controller->splitted_url[2]=='delete' && isset($controller->splitted_url[3])) {
|
if(isset($controller->splitted_url[2]) && $controller->splitted_url[2]=='delete' && isset($controller->splitted_url[3])) {
|
||||||
$tmp_folder = realpath($config['abs_root_folder'].'tmp');
|
$tmp_folder = realpath($config['abs_root_folder'].'tmp');
|
||||||
if ($tmp_folder !== false) {
|
if ($tmp_folder !== false) {
|
||||||
@@ -191,6 +199,7 @@ if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) {
|
|||||||
$backup_file = Array();
|
$backup_file = Array();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Génération d'une sauvegarde SQL.
|
||||||
// Nom du fichier de sauvegarde
|
// Nom du fichier de sauvegarde
|
||||||
$timestamp = date('Ymd_His');
|
$timestamp = date('Ymd_His');
|
||||||
$backup_filename[0] = $timestamp.'_backup.sql';
|
$backup_filename[0] = $timestamp.'_backup.sql';
|
||||||
@@ -218,6 +227,7 @@ if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) {
|
|||||||
$output = Array();
|
$output = Array();
|
||||||
$backup_file = Array();
|
$backup_file = Array();
|
||||||
|
|
||||||
|
// Suppression d'une archive existante.
|
||||||
if(isset($controller->splitted_url[2]) && $controller->splitted_url[2]=='delete' && isset($controller->splitted_url[3])) {
|
if(isset($controller->splitted_url[2]) && $controller->splitted_url[2]=='delete' && isset($controller->splitted_url[3])) {
|
||||||
$tmp_folder = realpath($config['abs_root_folder'].'tmp');
|
$tmp_folder = realpath($config['abs_root_folder'].'tmp');
|
||||||
if ($tmp_folder !== false) {
|
if ($tmp_folder !== false) {
|
||||||
@@ -233,6 +243,7 @@ if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Création des archives de fichiers.
|
||||||
// Nom du fichier de sauvegarde
|
// Nom du fichier de sauvegarde
|
||||||
$timestamp = date('Ymd_His');
|
$timestamp = date('Ymd_His');
|
||||||
$backup_source[0] = $config['abs_root_folder'].'medias/avatars';
|
$backup_source[0] = $config['abs_root_folder'].'medias/avatars';
|
||||||
@@ -288,6 +299,7 @@ else {
|
|||||||
|
|
||||||
// Fonctions de mise en forme
|
// Fonctions de mise en forme
|
||||||
|
|
||||||
|
// Icône FontAwesome selon le type MIME.
|
||||||
function getFontAwesomeIcon($mimeType) {
|
function getFontAwesomeIcon($mimeType) {
|
||||||
$icons = [
|
$icons = [
|
||||||
'application/pdf' => 'fa-file-pdf',
|
'application/pdf' => 'fa-file-pdf',
|
||||||
@@ -304,6 +316,7 @@ function getFontAwesomeIcon($mimeType) {
|
|||||||
return $icons[$mimeType] ?? 'fa-file'; // Default
|
return $icons[$mimeType] ?? 'fa-file'; // Default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Formatte une taille en octets selon la locale.
|
||||||
function formatBytes($bytes, $locale = 'en', $precision = 2) {
|
function formatBytes($bytes, $locale = 'en', $precision = 2) {
|
||||||
$unitMap = [
|
$unitMap = [
|
||||||
'en' => ['B', 'KB', 'MB', 'GB', 'TB', 'PB'],
|
'en' => ['B', 'KB', 'MB', 'GB', 'TB', 'PB'],
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contrôleur des pages blog : liste, lecture, édition.
|
||||||
|
*/
|
||||||
|
|
||||||
require_once($config['models_folder']."d.blog.php");
|
require_once($config['models_folder']."d.blog.php");
|
||||||
require_once($config['models_folder']."d.comments.php");
|
require_once($config['models_folder']."d.comments.php");
|
||||||
require_once($config['models_folder']."d.users.php");
|
require_once($config['models_folder']."d.users.php");
|
||||||
@@ -24,6 +28,7 @@ if (!isset($controller->splitted_url[1]) OR $controller->splitted_url[1]=="" OR
|
|||||||
$articles_per_pages = 5;
|
$articles_per_pages = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Routage des différentes actions du blog.
|
||||||
switch ($controller->splitted_url[1]) {
|
switch ($controller->splitted_url[1]) {
|
||||||
case "rss":
|
case "rss":
|
||||||
$page = 0;
|
$page = 0;
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contrôleur de la page contact et traitement du formulaire.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Récupère un champ POST avec une valeur par défaut.
|
||||||
function post($index) {
|
function post($index) {
|
||||||
return isset($_POST[$index]) ? $_POST[$index] : '';
|
return isset($_POST[$index]) ? $_POST[$index] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$error = "no";
|
$error = "no";
|
||||||
|
|
||||||
|
// Traitement de la soumission du formulaire.
|
||||||
if(isset($_POST['submit'])) {
|
if(isset($_POST['submit'])) {
|
||||||
$message = "Message reçu depuis Kabano par ".post('name').".<br>\r\n";
|
$message = "Message reçu depuis Kabano par ".post('name').".<br>\r\n";
|
||||||
$message .= "<hr>\r\n";
|
$message .= "<hr>\r\n";
|
||||||
$message .= "<pre style='padding: 10px; background: #ccc;'>".strip_tags(post('message'))."</pre><br>\r\n";
|
$message .= "<pre style='padding: 10px; background: #ccc;'>".strip_tags(post('message'))."</pre><br>\r\n";
|
||||||
|
|
||||||
|
// Nettoyage simple de l'email expéditeur.
|
||||||
$sender = str_replace(["\r", "\n"], '', post('email'));
|
$sender = str_replace(["\r", "\n"], '', post('email'));
|
||||||
$headers = 'From: '. $sender . "\r\n" .
|
$headers = 'From: '. $sender . "\r\n" .
|
||||||
'Reply-To: '. $sender . "\r\n" .
|
'Reply-To: '. $sender . "\r\n" .
|
||||||
@@ -18,6 +25,7 @@ if(isset($_POST['submit'])) {
|
|||||||
'MIME-Version: 1.0' . "\r\n" .
|
'MIME-Version: 1.0' . "\r\n" .
|
||||||
'Content-type: text/html; charset=UTF-8' . "\r\n";
|
'Content-type: text/html; charset=UTF-8' . "\r\n";
|
||||||
|
|
||||||
|
// Anti-spam basique via champ caché et captcha.
|
||||||
if(post('ns') == '' && $_POST['captcha'] == -2) {
|
if(post('ns') == '' && $_POST['captcha'] == -2) {
|
||||||
$send = true;
|
$send = true;
|
||||||
if(post('name') == '') {
|
if(post('name') == '') {
|
||||||
@@ -49,6 +57,7 @@ if(isset($_POST['submit'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Préremplissage du formulaire avec les infos connues.
|
||||||
if(post('name') != '')
|
if(post('name') != '')
|
||||||
$contact['name'] = post('name');
|
$contact['name'] = post('name');
|
||||||
else if($user->rankIsHigher("registered"))
|
else if($user->rankIsHigher("registered"))
|
||||||
@@ -68,6 +77,7 @@ $contact['message'] = post('message');
|
|||||||
$contact['ns'] = post('ns');
|
$contact['ns'] = post('ns');
|
||||||
|
|
||||||
|
|
||||||
|
// Chargement de la vue contact.
|
||||||
$head['css'] = "d.index.css;d.user.css";
|
$head['css'] = "d.index.css;d.user.css";
|
||||||
$head['js'] = "d.captcha.js";
|
$head['js'] = "d.captcha.js";
|
||||||
$head['title'] = "Contact";
|
$head['title'] = "Contact";
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contrôleur de la page carte (map).
|
||||||
|
*/
|
||||||
|
|
||||||
$head['css'] = "d.index.css";
|
$head['css'] = "d.index.css";
|
||||||
|
|
||||||
|
// Gestion des routes secondaires de la carte.
|
||||||
if(isset($controller->splitted_url[1]) && $controller->splitted_url[1] != '') {
|
if(isset($controller->splitted_url[1]) && $controller->splitted_url[1] != '') {
|
||||||
switch ($controller->splitted_url[1]) {
|
switch ($controller->splitted_url[1]) {
|
||||||
default:
|
default:
|
||||||
@@ -10,6 +15,7 @@ if(isset($controller->splitted_url[1]) && $controller->splitted_url[1] != '') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Chargement de la carte et des dépendances Leaflet.
|
||||||
$head['title'] = "Carte";
|
$head['title'] = "Carte";
|
||||||
$head['third'] = "leaflet/leaflet.js;leaflet-fullscreen/Leaflet.fullscreen.min.js;leaflet-easybutton/easy-button.js";
|
$head['third'] = "leaflet/leaflet.js;leaflet-fullscreen/Leaflet.fullscreen.min.js;leaflet-easybutton/easy-button.js";
|
||||||
$head['css'] .= ";d.map.css;../third/leaflet/leaflet.css;../third/leaflet-fullscreen/leaflet.fullscreen.css;../third/leaflet-easybutton/easy-button.css";
|
$head['css'] .= ";d.map.css;../third/leaflet/leaflet.css;../third/leaflet-fullscreen/leaflet.fullscreen.css;../third/leaflet-easybutton/easy-button.css";
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contrôleur des points d'intérêt (POI) : création, affichage, API.
|
||||||
|
*/
|
||||||
|
|
||||||
require_once($config['models_folder']."d.poi.php");
|
require_once($config['models_folder']."d.poi.php");
|
||||||
require_once($config['models_folder']."d.comments.php");
|
require_once($config['models_folder']."d.comments.php");
|
||||||
require_once($config['models_folder']."d.users.php");
|
require_once($config['models_folder']."d.users.php");
|
||||||
@@ -9,6 +13,7 @@ $head['css'] = "d.index.css;d.poi.css";
|
|||||||
|
|
||||||
$poi = new Kabano\Poi();
|
$poi = new Kabano\Poi();
|
||||||
|
|
||||||
|
// Routage des actions POI.
|
||||||
switch ($controller->splitted_url[1]) {
|
switch ($controller->splitted_url[1]) {
|
||||||
case "new":
|
case "new":
|
||||||
if ($user->rankIsHigher("registered")) {
|
if ($user->rankIsHigher("registered")) {
|
||||||
@@ -23,6 +28,7 @@ switch ($controller->splitted_url[1]) {
|
|||||||
$poi->source = "kab";
|
$poi->source = "kab";
|
||||||
$poi->is_commentable = 't';
|
$poi->is_commentable = 't';
|
||||||
|
|
||||||
|
// Paramètres selon le type de POI.
|
||||||
$definition = $poi_types[$poi->poi_type][5];
|
$definition = $poi_types[$poi->poi_type][5];
|
||||||
$params = [];
|
$params = [];
|
||||||
|
|
||||||
@@ -92,6 +98,7 @@ switch ($controller->splitted_url[1]) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "elevation_proxy":
|
case "elevation_proxy":
|
||||||
|
// Proxy vers l'API d'élévation.
|
||||||
if (isset($_GET['location'])) {
|
if (isset($_GET['location'])) {
|
||||||
if (!preg_match('/^[0-9,\.\|\-]+$/', $_GET['location'])) {
|
if (!preg_match('/^[0-9,\.\|\-]+$/', $_GET['location'])) {
|
||||||
$notfound = 1;
|
$notfound = 1;
|
||||||
@@ -107,6 +114,7 @@ switch ($controller->splitted_url[1]) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "api_list":
|
case "api_list":
|
||||||
|
// API JSON pour la liste des POIs (carte).
|
||||||
header("Content-Type: application/json; charset=utf-8");
|
header("Content-Type: application/json; charset=utf-8");
|
||||||
|
|
||||||
$pois = new Kabano\Pois();
|
$pois = new Kabano\Pois();
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contrôleur des pages utilisateurs : authentification, profils, liste.
|
||||||
|
*/
|
||||||
|
|
||||||
require_once($config['models_folder']."d.users.php");
|
require_once($config['models_folder']."d.users.php");
|
||||||
|
|
||||||
$head['css'] = "d.index.css;d.user.css";
|
$head['css'] = "d.index.css;d.user.css";
|
||||||
|
|
||||||
|
// Routage des actions utilisateur.
|
||||||
if(isset($controller->splitted_url[1])) {
|
if(isset($controller->splitted_url[1])) {
|
||||||
switch ($controller->splitted_url[1]) {
|
switch ($controller->splitted_url[1]) {
|
||||||
case 'login':
|
case 'login':
|
||||||
@@ -38,6 +43,7 @@ if(isset($controller->splitted_url[1])) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'logout':
|
case 'logout':
|
||||||
|
// Déconnexion et retour à la page précédente si locale.
|
||||||
session_destroy();
|
session_destroy();
|
||||||
$redirect = $config['rel_root_folder'];
|
$redirect = $config['rel_root_folder'];
|
||||||
if (!empty($_SERVER['HTTP_REFERER'])) {
|
if (!empty($_SERVER['HTTP_REFERER'])) {
|
||||||
@@ -91,6 +97,7 @@ if(isset($controller->splitted_url[1])) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'password_lost':
|
case 'password_lost':
|
||||||
|
// Demande de réinitialisation du mot de passe.
|
||||||
$head['title'] = "Récupération de mot de passe";
|
$head['title'] = "Récupération de mot de passe";
|
||||||
if ($user->rank == "visitor") {
|
if ($user->rank == "visitor") {
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
@@ -198,6 +205,7 @@ if(isset($controller->splitted_url[1])) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'member_list':
|
case 'member_list':
|
||||||
|
// Liste des membres.
|
||||||
if ($user->rankIsHigher("registered")) {
|
if ($user->rankIsHigher("registered")) {
|
||||||
$rows_per_pages = 50;
|
$rows_per_pages = 50;
|
||||||
// Get the correct page number
|
// Get the correct page number
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contrôleur des pages wiki : lecture, édition, création.
|
||||||
|
*/
|
||||||
|
|
||||||
require_once($config['models_folder']."d.wiki.php");
|
require_once($config['models_folder']."d.wiki.php");
|
||||||
|
|
||||||
$head['css'] = "d.index.css;d.wiki.css";
|
$head['css'] = "d.index.css;d.wiki.css";
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exemple de configuration globale pour l'application Kabano.
|
||||||
|
*/
|
||||||
|
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
ini_set('display_startup_errors', 1);
|
ini_set('display_startup_errors', 1);
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
@@ -11,6 +15,7 @@ date_default_timezone_set("UTC"); // Default tz for date manipulation is UTC. Di
|
|||||||
** Management of folder names
|
** Management of folder names
|
||||||
*****/
|
*****/
|
||||||
|
|
||||||
|
// Définition des chemins absolus de l'application.
|
||||||
$config['core_folder'] = rtrim(realpath(__DIR__), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
$config['core_folder'] = rtrim(realpath(__DIR__), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
||||||
$config['src_folder'] = rtrim(realpath(dirname($config['core_folder'])), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
$config['src_folder'] = rtrim(realpath(dirname($config['core_folder'])), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
||||||
$config['abs_root_folder'] = rtrim(realpath(dirname($config['src_folder'])), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
$config['abs_root_folder'] = rtrim(realpath(dirname($config['src_folder'])), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
||||||
@@ -47,6 +52,7 @@ $config['views_url'] = $config['rel_root_folder']."views/";
|
|||||||
** SQL Database configuration
|
** SQL Database configuration
|
||||||
*****/
|
*****/
|
||||||
|
|
||||||
|
// Paramètres PostgreSQL utilisés par sql_connect().
|
||||||
$config['SQL_host'] = "localhost";
|
$config['SQL_host'] = "localhost";
|
||||||
$config['SQL_user'] = "kabano";
|
$config['SQL_user'] = "kabano";
|
||||||
$config['SQL_pass'] = "PASSWORD";
|
$config['SQL_pass'] = "PASSWORD";
|
||||||
|
|||||||
@@ -2,14 +2,19 @@
|
|||||||
|
|
||||||
namespace Kabano;
|
namespace Kabano;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ouvre une connexion PostgreSQL avec les paramètres de configuration.
|
||||||
|
*/
|
||||||
function sql_connect() {
|
function sql_connect() {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Chaîne de connexion PostgreSQL.
|
||||||
$connection = "host=".$config['SQL_host']
|
$connection = "host=".$config['SQL_host']
|
||||||
." dbname=".$config['SQL_db']
|
." dbname=".$config['SQL_db']
|
||||||
." user=".$config['SQL_user']
|
." user=".$config['SQL_user']
|
||||||
." password=".$config['SQL_pass'];
|
." password=".$config['SQL_pass'];
|
||||||
|
|
||||||
|
// Connexion et gestion d'erreurs.
|
||||||
$con = pg_connect($connection);
|
$con = pg_connect($connection);
|
||||||
if (!$con) {
|
if (!$con) {
|
||||||
$error = error_get_last();
|
$error = error_get_last();
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Génère une miniature d'image en recadrant la source au format demandé.
|
||||||
|
*/
|
||||||
function generate_image_thumbnail($source_image_path, $thumbnail_image_path, $width, $height)
|
function generate_image_thumbnail($source_image_path, $thumbnail_image_path, $width, $height)
|
||||||
{
|
{
|
||||||
|
// Récupère les informations de l'image source.
|
||||||
list($source_image_width, $source_image_height, $source_image_type) = getimagesize($source_image_path);
|
list($source_image_width, $source_image_height, $source_image_type) = getimagesize($source_image_path);
|
||||||
switch ($source_image_type) {
|
switch ($source_image_type) {
|
||||||
case IMAGETYPE_GIF:
|
case IMAGETYPE_GIF:
|
||||||
@@ -18,6 +22,7 @@ function generate_image_thumbnail($source_image_path, $thumbnail_image_path, $wi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calcul des offsets pour conserver le ratio et recadrer.
|
||||||
$src_x = 0;
|
$src_x = 0;
|
||||||
$src_y = 0;
|
$src_y = 0;
|
||||||
$thumbnail_image_height = $height;
|
$thumbnail_image_height = $height;
|
||||||
@@ -31,6 +36,7 @@ function generate_image_thumbnail($source_image_path, $thumbnail_image_path, $wi
|
|||||||
$source_image_height = (int)($source_image_width * $height / $width);
|
$source_image_height = (int)($source_image_width * $height / $width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Génération du thumbnail et sauvegarde au format JPEG.
|
||||||
$thumbnail_gd_image = imagecreatetruecolor($thumbnail_image_width, $thumbnail_image_height);
|
$thumbnail_gd_image = imagecreatetruecolor($thumbnail_image_width, $thumbnail_image_height);
|
||||||
imagecopyresampled($thumbnail_gd_image, $source_gd_image, 0, 0, $src_x, $src_y, $thumbnail_image_width, $thumbnail_image_height, $source_image_width, $source_image_height);
|
imagecopyresampled($thumbnail_gd_image, $source_gd_image, 0, 0, $src_x, $src_y, $thumbnail_image_width, $thumbnail_image_height, $source_image_width, $source_image_height);
|
||||||
imagejpeg($thumbnail_gd_image, $thumbnail_image_path, 90);
|
imagejpeg($thumbnail_gd_image, $thumbnail_image_path, 90);
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Catalogue des types de points d'intérêt (POI) et leurs champs de saisie.
|
||||||
|
*/
|
||||||
$poi_types = array(
|
$poi_types = array(
|
||||||
|
|
||||||
"basic_hut" => array("Abri sommaire", "Abri", "#ef2929", "basic_hut",
|
"basic_hut" => array("Abri sommaire", "Abri", "#ef2929", "basic_hut",
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
** This file contains the routing from any request to the correct view and controller
|
** This file contains the routing from any request to the correct view and controller
|
||||||
*****/
|
*****/
|
||||||
|
|
||||||
|
// Objets pour partager les informations de routeur avec les contrôleurs et vues.
|
||||||
$controller = new stdClass;
|
$controller = new stdClass;
|
||||||
$view = new stdClass;
|
$view = new stdClass;
|
||||||
|
|
||||||
|
// URL complète demandée par le client.
|
||||||
$controller->full_url = $_SERVER['REQUEST_URI'];
|
$controller->full_url = $_SERVER['REQUEST_URI'];
|
||||||
$controller->url_no_param = explode('?',$controller->full_url);
|
$controller->url_no_param = explode('?',$controller->full_url);
|
||||||
|
|
||||||
@@ -17,9 +19,11 @@ $controller->splitted_url = explode ('/',$controller->base_url);
|
|||||||
// By default we use the desktop
|
// By default we use the desktop
|
||||||
$view->prefix = "d.";
|
$view->prefix = "d.";
|
||||||
$controller->prefix = "d.";
|
$controller->prefix = "d.";
|
||||||
|
// Flags de gestion d'erreurs et de session.
|
||||||
$notfound = 0;
|
$notfound = 0;
|
||||||
$session = 1;
|
$session = 1;
|
||||||
|
|
||||||
|
// La racine du site redirige vers la page d'accueil.
|
||||||
if($controller->splitted_url[0]=="") $controller->splitted_url[0]="index";
|
if($controller->splitted_url[0]=="") $controller->splitted_url[0]="index";
|
||||||
|
|
||||||
// Routing to the correct page from the correct link
|
// Routing to the correct page from the correct link
|
||||||
@@ -46,20 +50,24 @@ switch ($controller->splitted_url[0])
|
|||||||
default :
|
default :
|
||||||
$controller->name="";
|
$controller->name="";
|
||||||
$view->name="";
|
$view->name="";
|
||||||
$notfound = 1;
|
$notfound = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialisation de la session utilisateur.
|
||||||
if($session==1) {
|
if($session==1) {
|
||||||
require_once($config['includes_folder']."session.php");
|
require_once($config['includes_folder']."session.php");
|
||||||
}
|
}
|
||||||
|
// Exécution du contrôleur correspondant si défini.
|
||||||
if($controller->name != "") {
|
if($controller->name != "") {
|
||||||
include ($config['controllers_folder'].$controller->prefix.$controller->name.".php");
|
include ($config['controllers_folder'].$controller->prefix.$controller->name.".php");
|
||||||
}
|
}
|
||||||
|
// Affichage de la vue statique si définie.
|
||||||
if($view->name != "") {
|
if($view->name != "") {
|
||||||
include ($config['views_folder'].$view->prefix.$view->name.".html");
|
include ($config['views_folder'].$view->prefix.$view->name.".html");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rendu de la page 404 via le wiki si aucune route n'a correspondu.
|
||||||
if($notfound) {
|
if($notfound) {
|
||||||
require_once($config['includes_folder']."session.php");
|
require_once($config['includes_folder']."session.php");
|
||||||
require_once($config['models_folder']."d.wiki.php");
|
require_once($config['models_folder']."d.wiki.php");
|
||||||
|
|||||||
@@ -1,19 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise la session et charge l'utilisateur courant.
|
||||||
|
*/
|
||||||
|
|
||||||
require_once($config['models_folder']."d.users.php");
|
require_once($config['models_folder']."d.users.php");
|
||||||
|
|
||||||
ini_set("session.cookie_lifetime",60*60*24*30);
|
ini_set("session.cookie_lifetime",60*60*24*30);
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
// Utilisateur courant (visiteur par défaut).
|
||||||
$user = new Kabano\User();
|
$user = new Kabano\User();
|
||||||
|
|
||||||
if(isset($_SESSION['userid'])) {
|
if(isset($_SESSION['userid'])) {
|
||||||
if ($user->checkID($_SESSION['userid'])) {
|
if ($user->checkID($_SESSION['userid'])) {
|
||||||
|
// Mise à jour de la date de connexion et des préférences.
|
||||||
$user->updateLoginDate();
|
$user->updateLoginDate();
|
||||||
$config['locale'] = $user->locale;
|
$config['locale'] = $user->locale;
|
||||||
$config['timezone'] = $user->timezone;
|
$config['timezone'] = $user->timezone;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Réinitialisation si la session est invalide.
|
||||||
session_destroy();
|
session_destroy();
|
||||||
$config['locale'] = "fr_FR";
|
$config['locale'] = "fr_FR";
|
||||||
$config['timezone'] = "Europe/Paris";
|
$config['timezone'] = "Europe/Paris";
|
||||||
@@ -21,11 +28,13 @@ if(isset($_SESSION['userid'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Configuration par défaut pour les visiteurs.
|
||||||
$config['locale'] = "fr_FR";
|
$config['locale'] = "fr_FR";
|
||||||
$config['timezone'] = "Europe/Paris";
|
$config['timezone'] = "Europe/Paris";
|
||||||
$user->rank = "visitor"; // All users are visitors
|
$user->rank = "visitor"; // All users are visitors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Formatage des dates selon la version PHP.
|
||||||
if (PHP_VERSION_ID < 80000) {
|
if (PHP_VERSION_ID < 80000) {
|
||||||
$user->date_format = new IntlDateFormatter($config['locale'], IntlDateFormatter::LONG, IntlDateFormatter::NONE, $config['timezone']);
|
$user->date_format = new IntlDateFormatter($config['locale'], IntlDateFormatter::LONG, IntlDateFormatter::NONE, $config['timezone']);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace Kabano;
|
|||||||
require_once($config['third_folder']."Md/MarkdownExtra.inc.php");
|
require_once($config['third_folder']."Md/MarkdownExtra.inc.php");
|
||||||
require_once($config['includes_folder']."database.php");
|
require_once($config['includes_folder']."database.php");
|
||||||
|
|
||||||
|
// Objet représentant un article de blog.
|
||||||
class BlogArticle
|
class BlogArticle
|
||||||
{
|
{
|
||||||
public $content_id = NULL;
|
public $content_id = NULL;
|
||||||
@@ -39,6 +40,7 @@ class BlogArticle
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Le contenu est stocké comme {"text": "..."} en base.
|
||||||
$decoded = json_decode($value, true);
|
$decoded = json_decode($value, true);
|
||||||
if (!is_array($decoded)) {
|
if (!is_array($decoded)) {
|
||||||
return '';
|
return '';
|
||||||
@@ -53,6 +55,7 @@ class BlogArticle
|
|||||||
public function checkPermalink($permalink, $withArchive=0, $elementNb=0) {
|
public function checkPermalink($permalink, $withArchive=0, $elementNb=0) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Recherche de la dernière version publiée.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='blog'";
|
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='blog'";
|
||||||
@@ -145,6 +148,7 @@ class BlogArticle
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Protection contre l'édition sans identifiants valides.
|
||||||
if($this->content_id == 0 || $this->locale_id == 0 || $this->version_id == 0)
|
if($this->content_id == 0 || $this->locale_id == 0 || $this->version_id == 0)
|
||||||
die("Cannot update entry without giving ID");
|
die("Cannot update entry without giving ID");
|
||||||
|
|
||||||
@@ -173,6 +177,7 @@ class BlogArticle
|
|||||||
|
|
||||||
$this->version_id = pg_fetch_assoc($result)['id'];
|
$this->version_id = pg_fetch_assoc($result)['id'];
|
||||||
|
|
||||||
|
// Association de l'auteur comme contributeur.
|
||||||
$query = "INSERT INTO content_contributors (content, contributor) VALUES
|
$query = "INSERT INTO content_contributors (content, contributor) VALUES
|
||||||
($1, $2) ON CONFLICT (content, contributor) DO NOTHING";
|
($1, $2) ON CONFLICT (content, contributor) DO NOTHING";
|
||||||
|
|
||||||
@@ -181,6 +186,7 @@ class BlogArticle
|
|||||||
$result = pg_execute($con, "prepare3", array($this->locale_id, $user->id))
|
$result = pg_execute($con, "prepare3", array($this->locale_id, $user->id))
|
||||||
or die ("Cannot execute statement\n");
|
or die ("Cannot execute statement\n");
|
||||||
|
|
||||||
|
// Mise à jour du flag de commentaires.
|
||||||
$query = "UPDATE contents SET is_commentable = $1 WHERE id = $2";
|
$query = "UPDATE contents SET is_commentable = $1 WHERE id = $2";
|
||||||
pg_prepare($con, "prepare4", $query)
|
pg_prepare($con, "prepare4", $query)
|
||||||
or die ("Cannot prepare statement\n");
|
or die ("Cannot prepare statement\n");
|
||||||
@@ -252,6 +258,7 @@ class BlogArticle
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Création d'un article publié par défaut.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
pg_query($con, "BEGIN");
|
pg_query($con, "BEGIN");
|
||||||
@@ -288,6 +295,7 @@ class BlogArticle
|
|||||||
|
|
||||||
$this->version_id = pg_fetch_assoc($result)['id'];
|
$this->version_id = pg_fetch_assoc($result)['id'];
|
||||||
|
|
||||||
|
// Ajout du contributeur.
|
||||||
$query = "INSERT INTO content_contributors (content, contributor) VALUES
|
$query = "INSERT INTO content_contributors (content, contributor) VALUES
|
||||||
($1, $2)";
|
($1, $2)";
|
||||||
|
|
||||||
@@ -310,6 +318,7 @@ class BlogArticle
|
|||||||
** Converts the Markdown content to HTML
|
** Converts the Markdown content to HTML
|
||||||
*****/
|
*****/
|
||||||
public function md2html() {
|
public function md2html() {
|
||||||
|
// Transforme le contenu Markdown en HTML.
|
||||||
$this->content_html = \Michelf\MarkdownExtra::defaultTransform($this->content);
|
$this->content_html = \Michelf\MarkdownExtra::defaultTransform($this->content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,6 +326,7 @@ class BlogArticle
|
|||||||
** Converts the Markdown content to text
|
** Converts the Markdown content to text
|
||||||
*****/
|
*****/
|
||||||
public function md2txt() {
|
public function md2txt() {
|
||||||
|
// Transforme le contenu Markdown en texte brut.
|
||||||
$this->md2html();
|
$this->md2html();
|
||||||
$this->content_txt = strip_tags($this->content_html);
|
$this->content_txt = strip_tags($this->content_html);
|
||||||
}
|
}
|
||||||
@@ -331,6 +341,7 @@ class BlogArticle
|
|||||||
***********************************************************
|
***********************************************************
|
||||||
**********************************************************/
|
**********************************************************/
|
||||||
|
|
||||||
|
// Liste paginée des articles de blog.
|
||||||
class BlogArticles
|
class BlogArticles
|
||||||
{
|
{
|
||||||
public $objs = array();
|
public $objs = array();
|
||||||
@@ -342,6 +353,7 @@ class BlogArticles
|
|||||||
public function listArticles($first, $count, $archive=0) {
|
public function listArticles($first, $count, $archive=0) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Récupère les versions non archivées.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE is_archive=FALSE ";
|
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE is_archive=FALSE ";
|
||||||
@@ -370,6 +382,7 @@ class BlogArticles
|
|||||||
public function number($archive=0) {
|
public function number($archive=0) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Compte le nombre d'articles.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE is_archive=FALSE ";
|
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE is_archive=FALSE ";
|
||||||
@@ -393,6 +406,7 @@ class BlogArticles
|
|||||||
public function getHistory($url) {
|
public function getHistory($url) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Récupère l'historique des versions d'un article.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='blog' ORDER BY update_date DESC";
|
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='blog' ORDER BY update_date DESC";
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace Kabano;
|
|||||||
require_once($config['third_folder']."Md/MarkdownExtra.inc.php");
|
require_once($config['third_folder']."Md/MarkdownExtra.inc.php");
|
||||||
require_once($config['includes_folder']."database.php");
|
require_once($config['includes_folder']."database.php");
|
||||||
|
|
||||||
|
// Objet représentant un commentaire sur un contenu.
|
||||||
class Comment
|
class Comment
|
||||||
{
|
{
|
||||||
public $id = NULL;
|
public $id = NULL;
|
||||||
@@ -35,6 +36,7 @@ class Comment
|
|||||||
public function checkID($id) {
|
public function checkID($id) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Chargement du commentaire par ID.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT * FROM content_comments WHERE id=$1";
|
$query = "SELECT * FROM content_comments WHERE id=$1";
|
||||||
@@ -64,6 +66,7 @@ class Comment
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mapping des champs SQL vers les propriétés.
|
||||||
if (array_key_exists('id', $row)) {
|
if (array_key_exists('id', $row)) {
|
||||||
$this->id = $row['id'];
|
$this->id = $row['id'];
|
||||||
}
|
}
|
||||||
@@ -102,6 +105,7 @@ class Comment
|
|||||||
public function insert() {
|
public function insert() {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Insertion d'un nouveau commentaire.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "INSERT INTO content_comments (version, creation_date, update_date, author, is_public, is_archive, content, comment, locale) VALUES
|
$query = "INSERT INTO content_comments (version, creation_date, update_date, author, is_public, is_archive, content, comment, locale) VALUES
|
||||||
@@ -124,6 +128,7 @@ class Comment
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Archivage logique du commentaire.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "UPDATE content_comments SET is_public = FALSE WHERE id = $1";
|
$query = "UPDATE content_comments SET is_public = FALSE WHERE id = $1";
|
||||||
@@ -148,6 +153,7 @@ class Comment
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Restauration d'un commentaire archivé.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "UPDATE content_comments SET is_public = TRUE WHERE id = $1";
|
$query = "UPDATE content_comments SET is_public = TRUE WHERE id = $1";
|
||||||
@@ -169,6 +175,7 @@ class Comment
|
|||||||
** Converts the Markdown comment to HTML
|
** Converts the Markdown comment to HTML
|
||||||
*****/
|
*****/
|
||||||
public function md2html() {
|
public function md2html() {
|
||||||
|
// Conversion Markdown -> HTML.
|
||||||
$this->comment_html = \Michelf\MarkdownExtra::defaultTransform($this->comment);
|
$this->comment_html = \Michelf\MarkdownExtra::defaultTransform($this->comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,6 +183,7 @@ class Comment
|
|||||||
** Converts the Markdown comment to text
|
** Converts the Markdown comment to text
|
||||||
*****/
|
*****/
|
||||||
public function md2txt() {
|
public function md2txt() {
|
||||||
|
// Conversion Markdown -> texte brut.
|
||||||
$this->md2html();
|
$this->md2html();
|
||||||
$this->comment_txt = strip_tags($this->comment_html);
|
$this->comment_txt = strip_tags($this->comment_html);
|
||||||
}
|
}
|
||||||
@@ -190,11 +198,13 @@ class Comment
|
|||||||
***********************************************************
|
***********************************************************
|
||||||
**********************************************************/
|
**********************************************************/
|
||||||
|
|
||||||
|
// Liste de commentaires liée à un contenu.
|
||||||
class Comments
|
class Comments
|
||||||
{
|
{
|
||||||
public $objs = array();
|
public $objs = array();
|
||||||
public $number = NULL;
|
public $number = NULL;
|
||||||
|
|
||||||
|
// Retourne la liste des commentaires pour un contenu.
|
||||||
/*****
|
/*****
|
||||||
** Return the list of different articles
|
** Return the list of different articles
|
||||||
*****/
|
*****/
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace Kabano;
|
|||||||
|
|
||||||
require_once($config['includes_folder']."database.php");
|
require_once($config['includes_folder']."database.php");
|
||||||
|
|
||||||
|
// Objet représentant une locale (langue).
|
||||||
class Locale
|
class Locale
|
||||||
{
|
{
|
||||||
public $name = 0;
|
public $name = 0;
|
||||||
@@ -24,6 +25,7 @@ class Locale
|
|||||||
public function checkName($name) {
|
public function checkName($name) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Chargement de la locale par son code.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT * FROM locales WHERE name=$1";
|
$query = "SELECT * FROM locales WHERE name=$1";
|
||||||
@@ -53,6 +55,7 @@ class Locale
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mapping des champs SQL.
|
||||||
if (array_key_exists('name', $row)) {
|
if (array_key_exists('name', $row)) {
|
||||||
$this->name = $row['name'];
|
$this->name = $row['name'];
|
||||||
}
|
}
|
||||||
@@ -78,12 +81,14 @@ class Locales
|
|||||||
public $number = 0;
|
public $number = 0;
|
||||||
public $objs = array();
|
public $objs = array();
|
||||||
|
|
||||||
|
// Charge toutes les locales disponibles.
|
||||||
/*****
|
/*****
|
||||||
** Get all locales
|
** Get all locales
|
||||||
*****/
|
*****/
|
||||||
public function getAll() {
|
public function getAll() {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Récupère la liste complète des locales.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT * FROM locales";
|
$query = "SELECT * FROM locales";
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ require_once($config['third_folder']."Md/MarkdownExtra.inc.php");
|
|||||||
require_once($config['includes_folder']."poi_types.struct.php");
|
require_once($config['includes_folder']."poi_types.struct.php");
|
||||||
require_once($config['includes_folder']."database.php");
|
require_once($config['includes_folder']."database.php");
|
||||||
|
|
||||||
|
// Objet représentant un point d'intérêt.
|
||||||
class Poi
|
class Poi
|
||||||
{
|
{
|
||||||
public $content_id = NULL;
|
public $content_id = NULL;
|
||||||
@@ -46,6 +47,7 @@ class Poi
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Les paramètres sont stockés en JSON.
|
||||||
$decoded = json_decode($value, true);
|
$decoded = json_decode($value, true);
|
||||||
if (!is_array($decoded)) {
|
if (!is_array($decoded)) {
|
||||||
return [];
|
return [];
|
||||||
@@ -60,6 +62,7 @@ class Poi
|
|||||||
public function checkPermalink($permalink, $withArchive=0, $elementNb=0) {
|
public function checkPermalink($permalink, $withArchive=0, $elementNb=0) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Récupère la dernière version du POI.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT
|
$query = "SELECT
|
||||||
@@ -134,6 +137,7 @@ class Poi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Décode les paramètres JSON et mappe les champs.
|
||||||
$decodedParameters = null;
|
$decodedParameters = null;
|
||||||
if (array_key_exists('parameters', $row)) {
|
if (array_key_exists('parameters', $row)) {
|
||||||
$decodedParameters = $this->decodeJsonArray($row['parameters']);
|
$decodedParameters = $this->decodeJsonArray($row['parameters']);
|
||||||
@@ -214,6 +218,7 @@ class Poi
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Création d'un nouveau POI.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
pg_query($con, "BEGIN");
|
pg_query($con, "BEGIN");
|
||||||
@@ -282,6 +287,7 @@ class Poi
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Vérifie que les identifiants sont chargés.
|
||||||
if ($this->content_id == 0 || $this->locale_id == 0 || $this->version_id == 0)
|
if ($this->content_id == 0 || $this->locale_id == 0 || $this->version_id == 0)
|
||||||
die("Cannot update entry without giving ID");
|
die("Cannot update entry without giving ID");
|
||||||
|
|
||||||
@@ -342,6 +348,7 @@ class Poi
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Archivage logique du POI.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "UPDATE contents SET is_public = FALSE WHERE id = $1";
|
$query = "UPDATE contents SET is_public = FALSE WHERE id = $1";
|
||||||
@@ -365,6 +372,7 @@ class Poi
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Restauration d'un POI archivé.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "UPDATE contents SET is_public = TRUE WHERE id = $1";
|
$query = "UPDATE contents SET is_public = TRUE WHERE id = $1";
|
||||||
@@ -382,14 +390,17 @@ class Poi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Liste de points d'intérêt (POI).
|
||||||
class Pois
|
class Pois
|
||||||
{
|
{
|
||||||
public $objs = [];
|
public $objs = [];
|
||||||
public $number = 0;
|
public $number = 0;
|
||||||
|
|
||||||
|
// Liste des POIs publiés (ou archivés si demandé).
|
||||||
public function listPois($archive=0) {
|
public function listPois($archive=0) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Chargement des POIs avec leurs versions actives.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT
|
$query = "SELECT
|
||||||
@@ -453,6 +464,7 @@ class Pois
|
|||||||
public function getHistory($permalink) {
|
public function getHistory($permalink) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Historique des versions d'un POI.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT
|
$query = "SELECT
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ $ranks = array(
|
|||||||
"visitor" => array(0,"Visiteur", "black", "visitor")
|
"visitor" => array(0,"Visiteur", "black", "visitor")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Objet représentant un utilisateur.
|
||||||
class User
|
class User
|
||||||
{
|
{
|
||||||
public $id = 0;
|
public $id = 0;
|
||||||
@@ -52,6 +53,7 @@ class User
|
|||||||
public function checkID($id) {
|
public function checkID($id) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Recherche de l'utilisateur par identifiant.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT * FROM users WHERE id=$1";
|
$query = "SELECT * FROM users WHERE id=$1";
|
||||||
@@ -79,6 +81,7 @@ class User
|
|||||||
public function login($login, $pass) {
|
public function login($login, $pass) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Connexion à partir du nom et du mot de passe.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT * FROM users WHERE name=$1 AND password=$2";
|
$query = "SELECT * FROM users WHERE name=$1 AND password=$2";
|
||||||
@@ -105,6 +108,7 @@ class User
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mapping des champs SQL vers les propriétés.
|
||||||
if (array_key_exists('id', $row)) {
|
if (array_key_exists('id', $row)) {
|
||||||
$this->id = $row['id'];
|
$this->id = $row['id'];
|
||||||
}
|
}
|
||||||
@@ -152,6 +156,7 @@ class User
|
|||||||
public function get_rank() {
|
public function get_rank() {
|
||||||
global $ranks;
|
global $ranks;
|
||||||
|
|
||||||
|
// Renvoie l'affichage HTML du rang.
|
||||||
return '<span class="userrole" style="color: '.$ranks[$this->rank][2].';">'.$ranks[$this->rank][1].'</span>';
|
return '<span class="userrole" style="color: '.$ranks[$this->rank][2].';">'.$ranks[$this->rank][1].'</span>';
|
||||||
}
|
}
|
||||||
public function get_locale() {
|
public function get_locale() {
|
||||||
@@ -174,6 +179,7 @@ class User
|
|||||||
public function rankIsHigher($rank) {
|
public function rankIsHigher($rank) {
|
||||||
global $ranks;
|
global $ranks;
|
||||||
|
|
||||||
|
// Compare le niveau de rang.
|
||||||
return $ranks[$this->rank][0] >= $ranks[$rank][0];
|
return $ranks[$this->rank][0] >= $ranks[$rank][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +189,7 @@ class User
|
|||||||
public function availableName() {
|
public function availableName() {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Vérifie l'unicité du pseudo.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT * FROM users WHERE lower(name)=$1";
|
$query = "SELECT * FROM users WHERE lower(name)=$1";
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace Kabano;
|
|||||||
require_once($config['third_folder']."Md/MarkdownExtra.inc.php");
|
require_once($config['third_folder']."Md/MarkdownExtra.inc.php");
|
||||||
require_once($config['includes_folder']."database.php");
|
require_once($config['includes_folder']."database.php");
|
||||||
|
|
||||||
|
// Objet représentant une page wiki.
|
||||||
class WikiPage
|
class WikiPage
|
||||||
{
|
{
|
||||||
public $content_id = NULL;
|
public $content_id = NULL;
|
||||||
@@ -38,6 +39,7 @@ class WikiPage
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Contenu stocké sous la forme {"text": "..."}.
|
||||||
$decoded = json_decode($value, true);
|
$decoded = json_decode($value, true);
|
||||||
if (!is_array($decoded)) {
|
if (!is_array($decoded)) {
|
||||||
return '';
|
return '';
|
||||||
@@ -52,6 +54,7 @@ class WikiPage
|
|||||||
public function checkPermalink($permalink, $withArchive=0, $elementNb=0) {
|
public function checkPermalink($permalink, $withArchive=0, $elementNb=0) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Récupère la dernière version de la page.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='wiki'";
|
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='wiki'";
|
||||||
@@ -85,6 +88,7 @@ class WikiPage
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mapping des champs SQL vers les propriétés.
|
||||||
$decodedContent = null;
|
$decodedContent = null;
|
||||||
if (array_key_exists('content', $row)) {
|
if (array_key_exists('content', $row)) {
|
||||||
$decodedContent = $this->decodeJsonText($row['content']);
|
$decodedContent = $this->decodeJsonText($row['content']);
|
||||||
@@ -144,6 +148,7 @@ class WikiPage
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Protection contre les mises à jour sans IDs.
|
||||||
if($this->content_id == 0 || $this->locale_id == 0 || $this->version_id == 0)
|
if($this->content_id == 0 || $this->locale_id == 0 || $this->version_id == 0)
|
||||||
die("Cannot update entry without giving ID");
|
die("Cannot update entry without giving ID");
|
||||||
|
|
||||||
@@ -172,6 +177,7 @@ class WikiPage
|
|||||||
|
|
||||||
$this->version_id = pg_fetch_assoc($result)['id'];
|
$this->version_id = pg_fetch_assoc($result)['id'];
|
||||||
|
|
||||||
|
// Ajout du contributeur si absent.
|
||||||
$query = "INSERT INTO content_contributors (content, contributor) VALUES
|
$query = "INSERT INTO content_contributors (content, contributor) VALUES
|
||||||
($1, $2) ON CONFLICT (content, contributor) DO NOTHING";
|
($1, $2) ON CONFLICT (content, contributor) DO NOTHING";
|
||||||
|
|
||||||
@@ -197,6 +203,7 @@ class WikiPage
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Archivage logique de la page.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "UPDATE contents SET is_public=FALSE WHERE permalink=$1 AND type='wiki'";
|
$query = "UPDATE contents SET is_public=FALSE WHERE permalink=$1 AND type='wiki'";
|
||||||
@@ -221,6 +228,7 @@ class WikiPage
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Restauration d'une page archivée.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
$query = "UPDATE contents SET is_public=TRUE WHERE permalink=$1 AND type='wiki'";
|
$query = "UPDATE contents SET is_public=TRUE WHERE permalink=$1 AND type='wiki'";
|
||||||
@@ -245,6 +253,7 @@ class WikiPage
|
|||||||
global $config;
|
global $config;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
// Création d'une nouvelle page wiki.
|
||||||
$con = sql_connect();
|
$con = sql_connect();
|
||||||
|
|
||||||
pg_query($con, "BEGIN");
|
pg_query($con, "BEGIN");
|
||||||
@@ -303,6 +312,7 @@ class WikiPage
|
|||||||
** Converts the Markdown content to HTML
|
** Converts the Markdown content to HTML
|
||||||
*****/
|
*****/
|
||||||
public function md2html() {
|
public function md2html() {
|
||||||
|
// Conversion Markdown -> HTML.
|
||||||
$this->content_html = \Michelf\MarkdownExtra::defaultTransform($this->content);
|
$this->content_html = \Michelf\MarkdownExtra::defaultTransform($this->content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,11 +325,13 @@ class WikiPage
|
|||||||
***********************************************************
|
***********************************************************
|
||||||
**********************************************************/
|
**********************************************************/
|
||||||
|
|
||||||
|
// Liste de pages wiki.
|
||||||
class WikiPages
|
class WikiPages
|
||||||
{
|
{
|
||||||
public $objs = array();
|
public $objs = array();
|
||||||
public $number = NULL;
|
public $number = NULL;
|
||||||
|
|
||||||
|
// Historique des versions d'une page.
|
||||||
/*****
|
/*****
|
||||||
** Checks if a page at this URL exists and return the ID
|
** Checks if a page at this URL exists and return the ID
|
||||||
*****/
|
*****/
|
||||||
|
|||||||
Reference in New Issue
Block a user