Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plxAdmin : strCheck, bonne indentation et trim aux bons endroits #740

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 68 additions & 68 deletions core/lib/class.plx.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ public function getPage() {
# On check pour avoir le numero de page
if(!empty($_GET['page']) AND is_numeric($_GET['page']) AND $_GET['page'] > 0)
$this->page = $_GET['page'];
elseif($savePage) {
if(!empty($_POST['sel_cat'])) {
$this->page = 1;
} else {
$this->page = !empty($_SESSION['page'][$pageName]) ? intval($_SESSION['page'][$pageName]) : 1;
}
}
# On sauvegarde
if($savePage) {
$_SESSION['page'][$pageName] = $this->page;
elseif($savePage) {
if(!empty($_POST['sel_cat'])) {
$this->page = 1;
} else {
$this->page = !empty($_SESSION['page'][$pageName]) ? intval($_SESSION['page'][$pageName]) : 1;
}
}
# On sauvegarde
if($savePage) {
$_SESSION['page'][$pageName] = $this->page;
}
}

/**
Expand Down Expand Up @@ -284,11 +284,11 @@ public function editConfiguration($plxConfig, $content) {
# <!CDATA[..]]> est inutile : valeur numerique, champs uniquement avec caractères alphanumérique
$content = plxUtils::strCheck($v);
} elseif(in_array($k, array('description', 'feed_footer'))) {
# On tolère quelques balises par défaut : <i>, <em>, <a>, <sup>, <span>,
# <!CDATA[..]]> On tolère les balises HTML
$content = plxUtils::strCheck($v, true);
} else {
# Aucune balise HTML tolérée
$content = plxUtils::strCheck($v, true, null);
# <!CDATA[..]]> Aucune balise HTML tolérée
$content = plxUtils::strCheck($v, true, true);
}
?>
<parametre name="<?= $k ?>"><?= $content ?></parametre>
Expand Down Expand Up @@ -492,22 +492,22 @@ public function editProfil($content) {
if(isset($content['profil']) AND trim($content['name'])=='')
return plxMsg::Error(L_ERR_USER_EMPTY);

if(trim($content['email'])!='' AND !plxUtils::checkMail(trim($content['email'])))
return plxMsg::Error(L_ERR_INVALID_EMAIL);
if(trim($content['email'])!='' AND !plxUtils::checkMail(trim($content['email'])))
return plxMsg::Error(L_ERR_INVALID_EMAIL);

if(!in_array($content['lang'], plxUtils::getLangs()))
return plxMsg::Error(L_UNKNOWN_ERROR);
if(!in_array($content['lang'], plxUtils::getLangs()))
return plxMsg::Error(L_UNKNOWN_ERROR);

$this->aUsers[$_SESSION['user']]['name'] = trim($content['name']);
$this->aUsers[$_SESSION['user']]['infos'] = trim($content['content']);
$this->aUsers[$_SESSION['user']]['email'] = trim($content['email']);
$this->aUsers[$_SESSION['user']]['lang'] = $content['lang'];
$this->aUsers[$_SESSION['user']]['name'] = $content['name'];
$this->aUsers[$_SESSION['user']]['infos'] = $content['content'];
$this->aUsers[$_SESSION['user']]['email'] = $content['email'];
$this->aUsers[$_SESSION['user']]['lang'] = $content['lang'];

$_SESSION['admin_lang'] = $content['lang'];
$_SESSION['admin_lang'] = $content['lang'];

# Hook plugins
if(eval($this->plxPlugins->callHook('plxAdminEditProfil'))) return;
return $this->editUsers(null, true);
# Hook plugins
if(eval($this->plxPlugins->callHook('plxAdminEditProfil'))) return;
return $this->editUsers(null, true);
}

/**
Expand Down Expand Up @@ -699,7 +699,7 @@ public function editUsers($content, $action=false) {

$this->aUsers[$user_id]['delete'] = isset($this->aUsers[$user_id]['delete']) ? $this->aUsers[$user_id]['delete'] : 0;
$this->aUsers[$user_id]['lang'] = isset($this->aUsers[$user_id]['lang']) ? $this->aUsers[$user_id]['lang'] : $this->aConf['default_lang'];
$this->aUsers[$user_id]['infos'] = isset($this->aUsers[$user_id]['infos']) ? $this->aUsers[$user_id]['infos'] : '';
$this->aUsers[$user_id]['infos'] = isset($this->aUsers[$user_id]['infos']) ? trim($this->aUsers[$user_id]['infos']) : '';

$this->aUsers[$user_id]['password_token'] = isset($this->aUsers[$user_id]['_password_token']) ? $this->aUsers[$user_id]['_password_token'] : '';
$this->aUsers[$user_id]['password_token_expiry'] = isset($this->aUsers[$user_id]['_password_token_expiry']) ? $this->aUsers[$user_id]['_password_token_expiry'] : '';
Expand Down Expand Up @@ -746,8 +746,8 @@ public function editUsers($content, $action=false) {
}
?>
<user number="<?= $user_id ?>" active="<?= $user['active'] ?>" profil="<?= $user['profil'] ?>" delete="<?= $user['delete'] ?>">
<login><?= plxUtils::strCheck($user['login']) ?></login>
<name><?= plxUtils::strCheck($user['name']) ?></name>
<login><?= $user['login'] ?></login>
<name><?= $user['name'] ?></name>
<infos><?= plxUtils::strCheck($user['infos'], true) ?></infos>
<password><?= $user['password'] ?></password>
<salt><?= $user['salt'] ?></salt>
Expand Down Expand Up @@ -797,14 +797,14 @@ public function editUser($content) {
if(!in_array($content['lang'], plxUtils::getLangs()))
return plxMsg::Error(L_UNKNOWN_ERROR);

$this->aUsers[$content['id']]['email'] = $content['email'];
$this->aUsers[$content['id']]['infos'] = trim($content['content']);
$this->aUsers[$content['id']]['lang'] = $content['lang'];
$this->aUsers[$content['id']]['email'] = $content['email'];
$this->aUsers[$content['id']]['infos'] = $content['content'];
$this->aUsers[$content['id']]['lang'] = $content['lang'];

# Hook plugins
eval($this->plxPlugins->callHook('plxAdminEditUser'));
# Hook plugins
eval($this->plxPlugins->callHook('plxAdminEditUser'));

return $this->editUsers(null,true);
return $this->editUsers(null,true);
}

/**
Expand Down Expand Up @@ -863,7 +863,7 @@ public function editCategories($content, $action=false) {
# Ajout d'une nouvelle catégorie à partir de la page article
elseif(!empty($content['new_category'])) {
# Test pour autoriser uniquement les caractères alphanumériques
$cat_name = $content['new_catname'];
$cat_name = trim($content['new_catname']);
if(!preg_match(PATTERN_NAME, $cat_name)) {
return plxMsg::Error(L_INVALID_VALUE . ' : ' . $cat_name);
}
Expand Down Expand Up @@ -900,7 +900,7 @@ public function editCategories($content, $action=false) {

foreach($content['catNum'] as $cat_id) {
# Test pour autoriser uniquement les caractères alphanumériques
$cat_name = $content[$cat_id.'_name'];
$cat_name = trim($content[$cat_id.'_name']);
if(!preg_match(PATTERN_NAME, $cat_name)) {
return plxMsg::Error(L_INVALID_VALUE . ' : ' . $cat_name);
}
Expand All @@ -917,14 +917,14 @@ public function editCategories($content, $action=false) {
$this->aCats[$cat_id]['active'] = $content[$cat_id.'_active'];
$this->aCats[$cat_id]['ordre'] = intval($content[$cat_id.'_ordre']);
$this->aCats[$cat_id]['homepage'] = isset($this->aCats[$cat_id]['homepage']) ? $this->aCats[$cat_id]['homepage'] : 1;
$this->aCats[$cat_id]['description'] = isset($this->aCats[$cat_id]['description']) ? $this->aCats[$cat_id]['description'] : '';
$this->aCats[$cat_id]['description'] = isset($this->aCats[$cat_id]['description']) ? trim($this->aCats[$cat_id]['description']) : '';
$this->aCats[$cat_id]['template'] = isset($this->aCats[$cat_id]['template']) ? $this->aCats[$cat_id]['template'] : 'categorie.php';
$this->aCats[$cat_id]['thumbnail'] = isset($this->aCats[$cat_id]['thumbnail']) ? $this->aCats[$cat_id]['thumbnail'] : '';
$this->aCats[$cat_id]['thumbnail_title'] = isset($this->aCats[$cat_id]['thumbnail_title']) ? $this->aCats[$cat_id]['thumbnail_title'] : '';
$this->aCats[$cat_id]['thumbnail_alt'] = isset($this->aCats[$cat_id]['thumbnail_alt']) ? $this->aCats[$cat_id]['thumbnail_alt'] : '';
$this->aCats[$cat_id]['title_htmltag'] = isset($this->aCats[$cat_id]['title_htmltag']) ? $this->aCats[$cat_id]['title_htmltag'] : '';
$this->aCats[$cat_id]['meta_description'] = isset($this->aCats[$cat_id]['meta_description']) ? $this->aCats[$cat_id]['meta_description'] : '';
$this->aCats[$cat_id]['meta_keywords'] = isset($this->aCats[$cat_id]['meta_keywords']) ? $this->aCats[$cat_id]['meta_keywords'] : '';
$this->aCats[$cat_id]['thumbnail'] = isset($this->aCats[$cat_id]['thumbnail']) ? trim($this->aCats[$cat_id]['thumbnail']) : '';
$this->aCats[$cat_id]['thumbnail_title'] = isset($this->aCats[$cat_id]['thumbnail_title']) ? trim($this->aCats[$cat_id]['thumbnail_title']) : '';
$this->aCats[$cat_id]['thumbnail_alt'] = isset($this->aCats[$cat_id]['thumbnail_alt']) ? trim($this->aCats[$cat_id]['thumbnail_alt']) : '';
$this->aCats[$cat_id]['title_htmltag'] = isset($this->aCats[$cat_id]['title_htmltag']) ? trim($this->aCats[$cat_id]['title_htmltag']) : '';
$this->aCats[$cat_id]['meta_description'] = isset($this->aCats[$cat_id]['meta_description']) ? trim($this->aCats[$cat_id]['meta_description']) : '';
$this->aCats[$cat_id]['meta_keywords'] = isset($this->aCats[$cat_id]['meta_keywords']) ? trim($this->aCats[$cat_id]['meta_keywords']) : '';

# Hook plugins
eval($this->plxPlugins->callHook('plxAdminEditCategoriesUpdate'));
Expand Down Expand Up @@ -971,12 +971,12 @@ public function editCategories($content, $action=false) {
<categorie number="<?= $cat_id ?>" active="<?= $cat['active'] ?>" homepage="<?= $cat['homepage'] ?>" tri="<?= $cat['tri'] ?>" bypage="<?= $cat['bypage'] ?>" menu="<?= $cat['menu'] ?>" url="<?= $cat['url'] ?>" template="<?= basename($cat['template']) ?>">
<name><?= $cat['name'] ?></name>
<description><?= plxUtils::strCheck($cat['description'], true) ?></description>
<meta_description><?= plxUtils::strCheck($cat['meta_description'], true, null) ?></meta_description>
<meta_keywords><?= plxUtils::strCheck($cat['meta_keywords'], true, null) ?></meta_keywords>
<title_htmltag><?= plxUtils::strCheck($cat['title_htmltag'], true, null) ?></title_htmltag>
<thumbnail><?= plxUtils::strCheck($cat['thumbnail'], true, null) ?></thumbnail>
<thumbnail_alt><?= plxUtils::strCheck($cat['thumbnail_alt'], true) ?></thumbnail_alt>
<thumbnail_title><?= plxUtils::strCheck($cat['thumbnail_title'], true) ?></thumbnail_title>
<meta_description><?= plxUtils::strCheck($cat['meta_description']) ?></meta_description>
<meta_keywords><?= plxUtils::strCheck($cat['meta_keywords']) ?></meta_keywords>
<title_htmltag><?= plxUtils::strCheck($cat['title_htmltag']) ?></title_htmltag>
<thumbnail><?= plxUtils::strCheck($cat['thumbnail'], false, true) ?></thumbnail>
<thumbnail_alt><?= plxUtils::strCheck($cat['thumbnail_alt']) ?></thumbnail_alt>
<thumbnail_title><?= plxUtils::strCheck($cat['thumbnail_title']) ?></thumbnail_title>
<?php
# Hook plugins
eval($this->plxPlugins->callHook('plxAdminEditCategoriesXml'));
Expand Down Expand Up @@ -1007,14 +1007,14 @@ public function editCategories($content, $action=false) {
public function editCategorie($content) {
# Mise à jour du fichier categories.xml
$this->aCats[$content['id']]['homepage'] = intval($content['homepage']);
$this->aCats[$content['id']]['description'] = trim($content['content']);
$this->aCats[$content['id']]['description'] = $content['content'];
$this->aCats[$content['id']]['template'] = $content['template'];
$this->aCats[$content['id']]['thumbnail'] = $content['thumbnail'];
$this->aCats[$content['id']]['thumbnail_title'] = $content['thumbnail_title'];
$this->aCats[$content['id']]['thumbnail_alt'] = $content['thumbnail_alt'];
$this->aCats[$content['id']]['title_htmltag'] = trim($content['title_htmltag']);
$this->aCats[$content['id']]['meta_description'] = trim($content['meta_description']);
$this->aCats[$content['id']]['meta_keywords'] = trim($content['meta_keywords']);
$this->aCats[$content['id']]['title_htmltag'] = $content['title_htmltag'];
$this->aCats[$content['id']]['meta_description'] = $content['meta_description'];
$this->aCats[$content['id']]['meta_keywords'] = $content['meta_keywords'];
# Hook plugins
eval($this->plxPlugins->callHook('plxAdminEditCategorie'));
return $this->editCategories(null, true);
Expand Down Expand Up @@ -1049,7 +1049,7 @@ public function editStatiques($content, $action=false) {
# mise à jour de la liste des pages statiques
elseif(!empty($content['update'])) {
foreach($content['staticNum'] as $static_id) {
$stat_name = $content[$static_id.'_name'];
$stat_name = trim($content[$static_id.'_name']);
if($stat_name!='') {
$url = (!empty($content[$static_id.'_url'])) ? plxUtils::urlify($content[$static_id.'_url']) : '';
$stat_url = (!empty($url)) ? $url : plxUtils::urlify($stat_name);
Expand All @@ -1066,10 +1066,10 @@ public function editStatiques($content, $action=false) {
$this->aStats[$static_id]['active'] = $content[$static_id.'_active'];
$this->aStats[$static_id]['menu'] = $content[$static_id.'_menu'];
$this->aStats[$static_id]['ordre'] = intval($content[$static_id.'_ordre']);
$this->aStats[$static_id]['template'] = (isset($this->aStats[$static_id]['template'])?$this->aStats[$static_id]['template']:'static.php');
$this->aStats[$static_id]['title_htmltag'] = (isset($this->aStats[$static_id]['title_htmltag'])?$this->aStats[$static_id]['title_htmltag']:'');
$this->aStats[$static_id]['meta_description'] = (isset($this->aStats[$static_id]['meta_description'])?$this->aStats[$static_id]['meta_description']:'');
$this->aStats[$static_id]['meta_keywords'] = (isset($this->aStats[$static_id]['meta_keywords'])?$this->aStats[$static_id]['meta_keywords']:'');
$this->aStats[$static_id]['template'] = isset($this->aStats[$static_id]['template']) ? $this->aStats[$static_id]['template'] : 'static.php';
$this->aStats[$static_id]['title_htmltag'] = isset($this->aStats[$static_id]['title_htmltag']) ? trim($this->aStats[$static_id]['title_htmltag']) : '';
$this->aStats[$static_id]['meta_description'] = isset($this->aStats[$static_id]['meta_description']) ? trim($this->aStats[$static_id]['meta_description']) : '';
$this->aStats[$static_id]['meta_keywords'] = isset($this->aStats[$static_id]['meta_keywords']) ? trim($this->aStats[$static_id]['meta_keywords']) : '';
if(plxUtils::getValue($this->aStats[$static_id]['date_creation'])=='') {
$this->aStats[$static_id]['date_creation'] = date('YmdHi');
$this->aStats[$static_id]['date_update'] = date('YmdHi');
Expand Down Expand Up @@ -1112,7 +1112,7 @@ public function editStatiques($content, $action=false) {
<statique number="<?= $static_id ?>" active="<?= $static['active'] ?>" menu="<?= $static['menu'] ?>" url="<?= $static['url'] ?>" template="<?= basename($static['template']) ?>">
<group><?= plxUtils::strCheck($static['group']) ?></group>
<name><?= plxUtils::strCheck($static['name']) ?></name>
<meta_description><?= plxUtils::strCheck($static['meta_description'], true) ?></meta_description>
<meta_description><?= plxUtils::strCheck($static['meta_description']) ?></meta_description>
<meta_keywords><?= plxUtils::strCheck($static['meta_keywords']) ?></meta_keywords>
<title_htmltag><?= plxUtils::strCheck($static['title_htmltag']) ?></title_htmltag>
<date_creation><?= $static['date_creation'] ?></date_creation>
Expand Down Expand Up @@ -1291,15 +1291,15 @@ public function editArticle($content, &$id) {
<title><?= plxUtils::strCheck(trim($content['title']), true) ?></title>
<allow_com><?= intval($content['allow_com']) ?></allow_com>
<template><?= basename($content['template']) ?></template>
<chapo><![CDATA[<?= plxUtils::sanitizePhpTags(trim($content['chapo'])) ?>]]></chapo>
<content><![CDATA[<?= plxUtils::sanitizePhpTags(trim($content['content'])) ?>]]></content>
<tags><?= plxUtils::strCheck(trim($content['tags']), true) ?></tags>
<meta_description><?= plxUtils::strCheck(trim($meta_description)) ?></meta_description>
<meta_keywords><?= plxUtils::strCheck(trim($meta_keywords)) ?></meta_keywords>
<title_htmltag><?= plxUtils::strCheck(trim($title_htmltag)) ?></title_htmltag>
<thumbnail><?= plxUtils::strCheck(trim($thumbnail)) ?></thumbnail>
<thumbnail_alt><?= plxUtils::strCheck(trim($thumbnail_alt), true) ?></thumbnail_alt>
<thumbnail_title><?= plxUtils::strCheck(trim($thumbnail_title), true) ?></thumbnail_title>
<chapo><?= plxUtils::strCheck(trim($content['chapo']), true) ?></chapo>
<content><?= plxUtils::strCheck(trim($content['content']), true) ?></content>
<tags><?= plxUtils::strCheck(trim($content['tags']), false, true) ?></tags>
<meta_description><?= plxUtils::strCheck(trim($meta_description), false, true) ?></meta_description>
<meta_keywords><?= plxUtils::strCheck(trim($meta_keywords), false, true) ?></meta_keywords>
<title_htmltag><?= plxUtils::strCheck(trim($title_htmltag), false, true) ?></title_htmltag>
<thumbnail><?= plxUtils::strCheck(trim($thumbnail), false, true) ?></thumbnail>
<thumbnail_alt><?= plxUtils::strCheck(trim($thumbnail_alt)) ?></thumbnail_alt>
<thumbnail_title><?= plxUtils::strCheck(trim($thumbnail_title)) ?></thumbnail_title>
<date_creation><?= $dates['creation'] ?></date_creation>
<date_update><?= $dates['update'] ?></date_update>
<?php
Expand Down
18 changes: 8 additions & 10 deletions core/lib/class.plx.motor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1081,12 +1081,10 @@ public function newCommentaire($artId, $content) {

$comment = [
'type' => 'normal',
'author' => plxUtils::strCheck(trim(!empty($content['name']) ? $content['name'] : $content['login'])),
'content' => plxUtils::strCheck(trim($content['content'])),
# On vérifie le mail
'mail' => (!empty($content['mail']) and plxUtils::checkMail(trim($content['mail']))) ? trim($content['mail']) : '',
# On vérifie le site
'site' => (!empty($content['site']) and plxUtils::checkSite(trim($content['site']))) ? trim($content['site']) : '',
'author' => trim(!empty($content['name']) ? $content['name'] : $content['login']),
'content' => trim($content['content']),
'mail' => trim($content['mail']),
'site' => trim($content['site']),
# On récupère l'adresse IP du posteur
'ip' => plxUtils::getIp(),
# Commentaire parent en cas de réponse
Expand Down Expand Up @@ -1122,12 +1120,12 @@ public function addCommentaire($content) {
ob_start();
?>
<comment>
<author><![CDATA[<?= plxUtils::cdataCheck($content['author']) ?>]]></author>
<author><?= plxUtils::strCheck($content['author']) ?></author>
<type><?= $content['type'] ?></type>
<ip><?= $content['ip'] ?></ip>
<mail><?= plxUtils::strCheck($content['mail']) ?></mail>
<site><?= plxUtils::strCheck($content['site']) ?></site>
<content><?= plxUtils::strCheck($content['content'], true) ?></content>
<mail><?= plxUtils::checkMail($content['mail']) ?></mail>
<site><?= plxUtils::checkSite($content['site'])? $content['site']: '' ?></site>
<content><?= plxUtils::strCheck($content['content'], true, '<a><b><i><p><q><u><em><sub><sup><del><pre><code><span><strong>', true) ?></content>
<parent><?= !empty($content['parent']) ? intval($content['parent']) : '' ?></parent>
<?php

Expand Down
Loading