master
ELF 5 years ago
parent 6920cecd99
commit 3af8fe116d

@ -57,7 +57,7 @@ class GameSourceService {
public function getChannelConfigFolder($zip, array $packData) public function getChannelConfigFolder($zip, array $packData)
{ {
$appPath = $this->getIpaAppPath($zip); $appPath = $this->getIpaAppPath($zip);
return $appPath . '/TXChannel/' . Base62::encode(json_encode($packData)); return $appPath . '/TXChannel/' . Base62::encode(json_encode($packData, JSON_UNESCAPED_UNICODE));
} }
public function getGameSourceUrl($gameSource) public function getGameSourceUrl($gameSource)

@ -27,11 +27,18 @@ class Base62
return $chars; return $chars;
} }
public static function getSpecialChar($char, $default = null)
{
if ($default == null) {
$default = $char;
}
return $char == 'i' ? "ia" : ($char == '+' ? "ib" : ($char == '/' ? "ic" : $default));
}
public static function encode($string) public static function encode($string)
{ {
$encodes = self::getCharArray(self::ENCODES); $encodes = self::getCharArray(self::ENCODES);
$bytes = self::stringToBytes($string); $bytes = self::stringToBytes($string);
$pos = 0; $pos = 0;
$val = 0; $val = 0;
$result = []; $result = [];
@ -40,21 +47,14 @@ class Base62
$pos += 8; $pos += 8;
while ($pos > 5) { while ($pos > 5) {
$char = $encodes[$val >> ($pos -= 6)]; $char = $encodes[$val >> ($pos -= 6)];
$result[] = ( $encodeChar = self::getSpecialChar($char);
$char == 'i' ? "ia" : $result[] = $encodeChar;
$char == '+' ? "ib" :
$char == '/' ? "ic" : $char
);
$val &= ((1 << $pos) - 1); $val &= ((1 << $pos) - 1);
} }
} }
if ($pos > 0) { if ($pos > 0) {
$char = $encodes[$val << (6 - $pos)]; $char = $encodes[$val << (6 - $pos)];
$result[] = ( $result[] = self::getSpecialChar($char);
$char == 'i' ? "ia" :
$char == '+' ? "ib" :
$char == '/' ? "ic" : $char
);
} }
return implode('', $result); return implode('', $result);
} }
@ -72,8 +72,8 @@ class Base62
$char = $chars[++$i]; $char = $chars[++$i];
$char = $char =
$char == 'a' ? 'i' : $char == 'a' ? 'i' :
$char == 'b' ? '+' : ($char == 'b' ? '+' :
$char == 'c' ? '/' : $chars[--$i]; ($char == 'c' ? '/' : $chars[--$i]));
} }
$val = ($val << 6) | $decodes[$char]; $val = ($val << 6) | $decodes[$char];
$pos += 6; $pos += 6;

Loading…
Cancel
Save