#!/usr/bin/env php "src/main.php", 1 => "src/ifmarchive.php", 2 => "src/htpasswd.php" ); // get options $options = getopt(null, array("language::", "languages::", "cdn::")); // process languages $langs = array_unique(array_merge(explode(",", join(",", [$options['language']])), explode(",", join(",", [$options['languages']])))); print_r($langs); if (in_array("all", $langs)) { $available_languages = array_map( function($i) { return str_replace("src/i18n/", "", str_replace(".json", "", $i)); }, glob("src/i18n/*.json") ); // default language is english, if not given if ($langs[0] == 'all' || !file_exists($lang[0])) $default_lang = "en"; else $default_lang = $lang[0]; unset($available_langs[array_search($default_lang, $available_langs)]); $include_langs = array_merge($default_lang, $available_langs); } print_r($options['language']); print_r($include_langs); die(); // process languages $vars['languages'] = isset($options['language']) ? explode(',', $options['language']) : ["all"]; $vars['defaultlanguage'] = $vars['languages'][0]; $vars['languageincludes'] = ""; foreach ($vars['languages'] as $l) if (file_exists("src/i18n/".$l.".json")) $vars['languageincludes'] .= '$i18n["'.$l.'"] = <<<\'f00bar\'' . "\n" . file_get_contents( "src/i18n/".$l.".json" ) . "\n" . 'f00bar;' . "\n" . '$i18n["'.$l.'"] = json_decode( $i18n["'.$l.'"], true );' . "\n" ; else print "WARNING: Language file src/i18n/".$l.".json not found.\n"; // Concat PHP Files $compiled = array( "run(); ', FILE_APPEND ); // build compressed ifm file_put_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : 'simple.') . IFM_STANDALONE_GZ, '' . gzencode( file_get_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : 'simple.') .IFM_STANDALONE, false, null, 5 ) ) ); // build lib file_put_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : 'simple.') . IFM_LIB, $compiled );