2018-04-02 08:29:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2020-02-10 16:42:02 +01:00
|
|
|
* This file is part of Zwii. *
|
2018-04-02 08:29:19 +02:00
|
|
|
* For full copyright and license information, please see the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* @author Rémi Jean <remi.jean@outlook.com>
|
|
|
|
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
|
|
|
* @license GNU General Public License, version 3
|
2019-01-22 21:56:38 +01:00
|
|
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
2020-01-21 08:53:30 +01:00
|
|
|
* @copyright Copyright (C) 2018-2020, Frédéric Tempez
|
2018-04-02 08:29:19 +02:00
|
|
|
* @link http://zwiicms.com/
|
|
|
|
*/
|
|
|
|
|
|
|
|
class common {
|
|
|
|
|
|
|
|
const DISPLAY_RAW = 0;
|
|
|
|
const DISPLAY_JSON = 1;
|
|
|
|
const DISPLAY_LAYOUT_BLANK = 2;
|
|
|
|
const DISPLAY_LAYOUT_MAIN = 3;
|
|
|
|
const DISPLAY_LAYOUT_LIGHT = 4;
|
|
|
|
const GROUP_BANNED = -1;
|
|
|
|
const GROUP_VISITOR = 0;
|
|
|
|
const GROUP_MEMBER = 1;
|
|
|
|
const GROUP_MODERATOR = 2;
|
|
|
|
const GROUP_ADMIN = 3;
|
2019-08-15 19:44:53 +02:00
|
|
|
// Dossier de travail
|
2019-05-28 09:04:10 +02:00
|
|
|
const BACKUP_DIR = 'site/backup/';
|
|
|
|
const DATA_DIR = 'site/data/';
|
|
|
|
const FILE_DIR = 'site/file/';
|
|
|
|
const TEMP_DIR = 'site/tmp/';
|
2019-03-22 19:04:51 +01:00
|
|
|
|
2020-06-02 18:49:24 +02:00
|
|
|
// Miniatures de la galerie
|
2020-04-06 09:41:02 +02:00
|
|
|
const THUMBS_SEPARATOR = 'mini_';
|
2020-04-15 17:26:26 +02:00
|
|
|
const THUMBS_WIDTH = 640;
|
2020-04-06 09:41:02 +02:00
|
|
|
|
2020-05-28 19:03:31 +02:00
|
|
|
// Contrôle d'édition temps max en secondes avant déconnexion 30 minutes
|
2020-05-28 15:19:32 +02:00
|
|
|
const ACCESS_TIMER = 1800;
|
2020-05-28 09:28:10 +02:00
|
|
|
|
2020-05-24 19:59:21 +02:00
|
|
|
// Numéro de version
|
2020-08-21 18:35:07 +02:00
|
|
|
const ZWII_VERSION = '10.2.07';
|
2020-02-23 17:44:44 +01:00
|
|
|
const ZWII_UPDATE_CHANNEL = "v10";
|
2020-02-17 18:20:44 +01:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
public static $actions = [];
|
|
|
|
public static $coreModuleIds = [
|
|
|
|
'config',
|
|
|
|
'install',
|
|
|
|
'maintenance',
|
|
|
|
'page',
|
2019-07-04 12:38:23 +02:00
|
|
|
'search',
|
2018-04-02 08:29:19 +02:00
|
|
|
'sitemap',
|
|
|
|
'theme',
|
2019-07-04 12:38:23 +02:00
|
|
|
'user'
|
2018-04-02 08:29:19 +02:00
|
|
|
];
|
2019-12-10 10:53:31 +01:00
|
|
|
public static $dataStage = [
|
|
|
|
'config',
|
|
|
|
'core',
|
2020-05-24 19:59:21 +02:00
|
|
|
'module',
|
2019-12-10 10:53:31 +01:00
|
|
|
'page',
|
|
|
|
'user',
|
2020-05-15 17:36:55 +02:00
|
|
|
'theme',
|
|
|
|
'admin'
|
2019-12-10 10:53:31 +01:00
|
|
|
];
|
2020-05-24 19:59:21 +02:00
|
|
|
public static $accessList = [
|
|
|
|
'user',
|
|
|
|
'theme',
|
|
|
|
'config',
|
|
|
|
'edit',
|
|
|
|
'config'
|
|
|
|
];
|
2020-05-26 08:32:51 +02:00
|
|
|
public static $accessExclude = [
|
|
|
|
'login',
|
|
|
|
'logout'
|
|
|
|
];
|
2018-04-02 08:29:19 +02:00
|
|
|
private $data = [];
|
|
|
|
private $hierarchy = [
|
|
|
|
'all' => [],
|
2019-01-30 19:38:17 +01:00
|
|
|
'visible' => [],
|
|
|
|
'bar' => []
|
2018-04-02 08:29:19 +02:00
|
|
|
];
|
|
|
|
private $input = [
|
|
|
|
'_COOKIE' => [],
|
|
|
|
'_POST' => []
|
|
|
|
];
|
|
|
|
public static $inputBefore = [];
|
|
|
|
public static $inputNotices = [];
|
2019-12-10 10:53:31 +01:00
|
|
|
public static $importNotices = [];
|
|
|
|
public static $coreNotices = [];
|
2018-04-02 08:29:19 +02:00
|
|
|
public $output = [
|
|
|
|
'access' => true,
|
|
|
|
'content' => '',
|
2019-05-02 13:21:48 +02:00
|
|
|
'contentLeft' => '',
|
|
|
|
'contentRight' => '',
|
2018-04-02 08:29:19 +02:00
|
|
|
'display' => self::DISPLAY_LAYOUT_MAIN,
|
|
|
|
'metaDescription' => '',
|
|
|
|
'metaTitle' => '',
|
|
|
|
'notification' => '',
|
2020-05-24 19:59:21 +02:00
|
|
|
'redirect' => '',
|
2018-04-02 08:29:19 +02:00
|
|
|
'script' => '',
|
|
|
|
'showBarEditButton' => false,
|
|
|
|
'showPageContent' => false,
|
|
|
|
'state' => false,
|
|
|
|
'style' => '',
|
|
|
|
'title' => null, // Null car un titre peut être vide
|
|
|
|
// Trié par ordre d'exécution
|
|
|
|
'vendor' => [
|
|
|
|
'jquery',
|
|
|
|
'normalize',
|
|
|
|
'lity',
|
|
|
|
'filemanager',
|
2020-07-25 14:23:04 +02:00
|
|
|
//'flatpickr', Appelé par les modules désactivé par défaut
|
2018-04-02 08:29:19 +02:00
|
|
|
// 'tinycolorpicker', Désactivé par défaut
|
|
|
|
// 'tinymce', Désactivé par défaut
|
|
|
|
// 'codemirror', // Désactivé par défaut
|
|
|
|
'tippy',
|
2019-03-11 11:36:23 +01:00
|
|
|
'zwiico',
|
2019-03-21 11:18:45 +01:00
|
|
|
'imagemap',
|
2020-05-11 17:46:25 +02:00
|
|
|
'simplelightbox'
|
2018-04-02 08:29:19 +02:00
|
|
|
],
|
|
|
|
'view' => ''
|
|
|
|
];
|
|
|
|
public static $groups = [
|
|
|
|
self::GROUP_BANNED => 'Banni',
|
|
|
|
self::GROUP_VISITOR => 'Visiteur',
|
|
|
|
self::GROUP_MEMBER => 'Membre',
|
2019-01-11 19:42:35 +01:00
|
|
|
self::GROUP_MODERATOR => 'Éditeur',
|
2018-04-02 08:29:19 +02:00
|
|
|
self::GROUP_ADMIN => 'Administrateur'
|
|
|
|
];
|
|
|
|
public static $groupEdits = [
|
|
|
|
self::GROUP_BANNED => 'Banni',
|
|
|
|
self::GROUP_MEMBER => 'Membre',
|
2019-01-11 19:42:35 +01:00
|
|
|
self::GROUP_MODERATOR => 'Éditeur',
|
2018-04-02 08:29:19 +02:00
|
|
|
self::GROUP_ADMIN => 'Administrateur'
|
|
|
|
];
|
|
|
|
public static $groupNews = [
|
|
|
|
self::GROUP_MEMBER => 'Membre',
|
2019-01-11 19:42:35 +01:00
|
|
|
self::GROUP_MODERATOR => 'Éditeur',
|
2018-04-02 08:29:19 +02:00
|
|
|
self::GROUP_ADMIN => 'Administrateur'
|
|
|
|
];
|
|
|
|
public static $groupPublics = [
|
|
|
|
self::GROUP_VISITOR => 'Visiteur',
|
|
|
|
self::GROUP_MEMBER => 'Membre',
|
2019-01-11 19:42:35 +01:00
|
|
|
self::GROUP_MODERATOR => 'Éditeur',
|
2018-04-02 08:29:19 +02:00
|
|
|
self::GROUP_ADMIN => 'Administrateur'
|
|
|
|
];
|
|
|
|
public static $timezone;
|
|
|
|
private $url = '';
|
|
|
|
private $user = [];
|
2020-05-16 21:24:20 +02:00
|
|
|
private $page = '';
|
2018-04-02 08:29:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructeur commun
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
|
|
|
// Extraction des données http
|
|
|
|
if(isset($_POST)) {
|
|
|
|
$this->input['_POST'] = $_POST;
|
|
|
|
}
|
|
|
|
if(isset($_COOKIE)) {
|
|
|
|
$this->input['_COOKIE'] = $_COOKIE;
|
|
|
|
}
|
2019-01-24 20:44:53 +01:00
|
|
|
|
2020-05-24 19:59:21 +02:00
|
|
|
// Import version 9
|
|
|
|
if (file_exists(self::DATA_DIR . 'core.json') === true &&
|
|
|
|
$this->getData(['core','dataVersion']) < 10000) {
|
2019-12-17 16:04:40 +01:00
|
|
|
$keepUsers = isset($_SESSION['KEEP_USERS']) ? $_SESSION['KEEP_USERS'] : false;
|
|
|
|
$this->importData($keepUsers);
|
|
|
|
unset ($_SESSION['KEEP_USERS']);
|
2020-05-24 19:59:21 +02:00
|
|
|
// Réinstaller htaccess
|
|
|
|
copy('core/module/install/ressource/.htaccess', self::DATA_DIR . '.htaccess');
|
2019-12-10 10:53:31 +01:00
|
|
|
common::$importNotices [] = "Importation réalisée avec succès" ;
|
|
|
|
//echo '<script>window.location.replace("' . helper::baseUrl() . $this->getData(['config','homePageId']) . '")</script>';
|
2019-12-17 10:34:34 +01:00
|
|
|
}
|
2019-12-10 10:53:31 +01:00
|
|
|
// Installation fraîche, initialisation des modules manquants
|
|
|
|
// La langue d'installation par défaut est fr
|
|
|
|
foreach (self::$dataStage as $stageId) {
|
|
|
|
$folder = $this->dirData ($stageId, 'fr');
|
|
|
|
if (file_exists($folder . $stageId .'.json') === false) {
|
|
|
|
$this->initData($stageId,'fr');
|
|
|
|
common::$coreNotices [] = $stageId ;
|
|
|
|
}
|
2020-05-24 19:59:21 +02:00
|
|
|
}
|
2019-12-10 10:53:31 +01:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
// Utilisateur connecté
|
|
|
|
if($this->user === []) {
|
|
|
|
$this->user = $this->getData(['user', $this->getInput('ZWII_USER_ID')]);
|
|
|
|
}
|
2020-05-16 21:24:20 +02:00
|
|
|
|
2020-05-18 10:50:43 +02:00
|
|
|
// Mise en cache des pages
|
|
|
|
$this->page = $this->getPageCache();
|
2020-05-16 21:24:20 +02:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
// Construit la liste des pages parents/enfants
|
|
|
|
if($this->hierarchy['all'] === []) {
|
|
|
|
$pages = helper::arrayCollumn($this->getData(['page']), 'position', 'SORT_ASC');
|
|
|
|
// Parents
|
|
|
|
foreach($pages as $pageId => $pagePosition) {
|
|
|
|
if(
|
|
|
|
// Page parent
|
|
|
|
$this->getData(['page', $pageId, 'parentPageId']) === ""
|
|
|
|
// Ignore les pages dont l'utilisateur n'a pas accès
|
|
|
|
AND (
|
|
|
|
$this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR
|
|
|
|
OR (
|
|
|
|
$this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
|
|
|
|
AND $this->getUser('group') >= $this->getData(['page', $pageId, 'group'])
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
if($pagePosition !== 0) {
|
|
|
|
$this->hierarchy['visible'][$pageId] = [];
|
|
|
|
}
|
2019-01-30 19:38:17 +01:00
|
|
|
if($this->getData(['page', $pageId, 'block']) === 'bar') {
|
|
|
|
$this->hierarchy['bar'][$pageId] = [];
|
|
|
|
}
|
2018-04-02 08:29:19 +02:00
|
|
|
$this->hierarchy['all'][$pageId] = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Enfants
|
|
|
|
foreach($pages as $pageId => $pagePosition) {
|
|
|
|
if(
|
|
|
|
// Page parent
|
|
|
|
$parentId = $this->getData(['page', $pageId, 'parentPageId'])
|
|
|
|
// Ignore les pages dont l'utilisateur n'a pas accès
|
|
|
|
AND (
|
|
|
|
(
|
|
|
|
$this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR
|
|
|
|
AND $this->getData(['page', $parentId, 'group']) === self::GROUP_VISITOR
|
|
|
|
)
|
|
|
|
OR (
|
|
|
|
$this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
|
|
|
|
AND $this->getUser('group') >= $this->getData(['page', $parentId, 'group'])
|
|
|
|
AND $this->getUser('group') >= $this->getData(['page', $pageId, 'group'])
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
if($pagePosition !== 0) {
|
|
|
|
$this->hierarchy['visible'][$parentId][] = $pageId;
|
|
|
|
}
|
2019-01-30 19:38:17 +01:00
|
|
|
if($this->getData(['page', $pageId, 'block']) === 'bar') {
|
|
|
|
$this->hierarchy['bar'][$pageId] = [];
|
|
|
|
}
|
2018-04-02 08:29:19 +02:00
|
|
|
$this->hierarchy['all'][$parentId][] = $pageId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Construit l'url
|
|
|
|
if($this->url === '') {
|
|
|
|
if($url = $_SERVER['QUERY_STRING']) {
|
|
|
|
$this->url = $url;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->url = $this->getData(['config', 'homePageId']);
|
|
|
|
}
|
|
|
|
}
|
2019-11-04 21:27:04 +01:00
|
|
|
|
|
|
|
// Mise à jour des données core
|
|
|
|
$this->update();
|
2020-03-02 13:08:03 +01:00
|
|
|
|
|
|
|
// Données de proxy
|
|
|
|
$proxy = $this->getData(['config','proxyType']) . $this->getData(['config','proxyUrl']) . ':' . $this->getData(['config','proxyPort']);
|
|
|
|
if (!empty($this->getData(['config','proxyUrl'])) &&
|
|
|
|
!empty($this->getData(['config','proxyPort'])) ) {
|
|
|
|
$context = array(
|
|
|
|
'http' => array(
|
|
|
|
'proxy' => $proxy,
|
|
|
|
'request_fulluri' => true,
|
|
|
|
'verify_peer' => false,
|
|
|
|
'verify_peer_name' => false,
|
|
|
|
),
|
|
|
|
"ssl"=>array(
|
|
|
|
"verify_peer"=>false,
|
|
|
|
"verify_peer_name"=>false
|
|
|
|
)
|
|
|
|
);
|
|
|
|
stream_context_set_default($context);
|
2020-05-24 19:59:21 +02:00
|
|
|
}
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ajoute les valeurs en sortie
|
|
|
|
* @param array $output Valeurs en sortie
|
|
|
|
*/
|
|
|
|
public function addOutput($output) {
|
|
|
|
$this->output = array_merge($this->output, $output);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ajoute une notice de champ obligatoire
|
|
|
|
* @param string $key Clef du champ
|
|
|
|
*/
|
|
|
|
public function addRequiredInputNotices($key) {
|
|
|
|
// La clef est un tableau
|
|
|
|
if(preg_match('#\[(.*)\]#', $key, $secondKey)) {
|
|
|
|
$firstKey = explode('[', $key)[0];
|
|
|
|
$secondKey = $secondKey[1];
|
|
|
|
if(empty($this->input['_POST'][$firstKey][$secondKey])) {
|
|
|
|
common::$inputNotices[$firstKey . '_' . $secondKey] = 'Obligatoire';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// La clef est une chaine
|
|
|
|
elseif(empty($this->input['_POST'][$key])) {
|
|
|
|
common::$inputNotices[$key] = 'Obligatoire';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check du token CSRF (true = bo
|
|
|
|
*/
|
|
|
|
public function checkCSRF() {
|
|
|
|
return ((empty($_POST['csrf']) OR hash_equals($_SESSION['csrf'], $_POST['csrf']) === false) === false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Supprime des données
|
|
|
|
* @param array $keys Clé(s) des données
|
|
|
|
*/
|
2020-05-24 19:59:21 +02:00
|
|
|
public function deleteData($keys) {
|
2019-12-10 10:53:31 +01:00
|
|
|
//Retourne une chaine contenant le dossier à créer
|
|
|
|
$folder = $this->dirData ($keys[0],'fr');
|
|
|
|
// Constructeur JsonDB
|
2019-12-15 10:47:18 +01:00
|
|
|
//require_once "core/vendor/jsondb/Dot.php";
|
|
|
|
//require_once "core/vendor/jsondb/JsonDb.php";
|
2019-12-10 10:53:31 +01:00
|
|
|
$db = new \Prowebcraft\JsonDb([
|
|
|
|
'name' => $keys[0] . '.json',
|
|
|
|
'dir' => $folder,
|
|
|
|
'template' => self::TEMP_DIR . 'data.template.json'
|
|
|
|
]);
|
2018-04-02 08:29:19 +02:00
|
|
|
switch(count($keys)) {
|
2019-12-10 10:53:31 +01:00
|
|
|
case 1:
|
|
|
|
$db->delete($keys[0]);
|
|
|
|
$db->save();
|
2018-04-02 08:29:19 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2019-12-10 10:53:31 +01:00
|
|
|
$db->delete($keys[0].'.'.$keys[1]);
|
|
|
|
$db->save();
|
2018-04-02 08:29:19 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2019-12-10 10:53:31 +01:00
|
|
|
$db->delete($keys[0].'.'.$keys[1].'.'.$keys[2]);
|
2020-05-24 19:59:21 +02:00
|
|
|
$db->save();
|
2018-04-02 08:29:19 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2019-12-10 10:53:31 +01:00
|
|
|
$db->delete($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3]);
|
|
|
|
$db->save();
|
2018-04-02 08:29:19 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
2019-12-10 10:53:31 +01:00
|
|
|
$db->delete($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4]);
|
|
|
|
$db->save();
|
2018-04-02 08:29:19 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
2019-12-10 10:53:31 +01:00
|
|
|
$db->delete($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5]);
|
|
|
|
$db->save();
|
2018-04-02 08:29:19 +02:00
|
|
|
break;
|
|
|
|
case 7:
|
2019-12-10 10:53:31 +01:00
|
|
|
$db->delete($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5].'.'.$keys[6]);
|
|
|
|
$db->save();
|
2018-04-02 08:29:19 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accède aux données
|
|
|
|
* @param array $keys Clé(s) des données
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2019-12-11 11:59:10 +01:00
|
|
|
public function getData($keys = []) {
|
2020-05-24 19:59:21 +02:00
|
|
|
|
2019-12-10 10:53:31 +01:00
|
|
|
if (count($keys) >= 1) {
|
2020-05-16 21:24:20 +02:00
|
|
|
// Lecture d'une donnée de page en cache
|
|
|
|
if ($keys[0] === 'page') {
|
|
|
|
// Décent dans les niveaux de la variable $data
|
|
|
|
$data = $this->page;
|
|
|
|
foreach($keys as $key) {
|
|
|
|
// Si aucune donnée n'existe retourne null
|
|
|
|
if(isset($data[$key]) === false) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
// Sinon décent dans les niveaux
|
|
|
|
else {
|
|
|
|
$data = $data[$key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Retourne les données
|
|
|
|
return $data;
|
|
|
|
}
|
2019-12-10 10:53:31 +01:00
|
|
|
//Retourne une chaine contenant le dossier à créer
|
|
|
|
$folder = $this->dirData ($keys[0],'fr');
|
|
|
|
// Constructeur JsonDB
|
|
|
|
$db = new \Prowebcraft\JsonDb([
|
|
|
|
'name' => $keys[0] . '.json',
|
|
|
|
'dir' => $folder,
|
|
|
|
'template' => self::TEMP_DIR . 'data.template.json'
|
|
|
|
]);
|
|
|
|
switch(count($keys)) {
|
|
|
|
case 1:
|
|
|
|
$tempData = $db->get($keys[0]);
|
2020-05-24 19:59:21 +02:00
|
|
|
break;
|
2019-12-10 10:53:31 +01:00
|
|
|
case 2:
|
|
|
|
$tempData = $db->get($keys[0].'.'.$keys[1]);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
$tempData = $db->get($keys[0].'.'.$keys[1].'.'.$keys[2]);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
$tempData = $db->get($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3]);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
$tempData = $db->get($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4]);
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
$tempData = $db->get($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5]);
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
$tempData = $db->get($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5].'.'.$keys[6]);
|
|
|
|
break;
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
2019-12-10 10:53:31 +01:00
|
|
|
return $tempData;
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-16 21:24:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lecture des fichiers de données de page et mise ne cache
|
|
|
|
* @param @return string données des pages
|
|
|
|
*/
|
2020-05-18 10:50:43 +02:00
|
|
|
public function getPageCache() {
|
2020-05-16 21:24:20 +02:00
|
|
|
// Trois tentatives
|
|
|
|
for($i = 0; $i < 3; $i++) {
|
|
|
|
$data =json_decode(file_get_contents(self::DATA_DIR.'fr/page.json'), true);
|
|
|
|
if($data) {
|
|
|
|
return($data);
|
|
|
|
}
|
|
|
|
elseif($i === 2) {
|
2020-05-18 10:50:43 +02:00
|
|
|
exit('Erreur fatale : impossible d\'accéder aux pages');
|
2020-05-16 21:24:20 +02:00
|
|
|
}
|
|
|
|
// Pause de 10 millisecondes
|
|
|
|
usleep(10000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:10:04 +01:00
|
|
|
/*
|
|
|
|
* Dummy function
|
2020-02-18 11:18:27 +01:00
|
|
|
* Compatibilité des modules avec v8 et v9
|
2020-02-17 18:10:04 +01:00
|
|
|
*/
|
|
|
|
public function saveData() {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
/**
|
2019-02-10 13:07:43 +01:00
|
|
|
* Accède à la liste des pages parents et de leurs enfants
|
2018-04-02 08:29:19 +02:00
|
|
|
* @param int $parentId Id de la page parent
|
|
|
|
* @param bool $onlyVisible Affiche seulement les pages visibles
|
2019-02-10 13:07:43 +01:00
|
|
|
* @param bool $onlyBlock Affiche seulement les pages de type barre
|
2018-04-02 08:29:19 +02:00
|
|
|
* @return array
|
|
|
|
*/
|
2019-01-30 19:38:17 +01:00
|
|
|
public function getHierarchy($parentId = null, $onlyVisible = true, $onlyBlock = false) {
|
2018-04-02 08:29:19 +02:00
|
|
|
$hierarchy = $onlyVisible ? $this->hierarchy['visible'] : $this->hierarchy['all'];
|
2020-05-24 19:59:21 +02:00
|
|
|
$hierarchy = $onlyBlock ? $this->hierarchy['bar'] : $hierarchy;
|
2018-04-02 08:29:19 +02:00
|
|
|
// Enfants d'un parent
|
|
|
|
if($parentId) {
|
|
|
|
if(array_key_exists($parentId, $hierarchy)) {
|
|
|
|
return $hierarchy[$parentId];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Parents et leurs enfants
|
|
|
|
else {
|
|
|
|
return $hierarchy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accède à une valeur des variables http (ordre de recherche en l'absence de type : _COOKIE, _POST)
|
|
|
|
* @param string $key Clé de la valeur
|
|
|
|
* @param int $filter Filtre à appliquer à la valeur
|
|
|
|
* @param bool $required Champ requis
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getInput($key, $filter = helper::FILTER_STRING_SHORT, $required = false) {
|
|
|
|
// La clef est un tableau
|
|
|
|
if(preg_match('#\[(.*)\]#', $key, $secondKey)) {
|
|
|
|
$firstKey = explode('[', $key)[0];
|
|
|
|
$secondKey = $secondKey[1];
|
|
|
|
foreach($this->input as $type => $values) {
|
|
|
|
// Champ obligatoire
|
|
|
|
if($required) {
|
|
|
|
$this->addRequiredInputNotices($key);
|
|
|
|
}
|
|
|
|
// Check de l'existence
|
2020-06-02 18:49:24 +02:00
|
|
|
// Également utile pour les checkbox qui ne retournent rien lorsqu'elles ne sont pas cochées
|
2018-04-02 08:29:19 +02:00
|
|
|
if(
|
|
|
|
array_key_exists($firstKey, $values)
|
|
|
|
AND array_key_exists($secondKey, $values[$firstKey])
|
|
|
|
) {
|
|
|
|
// Retourne la valeur filtrée
|
|
|
|
if($filter) {
|
|
|
|
return helper::filter($this->input[$type][$firstKey][$secondKey], $filter);
|
|
|
|
}
|
|
|
|
// Retourne la valeur
|
|
|
|
else {
|
|
|
|
return $this->input[$type][$firstKey][$secondKey];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// La clef est une chaine
|
|
|
|
else {
|
|
|
|
foreach($this->input as $type => $values) {
|
2020-05-24 19:59:21 +02:00
|
|
|
// Champ obligatoire
|
2018-04-02 08:29:19 +02:00
|
|
|
if($required) {
|
|
|
|
$this->addRequiredInputNotices($key);
|
|
|
|
}
|
|
|
|
// Check de l'existence
|
2020-06-02 18:49:24 +02:00
|
|
|
// Également utile pour les checkbox qui ne retournent rien lorsqu'elles ne sont pas cochées
|
2018-04-02 08:29:19 +02:00
|
|
|
if(array_key_exists($key, $values)) {
|
|
|
|
// Retourne la valeur filtrée
|
|
|
|
if($filter) {
|
|
|
|
return helper::filter($this->input[$type][$key], $filter);
|
|
|
|
}
|
|
|
|
// Retourne la valeur
|
|
|
|
else {
|
|
|
|
return $this->input[$type][$key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Sinon retourne null
|
|
|
|
return helper::filter(null, $filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accède à une partie l'url ou à l'url complète
|
|
|
|
* @param int $key Clé de l'url
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getUrl($key = null) {
|
|
|
|
// Url complète
|
|
|
|
if($key === null) {
|
|
|
|
return $this->url;
|
|
|
|
}
|
|
|
|
// Une partie de l'url
|
|
|
|
else {
|
|
|
|
$url = explode('/', $this->url);
|
|
|
|
return array_key_exists($key, $url) ? $url[$key] : null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accède à l'utilisateur connecté
|
|
|
|
* @param int $key Clé de la valeur
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getUser($key) {
|
|
|
|
if(is_array($this->user) === false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
elseif($key === 'id') {
|
|
|
|
return $this->getInput('ZWII_USER_ID');
|
|
|
|
}
|
|
|
|
elseif(array_key_exists($key, $this->user)) {
|
|
|
|
return $this->user[$key];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check qu'une valeur est transmise par la méthode _POST
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isPost() {
|
|
|
|
return ($this->checkCSRF() AND $this->input['_POST'] !== []);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-12-10 10:53:31 +01:00
|
|
|
* Import des données de la version 9
|
|
|
|
* Convertit un fichier de données data.json puis le renomme
|
2018-04-02 08:29:19 +02:00
|
|
|
*/
|
2019-12-10 10:53:31 +01:00
|
|
|
public function importData($keepUsers = false) {
|
|
|
|
// Trois tentatives de lecture
|
2018-04-02 08:29:19 +02:00
|
|
|
for($i = 0; $i < 3; $i++) {
|
2019-12-10 10:53:31 +01:00
|
|
|
$tempData=json_decode(file_get_contents(self::DATA_DIR.'core.json'), true);
|
|
|
|
$tempTheme=json_decode(file_get_contents(self::DATA_DIR.'theme.json'), true);
|
|
|
|
if($tempData && $tempTheme) {
|
|
|
|
// Backup
|
|
|
|
rename (self::DATA_DIR.'core.json',self::DATA_DIR.'imported_core.json');
|
|
|
|
rename (self::DATA_DIR.'theme.json',self::DATA_DIR.'imported_theme.json');
|
2018-12-23 23:37:17 +01:00
|
|
|
break;
|
|
|
|
}
|
2019-12-10 10:53:31 +01:00
|
|
|
elseif($i === 2) {
|
|
|
|
exit('Impossible de lire les données à importer.');
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
|
|
|
// Pause de 10 millisecondes
|
|
|
|
usleep(10000);
|
|
|
|
}
|
2019-12-10 10:53:31 +01:00
|
|
|
|
|
|
|
// Dossier de langues
|
|
|
|
if (!file_exists(self::DATA_DIR . '/fr')) {
|
|
|
|
mkdir (self::DATA_DIR . '/fr');
|
|
|
|
}
|
2019-12-11 21:56:18 +01:00
|
|
|
|
|
|
|
// Un seul fichier pour éviter les erreurs de sauvegarde des v9
|
|
|
|
$tempData = array_merge($tempData,$tempTheme);
|
|
|
|
|
2019-12-10 10:53:31 +01:00
|
|
|
// Ecriture des données
|
|
|
|
$this->setData(['config',$tempData['config']]);
|
2020-05-24 19:59:21 +02:00
|
|
|
$this->setData(['core',$tempData['core']]);
|
2019-12-10 10:53:31 +01:00
|
|
|
$this->setData(['page',$tempData['page']]);
|
2020-05-24 19:59:21 +02:00
|
|
|
$this->setData(['module',$tempData['module']]);
|
2019-12-11 21:56:18 +01:00
|
|
|
$this->setData(['theme',$tempData['theme']]);
|
|
|
|
|
2019-12-10 10:53:31 +01:00
|
|
|
// Import des users sauvegardés si option active
|
|
|
|
if ($keepUsers === false) {
|
2020-05-24 19:59:21 +02:00
|
|
|
$this->setData(['user',$tempData['user']]);
|
2019-12-10 10:53:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Nettoyage du fichier de thème pour forcer une régénération
|
|
|
|
if (file_exists(self::DATA_DIR . '/theme.css')) { // On ne sait jamais
|
|
|
|
unlink (self::DATA_DIR . '/theme.css');
|
2020-05-24 19:59:21 +02:00
|
|
|
}
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
|
|
|
|
2019-12-10 10:53:31 +01:00
|
|
|
|
2019-03-13 17:11:04 +01:00
|
|
|
/**
|
2020-06-02 18:51:50 +02:00
|
|
|
* Génère un fichier json avec la liste des pages
|
2020-05-24 19:59:21 +02:00
|
|
|
*
|
2019-12-10 10:53:31 +01:00
|
|
|
*/
|
2019-07-04 19:54:51 +02:00
|
|
|
public function pages2Json() {
|
|
|
|
// Sauve la liste des pages pour TinyMCE
|
2019-03-14 19:04:03 +01:00
|
|
|
$parents = [];
|
2019-07-04 19:54:51 +02:00
|
|
|
$rewrite = (helper::checkRewrite()) ? '' : '?';
|
|
|
|
// Boucle de recherche des pages actives
|
2019-03-14 19:04:03 +01:00
|
|
|
foreach($this->getHierarchy(null,false,false) as $parentId => $childIds) {
|
|
|
|
$children = [];
|
|
|
|
// Exclure les barres
|
2020-05-24 19:59:21 +02:00
|
|
|
if ($this->getData(['page', $parentId, 'block']) !== 'bar' ) {
|
2019-04-23 19:24:03 +02:00
|
|
|
// Boucler sur les enfants et récupérer le tableau children avec la liste des enfants
|
2020-05-24 19:59:21 +02:00
|
|
|
foreach($childIds as $childId) {
|
2019-12-03 14:49:38 +01:00
|
|
|
$children [] = [ 'title' => ' » '. html_entity_decode($this->getData(['page', $childId, 'title']), ENT_QUOTES) ,
|
2019-03-14 19:04:03 +01:00
|
|
|
'value'=> $rewrite.$childId
|
2020-05-24 19:59:21 +02:00
|
|
|
];
|
2019-03-13 17:11:04 +01:00
|
|
|
}
|
2020-05-24 19:59:21 +02:00
|
|
|
// Traitement
|
|
|
|
if (empty($childIds)) {
|
2020-06-02 18:49:24 +02:00
|
|
|
// Pas d'enfant, uniquement l'entrée du parent
|
2019-12-03 14:49:38 +01:00
|
|
|
$parents [] = ['title' => html_entity_decode($this->getData(['page', $parentId, 'title']), ENT_QUOTES) ,
|
2020-05-24 19:59:21 +02:00
|
|
|
'value'=> $rewrite.$parentId
|
|
|
|
];
|
2019-04-23 19:24:03 +02:00
|
|
|
} else {
|
|
|
|
// Des enfants, on ajoute la page parent en premier
|
2019-12-03 14:49:38 +01:00
|
|
|
array_unshift ($children , ['title' => html_entity_decode($this->getData(['page', $parentId, 'title']), ENT_QUOTES) ,
|
2020-05-24 19:59:21 +02:00
|
|
|
'value'=> $rewrite.$parentId
|
|
|
|
]);
|
2019-04-23 19:24:03 +02:00
|
|
|
// puis on ajoute les enfants au parent
|
2019-12-03 14:49:38 +01:00
|
|
|
$parents [] = ['title' => html_entity_decode($this->getData(['page', $parentId, 'title']), ENT_QUOTES) ,
|
2020-05-24 19:59:21 +02:00
|
|
|
'value'=> $rewrite.$parentId ,
|
|
|
|
'menu' => $children
|
|
|
|
];
|
|
|
|
}
|
2019-03-14 19:04:03 +01:00
|
|
|
}
|
|
|
|
}
|
2019-07-04 23:52:21 +02:00
|
|
|
// Sitemap et Search
|
|
|
|
$children = [];
|
|
|
|
$children [] = ['title'=>'Rechercher dans le site',
|
|
|
|
'value'=>$rewrite.'search'
|
|
|
|
];
|
|
|
|
$children [] = ['title'=>'Plan du site',
|
|
|
|
'value'=>$rewrite.'sitemap'
|
|
|
|
];
|
|
|
|
$parents [] = ['title' => 'Pages spéciales',
|
|
|
|
'value' => '#',
|
|
|
|
'menu' => $children
|
|
|
|
];
|
2020-05-24 19:59:21 +02:00
|
|
|
|
2019-07-04 23:52:21 +02:00
|
|
|
// Enregistrement : 3 tentatives
|
2019-03-14 19:04:03 +01:00
|
|
|
for($i = 0; $i < 3; $i++) {
|
|
|
|
if (file_put_contents ('core/vendor/tinymce/link_list.json', json_encode($parents), LOCK_EX) !== false) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Pause de 10 millisecondes
|
|
|
|
usleep(10000);
|
2020-05-24 19:59:21 +02:00
|
|
|
}
|
2019-03-13 17:11:04 +01:00
|
|
|
}
|
|
|
|
|
2019-12-10 10:53:31 +01:00
|
|
|
/**
|
|
|
|
* Retourne une chemin localisé pour l'enregistrement des données
|
|
|
|
* @param $stageId nom du module
|
|
|
|
* @param $lang langue des pages
|
|
|
|
* @return string du dossier à créer
|
|
|
|
*/
|
|
|
|
public function dirData($id, $lang) {
|
|
|
|
// Sauf pour les pages et les modules
|
|
|
|
if ($id === 'page' ||
|
|
|
|
$id === 'module') {
|
|
|
|
$folder = self::DATA_DIR . $lang . '/' ;
|
|
|
|
} else {
|
|
|
|
$folder = self::DATA_DIR;
|
|
|
|
}
|
|
|
|
return ($folder);
|
|
|
|
}
|
|
|
|
|
2019-05-02 13:21:48 +02:00
|
|
|
/**
|
2020-06-02 18:51:50 +02:00
|
|
|
* Génère un fichier robots.txt à l'installation
|
|
|
|
* Si le fichier existe déjà les commandes sont ajoutées
|
2019-05-02 13:21:48 +02:00
|
|
|
*/
|
|
|
|
public function createRobots() {
|
|
|
|
|
2020-05-24 19:59:21 +02:00
|
|
|
$robotValue =
|
2019-05-02 13:21:48 +02:00
|
|
|
PHP_EOL .
|
|
|
|
'# ZWII CONFIG ---------' . PHP_EOL .
|
|
|
|
'User-agent: *' . PHP_EOL .
|
2020-05-24 19:59:21 +02:00
|
|
|
'Allow: /site/file/' .PHP_EOL .
|
2019-09-18 18:31:40 +02:00
|
|
|
'Disallow: /site/' .PHP_EOL .
|
2019-06-15 18:27:00 +02:00
|
|
|
'Sitemap: ' . helper::baseUrl(false) . 'sitemap.xml' . PHP_EOL .
|
|
|
|
'Sitemap: ' . helper::baseUrl(false) . 'sitemap.xml.gz' . PHP_EOL .
|
2019-05-02 13:21:48 +02:00
|
|
|
'# ZWII CONFIG ---------' . PHP_EOL ;
|
|
|
|
|
2020-05-24 19:59:21 +02:00
|
|
|
if (file_exists('robots.txt')) {
|
2019-05-02 13:21:48 +02:00
|
|
|
return(file_put_contents(
|
|
|
|
'robots.txt',
|
|
|
|
$robotValue,
|
|
|
|
FILE_APPEND
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
// Sinon on crée un fichier
|
|
|
|
return(file_put_contents(
|
|
|
|
'robots.txt',
|
|
|
|
$robotValue
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-06-02 18:49:24 +02:00
|
|
|
* Génère un fichier un fichier sitemap.xml
|
2019-05-02 13:21:48 +02:00
|
|
|
* https://github.com/icamys/php-sitemap-generator
|
|
|
|
* $command valeurs possible
|
2020-06-02 18:49:24 +02:00
|
|
|
* all : génère un site map complet
|
2019-05-02 13:21:48 +02:00
|
|
|
* Sinon contient id de la page à créer
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function createSitemap($command = "all") {
|
|
|
|
|
2019-12-15 10:47:18 +01:00
|
|
|
//require_once "core/vendor/sitemap/SitemapGenerator.php";
|
2019-05-02 13:21:48 +02:00
|
|
|
|
2019-06-13 14:01:43 +02:00
|
|
|
$timezone = $this->getData(['config','timezone']);
|
|
|
|
|
2019-05-02 13:21:48 +02:00
|
|
|
$sitemap = new \Icamys\SitemapGenerator\SitemapGenerator(helper::baseurl());
|
|
|
|
|
|
|
|
// will create also compressed (gzipped) sitemap
|
|
|
|
$sitemap->createGZipFile = true;
|
|
|
|
|
|
|
|
// determine how many urls should be put into one file
|
|
|
|
// according to standard protocol 50000 is maximum value (see http://www.sitemaps.org/protocol.html)
|
|
|
|
$sitemap->maxURLsPerSitemap = 50000;
|
|
|
|
|
|
|
|
// sitemap file name
|
|
|
|
$sitemap->sitemapFileName = "sitemap.xml";
|
2020-05-24 19:59:21 +02:00
|
|
|
|
2019-05-02 13:21:48 +02:00
|
|
|
$datetime = new DateTime(date('c'));
|
|
|
|
$datetime->format(DateTime::ATOM); // Updated ISO8601
|
|
|
|
// sitemap index file name
|
|
|
|
$sitemap->sitemapIndexFileName = "sitemap-index.xml";
|
2019-06-10 15:48:43 +02:00
|
|
|
foreach($this->getHierarchy(null, null, null) as $parentPageId => $childrenPageIds) {
|
2019-06-08 21:30:12 +02:00
|
|
|
// Exclure les barres et les pages non publiques et les pages masquées
|
2020-05-24 19:59:21 +02:00
|
|
|
if ($this->getData(['page',$parentPageId,'group']) !== 0 ||
|
2019-06-13 14:01:43 +02:00
|
|
|
$this->getData(['page', $parentPageId, 'block']) === 'bar' ) {
|
2019-05-07 18:36:05 +02:00
|
|
|
continue;
|
|
|
|
}
|
2019-06-18 16:25:39 +02:00
|
|
|
// Page désactivée, traiter les sous-pages sans prendre en compte la page parente.
|
|
|
|
if ($this->getData(['page', $parentPageId, 'disable']) !== true ) {
|
|
|
|
$sitemap->addUrl ($parentPageId,$datetime);
|
|
|
|
}
|
2019-06-09 15:24:43 +02:00
|
|
|
// Sous-pages
|
2019-05-02 13:21:48 +02:00
|
|
|
foreach($childrenPageIds as $childKey) {
|
2019-06-08 21:30:12 +02:00
|
|
|
if ($this->getData(['page',$childKey,'group']) !== 0 || $this->getData(['page', $childKey, 'disable']) === true) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-05-02 13:21:48 +02:00
|
|
|
$sitemap->addUrl($childKey,$datetime);
|
2019-06-09 15:24:43 +02:00
|
|
|
|
|
|
|
// La sous-page est un blog
|
2019-06-20 20:26:08 +02:00
|
|
|
if ($this->getData(['page', $childKey, 'moduleId']) === 'blog' &&
|
|
|
|
!empty($this->getData(['module',$childKey])) ) {
|
2019-06-10 16:21:41 +02:00
|
|
|
foreach($this->getData(['module',$childKey]) as $articleId => $article) {
|
|
|
|
if($this->getData(['module',$childKey,$articleId,'state']) === true) {
|
2019-06-13 14:01:43 +02:00
|
|
|
$date = $this->getData(['module',$childKey,$articleId,'publishedOn']);
|
2019-06-16 17:54:41 +02:00
|
|
|
$sitemap->addUrl( $childKey . '/' . $articleId , new DateTime("@{$date}",new DateTimeZone($timezone)));
|
2020-05-24 19:59:21 +02:00
|
|
|
}
|
2019-06-09 18:36:57 +02:00
|
|
|
}
|
2020-05-24 19:59:21 +02:00
|
|
|
}
|
2019-06-09 15:24:43 +02:00
|
|
|
}
|
|
|
|
// Articles du blog
|
2019-06-20 20:26:08 +02:00
|
|
|
if ($this->getData(['page', $parentPageId, 'moduleId']) === 'blog' &&
|
2020-05-24 19:59:21 +02:00
|
|
|
!empty($this->getData(['module',$parentPageId])) ) {
|
2019-06-10 16:21:41 +02:00
|
|
|
foreach($this->getData(['module',$parentPageId]) as $articleId => $article) {
|
2020-05-24 19:59:21 +02:00
|
|
|
if($this->getData(['module',$parentPageId,$articleId,'state']) === true) {
|
2019-06-13 14:01:43 +02:00
|
|
|
$date = $this->getData(['module',$parentPageId,$articleId,'publishedOn']);
|
|
|
|
$sitemap->addUrl( $parentPageId . '/' . $articleId , new DateTime("@{$date}",new DateTimeZone($timezone)));
|
2019-06-10 16:21:41 +02:00
|
|
|
}
|
2019-06-09 15:24:43 +02:00
|
|
|
}
|
2019-05-02 13:21:48 +02:00
|
|
|
}
|
2020-05-24 19:59:21 +02:00
|
|
|
}
|
|
|
|
|
2019-05-02 13:21:48 +02:00
|
|
|
// generating internally a sitemap
|
|
|
|
$sitemap->createSitemap();
|
|
|
|
|
|
|
|
// writing early generated sitemap to file
|
|
|
|
$sitemap->writeSitemap();
|
2020-05-24 19:59:21 +02:00
|
|
|
|
2019-05-02 13:21:48 +02:00
|
|
|
return(file_exists('sitemap.xml'));
|
|
|
|
|
|
|
|
}
|
2020-05-24 19:59:21 +02:00
|
|
|
|
2020-04-06 09:41:02 +02:00
|
|
|
/*
|
|
|
|
* Création d'une miniature
|
|