db: Add a wrapper around mysql_real_query()

Where before we would do something like

    snprintf(sql, SQL_MAX, "SELECT ...", somevar);
    d_fprintf(sql_log, "%s\n", sql);
    mysql_real_query(conn, sql, strlen(sql));
    res = mysql_store_result(conn);

We can now do

    res = sql_query(conn, "SELECT ...", somevar);

This involves two parts. A macro and a function to do the heavy lifting.

The macro is what should be used in code, as above. This macro then
calls __sql_query() passing it the mysql connection and the query
string, it also passes the function name of the caller for the sql log.

One micro-optimisation we do in __sql_query() is instead of doing
strlen(sql) in the mysql_real_query() call, use the return value from
vsnprintf() which is the number of bytes written into sql and pass that
to mysql_real_query() e.g

    len = vsnprintf(sql, sizeof(sql), ...);
    ...
    mysql_real_query(conn, sql, len);

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert delete_image() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert admin_list_users() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert admin_edit_user() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert admin_user_stats() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert admin_pending_activations() sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert activate_user() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert generate_new_key() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert forgotten_password() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert prefs_edit_user() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert process_receipt_approval() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert approve_receipts() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert reviewed_receipts() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert receipt_info() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert tagged_receipts() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert process_receipt() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: url_handlers: Convert void receipts() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: audit: Convert log_login() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: audit: Convert get_last_login() to sql_query()

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>
www: audit: Remove no longer required string.h include

With the conversion to sql_query() there are no longer any uses of
string.h here.

Signed-off-by: Andrew Clayton <andrew@opentechlabs.co.uk>