<?php 
require("./appdefaults.inc");
$Title="Central";
require(
"$LibDir/top.inc");
?>

<CENTER><H1>The Lunch Bunch Website </H1></CENTER>
<HR>

This is the Lunch Bunch website.  The lunchbunch concept was started by 
Ginger Cat <gingi@world.std.com> (aka Rachel Silverman).  The plan is to meet 
once a week for lunch, usually Wednesdays at noon, within easy walking or T 
distance of Kendall Square.  
<P>
To subscribe, send an email to lunchbunch-request@thekramers.net with the 
word "subscribe" (without the quotes) as the entire body of the email 
<P> 
The website and mailing list are maintained by <A HREF="mailto:david@thekramers.net">David Kramer</A>.
<HR>
<TABLE WIDTH="100%" BORDER=1>
<TR VALIGN=TOP>
    <TD WIDTH="50%">
        <H1>The events</H1>
        <?php PrintEvents() ?>

    </TD>
    <TD WIDTH="50%">
        <H1>The Places</H1>
        <?php PrintPlaces() ?>

    </TD>
</TR>
</TABLE>

<?php

require("$LibDir/bottom.inc");

function 
GetNextDate()
{
    
#Get next event
    
$DateOffset - `date +%w`;
    if(
$DateOffset>0)
    {
        
$DateOffset += 7;
    }
    
$Date = `date -d "now + $DateOffset days" +%Y%m%d`;
    return(
trim($Date));
}

function 
PrintEvents()
{
    global 
$Places;

    if(!(
$EventFh=fopen("events.dat","r")))
    {
        print(
"Events file could not be opened");
        return;
    }

    while((
$Buffer=fgets($EventFh,4096)))
    {
        
ereg("([0-9]{4})([0-9]{2})([0-9]{2})([ \t]*)([^ \t\r\n]+)([ \t\n\r]*)$",$Buffer,$EF);

        
$Line="$EF[2]/$EF[3]/$EF[1] ".$Places[$EF[5]]['name'];
        if(
"$EF[1]$EF[2]$EF[3]== GetNextDate())
        {
            
$Line="<FONT SIZE=\"+1\" COLOR=RED>$Line</FONT>";
        }
        if(
file_exists("events/$EF[1]$EF[2]$EF[3].phtml"))
        {
            
$Line="<A HREF=\"events/$EF[1]$EF[2]$EF[3].phtml\" TARGET=\"EventWindow\">$Line</A>";
        }
        print(
$Line."<BR>\n");
    }
    
fclose($EventFh);
}


function 
PrintPlaces()
{
    global 
$Places;

    print(
"<TABLE WIDTH=\"100%\" BORDER=0>");
    foreach(
$Places as $PlaceKey => $Place)
    {
        print(
"<TR><TD><A HREF=\"places/$PlaceKey.phtml\">".$Place["name"]."</A></TD><TD>".$Place["addr"]."</TD></TR>\n");
    }
    print(
"</TABLE>\n");


}

?>

</PRE>