Display an error page if a virtual path doesn't exist
[aur.git] / web / html / index.php
blob422c0e535b5e56d98430db6348dff756d50837ea
1 <?php
2 set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
4 include_once("aur.inc.php");
5 include_once("pkgfuncs.inc.php");
7 $path = $_SERVER['PATH_INFO'];
8 $tokens = explode('/', $path);
10 if (isset($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) {
11 if (isset($tokens[2])) {
12 /* TODO: Create a proper data structure to pass variables from
13 * the routing framework to the individual pages instead of
14 * initializing arbitrary variables here. */
15 $pkgname = $tokens[2];
16 $pkgid = pkgid_from_name($pkgname);
18 if (isset($tokens[3])) {
19 if ($tokens[3] == 'voters') {
20 $_GET['ID'] = pkgid_from_name($tokens[2]);
21 include('voters.php');
22 return;
25 /* TODO: Remove support for legacy URIs and move these
26 * actions to separate modules. */
27 switch ($tokens[3]) {
28 case "vote":
29 $_POST['do_Vote'] = __('Vote');
30 break;
31 case "unvote":
32 $_POST['do_UnVote'] = __('UnVote');
33 break;
34 case "notify":
35 $_POST['do_Notify'] = __('Notify');
36 break;
37 case "unnotify":
38 $_POST['do_UnNotify'] = __('UnNotify');
39 break;
40 case "flag":
41 $_POST['do_Flag'] = __('Flag');
42 break;
43 case "unflag":
44 $_POST['do_UnFlag'] = __('UnFlag');
45 break;
46 case "delete":
47 include('pkgdel.php');
48 return;
49 case "merge":
50 include('pkgmerge.php');
51 return;
54 if (isset($_COOKIE['AURSID'])) {
55 $_POST['token'] = $_COOKIE['AURSID'];
58 $_POST['IDs'] = array(pkgid_from_name($tokens[2]) => '1');
62 include get_route('/' . $tokens[1]);
63 } elseif (isset($tokens[1]) && '/' . $tokens[1] == get_user_route()) {
64 if (isset($tokens[2])) {
65 $_REQUEST['U'] = $tokens[2];
67 if (isset($tokens[3])) {
68 if ($tokens[3] == 'edit') {
69 $_REQUEST['Action'] = "DisplayAccount";
70 } elseif ($tokens[3] == 'update') {
71 $_REQUEST['Action'] = "UpdateAccount";
72 } else {
73 $_REQUEST['Action'] = "AccountInfo";
75 } else {
76 $_REQUEST['Action'] = "AccountInfo";
79 include get_route('/' . $tokens[1]);
80 } elseif (get_route($path) !== NULL) {
81 include get_route($path);
82 } else {
83 switch ($path) {
84 case "/css/archweb.css":
85 case "/css/aur.css":
86 case "/css/archnavbar/archnavbar.css":
87 header("Content-Type: text/css");
88 include "./$path";
89 break;
90 case "/css/archnavbar/archlogo.gif":
91 case "/images/new.png":
92 header("Content-Type: image/png");
93 include "./$path";
94 break;
95 case "/css/archnavbar/archlogo.png":
96 case "/images/AUR-logo-80.png":
97 case "/images/AUR-logo.png":
98 case "/images/favicon.ico":
99 case "/images/feed-icon-14x14.png":
100 case "/images/titlelogo.png":
101 case "/images/x.png":
102 header("Content-Type: image/png");
103 include "./$path";
104 break;
105 default:
106 header("HTTP/1.0 404 Not Found");
107 include "./404.php";
108 break;