MachineFormat() public method

public MachineFormat ( )
示例#1
0
 function calc($land, $kontonummer, $bankleitzahl, $ibanField, $bicField)
 {
     if ($kontonummer == "" or $bankleitzahl == "") {
         Red::alertD("Bitte tragen Sie Bankleitzahl und Kontonummer ein");
     }
     $url = "http://www.iban.de/iban-berechnen.html";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0', 'Referer: http://www.iban.de/iban-berechnen.html', 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8', 'X-Requested-With: XMLHttpRequest'));
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, "ibanrechnerCountry={$land}&ibanrechnerBlz={$bankleitzahl}&ibanrechnerKonto={$kontonummer}&ibanToolkit=ibanrechner");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $result = curl_exec($ch);
     curl_close($ch);
     $I = new IBAN(trim(str_replace("Die IBAN lautet: ", "", strip_tags($result))));
     $iban = $I->MachineFormat();
     $url = "https://www.s-bausparkasse.at/portal/if_ajax.asp";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, "mode=calc.ibanbic.listofbic&cuid=&alt_iban=&iban={$iban}&rechnername=IBAN%2FBIC-Rechner&currentpageid=87&berechnungsdaten=&autocalc=&getresult=&country={$land}&bank={$bankleitzahl}&account=" . str_pad($kontonummer, 10, "0", STR_PAD_LEFT));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $result = curl_exec($ch);
     curl_close($ch);
     $ex = explode("&&&", $result);
     $ex[0] = str_replace("listofbic==", "", strip_tags(trim($ex[0])));
     $ex[1] = str_replace("iban==", "", trim($ex[1]));
     $T = new HTMLTable(3, "Gefundene Ergebnisse");
     $T->weight("light");
     $T->maxHeight(400);
     $T->useForSelection(false);
     $T->setColWidth(1, 20);
     $T->addHeaderRow(array("", "BIC", "IBAN"));
     foreach (explode("\n", $ex[0]) as $bic) {
         $B = new Button("Diese Kombination verwenden", "arrow_right", "iconic");
         $T->addRow(array($B, trim($bic), $ex[1]));
         $T->addRowEvent("click", "\$j('[name={$ibanField}]').val('{$ex['1']}'); \$j('[name={$bicField}]').val('" . trim($bic) . "'); " . OnEvent::closePopup("IBANCalc"));
     }
     echo $T;
     #echo "<pre>";
     #echo htmlentities(print_r($ex, true));
     #echo($result);
     #echo "</pre>";
 }
示例#2
0
 print " - bank     " . $myIban->Bank() . "\n";
 print " - branch   " . $myIban->Branch() . "\n";
 print " - account  " . $myIban->Account() . "\n";
 # output all properties
 #$parts = $myIban->Parts();
 #print_r($parts);
 # verify
 print "\nChecking validity... ";
 if ($myIban->Verify()) {
     print "IBAN {$myIban->iban} is valid.\n";
 } else {
     print "ERROR: IBAN {$myIban->iban} is invalid.\n";
     $correct = $myIban->SetChecksum();
     if ($correct == $iban) {
         print "       (checksum is correct, structure must have issues.)\n";
         $machine_iban = $myIban->MachineFormat();
         print "        (machine format is: '{$machine_iban}')\n";
         $country = $myIban->Country();
         print "        (country is: '{$country}')\n";
         $myCountry = new IBANCountry($country);
         if (strlen($machine_iban) != $myCountry->IBANLength()) {
             print "        (ERROR: length of '" . strlen($machine_iban) . "' does not match expected length for country's IBAN '" . $myCountry->IBANLength() . "'.)";
         }
         $regex = '/' . $myCountry->IBANFormatRegex() . '/';
         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++;