コード例 #1
0
$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})";
            }
            ####################################################
            $errors++;
コード例 #2
0
ファイル: test.php プロジェクト: brittoavr/php-iban
 $countrycode = $country['country'];
 # start section
 print "[{$countrycode}: " . 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";
 # 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";
 # 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";
     $errors++;
コード例 #3
0
ファイル: test.php プロジェクト: globalcitizen/php-iban
 }
 # 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";
コード例 #4
0
ファイル: php-iban.php プロジェクト: gitter-badger/php-iban
function _iban_get_info($iban, $code)
{
    $country = iban_get_country_part($iban);
    return _iban_country_get_info($country, $code);
}
コード例 #5
0
ファイル: oophp-iban.php プロジェクト: globalcitizen/php-iban
 public function Country($iban = '')
 {
     return iban_get_country_part($this->iban);
 }
コード例 #6
0
ファイル: php-iban.php プロジェクト: globalcitizen/php-iban
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 '';
}