| Server IP : 104.21.21.239 / Your IP : 216.73.216.11 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/tgnewprod/mod/ |
Upload File : |
<?php require('_mod_security.php'); ?>
<?php
switch ($_GET['func']):
case 'load_month' :
$yr = nz($_GET['year'], '0');
$mo = nz($_GET['month'], '0');
$start_date = $yr . '-' . $mo . '-01';
$sql = "SELECT DAY(start_time_local) AS day_of_month, COUNT(*) as num_events
FROM events
WHERE start_time_local >= :start_date AND start_time_local < DATE_ADD(:start_date, INTERVAL 1 MONTH) AND status = 1
GROUP BY DAYOFMONTH(start_time_local)
ORDER BY day_of_month
";
$stmt = $db->prepare($sql);
$stmt->execute([
'start_date' => $start_date,
]);
$cal_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$cal_data = array_column($cal_data, 'num_events', 'day_of_month');
$first_day = intval(date('j', strtotime($yr.'-'.$mo.'-1')));
$first_day_of_week = intval(date('N', strtotime($yr.'-'.$mo.'-2'))); //use 1 for Monday, 2 for Sunday
$days_in_month = cal_days_in_month(CAL_GREGORIAN, $mo, $yr);
$html = '';
$html .= '<table class="grid">';
$html .= '<tr>';
for ($i = 0; $i < 7; $i++) :
$dow_text = substr(date('l', strtotime('Sunday + '.$i.' days')), 0, 1); //use Monday or Sunday here
$html .= '<th><div class="calendar_cell_header">' . $dow_text . '</div></th>';
endfor;
$html .= '</tr>';
$done = false;
$day = 0;
$row = 0;
$day_started = false;
while (!$done) :
$html .= '<tr>';
for ($i = 1; $i <= 7; $i++) :
$cell_html = '';
if ($i == $first_day_of_week) :
$day_started = true;
endif;
if ($day_started && $day < $days_in_month) :
$day++;
$current_day_style = '';
if ($yr.'-'.$mo.'-'.$day == date('Y-m-j')) :
$current_day_style = ' calendar_cell_current ';
endif;
$ring_style = '';
if (($cal_data[$day] ?? 0) > 9) :
$ring_style = 'calendar_cell_background_4';
elseif (($cal_data[$day] ?? 0) > 6) :
$ring_style = 'calendar_cell_background_3';
elseif (($cal_data[$day] ?? 0) > 3) :
$ring_style = 'calendar_cell_background_2';
elseif (($cal_data[$day] ?? 0) > 0) :
$ring_style = 'calendar_cell_background_1';
endif;
if (($cal_data[$day] ?? 0) > 0) :
$cell_html .= '<div class="calendar_cell '.$ring_style.' '.$current_day_style.'"><a href="events/' . date('Y-m-d', strtotime($yr.'-'.$mo.'-'.$day)) . '/">'.$day.'</a></div>';
else :
$cell_html .= '<div class="calendar_cell '.$ring_style.' '.$current_day_style.'">'.$day.'</div>';
endif;
endif;
$html .= '<td>' . $cell_html . '</td>';
endfor;
$html .= '</tr>';
if ($day >= $days_in_month) :
$done = true;
endif;
endwhile;
$html .= '</table>';
echo $html;
return;
break;
endswitch;