<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

if (!session_id()) {
  session_start();
}

if (!defined('BASEDIR')) {
  include_once '..' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'constants.php';
}

CodingOperations::encodeEingaben();
CodingOperations::setObStartIfInternalAndExternalEncodingAreDiffrent();

SecurityOperations::PurgeInput();

$year = SessionOperations::getVarValueEinst('year', date('Y'));
$month = SessionOperations::getVarValueEinst('month', date('n'));
$veranart = '';
if (isset($_REQUEST['year'])) {
  $year = $_REQUEST['year'];
}

if (isset($_REQUEST['month'])) {
  $month = $_REQUEST['month'];
}

if (isset($_REQUEST['kfs_veranartids'])) {
  $veranart = $_REQUEST['kfs_veranartids'];
}


if (!is_numeric($month) || !is_numeric($year) || !checkdate($month, 1, $year)) {
  exit;
} else {
  
  SessionOperations::setVarValueEinst('year', $year);
  SessionOperations::setVarValueEinst('month', $month);
}

$kalender = Kufer\Web\Webbasys\Includee\Api\KalenderAPIFactory::getKalenderAPI();



$kalender->typo3_call = TYPO3_CMS_USED;

if (SEARCHENGINE_FUNCTIONS === true && !TYPO3_CMS_USED && !WORDPRESS_CMS_USED) {
  echo SeoApi::rewriteLinks($kalender->getEinzelveranstaltungsTabelle($year, $month, $veranart));
} else {
  echo $kalender->getEinzelveranstaltungsTabelle($year, $month, $veranart);
}

CodingOperations::encodeAnzeige();