Forum Moderators: coopster

Message Too Old, No Replies

Server side includes with PHP.

Php includes

         

anyoldcard

3:25 am on Mar 1, 2006 (gmt 0)

10+ Year Member



In cPanel they have a banner script called entropybanner.cgi
This is the command line to put it on an .shtml page:

<!--#exec cmd="cgi-bin/entropybanner.cgi"-->

I want the banners to appear at the top of an SMF forum and I have tried different ways, none of which worked.

include 'entropybanner.cgi';
include 'cgi-bin/entropybanner.cgi';

Here is the area where the banner code should go.

<td valign="bottom" align="left" style="padding-top: 6px;"><img src="' ,$settings['images_url'], '/logo5a.gif" /> </td>';
echo ' <td valign="bottom" align="right">';
include ' cgi-bin/entropybanner.cgi';
echo ' </td></tr></table>';

I'm a novice so it may be something real simple.
Thanks for any help,
Ron.

Birdman

9:38 pm on Mar 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmaster World!

This may work for you:

echo ' <td valign="bottom" align="right">';
virtual("/cgi-bin/entropybanner");
echo ' </td></tr></table>';

I haven't done it myself, but it appears to be a solution.

anyoldcard

12:05 am on Mar 2, 2006 (gmt 0)

10+ Year Member



It returned this error:

Fatal error: Call to undefined function virtual() in /home/pkclary/public_html/pkczone/Sources/Load.php(1607) : eval()'d code on line 167

coopster

1:14 am on Mar 2, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The virtual function is only supported when PHP is installed as an Apache module. If you are on a shared host you must be running as CGI.

There are other ways to get that value though. You may still be able to use include [php.net] with the full 'http://example.com/cgi-bin/my-cgi-script.cgi' path.

Anyango

4:00 am on Mar 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you want Output HTML of that code to be included or Code be included?

anyoldcard

8:42 am on Mar 3, 2006 (gmt 0)

10+ Year Member



Its a banner code and displays a banner at the top of the page. The page is an index.template.php and there is also an index.php. It would probably work if put in either file. I give up at another forum after trying a combination of entries including the full path which none of worked.

I did not think the virtual would work but at this point I am willing to try most anything. It's just a simple entropybanner.cgi code that displays a banner at the top of the page so I don't get it.

Anyango

1:58 pm on Mar 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Then try Coopster's tip. that would work perfect i guess.

include your file as

[yourwebsite.com...]

if if in any case, that doesnt do as expected then try this.

ob_start();
include "http://yourwebsite.com/cgi-bin/yourscript.cgi";
$data=ob_get_contents();
ob_clean();
echo $data;

what that will do is, it will call your CGI script as browser request, will grab output from it and save in variable $data. then you can echo that $data anywhere in your code, and that for sure will be the output of your cgi script ;)