.t3x entpacken [Gelöst]

  • droptix droptix
    Jedi-Meister
    0 x
    275 Beiträge
    0 Hilfreiche Beiträge
    25. 04. 2007, 10:00

    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.

  • Hilfreichster Beitrag


  • 1 x
    11. 04. 2011, 17:47 - Hilfreichster Beitrag

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

    1. <?php
    2. require('/path/to/typo3/sysext/em/classes/connection/class.tx_em_connection_ter.php');
    3.  
    4.  
    5. // Usage ausgeben
    6. function printUsageAndDie(){
    7. global $argv;
    8. print <<<EOM
    9. ------------------------------------------------------------------------------
    10.   _____ _ _ _____
    11.  | ____|_ ___ __ __ _ _ __ __| | | |_|___ /_ __
    12.  | _| \ \/ / '_ \ / _` | '_ \ / _` | | __| |_ \ \/ /
    13.  | |___ > <| |_) | (_| | | | | (_| | | |_ ___) > <
    14.  |_____/_/\_\ .__/ \__,_|_| |_|\__,_| \__|____/_/\_\ Version 0.2, 11.04.2011
    15.   |_|
    16.  
    17.  ...written by droptix and luwo. (look at http://www.typo3.net/forum)
    18.  ...and Jonny007-MKD
    19.  
    20.  Usage: expand_t3x.php [filename.t3x] <directory>
    21.  
    22.  * filename.t3x = Name of your t3x-file
    23.  * directory = optional directory of extraction (default=name of extension)
    24.  
    25. ------------------------------------------------------------------------------
    26.  
    27. EOM;
    28. die();
    29. }
    30.  
    31.  
    32. // Wurde eine Datei angegeben?
    33. if (count($argv) <=1) { printUsageAndDie(); }
    34.  
    35. // Wurde ein Auspackverzeichnis angegeben?
    36. if ($argv[2] != '') $unpackDir=$argv[2];
    37. else $unpackDir=substr($argv[1], 0, -4);
    38.  
    39. // Datei aus Kommandozeile holen...
    40. $extFile=$argv[1];
    41. if (file_exists($extFile)) { print "\n Entpacke Datei: '$extFile'...\n\n";}
    42. else{ print "\n Datei: '$extFile' wurde leider nicht gefunden \n"; printUsageAndDie();}
    43.  
    44.  
    45.  
    46. // Start unpacking.
    47. $fileContent = file_get_contents($extFile);
    48. $ext = tx_em_Connection_Ter::decodeExchangeData($fileContent);
    49.  
    50.  
    51. function autocreate_subdirs($dir) {
    52. $path = array();
    53. $subdirs = explode("/", $dir);
    54. foreach ($subdirs as $subdir) {
    55. $path[] = $subdir;
    56. $fullPath = implode("/", $path);
    57. if (!file_exists($fullPath)) {
    58. if (mkdir($fullPath)) {
    59. echo sprintf("OK: created directory '%s'\n", $fullPath);
    60. } else {
    61. echo sprintf("ERROR: directory '%s' not created\n", $fullPath);
    62. }
    63. }
    64. }
    65. }
    66.  
    67. // Unpack extension(s).
    68. foreach ($ext as $e) {
    69. if ($e["EM_CONF"]) {
    70. // Create unpack directory.
    71. if (!file_exists($unpackDir)) {
    72. mkdir($unpackDir);
    73. }
    74. // Create directories.
    75. $dirs = explode(",", $e["EM_CONF"]["createDirs"]);
    76. foreach ($dirs as $dir) {
    77. // Start in unpack directory if any.
    78. if ($unpackDir) {
    79. $dir = $unpackDir."/".$dir;
    80. }
    81. autocreate_subdirs($dir);
    82. }
    83. // Write files.
    84. foreach ($e["FILES"] as $file) {
    85. // Start in unpack directory.
    86. if (empty($unpackDir)) {
    87. $path = array();
    88. } else {
    89. $path = array($unpackDir);
    90. }
    91. $tmp = explode("/", $file["name"]);
    92. // Separate file name and rest path.
    93. $fileName = array_pop($tmp);
    94. $path = array_merge($path, $tmp);
    95. unset($tmp);
    96. // Create subdirs if neccessary.
    97. $dirPath = implode("/", $path);
    98. autocreate_subdirs($dirPath);
    99. // Write file.
    100. $path[] = $fileName;
    101. $fullPath = implode("/", $path);
    102. $handle = fopen($fullPath, "wb");
    103. if ($handle && fwrite($handle, $file["content"])) {
    104. fclose($handle);
    105. echo sprintf("OK: wrote file '%s'\n", $fullPath);
    106. } else {
    107. echo sprintf("ERROR: file '%s' not written\n", $fullPath);
    108. }
    109. }
    110. }
    111. }
    112. ?>


  • SLAng SLAng
    Flash Gordon
    0 x
    2757 Beiträge
    0 Hilfreiche Beiträge
    22. 05. 2008, 06:35

    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...

  • 0 x
    7 Beiträge
    0 Hilfreiche Beiträge
    02. 06. 2008, 11:56

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

    [b]Internal Server Error[/b]
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Pfiffikus,
    der auch an dieser Stelle einen Timeout vermutet

  • Tolstoey Tolstoey
    Padawan
    0 x
    54 Beiträge
    0 Hilfreiche Beiträge
    29. 07. 2008, 16:26

    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: [url]http://www.proszenium.com/fileadmin/tt_news-2_3_2_LIGHT.t3x[/url]


  • 1 x
    11. 04. 2011, 17:47

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

    1. <?php
    2. require('/path/to/typo3/sysext/em/classes/connection/class.tx_em_connection_ter.php');
    3.  
    4.  
    5. // Usage ausgeben
    6. function printUsageAndDie(){
    7. global $argv;
    8. print <<<EOM
    9. ------------------------------------------------------------------------------
    10.   _____ _ _ _____
    11.  | ____|_ ___ __ __ _ _ __ __| | | |_|___ /_ __
    12.  | _| \ \/ / '_ \ / _` | '_ \ / _` | | __| |_ \ \/ /
    13.  | |___ > <| |_) | (_| | | | | (_| | | |_ ___) > <
    14.  |_____/_/\_\ .__/ \__,_|_| |_|\__,_| \__|____/_/\_\ Version 0.2, 11.04.2011
    15.   |_|
    16.  
    17.  ...written by droptix and luwo. (look at http://www.typo3.net/forum)
    18.  ...and Jonny007-MKD
    19.  
    20.  Usage: expand_t3x.php [filename.t3x] <directory>
    21.  
    22.  * filename.t3x = Name of your t3x-file
    23.  * directory = optional directory of extraction (default=name of extension)
    24.  
    25. ------------------------------------------------------------------------------
    26.  
    27. EOM;
    28. die();
    29. }
    30.  
    31.  
    32. // Wurde eine Datei angegeben?
    33. if (count($argv) <=1) { printUsageAndDie(); }
    34.  
    35. // Wurde ein Auspackverzeichnis angegeben?
    36. if ($argv[2] != '') $unpackDir=$argv[2];
    37. else $unpackDir=substr($argv[1], 0, -4);
    38.  
    39. // Datei aus Kommandozeile holen...
    40. $extFile=$argv[1];
    41. if (file_exists($extFile)) { print "\n Entpacke Datei: '$extFile'...\n\n";}
    42. else{ print "\n Datei: '$extFile' wurde leider nicht gefunden \n"; printUsageAndDie();}
    43.  
    44.  
    45.  
    46. // Start unpacking.
    47. $fileContent = file_get_contents($extFile);
    48. $ext = tx_em_Connection_Ter::decodeExchangeData($fileContent);
    49.  
    50.  
    51. function autocreate_subdirs($dir) {
    52. $path = array();
    53. $subdirs = explode("/", $dir);
    54. foreach ($subdirs as $subdir) {
    55. $path[] = $subdir;
    56. $fullPath = implode("/", $path);
    57. if (!file_exists($fullPath)) {
    58. if (mkdir($fullPath)) {
    59. echo sprintf("OK: created directory '%s'\n", $fullPath);
    60. } else {
    61. echo sprintf("ERROR: directory '%s' not created\n", $fullPath);
    62. }
    63. }
    64. }
    65. }
    66.  
    67. // Unpack extension(s).
    68. foreach ($ext as $e) {
    69. if ($e["EM_CONF"]) {
    70. // Create unpack directory.
    71. if (!file_exists($unpackDir)) {
    72. mkdir($unpackDir);
    73. }
    74. // Create directories.
    75. $dirs = explode(",", $e["EM_CONF"]["createDirs"]);
    76. foreach ($dirs as $dir) {
    77. // Start in unpack directory if any.
    78. if ($unpackDir) {
    79. $dir = $unpackDir."/".$dir;
    80. }
    81. autocreate_subdirs($dir);
    82. }
    83. // Write files.
    84. foreach ($e["FILES"] as $file) {
    85. // Start in unpack directory.
    86. if (empty($unpackDir)) {
    87. $path = array();
    88. } else {
    89. $path = array($unpackDir);
    90. }
    91. $tmp = explode("/", $file["name"]);
    92. // Separate file name and rest path.
    93. $fileName = array_pop($tmp);
    94. $path = array_merge($path, $tmp);
    95. unset($tmp);
    96. // Create subdirs if neccessary.
    97. $dirPath = implode("/", $path);
    98. autocreate_subdirs($dirPath);
    99. // Write file.
    100. $path[] = $fileName;
    101. $fullPath = implode("/", $path);
    102. $handle = fopen($fullPath, "wb");
    103. if ($handle && fwrite($handle, $file["content"])) {
    104. fclose($handle);
    105. echo sprintf("OK: wrote file '%s'\n", $fullPath);
    106. } else {
    107. echo sprintf("ERROR: file '%s' not written\n", $fullPath);
    108. }
    109. }
    110. }
    111. }
    112. ?>

  • 0 x
    11 Beiträge
    0 Hilfreiche Beiträge
    30. 11. 2011, 15:12

    [quote="Jonny007MKD"]
    Funktioniert jetzt mit Typo3 4.5
    neu: extension als standard-ordnername

    1. <?php
    2. require('/path/to/typo3/sysext/em/classes/connection/class.tx_em_connection_ter.php');
    3.  
    4.  
    5. // Usage ausgeben
    6. function printUsageAndDie(){
    7. global $argv;
    8. print <<<EOM
    9. ------------------------------------------------------------------------------
    10.   _____ _ _ _____
    11.  | ____|_ ___ __ __ _ _ __ __| | | |_|___ /_ __
    12.  | _| \ \/ / '_ \ / _` | '_ \ / _` | | __| |_ \ \/ /
    13.  | |___ > <| |_) | (_| | | | | (_| | | |_ ___) > <
    14.  |_____/_/\_\ .__/ \__,_|_| |_|\__,_| \__|____/_/\_\ Version 0.2, 11.04.2011
    15.   |_|
    16.  
    17.  ...written by droptix and luwo. (look at http://www.typo3.net/forum)
    18.  ...and Jonny007-MKD
    19.  
    20.  Usage: expand_t3x.php [filename.t3x] <directory>
    21.  
    22.  * filename.t3x = Name of your t3x-file
    23.  * directory = optional directory of extraction (default=name of extension)
    24.  
    25. ------------------------------------------------------------------------------
    26.  
    27. EOM;
    28. die();
    29. }
    30.  
    31.  
    32. // Wurde eine Datei angegeben?
    33. if (count($argv) <=1) { printUsageAndDie(); }
    34.  
    35. // Wurde ein Auspackverzeichnis angegeben?
    36. if ($argv[2] != '') $unpackDir=$argv[2];
    37. else $unpackDir=substr($argv[1], 0, -4);
    38.  
    39. // Datei aus Kommandozeile holen...
    40. $extFile=$argv[1];
    41. if (file_exists($extFile)) { print "\n Entpacke Datei: '$extFile'...\n\n";}
    42. else{ print "\n Datei: '$extFile' wurde leider nicht gefunden \n"; printUsageAndDie();}
    43.  
    44.  
    45.  
    46. // Start unpacking.
    47. $fileContent = file_get_contents($extFile);
    48. $ext = tx_em_Connection_Ter::decodeExchangeData($fileContent);
    49.  
    50.  
    51. function autocreate_subdirs($dir) {
    52. $path = array();
    53. $subdirs = explode("/", $dir);
    54. foreach ($subdirs as $subdir) {
    55. $path[] = $subdir;
    56. $fullPath = implode("/", $path);
    57. if (!file_exists($fullPath)) {
    58. if (mkdir($fullPath)) {
    59. echo sprintf("OK: created directory '%s'\n", $fullPath);
    60. } else {
    61. echo sprintf("ERROR: directory '%s' not created\n", $fullPath);
    62. }
    63. }
    64. }
    65. }
    66.  
    67. // Unpack extension(s).
    68. foreach ($ext as $e) {
    69. if ($e["EM_CONF"]) {
    70. // Create unpack directory.
    71. if (!file_exists($unpackDir)) {
    72. mkdir($unpackDir);
    73. }
    74. // Create directories.
    75. $dirs = explode(",", $e["EM_CONF"]["createDirs"]);
    76. foreach ($dirs as $dir) {
    77. // Start in unpack directory if any.
    78. if ($unpackDir) {
    79. $dir = $unpackDir."/".$dir;
    80. }
    81. autocreate_subdirs($dir);
    82. }
    83. // Write files.
    84. foreach ($e["FILES"] as $file) {
    85. // Start in unpack directory.
    86. if (empty($unpackDir)) {
    87. $path = array();
    88. } else {
    89. $path = array($unpackDir);
    90. }
    91. $tmp = explode("/", $file["name"]);
    92. // Separate file name and rest path.
    93. $fileName = array_pop($tmp);
    94. $path = array_merge($path, $tmp);
    95. unset($tmp);
    96. // Create subdirs if neccessary.
    97. $dirPath = implode("/", $path);
    98. autocreate_subdirs($dirPath);
    99. // Write file.
    100. $path[] = $fileName;
    101. $fullPath = implode("/", $path);
    102. $handle = fopen($fullPath, "wb");
    103. if ($handle && fwrite($handle, $file["content"])) {
    104. fclose($handle);
    105. echo sprintf("OK: wrote file '%s'\n", $fullPath);
    106. } else {
    107. echo sprintf("ERROR: file '%s' not written\n", $fullPath);
    108. }
    109. }
    110. }
    111. }
    112. ?>

    [/quote]

    Nach dem entpacken bekomme ich leider eine Fehlermeldung:

    1. Notice: Uninitialized string offset: 0 in /home/srv/www/htdocs/expandt3x/expandt3x.php on line 69
    2.  
    3. Call Stack:
    4. 0.0011 76812 1. {main}() /home/srv/www/htdocs/expandt3x/expandt3x.php:0
    5.  
    6.  
    7. Variables in local scope (#1):
    8. $argv = array (0 => 'expandt3x.php', 1 => 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804.t3x')
    9. $dir = 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804/uploads/tx_charbeitsbeispiele/'
    10. $dirPath = 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804/res'
    11. $dirs = array (0 => 'uploads/tx_charbeitsbeispiele/')
    12. $e = ''
    13. $ext = array (0 => array ('extKey' => 'ch_arbeitsbeispiele', 'EM_CONF' => array (...), 'misc' => array (...), 'techInfo' => array (...), 'FILES' => array (...)), 1 => '')
    14. $extFile = 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804.t3x'
    15. $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')
    16. $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...'
    17. $fileName = 'system.css'
    18. $fullPath = 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804/res/system.css'
    19. $handle = resource(63) of type (Unknown)
    20. $path = array (0 => 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804', 1 => 'res', 2 => 'system.css')
    21. $tmp = *uninitialized*
    22. $unpackDir = 'T3X_ch_arbeitsbeispiele-0_0_0-z-201111051804'

  • nevsred nevsred
    R2-D2
    0 x
    113 Beiträge
    0 Hilfreiche Beiträge
    07. 01. 2014, 11:31

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

    Danke!

  • dvschuetz dvschuetz
    R2-D2
    0 x
    111 Beiträge
    0 Hilfreiche Beiträge
    06. 11. 2014, 07:54

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

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

  • ViRuSTriNiTy ViRuSTriN...
    Typ im Roten Hemd
    0 x
    2 Beiträge
    0 Hilfreiche Beiträge
    21. 01. 2015, 10:43

    Hi,

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

    1. <?php
    2. require('/path/to/typo3/sysext/em/classes/connection/class.tx_em_connection_ter.php');
    3.  
    4.  
    5. // Usage ausgeben
    6. function printUsageAndDie(){
    7. global $argv;
    8. print <<<EOM
    9. ------------------------------------------------------------------------------
    10.   _____ _ _ _____
    11.  | ____|_ ___ __ __ _ _ __ __| | | |_|___ /_ __
    12.  | _| \ \/ / '_ \ / _` | '_ \ / _` | | __| |_ \ \/ /
    13.  | |___ > <| |_) | (_| | | | | (_| | | |_ ___) > <
    14.  |_____/_/\_\ .__/ \__,_|_| |_|\__,_| \__|____/_/\_\ Version 0.3, 21.01.2013
    15.   |_|
    16.  
    17.  ...written by droptix and luwo. (look at http://www.typo3.net/forum)
    18.  ...and Jonny007-MKD
    19.  ...and some fixes by ViRuSTriNiTy
    20.  
    21.  Usage: expand_t3x.php [filename.t3x] <directory>
    22.  
    23.  * filename.t3x = Name of your t3x-file
    24.  * directory = optional directory of extraction (default=name of extension)
    25.  
    26. ------------------------------------------------------------------------------
    27.  
    28. EOM;
    29. die();
    30. }
    31.  
    32.  
    33. // Wurde eine Datei angegeben?
    34. if (count($argv) <=1) { printUsageAndDie(); }
    35.  
    36. // Wurde ein Auspackverzeichnis angegeben?
    37. if ($argv[2] != '') $unpackDir=$argv[2];
    38. else $unpackDir=substr($argv[1], 0, -4);
    39.  
    40. // Datei aus Kommandozeile holen...
    41. $extFile=$argv[1];
    42. if (file_exists($extFile)) { print "\n Entpacke Datei: '$extFile'...\n\n";}
    43. else{ print "\n Datei: '$extFile' wurde leider nicht gefunden \n"; printUsageAndDie();}
    44.  
    45.  
    46.  
    47. // Start unpacking.
    48. $fileContent = file_get_contents($extFile);
    49. $terUtility = new tx_em_Connection_Ter(null);
    50. $ext = $terUtility->decodeExchangeData($fileContent);
    51.  
    52.  
    53.  
    54. function autocreate_subdirs($dir) {
    55. $path = array();
    56. $subdirs = explode("/", $dir);
    57. foreach ($subdirs as $subdir) {
    58. $path[] = $subdir;
    59. $fullPath = implode("/", $path);
    60. if (!file_exists($fullPath)) {
    61. if (mkdir($fullPath)) {
    62. echo sprintf("OK: created directory '%s'\n", $fullPath);
    63. } else {
    64. echo sprintf("ERROR: directory '%s' not created\n", $fullPath);
    65. }
    66. }
    67. }
    68. }
    69.  
    70.  
    71.  
    72. // Unpack extension(s).
    73. foreach ($ext as $e) {
    74. if (is_array($e) && array_key_exists("EM_CONF", $e) && $e["EM_CONF"]) {
    75. // Create unpack directory.
    76. if (!file_exists($unpackDir)) {
    77. mkdir($unpackDir);
    78. }
    79. // Create directories.
    80. $dirs = explode(",", $e["EM_CONF"]["createDirs"]);
    81. foreach ($dirs as $dir) {
    82. // Start in unpack directory if any.
    83. if ($unpackDir) {
    84. $dir = $unpackDir."/".$dir;
    85. }
    86. autocreate_subdirs($dir);
    87. }
    88. // Write files.
    89. foreach ($e["FILES"] as $file) {
    90. // Start in unpack directory.
    91. if (empty($unpackDir)) {
    92. $path = array();
    93. } else {
    94. $path = array($unpackDir);
    95. }
    96. $tmp = explode("/", $file["name"]);
    97. // Separate file name and rest path.
    98. $fileName = array_pop($tmp);
    99. $path = array_merge($path, $tmp);
    100. unset($tmp);
    101. // Create subdirs if neccessary.
    102. $dirPath = implode("/", $path);
    103. autocreate_subdirs($dirPath);
    104. // Write file.
    105. $path[] = $fileName;
    106. $fullPath = implode("/", $path);
    107. if (!is_dir($fullPath))
    108. {
    109. $handle = fopen($fullPath, "wb");
    110. if ($handle && fwrite($handle, $file["content"])) {
    111. fclose($handle);
    112. echo sprintf("OK: wrote file '%s'\n", $fullPath);
    113. } else {
    114. echo sprintf("ERROR: file '%s' not written\n", $fullPath);
    115. }
    116. }
    117. }
    118. }
    119. }
    120. ?>