Commit graph

826 commits

Author SHA1 Message Date
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
Lukas Fleischer
897211374f Use HTTPs for links in the main site navigation bar (fixes FS#23832).
Basically just sync with what archweb currently uses, prefixing all
relative URLs with "http://www.archlinux.org".

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-20 00:13:10 +02:00
Lukas Fleischer
973e4f8558 Use HTTPs for links in out of date notification mails.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-20 00:02:09 +02:00
Lukas Fleischer
5ea9fc197d Use HTTPs for links in password reset confirmation mails.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-19 23:59:19 +02:00
Lukas Fleischer
1e7b9d570d Use HTTPs for links in comment notification mails.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-19 23:58:32 +02:00
Lukas Fleischer
0e5f2e1f1e urlencode() query args for main site package search (fixes FS#23774).
There may be characters in package dependencies that are reserved within
URLs (e.g. "+"). Use urlencode() to ensure those are encoded correctly.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-19 23:45:43 +02:00
tuxce
c6d84b3a8d rpc: unify methods return (fixes FS#17597)
Include maintainer in info and search method.

Lukas: Adjustments for "multiinfo" queries.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-16 17:49:01 +02:00
Dan McGee
0488e8597c rpc: introduce multiinfo query (fixes FS#17583)
The majority of "real world" info requests [1] come in hefty batches. We
would be better served to handle these in one request rather than
multiple by allowing AUR clients to send multiple arguments.

This enables things like this to work:
    http://aur.test/rpc.php?type=multiinfo&arg[]=cups-xerox&arg[]=cups-mc2430dl&arg[]=10673

Note to RPC users: unfortunately due to the asinine design of PHP, you
unfortunately have to use the 'arg[]' syntax if you want more than one
query argument, or you will only get the package satisfying the last arg
you pass.

[1] Rough data from April 11, 2011, with a total hit count of 1,109,163:
     12 /login.php
     13 /rpc.php?type=sarch
     15 /rpc.php?type=msearch
     16 /pingserver.php
     16 /rpc.php
     22 /logout.php
    163 /passreset.php
    335 /account.php
    530 /pkgsubmit.php
    916 /rss2.php
   3838 /index.php
   6752 /rss.php
   9699 /
  42478 /rpc.php?type=search
 184737 /packages.php
 681725 /rpc.php?type=info

That means a whopping 61.5% of our requests were for info over the RPC
interface; package pages are a distant second at only 16.7%.

Lukas: Introduce "multiinfo" query instead of extending "info" (for the
sake of backward compatibility).

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-16 17:49:00 +02:00
Dan McGee
a3ad060158 rpc.php: be a bit more consistent in query building
Do the implode as the same but separate step each time, and remove
indentation where no other query has it.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-16 17:49:00 +02:00
Dan McGee
aa206b343a rpc.php overhaul
* Mark things static in the class rather than use a constructor every
  single invocation of the service.
* Don't call mysql_real_escape_string() before we even have a database
  connection, and don't do work in the database if we don't need to.
* Formatting consistency fixups in a few places.
* Add new process_query() helper function; use this instead of
  copy-pasted code in all of the RPC method calls.
* Remove the escaping code meant to fix FS#15526, introduced in commit
  4d1eb4dd7a. It broke more than it solved, only fixed the output in
  one of three RPC calls (and who knows what the web interface then also
  does), and proper encoding should be done at the database level rather
  than up here.

Lukas: Add special case for "info" queries to process_query() (return a
single result instead of an array of results here).

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-16 17:47:57 +02:00
Dan McGee
8fdb382d67 Don't allow dl() of json module
You need this enabled for the AUR, period. No need for this BS.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-13 12:36:07 +02:00
Lukas Fleischer
56de32c016 Pass array_map() callback function properly.
PHP requires callback functions to be passed as strings. Fix this to
supress PHP notices.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-13 12:24:01 +02:00
Lukas Fleischer
eef5353bde Remove "New Package Notify" option from user account settings.
Do this in preparation for the upcoming notification script removal.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-13 12:22:28 +02:00
Lukas Fleischer
3a5693166c Remove comment on translation helpers from "web/lib/translator.inc".
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-10 16:27:48 +02:00
Lukas Fleischer
0662f42884 Remove "web/lang/".
Those legacy ".po" files and translation helpers are no longer needed as
we moved to gettext compatible portable objects.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-10 15:40:50 +02:00
Lukas Fleischer
22a718ea89 Replace translation engine with php-gettext.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-10 15:40:50 +02:00
Lukas Fleischer
779ecc8c3a Add php-gettext libraries to "web/lib/".
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-10 15:40:49 +02:00
Lukas Fleischer
d9889c9dde Add dummy "web/locale/" directory.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-10 15:40:49 +02:00
Lukas Fleischer
f507f360a0 Remove newline in "web/lang/sr.po".
Do this in preparation for converting exisiting translation files into
gettext compatible ones. Newlines will he hard to match by a conversion
script.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-10 15:40:47 +02:00
Lukas Fleischer
668826226a Release 1.8.2.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-10 15:38:28 +02:00
Cédric Girard
77149ad011 Fix French translation.
* Translation of "notify" has been changed to the literal translation
  "notifier" which seems more appropriate (cf. recent thread on
  AUR-general)

* Uniformization of the translation of "flag"

* Addition of "TU" besides the translation of Trusted User as user may
  not understand that Trusted User and "Utilisateur de confiance" are
  the same thing

* Some capitalization correction (in French you don't put capital
  letters in the middle of a sentence as you do eg for title in
  English).

* "unsupported" translation has been replaced by "unsupported" (with
  quotes) as it makes no sense to translate it

* "Safe" translation has been replaced by "sûr" has it seems more
  appropriate than "sain" (sane)

Lukas: Added translator to "AUTHORS".

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-07 00:36:49 +02:00
Lukas Fleischer
5df16bf3c0 Merge branch 'wip' 2011-04-06 21:50:58 +02:00
Wieland Hoffmann
feff71ddfe Update the german translation
Lukas: Added missing translations strings. Added translator to
"AUTHORS".

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-06 21:42:59 +02:00
Lukas Fleischer
a5213daaec Make "Exact name" search option translatable.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-06 19:29:35 +02:00
Lukas Fleischer
1c55e6b40c Add option to search for exact name matches only (fixes FS#23556).
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-06 19:21:19 +02:00
Lukas Fleischer
8cd2aef50d Initialize "$name" in pkgname_from_id().
Ensures "$name" is always initialized, even if the package doesn't
exist. Fixes PHP warnings appearing when retrieving package details of a
package with an invalid ID.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-05 11:38:43 +02:00
Lukas Fleischer
8b4b2d207e Remove File_Find PEAR module from code base.
We removed the code depending on this a long time ago - drop it and add
some note to "UPGRADING".

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-05 11:31:12 +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
Dan McGee
2005a2889c Add more stats to the front page table
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-03 22:59:33 +02:00
Dan McGee
79ce38d271 Add indentation to stats table
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-03 22:59:32 +02:00
Dan McGee
7c91c59245 Remove Dummy Package concept
Instead, we just store dependencies directly in the PackageDepends
table. Since we don't use this info anywhere besides the package details
page, there is little value in precalculating what is in the AUR vs.
what is not.

An upgrade path is provided via several SQL statements in the UPGRADING
document. There should be no user-visible change from this, but the DB
schema gets a bit more sane and we no longer have loads of junk packages
in our tables that are never shown to the end user. This should also
help the MySQL query planner in several cases as we no longer have to be
careful to exclude dummy packages on every query.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-03 22:59:32 +02:00
Dan McGee
1f252eba64 Always set ModifiedTS including new packages
Set it equal to the SubmittedTS field, which will be our indication the
package is new when we show the logo on the front page of the AUR.

This results in the ability to remove the use of the unindexable
GREATEST() function from the AUR code everywhere we had to use it before
to handle the 0 timestamp case.

Note that there is no race condition here in calling UNIX_TIMESTAMP()
twice- it always returns the time at the beginning of statment
execution:

    mysql> select unix_timestamp(), sleep(2), unix_timestamp();
    +------------------+----------+------------------+
    | unix_timestamp() | sleep(2) | unix_timestamp() |
    +------------------+----------+------------------+
    |       1300851746 |        0 |       1300851746 |
    +------------------+----------+------------------+
    1 row in set (2.00 sec)

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-03 22:59:31 +02:00
Dan McGee
1128489bd0 Submission process code refactor
We had a ton of duplicate code shared between the insert and update
cases. Do a refactor so we can pull this stuff out below the if/else
block and only need it there once, saving some headaches.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-04-03 22:59:31 +02:00
Lukas Fleischer
a427bd72a7 Be more restrictive with source tarball contents.
Reject tarballs containing more than one directory or files outside a
directory.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-30 20:49:21 +02:00
Lukas Fleischer
0a625ae8ff Fix XSS vulnerability in "web/template/header.php".
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-30 17:07:27 +02:00
Lukas Fleischer
746c2b72b5 Fix PHP notice when submitting an empty file.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-30 16:16:27 +02:00
Lukas Fleischer
e4130fcca6 Fix strict standards warnings in "web/html/pkgsubmit.php".
end() expects a reference but we pass a function return value here.
Using list() is a bit hacky as well as it expects a 0-based array
whereas unpack() returns a 1-based array - thus we use "list(, $foo)".

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-30 12:28:17 +02:00
Lukas Fleischer
47faf88f14 Check if submitted files are in GZIP format.
This is quite hacky but this way we can ensure users get comprehensible
error messages when trying to upload ".tar.xz" or ".tar.bz2" files.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-30 11:55:32 +02:00
Lukas Fleischer
2eb45e7d9e Fix XSS vulnerabilities in "web/html/voters.php".
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-30 11:10:16 +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
Lukas Fleischer
3aa2240b7d Fix XSS vulnerabilities in package comment templates.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-30 10:49:51 +02:00