Reply
SSI in SSI?
Old 07-04-2002, 12:58 AM SSI in SSI?
X-Ray5's Avatar
Novice Talker

Posts: 8
Location: RI
Hey all, I need some help here. I have SSI on all my pages I sue if for my navigation on my pages. But I have a problem on the right side of my site in the SSI I'm trying to use a poll script with in that SSI so its a web page that calls *.txt and then the *.txt calls a *.cgi (my poll script) but the *.cgi (poll script) does not work, it will only work if I call if from a reg. html or shtml doc. Why is this and how can I fix this. I did a little editing to my htaccess here is what I did....

Code:
Options Indexes FollowSymLinks Includes
AddType text/x-server-parsed-html .html
AddType text/x-server-parsed-html .txt (I added this)
AddType text/x-server-parsed-html .shtml (I added this)
AddType text/x-server-parsed-html .htm (I added this)
AddType application/x-httpd-cgi .cgi
Please help me out my site is www.lemonbrain.com chk it out
X-Ray5 is offline
Reply With Quote
View Public Profile Visit X-Ray5's homepage!
 
When You Register, These Ads Go Away!
     
Old 07-04-2002, 03:24 AM
AhmedF's Avatar
Left for Better Places

Posts: 258
From the tech docs, if I remember right, you cannot SSI in an SSI call.

Server will only parse it once, not recurringly.

Last edited by AhmedF : 07-04-2002 at 10:20 AM.
AhmedF is offline
Reply With Quote
View Public Profile
 
Old 07-04-2002, 10:01 AM
Junior Talker

Posts: 2
Plus anyway, why would the the cgi script that you calling in SSI execute a CGI script inside of it... it makes no sense, simply create a fuction like



sub pulldisplay{



Whatever cgi in that file ( dont copy all of it such as the #!/local/

etc crap


}


Then on the page where you want it go like &pollydisplay;


I serioulsy doubt unless you know what your doing you'll get what I am trying to say.

I tried
Billabong089 is offline
Reply With Quote
View Public Profile
 
Old 07-04-2002, 10:47 AM I Tryed
X-Ray5's Avatar
Novice Talker

Posts: 8
Location: RI
I tryed
Code:
<!--#exec cgi="cgi-bin/poll/poll_ssi.cgi" -->
But it did not work and i did not even get an error, so i tryed this and it did work
Code:
<!--#include virtual="cgi-bin/poll/poll_ssi.cgi" -->
Did work but both of these did not work with-in a SSI
X-Ray5 is offline
Reply With Quote
View Public Profile Visit X-Ray5's homepage!
 
Old 07-04-2002, 10:52 AM
X-Ray5's Avatar
Novice Talker

Posts: 8
Location: RI
Quote:
Originally posted by Billabong089
Plus anyway, why would the the cgi script that you calling in SSI execute a CGI script inside of it... it makes no sense, simply create a fuction like



sub pulldisplay{



Whatever cgi in that file ( dont copy all of it such as the #!/local/

etc crap


}


Then on the page where you want it go like &pollydisplay;


I serioulsy doubt unless you know what your doing you'll get what I am trying to say.

I tried
So should I try this.....

Code:
sub pulldisplay{
# Variables: 

   $image_url = "http://www.lemonbrain.com/images/image.gif";
   $vote_text = "Rock the Vote!";

   # Notes:
   $last_poll_text = "<LI>our Previous Polls Results";
   $results_not_available = "<BR>The results will be posted soon...";
   $poll_not_available = "<BR>Currently there is no opinion poll available...<P>Check back soon for another poll...";
   $non_SSI_CGI_FileName = "poll_ssi.cgi";

%in = &ReadForm;

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";

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:                                                 #

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:                                               #
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
  }

}
X-Ray5 is offline
Reply With Quote
View Public Profile Visit X-Ray5's homepage!
 
Old 07-04-2002, 06:43 PM
Junior Talker

Posts: 2
should work
Billabong089 is offline
Reply With Quote
View Public Profile
 
Old 07-04-2002, 07:38 PM It dosent
X-Ray5's Avatar
Novice Talker

Posts: 8
Location: RI
But it dosent, there is no way to put an ssi in an ssi? why is this can i edit my htaccess to some how enable it?
X-Ray5 is offline
Reply With Quote
View Public Profile Visit X-Ray5's homepage!
 
Old 07-04-2002, 07:47 PM
Perfecthost's Avatar
Skilled Talker

Posts: 91
Location: a galaxy far, far away
Just a couple of ideas:

When using
Code:
<!--#exec cgi="cgi-bin/poll/poll_ssi.cgi" -->
be sure there is no space between <!-- and #exec .

Next, check your permissions. poll_ssi.cgi should have chmod to 755 .

-Lamar
__________________
You demand perfection; we strive for it!
Perfecthost
Perfecthost is offline
Reply With Quote
View Public Profile Visit Perfecthost's homepage!
 
Old 07-04-2002, 10:25 PM a space where?
X-Ray5's Avatar
Novice Talker

Posts: 8
Location: RI
Where do I put the space? I don't get it please show the hole code to include it, with the space and stuff. Thanks
X-Ray5 is offline
Reply With Quote
View Public Profile Visit X-Ray5's homepage!
 
Old 07-04-2002, 11:18 PM
Perfecthost's Avatar
Skilled Talker

Posts: 91
Location: a galaxy far, far away
No. Be sure there is no space between <!-- and #exec
Code:
<!--#exec cgi="cgi-bin/poll/poll_ssi.cgi" -->
   ^ NO space where the arrow is pointing
__________________
You demand perfection; we strive for it!
Perfecthost

Last edited by Perfecthost : 07-04-2002 at 11:20 PM.
Perfecthost is offline
Reply With Quote
View Public Profile Visit Perfecthost's homepage!
 
Old 07-05-2002, 10:27 AM MO :(
X-Ray5's Avatar
Novice Talker

Posts: 8
Location: RI
Nope it does not work, I don't even get an error message the only thing that can include my cgi script is this....

<!--#include virtual="cgi-bin/poll/poll_ssi.cgi" -->

the exec one does nothing? I can't figure it out does any one know if what I'm trying to do is even possible?
X-Ray5 is offline
Reply With Quote
View Public Profile Visit X-Ray5's homepage!
 
Old 07-25-2002, 10:04 PM
webbuilder's Avatar
Average Talker

Posts: 15
Location: Malaysia
well you could read the second include file from the first one and execute it from the first one.
__________________
The WebBuilder
webbuilder is offline
Reply With Quote
View Public Profile Visit webbuilder's homepage!
 
Reply     « Reply to SSI in SSI?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.65072 seconds with 13 queries