|
8 | 8 |
|
9 | 9 | chdir( realpath( dirname( __FILE__ ) ) );
|
10 | 10 |
|
| 11 | +// output files and common attrs |
| 12 | +define( "IFM_CDN", true ); |
| 13 | +define( "IFM_VERSION", "<a href='https://github.com/misterunknown/ifm/tree/cryol-2.6.1' target=_blank>v2.6.1</a>" ); |
| 14 | +define( "IFM_RELEASE_DIR", "dist/"); |
| 15 | +define( "IFM_STANDALONE", "ifm.php" ); |
| 16 | +define( "IFM_STANDALONE_GZ", "ifm.min.php" ); |
| 17 | +define( "IFM_LIB", "libifm.php" ); |
| 18 | + |
| 19 | +if( IFM_CDN ){ |
| 20 | + $IFM_ASSETS = "src/assets.cdn.part"; |
| 21 | +} else { |
| 22 | + $IFM_ASSETS = "src/assets.part"; |
| 23 | +} |
| 24 | + |
11 | 25 | // php source files
|
12 | 26 | $IFM_SRC_PHP = array(
|
13 | 27 | 0 => "src/main.php",
|
14 | 28 | 1 => "src/ifmarchive.php",
|
15 | 29 | 2 => "src/htpasswd.php"
|
16 | 30 | );
|
17 | 31 |
|
18 |
| -// output files |
19 |
| -define( "IFM_STANDALONE", "ifm.php" ); |
20 |
| -define( "IFM_STANDALONE_GZ", "build/ifm.min.php" ); |
21 |
| -define( "IFM_LIB", "build/libifm.php" ); |
22 |
| - |
23 | 32 | // get options
|
24 | 33 | $options = getopt( null, array( "language::" ) );
|
25 | 34 |
|
26 | 35 | // process languages
|
27 |
| -$vars['languages'] = isset( $options['language'] ) ? explode( ',', $options['language'] ) : array( "en" ); |
| 36 | +$vars['languages'] = isset( $options['language'] ) ? explode( ',', $options['language'] ) : array( "en", "ru" ); |
28 | 37 | $vars['defaultlanguage'] = $vars['languages'][0];
|
29 | 38 | $vars['languageincludes'] = "";
|
30 | 39 | foreach( $vars['languages'] as $l ) {
|
|
49 | 58 | }
|
50 | 59 | $compiled = join( $compiled );
|
51 | 60 |
|
| 61 | +$compiled = str_replace( "IFM_ASSETS", file_get_contents( $IFM_ASSETS ), $compiled ); |
52 | 62 | /**
|
53 | 63 | * Process file includes
|
54 | 64 | */
|
|
82 | 92 | foreach( $includes as $var )
|
83 | 93 | $compiled = str_replace( $var[0], $vars[$var[1]], $compiled );
|
84 | 94 |
|
85 |
| -/** |
86 |
| - * Build versions |
87 |
| - */ |
| 95 | +$compiled = str_replace( 'IFM_VERSION', IFM_VERSION, $compiled ); |
| 96 | + |
| 97 | +if (!is_dir(IFM_RELEASE_DIR)){ |
| 98 | + mkdir(IFM_RELEASE_DIR); |
| 99 | +} |
| 100 | + |
88 | 101 | // build standalone ifm
|
89 |
| -file_put_contents( IFM_STANDALONE, $compiled ); |
90 |
| -file_put_contents( IFM_STANDALONE, ' |
| 102 | +file_put_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : 'simple.') . IFM_STANDALONE, $compiled ); |
| 103 | +file_put_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : 'simple.') . IFM_STANDALONE, ' |
91 | 104 | /**
|
92 | 105 | * start IFM
|
93 | 106 | */
|
94 | 107 | $ifm = new IFM();
|
95 | 108 | $ifm->run();
|
96 | 109 | ', FILE_APPEND );
|
97 | 110 |
|
98 |
| -/* // build compressed ifm |
| 111 | +// build compressed ifm |
99 | 112 | file_put_contents(
|
100 |
| - IFM_STANDALONE_GZ, |
| 113 | + IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : 'simple.') . IFM_STANDALONE_GZ, |
101 | 114 | '<?php eval( gzdecode( file_get_contents( __FILE__, false, null, 85 ) ) ); exit(0); ?>'
|
102 |
| - . gzencode( file_get_contents( "ifm.php", false, null, 5 ) ) |
| 115 | + . gzencode( file_get_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : 'simple.') .IFM_STANDALONE, false, null, 5 ) ) |
103 | 116 | );
|
104 |
| - */ |
105 |
| - |
106 | 117 | // build lib
|
107 |
| -file_put_contents( IFM_LIB, $compiled ); |
| 118 | +file_put_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : 'simple.') . IFM_LIB, $compiled ); |
0 commit comments