---
title: ".t3x entpacken"
url: "https://www.typo3.net/d/61537-t3x-entpacken"
source: "typo3.net"
tags: ["Extensions","Entwicklung","Frage","PHP"]
created: "2007-04-25"
last_reply: "2015-01-21"
replies: 28
solved: false
page: 1
pages: 1
lang: "de"
---

# .t3x entpacken

Extensions › Entwicklung · 28 Antworten · gestartet 2007-04-25

## Eröffnungsbeitrag

**droptix** · 2007-04-25 · [Beitrag #1](https://www.typo3.net/d/61537-t3x-entpacken/1)

Ich müsste manchmal schnell eine .t3x Datei lokal entpacken, um die PHP-Dateien einzusehen und Feedback zu geben.

Daher suche ich nach einem Entpacker, am sinnvollsten wohl als PHP-Skript. Oder nach Infos zum Schreiben eines solchen Entpackers.

## Antworten

### [#2](https://www.typo3.net/d/61537-t3x-entpacken/2) · woida · 2007-04-25

Die dafür zuständige Methode "decodeExchangeData" findest du in der typo3/mod/tools/em/class.em_terconnection.php

### [#3](https://www.typo3.net/d/61537-t3x-entpacken/3) · droptix · 2007-04-25

Habe Probleme damit. Ich lese die .t3x Datei ein:

```php
function read_t3x() {
	// read file
	$handle = fopen($this->t3xFile, "r");
	$string = "";
	while (!feof($handle)) {
		$string .= fgets($handle, $this->buffer); 
	}
	fclose($handle);
	return $string;
}
```

Anschließend jage ich sie durch die Originalfunktion:

```php
require("class.em_terconnection.php");
$tmp = SC_mod_tools_em_terconnection::decodeServerData($this->t3xString);
print_r($tmp);
```

Liefert:

> Error: MD5 hashes in T3X data did not match!

Habe auch schon versucht, die .t3x binär einzulesen, aber das brachte dasselbe Ergebnis.

Die .t3x Datei besteht aus "zusammengeklebten" Teilen, die durch Doppelpunkte getrennt werden. Die Funktion `decodeServerData()` zerhackt den Inhalt. So sieht eine .t3x Datei aus:

```html
8a584ad8b44bfa81c9d1c73469229c1d:gzcompress:Base64-codierte Infos:Daten
```

Als Array könnte man das so abbilden:

```php
$array = (
	"MD5-Hash",
	"Kompressionsmethode",
	"Base64-codierte Infos",
	"Daten"
)
```

Die Funktion `decodeServerData()` macht folgendes:

- 1) dekodiere Base64-Infos aus $array[2]
  2) bilde MD5-Hash über dekodierte Base64-Infos
  3) Verlgeiche MD5-Hash in $array[0] mit dem gerade gebildeten MD5-Hash
  4) Stimmen sie nicht überein, meckere, ansonsten weiter
  5) Ist die Kompressionsmethode "gzcompress", so dekomprimiere die dekodierten Base64-Infos. Meckere bei einem Fehler, ansonsten weiter.
  6) Zerpflücke das Ergebnis mit `unserialize`, dabei sollte ein Array rauskommen

Der Fehler tritt bei jeder .t3x Datei auf. Jede davon lässt sich aber in TYPO3 importieren und installieren. Es muss daran liegen, wie die Datei eingelesen wird. **Hat jemand dazu einen Tipp?**

### [#4](https://www.typo3.net/d/61537-t3x-entpacken/4) · luwo · 2007-06-03

Hallo droptix,

probiers doch mal so:

```php
require("class.em_terconnection.php");

$file=file_get_contents('dateiname.t3x');
$tmp = SC_mod_tools_em_terconnection::decodeExchangeData($file);
print_r($tmp);
```

Grüße Luwo

### [#5](https://www.typo3.net/d/61537-t3x-entpacken/5) · droptix · 2007-06-04

Vielen vielen Dank!!! Hätte nicht gedacht, dass ich das Thema nochmal aufrolle, aber dank dir kommt hier gleich eine Komplettlösung für alle, die das auch brauchen:

```php
<?php
header("Content-type: text/plain");
require("class.em_terconnection.php");

// Settings.
$extFile = "file.t3x";
$unpackDir = "extension";

// Start unpacking.
$fileContent = file_get_contents($extFile);
$ext = SC_mod_tools_em_terconnection::decodeExchangeData($fileContent);

function autocreate_subdirs($dir) {
	$path = array();
	$subdirs = explode("/", $dir);
	foreach ($subdirs as $subdir) {
		$path[] = $subdir;
		$fullPath = implode("/", $path);
		if (!file_exists($fullPath)) {
			if (mkdir($fullPath)) {
				echo sprintf("OK: created directory '%s'\n", $fullPath);
			} else {
				echo sprintf("ERROR: directory '%s' not created\n", $fullPath);
			}
		}
	}
}

// Unpack extension(s).
foreach ($ext as $e) {
	if ($e["EM_CONF"]) {
		// Create unpack directory.
		if (!file_exists($unpackDir)) {
			mkdir($unpackDir);
		}
		// Create directories.
		$dirs = explode(",", $e["EM_CONF"]["createDirs"]);
		foreach ($dirs as $dir) {
			// Start in unpack directory if any.
			if ($unpackDir) {
				$dir = $unpackDir."/".$dir;
			}
			autocreate_subdirs($dir);
		}
		// Write files.
		foreach ($e["FILES"] as $file) {
			// Start in unpack directory.
			if (empty($unpackDir)) {
				$path = array();
			} else {
				$path = array($unpackDir);
			}
			$tmp = explode("/", $file["name"]);
			// Separate file name and rest path.
			$fileName = array_pop($tmp);
			$path = array_merge($path, $tmp);
			unset($tmp);
			// Create subdirs if neccessary.
			$dirPath = implode("/", $path);
			autocreate_subdirs($dirPath);
			// Write file.
			$path[] = $fileName;
			$fullPath = implode("/", $path);
			$handle = fopen($fullPath, "wb");
			if ($handle && fwrite($handle, $file["content"])) {
				fclose($handle);
				echo sprintf("OK: wrote file '%s'\n", $fullPath);
			} else {
				echo sprintf("ERROR: file '%s' not written\n", $fullPath);
			}
		}
	}
}
?>
```

### [#6](https://www.typo3.net/d/61537-t3x-entpacken/6) · luwo · 2007-06-04

Hallo Droptix,

Ehrlich, ein richtig cooles Script!!! :D
Genau soetwas brauche ich nämlich gerade :D

Habe es noch etwas erweitert, damit es direkt von der Kommandozeile aus mit entsprechenden Parametern aufgerufen werden kann.
Sollte so unter Windows und Linux laufen, vielleicht können ja mal ein paar Leute testen und Ihre Ergebnisse posten...

```php
<?php
require("class.em_terconnection.php");

// default-Settings.
$unpackDir = "extension";


// Usage ausgeben
function printUsageAndDie(){
global $argv;
print <<<EOM
------------------------------------------------------------------------------
  _____                            _   _   _____
 | ____|_  ___ __   __ _ _ __   __| | | |_|___ /_  __
 |  _| \ \/ / '_ \ / _` | '_ \ / _` | | __| |_ \ \/ /
 | |___ >  <| |_) | (_| | | | | (_| | | |_ ___) >  <
 |_____/_/\_\ .__/ \__,_|_| |_|\__,_|  \__|____/_/\_\  Version 0.1, 04.06.2007
           |_|

 ...written by droptix and luwo. (look at http://www.typo3.net/forum)

 Usage: expand_t3x.php [filename.t3x]  <directory> 

 * filename.t3x = Name of your t3x-file
 * directory    = optional directory of extraction (default="extension")   

------------------------------------------------------------------------------
 
EOM;
die();
}


// Wurde eine Datei angegeben?
if (count($argv) <=1) { printUsageAndDie(); }

// Wurde ein Auspackverzeichnis angegeben?
if ($argv[2] != '') $unpackDir=$argv[2];

// Datei aus Kommandozeile holen...
$extFile=$argv[1];
if (file_exists($extFile)) { print "\n Entpacke Datei: '$extFile'...\n\n";}
                       else{ print "\n Datei: '$extFile' wurde leider nicht gefunden \n"; printUsageAndDie();}



// Start unpacking.
$fileContent = file_get_contents($extFile);
$ext = SC_mod_tools_em_terconnection::decodeExchangeData($fileContent);


function autocreate_subdirs($dir) {
        $path = array();
        $subdirs = explode("/", $dir);
        foreach ($subdirs as $subdir) {
                $path[] = $subdir;
                $fullPath = implode("/", $path);
                if (!file_exists($fullPath)) {
                        if (mkdir($fullPath)) {
                                echo sprintf("OK: created directory '%s'\n", $fullPath);
                        } else {
                                echo sprintf("ERROR: directory '%s' not created\n", $fullPath);
                        }
                }
        }
}

// Unpack extension(s).
foreach ($ext as $e) {
        if ($e["EM_CONF"]) {
                // Create unpack directory.
                if (!file_exists($unpackDir)) {
                        mkdir($unpackDir);
                }
                // Create directories.
                $dirs = explode(",", $e["EM_CONF"]["createDirs"]);
                foreach ($dirs as $dir) {
                        // Start in unpack directory if any.
                        if ($unpackDir) {
                                $dir = $unpackDir."/".$dir;
                        }
                        autocreate_subdirs($dir);
                }
                // Write files.
                foreach ($e["FILES"] as $file) {
                        // Start in unpack directory.
                        if (empty($unpackDir)) {
                                $path = array();
                        } else {
                                $path = array($unpackDir);
                        }
                        $tmp = explode("/", $file["name"]);
                        // Separate file name and rest path.
                        $fileName = array_pop($tmp);
                        $path = array_merge($path, $tmp);
                        unset($tmp);
                        // Create subdirs if neccessary.
                        $dirPath = implode("/", $path);
                        autocreate_subdirs($dirPath);
                        // Write file.
                        $path[] = $fileName;
                        $fullPath = implode("/", $path);
                        $handle = fopen($fullPath, "wb");
                        if ($handle && fwrite($handle, $file["content"])) {
                                fclose($handle);
                                echo sprintf("OK: wrote file '%s'\n", $fullPath);
                        } else {
                                echo sprintf("ERROR: file '%s' not written\n", $fullPath);
                        }
                }
        }
}
?>
```

Viele Grüße Luwo

### [#7](https://www.typo3.net/d/61537-t3x-entpacken/7) · droptix · 2007-06-05

So, hier nun eine .exe Datei zum Auspacken einer .t3x Datei (Code leicht verbessert für meinen Geschmack):

[expandt3x.exe (~  1,33 MB)](http://droptix.ohost.de/boards/typo3-expandt3x/expandt3x.exe)
[expandt3x.exe  gezippt (~  598 KB)](http://droptix.ohost.de/boards/typo3-expandt3x/expandt3x.exe.zip)

- • entweder auf der Konsole starten und die Anleitung lesen
  • oder: expandt3x.exe file.t3x [outputdir]
  • oder deine .t3x Datei auf expandt3x.exe ziehen, allerdings landet das entpackte Verzeichnis in C:\Dokumente und Einstellungen\Benutzername, weil Windows das mit  dem *current working directory* verkackt...

Viel Spaß damit und Danke an alle, die mitgeholfen haben!

P.S. Erstellt mit dem [Bambalam PHP EXE Compiler/Embedder](http://www.bambalam.se/bamcompile/)

### [#8](https://www.typo3.net/d/61537-t3x-entpacken/8) · karlchen · 2007-06-07

Genial, kann ich da nur sagen :)

Habe sowas auch schon mal vor einer Weile gesucht doch nichts gefunden.

Vielen dank, für dieses schöne Werk, läuft bei mir eins A.

Karlchen

### [#9](https://www.typo3.net/d/61537-t3x-entpacken/9) · droptix · 2007-06-07

Tja, so bin ich eben  8-)  … und nicht zu vergessen auch luwo.

Denkt an mich, wenn ich mal ein Problem habe.

P.S. Wenn jemand Lust und Zeit hat ein PHP-Script für den umgekehrten Weg zu machen, wäre das sehr cool   :D  Das wär noch was, was ich mit meinem Extension-Halbwissen nicht zusammen kriege, mir aber sehr wünschen würde.

### [#10](https://www.typo3.net/d/61537-t3x-entpacken/10) · a.​otto · 2007-06-11

Schau mal im SVN Repository von TYPO3xdev [1] nach.

[1]<http://typo3xdev.svn.sourceforge.net/viewvc/typo3xdev/tools_t3x/trunk/>

### [#11](https://www.typo3.net/d/61537-t3x-entpacken/11) · steffenk · 2007-06-11

Hi Andreas, willkommen im Forum :)

dort hast Du einen Packer, aber keinen Entpacker, oder seh ich das falsch ?

### [#12](https://www.typo3.net/d/61537-t3x-entpacken/12) · dyne · 2007-12-19

Ich hole mal das Thema wieder hoch, da ich auf der Suche nach einem t3x-Packer bin. Ich habe so eine Art kleinen Ext-Kickstarter für meine Zwecke geschrieben, aber ich kann leider keine t3x erstellen. Gibt es kein PHP-Code-Snippet dafür? Typo3 kann das doch auch.
Irgendwie komm ich mit dem SourceForge-Link nicht klar. Egal welche File ich öffne, ich komme immer auf die gleiche Seite mit einem mir unverständlichen Formular.

### [#13](https://www.typo3.net/d/61537-t3x-entpacken/13) · just2b · 2007-12-19

> **dyne schrieb:**
>
> Gibt es kein PHP-Code-Snippet dafür? Typo3 kann das doch auch.

steht doch auf der ersten Seite...

### [#14](https://www.typo3.net/d/61537-t3x-entpacken/14) · dyne · 2007-12-19

Steh ich grade auf der Leitung?

> **droptix schrieb:**
>
> [...]
> P.S. Wenn jemand Lust und Zeit hat ein PHP-Script für den umgekehrten Weg zu machen, wäre das sehr cool   :D  Das wär noch was, was ich mit meinem Extension-Halbwissen nicht zusammen kriege, mir aber sehr wünschen würde.

> **a.otto schrieb:**
>
> Schau mal im SVN Repository von TYPO3xdev [1] nach.
>
> [1]<http://typo3xdev.svn.sourceforge.net/viewvc/typo3xdev/tools_t3x/trunk/>

Mehr finde ich nicht über einen Packer und wie gesagt habe ich ein Problem mit dem Link.

### [#15](https://www.typo3.net/d/61537-t3x-entpacken/15) · Stoneage · 2007-12-19

view klicken!?

### [#16](https://www.typo3.net/d/61537-t3x-entpacken/16) · dyne · 2007-12-19

> **Tetramatrix schrieb:**
>
> view klicken!?

[Bild: superweddings.com/lightbulb.gif](http://www.superweddings.com/lightbulb.gif) danke *AnDieStirnKlatsch*

### [#17](https://www.typo3.net/d/61537-t3x-entpacken/17) · InforMedic · 2008-01-18

Geiles und geniales Toolchen =)

Vor allem wenn mal wieder "File was to large for upload" bla oder so ähnlich kommt :p

### [#18](https://www.typo3.net/d/61537-t3x-entpacken/18) · -Z- · 2008-01-30

> Ich hole mal das Thema wieder hoch, da ich auf der Suche nach einem t3x-Packer bin. Ich habe so eine Art kleinen Ext-Kickstarter für meine Zwecke geschrieben, aber ich kann leider keine t3x erstellen.

Man kann im Ext Manager jede Ext als .t3x exportieren.

BTW gibt es eine Möglichkeit mit dem Entpacker an die Inhalte der "ext_emconf.php" heranzukommen?

### [#19](https://www.typo3.net/d/61537-t3x-entpacken/19) · PeterAllfonds · 2008-04-08

Ich bekomme nur die folgende Meldung

> Expand file: 'T3D__07-04-11-30-58-z.t3d'...
>
> Warning: Invalid argument supplied for foreach() in expandt3x.php on line 65

und es wird nichts extrahiert. Es handelt sich um einen einfachen export einer TYPO3 Site, den ich fehlerfrei importieren kann.

Oder soll das Tool nur für Extensions funktionieren?

### [#20](https://www.typo3.net/d/61537-t3x-entpacken/20) · saschae · 2008-05-07

> **PeterAllfonds schrieb:**
>
> Ich bekomme nur die folgende Meldung
>
> > Expand file: 'T3D__07-04-11-30-58-z.t3d'...
> >
> > Warning: Invalid argument supplied for foreach() in expandt3x.php on line 65
>
> und es wird nichts extrahiert. Es handelt sich um einen einfachen export einer TYPO3 Site, den ich fehlerfrei importieren kann.
>
> Oder soll das Tool nur für Extensions funktionieren?

es ist ein *.t3x entpacker und kein *.t3d entpacker ;-)
also nur für extensions.
Eine t3d müsste ja größtenteils aus datenbankdumps bestehen

### [#21](https://www.typo3.net/d/61537-t3x-entpacken/21) · Pfiffikus · 2008-05-21

So, nun habe ich die Erweiterung tt_news ausgepackt und per FTP hochgeladen. Das ganze Zeug liegt jetzt im Verzeichnis
cms/typo3conf/ext/tt_news

(Hintergrund: Mein Webspace ist langsaaam. Beim Retrieve/Update kommt ein Timeout-Fehler. So erfährt mein Typo3 nicht, dass es eine solche Extension "tt_news" gibt. Das Standard-Precedere geht also nicht.)

Schaue ich mir jetzt die "Loaded Extensions" an, ist diese Erweiterung nicht enthalten, obwohl ich sie manuell hochgeladen habe.

Wie kann ich nun meinem System die bereits hochgeladene Extension zeigen, damit ich sie installieren kann?

Pfiffikus,
der gerne die neuesten Neuigkeiten präsentieren möchte

### [#22](https://www.typo3.net/d/61537-t3x-entpacken/22) · SLAng · 2008-05-22

Du wählst statt "Loaded Extensions" eben Install Extensions und drückst auf das + vor tt_news...
Aber warum so kompliziert? Nur weil du die Liste im EM nicht geladen bekommst, kannst du doch dennoch unter Import Extensions die .t3x Importieren...

### [#23](https://www.typo3.net/d/61537-t3x-entpacken/23) · Pfiffikus · 2008-06-02

Diese Option würde ich gerne wählen. Hab ich auch schon probiert. Aber nach einer längeren Wartezeit erscheint die Meldung:

> **Internal Server Error**
> The server encountered an internal error or misconfiguration and was unable to complete your request.

Pfiffikus,
der auch an dieser Stelle einen Timeout vermutet

### [#24](https://www.typo3.net/d/61537-t3x-entpacken/24) · Tolstoey · 2008-07-29

Ich hatte dasselbe Problem, mit derselben Extension.
Es scheint so zu sein, dass zwa Typo3 4.17 stabil zum laufen zu bekommen ist auf 1&1 Business jedenfalls, probleme bekomme ich immer wieder nur beim ExtManager: händisch t3x-files hochladen geht ja meistens, es sei denn, die Dateien sind so um die 1.0 MB groß. Da scheint ein Timeout daz entpacken etc zu verhindern.

Nun ist es so, dass z.B. in der tt_news (v2.5.2) die Dokumentation den größten Teil der Datei einnimmt. Wenn man sich diese auf typo3.org separat runterlädt, kann man auf diesen Teil im t3x-file gut verzichten und hat somit nur noch ca 300KB übrig. Damit funktioniert dann auch die Installation bei 1&1 problemfrei.

Um das zu bewerkstelligen hatte ich diesen Thread bzgl. Packen und Entpacken gefunden, was allerdings alles etwas umständlich für mich schien. Ganz schnelle und dreckige Lösung also:

auf nem anderen Typo3 System (zum Glück habe ich auch einige bei besseren Provider am Start...) oder eben dem lokalen System die OriginalVariante installiert, per ftp oder so, die zu große Dokumentation gelöscht,
im ExtManager die Extension wieder exportiert.

Damit habe ich nun eine Light-Version 2.5.2 von tt_news, an der GARNICHTS verändert ist, ausser, dass die Doku fehlt...

Wer's brauchen kann: <http://www.proszenium.com/fileadmin/tt_news-2_3_2_LIGHT.t3x>

### [#25](https://www.typo3.net/d/61537-t3x-entpacken/25) · Unbekannter Benutzer · 2011-04-11

Funktioniert jetzt mit Typo3 4.5
neu: extension als standard-ordnername

```php
<?php
require('/path/to/typo3/sysext/em/classes/connection/class.tx_em_connection_ter.php');


// Usage ausgeben
function printUsageAndDie(){
global $argv;
print <<<EOM
------------------------------------------------------------------------------
  _____                            _   _   _____
 | ____|_  ___ __   __ _ _ __   __| | | |_|___ /_  __
 |  _| \ \/ / '_ \ / _` | '_ \ / _` | | __| |_ \ \/ /
 | |___ >  <| |_) | (_| | | | | (_| | | |_ ___) >  <
 |_____/_/\_\ .__/ \__,_|_| |_|\__,_|  \__|____/_/\_\  Version 0.2, 11.04.2011
           |_|

 ...written by droptix and luwo. (look at http://www.typo3.net/forum)
 ...and Jonny007-MKD

 Usage: expand_t3x.php [filename.t3x]  <directory>

 * filename.t3x = Name of your t3x-file
 * directory    = optional directory of extraction (default=name of extension)

------------------------------------------------------------------------------

EOM;
die();
}


// Wurde eine Datei angegeben?
if (count($argv) <=1) { printUsageAndDie(); }

// Wurde ein Auspackverzeichnis angegeben?
if ($argv[2] != '') $unpackDir=$argv[2];
else $unpackDir=substr($argv[1], 0, -4);

// Datei aus Kommandozeile holen...
$extFile=$argv[1];
if (file_exists($extFile)) { print "\n Entpacke Datei: '$extFile'...\n\n";}
                       else{ print "\n Datei: '$extFile' wurde leider nicht gefunden \n"; printUsageAndDie();}



// Start unpacking.
$fileContent = file_get_contents($extFile);
$ext = tx_em_Connection_Ter::decodeExchangeData($fileContent);


function autocreate_subdirs($dir) {
        $path = array();
        $subdirs = explode("/", $dir);
        foreach ($subdirs as $subdir) {
                $path[] = $subdir;
                $fullPath = implode("/", $path);
                if (!file_exists($fullPath)) {
                        if (mkdir($fullPath)) {
                                echo sprintf("OK: created directory '%s'\n", $fullPath);
                        } else {
                                echo sprintf("ERROR: directory '%s' not created\n", $fullPath);
                        }
                }
        }
}

// Unpack extension(s).
foreach ($ext as $e) {
        if ($e["EM_CONF"]) {
                // Create unpack directory.
                if (!file_exists($unpackDir)) {
                        mkdir($unpackDir);
                }
                // Create directories.
                $dirs = explode(",", $e["EM_CONF"]["createDirs"]);
                foreach ($dirs as $dir) {
                        // Start in unpack directory if any.
                        if ($unpackDir) {
                                $dir = $unpackDir."/".$dir;
                        }
                        autocreate_subdirs($dir);
                }
                // Write files.
                foreach ($e["FILES"] as $file) {
                        // Start in unpack directory.
                        if (empty($unpackDir)) {
                                $path = array();
                        } else {
                                $path = array($unpackDir);
                        }
                        $tmp = explode("/", $file["name"]);
                        // Separate file name and rest path.
                        $fileName = array_pop($tmp);
                        $path = array_merge($path, $tmp);
                        unset($tmp);
                        // Create subdirs if neccessary.
                        $dirPath = implode("/", $path);
                        autocreate_subdirs($dirPath);
                        // Write file.
                        $path[] = $fileName;
                        $fullPath = implode("/", $path);
                        $handle = fopen($fullPath, "wb");
                        if ($handle && fwrite($handle, $file["content"])) {
                                fclose($handle);
                                echo sprintf("OK: wrote file '%s'\n", $fullPath);
                        } else {
                                echo sprintf("ERROR: file '%s' not written\n", $fullPath);
                        }
                }
        }
}
?>
```

### [#26](https://www.typo3.net/d/61537-t3x-entpacken/26) · mothersh1p · 2011-11-30

> **Jonny007MKD schrieb:**
>
> Funktioniert jetzt mit Typo3 4.5
> neu: extension als standard-ordnername
>
> ```php
> <?php
> require('/path/to/typo3/sysext/em/classes/connection/class.tx_em_connection_ter.php');
>
>
> // Usage ausgeben
> function printUsageAndDie(){
> global $argv;
> print <<<EOM
> ------------------------------------------------------------------------------
>   _____                            _   _   _____
>  | ____|_  ___ __   __ _ _ __   __| | | |_|___ /_  __
>  |  _| \ \/ / '_ \ / _` | '_ \ / _` | | __| |_ \ \/ /
>  | |___ >  <| |_) | (_| | | | | (_| | | |_ ___) >  <
>  |_____/_/\_\ .__/ \__,_|_| |_|\__,_|  \__|____/_/\_\  Version 0.2, 11.04.2011
>            |_|
>
>  ...written by droptix and luwo. (look at http://www.typo3.net/forum)
>  ...and Jonny007-MKD
>
>  Usage: expand_t3x.php [filename.t3x]  <directory>
>
>  * filename.t3x = Name of your t3x-file
>  * directory    = optional directory of extraction (default=name of extension)
>
> ------------------------------------------------------------------------------
>
> EOM;
> die();
> }
>
>
> // Wurde eine Datei angegeben?
> if (count($argv) <=1) { printUsageAndDie(); }
>
> // Wurde ein Auspackverzeichnis angegeben?
> if ($argv[2] != '') $unpackDir=$argv[2];
> else $unpackDir=substr($argv[1], 0, -4);
>
> // Datei aus Kommandozeile holen...
> $extFile=$argv[1];
> if (file_exists($extFile)) { print "\n Entpacke Datei: '$extFile'...\n\n";}
>                        else{ print "\n Datei: '$extFile' wurde leider nicht gefunden \n"; printUsageAndDie();}
>
>
>
> // Start unpacking.
> $fileContent = file_get_contents($extFile);
> $ext = tx_em_Connection_Ter::decodeExchangeData($fileContent);
>
>
> function autocreate_subdirs($dir) {
>         $path = array();
>         $subdirs = explode("/", $dir);
>         foreach ($subdirs as $subdir) {
>                 $path[] = $subdir;
>                 $fullPath = implode("/", $path);
>                 if (!file_exists($fullPath)) {
>                         if (mkdir($fullPath)) {
>                                 echo sprintf("OK: created directory '%s'\n", $fullPath);
>                         } else {
>                                 echo sprintf("ERROR: directory '%s' not created\n", $fullPath);
>                         }
>                 }
>         }
> }
>
> // Unpack extension(s).
> foreach ($ext as $e) {
>         if ($e["EM_CONF"]) {
>                 // Create unpack directory.
>                 if (!file_exists($unpackDir)) {
>                         mkdir($unpackDir);
>                 }
>                 // Create directories.
>                 $dirs = explode(",", $e["EM_CONF"]["createDirs"]);
>                 foreach ($dirs as $dir) {
>                         // Start in unpack directory if any.
>                         if ($unpackDir) {
>                                 $dir = $unpackDir."/".$dir;
>                         }
>                         autocreate_subdirs($dir);
>                 }
>                 // Write files.
>                 foreach ($e["FILES"] as $file) {
>                         // Start in unpack directory.
>                         if (empty($unpackDir)) {
>                                 $path = array();
>                         } else {
>                                 $path = array($unpackDir);
>                         }
>                         $tmp = explode("/", $file["name"]);
>                         // Separate file name and rest path.
>                         $fileName = array_pop($tmp);
>                         $path = array_merge($path, $tmp);
>                         unset($tmp);
>                         // Create subdirs if neccessary.
>                         $dirPath = implode("/", $path);
>                         autocreate_subdirs($dirPath);
>                         // Write file.
>                         $path[] = $fileName;
>                         $fullPath = implode("/", $path);
>                         $handle = fopen($fullPath, "wb");
>                         if ($handle && fwrite($handle, $file["content"])) {
>                                 fclose($handle);
>                                 echo sprintf("OK: wrote file '%s'\n", $fullPath);
>                         } else {
>                                 echo sprintf("ERROR: file '%s' not written\n", $fullPath);
>                         }
>                 }
>         }
> }
> ?>
> ```

Nach dem entpacken bekomme ich leider eine Fehlermeldung:

```php
Notice: Uninitialized string offset:  0 in /home/srv/www/htdocs/expandt3x/expandt3x.php on line 69

Call Stack:
    0.0011      76812   1. {main}() /home/srv/www/htdocs/expandt3x/expandt3x.php:0


Variables in local scope (#1):
  $argv = array (0 => 'expandt3x.php', 1 => 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804.t3x')
  $dir = 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804/uploads/tx_charbeitsbeispiele/'
  $dirPath = 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804/res'
  $dirs = array (0 => 'uploads/tx_charbeitsbeispiele/')
  $e = ''
  $ext = array (0 => array ('extKey' => 'ch_arbeitsbeispiele', 'EM_CONF' => array (...), 'misc' => array (...), 'techInfo' => array (...), 'FILES' => array (...)), 1 => '')
  $extFile = 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804.t3x'
  $file = array ('name' => 'res/system.css', 'size' => 7227, 'mtime' => 1318886996, 'is_executable' => FALSE, 'content' => '/****************************************************/\r/* Transitions\t          \t\t\t    */\r/****************************************************/\r/* ab hier bitte nicht ändern */\r\r#tx-charbeitsbeispiele-pi1 .masonry,\r#tx-charbeitsbeispiele-pi1 .masonry .masonry-brick\r{\r  -webkit-transition-duration: 0.7s;\r     -moz-transition-duration: 0.7s;\r       -o-transition-duration: 0.7s;\r          transition-duration: 0.7s;\r}\r\r#tx-charbeitsbeispiele-pi1 .masonry\r{\r  -webkit-transition-property: he...', 'content_md5' => '7967aac9b453d51b96e3fbdc5563cebb')
  $fileContent = '22b2bef99eff8d3b56020e34a0b4e7b1:gzcompress:x???Kl,I? ?V\002??\fF:\t?\016??8\025?W????L~???d=v??\\2Y?%>NNd?\'3??\031?\021???s\020\006{?$@?\000\001\v,tZ`??.{?\026ZhF\003\b?A\v\035??\000A??\037\020t\032???GxDF~??W????j??pwsss3ssssw??V?\020???\006\037~???^?\033v?e?m??\001?\t?.?qL?\033?7???Cc?W*Xv?n?n(?\024-????\003?w???\r??:?k?\017?*k?\017? ????\016,?\by?7\032?w???w??\a??\001???@\017?\v\b?\006?Z!??|j\002?g?\033?\003?b?®??\v ??u?k?\032?\020Z\025???}???7(?\016:??????\005??P?\033A?????*??!\0378...'
  $fileName = 'system.css'
  $fullPath = 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804/res/system.css'
  $handle = resource(63) of type (Unknown)
  $path = array (0 => 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804', 1 => 'res', 2 => 'system.css')
  $tmp = *uninitialized*
  $unpackDir = 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804'
```

### [#27](https://www.typo3.net/d/61537-t3x-entpacken/27) · nevsred · 2014-01-07

Ohne externe Abhängigkeiten gibts jetzt auch eine Benutzbarkeit für einfache Anwendung:
<http://www.kopfpit.de/wordpress/goodies/>

Danke!

### [#28](https://www.typo3.net/d/61537-t3x-entpacken/28) · dvschuetz · 2014-11-06

> Funktioniert jetzt mit Typo3 4.5
> neu: extension als standard-ordnername

Bei mir funktioniert's!
Vielen Dank, geniales Tool. :)
Dietmar

### [#29](https://www.typo3.net/d/61537-t3x-entpacken/29) · ViRuSTriNiTy · 2015-01-21

Hi,

ich hab das expand_t3x.php Script aktualisiert, da es bei mir einige Fehler / Warnungen rausgeworfen hat:

```php
<?php
require('/path/to/typo3/sysext/em/classes/connection/class.tx_em_connection_ter.php');
 
 
// Usage ausgeben
function printUsageAndDie(){
global $argv;
print <<<EOM
------------------------------------------------------------------------------
  _____                            _   _   _____
 | ____|_  ___ __   __ _ _ __   __| | | |_|___ /_  __
 |  _| \ \/ / '_ \ / _` | '_ \ / _` | | __| |_ \ \/ /
 | |___ >  <| |_) | (_| | | | | (_| | | |_ ___) >  <
 |_____/_/\_\ .__/ \__,_|_| |_|\__,_|  \__|____/_/\_\  Version 0.3, 21.01.2013
           |_|
 
 ...written by droptix and luwo. (look at http://www.typo3.net/forum)
 ...and Jonny007-MKD
 ...and some fixes by ViRuSTriNiTy
 
 Usage: expand_t3x.php [filename.t3x]  <directory>
 
 * filename.t3x = Name of your t3x-file
 * directory    = optional directory of extraction (default=name of extension)
 
------------------------------------------------------------------------------
 
EOM;
die();
}
 
 
// Wurde eine Datei angegeben?
if (count($argv) <=1) { printUsageAndDie(); }
 
// Wurde ein Auspackverzeichnis angegeben?
if ($argv[2] != '') $unpackDir=$argv[2];
else $unpackDir=substr($argv[1], 0, -4);
 
// Datei aus Kommandozeile holen...
$extFile=$argv[1];
if (file_exists($extFile)) { print "\n Entpacke Datei: '$extFile'...\n\n";}
                       else{ print "\n Datei: '$extFile' wurde leider nicht gefunden \n"; printUsageAndDie();}
 
 
 
// Start unpacking.
$fileContent = file_get_contents($extFile);
$terUtility = new tx_em_Connection_Ter(null);
$ext = $terUtility->decodeExchangeData($fileContent);


 
function autocreate_subdirs($dir) {
        $path = array();
        $subdirs = explode("/", $dir);
        foreach ($subdirs as $subdir) {
                $path[] = $subdir;
                $fullPath = implode("/", $path);
                if (!file_exists($fullPath)) {
                        if (mkdir($fullPath)) {
                                echo sprintf("OK: created directory '%s'\n", $fullPath);
                        } else {
                                echo sprintf("ERROR: directory '%s' not created\n", $fullPath);
                        }
                }
        }
}



// Unpack extension(s).
foreach ($ext as $e) {
        if (is_array($e) && array_key_exists("EM_CONF", $e) && $e["EM_CONF"]) {
                // Create unpack directory.
                if (!file_exists($unpackDir)) {
                        mkdir($unpackDir);
                }
                // Create directories.
                $dirs = explode(",", $e["EM_CONF"]["createDirs"]);
                foreach ($dirs as $dir) {
                        // Start in unpack directory if any.
                        if ($unpackDir) {
                                $dir = $unpackDir."/".$dir;
                        }
                        autocreate_subdirs($dir);
                }
                // Write files.
                foreach ($e["FILES"] as $file) {
                        // Start in unpack directory.
                        if (empty($unpackDir)) {
                                $path = array();
                        } else {
                                $path = array($unpackDir);
                        }
                        $tmp = explode("/", $file["name"]);
                        // Separate file name and rest path.
                        $fileName = array_pop($tmp);
                        $path = array_merge($path, $tmp);
                        unset($tmp);
                        // Create subdirs if neccessary.
                        $dirPath = implode("/", $path);
                        autocreate_subdirs($dirPath);
                        // Write file.
                        $path[] = $fileName;
                        $fullPath = implode("/", $path);
                        if (!is_dir($fullPath))
                        {
                          $handle = fopen($fullPath, "wb");
                          if ($handle && fwrite($handle, $file["content"])) {
                                  fclose($handle);
                                  echo sprintf("OK: wrote file '%s'\n", $fullPath);
                          } else {
                                  echo sprintf("ERROR: file '%s' not written\n", $fullPath);
                          }
                        }
                }
        }
}
?>
```

---

Quelle: „.t3x entpacken“, typo3.net, https://www.typo3.net/d/61537-t3x-entpacken
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
