##################################
@define('_CAL_TABS_', $TABS);
@define('_CAL_LOGIN_LINK_', $LOGIN_LINK);
@define('_CAL_CALENDAR_TITLE_', $CALENDAR_TITLE);
@define('_CAL_DETAILS_POST_', $DETAILS_POST);
@define('_CAL_TODAY_LINK_', $TODAY_LINK);
@define('_CAL_SEARCH_BOX_', $SEARCH_BOX);
@define('_CAL_GOTO_DATE_', $GOTO_DATE);
$_cal_orig_mqr = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
# initial install?
@include_once(dirname(__FILE__) . "/include/config.php");
if(!@defined("_CAL_SQL_DRIVER_") && file_exists("install.php")) {
header("Location: install.php");
exit;
}
# holds notes for events
$GLOBALS['_cal_notes'] = array();
require_once(@constant("_CAL_BASE_PATH_") . "include/classes/class.html.php");
require_once(@constant("_CAL_BASE_PATH_") . "include/classes/class.calendar_real.php");
require_once(@constant("_CAL_BASE_PATH_") . "include/classes/class.repeater.php");
define("_CAL_USE_SESSION_", 1);
define("_CAL_INTERFACE_MAIN_", 1);
# LOGOUT USERR
######################333
if($_REQUEST['logout']) {
$_REQUEST['userid'] = $_REQUEST['pass'] = "";
$s = new _cal_session();
$s->start();
$s->destroy();
if(!is_array($_SESSION)) $_SESSION = array();
foreach(array_keys($_SESSION) as $k) {
unset($_SESSION[$k]);
}
unset($s);
}
global $_cal_html, $_cal_user, $_cal_views, $_cal_modules, $_cur_cal;
$_cal_html = new _cal_html();
###############################
#
### Apple Safari fix
#
###############################
if(!@constant("_CAL_EMBEDDED_") && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "safari") !== false) {
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0", true);
header("Pragma: no-cache");
}
require_once(_CAL_BASE_PATH_."include/classes/class.cal_obj.php");
($_cur_cal && $_cur_cal->id == $_SESSION['calendar']) or $_cur_cal = new _cal_obj(abs($_SESSION['calendar']));
# check for calendar access
###########################
if(($_SESSION['calendar'] && !$_cal_user->access->can_view($_cur_cal)) || !$_SESSION['calendar']) {
$_SESSION['calendar'] = 0;
$_cur_cal = new _cal_obj(0);
}
# include our modules definitions
###################################
require_once(@constant("_CAL_BASE_PATH_") ."include/modules.php");
#############################
#
### DECIDE WHAT TO DISPLAY
#
#############################
# events ?
####################
if(isset($_REQUEST['event_action'])) {
$_cal_view = "events";
# modules ?
##################
} else if($_cal_modules[$_REQUEST['module']]) {
$mod = $_cal_modules[$_REQUEST['module']];
# is the default user allowed?
##############################
if($mod['no_guest'] && $_cal_user->guest) {
$_cal_html->permission_denied(true); # fixed
return;
}
# is it an admin module
#############################
if($mod['admin_module'] && !$_cal_user->admin) {
$_cal_html->permission_denied(true); # fixed
return;
}
$_cal_view = "module";
$_cal_view_url = "module=". $_REQUEST['module'];
# default to this session's
# last known view
#################
} else {
$_cal_view = $_SESSION["v"];
$_cal_view_url = "v=". $_cal_view;
}
# figure out our title and set persistent
# url to go to
switch($_cal_view)
{
case "y":
$t = _YEAR_;
$_cal_tmp1 = 'year';
break;
case "m":
$t = _MONTH_;
$_cal_tmp1 = 'month';
break;
case "d":
$t = _DAY_;
$_cal_tmp1 = 'day';
break;
case "w":
$t = _WEEK_;
$_cal_tmp1 = 'week';
break;
case "module":
$t = $_cal_modules[$_REQUEST['module']]['display_name'];
break;
case "events";
$t = _EVENTS_;
break;
}
#######################
#
### GET CURRENT CALENDAR
#
#########################
if($_SESSION['calendar']) {
########################
#
# ADD RSS FEED LINK
#
#########################
if(strlen($_cal_view) == 1 && $_cal_view != 'y') {
$_cal_html->add_head(" description}\" href=\"".@constant("_CAL_BASE_URL_") .
"remote/rss.php?calendar={$_cur_cal->id}"._CAL_AMP_."view={$_cal_tmp1}\" >");
}
}
##################################
#
### SET PAGE TITLE
#
##################################
if(($_cal_view == "module" && $_cal_modules[$_REQUEST['module']]['keep_cal_title']) || $_cal_view != "module")
$t = ($_cur_cal->title ? $_cur_cal->title ." - " : "") . $t;
$_cal_html->print_header($t);
# check if admin
#################################################
if($GLOBALS['_cal_user']->logged_in && $GLOBALS['_cal_user']->admin) {
# check if install.php still exists
###################################
if(file_exists(@constant("_CAL_BASE_PATH_") . "install.php"))
$_cal_html->warning(sprintf(_WARNING_INSTALL_, constant("_CAL_BASE_PATH_") . "install.php"));
}
# require newWin
require_once(@constant("_CAL_BASE_PATH_") . "include/js/newWin.js");
# header start
################
##################################
#
### CALNEDAR SETUP AND INFO
#
###################################
if(!$_cur_cal->not_found) {
# NOTIFY OF INVALID CALENDARS
#################################
$_cur_cal->get_constraint();
if(count($_cur_cal->invalids)) {
$titles = $_cal_sql->query("select id, title from {$_cal_dbpref}Calendars where id in (".
join(",",$_cur_cal->invalids) .")", true);
foreach($titles as $t)
$_cal_html->warning(_VIEW_INVALID_CAL_." - ". $t." ");
}
$links = array();
if(@constant('_CAL_DETAILS_POST_')) {
$durl = new _cal_url("cal_details.php");
$durl->addArg("calendar", $_SESSION['calendar']);
$links[] = "toString() ."', 500, 700)\">". _DETAILS_ ." ";
$durl = new _cal_url("cal_publisher.php");
$durl->addArg("calendar", $_SESSION['calendar']);
if(function_exists("curl_init")) {
$links[] = "toString() . "', 300, 500)\">". _PUBLISH_ ." ";
}
}
$_cal_info['title'] = $_cur_cal->title;
$_cal_info['description'] = $_cur_cal->description;
# PRINT CALENDAR TITLE
###########################
if(@constant('_CAL_CALENDAR_TITLE_')&& (($_cal_view == "module" && $_cal_modules[$_REQUEST['module']]['keep_cal_title']) || ($_cal_view != "module" && $_cal_view != "events"))) {
_ex_cal_title($_cal_info, $links);
}
$links = array();
}
# main table start..
####################
echo("
");
##################################
#
### TABS
#
###################################
$_cal_views = array("d" => _DAY_, "w" =>_WEEK_, "m" => _MONTH_ , "y" => _YEAR_,
"events" => _EVENTS_);
if(@constant('_CAL_TABS_')) {
$url = new _cal_url();
$url->addArg("v","d");
$_cal_modules['daytab'] = array('display_name' => _DAY_,'url' => $url->toString(),
'selected' => ($_cal_view == "d"), 'priority' => 5);
$url->addArg("v","w");
$_cal_modules['weektab'] = array('display_name' => _WEEK_,'url' => $url->toString(),
'selected' => ($_cal_view == "w"), 'priority' => 10);
$url->addArg("v","m");
$_cal_modules['monthtab'] = array('display_name' => _MONTH_,'url' => $url->toString(),
'selected' => ($_cal_view == "m"), 'priority' => 15);
$url->addArg("v","y");
$_cal_modules['yeartab'] = array('display_name' => _YEAR_,'url' => $url->toString(),
'selected' => ($_cal_view == "y"), 'priority' => 20);
$url->addArg("v", "events");
$_cal_modules['eventstab'] = array('display_name' => _EVENTS_,'url' => $url->toString(),
'selected' => ($_cal_view == "events"), 'priority' => 25);
$url->addArg("v","");
$tabs_int = array('daytab','weektab','monthtab','yeartab','eventstab');
##########################
# GET TAB MODULES IF ANY
###########################
if(!is_array($_cal_modules['tab']['sub_modules'])) $_cal_modules['tab']['sub_modules'] = array();
$_cal_modules['tab']['sub_modules'] = array_merge($tabs_int, $_cal_modules['tab']['sub_modules']);
usort($_cal_modules['tab']['sub_modules'], "_ex_mod_cmp");
foreach($_cal_modules['tab']['sub_modules'] as $mn)
{
$url->addArg("module", $mn);
$name = $_cal_modules[$mn]['display_name'];
$selected = $_cal_modules[$mn]['selected'] || ($_cal_view == "module" && $_REQUEST['module'] == $mn);
$tabs[] = array('name' => $name,
'url' => ($_cal_modules[$mn]['url'] ? $_cal_modules[$mn]['url'] : $url->toString()),
'selected' => $selected);
}
echo("\n");
if(function_exists("_ex_tabs")) {
_ex_tabs($tabs);
}
echo('
');
}
# CHECK THAT OUR VIEW IS VALID
###############################
if(!$_cal_views[$_cal_view] && $_cal_view != "module")
$_SESSION["v"] = $_cal_view = "m";
# end main table row
echo(" \n \n");
# start a new one..
echo("\n\n");
# header row for main table..
###########################
if(function_exists("_ex_content_header"))
_ex_content_header();
# end main table row
echo(" \n \n");
# start a new one..
echo("\n\n");
# new table for content
echo("
\n");
usort($_cal_modules['navbar']['sub_modules'], "_ex_mod_cmp");
# ARE WE HIDING THE NAV BAR?
##############################
#if($_SESSION['hide_nav'] || $_REQUEST['event_action'] || $_cal_view == 'events' ||
# ($_cal_view == "module" && $_cal_modules[$_REQUEST['module']]['hide_nav'])) {
if(1) {
echo("\n");
main_cal();
echo(" \n");
# PRINT NAV BAR
###################################
} else {
if($_cal_modules['navbar']['modules_left']) {
# spacer
echo(" ");
echo("\n");
require(@constant("_CAL_BASE_PATH_") ."modules/navbar/navbar.php");
echo(" ");
# spacer
echo(" ");
}
echo("");
main_cal();
echo(" ");
if($_cal_modules['navbar']['modules_right']) {
# spacer
echo(" ");
echo("");
require(@constant("_CAL_BASE_PATH_") . "modules/navbar/navbar.php");
echo(" ");
# spacer
echo(" ");
}
}
echo("\n \n
\n");
echo("\n \n \n\n\n");
$url = new _cal_url();
$url->addArg("module", $_REQUEST['module']);
# footer row for main table..
###########################
if($_SESSION['hide_nav'] != 1) {
$url->addArg("hide_nav", "1");
$link = " ";
} else {
$url->addArg("hide_nav", "0");
$link = " ";
}
if(!$_REQUEST['event_action']) {
global $_cal_modules;
$links = array();
if(0 &&
($_cal_modules['navbar']['modules_left'] || $_cal_modules['navbar']['modules_right'])
&&
!($_REQUEST['event_action'] || $_cal_view == 'events' ||
($_cal_view == "module" && $_cal_modules[$_REQUEST['module']]['hide_nav']))) {
$links[] = _VIEW_NOUN_ .": ". $link;
} else {
$links = array();
}
# sort footer modules..
usort($_cal_modules['footer']['sub_modules'], "_ex_mod_cmp");
foreach($_cal_modules['footer']['sub_modules'] as $mn)
{
$mod = $_cal_modules[$mn];
if($_cal_user->guest && $mod['no_guest'])
continue;
if(!$_cal_user->guest && $mod['guest_only'])
continue;
if(!$_cal_user->admin && $mod['admin_module'])
continue;
if($_cal_user->admin && $mod['no_admin'])
continue;
$url = new _cal_url();
$url->addArg("module", $mn);
$links[] = "".
$mod['display_name'] ." ";
}
$url = new _cal_url();
if(!$_cal_user->guest && @constant('_CAL_LOGIN_LINK_')) {
$url->addArg("logout", "1");
$links[] = "". _LOGOUT_ .
(!@constant("_CAL_HIDE_USER_LOGOUT_") ? " - ". $_cal_user->userid : "")
." ";
$url->addArg("logout", "");
} else if(@constant('_CAL_LOGIN_LINK_')) {
$url = new _cal_url(_CAL_PAGE_LOGIN_);
$links[] = "".
_LOGIN_ ." ";
}
}
if(function_exists("_ex_content_footer")) {
_ex_content_footer($links);
} else {
foreach($links as $link) {
echo($link . " ");
}
}
echo("\n \n \n
\n");
#######################
#
#### QUICK ADD BOX
#
#######################
if(!($_cal_view == "module") && !isset($_REQUEST['event_action']) && $_cal_user->access->can_add($_cur_cal) && !@constant("_CAL_HIDE_QUICK_ADD_")) {
echo(" ");
require_once(@constant("_CAL_BASE_PATH_") . 'include/quick_add_event.php');
}
#
#
#######################
if(!@constant("_CAL_NO_ADV_")) {
echo(" ");
echo("");
}
##############################
#
### NOTE POPUPS
#
##############################
require_once(@constant("_CAL_BASE_PATH_") . "include/js/notes_popups.js");
$_cal_popups = "";
if(!@constant("_CAL_THEME_POPUPS_")) {
ob_start();
require_once(@constant("_CAL_BASE_PATH_") . "include/event_notes_popup.php");
$_cal_popups = ob_get_contents();
ob_end_clean();
} else {
require_once(_CAL_BASE_PATH_."include/event_notes_popup.php");
}
ob_start();
# print remaining notes popups
foreach($GLOBALS['_cal_notes'] as $n) {
print $n;
}
$_cal_popups .= ob_get_contents();
ob_end_clean();
$_cal_html->print_footer($_cal_popups);
set_magic_quotes_runtime($_cal_orig_mqr);
############################
#
### MAIN CALENDAR OR EVENT
#
############################
function nav_top()
{
global $_cur_cal, $_cal_user, $TABS, $_cal_view, $_cal_views, $TODAY_LINK, $SEARCH_BOX, $GOTO_DATE;
require_once(_CAL_BASE_PATH_."include/classes/class.form.php");
$nform = new _cal_form('navtop');
$nform->print_header();
$calendars_r = $_cal_user->access->get_cals_sel(0);
if(!$_SESSION['calendar'] || ($_SESSION['calendar'] && !$calendars_r[$_SESSION['calendar']])) {
if(!$calendars_r[0]) $calendars_r[0] = " ";
$nform->defaults['calendar'] = "0";
} else {
if($calendars_r[0]) unset($calendars_r[0]);
$nform->defaults['calendar'] = $_SESSION['calendar'];
}
$nform->defaults['evnt_type'] = intval($_SESSION['evnt_type']);
echo("\n");
echo("");
if(@constant('_CAL_TODAY_LINK_')) {
global $_cal_weekdays, $_cal_months;
$time = _ex_localtime();
$url = new _cal_url();
$url->addArg("d", _ex_date("j", $time));
$url->addArg("m", _ex_date("n", $time));
$url->addArg("y", _ex_date("Y", $time));
# Today
echo(" ");
if(@constant("_CAL_EURO_DATE_")) {
echo($_cal_weekdays[_ex_date("w", $time)]. " ");
echo(_ex_date("j", $time) ." ");
echo($_cal_months[_ex_date("n", $time)]);
} else {
echo($_cal_weekdays[_ex_date("w", $time)]. ", ");
echo($_cal_months[_ex_date("n", $time)]. " ");
echo(_ex_date("j", $time));
}
echo(" ");
}
echo(" ");
if(!@constant('_CAL_TABS_')) {
$nform->defaults['v'] = $_SESSION['v'];
echo(_VIEW_.": ". $nform->select('v', $_cal_views,
"onChange='document.forms[\"navtop\"].submit()'") ." ");
}
if(count($calendars_r) > 1) {
echo(_CALENDAR_ .": ". $nform->select('calendar', $calendars_r,
"onChange='document.forms[\"navtop\"].submit()'") ." ");
}
if(count($_cur_cal->get_categories())) {
echo(_EVENT_TYPE_ .": ". $nform->select("evnt_type",
array( 0 => _ALL_) + $_cur_cal->get_categories(),
"onChange='document.forms[\"navtop\"].submit()'"));
} else if($_cur_cal->has_subcals) {
global $_cal_sql, $_cal_dbpref;
# get categories
$vcats = $_cal_sql->query("select distinct name, name
from {$_cal_dbpref}EventTypes where calendar
". $_cur_cal->get_constraint(), true);
uasort($vcats,'strnatcasecmp');
echo(_EVENT_TYPE_.": ");
# set the default
$nform->defaults['vcat'. $which] = $_SESSION['vcat'];
$nform->print_select('vcat', array(0 => _ALL_) +
$vcats , "onChange='document.forms[\"navtop\"].submit()'");
}
if(@constant('_CAL_SEARCH_BOX_')) {
echo(" ". _SEARCH_ .": ". $nform->textbox("searchfor", 15));
}
$nform->print_footer();
if(@constant('_CAL_GOTO_DATE_')) {
$gtdform = new _cal_form();
$gtdform->print_header(" style='display: inline;'");
$gtdform->print_hidden('goto_date','goto_date');
echo(" ". _GOTO_DATE_.": ". $nform->textbox('date',15));
$gtdform->print_footer();
}
echo("
");
}
function nav_views()
{
global $_cur_cal, $_cal_user, $TABS, $_cal_view, $_cal_views;
if(@constant('_CAL_TABS_')) return;
require_once(_CAL_BASE_PATH_."include/classes/class.form.php");
$nform = new _cal_form('navtop');
$nform->print_header();
echo("");
$nform->defaults['v'] = $_cal_view;
$views = $_cal_views;
if(!$views[$_cal_view]) $views[$_cal_view] = " ";
echo(_VIEW_.": ". $nform->select('v', $views,
"onChange='document.forms[\"navtop\"].submit()'") ." ");
$nform->print_footer();
}
function main_cal()
{
global $_cal_view, $_cal_html, $cal, $_cal_modules;
$cal or $cal = new _cal_calendar_real();
if($_SESSION['evnt_type'] > 0) $cal->event_types = $_SESSION['evnt_type'];
$cal->show_footer = 1;
$cal->printable = 1;
switch($_cal_view)
{
case "y":
nav_top();
$cal->display_year();
break;
case "m":
nav_top();
$cal->display_month();
break;
case "d":
nav_top();
$cal->display_day();
break;
case "w":
nav_top();
$cal->display_week();
break;
case "module":
nav_views();
require_once(@constant("_CAL_BASE_PATH_") ."modules/" .$_cal_modules[$_REQUEST['module']]['include']);
break;
case "events";
nav_views();
require_once(@constant("_CAL_BASE_PATH_") . "include/events.php");
break;
}
}
function _ex_is_writable($f, $mkdir = false)
{
# NOT WINDOWS?
if(strtolower(substr(PHP_OS,0,3)) != 'win') {
if($mkdir || is_dir($f)) @chmod($f,0777);
else @chmod($f, 0666);
return is_writable($f);
}
@chmod($f,0666);
# dir?
if(is_dir($f)) {
if($mkdir) {
if(is_dir($f .'\\t_ex_is_writable')) return true;
return @mkdir($f.'\\t_ex_is_writable');
}
if(is_file($f .'\\t_ex_is_writable.tmp')) return true;
$ret = @fopen($f .'\\t_ex_is_writable.tmp',"w");
if(!$ret) return false;
fclose($ret);
return true;
}
# file
$ret = @fopen($f, "a");
if(!$ret) return false;
fclose($ret);
return true;
}
?>