#!/usr/bin/perl ############################################## # Title: Web Message Editor # Program: iexp-wme.pl # Date: July 18, 1997 # Author: Andrew Schwabe # # (c)1997 Internet Expressions, Inc. ############################################## # Main Program ############################################## &setenv; #Set environment variables &read_form; #Get form + get query_string &page_select; #Choose Proper form exit; ############################################## # Subroutine Area ############################################## sub setenv { $home = "/home/a/accent1/public_html/profiles"; $salt = "Pz"; $version = "1.03"; return; } sub read_form { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } @pairs = split(/;/, $ENV{'QUERY_STRING'}); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } return; } sub page_select { if ($ENV{'QUERY_STRING'}) { $Config = $ENV{'QUERY_STRING'}; &Read_Config; &Draw_Form; exit; } else { &Check_Password; &Check_input; &Change_File; &Draw_Confirm; exit; } return; } sub Read_Config { open (CONFIG,"$home/$Config") || die &error; $username = ; chop $username; $password = ; chop $password; $page = ; $page =~ s/\n//g; if (!($page =~ /,/)) { &error6 unless (-e $page); } return; } sub Draw_Form { $cr_usr = crypt($username,$salt); $cr_pwd = crypt($password,$salt); &header; print "

Web Message Edit Form

\n"; print "

\n"; print "\n"; print ""; print ""; print ""; print "\n"; if ($page =~ /\,/) { print ""; print "\n"; } else { print ""; } print "\n"; print "\n"; if (!($page =~ /\,/)) { print ""; } print "
Username:
Password:
Page to Update:
Field Type:
Message:
"; print "

Below is the information that was in this field previously. If "; print "you would like to use any of this, you may copy and paste it into "; print "the above box.

"; print ""; print "
"; &CC_File; print "

"; print "

"; print " \n"; print "
\n"; print "


"; print "Accent Internet\n"; exit; return; } sub Check_Password { $user_pwd = crypt($FORM{'PASSWORD'},$salt); $user_name = crypt($FORM{'USERNAME'},$salt); if (($user_pwd eq $FORM{'PASSWD'})&&($user_name eq $FORM{'USER'})) { return; } else { &error2; } &error; } sub Check_input { &error3 unless $FORM{'TYPE'}; &error3 unless $FORM{'MESSAGE'}; return; } sub Change_File { open (INFILE, "$FORM{'PAGE'}") || die &error4; $idlx = 0; while ($line = ) { if ($line eq "\n") { $found++; } if ($line eq "\n") { $found++; } @INDATA[$idlx] = $line; $idlx++; } close (INFILE); &error7 unless ($found == 2); open (OUTFILE, ">$FORM{'PAGE'}") || die &error5; $zx = 0; while (@INDATA[$zx] ne "\n") { print OUTFILE @INDATA[$zx]; $zx++; } print OUTFILE "\n"; if ($FORM{'TYPE'} eq "FORM1") { print OUTFILE "
\n"; } if ($FORM{'TYPE'} eq "FORM2") { print OUTFILE "
\n"; } if ($FORM{'TYPE'} eq "FORM3") { print OUTFILE "
\n"; } if ($FORM{'TYPE'} eq "FORM4") { print OUTFILE "
\n"; } if ($FORM{'TYPE'} eq "TABLE1") { print OUTFILE "$FORM{'MESSAGE'}\n"; } if ($FORM{'TYPE'} eq "TABLE2") { print OUTFILE "
$FORM{'MESSAGE'}
\n"; } if ($FORM{'TYPE'} eq "TABLE3") { print OUTFILE "
$FORM{'MESSAGE'}
\n"; } if ($FORM{'TYPE'} eq "TABLE4") { print OUTFILE "
$FORM{'MESSAGE'}
\n"; } if ($FORM{'TYPE'} eq "BOX1") { print OUTFILE "
\n"; } if ($FORM{'TYPE'} eq "BOX2") { print OUTFILE "
\n"; } if ($FORM{'TYPE'} eq "BOX3") { print OUTFILE "
\n"; } print OUTFILE "\n"; $zx++; while (@INDATA[$zx] ne "\n") { $zx++; } $zx++; while ($zx < @INDATA) { print OUTFILE @INDATA[$zx]; $zx++; } close (OUTFILE); undef @INDATA; return; } sub CC_File { open (INFILE, "$page") || die &error4; @INDATA = ; close (INFILE); $zx = 0; while (@INDATA[$zx] ne "\n") { $zx++; } $zx++; while (@INDATA[$zx] ne "\n") { $cc_contents .= @INDATA[$zx]; $zx++; } $cc_contents =~ s/\

Your page has been updated

"; # print "Click here to go to your page.

\n"; print "Use your back button and reload your page\n"; return; } sub error { &header; print "

WME Configuration Error

\n"; print "Please check that the profile: $home/$Config exists.\n"; print "

"; exit; } sub error2 { &header; print "

Bad username/password Combination

\n"; print "Please click here to go back\n"; print "

"; exit; } sub error3 { &header; print "

Form incomplete

\n"; print "Please complete the following information:

\n"; print "

  • Field Type\n" unless $FORM{'TYPE'}; print "
  • Message\n" unless $FORM{'MESSAGE'}; print "

    "; print "Please click here to go back\n"; print "

    "; exit; } sub error4 { &header; print "

    Specified file $FORM{'PAGE'} does not exists on server

    \n"; print "Check with your system administrator. \n"; print "

    "; exit; } sub error5 { &header; print "

    Specified file $FORM{'PAGE'} does not have write permissions

    \n"; print "Check with your system administrator. \n"; print "

    "; exit; } sub error6 { &header; print "

    Specified file $page does not exist.

    \n"; print "Check to see that the path and filename is correct in your profile.\n"; print "

    "; exit; } sub error7 { &header; print "

    Specified file $page does not contain proper marker tags.

    \n"; print "Check your documentation to ensure that you have proper comment tags defined. \n"; print "

    "; exit; } sub header { print "Content-type: text/html\n\n"; print < Page Editor
    Page Editor $version
    EOM return; }