Algorithms
|
|
|
|
1st file: calendar.php
////// CALENDAR.PHP /////////////////////////
<!--
PHP Calendar Script by Ricardo Assing.
URL: http://ra13.l1h.net
email: boanerges1320@yahoo.com
-->
<?php /////////////////////////////////////////////////////////////////////
///////// EDIT HERE ////////////////////////////////////////////// $hFont = "Verdana, Arial, Helvetica, sans-serif";//sets header font $hColor = "#333333";//sets header color $hBgColor = "999999";//sets header background for days of week $monthColor = "#000000";//font color of month $dColor = "000000";//color of days $dFont = "Verdana, Arial, Helvetica, sans-serif";//days font $dBgColor = "dddddd";//background of days $notsetDays = "eeeeee";//background of extra days $dBgColordef = "dddddd";//background of days *should be same as above $todayBg = "#ffffff";//background of today $calBg = "#333333";//background of calendar $headBg = "ffffff";//background of month $overColordef = "#ffffff";//same as below $overColor = "#ffffff";//Mouse over color $todayOver = "#ffffcc";//Mouse over color for current day
$fontSize = "7";//Font Size $calWidth = "170";//Overall Calendar width pixels
/////////// END EDIT //////////////////////////////////////////////
///////////////////////////////////////////////////////////////////// $currentYear = date(Y);//year ex. 2003 $currentMonth = date(F); $currentMonth = strtoupper($currentMonth);//month ex. JANUARY $currentMonthNum = date(n); $currentDay = date(j);//current day 1 - 31 $amtDays = date(t);//days in month 28 - 31 $firstDay = date("w",mktime(1,1,1,$currentMonthNum,1,$currentYear));
$lastDay = date("w",mktime(1,1,1,$currentMonthNum,$amtDays,$currentYear)); $days = array("S","M","T","W","T","F","S"); $daysNum = range(1,7); $day = date(w);//sets numeric day 0 - 6 where 0 = Sunday $colWidth = $calWidth/7; ?>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_setTextOfLayer(objName,x,newText) { //v4.01
if ((obj=MM_findObj(objName))!=null) with (obj)
if (document.layers) {document.write(unescape(newText)); document.close();}
else innerHTML = unescape(newText);
}
//-->
</script>
<!-- START HEADERS -->
<table width="<?php echo $calWidth; ?>" border="0" cellspacing="1" cellpadding="1" bgcolor="<?php echo $calBg; ?>" id="cal">
<tr bgcolor="<?php echo $headBg; ?>">
<td colspan="7" style="font-size:<?php echo $fontSize; ?>pt"><div align="center"><font color="<?php echo $monthColor; ?>" face="<?php echo $hFont; ?>"><strong><?php echo $currentDay." ".$currentMonth." ".$currentYear; ?></strong></font></div></td>
</tr>
<tr bgcolor="<?php echo $hBgColor; ?>">
<?php
foreach ($days as $value){
?>
<!-- DAYS OF THE WEEK ex. MON TUE -->
<td width="<?php echo $colWidth; ?>" style="font-size:<?php echo $fontSize; ?>pt"><div align="center"><strong><font color="<?php echo $hColor; ?>" face="<?php echo $hFont; ?>"><?php echo $value; ?></font></strong></div></td>
<!-- -->
<?php
}
?> </tr>
<!-- END HEADERS -->
<!-- START OUTPUT -->
<tr>
<?php
$row1=7-$firstDay; $i=0; $x=0; $days = range(1,$amtDays);
while ($x < $firstDay){
echo "<td bgcolor="$notsetDays" width="$colWidth"></td>"; $x++;
}
while ($i < $row1){
if ($currentDay == $days[$i]){
$dBgColor = $todayBg;
$overColor = $todayOver;
} else {
$dBgColor = $dBgColordef;
$overColor = $overColor;
} ?> <td align="center" style="font-size:<?php echo $fontSize; ?>pt" width="<?php echo $colWidth; ?>" bgcolor="<?php echo $dBgColor; ?>" onMouseOver="style.cursor='hand';style.background='<?php echo $overColor; ?>';MM_setTextOfLayer('dis','','<?php echo $days[$i]." ".$currentMonth." ".$currentYear; ?>')"
onMouseOut="style.background='<?php echo $dBgColor; ?>';MM_setTextOfLayer('dis','','')" onclick="window.navigate('schedule.php&fileName=<?php echo $days[$i]." ".$currentMonth." ".$currentYear; ?>')"><div align="center"><strong><font color="<?php echo $dColor; ?>" face="<?php echo $dFont; ?>"><?php echo $days[$i]; ?></font></strong></div></td>
<?php
$i++; $dBgColor = $dBgColordef; $overColor = $overColordef;
} ?> </tr>
<?php
$n=0; $ar = array(6,13,20,27); $ar1 = array(0,7,14,21,28); $var = $amtDays-$i; $var1 = $var-$daysNum[$lastDay];
while ($n < $var1){
if ($currentDay == $days[$i]){
$dBgColor = $todayBg;
$overColor = $todayOver;
} else {
$dBgColor = $dBgColordef;
$overColor = $overColor;
}
if (in_array($n,$ar1)){ ?>
<tr>
<td align="center" style="font-size:<?php echo $fontSize; ?>pt" width="<?php echo $colWidth; ?>" bgcolor="<?php echo $dBgColor; ?>" onMouseOver="style.cursor='hand';style.background='<?php echo $overColor; ?>';MM_setTextOfLayer('dis','','<?php echo $days[$i]." ".$currentMonth." ".$currentYear; ?>')"
onMouseOut="style.background='<?php echo $dBgColor; ?>';MM_setTextOfLayer('dis','','')" onclick="window.navigate('schedule.php&fileName=<?php echo $days[$i]." ".$currentMonth." ".$currentYear; ?>')"><div align="center"><strong><font color="<?php echo $dColor; ?>" face="<?php echo $dFont; ?>"><?php echo $days[$i]; ?></font></strong></div></td>
<?php
} elseif (in_array($n,$ar)) { ?>
<td align="center" style="font-size:<?php echo $fontSize; ?>pt" width="<?php echo $colWidth; ?>" bgcolor="<?php echo $dBgColor; ?>" onMouseOver="style.cursor='hand';style.background='<?php echo $overColor; ?>';MM_setTextOfLayer('dis','','<?php echo $days[$i]." ".$currentMonth." ".$currentYear; ?>')"
onMouseOut="style.background='<?php echo $dBgColor; ?>';MM_setTextOfLayer('dis','','')" onclick="window.navigate('schedule.php&fileName=<?php echo $days[$i]." ".$currentMonth." ".$currentYear; ?>')"><div align="center"><strong><font color="<?php echo $dColor; ?>" face="<?php echo $dFont; ?>"><?php echo $days[$i]; ?></font></strong></div></td>
</tr>
<?php
} else { ?>
<td align="center" style="font-size:<?php echo $fontSize; ?>pt" width="<?php echo $colWidth; ?>" bgcolor="<?php echo $dBgColor; ?>" onMouseOver="style.cursor='hand';style.background='<?php echo $overColor; ?>';MM_setTextOfLayer('dis','','<?php echo $days[$i]." ".$currentMonth." ".$currentYear; ?>')"
onMouseOut="style.background='<?php echo $dBgColor; ?>';MM_setTextOfLayer('dis','','')" onclick="window.navigate('schedule.php&fileName=<?php echo $days[$i]." ".$currentMonth." ".$currentYear; ?>')"><div align="center"><strong><font color="<?php echo $dColor; ?>" face="<?php echo $dFont; ?>"><?php echo $days[$i]; ?></font></strong></div></td>
<?php
}
$n++;
$i++;
$dBgColor = $dBgColordef;
$overColor = $overColordef;
}//end while echo "<tr>"; $x=0;
while ($i < $amtDays){
if ($currentDay == $days[$i]){
$dBgColor = $todayBg;
$overColor = $todayOver;
} else {
$dBgColor = $dBgColordef;
$overColor = $overColor;
} ?>
<td align="center" style="font-size:<?php echo $fontSize; ?>pt" width="<?php echo $colWidth; ?>" bgcolor="<?php echo $dBgColor; ?>" onMouseOver="style.cursor='hand';style.background='<?php echo $overColor; ?>';MM_setTextOfLayer('dis','','<?php echo $days[$i]." ".$currentMonth." ".$currentYear; ?>')"
onMouseOut="style.background='<?php echo $dBgColor; ?>';MM_setTextOfLayer('dis','','')" onclick="window.navigate('schedule.php&fileName=<?php echo $days[$i]." ".$currentMonth." ".$currentYear; ?>')"><div align="center"><strong><font color="<?php echo $dColor; ?>" face="<?php echo $dFont; ?>"><?php echo $days[$i]; ?></font></strong></div></td>
<?php
$i++; $dBgColor = $dBgColordef; $overColor = $overColordef; $x++;
}
while ($x < 7){ ?> <td bgcolor="<?php echo $notsetDays; ?>" width="<?php echo $colWidth; ?>"></td>
<?php
$x++;
} ?> </tr>
<!-- END OUTPUT -->
<tr><td colspan="7" bgcolor="<?php echo $headBg; ?>" id="varMes">
<div id="dis" style="position:absolute; width:173px; height:19px; z-index:1;" align="center">
</div>
</td></tr>
</table>
///////////////////////////////////////////////////////
2nd file: schedule.php
///////// SCHEDULE.PHP //////////////////////////
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="blackMain">
<tr>
<td> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="TLwhite">
<tr>
<td bgcolor="#CCCCCC" class="Botborder"><strong>Reminders for:<font color="7895a5" face="Verdana, Arial, Helvetica, sans-serif"><strong>
<font color="#660000"><?php echo $_REQUEST['fileName']; ?></font>
</strong></font></strong></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="blackMain">
<tr>
<td> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="TLwhite">
<tr>
<td bgcolor="#CCCCCC" class="Botborder"><strong></strong></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="blackMain">
<tr>
<td> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="TLwhite">
<tr>
<td class="Botborder"><strong>
<?php include("read.php"); ?>
</strong></td>
</tr>
</table></td>
</tr>
</table>
/////////////////////////////////////////////////////////
3rd file: read.php
////////// READ.PHP /////////////////////////////////
<?php
$fileSch = $_REQUEST['fileName']; $str = str_replace(" ","",$fileSch); $file = "events/$str.txt"; //echo $file; if (file_exists($file)){ $lines = file($file);
if( !($fd = fopen($file,"r")) )
die("Could not open $file for reading!");
for( $i = 0; $lines[$i]; $i++ )
{
echo $lines[$i];
}
if( !(flock($fd,LOCK_UN)) )
die("Could not release lock on $file!");
if( !(fclose($fd)) )
die("Could not close file pointer for $file!");
} else {
echo "Schedule not set!";
} ?>
/////////////////////////////////////////////////////////
1. All three files must be in the same directory.
2. A directory named "events" should be created and placed with the three files.
3. To set schedules, just create a .txt file with the name being that of the date for the events.
example: 13JULY2003.txt
4. Events, reminders etc. are stored in the .txt files
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|