forked from vanilla/vanilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
showthread.php
62 lines (56 loc) · 1.55 KB
/
showthread.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Handles 301 redirecting urls from forums that were imported from phpBB or
* vBulletin into their Vanilla equivalent pages.
*/
$Redirects = array(
'post' => 'discussion/comment/%1$d#Comment_%1$d',
'thread' => 'discussion/%d/redirect/%s',
'category' => 'categories/%d',
'user' => 'dashboard/profile/%d/x'
);
$Type = NULL; $Index = 0;
if (array_key_exists('p', $_GET) && $Index = $_GET['p'])
$Type = 'post';
elseif (array_key_exists('t', $_GET) && $Index = $_GET['t'])
$Type = 'thread';
elseif (array_key_exists('f', $_GET) && $Index = $_GET['f'])
$Type = 'category';
elseif (array_key_exists('u', $_GET) && $Index = $_GET['u'])
$Type = 'user';
switch ($Type) {
case 'user':
case 'category':
case 'post':
$Redirect = sprintf($Redirects[$Type], $Index);
break;
case 'thread':
$HasPage = array_key_exists('page', $_GET);
$PageNumber = 1;
if ($HasPage) {
$OldPageNumber = $_GET['page'];
$Comments = 25 * $OldPageNumber;
$PageNumber = ceil($Comments / 40);
}
$PageKey = "p{$PageNumber}";
$Redirect = sprintf($Redirects[$Type], $Index, $PageKey);
break;
default:
$Type = 'home';
$Redirect = '/';
break;
}
if (!is_null($Type)) {
header("Location: {$Redirect}", TRUE, 301);
exit();
}
header("Location: index.php", TRUE, 301);
exit();
//$t = $_GET['t'];
//$p = $_GET['p'];
//
//if ($p) {
// header("Location: discussion/comment/$p", TRUE, 301);
//} else {
// header("Location: discussion/$t/x", TRUE, 301);
//}