<?php
/*
    CREATIVE COMMONS - Attribution-No Derivative Works 3.0 Germany:
    - You may not alter, transform, or build upon this work.
    - Dieses Werk darf nicht bearbeitet oder in anderer Weise verändert werden.
*/
  if ( getSetup('SetupGeneralBackendUseCache') )
  {
    $Path = 'cache';
    $UserStatus = getCurrentUserVar ('UserStatus');
    $UserStatus = strtolower ( $UserStatus );
    $FileName = $UserStatus.'-'.$Year.'-'.$monat.'.php';
    if ( is_file($Path."/".$FileName ) )
    {
      $n = filesize( $Path."/".$FileName ) ;
      $FileHandle = fopen( $Path."/".$FileName , "r" ) ;
      $dateiInhalt = fread( $FileHandle , $n ) ;
      $zeit = filemtime ( $Path."/".$FileName );
      fclose( $FileHandle ) ;
      // Cache optimieren
        if (substr_count( $dateiInhalt, ' class="Today"' )==0) $FileContainsString = false;
          else $FileContainsString = true;
        if ( date('dmY', $zeit) != date('dmY') ) $FileFromToday = false;
          else $FileFromToday = true;
        if ( date('mY', $zeit) != date('mY') ) $FileFromThisMonth = false;
          else $FileFromThisMonth = true;
        if ( date($monat.$Year, $zeit) != date('mY') ) $CurrentMonthSimilarShownMonth = false;
          else $CurrentMonthSimilarShownMonth = true;
      if ( $FileContainsString )
      {
        if ( $FileFromToday )
        {
          if ( $CurrentMonthSimilarShownMonth ) echo $dateiInhalt;
          else
          {
            include ('calendar/backend_month-html.php');
            writeToCache ( $FileName, $String);
          }
        }
        else
        {
          include ('calendar/backend_month-html.php');
          writeToCache ( $FileName, $String);
        }
      }
      else
      {
        if ( $FileFromThisMonth ) echo $dateiInhalt;
        else
        {
          if ( $CurrentMonthSimilarShownMonth )
          {
            include ('calendar/backend_month-html.php');
            writeToCache ( $FileName, $String);
          }
          else echo $dateiInhalt;
        }
      }
    }
    else
    {
      include ('calendar/backend_month-html.php');
      writeToCache ( $FileName, $String);
    }
  }
  else
  {
    clearCache ();
    include ('calendar/backend_month-html.php');
    echo $String;
  }
?>