Gossamer Forum
Home : Products : Gossamer Links : Discussions :

hiding php from cgi (perl)

Quote Reply
hiding php from cgi (perl)
I have a some php code that is in one the left side bar include on my site. Everything works fine except on the cgi perl pages like the login or search programs.

Is there some way to hide the php code from those perl pages? Or is there some other solution for this?

thanks,
real3444
Quote Reply
Re: [real3444] hiding php from cgi (perl) In reply to
You can't do that =)

What you need, is a global to run the PHP "script"

For example, make a new .php script - and then add a new global, called "run_php", with this code:

Code:
sub {
return `php $_[0]`;
}

..and then call with this in your template:

Code:
<%run_php("/path/to/your/script.php")%>

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] hiding php from cgi (perl) In reply to
Andy,

Thanks for the help. I was not able to get that to work. I wonder if the path could be the issue. Is this supposed to a relative path or a full path?

thanks,
Kevin
Quote Reply
Re: [real3444] hiding php from cgi (perl) In reply to
Full path =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] hiding php from cgi (perl) In reply to
Great thread and a great reply.

I'd been trying to avoid calling php scripts to my sidebar because of the 'static verses cgi' page display issue. Thanks for this.

Smile
Quote Reply
Re: [MJB] hiding php from cgi (perl) In reply to
Just found a slight downside to this. It doesn't work with dynamic content on static pages.

I have a live counter that works fine on static pages with regular php code but with the global in use it doesn't, but it does on the cgi pages.

So I guess that this global is great for relatively static data but not for dynamic data.
Quote Reply
Re: [MJB] hiding php from cgi (perl) In reply to
Hi,

Give this a go:

check_if_is_script
Code:
sub {
$ENV{SCRIPT_NAME} ? return { is_script => 1 } : return { is_script => 0 };
}

Then, instead of just using:

Code:
<%run_php("/path/to/your/script.php")%>

Try using:

Code:
<%check_if_is_script%>
<%if is_script%>
<%run_php("/path/to/your/script.php")%>
<%else%>
..show your normal PHP code here
<%endif%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Mar 3, 2009, 2:45 AM
Quote Reply
Re: [Andy] hiding php from cgi (perl) In reply to
No that doesn't work. Returns:
Quote:
Unable to compile 'check_if_is_script': Can't modify constant item in scalar assignment at (eval 44) line 2, at EOF
plus the standard php output on the static pages and:
Quote:
Unable to compile 'check_if_is_script': Can't modify constant item in scalar assignment at (eval 20) line 2, at EOF
on the cgi page.
Quote Reply
Re: [MJB] hiding php from cgi (perl) In reply to
Sorry, please change:

Code:
$ENV{SCRIPT_NAME} ? return { is_script = 1 } : return { is_script = 0 };

..to:

Code:
$ENV{SCRIPT_NAME} ? return { is_script => 1 } : return { is_script => 0 };

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] hiding php from cgi (perl) In reply to
Now it displays:
Quote:
$ENV{SCRIPT_NAME} ? return { is_script => 1 } : return { is_script => 0 };
Quote Reply
Re: [MJB] hiding php from cgi (perl) In reply to
Hang on a minute, I've missed something out. Will return in a sec.
Quote Reply
Re: [MJB] hiding php from cgi (perl) In reply to
MJB wrote:
Hang on a minute, I've missed something out. Will return in a sec.

LOL ya, you still need sub {} around that line =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [MJB] hiding php from cgi (perl) In reply to
Yes, that's sorted it out.

I have replaced your original code but accidental deleted the sub { and } parts. [oops!]

Works a treat. Thanks for your input Andy. ;)
Quote Reply
Re: [MJB] hiding php from cgi (perl) In reply to
Hi,

NP, glad its ok now =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Post deleted by MJB In reply to

Last edited by:

MJB: Mar 28, 2009, 2:09 AM