index.php 2.6 KB
Newer Older
1
<?php
2
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
pjmattal's avatar
pjmattal committed
3

4
5
include_once("aur.inc.php");
include_once("pkgfuncs.inc.php");
Lukas Fleischer's avatar
Lukas Fleischer committed
6

7
$path = $_SERVER['PATH_INFO'];
8
$tokens = explode('/', $path);
Lukas Fleischer's avatar
Lukas Fleischer committed
9

10
if (isset($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) {
11
	if (isset($tokens[2])) {
12
13
14
15
16
		/* TODO: Create a proper data structure to pass variables from
		 * the routing framework to the individual pages instead of
		 * initializing arbitrary variables here. */
		$pkgname = $tokens[2];
		$pkgid = pkgid_from_name($pkgname);
17
18

		if (isset($tokens[3])) {
19
20
21
22
23
24
			if ($tokens[3] == 'voters') {
				$_GET['ID'] = pkgid_from_name($tokens[2]);
				include('voters.php');
				return;
			}

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
			/* TODO: Remove support for legacy URIs and move these
			 * actions to separate modules. */
			switch ($tokens[3]) {
			case "vote":
				$_POST['do_Vote'] = __('Vote');
				break;
			case "unvote":
				$_POST['do_UnVote'] = __('UnVote');
				break;
			case "notify":
				$_POST['do_Notify'] = __('Notify');
				break;
			case "unnotify":
				$_POST['do_UnNotify'] = __('UnNotify');
				break;
			case "flag":
				$_POST['do_Flag'] = __('Flag');
				break;
			case "unflag":
				$_POST['do_UnFlag'] = __('UnFlag');
				break;
46
47
48
			case "delete":
				include('pkgdel.php');
				return;
49
50
51
			case "merge":
				include('pkgmerge.php');
				return;
52
53
			}

54
55
56
57
			if (isset($_COOKIE['AURSID'])) {
				$_POST['token'] = $_COOKIE['AURSID'];
			}

58
59
			$_POST['IDs'] = array(pkgid_from_name($tokens[2]) => '1');
		}
60
61
	}

62
63
64
65
	include get_route('/' . $tokens[1]);
} elseif (isset($tokens[1]) && '/' . $tokens[1] == get_user_route()) {
	if (isset($tokens[2])) {
		$_REQUEST['U'] = $tokens[2];
66
67
68
69

		if (isset($tokens[3])) {
			if ($tokens[3] == 'edit') {
				$_REQUEST['Action'] = "DisplayAccount";
70
71
			} elseif ($tokens[3] == 'update') {
				$_REQUEST['Action'] = "UpdateAccount";
72
73
74
			} else {
				$_REQUEST['Action'] = "AccountInfo";
			}
75
76
		} else {
			$_REQUEST['Action'] = "AccountInfo";
77
		}
78
	}
79
80
	include get_route('/' . $tokens[1]);
} elseif (get_route($path) !== NULL) {
Lukas Fleischer's avatar
Lukas Fleischer committed
81
82
83
84
85
86
87
88
89
90
	include get_route($path);
} else {
	switch ($path) {
	case "/css/archweb.css":
	case "/css/aur.css":
	case "/css/archnavbar/archnavbar.css":
		header("Content-Type: text/css");
		include "./$path";
		break;
	case "/css/archnavbar/archlogo.gif":
91
92
	case "/images/new.png":
		header("Content-Type: image/png");
Lukas Fleischer's avatar
Lukas Fleischer committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
		include "./$path";
		break;
	case "/css/archnavbar/archlogo.png":
	case "/images/AUR-logo-80.png":
	case "/images/AUR-logo.png":
	case "/images/favicon.ico":
	case "/images/feed-icon-14x14.png":
	case "/images/titlelogo.png":
	case "/images/x.png":
		header("Content-Type: image/png");
		include "./$path";
		break;
	}
}