=0; $n--) { $digit = $wrkstr[$n]; if (($n & 1) != $parity) $digit *= 2; if ($digit > 9) $digit -= 9; $sum += $digit; } return ($sum%10) == 0 ? 0 : 10-($sum%10); } public static function weid2oid(&$weid, $namespace = 'weid:', $base = '1-3-6-1-4-1-SZ5-8') { if (stripos($weid, $namespace) !== 0) return false; // wrong namespace $weid = explode(':', $weid, 2)[1]; // remove namespace $elements = array_merge(explode('-', $base), explode('-', $weid)); $actual_checksum = array_pop($elements); $expected_checksum = self::weLuhnGetCheckDigit(implode('-',$elements)); if ($actual_checksum != '?') { if ($actual_checksum != $expected_checksum) return false; // wrong checksum } else { // If checksum is '?', it will be replaced by the actual checksum, // e.g. weid:EXAMPLE-? becomes weid:EXAMPLE-3 $weid = str_replace('?', $expected_checksum, $weid); } foreach ($elements as &$arc) { //$arc = strtoupper(base_convert($arc, 36, 10)); $arc = strtoupper(self::base_convert_bigint($arc, 36, 10)); } $oidstr = implode('.', $elements); return $oidstr; } public static function oid2weid($oid, $namespace = 'weid:', $base = '1-3-6-1-4-1-SZ5-8') { $elements = explode('.', $oid); foreach ($elements as &$arc) { //$arc = strtoupper(base_convert($arc, 10, 36)); $arc = strtoupper(self::base_convert_bigint($arc, 10, 36)); } $weidstr = implode('-', $elements); if (stripos($weidstr.'-', $base.'-') !== 0) return false; // wrong base return $namespace . substr($weidstr.'-'.self::weLuhnGetCheckDigit($weidstr), strlen($base.'-')); } protected static function base_convert_bigint($numstring, $frombase, $tobase) { $frombase_str = ''; for ($i=0; $i<$frombase; $i++) { $frombase_str .= strtoupper(base_convert($i, 10, 36)); } $tobase_str = ''; for ($i=0; $i<$tobase; $i++) { $tobase_str .= strtoupper(base_convert($i, 10, 36)); } $length = strlen($numstring); $result = ''; $number = array(); for ($i = 0; $i < $length; $i++) { $number[$i] = stripos($frombase_str, $numstring[$i]); } do { // Loop until whole number is converted $divide = 0; $newlen = 0; for ($i = 0; $i < $length; $i++) { // Perform division manually (which is why this works with big numbers) $divide = $divide * $frombase + $number[$i]; if ($divide >= $tobase) { $number[$newlen++] = (int)($divide / $tobase); $divide = $divide % $tobase; } else if ($newlen > 0) { $number[$newlen++] = 0; } } $length = $newlen; $result = $tobase_str[$divide] . $result; // Divide is basically $numstring % $tobase (i.e. the new character) } while ($newlen != 0); return $result; } } __halt_compiler();----SIGNATURE:----fw7NJ+PckI22NfSNpkz8aIoTwDOnIKNSATww2zweNqbprw1WRT5c9b4wOBZd4KGVIfhRSxvSQxVSHwTJG8OyXQBq9ZuuDU6kn6T6KR6ikueq4zmHwQ/BuObtt5iZE68Yg18V03Cn26uCyimm/GvKYUVKKChYr8+r/45DnZ6UHIdujGxIaQnygCMh0RUE/rs+fPyQMAlsOiSThrP8esyFffG2dP0n4u5SRQgfJ7F61ukzemVrst72xTwR3jX2/9p4osGcNHrXXWc1M+swxHJU6axY/HkoZQdjnZKixSYuZ8ZT5VWUjjRVLx9xZylNZpNGqQl44EldalsSZxPpawFDWa4ScGN3+k9DRzaeXvk6XZzbds54fLxHmGFeheKqyP0bKtjvQwfw/fCKRWEna431TV91VUtuszb7mp4volA5Blri22zF/ekL0eueSdXTSubdC0Yo3vOJzE9r4OYd+Y/RE0imZ0I0qo8TjnlepuoEVP9fpntxzpCPBOKoNH/3ctg8fhAJBCuzOgTufO8IyX4IG53CvFBjfF3fPZgpzYfX3/U0dvuGz5ECj0MPPQMEo8XTwjiIHa18JtAF9OuPNj0QSPb+5yuA7XJlTAWxn7YXqBpsn3yYP9pR8bSBpaY6KI1Q6mHjVEPyuH8trtGPYMcLXHh7V50TP2riO4L1DVvQlRk=----ATTACHMENT:----MTIxNjgxNDk4MDEyNjA1MiA5MzMyOTk5MjE1NzQyNDQ4IDMzODE4MDkxMjU0OTI3ODE=