Site hosted by Angelfire.com: Build your free website today!
open("calendar")) { // Define the database shema. // Note that the "last_name" field is our key. $schema = array( array("event_key", FFDB_INT, "key"), array("event_name", FFDB_STRING), array("event_description", FFDB_STRING), array("event_submitted_by", FFDB_STRING), array("event_month", FFDB_STRING), array("event_day", FFDB_INT), array("event_year", FFDB_INT) ); // Try and create it... if (!$db->create("calendar", $schema)) { echo "Error creating database\n"; return; } } function today($record) { global $event_day; global $event_month; global $event_year; //echo "$event_month $event_day $event_year"; if (($record["event_month"] == $event_month) && ($record["event_day"] == $event_day) && ($record["event_year"] == $event_year)) return true; return false; } function show_event($record){ $eventNumber = $record["event_key"]; $eventName = $record["event_name"]; echo "-$eventName
"; } function getEvents(){ global $db; //get events for today $result = $db->getbyfunction("today"); //display events if there are any if($result != null) foreach($result as $item) show_event($item); } function days_in_month($_month, $_year) { if($_month == 2) { return days_in_feb($_year); } else { if($_month == 1 || $_month == 3 || $_month == 5 || $_month == 7 || $_month == 8 || $_month == 10 || $_month == 12) { return(31); } else { return(30); } } } function selectMonth($_month){ $selectstart = " "; echo $selectstart; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo $selectend; } function selectYear($selectedyear){ $day = getdate(); $year = $day['year']; $selectyeartop = " "; echo $selectyeartop; for($i=$year; $i<$year+5; $i++) { echo " "; } echo $selectyearbottom; } function convertMonth($alpha_month){ if($alpha_month == "January") return 1; else if($alpha_month== "February") return 2; else if($alpha_month== "February") return 2; else if($alpha_month== "March") return 3; else if($alpha_month== "April") return 4; else if($alpha_month== "May") return 5; else if($alpha_month== "June") return 6; else if($alpha_month== "July") return 7; else if($alpha_month== "August") return 8; else if($alpha_month== "September") return 9; else if($alpha_month== "October") return 10; else if($alpha_month== "November") return 11; else if($alpha_month== "December") return 12; return 1; } function days_in_feb($year){ //$year must be YYYY //[gregorian] leap year math : if ($year < 0) $year++; $year += 4800; if ( ($year % 4) == 0) { if (($year % 100) == 0) { if (($year % 400) == 0) { return(29); } else { return(28); } } else { return(29); } } else { return(28); } } /* prints the month and year that are passed to it in $date */ function printMonth($_month, $_year) { $timestamp = mktime(0,0,0,$_month,1,2000); $date = getdate ($timestamp); $monthText = $date['month']; $monthtext1 = "
"; $monthtext2 = "
$monthText $_year
"; echo "$monthtext1"; selectMonth($_month); selectYear($_year); echo "$monthtext2"; } /* prints the bar that contains the days of the week */ function printDays() { $daybar = " "; echo $daybar; } /* opens table for calendar which is closed by last week, then prints the first week to the calendar */ function printFirstWeek($_day) { global $event_day; //write table declarations echo " "; $current_day = 1; $spot = 0; while ($spot < $_day){ echo " "; $spot++; } while ($spot < 7){ $event_day = $current_day; echo " "; $spot++; $current_day++; } echo" "; return $current_day; } function printWeek($_day, $_last) { global $event_day; while ($_day <= ($_last - 7)){ $count = 0; echo " "; while($count < 7){ $event_day = $_day; echo " "; $_day++; $count++; } echo " "; } return $_day; } function printLastWeek($_day, $_lastday) { global $event_day; $count = 0; echo " "; while($count <= $_lastday) { $event_day = $_day; echo " "; $_day++; $count++; } while($count < 7) { echo " "; $count++; $_day++; } echo " "; echo "
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
 $current_day
"; getEvents(); echo "
$_day
"; getEvents(); echo "
$_day
"; getEvents(); echo "
 
"; } //calculate all date information needed if($sent_month && $sent_year){ $month = convertMonth($sent_month); $year = $sent_year; $event_day = 1; $event_month = $sent_month; $event_year = $year; } else { $day = getdate(); $month = $month = $day['mon']; $mday = $mday = $day['mday']; $year = $year = $day['year']; $event_day = 1; $event_month = $day['month']; $event_year = $year; } $days_in_month = days_in_month ($month, $year); $first_day = mktime(0,0,0,$month,1,$year); $date_first = getdate ($first_day); $last_day = mktime(0,0,0,$month,$days_in_month,$year); $date_last = getdate($last_day); $dayofweekfirst = $date_first['wday']; $dayofweeklast = $date_last['wday']; //end date calculations printMonth($month, $year); printDays(); $current = printFirstWeek($dayofweekfirst); $current = printWeek($current, $days_in_month); printLastWeek($current, $dayofweeklast); // Include Footer include("footer.php"); ?>