Re: Re: MySQL for storing PHP code
| From: | Tom Rogers | Date: | Tue, 11 Feb 2003 04:41:25 +0000 |
| Subject: | Re: Re: MySQL for storing PHP code | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-135155@lists.php.net to get a copy of this message | ||
Hi,
Tuesday, February 11, 2003, 7:39:16 AM, you wrote:
DP> Thanks for the comments everyone! eval() has just made my day :)
DP> Cheers,
DP> Daniel
DP> "Daniel Page" <dlp@dlpage.com> a écrit dans le message de news:
DP> 20030210212012.70844.qmail@pb1.pair.com...
>> Hi,
>>
>> Would it be possible to store PHP code in a MySQL table, then via a web
>> page, connect to the DB, recover the code that corresponds to a certain id
>> number, then include that code for execution?
>>
>> For example (quick, dirty, and untested!):
>>
>> $sql = "SELECT phpcode FROM phpstorage WHERE codeid = 1";
>> $result = mysql_query($sql);
>> $_php_code = mysql_result($result, 0,"phpcode");
>> echo $_php_code;
>>
>> Will the echo (or print() ) just output code that can be read by the
DP> reader
>> of the page, or will it generate output that will be executed?
>>
>> If the echo/print does not work, is there another way to do this?
>>
>> Cheers,
>> Daniel
>>
>>
Be aware that it could also ruin your life :)
It would be a good idea to store an encrypted checksum of the code to ensure it
has not been tampered with as eval will do exactly what it is told to do.
--
regards,
Tom