/* connect to DB */ ($GLOBALS['db'] = mysqli_connect()) || internal_error('unable to connect to database: '.mysqli_connect_error()); mysqli_set_charset($GLOBALS['db'], 'utf8') || internal_error('unable to set character set: '.mysqli_error($GLOBALS['db'])); mysqli_select_db($GLOBALS['db'], 'ffvaDB') || internal_error('unable to select database: '.mysqli_error($GLOBALS['db'])); /* get rid of slashes produced by a moronic default setting on which * some software still relies... */ function cleanup_magic_quotes($array) { foreach ($array as $key => $value) { if (is_array($value)) cleanup_magic_quotes($value); else $array[$key] = stripslashes($value); } } if (get_magic_quotes_gpc()) { cleanup_magic_quotes($_GET); cleanup_magic_quotes($_POST); } // som van indices is graad van verwantschap // verschil van de indices is generatieverschil $familierelaties = array( array("proband", "kind", "kleinkind", "achterkleinkind (3e graad)", "achterkleinkind (4e graad)", "achterkleinkind (5e graad)", "achterkleinkind (6e graad)", "achterkleinkind (7e graad)", "achterkleinkind (8e graad)", "achterkleinkind (9e graad)", "achterkleinkind (10e graad)"), array("ouder", "broer/zus", "neef/nicht (3e graad)", "achterneef/nicht (4e graad)", "achterneef/nicht (5e graad)", "achterneef/nicht (6e graad)"), array("grootouder", "oom/tante", "neef/nicht (4e graad)", "achterneef/nicht (5e graad)", "achterneef/nicht (6e graad)", "achterneef/nicht (7e graad)"), array("overgrootouder", "oudoom/tante", "achterneef/nicht (5e graad)", "achterneef/nicht (6e graad)", "achterneef/nicht (7e graad)", "achterneef/nicht (8e graad)"), array("betovergrootouder", "oudgrootoom/tante", "achterneef/nicht (6e graad)", "achterneef/nicht (7e graad)", "achterneef/nicht (8e graad)", "achterneef/nicht (9e graad)"), array("oudouder", "oudovergrootoom/tante", "achterneef/nicht (7e graad)", "achterneef/nicht (8e graad)", "achterneef/nicht (9e graad)", "achterneef/nicht (10e graad)"), array("oudgrootouder", "oudbetovergrootoom/tante", "achterneef/nicht (8e graad)", "achterneef/nicht (9e graad)", "achterneef/nicht (10e graad)", "achterneef/nicht (11e graad)"), array("oudovergrootouder", "stamoom/tante", "achterneef/nicht (9e graad)", "achterneef/nicht (10e graad)", "achterneef/nicht (11e graad)", "achterneef/nicht (12e graad)"), array("oudbetovergrootouder", "stamgrootoom/tante", "achterneef/nicht (10e graad)", "achterneef/nicht (11e graad)", "achterneef/nicht (12e graad)", "achterneef/nicht (13e graad)"), array("stamouder", "stamovergrootoom/tante", "achterneef/nicht (11e graad)", "achterneef/nicht (12e graad)", "achterneef/nicht (13e graad)", "achterneef/nicht (14e graad)"), array("stamgrootouder", "stambetovergrootoom/tante", "achterneef/nicht (12e graad)", "achterneef/nicht (13e graad)", "achterneef/nicht (14e graad)", "achterneef/nicht (15e graad)"), array("stamovergrootouder", "stambetovergrootoom/tante", "achterneef/nicht (13e graad)", "achterneef/nicht (14e graad)", "achterneef/nicht (15e graad)", "achterneef/nicht (16e graad)"), ); /* convenience functions */ function mysqli_escape_data($string) { return mysqli_real_escape_string($GLOBALS['db'], $string); } function internal_error($string) { header('Content-Type: text/plain'); echo('Internal error: '.$string); exit; } function dec_signed_data($data) { if (!isset($data)) return NULL; $sigdata = explode(';', $data); if (count($sigdata) != 2) internal_error('error paramater malformed'); $hmac_key = sprint_singular("SELECT value FROM config WHERE `key` = 'HMAC_KEY'"); if (hash_hmac('sha256', $sigdata[1], $hmac_key) != $sigdata[0]) internal_error('invalid signature'); $timeoutdata = explode(',', $sigdata[1]); if (count($timeoutdata) != 2) internal_error('signed data malformed?!?!?!?'); if (time() > $timeoutdata[0]) return NULL; return unserialize(urlsafe_b64decode($timeoutdata[1])); } function enc_signed_data($data) { $hmac_key = sprint_singular("SELECT value FROM config WHERE `key` = 'HMAC_KEY'"); $timeout = sprint_singular("SELECT value FROM config WHERE `key` = 'HMAC_TIMEOUT'") + time(); $timeoutdata = $timeout.','.urlsafe_b64encode(serialize($data)); $sig = hash_hmac('sha256', $timeoutdata, $hmac_key); return $sig.';'.$timeoutdata; } function html_head($title, $script = '') { header('Content-Type: text/html; charset=UTF-8'); echo(''."\n"); ?>
'.entenc(mysqli_field_name($result, $i)).' | '; } $html_table .= "\n"; while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { $html_table .= '||
---|---|---|
'.entenc($row[$i]).' | '; if (isset($row[$i])) $html_table .= ''.$row[$i].' | '; else $html_table .= 'NULL | '; } $html_table .= "