<?php
define('OID_REGEX', oid_detection_regex
(HIGHLIGHT_OID_MINLEN
, ALLOW_LEADING_ZEROES
, LEADING_DOT_POLICY
, true /* HIGHLIGHT_REQUIRES_WHITESPACE_DELIMITERS */));
}
function queryInfo($query) {
return '<p class="green">Executed query <a href="?action=query&query='.urlencode($query).'">'.htmlentities($query).'</a></p>';
}
function showHTML($cont, $db, $show_internal_links=true, $monospace=true) {
# $cont = str_replace(' ', ' ', $cont);
# $cont = nl2br($cont);
$rm = $db->getRedactedMessage();
# TODO: htmlentities() bei den indexes usw
# TODO: <...> problem - wird hinzugefĆ¼gt
# TODO: als plugins?
// Recognize index links
if ($show_internal_links) {
$cont = preg_replace('@(index(\\((.+)\\)|):\\s*)([^\\s#].+)@', '\\1<a href="?action=show_index&ns=\\3&index=\\4">\\4</a>', $cont);
}
// Recognize web links
$cont = preg_replace('@([a-zA-Z]+://[^\\s]+)@', '<a href="\\1">\\1</a>', $cont);
// Recognize E-Mail links
$cont = preg_replace('@([^\\s:]+)\\@([^\\s]+)@', '<a href="mailto:\\1(at)\\2">\\1(at)\\2</a>', $cont); # TODO: antispam
// Recognize OID links (with or without leading dot)
if ($show_internal_links) {
$cont = preg_replace(OID_REGEX
, '<a href="?action=show_oid&oid=\\1">\\1</a>', $cont);
} else {
$cont = preg_replace(OID_REGEX
, '<a href="http://www.oid-info.com/get/\\1">\\1</a>', $cont);
}
// Decorate the "redacted" message
if ($show_internal_links) {
$cont = str_replace($rm, "<a href=\"?action=auth_tokens\" style=\"text-decoration:none\"><span style=\"background:black;color:white\">$rm</span></a>", $cont);
} else {
$cont = str_replace($rm, "<span style=\"background:black;color:white\">$rm</span>", $cont);
}
// Recognize all UUIDs (except if the UUID is already linked as uuid-index)
if ($show_internal_links) {
$cont = preg_replace('@\\b([A-Fa-f0-9]{8}\\-[A-Fa-f0-9]{4}\\-[A-Fa-f0-9]{4}\\-[A-Fa-f0-9]{4}\\-[A-Fa-f0-9]{12})\\b(?!</a>|">)@', '<a href="?action=uuid_info&uuid=\\1">\\1</a>', $cont);
}
if (($monospace) && ($cont != '')) {
return '<pre>'.$cont.'</pre>';
} else {
return $cont;
}
}
function showException($e) {
$title = 'Database error';
echo page_header($title);
$msg = $e;
?>
<h2><?php echo $title; ?></h2>
<p>An internal error occurred while reading the Volcano database. Please contact the administrator and try again later.</p>
<p>Error message:</p>
<p><pre><?php echo $msg; ?></pre></p>
<?php
echo page_footer();
return $cont;
}
function page_header($title='', $systemID='') { # TODO: w3c
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<?php if ($systemID) echo '<meta name="X-OidPlus-SystemID" content="'.$systemID.' ('.uuid_numeric_value($systemID).')" />'."\n"; ?>
<link href
="style.css" rel
="stylesheet" type
="text/css" />
<meta name
="robots" content
="noindex" /><!-- because
system is outdated
-->
</head>
<body>
<?php
return $cont;
}
function page_footer() { # TODO: auch version anzeigen
?>
<p style
="text-align:center">OID
+ web
interface © 2012 - <?php echo date('Y'); ?> <a href
="http://www.viathinksoft.de/">ViaThinkSoft
</a
>.</p
>
</body>
</html><?php
return $cont;
}