execute php code in html nugget ?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
pidee
Regular
Posts: 9
Joined: Thu Aug 31, 2006 11:06 am

execute php code in html nugget ?

Post by pidee »

hi,

how can php be executed in a html-nugget ?

i'm trying to echo a "simple text" as a test

<?php echo "simple text"; ?>
echo "simple text";
{php}echo "simple text";{/php}

neither one does the trick...


tia,

p.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: execute php code in html nugget ?

Post by garvinhicking »

Hi!

PHP-Code cannot be executed there as it would impose a huge security risk. You should build your own plugins, or use the "Include PHP script / External Code" sidebar nugget, where you can specify an external PHP script.

Or you search this forum for the php nugget. But it is not recommended.

The other option is to install the smartymarkup plugin, then you can use thise {php} markup in your nugget. But only if you also disable the smarty security setting in include/functions_smarty.inc.php or your templates config.inc.php via $serendipity['smarty']->security = false;

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
pidee
Regular
Posts: 9
Joined: Thu Aug 31, 2006 11:06 am

Re: execute php code in html nugget ?

Post by pidee »

garvinhicking wrote:Hi!

or use the "Include PHP script / External Code" sidebar nugget, where you can specify an external PHP script.

thanks Garvin but where do i find that script... i dont find it on the s9y site, and i dont find it on sourceforge...


p.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: execute php code in html nugget ?

Post by garvinhicking »

Hi!
thanks Garvin but where do i find that script... i dont find it on the s9y site, and i dont find it on sourceforge...
You can find it here on the forums. I can'T say much more, because I really don't advocate its use.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
pidee
Regular
Posts: 9
Joined: Thu Aug 31, 2006 11:06 am

Post by pidee »

i dont understand that smarty thingie... so i am limited to using that external code script...
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Yeah, but that's quite easy. Just upload your PHP script and include it. :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
pidee
Regular
Posts: 9
Joined: Thu Aug 31, 2006 11:06 am

Post by pidee »

can someoneplease point me to that plugin cause in dont seem to be able to find it on this site...

...

p.
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

I don't advocate its use either.

http://www.s9y.org/forums/viewtopic.php?t=148
pidee
Regular
Posts: 9
Joined: Thu Aug 31, 2006 11:06 am

Post by pidee »

ok, i know eval is supposed to be avoided...
so i'm willing to give it a go at writing my own SIMPLE plugin..

lets take the code mentioned in the post above and lets say i just want to do a echo can i then change this code :

Code: Select all

function generate_content(&$title, $output = true)
    {
        $title = $this->get_config('title', $title);
        if ($output) eval($this->get_config('content'));
    } 
into this :

Code: Select all

 function generate_content(&$title, $output = true)
    {
        $title = $this->get_config('title', $title);
        echo "this is a test";
    }

... i guess not, because it isnt working...

any thaughts or pointers ?[/quote]
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Yes, you can. What is not working? How does your full plugin look like? You did install the plugin through the interface, right? Without installing a plugin, nothing will happen?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
pidee
Regular
Posts: 9
Joined: Thu Aug 31, 2006 11:06 am

Post by pidee »

garvinhicking wrote:Hi!

Yes, you can. What is not working? How does your full plugin look like? You did install the plugin through the interface, right? Without installing a plugin, nothing will happen?

Regards,
Garvin
i just took the file mgroeninger linked me to, and changed 1 line as I posted...

in fact all i want is to be able to include my own log.php file... so i can count visitors...

i'm sure someone (smarter then me) must have done this before ?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

So you installed the plugin and have it in your plugin configuration panel as a sidebar item? And on your frontpage, it does not display anything? Try to put a "return true;" inside the generate_content() method?

Please paste your full current plugin file, then I can tell you what's wrong. You are definitely on the right path, it must be a minor issue.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
pidee
Regular
Posts: 9
Joined: Thu Aug 31, 2006 11:06 am

Post by pidee »

ah, never mind, i give up.

anyway, thanks for your time

p.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Okay, I'm sorry. Luck will come to those who wait. :)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply