Commit graph

866 commits

Author SHA1 Message Date
Lukas Fleischer
20b20c20f2 web/template/login_form.php: Escape the request URI
Reported-by: Thomas Bächler <thomas@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-09-05 16:56:09 +02:00
Lukas Fleischer
1b63994b8d web/html/pkgsubmit.php: Deal with unset category ID
Do not move the package to the incoming package directory and fail to
create proper database entries if some AUR upload helper doesn't provide
a category. We got several failing constraints here, such as:

  Cannot add or update a child row: a foreign key constraint fails
  (`AUR`.`Packages`, CONSTRAINT `Packages_ibfk_1` FOREIGN KEY
  (`CategoryID`) REFERENCES `PackageCategories` (`ID`) ON DELETE NO
  ACTION)

Instead, default to "1" (which is "none", or "keep category" for
existing packages) if no category is supplied.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-09-05 16:47:59 +02:00
Lukas Fleischer
a00e5b040a Link to current page in the login bar HTTPs link
This is way more convenient if you follow a HTTP link. Implements
FS#25757.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-09-05 16:47:57 +02:00
Lukas Fleischer
53a31865f4 RPC: Fix info queries when using package IDs
Info queries using package IDs were no longer working due to commit
c6d84b3a8d, which introduced a table join
in process_query(), thus making the "ID" column ambiguous. Fix this by
explicitly specifying the table to use. Fixes FS#25696.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-22 08:17:26 +02:00
Lukas Fleischer
dad42297c7 Add missing __() to category info in package details
This makes the "Category" label as well as "Change category" button on
the package details page translatable. Fixes FS#25692.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-22 08:15:36 +02:00
Lukas Fleischer
72b657eb17 Release 1.9.0
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-20 18:38:34 +02:00
Lukas Fleischer
beafbfd6a0 Replace "el_GR" translation by "el"
We discussed this on aur-dev. We shouldn't specify a territory unless
translations are specific to a variant of the Greek language.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-20 18:27:43 +02:00
Lukas Fleischer
87fba89a33 Add Portuguese (Brazilian) translation
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-20 18:25:23 +02:00
Lukas Fleischer
ffa1a5a609 Add Finnish and Dutch translations
Thanks-to: Jesse Jaara <jesse.jaara@gmail.com>
Thanks-to: Jelle van der Waa <jelle@vdwaa.nl>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-13 12:45:29 +02:00
Lukas Fleischer
00e4e0294f Use secure and httponly session cookies
As discussed on the mailing list, enable "secure" and "httponly" for
session cookies to prevent them from being transferred over insecure
connections.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-12 00:09:24 +02:00
Lukas Fleischer
1c9db1d1f1 Add a configuration setting to disallow HTTP login
If this is enabled, do not show the login form and display a note
suggesting to switch to a secure connection if a user accesses the site
via HTTP.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-11 21:04:38 +02:00
Dan McGee
45a50d4a66 Remove unnecessary atype and uid lookup from package_details()
These were never used in the function. Where they are used is in the
pkg_details.php template, so move them closer to their actual usage so
as not to confuse poor programmers such as myself.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-11 16:17:09 +02: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
Dan McGee
5d74a994ff Make package creation and update atomic
Add BEGIN and COMMIT statements where it makes sense to do so. This
allows the entire package creation or update process to be atomic and
not be seen until it is complete.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-11 16:17:08 +02:00
Dan McGee
0ac74ed733 pkgfuncs.inc.php: allow all DB funcs to take handle arg
Allows handle reuse if one is available.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-11 16:17:08 +02:00
Dan McGee
242f7afb96 aur.inc.php: allow all functions using DB to take handle as arg
This prevents needless calls to db_connect() if we already have a
reference to a handle we can pass into a function. Although the current
underlying implementation using mysql_connect() will return the same
connection if all parameters are the same, this might not be true if we
switch to a more modern (e.g. PDO) interface.

In the face of safe transactions, it is extremely important all actions
are being taken over the same connection to the database.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-11 16:17:08 +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
Lukas Fleischer
f481645e64 Add "mergepkgid" argument to pkg_delete()
This allows for merging comments and votes of deleted packages into
another one which is useful if a package needs to be renamed.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11 16:17:07 +02:00
Lukas Fleischer
0ac8970b62 Rename package_exists() to pkgid_from_name()
Describe what this function actually does: Return the ID of a package
with a given name and return NULL if such a package doesn't exist.

The function name is chosen in a fashion similar to other functions from
"pkgfuncs.inc.php" (pkgname_from_id(), pkgnotify_from_sid(), ...).

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-11 16:17:07 +02:00
Dan McGee
9a79d2105e Segment the upload directory by package name prefix
This implements the following scheme:

* /packages/cower/ --> /packages/co/cower/
* /packages/j/     --> /packages/j/j/
* /packages/zqy/   --> /packages/zq/zqy/

We take up to the first two characters of each package name as a
intermediate subdirectory, and then the full package name lives
underneath that. Shorter named packages live in a single letter
directory.

Why, you ask? Well because earlier today the AUR hit 32,000 entries in
the unsupported/ directory, making new package uploads impossible. While
some might argue we shouldn't have so many damn packages in the repos,
we should be able to handle this case.

Why two characters instead of one? Our two biggest two-char groups, 'pe'
and 'py', both start with 'p', and have nearly 2000 packages each. Go
Python and Perl.

Still needed is a "move the existing data" script, as well as a set of
rewrite rules for those wishing to preserve backward compatible URLs for
any helper programs doing the wrong thing and relying on them.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-10 14:34:07 +02:00
Dan McGee
1f79258e81 Allow SQL_DEBUG to be undefined
We shouldn't require this as it is a new config parameter and it causes
PHP warnings to be spewed everywhere.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-08-10 14:34:07 +02:00
Lukas Fleischer
16cda58ff8 Fix empty depends database insert
Do not try to insert a falsey value into the database in case of
"depends=()".

Signed-off-by: Manuel <manutortosa@chakra-project.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-07-29 23:51:29 +02:00
Lukas Fleischer
a32b2f2ef7 Replace split() invocations with explode()
Do not use split(), which has been deprecated as of PHP 5.3.0. As we
don't even require regular expressions here, just use explode() instead.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-28 08:55:47 +02:00
Lukas Fleischer
0f994df357 Simplify session ID generation
There was too much voodoo going on in new_sid(). Just use uniqid() with
a random seed and the optional entropy parameter to generate MD5 input.

Use the remote IP address as a salt to reduce the chance of two clients
getting the same ID if they login at exactly the same time.

Thanks-to: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-25 11:58:20 +02:00
Lukas Fleischer
e686b495a8 Stricter email address validation
Use PHP's filter extension to validate mail addresses. The filter
extension is enabled by default as of PHP 5.2.0.

Thanks-to: Florian Pritz <bluewind@xinu.at>
Thanks-to: Cédric Girard <girard.cedric@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-25 11:58:13 +02:00
Slavi Pantaleev
2131d3cb8b Honor epoch field in PKGBUILD files.
The epoch field in PKGBUILD files was completely ignored until now,
and the final Version field for a package consisted only of
pkgver and pkgrel (example: 5.0-1)

This means that rpc.php reported the version incorrectly for packages
having epoch > 0.
One case where this was a problem is that it confused AUR helpers
wanting to examine all locally installed packages (with epoch > 0)
and search the AUR for an updated version.

The epoch field is taken into consideration now, and if not 0,
will be prepended to the final Version field (example: 1:5.0-1)

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-25 11:29:56 +02:00
Florian Pritz
b60a30af71 fix incompatibility with php short open tags
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-25 11:29:56 +02:00
Florian Pritz
9c65ad3aa2 README: fix pacman call
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-25 11:29:55 +02:00
Dan McGee
3c110b13b5 Use sane ORDER BY clauses in package list queries
We were doing some silly things here with an "ORDER BY Name, CategoryID"
clause, due to the fact that Name is unique, and thus any additional
ordering after Name will have no effect. Of course, the dumb as a box of
rocks MySQL query optimizer doesn't realize this, leading to full table
scans every time of ~30000 packages instead of using index scans for the
ordering and only retrieving the first 50 rows.

The biggest change is noted in the default sort order as it cuts down
the columns to one, but we can remove the redundant sort from other
orderings as well, even though those will still not be able to use an
index-driven query plan.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-25 11:29:55 +02:00
Lukas Fleischer
0e9f8c0ff5 Do not redirect on single search results
The use of header() to redirect after previous output was a design flaw.
Our only luck here was PHP's "output_buffering" config variable
defaulting to 4096, which kind of hid the bug for a long time.

Fixes FS#24580.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-22 15:42:38 +02:00
elij
5853097561 Make cache type selectable based on config value
Provie a mechanism to specify cache type from NONE, APC, or MEMCACHE
based on a config variable.

If MEMCACHE type is selected, a list of servers can be specified to
provide multiserver support. Note that php-memcaced is required for
MEMCACHE support.

Lukas: Minor commenting style fixes.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-22 15:21:21 +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
elij
023d2a2521 make rss.php use the apc cache instead of a cache file
utilize the apc cache functionality in aur.inc to cache the rss feed
output. the cache will cache on a per-protocol basis (http/https) so
that urls are appropriate regardless of which url people hit.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-22 15:04:23 +02:00
elij
af5d05f4ad refactor apc code and move to aur.inc
- move apc cache code to aur.inc (centralize)
- refactor the apc usage in stats.inc to utilize new code in aur.inc

Lukas: Small commenting style and spelling changes.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-06-22 15:02:21 +02:00
Lukas Fleischer
fa53ca68b0 Cleanup RPC usage output a bit
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-05-29 16:06:28 +02:00
Lukas Fleischer
21827dfb1c Properly encode ampersands in the RPC usage output
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-05-29 15:58:46 +02:00
elij
4c9da512af fix two issues (php notice level) with html/rss.php
- Undefined index: HTTPS in rss.php on line 8
- Undefined property: RSSCreator20::$cssStyleSheet in
  feedcreator.class.php on line 591

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-05-29 15:57:45 +02:00
elij
4a24bca069 restructure the html/rpc.php endpoint
- move request_method test to the top, and catch other request types
  (HEAD, PUT, etc)
- change how html output is handled. instead of building a string, just
  output the html
- set appropriate response header for incorrect request_method.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-05-29 15:57:45 +02:00
kachelaqa
0df6d7b4e7 add first submitted and last modified to rpc output
after reading the discussion about the submitter field, i looked again
at my previous patch and realized that it was not very good at all.

hopefully this simplified version will be more acceptable.

the justification for this patch is that many third-party tools will
want to know how new a package is, or when it last changed. adding the
submitted and modified timestamps will allow users to get all the
relevant package data in a single query.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-05-17 10:46:56 +02:00
elij
77f3aa56b7 add support for etag and conditional get (if-none-match)
Add etag and if-none-match conditional get support. This will allow
'smart client' to save network bandwidth, as they can save the etag hash
value for queries and test it later. Still an http request because this
patch specifically sets a cache lifetime of zero, and must-revalidate.
The benefit here is bandwidth savings. Caching based on expires headers
would likely be counter productive, as the api data can change rather
quickly...but etag is a nice compromise, and could be quite beneficial
for bandwidth recution in some scenarios.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-05-17 10:43:49 +02:00
elij
3e81712fd6 fix case where user does not exist
the query was being performed when $id was not set, resulting in an
invalid sql query being performed.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-05-17 10:43:46 +02:00
elij
0898f1447a test return value from db_query before assuming it is valid
make the sql query form consistent in usage by cleaning up instances
where db_query's result was not inspected before attempting to fetch row
data from the handle

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-05-17 10:43:42 +02:00
Karlis Lauva
d38f3460e5 Added label tags for login form fields.
Lukas: Use tabs for indentation instead of spaces.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-05-09 10:54:36 +02:00
elij
c43558ba60 add SQL_DEBUG variable and database logging
add a hook to db_query to log all sql queries when SQL_DEBUG is set
Additionally, provide better logging for sql error situations (provide
backtrace as well as error message).

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-27 14:50:44 +02:00
elij
10ea5f5ff6 create variable before referencing it with .=
fixes php notice level error:
  Undefined variable: whovoted in ../tu.php

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-27 14:50:28 +02:00
Dan McGee
33a765ef03 stats: capitalize FROM in all SQL queries
Matches our normal code conventions.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-27 14:50:28 +02:00
Dan McGee
3609cf140e SQL: treat all UID/ID values as numbers, not strings
Ensure we are not quoting these values in any of our SQL queries.

Thanks-to: elij <elij.mx@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-27 14:50:27 +02:00
Dan McGee
fcda6671f3 SQL: use standard LIMIT/OFFSET syntax
Increases compatibility with standard SQL dialect.

Thanks-to: elij <elij.mx@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-27 14:50:27 +02:00
Lukas Fleischer
ed9c95623f pkgsubmit.php: Ensure the session is linked to a valid user.
Prevent race conditions that may occur when either the session or the
user is deleted before we extract the actual user identifier.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-24 14:22:24 +02:00
Lukas Fleischer
9ff30614b8 pkgsubmit.php: Remove redundant uid_from_sid() invocations.
uid_from_sid() is called once at the very beginning of the script,
storing the actual user identifier in "$uid". No need to fire up another
query.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-24 14:00:09 +02:00