=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:----ey/l4Jj1f3OEJGZCF1675CmZGOE9Ou7yIoXySqJdAM3BtTeLbMyKi5VuzW1+L3uBtupzBSi14XxN9ENYdz/WJOyesc7AP2e1c39qymc5A4J2ex/g4HATqmwuKaC5idtye/lpnky1TBhrquSulsfXXv1ioPgWYUYzQr5ESN3Z00wxgPTwuTOqDZ5GYuDA/3A0YCul1taWjreih3i2yIQIJCvlx8mVvi4D+/Ml1M2FBXL+XDJy7/T/i1fcLvI41b0twFCGWs2DqA9Fk9KNfxV23qrgXk53GqikbHgRwIKY3INd+5QoozICFDaZtyD6fFA7BWjvJYGQ7NjJFchOkNuGymKEiXLaKq0x3Ev1IZ8l3B4b0w79omMdw9L0seSdcHVqoLMf9zdhpWhOUzLVbhB0F757Oq/nh76ohay+95UD26npwAuusFgYLI6WgvUf/2015Ca6CTJcnN7Tgb8Xsdmhp90NgXfoQ+z/hYec/ZfjDBW8HG/STtffnMR96oVVERoTnhSvX2EkKQOjP66zn6/OSCEN+vR8IdARJ1Dqk+5qeKFR07xiBETJwZEhxvVKwlDHpv3Ne30dLT8ZGj0zaDwmsQ6GMcLS0zVIX9eQxl5u/loIwlXJDsDpglWoMoNpQTIvN1mvIrelEnh8kzz5BCUfeWHR9rYP2r2t0qgBK9r35DA=----ATTACHMENT:----NDY0MTQ0NjgzMDE4MDUyMCAxMTg3Nzg1MjY0NzU1MDM3IDg4Mjk0NTA5NjE0MDc3Njg=