Implement capability to pin comments above others
[aur.git] / web / html / index.php
blobe99d22f81ca872de73512085a486cf7f11b321e1
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 (config_get_bool('options', 'enable-maintenance') && (empty($tokens[1]) || ($tokens[1] != "css" && $tokens[1] != "images"))) {
11 if (!in_array($_SERVER['REMOTE_ADDR'], explode(" ", config_get('options', 'maintenance-exceptions')))) {
12 header("HTTP/1.0 503 Service Unavailable");
13 include "./503.php";
14 return;
18 if (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) {
19 if (!empty($tokens[2])) {
20 /* TODO: Create a proper data structure to pass variables from
21 * the routing framework to the individual pages instead of
22 * initializing arbitrary variables here. */
23 $pkgname = $tokens[2];
24 $pkgid = pkg_from_name($pkgname);
26 if (!$pkgid) {
27 header("HTTP/1.0 404 Not Found");
28 include "./404.php";
29 return;
33 include get_route('/' . $tokens[1]);
34 } elseif (!empty($tokens[1]) && '/' . $tokens[1] == get_pkgbase_route()) {
35 if (!empty($tokens[2])) {
36 /* TODO: Create a proper data structure to pass variables from
37 * the routing framework to the individual pages instead of
38 * initializing arbitrary variables here. */
39 $pkgbase_name = $tokens[2];
40 $base_id = pkgbase_from_name($pkgbase_name);
42 if (!$base_id) {
43 header("HTTP/1.0 404 Not Found");
44 include "./404.php";
45 return;
48 if (!empty($tokens[3])) {
49 /* TODO: Remove support for legacy URIs and move these
50 * actions to separate modules. */
51 switch ($tokens[3]) {
52 case "adopt":
53 $_POST['do_Adopt'] = __('Adopt');
54 break;
55 case "disown":
56 include('pkgdisown.php');
57 return;
58 case "vote":
59 $_POST['do_Vote'] = __('Vote');
60 break;
61 case "unvote":
62 $_POST['do_UnVote'] = __('UnVote');
63 break;
64 case "notify":
65 $_POST['do_Notify'] = __('Notify');
66 break;
67 case "unnotify":
68 $_POST['do_UnNotify'] = __('UnNotify');
69 break;
70 case "flag":
71 include('pkgflag.php');
72 return;
73 case "unflag":
74 $_POST['do_UnFlag'] = __('UnFlag');
75 break;
76 case "delete":
77 include('pkgdel.php');
78 return;
79 case "merge":
80 include('pkgmerge.php');
81 return;
82 case "voters":
83 $_GET['N'] = $tokens[2];
84 include('voters.php');
85 return;
86 case "request":
87 include('pkgreq.php');
88 return;
89 case "comaintainers":
90 include('comaintainers.php');
91 return;
92 case "edit-comment":
93 include('commentedit.php');
94 return;
95 default:
96 header("HTTP/1.0 404 Not Found");
97 include "./404.php";
98 return;
101 $_POST['IDs'] = array(pkgbase_from_name($tokens[2]) => '1');
105 include get_route('/' . $tokens[1]);
106 } elseif (!empty($tokens[1]) && '/' . $tokens[1] == get_pkgreq_route()) {
107 if (!empty($tokens[2])) {
108 /* TODO: Create a proper data structure to pass variables from
109 * the routing framework to the individual pages instead of
110 * initializing arbitrary variables here. */
111 if (!empty($tokens[3]) && $tokens[3] == 'close') {
112 $pkgreq_id = $tokens[2];
113 } else {
114 $pkgreq_id = null;
117 if (!$pkgreq_id) {
118 header("HTTP/1.0 404 Not Found");
119 include "./404.php";
120 return;
124 include get_route('/' . $tokens[1]);
125 } elseif (!empty($tokens[1]) && '/' . $tokens[1] == get_user_route()) {
126 if (!empty($tokens[2])) {
127 $_REQUEST['ID'] = uid_from_username($tokens[2]);
129 if (!$_REQUEST['ID']) {
130 header("HTTP/1.0 404 Not Found");
131 include "./404.php";
132 return;
135 if (!empty($tokens[3])) {
136 if ($tokens[3] == 'edit') {
137 $_REQUEST['Action'] = "DisplayAccount";
138 } elseif ($tokens[3] == 'update') {
139 $_REQUEST['Action'] = "UpdateAccount";
140 } elseif ($tokens[3] == 'delete') {
141 $_REQUEST['Action'] = "DeleteAccount";
142 } else {
143 header("HTTP/1.0 404 Not Found");
144 include "./404.php";
145 return;
147 } else {
148 $_REQUEST['Action'] = "AccountInfo";
151 include get_route('/' . $tokens[1]);
152 } elseif (get_route($path) !== NULL) {
153 include get_route($path);
154 } else {
155 switch ($path) {
156 case "/css/archweb.css":
157 case "/css/aurweb.css":
158 case "/css/cgit.css":
159 case "/css/archnavbar/archnavbar.css":
160 header("Content-Type: text/css");
161 readfile("./$path");
162 break;
163 case "/images/ajax-loader.gif":
164 header("Content-Type: image/gif");
165 readfile("./$path");
166 break;
167 case "/css/archnavbar/archlogo.gif":
168 case "/images/new.png":
169 header("Content-Type: image/png");
170 readfile("./$path");
171 break;
172 case "/css/archnavbar/archlogo.png":
173 case "/css/archnavbar/aurlogo.png":
174 case "/images/AUR-logo-80.png":
175 case "/images/AUR-logo.png":
176 case "/images/favicon.ico":
177 case "/images/feed-icon-14x14.png":
178 case "/images/titlelogo.png":
179 case "/images/x.png":
180 header("Content-Type: image/png");
181 readfile("./$path");
182 break;
183 case "/images/x.min.svg":
184 case "/images/pencil.min.svg":
185 case "/images/pin.min.svg":
186 case "/images/unpin.min.svg":
187 header("Content-Type: image/svg+xml");
188 readfile("./$path");
189 break;
190 case "/js/bootstrap-typeahead.min.js":
191 header("Content-Type: application/javascript");
192 readfile("./$path");
193 break;
194 case "/packages.gz":
195 case "/pkgbase.gz":
196 header("Content-Type: text/plain");
197 header("Content-Encoding: gzip");
198 readfile("./$path");
199 break;
200 default:
201 header("HTTP/1.0 404 Not Found");
202 include "./404.php";
203 break;