FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » execute php in template
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: execute php in template [message #175777 is a reply to message #175774] Sun, 23 October 2011 23:38 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 10/23/2011 6:43 PM, cerr wrote:
> On Oct 23, 2:03 pm, The Natural Philosopher<t...@invalid.invalid>
> wrote:
>> cerr wrote:
>>> hi There,
>>
>>> I have a page that i assemble with a graphics template and a content
>>> file in my index.php. Kinda like:
>>> <?
>>> $template = file_get_contents($tmpl_path);
>>> $content = file_get_contents($cont_path);
>>> and in template, there's a marker where to insert the content:
>>> $page = str_replace("[CONTENT]",$content,$template);
>>> echo $page.
>>
>>> This works well so far, but if I wanna use php in my template, it
>>> doesn't get executed by file_get_contents(). How can I load this file
>>> and execute php within it? Also, I would like to reuse ($_GET)
>>> variables i have in index.php. Do I need to forward them to my
>>> template by a regular get url or will i just be able to reuse the
>>> variables straight?
>>> Thanks for help in this matter!
>>
>> try
>> include("/path/to/my_template");
>>
>
> Thanks to both for the replies, I have not tried exec or passthru but
> include e.g. won't return me anything, it'll just execute the template
> right there instead of returning me a string that i'll be able to
> modify (to insert the content)...
>

You can buffer the content. See ob_start(), ob_end_clean(), etc.

>> what if someone snuck into
>> your code something like:
>> system('rm -r /');
>
> How would someone be able to do that? From the "outside" there's no
> access to do this, right?
>
> Thanks,
> Ron

Are you sure? Sony thought so...

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Using PHP Tags in eval()
Next Topic: pear include path
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 07:35:02 GMT 2024

Total time taken to generate the page: 0.04266 seconds