##########################################################################
# Please refer to the README file for licensing and contact information.
#
# This file has been updated for version 0.2.20021111
#
# If you like this application, do support me in its development
# by sending any contributions at www.calendarix.com.
#
#
# Copyright © 2002 Vincent Hor
##########################################################################
include ('cal_header.inc.php');
include ("search_func.php");
include ("cal_utils.php") ;
# today's date
if ($viewtodaydate == 1){
$weekday = date ("w", mktime(12,0,0,$m,$d,$y));
$weekday++;
echo "\n\n| ".$todayfont ;
echo ucfirst($week[$weekday])." ".$d." ".ucfirst($maand[$m])." ".$y;
echo $closefont." | " ;
echo "";
echo $todayfont ;
getEventStats($d,$m,$y) ;
echo $closefont." | " ;
echo "";
if ($caleventapprove==0) {
echo $todayfont.translate("Approval needed for posting of events.").$closefont." " ;
}
// display icons
echo " ";
if ($viewcalok == 1){
echo " ";
}
if ($viewweekok == 1){
echo " ";
}
if ($viewdayok == 1){
echo " ";
}
if ($viewcatsok == 1){
echo " ";
}
if ($administrationok == 1){
echo " " ;
}
echo " | \n\n";
}
/************************/
/* get event statistics */
/************************/
function getEventStats($day_i,$month_i,$year_i){
global $CAT_TB,$EVENTS_TB,$USER_TB,$showeventstats,$userid,$userview,$userlogin;
// now get number of events on $day_i approved
if ($showeventstats == '1') {
$query = "select count(id) from ".$EVENTS_TB." left join ".$CAT_TB." on ".$EVENTS_TB.".cat=".$CAT_TB.".cat_id where day='$day_i' and month='$month_i' and year='$year_i' and approved='1' order by day,month,year ASC";
if (($userview=='1')&&($userlogin==1)) { // view user specific events only
$uquery = "select username,group_id from ".$USER_TB." where ".$USER_TB.".user_id=".$userid ;
$uresult = mysql_query($uquery) ;
$urow = mysql_fetch_object($uresult);
if ($urow->group_id!=0) {
$query = "select count(id) from ".$EVENTS_TB." left join ".$CAT_TB." on ".$EVENTS_TB.".cat=".$CAT_TB.".cat_id where day='$day_i' and month='$month_i' and year='$year_i' and approved='1' and ".$EVENTS_TB.".user='".$urow->username."' order by day,month,year ASC";
}
}
$result = mysql_query($query);
$row = mysql_fetch_row($result) ;
echo "".$row[0]." ".translate("confirmed events for today")." " ;
// now get number of events on $day_i not approved
$query = "select count(id) from ".$EVENTS_TB." left join ".$CAT_TB." on ".$EVENTS_TB.".cat=".$CAT_TB.".cat_id where approved='0' order by day,month,year ASC";
$result = mysql_query($query);
$row = mysql_fetch_row($result) ;
}
}
/**************/
/* view event */
/**************/
function view($id){
global $EVENTS_TB,$CAT_TB,$language,$maand,$vieweventok,$popupeventtitlefont,$closefont,$popupeventfont,$addeventok,$addeventwin_w,$addeventwin_h,$time12hour;
echo " \n" ;
$query = "select id,title,cat_name,description,starttime,endtime,day,month,year,approved,url,email from ".$EVENTS_TB." left join ".$CAT_TB." on ".$EVENTS_TB.".cat=".$CAT_TB.".cat_id where id='$id'";
$result = mysql_query($query);
$row = mysql_fetch_object($result);
echo $popupeventtitlefont."".stripslashes($row->title)."".$closefont." \n";
echo "\n".$popupeventfont ;
echo " ".translate("Date")." : ".$row->day ." ".$maand[$row->month]." ".$row->year."\n";
echo " ".translate("From")." : " ;
if ($time12hour=='1') echo show12hour($row->starttime) ;
else echo $row->starttime ;
echo "\n";
echo " ".translate("To")." : " ;
if ($time12hour=='1') echo show12hour($row->endtime) ;
else echo $row->endtime ;
echo "\n";
echo " ".translate("Category")." : ".stripslashes($row->cat_name)."\n";
echo "
".translate("Event Description")." : \n";
echo "".stripslashes($row->description)." ";
echo " \n";
if ($row->email)
echo " ".translate("Email")." : email.">".$row->email."\n";
if ($row->url){
echo " ".translate("More info")." : url." target=_blank>".$row->url."\n";
}
echo "
\n" ;
if ($addeventok == 1){
echo " ";
}
echo "" ;
echo " " ;
if (($allowsearch==1)&&($vieweventok==1)) search();
}
/**************************/
/* overview of categories */
/**************************/
function cats($catcolor,$year){
global $EVENTS_TB,$CAT_TB,$USER_TB,$viewcatsok,$searchcatsok,$allowsearch,$titlefont,$headerfont,$menufont,$closefont,
$dayheaderbgclr,$maand,$normalfont,$titlebgclr,$secondcatcolor,$allowsearch,$calstartyear,$caladvanceyear,$y,$userview,$userlogin,$userid;
if ($viewcatsok == 1){
$query = "select cat_id,cat_name from ".$CAT_TB." order by cat_name ASC";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
// if no rows
if ($rows == "0"){
echo " ".$headerfont.translate("No categories yet").$closefont.". \n";
}
// show categories
else {
echo "| ".$headerfont.translate("Categories").$closefont." | \n";
echo "\n";
$foo = '';
while ($row = mysql_fetch_object($result)){
$foo++ % 2 ? $color=$catcolor : $color=$catcolor;
echo "" ;
echo "| ".$titlefont."cat_id.">".stripslashes($row->cat_name)."".$closefont."" ;
// get total number of events under category
$tquery = "select id from ".$EVENTS_TB." where ".$EVENTS_TB.".cat='".$row->cat_id."' and ".$EVENTS_TB.".approved='1' " ;
$normuser = false ;
if (($userview=='1')&&($userlogin==1)) { // view user specific events only
$uquery = "select group_id from ".$USER_TB." where ".$USER_TB.".user_id=".$userid ;
$uresult = mysql_query($uquery) ;
$urow = mysql_fetch_object($uresult);
if ($urow->group_id!=0) {
$normuser = true ;
$tquery = "select * from ".$EVENTS_TB.",".$USER_TB." where ".$EVENTS_TB.".cat='".$row->cat_id."' and ".$EVENTS_TB.".approved='1' and ".$EVENTS_TB.".user=".$USER_TB.".username and ".$USER_TB.".user_id=".$userid ;
}
}
$tresult = mysql_query($tquery);
$trows = mysql_num_rows($tresult);
echo $normalfont." (".$trows." ".translate("events for whole calendar").")".$closefont." | " ;
echo "" ;
$totalyearevents = 0 ;
for ($i=1;$i<13;$i++) {
if ($normuser)
$mquery = "select * from ".$EVENTS_TB.", ".$USER_TB." where ".$EVENTS_TB.".cat='$row->cat_id' and ".$EVENTS_TB.".year='$year' and ".$EVENTS_TB.".month='$i' and ".$EVENTS_TB.".approved='1' and ".$EVENTS_TB.".user=".$USER_TB.".username and ".$USER_TB.".user_id=".$userid ;
else
$mquery = "select id from ".$EVENTS_TB." where ".$EVENTS_TB.".cat='$row->cat_id' and ".$EVENTS_TB.".year='$year' and ".$EVENTS_TB.".month='$i' and ".$EVENTS_TB.".approved='1'";
$mresult = mysql_query($mquery);
$mrows = mysql_num_rows($mresult);
echo "| " ;
echo $normalfont ;
$totalyearevents = $totalyearevents + $mrows ;
if ($mrows!=0) echo " $mrows " ;
else echo " 0 " ;
echo $closefont." | ".$normalfont ;
echo translate("events for")." ";
if ($mrows!=0) echo "cat_id."&year=".$year."&catmonth=$i >" ;
echo $maand[$i] ;
if ($mrows!=0) echo "" ;
echo " ".$year.". ".$closefont ;
echo " | " ;
}
echo "| ".$normalfont.$totalyearevents.$closefont." | " ;
echo "".$normalfont.translate("events for year")." ".$year.". ".$closefont." | ";
echo " | \n";
}
echo " \n";
}
// this is for the goto year under categories redirection javascript
echo "" ;
// display form functions
echo "| | " ;
echo "" ;
echo "" ;
echo " | " ;
echo "" ;
if (($allowsearch==1)&&($searchcatsok == 1)) search();
echo " | " ;
}
else {
echo "".$titlefont.translate("disabled").$closefont.". " ;
}
}
/*******************************/
/* view events of one category */
/**??????A ?*****************************/
function cat($id,$firstcatevcolor,$secondcatevcolor,$year,$sort){
global $EVENTS_TB,$USER_TB,$CAT_TB,$language,$maand,$searchscatviews,$popupevent,$popupeventheight,$popupeventwidth,$allowsearch,
$headerfont,$weekheaderbgclr,$titlefont,$normalfont,$menufont,$closefont,$y,$searchcatsok,$calstartyear,$caladvanceyear,
$userid,$userview,$userlogin;
if (!isset($_GET['catmonth']))
$catmonth = '';
else
$catmonth = $_GET['catmonth'];
$query = "select id,title,cat_name,day,month,year from ".$EVENTS_TB." left join ".$CAT_TB." on ".$EVENTS_TB.".cat=".$CAT_TB.".cat_id where approved='1' and ".$EVENTS_TB.".cat='$id' and ".$EVENTS_TB.".year='$year' " ;
if ($catmonth!='') $query = $query . " and month='$catmonth' " ;
if (($userview=='1')&&($userlogin==1)) {
$uquery = "select group_id from ".$USER_TB." where ".$USER_TB.".user_id=".$userid ;
$uresult = mysql_query($uquery) ;
$urow = mysql_fetch_object($uresult);
if ($urow->group_id!=0) {
$query = "select * from ".$USER_TB.", ".$EVENTS_TB." where ".$EVENTS_TB.".approved='1' and ".$EVENTS_TB.".cat='$id' and ".$EVENTS_TB.".year='$year' and ".$EVENTS_TB.".user=".$USER_TB.".username and ".$USER_TB.".user_id=".$userid ;
if ($catmonth!='') $query = $query . " and month='$catmonth' " ;
}
}
if (($sort)&&($sort==1))
$query = $query . " order by title ASC, year ASC, month ASC, day ASC";
else
$query = $query . " order by year ASC, month ASC, day ASC, title ASC";
$result = mysql_query($query);
$rowname = mysql_fetch_object($result);
$rows = mysql_num_rows($result);
// this is for the category sort order redirection javascript
echo "" ;
$cquery = "select cat_name from ".$CAT_TB." where cat_id='$id' " ;
$cresult = mysql_query($cquery) ;
$crow = mysql_fetch_object($cresult) ;
echo "| " ;
echo "".$titlefont.translate("Events in category").": ".$crow->cat_name.$closefont." | ".$menufont."".translate("Sort by").": ".$closefont ;
echo " " ;
echo " " ;
echo " | \n";
if (!$rows) {
echo " ".$titlefont.translate("No events").$closefont.". \n";
}
else {
$result = mysql_query($query);
$foo = '';
while ($row = mysql_fetch_object($result)){
$foo++ % 2 ? $color=$firstcatevcolor : $color=$secondcatevcolor;
echo "\n";
}
}
// this is for the goto year under categories redirection javascript
echo "" ;
// this is the goto month under categories redirection javascript
echo "" ;
// display form functions
echo "" ;
echo "| " ;
echo "" ;
echo " | " ;
echo "" ;
if (($allowsearch==1)&&($searchcatsok == 1)) search();
echo " | " ;
}
/***********************/
/* view events per day */
/***********************/
function day($ask,$date){
global $EVENTS_TB,$CAT_TB,$USER_TB,$maand,$week,$language,$m,$d,$y,$viewdayok,$allowsearch,$searchdayok,$popupevent,$popupeventwidth,$popupeventheight,$dayheaderbgclr,$headerfont,$dayeventbgclr,$titlefont,$normalfont,$menufont,
$closefont,$titlebgclr,$calstartyear,$caladvanceyear,$addeventok,$userview,$userlogin,$userid,$addeventwin_w,$addeventwin_h,$time12hour,$shortdesclen ;
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 "";
$query = "select id,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' order by starttime,title ASC";
if (($userview=='1')&&($userlogin==1)) { // user view user specific events only
$uquery = "select username,group_id from ".$USER_TB." where ".$USER_TB.".user_id=".$userid ;
$uresult = mysql_query($uquery) ;
$urow = mysql_fetch_object($uresult);
if ($urow->group_id!=0) {
$query = "select id,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' and user='".$urow->username."' order by starttime,title ASC" ;
}
}
$result = mysql_query($query);
echo "" ;
if (mysql_num_rows($result)!=0) {
while ($row = mysql_fetch_object($result)){
echo $normalfont ;
if ($row->starttime=='') echo "" ;
else {
echo "" ;
if ($time12hour=='1') echo show12hour($row->starttime) ;
else echo $row->starttime ;
if ($row->endtime!='') {
echo " - " ;
if ($time12hour=='1') echo show12hour($row->endtime) ;
else echo $row->endtime ;
echo " " ;
}
else echo " " ;
}
echo "".$normalfont.stripslashes($row->title)." ";
echo $closefont ;
echo translate("Category")." : ".stripslashes($row->cat_name)." ";
$de = str_replace(" ","",$row->description);
$de = str_replace(" ","",$row->description);
echo substr(stripslashes($de),0,$shortdesclen) ;
if (($row->email!="")||($row->url!="")||(strlen($de)>$shortdesclen)) echo " ...".$closefont."\n";
else echo $closefont."\n" ;
echo " ";
if ($popupevent == 1)
echo $menufont."id."','Calendar','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=".$popupeventwidth.",height=".$popupeventheight."')\">" ;
else
echo $menufont."id.">";
echo translate("Read more")."".$closefont;
echo "
";
}
}
else echo " " ;
echo " | " ;
// this is for the goto day redirection javascript
echo "" ;
// display form functions
echo "| | " ;
echo "" ;
echo "" ;
echo " | " ;
echo "" ;
if (($allowsearch==1)&&($searchdayok == 1)) search();
echo " | " ;
}
else {
echo "".$titlefont.translate("disabled").$closefont.". " ;
}
}
/************************/
/* view events per week */
/************************/
function week($week,$date){
global $EVENTS_TB,$CAT_TB,$USER_TB,$maand,$week,$language,$m,$d,$y,$ld,$fd,$viewweekok,$searchweekok,$popupevent,$popupeventwidth,$popupeventheight,$menufont,$titlefont,$headerfont,$normalfont,$closefont,$weekstartday,$titlebgclr,$weekheaderbgclr,$weekeventbgclr,$calstartyear,$caladvanceyear,$allowsearch,$addeventok,$userid,$userview,$userlogin,$addeventwin_w,$addeventwin_h,$time12hour,$shortdesclen;
if ($viewweekok == 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);
}
// 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")) {
/* if (date("Y", mktime(0,0,0,$month,$day-1,$year)) >= $calstartyear) */$day-- ;
// else break ;
$day_offset = date("w", mktime(0,0,0,$month,$day,$year));
$dayoff++ ;
}
while ($day_offset".$headerfont.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." ".$maand[$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." ".$maand[$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.")".$closefont."\n";
$gdy = $ldy ;
$gdm = $ldm ;
if ($gdy>($y+$caladvanceyear)) { $gdy = $fdy ; $gdm = $fdm ; }
echo " ";
echo " ".$headerfont."(".translate("Week starts")." ".$week[$weekstartday+1].")".$closefont."\n" ;
echo " | | " ;
// display hyperlinks to previous and next week
$calendyear = $y + $caladvanceyear ;
echo "| " ;
if (($year > $calstartyear) || (($fdm >= 1)&&($fdy == $calstartyear)))
{
echo $menufont."<< ".translate("Previous week")." ".$closefont;
}
if ($ldy <= $calendyear) {
echo $menufont."".translate("Next week")." >> ".$closefont."\n";
}
// display the hyperlinks to each day
echo " | ".$menufont."".translate("Go to").": ";
$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 "" ;
echo ucfirst($week[$weekday])." - ".$fdd ;
echo " " ;
$afd = date("Y-m-d", mktime(0,0,0,$fdm,$fdd+1,$fdy));
}
echo " | " ;
$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 "";
// query and display events
echo "" ;
$query = "select id,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='$fdd' and month='$fdm' and year='$fdy' and approved='1' order by starttime,title ASC";
if (($userview=='1')&&($userlogin==1)) { // user view user specific events only
$uquery = "select username,group_id from ".$USER_TB." where ".$USER_TB.".user_id=".$userid ;
$uresult = mysql_query($uquery) ;
$urow = mysql_fetch_object($uresult);
if ($urow->group_id!=0) {
$query = "select id,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='$fdd' and month='$fdm' and year='$fdy' and approved='1' and ".$EVENTS_TB.".user='".$urow->username."' order by starttime,title ASC";
}
}
$result = mysql_query($query);
if (mysql_num_rows($result)==0) echo " " ;
while ($row = mysql_fetch_object($result)){
echo $normalfont ;
if ($row->starttime=='') echo "" ;
else {
echo "" ;
if ($time12hour=='1') echo show12hour($row->starttime) ;
else echo $row->starttime ;
if ($row->endtime!='') {
echo " - " ;
if ($time12hour=='1') echo show12hour($row->endtime) ;
else echo $row->endtime ;
echo " " ;
}
else echo " " ;
}
echo "".$normalfont.stripslashes($row->title)." ";
echo $closefont ;
echo $normalfont."".translate("Category")." : "."".stripslashes($row->cat_name).$closefont." ";
$de = str_replace(" ","",$row->description);
$de = str_replace(" ","",$row->description);
echo $normalfont.substr(stripslashes($de),0,$shortdesclen) ;
if (($row->email!="")||($row->url!="")||(strlen($de)>$shortdesclen)) echo " ...".$closefont."\n";
else echo $closefont."\n" ;
echo " ";
if ($popupevent == 1)
echo $menufont."id."','Calendar','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=".$popupeventwidth.",height=".$popupeventheight."')\">";
else
echo $menufont."id.">";
echo translate("Read more")."".$closefont;
echo "
";
}
$fd = date("Y-m-d", mktime(0,0,0,$fdm,$fdd+1,$fdy));
echo " | " ;
}
// display form functions
echo "| | " ;
echo "" ;
echo "" ;
echo " | " ;
echo "" ;
if (($allowsearch==1)&&($searchweekok == 1)) search();
echo " | " ;
}
else {
echo "".$titlefont.translate("disabled").$closefont.". " ;
}
}
/*****************/
/* vie??????A ?w calendar */
/*****************/
function cal($month,$year,$monthborder,$calcells,$calcellp,$tablewidth,$trtopcolor,$calfontback,$calfontasked,$calfontnext,$sundaytopclr,$weekdaytopclr,$sundayemptyclr,$weekdayemptyclr,$todayclr,$sundayclr,$weekdayclr){
global $CAT_TB,$EVENTS_TB,$USER_TB,$maand,$week,$language,$m,$d,$y,$tdwidth,$tdtopheight,$tddayheight,$tdheight,$viewcalok,$searchmonthok,$popupevent,$popupeventwidth,$popupeventheight,
$dayfont,$datenumfont,$caleventfont,$menufont,$closefont,$titlefont,
$calstartyear,$caladvanceyear,$allowsearch,$weekstartday,$addeventok,$userview,$userlogin,$userid,$showeventborder,$showeventtimeborder,$addeventwin_w,$addeventwin_h,$time12hour;
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 = $maand[$month];
$askedyear = $year;
$firstday = date ("w", mktime(12,0,0,$month,1,$year));
$firstday++;
// number of days in askedmonth
$nr = date("t",mktime(12,0,0,$month,1,$year));
echo "\n\n";
echo "";
echo " ";
if (($year > $calstartyear) || (($month > 1)&&($year == $calstartyear))) {
echo $calfontback."".$maand[$pm]." ".$py."".$closefont;
$pdate = date("Y-m-d",mktime(0,0,0,$month-1,1,$year)) ;
echo " " ;
echo " " ;
}
else echo " " ;
echo " | ";
echo "";
echo $calfontasked.$askedmonth.$closefont." " ;
echo " " ;
echo $calfontasked.$askedyear.$closefont."\n";
echo " | " ;
$calendyear = $y + $caladvanceyear ;
if ($ny <= $calendyear) {
$ndate = date("Y-m-d",mktime(0,0,0,$month+1,1,$year)) ;
echo " " ;
echo " " ;
echo $calfontnext."".$maand[$nm]." ".$ny."".$closefont ;
echo " ";
}
else echo " " ;
echo " | \n\n";
echo "";
echo "";
// make the days of week, consisting of seven | 's (=days)
for ($i=1;$i<=7;$i++){
echo " | ".$dayfont.$week[$i].$closefont." | \n"; // sunday
}
else{
echo "bgcolor=$weekdaytopclr>".$dayfont.$week[$i].$closefont."\n"; // rest of week
}
}
echo " \n\n";
// begin the days
for ($i=1;$i<$firstday;$i++){
echo "| | ";
}
$a=0;
for ($i=1;$i<=$nr;$i++){
echo "| " ;
echo "".$datenumfont.$i.$closefont." | " ;
echo " " ;
if (date("w",mktime(0,0,0,$month,$i,$year))==$weekstartday)
echo " " ;
if ($addeventok == 1){
echo "" ;
}
echo " | " ;
// now get eventual events on $i
$query = "select id,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' order by day,month,year,starttime,title ASC";
if (($userview=='1')&&($userlogin==1)) { // user view user specific events only
$uquery = "select username,group_id from ".$USER_TB." where ".$USER_TB.".user_id=".$userid ;
$uresult = mysql_query($uquery) ;
$urow = mysql_fetch_object($uresult);
if ($urow->group_id!=0) {
$query = "select id,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' and ".$EVENTS_TB.".user='".$urow->username."' order by day,month,year,starttime,title ASC";
}
}
$result = mysql_query($query);
if (mysql_num_rows($result)!=0) {
echo "\n" ;
}
echo " | \n" ;
}
echo " | ";
$a++;
if (($i == (8-$firstday)) or ($i == (15-$firstday)) or ($i == (22-$firstday)) or ($i == (29-$firstday)) or ($i == (36 - $firstday))){
echo " ";
$a = 0;
}
}
// ending stuff (making 'white' td's to fill table
if ($a != 0){
$last = 7-$a;
for ($i=1;$i<=$last;$i++){
echo "| | ";
}
}
echo " ";
echo " ";
echo "";
echo "" ;
echo "| ".$datenumfont.translate("Today").$closefont." | \n | " ;
echo "";
echo "" ;
echo " | " ;
// display search
echo "" ;
if (($allowsearch)&&($searchmonthok == '1')) { search(); }
else echo " " ;
echo " | ";
echo " ";
}
else {
echo "".$titlefont.translate("disabled").$closefont.". " ;
}
}
switch ($op){
// overview of category
case"cats":{
if ($year) cats($catcolor,$year);
else cats($catcolor,$y);
break;
}
// overview of one cat
case"cat":{
if (!isset($_GET['sort']))
$sort = '';
else
$sort = $_GET['sort'];
if ($year) cat($id,$firstcatevcolor,$secondcatevcolor,$year,$sort);
else cat($id,$firstcatevcolor,$secondcatevcolor,$y,$sort);
break;
}
// add event form
case"eventform":{
eventform();
break;
}
// add event
case "addevent":{
addevent($title,$description,$url,$email,$cat,$repeat,$bday,$bmonth,$byear,$rday);
break;
}
// view details of event
case "view":{
view($id);
break;
}
// view per day
case"day":{
day($ask,$date);
break;
}
// view per week
case"week":{
week($week,$date);
break;
}
// view cal per month
case"cal":{
if (!$month) $month = $m ;
if (!$year) $year = $y ;
cal($month,$year,$monthborder,$calcells,$calcellp,$tablewidth,$trtopcolor,$calfontback,$calfontasked,$calfontnext,$sundaytopclr,$weekdaytopclr,$sundayemptyclr,$weekdayemptyclr,$todayclr,$sundayclr,$weekdayclr);
break;
}
// default: bar, and show new submissions
default:{
if ($caldefault == 0)
day($ask,$da,$mo,$ye,$next,$prev);
if ($caldefault == 1)
week($week,$date);
if ($caldefault == 2){
if (!$month)
$month = $m;
if (!$year)
$year = $y;
cal($month,$year,$monthborder,$calcells,$calcellp,$tablewidth,$trtopcolor,$calfontback,$calfontasked,$calfontnext,$sundaytopclr,$weekdaytopclr,$sundayemptyclr,$weekdayemptyclr,$todayclr,$sundayclr,$weekdayclr);
}
break;
}
}
include ('cal_functions.inc.php');
include ('cal_footer.inc.php');
?>
|