.t3x entpacken
| Autor | Nachricht |
|---|---|
|
Verfasst am: 25. 04. 2007 [10:00]
|
|
|
droptix
Themenersteller
Dabei seit: 09.06.2005
Beiträge: 275
|
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. [Dieser Beitrag wurde 1mal bearbeitet, zuletzt am 25.04.2007 um 10:00.] |
|
Verfasst am: 25. 04. 2007 [11:25]
|
|
|
woida
Moderator
Dabei seit: 07.04.2005
Beiträge: 2445
|
Die dafür zuständige Methode "decodeExchangeData" findest du in der typo3/mod/tools/em/class.em_terconnection.php |
|
Verfasst am: 25. 04. 2007 [12:19]
|
|
|
droptix
Themenersteller
Dabei seit: 09.06.2005
Beiträge: 275
|
Habe Probleme damit. Ich lese die .t3x Datei ein: PHP function read_t3x() {
// read file
$handle = fopen($this->t3xFile, "r"<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />;
$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"<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />;
$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<img src="typo3conf/ext/mm_forum//res/smilies/icon_biggrin.gif" alt="icon_biggrin.gif" />atenAls Array könnte man das so abbilden: PHP $array = ( "MD5-Hash", "Kompressionsmethode", "Base64-codierte Infos", "Daten" ) Die Funktion `decodeServerData()` macht folgendes:
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? [Dieser Beitrag wurde 1mal bearbeitet, zuletzt am 25.04.2007 um 12:22.] |
|
Verfasst am: 03. 06. 2007 [23:18]
|
|
|
luwo
Dabei seit: 03.06.2007
Beiträge: 2
|
Hallo droptix, probiers doch mal so: PHP require("class.em_terconnection.php"<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />;
$file=file_get_contents('dateiname.t3x');
$tmp = SC_mod_tools_em_terconnection::decodeExchangeData($file);
print_r($tmp);Grüße Luwo |
|
Verfasst am: 04. 06. 2007 [09:31]
|
|
|
droptix
Themenersteller
Dabei seit: 09.06.2005
Beiträge: 275
|
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"<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />; require("class.em_terconnection.php"<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />; // 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"<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />; 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); } } } } ?> |
|
Verfasst am: 04. 06. 2007 [18:01]
|
|
|
luwo
Dabei seit: 03.06.2007
Beiträge: 2
|
Hallo Droptix, Ehrlich, ein richtig cooles Script!!! Genau soetwas brauche ich nämlich gerade 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"<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />; // 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"<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" /> ------------------------------------------------------------------------------ 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"<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />; 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 |
|
Verfasst am: 05. 06. 2007 [12:37]
|
|
|
droptix
Themenersteller
Dabei seit: 09.06.2005
Beiträge: 275
|
So, hier nun eine .exe Datei zum Auspacken einer .t3x Datei (Code leicht verbessert für meinen Geschmack): expandt3x.exe (~ 1,33 MB) expandt3x.exe gezippt (~ 598 KB)
Viel Spaß damit und Danke an alle, die mitgeholfen haben! P.S. Erstellt mit dem Bambalam PHP EXE Compiler/Embedder |
|
Verfasst am: 07. 06. 2007 [00:06]
|
|
|
karlchen
Dabei seit: 19.10.2006
Beiträge: 748
|
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 |
|
Verfasst am: 07. 06. 2007 [23:37]
|
|
|
droptix
Themenersteller
Dabei seit: 09.06.2005
Beiträge: 275
|
Tja, so bin ich eben 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 [Dieser Beitrag wurde 1mal bearbeitet, zuletzt am 07.06.2007 um 23:47.] |
|
Verfasst am: 11. 06. 2007 [17:19]
|
|
|
a.otto
Dabei seit: 11.06.2007
Beiträge: 2
|
Schau mal im SVN Repository von TYPO3xdev [1] nach. [1]typo3xdev.svn.sourceforge.net/viewvc/typo3xdev/tools_t3x/trunk/ |




