/** $DBhost = "localhost"; $DBuser = "username"; $DBpassword = "password"; $DBname = "dbname"; $db = mysql_connect($DBhost, $DBuser, $DBpassword); mysql_select_db($DBname); */ function normalLinks( $str ) { $pattern = array('#(^|[^\"=]{1})(http://|ftp://|mailto:|news:)([^\s<>]+)([\s\n<>]|$)#sm', '/(([^\s<>]+))(@)([^\s<>]+)\b/i'); $replace = array('\\1\\2\\3\\4', '\\0'); return preg_replace($pattern, $replace, $str); } function keywordExists($str) { $result = mysql_query("SELECT blastword FROM blastlite WHERE blastword='$str'"); return @mysql_result($result,0); } function isKeyword($str){ if (keywordExists($str)==NULL) { $str = ' '.$str.'(?)'; } else { $str = ' '.$str.''; } return $str; } function wordLinks( $str ) { return preg_replace( "/(\s|\A)([A-Z][a-z]+[A-Z][a-zA-Z]+)/e", "isKeyword($0)", $str ); } /** function specialNotation($str) { $pattern = array("(\[i\])", "(\[\/i\])", "(\[u\])", "(\[\/u\])", "(\[b\])", "(\[\/b\])"); $replace = array("", "", "", "", "", ""); return preg_replace($pattern, $replace, $str); } */ function renderPage( $str ) { $str = wordLinks( $str ); $str = normalLinks($str); //$str = specialNotation($str); $str = nl2br($str); return $str; } ?>