Esempio n. 1
0
 public static function init()
 {
     self::$win = substr(PHP_OS, 0, 3) == 'WIN';
     self::$hasReadline = function_exists('readline_callback_handler_install');
     if ($_ = getopt('d', ['log::', 'locales::', 'mpqDataDir::', 'delete'])) {
         // optional logging
         if (!empty($_['log'])) {
             self::$logFile = trim($_['log']);
         }
         // alternative data source (no quotes, use forward slash)
         if (!empty($_['mpqDataDir'])) {
             self::$srcDir = str_replace(['\\', '"', '\''], ['/', '', ''], $_['mpqDataDir']);
         }
         // optional limit handled locales
         if (!empty($_['locales'])) {
             // engb and enus are identical for all intents and purposes
             $from = ['engb', 'esmx'];
             $to = ['enus', 'eses'];
             $_['locales'] = str_ireplace($from, $to, strtolower($_['locales']));
             self::$locales = array_intersect(Util::$localeStrings, explode(',', $_['locales']));
         }
         if (isset($_['d']) || isset($_['delete'])) {
             self::$tmpDBC = true;
         }
     }
     if (!self::$locales) {
         self::$locales = array_filter(Util::$localeStrings);
     }
     // restrict actual locales
     foreach (self::$locales as $idx => $str) {
         if (!defined('CFG_LOCALES') || CFG_LOCALES & 1 << $idx) {
             self::$localeIds[] = $idx;
         }
     }
 }