1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
24: class Jyxo_Input_Validator_IsIban extends Jyxo_Input_Validator_AbstractValidator
25: {
26: 27: 28: 29: 30: 31:
32: public function isValid($value)
33: {
34:
35: $iban = preg_replace('~\s+~', '', (string) $value);
36:
37: if (!preg_match('~^CZ(\d{2})(\d{4})(\d{6})(\d{10})$~i', $iban, $matches)) {
38: return false;
39: }
40:
41: list(, $control, $bankCode, $prefix, $base) = $matches;
42:
43:
44: if (!Jyxo_Input_Validator::isBankAccountNumber(sprintf('%s-%s/%s', $prefix, $base, $bankCode))) {
45: return false;
46: }
47:
48:
49: $temp = $bankCode . $prefix . $base . '1235' . $control;
50: $mod = (int) substr($temp, 0, 9) % 97;
51: $mod = (int) ($mod . substr($temp, 9, 7)) % 97;
52: $mod = (int) ($mod . substr($temp, 16, 7)) % 97;
53: $mod = (int) ($mod . substr($temp, 23)) % 97;
54: if (1 !== $mod) {
55: return false;
56: }
57:
58: return true;
59: }
60: }
61: