Do not show ".SRCINFO unchanged" warning on restore
[aur.git] / web / lib / routing.inc.php
blob8c45c6265cf7faeeb67c69c9c13998f405f2002f
1 <?php
3 include_once("confparser.inc.php");
5 $ROUTES = array(
6 '' => 'home.php',
7 '/index.php' => 'home.php',
8 '/packages' => 'packages.php',
9 '/pkgbase' => 'pkgbase.php',
10 '/requests' => 'pkgreq.php',
11 '/register' => 'register.php',
12 '/account' => 'account.php',
13 '/accounts' => 'account.php',
14 '/login' => 'login.php',
15 '/logout' => 'logout.php',
16 '/passreset' => 'passreset.php',
17 '/rpc' => 'rpc.php',
18 '/rss' => 'rss.php',
19 '/tu' => 'tu.php',
20 '/addvote' => 'addvote.php',
23 $PKG_PATH = '/packages';
24 $PKGBASE_PATH = '/pkgbase';
25 $PKGREQ_PATH = '/requests';
26 $USER_PATH = '/account';
28 function get_route($path) {
29 global $ROUTES;
31 $path = rtrim($path, '/');
32 if (isset($ROUTES[$path])) {
33 return $ROUTES[$path];
34 } else {
35 return NULL;
39 function get_uri($path, $absolute=false) {
40 if ($absolute) {
41 return rtrim(aur_location(), '/') . $path;
42 } else {
43 return $path;
47 function get_pkg_route() {
48 global $PKG_PATH;
49 return $PKG_PATH;
52 function get_pkgbase_route() {
53 global $PKGBASE_PATH;
54 return $PKGBASE_PATH;
57 function get_pkgreq_route() {
58 global $PKGREQ_PATH;
59 return $PKGREQ_PATH;
62 function get_pkg_uri($pkgname, $absolute=false) {
63 global $PKG_PATH;
64 $path = $PKG_PATH . '/' . urlencode($pkgname) . '/';
65 return get_uri($path, $absolute);
68 function get_pkgbase_uri($pkgbase_name, $absolute=false) {
69 global $PKGBASE_PATH;
70 $path = $PKGBASE_PATH . '/' . urlencode($pkgbase_name) . '/';
71 return get_uri($path, $absolute);
74 function get_user_route() {
75 global $USER_PATH;
76 return $USER_PATH;
79 function get_user_uri($username, $absolute=false) {
80 global $USER_PATH;
81 $path = $USER_PATH . '/' . urlencode($username) . '/';
82 return get_uri($path, $absolute);