0) { print ", "; } print "ISO3166-1 alpha-2:$iso3166countrycode"; } if($codes_output==0) { print "no IANA or ISO3166-1 alpha-2 codes"; } print "): " . iban_country_get_country_name($countrycode) . "]\n"; # output remaining country properties print "Is a SEPA member? "; if(iban_country_is_sepa($countrycode)) { print "Yes"; } else { print "No"; } print ".\n"; # central bank print "Central Bank: "; $central_bank_name = iban_country_get_central_bank_name($countrycode); if($central_bank_name!='') { print $central_bank_name; $central_bank_url = iban_country_get_central_bank_url($countrycode); if($central_bank_url!='') { print " ($central_bank_url)"; } } else { print "None."; } print "\n"; # parent_registrar print "Has own team of bureaucrats? "; $parent_registrar = iban_country_get_parent_registrar($countrycode); if($parent_registrar!='') { print "No (outsources to the wise experts of '" . $parent_registrar . "')\n"; } else { print "Yes.\n"; } # official currency print "Official currency: "; $official_currency = iban_country_get_currency_iso4217($countrycode); if($official_currency == '') { print "None."; } else { print $official_currency; } print "\n"; # get example iban $iban = $country['iban_example']; # output example iban properties one by one print "Example IBAN: " . iban_to_human_format($iban) . "\n"; print " - country " . iban_get_country_part($iban) . "\n"; print " - checksum " . iban_get_checksum_part($iban) . "\n"; print " - bban " . iban_get_bban_part($iban) . "\n"; print " - bank " . iban_get_bank_part($iban) . "\n"; print " - branch " . iban_get_branch_part($iban) . "\n"; print " - account " . iban_get_account_part($iban) . "\n"; $nationalchecksum = iban_get_nationalchecksum_part($iban); print " - natcksum " . $nationalchecksum . "\n"; # if a national checksum was present, validate it $supposed_checksum = iban_find_nationalchecksum($iban); if($supposed_checksum!='') { if($supposed_checksum != $nationalchecksum) { print " (INVALID! Should be '" . $supposed_checksum . "'!)\n"; exit(1); } else { print " (National checksum manually validated.)\n"; } } # also check 'verify' codepath $result = iban_verify_nationalchecksum($iban); if($result!='') { if($result!=true) { print " (ERROR: iban_verify_nationalchecksum($iban) did not validate!)\n"; exit(1); } else { print " (National checksum automatically validated.)\n"; } } # also check 'set' codepath $fixed_iban = iban_set_nationalchecksum($iban); if($fixed_iban != '') { if($fixed_iban != $iban) { print " (ERROR: iban_set_nationalchecksum('$iban') returned '$fixed_iban')\n"; exit(1); } else { print " (Correction of national checksum functionality validated.)\n"; } } # output all properties #$parts = iban_get_parts($iban); #print_r($parts); # verify print "\nChecking validity... "; if(verify_iban($iban)) { print "IBAN $iban is valid.\n"; } else { print "ERROR: IBAN $iban is invalid.\n"; $correct = iban_set_checksum($iban); if($correct == $iban) { print " (checksum is correct, structure must have issues.)\n"; $machine_iban = iban_to_machine_format($iban); print " (machine format is: '$machine_iban')\n"; $country = iban_get_country_part($machine_iban); print " (country is: '$country')\n"; if(strlen($machine_iban)!=iban_country_get_iban_length($country)) { print " (ERROR: length of '" . strlen($machine_iban) . "' does not match expected length for country's IBAN '" . iban_country_get_iban_length($country) . "'.)"; } $regex = '/'.iban_country_get_iban_format_regex($country).'/'; if(!preg_match($regex,$machine_iban)) { print " (ERROR: did not match regular expression '" . $regex . "')\n"; } } else { print " (correct checksum version would be '" . $correct . "')\n"; } $errors++; exit(1); } print "\n"; } exit($errors); ?>