[aur-dev] [PATCH 0/6] [RFC] Virtual path feature
This implements nicer looking URLs, such as "/packages/" instead of "/packages.php", "/packages/$pkgname/" instead of "/packages.php?ID=$id" etc. Note that these patches are not ready to be merged yet but I'd like to get some comments. We'd probably also have to add rewrite rules to our AUR setup on sigurd or add legacy rules to the routing back end to ensure old URLs still work. Lukas Fleischer (6): Add routing front/back ends Use absolute URIs for style sheets and images Use virtual path feature for links Use virtual paths for package details Redirect to the home page after successful login web/html/pkgsubmit.php: Remove stray "</div>" web/html/addvote.php | 2 +- web/html/home.php | 123 ++++++++++++++++++++++++ web/html/index.php | 160 ++++++++------------------------ web/html/login.php | 4 +- web/html/logout.php | 2 +- web/html/passreset.php | 6 +- web/html/pkgsubmit.php | 6 +- web/html/tu.php | 8 +- web/html/voters.php | 4 +- web/lib/acctfuncs.inc.php | 6 +- web/lib/config.inc.php.proto | 4 + web/lib/pkgfuncs.inc.php | 7 +- web/lib/routing.inc.php | 57 ++++++++++++ web/template/account_details.php | 2 +- web/template/account_edit_form.php | 2 +- web/template/account_search_results.php | 8 +- web/template/actions_form.php | 2 +- web/template/header.php | 26 +++--- web/template/pkg_comments.php | 8 +- web/template/pkg_details.php | 14 +-- web/template/pkg_search_form.php | 2 +- web/template/pkg_search_results.php | 10 +- web/template/search_accounts_form.php | 2 +- web/template/stats/updates_table.php | 2 +- web/template/stats/user_table.php | 4 +- web/template/tu_details.php | 4 +- web/template/tu_list.php | 4 +- 27 files changed, 291 insertions(+), 188 deletions(-) create mode 100644 web/html/home.php create mode 100644 web/lib/routing.inc.php -- 1.7.11.2
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> --- web/html/home.php | 123 ++++++++++++++++++++++++++++++++++ web/html/index.php | 152 +++++++++---------------------------------- web/lib/config.inc.php.proto | 4 ++ web/lib/routing.inc.php | 39 +++++++++++ 4 files changed, 198 insertions(+), 120 deletions(-) create mode 100644 web/html/home.php create mode 100644 web/lib/routing.inc.php diff --git a/web/html/home.php b/web/html/home.php new file mode 100644 index 0000000..48f5e00 --- /dev/null +++ b/web/html/home.php @@ -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); diff --git a/web/html/index.php b/web/html/index.php index 48f5e00..b0f346d 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -1,123 +1,35 @@ <?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); +include_once("config.inc.php"); +include_once("routing.inc.php"); + +$path = rtrim($_SERVER['PATH_INFO'], '/'); + +if (get_route($path) !== NULL) { + 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": + case "/images/new.gif": + header("Content-Type: image/gif"); + 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; + } +} diff --git a/web/lib/config.inc.php.proto b/web/lib/config.inc.php.proto index 1e2699e..fee1022 100644 --- a/web/lib/config.inc.php.proto +++ b/web/lib/config.inc.php.proto @@ -51,3 +51,7 @@ $DISABLE_HTTP_LOGIN = true; # Web URL used in email links and absolute redirects, no trailing slash $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; diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php new file mode 100644 index 0000000..0d940a2 --- /dev/null +++ b/web/lib/routing.inc.php @@ -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); + } +} -- 1.7.11.2
This is needed for our new URI scheme, since we will use virtual directories, such as "/packages/" instead of "/packages.php" etc. Having relative URIs results in incorrect paths, such as "/packages/css/aur.css" (instead of "/css/aur.css"). Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/template/header.php | 6 +++--- web/template/pkg_comments.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/template/header.php b/web/template/header.php index 6dd52f7..246b304 100644 --- a/web/template/header.php +++ b/web/template/header.php @@ -5,9 +5,9 @@ xml:lang="<?php print htmlspecialchars($LANG, ENT_QUOTES) ?>" lang="<?php print htmlspecialchars($LANG, ENT_QUOTES) ?>"> <head> <title>AUR (<?php print htmlspecialchars($LANG); ?>)<?php if ($title != "") { print " - " . htmlspecialchars($title); } ?></title> - <link rel='stylesheet' type='text/css' href='css/archweb.css' /> - <link rel='stylesheet' type='text/css' href='css/aur.css' /> - <link rel='shortcut icon' href='images/favicon.ico' /> + <link rel='stylesheet' type='text/css' href='/css/archweb.css' /> + <link rel='stylesheet' type='text/css' href='/css/aur.css' /> + <link rel='shortcut icon' href='/images/favicon.ico' /> <link rel='alternate' type='application/rss+xml' title='Newest Packages RSS' href='rss.php' /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index 02f4963..b2d9ca5 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -19,7 +19,7 @@ $count = package_comments_count($_GET['ID']); <input type="hidden" name="action" value="do_DeleteComment" /> <input type="hidden" name="comment_id" value="<?php echo $row['ID'] ?>" /> <input type="hidden" name="token" value="<?php echo htmlspecialchars($_COOKIE['AURSID']) ?>" /> - <input type="image" src="images/x.png" alt="<?php echo __('Delete comment') ?> name="submit" value="1" /> + <input type="image" src="/images/x.png" alt="<?php echo __('Delete comment') ?> name="submit" value="1" /> </fieldset> </form> <?php endif; ?> -- 1.7.11.2
Op zondag 15 juli 2012 23:23:51 schreef Lukas Fleischer:
This is needed for our new URI scheme, since we will use virtual directories, such as "/packages/" instead of "/packages.php" etc.
Having relative URIs results in incorrect paths, such as "/packages/css/aur.css" (instead of "/css/aur.css").
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/template/header.php | 6 +++--- web/template/pkg_comments.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/web/template/header.php b/web/template/header.php index 6dd52f7..246b304 100644 --- a/web/template/header.php +++ b/web/template/header.php @@ -5,9 +5,9 @@ xml:lang="<?php print htmlspecialchars($LANG, ENT_QUOTES) ?>" lang="<?php print htmlspecialchars($LANG, ENT_QUOTES) ?>"> <head> <title>AUR (<?php print htmlspecialchars($LANG); ?>)<?php if ($title != "") { print " - " . htmlspecialchars($title); } ?></title> - <link rel='stylesheet' type='text/css' href='css/archweb.css' /> - <link rel='stylesheet' type='text/css' href='css/aur.css' /> - <link rel='shortcut icon' href='images/favicon.ico' /> + <link rel='stylesheet' type='text/css' href='/css/archweb.css' /> + <link rel='stylesheet' type='text/css' href='/css/aur.css' /> + <link rel='shortcut icon' href='/images/favicon.ico' /> <link rel='alternate' type='application/rss+xml' title='Newest Packages RSS' href='rss.php' /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index 02f4963..b2d9ca5 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -19,7 +19,7 @@ $count = package_comments_count($_GET['ID']); <input type="hidden" name="action" value="do_DeleteComment" /> <input type="hidden" name="comment_id" value="<?php echo $row['ID'] ?>" /> <input type="hidden" name="token" value="<?php echo htmlspecialchars($_COOKIE['AURSID']) ?>" /> - <input type="image" src="images/x.png" alt="<?php echo __('Delete comment') ?> name="submit" value="1" /> + <input type="image" src="/images/x.png" alt="<?php echo __('Delete comment') ?> name="submit" value="1" /> </fieldset> </form> <?php endif; ?>
maybe a suggestion to use a general BASEPATH defined, and use this as a prefix this would make sure the code is more portable. example: + <link rel='stylesheet' type='text/css' href='<?php echo BASEPATH;?>css/archweb.css' /> --Ike
Use virtual paths in links (e.g. link to "/packages/" instead of "/packages.php" etc.) if the virtual path feature is enabled. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/addvote.php | 2 +- web/html/home.php | 2 +- web/html/login.php | 4 ++-- web/html/logout.php | 2 +- web/html/passreset.php | 6 +++--- web/html/pkgsubmit.php | 4 ++-- web/html/tu.php | 8 ++++---- web/html/voters.php | 4 ++-- web/lib/acctfuncs.inc.php | 4 ++-- web/lib/pkgfuncs.inc.php | 6 +++--- web/template/account_details.php | 2 +- web/template/account_edit_form.php | 2 +- web/template/account_search_results.php | 8 ++++---- web/template/actions_form.php | 2 +- web/template/header.php | 20 ++++++++++---------- web/template/pkg_comments.php | 4 ++-- web/template/pkg_details.php | 14 +++++++------- web/template/pkg_search_form.php | 2 +- web/template/pkg_search_results.php | 10 +++++----- web/template/search_accounts_form.php | 2 +- web/template/stats/updates_table.php | 2 +- web/template/stats/user_table.php | 4 ++-- web/template/tu_details.php | 4 ++-- web/template/tu_list.php | 4 ++-- 24 files changed, 61 insertions(+), 61 deletions(-) diff --git a/web/html/addvote.php b/web/html/addvote.php index d3bd7d4..d1cd809 100644 --- a/web/html/addvote.php +++ b/web/html/addvote.php @@ -68,7 +68,7 @@ if ($atype == "Trusted User" || $atype == "Developer") { <div class="box"> <h2><?php print __("Submit a proposal to vote on.") ?></h2> - <form action="addvote.php" method="post"> + <form action="<?php echo get_uri('/addvote/'); ?>" method="post"> <p> <b><?php print __("Applicant/TU") ?></b> <input type="text" name="user" value="<?php if (!empty($_POST['user'])) { print htmlentities($_POST['user'], ENT_QUOTES); } ?>" /> diff --git a/web/html/home.php b/web/html/home.php index 48f5e00..df112b8 100644 --- a/web/html/home.php +++ b/web/html/home.php @@ -91,7 +91,7 @@ $dbh = db_connect(); </div> <div id="content-right"> <div id="pkgsearch" class="widget"> - <form id="pkgsearch-form" method="get" action="packages.php"> + <form id="pkgsearch-form" method="get" action="<?php get_uri('/packages/'); ?>"> <fieldset> <label for="pkgsearch-field">Package Search:</label> <input type="hidden" name="O" value="0" /> diff --git a/web/html/login.php b/web/html/login.php index 7f4f342..9c6a546 100644 --- a/web/html/login.php +++ b/web/html/login.php @@ -17,7 +17,7 @@ html_header('AUR ' . __("Login")); <?php if (isset($_COOKIE["AURSID"])): ?> <p> <?php echo __("Logged-in as: %s", '<strong>' . username_from_sid($_COOKIE["AURSID"]) . '</strong>'); ?> - <a href="logout.php">[<?php print __("Logout"); ?>]</a> + <a href="<?php get_uri('/logout/'); ?>">[<?php print __("Logout"); ?>]</a> </p> <?php elseif (!$DISABLE_HTTP_LOGIN || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'])): ?> <form method="post" action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES) ?>"> @@ -40,7 +40,7 @@ html_header('AUR ' . __("Login")); </p> <p> <input type="submit" class="button" value="<?php print __("Login"); ?>" /> - <a href="passreset.php">[<?php echo __('Forgot Password') ?>]</a> + <a href="<?php echo get_uri('/passreset/') ?>">[<?php echo __('Forgot Password') ?>]</a> </p> </fieldset> </form> diff --git a/web/html/logout.php b/web/html/logout.php index fe8ffb0..835f1c9 100644 --- a/web/html/logout.php +++ b/web/html/logout.php @@ -20,5 +20,5 @@ if (isset($_COOKIE["AURSID"])) { clear_expired_sessions($dbh); } -header('Location: index.php'); +header('Location: /'); diff --git a/web/html/passreset.php b/web/html/passreset.php index cb88e5a..9fca505 100644 --- a/web/html/passreset.php +++ b/web/html/passreset.php @@ -8,7 +8,7 @@ set_lang(); # this sets up the visitor's language check_sid(); # see if they're still logged in if (isset($_COOKIE["AURSID"])) { - header('Location: index.php'); + header('Location: /'); exit(); } @@ -48,14 +48,14 @@ if (isset($_GET['resetkey'], $_POST['email'], $_POST['password'], $_POST['confir 'your password follow the link below, otherwise ignore '. 'this message and nothing will happen.'). "\n\n". - "{$AUR_LOCATION}/passreset.php?". + "{$AUR_LOCATION}/" . get_uri('/passreset/') . "?". "resetkey={$resetkey}"; $body = wordwrap($body, 70); $headers = "Reply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR"; @mail($email, 'AUR Password Reset', $body, $headers); } - header('Location: passreset.php?step=confirm'); + header('Location: ' . get_uri('/passreset/') . '?step=confirm'); exit(); } diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 65e2f6d..8c93b0c 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -400,7 +400,7 @@ if ($uid): # Entire package creation process is atomic end_atomic_commit($dbh); - header('Location: packages.php?ID=' . $packageID); + header('Location: ' . get_uri('/packages/') . '?ID=' . $packageID); } chdir($cwd); @@ -429,7 +429,7 @@ html_header("Submit"); $pkg_categories = pkgCategories(); ?> -<form action="pkgsubmit.php" method="post" enctype="multipart/form-data"> +<form action="<?php echo get_uri('/submit/'); ?>" method="post" enctype="multipart/form-data"> <fieldset> <div> <input type="hidden" name="pkgsubmit" value="1" /> diff --git a/web/html/tu.php b/web/html/tu.php index 8619903..084a223 100644 --- a/web/html/tu.php +++ b/web/html/tu.php @@ -116,17 +116,17 @@ if ($atype == "Trusted User" || $atype == "Developer") { $nextresult = proposal_count(); ?> <div class="box"> - <p><a href="addvote.php"><?php print __("Add Proposal") ?></a></p> + <p><a href="<?php echo get_uri('/addvote/'); ?>"><?php print __("Add Proposal") ?></a></p> <?php if ($result): $by = htmlentities($by, ENT_QUOTES); ?> <?php if ($off != 0): $back = (($off - $limit) <= 0) ? 0 : $off - $limit; ?> - <a href='tu.php?off=<?php print $back ?>&by=<?php print $by ?>'><?php print __("Back") ?></a> + <a href='<?php echo get_uri('/tu/'); ?>?off=<?php print $back ?>&by=<?php print $by ?>'><?php print __("Back") ?></a> <?php endif; ?> <?php if (($off + $limit) < $nextresult): $forw = $off + $limit; ?> - <a href="tu.php?off=<?php print $forw ?>&by=<?php print $by ?>"><?php print __("Next") ?></a> + <a href="<?php echo get_uri('/tu/'); ?>?off=<?php print $forw ?>&by=<?php print $by ?>"><?php print __("Next") ?></a> <?php endif; ?> <?php endif; ?> </div> @@ -134,7 +134,7 @@ if ($atype == "Trusted User" || $atype == "Developer") { } } else { - header('Location: index.php'); + header('Location: /'); } html_footer(AUR_VERSION); diff --git a/web/html/voters.php b/web/html/voters.php index 231e323..378e605 100644 --- a/web/html/voters.php +++ b/web/html/voters.php @@ -15,12 +15,12 @@ if ($atype == 'Trusted User' || $atype== 'Developer'): ?> <div class="box"> - <h2>Votes for <a href="packages.php?ID=<?php echo $pkgid ?>"><?php echo pkgname_from_id($pkgid) ?></a></h2> + <h2>Votes for <a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $pkgid ?>"><?php echo pkgname_from_id($pkgid) ?></a></h2> <div class="boxbody"> <?php while (list($indx, $row) = each($votes)): ?> - <a href="account.php?Action=AccountInfo&ID=<?php echo $row['UsersID'] ?>"><?php echo htmlspecialchars($row['Username']) ?></a><br /> + <a href="<?php echo get_uri('/account/'); ?>?Action=AccountInfo&ID=<?php echo $row['UsersID'] ?>"><?php echo htmlspecialchars($row['Username']) ?></a><br /> <?php endwhile; ?> </div> </div> diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index a41a4e7..fcc6a60 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -545,7 +545,7 @@ function password_reset($hash, $salt, $resetkey, $email, $dbh=NULL) { $error = __('Invalid e-mail and reset key combination.'); return $error; } else { - header('Location: passreset.php?step=complete'); + header('Location: ' . get_uri('/passreset/') . '?step=complete'); exit(); } } @@ -817,7 +817,7 @@ function voter_list($voteid, $dbh=NULL) { $result = db_query($q, $dbh); if ($result) { while ($row = mysql_fetch_assoc($result)) { - $whovoted.= '<a href="account.php?Action=AccountInfo&ID='.$row['UserID'].'">'.$row['Username'].'</a> '; + $whovoted.= '<a href="' . get_uri('/accounts/') . '?Action=AccountInfo&ID='.$row['UserID'].'">'.$row['Username'].'</a> '; } } return $whovoted; diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index 0009b93..bdf8976 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -238,7 +238,7 @@ function add_package_comment($pkgid, $uid, $comment, $dbh=NULL) { # Simply making these strings translatable won't work, users would be # getting emails in the language that the user who posted the comment was in $body = - 'from ' . $AUR_LOCATION . '/packages.php?ID=' + 'from ' . $AUR_LOCATION . '/' . get_uri('/packages/') . '?ID=' . $pkgid . "\n" . username_from_sid($_COOKIE['AURSID'], $dbh) . " wrote:\n\n" . $comment @@ -744,7 +744,7 @@ function pkg_flag ($atype, $ids, $action=true, $dbh=NULL) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { # construct email - $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\n" . $AUR_LOCATION . "/packages.php?ID=" . $row['ID'] . "\n\n[1] - " . $AUR_LOCATION . "/account.php?Action=AccountInfo&ID=" . $f_uid; + $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\n" . $AUR_LOCATION . "/" . get_uri('/packages/') . "?ID=" . $row['ID'] . "\n\n[1] - " . $AUR_LOCATION . "/" . get_uri('/accounts/') . "?Action=AccountInfo&ID=" . $f_uid; $body = wordwrap($body, 70); $headers = "Reply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n"; @mail($row['Email'], "AUR Out-of-date Notification for ".$row['Name'], $body, $headers); @@ -813,7 +813,7 @@ function pkg_delete ($atype, $ids, $mergepkgid, $dbh=NULL) { $body = ""; if ($mergepkgid) { $body .= username_from_sid($_COOKIE['AURSID']) . " merged \"".$pkgname."\" into \"$mergepkgname\".\n\n"; - $body .= "You will no longer receive notifications about this package, please go to https://aur.archlinux.org/packages.php?ID=".$mergepkgid." and click the Notify button if you wish to recieve them again."; + $body .= "You will no longer receive notifications about this package, please go to https://aur.archlinux.org/" . get_uri('/packages/') . "?ID=".$mergepkgid." and click the Notify button if you wish to recieve them again."; } else { $body .= username_from_sid($_COOKIE['AURSID']) . " deleted \"".$pkgname."\".\n\n"; $body .= "You will no longer receive notifications about this package."; diff --git a/web/template/account_details.php b/web/template/account_details.php index f4c31c6..8551533 100644 --- a/web/template/account_details.php +++ b/web/template/account_details.php @@ -51,7 +51,7 @@ </tr> <tr> - <td colspan="2"><a href="packages.php?K=<?php echo $row['Username'] ?>&SeB=m"><?php echo __("View this user's packages") ?></a></td> + <td colspan="2"><a href="<?php echo get_uri('/packages/'); ?>?K=<?php echo $row['Username'] ?>&SeB=m"><?php echo __("View this user's packages") ?></a></td> </tr> </table> diff --git a/web/template/account_edit_form.php b/web/template/account_edit_form.php index c32eb94..fd58f84 100644 --- a/web/template/account_edit_form.php +++ b/web/template/account_edit_form.php @@ -1,4 +1,4 @@ -<form action="account.php" method="post"> +<form action="<?php echo get_uri('/account/'); ?>" method="post"> <fieldset> <input type="hidden" name="Action" value="<?php echo $A ?>" /> <?php if ($UID): ?> diff --git a/web/template/account_search_results.php b/web/template/account_search_results.php index f2ed62e..cc2a1c2 100644 --- a/web/template/account_search_results.php +++ b/web/template/account_search_results.php @@ -28,7 +28,7 @@ else: ?> <tbody> <tr class ="<?php echo $c ?>"> - <td><a href="packages.php?SeB=m&K=<?php echo $row["Username"] ?>"><?php echo $row["Username"] ?></a></td> + <td><a href="<?php echo get_uri('/packages/'); ?>?SeB=m&K=<?php echo $row["Username"] ?>"><?php echo $row["Username"] ?></a></td> <td><?php echo $row["AccountType"] ?></td> <td> <?php @@ -50,7 +50,7 @@ else: print " "; else: ?> - <a href="account.php?Action=DisplayAccount&ID=<?php echo $row["ID"] ?>"><?php echo __("Edit") ?></a> + <a href="<?php echo get_uri('/account/'); ?>?Action=DisplayAccount&ID=<?php echo $row["ID"] ?>"><?php echo __("Edit") ?></a> <?php endif; ?> </td> </tr> @@ -63,7 +63,7 @@ else: <table class="results"> <tr> <td align="left"> - <form action="account.php" method="post"> + <form action="<?php echo get_uri('/account/'); ?>" method="post"> <fieldset> <input type="hidden" name="Action" value="SearchAccounts" /> <input type="hidden" name="O" value="<?php echo ($OFFSET-$HITS_PER_PAGE) ?>" /> @@ -78,7 +78,7 @@ else: </form> </td> <td align="right"> - <form action="account.php" method="post"> + <form action="<?php echo get_uri('/account/'); ?>" method="post"> <fieldset> <input type="hidden" name="Action" value="SearchAccounts" /> <input type="hidden" name="O" value="<?php echo ($OFFSET+$HITS_PER_PAGE) ?>" /> diff --git a/web/template/actions_form.php b/web/template/actions_form.php index ff0fd4e..9cd5024 100644 --- a/web/template/actions_form.php +++ b/web/template/actions_form.php @@ -1,5 +1,5 @@ <div class="box"> - <form action="packages.php?ID=<?php echo $row['ID'] ?>" method="post"> + <form action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row['ID'] ?>" method="post"> <fieldset> <input type="hidden" name="IDs[<?php echo $row['ID'] ?>]" value="1" /> <input type="hidden" name="ID" value="<?php echo $row['ID'] ?>" /> diff --git a/web/template/header.php b/web/template/header.php index 246b304..52c0ab8 100644 --- a/web/template/header.php +++ b/web/template/header.php @@ -8,7 +8,7 @@ <link rel='stylesheet' type='text/css' href='/css/archweb.css' /> <link rel='stylesheet' type='text/css' href='/css/aur.css' /> <link rel='shortcut icon' href='/images/favicon.ico' /> - <link rel='alternate' type='application/rss+xml' title='Newest Packages RSS' href='rss.php' /> + <link rel='alternate' type='application/rss+xml' title='Newest Packages RSS' href='<?php echo get_uri('/rss/'); ?>' /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> @@ -50,17 +50,17 @@ </div> <div id="archdev-navbar"> <ul> - <li><a href="index.php">AUR <?php print __("Home"); ?></a></li> - <li><a href="packages.php"><?php print __("Packages"); ?></a></li> + <li><a href="<?php echo get_uri('/'); ?>">AUR <?php print __("Home"); ?></a></li> + <li><a href="<?php echo get_uri('/packages/'); ?>"><?php print __("Packages"); ?></a></li> <?php if (isset($_COOKIE['AURSID'])): ?> - <li><a href="packages.php?SeB=m&K=<?php print username_from_sid($_COOKIE["AURSID"]); ?>"><?php print __("My Packages"); ?></a></li> - <li><a href="pkgsubmit.php"><?php print __("Submit"); ?></a></li> - <li><a href="account.php"><?php print __("Accounts"); ?></a></li> - <?php if (check_user_privileges()): ?><li><a href="tu.php"><?php print __("Trusted User"); ?></a></li><?php endif; ?> - <li><a href="logout.php"><?php print __("Logout"); ?></a></li> + <li><a href="<?php echo get_uri('/packages/'); ?>?SeB=m&K=<?php print username_from_sid($_COOKIE["AURSID"]); ?>"><?php print __("My Packages"); ?></a></li> + <li><a href="<?php echo get_uri('/submit/'); ?>"><?php print __("Submit"); ?></a></li> + <li><a href="<?php echo get_uri('/accounts/'); ?>"><?php print __("Accounts"); ?></a></li> + <?php if (check_user_privileges()): ?><li><a href="<?php echo get_uri('/tu/'); ?>"><?php print __("Trusted User"); ?></a></li><?php endif; ?> + <li><a href="<?php echo get_uri('/logout/'); ?>"><?php print __("Logout"); ?></a></li> <?php else: ?> - <li><a href="account.php"><?php print __("Register"); ?></a></li> - <li><a href="login.php"><?php print __("Login"); ?></a></li> + <li><a href="<?php echo get_uri('/register/'); ?>"><?php print __("Register"); ?></a></li> + <li><a href="<?php echo get_uri('/login/'); ?>"><?php print __("Login"); ?></a></li> <?php endif; ?> </ul> </div><!-- #archdev-navbar --> diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index b2d9ca5..5b5f610 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -10,11 +10,11 @@ $count = package_comments_count($_GET['ID']); <?php while (list($indx, $row) = each($comments)): ?> <?php if ($SID): - $row['UserName'] = "<a href=\"account.php?Action=AccountInfo&ID={$row['UsersID']}\">{$row['UserName']}</a>"; + $row['UserName'] = "<a href=\"<?php echo get_uri('/account/'); ?>?Action=AccountInfo&ID={$row['UsersID']}\">{$row['UserName']}</a>"; endif; ?> <h4> <?php if (canDeleteCommentArray($row, $atype, $uid)): ?> - <form method="post" action="packages.php?ID=<?php echo $row['ID'] ?>"> + <form method="post" action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row['ID'] ?>"> <fieldset style="display:inline;"> <input type="hidden" name="action" value="do_DeleteComment" /> <input type="hidden" name="comment_id" value="<?php echo $row['ID'] ?>" /> diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index b41fded..4cb8602 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -57,7 +57,7 @@ if ($SID && ($uid == $row["MaintainerUID"] || ($atype == "Developer" || $atype == "Trusted User"))): ?> <td> - <form method="post" action="packages.php?ID=<?php echo $pkgid ?>"> + <form method="post" action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $pkgid ?>"> <div> <input type="hidden" name="action" value="do_ChangeCategory" /> <?php if ($SID): ?> @@ -75,7 +75,7 @@ if ($SID && ($uid == $row["MaintainerUID"] || </form> <?php else: ?> <td> - <a href="packages.php?C=<?php echo $row['CategoryID'] ?>"><?php print $row['Category'] ?></a> + <a href="<?php echo get_uri('/packages/'); ?>?C=<?php echo $row['CategoryID'] ?>"><?php print $row['Category'] ?></a> <?php endif; ?> </td> <tr> @@ -88,7 +88,7 @@ if ($SID && ($uid == $row["MaintainerUID"] || if ($row["SubmitterUID"]): if ($SID): ?> - <td><a href="account.php?Action=AccountInfo&ID=<?php echo htmlspecialchars($row['SubmitterUID'], ENT_QUOTES) ?>" title="<?php echo __('View account information for')?> <?php echo htmlspecialchars($submitter) ?>"><?php echo htmlspecialchars($submitter) ?></a></td> + <td><a href="<?php echo get_uri('/account/'); ?>?Action=AccountInfo&ID=<?php echo htmlspecialchars($row['SubmitterUID'], ENT_QUOTES) ?>" title="<?php echo __('View account information for')?> <?php echo htmlspecialchars($submitter) ?>"><?php echo htmlspecialchars($submitter) ?></a></td> <?php else: ?> <td><?php echo htmlspecialchars($submitter) ?></td> <?php endif; ?> @@ -101,7 +101,7 @@ if ($row["SubmitterUID"]): if ($row["MaintainerUID"]): if ($SID): ?> - <td><a href="account.php?Action=AccountInfo&ID=<?php echo htmlspecialchars($row['MaintainerUID'], ENT_QUOTES) ?>" title="<?php echo __('View account information for')?> <?php echo htmlspecialchars($maintainer) ?>"><?php echo htmlspecialchars($maintainer) ?></a></td> + <td><a href="<?php echo get_uri('/account/'); ?>?Action=AccountInfo&ID=<?php echo htmlspecialchars($row['MaintainerUID'], ENT_QUOTES) ?>" title="<?php echo __('View account information for')?> <?php echo htmlspecialchars($maintainer) ?>"><?php echo htmlspecialchars($maintainer) ?></a></td> <?php else: ?> <td><?php echo htmlspecialchars($maintainer) ?></td> <?php endif; ?> @@ -114,7 +114,7 @@ if ($row["MaintainerUID"]): <?php if ($atype == "Developer" || $atype == "Trusted User"): ?> - <td><a href="voters.php?ID=<?php echo$pkgid ?>"><?php echo $votes ?></a> + <td><a href="<?php echo get_uri('/voters/'); ?>?ID=<?php echo$pkgid ?>"><?php echo $votes ?></a> <?php else: ?> <td><?php echo $votes ?></td> <?php endif; ?> @@ -139,7 +139,7 @@ if ($atype == "Developer" || $atype == "Trusted User"): # darr: (DepName, DepCondition, PackageID), where ID is NULL if it didn't exist if (!is_null($darr[2])): ?> - <li><a href="packages.php?ID=<?php echo $darr[2]?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1]?>"><?php echo $darr[0].$darr[1]?></a></li> + <li><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $darr[2]?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1]?>"><?php echo $darr[0].$darr[1]?></a></li> <?php else: ?> <li><a href="http://www.archlinux.org/packages/?q=<?php echo urlencode($darr[0])?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1] ?>"><?php echo $darr[0].$darr[1] ?></a></li> <?php endif; ?> @@ -155,7 +155,7 @@ if ($atype == "Developer" || $atype == "Trusted User"): # darr: (PackageName, PackageID) while (list($k, $darr) = each($requiredby)): ?> - <li><a href="packages.php?ID=<?php echo $darr[1] ?>" title="<?php echo __('View packages details for').' '.$darr[0]?>"><?php echo $darr[0] ?></a></li> + <li><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $darr[1] ?>" title="<?php echo __('View packages details for').' '.$darr[0]?>"><?php echo $darr[0] ?></a></li> <?php endwhile; ?> </ul> <?php endif; ?> diff --git a/web/template/pkg_search_form.php b/web/template/pkg_search_form.php index 7997bb1..3f90088 100644 --- a/web/template/pkg_search_form.php +++ b/web/template/pkg_search_form.php @@ -36,7 +36,7 @@ $pages = array(50, 100, 250); <div id="pkglist-search" class="box filter-criteria"> <h2><?php print __("Search Criteria"); ?></h2> -<form action='packages.php' method='get'> +<form action='<?php echo get_uri('/packages/'); ?>' method='get'> <p><input type='hidden' name='O' value='0' /></p> <fieldset> diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php index 9076675..440698b 100644 --- a/web/template/pkg_search_results.php +++ b/web/template/pkg_search_results.php @@ -20,13 +20,13 @@ if (!$result): ?> <?php elseif ($pagestart + 1 == $first): ?> <span class="page"><?php echo $pagenr ?></span> <?php else: ?> - <a class="page" href="packages.php?<?php echo mkurl('O=' . $pagestart) ?>"><?php echo $pagenr ?></a> + <a class="page" href="<?php echo get_uri('/packages/'); ?>?<?php echo mkurl('O=' . $pagestart) ?>"><?php echo $pagenr ?></a> <?php endif; ?> <?php endforeach; ?> </p> </div> - <form id="pkglist-results-form" method="post" action="packages.php?<?php echo htmlentities($_SERVER['QUERY_STRING']) ?>"> + <form id="pkglist-results-form" method="post" action="<?php echo get_uri('/packages/'); ?>?<?php echo htmlentities($_SERVER['QUERY_STRING']) ?>"> <table class="results"> <thead> <tr> @@ -52,7 +52,7 @@ if (!$result): ?> <td><input type="checkbox" name="IDs[<?php echo $row["ID"] ?>]" value="1" /></td> <?php endif; ?> <td><?php echo htmlspecialchars($row["Category"]) ?></td> - <td><a href="packages.php?ID=<?php echo $row["ID"] ?>"><?php echo htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]) ?></a></td> + <td><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row["ID"] ?>"><?php echo htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]) ?></a></td> <td><?php echo $row["NumVotes"] ?></td> <?php if ($SID): ?> <td> @@ -69,7 +69,7 @@ if (!$result): ?> <td><?php echo htmlspecialchars($row['Description'], ENT_QUOTES); ?></td> <td> <?php if (isset($row["Maintainer"])): ?> - <a href="packages.php?K=<?php echo htmlspecialchars($row['Maintainer'], ENT_QUOTES) ?>&SeB=m"><?php echo htmlspecialchars($row['Maintainer']) ?></a> + <a href="<?php echo get_uri('/packages/'); ?>?K=<?php echo htmlspecialchars($row['Maintainer'], ENT_QUOTES) ?>&SeB=m"><?php echo htmlspecialchars($row['Maintainer']) ?></a> <?php else: ?> <span><?php echo __("orphan") ?></span> <?php endif; ?> @@ -90,7 +90,7 @@ if (!$result): ?> <?php elseif ($pagestart + 1 == $first): ?> <span class="page"><?php echo $pagenr ?></span> <?php else: ?> - <a class="page" href="packages.php?<?php echo mkurl('O=' . $pagestart) ?>"><?php echo $pagenr ?></a> + <a class="page" href="<?php echo get_uri('/packages/'); ?>?<?php echo mkurl('O=' . $pagestart) ?>"><?php echo $pagenr ?></a> <?php endif; ?> <?php endforeach; ?> </p> diff --git a/web/template/search_accounts_form.php b/web/template/search_accounts_form.php index 9e8c241..3080ecd 100644 --- a/web/template/search_accounts_form.php +++ b/web/template/search_accounts_form.php @@ -1,5 +1,5 @@ <br /> -<form action="account.php" method="post"> +<form action="<?php echo get_uri('/account/'); ?>" method="post"> <table> <tr> diff --git a/web/template/stats/updates_table.php b/web/template/stats/updates_table.php index b942dbc..835d956 100644 --- a/web/template/stats/updates_table.php +++ b/web/template/stats/updates_table.php @@ -6,7 +6,7 @@ <?php foreach ($newest_packages->getIterator() as $row): ?> <tr> <td> - <a href="packages.php?ID=<?php print intval($row["ID"]); ?>"><?php print htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]); ?></a> + <a href="<?php echo get_uri('/packages/'); ?>?ID=<?php print intval($row["ID"]); ?>"><?php print htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]); ?></a> </td> <td> <span><?php print gmdate("Y-m-d H:i", intval($row["ModifiedTS"])); ?></span> diff --git a/web/template/stats/user_table.php b/web/template/stats/user_table.php index 0882119..3620798 100644 --- a/web/template/stats/user_table.php +++ b/web/template/stats/user_table.php @@ -7,14 +7,14 @@ $username = username_from_sid($_COOKIE["AURSID"]); <table> <tr> <td> - <a href="packages.php?SeB=m&L=2&K=<?php echo $username; ?>"> + <a href="<?php echo get_uri('/packages/'); ?>?SeB=m&L=2&K=<?php echo $username; ?>"> <?php print __("Packages in unsupported"); ?></a> </td> <td><?php print $maintainer_unsupported_count; ?></td> </tr> <tr> <td> - <a href="packages.php?SeB=m&outdated=on&K=<?php echo $username; ?>"><?php print __("Out of Date"); ?></a> + <a href="<?php echo get_uri('/packages/'); ?>?SeB=m&outdated=on&K=<?php echo $username; ?>"><?php print __("Out of Date"); ?></a> </td> <td><?php echo $flagged_outdated ?></td> </tr> diff --git a/web/template/tu_details.php b/web/template/tu_details.php index 38015e1..3ec05ad 100644 --- a/web/template/tu_details.php +++ b/web/template/tu_details.php @@ -11,7 +11,7 @@ <?php echo __("User") ?>: <b> <?php if (!empty($row['User'])): ?> - <a href="packages.php?K=<?php print $row['User'] ?>&SeB=m"><?php print $row['User'] ?></a> + <a href="<?php echo get_uri('/packages/'); ?>?K=<?php print $row['User'] ?>&SeB=m"><?php print $row['User'] ?></a> <?php else: ?> N/A <?php endif; ?> @@ -61,7 +61,7 @@ <div class="box"> <?php if ($canvote == 1): ?> - <form action="tu.php?id=<?php print $row['ID'] ?>" method="post"> + <form action="<?php echo get_uri('/tu/'); ?>?id=<?php print $row['ID'] ?>" method="post"> <fieldset> <input type="submit" class="button" name="voteYes" value="<?php print __("Yes") ?>" /> <input type="submit" class="button" name="voteNo" value="<?php print __("No") ?>" /> diff --git a/web/template/tu_list.php b/web/template/tu_list.php index ce19da3..eed7f74 100644 --- a/web/template/tu_list.php +++ b/web/template/tu_list.php @@ -25,13 +25,13 @@ ?> <tr class="<?php print $c ?>"> <td><?php $row["Agenda"] = htmlspecialchars(substr($row["Agenda"], 0, $prev_Len)); ?> - <a href="tu.php?id=<?php print $row['ID'] ?>"><?php print $row["Agenda"] ?></a></span></span> + <a href="<?php echo get_uri('/tu/'); ?>?id=<?php print $row['ID'] ?>"><?php print $row["Agenda"] ?></a></span></span> </td> <td><?php print gmdate("Y-m-d", $row["Submitted"]) ?></td> <td><?php print gmdate("Y-m-d", $row["End"]) ?></td> <td> <?php if (!empty($row['User'])): ?> - <a href="packages.php?K=<?php echo $row['User'] ?>&SeB=m"><?php echo $row['User'] ?></a> + <a href="<?php echo get_uri('/packages/'); ?>?K=<?php echo $row['User'] ?>&SeB=m"><?php echo $row['User'] ?></a> <?php else: print "N/A"; endif; -- 1.7.11.2
Extend the routing front/back ends to allow for using "/package/$pkgname/" for individual packages. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/index.php | 10 +++++++++- web/html/pkgsubmit.php | 2 +- web/html/voters.php | 2 +- web/lib/pkgfuncs.inc.php | 7 +++---- web/lib/routing.inc.php | 18 ++++++++++++++++++ web/template/actions_form.php | 2 +- web/template/pkg_comments.php | 4 ++-- web/template/pkg_details.php | 6 +++--- web/template/pkg_search_results.php | 2 +- web/template/stats/updates_table.php | 2 +- 10 files changed, 40 insertions(+), 15 deletions(-) diff --git a/web/html/index.php b/web/html/index.php index b0f346d..de38178 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -5,8 +5,16 @@ include_once("config.inc.php"); include_once("routing.inc.php"); $path = rtrim($_SERVER['PATH_INFO'], '/'); +$tokens = explode('/', $path); -if (get_route($path) !== NULL) { +if (isset($tokens[1]) &&'/' . $tokens[1] == get_pkg_route()) { + if (isset($tokens[2])) { + unset($_GET['ID']); + $_GET['N'] = $tokens[2]; + } + + include get_route('/' . $tokens[1]); +} elseif (get_route($path) !== NULL) { include get_route($path); } else { switch ($path) { diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 8c93b0c..b918e8b 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -400,7 +400,7 @@ if ($uid): # Entire package creation process is atomic end_atomic_commit($dbh); - header('Location: ' . get_uri('/packages/') . '?ID=' . $packageID); + header('Location: ' . get_pkg_uri($pkg_name)); } chdir($cwd); diff --git a/web/html/voters.php b/web/html/voters.php index 378e605..3ba5248 100644 --- a/web/html/voters.php +++ b/web/html/voters.php @@ -15,7 +15,7 @@ if ($atype == 'Trusted User' || $atype== 'Developer'): ?> <div class="box"> - <h2>Votes for <a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $pkgid ?>"><?php echo pkgname_from_id($pkgid) ?></a></h2> + <h2>Votes for <a href="<?php echo get_pkg_uri(pkgname_from_id($pkgid)); ?>"><?php echo pkgname_from_id($pkgid) ?></a></h2> <div class="boxbody"> <?php diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index bdf8976..0610617 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -238,8 +238,7 @@ function add_package_comment($pkgid, $uid, $comment, $dbh=NULL) { # Simply making these strings translatable won't work, users would be # getting emails in the language that the user who posted the comment was in $body = - 'from ' . $AUR_LOCATION . '/' . get_uri('/packages/') . '?ID=' - . $pkgid . "\n" + 'from ' . $AUR_LOCATION . '/' . get_pkg_uri($row['Name']) . "\n" . username_from_sid($_COOKIE['AURSID'], $dbh) . " wrote:\n\n" . $comment . "\n\n---\nIf you no longer wish to receive notifications about this package, please go the the above package page and click the UnNotify button."; @@ -744,7 +743,7 @@ function pkg_flag ($atype, $ids, $action=true, $dbh=NULL) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { # construct email - $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\n" . $AUR_LOCATION . "/" . get_uri('/packages/') . "?ID=" . $row['ID'] . "\n\n[1] - " . $AUR_LOCATION . "/" . get_uri('/accounts/') . "?Action=AccountInfo&ID=" . $f_uid; + $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\n" . $AUR_LOCATION . "/" . get_pkg_uri($row['Name']) . "\n\n[1] - " . $AUR_LOCATION . "/" . get_uri('/accounts/') . "?Action=AccountInfo&ID=" . $f_uid; $body = wordwrap($body, 70); $headers = "Reply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n"; @mail($row['Email'], "AUR Out-of-date Notification for ".$row['Name'], $body, $headers); @@ -813,7 +812,7 @@ function pkg_delete ($atype, $ids, $mergepkgid, $dbh=NULL) { $body = ""; if ($mergepkgid) { $body .= username_from_sid($_COOKIE['AURSID']) . " merged \"".$pkgname."\" into \"$mergepkgname\".\n\n"; - $body .= "You will no longer receive notifications about this package, please go to https://aur.archlinux.org/" . get_uri('/packages/') . "?ID=".$mergepkgid." and click the Notify button if you wish to recieve them again."; + $body .= "You will no longer receive notifications about this package, please go to https://aur.archlinux.org/" . get_pkg_uri($mergepkgname) . " and click the Notify button if you wish to recieve them again."; } else { $body .= username_from_sid($_COOKIE['AURSID']) . " deleted \"".$pkgname."\".\n\n"; $body .= "You will no longer receive notifications about this package."; diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php index 0d940a2..e8a2deb 100644 --- a/web/lib/routing.inc.php +++ b/web/lib/routing.inc.php @@ -17,6 +17,8 @@ $ROUTES = array( '/addvote' => 'addvote.php', ); +$PKG_PATH = '/packages'; + function get_route($path) { global $ROUTES; @@ -37,3 +39,19 @@ function get_uri($path) { return get_route($path); } } + +function get_pkg_route() { + global $PKG_PATH; + return $PKG_PATH; +} + +function get_pkg_uri($pkgname) { + global $USE_VIRTUAL_URLS; + global $PKG_PATH; + + if ($USE_VIRTUAL_URLS) { + return $PKG_PATH . '/' . urlencode($pkgname) . '/'; + } else { + return get_route($PKG_PATH) . '?N=' . urlencode($pkgname); + } +} diff --git a/web/template/actions_form.php b/web/template/actions_form.php index 9cd5024..045022d 100644 --- a/web/template/actions_form.php +++ b/web/template/actions_form.php @@ -1,5 +1,5 @@ <div class="box"> - <form action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row['ID'] ?>" method="post"> + <form action="<?php echo htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>" method="post"> <fieldset> <input type="hidden" name="IDs[<?php echo $row['ID'] ?>]" value="1" /> <input type="hidden" name="ID" value="<?php echo $row['ID'] ?>" /> diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index 5b5f610..40b2fd1 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -4,7 +4,7 @@ $count = package_comments_count($_GET['ID']); ?> <div id="news"> <h3> - <a href="<?php echo htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES) ?>&comments=all" title="<?php echo __('View all %s comments' , $count) ?>"><?php echo __('Latest Comments') ?></a> + <a href="<?php echo htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES) ?>?comments=all" title="<?php echo __('View all %s comments' , $count) ?>"><?php echo __('Latest Comments') ?></a> <span class="arrow"></span> </h3> @@ -14,7 +14,7 @@ $count = package_comments_count($_GET['ID']); endif; ?> <h4> <?php if (canDeleteCommentArray($row, $atype, $uid)): ?> - <form method="post" action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row['ID'] ?>"> + <form method="post" action="<?php echo htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>"> <fieldset style="display:inline;"> <input type="hidden" name="action" value="do_DeleteComment" /> <input type="hidden" name="comment_id" value="<?php echo $row['ID'] ?>" /> diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index 4cb8602..b4b52d5 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -57,7 +57,7 @@ if ($SID && ($uid == $row["MaintainerUID"] || ($atype == "Developer" || $atype == "Trusted User"))): ?> <td> - <form method="post" action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $pkgid ?>"> + <form method="post" action="<?php echo htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>"> <div> <input type="hidden" name="action" value="do_ChangeCategory" /> <?php if ($SID): ?> @@ -139,7 +139,7 @@ if ($atype == "Developer" || $atype == "Trusted User"): # darr: (DepName, DepCondition, PackageID), where ID is NULL if it didn't exist if (!is_null($darr[2])): ?> - <li><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $darr[2]?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1]?>"><?php echo $darr[0].$darr[1]?></a></li> + <li><a href="<?php echo htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1]?>"><?php echo $darr[0].$darr[1]?></a></li> <?php else: ?> <li><a href="http://www.archlinux.org/packages/?q=<?php echo urlencode($darr[0])?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1] ?>"><?php echo $darr[0].$darr[1] ?></a></li> <?php endif; ?> @@ -155,7 +155,7 @@ if ($atype == "Developer" || $atype == "Trusted User"): # darr: (PackageName, PackageID) while (list($k, $darr) = each($requiredby)): ?> - <li><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $darr[1] ?>" title="<?php echo __('View packages details for').' '.$darr[0]?>"><?php echo $darr[0] ?></a></li> + <li><a href="<?php echo htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?php echo __('View packages details for').' '.$darr[0]?>"><?php echo $darr[0] ?></a></li> <?php endwhile; ?> </ul> <?php endif; ?> diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php index 440698b..11db7a1 100644 --- a/web/template/pkg_search_results.php +++ b/web/template/pkg_search_results.php @@ -52,7 +52,7 @@ if (!$result): ?> <td><input type="checkbox" name="IDs[<?php echo $row["ID"] ?>]" value="1" /></td> <?php endif; ?> <td><?php echo htmlspecialchars($row["Category"]) ?></td> - <td><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row["ID"] ?>"><?php echo htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]) ?></a></td> + <td><a href="<?php echo htmlspecialchars(get_pkg_uri($row["Name"]), ENT_QUOTES); ?>"><?php echo htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]) ?></a></td> <td><?php echo $row["NumVotes"] ?></td> <?php if ($SID): ?> <td> diff --git a/web/template/stats/updates_table.php b/web/template/stats/updates_table.php index 835d956..6e43e22 100644 --- a/web/template/stats/updates_table.php +++ b/web/template/stats/updates_table.php @@ -6,7 +6,7 @@ <?php foreach ($newest_packages->getIterator() as $row): ?> <tr> <td> - <a href="<?php echo get_uri('/packages/'); ?>?ID=<?php print intval($row["ID"]); ?>"><?php print htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]); ?></a> + <a href="<?php echo get_pkg_uri($row["Name"]); ?>"><?php print htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]); ?></a> </td> <td> <span><?php print gmdate("Y-m-d H:i", intval($row["ModifiedTS"])); ?></span> -- 1.7.11.2
Jump to the home page instead of displaying a page that only tells you that you're logged in. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/lib/acctfuncs.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index fcc6a60..d58c759 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -414,7 +414,7 @@ function try_login($dbh=NULL) { $cookie_time = 0; setcookie("AURSID", $new_sid, $cookie_time, "/", null, !empty($_SERVER['HTTPS']), true); - header("Location: " . $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']); + header("Location: " . get_uri('/')); $login_error = ""; } -- 1.7.11.2
Regression introduced in f3ce74c714e3460bb3e3e786f626e397d3139062 when resolving conflicts. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/pkgsubmit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index b918e8b..84688b4 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -433,7 +433,7 @@ html_header("Submit"); <fieldset> <div> <input type="hidden" name="pkgsubmit" value="1" /> - <input type="hidden" name="token" value="<?php print htmlspecialchars($_COOKIE['AURSID']) ?>" /> </div> + <input type="hidden" name="token" value="<?php print htmlspecialchars($_COOKIE['AURSID']) ?>" /> </div> <p> <label for="id_category"><?php print __("Package Category"); ?>:</label> -- 1.7.11.2
On Sun, Jul 15, 2012 at 5:23 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
This implements nicer looking URLs, such as "/packages/" instead of "/packages.php", "/packages/$pkgname/" instead of "/packages.php?ID=$id" etc.
Note that these patches are not ready to be merged yet but I'd like to get some comments. We'd probably also have to add rewrite rules to our AUR setup on sigurd or add legacy rules to the routing back end to ensure old URLs still work.
I didn't realize you were already merging these. Setting $USE_VIRTUAL_URLS = false seems broken on my test setup. I'm getting a call to an undefined function error on any page besides index.php. I'm guessing that the include_once("routing.inc.php") should really be in aur.inc.php not in index.php? It also seems that all CSS doesn't load properly. I'm guessing this is related to the change to absolute URI paths for stylesheets? Sorry I don't have much time to fully review these but this is what I've seen so far. Regards, Jason
On Tue, Jul 17, 2012 at 03:37:32PM -0400, canyonknight@gmail.com wrote:
On Sun, Jul 15, 2012 at 5:23 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
This implements nicer looking URLs, such as "/packages/" instead of "/packages.php", "/packages/$pkgname/" instead of "/packages.php?ID=$id" etc.
Note that these patches are not ready to be merged yet but I'd like to get some comments. We'd probably also have to add rewrite rules to our AUR setup on sigurd or add legacy rules to the routing back end to ensure old URLs still work.
I didn't realize you were already merging these. Setting $USE_VIRTUAL_URLS = false seems broken on my test setup. I'm getting a call to an undefined function error on any page besides index.php. I'm guessing that the include_once("routing.inc.php") should really be in aur.inc.php not in index.php?
Yeah, you're probably right. The include() should be moved.
It also seems that all CSS doesn't load properly. I'm guessing this is related to the change to absolute URI paths for stylesheets?
Works for me... Did you clear the browser cache? Does it work if you enable "$USE_VIRTUAL_URLS"?
Sorry I don't have much time to fully review these but this is what I've seen so far.
Don't worry -- I discovered a lot of other minor regressions that were probably introduced when merging all the archweb and virtual path stuff... Lots of bug fixes to follow.
Regards,
Jason
On Tue, Jul 17, 2012 at 5:02 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
On Tue, Jul 17, 2012 at 03:37:32PM -0400, canyonknight@gmail.com wrote:
On Sun, Jul 15, 2012 at 5:23 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
This implements nicer looking URLs, such as "/packages/" instead of "/packages.php", "/packages/$pkgname/" instead of "/packages.php?ID=$id" etc.
Note that these patches are not ready to be merged yet but I'd like to get some comments. We'd probably also have to add rewrite rules to our AUR setup on sigurd or add legacy rules to the routing back end to ensure old URLs still work.
I didn't realize you were already merging these. Setting $USE_VIRTUAL_URLS = false seems broken on my test setup. I'm getting a call to an undefined function error on any page besides index.php. I'm guessing that the include_once("routing.inc.php") should really be in aur.inc.php not in index.php?
Yeah, you're probably right. The include() should be moved.
It also seems that all CSS doesn't load properly. I'm guessing this is related to the change to absolute URI paths for stylesheets?
Works for me... Did you clear the browser cache? Does it work if you enable "$USE_VIRTUAL_URLS"?
Clearing cache doesn't work. Enabling/disabling $USE_VIRTUAL_URLS makes no difference. I think I know what the problem is though. Commit a03c684ecd51327f9c6921a6e0001d82e3223799 describes using absolute URI paths for CSS and images. They are actually root-relative with that commit, not absolute. So someone like me with a strange http root doesn't get the CSS loaded properly. It could be fixed by putting $AUR_LOCATION before any CSS or image paths (thus using truly absolute paths). Another solution was also previously suggested by Ike in regards to portability: http://mailman.archlinux.org/pipermail/aur-dev/2012-July/002041.html
Sorry I don't have much time to fully review these but this is what I've seen so far.
Don't worry -- I discovered a lot of other minor regressions that were probably introduced when merging all the archweb and virtual path stuff... Lots of bug fixes to follow.
Regards, Jason
On Wed, Jul 18, 2012 at 03:29:10PM -0400, canyonknight@gmail.com wrote:
On Tue, Jul 17, 2012 at 5:02 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
On Tue, Jul 17, 2012 at 03:37:32PM -0400, canyonknight@gmail.com wrote:
On Sun, Jul 15, 2012 at 5:23 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
This implements nicer looking URLs, such as "/packages/" instead of "/packages.php", "/packages/$pkgname/" instead of "/packages.php?ID=$id" etc.
Note that these patches are not ready to be merged yet but I'd like to get some comments. We'd probably also have to add rewrite rules to our AUR setup on sigurd or add legacy rules to the routing back end to ensure old URLs still work.
I didn't realize you were already merging these. Setting $USE_VIRTUAL_URLS = false seems broken on my test setup. I'm getting a call to an undefined function error on any page besides index.php. I'm guessing that the include_once("routing.inc.php") should really be in aur.inc.php not in index.php?
Yeah, you're probably right. The include() should be moved.
It also seems that all CSS doesn't load properly. I'm guessing this is related to the change to absolute URI paths for stylesheets?
Works for me... Did you clear the browser cache? Does it work if you enable "$USE_VIRTUAL_URLS"?
Clearing cache doesn't work. Enabling/disabling $USE_VIRTUAL_URLS makes no difference. I think I know what the problem is though. Commit a03c684ecd51327f9c6921a6e0001d82e3223799 describes using absolute URI paths for CSS and images. They are actually root-relative with that commit, not absolute. So someone like me with a strange http root doesn't get the CSS loaded properly.
It could be fixed by putting $AUR_LOCATION before any CSS or image paths (thus using truly absolute paths). Another solution was also previously suggested by Ike in regards to portability: http://mailman.archlinux.org/pipermail/aur-dev/2012-July/002041.html
Yes, I will submit a patch that implements that -- didn't know you were using a root != "/".
Sorry I don't have much time to fully review these but this is what I've seen so far.
Don't worry -- I discovered a lot of other minor regressions that were probably introduced when merging all the archweb and virtual path stuff... Lots of bug fixes to follow.
Regards,
Jason
participants (3)
-
canyonknight@gmail.com
-
Ike Devolder
-
Lukas Fleischer