Replace hack to determine url used by pagination

Until now, the pagination of the ACP games used a hack to determine the base
url, now this is determined while building the SQL query.