#!/usr/bin/perl
#
# calevents.pl
#
# ../cgi-bin/calevents.pl -skip > Calendar/index.html
#
#
# Other nice gui calendars
# ------------------------
# http://www.onebrick.org/calendar.asp
#
#
# 16-Apr-02 amo Date-of-Birth
# 14-Jul-02 amo CalLug is 1st Sat during summer
# 25-Dec-02 amo Added 2003 Calendar ( 2003.Months.txt )
# 01-Jun-03 amo Changed /usr2/www-linux to /usr2/home/httpd/html.linux-consulting/www-linux
# 02-Jun-03 amo Changed smaug to 2nd thur, Changed from Lsec to Sec, Added ucsc.edu
# 02-Dec-03 amo Added penlug.org for 4th Thu
# 07-Jan-04 amo Added 2004 Calendar ( yid )
# 10-May-04 amo Added SBAY wireless
# 02-Sep-04 amo Removed svbug, Removed callug
# 01-Feb-05 amo Updated $yid for 2005
# 26-Jun-05 amo Changed TOP_DIR
# 07-Jan-06 amo Modified for 2006, removed wireless
# 21-Aor-06 amo Changed Sluglug to 2nd Wed
#
#
#################################################
#
# List of Events
#
# Wed.1 == First Wed of each Month
# Thu.2 == Second Thur of each Month
#
# every other wed
# ---------------
# http://www.ccsf.edu/Organizations/Linux_Users_Group
#
#
#EVE{"Mon.1"} = "http www.scruz.org SMAUG";
#EVE{"Mon.1"} = "http sbay.linux-consulting.com SBAY^
Wireless";
#
$EVE{"Tue.1"} = "http lug.lbl.gov LBLlug ^
SV.PerlMongers
OpenBSD \n";
#
#EVE{"Tue.1"} = "http www-callug.cs.berkeley.edu CalLug ^
# http www.ocf.berkeley.edu/~linux/mirror> CalLug
#
$EVE{"Wed.1"} = "http www.SVLUG.org SVLUG";
#EVE{"Thu.1"} = "http www.SVBUG.com SVBUG ^
BUUG ";
$EVE{"Thu.1"} = "http www.weak.org/buug BUUG";
#
#
#EVE{"Sat.1"} = "http www-callug.cs.berkeley.edu CalLug";
#
#
#
#EVE{"Tue.2"} = "http www.imrryr.org/NetBSD/sfbanug.html NetBSD";
$EVE{"Tue.2"} = "http www.netbsd.org/gallery/groups.html#sfbanug NetBSD";
#
$EVE{"Wed.2"} = "http bad.debian.net BA-Debian ^
SLugLug ";
#
#EVE{"Wed.2"} = "http bad.debian.net BA-Debian ";
#EVE{"Wed.2"} = "http bad.debian.net BA-Debian ^
BayPiggies(Python)";
#
#EVE{"Wed.2"} = "http bad.debian.net BA-Debian ^
BayPiggies(Python)";
#
#
#EVE{"Thu.2"} = "Str Linux-LSec.net
OpenBSD ";
#
$EVE{"Thu.2"} = "Str Linux-Sec.net
FreeBSD
SMAUG
BayPiggies(Python) ";
#
#
OpenBSD ";
$EVE{"Sat.2"} = "http linuxmafia.com/cabal CABAL ^
OpenBSD ";
#
#
#
#EVE{"Mon.3"} = "http sbay.linux-consulting.com SBAY^
Wireless";
#
#EVE{"Tue.3"} = "http www-callug.cs.berkeley.edu CalLug ^
BALUG ";
# http www.ocf.berkeley.edu/~linux/mirror> CalLug
$EVE{"Tue.3"} = "http www.balug.org BALUG";
#
$EVE{"Wed.3"} = "http www.eblug.org EBLug";
$EVE{"Thu.3"} = "http www.BayLisa.org BayLisa ^
BUUG ";
#
$EVE{"Sat.3"} = "http www.SVLUG.org SVLUG-InstallFest ^
SBAY ";
#
#
#EVE{"Mon.4"} = "http sluglug.ucsc.edu SLugLug";
$EVE{"Tue.4"} = "http sf.pm.org SF.PerlMongers";
#EVE{"Thu.4"} = "http www.bafug.org FreeBSD";
$EVE{"Thu.4"} = "http www.penlug.org PenLug";
$EVE{"Sat.4"} = "http linuxmafia.com/cabal CABAL";
#
#
#################################################
#
#
# the Global Variable and Functions
#
local ( $NM ) = "calevents.pl";
#
local ( $Pid ) = $$;
#
#
# Set to 1 for testing, zero else
#
local ( $Test ) = 1; # Test mode == 1 ----> send to me only and do NOT increment counter
local ( $Content ) = 0; # for Content-type: text/html
#
#
#ocal ( $TOP_DIR ) = "/usr2/www-linux";
#ocal ( $TOP_DIR ) = "/usr2/home/httpd/html.linux-consulting/www-linux";
local ( $TOP_DIR ) = "/home/httpd/html.linux-consulting";
#
local ( $HTML_GEN )= "/home/httpd/cgi-bin/html_gen.pl";
#
#
#
local ( $Skip_Stdin ) = 0;
#
my ( @p_v ) = (); # web_page data
my ( $Func ) = "";
#
#
#
# for date function
#
require "ctime.pl";
#
# get the date
#
# Sun Apr 29 0:05:51 2001
my ( $ts ) = &ctime(time);
chop ( $ts );
my ( $Dow, $Mon, $date, $time, $Year ) = split ( /\s+/, $ts ); # one or more whitespac
$time =~ s/:/-/g;
#
my ( $Date ) = sprintf "%02s", $date;
#
my ( $Time ) = sprintf "%08s", $time; # fix hour to digits
#
#
#
# User Feedback Strings
# ---------------------
#
local ( @DayStr ) = split ( /\s+/, "Sun Mon Tue Wed Thu Fri Sat" );
#
local ( @MonStr ) = split ( /\s+/, " Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" );
#
local ( %MonID ) = ();
$MonID{"Jan"} ="01";
$MonID{"Feb"} ="02";
$MonID{"Mar"} ="03";
$MonID{"Apr"} ="04";
$MonID{"May"} ="05";
$MonID{"Jun"} ="06";
$MonID{"Jul"} ="07";
$MonID{"Aug"} ="08";
$MonID{"Sep"} ="09";
$MonID{"Oct"} ="10";
$MonID{"Nov"} ="11";
$MonID{"Dec"} ="12";
#
#
# Default Yr.Mon
#
my ( $Yr_Mon ) = "${Year}.${MonID{$Mon}}";
#
#
#
#
my ( $FIND ) = "/usr/bin/find";
my ( $EGREP ) = "/bin/egrep";
#
#
#
#
# Check for perl command line arguments
# -------------------------------------
#
&chk_argv;
#
#
# Process the Incming Web Page Form
# ---------------------------------
#
local ( @Param_Value ) = &Proc_Form;
#
#
# Search Directory and Search String
# -----------------------------------
#
local ( $CAL_DIR ) = "Calendar";
local ( $Cal_Str ) = &Proc_Str ( @Param_Value );
#
#
# Fix for 2002 vs 2003
my ( $y, $m ) = split ( /\./, $Yr_Mon );
#
#ocal ( $Cal_YrMon_StartEnd ) = "$TOP_DIR/$CAL_DIR/2002.Months.txt";
local ( $Cal_YrMon_StartEnd ) = "$TOP_DIR/$CAL_DIR/$y.Months.txt";
#
local ( $Cal_Temp_Dir ) = "$TOP_DIR/$CAL_DIR/Search.Temp";
local ( $Cal_gwif ) = "content.$Pid.gwif"; # fix lock
#
#
#
# Process the Data
# ----------------
#
local ( $html ) = &do_cal ( $Cal_Str );
#
#
# Display user Feedback on the Browser
# ------------------------------------
#
&Put_Display ( $html );
#
unlink "$Cal_Temp_Dir/$Cal_gwif";
unlink "$Cal_Temp_Dir/$Cal_gwif.html";
#
#
exit 1;
#
#
#
sub do_cal ()
{
#
#
open ( FWR, "> $Cal_Temp_Dir/$Cal_gwif" ); # Need to make this Multi-user searches
#
#
# Prepare the Search results
# ---------------------------
#
printf FWR "#\n";
printf FWR "# $NM - $Cal_gwif \n";
printf FWR "#\n";
printf FWR "Table2 Valign=top width=500\n";
printf FWR "#\n";
#
#
( $yr, $mn ) = split ( /\./, $Yr_Mon );
$m = sprintf "%02d", $mn;
#
#
printf FWR "Tabcbfs Blue White 3 Cal
Regularly Scheduled Monthly Linux/BSD User Group Meeting Calendar
$MonStr[$m] $yr
Generated from calevents.pl w/ gwif
\n";
printf FWR "#\n";
printf FWR "#\n";
printf FWR "nextrow\n";
printf FWR "TabItem Str For more detailed info... please see LinuxMafia.com/bale \n";
printf FWR "
\n";
printf FWR "
\n";
#
#
printf FWR "#\n";
printf FWR "#\n";
printf FWR "nextrow\n";
printf FWR "#\n";
printf FWR "table\n";
#
#
# List of Months
# --------------
#y ( $yid ) = "2003";
#y ( $yid ) = "2004";
#y ( $yid ) = "2005";
my ( $yid ) = "2006";
#
#
while ( $yid >= 2002 ) {
#
printf FWR "Tabitem Str $yid \n";
#
$id = 1;
while ( $id <= 12 ) {
$d = sprintf "%02d", $id;
#
if ( $Yr_Mon eq "$yid.$d" ) {
printf FWR "TabItem Str $MonStr[$d] - \n";
} else {
printf FWR "TabItem Str $MonStr[$d] - \n", $id ;
}
#
$id += 1;
} # Monthly
#
printf FWR "#\n";
printf FWR "nextrow\n";
#
$yid -= 1;
#
} # yid
#
#
printf FWR "#\n";
printf FWR "#\n";
#
printf FWR "#\n";
printf FWR "# end of Months\n";
printf FWR "endtab\n";
#
#
printf FWR "#\n";
printf FWR "#\n";
printf FWR "nextrow\n";
printf FWR "TabItem Str
\n";
#
printf FWR "#\n";
printf FWR "#\n";
printf FWR "nextrow\n";
printf FWR "#\n";
printf FWR "table\n";
#
#
# Day of the Week
# ---------------
#
printf FWR "#\n";
printf FWR "nextrow\n";
printf FWR "TabItem Str Sunday \n";
printf FWR "TabItem Str Monday \n";
printf FWR "TabItem Str Tuesday \n";
printf FWR "TabItem Str Wednesday \n";
printf FWR "TabItem Str Thursday \n";
printf FWR "TabItem Str Friday \n";
printf FWR "TabItem Str Saturday \n";
#
#
# See when the first of the month starts
#
( $yr_mon, $off, $end ) = split ( /\s+/, ` grep $Yr_Mon $Cal_YrMon_StartEnd `);
#
#
# printf FWR "#\n";
# printf FWR "nextrow\n";
# printf FWR "TabItem Str ..srch=$Yr_Mon....yr=$yr_mon...off=$off..end=$end..\n";
#
#
# Find the First Wed and/or 2nd Thur of the month
$dowid = 1;
$did = 0;
#
#
# =========================================
# At most 5 (partial) weeks in the months
# =========================================
#
while ( $jd <= 5 ) {
#
printf FWR "#\n";
printf FWR "nextrow\n";
printf FWR "TabItem Str
\n";
#
printf FWR "#\n";
printf FWR "nextrow\n";
#
#
if ( $jd == 0 ) {
$offj = 1;
} else {
$offj = ( 7 * $jd ) +1;
}
#
$id = 0;
$d = $id - $off + $offj ; # date
#
while ( $id <= 6 ) {
#
# Show the Date
#
if ( ( $id < $off ) && ( $jd == 0 ) ) {
printf FWR "TabItem Str
\n";
} else {
#
#
printf FWR "TabItem Str %d
\\\n", $d;
#
# See if there is any events for this date
# ----------------------------------------
#
$Dow = $DayStr[$id] ;
$Dow .= ".$dowid" ;
#
$eve = $EVE{$Dow};
#
#
# List the event
#
#
if ( $eve ne "" ) {
printf FWR "TabItem $eve\n";
} else {
printf FWR "TabItem Str
\n";
}
#
#
$did += 1 ;
if ( $did >= 7 ) {
$dowid += 1; # 3rd Thur of the month
$did = 0;
}
#
} # dayz
#
$id += 1;
#
$d = $id - $off + $offj ; # date
#
#
# past the end of the month
#
if ( $d > $end ) {
$id = 100 ;
$jd = 100 ;
}
#
} # 7 days worth
#
$jd += 1;
#
#
} # weeks
#
#
printf FWR "#\n";
printf FWR "# end of days\n";
printf FWR "endtab\n";
#
printf FWR "#\n";
printf FWR "nextrow\n";
printf FWR "TabItem Str Need to cleanup multiple events per day\\\n";
printf FWR "TabItem Str Need to cleanup stupid/quick-n-dirty coding\\\n";
printf FWR "TabItem Str Need to highlight holidays and handle holiday exceptions\\\n";
printf FWR "TabItem Str Need to fix multiple-day conferences\\\n";
#
#
# Clean up
# ---------
#
printf FWR "#\n";
printf FWR "# end data\n";
printf FWR "endtab\n";
printf FWR "#\n";
printf FWR "# end content\n";
printf FWR "endtab\n";
printf FWR "#\n";
printf FWR "# end of file\n";
#
close ( FWR );
` sync `;
#
# Generate the Order Page ( chmod 754 html_gen.pl )
# -----------------------
#
` cd $Cal_Temp_Dir ; $HTML_GEN $Cal_gwif `;
#
return ( "$Cal_Temp_Dir/$Cal_gwif.html" );
#
} # do_cal
#
#
# Extract Search String
# ---------------------
#
sub Proc_Str
{
my ( @p_v ) = @_;
#
my ( $cal_str ) = ""; # default to current directory
#
my ( $id ) = 0;
#
#
# Process the web form parameters
#
while ( $id <= $#p_v ) {
#
( $p, $v ) = split ( /=/, $p_v[$id] );
#
$Content = printf "Content-type: text/html\n\n" if ( $Content == 0 );
#
# printf "$id..p=$p..v=$v.....$p_v[$id]..
\n";
#
$Yr_Mon = "$v" if ( $p eq "YrMon" );
#
$id += 1;
}
#
return ( $cal_str );
#
} # Proc_Str
#
#
#
#
# print to the browser screen
# ---------------------------
#
sub Put_Display
{
my ( $html ) = @_;
#
my ( $line ) = "";
#
my ( $status ) = open ( FRD, "< $html" );
#
$Content = print "Content-type: text/html\n\n" if ( $Content == 0 ); # Normal processing of forms
#
while ( ) {
chomp ( $line = $_ );
printf "$line\n";
`echo "$line" >> /tmp/foo `;
}
#
close ( FRD );
#
} # Put_Display
#
#
#
# Process the Web Page Forms
# --------------------------
#
sub Proc_Form {
#
#y ( $GN_ARG ) = $ENV{PATH_INFO}; # Get the argument from the searchURL
#y ( $GN_QUERY ) = $ENV{QUERY_STRING};
#
my ( $postinput ) = if ( $Skip_Stdin == 0);
my ( @p_v ) = ();
#
#
$Content = print "Content-type: text/html\n\n" if ( $Content == 0 ); # Normal processing of forms
#
#
if ( $ENV{REQUEST_METHOD} eq "POST") {
#
# It's the POST method, so print content length and coded input from
# STDIN. Then decode it and print again.
# $GN_QUERY =~ s/\+/ /g; # Change +'s to spaces
# print "Posted input content-length = $len..GN=$GN_QUERY..
\n";
# print "Undecoded posted input:
..$postinput
\n\n";
# $postinput =~ s/&/&
\n/g;
$postinput =~ s/\+/ /g;
$postinput =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig;
#
# print "Decoded posted input:
..$postinput
\n";
#
} # post
#
#
# append ( from html url ): monitor.pl?Login=USR¶m=value
# ------------------------
#
$postinput .= "&" . "$ENV{'QUERY_STRING'}";
#
#
#
# Clean up Bad input Errors
# -------------------------
#
$postinput =~ s/\/;
$postinput =~ s/\>//;
$postinput =~ s/\[//;
$postinput =~ s/\]//;
$postinput =~ s/\+//;
$postinput =~ s/\;//;
#postinput =~ s/\.//;
$postinput =~ s/\&//;
#
#
#
( @p_v ) = split ( /&/, $postinput );
#
# printf "postinput=$postinput..
\n";
# printf "p_v[$#p_v]=@p_v..
\n";
#
return ( @p_v );
#
} # Proc_Form
#
#
#
# Check Command Line Args
# ------------------------
#
sub chk_argv
{
#
my ( $id ) = 0;
#
#
# Check the Command line options
# ------------------------------
#
while ( $id <= $#ARGV ) {
#
$arg = $ARGV[$id];
#
if ( $arg eq "-h" ) {
$Help = 1;
#
} elsif ( $arg eq "-d" || $arg eq "-debug" ) {
$DEBUG = 1;
#
} elsif ( $arg eq "-skip" ) {
#
$Skip_Stdin = 1; # Skip stdin check in proc_form
#
}
#
$id += 1;
#
} # command_line options
#
#
} # chk_arg
#
#
# end of file