<?php

use SCF\Core\DI;
use SCF\Additionals\Tracking;
use SCF\Additionals\Download;
/**
 *  Download page for Downloads
 */

/**
 * Tracking Settings set for Database logging of Downloads
 * Please Remind that this only counts Click on DL Button, User can Cancel the Download
 * and the system will still think it was a finished download
 */
$tracking = new Tracking(DI::getInstance()->get('db'));
$tracking->setCurrentUserIp($_SERVER['REMOTE_ADDR']);
$tracking->setCurrentUserAgent($_SERVER['HTTP_USER_AGENT']);

/**
 * Check if controllerFile is NOT the EuropeanFontPatch for DownloadTracking
 */
if ($match['params']['controllerFile'] != 'EuropeanFontPatch') {
    $tracking->saveTrackingInDb('download', $settings->getValue('sks_download_version'));
    $dlFile = $settings->getValue('sks_download_file');
} else {
    $dlFile = $settings->getValue('sks_eufont_file');
}

/**
 * Set Needed Variables for the Download Class
 */
$dl = new Download();
$dl->setAbsolutePath($settings->getValue('sks_download_path'));
$dl->setFileName($dlFile);

$dl->startDownloadFile();

$tpl->display('index.tpl');