Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
haruka-7 committed Jan 7, 2020
2 parents 3ff4a70 + ea61f65 commit c162567
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 70 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Créez un site web performant en toute simplicité et sans base de données.

[**Télécharger PluXml 5.8**](https://www.pluxml.org/download/pluxml-latest.zip) (zip)

* Version stable (5.8) : [master](https://github.com/pluxml/PluXml/tree/master)
* Version en développement (5.8.1) : [develop](https://github.com/pluxml/PluXml/tree/develop)
* Version stable (5.8.1) : [master](https://github.com/pluxml/PluXml/tree/master)
* Version en développement (6.0) : [develop](https://github.com/pluxml/PluXml/tree/develop)

Principales caractéristiques
----------------------------
Expand Down
6 changes: 3 additions & 3 deletions core/admin/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@

$plxAdmin->editPassword($_POST);

if (!empty($msg = $_SESSION['error'])) {
if (!empty($msg = isset($_SESSION['error']) ? $_SESSION['error'] : '')) {
$css = 'alert red';
}
else {
if (!empty($msg = $_SESSION['info'])) {
if (!empty($msg = isset($_SESSION['info']) ? $_SESSION['info'] : '')) {
$css = 'alert green';
}
}
Expand Down Expand Up @@ -173,7 +173,7 @@
<?php
# Hook plugins
eval($plxAdmin->plxPlugins->callHook('AdminAuthBegin'));
switch ($_GET['action']){
switch (isset($_GET['action']) ? $_GET['action'] : false){
case 'lostpassword': # Affichage du formulaire d'envoi du mail de changement de mot de passe
# Hook plugins
eval($plxAdmin->plxPlugins->callHook('AdminAuthTopLostPassword'));
Expand Down
3 changes: 0 additions & 3 deletions core/admin/prepend.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
const PLX_ROOT = '../../';
const PLX_CORE = PLX_ROOT .'core/';
const PLX_TEMPLATES = PLX_CORE.'templates/';
const PLX_TEMPLATES_DATA = PLX_ROOT.'data/templates/';
const SESSION_LIFETIME = 7200;

include PLX_ROOT.'config.php';
Expand Down Expand Up @@ -40,7 +38,6 @@
include_once PLX_CORE.'lib/class.plx.medias.php';
include_once PLX_CORE.'lib/class.plx.plugins.php';
include_once PLX_CORE.'lib/class.plx.token.php';
include_once PLX_CORE.'lib/class.plx.template.php';

# Echappement des caractères
if($_SERVER['REQUEST_METHOD'] == 'POST') $_POST = plxUtils::unSlash($_POST);
Expand Down
1 change: 1 addition & 0 deletions core/admin/theme/plucss.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions core/admin/top.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
else echo L_PROFIL_WRITER; ?>
</em>
</li>
<li><small><a class="version" title="PluXml" href="<?php echo PLX_REPO_URL ?>">PluXml <?php echo $plxAdmin->aConf['version'] ?></a></small></li>
<li><small><a class="version" title="PluXml" href="<?php echo PLX_URL_REPO ?>">PluXml <?php echo $plxAdmin->aConf['version'] ?></a></small></li>
</ul>
</header>
<nav class="responsive-menu">
Expand Down Expand Up @@ -150,4 +150,4 @@

# Hook Plugins
eval($plxAdmin->plxPlugins->callHook('AdminTopBottom'));
?>
?>
2 changes: 1 addition & 1 deletion core/lang/en/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

# class.plx.utils.php
'L_WRITE_ACCESS' => '%s has write access',
'L_WRITE_NOT_ACCESS' => '%s does not have write access or does not exist',
'L_WRITE_NOT_ACCESS' => '%s has no writing access or is missing',
'L_MODREWRITE_AVAILABLE' => 'Apache URL Rewriting module mod_rewrite available',
'L_MODREWRITE_NOT_AVAILABLE' => 'Apache URL Rewriting module mod_rewrite unavailable',
'L_LIBGD_INSTALLED' => 'GD library installed',
Expand Down
6 changes: 3 additions & 3 deletions core/lib/class.plx.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public function verifyLostPasswordToken($token) {
$valid = false;

foreach($this->aUsers as $user_id => $user) {
if ($user['password_token'] == $token AND $user['password_token_expiry'] >= date(YmdHi)) {
if ($user['password_token'] == $token AND $user['password_token_expiry'] >= date('YmdHi')) {
$valid = true;
}
}
Expand Down Expand Up @@ -439,8 +439,8 @@ public function editUsers($content, $action=false) {
$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]['password_token'] = trim($content[$user_id.'_password_token']);
$this->aUsers[$user_id]['password_token_expiry'] = trim($content[$user_id.'_password_token_expiry']);
$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']:'');
# Hook plugins
eval($this->plxPlugins->callHook('plxAdminEditUsersUpdate'));
$action = true;
Expand Down
35 changes: 24 additions & 11 deletions core/lib/class.plx.motor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
* @author Anthony GUÉRIN, Florent MONTHEL, Stéphane F, Pedro "P3ter" CADETE
**/

include_once PLX_CORE.'lib/class.plx.template.php';

class plxMotor {
const PLX_TEMPLATES = PLX_CORE . 'templates/';
const PLX_TEMPLATES_DATA = PLX_ROOT . 'data/templates/';

public $get = false; # Donnees variable GET
public $racine = false; # Url de PluXml
Expand Down Expand Up @@ -110,8 +114,8 @@ protected function __construct($filename) {
# Hook plugins
eval($this->plxPlugins->callHook('plxMotorConstruct'));
# Get templates from core/templates and data/templates
$this->getTemplates(PLX_TEMPLATES);
$this->getTemplates(PLX_TEMPLATES_DATA);
$this->getTemplates(self::PLX_TEMPLATES);
$this->getTemplates(self::PLX_TEMPLATES_DATA);
}

/**
Expand Down Expand Up @@ -443,9 +447,12 @@ public function getCategories($filename) {
# Recuperation du fichier template
$this->aCats[$number]['template']=isset($attributes['template'])?$attributes['template']:'categorie.php';
# Récupération des informations de l'image représentant la catégorie
$this->aCats[$number]['thumbnail']=plxUtils::getValue($values[$iTags['thumbnail'][$i]]['value']);
$this->aCats[$number]['thumbnail_title']=plxUtils::getValue($values[$iTags['thumbnail_title'][$i]]['value']);
$this->aCats[$number]['thumbnail_alt']=plxUtils::getValue($values[$iTags['thumbnail_alt'][$i]]['value']);
$thumbnail = plxUtils::getValue($iTags['thumbnail'][$i]);
$this->aCats[$number]['thumbnail']=plxUtils::getValue($values[$thumbnail]['value']);
$thumbnail_title = plxUtils::getValue($iTags['thumbnail_title'][$i]);
$this->aCats[$number]['thumbnail_title']=plxUtils::getValue($values[$thumbnail_title]['value']);
$thumbnail_alt = plxUtils::getValue($iTags['thumbnail_alt'][$i]);
$this->aCats[$number]['thumbnail_alt']=plxUtils::getValue($values[$thumbnail_alt]['value']);
# Récuperation état affichage de la catégorie dans le menu
$this->aCats[$number]['menu']=isset($attributes['menu'])?$attributes['menu']:'oui';
# Récuperation état activation de la catégorie dans le menu
Expand Down Expand Up @@ -569,8 +576,10 @@ public function getUsers($filename) {
$this->aUsers[$number]['email']=plxUtils::getValue($values[$email]['value']);
$lang = isset($iTags['lang'][$i]) ? $values[$iTags['lang'][$i]]['value']:'';
$this->aUsers[$number]['lang'] = $lang!='' ? $lang : $this->aConf['default_lang'];
$this->aUsers[$number]['password_token']=plxUtils::getValue($values[$iTags['password_token'][$i]]['value']);
$this->aUsers[$number]['password_token_expiry']=plxUtils::getValue($values[$iTags['password_token_expiry'][$i]]['value']);
$password_token = plxUtils::getValue($iTags['password_token'][$i]);
$this->aUsers[$number]['password_token']=plxUtils::getValue($values[$password_token]['value']);
$password_token_expiry = plxUtils::getValue($iTags['password_token_expiry'][$i]);
$this->aUsers[$number]['password_token_expiry']=plxUtils::getValue($values[$password_token_expiry]['value']);
# Hook plugins
eval($this->plxPlugins->callHook('plxMotorGetUsers'));
}
Expand Down Expand Up @@ -992,7 +1001,7 @@ public function getTags($filename) {
# Mémorisation de la liste des tags
$this->aTags = $array;
}

/**
* Méthode qui alimente le tableau aTemplate
*
Expand All @@ -1001,9 +1010,13 @@ public function getTags($filename) {
* @author Pedro "P3ter" CADETE
**/
public function getTemplates($templateFolder) {
$files = array_diff(scandir($templateFolder), array('..', '.'));
foreach ($files as $file) {
$this->aTemplates[$file] = new PlxTemplate($templateFolder, $file);
if(is_dir($templateFolder)) {
$files = array_diff(scandir($templateFolder), array('..', '.'));
if (!empty($files)) {
foreach ($files as $file) {
$this->aTemplates[$file] = new PlxTemplate($templateFolder, $file);
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/lib/class.plx.show.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,8 @@ public function catThumbnail($format='<a href="#img_url"><img class="cat_thumbna
array(
$img_url, # #img_url
(file_exists(PLX_ROOT.$img_thumb)) ? $this->plxMotor->urlRewrite($img_thumb) : $img_url, # #img_thumb_url
plxUtils::strCheck($this->plxMotor->aCats[$this->plxMotor->cible]['thumbnail_title']), # #img_title
plxUtils::strCheck($this->plxMotor->aCats[$this->plxMotor->cible]['thumbnail_alt']) # #img_alt
plxUtils::strCheck(plxUtils::getValue($this->plxMotor->aCats[$this->plxMotor->cible]['thumbnail_title'])), # #img_title
plxUtils::strCheck(plxUtils::getValue($this->plxMotor->aCats[$this->plxMotor->cible]['thumbnail_alt'])) # #img_alt
),
$format
);
Expand Down
19 changes: 13 additions & 6 deletions core/lib/class.plx.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,21 @@ private function parseTemplate($fileName) {
xml_parser_free($parser);

# getting datas from the parser
$template['name'] = plxUtils::getValue($values[$index['name'][0]]['value']);
$template['type'] = plxUtils::getValue($values[$index['type'][0]]['value']);
$name = plxUtils::getValue($index['name'][0]);
$template['name'] = plxUtils::getValue($values[$name]['value']);
$type = plxUtils::getValue($index['type'][0]);
$template['type'] = plxUtils::getValue($values[$type]['value']);
if ($template['type'] == 'email') {
$template['emailname'] = plxUtils::getValue($values[$index['emailname'][0]]['value']);
$template['emailfrom'] = plxUtils::getValue($values[$index['emailfrom'][0]]['value']);
$template['emailsubject'] = plxUtils::getValue($values[$index['emailsubject'][0]]['value']);
$emailname = plxUtils::getValue($index['emailname'][0]);
$template['emailname'] = plxUtils::getValue($values[$emailname]['value']);
$emailfrom = plxUtils::getValue($index['emailfrom'][0]);
$template['emailfrom'] = plxUtils::getValue($values[$emailfrom]['value']);
$emailsubject = plxUtils::getValue($index['emailsubject'][0]);
$template['emailsubject'] = plxUtils::getValue($values[$emailsubject]['value']);

}
$template['content'] = plxUtils::getValue($values[$index['content'][0]]['value']);
$content = plxUtils::getValue($index['content'][0]);
$template['content'] = plxUtils::getValue($values[$content]['value']);

return $template;
}
Expand Down
2 changes: 1 addition & 1 deletion core/lib/class.plx.token.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function generateToken() {
*/

public static function generateTokenExperyDate($hours = 24) {
return date(YmdHis, mktime(date(H)+$hours, date(i), date(s), date(m), date(d), date(Y)));
return date('YmdHis', mktime(date('H')+$hours, date('i'), date('s'), date('m'), date('d'), date('Y')));
}

}
5 changes: 3 additions & 2 deletions core/lib/config.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
const PLX_DEBUG = false;
const PLX_VERSION = '5.8';
const PLX_VERSION = '5.8.1';
const PLX_URL_REPO = 'https://www.pluxml.org';
const PLX_URL_VERSION = PLX_URL_REPO.'/download/latest-version.txt';

# Gestion des erreurs PHP
if(PLX_DEBUG) error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
if(PLX_DEBUG) error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

# Fonction qui retourne le timestamp UNIX actuel avec les microsecondes
function getMicrotime() {
Expand Down
8 changes: 7 additions & 1 deletion install.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
include(PLX_CORE.'lib/class.plx.token.php');

# Chargement des langues
$lang = (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : DEFAULT_LANG;
if(!empty($_POST) AND $_POST['default_lang'] != DEFAULT_LANG ){
$lang = $_POST['default_lang'];
}
Expand Down Expand Up @@ -53,6 +54,11 @@
@mkdir(PLX_ROOT.PLX_CONFIG_PATH.'plugins',0755,true);
}

# Vérification de l'existence du dossier data/templates
if(!is_dir(PLX_ROOT.'data/templates')) {
@mkdir(PLX_ROOT.'data/templates',0755,true);
}

# Echappement des caractères
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$_POST = plxUtils::unSlash($_POST);
Expand Down Expand Up @@ -158,7 +164,7 @@ function install($content, $config) {
$xml = '<?xml version="1.0" encoding="'.PLX_CHARSET.'"?>'."\n";
$xml .= '<document>'."\n";
if($content['data']>0)
$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 .= "\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><thumbnail><![CDATA[]]></thumbnail><thumbnail_title><![CDATA[]]></thumbnail_title><thumbnail_alt><![CDATA[]]></thumbnail_alt></categorie>'."\n";

$xml .= '</document>';
plxUtils::write($xml,path('XMLFILE_CATEGORIES'));
Expand Down
7 changes: 7 additions & 0 deletions readme/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## PLUXML 5.8.1 (sortie : 07/01/2020) ##
FIX #360 Undefined index: password_token
FIX #361 Use of undefined constant PLX_TEMPLATES
FIX #362 Uncaught Error: Class 'PlxTemplate' not found
FIX #363 Notice: Undefined index: name
FIX #364 warning messages and use browser language

## PLUXML 5.8 (sortie : 05/01/2020) ##
[+] PluCSS 1.3.1
[+] Feature "Mot de passe oublié" : envoi d'un lien par mail permettant la création d'un nouveau mot de passe (P3ter)
Expand Down
16 changes: 7 additions & 9 deletions update/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
define('PLX_ROOT', '../');
define('PLX_CORE', PLX_ROOT.'core/');
const PLX_ROOT = '../';
const PLX_CORE = PLX_ROOT . 'core/';
include(PLX_ROOT.'config.php');
include(PLX_CORE.'lib/config.php');

define('PLX_UPDATER', true);
const PLX_UPDATER = true;

# On verifie que PluXml est installé
if(!file_exists(path('XMLFILE_PARAMETERS'))) {
Expand All @@ -27,7 +27,7 @@
include(PLX_ROOT.'update/class.plx.updater.php');

# Chargement des langues
$lang = DEFAULT_LANG;
$lang = (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : DEFAULT_LANG;
if(isset($_POST['default_lang'])) $lang=$_POST['default_lang'];
if(!array_key_exists($lang, plxUtils::getLangs())) {
$lang = DEFAULT_LANG;
Expand Down Expand Up @@ -95,15 +95,13 @@
<form action="index.php" method="post">
<fieldset>
<div class="grid">
<div class="col sml-12 med-5 label-centered">
<div class="col sml-9 med-7 label-centered">
<label for="id_default_lang"><?php echo L_SELECT_LANG ?></label>
</div>
<div class="col sml-12 med-7">
<div class="col sml-3 med-2">
<?php plxUtils::printSelect('default_lang', plxUtils::getLangs(), $lang) ?>&nbsp;
</div>
</div>
<div class="grid">
<div class="col sml-12">
<div class="col med-3">
<input type="submit" name="select_lang" value="<?php echo L_INPUT_CHANGE ?>" />
<?php echo plxToken::getTokenPostMethod() ?>
</div>
Expand Down
66 changes: 66 additions & 0 deletions update/update_5.8.1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* Classe de mise a jour pour PluXml version 5.8
*
* @package PLX
* @author Pedro "P3ter" CADETE
**/
class update_5_8_1 extends plxUpdate{

/**
* Update category file with new fields thumbnail, thumbnail_title, thumbnail_alt
* @return boolean
*/
public function step1() {
echo L_UPDATE_FILE." (".path('XMLFILE_CATEGORIES').")<br />";
$data = file_get_contents(path('XMLFILE_CATEGORIES'));
$tag = 'categorie';
if(preg_match_all('{<'.$tag.'[^>]*>(.*?)</'.$tag.'>}', $data, $matches, PREG_PATTERN_ORDER)) {
foreach($matches[0] as $match) {
if(!preg_match('/<thumbnail>/', $match)) {
$str = str_replace('</'.$tag.'>', '<thumbnail><![CDATA[]]></thumbnail><thumbnail_title><![CDATA[]]></thumbnail_title><thumbnail_alt><![CDATA[]]></thumbnail_alt></'.$tag.'>', $match);
$data = str_replace($match, $str, $data);
}
}
if(!plxUtils::write($data, path('XMLFILE_CATEGORIES'))) {
echo '<p class="error">'.L_UPDATE_ERR_FILE.'</p>';
return false;
}
}
return true;
}

/**
* Update users file with new fields password_token, password_token_expiry
* @return boolean
*/
public function step2() {
echo L_UPDATE_FILE." (".path('XMLFILE_USERS').")<br />";
$data = file_get_contents(path('XMLFILE_USERS'));
$tag = 'user';
if(preg_match_all('{<'.$tag.'[^>]*>(.*?)</'.$tag.'>}', $data, $matches, PREG_PATTERN_ORDER)) {
foreach($matches[0] as $match) {
if(!preg_match('/<password_token>/', $match)) {
$str = str_replace('</'.$tag.'>', '<password_token><![CDATA[]]></password_token><password_token_expiry><![CDATA[]]></password_token_expiry></'.$tag.'>', $match);
$data = str_replace($match, $str, $data);
}
}
if(!plxUtils::write($data, path('XMLFILE_CATEGORIES'))) {
echo '<p class="error">'.L_UPDATE_ERR_FILE.'</p>';
return false;
}
}
return true;
}

/**
* Create data/templates folder if is missing
* @return boolean
*/
public function step3() {
if(!is_dir(PLX_ROOT.'data/templates')) {
@mkdir(PLX_ROOT.'data/templates',0755,true);
}
return true;
}
}
Loading

0 comments on commit c162567

Please sign in to comment.