Code: Alles auswählen
if (($board_config['enable_shorturls'] == 1) && ($userdata['user_id'] == ANONYMOUS))
{
ob_start();
function replace_for_mod_rewrite(&$s) {
// get the correct base_url: protocoll,url,path to make sure to rewrite only internal links
if (empty($HTTP_SERVER_VARS['HTTP_HOST'])) {
$server = getenv('HTTP_HOST');
} else {
$server = $HTTP_SERVER_VARS['HTTP_HOST'];
}
// IIS sets HTTPS=off
if (isset($HTTP_SERVER_VARS['HTTPS']) && $HTTP_SERVER_VARS['HTTPS'] != 'off') {
$proto = 'https://';
} else {
$proto = 'http://';
}
// Get the name of this URI
// Start of with REQUEST_URI
if (isset($HTTP_SERVER_VARS['REQUEST_URI'])) {
$path = $HTTP_SERVER_VARS['REQUEST_URI'];
} else {
$path = getenv('REQUEST_URI');
}
if ((empty($path)) || (substr($path, -1, 1) == '/')) {
// REQUEST_URI was empty or pointed to a path
// Try looking at PATH_INFO
$path = getenv('PATH_INFO');
if (empty($path)) {
// No luck there either
// Try SCRIPT_NAME
if (isset($HTTP_SERVER_VARS['SCRIPT_NAME'])) {
$path = $HTTP_SERVER_VARS['SCRIPT_NAME'];
} else {
$path = getenv('SCRIPT_NAME');
}
}
}
$path = preg_replace('/[#\?].*/', '', $path);
$path = dirname($path);
if (preg_match('!^[/\\\]*$!', $path)) {
$path = '';
}
$base_url = "$proto$server$path/";
$prefix = '|"(?:'.$base_url.')?';
// now that we know about the correct $prefix we can start the rewriting
$urlin = array(
//Forums
$prefix . '(?<!/)index.php\?f=([0-9]*)&ppage=([0-9]*)&sort=lastpost&order=DESC&start=([0-9]*)"|',
$prefix . '(?<!/)index.php\?f=([0-9]*)&ppage=([0-9]*)&sort=lastpost&order=DESC"|',
$prefix . '(?<!/)index.php\?f=([0-9]*)&mark=topics"|',
$prefix . '(?<!/)index.php\?mark=forums"|',
$prefix . '(?<!/)index.php\?f=([0-9]*)"|',
$prefix . '(?<!/)index.php"|',
//Forums ./
$prefix . '(?<!/)./index.php\?f=([0-9]*)&ppage=([0-9]*)&sort=lastpost&order=DESC&start=([0-9]*)"|',
$prefix . '(?<!/)./index.php\?f=([0-9]*)&ppage=([0-9]*)&sort=lastpost&order=DESC"|',
$prefix . '(?<!/)./index.php\?f=([0-9]*)&mark=topics"|',
$prefix . '(?<!/)./index.php\?mark=forums"|',
$prefix . '(?<!/)./index.php\?f=([0-9]*)"|',
$prefix . '(?<!/)./index.php"|',
//Topics
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&postdays=([0-9]*)&postorder=asc&start=([0-9]*)"|',
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&postdays=([0-9]*)&postorder=asc&vote=viewresult"|',
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&watch=topic&postorder=asc"|',
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&unwatch=topic&postorder=asc"|',
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&start=([0-9]*)"|',
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&unmark=topic"|',
$prefix . '(?<!/)viewtopic.php\?p=([0-9]*)&unmark=post"|',
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&view=newest"|',
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&postorder=asc&start=([0-9]*)"|',
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&view=previous"|',
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&view=next"|',
$prefix . '(?<!/)viewtopic.php\?p=([0-9]*)"|',
$prefix . '(?<!/)viewtopic.php\?p=([0-9]*)#([0-9]*)"|',
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)"|',
$prefix . '(?<!/)viewtopic.php\?printertopic=([0-9]*)(?:&)t=([0-9]*)(?:&)start=([0-9]*)(?:&)postdays=([0-9]*)(?:&)postorder=asc(?:&)vote=viewresult"|',
//Topics ./
$prefix . '(?<!/)./viewtopic.php\?t=([0-9]*)&postdays=([0-9]*)&postorder=asc&start=([0-9]*)"|',
$prefix . '(?<!/)./viewtopic.php\?t=([0-9]*)&postdays=([0-9]*)&postorder=asc&vote=viewresult"|',
$prefix . '(?<!/)./viewtopic.php\?t=([0-9]*)&watch=topic&postorder=asc"|',
$prefix . '(?<!/)./viewtopic.php\?t=([0-9]*)&unwatch=topic&postorder=asc"|',
$prefix . '(?<!/)./viewtopic.php\?t=([0-9]*)&start=([0-9]*)"|',
$prefix . '(?<!/)./viewtopic.php\?t=([0-9]*)&unmark=topic"|',
$prefix . '(?<!/)./viewtopic.php\?p=([0-9]*)&unmark=post"|',
$prefix . '(?<!/)./viewtopic.php\?t=([0-9]*)&view=newest"|',
$prefix . '(?<!/)./viewtopic.php\?t=([0-9]*)&postorder=asc&start=([0-9]*)"|',
$prefix . '(?<!/)./viewtopic.php\?t=([0-9]*)&view=previous"|',
$prefix . '(?<!/)./viewtopic.php\?t=([0-9]*)&view=next"|',
$prefix . '(?<!/)./viewtopic.php\?p=([0-9]*)"|',
$prefix . '(?<!/)./viewtopic.php\?p=([0-9]*)#([0-9]*)"|',
$prefix . '(?<!/)./viewtopic.php\?t=([0-9]*)"|',
$prefix . '(?<!/)./viewtopic.php\?printertopic=([0-9]*)&(?:amp;)t=([0-9]*)&(?:amp;)start=([0-9]*)&(?:amp;)postdays=([0-9]*)&(?:amp;)postorder=asc&(?:amp;)vote=viewresult"|',
// Adds
$prefix . '(?<!/)portal.php"|',
$prefix . '(?<!/)portal.php\?page=([0-9]*)"|',
$prefix . '(?<!/)posting.php\?mode=newtopic&(?:amp;)f=([0-9]*)"|',
$prefix . '(?<!/)posting.php\?mode=reply&(?:amp;)t=([0-9]*)"|',
$prefix . '(?<!/)posting.php\?mode=([a-z]*)&(?:amp;)p=([0-9]*)"|',
$prefix . '(?<!/)profile.php\?mode=viewprofile&(?:amp;)u=([0-9]*)"|',
$prefix . '(?<!/)search.php\?search_author=([[:alnum:]%+\.]+)"|',
$prefix . '(?<!/)search.php\?search_id=([0-9]*)&(?:amp;)start=([0-9]*)"|',
$prefix . '(?<!/)search.php\?search_id=([a-zA-Z]*)"|',
$prefix . '(?<!/)privmsg.php\?mode=([a-zA-Z]*)&(?:amp;)u=([0-9]*)"|',
$prefix . '(?<!/)privmsg.php\?folder=([a-zA-Z]*)"|',
$prefix . '(?<!/)profile.php\?mode=register&(?:amp;)agreed=true"|',
$prefix . '(?<!/)profile.php\?mode=([0-9a-zA-Z]*)"|',
$prefix . '(?<!/)faq.php"|',
$prefix . '(?<!/)recent.php"|',
$prefix . '(?<!/)recent.php\?mode=([0-9a-zA-Z]*)"|',
//$prefix . '(?<!/)recent.php\?mode=([0-9a-zA-Z]*)&(?:amp;)amount_days=([0-9]*)"|',
// Adds2
$prefix . '(?<!/)nickpage.php\?user=([[:alnum:]%+\.]+)"|',
$prefix . '(?<!/)nickpage_list.php"|',
$prefix . '(?<!/)usercars_list.php"|',
$prefix . '(?<!/)imageresize.php"|',
$prefix . '(?<!/)search.php"|',
$prefix . '(?<!/)memberlist.php"|',
$prefix . '(?<!/)memberlist.php\?level=([0-9]*)"|',
$prefix . '(?<!/)groupcp.php"|',
$prefix . '(?<!/)groupcp.php\?g=([0-9]*)"|',
$prefix . '(?<!/)calendar.php"|',
$prefix . '(?<!/)viewonline.php"|',
$prefix . '(?<!/)auc_listing.php\?id=([0-9]*)"|',
// Adds ./
$prefix . '(?<!/)./portal.php"|',
$prefix . '(?<!/)./portal.php\?page=([0-9]*)"|',
$prefix . '(?<!/)./posting.php\?mode=newtopic&(?:amp;)f=([0-9]*)"|',
$prefix . '(?<!/)./posting.php\?mode=reply&(?:amp;)t=([0-9]*)"|',
$prefix . '(?<!/)./posting.php\?mode=([a-z]*)&(?:amp;)p=([0-9]*)"|',
$prefix . '(?<!/)./profile.php\?mode=viewprofile&(?:amp;)u=([0-9]*)"|',
$prefix . '(?<!/)./search.php\?search_author=([[:alnum:]%+\.]+)"|',
$prefix . '(?<!/)./search.php\?search_id=([0-9]*)&(?:amp;)start=([0-9]*)"|',
$prefix . '(?<!/)./search.php\?search_id=([a-zA-Z]*)"|',
$prefix . '(?<!/)./privmsg.php\?mode=([a-zA-Z]*)&(?:amp;)u=([0-9]*)"|',
$prefix . '(?<!/)./privmsg.php\?folder=([a-zA-Z]*)"|',
$prefix . '(?<!/)./profile.php\?mode=register&(?:amp;)agreed=true"|',
$prefix . '(?<!/)./profile.php\?mode=([0-9a-zA-Z]*)"|',
$prefix . '(?<!/)./faq.php"|',
$prefix . '(?<!/)./recent.php"|',
$prefix . '(?<!/)./recent.php\?mode=([0-9a-zA-Z]*)"|',
//$prefix . '(?<!/)./recent.php\?mode=([0-9a-zA-Z]*)&(?:amp;)amount_days=([0-9]*)"|',
// Adds2 ./
$prefix . '(?<!/)./nickpage.php\?user=([[:alnum:]%+\.]+)"|',
$prefix . '(?<!/)./nickpage_list.php"|',
$prefix . '(?<!/)./usercars_list.php"|',
$prefix . '(?<!/)./imageresize.php"|',
$prefix . '(?<!/)./search.php"|',
$prefix . '(?<!/)./memberlist.php"|',
$prefix . '(?<!/)./memberlist.php\?level=([0-9]*)"|',
$prefix . '(?<!/)./groupcp.php"|',
$prefix . '(?<!/)./groupcp.php\?g=([0-9]*)"|',
$prefix . '(?<!/)./calendar.php"|',
$prefix . '(?<!/)./viewonline.php"|',
$prefix . '(?<!/)./auc_listing.php\?id=([0-9]*)"|',
);
$urlout = array(
//Forums
"forum-\\1-\\2-\\3.html",
"forum-\\1-\\2.html",
"mforum-\\1.html",
"mforums.html",
"forum-\\1.html",
"forums.html",
//Forums ./
"forum-\\1-\\2-\\3.html",
"forum-\\1-\\2.html",
"mforum-\\1.html",
"mforums.html",
"forum-\\1.html",
"forums.html",
//Topics
"topic-\\1-\\2-\\3.html",
"poll-\\1-\\2.html",
"wtopic-\\1.html",
"utopic-\\1.html",
"topic-\\1-\\2.html",
"uttopic\\1.html",
"uptopic\\1.html",
"newtopic\\1.html",
"topic-\\1-\\2.html",
"ptopic-\\1.html",
"ntopic-\\1.html",
"post-\\1.html",
"post-\\1.html#\\2",
"topic-\\1.html",
"print-\\1-\\2-\\3-\\4.html",
//Topics ./
"topic-\\1-\\2-\\3.html",
"poll-\\1-\\2.html",
"wtopic-\\1.html",
"utopic-\\1.html",
"topic-\\1-\\2.html",
"uttopic\\1.html",
"uptopic\\1.html",
"newtopic\\1.html",
"topic-\\1-\\2.html",
"ptopic-\\1.html",
"ntopic-\\1.html",
"post-\\1.html",
"post-\\1.html#\\2",
"topic-\\1.html",
"print-\\1-\\2-\\3-\\4.html",
// Adds
"index.html",
"index\\1.html",
"post-newtopic-\\1.html",
"post-reply-\\1.html",
"post-\\1-\\2.html",
"profile\\1.html",
"search-author-\\1.html",
"search-\\1-\\2.html",
"search-\\1.html",
"privmsg-\\1-\\2.html",
"privmsg-\\1.html",
"register.html",
"profile-\\1.html",
"faq.html",
"last-topics.html",
"last-topics-\\1.html",
//"last-topics-\\1-\\2.html",
// Adds2
"nickpage-\\1.html",
"nickpages.html",
"carlist.html",
"imageresize.html",
"search.html",
"memberlist.html",
"memberlist-\\1.html",
"groups.html",
"group-\\1.html",
"cal.html",
"online.html",
"memberslist-\\1.html",
// Adds ./
"index.html",
"index\\1.html",
"post-newtopic-\\1.html",
"post-reply-\\1.html",
"post-\\1-\\2.html",
"profile\\1.html",
"search-author-\\1.html",
"search-\\1-\\2.html",
"search-\\1.html",
"privmsg-\\1-\\2.html",
"privmsg-\\1.html",
"register.html",
"profile-\\1.html",
"faq.html",
"last-topics.html",
"last-topics-\\1.html",
//"last-topics-\\1-\\2.html",
// Adds2 ./
"nickpage-\\1.html",
"nickpages.html",
"carlist.html",
"imageresize.html",
"search.html",
"memberlist.html",
"memberlist-\\1.html",
"groups.html",
"group-\\1.html",
"cal.html",
"online.html",
"memberslist-\\1.html",
);
$s = preg_replace($urlin, $urlout, $s);
return $s;
}
}