#!/usr/local/bin/perl require 'cgi-lib.pl'; #Set defaults $path="/home/femibyte/www/data/"; $bhref="http://mandela.femibyte.com:8000/"; &ReadParse(*input); print &PrintHeader; $appchoice=$input{'Project_Choice'}; $uid=$input{'UserId'}; @newupdate=$input{'newupdate'}; if ($input{'Button'} eq "Search") { $action="Read"; undef $input{'Button'}; } elsif ($input{'Button2'} eq "Update") { $action="Write"; undef $input{'Button2'}; } $fname="$path"."$appchoice"; if ($action eq "Read") { @LastUpd=&GetLastUpdate($fname) } elsif ($action eq "Write") { if ($uid eq "") { &CgiError("Need to specify userid!!\n"); exit; } if ($newupdate[0] eq "") { &CgiError("Empty input field!\n"); exit; } &PutNextUpdate($fname,@newupdate); } foreach $j (0 .. $#LastUpd) { $buffer .=@LastUpd[$j]; } print < Generic Software Programming Project Team


Project Status Update Screen

Mail comments or suggestions to: Site Guide.


Latest Update

New Update

Userid#


femibyte@ritz.mordor.com
EOF sub PutNextUpdate { local($appfile,@buf)=@_; open (INFILE,"$appfile"); open(TMPFILE,">/tmp/parsed"); while () { if (/\*Latest/) { s/\*Latest//;} print TMPFILE $_; } $date=`date '+%m/%d/%y'`; chop $date; print TMPFILE "*$uid*$date*Latest\n"; foreach $j (0..$#buf) { print TMPFILE "@buf[$j]"; } print TMPFILE "\n"; close(INFILE); close(TMPFILE); `cp /tmp/parsed $appfile`; `rm /tmp/parsed`; } sub GetLastUpdate { local($appfile)=@_; local($found,$i,@buffer);@buffer[$i++]="$person $date"; open(FILE,$appfile); while() { if (/Latest/) { $found=1; ($junk,$person,$date)=split(/\*/,$_); next; } else { if ($found==1) { @buffer[$i++]=$_; } } } @buffer[$i++]="$person $date"; return(@buffer); }