routing.inc.php 1.71 KB
Newer Older
Lukas Fleischer's avatar
Lukas Fleischer committed
1
2
<?php

3
4
include_once("confparser.inc.php");

Lukas Fleischer's avatar
Lukas Fleischer committed
5
6
7
8
$ROUTES = array(
	'' => 'home.php',
	'/index.php' => 'home.php',
	'/packages' => 'packages.php',
9
	'/pkgbase' => 'pkgbase.php',
Lukas Fleischer's avatar
Lukas Fleischer committed
10
	'/requests' => 'pkgreq.php',
11
	'/register' => 'register.php',
12
	'/account' => 'account.php',
Lukas Fleischer's avatar
Lukas Fleischer committed
13
14
15
16
17
	'/accounts' => 'account.php',
	'/login' => 'login.php',
	'/logout' => 'logout.php',
	'/passreset' => 'passreset.php',
	'/rpc' => 'rpc.php',
hashworks's avatar
hashworks committed
18
	'/rss/modified' => 'modified-rss.php',
Lukas Fleischer's avatar
Lukas Fleischer committed
19
	'/rss' => 'rss.php',
20
	'/tos' => 'tos.php',
Lukas Fleischer's avatar
Lukas Fleischer committed
21
	'/tu' => 'tu.php',
22
	'/addvote' => 'addvote.php',
Lukas Fleischer's avatar
Lukas Fleischer committed
23
24
);

25
$PKG_PATH = '/packages';
26
$PKGBASE_PATH = '/pkgbase';
27
$PKGREQ_PATH = '/requests';
28
$USER_PATH = '/account';
29

Lukas Fleischer's avatar
Lukas Fleischer committed
30
31
32
function get_route($path) {
	global $ROUTES;

33
	$path = rtrim($path, '/');
Lukas Fleischer's avatar
Lukas Fleischer committed
34
35
36
37
38
39
40
	if (isset($ROUTES[$path])) {
		return $ROUTES[$path];
	} else {
		return NULL;
	}
}

41
42
43
44
45
46
function get_uri($path, $absolute=false) {
	if ($absolute) {
		return rtrim(aur_location(), '/') . $path;
	} else {
		return $path;
	}
Lukas Fleischer's avatar
Lukas Fleischer committed
47
}
48
49
50
51
52
53

function get_pkg_route() {
	global $PKG_PATH;
	return $PKG_PATH;
}

54
55
56
57
58
function get_pkgbase_route() {
	global $PKGBASE_PATH;
	return $PKGBASE_PATH;
}

59
60
61
62
63
function get_pkgreq_route() {
	global $PKGREQ_PATH;
	return $PKGREQ_PATH;
}

64
function get_pkg_uri($pkgname, $absolute=false) {
65
	global $PKG_PATH;
66
67
	$path = $PKG_PATH . '/' . urlencode($pkgname) . '/';
	return get_uri($path, $absolute);
68
}
69

70
function get_pkgbase_uri($pkgbase_name, $absolute=false) {
71
	global $PKGBASE_PATH;
72
73
	$path = $PKGBASE_PATH . '/' . urlencode($pkgbase_name) . '/';
	return get_uri($path, $absolute);
74
75
}

76
77
78
79
80
function get_user_route() {
	global $USER_PATH;
	return $USER_PATH;
}

81
function get_user_uri($username, $absolute=false) {
82
	global $USER_PATH;
83
84
	$path = $USER_PATH . '/' . urlencode($username) . '/';
	return get_uri($path, $absolute);
85
}