Force obtention des permissions à chaque isPost
This commit is contained in:
parent
101da263fd
commit
08e8c3fa2c
@ -240,7 +240,10 @@ class config extends common
|
||||
public function backup()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Creation du ZIP
|
||||
$filter = $this->getInput('configBackupOption', helper::FILTER_BOOLEAN) === true ? ['backup', 'tmp'] : ['backup', 'tmp', 'file'];
|
||||
$fileName = helper::autoBackup(self::TEMP_DIR, $filter);
|
||||
@ -330,7 +333,10 @@ class config extends common
|
||||
public function restore()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
$success = false;
|
||||
|
||||
@ -361,10 +367,10 @@ class config extends common
|
||||
}
|
||||
// Lire le contenu de l'archive dans le tableau files
|
||||
/*
|
||||
for ($i = 0; $i < $zip->numFiles; $i++) {
|
||||
$stat = $zip->statIndex($i);
|
||||
$files[] = (basename($stat['name']));
|
||||
}*/
|
||||
for ($i = 0; $i < $zip->numFiles; $i++) {
|
||||
$stat = $zip->statIndex($i);
|
||||
$files[] = (basename($stat['name']));
|
||||
}*/
|
||||
// Extraction de l'archive dans un dossier temporaire
|
||||
$tmpDir = uniqid(8);
|
||||
$success = $zip->extractTo(self::TEMP_DIR . $tmpDir);
|
||||
@ -427,7 +433,10 @@ class config extends common
|
||||
public function index()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
// Basculement en mise à jour auto, remise à 0 du compteur
|
||||
if (
|
||||
@ -600,7 +609,10 @@ class config extends common
|
||||
public function script()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Ecrire les fichiers de script
|
||||
if ($this->geturl(2) === 'head') {
|
||||
file_put_contents(self::DATA_DIR . 'head.inc.html', $this->getInput('configScriptHead', null));
|
||||
|
@ -52,7 +52,10 @@ class install extends common
|
||||
}
|
||||
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
$lang = $this->getInput('installLanguage');
|
||||
// Pour la suite de l'installation
|
||||
@ -95,7 +98,10 @@ class install extends common
|
||||
// Accès autorisé
|
||||
else {
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
$success = true;
|
||||
|
||||
|
@ -296,7 +296,10 @@ class page extends common
|
||||
// La page existe
|
||||
else {
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Si le Title n'est pas vide, premier test pour positionner la notification du champ obligatoire
|
||||
if ($this->getInput('pageEditTitle', helper::FILTER_ID, true) !== null && $this->getInput('pageEditTitle') !== '') {
|
||||
// Génére l'ID si le titre de la page a changé
|
||||
@ -541,7 +544,10 @@ class page extends common
|
||||
public function cssEditor()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$css = $this->getInput('pageCssEditorContent', helper::FILTER_STRING_LONG) === null ? '' : $this->getInput('pageCssEditorContent', helper::FILTER_STRING_LONG);
|
||||
// Enregistre le CSS
|
||||
$this->setData([
|
||||
@ -572,7 +578,10 @@ class page extends common
|
||||
public function jsEditor()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$js = $this->getInput('pageJsEditorContent', helper::FILTER_STRING_LONG) === null ? '' : $this->getInput('pageJsEditorContent', helper::FILTER_STRING_LONG);
|
||||
// Enregistre le JS
|
||||
$this->setData([
|
||||
|
@ -265,8 +265,11 @@ class plugin extends common
|
||||
public function upload()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
|
||||
if ($this->isPost()) {
|
||||
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Installation d'un module
|
||||
$checkValidMaj = $this->getInput('configModulesCheck', helper::FILTER_BOOLEAN);
|
||||
$zipFilename = $this->getInput('configModulesInstallation', helper::FILTER_STRING_SHORT);
|
||||
@ -422,9 +425,9 @@ class plugin extends common
|
||||
foreach (self::$languages as $key => $value) {
|
||||
// tableau des langues installées
|
||||
if (
|
||||
is_dir(self::DATA_DIR . $key)
|
||||
&& file_exists(self::DATA_DIR . $key . '/page.json')
|
||||
&& file_exists(self::DATA_DIR . $key . '/module.json')
|
||||
is_dir(self::DATA_DIR . $key)
|
||||
&& file_exists(self::DATA_DIR . $key . '/page.json')
|
||||
&& file_exists(self::DATA_DIR . $key . '/module.json')
|
||||
) {
|
||||
$i18nSites[$key] = $value;
|
||||
}
|
||||
@ -759,7 +762,10 @@ class plugin extends common
|
||||
public function dataImport()
|
||||
{
|
||||
// Soumission du formulaire d'importation du module dans une page libre
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Récupérer le fichier et le décompacter
|
||||
$zipFilename = $this->getInput('pluginImportFile', helper::FILTER_STRING_SHORT, true);
|
||||
$pageId = $this->getInput('pluginImportPage', null, true);
|
||||
|
@ -249,7 +249,10 @@ class theme extends common
|
||||
public function admin()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$this->setData([
|
||||
'admin',
|
||||
[
|
||||
@ -295,7 +298,10 @@ class theme extends common
|
||||
public function advanced()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Enregistre le CSS
|
||||
file_put_contents(self::DATA_DIR . 'custom.css', $this->getInput('themeAdvancedCss', null));
|
||||
// Valeurs en sortie
|
||||
@ -321,7 +327,10 @@ class theme extends common
|
||||
public function body()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$this->setData([
|
||||
'theme',
|
||||
'body',
|
||||
@ -359,7 +368,10 @@ class theme extends common
|
||||
public function footer()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
if (
|
||||
$this->getInput('themeFooterCopyrightPosition') === 'hide' &&
|
||||
$this->getInput('themeFooterSocialsPosition') === 'hide' &&
|
||||
@ -449,7 +461,10 @@ class theme extends common
|
||||
public function header()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Modification des URL des images dans la bannière perso
|
||||
$featureContent = $this->getInput('themeHeaderText', null);
|
||||
/**
|
||||
@ -550,7 +565,10 @@ class theme extends common
|
||||
public function menu()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$this->setData([
|
||||
'theme',
|
||||
'menu',
|
||||
@ -675,7 +693,10 @@ class theme extends common
|
||||
public function fontAdd()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Type d'import en ligne ou local
|
||||
$type = $this->getInput('fontAddUrl', helper::FILTER_BOOLEAN) ? 'imported' : 'files';
|
||||
$type === 'files' ? 'imported' : 'files';
|
||||
@ -742,7 +763,10 @@ class theme extends common
|
||||
public function fontEdit()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Type d'import en ligne ou local
|
||||
$type = $this->getInput('fontEditUrl', helper::FILTER_BOOLEAN) ? 'imported' : 'files';
|
||||
$ressource = $type === 'imported' ? $this->getInput('fontEditUrl', null) : $this->getInput('fontEditFile', null);
|
||||
@ -880,7 +904,10 @@ class theme extends common
|
||||
public function site()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$this->setData([
|
||||
'theme',
|
||||
'title',
|
||||
@ -954,7 +981,10 @@ class theme extends common
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
$zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true);
|
||||
$data = $this->import(self::FILE_DIR . 'source/' . $zipFilename);
|
||||
|
@ -66,38 +66,47 @@ class translate extends common
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$lang = $this->getUrl(2);
|
||||
// Action interdite ou URl avec le code langue incorrecte
|
||||
if (
|
||||
array_key_exists($lang, self::$languages) === false
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true
|
||||
) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'access' => false
|
||||
]);
|
||||
} else {
|
||||
$lang = $this->getUrl(2);
|
||||
// Action interdite ou URl avec le code langue incorrecte
|
||||
if (
|
||||
array_key_exists($lang, self::$languages) === false
|
||||
) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'translate',
|
||||
'state' => false,
|
||||
'notification' => helper::translate('Action interdite')
|
||||
]);
|
||||
}
|
||||
|
||||
// Upload et sauver le fichier de langue
|
||||
$response = json_decode(helper::getUrlContents(common::ZWII_UI_URL . $lang . '.json'), true);
|
||||
if ($response !== false) {
|
||||
$response = file_put_contents(self::I18N_DIR . $lang . '.json', json_encode($response, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
||||
// Mettre à jour le descripteur
|
||||
$enumsStore = json_decode(helper::getUrlContents(common::ZWII_UI_URL . 'language.json'), true);
|
||||
$enums = $this->getData(['language']);
|
||||
$enums = array_merge($enums, [
|
||||
$lang => $enumsStore['language'][$lang]
|
||||
]);
|
||||
$response = (bool) $response && $this->setData(['language', $enums]);
|
||||
}
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'translate',
|
||||
'state' => false,
|
||||
'notification' => helper::translate('Action interdite')
|
||||
'notification' => $response ? helper::translate('Copie terminée avec succès') : 'Copie terminée avec des erreurs',
|
||||
'state' => $response
|
||||
]);
|
||||
}
|
||||
|
||||
// Upload et sauver le fichier de langue
|
||||
$response = json_decode(helper::getUrlContents(common::ZWII_UI_URL . $lang . '.json'), true);
|
||||
if ($response !== false) {
|
||||
$response = file_put_contents(self::I18N_DIR . $lang . '.json', json_encode($response, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
||||
// Mettre à jour le descripteur
|
||||
$enumsStore = json_decode(helper::getUrlContents(common::ZWII_UI_URL . 'language.json'), true);
|
||||
$enums = $this->getData(['language']);
|
||||
$enums = array_merge($enums, [
|
||||
$lang => $enumsStore['language'][$lang]
|
||||
]);
|
||||
$response = (bool) $response && $this->setData(['language', $enums]);
|
||||
}
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'translate',
|
||||
'notification' => $response ? helper::translate('Copie terminée avec succès') : 'Copie terminée avec des erreurs',
|
||||
'state' => $response
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,9 +114,11 @@ class translate extends common
|
||||
*/
|
||||
public function copy()
|
||||
{
|
||||
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Initialisation
|
||||
$success = false;
|
||||
$copyFrom = $this->getInput('translateFormCopySource');
|
||||
@ -175,33 +186,34 @@ class translate extends common
|
||||
foreach (self::$languages as $key => $value) {
|
||||
// tableau des langues installées
|
||||
if (is_dir(self::DATA_DIR . $key)) {
|
||||
if (file_exists(self::DATA_DIR . $key . '/page.json') &&
|
||||
if (
|
||||
file_exists(self::DATA_DIR . $key . '/page.json') &&
|
||||
file_exists(self::DATA_DIR . $key . '/module.json') &&
|
||||
file_exists(self::DATA_DIR . $key . '/locale.json')
|
||||
) {
|
||||
if (file_exists(self::DATA_DIR . $key . '/.default')) {
|
||||
$messageLocale = helper::translate('Langue par défaut');
|
||||
} elseif (isset($_SESSION['ZWII_CONTENT']) && $_SESSION['ZWII_CONTENT'] === $key) {
|
||||
$messageLocale = helper::translate('Langue du site sélectionnée');
|
||||
} else {
|
||||
$messageLocale = '';
|
||||
}
|
||||
self::$languagesInstalled[] = [
|
||||
template::flag($key, '20 %') . ' ' . $value . ' (' . $key . ')',
|
||||
$messageLocale,
|
||||
template::button('translateContentLanguageLocaleEdit' . $key, [
|
||||
'class' => file_exists(self::DATA_DIR . $key . '/locale.json') ? '' : ' disabled',
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/locale/' . $key,
|
||||
'value' => template::ico('pencil'),
|
||||
'help' => 'Éditer'
|
||||
]),
|
||||
template::button('translateContentLanguageLocaleDelete' . $key, [
|
||||
'class' => 'translateDelete buttonRed' . ($messageLocale ? ' disabled' : ''),
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/locale/' . $key,
|
||||
'value' => template::ico('trash'),
|
||||
'help' => 'Supprimer',
|
||||
])
|
||||
];
|
||||
$messageLocale = helper::translate('Langue par défaut');
|
||||
} elseif (isset($_SESSION['ZWII_CONTENT']) && $_SESSION['ZWII_CONTENT'] === $key) {
|
||||
$messageLocale = helper::translate('Langue du site sélectionnée');
|
||||
} else {
|
||||
$messageLocale = '';
|
||||
}
|
||||
self::$languagesInstalled[] = [
|
||||
template::flag($key, '20 %') . ' ' . $value . ' (' . $key . ')',
|
||||
$messageLocale,
|
||||
template::button('translateContentLanguageLocaleEdit' . $key, [
|
||||
'class' => file_exists(self::DATA_DIR . $key . '/locale.json') ? '' : ' disabled',
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/locale/' . $key,
|
||||
'value' => template::ico('pencil'),
|
||||
'help' => 'Éditer'
|
||||
]),
|
||||
template::button('translateContentLanguageLocaleDelete' . $key, [
|
||||
'class' => 'translateDelete buttonRed' . ($messageLocale ? ' disabled' : ''),
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/locale/' . $key,
|
||||
'value' => template::ico('trash'),
|
||||
'help' => 'Supprimer',
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,13 +255,13 @@ class translate extends common
|
||||
//self::$i18nUI === $file ? helper::translate('Interface') : '',
|
||||
'',
|
||||
/*
|
||||
template::button('translateContentLanguageUIEdit' . $file, [
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $file,
|
||||
'value' => template::ico('pencil'),
|
||||
'help' => 'Éditer',
|
||||
'disabled' => 'fr_FR' === $file
|
||||
]),
|
||||
*/
|
||||
template::button('translateContentLanguageUIEdit' . $file, [
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $file,
|
||||
'value' => template::ico('pencil'),
|
||||
'help' => 'Éditer',
|
||||
'disabled' => 'fr_FR' === $file
|
||||
]),
|
||||
*/
|
||||
template::button('translateContentLanguageUIDownload' . $file, [
|
||||
'class' => version_compare($installedUI[$file]['version'], $storeUI[$file]['version']) < 0 ? 'buttonGreen' : '',
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/update/' . $file,
|
||||
@ -302,7 +314,10 @@ class translate extends common
|
||||
{
|
||||
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
// Création du contenu
|
||||
$lang = $this->getInput('translateAddContent');
|
||||
@ -356,7 +371,10 @@ class translate extends common
|
||||
}
|
||||
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
// Sauvegarder les locales
|
||||
$data = [
|
||||
@ -459,7 +477,10 @@ class translate extends common
|
||||
]);
|
||||
}
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
// Sauvegarder les champs de la langue
|
||||
$data = json_decode(file_get_contents(self::I18N_DIR . $lang . '.json'), true);
|
||||
@ -536,52 +557,61 @@ class translate extends common
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
// Action interdite ou URl avec le code langue incorrecte
|
||||
$target = $this->getUrl(2);
|
||||
$lang = $this->getUrl(3);
|
||||
if (
|
||||
array_key_exists($lang, self::$languages) === false
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true
|
||||
) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'translate',
|
||||
'state' => false,
|
||||
'notification' => helper::translate('Action interdite')
|
||||
'access' => false
|
||||
]);
|
||||
}
|
||||
switch ($target) {
|
||||
case 'locale':
|
||||
$success = false;
|
||||
// Effacement d'une site dans une langue
|
||||
if (is_dir(self::DATA_DIR . $lang) === true) {
|
||||
$success = $this->removeDir(self::DATA_DIR . $lang);
|
||||
}
|
||||
} else {
|
||||
// Action interdite ou URl avec le code langue incorrecte
|
||||
$target = $this->getUrl(2);
|
||||
$lang = $this->getUrl(3);
|
||||
if (
|
||||
array_key_exists($lang, self::$languages) === false
|
||||
) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'translate',
|
||||
'notification' => $success ? helper::translate('Traduction supprimée') : helper::translate('Erreur inconnue'),
|
||||
'state' => $success
|
||||
'state' => false,
|
||||
'notification' => helper::translate('Action interdite')
|
||||
]);
|
||||
break;
|
||||
}
|
||||
switch ($target) {
|
||||
case 'locale':
|
||||
$success = false;
|
||||
// Effacement d'une site dans une langue
|
||||
if (is_dir(self::DATA_DIR . $lang) === true) {
|
||||
$success = $this->removeDir(self::DATA_DIR . $lang);
|
||||
}
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'translate',
|
||||
'notification' => $success ? helper::translate('Traduction supprimée') : helper::translate('Erreur inconnue'),
|
||||
'state' => $success
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'ui':
|
||||
$success = false;
|
||||
// Effacement d'une langue de l'interface
|
||||
if (file_exists(self::I18N_DIR . $lang . '.json') === true) {
|
||||
$this->deleteData(['language', $lang]);
|
||||
$success = unlink(self::I18N_DIR . $lang . '.json');
|
||||
}
|
||||
// Effacer la langue dans la base
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'translate',
|
||||
'notification' => $success ? helper::translate('Traduction supprimée') : helper::translate('Erreur inconnue'),
|
||||
'state' => $success
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
# Do nothing
|
||||
break;
|
||||
case 'ui':
|
||||
$success = false;
|
||||
// Effacement d'une langue de l'interface
|
||||
if (file_exists(self::I18N_DIR . $lang . '.json') === true) {
|
||||
$this->deleteData(['language', $lang]);
|
||||
$success = unlink(self::I18N_DIR . $lang . '.json');
|
||||
}
|
||||
// Effacer la langue dans la base
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'translate',
|
||||
'notification' => $success ? helper::translate('Traduction supprimée') : helper::translate('Erreur inconnue'),
|
||||
'state' => $success
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
# Do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -591,32 +621,41 @@ class translate extends common
|
||||
*/
|
||||
public function default()
|
||||
{
|
||||
// Action interdite ou URl avec le code langue incorrecte
|
||||
$lang = $this->getUrl(2);
|
||||
if (
|
||||
array_key_exists($lang, self::$languages) === false
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true
|
||||
) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'access' => false
|
||||
]);
|
||||
} else {
|
||||
// Action interdite ou URl avec le code langue incorrecte
|
||||
$lang = $this->getUrl(2);
|
||||
if (
|
||||
array_key_exists($lang, self::$languages) === false
|
||||
) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'translate',
|
||||
'state' => false,
|
||||
'notification' => helper::translate('Action interdite')
|
||||
]);
|
||||
}
|
||||
|
||||
foreach (self::$languages as $key => $value) {
|
||||
if (file_exists(self::DATA_DIR . $key . '/.default')) {
|
||||
unlink(self::DATA_DIR . $key . '/.default');
|
||||
touch(self::DATA_DIR . $lang . '/.default');
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => helper::translate('Modifications enregistrées'),
|
||||
'redirect' => helper::baseUrl() . 'translate',
|
||||
'state' => false,
|
||||
'notification' => helper::translate('Action interdite')
|
||||
'state' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
foreach (self::$languages as $key => $value) {
|
||||
if (file_exists(self::DATA_DIR . $key . '/.default')) {
|
||||
unlink(self::DATA_DIR . $key . '/.default');
|
||||
touch(self::DATA_DIR . $lang . '/.default');
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => helper::translate('Modifications enregistrées'),
|
||||
'redirect' => helper::baseUrl() . 'translate',
|
||||
'state' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -75,7 +75,10 @@ class user extends common
|
||||
public function add()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$check = true;
|
||||
// L'identifiant d'utilisateur est indisponible
|
||||
$userId = $this->getInput('userAddId', helper::FILTER_ID, true);
|
||||
@ -259,7 +262,10 @@ class user extends common
|
||||
// Accès autorisé
|
||||
else {
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Double vérification pour le mot de passe
|
||||
$newPassword = $this->getData(['user', $this->getUrl(2), 'password']);
|
||||
if ($this->getInput('userEditNewPassword')) {
|
||||
@ -384,7 +390,10 @@ class user extends common
|
||||
public function forgot()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$userId = $this->getInput('userForgotId', helper::FILTER_ID, true);
|
||||
if ($this->getData(['user', $userId])) {
|
||||
// Enregistre la date de la demande dans le compte utilisateur
|
||||
@ -529,18 +538,12 @@ class user extends common
|
||||
*/
|
||||
public function profilEdit()
|
||||
{
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true ||
|
||||
$this->checkCSRF()
|
||||
) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'access' => false
|
||||
]);
|
||||
}
|
||||
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$this->setData([
|
||||
'profil',
|
||||
$this->getInput('profilEditGroup', helper::FILTER_STRING_LONG, true),
|
||||
@ -667,7 +670,10 @@ class user extends common
|
||||
public function profilAdd()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Nombre de profils de ce groupe
|
||||
$group = $this->getInput('profilAddGroup');
|
||||
$profil = (string) (count($this->getData(['profil', $group])) + 1);
|
||||
@ -827,7 +833,9 @@ class user extends common
|
||||
{
|
||||
// Soumission du formulaire
|
||||
$logStatus = '';
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->isPost()
|
||||
) {
|
||||
// Lire Id du compte
|
||||
$userId = $this->getInput('userLoginId', helper::FILTER_ID, true);
|
||||
// Check le captcha
|
||||
@ -1003,7 +1011,10 @@ class user extends common
|
||||
// Accès autorisé
|
||||
else {
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Double vérification pour le mot de passe
|
||||
if ($this->getInput('userResetNewPassword')) {
|
||||
// La confirmation ne correspond pas au mot de passe
|
||||
@ -1046,7 +1057,10 @@ class user extends common
|
||||
// Soumission du formulaire
|
||||
$notification = '';
|
||||
$success = true;
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Lecture du CSV et construction du tableau
|
||||
$file = $this->getInput('userImportCSVFile', helper::FILTER_STRING_SHORT, true);
|
||||
$filePath = self::FILE_DIR . 'source/' . $file;
|
||||
@ -1180,16 +1194,19 @@ class user extends common
|
||||
*/
|
||||
public function template()
|
||||
{
|
||||
$file = 'template.csv';
|
||||
$path = 'core/module/user/ressource/';
|
||||
// Téléchargement du CSV
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Content-Disposition: attachment; filename="' . $file . '"');
|
||||
header('Content-Length: ' . filesize($path . $file));
|
||||
readfile($path . $file);
|
||||
exit();
|
||||
if ($this->getUser('permission', __CLASS__, __FUNCTION__) !== true) {
|
||||
$file = 'template.csv';
|
||||
$path = 'core/module/user/ressource/';
|
||||
// Téléchargement du CSV
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Content-Disposition: attachment; filename="' . $file . '"');
|
||||
header('Content-Length: ' . filesize($path . $file));
|
||||
readfile($path . $file);
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,7 +250,10 @@ class blog extends common
|
||||
public function add()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Modification de l'userId
|
||||
if ($this->getUser('group') === self::GROUP_ADMIN) {
|
||||
$newuserid = $this->getInput('blogAddUserId', helper::FILTER_STRING_SHORT, true);
|
||||
@ -556,7 +559,10 @@ class blog extends common
|
||||
{
|
||||
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$this->setData([
|
||||
'module', $this->getUrl(0),
|
||||
'config',
|
||||
@ -635,7 +641,10 @@ class blog extends common
|
||||
// L'article existe
|
||||
else {
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
if ($this->getUser('group') === self::GROUP_ADMIN) {
|
||||
$newuserid = $this->getInput('blogEditUserId', helper::FILTER_STRING_SHORT, true);
|
||||
} else {
|
||||
@ -730,7 +739,10 @@ class blog extends common
|
||||
// L'article existe
|
||||
else {
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Check la captcha
|
||||
if (
|
||||
$this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')
|
||||
@ -892,21 +904,24 @@ class blog extends common
|
||||
*/
|
||||
public function signature($userId)
|
||||
{
|
||||
switch ($this->getData(['user', $userId, 'signature'])) {
|
||||
case 1:
|
||||
return $userId;
|
||||
break;
|
||||
case 2:
|
||||
return $this->getData(['user', $userId, 'pseudo']);
|
||||
break;
|
||||
case 3:
|
||||
return $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']);
|
||||
break;
|
||||
case 4:
|
||||
return $this->getData(['user', $userId, 'lastname']) . ' ' . $this->getData(['user', $userId, 'firstname']);
|
||||
break;
|
||||
default:
|
||||
return $this->getData(['user', $userId, 'firstname']);
|
||||
if ($this->getUser('permission', __CLASS__, __FUNCTION__) !== true) {
|
||||
switch ($this->getData(['user', $userId, 'signature'])) {
|
||||
case 1:
|
||||
return $userId;
|
||||
break;
|
||||
case 2:
|
||||
return $this->getData(['user', $userId, 'pseudo']);
|
||||
break;
|
||||
case 3:
|
||||
return $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']);
|
||||
break;
|
||||
case 4:
|
||||
return $this->getData(['user', $userId, 'lastname']) . ' ' . $this->getData(['user', $userId, 'firstname']);
|
||||
break;
|
||||
default:
|
||||
return $this->getData(['user', $userId, 'firstname']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -117,7 +117,10 @@ class form extends common
|
||||
self::$listUsers[] = $userId;
|
||||
}
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Génération des données vides
|
||||
if ($this->getData(['module', $this->getUrl(0), 'data']) === null) {
|
||||
$this->setData(['module', $this->getUrl(0), 'data', []]);
|
||||
@ -163,7 +166,10 @@ class form extends common
|
||||
self::$listUsers[] = $userId;
|
||||
}
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Débordement
|
||||
$width = $this->getInput('formOptionWidth');
|
||||
if ($this->getInput('formOptionWidth', helper::FILTER_INT) + $this->getInput('formOptionOffset', helper::FILTER_INT) > 12) {
|
||||
@ -228,7 +234,10 @@ class form extends common
|
||||
public function data()
|
||||
{
|
||||
$data = $this->getData(['module', $this->getUrl(0), 'data']);
|
||||
if ($data) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$data
|
||||
) {
|
||||
// Pagination
|
||||
$pagination = helper::pagination($data, $this->getUrl(), self::$itemsperPage);
|
||||
// Liste des pages
|
||||
@ -383,7 +392,10 @@ class form extends common
|
||||
$this->update();
|
||||
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Check la captcha
|
||||
if (
|
||||
$this->getData(['module', $this->getUrl(0), 'config', 'captcha'])
|
||||
|
@ -417,7 +417,10 @@ class gallery extends common
|
||||
public function add()
|
||||
{
|
||||
// Soumission du formulaire d'ajout d'une galerie
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$galleryId = $this->getInput('galleryAddName', null, true);
|
||||
$success = false;
|
||||
if ($galleryId) {
|
||||
@ -499,8 +502,10 @@ class gallery extends common
|
||||
public function delete()
|
||||
{
|
||||
// La galerie n'existe pas
|
||||
if ($this->getUser('permission', __CLASS__, __FUNCTION__) !== true ||
|
||||
$this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2)]) === null) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true ||
|
||||
$this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2)]) === null
|
||||
) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'access' => false
|
||||
@ -536,7 +541,10 @@ class gallery extends common
|
||||
public function edit()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
// légendes
|
||||
foreach ((array) $this->getInput('legend', null) as $file => $legend) {
|
||||
@ -687,25 +695,25 @@ class gallery extends common
|
||||
// Définir les options
|
||||
self::$config['homePicture'] = $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'homePicture']);
|
||||
self::$config['fullScreen'] = $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'fullScreen']) === true ? 'fullScreen' : '';
|
||||
self::$config['backPositionTop'] = ( $this->getData(['module', $this->getUrl(0), 'config', 'backPosition']) === 'top'||
|
||||
$this->getData(['module', $this->getUrl(0), 'config', 'backPosition']) === 'both' )
|
||||
? ''
|
||||
: 'displayNone';
|
||||
self::$config['backPositionBottom'] = ( $this->getData(['module', $this->getUrl(0), 'config', 'backPosition']) === 'bottom'||
|
||||
$this->getData(['module', $this->getUrl(0), 'config', 'backPosition']) === 'both' )
|
||||
? ''
|
||||
: 'displayNone';
|
||||
self::$config['backPositionTop'] = ($this->getData(['module', $this->getUrl(0), 'config', 'backPosition']) === 'top' ||
|
||||
$this->getData(['module', $this->getUrl(0), 'config', 'backPosition']) === 'both')
|
||||
? ''
|
||||
: 'displayNone';
|
||||
self::$config['backPositionBottom'] = ($this->getData(['module', $this->getUrl(0), 'config', 'backPosition']) === 'bottom' ||
|
||||
$this->getData(['module', $this->getUrl(0), 'config', 'backPosition']) === 'both')
|
||||
? ''
|
||||
: 'displayNone';
|
||||
self::$config['backAlign'] = 'textAlign' . ucfirst($this->getData(['module', $this->getUrl(0), 'config', 'backAlign']));
|
||||
|
||||
// Annulation de l'apparition des boutons si la galerie est unique
|
||||
self::$config['backPositionTop'] = ($this->getData(['module', $this->getUrl(0), 'config', 'showUniqueGallery']) === true
|
||||
&& count($this->getData(['module', $this->getUrl(0), 'content'])) === 1)
|
||||
? 'displayNone'
|
||||
: self::$config['backPositionTop'];
|
||||
&& count($this->getData(['module', $this->getUrl(0), 'content'])) === 1)
|
||||
? 'displayNone'
|
||||
: self::$config['backPositionTop'];
|
||||
self::$config['backPositionBottom'] = ($this->getData(['module', $this->getUrl(0), 'config', 'showUniqueGallery']) === true
|
||||
&& count($this->getData(['module', $this->getUrl(0), 'content'])) === 1)
|
||||
? 'displayNone'
|
||||
: self::$config['backPositionBottom'];
|
||||
&& count($this->getData(['module', $this->getUrl(0), 'content'])) === 1)
|
||||
? 'displayNone'
|
||||
: self::$config['backPositionBottom'];
|
||||
|
||||
if (is_dir($directory)) {
|
||||
$iterator = new DirectoryIterator($directory);
|
||||
@ -838,7 +846,10 @@ class gallery extends common
|
||||
public function theme()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Dossier de l'instance
|
||||
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0))) {
|
||||
mkdir(self::DATADIRECTORY . $this->getUrl(0), 0755, true);
|
||||
@ -910,16 +921,11 @@ class gallery extends common
|
||||
* Options applicables à toutes les galeries du module
|
||||
*/
|
||||
if ($this->getUrl(2) === 'galleries') {
|
||||
// Action interdite
|
||||
if ($this->checkCSRF()) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
|
||||
'notification' => helper::translate('Action interdite')
|
||||
]);
|
||||
}
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
// Sauver la configuration de la galerie
|
||||
$this->setData([
|
||||
@ -960,7 +966,10 @@ class gallery extends common
|
||||
]);
|
||||
}
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
// Le nom de la galerie est vide c'est le nom dans l'url qui est pris en compte
|
||||
$galleryId = !empty($this->getInput('galleryEditName')) ? $this->getInput('galleryEditName', helper::FILTER_ID, true) : $this->getUrl(3);
|
||||
|
@ -163,7 +163,10 @@ class news extends common
|
||||
public function add()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
// Crée la news
|
||||
$newsId = helper::increment($this->getInput('newsAddTitle', helper::FILTER_ID), (array) $this->getData(['module', $this->getUrl(0), 'posts']));
|
||||
$publishedOn = $this->getInput('newsAddPublishedOn', helper::FILTER_DATETIME, true);
|
||||
@ -262,7 +265,10 @@ class news extends common
|
||||
public function option()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
// Générer la feuille de CSS
|
||||
$style = '.newsFrame {';
|
||||
@ -404,7 +410,7 @@ class news extends common
|
||||
// La news existe
|
||||
else {
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
if ($this->getUser('permission', __CLASS__, __FUNCTION__) !== true && $this->isPost()) {
|
||||
// Si l'id a changée
|
||||
$newsId = $this->getInput('newsEditTitle', helper::FILTER_ID, true);
|
||||
if ($newsId !== $this->getUrl(2)) {
|
||||
|
@ -13,7 +13,8 @@
|
||||
* @link http://zwiicms.fr/
|
||||
*/
|
||||
|
||||
class redirection extends common {
|
||||
class redirection extends common
|
||||
{
|
||||
|
||||
const VERSION = '1.6';
|
||||
const REALNAME = 'Redirection';
|
||||
@ -28,9 +29,13 @@ class redirection extends common {
|
||||
/**
|
||||
* Configuration
|
||||
*/
|
||||
public function config() {
|
||||
public function config()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$this->setData(['module', $this->getUrl(0), 'url', $this->getInput('redirectionConfigUrl', helper::FILTER_URL, true)]);
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
@ -49,9 +54,11 @@ class redirection extends common {
|
||||
/**
|
||||
* Accueil
|
||||
*/
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
// Message si l'utilisateur peut éditer la page
|
||||
if( $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true
|
||||
&& $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
|
||||
&& $this->getUser('group') >= self::GROUP_MODERATOR
|
||||
&& $this->getUrl(1) !== 'force'
|
||||
@ -74,4 +81,4 @@ class redirection extends common {
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@ class search extends common
|
||||
if (
|
||||
$this->getData(['module', $this->getUrl(0), 'config']) === NULL
|
||||
|| $this->getData(['module', $this->getUrl(0), 'theme']) === NULL
|
||||
|| !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css')
|
||||
|| !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css')
|
||||
) {
|
||||
$this->init();
|
||||
}
|
||||
@ -120,7 +120,10 @@ class search extends common
|
||||
// Mise à jour des données de module
|
||||
$this->update();
|
||||
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
|
||||
// Générer la feuille de CSS
|
||||
$style = '.keywordColor {background:' . $this->getInput('searchKeywordColor') . ';}';
|
||||
@ -129,23 +132,31 @@ class search extends common
|
||||
// Fin feuille de style
|
||||
|
||||
// Soumission du formulaire
|
||||
$this->setData(['module', $this->getUrl(0), 'config', [
|
||||
'submitText' => $this->getInput('searchSubmitText'),
|
||||
'placeHolder' => $this->getInput('searchPlaceHolder'),
|
||||
'resultHideContent' => $this->getInput('searchResultHideContent', helper::FILTER_BOOLEAN),
|
||||
'previewLength' => $this->getInput('searchPreviewLength', helper::FILTER_INT),
|
||||
'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData'])
|
||||
]]);
|
||||
$this->setData(['module', $this->getUrl(0), 'theme', [
|
||||
'keywordColor' => $this->getInput('searchKeywordColor'),
|
||||
'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '',
|
||||
]]);
|
||||
$this->setData([
|
||||
'module', $this->getUrl(0),
|
||||
'config',
|
||||
[
|
||||
'submitText' => $this->getInput('searchSubmitText'),
|
||||
'placeHolder' => $this->getInput('searchPlaceHolder'),
|
||||
'resultHideContent' => $this->getInput('searchResultHideContent', helper::FILTER_BOOLEAN),
|
||||
'previewLength' => $this->getInput('searchPreviewLength', helper::FILTER_INT),
|
||||
'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData'])
|
||||
]
|
||||
]);
|
||||
$this->setData([
|
||||
'module', $this->getUrl(0),
|
||||
'theme',
|
||||
[
|
||||
'keywordColor' => $this->getInput('searchKeywordColor'),
|
||||
'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '',
|
||||
]
|
||||
]);
|
||||
|
||||
|
||||
// Valeurs en sortie, affichage du formulaire
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . $this->getUrl(),
|
||||
'notification' => $success ? 'Modifications enregistrées' : 'Modifications non enregistrées !',
|
||||
'notification' => $success ? 'Modifications enregistrées' : 'Modifications non enregistrées !',
|
||||
'state' => $success
|
||||
]);
|
||||
}
|
||||
@ -165,7 +176,10 @@ class search extends common
|
||||
// Mise à jour des données de module
|
||||
$this->update();
|
||||
|
||||
if ($this->isPost()) {
|
||||
if (
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
//Initialisations variables
|
||||
$success = true;
|
||||
$result = [];
|
||||
@ -181,10 +195,12 @@ class search extends common
|
||||
$arraymotclef = explode(' ', $motclef);
|
||||
$motclef = '';
|
||||
foreach ($arraymotclef as $key => $value) {
|
||||
if (strlen($value) > 2 && $value !== 'les' && $value !== 'des' && $value !== 'une' && $value !== 'aux') $motclef .= $value . ' ';
|
||||
if (strlen($value) > 2 && $value !== 'les' && $value !== 'des' && $value !== 'une' && $value !== 'aux')
|
||||
$motclef .= $value . ' ';
|
||||
}
|
||||
// Suppression du dernier ' '
|
||||
if ($motclef !== '') $motclef = substr($motclef, 0, strlen($motclef) - 1);
|
||||
if ($motclef !== '')
|
||||
$motclef = substr($motclef, 0, strlen($motclef) - 1);
|
||||
|
||||
// Récupération de l'état de l'option mot entier passé par le même formulaire
|
||||
self::$motentier = $this->getInput('searchMotentier', helper::FILTER_BOOLEAN);
|
||||
@ -192,7 +208,7 @@ class search extends common
|
||||
if ($motclef !== '') {
|
||||
foreach ($this->getHierarchy(null, false, null) as $parentId => $childIds) {
|
||||
if (
|
||||
$this->getData(['page', $parentId, 'disable']) === false &&
|
||||
$this->getData(['page', $parentId, 'disable']) === false &&
|
||||
$this->getUser('group') >= $this->getData(['page', $parentId, 'group']) &&
|
||||
$this->getData(['page', $parentId, 'block']) !== 'bar'
|
||||
) {
|
||||
@ -200,9 +216,9 @@ class search extends common
|
||||
$titre = $this->getData(['page', $parentId, 'title']);
|
||||
//$content = file_get_contents(self::DATA_DIR . self::$i18nContent . '/content/' . $this->getData(['page', $parentId, 'content']));
|
||||
$content = $this->getPage($parentId, self::$i18nContent);
|
||||
$content = $titre . ' ' . $content;
|
||||
$content = $titre . ' ' . $content;
|
||||
// Pages sauf pages filles et articles de blog
|
||||
$tempData = $this->occurrence($url, $titre, $content, $motclef, self::$motentier);
|
||||
$tempData = $this->occurrence($url, $titre, $content, $motclef, self::$motentier);
|
||||
if (is_array($tempData)) {
|
||||
$result[] = $tempData;
|
||||
}
|
||||
@ -219,9 +235,9 @@ class search extends common
|
||||
$titre = $this->getData(['page', $childId, 'title']);
|
||||
//$content = file_get_contents(self::DATA_DIR . self::$i18nContent . '/content/' . $this->getData(['page', $childId, 'content']));
|
||||
$content = $this->getPage($childId, self::$i18nContent);
|
||||
$content = $titre . ' ' . $content;
|
||||
$content = $titre . ' ' . $content;
|
||||
//Pages filles
|
||||
$tempData = $this->occurrence($url, $titre, $content, $motclef, self::$motentier);
|
||||
$tempData = $this->occurrence($url, $titre, $content, $motclef, self::$motentier);
|
||||
if (is_array($tempData)) {
|
||||
$result[] = $tempData;
|
||||
}
|
||||
@ -235,7 +251,7 @@ class search extends common
|
||||
$titre = $article['title'];
|
||||
$contenu = ' ' . $titre . ' ' . $article['content'];
|
||||
// Articles de sous-page de type blog
|
||||
$tempData = $this->occurrence($url, $titre, $contenu, $motclef, self::$motentier);
|
||||
$tempData = $this->occurrence($url, $titre, $contenu, $motclef, self::$motentier);
|
||||
if (is_array($tempData)) {
|
||||
$result[] = $tempData;
|
||||
}
|
||||
@ -252,7 +268,7 @@ class search extends common
|
||||
$url = $parentId . '/' . $articleId;
|
||||
$titre = $article['title'];
|
||||
$contenu = ' ' . $titre . ' ' . $article['content'];
|
||||
$tempData = $this->occurrence($url, $titre, $contenu, $motclef, self::$motentier);
|
||||
$tempData = $this->occurrence($url, $titre, $contenu, $motclef, self::$motentier);
|
||||
if (is_array($tempData)) {
|
||||
$result[] = $tempData;
|
||||
}
|
||||
@ -282,8 +298,8 @@ class search extends common
|
||||
'showBarEditButton' => true,
|
||||
'showPageContent' => !$this->getData(['module', $this->getUrl(0), 'config', 'resultHideContent']),
|
||||
'style' => file_exists($this->getData(['module', $this->getUrl(0), 'theme', 'style']))
|
||||
? $this->getData(['module', $this->getUrl(0), 'theme', 'style'])
|
||||
: ''
|
||||
? $this->getData(['module', $this->getUrl(0), 'theme', 'style'])
|
||||
: ''
|
||||
]);
|
||||
} else {
|
||||
// Valeurs en sortie, affichage du formulaire
|
||||
@ -323,7 +339,7 @@ class search extends common
|
||||
$valid = preg_match_all($keywords, $contenu, $matches, PREG_OFFSET_CAPTURE);
|
||||
if ($valid > 0) {
|
||||
if (($matches[0][0][1]) > 0) {
|
||||
$resultat = sprintf('<h2><a href="./?%s" target="_blank" rel="noopener">%s (%s)</a></h2>', $url, $titre, count($matches[0]));
|
||||
$resultat = sprintf('<h2><a href="./?%s" target="_blank" rel="noopener">%s (%s)</a></h2>', $url, $titre, count($matches[0]));
|
||||
// Création de l'aperçu
|
||||
// Eviter de découper avec une valeur négative
|
||||
$d = $matches[0][0][1] - 50 < 0 ? 1 : $matches[0][0][1] - 50;
|
||||
@ -344,4 +360,4 @@ class search extends common
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user