/**
  * Process Games Database Configuration With Multi-Patch And Multi-Realm Support
  * @param $Data
  * @param $ExistingArray
  * @return array
  */
 private function processGameDatabase($Data, $ExistingArray)
 {
     $Name = $this->getPatchMatch($Data['game_patch'])['dbname'];
     $KeyName = "";
     if (empty($ExistingArray)) {
         $KeyName = $Name . 'One';
     } else {
         foreach ($ExistingArray as $Key => $Value) {
             $Reversed = strrev($Key);
             $Counter = strrev(substr($Reversed, 0, strcspn($Reversed, 'ABCDEFGHJIJKLMNOPQRSTUVWXYZ') + 1));
             if (array_key_exists($Name . $Counter, $ExistingArray)) {
                 $intCounter = Text::convertTextToNumber($Counter);
                 $intCounter = $intCounter + 1;
                 $textCounter = Text::convertNumberToText($intCounter);
                 $KeyName = $Name . ucfirst($textCounter);
             } else {
                 $KeyName = $Name . 'One';
             }
         }
     }
     $ConfigurationString = PHP_EOL . '// ' . $KeyName . ' Database Configuration' . PHP_EOL;
     $DBConfiguration = [];
     $SoapConfiguration = [];
     $SiteConfiguration = [];
     foreach ($Data as $Key => $Value) {
         if (strstr($Key, 'database')) {
             $DBConfiguration[str_replace('database_', '', $Key)] = $Value;
         } elseif (strstr($Key, 'soap')) {
             $SoapConfiguration[str_replace('soap_', '', $Key)] = $Value;
         } else {
             $SiteConfiguration[$Key] = $Value;
         }
     }
     foreach ($DBConfiguration as $Key => $Value) {
         $ConfigurationString .= '$FCCore[\'' . $KeyName . '\'][\'Database\'][\'' . $Key . '\'] = \'' . $Value . '\';' . PHP_EOL;
     }
     $ConfigurationString .= PHP_EOL;
     foreach ($SoapConfiguration as $Key => $Value) {
         $ConfigurationString .= '$FCCore[\'' . $KeyName . '\'][\'soap\'][\'' . $Key . '\'] = \'' . $Value . '\';' . PHP_EOL;
     }
     $ConfigurationString .= PHP_EOL;
     foreach ($SiteConfiguration as $Key => $Value) {
         $ConfigurationString .= '$FCCore[\'' . $KeyName . '\'][\'site\'][\'' . str_replace('site_', '', $Key) . '\'] = \'' . $Value . '\';' . PHP_EOL;
     }
     return ['Key' => $KeyName, 'Config' => $ConfigurationString];
 }
Esempio n. 2
0
 public static function convertNumberToText($Number)
 {
     $Hyphen = '-';
     $Conjunction = ' and ';
     $Separator = ', ';
     $Negative = 'negative ';
     $Decimal = ' point ';
     $Dictionary = [0 => 'zero', 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten', 11 => 'eleven', 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen', 16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen', 19 => 'nineteen', 20 => 'twenty', 30 => 'thirty', 40 => 'fourty', 50 => 'fifty', 60 => 'sixty', 70 => 'seventy', 80 => 'eighty', 90 => 'ninety', 100 => 'hundred', 1000 => 'thousand', 1000000 => 'million', 1000000000 => 'billion', 1000000000000 => 'trillion', 1000000000000000 => 'quadrillion', 1000000000000000000 => 'quintillion'];
     if (!is_numeric($Number)) {
         return false;
     }
     if ($Number >= 0 && (int) $Number < 0 || (int) $Number < 0 - PHP_INT_MAX) {
         trigger_error('convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING);
         return false;
     }
     if ($Number < 0) {
         return $Negative . Text::convertNumberToText(abs($Number));
     }
     $String = $Fraction = null;
     if (strpos($Number, '.') !== false) {
         list($Number, $Fraction) = explode('.', $Number);
     }
     switch (true) {
         case $Number < 21:
             $String = $Dictionary[$Number];
             break;
         case $Number < 100:
             $Tens = (int) ($Number / 10) * 10;
             $Units = $Number % 10;
             $String = $Dictionary[$Tens];
             if ($Units) {
                 $String .= $Hyphen . $Dictionary[$Units];
             }
             break;
         case $Number < 1000:
             $Hundreds = $Number / 100;
             $Remainder = $Number % 100;
             $String = $Dictionary[$Hundreds] . ' ' . $Dictionary[100];
             if ($Remainder) {
                 $String .= $Conjunction . Text::convertNumberToText($Remainder);
             }
             break;
         default:
             $baseUnit = pow(1000, floor(log($Number, 1000)));
             $numBaseUnits = (int) ($Number / $baseUnit);
             $Remainder = $Number % $baseUnit;
             $String = Text::convertNumberToText($numBaseUnits) . ' ' . $Dictionary[$baseUnit];
             if ($Remainder) {
                 $String .= $Remainder < 100 ? $Conjunction : $Separator;
                 $String .= Text::convertNumberToText($Remainder);
             }
             break;
     }
     if (null !== $Fraction && is_numeric($Fraction)) {
         $String .= $Decimal;
         $Words = [];
         foreach (str_split((string) $Fraction) as $Number) {
             $words[] = $Dictionary[$Number];
         }
         $String .= implode(' ', $Words);
     }
     return $String;
 }