Browse Source
testé avec les plugins svp et medias Co-authored-by: JamesRezo <james@rezo.net> Reviewed-on: #4416 Co-authored-by: JamesRezo <jamesrezo@noreply.git.spip.net> Co-committed-by: JamesRezo <jamesrezo@noreply.git.spip.net>pull/4422/head
33 changed files with 1220 additions and 11060 deletions
@ -0,0 +1,14 @@
|
||||
root = true |
||||
[*] |
||||
end_of_line = lf |
||||
indent_size = 4 |
||||
insert_final_newline = true |
||||
trim_trailing_whitespace = true |
||||
charset = utf-8 |
||||
indent_style = tab |
||||
|
||||
[composer.json] |
||||
indent_style = space |
||||
|
||||
[CHANGELOG, *.md] |
||||
indent_size = 2 |
@ -0,0 +1,8 @@
|
||||
/.editorconfig export-ignore |
||||
/.gitattributes export-ignore |
||||
/.gitignore export-ignore |
||||
/phpcs.xml.dist export-ignore |
||||
/phpstan.neon.dist export-ignore |
||||
/phpunit.xml.dist export-ignore |
||||
/tests export-ignore |
||||
/var export-ignore |
@ -1,18 +1,33 @@
|
||||
{ |
||||
"autoload": { |
||||
"psr-4": { |
||||
"Spip\\Archiver\\": "src/" |
||||
} |
||||
}, |
||||
"autoload-dev": { |
||||
"psr-4": { |
||||
"Spip\\Archiver\\Tests\\": "tests/" |
||||
} |
||||
}, |
||||
"require": { |
||||
"php": "^7.4 || ^8.0" |
||||
"php": "^7.4 || ^8.0", |
||||
"ext-zip": "*", |
||||
"ext-zlib": "*", |
||||
"ext-phar": "*" |
||||
}, |
||||
"require-dev": { |
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", |
||||
"phpunit/phpunit": "^9.5", |
||||
"spip/coding-standards": "^1.2", |
||||
"phpstan/phpstan": "^1.4", |
||||
"spip/coding-standards": "^1.2" |
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", |
||||
"rector/rector": "^0.12.13" |
||||
}, |
||||
"config": { |
||||
"allow-plugins": { |
||||
"dealerdirect/phpcodesniffer-composer-installer": true |
||||
}, |
||||
"platform": { |
||||
"php": "7.4.27" |
||||
}, |
||||
"allow-plugins": { |
||||
"dealerdirect/phpcodesniffer-composer-installer": true |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,445 +1,31 @@
|
||||
<?php |
||||
|
||||
/***************************************************************************\ |
||||
/*************************************************************************** |
||||
* SPIP, Système de publication pour l'internet * |
||||
* * |
||||
* Copyright © avec tendresse depuis 2001 * |
||||
* Copyright (c) avec tendresse depuis 2001 * |
||||
* Arnaud Martin, Antoine Pitrou, Philippe Rivière, Emmanuel Saint-James * |
||||
* * |
||||
* Ce programme est un logiciel libre distribué sous licence GNU/GPL. * |
||||
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. * |
||||
\***************************************************************************/ |
||||
***************************************************************************/ |
||||
|
||||
namespace Spip\Archives; |
||||
|
||||
include_spip('src/ArchiverInterface'); |
||||
include_spip('src/AbstractArchiver'); |
||||
include_spip('src/ArchiveInterface'); |
||||
include_spip('src/NoDotFilterIterator'); |
||||
include_spip('src/TarArchive'); |
||||
include_spip('src/TgzArchive'); |
||||
include_spip('src/ZipArchive'); |
||||
include_spip('src/SpipArchiver'); |
||||
|
||||
use Spip\Archiver\SpipArchiver; |
||||
|
||||
/** |
||||
* Point d'entrée de la gestion des archives compressées de SPIP |
||||
*/ |
||||
class SpipArchives |
||||
class SpipArchives extends SpipArchiver |
||||
{ |
||||
/** @const array Mode de compression connus */ |
||||
public const compressionsConnues = ['zip', 'tar', 'tgz']; |
||||
|
||||
/** @var integer Dernier code d'erreur */ |
||||
private int $codeErreur; |
||||
|
||||
/** @var string Dernier message d'erreur */ |
||||
private string $messageErreur; |
||||
|
||||
/** @var string Mode de compression si l'extension du fichier n'est pas explicite */ |
||||
private string $modeCompression; |
||||
|
||||
/** @var string Chemin vers le fichier d'archives */ |
||||
private string $fichierArchive; |
||||
|
||||
/** @var boolean true si l'archive est en lecture seule */ |
||||
private bool $lectureSeule = true; |
||||
|
||||
/** @var array Liste des erreurs possibles */ |
||||
private array $erreurs = [ |
||||
0 => 'OK', |
||||
1 => 'erreur_inconnue', |
||||
2 => 'extension_inconnue', |
||||
3 => 'fichier_absent', |
||||
4 => 'fichier_lecture_seule', |
||||
5 => 'destination_inaccessible', |
||||
6 => 'fichier_deja_existant', |
||||
]; |
||||
|
||||
/** |
||||
* Renvoyer le dernier code d'erreur. |
||||
* |
||||
* @return integer Dernier code d'erreur |
||||
*/ |
||||
public function erreur() { |
||||
if (!$this->codeErreur) { |
||||
return false; |
||||
} |
||||
|
||||
$code = in_array($this->codeErreur, array_keys($this->erreurs)) ? $this->codeErreur : 1; |
||||
|
||||
$this->codeErreur = $code; |
||||
if ($this->codeErreur !== 1 or !$this->messageErreur) { |
||||
$this->messageErreur = 'archives:' . $this->erreurs[$code]; |
||||
} |
||||
|
||||
return $code; |
||||
} |
||||
|
||||
/** |
||||
* Renvoyer le dernier message d'erreur. |
||||
* |
||||
* @return string Dernier message d'erreur |
||||
*/ |
||||
public function message() { |
||||
return $this->messageErreur; |
||||
} |
||||
|
||||
/** |
||||
* Indiquer le détail du contenu de l'archive. |
||||
* |
||||
* @return array détail du contenu de l'archive |
||||
*/ |
||||
public function informer() { |
||||
if ($this->codeErreur !== 0) { |
||||
return false; |
||||
} |
||||
|
||||
$res = [ |
||||
'proprietes' => [], |
||||
'fichiers' => [ |
||||
/* |
||||
* filename |
||||
* checksum |
||||
* size |
||||
* mtime |
||||
* status |
||||
* raw |
||||
*/ |
||||
] |
||||
]; |
||||
|
||||
switch ($this->modeCompression) { |
||||
case 'zip': |
||||
include_spip('inc/pclzip'); |
||||
$zip = new \PclZip($this->fichierArchive); |
||||
$files = $zip->listContent(); |
||||
foreach ($files as $file) { |
||||
$res['fichiers'][] = [ |
||||
'filename' => $file['stored_filename'], |
||||
'checksum' => $file['crc'], |
||||
'size' => $file['size'], |
||||
'mtime' => $file['mtime'], |
||||
'raw' => $file |
||||
]; |
||||
} |
||||
break; |
||||
case 'tar': |
||||
case 'tgz': |
||||
include_spip('inc/pcltar'); |
||||
$files = PclTarList($this->fichierArchive, $this->modeCompression); |
||||
foreach ($files as $file) { |
||||
$res['fichiers'][] = [ |
||||
'filename' => $file['filename'], |
||||
'checksum' => $file['checksum'], |
||||
'size' => $file['size'], |
||||
'mtime' => $file['mtime'], |
||||
'raw' => $file |
||||
]; |
||||
} |
||||
} |
||||
|
||||
// trouver la racine des fichiers |
||||
if (!empty($res['fichiers'])) { |
||||
$res['proprietes']['racine'] = $this->trouver_racine(array_column($res['fichiers'], 'filename')); |
||||
} |
||||
else { |
||||
$res['proprietes']['racine'] = ''; |
||||
} |
||||
|
||||
return $res; |
||||
} |
||||
|
||||
/** |
||||
* Cherche la plus longue racine commune à tous les fichiers |
||||
* |
||||
* @param array $list |
||||
* Liste de chemin de fichiers |
||||
* @return string |
||||
* Chemin commun entre tous les fichiers |
||||
**/ |
||||
protected function trouver_racine($path_list) { |
||||
// on cherche la plus longue racine commune a tous les fichiers |
||||
// pour l'enlever au deballage |
||||
$max_n = 999999; |
||||
$paths = []; |
||||
foreach ($path_list as $path) { |
||||
$p = []; |
||||
foreach (explode('/', $path) as $n => $x) { |
||||
if ($n > $max_n) { |
||||
continue; |
||||
} |
||||
$sofar = join('/', $p); |
||||
if (!isset($paths[$n])) { |
||||
$paths[$n] = []; |
||||
} |
||||
if (!isset($paths[$n][$sofar])) { |
||||
$paths[$n][$sofar] = 0; |
||||
} |
||||
$paths[$n][$sofar]++; |
||||
$p[] = $x; |
||||
} |
||||
$max_n = min($n, $max_n); |
||||
} |
||||
|
||||
$total = $paths[0]['']; |
||||
$i = 0; |
||||
while ( |
||||
isset($paths[$i]) |
||||
and count($paths[$i]) <= 1 |
||||
and array_values($paths[$i]) == [$total] |
||||
) { |
||||
$i++; |
||||
} |
||||
|
||||
$racine = ''; |
||||
if ($i) { |
||||
$racine = array_keys($paths[$i - 1]); |
||||
$racine = array_pop($racine); |
||||
if ($racine) { |
||||
$racine .= '/'; |
||||
} |
||||
} |
||||
|
||||
return $racine; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Extraire tout ou partie des fichiers de l'archive vers une destination. |
||||
* |
||||
* @param string $destination Chemin du répertoire d'extraction |
||||
* @param array $fichiers Liste des fichiers à extraire |
||||
* |
||||
* @return boolean Succès de l'opération |
||||
*/ |
||||
public function deballer($destination = '', array $fichiers = []) { |
||||
if ($this->codeErreur !== 0) { |
||||
return false; |
||||
} |
||||
|
||||
if (!(is_dir($destination) and is_writable($destination))) { |
||||
$this->codeErreur = 5; |
||||
return false; |
||||
} |
||||
|
||||
if (!$infos = $this->informer()) { |
||||
return false; |
||||
} |
||||
|
||||
$errors = []; |
||||
switch ($this->modeCompression) { |
||||
case 'zip': |
||||
include_spip('inc/pclzip'); |
||||
$zip = new \PclZip($this->fichierArchive); |
||||
|
||||
if (!$fichiers) { |
||||
$ok = $zip->extract( |
||||
PCLZIP_OPT_PATH, |
||||
$destination, |
||||
PCLZIP_OPT_SET_CHMOD, |
||||
_SPIP_CHMOD, |
||||
PCLZIP_OPT_REPLACE_NEWER, |
||||
PCLZIP_OPT_REMOVE_PATH, |
||||
$infos['proprietes']['racine'] |
||||
); |
||||
if (!$ok or $zip->error_code < 0) { |
||||
$errors[] = 'deballer() erreur zip ' . $zip->error_code . ' pour paquet: ' . $this->fichierArchive; |
||||
return false; |
||||
} |
||||
} |
||||
else { |
||||
foreach ($fichiers as $fichier) { |
||||
$ok = $zip->extract( |
||||
PCLZIP_OPT_PATH, |
||||
$destination, |
||||
PCLZIP_OPT_SET_CHMOD, |
||||
_SPIP_CHMOD, |
||||
PCLZIP_OPT_REPLACE_NEWER, |
||||
PCLZIP_OPT_REMOVE_PATH, |
||||
$infos['proprietes']['racine'], |
||||
PCLZIP_OPT_BY_NAME, |
||||
$fichier |
||||
); |
||||
if (!$ok or $zip->error_code < 0) { |
||||
$errors[] = "deballer() Fichier $fichier: erreur zip " . $zip->error_code . ' pour paquet: ' . $this->fichierArchive; |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
break; |
||||
|
||||
case 'tar': |
||||
case 'tgz': |
||||
include_spip('inc/pcltar'); |
||||
if (!$fichiers) { |
||||
$ok = PclTarExtract($this->fichierArchive, $destination, $infos['proprietes']['racine'], $this->modeCompression); |
||||
if ($ok === 0) { |
||||
$errors[] = 'deballer() erreur tar ' . PclErrorString() . ' pour paquet: ' . $this->fichierArchive; |
||||
} |
||||
} |
||||
else { |
||||
$ok = PclTarExtractList($this->fichierArchive, $fichiers, $destination, $infos['proprietes']['racine'], $this->modeCompression); |
||||
if ($ok === 0) { |
||||
$errors[] = 'deballer() erreur tar ' . PclErrorString() . ' pour paquet: ' . $this->fichierArchive; |
||||
} |
||||
} |
||||
|
||||
break; |
||||
} |
||||
|
||||
if (count($errors)) { |
||||
$this->codeErreur = 1; |
||||
$this->messageErreur = implode("\n", $errors); |
||||
|
||||
return false; |
||||
} |
||||
|
||||
$this->codeErreur = 0; |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* Créer ou modifier des fichiers dans le fichier d'archive. |
||||
* |
||||
* @param array $fichiers Liste des fichiers à ajouter ou modifier |
||||
* @param string $racine Repertoire racine des fichiers a retirer du chemin lorsqu'on zip |
||||
* |
||||
* @return boolean Succès de l'opération |
||||
*/ |
||||
public function emballer(array $fichiers = [], $racine = null) { |
||||
if ($this->lectureSeule) { |
||||
$this->codeErreur = 4; |
||||
return false; |
||||
} |
||||
|
||||
// le fichier ne doit pas deja exister (c'est une creation) |
||||
if ($this->codeErreur !== 3) { |
||||
$this->codeErreur = 6; |
||||
return false; |
||||
} |
||||
|
||||
// si pas de racine fournie, on la determine automatiquement |
||||
// en trouvant le chemin le plus long commun a tous les fichiers |
||||
if (is_null($racine)) { |
||||
$racine = $this->trouver_racine($fichiers); |
||||
} |
||||
|
||||
switch ($this->modeCompression) { |
||||
case 'zip': |
||||
include_spip('inc/pclzip'); |
||||
$zip = new \PclZip($this->fichierArchive); |
||||
|
||||
$v_list = $zip->create( |
||||
$fichiers, |
||||
PCLZIP_OPT_REMOVE_PATH, |
||||
$racine, |
||||
PCLZIP_OPT_ADD_PATH, |
||||
'' |
||||
); |
||||
if (!$v_list or $zip->error_code < 0) { |
||||
$this->codeErreur = 1; |
||||
$this->messageErreur = 'emballer() : Echec creation du zip ' . $zip->error_code . ' pour paquet: ' . $this->fichierArchive; |
||||
return false; |
||||
} |
||||
|
||||
break; |
||||
|
||||
case 'tar': |
||||
case 'tgz': |
||||
include_spip('inc/pcltar'); |
||||
|
||||
$ok = PclTarCreate($this->fichierArchive, $fichiers, $this->modeCompression, '', $racine); |
||||
if ($ok === 0) { |
||||
$this->codeErreur = 1; |
||||
$this->messageErreur = 'emballer() : Echec creation du ' . $this->modeCompression . ' ' . PclErrorString() . ' pour paquet: ' . $this->fichierArchive; |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
// verifier que le fichier existe bien |
||||
if (!file_exists($this->fichierArchive)) { |
||||
$this->codeErreur = 3; |
||||
return false; |
||||
} |
||||
|
||||
$this->codeErreur = 0; |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* Retirer une liste de fichiers dans le fichier d'archive. |
||||
* |
||||
* @param array $fichiers Liste des fichiers à retirer |
||||
* |
||||
* @return boolean Succès de l'opération |
||||
*/ |
||||
public function retirer(array $fichiers = []) { |
||||
if ($this->lectureSeule) { |
||||
$this->codeErreur = 4; |
||||
return false; |
||||
} |
||||
|
||||
if ($this->codeErreur !== 0) { |
||||
return false; |
||||
} |
||||
|
||||
switch ($this->modeCompression) { |
||||
case 'zip': |
||||
include_spip('inc/pclzip'); |
||||
$zip = new \PclZip($this->fichierArchive); |
||||
$ok = $zip->delete(PCLZIP_OPT_BY_NAME, $fichiers); |
||||
if (!$ok or $zip->error_code < 0) { |
||||
$this->codeErreur = 1; |
||||
$this->messageErreur = 'retirer() : Echec retirer fichiers ' . json_encode($fichiers, JSON_THROW_ON_ERROR) . ' ' . $zip->error_code . ' pour paquet: ' . $this->fichierArchive; |
||||
return false; |
||||
} |
||||
break; |
||||
|
||||
case 'tar': |
||||
case 'tgz': |
||||
include_spip('inc/pcltar'); |
||||
$ok = PclTarDelete($this->fichierArchive, $fichiers, $this->modeCompression); |
||||
if ($ok === 0) { |
||||
$this->codeErreur = 1; |
||||
$this->messageErreur = 'retirer() : Echec retirer fichiers ' . json_encode($fichiers, JSON_THROW_ON_ERROR) . ' ' . PclErrorString() . ' pour paquet: ' . $this->fichierArchive; |
||||
return false; |
||||
} |
||||
|
||||
break; |
||||
} |
||||
|
||||
|
||||
$this->codeErreur = 0; |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* Constructeur de base. |
||||
* |
||||
* @param string $fichierArchive Chemin vers le fichier d'archives |
||||
* @param string $modeCompression Mode de compression si l'extension du fichier n'est pas explicite |
||||
*/ |
||||
public function __construct($fichierArchive, $modeCompression = '') { |
||||
$this->codeErreur = 0; |
||||
|
||||
if ('' === $modeCompression) { |
||||
$modeCompression = preg_replace(',.+\.([^.]+)$,', '$1', $fichierArchive); |
||||
} |
||||
|
||||
$modeCompression = strtolower($modeCompression); |
||||
if (!in_array($modeCompression, self::compressionsConnues)) { |
||||
$this->codeErreur = 2; |
||||
} elseif (!file_exists($fichierArchive)) { |
||||
$this->codeErreur = 3; |
||||
|
||||
$repertoireArchive = dirname($fichierArchive); |
||||
$this->lectureSeule = !(is_dir($repertoireArchive) and is_writable($repertoireArchive)); |
||||
} else { |
||||
$this->lectureSeule = !is_writable($fichierArchive); |
||||
} |
||||
|
||||
$this->modeCompression = $modeCompression; |
||||
$this->fichierArchive = $fichierArchive; |
||||
} |
||||
|
||||
/** |
||||
* Indique si l'archive est accessible en ecriture ou pas. |
||||
* |
||||
* @return boolean true si l'archive est en lecture seule |
||||
*/ |
||||
public function getLectureSeule() { |
||||
return $this->lectureSeule; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,11 @@
|
||||
<?php |
||||
|
||||
$GLOBALS[$GLOBALS['idx_lang']] = [ |
||||
'OK' => 'OK', |
||||
'erreur_inconnue' => 'Erreur inconnue', |
||||
'extension_inconnue' => 'Extension inconnue', |
||||
'fichier_absent' => 'Fichier absent', |
||||
'fichier_lecture_seule' => 'Fichier en lecture seule', |
||||
'destination_inaccessible' => 'Desination inaccessible', |
||||
'fichier_deja_existant' => 'Le fichier existe déjà', |
||||
]; |
@ -1,132 +0,0 @@
|
||||
<?php |
||||
// -------------------------------------------------------------------------------- |
||||
// PhpConcept Library (PCL) Error 1.0 |
||||
// -------------------------------------------------------------------------------- |
||||
// License GNU/GPL - Vincent Blavet - Mars 2001 |
||||
// http://www.phpconcept.net & http://phpconcept.free.fr |
||||
// -------------------------------------------------------------------------------- |
||||
// Français : |
||||
// La description de l'usage de la librairie PCL Error 1.0 n'est pas encore |
||||
// disponible. Celle-ci n'est pour le moment distribuée qu'avec les |
||||
// développements applicatifs de PhpConcept. |
||||
// Une version indépendante sera bientot disponible sur http://www.phpconcept.net |
||||
// |
||||
// English : |
||||
// The PCL Error 1.0 library description is not available yet. This library is |
||||
// released only with PhpConcept application and libraries. |
||||
// An independant release will be soon available on http://www.phpconcept.net |
||||
// |
||||
// -------------------------------------------------------------------------------- |
||||
// |
||||
// * Avertissement : |
||||
// |
||||
// Cette librairie a été créée de façon non professionnelle. |
||||
// Son usage est au risque et péril de celui qui l'utilise, en aucun cas l'auteur |
||||
// de ce code ne pourra être tenu pour responsable des éventuels dégats qu'il pourrait |
||||
// engendrer. |
||||
// Il est entendu cependant que l'auteur a réalisé ce code par plaisir et n'y a |
||||
// caché aucun virus, ni malveillance. |
||||
// Cette libairie est distribuée sous la license GNU/GPL (http://www.gnu.org) |
||||
// |
||||
// * Auteur : |
||||
// |
||||
// Ce code a été écrit par Vincent Blavet (vincent@blavet.net) sur son temps |
||||
// de loisir. |
||||
// |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// ----- Look for double include |
||||
if (!defined("PCLERROR_LIB")) |
||||
{ |
||||
define( "PCLERROR_LIB", 1 ); |
||||
|
||||
// ----- Version |
||||
$g_pcl_error_version = "1.0"; |
||||
|
||||
// ----- Internal variables |
||||
// These values must only be change by PclError library functions |
||||
$g_pcl_error_string = ""; |
||||
$g_pcl_error_code = 1; |
||||
|
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : PclErrorLog() |
||||
// Description : |
||||
// Parameters : |
||||
// -------------------------------------------------------------------------------- |
||||
function PclErrorLog($p_error_code = 0, $p_error_string = "") |
||||
{ |
||||
global $g_pcl_error_string; |
||||
global $g_pcl_error_code; |
||||
|
||||
$g_pcl_error_code = $p_error_code; |
||||
$g_pcl_error_string = $p_error_string; |
||||
|
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : PclErrorFatal() |
||||
// Description : |
||||
// Parameters : |
||||
// -------------------------------------------------------------------------------- |
||||
function PclErrorFatal($p_file, $p_line, $p_error_string = "") |
||||
{ |
||||
global $g_pcl_error_string; |
||||
global $g_pcl_error_code; |
||||
|
||||
$v_message = "<html><body>"; |
||||
$v_message .= "<p align=center><font color=red bgcolor=white><b>PclError Library has detected a fatal error on file '$p_file', line $p_line</b></font></p>"; |
||||
$v_message .= "<p align=center><font color=red bgcolor=white><b>$p_error_string</b></font></p>"; |
||||
$v_message .= "</body></html>"; |
||||
die($v_message); |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : PclErrorReset() |
||||
// Description : |
||||
// Parameters : |
||||
// -------------------------------------------------------------------------------- |
||||
function PclErrorReset() |
||||
{ |
||||
global $g_pcl_error_string; |
||||
global $g_pcl_error_code; |
||||
|
||||
$g_pcl_error_code = 1; |
||||
$g_pcl_error_string = ""; |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : PclErrorCode() |
||||
// Description : |
||||
// Parameters : |
||||
// -------------------------------------------------------------------------------- |
||||
function PclErrorCode() |
||||
{ |
||||
global $g_pcl_error_string; |
||||
global $g_pcl_error_code; |
||||
|
||||
return($g_pcl_error_code); |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : PclErrorString() |
||||
// Description : |
||||
// Parameters : |
||||
// -------------------------------------------------------------------------------- |
||||
function PclErrorString() |
||||
{ |
||||
global $g_pcl_error_string; |
||||
global $g_pcl_error_code; |
||||
|
||||
return($g_pcl_error_string." [code $g_pcl_error_code]"); |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
|
||||
// ----- End of double include look |
||||
} |
||||
?> |
@ -1,454 +0,0 @@
|
||||
<?php |
||||
// -------------------------------------------------------------------------------- |
||||
// PhpConcept Library (PCL) Trace 1.0 |
||||
// -------------------------------------------------------------------------------- |
||||
// License GNU/GPL - Vincent Blavet - Janvier 2001 |
||||
// http://www.phpconcept.net & http://phpconcept.free.fr |
||||
// -------------------------------------------------------------------------------- |
||||
// Français : |
||||
// La description de l'usage de la librairie PCL Trace 1.0 n'est pas encore |
||||
// disponible. Celle-ci n'est pour le moment distribuée qu'avec l'application |
||||
// et la librairie PhpZip. |
||||
// Une version indépendante sera bientot disponible sur http://www.phpconcept.net |
||||
// |
||||
// English : |
||||
// The PCL Trace 1.0 library description is not available yet. This library is |
||||
// released only with PhpZip application and library. |
||||
// An independant release will be soon available on http://www.phpconcept.net |
||||
// |
||||
// -------------------------------------------------------------------------------- |
||||
// |
||||
// * Avertissement : |
||||
// |
||||
// Cette librairie a été créée de façon non professionnelle. |
||||
// Son usage est au risque et péril de celui qui l'utilise, en aucun cas l'auteur |
||||
// de ce code ne pourra être tenu pour responsable des éventuels dégats qu'il pourrait |
||||
// engendrer. |
||||
// Il est entendu cependant que l'auteur a réalisé ce code par plaisir et n'y a |
||||
// caché aucun virus, ni malveillance. |
||||
// Cette libairie est distribuée sous la license GNU/GPL (http://www.gnu.org) |
||||
// |
||||
// * Auteur : |
||||
// |
||||
// Ce code a été écrit par Vincent Blavet (vincent@blavet.net) sur son temps |
||||
// de loisir. |
||||
// |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// ----- Look for double include |
||||
if (!defined("PCLTRACE_LIB")) |
||||
{ |
||||
define( "PCLTRACE_LIB", 1 ); |
||||
|
||||
// ----- Version |
||||
$g_pcl_trace_version = "1.0"; |
||||
|
||||
// ----- Internal variables |
||||
// These values must be change by PclTrace library functions |
||||
$g_pcl_trace_mode = "memory"; |
||||
$g_pcl_trace_filename = "trace.txt"; |
||||
$g_pcl_trace_name = array(); |
||||
$g_pcl_trace_index = 0; |
||||
$g_pcl_trace_level = 0; |
||||
//$g_pcl_trace_entries = array(); |
||||
|
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : TrOn($p_level, $p_mode, $p_filename) |
||||
// Description : |
||||
// Parameters : |
||||
// $p_level : Trace level |
||||
// $p_mode : Mode of trace displaying : |
||||
// 'normal' : messages are displayed at function call |
||||
// 'memory' : messages are memorized in a table and can be display by |
||||
// TrDisplay() function. (default) |
||||
// 'log' : messages are writed in the file $p_filename |
||||
// -------------------------------------------------------------------------------- |
||||
function TrOn($p_level = 1, $p_mode = "memory", $p_filename = "trace.txt") |
||||
{ |
||||
global $g_pcl_trace_level; |
||||
global $g_pcl_trace_mode; |
||||
global $g_pcl_trace_filename; |
||||
global $g_pcl_trace_name; |
||||
global $g_pcl_trace_index; |
||||
global $g_pcl_trace_entries; |
||||
|
||||
// ----- Enable trace mode |
||||
$g_pcl_trace_level = $p_level; |
||||
|
||||
// ----- Memorize mode and filename |
||||
switch ($p_mode) { |
||||
case "normal" : |
||||
case "memory" : |
||||
case "log" : |
||||
$g_pcl_trace_mode = $p_mode; |
||||
break; |
||||
default : |
||||
$g_pcl_trace_mode = "logged"; |
||||
} |
||||
|
||||
// ----- Memorize filename |
||||
$g_pcl_trace_filename = $p_filename; |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : IsTrOn() |
||||
// Description : |
||||
// Return value : |
||||
// The trace level (0 for disable). |
||||
// -------------------------------------------------------------------------------- |
||||
function IsTrOn() |
||||
{ |
||||
global $g_pcl_trace_level; |
||||
|
||||
return($g_pcl_trace_level); |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : TrOff() |
||||
// Description : |
||||
// Parameters : |
||||
// -------------------------------------------------------------------------------- |
||||
function TrOff() |
||||
{ |
||||
global $g_pcl_trace_level; |
||||
global $g_pcl_trace_mode; |
||||
global $g_pcl_trace_filename; |
||||
global $g_pcl_trace_name; |
||||
global $g_pcl_trace_index; |
||||
|
||||
// ----- Clean |
||||
$g_pcl_trace_mode = "memory"; |
||||
unset($g_pcl_trace_entries); |
||||
unset($g_pcl_trace_name); |
||||
unset($g_pcl_trace_index); |
||||
|
||||
// ----- Switch off trace |
||||
$g_pcl_trace_level = 0; |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : TrFctStart() |
||||
// Description : |
||||
// Just a trace function for debbugging purpose before I use a better tool !!!! |
||||
// Start and stop of this function is by $g_pcl_trace_level global variable. |
||||
// Parameters : |
||||
// $p_level : Level of trace required. |
||||
// -------------------------------------------------------------------------------- |
||||
function TrFctStart($p_file, $p_line, $p_name, $p_param = "", $p_message = "") |
||||
{ |
||||
global $g_pcl_trace_level; |
||||
global $g_pcl_trace_mode; |
||||
global $g_pcl_trace_filename; |
||||
global $g_pcl_trace_name; |
||||
global $g_pcl_trace_index; |
||||
global $g_pcl_trace_entries; |
||||
|
||||
// ----- Look for disabled trace |
||||
if ($g_pcl_trace_level < 1) |
||||
return; |
||||
|
||||
// ----- Add the function name in the list |
||||
if (!isset($g_pcl_trace_name)) |
||||
$g_pcl_trace_name = $p_name; |
||||
else |
||||
$g_pcl_trace_name .= ",".$p_name; |
||||
|
||||
// ----- Update the function entry |
||||
$i = sizeof($g_pcl_trace_entries); |
||||
$g_pcl_trace_entries[$i][name] = $p_name; |
||||
$g_pcl_trace_entries[$i][param] = $p_param; |
||||
$g_pcl_trace_entries[$i][message] = ""; |
||||
$g_pcl_trace_entries[$i][file] = $p_file; |
||||
$g_pcl_trace_entries[$i][line] = $p_line; |
||||
$g_pcl_trace_entries[$i][index] = $g_pcl_trace_index; |
||||
$g_pcl_trace_entries[$i][type] = "1"; // means start of function |
||||
|
||||
// ----- Update the message entry |
||||
if ($p_message != "") |
||||
{ |
||||
$i = sizeof($g_pcl_trace_entries); |
||||
$g_pcl_trace_entries[$i][name] = ""; |
||||
$g_pcl_trace_entries[$i][param] = ""; |
||||
$g_pcl_trace_entries[$i][message] = $p_message; |
||||
$g_pcl_trace_entries[$i][file] = $p_file; |
||||
$g_pcl_trace_entries[$i][line] = $p_line; |
||||
$g_pcl_trace_entries[$i][index] = $g_pcl_trace_index; |
||||
$g_pcl_trace_entries[$i][type] = "3"; // means message |
||||
} |
||||
|
||||
// ----- Action depending on mode |
||||
PclTraceAction($g_pcl_trace_entries[$i]); |
||||
|
||||
// ----- Increment the index |
||||
$g_pcl_trace_index++; |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : TrFctEnd() |
||||
// Description : |
||||
// Just a trace function for debbugging purpose before I use a better tool !!!! |
||||
// Start and stop of this function is by $g_pcl_trace_level global variable. |
||||
// Parameters : |
||||
// $p_level : Level of trace required. |
||||
// -------------------------------------------------------------------------------- |
||||
function TrFctEnd($p_file, $p_line, $p_return = 1, $p_message = "") |
||||
{ |
||||
global $g_pcl_trace_level; |
||||
global $g_pcl_trace_mode; |
||||
global $g_pcl_trace_filename; |
||||
global $g_pcl_trace_name; |
||||
global $g_pcl_trace_index; |
||||
global $g_pcl_trace_entries; |
||||
|
||||
// ----- Look for disabled trace |
||||
if ($g_pcl_trace_level < 1) |
||||
return; |
||||
|
||||
// ----- Extract the function name in the list |
||||
// ----- Remove the function name in the list |
||||
if (!($v_name = strrchr($g_pcl_trace_name, ","))) |
||||
{ |
||||
$v_name = $g_pcl_trace_name; |
||||
$g_pcl_trace_name = ""; |
||||
} |
||||
else |
||||
{ |
||||
$g_pcl_trace_name = substr($g_pcl_trace_name, 0, strlen($g_pcl_trace_name)-strlen($v_name)); |
||||
$v_name = substr($v_name, -strlen($v_name)+1); |
||||
} |
||||
|
||||
// ----- Decrement the index |
||||
$g_pcl_trace_index--; |
||||
|
||||
// ----- Update the message entry |
||||
if ($p_message != "") |
||||
{ |
||||
$i = sizeof($g_pcl_trace_entries); |
||||
$g_pcl_trace_entries[$i][name] = ""; |
||||
$g_pcl_trace_entries[$i][param] = ""; |
||||
$g_pcl_trace_entries[$i][message] = $p_message; |
||||
$g_pcl_trace_entries[$i][file] = $p_file; |
||||
$g_pcl_trace_entries[$i][line] = $p_line; |
||||
$g_pcl_trace_entries[$i][index] = $g_pcl_trace_index; |
||||
$g_pcl_trace_entries[$i][type] = "3"; // means message |
||||
} |
||||
|
||||
// ----- Update the function entry |
||||
$i = sizeof($g_pcl_trace_entries); |
||||
$g_pcl_trace_entries[$i][name] = $v_name; |
||||
$g_pcl_trace_entries[$i][param] = $p_return; |
||||
$g_pcl_trace_entries[$i][message] = ""; |
||||
$g_pcl_trace_entries[$i][file] = $p_file; |
||||
$g_pcl_trace_entries[$i][line] = $p_line; |
||||
$g_pcl_trace_entries[$i][index] = $g_pcl_trace_index; |
||||
$g_pcl_trace_entries[$i][type] = "2"; // means end of function |
||||
|
||||
// ----- Action depending on mode |
||||
PclTraceAction($g_pcl_trace_entries[$i]); |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : TrFctMessage() |
||||
// Description : |
||||
// Parameters : |
||||
// -------------------------------------------------------------------------------- |
||||
function TrFctMessage($p_file, $p_line, $p_level, $p_message = "") |
||||
{ |
||||
global $g_pcl_trace_level; |
||||
global $g_pcl_trace_mode; |
||||
global $g_pcl_trace_filename; |
||||
global $g_pcl_trace_name; |
||||
global $g_pcl_trace_index; |
||||
global $g_pcl_trace_entries; |
||||
|
||||
// ----- Look for disabled trace |
||||
if ($g_pcl_trace_level < $p_level) |
||||
return; |
||||
|
||||
// ----- Update the entry |
||||
$i = sizeof($g_pcl_trace_entries); |
||||
$g_pcl_trace_entries[$i][name] = ""; |
||||
$g_pcl_trace_entries[$i][param] = ""; |
||||
$g_pcl_trace_entries[$i][message] = $p_message; |
||||
$g_pcl_trace_entries[$i][file] = $p_file; |
||||
$g_pcl_trace_entries[$i][line] = $p_line; |
||||
$g_pcl_trace_entries[$i][index] = $g_pcl_trace_index; |
||||
$g_pcl_trace_entries[$i][type] = "3"; // means message of function |
||||
|
||||
// ----- Action depending on mode |
||||
PclTraceAction($g_pcl_trace_entries[$i]); |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : TrMessage() |
||||
// Description : |
||||
// Parameters : |
||||
// -------------------------------------------------------------------------------- |
||||
function TrMessage($p_file, $p_line, $p_level, $p_message = "") |
||||
{ |
||||
global $g_pcl_trace_level; |
||||
global $g_pcl_trace_mode; |
||||
global $g_pcl_trace_filename; |
||||
global $g_pcl_trace_name; |
||||
global $g_pcl_trace_index; |
||||
global $g_pcl_trace_entries; |
||||
|
||||
// ----- Look for disabled trace |
||||
if ($g_pcl_trace_level < $p_level) |
||||
return; |
||||
|
||||
// ----- Update the entry |
||||
$i = sizeof($g_pcl_trace_entries); |
||||
$g_pcl_trace_entries[$i][name] = ""; |
||||
$g_pcl_trace_entries[$i][param] = ""; |
||||
$g_pcl_trace_entries[$i][message] = $p_message; |
||||
$g_pcl_trace_entries[$i][file] = $p_file; |
||||
$g_pcl_trace_entries[$i][line] = $p_line; |
||||
$g_pcl_trace_entries[$i][index] = $g_pcl_trace_index; |
||||
$g_pcl_trace_entries[$i][type] = "4"; // means simple message |
||||
|
||||
// ----- Action depending on mode |
||||
PclTraceAction($g_pcl_trace_entries[$i]); |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : TrDisplay() |
||||
// Description : |
||||
// Parameters : |
||||
// -------------------------------------------------------------------------------- |
||||
function TrDisplay() |
||||
{ |
||||
global $g_pcl_trace_level; |
||||
global $g_pcl_trace_mode; |
||||
global $g_pcl_trace_filename; |
||||
global $g_pcl_trace_name; |
||||
global $g_pcl_trace_index; |
||||
global $g_pcl_trace_entries; |
||||
|
||||
// ----- Look for disabled trace |
||||
if (($g_pcl_trace_level <= 0) || ($g_pcl_trace_mode != "memory")) |
||||
return; |
||||
|
||||
$v_font = "\"Verdana, Arial, Helvetica, sans-serif\""; |
||||
|
||||
// ----- Trace Header |
||||
echo "<table width=100% border=0 cellspacing=0 cellpadding=0>"; |
||||
echo "<tr bgcolor=#0000CC>"; |
||||
echo "<td bgcolor=#0000CC width=1>"; |
||||
echo "</td>"; |
||||
echo "<td><div align=center><font size=3 color=#FFFFFF face=$v_font>Trace</font></div></td>"; |
||||
echo "</tr>"; |
||||
echo "<tr>"; |
||||
echo "<td bgcolor=#0000CC width=1>"; |
||||
echo "</td>"; |
||||
echo "<td>"; |
||||
|
||||
// ----- Content header |
||||
echo "<table width=100% border=0 cellspacing=0 cellpadding=0>"; |
||||
|
||||
// ----- Display |
||||
$v_again=0; |
||||
for ($i=0; $i<sizeof($g_pcl_trace_entries); $i++) |
||||
{ |
||||
// ---- Row header |
||||
echo "<tr>"; |
||||
echo "<td><table width=100% border=0 cellspacing=0 cellpadding=0><tr>"; |
||||
$n = ($g_pcl_trace_entries[$i][index]+1)*10; |
||||
echo "<td width=".$n."><table width=100% border=0 cellspacing=0 cellpadding=0><tr>"; |
||||
|
||||
for ($j=0; $j<=$g_pcl_trace_entries[$i][index]; $j++) |
||||
{ |
||||
if ($j==$g_pcl_trace_entries[$i][index]) |
||||
{ |
||||
if (($g_pcl_trace_entries[$i][type] == 1) || ($g_pcl_trace_entries[$i][type] == 2)) |
||||
echo "<td width=10><div align=center><font size=2 face=$v_font>+</font></div></td>"; |
||||
} |
||||
else |
||||
echo "<td width=10><div align=center><font size=2 face=$v_font>|</font></div></td>"; |
||||
} |
||||
//echo "<td> </td>"; |
||||
echo "</tr></table></td>"; |
||||
|
||||
echo "<td width=2></td>"; |
||||
switch ($g_pcl_trace_entries[$i][type]) { |
||||
case 1: |
||||
echo "<td><font size=2 face=$v_font>".$g_pcl_trace_entries[$i][name]."(".$g_pcl_trace_entries[$i][param].")</font></td>"; |
||||
break; |
||||
case 2: |
||||
echo "<td><font size=2 face=$v_font>".$g_pcl_trace_entries[$i][name]."()=".$g_pcl_trace_entries[$i][param]."</font></td>"; |
||||
break; |
||||
case 3: |
||||
case 4: |
||||
echo "<td><table width=100% border=0 cellspacing=0 cellpadding=0><td width=20></td><td>"; |
||||
echo "<font size=2 face=$v_font>".$g_pcl_trace_entries[$i][message]."</font>"; |
||||
echo "</td></table></td>"; |
||||
break; |
||||
default: |
||||
echo "<td><font size=2 face=$v_font>".$g_pcl_trace_entries[$i][name]."(".$g_pcl_trace_entries[$i][param].")</font></td>"; |
||||
} |
||||
echo "</tr></table></td>"; |
||||
echo "<td width=5></td>"; |
||||
echo "<td><font size=1 face=$v_font>".basename($g_pcl_trace_entries[$i][file])."</font></td>"; |
||||
echo "<td width=5></td>"; |
||||
echo "<td><font size=1 face=$v_font>".$g_pcl_trace_entries[$i][line]."</font></td>"; |
||||
echo "</tr>"; |
||||
} |
||||
|
||||
// ----- Content footer |
||||
echo "</table>"; |
||||
|
||||
// ----- Trace footer |
||||
echo "</td>"; |
||||
echo "<td bgcolor=#0000CC width=1>"; |
||||
echo "</td>"; |
||||
echo "</tr>"; |
||||
echo "<tr bgcolor=#0000CC>"; |
||||
echo "<td bgcolor=#0000CC width=1>"; |
||||
echo "</td>"; |
||||
echo "<td><div align=center><font color=#FFFFFF face=$v_font> </font></div></td>"; |
||||
echo "</tr>"; |
||||
echo "</table>"; |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// -------------------------------------------------------------------------------- |
||||
// Function : PclTraceAction() |
||||
// Description : |
||||
// Parameters : |
||||
// -------------------------------------------------------------------------------- |
||||
function PclTraceAction($p_entry) |
||||
{ |
||||
global $g_pcl_trace_level; |
||||
global $g_pcl_trace_mode; |
||||
global $g_pcl_trace_filename; |
||||
global $g_pcl_trace_name; |
||||
global $g_pcl_trace_index; |
||||
global $g_pcl_trace_entries; |
||||
|
||||
if ($g_pcl_trace_mode == "normal") |
||||
{ |
||||
for ($i=0; $i<$p_entry[index]; $i++) |
||||
echo "---"; |
||||
if ($p_entry[type] == 1) |
||||
echo "<b>".$p_entry[name]."</b>(".$p_entry[param].") : ".$p_entry[message]." [".$p_entry[file].", ".$p_entry[line]."]<br>"; |
||||
else if ($p_entry[type] == 2) |
||||
echo "<b>".$p_entry[name]."</b>()=".$p_entry[param]." : ".$p_entry[message]." [".$p_entry[file].", ".$p_entry[line]."]<br>"; |
||||
else |
||||
echo $p_entry[message]." [".$p_entry[file].", ".$p_entry[line]."]<br>"; |
||||
} |
||||
} |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
// ----- End of double include look |
||||
} |
||||
?> |
@ -1,493 +0,0 @@
|
||||
// -------------------------------------------------------------------------------- |
||||
// PclTar 1.3.1 - readme.txt |
||||
// -------------------------------------------------------------------------------- |
||||
// License GNU/GPL - Vincent Blavet - January 2003 |
||||
// http://www.phpconcept.net |
||||
// -------------------------------------------------------------------------------- |
||||
|
||||
(Voir version Française à la fin) |
||||
|
||||
0 - Sommaire |
||||
============ |
||||
1 - Introduction |
||||
2 - Install |
||||
3 - What's new |
||||
4 - Using PclTar |
||||
5 - Manual |
||||
6 - Language |
||||
7 - Known bugs |
||||
8 - License |
||||
9 - Warning |
||||
10 - Author |
||||
|
||||
1 - Introduction |
||||
================ |
||||
|
||||
PclTar is a library that allow you to create a GNU TAR archive, |
||||
to add files or directories, to extract all the archive or a part of it. |
||||
So far tests show that the files generated by PclTar are readable by |
||||
gzip tools and WinZip application. |
||||
|
||||
PclTar is made of the following files, placed in the same 'lib' directory : |
||||
- pcltar.lib.php3 |
||||
- pcltrace.lib.php3 |
||||
- pclerror.lib.php3 |
||||
|
||||
Today the libraries PclTrace and PclError are mandatory to run PclTar. |
||||
|
||||
The extension of the files can be modified to .php (or other) without any |
||||
internal modification. |
||||
|
||||
The files can be put into any directory as far as the calling script/application |
||||
has a valid path to it (see section using PclTar). |
||||
|
||||
|
||||
2 - Install |
||||
=========== |
||||
|
||||
PclTar 1.3 is released in three format : |
||||
|
||||
- Zip traditionnal format (pcltar-1-3.zip), |
||||
- Compressed GNU TAR format (pcltar-1-3.tgz), |
||||
- PhpZip auto-extract PhpZip (pcltar-1-3.piz). |
||||
|
||||
The Zip and compressed GNU TAR file also include the auto-extract PhpZip file, which |
||||
might be usefull for a remote auto-install. |
||||
|
||||
a. Zip archive |
||||
Unzip the Zip file in a folder. |
||||
The files are in the 'lib' directory, but may be moved in any other directory. |
||||
|
||||
b. Compressed GNU TAR archive |
||||
Extract the Compressed GNU TAR file in a folder. |
||||
The files are in the 'lib' directory, but may be moved in any other directory. |
||||
|
||||
c. Auto-extract PhpZip archive |
||||
Download *** IN BINARY MODE *** the auto-extract PhpZip archive on your web site |
||||
in the destination directory 'myfolder'. |
||||
Launch the extract by calling http://mydomain.com/myfolder/pcltar-1-3.piz.php3. |
||||
The files are automatically placed in the 'lib' directory of the 'myfolder' |
||||
directory. |
||||
|
||||
3 - What's new |
||||
============== |
||||
|
||||
In version 1.3.1 : |
||||
|
||||
- Remove deprecated call to functions with references |
||||
|
||||
In version 1.3 : |
||||
|
||||
- Add the function PclTarExtractIndex() |
||||
- Correction of a bug with folders. When folder are archived, the size is sometime not |
||||
null. PclTar now force the size to be zero when the archived file is a folder. When |
||||
un-archiving the size is also forced to 0 when the item is a folder. |
||||
- Modify function PclTarDelete() : When you give the name of a directory to be deleted, the |
||||
directory entry and the files of the directory are deleted. |
||||
- Correct bug in the path add/remove options in functions. When a path is removed, |
||||
sometime the 'home' path was not. |
||||
- Correct a bug in directory extraction : The directory is created but the status in |
||||
the resulting file list is set to write_error. |
||||
- Correct a bug : missing update of file cache (clearstatcache()) |
||||
|
||||
In version 1.2 : |
||||
|
||||
- Add a new function PclTarMerge(), which allow to merge two archives. |
||||
- Add the add_path/remove_path ability to the PclTarCreate() function |
||||
- The add list/dir function now support empty directory. Before version 1.2, directories |
||||
where not identified as separate entries, there where in the archive, only if there is at |
||||
least one file. |
||||
- Optimization of PclTarHandleAddList() |
||||
|
||||
In version 1.1 : |
||||
|
||||
- Adding check of header checksum while extracting a file from the archive, |
||||
- Enhancement in POSIX header creation. In the first version PclTar use a temporary |
||||
file for checksum calculation. It is now directly computed. |
||||
- Adding field "status" in file description, remove fields "link", "magic", "version", |
||||
"uname", "gname", "devmajor" and "devminor", because they do not carry interesting info. |
||||
- While extracting, a check is done if the file exists or not. If an error occurs in the |
||||
file extraction, the file is skipped, and the function tries to extract the next one. |
||||
In previous release, the extraction was stopped. |
||||
- While extracting a file, the mtime is now updated with the value stored in the archive. |
||||
Note that the mode (R/W) is not set today (default RW). |
||||
|
||||
- New function PclTarDelete($tarname, $filelist), which deletes the files specified in |
||||
$filelist. |
||||
- New function PclTarUpdate(), which replace old files with new ones (depending of last |
||||
modification date). If the file does not exist, it is added at the end of the archive. |
||||
- Values for the file properties array : |
||||
filename (with path), |
||||
size, |
||||
mode (decimal value of the octal value), |
||||
uid, |
||||
gid, |
||||
mtime (last modification date like time() function result), |
||||
typeflag ("0" or "" = file, "5" = directory, "1" = link), |
||||
status (ok, added, updated, not_updated, already_a_directory, |
||||
write_protected, newer_exist, path_creation_fail, write_error) |
||||
- Add a "remove path" property in the extract functions. This allow to extract file |
||||
in an other directory than the expected directory. |
||||
- Add new function PclTarAddList() |
||||
- Add parameter $p_mode in PclTarList() |
||||
|
||||
4 - Using PclTar |
||||
======================== |
||||
|
||||
In order to use PclTar 1.3, an application (or a script) must include |
||||
the PclTar file pcltar.lib.php3. |
||||
Because PclTar 1.3 include two other libraries (PclTrace and PclError), a |
||||
way to include these libraries must be done. Several solutions are available : |
||||
|
||||
- Include each library in the application/script (in this order) : |
||||
<? |
||||
include ("my_lib_dir/pclerror.lib.php3"); |
||||
include ("my_lib_dir/pcltrace.lib.php3"); |
||||
include ("my_lib_dir/pcltar.lib.php3"); |
||||
[...] |
||||
?> |
||||
|
||||
- Give the library path knownledge to PclTar : |
||||
<? |
||||
$g_pcltar_lib_dir = "my_lib_dir"; |
||||
include ("my_lib_dir/pcltar.lib.php3"); |
||||
[...] |
||||
?> |
||||
|
||||
- Modify the $g_pcltar_lib_dir value in pcltar.lib.php3 |
||||
|
||||
- Use the global include directory configured in php.ini, and modify the |
||||
$g_pcltar_lib_dir value in pcltar.lib.php3 and set it to '' |
||||
|
||||
Note that PclTar file (pcltar.lib.php3) may be included several time without any |
||||
problem. However this is not recomended for performance reason. |
||||
|
||||
After the include(s), the functions defined by PclTar can be directly used |
||||
(see manual section). |
||||
|
||||
|
||||
5 - Manual |
||||
========== |
||||
|
||||
PclTar introduce functions to create, add, list, delete and extract files in a GNU |
||||
TAR archive. The GNU TAR archive can be compressed or not. |
||||
|
||||
A more complete documentation of the PclTar function is available at |
||||
http://www.phpconcept.net |
||||
|
||||
Each public function is documented in an appropriate header directly in the source |
||||
code. |
||||
|
||||
|
||||
|
||||
6 - Langage |
||||
=========== |
||||
|
||||
PclTar was developped in PHP3 but is compatible with PHP4. The files |
||||
extension can be modified without any action needed inside the files. |
||||
|
||||
PclTar code is fully documented (nearly step by step) in english. |
||||
|
||||
|
||||
7 - Known bugs |
||||
============== |
||||
|
||||
Here is a list of known bugs in PclTar 1.0 (not exhaustive list) : |
||||
|
||||
- Only GNU TAR archive with POSIX header are supported |
||||
- While extracting a file, the header checksum is not checked. |
||||
- While extracting a file, the last modified date is not checked with the one |
||||
of the file that will be replaced. |
||||
- While extracting a file, the file mode (access right by user, ...) is not |
||||
reproduced. |
||||
- While archiving a full directory, the directory it self is not archived. |
||||
- While extracting a directory name the directory is created only if there is |
||||
a file inside. Should be created even if no file is inside. |
||||
|
||||
Known bugs will be updated in http://www.phpconcept.net |
||||
|
||||
|
||||
8 - License |
||||
=========== |
||||
|
||||
PclTar 1.3 Library is released under GNU/GPL license. |
||||
This library is free, so you can use it at no cost. |
||||
|
||||
HOWEVER, if you release a script, an application, a library or any kind of |
||||
code including PclTar library (or a part of it), YOU MUST : |
||||
- Release your work under GNU/GPL license (free software), |
||||
- You must indicate in the documentation (or a readme file), that your work |
||||
include PclTar Library, and make a reference to the author and the web site |
||||
http://www.phpconcept.net |
||||
|
||||
I will also appreciate that you send me a mail (vincent@blavet.net), just to |
||||
be aware that someone is using PclTar (but this is not mandatory ;-) ). |
||||
|
||||
For more information : http://www.gnu.org |
||||
|
||||
9 - Warning |
||||
================= |
||||
|
||||
This library and the associated files are non commercial, non professional work. |
||||
It should not have unexpected results. However if any damage is caused by this software |
||||
the author can not be responsible. |
||||
The use of this software is at the risk of the user. |
||||
|
||||
10 - Author |
||||
========== |
||||
|
||||
This software was written by Vincent Blavet (vincent@blavet.net) on its leasure time. |
||||
|
||||
|
||||
|
||||
******************************************************************************** |
||||
* VERSION FRANCAISE * |
||||
******************************************************************************** |
||||
|
||||
|
||||
0 - Sommaire |
||||
============ |
||||
1 - Introduction |
||||
2 - Installation |
||||
3 - Nouveautés |
||||
4 - Démarrer avec PclTar |
||||
5 - Manuel |
||||
6 - Langage |
||||
7 - Problèmes connus |
||||
8 - License |
||||
9 - Avertissement |
||||
10 - Auteur |
||||
|
||||
|
||||
1 - Introduction |
||||
================ |
||||
|
||||
PclTar est une librairie qui vous permet de créer des archives au format GNU TAR ou GNU |
||||
TAR compressé, d'ajouter des fichiers ou des dossiers entiers et d'extraire le contenu |
||||
total ou partiel des archives. |
||||
A présent les tests ont montré que les archives créées par PclTar sont lisibles par les |
||||
outils tar et gzip, ainsi que l'application WinZip. |
||||
|
||||
PclTar est constituée des fichiers suivants, ils sont placés dans le dossier 'lib' : |
||||
- pcltar.lib.php3 |
||||
- pcltrace.lib.php3 |
||||
- pclerror.lib.php3 |
||||
|
||||
Aujourd'hui les librairies PclTrace et PclError sont obligatoires pour faire fonctionner |
||||
PclTar. |
||||
|
||||
Les extensions de fichiers (.php3) peuvent être modifiés (en .php par exemple) sans |
||||
nécessité d'intervenir à l'intérieur du fichier. |
||||
|
||||
Les fichiers peuvent être placés dans n'importe quel dossier pour peu que l'application |
||||
ou le script appelant utilise un chemin d'appel valide. |
||||
|
||||
|
||||
2 - Installation |
||||
================ |
||||
|
||||
PclTar 1.3 est distribué sous trois formats : |
||||
|
||||
- Format Zip traditionnel (pcltar-1-3.zip), |
||||
- Format GNU TAR compressé (pcltar-1-3.tgz), |
||||
- Format PhpZip auto-extract (pcltar-1-3.piz). |
||||
|
||||
Les fichiers Zip and GNU TAR compressés contiennent aussi le format PhpZip |
||||
auto-extract. |
||||
|
||||
a. Archive Zip |
||||
Décompressez l'archive Zip dans un dossier. |
||||
Les fichiers sont dans le dossier 'lib' et peuvent être déplacés ailleurs. |
||||
|
||||
b. Archive GNU TAR compressée |
||||
Décompressez l'archive GNU TAR dans un dossier. |
||||
Les fichiers sont dans le dossier 'lib' et peuvent être déplacés ailleurs. |
||||
|
||||
c. Auto-extract PhpZip archive |
||||
Téléchargez *** EN MODE BINAIRE *** l'archive PhpZip sur votre site Web dans |
||||
le dossier souhaité 'mondossier'. |
||||
Lancer l'extraction en appelant http://mondomaine.com/mondossier/pcltar-1-3.piz.php3 |
||||
Les fichiers sont dans le dossier 'lib' du dossier 'mondossier'. |
||||
|
||||
|
||||
3 - Nouveautés |
||||
============== |
||||
|
||||
En version 1.3.1 : |
||||
|
||||
- Suppression des appels de fonctions par références |
||||
|
||||
En version 1.3 : |
||||
|
||||
- Ajout de la fonction PclTarExtractIndex() |
||||
- Correction d'un bug avec l'archivage des dossiers. Parfois la taille des |
||||
dossiers archivés était non nul ce qui entrainait une erreur lors de l'extraction. |
||||
PclTar force désormais la taille à zéro lorsqu'il s'agit d'un dossier. De même lors |
||||
de l'extraction il ignore la taille éventuellement incorrecte. |
||||
- Modification de la fonction PclTarDelete() : Lorsque l'on donne le nom d'un dossier |
||||
à supprimer, le dossier et les fichiers se trouvant dedans sont supprimés. |
||||
Avant la version 1.3 seulement l'entrée concernant le dossier était supprimée. |
||||
- Correction d'un bug dans les propriétés d'ajout/suppression de chemin. Lorsque l'on |
||||
indiquait un chemin à supprimer, cela se passait bien pour les fichiers et |
||||
sous-dossiers, mais le dossier en lui-même n'était pas ignoré. |
||||
- Correction d'un bug dans l'extraction d'un dossier : Le dossier est normalement créé, |
||||
mais le status de l'opération pour ce dossier était en 'write_erreor'. |
||||
- Correction d'un bug sur la validité des dates de dernière modification des |
||||
fichiers. Utilisation plus systèmatique de clearstatcache(). |
||||
|
||||
En version 1.2 : |
||||
|
||||
- Ajout d'une nouvelle fonction PclTarMerge(), qui permet d'ajouter à une archive le |
||||
contenu d'une autre. |
||||
- Ajout des propriétés "ajout de path/suppression de path" pour la fonction PclTarCreate(). |
||||
- Les archives générées par PclTar supportent maintenant les dossiers vide. Avant la |
||||
version 1.2, un dossier n'était ajouté que lorsqu'il y avait au moins un fichier dedans. |
||||
- Optimisation du code de PclTarHandleAddList() |
||||
|
||||
En version 1.1 : |
||||
|
||||
- Ajout de la vérification du checksum lors de l'extraction d'un fichier. |
||||
- Amélioration de la création des entêtes POSIX. En version 1.0 PclTar utilisait un fichier |
||||
temporaire pour calculer le checksum. Ce n'est plus le cas à partir de la version 1.2. |
||||
- Ajout d'un champ "status" dans le tableau de description des propriétés d'un fichier. |
||||
Les champs "link", "magic", "version", "uname", "gname", "devmajor" and "devminor" sont |
||||
eux supprimés car ils ne contiennent aucune information interessante. |
||||
- Lors de l'extraction une vérification est faite pour savoir si le fichier existe déjà ou non. |
||||
Si une erreur arrive lors de l'extraction le fichier est sauté et la fonction cherche à |
||||
extraire le fichier suivant. Dans la version précédente l'extraction était arrêtée. |
||||
- Lors de l'extraction d'un fichier la date de dernière modification est mise à jour avec |
||||
celle mémorisée dans l'archive. |
||||
Notez que ce n'est pas le cas pour le mode (R/W) qui reste celui par défaut. |
||||
- Nouvelle fonction PclTarDelete($tarname, $filelist), qui supprime de l'archive les fichiers |
||||
spécifiés dans $filelist. |
||||
- Nouvelle fonction PclTarUpdate(), qui remplace les anciens fichiers par les nouveaux |
||||
(en fonction de la date de dernière modification). Si le fichier n'existe pas il est |
||||
ajouté en fin d'archive. |
||||
- Le tableau contenant les propriétés d'un fichier a les champs suivants : |
||||
filename (with path), |
||||
size, |
||||
mode (decimal value of the octal value), |
||||
uid, |
||||
gid, |
||||
mtime (last modification date like time() function result), |
||||
typeflag ("0" or "" = file, "5" = directory, "1" = link), |
||||
status (ok, added, updated, not_updated, already_a_directory, |
||||
write_protected, newer_exist, path_creation_fail, write_error) |
||||
- Ajout d'une propriété "chemin à retirer" dans les fonctions d'extraction. Cela permet |
||||
d'extraire un fichier ou un dossier dans un dossier différent de celui qui a été mémorizé. |
||||
- Ajout de la focntion PclTarAddList() |
||||
- Ajout du parametre $p_mode dans PclTarList() |
||||
|
||||
3 - Démarrer avec PclTar |
||||
======================== |
||||
|
||||
Pour utiliser PclTar, une application ou un script doivent inclure le fichier |
||||
pcltar.lib.php3. |
||||
PclTar utilisant deux librairies annexes (PclTrace et PclError), une configuration |
||||
est nécessaire pour que PclTar retrouve le chemin d'inclusion des deux librairies. |
||||
Plusieurs solutions, au choix, sont possibles : |
||||
|
||||
- Inclure chaque librarie dans l'application/script : |
||||
<? |
||||
include ("my_lib_dir/pclerror.lib.php3"); |
||||
include ("my_lib_dir/pcltrace.lib.php3"); |
||||
include ("my_lib_dir/pcltar.lib.php3"); |
||||
[...] |
||||
?> |
||||
|
||||
- Donner à PclTar la connaissance du chemin d'inclusion : |
||||
<? |
||||
$g_pcltar_lib_dir = "my_lib_dir"; |
||||
include ("my_lib_dir/pcltar.lib.php3"); |
||||
[...] |
||||
?> |
||||
|
||||
- Modifier la variable $g_pcltar_lib_dir dans pcltar.lib.php3 |
||||
|
||||
- Utiliser le chemin d'include par défaut (configuré dans php.ini), sans oublier de |
||||
modifier la variable $g_pcltar_lib_dir pour la mettre à ''. |
||||
|
||||
Il est à noter que le fichier pcltar.lib.php3 peut être inclu plusieurs fois sans |
||||
impact autre qu'une légère perte de performance. |
||||
|
||||
|
||||
4 - Manuel |
||||
========== |
||||
|
||||
PclTar définit des fonctions pour créer, ajouter, lister, détruire et extraire des |
||||
fichiers depuis une archive GNU TAR. Cette archive peut être compressée ou non. |
||||
|
||||
Une description plus complète de PclTar est disponible sur |
||||
http://www.phpconcept.net |
||||
|
||||
Chaque fonction est aussi documentée dans un entête associé, directement dans |
||||
le code source. |
||||
|
||||
|
||||
5 - Langage |
||||
=========== |
||||
|
||||
PclTar a été développé en PHP3 mais est compatible avec PHP4. Les |
||||
extensions de fichiers (.php3) peuvent être modifié sans toucher à l'intérieur |
||||
des fichiers. |
||||
|
||||
Le code de PclTar est entièrement documenté en anglais. |
||||
|
||||
|
||||
6 - Problèmes connus |
||||
==================== |
||||
|
||||
Liste des problèmes connus dans PclTar 1.0 (liste non exhaustive) : |
||||
|
||||
- Seuls les archives GNU TAR au format "header POSIX" sont supportées |
||||
- Lors de l'extraction d'un fichier le checksupm de l'entête n'est pas vérifié |
||||
- Lors de l'extraction d'un fichier la date de dernière modification d'un |
||||
fichier n'est pas comparé avec celle du fichier existant. |
||||
- Lors de l'extraction d'un fichier les droits d'accès d'un fichier ne sont pas |
||||
reconduits |
||||
- Lors de l'archivage d'un dossier entier, le nom du dossier lui même n'est pas |
||||
archivé comme une entrée indépendante |
||||
- Lors de l'extraction de l'entrée décrivant un dossier, le dossier n'est créé que si |
||||
au moins un fichier est archivé pour ce dossier. |
||||
|
||||
Les bugs connus et les contournements possibles ou les versions de correction |
||||
seront mis à jour sur le site http://www.phpconcept.net |
||||
|
||||
Merci d'y documenter les bugs que vous rencontrez afin qu'ils soient pris en compte |
||||
dans les versions futures ! |
||||
|
||||
7 - License |
||||
=========== |
||||
|
||||
La librairie PclTar 1.3 est distribuées sous license GNU/GPL. |
||||
Vous pouvez donc l'utiliser gratuitement. |
||||
|
||||
CEPENDANT, si vous publiez un script, une application, une librairie ou tout |
||||
code incluant PclTar (entier ou partiel), VOUS DEVEZ : |