<?php
// Month Scheduler Version 1.0c - Jan 7, 2005 - bad word function call
// The original parts of this script were developed by G. Michael Bowen And Mark Kasper for a SSHRC research project using wikka wiki.
// As far as it is possible to tell (because the code exists all over the web), we provide credit for the original calendar code
// to Marcus Kazmierczak which was released at www.blazonry.com, although this script builds considerably on that code.
// Code additions copyright GMBowen & Mark Kasper, 2004. Released to public domain under GPL. Modify, improve, change as you wish.
// There are two complementary actions. dayschedule.php allows anyone to designate an owner & date to see their schedule (see line 140)
// and it should be placed on a page named "DaySchedule". The other action, scheduler.php, is a small version of the calendar action
// which allows easy and fast entering of data on different days.
?>
<div align="center">
<P><TABLE BORDER=0 width=100%>
<TR>
<TD>
<P>
<?php
$site_base = $this->GetConfigValue("base_url");
$thispage=$this->GetPageTag();
$username = $this->GetUserName();
// badword array for replacing badwords (not initialized as currently using added function in wakka.php)
//$badwords = Array ('/motherfucker/i', '/cunt/i', '/fuck/i', '/cocksucker/i', '/bitch/i', '/son of a bitch/i', '/asshole/i', '/shit/i', '/fag/i', '/wank/i', '/dick/i', '/pussy/i', '/bastard/i', '/molester/i', '/molezter/i', '/cock/i');
//$changeto = '****';
// gets username
$username = $this->GetUserName();
// kasper
// NOTE VERY IMPORTANT, if the table is totally empty the function will not work, you
// must add one in maually for this function to work.
// I could add it in the code but very messy, will come up with better way.
$dayschedule = $_POST['dayscheduleX'];
include_once("./scripts/badwordfunction.php");
$dayschedule = BadWordFunction($dayschedule);
$dayschedule =
addslashes($dayschedule);
// for single quotes to work
// replace above function call with line below if wakka.php doesn't have a bad word function code in it
//$dayschedule = preg_replace($badwords, $changeto, $dayschedule);
$query = "select * from ".$this->config['table_prefix']."scheduler";
if ($_POST['save']){
// Kasper added to delete the empty schedule
$del = "delete from ".$this->config['table_prefix']."scheduler where dayschedule = ''";
$up = 0;
{
if($row->user == $username && $row->month == $month && $row->day == $today && $row->year == $year)
{
$up = 1;
$ro = $row->id;
}
}
if($up == 1)
{
$query = "UPDATE ".$this->config['table_prefix']."scheduler SET dayschedule='$dayschedule' WHERE user='$username' AND id='$ro'";
}else{
$query = "INSERT into ".$this->config['table_prefix']."scheduler (user,dayschedule,month,day,year) VALUES ('$username','$dayschedule','$month','$today','$year')";
}
}
// end kasper
?>
<table>
<tr>
<td valign="top">
<?php
/*== get what weekday the first is on ==*/
$monthname = $tmpd["month"];
$firstwday= $tmpd["wday"];
$lastday = mk_getLastDayofMonth($month,$year);
?>
<table cellpadding="2" cellspacing="0" border="1">
<tr>
<td colspan="7">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="20"><a href="<?php echo $this->href("", "", "month="); echo (($month-1)<1) ? 12 : $month-1 ; ?>&year=<?php echo (($month-1)<1) ? $year-1 : $year ; ?>"><<<</a></td>
<td align=
"center"><font size=
"2"><strong><?
echo $username ?>'s Calendar for <?php echo "$monthname $year"; ?></strong></font></td>
<td width="20"><a href="<?php echo $this->href("", "", "month="); echo (($month+1)>12) ? 1 : $month+1 ; ?>&year=<?php echo (($month+1)>12) ? $year+1 : $year ; ?>">>>></a></td>
</tr>
</table>
</td>
</tr>
<tr BGCOLOR="#DDccbb">
<td>Sunday</td>
<td>Monday</td>
<td>Tuesday</td>
<td>Wednesday</td>
<td>Thursday</td>
<td>Friday</td>
<td>Saturday</td>
</tr>
<?php
$day = 1;
$wday = $firstwday;
$firstweek = true;
/*== loop through all the days of the month ==*/
while ( $day <= $lastday)
{
/*== set up blank days for first week ==*/
if ($firstweek) {
print " <tr>";
for ($i=1; $i<=$firstwday; $i++)
{ print " <td VALIGN=top ALIGN=left HEIGHT=70><font size=\"2\"> </font></td>"; }
$firstweek = false;
}
/*== Sunday start week with <tr> ==*/
if ($wday==0) { print " <tr>\n"; }
/*== check for event ==*/
print " <td VALIGN=top ALIGN=left WIDTH=150 HEIGHT=70>";
if($day<10) {
if($month<10) {
$tag = "$year:0$month:0$day";
} else {
$tag = "$year:$month:0$day";
}
} else {
if($month<10) {
$tag = "$year:0$month:$day";
} else {
$tag = "$year:$month:$day";
}
}
$todaydate = date("Y:m:d",mktime());
if($tag==$todaydate)
{
$font1 = "<font color=\"#FF0000\"><b>";
$font2 = "</b></font>";
$token="yes";
}
else
{
$font1 = "";
$font2 = "";
$token="no";
}
// code to determine what data should be entered into each cell
$thisdayschedule = $this->LoadSingle("SELECT dayschedule FROM ".$this->config["table_prefix"]."scheduler WHERE user='".$username."' AND day='".$day."' AND month='".$month."' AND year='".$year."'");
$dayoutput = str_replace("\n", "<br> ", $thisdayschedule[dayschedule]);
if ($token=="yes")
{
$printme="<a href=".$site_base."DaySchedule&month=".$month."&day=".$today."&year=".$year."><small>[Print Day]</small></a>";
}
else
{
$printme="";
}
print "<table width=\"100%\"><TR BGCOLOR=\"#E4DFDA\"><td><a href=".$site_base.$thispage."&day=$day&month=$month&year=$year#EntryBox> $font1$day$font2</a> $printme</td</tr><tr><td><small>$dayoutput</small></td></tr></table>";
print "</td>\n";
/*== Saturday week with </tr> ==*/
if ($wday==6) { print " </tr>\n"; }
$wday++;
$wday = $wday % 7;
$day++;
}
?>
</tr>
</table>
</td>
</tr>
</table>
<?php
/*== get the last day of the month ==*/
function mk_getLastDayofMonth($mon,$year)
{
for ($tday=28; $tday <= 31; $tday++)
{
$tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
if ($tdate["mon"] != $mon) break;
}
$tday--;
return $tday;
}
?>
<!-- Comment below 3 lines out if you don't want to
link to the formatted schedule page & scheduler page.-->
<center><a href=
<? echo $site_base; ?>DaySchedule&<?
echo "month=".
$month.
"&day=".
$today.
"&year=".
$year; ?>><small>Formatted Day Page</small></a>
|
<a href=
<? echo $site_base; ?>Scheduler&<?
echo "month=".
$month.
"&day=".
$today.
"&year=".
$year; ?>><small>Small Monthly Calendar</small></a></center>
</TD>
</tr><tr>
<TD WIDTH=500>
<P>
<?
if ($user = $this->GetUser())
{
$dayschedule =
str_replace("\n",
",",
$_POST['dayschedule']);
// title over textarea box
$printowner = $username."'s Schedule for ";
$dayschedule = $this->LoadSingle("SELECT dayschedule FROM ".$this->config["table_prefix"]."scheduler WHERE user='".$username."' AND day='".$today."' AND month='".$month."' AND year='".$year."'");
// replaced a comma with XXZXX below....I don't know what the purpose of the code is...
$dayschedule =
str_replace("XXZXX",
"\n",
$dayschedule[dayschedule
]);
$output =
str_replace(",",
" ",
$dayschedule[dayschedule
]);
?>
<center><A NAME=EntryBox></A>
<a href="<?php echo $this->href("", "", "day="); echo (($today-1)<1) ? $lastday : $today-1 ; ?>&year=<?php echo $year; ?>&month=<?php echo $month; ?>"><<</a>
<b><?
echo "$printowner$monthname $today, $year:"; ?></b>
<a href="<?php echo $this->href("", "", "day="); echo (($today+1)>$lastday) ? 1 : $today+1 ; ?>&year=<?php echo $year; ?>&month=<?php echo $month; ?>">>></a>
<center><form action="" method="post">
<textarea cols=
"65" rows=
"12" name=
"dayscheduleX"><?php
echo $dayschedule; ?></textarea>
<input type="submit" value="Submit" />
<input type="hidden" name="save" value="true" />
</form></center>
</center>
<?
}
else
{
echo "<em>The Scheduler only works for logged-in users.</em>";
}
?>
</P>
</TD>
</TR>
</TABLE>
</div>