. */ //######################################### //### File: CSNcheck.php ### //### Author: Wim van Ravesteijn ### //######################################### //### Created: 2002.08.10 ### //### Last changed: 2002.09.08 ### //### Version: 1.10 ### //######################################### function CSN_check ($CSN) { # *** Written in LotusScript for Notes/Domino 5.x [by P v Klitzing] *** # *** Translated to PHP and extended functionality [by Wim van Ravesteijn] *** # *** *** # *** Aim: Compute the last character of the CSN (card serial number) *** # *** introduced by AEGEE-Europe in spring 2000 (AGORA Utrecht) *** # *** This last character has the function of a check digit *** # *** *** # *** As input, you send a full CSN number, with or without dash (-), *** # *** upper or lower case letters *** # *** *** # *** The return of the function is the following: *** # *** ok: CSN number valid *** # *** no: CSN number invalid *** # *** error: unrecognised characters # # ord() : Return the ASCII code for this character # substr() : Extract x charcacters from a string, starting at position i # strlen() : Length of a string # % : Modula operation $stringtemp = strtoupper(substr($CSN, 0, strlen($CSN)-1)); $CSN_check = strtoupper(substr($CSN, strlen($CSN)-1,1)); if( strlen($stringtemp)>0 ) { for( $i=0;$i=65) AND (ord( substr($stringtemp, $i, 1) )<=90) ) { $newwork = $newwork . ord( substr($stringtemp, $i, 1) ); }else if( substr($stringtemp, $i, 1)=="-" ) { # Dealing with - # -> Do nothing }else if( (ord(substr($stringtemp, $i, 1))>=48) AND (ord(substr($stringtemp, $i, 1))<=57) ) { # Dealing with 0-9 $newwork = $newwork . substr($stringtemp, $i, 1); }else { return "error"; } } } for($i=0;$i