• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

a good challenge for u php freaks, I mean masta's

Weapon

NLC
NLC
convert this cgi image script to php

#!/usr/local/bin/perl

$headfile = ' ';

$footfile = ' ';

$File = $ENV{'QUERY_STRING'};


unless (open (DATA,"$headfile")) {die (&error);}
if ($uselock eq '1') {
flock DATA, 2;
seek DATA, 0, 0;
}
@headinfo = <DATA>;
if ($uselock eq '1') {
flock DATA, 8;
}
close (DATA);
foreach $headline (@headinfo){
$heading = $heading.$headline;
}


unless (open (DATA,"$footfile")) {die (&error);}
if ($uselock eq '1') {
flock DATA, 2;
seek DATA, 0, 0;
}
@footinfo = <DATA>;
if ($uselock eq '1') {
flock DATA, 8;
}
close (DATA);
foreach $footline (@footinfo){
$footer = $footer.$footline;
}


print "Content-type:text/html\n\n";
print "$heading";
print "<CENTER><IMG SRC=\"$File\"></CENTER>";
print "$footer";


:bandit2:
 
its an image posting script, where instead of making a html page for each image it grabs a header and then a footer file
 
That is utterly complicated for a script that only does that.

If you know what you're doing, this is good enough:

Code:
#!/usr/bin/perl

print "Content-type: text/html\n\n";
$headfile = ' ';  # insert filename
$footfile = ' ';  # insert filename

$File = $ENV{'QUERY_STRING'}; 
if (-e $headfile && -e $footfile){
open (HEADER, $headfile);
open (FOOTER, $footfile);
print <HEADER>;
close (HEADER);
print "<img src=\"$File\">";
print <FOOTER>;
close (FOOTER);
} else {
print "Error.\n";
}

PHP Version:
PHP:
<? 
$headfile='';
$footfile='';
include ("$headfile");
echo ("<img src\"$QUERY_STRING\">");
include ("$footfile");
?>
 
Weepsie-poopoo, I'm saying there's no sh, but there's shi. :classic2:
 
Hey hayama, there is now QUERY_STRING func. in php...
maybe you can try this :

PHP:
<? 
$headfile='';
$footfile='';
include ("$headfile");
print '<img src='.$img.'>';
include ("$footfile");
?>
and to display some image, you need to do this...
bla.php?img=image.gif
 
I was using the original script, so I used $QUERY_STRING (as in $ENV{'QUERY_STRING'}) in Perl.
 
well of course there is no query string "function," and if your php config is fully optimized like mine there is no $QUERY_STRING variable either... best to use getenv()... and readfile() is more efficient than include() (and closer to what the original perl script does)...


PHP:
<?readfile('')?><img src="<?=getenv('QUERY_STRING')?>"><?readfile('')?>
 
sorry for bringing an old thread up, but how do I specify a image size for the image? ( eg, width=, height= )
 
add these var to your page :
PHP:
$height = "50";
$width = "10";

and add theme !
PHP:
<?readfile('')?><img src="<?=getenv('QUERY_STRING')?>" width="<?=width?>" height="<?=height?>"><?readfile('')?>

thats all
 
Back
Top