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:
|
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 Michael Wallner <mike@iworks.at> |
// +----------------------------------------------------------------------+
//
// $Id: AT.php,v 1.1 2005/03/07 21:00:53 krabu Exp $
/**
* Requires Validate
*/
require_once('Validate.php');
/**
* Validate_AT
*
* @author Michael Wallner <mike@php.net>
* @package Validate
* @category PHP
*
* @version $Revision: 1.1 $
* @access public
*/
class Validate_AT
{
/**
* Validate postcode ("Postleitzahl")
*
* @static
* @access public
* @param string postcode to validate
* @param bool optional; strong checks (e.g. against a list of postcodes)
* @return bool true if postcode is ok, false otherwise
*/
function postcode($postcode, $strong=false)
{
if ($strong) {
static $postcodes;
if (!isset($postcodes)) {
$file = '/usr/share/pear/data/Validate/AT_postcodes.txt';
$postcodes = array_map('trim', file($file));
}
return in_array((int) $postcode, $postcodes);
} else {
return (ereg('^[0-9]{4}$', $postcode));
}
}
/**
* Validate SSN
*
* "Sozialversicherungsnummer"
*
* @static
* @access public
* @param string $svn
* @return bool
*/
function ssn($svn)
{
$matched = preg_match(
'/^(\d{3})(\d)\D*(\d{2})\D*(\d{2})\D*(\d{2})$/',
$svn,
$matches
);
if (!$matched) {
return false;
}
list(, $num, $chk, $d, $m, $y) = $matches;
if (!Validate::date("$d-$m-$y", array('format' => '%d-%m-%y'))) {
return false;
}
$str = (string) $num . $chk . $d . $m . $y;
$len = strlen($str);
$fkt = '3790584216';
$sum = 0;
for ($i = 0; $i < $len; $i++) {
$sum += $str{$i} * $fkt{$i};
}
$sum = $sum % 11;
if ($sum == 10) {
$sum = 0;
}
return ($sum == $chk);
}
}
?> |