#!/usr/bin/env php "src/main.php", 1 => "src/ifmarchive.php", 2 => "src/htpasswd.php" ]; // get options $options = getopt(null, ["language::", "languages::", "lang::", "cdn"]); // build CDN version? if (isset($options['cdn'])) { define("IFM_CDN", true); } else { define("IFM_CDN", false); } // process languages $langs = []; foreach ($options as $key => $value) { if (substr($key, 0, 4) == "lang") { $langs = array_merge($langs, explode(",", $value)); } } $langs = array_unique($langs); if (!empty($langs)) { $vars['default_lang'] = ($langs[0] == "all") ? "en" : $langs[0]; } else { $vars['default_lang'] = "en"; } // ensure english is available, as it gets merged with the other languages // in case of missing keys in other languages. if (!in_array("all", $langs) || !in_array("en", $langs)) { array_push($langs, "en"); } if (in_array("all", $langs)) $langs = array_map( function ($lang_file) { return pathinfo($lang_file)['filename']; }, glob("src/i18n/*.json") ); $vars['languageincludes'] = ""; foreach ($langs 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 = ["run(); ', FILE_APPEND); // build compressed ifm file_put_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') . IFM_STANDALONE_GZ, '' . gzencode(file_get_contents(IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') . IFM_STANDALONE, false, null, 5)) ); // build lib file_put_contents(IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') . IFM_LIB, $compiled);