require_once("includes/config.php");
if(!isset($installed))
{
header("Location: install.php");
exit;
}
else
{
if(file_exists('install.php'))
{
header("Location: install.php");
exit;
}
}
$db_connection = mysql_connect ($DBHost, $DBUser, $DBPass) OR die (mysql_error());
$db_select = mysql_select_db ($DBName) or die (mysql_error());
$db_table = $TBL_PR . "events";
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
IF(!isset($_GET['year'])){
$_GET['year'] = date("Y");
}
IF(!isset($_GET['month'])){
$_GET['month'] = date("n")+1;
}
$month = addslashes($_GET['month'] - 1);
$year = addslashes($_GET['year']);
$query = "SELECT event_id,event_title,event_day,event_time FROM $db_table WHERE event_month='$month' AND event_year='$year' ORDER BY event_time";
$query_result = mysql_query ($query);
while ($info = mysql_fetch_array($query_result))
{
$day = $info['event_day'];
$event_id = $info['event_id'];
$events[$day][] = $info['event_id'];
$event_info[$event_id]['0'] = substr($info['event_title'], 0, 8);;
$event_info[$event_id]['1'] = $info['event_time'];
}
$todays_date = date("j");
$todays_month = date("n");
$days_in_month = date ("t", mktime(0,0,0,$_GET['month'],0,$_GET['year']));
$first_day_of_month = date ("w", mktime(0,0,0,$_GET['month']-1,1,$_GET['year']));
$first_day_of_month = $first_day_of_month + 1;
$count_boxes = 0;
$days_so_far = 0;
IF($_GET['month'] == 13){
$next_month = 2;
$next_year = $_GET['year'] + 1;
} ELSE {
$next_month = $_GET['month'] + 1;
$next_year = $_GET['year'];
}
IF($_GET['month'] == 2){
$prev_month = 13;
$prev_year = $_GET['year'] - 1;
} ELSE {
$prev_month = $_GET['month'] - 1;
$prev_year = $_GET['year'];
}
?>
Kyle McGillivray - Calendar
|
echo date ("F Y", mktime(0,0,0,$_GET['month']-1,1,$_GET['year'])); ?>
|
|
|
Sunday |
Monday |
Tuesday |
Wednesday |
Thursday |
Friday |
Saturday |
for ($i = 1; $i <= $first_day_of_month-1; $i++) {
$days_so_far = $days_so_far + 1;
$count_boxes = $count_boxes + 1;
echo " | \n";
}
for ($i = 1; $i <= $days_in_month; $i++) {
$days_so_far = $days_so_far + 1;
$count_boxes = $count_boxes + 1;
IF($_GET['month'] == $todays_month+1){
IF($i == $todays_date){
$class = "highlighteddayboxes";
} ELSE {
$class = "dayboxes";
}
} ELSE {
IF($i == 1){
$class = "highlighteddayboxes";
} ELSE {
$class = "dayboxes";
}
}
echo "\n";
$link_month = $_GET['month'] - 1;
echo "\n";
IF(isset($events[$i])){
echo "\n";
}
echo " | \n";
IF(($count_boxes == 7) AND ($days_so_far != (($first_day_of_month-1) + $days_in_month))){
$count_boxes = 0;
echo " \n";
}
}
$extra_boxes = 7 - $count_boxes;
for ($i = 1; $i <= $extra_boxes; $i++) {
echo " | \n";
}
$time_end = getmicrotime();
$time = round($time_end - $time_start, 3);
?>
|
|
|
|
|