[9.1.08] Placer des constantes pour les dossiers dir file tmp et backup

This commit is contained in:
fredtempez 2019-05-27 20:35:04 +02:00
parent 0696046446
commit 40933f3121
15 changed files with 57 additions and 57 deletions

View File

@ -12,8 +12,8 @@
<?php $layout->showVendor(); ?> <?php $layout->showVendor(); ?>
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/blank.css"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/blank.css">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/theme.css?<?php echo md5_file('site/data/theme.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/theme.css?<?php echo md5_file(self::DATA_DIR.'theme.css'); ?>">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/custom.css?<?php echo md5_file('site/data/custom.css'); ?>"></head> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/custom.css?<?php echo md5_file(self::DATA_DIR.'custom.css'); ?>"></head>
<body> <body>
<?php $layout->showStyle(); ?> <?php $layout->showStyle(); ?>
<?php $layout->showContent(); ?> <?php $layout->showContent(); ?>

View File

@ -12,8 +12,8 @@
<?php $layout->showVendor(); ?> <?php $layout->showVendor(); ?>
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/light.css"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/light.css">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/theme.css?<?php echo md5_file('site/data/theme.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/theme.css?<?php echo md5_file(self::DATA_DIR.'theme.css'); ?>">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/custom.css?<?php echo md5_file('site/data/custom.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/custom.css?<?php echo md5_file(self::DATA_DIR.'custom.css'); ?>">
</head> </head>
<body> <body>
<?php $layout->showStyle(); ?> <?php $layout->showStyle(); ?>

View File

@ -12,8 +12,8 @@
<?php $layout->showVendor(); ?> <?php $layout->showVendor(); ?>
<?php $layout->showAnalytics(); ?> <?php $layout->showAnalytics(); ?>
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/theme.css?<?php echo md5_file('site/data/theme.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/theme.css?<?php echo md5_file(self::DATA_DIR.'theme.css'); ?>">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/custom.css?<?php echo md5_file('site/data/custom.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>site/data/custom.css?<?php echo md5_file(self::DATA_DIR.'custom.css'); ?>">
</head> </head>
<body> <body>
<?php $layout->showStyle(); ?> <?php $layout->showStyle(); ?>

View File

@ -203,7 +203,7 @@ class config extends common {
// Creation du ZIP // Creation du ZIP
$fileName = date('Y-m-d-h-i-s', time()) . '.zip'; $fileName = date('Y-m-d-h-i-s', time()) . '.zip';
$zip = new ZipArchive(); $zip = new ZipArchive();
if($zip->open('site/tmp/' . $fileName, ZipArchive::CREATE) === TRUE){ if($zip->open(self::TEMP_DIR . $fileName, ZipArchive::CREATE) === TRUE){
foreach(configHelper::scanDir('site/') as $file) { foreach(configHelper::scanDir('site/') as $file) {
$zip->addFile($file); $zip->addFile($file);
} }
@ -212,13 +212,13 @@ class config extends common {
// Téléchargement du ZIP // Téléchargement du ZIP
header('Content-Transfer-Encoding: binary'); header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="' . $fileName . '"'); header('Content-Disposition: attachment; filename="' . $fileName . '"');
header('Content-Length: ' . filesize('site/tmp/' . $fileName)); header('Content-Length: ' . filesize(self::TEMP_DIR . $fileName));
readfile('site/tmp/' . $fileName); readfile(self::TEMP_DIR . $fileName);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'display' => self::DISPLAY_RAW 'display' => self::DISPLAY_RAW
]); ]);
unlink('site/tmp/' . $fileName); unlink(self::TEMP_DIR . $fileName);
} }
/** /**
@ -237,7 +237,7 @@ class config extends common {
$screenshot = str_replace(array('_','-'),array('/','+'),$screenshot); $screenshot = str_replace(array('_','-'),array('/','+'),$screenshot);
$data = 'data:image/jpeg;base64,'.$screenshot; $data = 'data:image/jpeg;base64,'.$screenshot;
$data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $data)); $data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $data));
file_put_contents( 'site/file/source/screenshot.png',$data); file_put_contents( self::FILE_DIR.'source/screenshot.png',$data);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -323,7 +323,7 @@ class config extends common {
]); ]);
} }
// Initialisation du screen // Initialisation du screen
if (!file_exists('site/file/source/screenshot.png')) { if (!file_exists(self::FILE_DIR.'source/screenshot.png')) {
$this->configMetaImage(); $this->configMetaImage();
} }
// Valeurs en sortie // Valeurs en sortie

View File

@ -63,7 +63,7 @@
<h4>Copie d'écran OpenGraph</h4> <h4>Copie d'écran OpenGraph</h4>
<div class="row"> <div class="row">
<div class="col8 offset2"> <div class="col8 offset2">
<img src='<?php echo helper::baseUrl(false) . 'site/file/source/screenshot.png';?>' /> <img src='<?php echo helper::baseUrl(false) . self::FILE_DIR.'source/screenshot.png';?>' />
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View File

@ -62,9 +62,9 @@ class install extends common {
// Ajouter ici la liste des pages privées qui ne sont pas vues lors de l'installation. // Ajouter ici la liste des pages privées qui ne sont pas vues lors de l'installation.
$this->deleteData(['page', 'privee']); $this->deleteData(['page', 'privee']);
// Effacer les fichiers par défaut // Effacer les fichiers par défaut
if (is_dir('site/file/source/galerie')) { if (is_dir(self::FILE_DIR.'source/galerie')) {
$this->removeAll('site/file/source/galerie'); $this->removeAll(self::FILE_DIR.'source/galerie');
$this->removeAll('site/file/thumb/galerie'); $this->removeAll(self::FILE_DIR.'thumb/galerie');
} }
} else { } else {
$this->setData(['module', 'blog', 'mon-premier-article', 'userId', $userId]); $this->setData(['module', 'blog', 'mon-premier-article', 'userId', $userId]);
@ -123,14 +123,14 @@ class install extends common {
case 1: case 1:
$success = true; $success = true;
// Copie du fichier de données // Copie du fichier de données
copy('site/data/core.json', 'site/backup/' . date('Y-m-d', time()) . '-core-update.json'); copy(self::DATA_DIR.'core.json', self::BACKUP_DIR . date('Y-m-d', time()) . '-core-update.json');
copy('site/data/theme.json', 'site/backup/' . date('Y-m-d', time()) . '-theme-update.json'); copy(self::DATA_DIR.'theme.json', self::BACKUP_DIR . date('Y-m-d', time()) . '-theme-update.json');
// Nettoyage des fichiers temporaires // Nettoyage des fichiers temporaires
if(file_exists('site/tmp/update.tar.gz')) { if(file_exists(self::TEMP_DIR.'update.tar.gz')) {
$success = unlink('site/tmp/update.tar.gz'); $success = unlink(self::TEMP_DIR.'update.tar.gz');
} }
if(file_exists('site/tmp/update.tar')) { if(file_exists(self::TEMP_DIR.'update.tar')) {
$success = unlink('site/tmp/update.tar'); $success = unlink(self::TEMP_DIR.'update.tar');
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -144,7 +144,7 @@ class install extends common {
// Téléchargement // Téléchargement
case 2: case 2:
// Téléchargement depuis le serveur de Zwii // Téléchargement depuis le serveur de Zwii
$success = (file_put_contents('site/tmp/update.tar.gz', file_get_contents('https://zwiicms.com/update/update.tar.gz')) !== false); $success = (file_put_contents(self::TEMP_DIR.'update.tar.gz', file_get_contents('https://zwiicms.com/update/update.tar.gz')) !== false);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'display' => self::DISPLAY_JSON, 'display' => self::DISPLAY_JSON,
@ -162,7 +162,7 @@ class install extends common {
// Décompression et installation // Décompression et installation
try { try {
// Décompression dans le dossier de fichier temporaires // Décompression dans le dossier de fichier temporaires
$pharData = new PharData('site/tmp/update.tar.gz'); $pharData = new PharData(self::TEMP_DIR.'update.tar.gz');
$pharData->decompress(); $pharData->decompress();
// Installation // Installation
$pharData->extractTo(__DIR__ . '/../../../', null, true); $pharData->extractTo(__DIR__ . '/../../../', null, true);
@ -170,11 +170,11 @@ class install extends common {
$success = $e->getMessage(); $success = $e->getMessage();
} }
// Netooyage du dossier // Netooyage du dossier
if(file_exists('site/tmp/update.tar.gz')) { if(file_exists(self::TEMP_DIR.'update.tar.gz')) {
unlink('site/tmp/update.tar.gz'); unlink(self::TEMP_DIR.'update.tar.gz');
} }
if(file_exists('site/tmp/update.tar')) { if(file_exists(self::TEMP_DIR.'update.tar')) {
unlink('site/tmp/update.tar'); unlink(self::TEMP_DIR.'update.tar');
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([

View File

@ -356,7 +356,7 @@ class install extends common {
'beaux-paysages' => [ 'beaux-paysages' => [
'config' => [ 'config' => [
'name' => 'Beaux paysages', 'name' => 'Beaux paysages',
'directory' => 'site/file/source/galerie/landscape' 'directory' => self::FILE_DIR.'source/galerie/landscape'
], ],
'legend' => [ 'legend' => [
'desert.jpg' => 'Un désert', 'desert.jpg' => 'Un désert',
@ -367,7 +367,7 @@ class install extends common {
'espace' => [ 'espace' => [
'config' => [ 'config' => [
'name' => 'Espace', 'name' => 'Espace',
'directory' => 'site/file/source/galerie/space' 'directory' => self::FILE_DIR.'source/galerie/space'
], ],
'legend' => [ 'legend' => [
'earth.jpg' => 'La Terre et la Lune', 'earth.jpg' => 'La Terre et la Lune',

View File

@ -216,7 +216,7 @@ class theme extends common {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if($this->isPost()) {
// Enregistre le CSS // Enregistre le CSS
file_put_contents('site/data/custom.css', $this->getInput('themeAdvancedCss', null)); file_put_contents(self::DATA_DIR.'custom.css', $this->getInput('themeAdvancedCss', null));
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'notification' => 'Modifications enregistrées', 'notification' => 'Modifications enregistrées',
@ -432,7 +432,7 @@ class theme extends common {
*/ */
public function reset() { public function reset() {
// Supprime le fichier de personnalisation avancée // Supprime le fichier de personnalisation avancée
unlink('site/data/custom.css'); unlink(self::DATA_DIR.'custom.css');
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'notification' => 'Personnalisation avancée réinitialisée', 'notification' => 'Personnalisation avancée réinitialisée',
@ -492,7 +492,7 @@ class theme extends common {
$zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true); $zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true);
$zip = new ZipArchive(); $zip = new ZipArchive();
if ($zip->open('site/file/source/'.$zipFilename) === TRUE) { if ($zip->open(self::FILE_DIR.'source/'.$zipFilename) === TRUE) {
$zip->extractTo('.'); $zip->extractTo('.');
$zip->close(); $zip->close();
// Valeurs en sortie // Valeurs en sortie
@ -527,10 +527,10 @@ class theme extends common {
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary'); header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="' . $zipFilename . '"'); header('Content-Disposition: attachment; filename="' . $zipFilename . '"');
header('Content-Length: ' . filesize('site/tmp/' . $zipFilename)); header('Content-Length: ' . filesize(self::TEMP_DIR . $zipFilename));
readfile('site/tmp/' . $zipFilename); readfile(self::TEMP_DIR . $zipFilename);
// Nettoyage du dossier // Nettoyage du dossier
unlink ('site/tmp/' . $zipFilename); unlink (self::TEMP_DIR . $zipFilename);
die(); die();
} }
@ -541,10 +541,10 @@ class theme extends common {
// Make zip // Make zip
$zipFilename = $this->makezip(); $zipFilename = $this->makezip();
// Téléchargement du ZIP // Téléchargement du ZIP
mkdir('site/file/source/theme'); mkdir(self::FILE_DIR.'source/theme');
copy ('site/tmp/' . $zipFilename , 'site/file/source/theme/' . $zipFilename); copy (self::TEMP_DIR . $zipFilename , self::FILE_DIR.'source/theme/' . $zipFilename);
// Nettoyage du dossier // Nettoyage du dossier
unlink ('site/tmp/' . $zipFilename); unlink (self::TEMP_DIR . $zipFilename);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'notification' => 'Archive <b>'.$zipFilename.'</b> sauvegardée dans fichiers', 'notification' => 'Archive <b>'.$zipFilename.'</b> sauvegardée dans fichiers',
@ -561,18 +561,18 @@ class theme extends common {
// $zipFilename = 'theme-'.date('dmY').'-'.date('hm').'-'.rand(10,99).'.zip'; // $zipFilename = 'theme-'.date('dmY').'-'.date('hm').'-'.rand(10,99).'.zip';
$zipFilename = 'theme '.date('d m Y').' '.date('H i s ').'.zip'; $zipFilename = 'theme '.date('d m Y').' '.date('H i s ').'.zip';
$zip = new ZipArchive(); $zip = new ZipArchive();
if ($zip->open('site/tmp/' . $zipFilename, ZipArchive::CREATE | ZipArchive::OVERWRITE ) === TRUE) { if ($zip->open(self::TEMP_DIR . $zipFilename, ZipArchive::CREATE | ZipArchive::OVERWRITE ) === TRUE) {
$zip->addFile('site/data/theme.json','site/data/theme.json'); $zip->addFile(self::DATA_DIR.'theme.json',self::DATA_DIR.'theme.json');
$zip->addFile('site/data/theme.json','site/data/theme.css'); $zip->addFile(self::DATA_DIR.'theme.json',self::DATA_DIR.'theme.css');
$zip->addFile('site/data/theme.json','site/data/custom.css'); $zip->addFile(self::DATA_DIR.'theme.json',self::DATA_DIR.'custom.css');
if ($this->getData(['theme','body','image']) !== '' ) { if ($this->getData(['theme','body','image']) !== '' ) {
$zip->addFile('site/file/source/'.$this->getData(['theme','body','image']), $zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','body','image']),
'site/file/source/'.$this->getData(['theme','body','image']) self::FILE_DIR.'source/'.$this->getData(['theme','body','image'])
); );
} }
if ($this->getData(['theme','header','image']) !== '' ) { if ($this->getData(['theme','header','image']) !== '' ) {
$zip->addFile('site/file/source/'.$this->getData(['theme','header','image']), $zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','header','image']),
'site/file/source/'.$this->getData(['theme','header','image']) self::FILE_DIR.'source/'.$this->getData(['theme','header','image'])
); );
} }
$ret = $zip->close(); $ret = $zip->close();

View File

@ -23,7 +23,7 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::textarea('themeAdvancedCss', [ <?php echo template::textarea('themeAdvancedCss', [
'value' => file_get_contents('site/data/custom.css'), 'value' => file_get_contents(self::DATA_DIR.'custom.css'),
'class' => 'editorCss' 'class' => 'editorCss'
]); ?> ]); ?>
</div> </div>

View File

@ -28,7 +28,7 @@
<div class="block"> <div class="block">
<h4>Image</h4> <h4>Image</h4>
<?php <?php
$imageFile = file_exists('site/file/source/'.$this->getData(['theme', 'body', 'image'])) ? $this->getData(['theme', 'body', 'image']) : ""; $imageFile = file_exists(self::FILE_DIR.'source/'.$this->getData(['theme', 'body', 'image'])) ? $this->getData(['theme', 'body', 'image']) : "";
echo template::file('themeBodyImage', [ echo template::file('themeBodyImage', [
'label' => 'Fond', 'label' => 'Fond',
'type' => 1, 'type' => 1,

View File

@ -40,7 +40,7 @@
<div class="block"> <div class="block">
<h4>Image</h4> <h4>Image</h4>
<?php <?php
$imageFile = file_exists('site/file/source/'.$this->getData(['theme', 'header', 'image'])) ? $this->getData(['theme', 'header', 'image']) : ""; $imageFile = file_exists(self::FILE_DIR.'source/'.$this->getData(['theme', 'header', 'image'])) ? $this->getData(['theme', 'header', 'image']) : "";
echo template::file('themeHeaderImage', [ echo template::file('themeHeaderImage', [
'label' => 'Fond', 'label' => 'Fond',
'type' => 1, 'type' => 1,

View File

@ -5,8 +5,8 @@
</div> </div>
<?php if ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'hidePicture']) == false) { <?php if ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'hidePicture']) == false) {
// echo '<div id="blogArticlePicture" style="background-image:url(' . helper::baseUrl(false) . 'site/file/source/' . $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'picture']) . ');"></div>'; // echo '<div id="blogArticlePicture" style="background-image:url(' . helper::baseUrl(false) . self::FILE_DIR.'source/' . $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'picture']) . ');"></div>';
echo '<div id="blogArticlePicture"><img id="blogArticlePicture" src="' . helper::baseUrl(false) . 'site/file/source/' . $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'picture']) . '"></div>'; echo '<div id="blogArticlePicture"><img id="blogArticlePicture" src="' . helper::baseUrl(false) . self::FILE_DIR.'source/' . $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'picture']) . '"></div>';
} ?> } ?>
<?php echo $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'content']); ?> <?php echo $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'content']); ?>

View File

@ -5,7 +5,7 @@
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>" class="blogPicture"> <a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>" class="blogPicture">
<img src="<?php echo helper::baseUrl(false) . 'site/file/thumb/' . $article['picture']; ?>"> <img src="<?php echo helper::baseUrl(false) . self::FILE_DIR.'thumb/' . $article['picture']; ?>">
</a> </a>
</div> </div>
<div class="col9"> <div class="col9">

View File

@ -178,10 +178,10 @@ class form extends common {
$data = $this->getData(['module', $this->getUrl(0), 'data']); $data = $this->getData(['module', $this->getUrl(0), 'data']);
if ($data !== []) { if ($data !== []) {
$csvfilename = 'data-'.date('dmY').'-'.date('hm').'-'.rand(10,99).'.csv'; $csvfilename = 'data-'.date('dmY').'-'.date('hm').'-'.rand(10,99).'.csv';
if (!file_exists('site/file/source/data')) { if (!file_exists(self::FILE_DIR.'source/data')) {
mkdir('site/file/source/data'); mkdir(self::FILE_DIR.'source/data');
} }
$fp = fopen('site/file/source/data/'.$csvfilename, 'w'); $fp = fopen(self::FILE_DIR.'source/data/'.$csvfilename, 'w');
fputcsv($fp, array_keys($data[1]), ';','"'); fputcsv($fp, array_keys($data[1]), ';','"');
foreach ($data as $fields) { foreach ($data as $fields) {
fputcsv($fp, $fields, ';','"'); fputcsv($fp, $fields, ';','"');

View File

@ -130,7 +130,7 @@ class gallery extends common {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'display' => self::DISPLAY_JSON, 'display' => self::DISPLAY_JSON,
'content' => galleriesHelper::scanDir('site/file/source') 'content' => galleriesHelper::scanDir(self::FILE_DIR.'source')
]); ]);
} }