Wikka : GmBowenWikkaAsPIM

HomePage :: Categories :: Index :: Changes :: Comments :: Documentation :: Blog :: Login/Register

Tools To Use Wiki As a Pim

Last edited by GmBowen:
Modified links pointing to docs server
Mon, 28 Jan 2008 00:15 EST [diff]

One use of Wikka is as a Personal Information Manager. For some things the free-form writing nature of a wiki is useful (and, dare-I-say, liberating). However, as some of our usage at this site suggests, there are tools that can be developed AS actions in wikka that can make some aspects of information management a bit easier. In the past six months I've modified/developed two tools (with more forthcoming) with this purpose. One tool is a collection of actions so that schedules can be kept and organized on line. Its components include a "rapid entry" tool (scheduler.php, which should be kept on a page called ScheDuler), a monthly schedule view (monthschedule.php which should be kept on a page called MonthSchedule) and a day view (dayview.php which should be kept on a page called DaySchedule). These actions depend on a function which must be included as a file in the scripts directory. A year-view calendar is also available at GmBowenCalendar.

The other available action is a task manager (based on gbtask). The badwordfunction is at the bottom of the page (and currently is needed by the task manager & must be included in wikka.php).

Scheduler

Scheduler is an action which allows a person to keep a day calendar (or diary for that matter). Although the entry formatting is simple, at the same time it provides flexibility. A user can enter a day schedule.....
8:00 am - meeting with joe
9:00 am - coffee with angie
10:00 am - clients from budapest

or use it to keep a to-do list, or even a diary for the day. The schedule for a day can be viewed with the entry tool, in the monthly view, or in the day view. The day viewer is formatted for printing out usable schedules, & you can designate a specific user with it and see somebody else's schedule (I intend on modifying this so that there will be an easy-to-use text entry box for entering user names).
image

Code for table in data base.....
CREATE TABLE `wakka_scheduler` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `user` varchar(80) NOT NULL DEFAULT '',
  `day` tinyint(2) NOT NULL DEFAULT '0',
  `month` tinyint(2) NOT NULL DEFAULT '0',
  `year` mediumint(4) NOT NULL DEFAULT '0',
  `dayschedule` text,
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;


These actions rely on a "bad word function" which must be placed as a file called badwordfunction.php located in a directory called scripts located in the wiki root directory.
  1. <?php
  2. //remove bad word filter
  3. //Must be called badwordfunction.php and be placed in a directory called "scripts" in wakka root.
  4.  
  5. function BadWordFunction($RemoveBadWordText) {
  6.     $RemoveBadWordText = eregi_replace("fuc?k|[kc]unt|motherfucker|cocksucker|bitch|son of a bitch|asshole|shit|fag|wank|dick|pu[zs]?[zs][yi]|bastard|s[kc]rew|mole[zs]ter|mole[sz]t|coc?k", "", $RemoveBadWordText);
  7. return $RemoveBadWordText;
  8. }
  9. ?>


below code added to actions directory as scheduler.php. The action should be placed on a page called "ScheDule".
  1. <?php
  2. // Scheduler Version 1.1f - Jan 7, 2005 - bad word function call
  3. // The original parts of this script were developed by G. Michael Bowen And Mark Kasper for a SSHRC research project using wikka wiki.
  4. // As far as it is possible to tell (because the code exists all over the web), we provide credit to the original calendar code for the
  5. // to Marcus Kazmierczak and released at www.blazonry.com, although this script builds considerably on that code.
  6. // Code additions copyright GMBowen & Mark Kasper, 2004. Released to public domain under GPL. Modify, improve, change as you wish.
  7. // There are two complementary actions. dayschedule.php allows anyone to designate an owner & date to see their schedule (see line 140)
  8. // and the should be placed on a page named "DaySchedule". The other action, monthschedule.php, is a
  9. // larger version of the dayschedule action which shows entries for an entire month on one page.
  10. ?>
  11. <div align="center">
  12. <P><TABLE BORDER=0>
  13.    <TR>
  14.       <TD>
  15.         <P>
  16. <?php
  17. $month = (!isset($_GET['month'])) ? date("n",mktime()) : $_GET['month'];   
  18. $year = (!isset($_GET['year'])) ? date("Y",mktime()) : $_GET['year'];
  19. $today = (!isset($_GET['day'])) ? date("d",mktime()) : $_GET['day'];
  20.  
  21. $site_base = $this->GetConfigValue("base_url");
  22. $thispage=$this->GetPageTag();
  23.  
  24. // badword array for replacing badwords (not initialized as currently using added function in wakka.php)
  25. //$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');
  26. //$changeto = '****';
  27.  
  28. // gets username
  29. $username = $this->GetUserName();
  30.  
  31. // kasper
  32. //  NOTE VERY IMPORTANT,  if the table is totally empty the function will not work, you
  33. //                        must add one in maually, for this function to work
  34. //                        I could add it in the code but very messy, will come up with better way.
  35.  
  36. $dayschedule = $_POST['dayscheduleX'];
  37.  
  38. include_once("./scripts/badwordfunction.php");
  39. $dayschedule = BadWordFunction($dayschedule);
  40. $dayschedule = addslashes($dayschedule)// for single quotes to work
  41.  
  42.  
  43. // replace above function call with line below if wakka.php doesn't have a bad word function code in it
  44. //$dayschedule = preg_replace($badwords, $changeto, $dayschedule);
  45.  
  46. $query = "select * from ".$this->config['table_prefix']."scheduler";
  47. $result = mysql_query($query);
  48.  
  49. if ($_POST['save']){
  50.     // Kasper added to delete the empty schedule
  51.   $del = "delete from ".$this->config['table_prefix']."scheduler where dayschedule = ''";
  52.   $delresult = mysql_query($del);
  53.   $up = 0;
  54.     while ($row = mysql_fetch_object($result))
  55.     {     
  56.         if($row->user == $username && $row->month == $month && $row->day == $today && $row->year == $year)
  57.         {
  58.         $up = 1;     
  59.         $ro = $row->id;     
  60.         }                   
  61.     }
  62.  
  63.     if($up == 1)
  64.     {         
  65.         $query = "UPDATE ".$this->config['table_prefix']."scheduler SET dayschedule='$dayschedule' WHERE user='$username' AND id='$ro'";
  66.         $result = mysql_query($query);
  67.     }else{     
  68.         $query = "INSERT into ".$this->config['table_prefix']."scheduler (user,dayschedule,month,day,year) VALUES ('$username','$dayschedule','$month','$today','$year')";
  69.         $result = mysql_query($query);             
  70.     }
  71. }
  72.  
  73. // end kasper
  74. ?>
  75.  
  76. <table BGCOLOR="#DDccbb">
  77.     <tr>
  78.         <td valign="top">
  79. <?php
  80.     /*== get what weekday the first is on ==*/
  81.     $tmpd = getdate(mktime(0,0,0,$month,1,$year));
  82.     $monthname = $tmpd["month"];
  83.     $firstwday= $tmpd["wday"];
  84.     $lastday = mk_getLastDayofMonth($month,$year);
  85. ?>
  86. <table cellpadding="2" cellspacing="0" border="1">
  87.     <tr BGCOLOR="#ffffff">
  88.         <td colspan="7">
  89.             <table cellpadding="0" cellspacing="0" border="0" width="100%">
  90.                 <tr  BGCOLOR="#ffffff">
  91.                     <td width="20"><a href="<?php echo $this->href("", "", "month="); echo (($month-1)<1) ? 12 : $month-1 ; ?>&amp;year=<?php echo (($month-1)<1) ? $year-1 : $year ; ?>">&lt;&lt;&lt;</a></td>
  92.                     <td align="center"><font size="2"><?php echo "$monthname $year"; ?></font></td>
  93.                     <td width="20"><a href="<?php echo $this->href("", "", "month="); echo (($month+1)>12) ? 1 : $month+1 ; ?>&amp;year=<?php echo (($month+1)>12) ? $year+1 : $year ; ?>">&gt;&gt;&gt;</a></td>
  94.                 </tr>
  95.             </table>
  96.       </td>
  97.     </tr>
  98.     <tr BGCOLOR="#DDccbb">
  99.         <td width="22">Su</td>
  100.         <td width="22">Mo</td>
  101.         <td width="22">Tu</td>
  102.         <td width="22">We</td>
  103.         <td width="22">Th</td>
  104.         <td width="22">Fr</td>
  105.         <td width="22">Sa</td>
  106.     </tr>
  107.     <?php
  108.     $day = 1;
  109.     $wday = $firstwday;
  110.     $firstweek = true;
  111.  
  112.     /*== loop through all the days of the month ==*/
  113.     while ( $day <= $lastday)
  114.     {
  115.         /*== set up blank days for first week ==*/
  116.         if ($firstweek) {
  117.             print "    <tr  BGCOLOR=\"#ffffff\">";
  118.             for ($i=1; $i<=$firstwday; $i++)
  119.             { print "        <td><font size=\"2\">&nbsp;</font></td>"; }
  120.             $firstweek = false;
  121.         }
  122.  
  123.         /*== Sunday start week with <tr> ==*/
  124.         if ($wday==0) { print "    <tr BGCOLOR=\"#ffffff\">\n"; }
  125.  
  126.         /*== check for event ==*/
  127.         print "        <td>";
  128.         if($day<10) {
  129.             if($month<10) {
  130.                 $tag = "$year:0$month:0$day";
  131.             } else {
  132.                 $tag = "$year:$month:0$day";
  133.             }
  134.         } else {
  135.             if($month<10) {
  136.                 $tag = "$year:0$month:$day";
  137.             } else {
  138.                 $tag = "$year:$month:$day";
  139.             }
  140.         }
  141.        
  142.         $todaydate = date("Y:m:d",mktime());
  143.         if($tag==$todaydate)
  144.         {
  145.             $font1 = "<font color=\"#FF0000\"><b>";
  146.             $font2 = "</b></font>";
  147.         }
  148.         else
  149.         {
  150.             $font1 = "";
  151.             $font2 = "";
  152.         }
  153.         print "<a href=".$site_base.$thispage."&day=$day&month=$month&year=$year>$font1$day$font2</a>";
  154.         print "</td>\n";
  155.  
  156.         /*== Saturday week with </tr> ==*/
  157.         if ($wday==6) { print "    </tr>\n"; }
  158.  
  159.         $wday++;
  160.         $wday = $wday % 7;
  161.         $day++;
  162.     }
  163. ?>
  164.     </tr>
  165. </table>
  166.  
  167.         </td>
  168.     </tr>
  169. </table>
  170.  
  171. <?php
  172. /*== get the last day of the month ==*/
  173. function mk_getLastDayofMonth($mon,$year)
  174. {
  175.   for ($tday=28; $tday <= 31; $tday++)
  176.   {
  177.     $tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
  178.     if ($tdate["mon"] != $mon) break;
  179.   }
  180. $tday--;
  181. return $tday;
  182. }
  183. ?>
  184. <!-- Comment line below out if you don't want to link to the formatted schedule page-->
  185. <center><a href=<? echo $site_base; ?>DaySchedule&amp;<? echo "month=".$month."&amp;day=".$today."&amp;year=".$year; ?>><small>Day Schedule</small></a>
  186. &nbsp;|&nbsp;
  187. <a href=<? echo $site_base; ?>MonthSchedule&amp;<? echo "month=".$month."&amp;day=".$today."&amp;year=".$year; ?>><small>Month Schedule</small></a></center>
  188.       </TD>
  189.       <TD WIDTH=500>
  190.     <P>
  191. <?php
  192. if ($user = $this->GetUser())
  193. {
  194.   $dayschedule = str_replace("\n", ",", $_POST['dayschedule']);
  195.     // title over textarea box
  196.   $printowner = $username."'s Schedule for ";
  197.   $dayschedule = $this->LoadSingle("SELECT dayschedule FROM ".$this->config["table_prefix"]."scheduler WHERE user='".$username."' AND day='".$today."' AND month='".$month."' AND year='".$year."'");
  198. // replaced a comma with XXZXX below....I don't know what the purpose of the code is...
  199.   $dayschedule = str_replace("XXZXX", "\n", $dayschedule[dayschedule]);   
  200.   $output = str_replace(",", " ", $dayschedule[dayschedule]);
  201. ?>
  202.         <br><a href="<?php echo $this->href("", "", "day="); echo (($today-1)<1) ? $lastday : $today-1 ; ?>&amp;year=<?php echo $year; ?>&amp;month=<?php echo $month; ?>">&lt;&lt;</a>
  203.         <b><? echo "$printowner$monthname $today, $year:"; ?></b>
  204.         <a href="<?php echo $this->href("", "", "day="); echo (($today+1)>$lastday) ? 1 : $today+1 ; ?>&amp;year=<?php echo $year; ?>&amp;month=<?php echo $month; ?>">&gt;&gt;</a>
  205.            <form action="" method="post">
  206.                <textarea cols="65" rows="12" name="dayscheduleX"><?php echo $dayschedule; ?></textarea>
  207.                <input type="submit" value="Submit" />
  208.                <input type="hidden" name="save" value="true" />
  209.         </form>   
  210. <?
  211. }
  212. else
  213. {
  214. echo "<em>The Scheduler only works for logged-in users.</em>";
  215. } ?>
  216. </P>
  217.       </TD>
  218.    </TR>
  219. </TABLE>
  220. </div>


The following is the action which shows a formatted output for a selected day....the current day (by default) or for any other day (using a link from the scheduler.php & monthview.php actions)....it should be saved into the actions directory as dayschedule.php and for proper functioning with scheduler.php should be placed on a page called DaySchedule.
  1. <?php
  2. // This script was developed by G. Michael Bowen for a SSHRC research project using wikka wiki.
  3. // This action complements the scheduler.php action showing the day schedule for that user.
  4. // DaySchedule Version 1c -- Jan 6, 2005
  5. // This action should be placed on a page called "DaySchedule" to work with the scheduler.
  6. // Code copyright GMBowen. Released to public domain under GPL. Modify, improve, change as you wish.
  7.  
  8. $month = (!isset($_GET['month'])) ? date("n",mktime()) : $_GET['month'];   
  9. // $monthname = $month;
  10. $tmpd = getdate(mktime(0,0,0,$month,1,$year));
  11. $monthname = $tmpd["month"];
  12. $year = (!isset($_GET['year'])) ? date("Y",mktime()) : $_GET['year'];
  13. $today = (!isset($_GET['day'])) ? date("d",mktime()) : $_GET['day'];
  14. $site_base = $this->GetConfigValue("base_url");
  15. $thispage=$this->GetPageTag();
  16. $lastday = getLastDayofMonth($month,$year);
  17.  
  18. /*== get the last day of the month ==*/
  19. function getLastDayofMonth($mon,$year)
  20. {
  21.   for ($tday=28; $tday <= 31; $tday++)
  22.   {
  23.     $tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
  24.     if ($tdate["mon"] != $mon) break;
  25.   }
  26. $tday--;
  27. return $tday;
  28. }
  29.  
  30. // gets username
  31. $username = $this->GetUserName();
  32. $user = $username;
  33.  
  34. $dayschedule = $this->LoadSingle("SELECT dayschedule FROM ".$this->config["table_prefix"]."scheduler WHERE user='".$username."' AND day='".$today."' AND month='".$month."' AND year='".$year."'");
  35. $printout = str_replace("\n", "<HR></TD></TR><TR ALIGN='left'><TD>", $dayschedule[dayschedule]);   
  36. $printowner = $username."'s entries for ";
  37. ?>
  38. <div align="center">
  39. <center>      <a href="<?php echo $this->href("", "", "day="); echo (($today-1)<1) ? $lastday : $today-1 ; ?>&amp;year=<?php echo $year; ?>&amp;month=<?php echo $month; ?>">&lt;&lt;</a>
  40.         <b><? echo "$printowner$monthname $today, $year:"; ?></b>
  41.         <a href="<?php echo $this->href("", "", "day="); echo (($today+1)>$lastday) ? 1 : $today+1 ; ?>&amp;year=<?php echo $year; ?>&amp;month=<?php echo $month; ?>">&gt;&gt;</a>
  42.  
  43. <TABLE class='box' width='600' border='1' CELLSPACING='1' CELLPADDING='7' BGCOLOR='#DDccbb'>
  44.    <TR>
  45.       <TD>
  46. <P><TABLE class='box' width='100%' border='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#ffffff'>
  47.    <TR ALIGN='left'>
  48.       <TD>
  49.         <P>
  50. <?
  51. if ($user = $this->GetUser())
  52. {
  53.     if(!empty($printout))
  54.         {
  55.         echo $printout;
  56.         }
  57.         else
  58.         {
  59.         echo "There are no entries on this day.";
  60.         }
  61. }
  62. else
  63. {
  64. echo "<em>Showing the day schedule only works for logged-in users.</em>";
  65. }
  66. ?>
  67. </P>
  68.       </TD>
  69.    </TR>
  70. </TABLE>
  71.       </TD>
  72.    </TR>
  73. </TABLE>
  74. <center><a href=<? echo $site_base; ?>ScheDuler&amp;<? echo "month=".$month."&amp;day=".$today."&amp;year=".$year; ?>><small>Small Scheduler</small></a>
  75. &nbsp;|&nbsp;
  76. <a href=<? echo $site_base; ?>MonthSchedule&amp;<? echo "month=".$month."&amp;day=".$today."&amp;year=".$year; ?>><small>Month Scheduler</small></a></center>
  77. </center></div>

This is a screenshot of the dayschedule.php output...
image

This final action show a month-view with all of the entries. It should be saved into the actions directory as monthscheduler.php and for proper functioning with scheduler.php the action should be placed on a page called MonthSchedule.
  1. <?php
  2. // Month Scheduler Version 1.0c - Jan 7, 2005 - bad word function call
  3. // The original parts of this script were developed by G. Michael Bowen And Mark Kasper for a SSHRC research project using wikka wiki.
  4. // As far as it is possible to tell (because the code exists all over the web), we provide credit for the original calendar code
  5. // to Marcus Kazmierczak which was released at www.blazonry.com, although this script builds considerably on that code.
  6. // Code additions copyright GMBowen & Mark Kasper, 2004. Released to public domain under GPL. Modify, improve, change as you wish.
  7. // There are two complementary actions. dayschedule.php allows anyone to designate an owner & date to see their schedule (see line 140)
  8. // and it should be placed on a page named "DaySchedule". The other action, scheduler.php, is a small version of the calendar action
  9. // which allows easy and fast entering of data on different days.
  10. ?>
  11. <div align="center">
  12. <P><TABLE BORDER=0 width=100%>
  13.    <TR>
  14.       <TD>
  15.         <P>
  16. <?php
  17. $month = (!isset($_GET['month'])) ? date("n",mktime()) : $_GET['month'];   
  18. $year = (!isset($_GET['year'])) ? date("Y",mktime()) : $_GET['year'];
  19. $today = (!isset($_GET['day'])) ? date("d",mktime()) : $_GET['day'];
  20.  
  21. $site_base = $this->GetConfigValue("base_url");
  22. $thispage=$this->GetPageTag();
  23. $username = $this->GetUserName();
  24.  
  25. // badword array for replacing badwords (not initialized as currently using added function in wakka.php)
  26. //$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');
  27. //$changeto = '****';
  28.  
  29. // gets username
  30. $username = $this->GetUserName();
  31.  
  32. // kasper
  33. //  NOTE VERY IMPORTANT,  if the table is totally empty the function will not work, you
  34. //                        must add one in maually for this function to work.
  35. //                        I could add it in the code but very messy, will come up with better way.
  36.  
  37. $dayschedule = $_POST['dayscheduleX'];
  38. include_once("./scripts/badwordfunction.php");
  39. $dayschedule = BadWordFunction($dayschedule);
  40. $dayschedule = addslashes($dayschedule)// for single quotes to work
  41.  
  42.  
  43. // replace above function call with line below if wakka.php doesn't have a bad word function code in it
  44. //$dayschedule = preg_replace($badwords, $changeto, $dayschedule);
  45.  
  46. $query = "select * from ".$this->config['table_prefix']."scheduler";
  47. $result = mysql_query($query);
  48.  
  49. if ($_POST['save']){
  50.     // Kasper added to delete the empty schedule
  51.   $del = "delete from ".$this->config['table_prefix']."scheduler where dayschedule = ''";
  52.   $delresult = mysql_query($del);
  53.   $up = 0;
  54.     while ($row = mysql_fetch_object($result))
  55.     {     
  56.         if($row->user == $username && $row->month == $month && $row->day == $today && $row->year == $year)
  57.         {
  58.         $up = 1;     
  59.         $ro = $row->id;     
  60.         }                   
  61.     }
  62.  
  63.     if($up == 1)
  64.     {         
  65.         $query = "UPDATE ".$this->config['table_prefix']."scheduler SET dayschedule='$dayschedule' WHERE user='$username' AND id='$ro'";
  66.         $result = mysql_query($query);
  67.     }else{     
  68.         $query = "INSERT into ".$this->config['table_prefix']."scheduler (user,dayschedule,month,day,year) VALUES ('$username','$dayschedule','$month','$today','$year')";
  69.         $result = mysql_query($query);             
  70.     }
  71. }
  72. // end kasper
  73. ?>
  74. <table>
  75.     <tr>
  76.         <td valign="top">
  77. <?php
  78.     /*== get what weekday the first is on ==*/
  79.     $tmpd = getdate(mktime(0,0,0,$month,1,$year));
  80.     $monthname = $tmpd["month"];
  81.     $firstwday= $tmpd["wday"];
  82.     $lastday = mk_getLastDayofMonth($month,$year);
  83. ?>
  84. <table cellpadding="2" cellspacing="0" border="1">
  85.     <tr>
  86.         <td colspan="7">
  87.             <table cellpadding="0" cellspacing="0" border="0" width="100%">
  88.                 <tr>
  89.                     <td width="20"><a href="<?php echo $this->href("", "", "month="); echo (($month-1)<1) ? 12 : $month-1 ; ?>&amp;year=<?php echo (($month-1)<1) ? $year-1 : $year ; ?>">&lt;&lt;&lt;</a></td>
  90.                     <td align="center"><font size="2"><strong><? echo $username ?>'s Calendar for <?php echo "$monthname $year"; ?></strong></font></td>
  91.                     <td width="20"><a href="<?php echo $this->href("", "", "month="); echo (($month+1)>12) ? 1 : $month+1 ; ?>&amp;year=<?php echo (($month+1)>12) ? $year+1 : $year ; ?>">&gt;&gt;&gt;</a></td>
  92.                 </tr>
  93.             </table>
  94.       </td>
  95.     </tr>
  96.     <tr BGCOLOR="#DDccbb">
  97.         <td>Sunday</td>
  98.         <td>Monday</td>
  99.         <td>Tuesday</td>
  100.         <td>Wednesday</td>
  101.         <td>Thursday</td>
  102.         <td>Friday</td>
  103.         <td>Saturday</td>
  104.     </tr>
  105.     <?php
  106.     $day = 1;
  107.     $wday = $firstwday;
  108.     $firstweek = true;
  109.     /*== loop through all the days of the month ==*/
  110.     while ( $day <= $lastday)
  111.     {
  112.         /*== set up blank days for first week ==*/
  113.         if ($firstweek) {
  114.             print "    <tr>";
  115.             for ($i=1; $i<=$firstwday; $i++)
  116.             { print "        <td VALIGN=top ALIGN=left HEIGHT=70><font size=\"2\">&nbsp;</font></td>"; }
  117.             $firstweek = false;
  118.         }
  119.         /*== Sunday start week with <tr> ==*/
  120.         if ($wday==0) { print "    <tr>\n"; }
  121.         /*== check for event ==*/
  122.         print "        <td VALIGN=top ALIGN=left WIDTH=150 HEIGHT=70>";
  123.         if($day<10) {
  124.             if($month<10) {
  125.                 $tag = "$year:0$month:0$day";
  126.             } else {
  127.                 $tag = "$year:$month:0$day";
  128.             }
  129.         } else {
  130.             if($month<10) {
  131.                 $tag = "$year:0$month:$day";
  132.             } else {
  133.                 $tag = "$year:$month:$day";
  134.             }
  135.         }
  136.        
  137.         $todaydate = date("Y:m:d",mktime());
  138.         if($tag==$todaydate)
  139.         {
  140.             $font1 = "<font color=\"#FF0000\"><b>";
  141.             $font2 = "</b></font>";
  142.         $token="yes";   
  143.         }
  144.         else
  145.         {
  146.             $font1 = "";
  147.             $font2 = "";
  148.         $token="no";
  149.         }
  150. // code to determine what data should be entered into each cell
  151.     $thisdayschedule = $this->LoadSingle("SELECT dayschedule FROM ".$this->config["table_prefix"]."scheduler WHERE user='".$username."' AND day='".$day."' AND month='".$month."' AND year='".$year."'");
  152.     $dayoutput = str_replace("\n", "<br> ", $thisdayschedule[dayschedule]);
  153.     if ($token=="yes")
  154.         {
  155.         $printme="<a href=".$site_base."DaySchedule&month=".$month."&amp;day=".$today."&amp;year=".$year."><small>[Print Day]</small></a>";
  156.         }
  157.         else
  158.         {
  159.         $printme="";
  160.         }
  161.         print "<table width=\"100%\"><TR BGCOLOR=\"#E4DFDA\"><td><a href=".$site_base.$thispage."&day=$day&month=$month&year=$year#EntryBox>&nbsp;$font1$day$font2</a>&nbsp;$printme</td</tr><tr><td><small>$dayoutput</small></td></tr></table>";
  162.         print "</td>\n";
  163.         /*== Saturday week with </tr> ==*/
  164.         if ($wday==6) { print "    </tr>\n"; }
  165.         $wday++;
  166.         $wday = $wday % 7;
  167.         $day++;
  168.     }
  169. ?>
  170.     </tr>
  171. </table>
  172.         </td>
  173.     </tr>
  174. </table>
  175. <?php
  176. /*== get the last day of the month ==*/
  177. function mk_getLastDayofMonth($mon,$year)
  178. {
  179.   for ($tday=28; $tday <= 31; $tday++)
  180.   {
  181.     $tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
  182.     if ($tdate["mon"] != $mon) break;
  183.   }
  184. $tday--;
  185. return $tday;
  186. }
  187. ?>
  188. <!-- Comment below 3 lines out if you don't want to link to the formatted schedule page & scheduler page.-->
  189. <center><a href=<? echo $site_base; ?>DaySchedule&amp;<? echo "month=".$month."&amp;day=".$today."&amp;year=".$year; ?>><small>Formatted Day Page</small></a>
  190. &nbsp;|&nbsp;
  191. <a href=<? echo $site_base; ?>Scheduler&amp;<? echo "month=".$month."&amp;day=".$today."&amp;year=".$year; ?>><small>Small Monthly Calendar</small></a></center>
  192.  
  193.        </TD>
  194.     </tr><tr>
  195.       <TD WIDTH=500>
  196.     <P>
  197. <?
  198. if ($user = $this->GetUser())
  199. {
  200.   $dayschedule = str_replace("\n", ",", $_POST['dayschedule']);
  201.  
  202.     // title over textarea box
  203.   $printowner = $username."'s Schedule for ";
  204.   $dayschedule = $this->LoadSingle("SELECT dayschedule FROM ".$this->config["table_prefix"]."scheduler WHERE user='".$username."' AND day='".$today."' AND month='".$month."' AND year='".$year."'");
  205. // replaced a comma with XXZXX below....I don't know what the purpose of the code is...
  206.   $dayschedule = str_replace("XXZXX", "\n", $dayschedule[dayschedule]);   
  207.   $output = str_replace(",", " ", $dayschedule[dayschedule]);
  208. ?>
  209. <center><A NAME=EntryBox></A>
  210.       <a href="<?php echo $this->href("", "", "day="); echo (($today-1)<1) ? $lastday : $today-1 ; ?>&amp;year=<?php echo $year; ?>&amp;month=<?php echo $month; ?>">&lt;&lt;</a>
  211.         <b><? echo "$printowner$monthname $today, $year:"; ?></b>
  212.         <a href="<?php echo $this->href("", "", "day="); echo (($today+1)>$lastday) ? 1 : $today+1 ; ?>&amp;year=<?php echo $year; ?>&amp;month=<?php echo $month; ?>">&gt;&gt;</a>
  213.            <center><form action="" method="post">
  214.                <textarea cols="65" rows="12" name="dayscheduleX"><?php echo $dayschedule; ?></textarea>
  215.                <input type="submit" value="Submit" />
  216.                <input type="hidden" name="save" value="true" />
  217.         </form></center>   
  218. </center>
  219. <?
  220.     }
  221.     else
  222.     {
  223. echo "<em>The Scheduler only works for logged-in users.</em>";
  224.     }
  225. ?>
  226. </P>
  227.       </TD>
  228.    </TR>
  229. </TABLE>
  230. </div>