/**
 * @return boolean
 */
function check_download_ability()
{
    refresh_session_folder();
    if (check_download_ability_current() && check_download_ability_daily()) {
        return true;
    } else {
        return false;
    }
}
<?php

/*
 * Author: Hendrik Still
 * Email: gamma32@gmail.com
 */
require_once 'lib.php';
require_once 'config.php';
refresh_session_folder();
switch ($_GET['action']) {
    case 'test':
        echo get_oldest_current();
        $seconds_to_next_reset_daily = mktime(0, 0, 0, date('m') + $mth, date('d') + 1, date('Y')) - time();
        $seconds_to_next_reset_current = AVG_DOWNLOAD_TIME - (time() - get_oldest_current());
        $seconds_to_next_reset = !check_download_ability_current() && check_download_ability_daily() ? $seconds_to_next_reset_current : $seconds_to_next_reset_daily;
        echo $seconds_to_next_reset;
        echo '<br>';
        echo $seconds_to_next_reset_current;
        break;
    case 'json':
        echo "{\r\n\t\t\t\"MAXIMUM_PARALLEL_DOWNLOADS\" : " . MAXIMUM_PARALLEL_DOWNLOADS . ",\r\n\t\t\t\"MAXIMUM_DAILY_DOWNLOADS\" : " . MAXIMUM_DAILY_DOWNLOADS . ",\r\n\t\t\t\"PARALLEL_DOWNLOADS\" : " . get_current_downloads() . ",\r\n\t\t\t\"DAILY_DOWNLOADS\" : " . get_daily_downloads() . ",\r\n\t\t\t\"DOWNLOAD_ABILITY\" : ";
        echo check_download_ability() ? 'true' : 'false';
        echo "}";
        break;
    case 'reset':
        if ($_GET['password'] == RESET_PASSWORD) {
            reset_sessions();
        }
    default:
        $template_vars['maximum_parallel'] = MAXIMUM_PARALLEL_DOWNLOADS;
        $template_vars['maximum_daily'] = MAXIMUM_DAILY_DOWNLOADS;