Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
226 | daniel-mar | 1 | <?php |
2 | |||
3 | if (!defined('OID_REGEX')) { |
||
4 | define('OID_REGEX', oid_detection_regex(HIGHLIGHT_OID_MINLEN, ALLOW_LEADING_ZEROES, LEADING_DOT_POLICY, true /* HIGHLIGHT_REQUIRES_WHITESPACE_DELIMITERS */)); |
||
5 | } |
||
6 | |||
7 | function queryInfo($query) { |
||
8 | return '<p class="green">Executed query <a href="?action=query&query='.urlencode($query).'">'.htmlentities($query).'</a></p>'; |
||
9 | } |
||
10 | |||
11 | function showHTML($cont, $db, $show_internal_links=true, $monospace=true) { |
||
12 | $cont = htmlentities($cont); |
||
13 | # $cont = str_replace(' ', ' ', $cont); |
||
14 | # $cont = nl2br($cont); |
||
15 | |||
16 | $rm = $db->getRedactedMessage(); |
||
17 | |||
18 | # TODO: htmlentities() bei den indexes usw |
||
19 | # TODO: <...> problem - wird hinzugefügt |
||
20 | |||
21 | # TODO: als plugins? |
||
22 | |||
23 | // Recognize index links |
||
24 | if ($show_internal_links) { |
||
25 | $cont = preg_replace('@(index(\\((.+)\\)|):\\s*)([^\\s#].+)@', '\\1<a href="?action=show_index&ns=\\3&index=\\4">\\4</a>', $cont); |
||
26 | } |
||
27 | |||
28 | // Recognize web links |
||
29 | $cont = preg_replace('@([a-zA-Z]+://[^\\s]+)@', '<a href="\\1">\\1</a>', $cont); |
||
30 | |||
31 | // Recognize E-Mail links |
||
32 | $cont = preg_replace('@([^\\s:]+)\\@([^\\s]+)@', '<a href="mailto:\\1(at)\\2">\\1(at)\\2</a>', $cont); # TODO: antispam |
||
33 | |||
34 | // Recognize OID links (with or without leading dot) |
||
35 | if ($show_internal_links) { |
||
36 | $cont = preg_replace(OID_REGEX, '<a href="?action=show_oid&oid=\\1">\\1</a>', $cont); |
||
37 | } else { |
||
38 | $cont = preg_replace(OID_REGEX, '<a href="http://www.oid-info.com/get/\\1">\\1</a>', $cont); |
||
39 | } |
||
40 | |||
41 | // Decorate the "redacted" message |
||
42 | if ($show_internal_links) { |
||
43 | $cont = str_replace($rm, "<a href=\"?action=auth_tokens\" style=\"text-decoration:none\"><span style=\"background:black;color:white\">$rm</span></a>", $cont); |
||
44 | } else { |
||
45 | $cont = str_replace($rm, "<span style=\"background:black;color:white\">$rm</span>", $cont); |
||
46 | } |
||
47 | |||
48 | // Recognize all UUIDs (except if the UUID is already linked as uuid-index) |
||
49 | if ($show_internal_links) { |
||
50 | $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); |
||
51 | } |
||
52 | |||
53 | if (($monospace) && ($cont != '')) { |
||
54 | return '<pre>'.$cont.'</pre>'; |
||
55 | } else { |
||
56 | return $cont; |
||
57 | } |
||
58 | } |
||
59 | |||
60 | function showException($e) { |
||
61 | ob_start(); |
||
62 | if (!headers_sent()) header('HTTP/1.1 500 Internal Server Error'); |
||
63 | $title = 'Database error'; |
||
64 | echo page_header($title); |
||
65 | $msg = $e; |
||
66 | $msg = str_replace(__DIR__, '.', $msg); |
||
67 | ?> |
||
68 | <h2><?php echo $title; ?></h2> |
||
69 | <p>An internal error occurred while reading the Volcano database. Please contact the administrator and try again later.</p> |
||
70 | <p>Error message:</p> |
||
71 | <p><pre><?php echo $msg; ?></pre></p> |
||
72 | <?php |
||
73 | echo page_footer(); |
||
74 | $cont = ob_get_contents(); |
||
75 | ob_end_clean(); |
||
76 | return $cont; |
||
77 | } |
||
78 | |||
79 | function page_header($title='', $systemID='') { # TODO: w3c |
||
80 | ob_start(); |
||
81 | ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
||
82 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||
83 | |||
84 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> |
||
85 | |||
86 | <head> |
||
87 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> |
||
88 | <?php if ($systemID) echo '<meta name="X-OidPlus-SystemID" content="'.$systemID.' ('.uuid_numeric_value($systemID).')" />'."\n"; ?> |
||
89 | <title><?php echo htmlentities($title); ?></title> |
||
90 | <link href="style.css" rel="stylesheet" type="text/css" /> |
||
91 | <meta name="robots" content="noindex" /><!-- because system is outdated --> |
||
92 | </head> |
||
93 | |||
94 | <body> |
||
95 | |||
96 | <?php |
||
97 | $cont = ob_get_contents(); |
||
98 | ob_end_clean(); |
||
99 | return $cont; |
||
100 | } |
||
101 | |||
102 | function page_footer() { # TODO: auch version anzeigen |
||
103 | ob_start(); |
||
104 | ?> |
||
105 | |||
106 | <p style="text-align:center">OID+ web interface © 2012 - <?php echo date('Y'); ?> <a href="http://www.viathinksoft.de/">ViaThinkSoft</a>.</p> |
||
107 | |||
108 | </body> |
||
109 | |||
110 | </html><?php |
||
111 | $cont = ob_get_contents(); |
||
112 | ob_end_clean(); |
||
113 | return $cont; |
||
114 | } |
||
115 |