/** * Méthode qui valide la durée de vide d'un token * * @parm $request (deprecated) * @return stdio/null * @author Stephane F **/ public static function validateFormToken($request = '') { if ($_SERVER['REQUEST_METHOD'] == 'POST' and isset($_SESSION['formtoken'])) { if (empty($_POST['token']) or plxUtils::getValue($_SESSION['formtoken'][$_POST['token']]) < time() - 3600) { # 3600 seconds unset($_SESSION['formtoken']); die('Security error : invalid or expired token'); } unset($_SESSION['formtoken'][$_POST['token']]); } }
* * @package PLX * @author Florent MONTHEL, Stephane F **/ include dirname(__FILE__) . '/prepend.php'; # Control du token du formulaire plxToken::validateFormToken($_POST); # Control de l'accès à la page en fonction du profil de l'utilisateur connecté $plxAdmin->checkProfil(PROFIL_ADMIN); # On édite la configuration if (!empty($_POST)) { $_POST['feed_footer'] = $_POST['content']; $_POST['images_l'] = plxUtils::getValue($_POST['images_l'], 800); $_POST['images_h'] = plxUtils::getValue($_POST['images_h'], 600); $_POST['miniatures_l'] = plxUtils::getValue($_POST['miniatures_l'], 200); $_POST['miniatures_h'] = plxUtils::getValue($_POST['miniatures_h'], 100); unset($_POST['content']); $plxAdmin->editConfiguration($plxAdmin->aConf, $_POST); header('Location: parametres_affichage.php'); exit; } # On récupère les thèmes $aStyles[''] = L_NONE1; $files = plxGlob::getInstance(PLX_ROOT . $plxAdmin->aConf['racine_themes'], true); if ($styles = $files->query("/[a-z0-9-_\\.\\(\\)]+/i")) { foreach ($styles as $k => $v) { if (substr($v, 0, 7) != 'mobile.') { $aStyles[$v] = $v; } } }
/** * Méthode qui effectue une création ou mise a jour d'un article * * @param content données saisies de l'article * @param &id retourne le numero de l'article * @return string * @author Stephane F. et Florent MONTHEL **/ public function editArticle($content, &$id) { # Détermine le numero de fichier si besoin est if ($id == '0000' or $id == '') { $id = $this->nextIdArticle(); } # Vérification de l'intégrité de l'identifiant if (!preg_match('/^_?[0-9]{4}$/', $id)) { $id = ''; return L_ERR_INVALID_ARTICLE_IDENT; } # Génération de notre url d'article if (trim($content['url']) == '') { $content['url'] = plxUtils::title2url($content['title']); } else { $content['url'] = plxUtils::title2url($content['url']); } # URL vide après le passage de la fonction ;) if ($content['url'] == '') { $content['url'] = L_DEFAULT_NEW_ARTICLE_URL; } # Hook plugins if (eval($this->plxPlugins->callHook('plxAdminEditArticle'))) { return; } # Génération du fichier XML $xml = "<?xml version='1.0' encoding='" . PLX_CHARSET . "'?>\n"; $xml .= "<document>\n"; $xml .= "\t" . '<title><![CDATA[' . plxUtils::cdataCheck(trim($content['title'])) . ']]></title>' . "\n"; $xml .= "\t" . '<allow_com>' . $content['allow_com'] . '</allow_com>' . "\n"; $xml .= "\t" . '<template><![CDATA[' . basename($content['template']) . ']]></template>' . "\n"; $xml .= "\t" . '<chapo><![CDATA[' . plxUtils::cdataCheck(trim($content['chapo'])) . ']]></chapo>' . "\n"; $xml .= "\t" . '<content><![CDATA[' . plxUtils::cdataCheck(trim($content['content'])) . ']]></content>' . "\n"; $xml .= "\t" . '<tags><![CDATA[' . plxUtils::cdataCheck(trim($content['tags'])) . ']]></tags>' . "\n"; $meta_description = plxUtils::getValue($content['meta_description']); $xml .= "\t" . '<meta_description><![CDATA[' . plxUtils::cdataCheck(trim($meta_description)) . ']]></meta_description>' . "\n"; $meta_keywords = plxUtils::getValue($content['meta_keywords']); $xml .= "\t" . '<meta_keywords><![CDATA[' . plxUtils::cdataCheck(trim($meta_keywords)) . ']]></meta_keywords>' . "\n"; $title_htmltag = plxUtils::getValue($content['title_htmltag']); $xml .= "\t" . '<title_htmltag><![CDATA[' . plxUtils::cdataCheck(trim($title_htmltag)) . ']]></title_htmltag>' . "\n"; # Hook plugins eval($this->plxPlugins->callHook('plxAdminEditArticleXml')); $xml .= "</document>\n"; # Recherche du nom du fichier correspondant à l'id $oldArt = $this->plxGlob_arts->query('/^' . $id . '.(.*).xml$/', '', 'sort', 0, 1, 'all'); # Si demande de modération de l'article if (isset($content['moderate'])) { $id = '_' . str_replace('_', '', $id); } # Si demande de publication if (isset($content['publish']) or isset($content['draft'])) { $id = str_replace('_', '', $id); } # On genère le nom de notre fichier $time = $content['year'] . $content['month'] . $content['day'] . substr(str_replace(':', '', $content['time']), 0, 4); if (!preg_match('/^[0-9]{12}$/', $time)) { $time = date('YmdHi'); } # Check de la date au cas ou... if (empty($content['catId'])) { $content['catId'] = array('000'); } # Catégorie non classée $filename = PLX_ROOT . $this->aConf['racine_articles'] . $id . '.' . implode(',', $content['catId']) . '.' . trim($content['author']) . '.' . $time . '.' . $content['url'] . '.xml'; # On va mettre à jour notre fichier if (plxUtils::write($xml, $filename)) { # suppression ancien fichier si nécessaire if ($oldArt) { $oldfilename = PLX_ROOT . $this->aConf['racine_articles'] . $oldArt['0']; if ($oldfilename != $filename and file_exists($oldfilename)) { unlink($oldfilename); } } # mise à jour de la liste des tags $this->aTags[$id] = array('tags' => trim($content['tags']), 'date' => $time, 'active' => intval(!in_array('draft', $content['catId']))); $this->editTags(); if ($content['artId'] == '0000' or $content['artId'] == '') { return plxMsg::Info(L_ARTICLE_SAVE_SUCCESSFUL); } else { return plxMsg::Info(L_ARTICLE_MODIFY_SUCCESSFUL); } } else { return plxMsg::Error(L_ARTICLE_SAVE_ERR); } }
/** * Méthode qui parse le commentaire du fichier $filename * * @param filename fichier du commentaire à parser * @return array * @author Florent MONTHEL **/ public function parseCommentaire($filename) { # Mise en place du parseur XML $data = implode('', file($filename)); $parser = xml_parser_create(PLX_CHARSET); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); xml_parse_into_struct($parser, $data, $values, $iTags); xml_parser_free($parser); # Recuperation des valeurs de nos champs XML $com['author'] = plxUtils::getValue($values[$iTags['author'][0]]['value']); if (isset($iTags['type'])) { $com['type'] = plxUtils::getValue($values[$iTags['type'][0]]['value'], 'normal'); } else { $com['type'] = 'normal'; } $com['ip'] = plxUtils::getValue($values[$iTags['ip'][0]]['value']); $com['mail'] = plxUtils::getValue($values[$iTags['mail'][0]]['value']); $com['site'] = plxUtils::getValue($values[$iTags['site'][0]]['value']); $com['content'] = trim($values[$iTags['content'][0]]['value']); $com['parent'] = isset($iTags['parent']) ? plxUtils::getValue($values[$iTags['parent'][0]]['value']) : ''; # Informations obtenues en analysant le nom du fichier $tmp = $this->comInfoFromFilename(basename($filename)); $com['status'] = $tmp['comStatus']; $com['numero'] = $tmp['comId']; $com['article'] = $tmp['artId']; $com['date'] = $tmp['comDate']; $com['index'] = $tmp['comIdx']; # Hook plugins eval($this->plxPlugins->callHook('plxMotorParseCommentaire')); # On retourne le tableau return $com; }
echo L_ARTICLE_LIST_ACTION; ?> </th> </tr> </thead> <tbody> <?php # On va lister les articles if ($arts) { # On a des articles # Initialisation de l'ordre $num = 0; $datetime = date('YmdHi'); while ($plxAdmin->plxRecord_arts->loop()) { # Pour chaque article $author = plxUtils::getValue($plxAdmin->aUsers[$plxAdmin->plxRecord_arts->f('author')]['name']); $publi = (bool) (!($plxAdmin->plxRecord_arts->f('date') > $datetime)); # Catégories : liste des libellés de toutes les categories $draft = ''; $libCats = ''; $catIds = explode(',', $plxAdmin->plxRecord_arts->f('categorie')); if (sizeof($catIds) > 0) { $catsName = array(); foreach ($catIds as $catId) { if ($catId == 'home') { $catsName[] = L_CATEGORY_HOME; } elseif ($catId == 'draft') { $draft = ' - <strong>' . L_CATEGORY_DRAFT . '</strong>'; } elseif (!isset($plxAdmin->aCats[$catId])) { $catsName[] = L_UNCLASSIFIED; } else {
/** * Méthode qui parse le fichier les produits et alimente * le tableau aProds * * @param filename emplacement du fichier XML des produits * @return null * @author David.L **/ public function getProducts($filename = '') { $filename = $filename == '' ? PLX_ROOT . PLX_CONFIG_PATH . 'products.xml' : $filename; if (!is_file($filename)) { return; } # Mise en place du parseur XML $data = implode('', file($filename)); $parser = xml_parser_create(PLX_CHARSET); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); xml_parse_into_struct($parser, $data, $values, $iTags); xml_parser_free($parser); if (isset($iTags['product']) and isset($iTags['name'])) { $nb = sizeof($iTags['name']); $size = ceil(sizeof($iTags['product']) / $nb); for ($i = 0; $i < $nb; $i++) { $attributes = $values[$iTags['product'][$i * $size]]['attributes']; $number = $attributes['number']; # Recuperation du nom du produit $this->aProds[$number]['name'] = plxUtils::getValue($values[$iTags['name'][$i]]['value']); # Recuperation prix ttc $pricettc = plxUtils::getValue($iTags['pricettc'][$i]); $this->aProds[$number]['pricettc'] = plxUtils::getValue($values[$pricettc]['value']); # Recuperation noaddcart $noaddcart = plxUtils::getValue($iTags['noaddcart'][$i]); $this->aProds[$number]['noaddcart'] = plxUtils::getValue($values[$noaddcart]['value']); $notice_noaddcart = plxUtils::getValue($iTags['notice_noaddcart'][$i]); $this->aProds[$number]['notice_noaddcart'] = plxUtils::getValue($values[$notice_noaddcart]['value']); # Recuperation poid $poidg = plxUtils::getValue($iTags['poidg'][$i]); $this->aProds[$number]['poidg'] = plxUtils::getValue($values[$poidg]['value']); # Recuperation image $image = plxUtils::getValue($iTags['image'][$i]); $this->aProds[$number]['image'] = plxUtils::getValue($values[$image]['value']); # Recuperation de la balise title $title_htmltag = plxUtils::getValue($iTags['title_htmltag'][$i]); $this->aProds[$number]['title_htmltag'] = plxUtils::getValue($values[$title_htmltag]['value']); # Recuperation du meta description $meta_description = plxUtils::getValue($iTags['meta_description'][$i]); $this->aProds[$number]['meta_description'] = plxUtils::getValue($values[$meta_description]['value']); # Recuperation du meta keywords $meta_keywords = plxUtils::getValue($iTags['meta_keywords'][$i]); $this->aProds[$number]['meta_keywords'] = plxUtils::getValue($values[$meta_keywords]['value']); # Recuperation du groupe du produit $this->aProds[$number]['group'] = plxUtils::getValue($values[$iTags['group'][$i]]['value']); # Recuperation du de la variable categorie $this->aProds[$number]['pcat'] = plxUtils::getValue($values[$iTags['pcat'][$i]]['value']); $this->aProds[$number]['menu'] = plxUtils::getValue($values[$iTags['menu'][$i]]['value']); # Recuperation de l'url du produit $this->aProds[$number]['url'] = strtolower($attributes['url']); # Recuperation de l'etat du produit $this->aProds[$number]['active'] = intval($attributes['active']); # recuperation du fichier template $this->aProds[$number]['template'] = isset($attributes['template']) ? $attributes['template'] : $this->getParam('template'); # On verifie que le produit existe bien $file = PLX_ROOT . 'data/products/' . $number . '.' . $attributes['url'] . '.php'; # On test si le fichier est lisible $this->aProds[$number]['readable'] = is_readable($file) ? 1 : 0; } } }
/** * Méthode qui affiche la liste des $max derniers articles. * Si la variable $cat_id est renseignée, seuls les articles de cette catégorie sont retournés. * On tient compte si la catégorie est active * * @param format format du texte pour chaque article * @param max nombre d'articles maximum * @param cat_id ids des catégories cible * @param ending texte à ajouter en fin de ligne * @param sort tri de l'affichage des articles (sort|rsort|alpha|random) * @return stdout * @scope global * @author Florent MONTHEL, Stephane F **/ public function lastArtList($format = '<li><a href="#art_url" title="#art_title">#art_title</a></li>', $max = 5, $cat_id = '', $ending = '', $sort = 'rsort') { # Hook Plugins if (eval($this->plxMotor->plxPlugins->callHook('plxShowLastArtList'))) { return; } # Génération de notre motif if (empty($cat_id)) { $motif = '/^[0-9]{4}.(?:[0-9]|home|,)*(?:' . $this->plxMotor->activeCats . '|home)(?:[0-9]|home|,)*.[0-9]{3}.[0-9]{12}.[a-z0-9-]+.xml$/'; } else { $motif = '/^[0-9]{4}.((?:[0-9]|home|,)*(?:' . str_pad($cat_id, 3, '0', STR_PAD_LEFT) . ')(?:[0-9]|home|,)*).[0-9]{3}.[0-9]{12}.[a-z0-9-]+.xml$/'; } # Nouvel objet plxGlob et récupération des fichiers $plxGlob_arts = clone $this->plxMotor->plxGlob_arts; if ($aFiles = $plxGlob_arts->query($motif, 'art', $sort, 0, $max, 'before')) { foreach ($aFiles as $v) { # On parcourt tous les fichiers $art = $this->plxMotor->parseArticle(PLX_ROOT . $this->plxMotor->aConf['racine_articles'] . $v); $num = intval($art['numero']); $date = $art['date']; if ($this->plxMotor->mode == 'article' and $art['numero'] == $this->plxMotor->cible) { $status = 'active'; } else { $status = 'noactive'; } # Mise en forme de la liste des catégories $catList = array(); $catIds = explode(',', $art['categorie']); foreach ($catIds as $idx => $catId) { if (isset($this->plxMotor->aCats[$catId])) { # La catégorie existe $catName = plxUtils::strCheck($this->plxMotor->aCats[$catId]['name']); $catUrl = $this->plxMotor->aCats[$catId]['url']; $catList[] = '<a title="' . $catName . '" href="' . $this->plxMotor->urlRewrite('?categorie' . intval($catId) . '/' . $catUrl) . '">' . $catName . '</a>'; } else { $catList[] = L_UNCLASSIFIED; } } # On modifie nos motifs $row = str_replace('#art_id', $num, $format); $row = str_replace('#cat_list', implode(', ', $catList), $row); $row = str_replace('#art_url', $this->plxMotor->urlRewrite('?article' . $num . '/' . $art['url']), $row); $row = str_replace('#art_status', $status, $row); $author = plxUtils::getValue($this->plxMotor->aUsers[$art['author']]['name']); $row = str_replace('#art_author', plxUtils::strCheck($author), $row); $row = str_replace('#art_title', plxUtils::strCheck($art['title']), $row); $strlength = preg_match('/#art_chapo\\(([0-9]+)\\)/', $row, $capture) ? $capture[1] : '100'; $chapo = plxUtils::truncate($art['chapo'], $strlength, $ending, true, true); $row = str_replace('#art_chapo(' . $strlength . ')', '#art_chapo', $row); $row = str_replace('#art_chapo', $chapo, $row); $strlength = preg_match('/#art_content\\(([0-9]+)\\)/', $row, $capture) ? $capture[1] : '100'; $content = plxUtils::truncate($art['content'], $strlength, $ending, true, true); $row = str_replace('#art_content(' . $strlength . ')', '#art_content', $row); $row = str_replace('#art_content', $content, $row); $row = str_replace('#art_date', plxDate::formatDate($date, '#num_day/#num_month/#num_year(4)'), $row); $row = str_replace('#art_hour', plxDate::formatDate($date, '#hour:#minute'), $row); $row = str_replace('#art_time', plxDate::formatDate($date, '#time'), $row); $row = plxDate::formatDate($date, $row); $row = str_replace('#art_nbcoms', $art['nb_com'], $row); $row = str_replace('#art_thumbnail', '<img class="art_thumbnail" src="#img_url" alt="#img_alt" title="#img_title" />', $row); $row = str_replace('#img_url', $this->plxMotor->urlRewrite($art['thumbnail']), $row); $row = str_replace('#img_title', $art['thumbnail_title'], $row); $row = str_replace('#img_alt', $art['thumbnail_alt'], $row); # Hook plugin eval($this->plxMotor->plxPlugins->callHook('plxShowLastArtListContent')); # On genère notre ligne echo $row; } } }