Commit graph

95 commits

Author SHA1 Message Date
Lukas Fleischer
6892ec7791 Call check_sid() from a central location
Instead of calling check_sid() from every single PHP script representing
a web page, add the call to aur.inc.php which is sourced by all of them.

Also, remove set_lang() calls from the scripts since these are also
already included in aur.inc.php.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-27 09:22:53 +02:00
Lukas Fleischer
4be9aa6350 Fix the comment collapse feature
In commit 4abde89 (Use JavaScript to collapse long comments,
2017-04-19), support for collapsing/expanding long comments was added.
This was broken by the recent Markdown support since comments no longer
live inside a single HTML paragraph. Fix this by wrapping each comment
in another div container.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 21:10:02 +02:00
Lukas Fleischer
4abde895a5 Use JavaScript to collapse long comments
Instead of using CSS to limit the height of package comments as
implemented in 7b13203 (Limit comment height to 15 lines, 2016-03-12),
use JavaScript to collapse long comments and add a link to expand them.
Clicking the same link twice results in the corresponding comment being
collapsed again.

If JavaScript is disabled, the full comments are shown (without any
possibility to collapse or expand).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-20 07:03:54 +02:00
Lukas Fleischer
b6aced9692 pkg_search_results.php: Split out package results box
Do not print the wrapper div container when calling pkg_search_page().

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-04 00:36:55 +01:00
Lukas Fleischer
3b4c6e72a9 Refactor pkg_search_page()
* Pass search parameters using an associative array instead of $_GET.
* Add a boolean parameter to enable and disable headers/footers.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-04 00:36:17 +01:00
Lukas Fleischer
ac745f656d Split out the search form from pkg_search_page()
This makes it easier to display search results without showing the
search form.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-03 23:54:31 +01:00
Lukas Fleischer
d0f8b285e4 Fix a PHP "Undefined index" notice
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-10-03 11:15:53 +02:00
Lukas Fleischer
9cae17ff7c Extract package name from details
When requesting package details, instead of performing another SQL query
to obtain the package name, extract the name from the result of the
package details query.

Also, drop pkg_name_from_id() which is no longer needed after this
optimization.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-09-18 08:03:56 +02:00
Johannes Löthberg
828506e868 Reindent web/html/packages with tabs
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-08 12:59:23 +02:00
Lukas Fleischer
6e514ee335 Default to ordering packages by popularity
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-11 19:15:51 +02:00
Lukas Fleischer
cc1e8aed30 Rename the AUR software to aurweb
Rename the project to help differentiate between the software providing
access to the Arch User Repository and the collection of source packages
itself.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2015-02-04 09:50:01 +01:00
Lukas Fleischer
03c6304e19 Rework permission handling
Add a new function has_credential() that checks whether the currently
logged in user is allowed to perform a given action. Moving all
permission handling to this central place makes adding new user groups
and adjusting permissions much more convenient.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-07-15 22:56:57 +02:00
Lukas Fleischer
13820d2b16 Collapse long source lists
In commit e582cfe (Collapse long dependency lists, 2014-04-18), we added
code to automatically collapse dependency and requirement lists with
more than 20 entries. Add the same functionality to source lists.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-06-05 15:12:10 +02:00
Lukas Fleischer
e582cfe182 Collapse long dependency lists
Collapse package dependency lists with more than 20 entries and add a
link to show the full list.

The JavaScript code for this originates from the archweb project. Note
that the full list is shown when JavaScript is disabled or unavailable.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-18 23:57:46 +02:00
Lukas Fleischer
676595f9bf Prefix package functions with pkg_/pkgbase_
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 15:55:31 +02:00
Lukas Fleischer
f461344211 Move package actions to package bases
Package actions now operate on package bases instead of packages. Move
all actions to the correct locations.

This also fixes some issues with comment notifications.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 13:54:06 +02:00
Lukas Fleischer
b558572a2e Make the delete function remove package bases
Deleting a single package without deleting the whole package base makes
no sense. Comments and votes are already stored on a per-package basis,
making this a straightforward extension.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 12:21:36 +02:00
Lukas Fleischer
165bcba54e Style fixes: Capitalization of "true" and "false"
Use "true" instead of "TRUE" and "false" instead of "FALSE" or "False".

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-06 16:32:31 +01:00
Lukas Fleischer
c1c7f9b350 Move package comment check to packages.php
Checking whether to add a comment is something that really does not
belong to a function named display_package_details().

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-27 11:35:26 +02:00
Lukas Fleischer
bf019a5b6c Use POST-Redirect-GET for most package actions
Avoid showing a POST data resubmission dialog and simply redirect to the
package page if a package action completed successfully.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-27 11:25:14 +02:00
Lukas Fleischer
23867a211c Add boolean return values to several pkg_*() functions
Change the return values of following functions to return both
error/success and an error/success message:

* pkg_flag()
* pkg_unflag()
* pkg_adopt()
* pkg_vote()
* pkg_delete()
* pkg_notify()
* pkg_delete_comment()
* pkg_change_category()

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-27 11:19:45 +02:00
canyonknight
ca067d5492 Retrieve package details after package actions are processed
Fixes FS#34508

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-04-20 00:22:53 +02:00
Lukas Fleischer
4fc1b9a0ca Return 404 error page if invalid package ID is used
We already display the 404 error page if someone tries to access an
invalid package via virtual URLs ("/packages/nonexistent"). Add the same
check to "web/html/packages.php" to make sure the same error is shown if
a user requests package details of a nonexistent package ID via legacy
URLs ("/packages.php?ID=-1").

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-21 22:38:49 +01:00
Marcel Korpel
8e1051932e Add description meta-element to package pages
Implements FS#33294

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-01-19 12:18:13 +01:00
canyonknight@gmail.com
20407bb8c6 Split package flagging and unflagging into separate functions
Currently, package flagging and unflagging takes place within the
pkg_flag() function. A bool is set to true or false depending on the
action.

Create new pkg_unflag() function with sole purpose of unflagging
and keep pkg_flag() in place. This split will be useful in the
overhaul of the notification system.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-12-07 23:24:11 +01:00
Lukas Fleischer
6102759b7c Use echo shortcut syntax
Replace all occurrences of "<?php echo" and "<?php print" by "<?=" to
reduce noise in templates.

Note that as of PHP 5.4.0, "<?=" is always available and no longer
requires "short_open_tag" to be set.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-24 12:23:04 +02:00
Lukas Fleischer
3b1dad229b Fix category selection
Add a package ID parameter to pkg_change_category() instead of relying
on the "ID" or "N" GET parameters.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 16:09:30 +02:00
Lukas Fleischer
2e552cbcad Do not set GET parameters in the routing framework
Setting GET parameters manually is bad style and causes some strange
side effects when using virtual URLs and mkurl().

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 14:05:11 +02:00
Lukas Fleischer
f3ce74c714 Merge branch 'maint'
Conflicts:
	web/html/account.php
	web/html/addvote.php
	web/html/pkgsubmit.php
	web/lib/acctfuncs.inc.php
	web/template/actions_form.php
	web/template/pkg_comment_form.php
	web/template/pkg_comments.php
	web/template/pkg_details.php
	web/template/pkg_search_results.php
	web/template/tu_details.php
2012-07-14 22:52:04 +02:00
canyonknight
2c93f0a98f Implement token system to fix CSRF vulnerabilities
Specially crafted pages can force authenticated users to unknowingly perform
actions on the AUR website despite being on an attacker's website. This
cross-site request forgery (CSRF) vulnerability applies to all POST data on
the AUR.

Implement a token system using a double submit cookie. Have a hidden form
value on every page containing POST forms. Use the newly added check_token() to
verify the token sent via POST matches the "AURSID" cookie value. Random
nature of the token limits potential for CSRF.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-06-24 10:59:23 +02:00
Lukas Fleischer
5b0f1f39db web/html/packages.php: Remove duplicate code
Retrieve the package ID early and merge the if-branches calling
package_details().

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-05-06 12:47:19 +02:00
Lukas Fleischer
cf2f667512 Support canonical links to packages
This is more user-friendly than supporting package IDs only and can be
used as a basis to support direct links to AUR packages in places where
links are computer-produced (e.g. Wiki templates).

Addresses FS#21600 and FS#28839.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-03-24 10:34:35 +01:00
Dan McGee
34fe0bec4c Use 'true' instead of 'True' everywhere
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-11 16:17:09 +02:00
Lukas Fleischer
87bdee60bc Allow for merging deleted packages into existing ones
Merge all comments and votes of deleted packages into another package if
the "Merge with" field is used. Duplicate votes (votes from a user who
already voted on the target package or voted on more than one of the
deleted packages) are discarded.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-11 16:17:07 +02:00
elij
888db089c5 rename *.inc files to *.inc.php and adjust imports and references
Lukas: Add note to "UPGRADING".

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-22 15:15:04 +02:00
Lukas Fleischer
d142ca4053 Fix PHP warning when browsing a non-existent package.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-04 23:31:19 +02:00
Lukas Fleischer
55eb55a75f Fix PHP undefined notice in "web/html/packages.php".
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-30 11:06:20 +02:00
Dan McGee
80401c6afc More PHP Notice undefined fixups
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-10 18:15:59 +01:00
Dan McGee
d1d0288598 Add action lookup helper function
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-04 10:29:15 +01:00
Dan McGee
90485e8f42 Fix potential injection vulnerability
We trusted the values we pulled out of the IDs array and never coerced
them to integers, passing them to the backend unescaped and uncasted.
Ensure they are treated as integers only and validate the resulting
value is > 0.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-01 20:27:49 +01:00
Dan Vratil
57a5cbfd88 Auto redirect from confirmation screens.
Finally move comment deletion and category editing into functions and
remove pkgedit.php

Signed-off-by: Loui Chang <louipc.ist@gmail.com>
-Fix indentation
-Fix variable naming conflict $id vs $cid
2010-11-21 03:37:17 -05:00
Lukas Fleischer
b5bc6ab742 Confirmation when deleting packages
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
2010-07-01 21:19:18 -04:00
Loui Chang
d53901eecd packages.php: Fix explicit sorting when search keywords aren't specified.
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
2010-03-13 00:03:00 -05:00
Loui Chang
b6e012ea3b packages.php: Only sort by vote if search keyword isn't set.
People entering explicit search terms would expect alphabetical order.

Signed-off-by: Loui Chang <louipc.ist@gmail.com>
2010-03-12 16:47:48 -05:00
Loui Chang
b51458f752 packages.php: Check if _GET value is set before assuming a default.
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
2009-12-15 22:39:14 -05:00
Loui Chang
9c1781f03d packages.php: Make default view sort packages by descending votes.
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
2009-12-15 11:15:43 -05:00
Loui Chang
1bc4836e19 Restyle the layout.
Make HTML markup more logical.
Remove some unused style sheets rules.

Signed-off-by: Loui Chang <louipc.ist@gmail.com>
2009-11-23 23:24:56 -05:00
Dan McGee
46f2798524 Use include_once where applicable
All of these are sourcing function libraries so we don't need to include
them more than once. Things that insert actual HTML into the output were
left calling include().

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
2009-08-11 13:58:12 -04:00
Loui Chang
402c6d0933 Fix the comment poop bug.
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
2009-02-20 20:59:07 -05:00
Loui Chang
2ee3276348 Use new conglomerated translation files.
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
2009-01-19 16:29:45 -05:00