Rename the AUR software to aurweb
[aur.git] / web / html / index.php
blobfad1d2f328e3581eadd71b72a053160da33fcf74
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 (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) {
11 if (!empty($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 = pkg_from_name($pkgname);
18 if (!$pkgid) {
19 header("HTTP/1.0 404 Not Found");
20 include "./404.php";
21 return;
25 include get_route('/' . $tokens[1]);
26 } elseif (!empty($tokens[1]) && '/' . $tokens[1] == get_pkgbase_route()) {
27 if (!empty($tokens[2])) {
28 /* TODO: Create a proper data structure to pass variables from
29 * the routing framework to the individual pages instead of
30 * initializing arbitrary variables here. */
31 $pkgbase_name = $tokens[2];
32 $base_id = pkgbase_from_name($pkgbase_name);
34 if (!$base_id) {
35 header("HTTP/1.0 404 Not Found");
36 include "./404.php";
37 return;
40 if (!empty($tokens[3])) {
41 /* TODO: Remove support for legacy URIs and move these
42 * actions to separate modules. */
43 switch ($tokens[3]) {
44 case "adopt":
45 $_POST['do_Adopt'] = __('Adopt');
46 break;
47 case "disown":
48 $_POST['do_Disown'] = __('Disown');
49 break;
50 case "vote":
51 $_POST['do_Vote'] = __('Vote');
52 break;
53 case "unvote":
54 $_POST['do_UnVote'] = __('UnVote');
55 break;
56 case "notify":
57 $_POST['do_Notify'] = __('Notify');
58 break;
59 case "unnotify":
60 $_POST['do_UnNotify'] = __('UnNotify');
61 break;
62 case "flag":
63 $_POST['do_Flag'] = __('Flag');
64 break;
65 case "unflag":
66 $_POST['do_UnFlag'] = __('UnFlag');
67 break;
68 case "delete":
69 include('pkgdel.php');
70 return;
71 case "merge":
72 include('pkgmerge.php');
73 return;
74 case "voters":
75 $_GET['N'] = $tokens[2];
76 include('voters.php');
77 return;
78 case "request":
79 include('pkgreq.php');
80 return;
81 case "comaintainers":
82 include('comaintainers.php');
83 return;
84 default:
85 header("HTTP/1.0 404 Not Found");
86 include "./404.php";
87 return;
90 $_POST['IDs'] = array(pkgbase_from_name($tokens[2]) => '1');
94 include get_route('/' . $tokens[1]);
95 } elseif (!empty($tokens[1]) && '/' . $tokens[1] == get_pkgreq_route()) {
96 if (!empty($tokens[2])) {
97 /* TODO: Create a proper data structure to pass variables from
98 * the routing framework to the individual pages instead of
99 * initializing arbitrary variables here. */
100 if (!empty($tokens[3]) && $tokens[3] == 'close') {
101 $pkgreq_id = $tokens[2];
102 } else {
103 $pkgreq_id = null;
106 if (!$pkgreq_id) {
107 header("HTTP/1.0 404 Not Found");
108 include "./404.php";
109 return;
113 include get_route('/' . $tokens[1]);
114 } elseif (!empty($tokens[1]) && '/' . $tokens[1] == get_user_route()) {
115 if (!empty($tokens[2])) {
116 $_REQUEST['ID'] = uid_from_username($tokens[2]);
118 if (!$_REQUEST['ID']) {
119 header("HTTP/1.0 404 Not Found");
120 include "./404.php";
121 return;
124 if (!empty($tokens[3])) {
125 if ($tokens[3] == 'edit') {
126 $_REQUEST['Action'] = "DisplayAccount";
127 } elseif ($tokens[3] == 'update') {
128 $_REQUEST['Action'] = "UpdateAccount";
129 } elseif ($tokens[3] == 'delete') {
130 $_REQUEST['Action'] = "DeleteAccount";
131 } else {
132 header("HTTP/1.0 404 Not Found");
133 include "./404.php";
134 return;
136 } else {
137 $_REQUEST['Action'] = "AccountInfo";
140 include get_route('/' . $tokens[1]);
141 } elseif (get_route($path) !== NULL) {
142 include get_route($path);
143 } else {
144 switch ($path) {
145 case "/css/archweb.css":
146 case "/css/aurweb.css":
147 case "/css/cgit.css":
148 case "/css/archnavbar/archnavbar.css":
149 header("Content-Type: text/css");
150 readfile("./$path");
151 break;
152 case "/css/archnavbar/archlogo.gif":
153 case "/images/new.png":
154 header("Content-Type: image/png");
155 readfile("./$path");
156 break;
157 case "/css/archnavbar/archlogo.png":
158 case "/css/archnavbar/aurlogo.png":
159 case "/images/AUR-logo-80.png":
160 case "/images/AUR-logo.png":
161 case "/images/favicon.ico":
162 case "/images/feed-icon-14x14.png":
163 case "/images/titlelogo.png":
164 case "/images/x.png":
165 header("Content-Type: image/png");
166 readfile("./$path");
167 break;
168 case "/js/bootstrap-typeahead.min.js":
169 header("Content-Type: application/javascript");
170 readfile("./$path");
171 break;
172 case "/packages.gz":
173 case "/pkgbase.gz":
174 header("Content-Type: text/plain");
175 header("Content-Encoding: gzip");
176 readfile("./$path");
177 break;
178 default:
179 header("HTTP/1.0 404 Not Found");
180 include "./404.php";
181 break;