public function step1() { echo L_UPDATE_USERS_MIGRATION . "<br />"; # On génère le fichier XML $xml = "<?xml version=\"1.0\" encoding=\"" . PLX_CHARSET . "\"?>\n"; $xml .= "<document>\n"; foreach ($this->plxAdmin->aUsers as $user_id => $user) { $salt = plxUtils::charAleatoire(10); $password = sha1($salt . $user['password']); $xml .= "\t" . '<user number="' . $user_id . '" active="' . $user['active'] . '" profil="' . $user['profil'] . '" delete="' . $user['delete'] . '">' . "\n"; $xml .= "\t\t" . '<login><![CDATA[' . plxUtils::cdataCheck($user['login']) . ']]></login>' . "\n"; $xml .= "\t\t" . '<name><![CDATA[' . plxUtils::cdataCheck($user['name']) . ']]></name>' . "\n"; $xml .= "\t\t" . '<infos><![CDATA[' . plxUtils::cdataCheck($user['infos']) . ']]></infos>' . "\n"; $xml .= "\t\t" . '<password><![CDATA[' . $password . ']]></password>' . "\n"; $xml .= "\t\t" . '<salt><![CDATA[' . $salt . ']]></salt>' . "\n"; $xml .= "\t\t" . '<email><![CDATA[' . $user['email'] . ']]></email>' . "\n"; $xml .= "\t\t" . '<lang><![CDATA[' . $user['lang'] . ']]></lang>' . "\n"; $xml .= "\t</user>\n"; } $xml .= "</document>"; if (!plxUtils::write($xml, PLX_ROOT . $this->plxAdmin->aConf['users'])) { echo '<p class="error">' . L_UPDATE_ERR_USERS_MIGRATION . ' (' . $this->plxAdmin->aConf['users'] . ')</p>'; return false; } return true; }
public function OnActivate() { if (version_compare(PHP_VERSION, PP_REQUIRED_PHP_VERSION) < 0) { exit(sprintf($this->getLang('L_PHP_VERSION_TOO_LOW'), PP_REQUIRED_PHP_VERSION)); } if (!is_file(PLX_ROOT . 'data/configuration/plugins/pickypaste.site.css')) { $css = file_get_contents(PLX_PLUGINS . 'pickyPasteInPluxml/css/pickypaste.css'); plxUtils::write($css, PLX_ROOT . 'data/configuration/plugins/pickyPasteInPluxml.site.css'); } }
public function step4() { echo L_UPDATE_FILE . " (" . $this->plxAdmin->aConf['categories'] . ")<br />"; $data = file_get_contents(PLX_ROOT . $this->plxAdmin->aConf['categories']); $tag = 'categorie'; if (preg_match_all('{<' . $tag . '[^>]*>(.*?)</' . $tag . '>}', $data, $matches, PREG_PATTERN_ORDER)) { foreach ($matches[0] as $match) { if (!preg_match('/<title_htmltag>/', $match)) { $str = str_replace('</' . $tag . '>', '<title_htmltag><![CDATA[]]></title_htmltag></' . $tag . '>', $match); $data = str_replace($match, $str, $data); } } if (!plxUtils::write($data, PLX_ROOT . $this->plxAdmin->aConf['categories'])) { echo '<p class="error">' . L_UPDATE_ERR_FILE . '</p>'; return false; } } return true; }
public function step2() { echo L_UPDATE_UPDATE_PLUGINS_FILE . "<br />"; # récupération de la liste des plugins $aPlugins = $this->loadConfig(); # Migration du format du fichier plugins.xml $xml = "<?xml version='1.0' encoding='" . PLX_CHARSET . "'?>\n"; $xml .= "<document>\n"; foreach ($aPlugins as $k => $v) { if (isset($v['activate']) and $v['activate'] != '0') { $xml .= "\t<plugin name=\"{$k}\"></plugin>\n"; } } $xml .= "</document>"; if (!plxUtils::write($xml, path('XMLFILE_PLUGINS'))) { echo '<p class="error">' . L_UPDATE_ERR_FILE_PROCESSING . '</p>'; return false; } return true; }
public function step2() { echo L_UPDATE_ARTICLES_CONVERSION . "<br />"; $plxGlob_arts = plxGlob::getInstance(PLX_ROOT . $this->plxAdmin->aConf['racine_articles']); if ($files = $plxGlob_arts->query('/(.*).xml$/', 'art')) { foreach ($files as $filename) { if (is_readable($filename)) { $data = file_get_contents(PLX_ROOT . $this->plxAdmin->aConf['racine_articles'] . $filename); if (!preg_match('/\\]\\]<\\/title_htmltag>/', $data)) { $data = preg_replace("/<\\/document>\$/", "\t<title_htmltag>\n\t\t<![CDATA[]]>\n\t</title_htmltag>\n</document>", $data); } if (!plxUtils::write($data, PLX_ROOT . $this->plxAdmin->aConf['racine_articles'] . $filename)) { echo '<p class="error">' . L_UPDATE_ERR_FILE_PROCESSING . ' : ' . $filename . '</p>'; return false; } } } } return true; }
public function step9() { if (!is_file(PLX_ROOT . '.htaccess')) { echo "Création du fichier .htaccess<br />"; $txt = '<Files "version"> Order allow,deny Deny from all </Files>'; if (!plxUtils::write($txt, PLX_ROOT . '.htaccess')) { echo '<p class="error">Erreur pendant la crétion du fichier .htaccess</p>'; return false; } } return true; }
/** * Méthode qui sauvegarde le fichier des parametres du plugin parameters.xml * * @return boolean resultat de la sauvegarde / TRUE = ok * @author Stephane F **/ public function saveParams() { # Début du fichier XML $xml = "<?xml version='1.0' encoding='" . PLX_CHARSET . "'?>\n"; $xml .= "<document>\n"; foreach ($this->aParams as $k => $v) { switch ($v['type']) { case 'numeric': $xml .= "\t<parameter name=\"{$k}\" type=\"" . $v['type'] . "\">" . intval($v['value']) . "</parameter>\n"; break; case 'string': $xml .= "\t<parameter name=\"{$k}\" type=\"" . $v['type'] . "\">" . plxUtils::cdataCheck(plxUtils::strCheck($v['value'])) . "</parameter>\n"; break; case 'cdata': $xml .= "\t<parameter name=\"{$k}\" type=\"" . $v['type'] . "\"><![CDATA[" . plxUtils::cdataCheck($v['value']) . "]]></parameter>\n"; break; } } $xml .= "</document>"; # On écrit le fichier if (plxUtils::write($xml, $this->plug['parameters.xml'])) { # suppression ancien fichier parameters.xml s'il existe encore (5.1.7+) if (file_exists($this->plug['dir'] . $this->plug['name'] . '/parameters.xml')) { unlink($this->plug['dir'] . $this->plug['name'] . '/parameters.xml'); } return plxMsg::Info(L_SAVE_SUCCESSFUL); } else { return plxMsg::Error(L_SAVE_ERR . ' ' . $this->plug['parameters.xml']); } }
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'); }
/** * Méthode qui sauvegarde la liste des tags dans fichier XML * selon le contenu de la variable de classe $aTags * * @param null * @return null * @author Stephane F **/ public function editTags() { # Génération du fichier XML $xml = "<?xml version='1.0' encoding='" . PLX_CHARSET . "'?>\n"; $xml .= "<document>\n"; foreach ($this->aTags as $id => $tag) { $xml .= "\t" . '<article number="' . $id . '" date="' . $tag['date'] . '" active="' . $tag['active'] . '"><![CDATA[' . $tag['tags'] . ']]></article>' . "\n"; } $xml .= "</document>"; # On écrit le fichier plxUtils::write($xml, PLX_ROOT . $this->aConf['tags']); }
} $style = $plxAdmin->aConf['style']; $filename = realpath(PLX_ROOT . $plxAdmin->aConf['racine_themes'] . $style . '/' . $tpl); if (!preg_match('#^' . str_replace('\\', '/', realpath(PLX_ROOT . $plxAdmin->aConf['racine_themes'] . $style . '/') . '#'), str_replace('\\', '/', $filename))) { $tpl = 'home.php'; } $filename = realpath(PLX_ROOT . $plxAdmin->aConf['racine_themes'] . $style . '/' . $tpl); # On teste l'existence du thème if (empty($style) or !is_dir(PLX_ROOT . $plxAdmin->aConf['racine_themes'] . $style)) { plxMsg::Error(L_CONFIG_EDITTPL_ERROR_NOTHEME); header('Location: parametres_affichage.php'); exit; } # Traitement du formulaire: sauvegarde du template if (isset($_POST['submit']) and trim($_POST['content']) != '') { if (plxUtils::write($_POST['content'], $filename)) { plxMsg::Info(L_SAVE_FILE_SUCCESSFULLY); } else { plxMsg::Error(L_SAVE_FILE_ERROR); } } # On récupère les fichiers templates du thèmes $aTemplates = array(); function listFolderFiles($dir, $include, $root = '') { $content = array(); $ffs = scandir($dir); foreach ($ffs as $ff) { if ($ff != '.' && $ff != '..') { $ext = strtolower(strrchr($ff, '.')); if (!is_dir($dir . '/' . $ff) and is_array($include) and in_array($ext, $include)) {
public function step6() { echo L_UPDATE_CREATE_PLUGINS_FILE . "<br />"; $xml = '<?xml version="1.0" encoding="' . PLX_CHARSET . '"?>' . "\n"; $xml .= '<document>' . "\n"; $xml .= '</document>'; if (!plxUtils::write($xml, PLX_ROOT . $this->plxAdmin->aConf['plugins'])) { echo '<p class="error">' . L_UPDATE_ERR_CREATE_PLUGINS_FILE . '</p>'; return false; } return true; }
/** * Méthode qui crée physiquement le fichier XML du commentaire * * @param comment array avec les données du commentaire à ajouter * @return booléen * @author Anthony GUÉRIN, Florent MONTHEL et Stéphane F **/ public function addCommentaire($content) { # Hook plugins if (eval($this->plxPlugins->callHook('plxMotorAddCommentaire'))) { return; } # On genere le contenu de notre fichier XML $xml = "<?xml version='1.0' encoding='" . PLX_CHARSET . "'?>\n"; $xml .= "<comment>\n"; $xml .= "\t<author><![CDATA[" . plxUtils::cdataCheck($content['author']) . "]]></author>\n"; $xml .= "\t<type>" . $content['type'] . "</type>\n"; $xml .= "\t<ip>" . $content['ip'] . "</ip>\n"; $xml .= "\t<mail><![CDATA[" . plxUtils::cdataCheck($content['mail']) . "]]></mail>\n"; $xml .= "\t<site><![CDATA[" . plxUtils::cdataCheck($content['site']) . "]]></site>\n"; $xml .= "\t<content><![CDATA[" . plxUtils::cdataCheck($content['content']) . "]]></content>\n"; $xml .= "\t<parent><![CDATA[" . plxUtils::cdataCheck($content['parent']) . "]]></parent>\n"; # Hook plugins eval($this->plxPlugins->callHook('plxMotorAddCommentaireXml')); $xml .= "</comment>\n"; # On ecrit ce contenu dans notre fichier XML return plxUtils::write($xml, PLX_ROOT . $this->aConf['racine_commentaires'] . $content['filename']); }
public function step9() { if (!is_file(PLX_ROOT . '.htaccess')) { echo L_UPDATE_CREATE_HTACCESS_FILE . "<br />"; $txt = '<Files "version"> Order allow,deny Deny from all </Files>'; if (!plxUtils::write($txt, PLX_ROOT . '.htaccess')) { echo '<p class="error">' . L_UPDATE_ERR_CREATE_HTACCESS_FILE . '</p>'; return false; } } return true; }
/** * Méthode qui crée physiquement le fichier XML du commentaire * * @param filename fichier du commentaire à créer * @param author auteur du commmentaire * @param type type du commmentaire (admin ou normal) * @param ip adresse IP posteuse du commmentaire * @param mail mail de l'auteur du commmentaire * @param site site de l'auteur du commmentaire * @param contenu contenu du commmentaire * @return booléen * @author Anthony GUÉRIN et Florent MONTHEL **/ public function addCommentaire($filename, $author, $type, $ip, $mail, $site, $contenu) { # On genere le contenu de notre fichier XML $xml = "<?xml version='1.0' encoding='" . PLX_CHARSET . "'?>\n"; $xml .= "<comment>\n"; $xml .= "\t<author><![CDATA[{$author}]]></author>\n"; $xml .= "\t<type>{$type}</type>\n"; $xml .= "\t<ip>{$ip}</ip>\n"; $xml .= "\t<mail><![CDATA[{$mail}]]></mail>\n"; $xml .= "\t<site><![CDATA[{$site}]]></site>\n"; $xml .= "\t<content><![CDATA[{$contenu}]]></content>\n"; $xml .= "</comment>\n"; # On ecrit ce contenu dans notre fichier XML return plxUtils::write($xml, $filename); }
/** * Méthode qui sauvegarde le contenu d'un produit * * @param content données à sauvegarder * @return string * @author David.L **/ public function editProduct($content) { # Mise à jour du fichier product.xml if (isset($content["listeCategories"])) { $this->aProds[$content['id']]['group'] = implode(",", $content["listeCategories"]); } // formatage du prix et du poids à l'édition foreach (array("pricettc", "poidg") as $champ) { $content[$champ] = number_format($content[$champ], 2, ".", ""); } // données du produit $this->aProds[$content['id']]['image'] = $content['image']; $this->aProds[$content['id']]['noaddcart'] = $content['noaddcart']; $this->aProds[$content['id']]['notice_noaddcart'] = $content['notice_noaddcart']; $this->aProds[$content['id']]['pricettc'] = $content['pricettc']; $this->aProds[$content['id']]['poidg'] = $content['poidg']; $this->aProds[$content['id']]['template'] = $content['template']; $this->aProds[$content['id']]['title_htmltag'] = trim($content['title_htmltag']); $this->aProds[$content['id']]['meta_description'] = trim($content['meta_description']); $this->aProds[$content['id']]['meta_keywords'] = trim($content['meta_keywords']); # Hook plugins //eval($this->plxPlugins->callHook('plxAdminEditProduct')); if ($this->editProducts(null, true)) { if (!is_dir(PLX_ROOT . 'data/products/')) { mkdir(PLX_ROOT . 'data/products/', 0755, true); } # Génération du nom du fichier de la page statique $filename = PLX_ROOT . 'data/products/' . $content['id'] . '.' . $this->aProds[$content['id']]['url'] . '.php'; # On écrit le fichier if (plxUtils::write($content['content'], $filename)) { return plxMsg::Info(L_SAVE_SUCCESSFUL); } else { return plxMsg::Error(L_SAVE_ERR . ' ' . $filename); } } }
public function onActivate() { if (!is_file(PLX_ROOT . 'data/configuration/plugins/cryptMyPluxml.admin.css')) { $css = file_get_contents(PLX_PLUGINS . 'cryptMyPluxml/css/admin.css'); plxUtils::write($css, PLX_ROOT . 'data/configuration/plugins/cryptMyPluxml.admin.css'); } if (!is_file(PLX_ROOT . 'data/configuration/plugins/cryptMyPluxml.site.css')) { $css = file_get_contents(PLX_PLUGINS . 'cryptMyPluxml/css/site.css'); plxUtils::write($css, PLX_ROOT . 'data/configuration/plugins/cryptMyPluxml.site.css'); } }
public function step3() { # Récupère le nouveau n° de version de PluXml if (is_readable(PLX_ROOT . 'version')) { $f = file(PLX_ROOT . 'version'); $newVersion = $f['0']; } echo L_UPDATE_PLUG_MOVEPARAMFILE . "<br />"; foreach ($this->plxAdmin->plxPlugins->aPlugins as $plugName => $plugAttrs) { $plugParamFile = PLX_PLUGINS . $plugName . '/parameters.xml'; if (is_file($plugParamFile)) { if (version_compare($newVersion, '5.1.7') > 0) { $title = $plugAttrs->getInfo('title'); } else { $title = $plugAttrs['title']; } if (plxUtils::write(file_get_contents($plugParamFile), PLX_ROOT . PLX_CONFIG_PATH . '/plugins/' . $plugName . '.xml')) { echo '<span style="color:green">✔ ' . $title . '</span><br />'; unlink($plugParamFile); } else { echo '<span style="color:red">✗ ' . $title . '</span><br />'; } } } return true; # pas d'erreurs }
public function delhtaccess() { if (is_file(PLX_ROOT . '.htaccess')) { unlink(PLX_ROOT . '.htaccess'); } if (is_file(PLX_ROOT . 'htaccess.txt')) { $ht = file_get_contents(PLX_ROOT . 'htaccess.txt'); plxUtils::write($ht, PLX_ROOT . '.htaccess'); unlink(PLX_ROOT . 'htaccess.txt'); } }
**/ 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); $plugin = isset($_GET['p']) ? urldecode($_GET['p']) : ''; $plugin = plxUtils::nullbyteRemove($plugin); # chargement du fichier css du plugin pour le frontend $file_frontend = PLX_ROOT . PLX_CONFIG_PATH . 'plugins/' . basename($plugin) . '.site.css'; # chargement du fichier css du plugin pour le backend $file_backend = PLX_ROOT . PLX_CONFIG_PATH . 'plugins/' . basename($plugin) . '.admin.css'; # Traitement du formulaire: sauvegarde du code css et regénération du cache if (isset($_POST['submit'])) { $ret_f = plxUtils::write(trim($_POST['frontend']), $file_frontend); $ret_b = plxUtils::write(trim($_POST['backend']), $file_backend); if ($ret_f and $ret_b) { $ret_1 = $plxAdmin->plxPlugins->cssCache('site'); $ret_2 = $plxAdmin->plxPlugins->cssCache('admin'); } if ($ret_f and $ret_b and $ret_1 and $ret_2) { plxMsg::Info(L_SAVE_FILE_SUCCESSFULLY); } else { plxMsg::Error(L_SAVE_FILE_ERROR); } header('Location: parametres_plugincss.php?p=' . urlencode($plugin)); exit; } $backend = is_file($file_backend) ? trim(file_get_contents($file_backend)) : ''; $file_backend_init = PLX_PLUGINS . basename($plugin) . '/css/admin.css'; $backend = ($backend == '' and is_file($file_backend_init)) ? trim(file_get_contents($file_backend_init)) : $backend;