Rewrite url if group changes section in thread.php and article-flat.php

This commit is contained in:
Retro_Guy 2021-04-01 23:23:14 -07:00
parent c1111c155d
commit 5f531dc6da
3 changed files with 42 additions and 0 deletions

View File

@ -12,6 +12,14 @@
// register parameters
$id=$_REQUEST["id"];
$group=_rawurldecode($_REQUEST["group"]);
$findsection = get_section_by_group($group);
if(trim($findsection) !== $config_name) {
$newurl = preg_replace("|/$config_name/|", "/$findsection/", $_SERVER['REQUEST_URI']);
header("Location: $newurl");
die();
}
if(isset($_REQUEST["first"]))
$first=$_REQUEST["first"];

View File

@ -336,6 +336,33 @@ function testGroup($groupname) {
}
}
function get_section_by_group($groupname) {
global $CONFIG, $config_dir;
$menulist = file($config_dir."menu.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach($menulist as $menu) {
if($menu[0] == '#') {
continue;
}
$menuitem=explode(':', $menu);
if($menuitem[1] == '0') {
continue;
}
$section = "";
$glfp=fopen($config_dir.$menuitem[0]."/groups.txt", 'r');
while($gl=fgets($glfp)) {
$group_name = preg_split("/( |\t)/", $gl, 2);
if(stripos(trim($groupname), trim($group_name[0])) !== false) {
fclose($glfp);
$section=$menuitem[0];
fclose($glfp);
return $section;
}
}
}
fclose($glfp);
return false;
}
function testGroups($newsgroups) {
$groups=explode(",",$newsgroups);
$count=count($groups);

View File

@ -15,6 +15,13 @@ if(isset($_REQUEST["first"]))
if(isset($_REQUEST["last"]))
$last=intval($_REQUEST["last"]);
$findsection = get_section_by_group($group);
if(trim($findsection) !== $config_name) {
$newurl = preg_replace("|/$config_name/|", "/$findsection/", $_SERVER['REQUEST_URI']);
header("Location: $newurl");
die();
}
$thread_show["latest"]=true;
$title.= ' - '.$group;
include "head.inc";