*
 * Copyright (c) 2015 Potsky, contributors
 * Licensed under the GPLv3 license.
 */
include_once 'global.inc.php';
list($badges, $files) = config_load();
/*
|--------------------------------------------------------------------------
| Login
|--------------------------------------------------------------------------
|
*/
if (!Sentinel::isAuthSet()) {
    die;
}
$current_user = Sentinel::attempt($files);
/*
|--------------------------------------------------------------------------
| Error handling
|--------------------------------------------------------------------------
|
*/
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
    global $return;
    if (!(error_reporting() & $errno)) {
        return;
    }
    switch ($errno) {
        case E_USER_ERROR:
            echo json_encode(array('error' => $errstr));