<?php
function encodeurl($match)
{
$match = trim(str_replace ("ä", "ae;", $match));
$match = str_replace ("ö", "oe;", $match);
$match = str_replace ("ü", "ue;", $match);
$match = str_replace ("Ä", "Ae;", $match);
$match = str_replace ("Ö", "Oe;", $match);
$match = str_replace ("Ü", "Ue;", $match);
$match = str_replace('ß','ss', $match);
$match = str_replace('&auml;','ae', $match);
$match = str_replace('&ouml;','oe', $match);
$match = str_replace('&uuml;','ue', $match);
$match = str_replace('&ndash;','-', $match);
$match = str_replace('szlig;','ss', $match);
$match = str_replace('é','e', $match);
$match = str_replace("039","", $match);
$match = str_replace('eacute;','e', $match);
$match = preg_replace("|&#[0-9]{3,4};|",null, $match);
$match = str_replace('amp;','und', $match);
$match=urlencode(str_replace('--','-',str_replace('--','-', preg_replace('#[^A-Za-z0-9\s-]#',null, str_replace(' ','-',$match)))));

if (substr($match, -1) == '-') {
    $match = substr($match, 0, -1);
} 
return $match;
}
function decodeurl($match)
{
$match=urldecode($match);
$match = str_replace ("-", " " , $match);
$match = str_replace ("ae", "&auml;" , $match);
$match = str_replace ("oe", "&ouml;", $match);
$match = str_replace ("ue", "&uuml;", $match);
$match = str_replace ("Ae", "Ä;", $match);
$match = str_replace ("Oe", "Ö;", $match);
$match = str_replace ("UE", "Ü;", $match);
$match = str_replace('ß','ss', $match);
$match = str_replace('-','&ndash;', $match);
$match = preg_replace("|&#[0-9]{3,4};|",null, $match);
$match = str_replace('amp;','und', $match);

if (substr($match, -1) == '-') {
    $match = substr($match, 0, -1);
}return $match;}

function inStr ($needle, $haystack)
{
  $needlechars = strlen($needle); 
  $i = 0;
  for($i=0; $i < strlen($haystack); $i++) 
  {
    if(substr($haystack, $i, $needlechars) == $needle) 
    {
      return TRUE; 
    }
  }
  return FALSE;
}  
?>
