mod rewrite

Visa första olästa
Ämnesverktyg
Visa huvudforum
Visningsalternativ
Oläst 2008-10-14, 00:05 #11
eidos-eidos- är inte uppkopplad
Medlem
Reg.datum: Nov 2003
Inlägg: 62
sorry...


Citat:

if ( !$userdata['session_logged_in'] )
{
ob_start();
function replace_for_mod_rewrite(&$s)
{
$urlin =
array(
"'(?<!/)viewforum.php\?f=([0-9]*)&topicdays=([0-9]*)&start=([0-9]*)'",
"'(?<!/)viewforum.php\?f=([0-9]*)&mark=topics'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&watch=topic*'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&unwatch=topic*'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&highlight=*'",
"'(?<!/)viewforum.php\?f=([0-9]*)'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&view=previous'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&view=next'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&postdays=([0-9]*)&postorder=([a-zA-Z]*)&vote=viewresult'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&postdays=([0-9]*)&postorder=([a-zA-Z]*)&start=([0-9]*)'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&start=([0-9]*)&postdays=([0-9]*)&postorder=([a-zA-Z]*)&highlight=([a-zA-Z0-9]*)'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&start=([0-9]*)'",
"'(?<!/)viewtopic.php\?t=([0-9]*)'",
"'(?<!/)viewtopic.php&p=([0-9]*)'",
"'(?<!/)viewtopic.php\?p=([0-9]*)'",
);
$urlout = array(
"topic-\\1-\\2-\\3.html",
"mark-forum\\1.html",
"updates-topic\\1.html",
"stop-updates-topic\\1.html",
"about\\1.html&highlight=\\2",
"forum-\\1.html",
"ptopic\\1.html",
"ntopic\\1.html",
"view-poll\\1-\\2-\\3.html",
"about\\1-\\2-\\3-\\4.html",
"about\\1.html",
"about\\1-\\2.html",
"about\\1.html",
"post-\\1.html",
"post-\\1.html",
);
$s = preg_replace($urlin, $urlout, $s);
return $s;
}
}
eidos- är inte uppkopplad
Oläst 2008-10-14, 00:44 #12
WizKidWizKid är inte uppkopplad
Mycket flitig postare
Reg.datum: Apr 2004
Inlägg: 618
a-zA-Z matchar inte åäö

men jag ser inte hur den koden skulle kunna generera: trningsjournal-vf19.html med tanke på att ingen replace skriver om till det.
WizKid är inte uppkopplad
Oläst 2008-10-14, 01:05 #13
eidos-eidos- är inte uppkopplad
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;

}
eidos- är inte uppkopplad
Aktiva användare som för närvarande tittar på det här ämnet: 0 (0 medlemmar och 0 gäster)