Jump to content

Recommended Posts

Hi all, not sure if this is posible, but..

 

I've recently been taking a large website, and putting the page content into a mysql database so it can be worked on in a CMS.

 

However, some of the pages have PHP scripts within the content on the page - (mainly php includes). So, when I run my template, and load the page content out of the database and write it  back on to the page, php just reads the info from the field and writes it onto the page, but of course, it doesn't execute the php script.

 

Does anyone know any way around this? maybe getting php to check through the data and run any commands it finds?

 

Thanks

The C in CMS stands for Content, not Code. As a general rule, code should not be stored in with content as that opens up a huge window for abuse (a hacker just needs to get his php code into your content in order to take over your site.)

 

You should not store php code in your content and if you do find that you need to do something like put logic into your content, you should be using a template system, instead of directly executing content/code in a string using an eval() statement, so that you will have control over what exactly can be put into it.

hmm, I understand the theory of not putting code in the database. However, I'll give you an example of why I might need to.

 

The CMS stores the html for area on the page (within a template). Some of these areas include a PHP script like  <? include 'video.php'; ?> which should bring in a file with a video player in it. Having the video.php file as an include file make sense, as it's used many times.

 

To avoid having the code in the database, i would have to write the entire content of the video.php file into all the places it is used - losing the ability to update it quickly. Unless anyone has any suggestions on how to do the equivilent of an include but not using PHP?  (Server side includes don't seem to work on a php file)

 

I know it all sounds very muddled, but i'm updating an old website,  - if I was building from fresh it's not how i'd do it!

Use an include to include video.php in your other templates.

And for editing the file, just open the file using php file functions (fopen, fread, fwrite, fclose, etc), instead of loading a database field into your textarea. It's just the same really.

Wordpress does it ;)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.