Copyright (c) 1999-2005 by Dominik Storck Datentechnik Traisaer Weg 35 D-64380 Roßdorf Germany ******************************************************************* */ require("config.inc"); require("languages.lib"); require("functions.inc"); error_reporting(0); if (($id == "") && ($keyword == "")) { Header("Status: 302"); Header("Location: ./"); exit; } $id = (integer) $_REQUEST["id"]; $la = mysql_escape_string($_REQUEST["la"]); $keyword = mysql_escape_string($_REQUEST["keyword"]); $pagetitle = $_glossary[$la]; $headline = $pagetitle; include("header.inc"); $cid = mysql_connect($dbhost,$dbuser,$dbpasswd); mysql_selectdb($dbname); if ($la != "") { $sprache = "AND sprache='$la'"; } // Glossar-Info holen if ($id != "") { $q = "SELECT * FROM glossar WHERE glossarid=$id $sprache"; } else if ($keyword != "") { $q = "SELECT * FROM glossar WHERE upper(keyword)=upper('$keyword') $sprache"; } $rg = mysql_query($q, $cid); if (mysql_num_rows($rg) == 0) { // jetzt versuchen wir es halt mit Englisch if ($id != "") { $q = "SELECT * FROM glossar WHERE glossarid=$id AND sprache='en'"; } else if ($keyword != "") { $q = "SELECT * FROM glossar WHERE upper(keyword)=upper('$keyword') AND sprache='en'"; } $rg = mysql_query($q, $cid); } if (mysql_num_rows($rg) == 0) { echo "$noentry[$la]"; include("footer.inc"); exit; } //odbc_binmode($rg,2); //odbc_longreadlen($rg,16384); $glossarid = mysql_result($rg,0, "glossarid"); $keyword = mysql_result($rg,0, "keyword"); $text = mysql_result($rg,0, "text"); // Wort auf Existenz im Glossar prüfen, Querverweise als Link formatieren // Jeweils nur das erste Auftreten in der Textstelle ausgeben. // Selbstbezüge unterdrücken. $words = explode(" ",$text); $count = 0; for ($i = 0; $i <= count($words); $i++) { $w = $words[$i]; // ggf. Klammern vor/nach dem Keyword abtrennen $prefix = ""; $postfix = ""; $ch = substr($w,0,1); while ( ($ch == "(") || ($ch == ")") || ($ch == ";") || ($ch == ",") || ($ch == ":") || ($ch == ".") || ($ch == "/") || ($ch == "-")) { $prefix = $prefix . $ch; $w = substr($w,1); $ch = substr($w,0,1); } $ch = substr($w,strlen($w)-1,1); while ( ($ch == "(") || ($ch == ")") || ($ch == ";") || ($ch == ":") || ($ch == ".") || ($ch == "/")) { $postfix = $ch . $postfix; $w = substr($w,0,strlen($w)-1); $ch = substr($w,strlen($w)-1); } // Endung abschneiden, falls Wort länger als 4 Buchstaben if (strlen($w) > 4) { $wx = substr($w,0,strlen($w)-1); $q = "SELECT * FROM glossar WHERE upper(keyword) LIKE upper('$wx%') AND sprache='$la'"; $r = mysql_query($q, $cid); if (@mysql_result($r,0,"keyword") != "") { // ist es das erste Auftreten im Abschnitt? $iw = strtolower($wx); $icount = 1; while (($icount <= $count) && ($links[$icount] != $iw)) { $icount++; } // ja, also merken und als Link markieren if (($links[$icount] != $iw) && ($iw != strtolower($keyword))) { $glid = mysql_result($r,0, "glossarid"); $links[$count++] = $iw; $words[$i] = "" . $w . ""; if ($prefix != "") { $words[$i] = $prefix . $words[$i]; } if ($postfix != "") { $words[$i] = $words[$i] . $postfix; } } } } } $text = implode($words," "); mysql_free_result($rg); ?>