/* 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'], 'people') || 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... */
/* take from ffvaDB as needed */
$path = '/fotos/php';
function internal_error($string) {
header('Content-Type: text/plain');
echo('Internal error: '.$string);
exit;
}
function entenc($string) {
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
function html_head($title, $script = '') {
global $path;
echo(''."\n"); ?>
echo($title) ?>
}
function html_tail() { ?>
}
function tagmeister_command($command) {
global $socket;
if (!isset($socket)) if (!($socket = fsockopen('unix:///home/rsnel/.tagmeister.fifo'))) internal_error('opening socket');
fwrite($socket, $command."\n");
$out = fgets($socket);
if ($out != "OK\n") {
if ($out == "ERR\n") internal_error('received error: '.fgets($socket));
internal_error('received not "ERR\n" or "OK\n", which is unexpected');
}
$out = fgets($socket);
$data = json_decode($out, TRUE);
if (!$data) internal_error('received incorrect JSON data: ', $out);
if (fgets($socket) != ".\n") internal_error('expected ".\n", which we didn\'t get');
return $data;
}
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);
//}
/* convenience functions */
function mysql_escape_data($string) {
return mysqli_real_escape_string($GLOBALS['db'], $string);
}
/*
function sprint_table($result) {
if (mysql_num_rows($result) == 0) return '