P
P E Schoen
I was able to run a single PHP script from Perl by using
print '<html><body><iframe src="HTMLfilter.php"></iframe></body></html>' .
"\n";
But when I set up a loop to apply it to all the CGI Input variables, it
seemed that the PHP script ran after the Perl script had finished, and it
only acted on the last environment variable. I also tried using <script
language="text/php" src="HTMLfilter.php"> but no joy.
The loop is as follows:
my %in = Vars(); # Get the CGI input variables
while ( (my $key, my $value) = each (%in) ) {
# Write to Raw.htm
print fLog "Raw: $key -> $in{$key}\n";
open (fHTMLraw, '>', $HTMLrawfile)
or HTMLdie ("File error: $!");
print fHTMLraw $value;
close fHTMLraw;
print '<html><body><iframe src="HTMLfilter.php"></iframe></body></html>'
.. "\n";
# sleep(1);
if (-e $HTMLpurefile){
open (fHTMLpure, '<', $HTMLpurefile);
$in{$key} = <fHTMLpure>;
close fHTMLpure; }
else {
$in{$key} = 'Purifier error';
print fLog "Purifier error"; }
print fLog "Pure: $key -> $in{$key}\n";
# sleep(1);
}
I had used the sleep() but it just delayed the script and the iframes
appeared after the script had finished.
I found this article about using the PHP::Interpreter module:
http://www.linuxjournal.com/article/9282
I was able to download and unzip the package but I was unable to install it
using ppm install PHP::Interpreter. The article was aimed at Linux and I'm
not sure if it applies to Win7. I would like to be able to use the PHP
HTMLpurifier rather than the Perl equivalent if possible.
Another option may be to assemble the various inputs into a single HTML
document and then run it through the purifier. The problem is that I am
storing the input variables in a database, although I could just use an
autoincrement ID and a DateTime for indexing, and combine the other
variables into a single field with the complete HTML. But that would not
lend itself to changing the appearance of the HTML page for display of all
the data.
It would probably be OK to use the "Declaw" and "Defang" utilities to clean
up the raw entries, and then run the final rendered HTML through the PHP
purifier to catch anything missed.
Thanks,
Paul
print '<html><body><iframe src="HTMLfilter.php"></iframe></body></html>' .
"\n";
But when I set up a loop to apply it to all the CGI Input variables, it
seemed that the PHP script ran after the Perl script had finished, and it
only acted on the last environment variable. I also tried using <script
language="text/php" src="HTMLfilter.php"> but no joy.
The loop is as follows:
my %in = Vars(); # Get the CGI input variables
while ( (my $key, my $value) = each (%in) ) {
# Write to Raw.htm
print fLog "Raw: $key -> $in{$key}\n";
open (fHTMLraw, '>', $HTMLrawfile)
or HTMLdie ("File error: $!");
print fHTMLraw $value;
close fHTMLraw;
print '<html><body><iframe src="HTMLfilter.php"></iframe></body></html>'
.. "\n";
# sleep(1);
if (-e $HTMLpurefile){
open (fHTMLpure, '<', $HTMLpurefile);
$in{$key} = <fHTMLpure>;
close fHTMLpure; }
else {
$in{$key} = 'Purifier error';
print fLog "Purifier error"; }
print fLog "Pure: $key -> $in{$key}\n";
# sleep(1);
}
I had used the sleep() but it just delayed the script and the iframes
appeared after the script had finished.
I found this article about using the PHP::Interpreter module:
http://www.linuxjournal.com/article/9282
I was able to download and unzip the package but I was unable to install it
using ppm install PHP::Interpreter. The article was aimed at Linux and I'm
not sure if it applies to Win7. I would like to be able to use the PHP
HTMLpurifier rather than the Perl equivalent if possible.
Another option may be to assemble the various inputs into a single HTML
document and then run it through the purifier. The problem is that I am
storing the input variables in a database, although I could just use an
autoincrement ID and a DateTime for indexing, and combine the other
variables into a single field with the complete HTML. But that would not
lend itself to changing the appearance of the HTML page for display of all
the data.
It would probably be OK to use the "Declaw" and "Defang" utilities to clean
up the raw entries, and then run the final rendered HTML through the PHP
purifier to catch anything missed.
Thanks,
Paul