Forums / General Questions / PHP inside ezpages

PHP inside ezpages

Views: 54,189

Results 41 to 60 of 114
24 Sep 2009, 12:51 AM
#41
lndlyb4 avatar

lndlyb4

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

PHP inside ezpages

Hello All,

I have been trying very hard to get this to work and could use some help. I have created a price list that draws from the database and want to make it so that users have to log in to see it. I have taken the steps below to make this work. I have described the results at the end. Any help would be appreciated.

  1. I copied includes/templates/template_default/templates/tpl_page_default.php to includes/templates/my template/templates/

  2. I modified the code in tpl_page_default.php to the following:

<div><?php echo $titlecheck=substr($var_pageDetails->fields[pages_title],0,5); if ($titlecheck=="Print"){ eval(stripslashes('?>' . $var_pageDetails->fields['pages_html_text'])); } else{echo $var_pageDetails->fields['pages_html_text']; }?></div>
  1. I created a new Ez page called “Print” and a new page called “priceList_ezInclude.php”.

  2. I inserted the following code into the Print ez page via the html box.

<php?

include (" http://www.blackoliveeastnursery.net/zenCart_boe/priceManager/priceList_ezInclude.php");

?>
<a href="http://www/zen-cart.com">Get Zenned</a>

  1. I actived the “Page is SSL” button in the Admin > Tools > ez pages page for the Print ez page.

RESULT:

When I click on the “Print” link in the sidebox, I am sent to the Login page. After I log in, I am taken to the Print page, but the included page does not appear. All that is there is the include code below:

Print
<php?
include
(" http://www.blackoliveeastnursery.net/zenCart_boe/priceManager/priceList_ezInclude.php"); ?>
<a href="http://www/zen-cart.com">Get Zenned</a>

I have verified that the link to the included file is working, so that is not the problem. Any help would be appreciated.

24 Sep 2009, 12:57 AM
#42
lndlyb4 avatar

lndlyb4

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: PHP inside ezpages

I have also made the changed to the FCKeditor as suggested.

Same results.

thanks

24 Sep 2009, 2:10 AM
#43
jason_whitener avatar

jason_whitener

New Zenner

Join Date:
Sep 2009
Posts:
1
Plugin Contributions:
0

Re: PHP inside ezpages

My blog post wasn't about zen cart, the site I was working on was one that I created, so I may not be understanding how zen cart code operates.

"All that is there is the include code below"

To see that include code did you view the source code of the page, or are you saying that the page itself was displaying code instead of the code's output?

If the later, then I think you need to modify the regex governing protected source code to include more tags.

FCKConfig.ProtectedSource.Add( /<?[\s\S]*??>/g ) ; // PHP style server side code

jasonwhitener.com/2009/03/02/fckeditor-php-html-header-is-gone

24 Sep 2009, 5:10 AM
#44
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: PHP inside ezpages

lndlyb4:

I have also made the changed to the FCKeditor as suggested.

Same results.

thanks
PHP included into EZ Pages requires additional code alteration..see thread/post at
http://www.zen-cart.com/forum/showpost.php?p=219348&postcount=7

Dezina ZenCart Templates
Please do not PM for support queries..Post in forums..help others

24 Sep 2009, 8:46 AM
#45
bonnit avatar

bonnit

Zen Follower

Join Date:
Jun 2009
Location:
Kent, UK
Posts:
350
Plugin Contributions:
0

Re: PHP inside ezpages

and have you made the changes themselves within fckconfig.js in fckeditor as per my post on the previous page of this thread, that must be enabled to have it recognise php and view the page head info etc within source code. once its done you should on any new blank page click on source and already be able to see the following:

<html dir="ltr">
    <head>
        <title></title>
    </head>
    <body>
        <p> </p>
    </body>
</html>

if you cant then those changes have not been made properly.

http://www.mods.livvylougifts.co.uk Zen Cart Mod Site
http://www.livvylougifts.co.uk Personalised gifts for every occasion

24 Sep 2009, 6:28 PM
#46
lndlyb4 avatar

lndlyb4

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: PHP inside ezpages

I made all the changes suggested above. I think I have a problem with my install of fckeditor. My php code keeps getting wiped out even if I work in source code. I went to Admin > My Store > html editor to make sure fckeditor was selected and it wasn't even available on the list. I think I was still working in the regular html editor which is why the code was getting wiped out even though I had installed fckeditor.

I re-uploaded the fckeditor files, but it is still not availible in the html editor list.

My next strategy is to remove all of the fckeditor files from the server and re-install unless someone else has a better idea.

Any guidance would be appreciated as this is a bit discouraging.

24 Sep 2009, 7:49 PM
#47
bonnit avatar

bonnit

Zen Follower

Join Date:
Jun 2009
Location:
Kent, UK
Posts:
350
Plugin Contributions:
0

Re: PHP inside ezpages

first of all try logging out and clearing your browser cache, if no change or still doesnt appear then remove all fckeditor files and then reinstall making sure you use the latest version from the fckeditor site instead.

it still sounds like you are missing changes to your fckconfig.js, ive uploaded mine, compare changes and see if that helps?

http://www.mods.livvylougifts.co.uk Zen Cart Mod Site
http://www.livvylougifts.co.uk Personalised gifts for every occasion

24 Sep 2009, 7:55 PM
#48
lndlyb4 avatar

lndlyb4

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: PHP inside ezpages

bonnit, misty, jason, Thanks for hanging with me on this.

  1. I re-installed fckeditor and the situation has improved somewhat. The editor inside the ez page is no longer wiping out my code. I can see the html code that bonnit referred to.

  2. To test it out, I inserted some php into the ez page editor as presented below:

<html dir="ltr"> <head> <title></title> </head> <body> <div id="test_php"><?php print("this");?></div> </body> </html>
  1. Neither the html, the php code or the php output appeared in the ez page when I accessed it. However, I could see the php code in the source code of the ez page. The login feature seems to be working fine as it does send me to the login page first.

  2. I replaced this code in tpl_page_default.php:

<div><?php echo $var_pageDetails->fields['pages_html_text']; ?></div>

with this:

<div><?php eval(stripslashes('?>' . $var_pageDetails->fields['pages_html_text'])); ?></div>
  1. I change "false" to "true" in fckconfig.js.

FCKConfig.FullPage = true ;

  1. I removed the // from

FCKConfig.ProtectedSource.Add( /<?[\s\S]*??>/g ) ;

I'm not sure what I am overlooking.

24 Sep 2009, 8:13 PM
#49
lndlyb4 avatar

lndlyb4

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: PHP inside ezpages

bonnit,

The version of fckeditor I installed is 2.6.4.1.

I did a comparison. The fullpage script and the protect script are identical in our fckconfig files. There some other differences in regard to email and such, does that matter?

Bill

24 Sep 2009, 8:20 PM
#50
lndlyb4 avatar

lndlyb4

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: PHP inside ezpages

Is this the only code that is changed in tpl_page_default.php?

<div><?php echo $var_pageDetails->fields['pages_html_text']; ?></div>

Is there something else in this file I should be changing? I got a little confused because of the shift in techniques mid stream on the thread. By the way, thank you TecBrat for the initial solution.

Is there part of TechBrat's solution I should be incorporating?

thanks

25 Sep 2009, 7:26 AM
#51
bonnit avatar

bonnit

Zen Follower

Join Date:
Jun 2009
Location:
Kent, UK
Posts:
350
Plugin Contributions:
0

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.

both techbrats and brandtims solution should work, although brandtims solution seems to give more flexibility without having to "turn php on" within pages via page name.

my addition to this thread was only a follow on for those who are still having their code wiped due to the coding in the fckconfig.js, despite adding the line of code, all previous steps should still be followed.

so in short the full steps to allow php code are a follows:

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/

<div><?php echo $var_pageDetails->fields['pages_html_text']; ?></div>

change to

<div><?php eval(stripslashes('?>' . $var_pageDetails->fields['pages_html_text'])); ?></div>

ensure that a fresh version on fckeditor is installed on your site by downloading DIRECT from fckeditor site (
then in editors/fckeditor/fckconfig.js

find

FCKConfig.FullPage = false;

and change it to

FCKConfig.FullPage = true;

and then find

// FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ; // PHP style server side code

replace with

 FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ; // PHP style server side code

reupload to fckeditor directory. once its done you should on any new blank EZ page(from within admin) click on source and already be able to see the following in the edit area:

<html dir="ltr">
    <head>
        <title></title>
    </head>
    <body>
        <p> </p>
    </body>
</html>

test by using php code inside the body tags, such as

<?php echo "Hello World!"; ?>
``` save ez page and then view EZ page, you should see 

Hello World!


for comparison i have uploaded my working versions of each file, obviously, use them with caution i take no responsibility for their usage. (fckconfig.js is found in post #47)

i am using fckeditor v.2.6.5 and zen cart 1.3.8a

http://www.mods.livvylougifts.co.uk Zen Cart Mod Site
http://www.livvylougifts.co.uk Personalised gifts for every occasion

25 Sep 2009, 7:48 AM
#52
bonnit avatar

bonnit

Zen Follower

Join Date:
Jun 2009
Location:
Kent, UK
Posts:
350
Plugin Contributions:
0

Re: PHP inside ezpages

Jason Whitener:

My blog post wasn't about zen cart, the site I was working on was one that I created, so I may not be understanding how zen cart code operates.

"All that is there is the include code below"

To see that include code did you view the source code of the page, or are you saying that the page itself was displaying code instead of the code's output?

If the later, then I think you need to modify the regex governing protected source code to include more tags.

FCKConfig.ProtectedSource.Add( /<?[\s\S]*??>/g ) ; // PHP style server side code

jasonwhitener.com/2009/03/02/fckeditor-php-html-header-is-gone

i am using the advice from your site and can confirm that it is in fact working, so thankyou very much for your contribution :clap:

http://www.mods.livvylougifts.co.uk Zen Cart Mod Site
http://www.livvylougifts.co.uk Personalised gifts for every occasion

25 Sep 2009, 1:05 PM
#53
lndlyb4 avatar

lndlyb4

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: PHP inside ezpages

Wow! I've got it working!

The mistake I was making was this. I was putting the tpl_page_default in the wrong folder.

The instructions are this:
"copy includes/templates/template_default/templates/tpl_page_default.php
to
includes/templates/YOUR TEMPLATE/templates/"

I was putting it in the folder below thinking I only had to move it up one level into a custom template folder.

includes/templates/template_default/templates/mytemplate/

bonnit,

Thank you for laying out the steps in order like that. As you can imagine, it can be a bit difficult following instructions in a post sometimes because solutions evolve as they go.

Much appreciation to Misti and Jason as well.

Now, the next step is to see if I can get my php code to work inside the EZ page.

Have a great day.

25 Sep 2009, 7:46 PM
#54
lndlyb4 avatar

lndlyb4

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: PHP inside ezpages

Good news! I was able to get the php code in my page to work in the EZ page.

This is the location of the page: http://blackoliveeastnursery.net/zenCart_boe/index.php?main_page=page&id=7.

email: test1 at aol . com
password: test1

However, I do have one more problem to solve before it works completely.

I have a drop down box search filter that was working fine before I moved the code to the EZ page.

I have been trying to change the action link in the form so that it points to the new page.This is what I set the action field to:

<form id="searchForm"action="http://www.blackoliveeastnursery.net/zenCart_boe/index.php?main_page=page&id=7" method="GET">

When I make a selection from the drop down box and press the Submit button, I am sent to the home page for the catalogue instead of staying on the same page.

It sends me here: "http://www.blackoliveeastnursery.net/zenCart_boe/index.php?categoryChoice=22"

It needs to go to this page (and pass the category variable like below):

"http://www.blackoliveeastnursery.net/zenCart_boe/index.php?main_page=page&id=7&categoryChoice=2"

It seems that, for some reason, the page name and page Id are not being sent so I'm just being sent back to the index.

I'm kind of new with php, so I would appreciate any input.

If you have a minute to help me out, you can access the page with the following email and password.

test1 at aol. com
test1

25 Sep 2009, 8:01 PM
#55
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: PHP inside ezpages

Basic HTML rules say that if you're going to open a tag such as <select>, you should also close it at some point ... ie: </select>
You haven't closed it in your list of pulldown menu options.

.
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.

26 Sep 2009, 1:06 AM
#56
lndlyb4 avatar

lndlyb4

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: PHP inside ezpages

Thanks DrByte,

I put the closing select back in. (I wiped it out while cleaning up some unnecessary code.)

I am, unfortunately, still have the same problem as described above.

If you have any suggestions, I would really appreciate it.

Bill

26 Sep 2009, 1:11 AM
#57
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: PHP inside ezpages

Sounds like you've got bugs in the PHP code you're using to process the form data, or your form isn't sending its selections properly.
You really are in uncharted territory, since ezPages was never designed to handle embedded forms and embedded PHP code.

.
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.

26 Sep 2009, 9:40 AM
#58
bonnit avatar

bonnit

Zen Follower

Join Date:
Jun 2009
Location:
Kent, UK
Posts:
350
Plugin Contributions:
0

Re: PHP inside ezpages

is it possible to remove the php code from your ezpage and instead insert it into a new php page uploaded on to your server? so instead of having the php code on your page just have an include of

<?php include("yourpage.php"); ?> which holds the php script?

http://www.mods.livvylougifts.co.uk Zen Cart Mod Site
http://www.livvylougifts.co.uk Personalised gifts for every occasion

26 Sep 2009, 2:29 PM
#59
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: PHP inside ezpages

Another way to have custom forms is to put up a page dedicated to that purpose. Here's a link to one that collects several fields of information and emails it to the storeowner: http://www.zen-cart.com/forum/showthread.php?p=386482#post386482

.
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.

26 Sep 2009, 5:29 PM
#60
lndlyb4 avatar

lndlyb4

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: PHP inside ezpages

bonnit, Dr. Byte,

Thank you so much for your continued feedback on this.

bonnit,

The ez page is already set up as an include (In fact, I tried just pasting it in, and I couldn't get it to work at all.):

<html dir="ltr"> <head> <title></title> </head> <body> <?php include ("http://www.blackoliveeastnursery.net/zenCart_boe/priceManager/priceList_ezInclude.php");?> </body> </html>

Dr. byte,

The form worked well as a stand-alone page. So I'm hoping it will work inside the ezpage. Everything works except the drop down box.

I am leaning toward your second thought as the culprit "your form isn't sending its selections properly"

As I mentioned in my post, if I can just get the Action part of the form to send the page and id, I bet it would work.

<form id="searchForm"action="http://www.blackoliveeastnursery.net/zenCart_boe/index.php?main_page=page&id=7" method="GET">

This is how I described the problem earlier (for folks following along at home).

When I make a selection from the drop down box and press the Submit button, I am sent to the home page for the catalogue instead of staying on the same page.

It sends me here: "http://www.blackoliveeastnursery.net/zenCart_boe/index.php?categoryChoice=22"

It needs to go to this page (and pass the category variable like below):

"http://www.blackoliveeastnursery.net...tegoryChoice=2"

It seems that, for some reason, the page name and page Id are not being sent so I'm just being sent back to the index.