Forum Moderators: coopster
Ok, here's the scoop,
The site uses php imbedded in html so I use this code in the htaccess: AddHandler application/x-httpd-php .html .htm
I then place an include on the page where needed like this:
<script language="php"> virtual("/cgi-bin/widgets.pl"); </script>
This worked perfect on the old server, but not on the new server. The new hosting provider gave this help:
###START MESSAGE###
"Unfortunately, as it turns out, the virtual() function is unavailable on a server configured with PHPSuExec. This means that this bit of code:
<script language="php"> virtual("/cgi-bin/widgets.pl"); </script>
must be turned into this:
putenv('REQUEST_METHOD=GET'); putenv('QUERY_STRING=arg=value');
passthru("/cgi-bin/widgets.pl");
in order to maintain the security of the site and to also enable the script to function correctly."
###END MESSAGE###
I inserted this code but it still doesn't work. It does call the file that the pl file prints(hope that's the right term), which is a random line from a simple txt file, but this is what shows in place of the actual content:
Content-type: text/plain
Just to be clear what the pl file looks like and does, here it is:
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
$WidgetDelimiter = "\\(1\\)";
$WidgetFile = "data/somepage.txt";
open(WIDGET, "$WidgetFile") ¦¦
die "Cannot open $WidgetFile\n";
@widget = <WIDGET>;
$bigdata = join("",@widget);
@widget = split(/$WidgetDelimiter/,$bigdata);
#@widget = split(/\(1\)/,$bigdata);
$WidgetCount= @widget;
srand();
$WidgetIndex = int(rand($WidgetCount));
print "$widget[$WidgetIndex]";
The txt file is nothing but sentences separated by the delimiter (1) as shown in the above pl file.
Like I said, it has worked with no problems for nearly a year on the old server but not at all on the new.
Is the code from the new hosting provider correct or is it missing something? Personally I've never seen this before and if anyone has any input, please give it.
<script language="php"> virtual("/cgi-bin/widgets.pl"); </script>
<?php include("/cgi-bin/widgets.pl");?>
OR
<?php require("/cgi-bin/widgets.pl");?>
Assuming this is still a valid path with your new host.
Habtom
To my limited knowledge, it must call the script to run, not print it on the page. A staight include such as <?php include("cgi-bin/widgets.pl");?> tries to print the contents of the pl file on the page and not run the script, at least this is how it appears to be happening.
The site has other includes like this <script language="php"> include("footer.html") </script> that are working fine, but they don't have to do anything. It seems to be this one type of script that actually does something that is not functioning.
that is why your footer.html URL is working okay -- because that is a relative path.