1<?php
2define('BASE', './');
3$current_view = "month";
4require_once(BASE.'functions/ical_parser.php');
5require_once(BASE.'functions/list_functions.php');
6require_once(BASE.'functions/template.php');
7header("Content-Type: text/html; charset=$phpiCal_config->charset");
8
9$minical_view = $current_view;
10switch ($phpiCal_config->minical_view) {
11	case 'day':
12	case 'week':
13	case 'month':
14		$minical_view = $phpiCal_config->minical_view;
15		break;
16}
17
18$unix_time 				= strtotime($getdate);
19$today_today 			= date('Ymd', time() + $phpiCal_config->second_offset);
20$tomorrows_date 		= date('Ymd', strtotime("+1 day",  $unix_time));
21$yesterdays_date 		= date('Ymd', strtotime("-1 day",  $unix_time));
22$sidebar_date 			= localizeDate($dateFormat_week_list, $unix_time);
23if (!isset($style_select)) $style_select = '';
24
25// find out next month
26$next_month_month 		= ($this_month+1 == '13') ? '1' : ($this_month+1);
27$next_month_day 		= $this_day;
28$next_month_year 		= ($next_month_month == '1') ? ($this_year+1) : $this_year;
29while (!checkdate($next_month_month,$next_month_day,$next_month_year)) $next_month_day--;
30$next_month_time 		= mktime(0,0,0,$next_month_month,$next_month_day,$next_month_year);
31
32// find out last month
33$prev_month_month 		= ($this_month-1 == '0') ? '12' : ($this_month-1);
34$prev_month_day 		= $this_day;
35$prev_month_year 		= ($prev_month_month == '12') ? ($this_year-1) : $this_year;
36while (!checkdate($prev_month_month,$prev_month_day,$prev_month_year)) $prev_month_day--;
37$prev_month_time 		= mktime(0,0,0,$prev_month_month,$prev_month_day,$prev_month_year);
38
39$next_month 			= date("Ymd", $next_month_time);
40$prev_month 			= date("Ymd", $prev_month_time);
41$display_date 			= localizeDate ($dateFormat_month, $unix_time);
42$parse_month 			= date ("Ym", $unix_time);
43$first_of_month 		= $this_year.$this_month."01";
44$start_month_day 		= dateOfWeek($first_of_month, $phpiCal_config->week_start_day);
45$thisday2 				= localizeDate($dateFormat_week_list, $unix_time);
46$num_of_events2 			= 0;
47
48// select for calendars
49$available		= availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED);
50$list_icals 	= display_ical_list($available);
51$list_years 	= list_years();
52$list_months 	= list_months();
53$list_weeks 	= list_weeks();
54$list_jumps 	= list_jumps();
55$list_calcolors = list_calcolors();
56$list_icals_pick = display_ical_list($available, TRUE);
57
58// login/logout
59$is_logged_in = ($username != '' && !$invalid_login) ? true : false;
60$show_user_login = (!$is_logged_in && $phpiCal_config->allow_login == 'yes');
61$login_querys = login_querys();
62$logout_querys = logout_querys();
63
64$page = new Page(BASE.'templates/'.$phpiCal_config->template.'/month.tpl');
65$page->replace_files(array(
66	'header'			=> BASE.'templates/'.$phpiCal_config->template.'/header.tpl',
67	'event_js'			=> BASE.'functions/event.js',
68	'footer'			=> BASE.'templates/'.$phpiCal_config->template.'/footer.tpl',
69    'calendar_nav'      => BASE.'templates/'.$phpiCal_config->template.'/calendar_nav.tpl',
70    'search_box'        => BASE.'templates/'.$phpiCal_config->template.'/search_box.tpl'
71	));
72
73$page->replace_tags(array(
74	'version'			=> $phpiCal_config->phpicalendar_version,
75	'charset'			=> $phpiCal_config->charset,
76	'template'			=> $phpiCal_config->template,
77	'cal'				=> $cal,
78	'getdate'			=> $getdate,
79	'getcpath'			=> "&cpath=$cpath",
80	'cpath'             => $cpath,
81	'calendar_name'		=> $cal_displayname,
82	'display_date'		=> $display_date,
83	'rss_powered'	 	=> $rss_powered,
84	'default_path'		=> $phpiCal_config->default_path,
85	'rss_available' 	=> '',
86	'rss_valid' 		=> '',
87	'show_search' 		=> $phpiCal_config->show_search,
88	'next_day' 			=> $tomorrows_date,
89	'next_month' 		=> $next_month,
90	'prev_day'	 		=> $yesterdays_date,
91	'prev_month'	 	=> $prev_month,
92	'show_goto' 		=> '',
93	'show_user_login'	=> $show_user_login,
94	'invalid_login'		=> $invalid_login,
95	'login_querys'		=> $login_querys,
96	'is_logged_in' 		=> $is_logged_in,
97	'username'			=> $username,
98	'logout_querys'		=> $logout_querys,
99	'list_jumps' 		=> $list_jumps,
100	'list_icals' 		=> $list_icals,
101	'list_icals_pick'	=> $list_icals_pick,
102	'list_years' 		=> $list_years,
103	'list_months' 		=> $list_months,
104	'list_weeks' 		=> $list_weeks,
105	'legend'	 		=> $list_calcolors,
106	'current_view'		=> $current_view,
107#	'style_select' 		=> $style_select,
108	'sidebar_date'		=> $sidebar_date,
109	'l_goprint'			=> $lang['l_goprint'],
110	'l_preferences'		=> $lang['l_preferences'],
111	'l_calendar'		=> $lang['l_calendar'],
112	'l_legend'			=> $lang['l_legend'],
113	'l_tomorrows'		=> $lang['l_tomorrows'],
114	'l_jump'			=> $lang['l_jump'],
115	'l_todo'			=> $lang['l_todo'],
116	'l_prev'			=> $lang['l_prev'],
117	'l_next'			=> $lang['l_next'],
118	'l_day'				=> $lang['l_day'],
119	'l_week'			=> $lang['l_week'],
120	'l_month'			=> $lang['l_month'],
121	'l_year'			=> $lang['l_year'],
122	'l_subscribe'		=> $lang['l_subscribe'],
123	'l_download'		=> $lang['l_download'],
124	'l_this_months'		=> $lang['l_this_months'],
125	'l_search'			=> $lang['l_search'],
126	'l_pick_multiple'	=> $lang['l_pick_multiple'],
127	'l_powered_by'		=> $lang['l_powered_by'],
128	'l_this_site_is'	=> $lang['l_this_site_is']
129	));
130
131if ($phpiCal_config->allow_preferences != 'yes') {
132	$page->replace_tags(array(
133	'allow_preferences'	=> ''
134	));
135}
136
137if ($phpiCal_config->allow_login == 'yes') {
138	$page->replace_tags(array(
139	'l_invalid_login'	=> $lang['l_invalid_login'],
140	'l_password'		=> $lang['l_password'],
141	'l_username'		=> $lang['l_username'],
142	'l_login'			=> $lang['l_login'],
143	'l_logout'			=> $lang['l_logout']
144	));
145}
146
147if ($phpiCal_config->show_search != 'yes') {
148	$page->nosearch($page);
149}
150
151if ($phpiCal_config->this_months_events == 'yes') {
152	$page->monthbottom($page);
153} else {
154	$page->nomonthbottom($page);
155}
156
157$page->draw_subscribe($page);
158$page->output();
159
160?>
161