Solved

SSI - Cgi Script Error

Posted on 2000-03-28
3
306 Views
Last Modified: 2013-12-25
I'm working on a script called Pollit from http://www.cgi-world.com.  The script seems to work fine at http://www.positive-word-of-mouth.com/cgi-bin/pollit/Poll_It_v2.0.cgi.

But when I try to pull it in with a SSI I get an error message - [an error occurred while processing this directive]

Here is the code I put in my HMTL document at
http://www.positive-word-of-mouth.com/test.shtml:

 <!--#exec cgi ="/u156/pwom/cgi-bin/pollit/Poll_It_SSI_v2.0.cgi" -->

I'm really stuck.  I've been working on this for 2 days.  Need your help!

For reference I've posted below the 2 CGI scripts and the HTML code.

I've also run the PERL syntax checker at http://www.valueweb.net/ and it checks out ok.  I don't have Telnet access to this account yet because it isn't offered.

Thanks, April



<--SCRIPT ONE--->
#!/usr/local/bin/perl
####################################################################
# Script:       | Poll It                                          #
# Version:      | 2.0                                              #
# By:           | Jason Berry (i2 Services, Inc. / CGI World)      #
# Contact:      | jason@cgi-world.com                              #
# WWWeb:        | http://www.cgi-world.com                         #
# Copyright:    | Jason Berry (CGI World of i2 Services, Inc.)     #
# Released      | August 09, 1998                                  #
####################################################################
# By using this software, you have agreed to the license           #
# agreement packaged with this program.                            #
#                                                                  #
####################################################################
# Variables:
 #
   #

   $image_url = "http://www.positive-word-of-mouth.com/images/image.gif";
   # URL to the 'image.gif' that was packaged with this script. Upload
   # that GIF Image to your website & enter the URL to it above.


   $vote_text = "Rock the Vote!";
   # Text that is shown on the submit button when casting your vote.

   
   # Note:
   ##################################################################
          # If you're looking to use an image in one of the variables
          # below, input the IMAGE tag inside of the quotes as:
          # <IMG SRC=\"image_url.gif\"> <-- Placing backslashes (\)
          # before the extra quotes inside a quote.
          ###########################################################


   $last_poll_text = "<LI>our Previous Polls Results";
   # Text that is linked to view the previous results of your
   # previous poll.


   $results_not_available = "<BR>The results will be posted soon...";
   # Message shown when the number of votes is not greater then
   # the ammount you opted for when setting up a poll.

   
   $poll_not_available = "<BR>Currently there is no opinion poll available...<P>Check back soon for another poll...";
   # Message listed when a poll is not available.
   #


   $non_SSI_CGI_FileName = "Poll_It_v2.0.cgi";
   # The name of the file that was originaly named  "Poll_It_v2.0.cgi" when
   # you received this zipped up package. If you renamed that file to poll.cgi
   # then enter "poll.cgi" above.

     


#
 #
  # (We do not support this script if you edit below this line )
   ################################################################
  #
#

if ($0=~m#^(.*)(\\|/)#)      { $cgidir = $1; }
else { $cgidir = `pwd`; chomp $cgidir; }

$script_url  = $ENV{'SCRIPT_NAME'};
$data_dir = "$cgidir/pollit_files";
$poll_options = "$data_dir/poll_options.txt";
$poll_info = "$data_dir/poll_info.txt";
$ips_file = "$data_dir/ips.txt";
$last_file = "$data_dir/last_poll.txt";
$lockdir = "$data_dir/filelock";

%in = &ReadForm;


open(IPS,"<$ips_file");
@ips = <IPS>;
close(IPS);

$all_ips = join('|',@ips);

$addr = "$ENV{'REMOTE_ADDR'}\n";

if(@ips && $addr =~ /$all_ips/) {
   $voted = 1;
}


if($option_selected && !$voted) {


   &FileLock("$lockdir");
   open(MIPS,">>$ips_file");
   print MIPS "$ENV{'REMOTE_ADDR'}\n";
   close(MIPS);
   &FileUnlock("$lockdir");


   open(POPTIONS,"<$poll_options");
   while(<POPTIONS>) {
      ($option_id,$poll_option,$votes_received) = split(/=/,$_);

      if($option_id eq "total") {
         $new_total = $poll_option + 1;
         $push = "total=$new_total\n";
         push(@reprint,$push);
      }      

      else {
     
         if($option_id eq "$option_selected") {
            $new_ototal = $votes_received + 1;
            $push = "$option_id\=$poll_option\=$new_ototal\n";
            push(@reprint,$push);
         }

         else {
            push(@reprint,$_);
         }
      }

   }
   close(POPTIONS);


   &FileLock("$lockdir");
   open(REPRINT,">$poll_options");
   print REPRINT @reprint;
   close(REPRINT);
   &FileUnlock("$lockdir");

   $voted = 1;

   print "Location: $ENV{'HTTP_REFERER'}\n\n";

}



# Print Out SSI Poll Box:
###############################################################

&Template("$data_dir/_ssi_poll.html");

open(POLLINFO,"<$poll_info");
while(<POLLINFO>) {
   chop($_);
   ($pinfo,$pvalue) = split(/=/,$_);
   $$pinfo = "$pvalue";
}
close(POLLINFO);

open(POLLOPTIONS,"<$poll_options");
@unsorted_poll_options = <POLLOPTIONS>;
close(POLLOPTIONS);

foreach$unsorted(@unsorted_poll_options) {
   ($option_id,$poll_option,$votes_received) = split(/=/,$unsorted);
   chop($votes_recieved);

   if($option_id eq "total") {
      $total = $poll_option;
      $show_total = "Total Votes: $total";

   }

   

   $push = "$votes_received\=$option_id\=$poll_option";
   push(@poll_options,$push);
}


# Show Voting Results:
#####################################

if($voted) {

   foreach$p_option(sort { $b <=> $a } @poll_options) {
      ($votes_received,$option_id,$poll_option) = split(/=/,$p_option);


      if($option_id ne "total" && $total > "0") {


         $percent = (int(($votes_received / $total) * 1000)) / 10;
         $percent = substr($percent,0,4);
 
         $sign = "%";

         if($votes_received < 1) {
            $percent = "0";
         }

         $width = int($percent * 1);

         if($votes_received < 1) {
            $width = 2;
         }


         $percent = "$percent$sign";
         $image_percent = "<IMG SRC=\"$image_url\" Height=\"10\" Width=\"$width\">";
         $show_results .= &Cell('poll_results');

      }
   }


   $show_results .= &Cell('total_votes');

   if($show_results_after > $total) {
      undef($show_results);
      $show_results = "$results_not_available";
   }

}



# Show Voting Options:
#####################################

if(!$voted) {

   foreach$p_option(@poll_options) {
      ($votes_received,$option_id,$poll_option) = split(/=/,$p_option);

      if($option_id ne "total") {
         $display_options .= &Cell("show_options");
      }
   }

   if(!$display_options) { $display_options = "$poll_not_available" };

}

if($display_options) { $submit = " <BR> <INPUT Type=SUBMIT Value=\"$vote_text\">" };


open(LASTPOLL,"<$last_file");
@last_poll = <LASTPOLL>;
close(LASTPOLL);

if(@last_poll) {
   $last_poll = "<A HREF=\"$non_SSI_CGI_FileName?load=lastpoll\">$last_poll_text</A><BR>";
}


print &Template("$data_dir/_ssi_poll.html",'html');


# Load Template:                                              #
###############################################################

sub Template {  

  local(*FILE);

  if    ($_[1] eq 'html') { print "Content-type: text/html\n\n"  unless ($ContentType++ > 0); }
  elsif ($_[1] eq 'text') { print "Content-type: text/plain\n\n" unless ($ContentType++ > 0); }

  if    (!$_[0])      { return "<br>\nTemplate : No file was specified<br>\n"; }
  elsif (!-e "$_[0]")      { return "<br>\nTemplate : File '$_[0]' does not exist<br>\n"; }
  else {
    open(FILE, "<$_[0]") || return "<br>\nTemplate : Could open $_[0]<br>\n";
    while (<FILE>) { $FILE .= $_; }
    close(FILE);
    for ($FILE) {
      s/<!-- insert : (.*?) -->/\1/gi;                        # show hidden inserts
      s/<!-- def : (\w+) -->(?:\r\n|\n)?(.*?)<!-- \/def : \1 -->/
      $CELL{$1}=$2;''/ges;                              # read/remove template cells
      s/\$(\w+)\$/${$1}/g;                              # translate $scalars$
      }
    }
  return $FILE;
}


# Translate Cell:                                             #
###############################################################

sub Cell {  

  my($CELL);
  for (0..$#_) { if ($_[$_]) { $CELL .= $CELL{$_[$_]}; }}

  if    (!$_[0]) { return "<br>\nCell : No cell was specified<br>\n"; }
  elsif (!$CELL) { return "<br>\nCell : Cell '$_[0]' is not defined<br>\n"; }
  else             { $CELL =~ s/\$(\w+)\$/${$1}/g; }            # translate $scalars$
 
  return $CELL;

}


# Parse Form:                                                 #
###############################################################
# Usage    : %in = &ReadForm;                                 #
#                                                             #
###############################################################

sub ReadForm {

  my($max) = $_[1];                              # Max Input Size
  my($name,$value,$pair,@pairs,$buffer,%hash);            # localize variables

  # Check input size if max input size is defined
  if ($max && ($ENV{'CONTENT_LENGTH'}||length $ENV{'QUERY_STRING'}) > $max) {
    die("ReadForm : Input exceeds max input limit of $max bytes\n");
    }

  # Read GET or POST form into $buffer
  if    ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
  if    ($ENV{'QUERY_STRING'}) { $buffer .= $ENV{'QUERY_STRING'}; }

  @pairs = split(/&/, $buffer);                        # Split into name/value pairs
  foreach $pair (@pairs) {            

    ($name, $value) = split(/=/, $pair);            # split into $name and $value
    $value =~ tr/+/ /;                              # replace "+" with " "
    $value =~ s/%([A-F0-9]{2})/pack("C", hex($1))/egi;      # replace %hex with char


    $$name = $value;
    }

  return %hash;
  }


# File Locking:                                               #
###############################################################
# Usage    : &FileLock("$lockdir");                           #
#         : &FileUnlock("$lockdir");                         #
#                                                             #
###############################################################

sub FileLock   {
  my($i);                              # sleep counter
  while (!mkdir($_[0],0777)) {                  # if there already is a lock
    sleep 1;                              # sleep for 1 sec and try again
    if (++$i>60) { die("File_Lock : Can't create filelock : $!\n"); }            
    }
  }

sub FileUnlock {
  rmdir($_[0]);                              # remove file lock dir
  }


####################################################################

<--SCRIPT TWO--->

#!/usr/local/bin/perl
####################################################################
# Script:       | Poll It                                          #
# Version:      | 2.0                                              #
# By:           | Jason Berry (i2 Services, Inc. / CGI World)      #
# Contact:      | jason@cgi-world.com                              #
# WWWeb:        | http://www.cgi-world.com                         #
# Copyright:    | Jason Berry (CGI World of i2 Services, Inc.)     #
# Released      | August 09, 1998                                  #
####################################################################
# By using this software, you have agreed to the license           #
# agreement packaged with this program.                            #
#                                                                  #
####################################################################
# Variables:
 #
   #

   $admin_password = "33333333";
   # Password you would like to use for entering the administration
   # area located at:  ScriptName.cgi?load=login


   $image_url = "http://www.positive-word-of-mouth.com/images/image.gif";
   # URL to the 'image.gif' that was packaged with this script. Upload
   # that GIF Image to your website & enter the URL to it above.


   $vote_text = "Rock the Vote!";
   # Text that is shown on the submit button when casting your vote.

   
   # Note:
   ##################################################################
          # If you're looking to use an image in one of the variables
          # below, input the IMAGE tag inside of the quotes as:
          # <IMG SRC=\"image_url.gif\"> <-- Placing backslashes (\)
          # before the extra quotes inside a quote.
          ###########################################################


   $last_poll_text = "<LI>View our Previous Polls Results";
   # Text that is linked to view the previous results of your
   # previous poll.


   $results_not_available = "<BR>The results will be posted soon...";
   # Message shown when the number of votes is not greater then
   # the ammount you opted for when setting up a poll.

   
   $poll_not_available = "<BR>Currently there is no opinion poll available...<P>Check back soon for another poll...";
   # Message listed when a poll is not available.
   #


#
 #
  # (We do not support this script if you edit below this line )
   ################################################################
  #
#

if ($0=~m#^(.*)(\\|/)#)      { $cgidir = $1; }
else { $cgidir = `pwd`; chomp $cgidir; }

$script_url  = $ENV{'SCRIPT_NAME'};
$data_dir = "$cgidir/pollit_files";
$poll_options = "$data_dir/poll_options.txt";
$last_poll_options = "$data_dir/last_poll_options.txt";
$poll_info = "$data_dir/poll_info.txt";
$last_poll_info = "$data_dir/last_poll_info.txt";
$ips_file = "$data_dir/ips.txt";
$last_file = "$data_dir/last_poll.txt";
$lockdir = "$data_dir/filelock";


%in = &ReadForm;


# Administration Area:
###############################################################

   if($admin_password eq "$entered_password") {
   
      print "Content-Type: text/html\n\n";


      # Add New Voting Option:
      #########################################################
 
      if($action eq "add_option" && $add_option) {

         open(COPTIONS,"$poll_options");
         @coptions = <COPTIONS>;
         close(COPTIONS);

         $number_info = pop(@coptions);
         @ninfo = split(/=/,$number_info);
         $new_num = $ninfo[0] + 1;

         open(COPTIONS2,">>$poll_options");
         print COPTIONS2 "$new_num=$add_option=0\n";
         close(COPTIONS2);

      }


      # Expire Poll & Remove Poll:
      #########################################################
 
      if($action eq "expire_poll") {

         &last_poll;
         &remove_poll;

      }


      # Delete Poll:
      #########################################################
 
      if($action eq "delete_poll") {

         &remove_poll;

      }


   
      # New Poll Action:
      ######################################################

      if($new_pollaction && $show_after && $new_title) {

         if($new_pollaction eq "lastpoll") {
            &last_poll;
         }

         &FileLock("$lockdir");
         open(NEWOPTIONS,">$poll_options");
         print NEWOPTIONS "total=0\n";
         $ncount = 1;
         foreach$new_option(@added_options) {
            print NEWOPTIONS "$ncount=$new_option=0\n";
            $ncount++;
         }
         close(NEWOPTIONS);

           
         open(NEWINFO,">$poll_info");
         print NEWINFO "poll_title=$new_title\n";
         print NEWINFO "show_results_after=$show_after\n";
         close(NEWINFO);

         open(NEWIPS,">$ips_file");
         print NEWIPS "";
         close(NEWIPS);


         &FileUnlock("$lockdir");

         undef($action);

      }


      # Create New Poll:
      #########################################################

      if($action eq "create_new") {

         # Create New Poll:
         ######################################################

         &Template("$data_dir/_admin_create_poll.html");

         $remove = join('|',@removes);


         foreach$new_option(sort @added_options) {

            if($new_option !~ /^$remove$/) {
               $show_new_options .= &Cell('poll_options');
            }
         }            

         if($show_new_options) { $show_new_options .= "<P><font size=2 color=red>To remove an added option mark its checkbox <BR>next to it, then press <INPUT Type=SUBMIT Value=\"OK\"> </font>" };

         if(!$show_new_options) { $show_new_options = "<b><font color=red>No NEW Options Currently...</font></b>" };

         print &Template("$data_dir/_admin_create_poll.html");

         exit;

      }



      # Show Main Menu:
      #########################################################

      else {
   
         &Template("$data_dir/_admin_menu.html");

         open(POLLINFO,"<$poll_info");
         while(<POLLINFO>) {
            chop($_);
            ($pinfo,$pvalue) = split(/=/,$_);
            $$pinfo = "$pvalue";
         }
         close(POLLINFO);

         open(POLLOPTIONS,"<$poll_options");
         @unsorted_poll_options = <POLLOPTIONS>;
         close(POLLOPTIONS);

         foreach$unsorted(@unsorted_poll_options) {
            ($option_id,$poll_option,$votes_received) = split(/=/,$unsorted);
            chop($votes_recieved);

            if($option_id eq "total") {
               $total = $poll_option;
            }

            $push = "$votes_received\=$option_id\=$poll_option";
            push(@poll_options,$push);

         }

         foreach$p_option(sort { $b <=> $a } @poll_options) {
            ($votes_received,$option_id,$poll_option) = split(/=/,$p_option);

            if($option_id ne "total" && $total > 0) {


               $percent = (int(($votes_received / $total) * 1000)) / 10;
               $percent = substr($percent,0,4);
 
               $sign = "%";

               if($votes_received < 1) {
                  $percent = "0";
               }

               $width = int($percent * 2);

               if($votes_received < 1) {
                  $width = 2;
               }


               $percent = "$percent$sign";
               $image_percent = "<IMG SRC=\"$image_url\" Height=\"10\" Width=\"$width\">";
               $show_results .= &Cell('poll_results');

            }  
         }

         if(!$show_results) { $show_results = "<b><font color=red>There are currently no results for your current poll</font></b>" };

         if(!$poll_title) { undef($show_results) };

         print &Template("$data_dir/_admin_menu.html");
      }

      exit;


}


# Administration Login:
###############################################################

if($load =~ /login|admin/i || $entered_password && $entered_password ne "$admin_password") {
   
   print "Content-Type: text/html\n\n";

   &Template("$data_dir/_admin_login.html");

   print &Template("$data_dir/_admin_login.html");

   exit;
}


# Show Last Poll Results:
###############################################################

if($load =~ /^lastpoll/i) {
   
   print "Content-Type: text/html\n\n";

   &Template("$data_dir/_last_poll.html");

   open(POLLINFO,"<$last_poll_info");
   while(<POLLINFO>) {
      chop($_);
      ($pinfo,$pvalue) = split(/=/,$_);
      $$pinfo = "$pvalue";
   }
   close(POLLINFO);

   open(POLLOPTIONS,"<$last_poll_options");
   @unsorted_poll_options = <POLLOPTIONS>;
   close(POLLOPTIONS);

   foreach$unsorted(@unsorted_poll_options) {
      ($option_id,$poll_option,$votes_received) = split(/=/,$unsorted);
      chop($votes_recieved);

      if($option_id eq "total") {
         $total = $poll_option;
      }


      $push = "$votes_received\=$option_id\=$poll_option";
      push(@last_poll_options,$push);
   }


   foreach$p_option(sort { $b <=> $a } @last_poll_options) {
      ($votes_received,$option_id,$poll_option) = split(/=/,$p_option);


      if($option_id ne "total" && $total > 1) {


         $percent = (int(($votes_received / $total) * 1000)) / 10;
         $percent = substr($percent,0,4);
 
         $sign = "%";

         if($votes_received < 1) {
            $percent = "0";
         }

         $width = int($percent * 2);

         if($votes_received < 1) {
            $width = 2;
         }


         $percent = "$percent$sign";
         $image_percent = "<IMG SRC=\"$image_url\" Height=\"10\" Width=\"$width\">";
         $show_results .= &Cell('poll_results');

      }
   }

   $show_results .= &Cell('total_votes');


   print &Template("$data_dir/_last_poll.html");




   exit;
}



# Show Poll:
###############################################################

if(!$ENV{'QUERY_STRING'}) {


open(IPS,"<$ips_file");
@ips = <IPS>;
close(IPS);

$all_ips = join('|',@ips);

$addr = "$ENV{'REMOTE_ADDR'}\n";

if(@ips && $addr =~ /$all_ips/) {
   $voted = 1;
}


if($option_selected && !$voted) {


   &FileLock("$lockdir");
   open(MIPS,">>$ips_file");
   print MIPS "$ENV{'REMOTE_ADDR'}\n";
   close(MIPS);
   &FileUnlock("$lockdir");


   open(POPTIONS,"<$poll_options");
   while(<POPTIONS>) {
      ($option_id,$poll_option,$votes_received) = split(/=/,$_);

      if($option_id eq "total") {
         $new_total = $poll_option + 1;
         $push = "total=$new_total\n";
         push(@reprint,$push);
      }      

      else {
     
         if($option_id eq "$option_selected") {
            $new_ototal = $votes_received + 1;
            $push = "$option_id\=$poll_option\=$new_ototal\n";
            push(@reprint,$push);
         }

         else {
            push(@reprint,$_);
         }
      }

   }
   close(POPTIONS);


   &FileLock("$lockdir");
   open(REPRINT,">$poll_options");
   print REPRINT @reprint;
   close(REPRINT);
   &FileUnlock("$lockdir");


   $voted = 1;

}



# Print Out Poll:
###############################################################

&Template("$data_dir/_poll.html");

open(POLLINFO,"<$poll_info");
while(<POLLINFO>) {
   chop($_);
   ($pinfo,$pvalue) = split(/=/,$_);
   $$pinfo = "$pvalue";
}
close(POLLINFO);

open(POLLOPTIONS,"<$poll_options");
@unsorted_poll_options = <POLLOPTIONS>;
close(POLLOPTIONS);

foreach$unsorted(@unsorted_poll_options) {
   ($option_id,$poll_option,$votes_received) = split(/=/,$unsorted);
   chop($votes_recieved);

   if($option_id eq "total") {
      $total = $poll_option;
   }


   $push = "$votes_received\=$option_id\=$poll_option";
   push(@poll_options,$push);
}


# Show Voting Results:
#####################################

if($voted) {

   foreach$p_option(sort { $b <=> $a } @poll_options) {
      ($votes_received,$option_id,$poll_option) = split(/=/,$p_option);


      if($option_id ne "total" && $total > 0) {


         $percent = (int(($votes_received / $total) * 1000)) / 10;
         $percent = substr($percent,0,4);
 
         $sign = "%";

         if($votes_received < 1) {
            $percent = "0";
         }

         $width = int($percent * 2);

         if($votes_received < 1) {
            $width = 2;
         }


         $percent = "$percent$sign";
         $image_percent = "<IMG SRC=\"$image_url\" Height=\"10\" Width=\"$width\">";
         $show_results .= &Cell('poll_results');

      }
   }

   $show_results .= &Cell('total_votes');

   if($show_results_after > $total) {
      undef($show_results);
      $show_results = "$results_not_available";
   }

}



# Show Voting Options:
#####################################

if(!$voted) {

   foreach$p_option(@poll_options) {
      ($votes_received,$option_id,$poll_option) = split(/=/,$p_option);

      if($option_id ne "total") {
         $display_options .= &Cell("show_options");
      }
   }


   if(!$display_options) {

      $display_options = "$poll_not_available" ;
      $poll_title = "No Poll Currently Available...";  
   }
}

if($display_options) { $submit = " <BR> <INPUT Type=SUBMIT Value=\"$vote_text\">" };


open(LASTPOLL,"<$last_poll_options");
@last_poll = <LASTPOLL>;
close(LASTPOLL);

if(@last_poll) {
   $last_poll = "<A HREF=\"$script_url?load=lastpoll\">$last_poll_text</A><BR>";
}



print &Template("$data_dir/_poll.html",'html');

}




# Send Poll to Last Poll:                                     #
###############################################################
# Usage    : &last_poll                                       #
#                                                             #
###############################################################

sub last_poll {

   open(CPOLLOPTIONS,"<$poll_options");
   @cpoptions = <CPOLLOPTIONS>;
   close(CPOLLOPTIONS);

   open(CPOLLINFO,"<$poll_info");
   @cpollinfo = <CPOLLINFO>;
   close(CPOLLOINFO);

   open(LASTPOLLOPTIONS,">$last_poll_options");
   print LASTPOLLOPTIONS @cpoptions;
   close(LASTPOLLOPTIONS);

   $expired_date = localtime();

   open(LASTPOLLINFO,">$last_poll_info");
   print LASTPOLLINFO @cpollinfo;
   print LASTPOLLINFO "expired=$expired_date\n";
   close(LASTPOLLINFO);

}

# Remove Current Poll:                                        #
###############################################################
# Usage    : &remove_poll;                                    #
#                                                             #
###############################################################

sub remove_poll {

   open(POLL,">$poll_options");
   print POLL "";
   close(POLL);

   open(INFO,">$poll_info");
   print INFO "";
   close(INFO);

   open(IPS,">$ips_file");
   print IPS "";
   close(IPS);


}


# Load Template:                                              #
###############################################################

sub Template {  

  local(*FILE);

  if    ($_[1] eq 'html') { print "Content-type: text/html\n\n"  unless ($ContentType++ > 0); }
  elsif ($_[1] eq 'text') { print "Content-type: text/plain\n\n" unless ($ContentType++ > 0); }

  if    (!$_[0])      { return "<br>\nTemplate : No file was specified<br>\n"; }
  elsif (!-e "$_[0]")      { return "<br>\nTemplate : File '$_[0]' does not exist<br>\n"; }
  else {
    open(FILE, "<$_[0]") || return "<br>\nTemplate : Could open $_[0]<br>\n";
    while (<FILE>) { $FILE .= $_; }
    close(FILE);
    for ($FILE) {
      s/<!-- insert : (.*?) -->/\1/gi;                        # show hidden inserts
      s/<!-- def : (\w+) -->(?:\r\n|\n)?(.*?)<!-- \/def : \1 -->/
      $CELL{$1}=$2;''/ges;                              # read/remove template cells
      s/\$(\w+)\$/${$1}/g;                              # translate $scalars$
      }
    }
  return $FILE;
}


# Translate Cell:                                             #
###############################################################

sub Cell {  

  my($CELL);
  for (0..$#_) { if ($_[$_]) { $CELL .= $CELL{$_[$_]}; }}

  if    (!$_[0]) { return "<br>\nCell : No cell was specified<br>\n"; }
  elsif (!$CELL) { return "<br>\nCell : Cell '$_[0]' is not defined<br>\n"; }
  else             { $CELL =~ s/\$(\w+)\$/${$1}/g; }            # translate $scalars$
 
  return $CELL;

}


# Parse Form:                                                 #
###############################################################
# Usage    : %in = &ReadForm;                                 #
#                                                             #
###############################################################

sub ReadForm {

  my($max) = $_[1];                              # Max Input Size
  my($name,$value,$pair,@pairs,$buffer,%hash);            # localize variables

  # Check input size if max input size is defined
  if ($max && ($ENV{'CONTENT_LENGTH'}||length $ENV{'QUERY_STRING'}) > $max) {
    die("ReadForm : Input exceeds max input limit of $max bytes\n");
    }

  # Read GET or POST form into $buffer
  if    ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
  elsif ($ENV{'REQUEST_METHOD'} eq 'GET')  { $buffer = $ENV{'QUERY_STRING'}; }

  @pairs = split(/&/, $buffer);                        # Split into name/value pairs
  foreach $pair (@pairs) {            

    ($name, $value) = split(/=/, $pair);            # split into $name and $value
    $value =~ tr/+/ /;                              # replace "+" with " "
    $value =~ s/%([A-F0-9]{2})/pack("C", hex($1))/egi;      # replace %hex with char

    if($name eq "add_option" && $value) {
       push(@added_options,$value);
    }

    if($name eq "remove_new") {
       push(@removes,$value);
    }

    $$name = $value;
    }

  return %hash;

  }


# File Locking:                                               #
###############################################################
# Usage    : &FileLock("$lockdir");                           #
#         : &FileUnlock("$lockdir");                         #
#                                                             #
###############################################################

sub FileLock   {
  my($i);                              # sleep counter
  while (!mkdir($_[0],0777)) {                  # if there already is a lock
    sleep 1;                              # sleep for 1 sec and try again
    if (++$i>60) { die("File_Lock : Can't create filelock : $!\n"); }            
    }
  }

sub FileUnlock {
  rmdir($_[0]);                              # remove file lock dir
  }


####################################################################

<--HTML-->

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
test <!--#exec cgi ="/u156/pwom/cgi-bin/pollit/Poll_It_SSI_v2.0.cgi" -->
</body>
</html>






0
Comment
Question by:aprillougheed
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
djsansui earned 500 total points
ID: 2665917
Try these:

<!--#include virtual="/cgi-bin/pollit/Poll_It_v2.0.cgi" -->
<!--#exec cmd="./u156/pwom/cgi-bin/pollit/Poll_It_SSI_v2.0.cgi" -->
0
 
LVL 2

Expert Comment

by:djsansui
ID: 2665922
That error you recieved is not caused by a problem with the script since it runs fine directly, it is a problem with the way you call it with the SSI.

Above I gave you two ways to fix it.  Depending on your server setup, at least one will work, but both usually will.  Please leave a comment if you have any further questions, I'll be happy to help you out.
0
 

Author Comment

by:aprillougheed
ID: 2684803
The only comment I have is that I don't think I received and E-mail that this question had been answered.  Luckily, I checked back.  Everything is working fine now.  Thanks so much.  April guider@guider.com
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now