This file is indexed.

/usr/share/IlohaMail/source/calendar.php is in ilohamail 0.8.14-0rc3sid6.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<?php
/////////////////////////////////////////////////////////
//	
//	source/calendar.php
//
//	(C)Copyright 2002-2003 Ryo Chijiiwa <Ryo@IlohaMail.org>
//
//		This file is part of IlohaMail.
//		IlohaMail is free software released under the GPL 
//		license.  See enclosed file COPYING for details,
//		or see http://www.fsf.org/copyleft/gpl.html
//
/////////////////////////////////////////////////////////

/********************************************************

	AUTHOR: Ryo Chijiiwa <ryo@ilohamail.org>
	FILE:  source/compose.php
	PURPOSE:
		Display calendar...
	
********************************************************/

include("../include/super2global.inc");
include("../include/header_main.inc");
include("../lang/".$my_prefs["lang"]."dates.inc");
include("../lang/".$my_prefs["lang"]."calendar.inc");
include("../include/icl.inc");
include("../include/version.inc");
include("../conf/defaults.inc");
include("../include/calendar.inc");

//authenticate
$conn=iil_Connect($host, $loginID, $password, $AUTH_MODE);
if ($conn){
	iil_Close($conn);
}else{
	echo "Authentication failed.";
	echo "</body></html>\n";
	exit;
}

//make sure feature is not disabled
if ($DISABLE_CALENDAR){
	echo $calStr["disabled"];
	echo "</body></html>\n";
	exit;
}

if ($edit_cal || $delete_cal){
	include("../include/edit_calendar.inc");
}

echo "<center>\n";

if (($go_month > 0) && ($go_year > 0)) $date = formatCalDate($go_month, 1, $go_year);

if (empty($date)) $date = date("Ymd", time());
if (strlen($date)==8){
	$current_year = substr($date, 0, 4);
	$current_month = substr($date, 4, 2);
	$current_day = substr($date, 6, 2);
}
if (!isset($current_ts)) $current_ts = mktime(0, 0, 0, $current_month, $current_day, $current_year);

//what's today's day of week?
$dow = date("w", $current_ts);

if (!isset($disp_mode)) $disp_mode = 0;
//0: begin on sunday
//1: begin on monday
//2: begin 3 days ago
//3: begin today
if ($disp_mode==0) $offset = $dow;
else if ($disp_mode==1) $offset = $dow-1;
else if ($disp_mode==2) $offset = 3;
else if ($disp_mode==3) $offset = 0;

//time stamp for last sunday (beginning of week)
$start_ts = $current_ts - ($offset * (60 * 60 * 24));

//time stamp for next saturday (end of week)
$end_ts = $start_ts + (60 * 60 * 24 * 6);

//which week of the month?
$end_day = date("d", $end_ts);
$wom = (int)($end_day / 7);
if (($end_day % 7) != 0) $wom++;

//starting date
$start_date = date("Ymd", $start_ts);
$end_date = date("Ymd", $end_ts);

//create hash tables for day-of-week <-> date
for ($i=0; $i<7; $i++){
	$temp_ts = $start_ts + ($i * (60 * 60 * 24));
	$temp_date = date("Ymd", $temp_ts);
	$temp_dow = date("w", $temp_ts);
	$date_dow[$temp_date] = "d".$temp_dow;		//date to day-of-week lookup
	$dow_date["d".$temp_dow] = $temp_date;		//day-of-week to date lookup
	$schedule2[$temp_date]["dow"] = $temp_dow;
}

$sql = "SELECT * FROM $DB_CALENDAR_TABLE WHERE userID='$session_dataID' ";
$sql.= "and ((beginDate<='$end_date' and endDate>='$start_date') ";
$sql.= "or (endDate<='$end_date' and endDate>='$start_date'))";

$backend_result = false;

if ($backend!="FS"){
	include_once("../conf/db_conf.php");
    include_once("../include/idba.$DB_TYPE.inc");
	
	if (!isset($db)) $db = new idba_obj;
	if ($db->connect()){
		$backend_result = $db->query($sql);
	}else{
		$backend_result = false;
	}
}
if ($backend_result){
	if ($db->num_rows($backend_result) > 0){
		//initialize schedule array
		//$schedule = array();
		
		//echo $backend_num_rows($backend_result)." rows";
		
		//loop through records
		while( $a = $db->fetch_row($backend_result) ){
			//create & initialize new scheduleItem object
			$item = new scheduleItem;
			$item->id = $a["id"];
			$item->title = $a["title"];
			$item->place = $a["place"];
			$item->description = $a["description"];
			$item->participants = $a["participants"];
			$item->beginTime = $a["beginTime"];
			$item->endTime = $a["endTime"];
			$item->color = $a["color"];
			
			//echo "<!-- ".$a["id"].":".$a["color"]." //-->\n";
			
			$pattern = $a["pattern"];
			$beginDate = $a["beginDate"];
			$endDate = $a["endDate"];
			
			//non-repeating event
			//if (strpos($pattern, "d:")===false){
			$pattern = chop($pattern);
			if (empty($pattern)){
				
				if ($beginDate == $endDate){
				//single day event
					$schedule2[$beginDate][$item->beginTime][] = $item;
				}else{
				//multi-day event
					if (($beginDate>=$start_date) && ($beginDate <= $end_date)){
						//insert event for first day (event ends at midnight)
						$temp_item = $item;
						$temp_item->endTime = 2400;
						$schedule2[$beginDate][$item->beginTime][]=$temp_item;					}
					if (($endDate<=$end_date) && ($endDate >= $start_date)){
						//insert event for last day (event beings at midnight)
						$temp_item = $item;
						$temp_item->beginTime = 0;
						$schedule2[$endDate][0][]=$temp_item;
					}
					
					if (($endDate-$beginDate)>1){
						//if event spans more than two days, insert events for all days inbetween
						
						if (!empty($date_dow[$beginDate])) $fromD = $date_dow[$beginDate][1]+1;
						else $fromD = 0;
						if (!empty($date_dow[$endDate])) $untilD = $date_dow[$endDate][1];
						else $untilD = 7;
						
						reset($date_dow);
						while ( list($k,$v) = each($date_dow) ){
							if (($k > $beginDate) && ($k < $endDate)){
								$temp_item = $item;
								$temp_item->beginTime = 0;
								$temp_item->endTime = 2400;
								$schedule2[$k][0][]=$temp_item;
							}
						}
						
					}
				}
			}else{
			//repeating event
				//check if this week is included in repetition
				if ((strpos($pattern,"w:all")!==false) || (strpos($pattern, "w".$wom)!==false)){
					$words = explode(" ", $pattern);
					while( list($k,$w)=each($words) ) if ($w[0]=="d") $dowpat=$w;
					$dowpat = substr($dowpat, 2);
					$dows = explode(",", $dowpat);
					while( list($k, $d)=each($dows) ){
						if (($dow_date["d".$d]>$start_date) && ($dow_date["d".$d]<$end_date)){
							$schedule2[$dow_date["d".$d]][$item->beginTime][]=$item;
						}
					}
				}else if (false !== ($pos=strpos($pattern, "m:"))){
					$repeat_day = substr($pattern, $pos+2, 2);
					$repeat_date = $current_year.$current_month.$repeat_day;
					if (($repeat_date >= $start_date) && ($repeat_date <= $end_date))
						$schedule2[$repeat_date][$item->beginTime][]=$item;
				}else if (false !== ($pos=strpos($pattern, "y:"))){
					$repeat_date = substr($pattern, $pos+2, 4);
					$repeat_date = $current_year.$repeat_date;
					if (($repeat_date >= $start_date) && ($repeat_date <= $end_date))
						$schedule2[$repeat_date][$item->beginTime][]=$item;					
				}
			}
		}

	}else{
		echo $error;
	}

	if (is_array($schedule2)){
		$start_date_a = getdate($start_ts);
		$end_date_a = getdate($end_ts);
		
		$last_ts = $current_ts - (60 * 60 * 24 * 7);
		$next_ts = $current_ts + (60 * 60 * 24 * 7);
		
		echo "<table width=\"60%\" cellspacing=0 cellpadding=0>\n";
		echo "<tr bgcolor=\"".$my_colors["main_head_bg"]."\">";
		echo "<td width=\"15%\" align=\"left\">";
			echo "<a class=mainHeading href=\"calendar.php?user=$user&date=".date("Ymd",$last_ts)."&mode=$mode\">&lt;&lt;</a";
		echo "</td>\n";
		echo "<td width=\"70%\" align=\"center\">";
			echo "<span class=\"bigTitle\">";
			$wdate_a = array("m"=>$lang_datetime["short_mon"][$start_date_a["mon"]], "d"=>$start_date_a["mday"], "y"=>$start_date_a["year"]);
			$wdate_str = LangInsertStringsFromAK($lang_datetime["verbal"], $wdate_a);
			echo str_replace("%d", $wdate_str, $calStr["weekof"]);
			echo "</span>\n";
		echo "</td>\n";
		echo "<td width=\"15%\" align=\"right\">";
				echo "<a class=mainHeading href=\"calendar.php?user=$user&date=".date("Ymd",$next_ts)."&mode=$mode\">&gt;&gt;</a";
		echo "</td>\n";
		echo "</table>\n";
		
		$dsow = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
		
		//display weekly schedule
		echo "\n<p>\n";
		echo '<table width="95%" border="0" cellspacing="1" cellpadding="3" bgcolor="'.$my_colors["main_head_bg"].'">';
		
		//show tabl header -days of week and dates
		echo "\n<tr>\n";
		reset($date_dow);
		while ( list($k,$d)=each($date_dow) ){
			$tbh_month = (int)substr($k, 4, 2);
			$tbh_day = (int)substr($k, 6, 2);
			$tbh_a = array("m"=>$lang_datetime["short_mon"][$tbh_month], "d"=>$tbh_day);
			$tbh_str = LangInsertStringsFromAK($lang_datetime["verbal_short"], $tbh_a);
			echo "<td align=\"center\" bgcolor=\"".$my_colors["main_hilite"]."\" width=\"14%\">";
			echo ($k==$date?"<b>":"").$lang_datetime["dsow"][$d[1]]."<br>".$tbh_str.($k==$date?"</b>":"");
			echo "</td>\n";
		}
		echo "</tr>\n";
		
		//show schedule
		echo "<tr>\n";
		reset($schedule2);
		while (list($k,$schedules)=each($schedule2)){
			if (!empty($k)){
				echo "<td align=\"left\" valign=\"top\" bgcolor=\"".$my_colors["main_bg"]."\" width=\"14%\"><span class=\"small\">";
				echo "[<a href=\"edit_calendar.php?user=$user&date=".$k."edit=\">+</a>]\n";
				
				$schedules = $schedule2[$k];
				
				//echo count($schedules);
				
				ksort($schedules);
				reset($schedules);
				while(list($start, $blah) = each($schedules)){
					if (strcmp($start,"date")!=0){
						if (is_array($schedules[$start])){
							while ( list($k2, $item)=each($schedules[$start]) ){
								//$item = $schedules[$start];
								echo "<p>";
						
								if (!empty($item->color)) $style="style=\"color: ".$item->color."\"";
								else $style="";
						
								if (($item->beginTime+$item->endTime)!=0){
									echo LangFormatIntTime($item->beginTime, $my_prefs["clock_system"], $lang_datetime["ampm"], $lang_datetime["time_format"]);
									//echo $item->beginTime;
									echo "-";
									//echo $item->endTime;
									echo LangFormatIntTime($item->endTime, $my_prefs["clock_system"], $lang_datetime["ampm"], $lang_datetime["time_format"]);
									echo ":<br>\n";
								}
								echo "<a href=\"edit_calendar.php?user=$user&edit=".$item->id."\" $style>";
								echo $item->title;
								echo (!empty($item->place)?" @":"").$item->place;
								echo "</a>\n";
							}
						}
					}
				}
				echo "</span></td>\n";
			} //if
		}//while
	}
	echo "</tr>\n";
	echo "</table>\n";
}//if ($backend_result)


//default values for month/year
$month = (int)$current_month;
$year = (int)$current_year;
$prev_month = ($month>1?$month-1:12);
$prev_year = ($month==1?$year-1:$year);
$next_month = ($month<12?$month+1:1);
$next_year = ($month==12?$year+1:$year);

echo "<p>\n";
echo "<table cellspacing=0 cellpadding=0><tr bgcolor=\"".$my_colors["main_head_bg"]."\">\n";
echo "<td valign=\"middle\">";
echo "<a class=mainHeading href=\"calendar.php?user=$user&date=".formatCalDate($current_month, $current_day, $current_year-1)."\">&nbsp;&lt;&lt;&nbsp;</a>\n";
echo "<a class=mainHeading href=\"calendar.php?user=$user&date=".formatCalDate($prev_month, $current_day, $prev_year)."\">&nbsp;&lt;&nbsp;</a>\n";
echo "</td>";
?>
<td class=mainHeading valign=bottom>
<form method="POST" action="calendar.php">
	<input type="hidden" name="user" value="<?php echo $user ?>">
	<select name="go_month">
	<?php
	for ($i=1;$i<=12;$i++) echo "<option value=\"$i\" ".($i==$current_month?"SELECTED":"").">".$lang_months[$i]."\n";
	?>
	</select>
	<select name="go_year">
	<?php
	for ($i=-5;$i<=10;$i++){
		$go_year = $current_year + $i;
		echo "<option value=\"$go_year\" ".($go_year==$current_year?"SELECTED":"").">$go_year\n";
	}
	?>
	</select>
	<input type="submit" name="go" value="<?php echo $calStr["go"]?>">
</form>
</td>
<?php
echo "<td valign=\"middle\">";
echo "<a class=mainHeading href=\"calendar.php?user=$user&date=".formatCalDate($next_month, $current_day, $next_year)."\">&nbsp;&gt;&nbsp;</a>\n";
echo "<a class=mainHeading href=\"calendar.php?user=$user&date=".formatCalDate($current_month, $current_day, $current_year+1)."\">&nbsp;&gt;&gt;&nbsp;</a>\n";
echo "</td>";
echo "</tr></table>\n";
echo "<p><table wdith=\"95%\" cellspacing=\"10\"><tr>\n";
echo "<td valign=\"top\">";
$month = $prev_month;
$year = $prev_year;
include("../include/display_monthly_calendar.inc");
echo "</td><td valign=\"top\">";
$month = (int)$current_month;
$year = $current_year;
include("../include/display_monthly_calendar.inc");
echo "</td><td valign=\"top\">";
$month = $next_month;
$year = $next_year;
include("../include/display_monthly_calendar.inc");
echo "</td>";
echo "</tr></table>";


echo "</center>";

?>