Medlem
|
|
Reg.datum: Nov 2003
Inlägg: 62
|
|
Medlem
Reg.datum: Nov 2003
Inlägg: 62
|
här kanske
Citat:
function make_url_friendly($url)
{
$url = strtolower($url);
$find = array(' ',
'&',
'\r\n',
'\n',
'/',
'\\',
'+');
$url = str_replace ($find, '-', $url);
$find = array(' ',
'é',
'è',
'ë',
'ê');
$url = str_replace ($find, 'e', $url);
$find = array(' ',
'ó',
'ò',
'ô',
'ö');
$url = str_replace ($find, 'o', $url);
$find = array(' ',
'á',
'à',
'â',
'ä');
$url = str_replace ($find, 'a', $url);
$find = array(' ',
'í',
'ì',
'î',
'ï');
$url = str_replace ($find, 'i', $url);
$find = array(' ',
'ú',
'ù',
'û',
'ü');
$url = str_replace ($find, 'u', $url);
$find = array('/[^a-z0-9\-<>]/',
'/[\-]+/',
'/<[^>]*>/');
$repl = array('',
'-',
'');
$url = preg_replace ($find, $repl, $url);
return $url;
}
function rewrite_urls($content)
{
function if_query($amp)
{
if($amp != '')
{
return '?';
}
}
$url_in = array('/(?<!\/)viewforum.php\?f=([0-9]+)((& |(&)){0,1}([^>]+>)(.*?)<\/a>/e',
'/(?<!\/)viewtopic.php\?p=([0-9]+)((& |(&)){0,1}([^>]+>)(.*?)<\/a>/e',
'/(?<!\/)viewtopic.php\?t=([0-9]+)((& |(&)){0,1}([^>]+>)(.*?)<\/a>/e');
$url_out = array("make_url_friendly('\\6') . '-vf\\1.html' . if_query('\\2') . stripslashes('\\5\\6') . '</a>'",
"make_url_friendly('\\6') . '-vp\\1.html' . if_query('\\2') . stripslashes('\\5\\6') . '</a>'",
"make_url_friendly('\\6') . '-vt\\1.html' . if_query('\\2') . stripslashes('\\5\\6') . '</a>'");
$content = preg_replace($url_in, $url_out, $content);
return $content;
}
|
|