Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,661 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,179 people online right now. Registration is fast and FREE... Join Now!




Pulling PHP from MySQL

 
Reply to this topicStart new topic

Pulling PHP from MySQL, Getting the PHP to be interpreted

jbeall
post 26 Nov, 2002 - 09:07 AM
Post #1


New D.I.C Head

*
Joined: 1 Oct, 2002
Posts: 42

Greetings,

I'm trying to develop a page content wizard, as follows - I have divided up every page into four sections: header, navbar, content area, and footer. Everything except the content area is the same on every page of the site; I simply require the header, navbar, and footer at the appropriate place on each page.

Now I want to pull the content information for each page out of a MySQL database. This allows me to easily design wizards that allow users to edit the content area of any page. Here's my question, though - what if I want to let my users include PHP code in the content areas? Is there a way to do that? I can't just echo the string to the browser, because it won't be interpreted by mod_php, it will just get echoed as a text string.

I've thought of writing the content area information to a temporary file, then requiring the temporary file, but that seems cumbersome, and you have to worry about filelocking, and purging old files, etc - can anyone think of another way to do this! Many thanks for any auggestions!

-Josh
User is offlineProfile CardPM

Go to the top of the page

The Neoracle
post 26 Nov, 2002 - 10:00 AM
Post #2


Check, check, 1, 2.

Group Icon
Joined: 30 Mar, 2001
Posts: 4,069



Thanked 1 times
My Contributions


You could have them put in tags like this: [php]echo(their code)[/php] and then do a string replace and repace them with " and then they wouldn't be counted as a string.


(you do realize that it is like beyond unsecure to let your users do this right? What are you gonna do if they put php in that drops your DB? or a forever loop that brings the server down every time the page is called?)
User is offlineProfile CardPM

Go to the top of the page

fyrestorm
post 26 Nov, 2002 - 10:26 AM
Post #3


D.I.C Lover

Group Icon
Joined: 4 Apr, 2002
Posts: 3,103



Thanked 2 times

Dream Kudos: 228
My Contributions


yes, what you are proposing is a very bad idea...

in fact letting the users do anything to the content on your page besides letting them add strings is bad...
User is offlineProfile CardPM

Go to the top of the page

jbeall
post 28 Nov, 2002 - 07:10 PM
Post #4


New D.I.C Head

*
Joined: 1 Oct, 2002
Posts: 42

I realized the security implications. However, this is not something I am letting just any joe log onto - I hope to use it to speed internal development. Anybody using this already knows and codes PHP write onto the webserver, and this is just to help speed things up a bit and make it simpler. At any rate, I realized that I could simply use the eval() function to do what I needed. I come from C++ land, and I'm still not totally familiar with the PHP function library. Thanks for your thoughts.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 05:39AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month