This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
extExtract.php
executable file
·620 lines (524 loc) · 20.6 KB
/
extExtract.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
#!/usr/bin/php
<?php
// TYPO3 Extension Extraction Script
// written by Oliver Salzburg
define( "SELF", basename( __FILE__ ) );
define( "INVNAME", $argv[ 0 ] );
/**
* Show the help for this script
* @name string The name of this script as invoked by the user (usually $argv[0])
*/
function showHelp( $name ) {
echo <<<EOS
Usage: $name [OPTIONS] [--extension=]EXTKEY
Core:
--help Display this help and exit.
--verbose Display more detailed messages.
--quiet Do not display anything.
--force Perform actions that would otherwise abort the script.
--update Tries to update the script to the latest version.
--update-check Checks if a newer version of the script is available.
--export-config Prints the default configuration of this script.
--extract-config Extracts configuration parameters from TYPO3.
--base=PATH The name of the base path where TYPO3 is
installed. If no base is supplied, "typo3" is used.
Options:
--extension=EXTKEY The extension key of the extension that should be
operated on.
--force-version=VERSION Forces download of specific extension version.
--dump Prints out a dump of the data structure of the
extension file.
--string-limit=LENGTH The LENGTH at which string data should be summarized
as String[N]. Default: 60 No Limit: 0
--extract Forces the extraction process even if other commands
were invoked.
--output-dir=DIRECTORY The DIRECTORY to where the extension should be
extracted.
--output-file[=NAME] Write the downloaded extension file to disk with an
optional NAME.
EOS;
}
/**
* Print the default configuration to ease creation of a config file.
*/
function exportConfig() {
$config = "";
preg_match_all( "/# Script Configuration start.+?# Script Configuration end/ms", file_get_contents( INVNAME ), $config );
$_configuration = preg_replace( "/\\$(?P<name>[^=]+)\\s*=\\s*\"(?P<value>[^\"]*)\";/", "\\1=\\2", $config[ 0 ][ 1 ] );
echo $_configuration;
}
function extractConfig() {
echo "Extracting a configuration is currently not supported!\n";
echo "Please use another script to extract the configuration.\n";
return;
}
define( "REQUIRED_ARGUMENT_COUNT", 1 );
if( $argc <= REQUIRED_ARGUMENT_COUNT ) {
consoleWriteLine( "Insufficient command line arguments!" );
consoleWriteLine( "Use " . INVNAME . " --help to get additional information." );
exit( 1 );
}
# Script Configuration start
# Should the script give more detailed feedback?
$VERBOSE="false";
# Should the script surpress all feedback?
$QUIET="false";
# Should the script ignore reasons that would otherwise cause it to abort?
$FORCE="false";
# The base directory where Typo3 is installed
$BASE="typo3";
# The hostname of the MySQL server that Typo3 uses
$HOST="localhost";
# The username used to connect to that MySQL server
$USER="*username*";
# The password for that user
$PASS="*password*";
# The name of the database in which Typo3 is stored
$DB="typo3";
# The extension key for which to retrieve the changelog
$EXTENSION="";
# The directory to where the extension should be extracted.
$OUTPUTDIR="";
# The file where possibly downloaded, temporary files should be stored
$OUTPUTFILE="";
# Should the data structure of the extension be printed?
$DUMP="false";
# The length at which strings should be summarized in the dump output.
$STRING_LIMIT="60";
# Should the extraction process be skipped?
$EXTRACT="true";
# Force a specific extension version to be downloaded
$FORCE_VERSION="";
# Script Configuration end
function consoleWrite( $args ) {
global $QUIET;
if( "false" == "$QUIET" ) file_put_contents( "php://stderr", $args );
return 0;
}
function consoleWriteLine( $args ) {
global $QUIET;
if( "false" == "$QUIET" ) file_put_contents( "php://stderr", $args . "\n" );
return 0;
}
function consoleWriteVerbose( $args ) {
global $VERBOSE;
if( "true" == $VERBOSE ) consoleWrite( $args );
return 0;
}
function consoleWriteLineVerbose( $args ) {
global $VERBOSE;
if( "true" == $VERBOSE ) consoleWriteLine( $args );
return 0;
}
// The base location from where to retrieve new versions of this script
$UPDATE_BASE = "https://raw.github.com/oliversalzburg/typo3scripts/master";
/**
* Update check
*/
function updateCheck() {
global $UPDATE_BASE, $SUM_SELF, $SUM_LATEST;
$_contentVersions = file_get_contents( $UPDATE_BASE . "/versions" );
$_contentSelf = explode( "\n", file_get_contents( INVNAME ), 2 );
$_sumSelf = md5( $_contentSelf[ 1 ] );
consoleWriteLineVerbose( "Remote hash source: '" . $UPDATE_BASE . "/versions'" );
consoleWriteLineVerbose( "Own hash: '" . $SUM_SELF . "' Remote hash: '" . $SUM_LATEST . "'" );
$_isListed = preg_match( "/^" . SELF . " (?P<sum>[0-9a-zA-Z]{32})/ms", $_contentVersions, $_sumLatest );
if( !$_isListed ) {
consoleWriteLine( "No update information is available for '" . SELF . "'." );
consoleWriteLine( "Please check the project home page https://github.com/oliversalzburg/typo3scripts." );
return 2;
} else if( $_sumSelf != $_sumLatest[ 1 ] ) {
consoleWriteLine( "NOTE: New version available!" );
return 1;
}
return 0;
}
/**
* Self-update
*/
function runSelfUpdate() {
echo "Performing self-update...\n";
$_tempFileName = INVNAME . ".tmp";
// Download new version
echo "Downloading latest version...";
global $UPDATE_BASE;
$_fileContents = @file_get_contents( $UPDATE_BASE . "/" . SELF );
if( strlen( $_fileContents ) <= 0 ) {
echo "Failed: Error while trying to download new version!\n";
echo "File requested: " . $UPDATE_BASE . "/" . SELF . "\n";
exit( 1 );
}
$_payload = explode( "\n", $_fileContents, 2 );
echo "Done.\n";
// Restore shebang
$_selfContent = explode( "\n", file_get_contents( INVNAME ), 2 );
$_interpreter = $_selfContent[ 0 ];
file_put_contents( $_tempFileName, $_interpreter . "\n" );
file_put_contents( $_tempFileName, $_payload[ 1 ], FILE_APPEND );
// Copy over modes from old version
$_octalMode = fileperms( INVNAME );
if( FALSE == chmod( $_tempFileName, $_octalMode ) ) {
echo "Failed: Error while trying to set mode on $_tempFileName.\n";
exit( 1 );
}
// Spawn update script
$_name = INVNAME;
$_updateScript = <<<EOS
#!/bin/bash
# Overwrite old file with new
if mv "$_tempFileName" "$_name"; then
echo "Done."
echo "Update complete."
rm -- $0
else
echo "Failed!"
fi
EOS;
file_put_contents( "updateScript.sh", $_updateScript );
echo "Inserting update process...";
file_put_contents( "updateScript.sh", $_updateScript );
chmod( "updateScript.sh", 0700 );
if( function_exists( "pcntl_exec" ) ) {
pcntl_exec( "/bin/bash", array( "./updateScript.sh" ) );
} else if( function_exists( "passthru" ) ) {
die( passthru( "./updateScript.sh" ) );
} else {
die( "Please execute ./updateScript.sh now." );
}
}
# Make a quick run through the command line arguments to see if the user wants
# to print the help. This saves us a lot of headache with respecting the order
# in which configuration parameters have to be overwritten.
foreach( $argv as $_option ) {
if( 0 === strpos( $_option, "--help" ) || 0 === strpos( $_option, "-h" ) ) {
showHelp( $argv[ 0 ] );
exit( 0 );
}
}
// Read external configuration - Stage 1 - typo3scripts.conf (overwrites default, hard-coded configuration)
$BASE_CONFIG_FILENAME = "typo3scripts.conf";
if( file_exists( $BASE_CONFIG_FILENAME ) ) {
if( !is_readable( $BASE_CONFIG_FILENAME ) ) {
consoleWriteLine( "Unable to read '" . $BASE_CONFIG_FILENAME . "'. Check permissions." );
exit( 1 );
}
consoleWriteVerbose( "Sourcing script configuration from " . $BASE_CONFIG_FILENAME . "..." );
$_baseConfig = file_get_contents( $BASE_CONFIG_FILENAME );
$_baseConfigFixed = preg_replace( "/^(?!\\s*$)(?P<name>[^#][^=]+)\\s*=\\s*(?P<value>[^$]*?)$/ms", "$\\1=\"\\2\";", $_baseConfig );
eval( $_baseConfigFixed );
consoleWriteLineVerbose( "Done." );
}
// Read external configuration - Stage 2 - script-specific (overwrites default, hard-coded configuration)
$CONFIG_FILENAME = substr( SELF, 0, -4 ) . ".conf";
if( file_exists( $CONFIG_FILENAME ) ) {
if( is_readable( $CONFIG_FILENAME ) ) {
consoleWriteLine( "Unable to read '" . $CONFIG_FILENAME . "'. Check permissions." );
exit( 1 );
}
consoleWriteVerbose( "Sourcing script configuration from " . $CONFIG_FILENAME . "..." );
$_config = file_get_contents( $CONFIG_FILENAME );
$_configFixed = preg_replace( "/^(?!\\s*$)(?P<name>[^#][^=]+)\\s*=\\s*(?P<value>[^$]*?)$/ms", "$\\1=\"\\2\";", $_config );
eval( $_configFixed );
consoleWriteLineVerbose( "Done." );
}
foreach( $argv as $_option ) {
if( $_option === $argv[ 0 ] ) continue;
if( $_option == "--verbose" ) {
$VERBOSE = "true";
} else if( $_option == "--quiet" ) {
$QUIET = "true";
} else if( $_option == "--force" ) {
$FORCE = "true";
} else if( $_option == "--update" ) {
runSelfUpdate();
} else if( $_option == "--update-check" ) {
$returnValue = updateCheck();
exit( $returnValue );
} else if( 0 === strpos( $_option, "--base=" ) ) {
$BASE = substr( $_option, strpos( $_option, "=" ) + 1 );
} else if( $_option == "--export-config" ) {
exportConfig();
exit( 0 );
} else if( $_option == "--extract-config" ) {
extractConfig();
exit( 0 );
} else if( 0 === strpos( $_option, "--extension=" ) ) {
$EXTENSION = substr( $_option, strpos( $_option, "=" ) + 1 );
} else if( 0 === strpos( $_option, "--force-version=" ) ) {
$FORCE_VERSION = substr( $_option, strpos( $_option, "=" ) + 1 );
} else if( $_option == "--dump" ) {
$DUMP = "true";
$EXTRACT = "false";
} else if( 0 === strpos( $_option, "--string-limit=" ) ) {
$STRING_LIMIT = substr( $_option, strpos( $_option, "=" ) + 1 );
} else if( $_option == "--extract" ) {
$EXTRACT = "true";
} else if( 0 === strpos( $_option, "--output-dir=" ) ) {
$OUTPUTDIR = substr( $_option, strpos( $_option, "=" ) + 1 );
} else if( $_option == "--output-file" ) {
$_equalSignIndex = strpos( $_option, "=" );
if( FALSE === $_equalSignIndex ) {
$OUTPUTFILE = FALSE;
} else {
$OUTPUTFILE = substr( $_option, $_equalSignIndex + 1 );
}
} else {
$EXTENSION = $_option;
}
}
// Begin main operation
// Check default argument validity
if( 0 === strpos( $EXTENSION, "--" ) ) {
consoleWriteLine( "The given extension key '$EXTENSION' looks like a command line parameter." );
consoleWriteLine( "Please use --help to see a list of available command line parameters." );
exit( 1 );
}
if( "" === $EXTENSION ) {
consoleWriteLine( "No extension given." );
exit( 1 );
}
/**
* Downloads an extension from the TYPO3 extension repository
*/
function downloadExtension( $_extKey, $_version ) {
$_firstLetter = substr( $_extKey, 0, 1 );
$_secondLetter = substr( $_extKey, 1, 1 );
$_t3xName = $_extKey . "_" . $_version . ".t3x";
$_extensionUrl = "http://typo3.org/fileadmin/ter/" . $_firstLetter . "/" . $_secondLetter . "/" . $_t3xName;
$_extensionData = @file_get_contents( $_extensionUrl );
if( FALSE === $_extensionData ) {
consoleWriteLine( "Error: Could not retrieve extension file." );
consoleWriteLine( "File requested: $_extensionUrl" );
exit( 1 );
}
$_tempFileName = $_t3xName;
global $OUTPUTFILE;
if( FALSE !== $OUTPUTFILE && "" !== $OUTPUTFILE ) {
$_tempFileName = $OUTPUTFILE;
}
file_put_contents( $_tempFileName, $_extensionData );
if( "" === $OUTPUTFILE ) {
register_shutdown_function( "cleanUpTempFile", $_tempFileName );
}
return $_tempFileName;
}
function cleanUpTempFile( &$_tempFileName ) {
unlink( $_tempFileName );
}
// Is the provided extension not just an extension key, but a filename?
$_extensionFile = $EXTENSION;
if( !file_exists( $_extensionFile ) ) {
// It must be a reference to an extension installed in the local TYPO3 installation.
$_extensionDirectory = "$BASE/typo3conf/ext/$EXTENSION";
// But we only need to check it if the user doesn't want a specific version.
if( is_dir( $_extensionDirectory ) && "" == $FORCE_VERSION ) {
// The user wants to get the latest, official extension file for an installed extension
consoleWrite( "Retrieving original extension file for '$EXTENSION' " );
$_extensionConfigFile = "$_extensionDirectory/ext_emconf.php";
// While it's not very nice to polute our script with the contents of ext_emconf.php,
// it's the most reliable way to parse the information.
$_EXTKEY = $EXTENSION;
include( $_extensionConfigFile );
$_extensionConfiguration = $EM_CONF[ $EXTENSION ];
$_installedVersion = $_extensionConfiguration[ "version" ];
consoleWrite( "$_installedVersion..." );
$_tempFileName = downloadExtension( $EXTENSION, $_installedVersion );
consoleWriteLine( "Done." );
$_extensionFile = $_tempFileName;
} else if( "" != $FORCE_VERSION ) {
// The user is looking for a specific version of an extension. Retrieve it.
consoleWrite( "Retrieving original extension file for '$EXTENSION' " );
consoleWrite( "$FORCE_VERSION..." );
$_tempFileName = downloadExtension( $EXTENSION, $FORCE_VERSION );
consoleWriteLine( "Done." );
$_extensionFile = $_tempFileName;
} else {
consoleWriteLine( "Unable to find extension '$EXTENSION'." );
consoleWriteLine( "Directory requested: '$BASE/typo3conf/ext/$EXTENSION'" );
exit( 1 );
}
}
// If no output directory is yet defined, use the extension filename as a base
if( 0 === strlen( $OUTPUTDIR ) ) {
$OUTPUTDIR = $_extensionFile . "-extracted";
}
// Don't overwrite existing data!
if( is_dir( $OUTPUTDIR ) ) {
consoleWriteLine( "Error: The target directory '$OUTPUTDIR' already exists." );
exit( 1 );
}
/**
* Extracts extension array from extension file.
*/
function extractExtensionData( $extensionFile ) {
if( file_exists( $extensionFile ) ) {
$_fileContents = file_get_contents( $extensionFile );
$_fileParts = explode( ":", $_fileContents, 3 );
$_extensionContent = "";
if( "gzcompress" == $_fileParts[ 1 ] ) {
if( function_exists( "gzuncompress" ) ) {
$_extensionContent = gzuncompress( $_fileParts[ 2 ] );
} else {
consoleWriteLine( "Error: Unable to decode extension. gzuncompress() is unavailable." );
exit( 1 );
}
}
$_extension = null;
if( md5( $_extensionContent ) == $_fileParts[ 0 ] ) {
$_extension = unserialize( $_extensionContent );
if( is_array( $_extension ) ) {
return $_extension;
} else {
consoleWriteLine( "Error: Unable to unserialize extension! (Shouldn't happen)" );
exit( 1 );
}
} else {
consoleWriteLine( "Error: MD5 mismatch. Extension file may be corrupt!" );
exit( 1 );
}
} else {
consoleWriteLine( "Error: Unable to open '$extensionFile'!" );
exit( 1 );
}
}
/**
* Dump the contents of a PHP array and apply some pretty-printing
*/
function printArray( $array, $indent, $nameIndent ) {
foreach( $array as $name => $value ) {
echo $indent . $name . substr( $nameIndent, 0, -strlen( $name ) ) . " = ";
if( is_array( $value ) ) {
echo "\n";
$_maxValueLength = 0;
foreach( $value as $string => $_ignoredValue ) {
if( strlen( $string ) > $_maxValueLength ) {
$_maxValueLength = strlen( $string );
}
}
printArray( $value, $indent . " ", str_repeat( " ", $_maxValueLength ) );
} else if( is_int( $value ) ) {
echo $value;
} else if( is_string( $value ) ) {
$_valueLength = strlen( $value );
global $STRING_LIMIT;
// $STRING_LIMIT is a string due to configuration file interoperability concerns
if( !ctype_print( $value ) || ( intval( $STRING_LIMIT ) > 0 && $_valueLength > intval( $STRING_LIMIT ) ) ) {
echo "String[$_valueLength]";
} else {
echo $value;
}
} else {
echo gettype( $value );
}
echo "\n";
}
}
function dependencyToString( $dependency, $type ) {
if( !is_array( $dependency ) || !is_array( $dependency[ $type ] ) ) {
return "";
}
unset( $dependency[ $type ][ "php" ] );
unset( $dependency[ $type ][ "typo3" ] );
return implode( ",", array_keys( $dependency[ $type ] ) );
}
function stringToDependency( $dependency ) {
$constraint = array();
if( is_string( $dependency ) && strlen( $dependency ) ) {
$dependency = explode( ",", $dependency );
foreach( $dependency as $v ) {
$constraint[ $v ] = "";
}
}
return $constraint;
}
function constructEmConf( array $extensionData ) {
$emConf = $extensionData[ "EM_CONF" ];
if (
!isset( $emConf[ "constraints" ] ) || !isset( $emConf[ "constraints" ][ "depends" ] )
|| !isset( $emConf[ "constraints" ][ "conflicts" ] ) || !isset( $emConf[ "constraints" ][ "suggests" ] )
) {
if( !isset( $emConf[ "constraints" ] ) || !isset( $emConf[ "constraints" ][ "depends" ] ) ) {
$emConf[ "constraints" ][ "depends" ] = stringToDependency( $emConf[ "dependencies" ] );
if( strlen( $emConf[ "PHP_version" ] ) ) {
$emConf[ "constraints" ][ "depends" ][ "php" ] = $emConf[ "PHP_version" ];
}
if( strlen( $emConf[ "TYPO3_version" ] ) ) {
$emConf[ "constraints" ][ "depends" ][ "typo3" ] = $emConf[ "TYPO3_version" ];
}
}
if( !isset( $emConf[ "constraints" ] ) || !isset( $emConf[ "constraints" ][ "conflicts" ] ) ) {
$emConf[ "constraints" ][ "conflicts" ] = stringToDependency( $emConf[ "conflicts" ] );
}
if( !isset( $emConf[ "constraints" ] ) || !isset( $emConf[ "constraints" ][ "suggests" ] ) ) {
$emConf[ "constraints" ][ "suggests" ] = array();
}
} elseif( isset( $emConf[ "constraints" ] ) && isset( $emConf[ "dependencies" ] ) ) {
$emConf[ "suggests" ] = isset( $emConf[ "suggests" ] ) ? $emConf[ "suggests" ] : array();
$emConf[ "dependencies" ] = dependencyToString( $emConf[ "constraints" ], "depends" );
$emConf[ "conflicts" ] = dependencyToString( $emConf[ "constraints" ], "conflicts" );
}
unset( $emConf[ "private" ] );
unset( $emConf[ "download_password" ] );
unset( $emConf[ "TYPO3_version" ] );
unset( $emConf[ "PHP_version" ] );
$emConf = var_export( $emConf, TRUE );
$code = "<?php
/***************************************************************
* Extension Manager/Repository config file for ext \"" . $extensionData[ "extKey" ] . "\".
*
* Auto generated " . date( "d-m-Y H:i" ) . "
*
* Manual updates:
* Only the data in the array - everything else is removed by next
* writing. \"version\" and \"dependencies\" must not be touched!
***************************************************************/
\$EM_CONF[\$_EXTKEY] = " . $emConf . ";
?>";
return str_replace( " ", "\t", $code );
}
consoleWrite( "Extracting file '$_extensionFile'..." );
consoleWriteLineVerbose( "" );
$_extension = extractExtensionData( $_extensionFile );
$_emConf = constructEmConf( $_extension );
// Dump data structure first (if requested).
// $DUMP is a string due to configuration file interoperability concerns
if( $DUMP === "true" ) {
printArray( $_extension, "", "" );
}
// Finally extract the extension files.
// $EXTRACT is a string due to configuration file interoperability concerns
if( $EXTRACT === "true" ) {
// Extract contents
foreach( $_extension[ "FILES" ] as $_filename => $_file ) {
$_directoryName = dirname( $_file[ "name" ] );
$_fullPathName = $OUTPUTDIR . "/" . $_directoryName;
// is_dir() and mkdir() seem highly unreliable in their return values,
// so we must ignore failures on mkdir() and have to catch issues later.
if( FALSE === is_dir( $_fullPathName ) ) {
consoleWriteLineVerbose( "Creating directory '$_fullPathName'." );
@mkdir( $_fullPathName, 0700, true );
}
$_fullFileName = $OUTPUTDIR . "/" . $_file[ "name" ];
if( "/" == substr( $_fullFileName, -1 ) ) {
consoleWriteLineVerbose( "Creating folder '$_fullFileName'." );
if( FALSE === mkdir( $_fullFileName ) ) {
consoleWriteLine( "Error: Failed to create folder '$_fullFileName'." );
}
} else {
consoleWriteLineVerbose( "Writing file '$_fullFileName'." );
if( FALSE === file_put_contents( $_fullFileName, $_file[ "content" ] ) ) {
consoleWriteLine( "Error: Failed to write file '$_fullFileName'." );
}
}
}
consoleWriteLine( "Done." );
$_emConfFilename = $OUTPUTDIR . "/ext_emconf.php";
if( !file_exists( $_emConfFilename ) ) {
consoleWrite( "Writing 'ext_emconf.php'..." );
file_put_contents( $_emConfFilename, $_emConf );
consoleWriteLine( "Done." );
}
} else {
consoleWriteLine( "Skipped." );
}
# vim:ts=2:sw=2:expandtab: