<?php
// Easy PHP Calendar
// Version 7
// Copyright NashTech, Inc.
// http://www.EasyPHPCalendar.com

// SET ERROR REPORTING LEVEL
error_reporting(E_ALL ^ E_NOTICE);
if(defined('E_DEPRECATED')) {
    error_reporting(error_reporting() & ~E_DEPRECATED);
}

if ($epcGetInit!=1) {

// DETERMINE NAME OF CURRENT FILE
if (!isset($thisFile) || (isset($_GET['thisFile']) || isset($_POST['thisFile']))) {
  $thisFile = $_SERVER['SCRIPT_NAME'];
  $thisFile = explode("/",trim($thisFile)); 
  $thisFile = $thisFile[count($thisFile)-1];
  if (!file_exists($thisFile)) $thisFile = htmlentities($_SERVER['PHP_SELF']);
  }

// SERVER (ROOT) PATH TO CALENDAR DIRECTORY
if (!isset($serverPath) || $serverPath!="../" || $getPaths==1) {

// This address should start and end with a "/" unless this is on a windows server where it will start with a drive letter;

$serverPath=""; // MANUALLY SET THE SERVER PATH HERE

if ($serverPath=="") $serverPath = dirname( __FILE__ )."/";
}

// URL PATH TO CALENDAR DIRECTORY
// This path should start and end with a "/". 
// It is usually the name of the directory this file is in (Example: "/calendar/");
// This would only need to be manually set if the calendar directory is not
// within the public root directory structure of your web space or you're
// using a temporary address (such as with a "~" in the URL).
// * If you enter the full URL starting with "http://", this address will not be verified by the calendar script!

$urlPath=""; // MANUALLY SET THE URL PATH HERE

if ($urlPath=="" && $serverPath!="") {
    $serverPathTemp = str_replace("\\","/",$serverPath);
	if (stripos($serverPathTemp,$_SERVER['DOCUMENT_ROOT']) !== false) {
		$urlPath = str_replace($_SERVER['DOCUMENT_ROOT'],"",$serverPathTemp);
	}
	else {
		$urlPath = explode("/",str_replace("\\","/",$serverPath));
	    $urlPath = "/".$urlPath[(count($urlPath)-2)]."/";
	}
}
}

if ($getPaths!=1 && $epcGetInit!=1) {

// MAKE SURE CONFIGURATION IS LOADED
if (!is_array($epcConfig)) {
	require($serverPath."config.inc.php");
}

// INCLUDE CSS ROUTINE
if ($CSS!="") {

  $currentTheme=$epcConfig['theme'];

  if ($urlPath=="") {
    echo "<link href=\"theme/$currentTheme/esstyle.css\" rel=\"stylesheet\" type=\"text/css\" />";
	echo "<link href=\"theme/$currentTheme/annual.css\" rel=\"stylesheet\" type=\"text/css\" />";
	require("functions/categories.php");
	}
  else {
    if (!isset($showTheme) && $_REQUEST['showTheme']!="") $showTheme=$_REQUEST['showTheme'];
    if (isset($showTheme)) {
	  $checkTheme = $serverPath."theme/".$showTheme."/esstyle.css";
	  if (file_exists($checkTheme)) {
	    $currentTheme = $showTheme;
		}
	  }
    echo "<link href=\"".$urlPath."theme/$currentTheme/esstyle.css\" rel=\"stylesheet\" type=\"text/css\" />";
	echo "<link href=\"".$urlPath."theme/$currentTheme/annual.css\" rel=\"stylesheet\" type=\"text/css\" />";
	require($serverPath."functions/categories.php");
	}
  }

if ($PCSS==1) {
  echo "<link href=\"".$urlPath."theme/".$epcConfig['theme']."/popup.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
  echo "<link href=\"".$urlPath."theme/".$epcConfig['theme']."/esstyle.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
  require($serverPath."functions/categories.php");
  }

// INCLUDE OVERLIB ROUTINE
if ($OL==1) {
  
  // DETERMINE FILENAME
  $olFileName = "overlib.js";
  if (file_exists($serverPath."includes/overLIB/overlib_mini.js")) $olFileName = "overlib_mini.js";
  
  echo "<script type=\"text/JavaScript\">\n";
  if (isset($epcConfig[ol_width])) echo "  var ol_width=$epcConfig[ol_width];\n";
  if (isset($epcConfig[ol_delay])) echo "  var ol_delay=$epcConfig[ol_delay];\n";
  if (isset($epcConfig[ol_fgcolor])) echo "  var ol_fgcolor=\"#$epcConfig[ol_fgcolor]\";\n";
  if (isset($epcConfig[ol_bgcolor])) echo "  var ol_bgcolor=\"#$epcConfig[ol_bgcolor]\";\n";
  if (isset($epcConfig[ol_offsetx])) echo "  var ol_offsetx=$epcConfig[ol_offsetx];\n";
  if (isset($epcConfig[ol_offsety])) echo "  var ol_offsety=$epcConfig[ol_offsety];\n";
  if (isset($epcConfig[ol_border])) echo "  var ol_border=$epcConfig[ol_border];\n";
  if ($epcConfig[ol_fixx]!=0) echo "  var ol_fixx=$epcConfig[ol_fixx];\n";
  if ($epcConfig[ol_fixy]!=0) echo "  var ol_fixy=$epcConfig[ol_fixy];\n";
  if ($epcConfig[ol_sticky]!=0 || $showTheme=="system") echo "  var ol_sticky=1;\n";
  if ($epcConfig[ol_anchor]==1) echo "  var ol_anchor=\"escOL\";";
  if ($epcConfig[ol_anchor]==1) echo "  var ol_anchoralign=\"ul\";";
  echo "  var ol_vauto=1;\n";
  echo "</script>\n";
  echo "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div><script type=\"text/JavaScript\" src=\"".$urlPath."includes/overLIB/".$olFileName."\"><!-- overLIB (c) Erik Bosrup --></script>";
  if ($epcConfig[ol_anchor]==1) echo "<script src=\"".$urlPath."includes/overLIB/overlib_anchor.js\"></script>";
  }

// DISPLAY AGENDA CALENDAR
if ($LIST==1) {
  require ($serverPath."functions/agenda.php");
  }

// DISPLAY BLOG CALENDAR
if ($EPCBLOG==1) {
  require ($serverPath."functions/mini.php");
  }
if ($EPCBLOG==2) {
  require ($serverPath."functions/blog.php");
  }

// DISPLAY STANDARD CALENDAR
if ($TOC==1) {
  require ($serverPath."functions/standard.php");
  }

// DISPLAY FILM STRIP CALENDAR
if ($EPCANNUAL==1) {
  require ($serverPath."functions/annual.php");
  }

// DISPLAY MULTIPLE CALENDARS
if ($MULTI==1) {
  require($serverPath."plugins/multiShow.php");
  $MULTIX=1;
  }

// DISPLAY MINI CALENDAR
if ($CSS=="" && $OL!=1 && $LIST!=1 && $PCSS=="" && $TOC=="" && $MULTIX=="" && $EPCBLOG=="" && $EPCANNUAL=="") {
  require ($serverPath."functions/mini.php");
  }

// UNSET MODE VARIABLES
unset ($CSS,$PCSS,$OL,$LIST,$TOC,$MULTI,$MULTIX,$EPCANNUAL);
}
?>