$hash_key = array(
0x74, 0x2d, 0x13, 0xc4, 0x1a, 0xf3, 0x55, 0xd4,
0xf5, 0x3d, 0xb7, 0xf3, 0xe7, 0x92, 0xe5, 0x8f,
0x89, 0xeb, 0x08, 0x33, 0xa9, 0x34, 0x0e, 0x2e,
0x06, 0x40, 0x6a, 0x6c, 0xb1, 0x80, 0x87, 0xa4,
0x4c, 0xca, 0x0b, 0x09, 0xd2, 0x0c, 0x34, 0xe4,
0x88, 0x26, 0x1b, 0x09, 0x1f, 0xd8, 0x0f, 0x87,
0x82, 0x1d, 0xe1, 0x1a, 0x01, 0x6e, 0xa9, 0x1f,
0x33, 0x65, 0x80, 0xac, 0xcc, 0x92, 0xa6, 0xa5,
0x53, 0x68, 0x33, 0xf3, 0x79, 0x8a, 0x55, 0x41,
0x5e, 0x86, 0x98, 0x38, 0x9e, 0x57, 0xf2, 0xfa,
0x38, 0x13, 0xa8, 0x29, 0x15, 0x81, 0x90, 0xe9,
0x5c, 0xea, 0x61, 0xc5, 0x7f, 0xee, 0xce, 0xc3,
0xad, 0x44, 0x9f, 0xb1, 0x33, 0x62, 0x57, 0xdb,
0x3b, 0x44, 0xad, 0x17, 0xe0, 0xd5, 0x62, 0x89,
0x3b, 0x54, 0xd8, 0xb7, 0xd3, 0xb9, 0x1b, 0x5c,
0xf1, 0x71, 0x7a, 0x5c, 0xc0, 0xdf, 0x3d, 0x38
);
function gen_hash($key, $val) {
# add input value to key, at start index given by the first character
$start_idx = ord($val) % count($key);
$in = $key;
for($i=0; $i < strlen($val); $i++) {
$pos = $i % count($key);
$in[$pos] += ord(substr($val, $i, 1));
$in[$pos] %= 256;
}
# convert unsigned char array to string
$in2 = '';
for($i=0; $i < count($key); $i++) {
$in2 .= chr($in[$i]);
}
return sha1($in2);
}
function verify_hash($key, $hash, $val) {
$h = gen_hash($key, $val);
return $h == $hash;
}
?>
if(isset($_REQUEST['edit']) && $_REQUEST['edit'] != 0) {
print "
Eintrag ändern
";
# protect other entries from manipulation
if(!isset($_REQUEST['sec']) || !verify_hash($hash_key, $_REQUEST['sec'], $_REQUEST['personen_id'])) {
print "
invalid request
\n";
exit;
}
} else {
print "
Neuen Eintrag erstellen
";
}
?>
if(isset($_REQUEST['bad']))
print "
Die rot markierten Eingaben sind fehlerhaft.\n
\n";
?>
Mit (*) gekennzeichnete Felder müssen
ausgefüllt werden. Sie dienen der eindeutigen Identifikation.