]*?>.*?'si", // Strip out javascript "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags "'([\r\n])[\s]+'", // Strip out white space "'&(quot|#34);'i", // Replace HTML entities "'&(amp|#38);'i", "'&(lt|#60);'i", "'&(gt|#62);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'&#(\d+);'e"); // evaluate as php $replace = array ("", "", "\\1", "\"", "&", "<", ">", " ", chr(161), chr(162), chr(163), chr(169), "chr(\\1)"); return preg_replace($search, $replace, $string); } function udsnit_af_tekst($tekst, $keyword, $kort) { if($kort == true) $antal_bogstaver = 100; else $antal_bogstaver = 500; $pos = strpos(strtolower($tekst), strtolower($keyword)); $start_pos = $pos - $antal_bogstaver; if($start_pos < 0) $start_pos = 0; $slut_pos = ($pos - $start_pos) + ($antal_bogstaver * 2) + strlen($keyword); $udsnit = substr($tekst, $start_pos, $slut_pos); $udsnit_keyword_highlighted = str_highlight($udsnit, $keyword); return "...".$udsnit_keyword_highlighted."..."; } function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function my_str_ireplace($needle, $replacement, $haystack) { $i = 0; while (($pos = strpos(strtolower($haystack), strtolower($needle), $i)) !== false) { $haystack = substr($haystack, 0, $pos) . $replacement . substr($haystack, $pos + strlen($needle)); $i = $pos + strlen($replacement); } return $haystack; } /** * Perform a simple text replace * This should be used when the string does not contain HTML * (off by default) */ define('STR_HIGHLIGHT_SIMPLE', 1); /** * Only match whole words in the string * (off by default) */ define('STR_HIGHLIGHT_WHOLEWD', 2); /** * Case sensitive matching * (off by default) */ define('STR_HIGHLIGHT_CASESENS', 4); /** * Overwrite links if matched * This should be used when the replacement string is a link * (off by default) */ define('STR_HIGHLIGHT_STRIPLINKS', 8); /** * Highlight a string in text without corrupting HTML tags * * @author Aidan Lister * @version 3.1.1 * @param string $text Haystack - The text to search * @param array|string $needle Needle - The string to highlight * @param bool $options Bitwise set of options * @param array $highlight Replacement string * @return Text with needle highlighted */ function str_highlight($text, $needle, $options = null, $highlight = null) { // Default highlighting if ($highlight === null) { $highlight = '\1'; } // Select pattern to use if ($options & STR_HIGHLIGHT_SIMPLE) { $pattern = '#(%s)#'; $sl_pattern = '#(%s)#'; } else { $pattern = '#(?!<.*?)(%s)(?![^<>]*?>)#'; $sl_pattern = '#(%s)#'; } // Case sensitivity if (!($options & STR_HIGHLIGHT_CASESENS)) { $pattern .= 'i'; $sl_pattern .= 'i'; } $needle = (array) $needle; foreach ($needle as $needle_s) { $needle_s = preg_quote($needle_s); // Escape needle with optional whole word check if ($options & STR_HIGHLIGHT_WHOLEWD) { $needle_s = '\b' . $needle_s . '\b'; } // Strip links if ($options & STR_HIGHLIGHT_STRIPLINKS) { $sl_regex = sprintf($sl_pattern, $needle_s); $text = preg_replace($sl_regex, '\1', $text); } $regex = sprintf($pattern, $needle_s); $text = preg_replace($regex, $highlight, $text); } return $text; } // start timer-> $stimer = explode( ' ', microtime() ); $stimer = $stimer[1] + $stimer[0]; global $sprog; if($keyword == "") $keyword = "pqoitjqwoeiljflaskdngerughæklasdngæoerihjgælkadgæoeriuhgælkdzfgodægh"; // søg uden limits (for at vise antal i alt) // SØG INDHOLD---> $find_query = "select t_id,titel,tekst from tekst WHERE tekst LIKE '%".$keyword."%' AND sprog = ".$sprog; $find_result_with_html = mysql_query($find_query); $find_result_tekst = array(); $find_result_t_id = array(); $find_result_titel= array(); while($qd = mysql_fetch_array($find_result_with_html)) { if(eregi($keyword, removeHTML($qd["tekst"]))) { $next_index = count($find_result_tekst); $find_result_tekst[$next_index] = removeHTML($qd["tekst"]); $find_result_t_id[$next_index] = $qd["t_id"]; $find_result_titel[$next_index] = removeHTML($qd["titel"]); } } $seek_hits = count($find_result_tekst); if($nyheder_modul_aktiveret) { // SØG NYHEDER---> $find_query = "select nyheds_id,titel,indhold from nyhedsmodul_indhold WHERE indhold LIKE '%".$keyword."%' AND sprog_id = ".$sprog; $find_result_with_html = mysql_query($find_query); $find_nyheder_result_tekst = array(); $find_nyheder_result_id = array(); $find_nyheder_result_titel= array(); while($qd = mysql_fetch_array($find_result_with_html)) { if(eregi($keyword, removeHTML($qd["indhold"]))) { $next_index = count($find_nyheder_result_tekst); $find_nyheder_result_tekst[$next_index] = removeHTML($qd["indhold"]); $find_nyheder_result_id[$next_index] = $qd["nyheds_id"]; $find_nyheder_result_titel[$next_index] = removeHTML($qd["titel"]); } } $seek_hits += count($find_nyheder_result_tekst); // SØG NYHEDER TITEL---> $find_query = "select nyheds_id,titel,indhold from nyhedsmodul_indhold WHERE titel LIKE '%".$keyword."%' AND sprog_id = ".$sprog; $find_result_with_html = mysql_query($find_query); while($qd = mysql_fetch_array($find_result_with_html)) { if(eregi($keyword, removeHTML($qd["titel"]))) { $next_index = count($find_nyheder_result_tekst); $find_nyheder_result_tekst[$next_index] = removeHTML($qd["indhold"]); $find_nyheder_result_id[$next_index] = $qd["nyheds_id"]; $find_nyheder_result_titel[$next_index] = removeHTML($qd["titel"]); } } $seek_hits += count($find_nyheder_result_tekst); } ?> $etimer = explode( ' ', microtime() ); $etimer = $etimer[1] + $etimer[0]; $seconds = substr(($etimer - $stimer),0,6); if($limit) { if($seek_hits > 10) // over 10 hits { switch($sprog) { case 2 : echo "Din søgning gav ".$seek_hits." hits! Viser ".$limit_numbers." - [Vis Alle] (".$seconds." sekunder)
"; break; case 3 : echo "Your search had ".$seek_hits." hits! Showing ".$limit_numbers." - [Show All] (".$seconds." seconds)
"; break; default : echo "".$seek_hits."-t nassaarineqarput! ".$limit_numbers."-t takutinneqarput - [Tamaasa takukkit] (".$seconds." sekund-it)
"; break; } // switch sprog } else // under 10 hits { switch($sprog) { case 2 : echo "Din søgning gav ".$seek_hits." hits! (".$seconds." sekunder)
"; break; case 3 : echo "Your search had ".$seek_hits." hits! (".$seconds." seconds)
"; break; default : echo "".$seek_hits."-t nassaarineqarput! (".$seconds." sekund-it)
"; break; } // switch sprog } } else { switch($sprog) { case 2 : echo "Din søgning gav ".$seek_hits." hits! Viser alle hits! (".$seconds." sekunder)
"; break; case 3 : echo "Your search had ".$seek_hits." hits! Showing all hits! (".$seconds." seconds)
"; break; default : echo "".$seek_hits."-t nassaarineqarput! Nassaarineqartut tamarmik takutinneqarput! (".$seconds." sekund-it)
"; break; } // switch sprog } if(count($find_result_tekst) > 0) { if($sprog == 1) $sider = "Quppernerit"; elseif($sprog == 2) $sider = "Sider"; elseif($sprog == 3) $sider = "Pages"; ?>

".($i+1).". ".$titel."
".udsnit_af_tekst($tekst, $keyword, true)."

"; // spring ud af while hvis limited if($limit && $i==$limit_numbers) break; } ?>

0) { if($sprog == 1) $nyheder = "Nutaarsiassat"; elseif($sprog == 2) $nyheder = "Nyheder"; elseif($sprog == 3) $nyheder = "News"; ?>

".($i+1).". ".udsnit_af_tekst($titel, $keyword, false)."
".udsnit_af_tekst($tekst, $keyword, true)."

"; // spring ud af while hvis limited if($limit && $i==$limit_numbers) break; } ?>

Nutaarsiassat [Allagarsiivik]
"; elseif($sprog == 2) echo "
Nyheder [Nyhedsbrev]

"; else echo "
News [Newsletter]

"; // go get the last 20 news! if(!isset($_GET["start"])) $start = 0; else $start = $_GET["start"]; $jump = 7; $sql = "SELECT * FROM nyhedsmodul_nyheder ORDER BY dato DESC, tid DESC, id DESC LIMIT ".$start.", ".$jump; if(!$res_nyheder = mysql_query($sql)) nyhederDbFejl($sql); if(mysql_num_rows($res_nyheder) > 0) { ?>
Database-mi nutaarsiassaqanngilaq!\n"; elseif($sprog == 2) echo "
Der findes ingen nyheder i databasen!
\n"; else echo "
There are no news in the database!
\n"; } if($sprog == 1) $naeste = "Tullia"; elseif($sprog == 2) $naeste = "Næste"; elseif($sprog == 3) $naeste = "Next"; if($sprog == 1) $last = "Kingulia"; elseif($sprog == 2) $last = "Foregående"; elseif($sprog == 3) $last = "Last"; $sql = "SELECT id FROM nyhedsmodul_nyheder LIMIT ".($start+$jump).", ".$jump; if(!$res_tjek = mysql_query($sql)) nyhederDbFejl($sql); if(mysql_num_rows($res_tjek) > 0) $next_link = "".$naeste."»"; else $next_link = $naeste."»"; if($start > 0) $prev_link = "«".$last.""; else $prev_link = "«".$last; ?>

[Start]   
Nutaarsiassaq database-miik peerneqarnikuuvoq!
"; elseif($sprog == 2) echo "Nyheden er blevet slettet fra databasen!
"; else echo "This entry has been deleted!
"; exit(); } $dato = toBjarneDate(mysql_result($res_nyhed, 0, "dato")); $tid = mysql_result($res_nyhed, 0, "tid"); $hits = mysql_result($res_nyhed, 0, "visitors"); if(mysql_result($res_nyhed, 0, "er_aendret") == 1) { $aendret_dato = toBjarneDate(mysql_result($res_nyhed,0,"aendret_dato")); $aendret_forfatter = mysql_result($res_nyhed,0,"aendret_forfatter"); if($aendret_forfatter == "") $forfatter = "N/A"; else { $sql = "SELECT brugernavn FROM bruger WHERE user_id = ".$aendret_forfatter; if(!$res_brugernavn = mysql_query($sql)) nyhederDbFejl(__LINE__); if(mysql_num_rows($res_brugernavn) == 0) $forfatter = "N/A"; else $forfatter = mysql_result($res_brugernavn, 0, "brugernavn"); } if($sprog == 1) $aendret_tekst = " (Allanngortinneqarpoq ".$aendret_dato." ".mysql_result($res_nyhed,0,"aendret_tid")." ".$forfatter."-imik)"; elseif($sprog == 2) $aendret_tekst = " (Ændret ".$aendret_dato." ".mysql_result($res_nyhed,0,"aendret_tid")." af ".$forfatter.")"; else $aendret_tekst = " (Editited ".$aendret_dato." ".mysql_result($res_nyhed,0,"aendret_tid")." by ".$forfatter.")"; } else $aendret_tekst = ""; // hent forfatter $forfatter_id = mysql_result($res_nyhed, 0, "forfatter"); if($forfatter_id == "") $forfatter = "N/A"; else { $sql = "SELECT brugernavn FROM bruger WHERE user_id = ".$forfatter_id; if(!$res_brugernavn = mysql_query($sql)) nyhederDbFejl(__LINE__); if(mysql_num_rows($res_brugernavn) == 0) $forfatter = "N/A"; else $forfatter = mysql_result($res_brugernavn, 0, "brugernavn"); if($sprog == 1) $forfatter = "Allattoq: ".$forfatter; elseif($sprog == 2) $forfatter = "Skrevet af: ".$forfatter ; else $forfatter = "Written by ".$forfatter; } $sql = "SELECT titel, indhold FROM nyhedsmodul_indhold WHERE nyheds_id = ".$nyheds_id." AND sprog_id = ".$sprog.";"; if(!$res_nyhed = mysql_query($sql)) nyhederDbFejl($sql); $titel = mysql_result($res_nyhed, 0, "titel"); $indhold = mysql_result($res_nyhed, 0, "indhold"); ?>