| 1 | 
        
            2
         | 
        
            Manuela
         | 
        <?php
  | 
      
      
        | 2 | 
        
         | 
        
         | 
        // -----
  | 
      
      
        | 3 | 
        
         | 
        
         | 
            $getLanguage = function($sFile) {
 | 
      
      
        | 4 | 
        
         | 
        
         | 
                $aRetval = null;
  | 
      
      
        | 5 | 
        
         | 
        
         | 
                $language_code = $language_name = '';
  | 
      
      
        | 6 | 
        
         | 
        
         | 
                include $sFile;
  | 
      
      
        | 7 | 
        
         | 
        
         | 
                if ($language_code && $language_name) {
 | 
      
      
        | 8 | 
        
         | 
        
         | 
                    $aRetval = ['code' => $language_code, 'name' => $language_name];
  | 
      
      
        | 9 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 10 | 
        
         | 
        
         | 
                return $aRetval;
  | 
      
      
        | 11 | 
        
         | 
        
         | 
            };
  | 
      
      
        | 12 | 
        
         | 
        
         | 
        // -----
  | 
      
      
        | 13 | 
        
         | 
        
         | 
            if (!defined('WB_PATH')){define('WB_PATH', (dirname(__DIR__)));}
 | 
      
      
        | 14 | 
        
         | 
        
         | 
            $aMatches = [];
  | 
      
      
        | 15 | 
        
         | 
        
         | 
            $sOutput = PHP_EOL;
  | 
      
      
        | 16 | 
        
         | 
        
         | 
            $sDefaultLang = isset($_SESSION['default_language']) ? $_SESSION['default_language'] : 'EN';
  | 
      
      
        | 17 | 
        
         | 
        
         | 
            $sLangDir = str_replace('\\', '/', dirname(__DIR__).'/languages/');
 | 
      
      
        | 18 | 
        
         | 
        
         | 
            $sOldWorkingDir = getcwd();
  | 
      
      
        | 19 | 
        
         | 
        
         | 
            chdir($sLangDir);
  | 
      
      
        | 20 | 
        
         | 
        
         | 
            foreach(glob('??.php') as $sFilename) {
 | 
      
      
        | 21 | 
        
         | 
        
         | 
                if (preg_match('/[A-Z]{2}\.php$/s', $sFilename) && is_readable($sLangDir.$sFilename)) {
 | 
      
      
        | 22 | 
        
         | 
        
         | 
                    if (!($aMatch = $getLanguage($sLangDir.$sFilename))) { continue; }
 | 
      
      
        | 23 | 
        
         | 
        
         | 
                    $aMatch['status'] = ($aMatch['code'] == $sDefaultLang);
  | 
      
      
        | 24 | 
        
         | 
        
         | 
                    $sOutput .= '<option value="'.$aMatch['code'].'" '
  | 
      
      
        | 25 | 
        
         | 
        
         | 
                              . ($aMatch['status'] ? 'selected="selected"' : '').'>'
  | 
      
      
        | 26 | 
        
         | 
        
         | 
                              . $aMatch['name'].'</option>'.PHP_EOL;
  | 
      
      
        | 27 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 28 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 29 | 
        
         | 
        
         | 
            chdir($sOldWorkingDir);
  | 
      
      
        | 30 | 
        
         | 
        
         | 
            $sOutput .= '</select>'.PHP_EOL;
  | 
      
      
        | 31 | 
        
         | 
        
         | 
            // output Language options
  | 
      
      
        | 32 | 
        
         | 
        
         | 
            echo $sOutput;
  | 
      
      
        | 33 | 
        
         | 
        
         | 
        
  | 
      
      
        | 34 | 
        
         | 
        
         | 
            if (sizeof($aMatches) > 0) {
 | 
      
      
        | 35 | 
        
         | 
        
         | 
                $sOutput = PHP_EOL;
  | 
      
      
        | 36 | 
        
         | 
        
         | 
                foreach ($aMatches as $aMatch) {
 | 
      
      
        | 37 | 
        
         | 
        
         | 
                    $sOutput .= '<option value="'.$aMatch['code'].'" '
  | 
      
      
        | 38 | 
        
         | 
        
         | 
                              . ($aMatch['status'] ? 'selected="selected"' : '').'>'
  | 
      
      
        | 39 | 
        
         | 
        
         | 
                              . $aMatch['name'].'</option>'.PHP_EOL;
  | 
      
      
        | 40 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 41 | 
        
         | 
        
         | 
                $sOutput .= '</select>'.PHP_EOL;
  | 
      
      
        | 42 | 
        
         | 
        
         | 
                // output Language options
  | 
      
      
        | 43 | 
        
         | 
        
         | 
                echo $sOutput;
  | 
      
      
        | 44 | 
        
         | 
        
         | 
                unset($sOutput);
  | 
      
      
        | 45 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 46 | 
        
         | 
        
         | 
            unset($sOutput, $aMatch, $getLanguage);
  |