Page 1 of 12 12311 ... LastLast
Results 1 to 10 of 114
  1. #1
    Join Date
    Feb 2005
    Posts
    246
    Plugin Contributions
    0

    Default PHP inside ezpages

    MODERATOR COMMENT: Adding eval() to arbitrarily execute random PHP or other code in the manner suggested here opens your site up to security risks.
    USE AT YOUR OWN RISK.


    Not a Question, but I didn't know where else to post this.

    I posted this in the infopages thread a while back. I have updated it to work with ezpages in 1.3.0

    To allow PHP code to run inside a "page".

    copy includes/templates/template_default/templates/tpl_page_default.php to
    includes/templates/*your template*/templates/

    Then edit the new copy as such
    find between "<div></div>"
    Code:
    echo $var_pageDetails->fields['pages_html_text'];
    and replace with:

    Code:
    $titlecheck=substr($var_pageDetails->fields[pages_title],0,9);
    if ($titlecheck=="allowcode"){
    eval(stripslashes($var_pageDetails->fields['pages_html_text']));}
    else{echo $var_pageDetails->fields['pages_html_text']; }
    Change "allocode" to whatever name you want your php code ezpages to have, or add more names or remove the if alltogether if you want. (dont forget to change ,0,9 to ,0,x where x is the length of your "allowcode" replacement string.

    I hope this is helpful. (I notice that someone else was looking to use include in infopages or ezpages, That's exactly what I am doing. Apparently That person didn't dig deep enough in the other thread, it was 30+ pages long.)

  2. #2
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: PHP inside ezpages

    Thanks for this Techbrat. It looks interesting and potentially relevant to something I am about to do.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  3. #3
    Join Date
    Oct 2005
    Location
    Qld Australia
    Posts
    156
    Plugin Contributions
    1

    Default Re: PHP inside ezpages

    And to think that I was about to tackle that little nightmare and along comes the solution

    One question
    dont forget to change ,0,9 to ,0,x where x is the length of your "allowcode" replacement string
    Can this point be clarified since I am only new to the whole php experience.

    Thx
    Gerard

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: PHP inside ezpages

    There is something down the pike for this that we have been fooling with for EZ-Pages to allow for an includes/require ...

    Ideas of how you forsee using this are helpful to hear ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Feb 2005
    Posts
    246
    Plugin Contributions
    0

    Default Re: PHP inside ezpages

    Quote Originally Posted by Gerard
    And to think that I was about to tackle that little nightmare and along comes the solution

    One question
    "dont forget to change ,0,9 to ,0,x where x is the length of your 'allowcode' replacement string "
    Can this point be clarified since I am only new to the whole php experience.

    Thx
    Gerard
    I made it so that only certain page names will trigger this change. In case of the example it is allowcode. "allowcode" is 9 characters long. If I change that to "Form" then every form I create I could name Form1 or Form-1 or Form-Contact etc, then the forms will work. But you will need to change
    Code:
    $titlecheck=substr($var_pageDetails->fields[pages_title],0,9);
    if ($titlecheck=="allowcode"){
    to
    Code:
    $titlecheck=substr($var_pageDetails->fields[pages_title],0,4);
    if ($titlecheck=="Form"){
    Remember that "==" is a case sensitive evaluation.

    I have used this to include dynamic content in an infopage (now ezpage), and to create a custom contact form with handler.

  6. #6
    Join Date
    Feb 2005
    Posts
    246
    Plugin Contributions
    0

    Default Re: PHP inside ezpages

    I think I forgot to mention,
    With this setting, The ezpage with a title that begins with "allowcode", or "Form" in the second examle, will assume "<?" or one might say that PHP is already "on". If you want some HTML before your PHP code, start with "?>" Like

    Code:
     
    ?>
    <a href="http://www/zen-cart.com">Get Zenned</a>
    <?
    include ("some_great_file.php");
    ?>
    otherwise, like this
    Code:
    include ("some_great_file.php");
    ?>
    <a href="http://www/zen-cart.com">Get Zenned</a>

  7. #7
    Join Date
    Apr 2006
    Posts
    265
    Plugin Contributions
    0

    Default Re: PHP inside ezpages

    MODERATOR COMMENT: Adding eval() to arbitrarily execute random PHP or other code in the manner suggested here opens your site up to security risks.
    USE AT YOUR OWN RISK.


    I definately needed this feature. Here's an even simpler version.

    Replace this:
    Code:
    <div><?php echo $var_pageDetails->fields['pages_html_text']; ?></div>
    with this:

    Code:
    <div><?php eval(stripslashes('?>' . $var_pageDetails->fields['pages_html_text'])); ?></div>
    This way you don't have worry about php being 'on' in the ezpage - you can make the code of the page html with php inside it (a lot easier).

    Tim

  8. #8
    Join Date
    Feb 2005
    Posts
    246
    Plugin Contributions
    0

    Default Re: PHP inside ezpages

    Quote Originally Posted by brandtim View Post
    I definately needed this feature. Here's an even simpler version.
    ...
    Tim
    Code:
    <div><?php eval(stripslashes('?>'.$var_pageDetails->fields['pages_html_text'])); ?></div>
    Verified this works in 1.3.5

    Thanks for the simplification Tim.
    I am starting to really appreciate the concatenation operator!

  9. #9
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: PHP inside ezpages

    Be sure to thoroughly understand the security risks associated with using the eval() function.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #10
    Join Date
    Jul 2006
    Posts
    32
    Plugin Contributions
    0

    Default Re: PHP inside ezpages

    I notice I can't input php with the default wysiwyg editor. It erases it and replaces it with a line break.

    I'm wanting to replace ezpages with my own uploaded php pages to be wrapped by the site. Is there an easier way to do this than to have an include in the ezpage?

 

 
Page 1 of 12 12311 ... LastLast

Similar Threads

  1. PHP inside EZ-Pages
    By digiprint in forum General Questions
    Replies: 0
    Last Post: 17 Jun 2013, 09:10 AM
  2. PHP code inside of an EZ page
    By tcarden in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 18 Dec 2012, 05:19 PM
  3. PHP inside EZpages
    By hookah in forum General Questions
    Replies: 3
    Last Post: 15 Nov 2008, 08:40 AM
  4. search inside php files
    By papadopoulos in forum General Questions
    Replies: 2
    Last Post: 20 Jun 2006, 02:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR