-
Notifications
You must be signed in to change notification settings - Fork 2
/
router.php
51 lines (50 loc) · 1.18 KB
/
router.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
<?php
$req=$_SERVER['REQUEST_URI'];
$p=strpos($req, '?');
if($p!==false)
$req=substr($req, 0, $p);
if($req=='/github' || $req=='/github/') {
header('Status: 301');
header('Location: https://github.com/MASCOTNUM');
exit;
}
$id=false;
$n=strlen($req);
$redirhtml=false;
if($n==5 && substr_compare($req,'/20',0,3)===0 && $req[3]>=0 && $req[3]<=9 && $req[4]>=0 && $req[4]<=9) {
$id='mascot'.substr($req,3);
} else if($req=='/dam.incertitudes') {
$id='forumincertitudes';
} else {
if(substr_compare($req, '.html', -5, 5)===0) {
$req=substr($req, 0, $n-5);
$n-=5;
$redirhtml=true;
}
for($i=1; $i<$n; ++$i)
if(!($req[$i]>='a' && $req[$i]<='z') &&
!($req[$i]>='A' && $req[$i]<='Z') &&
!($req[$i]>='0' && $req[$i]<='9') &&
$req[$i]!='_' && $req[$i]!='-' )
break;
if($i==$n)
$id=substr($req,1);
}
if($id===false) {
header('Status: 404');
print 'The requested resource has not been found. ';
exit;
} else if($redirhtml) {
header('Status: 302');
header('Location: '.$id);
} else {
$req=$_SERVER['REQUEST_URI'];
if($p!==false)
$qs=substr($req,$p+1);
parse_str($qs, $tab);
foreach($tab as $k=>$v) {
$_GET[$k]=$_REQUEST[$k]=$v;
}
$_GET['id']=$id;
include 'index.php';
}