#!perl # Adapted from code written by Rich Toscano. $url = "jobs.html"; ## the calling URL. # import, read, parse. use CGI qw/:all/; use Time::localtime; use Carp; use Mac::Files; # Modifies the appropriate job category file based on job type. # Allowable job types are Post Doc, Faculty, Industrial, and Other. # Begin by defining the appropriate file to modify by equating it with "oldfilename" if (param('type') =~ /Post Doc/) { $oldfilename = "pd.html"; } elsif (param('type') =~ /Faculty/) { $oldfilename = "faculty.html"; } elsif (param('type') =~ /Industrial/) { $oldfilename = "industry.html"; } elsif (param('type') =~ /Other/) { $oldfilename = "other.html"; } else { die; } # Define a new file - this way if there is a screw up # we can recover the previously intact file! $newfilename = $oldfilename.".tmp"; # Get the date and time in an appropriate format. $date = localtime->mday()."/".localtime->mon()."/".localtime->year(); $anchor = time(); # Open the existing and new file. open (READ, "$oldfilename") || croak "Can't open file $oldfilename: $!\n"; open (WRITE, ">>$newfilename") || croak "Can't open file $newfilename: $!\n"; while ($line=) { # If the "" string is found make a new entry immediately # following it in the new file. Thus, this is a flag indicating where in the # file to place the update. We retain inverse chronological order, i.e., the # user sees the newest entries first when scrolling through the file. if ($line =~ /^/) { print WRITE "$line\n"; print WRITE li(a({-href=>"\#$anchor"}, param('title'), param('institution'), param('location'), "[$date]")); next } # If the "" string is found write summary information. # Thus, this is a flag after which summary information is written. if ($line =~ /^/) { print WRITE "$line\n"; print WRITE p, hr, i("Last posting:", $date); print WRITE "Problems? Send mail to bourne\@sdsc.edu.\n"; last; } # If the "" string is found enter the full job description, # formatting it based on the variables collected from the Web form. elsif ($line =~ /^/) { print WRITE $line; print WRITE hr, h3("", param('title')), "\n"; print WRITE h3(param('institution')); if (param('dept') ne '') { print WRITE "Department: ", param('dept'), br;} if (param('location') ne ''){ print WRITE "Location: ", param('location'), br; } if (param('site') ne ''){ print WRITE "URL: ", a({-href=>param('site')}, param('site')), br; } if (param('start') ne ''){ print WRITE "Start Date: ", param('start'), br; } if (param('end') ne ''){ print WRITE "Duration: ", param('end'), br; } if (param('details') ne ''){ print WRITE "Description: ", param('details'), br; } if (param('other_details') ne ''){ print WRITE "Other details: ", param('other_details'), br; } if (param('requirements') ne ''){ print WRITE "Please submit: ", param('requirements'), br; } if (param('contact_name') ne ''){ print WRITE "Person to contact: ", param('contact_name'), br; } if (param('contact_address') ne ''){ print WRITE "Surface mail address: ", param('contact_address'), br; } if (param('contact_email') ne ''){ print WRITE "Email address: ", param('contact_email'), br; } if (param('contact_phone') ne ''){ print WRITE "Phone number: ", param('contact_phone'), br; } if (param('contact_fax') ne ''){ print WRITE "Fax number: ", param('contact_fax'), br; } print WRITE "Job Posted: $date
\n"; print WRITE "Job ID Number: $anchor
\n"; next; } # Finally if nothing else write an existing line from OLDFILE to NEWFILE. else { print WRITE "$line\n"; } } close READ; close WRITE; FSpExchangeFiles($newfilename, $oldfilename); # This section makes a pointer to the job listing in the appropriate # location file which is accessed via the clickable map. # Define the appropriate file to update. if (param('area') =~ /Eastern US/) { $oldlfilename = "east.html"; } elsif (param('area') =~ /Central US/) { $oldlfilename = "central.html"; } elsif (param('area') =~ /Western US/) { $oldlfilename = "pacific.html"; } else { $oldlfilename = "international.html"; } $newlfilename = $oldlfilename.".tmp"; # Open the original file and a new file. open (OLDFILE, "$oldlfilename") || die "Can't open job file $oldlfilename: $!\n"; open (NEWFILE, ">$newlfilename") || die "Can't open job file $newlfilename: $!\n"; # Append an entry with the appropriate URL to the listing when the # flag "" is found. $marker = ""; while ($line=) { if ($line =~ /^$marker/) { print NEWFILE li(a({-href=>"$oldfilename\#$anchor"}, param('location'))); print NEWFILE "$line\n"; next } # Reestablish the flag after the last member of the list. elsif ($line =~ /^/) { print NEWFILE "$line\n"; last; } # Otherwise just copy the line to the newfile. else { print NEWFILE "$line\n"; } } # Include some ending information print NEWFILE "

Last modified: $date

"; print NEWFILE "Problems? Send mail to bourne\@sdsc.edu.\n"; close OLDFILE; close NEWFILE; FSpExchangeFiles($newlfilename, $oldlfilename); # Print out a message which is sent back to the employee. print header, start_html("Job Posting Results"), h1("Job Posting Results"), hr, p, "Your job was successfully posted to our ", a({-href=>"$oldfilename"}, param('type'), " job list. "), "For further assistance, send mail to the", a({-href=>"mailto:bourne\@sdsc.edu"}, "Job List Editor. "), "If you would like a job removed from the listings, please make sure to include the ", b("Job ID Number."), end_html;