function verify_and_format_iban($IBAN) { if (!verify_iban($IBAN)) { throw new Exception("IBAN {$IBAN} is ongeldig"); } return iban_to_machine_format($IBAN); }
function check_IBAN($iban) { $machine_iban = iban_to_machine_format($iban); if (verify_iban($machine_iban)) { $array['result'] = false; $array['human_IBAN'] = iban_to_human_format($machine_iban); echo json_encode($array); } else { $array['result'] = true; $array['message'] = "Nesprávny iban"; echo json_encode($array); } }
$list_file = $argv[1]; $errors = 0; if (!($raw_list = file_get_contents($list_file))) { print "Error opening list file '{$list_file}'.\n"; exit(1); } $list = preg_split("/[\r\n]+/", $raw_list); $results = array(); foreach ($list as $iban) { if ($iban != '') { # let's check it print $iban . " ... "; if (!verify_iban($iban)) { print "FAILED"; ########## try to provide better output ############# $iban = iban_to_machine_format($iban); $country = iban_get_country_part($iban); $observed_length = strlen($iban); $expected_length = iban_country_get_iban_length($country); if ($observed_length != $expected_length) { print " (length {$observed_length} does not match expected length {$expected_length} for country {$country})"; } $checksum = iban_get_checksum_part($iban); if (!iban_verify_checksum($iban)) { print " (checksum {$checksum} invalid)"; } $regex = '/' . iban_country_get_iban_format_regex($country) . '/'; if (!preg_match($regex, $iban)) { print " (does not match regex {$regex} for country {$country})"; } ####################################################
function iban_get_account_part($iban) { $iban = iban_to_machine_format($iban); $country = iban_get_country_part($iban); $start = iban_country_get_branchid_stop_offset($country); if ($start == '') { $start = iban_country_get_bankid_stop_offset($country); } if ($start != '') { $bban = iban_get_bban_part($iban); return substr($bban, $start + 1); } return ''; }
public function MachineFormat() { return iban_to_machine_format($this->iban); }
function iban_get_nationalchecksum_part($iban) { $iban = iban_to_machine_format($iban); $country = iban_get_country_part($iban); $start = iban_country_get_nationalchecksum_start_offset($country); if ($start == '') { return ''; } $stop = iban_country_get_nationalchecksum_stop_offset($country); if ($stop == '') { return ''; } $bban = iban_get_bban_part($iban); return substr($bban, $start, $stop - $start + 1); }
function _iban_nationalchecksum_implementation($iban, $mode) { if ($mode != 'set' && $mode != 'find' && $mode != 'verify') { return ''; } # blank value on return to distinguish from correct execution $iban = iban_to_machine_format($iban); $country = iban_get_country_part($iban); if (strlen($iban) != iban_country_get_iban_length($country)) { return ''; } $function_name = '_iban_nationalchecksum_implementation_' . strtolower($country); if (function_exists($function_name)) { return $function_name($iban, $mode); } return ''; }