Beispiel #1
0
function install($content, $config)
{
    # gestion du timezone
    date_default_timezone_set($config['timezone']);
    # Création du fichier de configuration
    $xml = '<?xml version="1.0" encoding="' . PLX_CHARSET . '"?>' . "\n";
    $xml .= '<document>' . "\n";
    foreach ($config as $k => $v) {
        if (is_numeric($v)) {
            $xml .= "\t<parametre name=\"{$k}\">" . $v . "</parametre>\n";
        } else {
            $xml .= "\t<parametre name=\"{$k}\"><![CDATA[" . plxUtils::cdataCheck($v) . "]]></parametre>\n";
        }
    }
    $xml .= '</document>';
    plxUtils::write($xml, path('XMLFILE_PARAMETERS'));
    # Création du fichier des utilisateurs
    $salt = plxUtils::charAleatoire(10);
    $xml = '<?xml version="1.0" encoding="' . PLX_CHARSET . '"?>' . "\n";
    $xml .= "<document>\n";
    $xml .= "\t" . '<user number="001" active="1" profil="0" delete="0">' . "\n";
    $xml .= "\t\t" . '<login><![CDATA[' . trim($content['login']) . ']]></login>' . "\n";
    $xml .= "\t\t" . '<name><![CDATA[' . trim($content['name']) . ']]></name>' . "\n";
    $xml .= "\t\t" . '<infos><![CDATA[]]></infos>' . "\n";
    $xml .= "\t\t" . '<password><![CDATA[' . sha1($salt . md5(trim($content['pwd']))) . ']]></password>' . "\n";
    $xml .= "\t\t" . '<salt><![CDATA[' . $salt . ']]></salt>' . "\n";
    $xml .= "\t\t" . '<email><![CDATA[]]></email>' . "\n";
    $xml .= "\t\t" . '<lang><![CDATA[' . $config['default_lang'] . ']]></lang>' . "\n";
    $xml .= "\t</user>\n";
    $xml .= "</document>";
    plxUtils::write($xml, path('XMLFILE_USERS'));
    # Création du fichier des categories
    $xml = '<?xml version="1.0" encoding="' . PLX_CHARSET . '"?>' . "\n";
    $xml .= '<document>' . "\n";
    $xml .= "\t" . '<categorie number="001" active="1" homepage="1" tri="' . $config['tri'] . '" bypage="' . $config['bypage'] . '" menu="oui" url="' . L_DEFAULT_CATEGORY_URL . '" template="categorie.php"><name><![CDATA[' . plxUtils::strRevCheck(L_DEFAULT_CATEGORY_TITLE) . ']]></name><description><![CDATA[]]></description><meta_description><![CDATA[]]></meta_description><meta_keywords><![CDATA[]]></meta_keywords><title_htmltag><![CDATA[]]></title_htmltag></categorie>' . "\n";
    $xml .= '</document>';
    plxUtils::write($xml, path('XMLFILE_CATEGORIES'));
    # Création du fichier des pages statiques
    $xml = '<?xml version="1.0" encoding="' . PLX_CHARSET . '"?>' . "\n";
    $xml .= '<document>' . "\n";
    $xml .= "\t" . '<statique number="001" active="1" menu="oui" url="' . L_DEFAULT_STATIC_URL . '" template="static.php"><group><![CDATA[]]></group><name><![CDATA[' . plxUtils::strRevCheck(L_DEFAULT_STATIC_TITLE) . ']]></name><meta_description><![CDATA[]]></meta_description><meta_keywords><![CDATA[]]></meta_keywords><title_htmltag><![CDATA[]]></title_htmltag></statique>' . "\n";
    $xml .= '</document>';
    plxUtils::write($xml, path('XMLFILE_STATICS'));
    plxUtils::write(file_get_contents(PLX_CORE . '/lib/html.static.txt'), PLX_ROOT . $config['racine_statiques'] . '001.' . L_DEFAULT_STATIC_URL . '.php');
    # Création du premier article
    $html = explode('-----', file_get_contents(PLX_CORE . '/lib/html.article.txt'));
    $xml = '<?xml version="1.0" encoding="' . PLX_CHARSET . '"?>' . "\n";
    $xml .= '<document>
	<title><![CDATA[' . plxUtils::strRevCheck(L_DEFAULT_ARTICLE_TITLE) . ']]></title>
	<allow_com>1</allow_com>
	<template><![CDATA[article.php]]></template>
	<chapo>
		<![CDATA[' . $html[0] . ']]>
	</chapo>
	<content>
		<![CDATA[' . $html[1] . ']]>
	</content>
	<tags>
		<![CDATA[PluXml]]>
	</tags>
	<meta_description>
		<![CDATA[]]>
	</meta_description>
	<meta_keywords>
		<![CDATA[]]>
	</meta_keywords>
	<title_htmltag>
		<![CDATA[]]>
	</title_htmltag>
</document>';
    plxUtils::write($xml, PLX_ROOT . $config['racine_articles'] . '0001.001.001.' . date('YmdHi') . '.' . L_DEFAULT_ARTICLE_URL . '.xml');
    # Création du fichier des tags servant de cache
    $xml = '<?xml version="1.0" encoding="' . PLX_CHARSET . '"?>' . "\n";
    $xml .= '<document>' . "\n";
    $xml .= "\t" . '<article number="0001" date="' . date('YmdHi') . '" active="1"><![CDATA[PluXml]]></article>' . "\n";
    $xml .= '</document>';
    plxUtils::write($xml, path('XMLFILE_TAGS'));
    # Création du fichier des plugins
    $xml = '<?xml version="1.0" encoding="' . PLX_CHARSET . '"?>' . "\n";
    $xml .= '<document>' . "\n";
    $xml .= '</document>';
    plxUtils::write($xml, path('XMLFILE_PLUGINS'));
    # Création du premier commentaire
    $xml = '<?xml version="1.0" encoding="' . PLX_CHARSET . '"?>' . "\n";
    $xml .= '<comment>
	<author><![CDATA[pluxml]]></author>
		<type>normal</type>
		<ip>127.0.0.1</ip>
		<mail><![CDATA[contact@pluxml.org]]></mail>
		<site><![CDATA[http://www.pluxml.org]]></site>
		<content><![CDATA[' . plxUtils::strRevCheck(L_DEFAULT_COMMENT_CONTENT) . ']]></content>
	</comment>';
    plxUtils::write($xml, PLX_ROOT . $config['racine_commentaires'] . '0001.' . date('U') . '-1.xml');
}
$plxAdmin->getCommentaires('/^_' . $artRegex . '.(.*).xml$/', 'rsort', $start, $plxAdmin->aConf['bypage_admin_coms'], 'all');
if ($plxAdmin->plxGlob_coms->count and !empty($plxAdmin->plxRecord_coms->size)) {
    # On a des commentaires
    while ($plxAdmin->plxRecord_coms->loop()) {
        # On boucle
        $year = substr($plxAdmin->plxRecord_coms->f('date'), 0, 4);
        $month = substr($plxAdmin->plxRecord_coms->f('date'), 5, 2);
        $day = substr($plxAdmin->plxRecord_coms->f('date'), 8, 2);
        $time = substr($plxAdmin->plxRecord_coms->f('date'), 11, 8);
        $artId = $plxAdmin->plxRecord_coms->f('article');
        $id = '_' . $artId . '.' . $plxAdmin->plxRecord_coms->f('numero');
        # On coupe le commentaire mais attention aux entités HTML
        if ($plxAdmin->plxRecord_coms->f('type') == 'admin') {
            $content = plxUtils::strCut(strip_tags($plxAdmin->plxRecord_coms->f('content')), 70);
        } else {
            $content = plxUtils::strCheck(plxUtils::strCut(plxUtils::strRevCheck($plxAdmin->plxRecord_coms->f('content')), 70));
        }
        # On génère notre ligne
        echo '<tr class="line-' . $plxAdmin->plxRecord_coms->i % 2 . '">';
        echo '<td><input type="checkbox" name="idCom[]" value="' . $id . '" /></td>';
        echo '<td>&nbsp;' . $day . '/' . $month . '/' . $year . ' ' . $time . '</td>';
        echo '<td>&nbsp;' . plxUtils::strCut($plxAdmin->plxRecord_coms->f('author'), 15) . '</td>';
        echo '<td>&nbsp;<a href="commentaire.php?c=' . $id . (!empty($_GET['a']) ? '&amp;a=' . $_GET['a'] : '') . '" title="&Eacute;diter ce commentaire">' . $content . '</a></td>';
        echo '<td style="text-align:center"> ';
        echo '<a href="commentaire.php?c=' . $id . (!empty($_GET['a']) ? '&amp;a=' . $_GET['a'] : '') . '" title="&Eacute;diter ce commentaire">&Eacute;diter</a> - ';
        echo '<a href="article.php?a=' . $artId . '" title="Article attach&eacute; &agrave; ce commentaire">Article</a>';
        echo '</td></tr>';
    }
    ?>
	<tr>
		<td colspan="5">
Beispiel #3
0
    $artId = $result['numero'];
    $allow_com = $result['allow_com'];
    $template = $result['template'];
    $meta_description = $result['meta_description'];
    $meta_keywords = $result['meta_keywords'];
    $title_htmltag = $result['title_htmltag'];
    if ($author != $_SESSION['user'] and $_SESSION['profil'] == PROFIL_WRITER) {
        plxMsg::Error(L_ERR_FORBIDDEN_ARTICLE);
        header('Location: index.php');
        exit;
    }
    # Hook Plugins
    eval($plxAdmin->plxPlugins->callHook('AdminArticleParseData'));
} else {
    # On a rien validé, c'est pour la création d'un article
    $title = plxUtils::strRevCheck(L_DEFAULT_NEW_ARTICLE_TITLE);
    $chapo = $url = '';
    $content = '';
    $tags = '';
    $author = $_SESSION['user'];
    $date = array('year' => date('Y'), 'month' => date('m'), 'day' => date('d'), 'time' => date('H:i'));
    $catId = array('draft');
    $artId = '0000';
    $allow_com = $plxAdmin->aConf['allow_com'];
    $template = 'article.php';
    $meta_description = $meta_keywords = $title_htmltag = '';
    # Hook Plugins
    eval($plxAdmin->plxPlugins->callHook('AdminArticleInitData'));
}
# On inclut le header
include dirname(__FILE__) . '/top.php';
Beispiel #4
0
             $art_num = intval($art['numero']);
             $art_url = $art['url'];
             $art_title = plxUtils::strCheck($art['title']);
             $art_date = plxDate::formatDate($art['date'], $format_date);
             echo '<li>' . $art_date . ': <a href="' . $plxMotor->urlRewrite('?article' . $art_num . '/' . $art_url) . '">' . $art_title . '</a></li>';
         }
     }
 }
 # recherche dans les pages statiques
 if ($plxMotor->aStats) {
     foreach ($plxMotor->aStats as $k => $v) {
         if ($v['active'] == 1 and $v['url'] != $plxMotor->mode) {
             # si la page est bien active
             $filename = PLX_ROOT . $plxMotor->aConf['racine_statiques'] . $k . '.' . $v['url'] . '.php';
             if (file_exists($filename)) {
                 $searchstring = strtolower(plxUtils::strRevCheck(file_get_contents($filename)));
                 $searchstring = plxUtils::unSlash($searchstring);
                 $searchok = false;
                 foreach ($searchwords as $word) {
                     if (strpos($searchstring, $word) !== false) {
                         $searchok = true;
                     }
                 }
                 if ($searchok) {
                     $searchresults = true;
                     $stat_num = intval($k);
                     $stat_url = $v['url'];
                     $stat_title = plxUtils::strCheck($v['name']);
                     echo '<li><a href="' . $plxMotor->urlRewrite('?static' . $stat_num . '/' . $stat_url) . '">' . $stat_title . '</a></li>';
                 }
             }
Beispiel #5
0
 /**
  * Méthode qui affiche la liste des $max derniers commentaires.
  * Si la variable $art_id est renseignée, seuls les commentaires de cet article sont retournés.
  *
  * @param	format	format du texte pour chaque commentaire
  * @param	max		nombre de commentaires maximum
  * @param	art_id	id de l'article cible (24,3)
  * @param	cat_ids	liste des categories pour filtrer les derniers commentaires (sous la forme 001|002)
  * @return	stdout
  * @scope	global
  * @author	Florent MONTHEL, Stephane F
  **/
 public function lastComList($format = '<li><a href="#com_url">#com_author L_SAID :</a><br/>#com_content(50)</li>', $max = 5, $art_id = '', $cat_ids = '')
 {
     # Hook Plugins
     if (eval($this->plxMotor->plxPlugins->callHook('plxShowLastComList'))) {
         return;
     }
     # Génération de notre motif
     if (empty($art_id)) {
         $motif = '/^[0-9]{4}.[0-9]{10}-[0-9]+.xml$/';
     } else {
         $motif = '/^' . str_pad($art_id, 4, '0', STR_PAD_LEFT) . '.[0-9]{10}-[0-9]+.xml$/';
     }
     $count = 1;
     $datetime = date('YmdHi');
     # Nouvel objet plxGlob et récupération des fichiers
     $plxGlob_coms = clone $this->plxMotor->plxGlob_coms;
     if ($aFiles = $plxGlob_coms->query($motif, 'com', 'rsort', 0, false, 'before')) {
         $aComArtTitles = array();
         # tableau contenant les titres des articles
         $isComArtTitle = strpos($format, '#com_art_title') != FALSE ? true : false;
         # On parcourt les fichiers des commentaires
         foreach ($aFiles as $v) {
             # On filtre si le commentaire appartient à un article d'une catégorie inactive
             if (isset($this->plxMotor->activeArts[substr($v, 0, 4)])) {
                 $com = $this->plxMotor->parseCommentaire(PLX_ROOT . $this->plxMotor->aConf['racine_commentaires'] . $v);
                 $artInfo = $this->plxMotor->artInfoFromFilename($this->plxMotor->plxGlob_arts->aFiles[$com['article']]);
                 if ($artInfo['artDate'] <= $datetime) {
                     # on ne prends que les commentaires pour les articles publiés
                     if (empty($cat_ids) or preg_match('/(' . $cat_ids . ')/', $artInfo['catId'])) {
                         $url = '?article' . intval($com['article']) . '/' . $artInfo['artUrl'] . '#c' . $com['article'] . '-' . $com['index'];
                         $date = $com['date'];
                         $content = strip_tags($com['content']);
                         # On modifie nos motifs
                         $row = str_replace('L_SAID', L_SAID, $format);
                         $row = str_replace('#com_id', $com['index'], $row);
                         $row = str_replace('#com_url', $this->plxMotor->urlRewrite($url), $row);
                         $row = str_replace('#com_author', $com['author'], $row);
                         while (preg_match('/#com_content\\(([0-9]+)\\)/', $row, $capture)) {
                             if ($com['author'] == 'admin') {
                                 $row = str_replace('#com_content(' . $capture[1] . ')', plxUtils::strCut($content, $capture[1]), $row);
                             } else {
                                 $row = str_replace('#com_content(' . $capture[1] . ')', plxUtils::strCheck(plxUtils::strCut(plxUtils::strRevCheck($content), $capture[1])), $row);
                             }
                         }
                         $row = str_replace('#com_content', $content, $row);
                         $row = str_replace('#com_date', plxDate::formatDate($date, '#num_day/#num_month/#num_year(4)'), $row);
                         $row = str_replace('#com_hour', plxDate::formatDate($date, '#time'), $row);
                         $row = plxDate::formatDate($date, $row);
                         # récupération du titre de l'article
                         if ($isComArtTitle) {
                             if (isset($aComArtTitles[$com['article']])) {
                                 $row = str_replace('#com_art_title', $aComArtTitles[$com['article']], $row);
                             } else {
                                 if ($file = $this->plxMotor->plxGlob_arts->query('/^' . $com['article'] . '.(.*).xml$/')) {
                                     $art = $this->plxMotor->parseArticle(PLX_ROOT . $this->plxMotor->aConf['racine_articles'] . $file[0]);
                                     $aComArtTitles[$com['article']] = $art_title = $art['title'];
                                     $row = str_replace('#com_art_title', $art_title, $row);
                                 }
                             }
                         }
                         # On genère notre ligne
                         echo $row;
                         $count++;
                     }
                 }
             }
             if ($count > $max) {
                 break;
             }
         }
     }
 }
Beispiel #6
0
 /**
  * M�thode qui affiche la liste des $max derniers commentaires.
  * Si la variable $art_id est renseign�e, seulement les commentaires de cet article seront retourn�s.
  *
  * @param	format	format du texte pour chaque commentaire (variable: #com_id, #com_url, #com_author, #com_content(num), #com_content, #com_date, #com_hour)
  * @param	max		nombre de commentaires maximum
  * @param	art_id	id de l'article cible (24,3)
  * @return	stdout
  * @scope	global
  * @author	Florent MONTHEL, Stephane F
  **/
 public function lastComList($format = '<li><a href="#com_url">#com_author a dit :</a><br/>#com_content(50)</li>', $max = 5, $art_id = '')
 {
     # G�n�ration de notre motif
     if (empty($art_id)) {
         $motif = '/^[0-9]{4}.[0-9]{10}-[0-9]+.xml$/';
     } else {
         $motif = '/^' . str_pad($art_id, 4, '0', STR_PAD_LEFT) . '.[0-9]{10}-[0-9]+.xml$/';
     }
     # Nouvel objet plxGlob et r�cup�ration des fichiers
     $plxGlob_coms = plxGlob::getInstance(PLX_ROOT . $this->plxMotor->aConf['racine_commentaires']);
     $aFiles = $plxGlob_coms->query($motif, 'com', 'rsort', 0, $max);
     # On parse les fichiers
     if (is_array($aFiles)) {
         # On a des fichiers
         foreach ($aFiles as $v) {
             # On parcourt tous les fichiers
             $com = $this->plxMotor->parseCommentaire(PLX_ROOT . $this->plxMotor->aConf['racine_commentaires'] . $v);
             $url = '?article' . intval($com['article']) . '/#c' . $com['numero'];
             $date = $com['date'];
             $content = strip_tags($com['content']);
             # On modifie nos motifs
             $row = str_replace('#com_id', $com['numero'], $format);
             $row = str_replace('#com_url', $this->plxMotor->urlRewrite($url), $row);
             $row = str_replace('#com_author', $com['author'], $row);
             while (preg_match('/#com_content\\(([0-9]+)\\)/', $row, $capture)) {
                 if ($com['author'] == 'admin') {
                     $row = str_replace('#com_content(' . $capture[1] . ')', plxUtils::strCut($content, $capture[1]), $row);
                 } else {
                     $row = str_replace('#com_content(' . $capture[1] . ')', plxUtils::strCheck(plxUtils::strCut(plxUtils::strRevCheck($content), $capture[1])), $row);
                 }
             }
             $row = str_replace('#com_content', $content, $row);
             $row = str_replace('#com_date', plxDate::dateIsoToHum($date, '#num_day/#num_month/#num_year(4)'), $row);
             $row = str_replace('#com_hour', plxDate::dateIsoToHum($date, '#hour:#minute'), $row);
             # On gen�re notre ligne
             echo $row;
         }
     }
 }