Biciban.php

Gesponsorde koppelingen

PHP script bestanden

  1. Biciban.php
  2. bankfuncties.php

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<?php
class Biciban {
  //Fortis is ABN geworden
  //ASN en SNS hebben dezelfde BIC, ASN is onderdeel van SNS dus ASN niet in de array $babic
  //Dsb bestaat vermoedelijk niet meer maar nog in de array $babic
  //Friesland bank wordt ooit RABO
  //bron wat BIC betreft http://www.theswiftcodes.com/netherlands-2/ , BIC-code altijd in uppercase
  //Slechts voor nederlanse rekeningnummers!!!!!!!!!!!!!!!!!
  //autheur Rene Geul , geen copyrights = open software
  //de BIC is in wezen de verkorte notatie van de Swift code pos 1..4 is bank pos 5..6 is land
  //dit is een class en er is geen echte pogingen gedaan om te voldoen aan allerlei OOP regels
  //er zijn 4 methoden die gebruikt kunnen worden
  //-1 generate_select_string
  //   geen input
  //   returns
  //    een string die een select bevat waar alle banken in staan
  //                      de select heeft options waar in de value de BIC staat
  //                      de select heeft ook "selected = selected" bij een option indien
  //                      de waarde al een keer is geselecteerd in een form die
  //                      gebruik maakt van de select_string die uiteraard met een echo
  //                      in het script staat
  //                      name en id van de select = "Banksel"
  //    voorbeeld :$objectje = new Biciban();
  //               $echo_string = objectje->generate_select_string;
  //               echo $echo_string;
  //-2 invoer_voor_iban
  //   input
  //   -de bic van de bank, maak gebruik van $_POST['Banksel'] indien select_string is gebruikt
  //   -het rekeningnummer bijvoorbeeld $_POST['Reknr']
  //   returns
  //    een string die
  //    -de IBAN bevat of
  //    -een foutmelding, de string begint dan met een "!"
  //-3 banknaam
  //   input
  //    de BIC die wordt naar uppercase gezet
  //   returns
  //    de banknaam of "onbekend" indien de BIC niet bekend is
  //-4 bepaal_11_proef
  //   input
  //    een rekeningnummer
  //   returns
  //    boolean true of false
  //    true indien de input voldoet aan de 11-proef
  //-------------------------------------------------------------------------------------------------------------  
  //beschrijving van berekening IBAN zie http://nl.wikipedia.org/wiki/International_Bank_Account_Number
  //controledigits altijd 2 posities dus geen "4" maar "04"
  //beschrijving 11-proef zie http://nl.wikipedia.org/wiki/Elfproef
  //-------------------------------------------------------------------------------------------------------------
  //                      BIC      =>  Naam vd bank

  private $babic = array('ABNANL'  => 'Abn Amro' ,
                         'AEGONL'  => 'Aegon bank' ,
                         'CEBUNL'  => 'C & E Bankiers' ,
                         'CITINL'  => 'Citybank International' ,
                         'FVLBNL'  => 'F. van Lanschot Bankiers' ,
                         'FTSBNL'  => 'Fortis bank' ,
                         'FRBKNL'  => 'Friesland bank' ,
                         'INGBNL'  => 'Ing bank' ,
                         'RABONL'  => 'Rabobank' ,
                         'SNSBNL'  => 'Sns en Asn bank',
//                       'SNSBNL'  => 'Asn bank(=Sns bank)',
                         'RBOSNL'  => 'Royal bank of Scotland',
                         'AHBKNL'  => 'Achmea Hypotheek bank',
                         'ARBNNL'  => 'Achmea Retail bank',
                         'AENVNL'  => 'Aegon NV',
                         'AKBKNL'  => 'Akbank',
                         'AMSCNL'  => 'Amstel Securities',
                         'STOLNL'  => 'Amsterdam Trade bank',
                         'ANDLNL'  => 'Anadolubank Nederland',
                         'ABPTNL'  => 'Apg Algemene Pensioen Groep',
                         'ARAMNL'  => 'Aramco Overseas Company',
                         'AZLHNL'  => 'Azl',
                         'INSINL'  => 'Bank Insinger de Beaufort',
                         'BKMGNL'  => 'Bank Mendes Gans',
                         'BOFANL'  => 'Bank of America',
                         'BKCHNL'  => 'Bank of China',
                         'BOTKNL'  => 'Bank of Tokyo-Mitsubishi UFJ',
                         'BICKNL'  => 'Binck bank',
                         'BNPANL'  => 'Bnp Paribas',
                         'CGGVNL'  => 'Cggveritas Services Holding',
                         'CITCNL'  => 'Citco bank',
                         'COBANL'  => 'Commertz bank AG',
                         'FBHLNL'  => 'Credit Europe bank',
                         'DAIXNL'  => 'Daimler International Finance',
                         'DLIMNL'  => 'Delta Lloyd Asset Management',
                         'DLBKNL'  => 'Delta Lloyd bank',
                         'DHBNNL'  => 'Demir-Halk bank',
                         'DEUTNL'  => 'Deutsche bank',
                         'DSSBNL'  => 'Dsb bank',
                         'MIFINL'  => 'Dutch Ministry of Finance',
                         'DSTANL'  => 'Dutch State Treasury Agency',
                         'TEBUNL'  => 'Economy bank',
                         'EMCFNL'  => 'Emcf',
                         'INNDNL'  => 'Equens',
                         'EQUINL'  => 'Equity Trust Co',
                         'NECINL'  => 'Euroclear Nederland',
//                       'ECLNNL'  => 'Euroclear Nederland(2)', niet in gebruik oid volgens Euroclear
//                                     mensen van Euroclear zijn niet echt spraakzaam

                         'UGBINL'  => 'Garantibank International',
                         'ARTENL'  => 'Ge Artesia bank',
                         'HABBNL'  => 'Habib bank',
                         'HBUANL'  => 'Hollandsche Bank Unie',
                         'HSBCNL'  => 'HSBC bank',
                         'BBRUNL'  => 'Ing Belgium NV/SA',
                         'INGINL'  => 'Ing Investment Management',
                         'BCITNL'  => 'Intensa Sanpaolo S.P.A.',
                         'ISBKNL'  => 'Isbank GMBH',
                         'CHASNL'  => 'JpMorgan Chase bank',
                         'KASANL'  => 'Kas bank',
                         'KREDNL'  => 'Kbc bank',
                         'KBCLNL'  => 'Kbc Clearing',
                         'KEMPNL'  => 'Kempen and Co',
                         'KECANL'  => 'Kempen Capital Management',
                         'JBBRNL'  => 'Kepler Equities',
                         'KPNCNL'  => 'Koninklijke KPN',
                         'KOEXNL'  => 'Korea Exchange bank',
                         'LPLNNL'  => 'Leaseplan Corporation',
                         'OVBNNL'  => 'Levob bank',
                         'LOYDNL'  => 'Lloyds TSB bank',
                         'LOCYNL'  => 'Lombard Odier Darier Hentsch en Cie',
                         'TWIXNL'  => 'Mars Nederland',
                         'ICBCNL'  => 'Mega International Commercial bank',
                         'MHCBNL'  => 'Mizuho Corporate bank',
                         'MNSNNL'  => 'Mn Services NV',
                         'AMTSNL'  => 'Mts Amsterdam',
                         'BOUNNL'  => 'N.V. Bank Voor de Bouwnijverheid',
                         'NTCONL'  => 'Nachenius Tjeenk and Co',
                         'ESESNL'  => 'Nederlands Centraal Instituut Voor Giraal Effectenverkeer',
                         'FLORNL'  => 'Nederlandsche bank',
                         'NFMONL'  => 'Nederlandse Financierings-maatschappij voor ontwikkelingslanden',
                         'NWABNL'  => 'Nederlandse Waterschapsbank',
                         'DNIBNL'  => 'Nibc bank',
                         'BNGHNL'  => 'Bank Nederlandse Gemeenten',
                         'SBNLNL'  => 'Settlement bank of the Netherlands',
                         'PGGMNL'  => 'Pggm',
                         'BVHLNL'  => 'Rbc Dexia Investor Services',
                         'RGVMNL'  => 'Robeco Institutional Asset Management',
                         'RGRBNL'  => 'Robeco Institutional Asset Management Funds',
                         'ROCHNL'  => 'Roche Pharmholding',
                         'SFBVNL'  => 'Schlumberger Finance',
                         'SCRTNL'  => 'Schretlen en Co',
                         'SNSINL'  => 'Sns asset management',
                         'SOVENL'  => 'Sociale Verzekeringsbank',
                         'SOGENL'  => 'Societe Generale',
                         'STALNL'  => 'Staal bankiers',
                         'SCBLNL'  => 'Standard Chartered Latin America',
                         'SHELNL'  => 'Stichting Shell pensioenfonds',
                         'HANDNL'  => 'Svenska Handelsbanken',
                         'SWHQNL'  => 'Swift Customer Service Centre',
                         'SYAVNL'  => 'Syntrus Achmea asset management',
                         'TDOMNL'  => 'Td Waterhouse bank',
                         'GILLNL'  => 'Theodoor Gilissen bankiers',
                         'TRIONL'  => 'Triodus bank',
                         'BFOFNL'  => 'Unilever Finance International',
                         'AMSTNL'  => 'Westlandutrecht effectenbank',
                         'KABANL'  => 'Yapi KREDI bank');
  private $numeriek  = false; //indicator of iets numeriek is
  private $input_bic ='';     //de bic ontdaan van voorloop en trailing spaties en HTML en in uppercase
  private $input_rek ='';     //rekeningnummer ontdaan van voorloop en trailing spaties en HTML
  private $iban     ='';      //de uiteindelijk berekende iban/foutmelding die geretouneerd wordt

  private function numeriek_test($teststring)
  {

     $loopcount      = 0;
     $this->numeriek = true;
      for ($loopcount = 0;$loopcount < strlen($teststring);$loopcount++)
      {

        if (($teststring[$loopcount] < '0') or ($teststring[$loopcount] > '9'))
        {

          $this->numeriek = false;
        }
      }
  }


  public function banknaam($bic)
  {

    $onbekend = 'onbekend';
    $upperbic = strtoupper($bic);//de bic in uppercase
    if (isset($this->babic[$upperbic]))
    {

      return $this->babic[$upperbic];
    }

    return $onbekend;  
  }


  public function bepaal_11_proef($testrekening)
  {

   //rekeningnummers met minder dan 8 posities(voormalige postbank) voldoen vaak niet aan de 11-proef
   //"gewone" rekeningnummers (9 posities) voldoen als het goed is aan de 11-proef

   $loopcount  = 0; //naam spreekt voor zich
   $weegfactor = 0; //naam spreekt voor zich
   $totaal     = 0; //totaal om modulo 11 te plegen
   $this->numeriek_test($testrekening);
   if (!$this->numeriek)
   {

     return false;
   }

   else
   {
     $weegfactor = strlen($testrekening);
     for ($loopcount=0;$loopcount < strlen($testrekening);$loopcount++)
     {

        $totaal = $totaal + (($testrekening[$loopcount]) * $weegfactor);
        $weegfactor = $weegfactor - 1;
     }

     if (($totaal % 11) == 0)
     {

        return true;
     }

     else
     {
       return false;
     }
   }
  }


  public function generate_select_string()
  {

     $select_string = '';
     asort($this->babic);
     $select_string = "\n" . '<select name="Banksel" id="Banksel" >';
     foreach ($this->babic as $labl => $waarde)
     {

       $select_string = $select_string . "\n    <option value=\"" . $labl . "\" ";
       if (isset($_POST['Banksel']))
       {

          if ($labl ==  $_POST['Banksel'])
          {

             $select_string = $select_string . "selected=\"selected\" ";
          }
       }

       $select_string = $select_string . '>' . $waarde . '</option>';
     }

     $select_string = $select_string . "\n";
     $select_string = $select_string . '</select>' . "\n";
     return $select_string;
  }


  public  function invoer_voor_iban($invoer_bic , $invoer_rek)
  {

     $this->input_bic = trim($invoer_bic);
     $this->input_bic = strtoupper($this->input_bic);
     $this->input_bic = htmlspecialchars($this->input_bic);
     $this->input_rek = trim($invoer_rek);
     $this->input_rek = htmlspecialchars($this->input_rek);
     $this->iban='';
     $this->validate();
     return $this->iban;
  }


  private function omzet($omstring)
  {

  //zet 1e 4 pos van een BICstring om in een cijferstring A--->10 B-->11 etc
  $res = (string) ord($omstring[0]) - ord('A') + 10 .
         (string)
ord($omstring[1]) - ord('A') + 10 .
         (string)
ord($omstring[2]) - ord('A') + 10 .
         (string)
ord($omstring[3]) - ord('A') + 10;
   return $res;
  }


  private function reken()
  {

    //bereken iban
    $numbic   = $this->omzet($this->input_bic);
    $bignum =  $numbic . $this->input_rek . '2321' . '00' ; //'2321' is 'NL' ("A" = 10 etc)
    $modulo97='';
    $checkdigits='00';//checkdigits of controlegetal is 2 digits/tekens groot
    //lange string (bignum)voor uitrekenen checkdigits
    //deze string krijgt een modulo berekening over 24 digits dus staartdeling met 6 pos tegelijk
    //modulo gedaan voor het berekenen van de 2 checkdigits

    $modulo97 = (int)substr($bignum,0,6);
    $modulo97 = $modulo97 % 97;
    $modulo97 = (1000000 * $modulo97) + (int)substr($bignum,6,6);
    $modulo97 = $modulo97 % 97;
    $modulo97 = (1000000 * $modulo97) + (int)substr($bignum,12,6);
    $modulo97 = $modulo97 % 97;
    $modulo97 = (1000000 * $modulo97) + (int)substr($bignum,18,6);
    $modulo97 = $modulo97 % 97;
    $checkdigits = 98 - $modulo97;  
    //einde modulo staartdeling
    if (strlen($checkdigits) < 2)
    {

       $checkdigits = '0' . $checkdigits;
    }

    $this->iban = 'NL' . $checkdigits . substr($this->input_bic,0,4) . $this->input_rek;
  }


  private function validate()
  {

    //valideren van reknr
    $fout  = '!geen reknr opgegeven'; //eventuele foutmelding
    $loopcount = 0; //loopcount = teller tbv een loop
    $valrek = $this->input_rek; //kopie van $this->input_rek (korte notatie)
    if ( strlen($this->input_rek) > 0)
    {

      $fout = '';
      $this->numeriek_test($this->input_rek);
      if (!$this->numeriek)
      {

         $fout = '!rekeningnummer mag alleen de tekens 0...9 bevatten';
      }

      if ( ($fout == '') and (strlen($this->input_rek) >10))
      {

          $fout = '!rekeningnummer mag maximaal 10 posities bevatten';
      }
    }

    if ($fout == "")
    {

      if (!isset($this->babic[$this->input_bic]))
      {

         $fout = '!BIC onbekend ' . $this->input_bic;
      }
    }

    if ($fout != "")
    {

      $this->iban = $fout;
    }

    else    
    { while (strlen($this->input_rek) < 10)
      {

        $this->input_rek = '0' . $this->input_rek;
      }

      $this->reken();
    }
  }
}
// einde class
?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.