mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add routing front/back ends
This adds a URL mapping library that can be used to implement virtual paths. Also, "web/html/index.php" is moved to "web/html/home.php" and "web/html/index.php" becomes a routing front end that maps virtual paths to corresponding files. To enable the virtual path feature, all requests need to be redirected to the "index.php" routing script. If you use lighttpd, following rewrite rule can be used: url.rewrite = ( "^(.*)$" => "/index.php/$1" ) A similar rule can be used for Apache (using mod_rewrite). Note that the current routing front end only works if PATH_INFO is provided. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
f3ce74c714
commit
eb22bcc754
4 changed files with 196 additions and 118 deletions
123
web/html/home.php
Normal file
123
web/html/home.php
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
|
||||||
|
|
||||||
|
include_once("aur.inc.php");
|
||||||
|
set_lang();
|
||||||
|
check_sid();
|
||||||
|
|
||||||
|
include_once('stats.inc.php');
|
||||||
|
|
||||||
|
html_header( __("Home") );
|
||||||
|
|
||||||
|
$dbh = db_connect();
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div id="content-left-wrapper">
|
||||||
|
<div id="content-left">
|
||||||
|
<div id="intro" class="box">
|
||||||
|
<h2>AUR <?php print __("Home"); ?></h2>
|
||||||
|
<p>
|
||||||
|
<?php
|
||||||
|
echo __(
|
||||||
|
'Welcome to the AUR! Please read the %sAUR User Guidelines%s and %sAUR TU Guidelines%s for more information.',
|
||||||
|
'<a href="http://wiki.archlinux.org/index.php/AUR_User_Guidelines">',
|
||||||
|
'</a>',
|
||||||
|
'<a href="http://wiki.archlinux.org/index.php/AUR_Trusted_User_Guidelines">',
|
||||||
|
'</a>'
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<?php
|
||||||
|
echo __(
|
||||||
|
'Contributed PKGBUILDs %smust%s conform to the %sArch Packaging Standards%s otherwise they will be deleted!',
|
||||||
|
'<b>', '</b>',
|
||||||
|
'<a href="http://wiki.archlinux.org/index.php/Arch_Packaging_Standards">',
|
||||||
|
'</a>'
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<?php echo __('Remember to vote for your favourite packages!'); ?>
|
||||||
|
<?php echo __('Some packages may be provided as binaries in [community].'); ?>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<h4><?php echo __('Discussion') ?></h4>
|
||||||
|
<?php
|
||||||
|
echo __(
|
||||||
|
'General discussion regarding the Arch User Repository (AUR) and Trusted User structure takes place on %saur-general%s. This list can be used for package orphan requests, merge requests, and deletion requests. For discussion relating to the development of the AUR, use the %saur-dev%s mailing list.',
|
||||||
|
'<a href="http://mailman.archlinux.org/mailman/listinfo/aur-general">',
|
||||||
|
'</a>',
|
||||||
|
'<a href="http://mailman.archlinux.org/mailman/listinfo/aur-dev">',
|
||||||
|
'</a>'
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
<h4><?php echo __('Bug Reporting') ?></h4>
|
||||||
|
<?php
|
||||||
|
echo __(
|
||||||
|
'If you find a bug in the AUR, please fill out a bug report on our %sbug tracker%s. Use the tracker to report bugs in the AUR %sonly%s. To report packaging bugs contact the package maintainer or leave a comment on the appropriate package page.',
|
||||||
|
'<a href="https://bugs.archlinux.org/index.php?project=2">',
|
||||||
|
'</a>',
|
||||||
|
'<strong>',
|
||||||
|
'</strong>'
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="important">
|
||||||
|
<b><?php echo __('DISCLAIMER') ?> :</b>
|
||||||
|
<br />
|
||||||
|
<?php echo __('Unsupported packages are user produced content. Any use of the provided files is at your own risk.'); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php if (!empty($_COOKIE["AURSID"])): ?>
|
||||||
|
<div id="pkg-updates" class="widget box">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="pkg-name">
|
||||||
|
<?php
|
||||||
|
$userid = uid_from_sid($_COOKIE["AURSID"]);
|
||||||
|
user_table($userid, $dbh);
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="content-right">
|
||||||
|
<div id="pkgsearch" class="widget">
|
||||||
|
<form id="pkgsearch-form" method="get" action="packages.php">
|
||||||
|
<fieldset>
|
||||||
|
<label for="pkgsearch-field">Package Search:</label>
|
||||||
|
<input type="hidden" name="O" value="0" />
|
||||||
|
<input type="text" name="K" size="30" value="<?php if (isset($_REQUEST["K"])) { print stripslashes(trim(htmlspecialchars($_REQUEST["K"], ENT_QUOTES))); } ?>" maxlength="35" />
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div id="pkg-updates" class="widget box">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="pkg-name">
|
||||||
|
<?php updates_table($dbh); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div id="pkg-updates" class="widget box">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="pkg-name">
|
||||||
|
<?php general_stats_table($dbh); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
html_footer(AUR_VERSION);
|
|
@ -1,123 +1,35 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
|
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
|
||||||
|
|
||||||
include_once("aur.inc.php");
|
include_once("config.inc.php");
|
||||||
set_lang();
|
include_once("routing.inc.php");
|
||||||
check_sid();
|
|
||||||
|
|
||||||
include_once('stats.inc.php');
|
$path = rtrim($_SERVER['PATH_INFO'], '/');
|
||||||
|
|
||||||
html_header( __("Home") );
|
if (get_route($path) !== NULL) {
|
||||||
|
include get_route($path);
|
||||||
$dbh = db_connect();
|
} else {
|
||||||
|
switch ($path) {
|
||||||
?>
|
case "/css/archweb.css":
|
||||||
|
case "/css/aur.css":
|
||||||
<div id="content-left-wrapper">
|
case "/css/archnavbar/archnavbar.css":
|
||||||
<div id="content-left">
|
header("Content-Type: text/css");
|
||||||
<div id="intro" class="box">
|
include "./$path";
|
||||||
<h2>AUR <?php print __("Home"); ?></h2>
|
break;
|
||||||
<p>
|
case "/css/archnavbar/archlogo.gif":
|
||||||
<?php
|
case "/images/new.gif":
|
||||||
echo __(
|
header("Content-Type: image/gif");
|
||||||
'Welcome to the AUR! Please read the %sAUR User Guidelines%s and %sAUR TU Guidelines%s for more information.',
|
include "./$path";
|
||||||
'<a href="http://wiki.archlinux.org/index.php/AUR_User_Guidelines">',
|
break;
|
||||||
'</a>',
|
case "/css/archnavbar/archlogo.png":
|
||||||
'<a href="http://wiki.archlinux.org/index.php/AUR_Trusted_User_Guidelines">',
|
case "/images/AUR-logo-80.png":
|
||||||
'</a>'
|
case "/images/AUR-logo.png":
|
||||||
);
|
case "/images/favicon.ico":
|
||||||
?>
|
case "/images/feed-icon-14x14.png":
|
||||||
</p>
|
case "/images/titlelogo.png":
|
||||||
<p>
|
case "/images/x.png":
|
||||||
<?php
|
header("Content-Type: image/png");
|
||||||
echo __(
|
include "./$path";
|
||||||
'Contributed PKGBUILDs %smust%s conform to the %sArch Packaging Standards%s otherwise they will be deleted!',
|
break;
|
||||||
'<b>', '</b>',
|
}
|
||||||
'<a href="http://wiki.archlinux.org/index.php/Arch_Packaging_Standards">',
|
}
|
||||||
'</a>'
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<?php echo __('Remember to vote for your favourite packages!'); ?>
|
|
||||||
<?php echo __('Some packages may be provided as binaries in [community].'); ?>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<h4><?php echo __('Discussion') ?></h4>
|
|
||||||
<?php
|
|
||||||
echo __(
|
|
||||||
'General discussion regarding the Arch User Repository (AUR) and Trusted User structure takes place on %saur-general%s. This list can be used for package orphan requests, merge requests, and deletion requests. For discussion relating to the development of the AUR, use the %saur-dev%s mailing list.',
|
|
||||||
'<a href="http://mailman.archlinux.org/mailman/listinfo/aur-general">',
|
|
||||||
'</a>',
|
|
||||||
'<a href="http://mailman.archlinux.org/mailman/listinfo/aur-dev">',
|
|
||||||
'</a>'
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
</p>
|
|
||||||
<h4><?php echo __('Bug Reporting') ?></h4>
|
|
||||||
<?php
|
|
||||||
echo __(
|
|
||||||
'If you find a bug in the AUR, please fill out a bug report on our %sbug tracker%s. Use the tracker to report bugs in the AUR %sonly%s. To report packaging bugs contact the package maintainer or leave a comment on the appropriate package page.',
|
|
||||||
'<a href="https://bugs.archlinux.org/index.php?project=2">',
|
|
||||||
'</a>',
|
|
||||||
'<strong>',
|
|
||||||
'</strong>'
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="important">
|
|
||||||
<b><?php echo __('DISCLAIMER') ?> :</b>
|
|
||||||
<br />
|
|
||||||
<?php echo __('Unsupported packages are user produced content. Any use of the provided files is at your own risk.'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php if (!empty($_COOKIE["AURSID"])): ?>
|
|
||||||
<div id="pkg-updates" class="widget box">
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td class="pkg-name">
|
|
||||||
<?php
|
|
||||||
$userid = uid_from_sid($_COOKIE["AURSID"]);
|
|
||||||
user_table($userid, $dbh);
|
|
||||||
?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="content-right">
|
|
||||||
<div id="pkgsearch" class="widget">
|
|
||||||
<form id="pkgsearch-form" method="get" action="packages.php">
|
|
||||||
<fieldset>
|
|
||||||
<label for="pkgsearch-field">Package Search:</label>
|
|
||||||
<input type="hidden" name="O" value="0" />
|
|
||||||
<input type="text" name="K" size="30" value="<?php if (isset($_REQUEST["K"])) { print stripslashes(trim(htmlspecialchars($_REQUEST["K"], ENT_QUOTES))); } ?>" maxlength="35" />
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div id="pkg-updates" class="widget box">
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td class="pkg-name">
|
|
||||||
<?php updates_table($dbh); ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div id="pkg-updates" class="widget box">
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td class="pkg-name">
|
|
||||||
<?php general_stats_table($dbh); ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
html_footer(AUR_VERSION);
|
|
||||||
|
|
|
@ -51,3 +51,7 @@ $DISABLE_HTTP_LOGIN = true;
|
||||||
|
|
||||||
# Web URL used in email links and absolute redirects, no trailing slash
|
# Web URL used in email links and absolute redirects, no trailing slash
|
||||||
$AUR_LOCATION = "http://localhost";
|
$AUR_LOCATION = "http://localhost";
|
||||||
|
|
||||||
|
# Use virtual URLs -- to enable this feature, you also need to tell your web
|
||||||
|
# server to redirect all requests to "/index.php/$uri".
|
||||||
|
$USE_VIRTUAL_URLS = true;
|
||||||
|
|
39
web/lib/routing.inc.php
Normal file
39
web/lib/routing.inc.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$ROUTES = array(
|
||||||
|
'' => 'home.php',
|
||||||
|
'/index.php' => 'home.php',
|
||||||
|
'/packages' => 'packages.php',
|
||||||
|
'/register' => 'account.php',
|
||||||
|
'/accounts' => 'account.php',
|
||||||
|
'/login' => 'login.php',
|
||||||
|
'/logout' => 'logout.php',
|
||||||
|
'/passreset' => 'passreset.php',
|
||||||
|
'/rpc' => 'rpc.php',
|
||||||
|
'/rss' => 'rss.php',
|
||||||
|
'/submit' => 'pkgsubmit.php',
|
||||||
|
'/tu' => 'tu.php',
|
||||||
|
'/voters' => 'voters.php',
|
||||||
|
'/addvote' => 'addvote.php',
|
||||||
|
);
|
||||||
|
|
||||||
|
function get_route($path) {
|
||||||
|
global $ROUTES;
|
||||||
|
|
||||||
|
if (isset($ROUTES[$path])) {
|
||||||
|
return $ROUTES[$path];
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_uri($path) {
|
||||||
|
global $USE_VIRTUAL_URLS;
|
||||||
|
global $ROUTES;
|
||||||
|
|
||||||
|
if ($USE_VIRTUAL_URLS) {
|
||||||
|
return $path;
|
||||||
|
} else {
|
||||||
|
return get_route($path);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue