[TYPO3] unziping an extension
Andreas Becker
ab.becker at web.de
Sun Jul 15 09:55:02 CEST 2007
Hi again
Have found another hint on the frenh list:
-----------------
Un t3x, ça n'est rien d'aure qu'un tableau sérialisé et compressé
Structure d'un t3x :
<md5>:<compression>:<contenu>
<md5> est le md5 du contenu (non compressé) et permet de s'assurer qu'il n'y
a aucune erreur de transfert
Si <compression> = gzcompress, alors il faut décompresser <contenu> avec
gzuncompress
<contenu> est un simple array sérialisé qui contient les fichiers de
l'extension
------------------
http://forum.typo3.fr/index.php?showtopic=8413
-------------------
Perhaps you cn use also this script here - try it:
------------------
1. <?php
2. header <http://www.php.net/header>("Content-type: text/plain");
3. require("class.em_terconnection.php");
4.
5. // Settings.
6. $extFile = "file.t3x";
7. $unpackDir = "extension";
8.
9. // Start unpacking.
10. $fileContent = file_get_contents<http://www.php.net/file_get_contents>
($extFile);
11. $ext = SC_mod_tools_em_terconnection::decodeExchangeData(
$fileContent);
12.
13. function autocreate_subdirs($dir) {
14. $path = array <http://www.php.net/array>();
15. $subdirs = explode <http://www.php.net/explode>("/", $dir)
;
16. foreach ($subdirs as $subdir) {
17. $path[] = $subdir;
18. $fullPath = implode <http://www.php.net/implode>(
"/", $path);
19. if (!file_exists <http://www.php.net/file_exists>(
$fullPath)) {
20. if (mkdir <http://www.php.net/mkdir>(
$fullPath)) {
21. echo <http://www.php.net/echo>
sprintf <http://www.php.net/sprintf>("OK: created directory '%s'\n",
$fullPath);
22. } else {
23. echo <http://www.php.net/echo>
sprintf <http://www.php.net/sprintf>("ERROR: directory '%s' not
created\n", $fullPath);
24. }
25. }
26. }
27. }
28.
29. // Unpack extension(s).
30. foreach ($ext as $e) {
31. if ($e["EM_CONF"]) {
32. // Create unpack directory.
33. if (!file_exists <http://www.php.net/file_exists>(
$unpackDir)) {
34. mkdir <http://www.php.net/mkdir>(
$unpackDir);
35. }
36. // Create directories.
37. $dirs = explode <http://www.php.net/explode>(",",
$e["EM_CONF"]["createDirs"]);
38. foreach ($dirs as $dir) {
39. // Start in unpack directory if any.
40. if ($unpackDir) {
41. $dir = $unpackDir."/".$dir;
42. }
43. autocreate_subdirs($dir);
44. }
45. // Write files.
46. foreach ($e["FILES"] as $file) {
47. // Start in unpack directory.
48. if (empty <http://www.php.net/empty>(
$unpackDir)) {
49. $path = array<http://www.php.net/array>
();
50. } else {
51. $path = array<http://www.php.net/array>
($unpackDir);
52. }
53. $tmp = explode<http://www.php.net/explode>
("/", $file["name"]);
54. // Separate file name and rest path.
55. $fileName =
array_pop<http://www.php.net/array_pop>
($tmp);
56. $path =
array_merge<http://www.php.net/array_merge>
($path, $tmp);
57. unset <http://www.php.net/unset>($tmp);
58. // Create subdirs if neccessary.
59. $dirPath = implode<http://www.php.net/implode>
("/", $path);
60. autocreate_subdirs($dirPath);
61. // Write file.
62. $path[] = $fileName;
63. $fullPath = implode<http://www.php.net/implode>
("/", $path);
64. $handle = fopen <http://www.php.net/fopen>
($fullPath, "wb");
65. if ($handle && fwrite<http://www.php.net/fwrite>
($handle, $file["content"])) {
66. fclose <http://www.php.net/fclose>
($handle);
67. echo <http://www.php.net/echo>
sprintf <http://www.php.net/sprintf>("OK: wrote file '%s'\n",
$fullPath);
68. } else {
69. echo <http://www.php.net/echo>
sprintf <http://www.php.net/sprintf>("ERROR: file '%s' not written\n",
$fullPath);
70. }
71. }
72. }
73. }
74. ?>
75.
------------------------------------------
By the way I do it with a local installation - is fast easy and you can test
immedeately inside TYPo3.
I am using WOS-Portable - Fast to install complette server/TYPO3 solution
which you can even copy on a USB stick and it is still working:
http://www.chsoftware.net
Andi
2007/7/15, Andreas Becker <ab.becker at web.de>:
>
> Hi Nagita
>
> The packing is more a serialization with optinonal compression. Have a
> look at the BE Code. Here you can see how it works.
>
> Partly it's gzipped:
>
> Have a look here how t3x files are created: (class.tx_extrep.php line 893)
>
>
> ----------------------------------
>
> function compileOutputData($outArr) {
>
> $outDat = serialize($outArr);
>
> if ($this->piData["gzcompress"]) $outDat = gzcompress($outDat);
>
> return
> md5($outDat).":".($this->piData["gzcompress"]?"gzcompress":"").":".base64_encode($outDat).":";
>
>
> }
> --------------------------------------
>
> Perhaps this helps you to get the data aout again:
>
> --------------------------------
>
> function decodeExchangeData($str) {
>
> $parts = explode(":",$str,3);
>
> if ($parts[1]=="gzcompress") {
>
> $parts[2] = gzuncompress($parts[2]);
>
> }
>
> if (md5($parts[2]) == $parts[0]) {
>
> return unserialize($parts[2]);
>
> }
>
> }
> ------------------------------
> Have a look also here:
> http://www.php.net/manual/de/function.gzcompress.php
>
> And how it is donte at the .t3d extenion impexp
> ------------------------------
>
> Chokdee
> Andi
>
> 2007/7/15, Nagita Karunaratne <Nagita.k at gmail.com>:
> >
> > Hi,
> >
> > How are extension t3x files created. I would like to modify an extsting
> > extension so I would like to 'unzip' it, modify the files and recreate
> > the t3x file.
> >
> > Thanks,
> > Nagita
> > _______________________________________________
> > TYPO3-english mailing list
> > TYPO3-english at lists.netfielders.de
> > http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
> >
>
>
More information about the TYPO3-english
mailing list