ZwiiCMS, le gestionnaire de site Web sans base de données. #zwii #cms #nosql #json https://www.zwiicms.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.1 KiB

4 years ago
<?php
/**
8 months ago
* This file is part of Zwii.
4 years ago
* 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
8 months ago
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2021, Frédéric Tempez
4 years ago
* @license GNU General Public License, version 3
* @link http://zwiicms.fr/
4 years ago
*/
class redirection extends common {
const VERSION = '1.5';
const REALNAME = 'Redirection';
const DELETE = true;
const UPDATE = '0.0';
const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json)
4 years ago
public static $actions = [
'config' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR
];
4 years ago
/**
* Configuration
*/
public function config() {
// Soumission du formulaire
if($this->isPost()) {
$this->setData(['module', $this->getUrl(0), 'url', $this->getInput('redirectionConfigUrl', helper::FILTER_URL, true)]);
4 years ago
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(),
'notification' => 'Modifications enregistrées',
'state' => true
]);
}
// Valeurs en sortie
$this->addOutput([
'title' => 'Configuration du module',
'view' => 'config'
]);
}
/**
* Accueil
*/
public function index() {
// Message si l'utilisateur peut éditer la page
if(
$this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
4 years ago
AND $this->getUser('group') >= self::GROUP_MODERATOR
4 years ago
AND $this->getUrl(1) !== 'force'
) {
// Valeurs en sortie
$this->addOutput([
'display' => self::DISPLAY_LAYOUT_BLANK,
'title' => '',
'view' => 'index'
]);
}
// Sinon redirection
else {
// Incrémente le compteur de clics
$this->setData(['module', $this->getUrl(0), 'count', helper::filter($this->getData(['module', $this->getUrl(0), 'count']) + 1, helper::FILTER_INT)]);
// Valeurs en sortie
$this->addOutput([
'redirect' => $this->getData(['module', $this->getUrl(0), 'url']),
'state' => true
]);
}
}
}