function day($ask, $date) { global $EVENTS_TB, $CAT_TB, $USER_TB, $mth, $week, $m, $d, $y, $viewweekok, $viewcalok, $viewdayok, $allowsearch, $searchdayok, $popupevent, $popupeventwidth, $popupeventheight, $calstartyear, $caladvanceyear, $addeventok, $userview, $userlogin, $userid, $addeventwin_w, $addeventwin_h, $shortdesclen, $catview, $ugroup, $uname, $showuserentry, $publicview, $dayview_w, $notimeentry; if (!isset($yda)) { $yda = ''; } if ($viewdayok == 1) { if (!$date) { $year = $y; $month = $m; $day = $d; } else { $year = substr($date, 0, 4); $month = substr($date, 5, 2); $day = substr($date, 8, 2); } $we = mktime(0, 0, 0, $month, $day, $year); $we = strftime("%w", $we); $we++; // variables with exact digit without the leading 0 used for query and accessing array $vdm = $month; if (substr($vdm, 0, 1) == "0") { $vdm = str_replace("0", "", $vdm); } $vda = $day; if (substr($vda, 0, 1) == "0") { $vda = str_replace("0", "", $vda); } $weeknumber = weekNumber($day, $month, $year); if ($year > $y + $caladvanceyear) { $weeknumber = 53; } // to ensure weeks cannot go beyond restricted dates if ($year < $calstartyear) { $weeknumber = 1; } // to ensure weeks cannot go beyond restricted dates echo "<table border=0 width={$dayview_w} cellspacing=0 align=center class=headerfont><tr><td align=left>" . translate("Events for day"); echo ": " . $week[$we] . " " . $day . " "; if ($year <= $y + $caladvanceyear && $year >= $calstartyear) { if ($viewcalok == 1) { echo "<a class=headerfont href='calendar.php?op=cal&month=" . $vdm . "&year=" . $year . "&catview={$catview}'>"; } } echo $mth[$vdm]; if ($year <= $y + $caladvanceyear && $year >= $calstartyear) { if ($viewcalok == 1) { echo "</a>"; } } echo " " . $year . " "; if ($viewweekok == 1) { echo "<a href='cal_week.php?op=week&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $day, $year)) . "&catview={$catview}'><img src=\"images/week.gif\" border=0 alt='" . translate("View week") . " {$weeknumber}" . "' width=16 height=16/></a>"; } $weekday = date("w", mktime(12, 0, 0, $vdm, $vda, $year)); $weekday++; if ($publicview == 1 && $uname != "" || $publicview == 0) { if ($addeventok == 1) { echo " <a href='#{$week[$weekday]}' onclick=\"Javascript:wopen('cal_addevent.php?op=eventform&add_day={$day}&add_month={$month}&add_year={$year}&catview={$catview}','popupwin'," . $addeventwin_w . "," . $addeventwin_h . ",'yes');\"><img src='images/plus.gif' border=0 valign=middle alt='" . translate("Add Event") . "' width=11 height=11/></a>"; } } echo "</td>"; echo "<td align=right><div class=menufont>"; // display previous day and next day navigation if ($year > $calstartyear || $vdm > 1 && $year == $calstartyear || $vdm == 1 && $year == $calstartyear && $vda > 1) { echo "<a href=\"cal_day.php?op=day&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $day - 1, $year)) . "&catview={$catview}\r\n\"><< " . translate("Previous day") . "</a> "; } else { echo " "; } $calendyear = $y + $caladvanceyear; if ($year < $calendyear || $vdm < 12 && $year == $calendyear || $vdm == 12 && $year == $calendyear && $vda < 31) { echo "<a href=\"cal_day.php?op=day&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $day + 1, $year)) . "&catview={$catview}\">" . translate("Next day") . " >></a> <br/>"; } else { echo " "; } echo "</div></td></tr></table>"; $query = "select id,user,title,description,url,email,cat_name,starttime,endtime,day,month,year from " . $EVENTS_TB . " left join " . $CAT_TB . " on " . $EVENTS_TB . ".cat=" . $CAT_TB . ".cat_id where day='{$vda}' and month='{$vdm}' and year='{$year}' and approved='1'"; if ($catview != 0) { $query = $query . " and " . $EVENTS_TB . ".cat={$catview}"; } if ($userview == 1 && $userlogin == 1) { // user view user specific events only if ($ugroup != 0) { $query = $query . " and user='******'"; } } $query = $query . " order by starttime,title ASC"; $result = mysql_query($query); echo "<table width={$dayview_w} class=dayevent cellspacing=0 align=center><tr><td align=left>"; if (mysql_num_rows($result) != 0) { while ($row = mysql_fetch_object($result)) { if ($notimeentry == 0) { if ($row->starttime == '') { echo "<li>"; } else { showtime($row->starttime, $row->endtime, 0); } } else { echo "<li>"; } echo "<b>"; echo stripslashes($row->title); if ($showuserentry == 1 && $uname != "") { echo " <" . $row->user . ">"; } echo "</b>"; if ($notimeentry == 1 || $row->starttime == '') { echo "</li>"; } else { echo "<br/>"; } echo translate("Category") . " : " . stripslashes($row->cat_name) . "<br/>"; $de = $row->description; // $de = str_replace("<br />","",$row->description); echo substr(stripslashes($de), 0, $shortdesclen); if ($row->email != "" || $row->url != "" || strlen($de) > $shortdesclen) { echo " ...\n"; } else { echo "\n"; } echo "<br/>"; if ($popupevent == 1) { echo "<div class=menufont><a href=\"Javascript:void(0);\" onclick=\"Javascript:popup(" . $row->id . ");\">"; } else { echo "<div class=menufont><a href=cal_event.php?id=" . $row->id . ">"; } echo translate("Read more") . "</a></div>"; echo "<hr/>"; } } else { echo " <br/>"; } echo "</td></tr></table>"; // this is for the goto day redirection javascript echo "<script language=\"JavaScript\" type=\"text/JavaScript\">\n"; echo "\tfunction gotoday(selectopt) {\n"; echo "var geti = '1' ;\n"; echo "for (i=0;i<selectopt.options.length;i++) {\n"; echo "\tif (selectopt.options[i].selected) {\n"; echo "\t\tgeti = selectopt.options[i].value ;\n"; echo "\t\tbreak ;\n"; echo "\t}\n"; echo "}\n\n"; echo "\t\tswitch (geti) { \n"; $dateinmonth = date("t", mktime(0, 0, 0, $month, $day, $year)); for ($i = 1; $i <= $dateinmonth; ++$i) { echo "case \"" . $i . "\" : { window.location.href='cal_day.php?op=day&date="; echo date("Y-m-d", mktime(0, 0, 0, $month, $i, $year)); echo "&catview={$catview}' ; break ;} \n"; } echo "default : { window.location.href='cal_day.php?op=day&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $day, $year)) . "&catview={$catview}' ; break;} \n"; echo "\t\t}\n"; echo "\t}\n"; echo "</script>"; // display form functions echo "<table border=0 width={$dayview_w} align=center><tr><td align=left width=34%> </td>"; echo "<td align=center valign=middle width=33%>"; echo "<form><div class=menufont>\n"; echo "<b>" . translate("Go to day") . " </b>"; // get week number echo "<select name=goday onchange=\"javascript:gotoday(this);\""; if ($year > $y + $caladvanceyear || $year < $calstartyear) { echo " disabled"; } echo ">\n"; for ($i = 1; $i <= $dateinmonth; $i++) { echo "\t<option value=" . $i; if ($day == $i) { echo " selected "; } echo ">" . $i . "\n"; } echo "</select>\n"; if ($viewweekok == 1) { echo "<b>" . translate("or week") . " </b>"; // get week number echo "<select name=goweek onchange=\"javascript:gotoweek(this);\">\n"; for ($i = 1; $i < 53; $i++) { echo "\t<option value=" . $i; if ($weeknumber == $i) { echo " selected "; } echo ">" . $i . "\n"; } if (showWeek53($year) > 52) { for ($i = 53; $i <= showWeek53($year); $i++) { echo "\t<option value=" . $i; if ($weeknumber == $i) { echo " selected "; } echo ">" . $i . "\n"; } } echo "</select> \n"; } echo "</div></form>"; echo "</td>"; echo "<td align=right valign=middle width=33%>"; if ($allowsearch == 1 && $searchdayok == 1) { search(); } echo "</td></tr></table>"; } else { echo "<br/><div class=titlefont>" . translate("disabled") . ".</div>"; } }
echo "\t}\n"; echo "}\n\n"; echo "\t\tswitch (geti) { \n"; for ($i = $calstartyear; $i <= $y + $caladvanceyear; ++$i) { $jstr = "calendar.php?op=cal&month=" . $hm . "&year=" . $i; if ($uname != "" && $uname != "-") { $jstr = $jstr . "&uname={$uname}"; } echo "case \"{$i}\" : { window.location.href='" . $jstr . "' ; break ;} \n"; } echo "default : { window.location.href='calendar.php?op=cal&month={$hm}&year={$hy}' ; break;} \n"; echo "\t\t}\n"; echo "\t}\n"; echo "</script>"; // this is for the goto week redirection javascript $weeknumber = weekNumber($hd, $hm, $hy); echo "<script language=\"JavaScript\" type=\"text/JavaScript\">\n"; echo "\tfunction gotoweek(selectopt) {\n"; echo "var geti = '1' ;\n"; echo "for (i=0;i<selectopt.options.length;i++) {\n"; echo "\tif (selectopt.options[i].selected) {\n"; echo "\t\tgeti = selectopt.options[i].value ;\n"; echo "\t\tbreak ;\n"; echo "\t}\n"; echo "}\n\n"; echo "\t\tswitch (geti) { \n"; for ($i = 1; $i <= 54; ++$i) { // maximum ever number of weeks is 54! $jstr = "cal_adminweek.php?op=week&date="; $totaldays = ($i - $weeknumber) * 7 + $hd; $jstr = $jstr . date("Y-m-d", mktime(0, 0, 0, $hm, $totaldays, $hy));
function day($ask, $date) { global $EVENTS_TB, $CAT_TB, $USER_TB, $uname, $mth, $week, $language, $m, $d, $y, $calstartyear, $caladvanceyear, $unapprovedclr, $shortdesclen, $showuserentry, $notimeentry; // View events for specific user if (!isset($_POST['huser'])) { $huser = ''; } else { $huser = $_POST['huser']; } if (!isset($yda)) { $yda = ''; } if (!$date) { $year = $y; $month = $m; $day = $d; } else { $year = substr($date, 0, 4); $month = substr($date, 5, 2); $day = substr($date, 8, 2); } $we = mktime(0, 0, 0, $month, $day, $year); $we = strftime("%w", $we); $we++; // variables with exact digit without the leading 0 used for query and accessing array $vdm = $month; if (substr($vdm, 0, 1) == "0") { $vdm = str_replace("0", "", $vdm); } $vda = $day; if (substr($vda, 0, 1) == "0") { $vda = str_replace("0", "", $vda); } $weeknumber = weekNumber($day, $month, $year); if ($year > $y + $caladvanceyear) { $weeknumber = 53; } // to ensure weeks cannot go beyond restricted dates if ($year < $calstartyear) { $weeknumber = 1; } // to ensure weeks cannot go beyond restricted dates echo "<table class=headerfont border=0 width=100% cellspacing=0><tr><td align=left>" . translate("Events for day"); echo ": " . $week[$we] . " " . $day; if ($year <= $y + $caladvanceyear && $year >= $calstartyear) { echo " <a class=headerfont href=calendar.php?op=cal&month=" . $vdm . "&year=" . $year; urlvar($uname); echo " >"; } else { echo " "; } echo $mth[$vdm]; if ($year <= $y + $caladvanceyear && $year >= $calstartyear) { echo "</a> "; } else { echo " "; } echo $year . " <a href=cal_adminweek.php?op=week&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $day, $year)); urlvar($uname); echo " ><img src=\"../images/week.gif\" border=0 alt='" . translate("View week") . " {$weeknumber}" . "' width=16 height=16/></a>"; echo " <a href='cal_event.php?op=eventform&add_day={$day}&add_month={$month}&add_year={$year}'><img src='../images/plus.gif' border=0 valign=middle alt='" . translate("Add Event") . "' width=11 height=11/></a>"; echo "</td>"; echo "<td align=right><div class=menufont>"; // display previous day and next day navigation if ($year > $calstartyear || $vdm > 1 && $year == $calstartyear || $vdm == 1 && $year == $calstartyear && $vda > 1) { echo "<a href=\"cal_adminday.php?op=day&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $day - 1, $year)); urlvar($uname); echo "\"><< " . translate("Previous day") . "</a> "; } else { echo " "; } $calendyear = $y + $caladvanceyear; if ($year < $calendyear || $vdm < 12 && $year == $calendyear || $vdm == 12 && $year == $calendyear && $vda < 31) { echo "<a href=\"cal_adminday.php?op=day&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $day + 1, $year)); urlvar($uname); echo "\">" . translate("Next day") . " >></a> <br/>"; } else { echo " "; } echo "</div></td></tr></table>"; $query = "select id,user,title,description,url,email,cat_name,starttime,endtime,day,month,year,approved from " . $EVENTS_TB . " left join " . $CAT_TB . " on " . $EVENTS_TB . ".cat=" . $CAT_TB . ".cat_id where day='{$vda}' and month='{$vdm}' and year='{$year}' "; if ($uname != "" && $uname != "-") { $query = $query . " and " . $EVENTS_TB . ".user='******' "; } $query = $query . " order by starttime,title ASC"; $result = mysql_query($query); echo "<table class=dayevent width=100% border=0 class=dayevent cellspacing=0><tr><td align=left>"; if (mysql_num_rows($result) != 0) { while ($row = mysql_fetch_object($result)) { if ($row->approved == '0') { echo "<table class=dayevent width=100% border=0 ><tr><td bgcolor='{$unapprovedclr}'>"; } if ($notimeentry == 0) { if ($row->starttime == '') { echo "<li>"; } else { showtime($row->starttime, $row->endtime, 0); } } else { echo "<li>"; } echo "<b>" . stripslashes($row->title); if ($showuserentry == 1) { echo " <" . $row->user . ">"; } echo "</b>"; if ($notimeentry == 1 || $row->starttime == '') { echo "</li>"; } else { echo "<br/>"; } echo translate("Category") . " : " . stripslashes($row->cat_name) . "<br/>"; $de = $row->description; //$de = str_replace("<br />","",$row->description); echo substr(stripslashes($de), 0, $shortdesclen); if ($row->email != "" || $row->url != "" || strlen($de) > $shortdesclen) { echo " ...\n"; } else { echo "\n"; } echo "<div class=menufont><a href=cal_event.php?op=view&id=" . $row->id . ">" . translate("View event") . "</a>\n"; echo " - <a href=cal_event.php?op=edit&id=" . $row->id . ">" . translate("Edit event") . "</a>\n"; echo " - <a href=cal_event.php?op=delev&id=" . $row->id . ">" . translate("Delete event") . "</a>\n"; if ($row->approved == '0') { echo " - <a href=calendar.php?op=approve&id=" . $row->id . ">" . translate("Approve") . "</a>\n"; } echo "</div>\n"; echo "<hr/>"; if ($row->approved == '0') { echo "</td></tr></table>"; } } } else { echo " <br/>"; } echo "</td></tr></table>"; // this is for the goto day redirection javascript echo "<script language=\"JavaScript\" type=\"text/JavaScript\">\n"; echo "\tfunction gotoday(selectopt) {\n"; echo "var geti = '1' ;\n"; echo "for (i=0;i<selectopt.options.length;i++) {\n"; echo "\tif (selectopt.options[i].selected) {\n"; echo "\t\tgeti = selectopt.options[i].value ;\n"; echo "\t\tbreak ;\n"; echo "\t}\n"; echo "}\n\n"; echo "\t\tswitch (geti) { \n"; $dateinmonth = date("t", mktime(0, 0, 0, $month, $day, $year)); for ($i = 1; $i <= $dateinmonth; ++$i) { $jstr = "cal_adminday.php?op=day&date="; $jstr = $jstr . date("Y-m-d", mktime(0, 0, 0, $month, $i, $year)); if ($uname != "" && $uname != "-") { $jstr = $jstr . "&uname={$uname}"; } echo "case \"" . $i . "\" : { window.location.href='" . $jstr . "' ; break ;} \n"; } echo "default : { window.location.href='cal_adminday.php?op=day&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $day, $year)) . "' ; break;} \n"; echo "\t\t}\n"; echo "\t}\n"; echo "</script>"; // display form functions echo "<table border=0 width=100%><tr><td align=left width=50%>"; echo "<table width=100 cellspacing=0 cellpadding=2 align=left class=txtbox><tr><td bgcolor='{$unapprovedclr}' align=center><div class=normalfont>" . translate("Unapproved events") . "</div></td></tr></table>\n</td>"; echo "<td align=right valign=middle width=50%>"; echo "<form><div class=menufont>\n"; echo "<b>" . translate("Go to day") . " </b>"; // get week number echo "<select name=goday onchange=\"javascript:gotoday(this);\""; if ($year > $y + $caladvanceyear || $year < $calstartyear) { echo " disabled"; } echo ">\n"; for ($i = 1; $i <= $dateinmonth; $i++) { echo "\t<option value=" . $i; if ($day == $i) { echo " selected "; } echo ">" . $i . "\n"; } echo "</select>\n"; echo "<b>" . translate("or week") . " </b>"; // get week number echo "<select name=goweek onchange=\"javascript:gotoweek(this);\">\n"; for ($i = 1; $i < 53; $i++) { echo "\t<option value=" . $i; if ($weeknumber == $i) { echo " selected "; } echo ">" . $i . "\n"; } if (showWeek53($year) > 52) { for ($i = 53; $i <= showWeek53($year); $i++) { echo "\t<option value=" . $i; if ($weeknumber == $i) { echo " selected "; } echo ">" . $i . "\n"; } } echo "</select> <br/>\n"; // Display the users to be selected echo "<b>" . translate("View events of user") . ": </b> "; // get users $uquery = "select username,user_id from " . $USER_TB; $uresult = mysql_query($uquery); echo "<select name=huser onchange=\"Javascript:seeuser(this);\">\n"; echo "\t<option value='-'"; if ($uname == "-" || $uname == "") { echo " selected "; } echo ">--\n"; while ($urow = mysql_fetch_object($uresult)) { echo "\t<option value='{$urow->username}'"; if ($uname == "{$urow->username}") { echo " selected "; } echo ">" . $urow->username . "\n"; } echo "</select> \n"; echo "</div></form>"; echo "</td>"; echo "<td align=right valign=middle width=33%>"; echo "</td></tr></table>"; }
function week($week, $date) { global $EVENTS_TB, $CAT_TB, $USER_TB, $mth, $week, $m, $d, $y, $ld, $fd, $weekstartday, $calstartyear, $caladvanceyear, $unapprovedclr, $shortdesclen, $showuserentry, $uname, $notimeentry; // View events for specific user if (!isset($_POST['huser'])) { $huser = ''; } else { $huser = $_POST['huser']; } if (!$date) { $year = $y; $month = $m; $day = $d; } else { $year = substr($date, 0, 4); $month = substr($date, 5, 2); $day = substr($date, 8, 2); } // offset to get correct day calculation when "date" is sent $day_offset = date("w", mktime(0, 0, 0, $month, $day, $year)); $dayoff = 0; // use to get back original url "date" while ($day_offset > date("w")) { $day--; $day_offset = date("w", mktime(0, 0, 0, $month, $day, $year)); $dayoff++; } while ($day_offset < date("w")) { $day++; $day_offset = date("w", mktime(0, 0, 0, $month, $day, $year)); $dayoff--; } // get first day of the week based on "$weekstartday" function firstDayOfWeek($year, $month, $day) { global $fd, $weekstartday; $dayOfWeek = date("w"); $sunday_offset = $dayOfWeek * 60 * 60 * 24; $startday_offset = ($weekstartday - 1) * 60 * 60 * 24; $fd = date("Y-m-d", mktime(0, 0, 0, $month, $day + 1, $year) - $sunday_offset + $startday_offset); return $fd; } firstDayOfWeek($year, $month, $day); // get last day of the week based on "$weekstartday" function lastDayOfWeek($year, $month, $day) { global $ld, $weekstartday; $dayOfWeek = date("w"); $saturday_offset = (6 - $dayOfWeek) * 60 * 60 * 24; $startday_offset = ($weekstartday - 1) * 60 * 60 * 24; $ld = date("Y-m-d", mktime(0, 0, 0, $month, $day + 1, $year) + $saturday_offset + $startday_offset); return $ld; } lastDayOfWeek($year, $month, $day); // display header with week number echo "<table class=headerfont border=0 width=100% cellspacing=0><tr><td>" . translate("Events from "); $fdy = substr($fd, 0, 4); $fdm = substr($fd, 5, 2); if (substr($fdm, 0, 1) == "0") { $fdm = str_replace("0", "", $fdm); } $fdd = substr($fd, 8, 2); echo $fdd . " " . $mth[$fdm] . " " . $fdy; echo " " . translate("till") . " "; $ldy = substr($ld, 0, 4); $ldm = substr($ld, 5, 2); if (substr($ldm, 0, 1) == "0") { $ldm = str_replace("0", "", $ldm); } $ldd = substr($ld, 8, 2); echo $ldd . " " . $mth[$ldm] . " " . $ldy; $weeknumber = weekNumber($day + $dayoff, $month, $year); if ($ldy > $y + $caladvanceyear) { $weeknumber = 53; } // to ensure weeks cannot go beyond restricted dates if ($fdy < $calstartyear) { $weeknumber = 1; } // to ensure weeks cannot go beyond restricted dates echo " (" . translate("week number") . " : " . $weeknumber . ")\n"; $gdy = $ldy; $gdm = $ldm; if ($gdy > $y + $caladvanceyear) { $gdy = $fdy; $gdm = $fdm; } echo " <a href=calendar.php?op=cal&month={$gdm}&year={$gdy}"; urlvar($uname); echo " ><img src=\"../images/month.gif\" border=0 alt='" . translate("View month") . " " . $mth[$gdm] . "'/></a>"; echo "<br/>(" . translate("Week starts") . " " . $week[$weekstartday + 1] . ")\n"; echo "</td></tr></table>"; // display hyperlinks to previous and next week $calendyear = $y + $caladvanceyear; echo "<table width=100% border=0><tr><td align=left><div class=menufont>"; if ($year > $calstartyear || $fdm >= 1 && $fdy == $calstartyear) { echo "<a href=cal_adminweek.php?op=week&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $day - 7, $year)); urlvar($uname); echo " ><< " . translate("Previous week") . "</a> "; } if ($ldy <= $calendyear) { echo "<a href=cal_adminweek.php?op=week&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $day + 7, $year)); urlvar($uname); echo " >" . translate("Next week") . " >> </a>\n"; } // display the hyperlinks to each day echo "</div></td><td align=right><div class=menufont><b>" . translate("Go to") . ": </b> "; $afd = $fd; $ald = date("Y-m-d", mktime(0, 0, 0, $ldm, $ldd + 1, $ldy)); while ($afd != $ald) { $fdy = substr($afd, 0, 4); $fdm = substr($afd, 5, 2); if (substr($fdm, 0, 1) == "0") { $fdm = str_replace("0", "", $fdm); } $fdd = substr($afd, 8, 2); $weekday = date("w", mktime(12, 0, 0, $fdm, $fdd, $fdy)); $weekday++; echo "<a href='#{$week[$weekday]}' >"; echo ucfirst($week[$weekday]) . " - " . $fdd; echo "</a> "; $afd = date("Y-m-d", mktime(0, 0, 0, $fdm, $fdd + 1, $fdy)); } echo "</div></td></tr></table>"; $ld = date("Y-m-d", mktime(0, 0, 0, $ldm, $ldd + 1, $ldy)); while ($fd != $ld) { $fdy = substr($fd, 0, 4); $fdm = substr($fd, 5, 2); if (substr($fdm, 0, 1) == "0") { $fdm = str_replace("0", "", $fdm); } $fdd = substr($fd, 8, 2); // display the day header echo "<table class=titlefont width=100% border=0 cellspacing=0><tr><td valign=middle align=left><div class=titlefont>"; $weekday = date("w", mktime(12, 0, 0, $fdm, $fdd, $fdy)); $weekday++; echo "<a class=none name='{$week[$weekday]}'>"; echo ucfirst($week[$weekday]) . " "; echo "<a class=titlefont href='cal_adminday.php?op=day&date=" . date("Y-m-d", mktime(0, 0, 0, $fdm, $fdd, $fdy)); urlvar($uname); echo "'>" . $fdd . "</a>" . " " . ucfirst($mth[$fdm]) . " " . $fdy; echo "</a> <a href='cal_event.php?op=eventform&add_day={$fdd}&add_month={$fdm}&add_year={$fdy}'><img src='../images/plus.gif' alt='" . translate("Add Event") . "' border=0 valign=middle width=11 height=11/></a>"; echo "</div></td></tr></table>"; // query and display events echo "<table class=weekevent width=100% border=0 cellspacing=0><tr><td>"; $query = "select id,user,title,description,url,email,cat_name,starttime,endtime,day,month,year,approved from " . $EVENTS_TB . " left join " . $CAT_TB . " on " . $EVENTS_TB . ".cat=" . $CAT_TB . ".cat_id where day='{$fdd}' and month='{$fdm}' and year='{$fdy}' "; if ($uname != "" && $uname != "-") { $query = $query . " and " . $EVENTS_TB . ".user='******' "; } $query = $query . " order by starttime,title ASC"; $result = mysql_query($query); if (mysql_num_rows($result) == 0) { echo "<br/>"; } while ($row = mysql_fetch_object($result)) { if ($row->approved == '0') { echo "<table class=weekevent width=100% border=0><tr><td bgcolor='{$unapprovedclr}'>"; } if ($notimeentry == 0) { if ($row->starttime == '') { echo "<div><li>"; } else { showtime($row->starttime, $row->endtime, 0); } } else { echo "<div><li>"; } echo "<b>" . stripslashes($row->title); if ($showuserentry == 1) { echo " <" . $row->user . ">"; } echo "</b>"; if ($notimeentry == 1 || $row->starttime == '') { echo "</li></div>"; } else { echo "<br/>\n"; } echo "<b>" . translate("Category") . " : " . "</b>" . stripslashes($row->cat_name) . "<br/>"; $de = $row->description; //$de = str_replace("<br />","",$row->description); echo substr(stripslashes($de), 0, $shortdesclen); if ($row->email != "" || $row->url != "" || strlen($de) > $shortdesclen) { echo " ...\n"; } else { echo "\n"; } echo "<br/>"; echo "<div class=menufont><a href=cal_event.php?op=view&id=" . $row->id . ">" . translate("View event") . "</a>\n"; echo " - <a href=cal_event.php?op=edit&id=" . $row->id . ">" . translate("Edit event") . "</a>\n"; echo " - <a href=cal_event.php?op=delev&id=" . $row->id . ">" . translate("Delete event") . "</a>\n"; if ($row->approved == '0') { echo " - <a href=calendar.php?op=approve&id=" . $row->id . ">" . translate("Approve") . "</a>\n"; } echo "</div>\n"; echo "<hr/>"; if ($row->approved == '0') { echo "</td></tr></table>\n"; } } $fd = date("Y-m-d", mktime(0, 0, 0, $fdm, $fdd + 1, $fdy)); echo "</td></tr></table>"; } // display form functions echo "<table border=0 width=100%><tr><td align=left width=50%>"; echo "<table width=100 cellspacing=0 cellpadding=2 align=left class=txtbox><tr><td bgcolor='{$unapprovedclr}' align=center><div class=normalfont>" . translate("Unapproved events") . "</div></td></tr></table>\n</td>"; echo "<td align=right valign=middle width=50%>"; echo "<form><div class=menufont>\n"; echo "<b>" . translate("Go to week") . " </b>"; // get week number echo "<select name=goweek onchange=\"javascript:gotoweek(this);\">\n"; for ($i = 1; $i < 53; $i++) { echo "\t<option value=" . $i; if ($weeknumber == $i) { echo " selected "; } echo ">" . $i . "\n"; } if (showWeek53($year) > 52) { for ($i = 53; $i <= showWeek53($year); $i++) { echo "\t<option value=" . $i; if ($weeknumber == $i) { echo " selected "; } echo ">" . $i . "\n"; } } echo "</select>\n"; echo "<b>" . translate("or month") . " </b>"; // get months echo "<select name=gomonth onchange=\"javascript:gotomonth(this);\">\n"; for ($i = 1; $i < 13; $i++) { echo "\t<option value=" . $i; if ($ldm == $i) { echo " selected "; } echo ">" . ucfirst($mth[$i]) . "\n"; } echo "</select> <br/>\n"; // Display the users to be selected echo "<b>" . translate("View events of user") . ": </b> "; // get users $uquery = "select username,user_id from " . $USER_TB; $uresult = mysql_query($uquery); echo "<select name=huser onchange=\"Javascript:seeuser(this);\">\n"; echo "\t<option value='-'"; if ($uname == "-" || $uname == "") { echo " selected "; } echo ">--\n"; while ($urow = mysql_fetch_object($uresult)) { echo "\t<option value='{$urow->username}'"; if ($uname == "{$urow->username}") { echo " selected "; } echo ">" . $urow->username . "\n"; } echo "</select> \n"; echo "</div></form>"; echo "</td></tr></table>"; }
function cal($month, $year) { global $CAT_TB, $EVENTS_TB, $USER_TB, $mth, $week, $language, $m, $d, $y, $viewcalok, $viewweekok, $viewdayok, $searchmonthok, $popupevent, $popupeventwidth, $popupeventheight, $calstartyear, $caladvanceyear, $allowsearch, $weekstartday, $addeventok, $userview, $userlogin, $userid, $addeventwin_w, $addeventwin_h, $catview, $uname, $ugroup, $showuserentry, $publicview, $limitmthevt, $notimeentry, $overlibbgclr, $rssfeeds, $rssactive, $rssview; if (isset($rssview)) { $rsschannel = $rssfeeds[$rssview][0]; } else { $rsschannel = "None"; } if ($viewcalok == 1) { // previous month $pm = $month; if ($month == "1") { $pm = "12"; } else { $pm--; } // previous year $py = $year; if ($pm == "12") { $py--; } // next month $nm = $month; if ($month == "12") { $nm = "1"; } else { $nm++; } // next year $ny = $year; if ($nm == 1) { $ny++; } // get month we want to see $askedmonth = $mth[$month]; $askedyear = $year; $firstday = date("w", mktime(12, 0, 0, $month, 1, $year)); $firstday; // Check RSS Feed if ($rssactive == 1) { $RSSData = RSS(1, 1, 2007); } // number of days in askedmonth $nr = date("t", mktime(12, 0, 0, $month, 1, $year)); echo "\n\n<table class=monthview align=center>"; echo "<tr>"; echo "<td align=left colspan=2 class=monthview width='28%' valign=middle> "; if ($year > $calstartyear || $month > 1 && $year == $calstartyear) { echo "<a href=calendar.php?op=cal&month=" . $pm . "&year=" . $py . "&catview={$catview} class=calfontnav>" . $mth[$pm] . " " . $py . "</a>"; $pdate = date("Y-m-d", mktime(0, 0, 0, $month - 1, 1, $year)); echo " <a href='Javascript:void(0);' onclick=\"Javascript:wopen('smallcal.php?op=smallcal&date={$pdate}','popupmonth',350,220,'no');\">"; echo "<img src='images/smallcal.gif' border=0 alt='" . translate("Popup Month") . "' valign=middle width=16 height=16/></a>"; } else { echo " "; } echo "</td>"; echo "<td align=center colspan=3 class=monthview width='44%' >"; echo "<div class=calfontasked>" . $askedmonth . " "; echo " <a href='Javascript:void(0);' onclick=\"Javascript:wopen('yearcal.php?op=yearcal&ycyear={$askedyear}','popupyear',610,600,'yes');\" class=calfontasked>"; echo $askedyear . "</a></div>\n"; echo "<td align=right colspan=2 class=monthview width='28%'>"; $calendyear = $y + $caladvanceyear; if ($ny <= $calendyear) { $ndate = date("Y-m-d", mktime(0, 0, 0, $month + 1, 1, $year)); echo " <a href='Javascript:void(0);' onclick=\"Javascript:wopen('smallcal.php?op=smallcal&date={$ndate}','popupmonth',350,220,'no');\">"; echo "<img src='images/smallcal.gif' border=0 alt='" . translate("Popup Month") . "' valign=middle width=16 height=16/></a> "; echo "<a href=calendar.php?op=cal&month=" . $nm . "&year=" . $ny . "&catview={$catview} class=calfontnav>" . $mth[$nm] . " " . $ny . "</a>"; echo " "; } else { echo " "; } echo "</td></tr></table>\n\n"; echo "<table align=center class=monthview cellspacing=1>"; echo "<tr>"; // make the header days of week for ($i = intval($weekstartday) + 1; $i <= intval($weekstartday) + 7; $i++) { echo "<td align=center "; if (dayinweek($i) == 1) { echo "class=sundaytopcolor><div class=dayfont>" . $week[dayinweek($i)] . "</div></td>\n"; } else { echo "class=weekdaytopcolor><div class=dayfont>" . $week[dayinweek($i)] . "</div></td>\n"; } // rest of week } echo "</tr>\n\n<tr>\n"; // begin the days // print initial blank squares for ($i = 1; $i <= blankdays(intval($weekstartday), $firstday); $i++) { echo "<td "; if (dayinweek($i) == 1) { echo "class=sundayemptyclr "; } else { echo "class=weekdayemptyclr "; } echo "> </td>"; } $a = 0; for ($i = 1; $i <= $nr; $i++) { echo "<td "; if ($i == $d && $month == $m && $year == $y) { // highlight today's day echo "class=todayclr "; } else { if (date("w", mktime(0, 0, 0, $month, $i, $year)) == 0) { echo "class=sundayclr "; } else { echo "class=weekdayclr "; } } // click on date number to view events for the date echo " valign=top><table width='100%' border=0 cellspacing=1 cellpadding=1><tr><td align=left>"; echo "<b>"; if ($viewdayok == 1) { echo "<a class=datenumfont href='cal_day.php?op=day&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $i, $year)) . "&catview={$catview}'>"; } echo $i; if ($viewdayok == 1) { echo "</a>"; } echo "</b></td>"; echo "<td align=right> "; if (date("w", mktime(0, 0, 0, $month, $i, $year)) == $weekstartday) { if ($viewweekok == 1) { echo "<a href='cal_week.php?op=week&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $i, $year)) . "&catview={$catview}'><img src='images/week.gif' alt='" . translate("View week") . " " . weekNumber($i, $month, $year) . "' border=0 valign=middle width=11 height=11/></a> "; } } if ($publicview == 1 && $uname != "" || $publicview == 0) { if ($addeventok == 1) { echo "<a href='Javascript:void(0);' onclick=\"Javascript:wopen('cal_addevent.php?op=eventform&add_day={$i}&add_month={$month}&add_year={$year}&catview={$catview}','popupwin'," . $addeventwin_w . "," . $addeventwin_h . ",'yes');\"><img src='images/plus.gif' alt='" . translate("Add Event") . "' border=0 valign=middle width=11 height=11/></a>"; } } echo "</td></tr></table>"; // now get RSS events if ($rssactive == 1) { if (isset($RSSData[$i][$month][$year])) { echo "\n<table class=eventborder border=1 cellspacing=0 cellpadding=0 width=100%><tr><td align=center class=eventtimeborder valign=top>"; echo "\n<div class=smallcalev><b>"; // overlib line echo "<a href='Javascript:void(0);' onmouseover=\"return overlib('"; echo "<table border=0 cellspacing=0 cellpadding=0 width=100%>"; for ($j = 0; $j <= $RSSData[$i][$month][$year]['count']; $j++) { echo "<tr><td align=center valign=top>"; echo "<table class=eventborder border=1 cellspacing=0 cellpadding=0 width=100%><tr>"; if ($notimeentry == 0) { echo "<td align=center class=eventtimeborder valign=top>"; echo "<div class=smallcalevtime>"; if (isset($RSSData[$i][$month][$year][$j]['starttime'])) { if ($RSSData[$i][$month][$year][$j]['starttime'] == '') { echo " "; } else { showtime($RSSData[$i][$month][$year][$j]['starttime'], $RSSData[$i][$month][$year][$j]['endtime'], 1); } echo "</div>"; echo "</td>"; } } echo "<td align=left valign=top width=80% class=eventborder>"; echo "<div class=smallcalevtime>"; echo "<a class=smallcalev href=\\'" . $RSSData[$i][$month][$year][$j]['link'] . "\\' target=_BLANK>"; echo subquot(stripslashes($RSSData[$i][$month][$year][$j]['title'])); echo "</a>"; echo "</td></tr></table>"; echo "</td></tr>"; } echo "</table>"; // overlib line echo "',FGCOLOR,'{$overlibbgclr}',TEXTSIZE,'1',WIDTH,'125',VAUTO,HAUTO,STICKY,CAPTION,'"; echo $i . " " . $askedmonth . " ');\" onmouseout=\"return nd();\">"; echo "[" . $rsschannel . "]"; echo "</a>"; echo "</b></div>\n"; echo "</td></tr></table>"; } } // now get eventual events on $i $query = "select id,user,title,starttime,endtime from " . $EVENTS_TB . " left join " . $CAT_TB . " on " . $EVENTS_TB . ".cat=" . $CAT_TB . ".cat_id where day='{$i}' and month='{$month}' and year='{$year}' and approved='1' "; if ($catview != 0) { $query = $query . " and " . $EVENTS_TB . ".cat={$catview} "; } if ($userview == 1 && $userlogin == 1) { // user view user specific events only if ($ugroup != 0) { $query = $query . " and " . $EVENTS_TB . ".user='******' "; } } $query = $query . " order by day,month,year,starttime,title ASC"; $result = mysql_query($query); $devtcnt = mysql_num_rows($result); if ($limitmthevt != 0 && $devtcnt != 0 && $devtcnt >= $limitmthevt) { echo "\n<div class=smallcalev><b> ## "; // overlib line echo "<a href='cal_day.php?op=day&date=" . date("Y-m-d", mktime(0, 0, 0, $month, $i, $year)) . "&catview={$catview}' onmouseover=\"return overlib('"; echo "<table border=0 cellspacing=0 cellpadding=0 width=100%>"; while ($row = mysql_fetch_object($result)) { echo "<tr><td align=center valign=top>"; echo "<table class=eventborder border=1 cellspacing=0 cellpadding=0 width=100%><tr>"; if ($notimeentry == 0) { echo "<td align=center class=eventtimeborder valign=top>"; echo "<div class=smallcalevtime>"; if ($row->starttime == '') { echo " "; } else { showtime($row->starttime, $row->endtime, 1); } echo "</div>"; echo "</td>"; } echo "<td align=left valign=top width=80% class=eventborder>"; echo "<div class=smallcalev>"; // bug in overlib when putting hyperlink if ($popupevent == 1) { echo "<a class=smallcalev href=\\'Javascript:void(0);\\' onclick=\\'Javascript:popup(" . $row->id . ");\\'>"; } else { echo "<a class=smallcalev href=\\'cal_event.php?id=" . $row->id . "\\' >"; } echo subquot(stripslashes($row->title)); echo "</a>"; echo "</div>"; echo "</td></tr>"; echo "</table>"; echo "</td></tr>"; } echo "</table>"; // overlib line echo "',FGCOLOR,'{$overlibbgclr}',TEXTSIZE,'1',WIDTH,'125',VAUTO,HAUTO,STICKY,CAPTION,'"; echo $i . " " . $askedmonth . " ');\" onmouseout=\"return nd();\">"; echo $devtcnt . " " . translate("events"); echo "</a>"; echo " ## </b></div>\n"; } else { if ($devtcnt != 0) { echo "\n<table border=0 cellspacing=0 cellpadding=0 width='100%'>"; while ($row = mysql_fetch_object($result)) { echo "<tr><td align=center valign=top>\n"; echo "<table class=eventborder border=1 cellspacing=0 cellpadding=0 width='100%'><tr>"; if ($notimeentry == 0) { echo "<td align=center class=eventtimeborder valign=top>"; echo "<div class=smallcalevtime>"; if ($row->starttime == '') { echo " "; } else { showtime($row->starttime, $row->endtime, 1); } echo "</td>"; } echo "<td align=left valign=top width='80%' class=eventborder>"; if ($showuserentry == 1 && $uname != "") { echo "<" . $row->user . "> "; } if ($popupevent == 1) { echo "<a class=smallcalev href=\"Javascript:void(0);\" onclick=\"Javascript:popup(" . $row->id . ");\">"; } else { echo "<a class=smallcalev href=cal_event.php?id=" . $row->id . ">"; } echo stripslashes($row->title) . "</a>"; echo "</td></tr>"; echo "</table>"; } echo "</table>\n"; } } echo "</td>"; $a++; if (blankdays(intval($weekstartday), date("w", mktime(0, 0, 0, $month, $i, $year))) == 6) { echo "</tr>\n\n<tr>"; $a = 0; } } // ending stuff (making 'white' td's to fill table if ($a != 0) { $last = 7 - $a; for ($i = 1; $i <= $last; $i++) { echo "<td class=weekdayemptyclr> </td>"; } } echo "</tr>"; echo "</table>"; echo "<table width='100%' align=center border=0 cellspacing=1 cellpadding=0>"; echo "<tr><td align=center width='30%' valign=top>"; echo "<table class=txtbox width=70 align=left cellpadding=2 cellspacing=0><tr><td align=center class=todayclr><i><div class=normalfont>" . translate("Today") . "</div></i></td></tr></table>\n</td>"; echo "<td align=right valign=top width='30%'>"; echo "<form action=POST><div class=menufont>\n"; echo "<b>" . translate("Go to") . ": </b>"; // get months echo "<select name=gomonth onchange=\"javascript:gotomonth(this);\">\n"; for ($i = 1; $i < 13; $i++) { echo "\t<option value=" . $i; if ($month == $i) { echo " selected "; } echo ">" . ucfirst($mth[$i]) . "\n"; } echo "</select> \n"; // get year from "calstartyear" and give "caladvanceyear" years more to select echo "<select name=goyear onchange=\"javascript:gotoyear(this);\">\n"; for ($i = $calstartyear; $i <= $y + $caladvanceyear; $i++) { echo "\t<option value={$i}"; if ($year == $i) { echo " selected "; } echo ">{$i}\n"; } echo "</select><br/>\n"; echo "</div></form>"; echo "</td>"; // display search echo "<td align=right valign=bottom width='40%'>"; if ($allowsearch == 1 && $searchmonthok == 1) { search(); } else { echo " "; } echo "</td></tr>"; echo "</table>"; } else { echo "<br/><div class=titlefont>" . translate("disabled") . ".</div>"; } }
function showWeek53($cyear) { $ShowWeek53 = false; $weeknum = weekNumber(31, 12, $cyear); if ($weeknum > 52) { $ShowWeek53 = $weeknum; } settype($ShowWeek53, "integer"); return $ShowWeek53; }